@nectary/components 0.39.0 → 0.40.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 (115) hide show
  1. package/accordion/index.js +47 -84
  2. package/accordion-item/index.js +26 -53
  3. package/action-menu/index.d.ts +0 -1
  4. package/action-menu/index.js +179 -223
  5. package/action-menu/types.d.ts +8 -18
  6. package/action-menu-option/index.d.ts +1 -0
  7. package/action-menu-option/index.js +51 -62
  8. package/action-menu-option/types.d.ts +9 -0
  9. package/action-menu-option/utils.d.ts +2 -0
  10. package/action-menu-option/utils.js +3 -0
  11. package/alert/index.js +6 -20
  12. package/avatar/index.js +12 -31
  13. package/avatar-badge/index.js +8 -22
  14. package/avatar-status/index.js +1 -1
  15. package/button/index.js +42 -92
  16. package/card/index.js +21 -59
  17. package/chat-avatar/index.js +8 -22
  18. package/chat-block/index.js +29 -69
  19. package/chat-bubble/index.js +6 -20
  20. package/checkbox/index.js +55 -107
  21. package/chip/index.d.ts +13 -0
  22. package/chip/index.js +137 -0
  23. package/chip/types.d.ts +38 -0
  24. package/color-menu/index.d.ts +13 -0
  25. package/color-menu/index.js +464 -0
  26. package/color-menu/types.d.ts +37 -0
  27. package/color-swatch/index.d.ts +13 -0
  28. package/color-swatch/index.js +59 -0
  29. package/color-swatch/types.d.ts +12 -0
  30. package/colors.json +57 -49
  31. package/date-picker/index.js +161 -292
  32. package/dialog/index.js +70 -142
  33. package/dropdown-checkbox-option/index.js +6 -20
  34. package/dropdown-radio-option/index.js +6 -20
  35. package/field/index.js +25 -63
  36. package/file-drop/index.js +123 -200
  37. package/file-picker/index.d.ts +0 -1
  38. package/file-picker/index.js +55 -108
  39. package/file-status/index.js +15 -39
  40. package/help-tooltip/index.js +1 -1
  41. package/horizontal-stepper/index.js +33 -59
  42. package/horizontal-stepper-item/index.js +13 -37
  43. package/icon-button/index.js +39 -84
  44. package/icons-channel/notify/index.d.ts +11 -0
  45. package/icons-channel/notify/index.js +4 -0
  46. package/illustrations/create-illustration-class.js +1 -1
  47. package/inline-alert/index.js +29 -81
  48. package/input/index.js +113 -222
  49. package/link/index.js +46 -96
  50. package/list-item/index.js +1 -1
  51. package/package.json +12 -14
  52. package/pagination/index.js +109 -163
  53. package/popover/index.js +224 -294
  54. package/progress/index.js +9 -28
  55. package/radio/index.js +103 -169
  56. package/radio-option/index.js +24 -48
  57. package/segment/index.js +49 -130
  58. package/segment-collapse/index.js +24 -49
  59. package/segmented-control/index.js +36 -73
  60. package/segmented-control-option/index.js +41 -87
  61. package/segmented-icon-control/index.js +47 -84
  62. package/segmented-icon-control-option/index.js +38 -79
  63. package/select-button/index.d.ts +13 -0
  64. package/select-button/index.js +153 -0
  65. package/select-button/types.d.ts +43 -0
  66. package/select-menu/index.d.ts +11 -0
  67. package/select-menu/index.js +346 -0
  68. package/select-menu/types.d.ts +29 -0
  69. package/select-menu/types.js +1 -0
  70. package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
  71. package/select-menu-option/index.js +76 -0
  72. package/{select-option → select-menu-option}/types.d.ts +8 -9
  73. package/stop-events/index.js +7 -20
  74. package/table-head-cell/index.js +7 -21
  75. package/tabs/index.js +103 -165
  76. package/tabs-option/index.js +20 -44
  77. package/tag/index.d.ts +0 -1
  78. package/tag/index.js +37 -38
  79. package/tag/types.d.ts +13 -7
  80. package/textarea/index.js +92 -167
  81. package/theme.css +80 -49
  82. package/tile-control/index.js +55 -96
  83. package/tile-control-option/index.js +40 -86
  84. package/time-picker/index.js +216 -368
  85. package/title/index.js +6 -20
  86. package/toast/index.js +32 -70
  87. package/toast-manager/index.js +141 -217
  88. package/toggle/index.js +54 -106
  89. package/types.d.ts +7 -0
  90. package/utils/colors.d.ts +10 -0
  91. package/utils/colors.js +121 -0
  92. package/{utils.d.ts → utils/index.d.ts} +17 -9
  93. package/{utils.js → utils/index.js} +96 -39
  94. package/vertical-stepper/index.js +29 -50
  95. package/vertical-stepper-item/index.js +13 -37
  96. package/dropdown/index.d.ts +0 -12
  97. package/dropdown/index.js +0 -415
  98. package/dropdown/types.d.ts +0 -32
  99. package/dropdown-text-option/index.js +0 -104
  100. package/dropdown-text-option/types.d.ts +0 -16
  101. package/select/index.d.ts +0 -13
  102. package/select/index.js +0 -316
  103. package/select/types.d.ts +0 -53
  104. package/select-option/index.d.ts +0 -11
  105. package/select-option/index.js +0 -8
  106. package/tag/utils.d.ts +0 -5
  107. package/tag/utils.js +0 -6
  108. package/tag-close/index.d.ts +0 -12
  109. package/tag-close/index.js +0 -42
  110. package/tag-close/types.d.ts +0 -5
  111. /package/{dropdown-text-option → chip}/types.js +0 -0
  112. /package/{dropdown → color-menu}/types.js +0 -0
  113. /package/{select-option → color-swatch}/types.js +0 -0
  114. /package/{select → select-button}/types.js +0 -0
  115. /package/{tag-close → select-menu-option}/types.js +0 -0
@@ -1,72 +1,30 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$firstName, _$lastName, _$timeStamp, _$bubbleSlot, _onBubbleSlotChange, _updateBubbleTypes;
5
-
6
- function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
-
8
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
9
-
10
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
11
-
12
- function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
13
-
14
1
  import { typeValues } from '../chat-bubble/utils';
15
2
  import { defineCustomElement, getAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
16
3
  const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;display:flex;flex-direction:column;gap:4px;align-items:flex-end;padding-left:72px}#stamp{display:flex;gap:4px;margin:0;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-stormy-400)}#avatar{display:none;position:absolute;left:0;top:24px}:host([type=customer])>#wrapper{align-items:flex-start}:host([type=customer]) #avatar{display:block}</style><div id="wrapper"><div id="avatar"><slot name="avatar"></slot></div><p id="stamp"><span id="firstname"></span><span id="lastname"></span>&bull;<span id="time"></span></p><slot name="bubble"></slot></div>';
17
4
  const template = document.createElement('template');
18
5
  template.innerHTML = templateHTML;
19
- defineCustomElement('sinch-chat-block', (_$firstName = new WeakMap(), _$lastName = new WeakMap(), _$timeStamp = new WeakMap(), _$bubbleSlot = new WeakMap(), _onBubbleSlotChange = new WeakMap(), _updateBubbleTypes = new WeakSet(), class extends NectaryElement {
6
+ defineCustomElement('sinch-chat-block', class extends NectaryElement {
7
+ #$firstName;
8
+ #$lastName;
9
+ #$timeStamp;
10
+ #$bubbleSlot;
11
+
20
12
  constructor() {
21
13
  super();
22
-
23
- _classPrivateMethodInitSpec(this, _updateBubbleTypes);
24
-
25
- _classPrivateFieldInitSpec(this, _$firstName, {
26
- writable: true,
27
- value: void 0
28
- });
29
-
30
- _classPrivateFieldInitSpec(this, _$lastName, {
31
- writable: true,
32
- value: void 0
33
- });
34
-
35
- _classPrivateFieldInitSpec(this, _$timeStamp, {
36
- writable: true,
37
- value: void 0
38
- });
39
-
40
- _classPrivateFieldInitSpec(this, _$bubbleSlot, {
41
- writable: true,
42
- value: void 0
43
- });
44
-
45
- _classPrivateFieldInitSpec(this, _onBubbleSlotChange, {
46
- writable: true,
47
- value: () => {
48
- _classPrivateMethodGet(this, _updateBubbleTypes, _updateBubbleTypes2).call(this);
49
- }
50
- });
51
-
52
14
  const shadowRoot = this.attachShadow();
53
15
  shadowRoot.appendChild(template.content.cloneNode(true));
54
-
55
- _classPrivateFieldSet(this, _$firstName, shadowRoot.querySelector('#firstname'));
56
-
57
- _classPrivateFieldSet(this, _$lastName, shadowRoot.querySelector('#lastname'));
58
-
59
- _classPrivateFieldSet(this, _$timeStamp, shadowRoot.querySelector('#time'));
60
-
61
- _classPrivateFieldSet(this, _$bubbleSlot, shadowRoot.querySelector('slot[name="bubble"]'));
16
+ this.#$firstName = shadowRoot.querySelector('#firstname');
17
+ this.#$lastName = shadowRoot.querySelector('#lastname');
18
+ this.#$timeStamp = shadowRoot.querySelector('#time');
19
+ this.#$bubbleSlot = shadowRoot.querySelector('slot[name="bubble"]');
62
20
  }
63
21
 
64
22
  connectedCallback() {
65
- _classPrivateFieldGet(this, _$bubbleSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onBubbleSlotChange));
23
+ this.#$bubbleSlot.addEventListener('slotchange', this.#onBubbleSlotChange);
66
24
  }
67
25
 
68
26
  disconnectedCallback() {
69
- _classPrivateFieldGet(this, _$bubbleSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onBubbleSlotChange));
27
+ this.#$bubbleSlot.removeEventListener('slotchange', this.#onBubbleSlotChange);
70
28
  }
71
29
 
72
30
  static get observedAttributes() {
@@ -77,26 +35,25 @@ defineCustomElement('sinch-chat-block', (_$firstName = new WeakMap(), _$lastName
77
35
  switch (name) {
78
36
  case 'firstname':
79
37
  {
80
- _classPrivateFieldGet(this, _$firstName).textContent = newVal;
38
+ this.#$firstName.textContent = newVal;
81
39
  break;
82
40
  }
83
41
 
84
42
  case 'lastname':
85
43
  {
86
- _classPrivateFieldGet(this, _$lastName).textContent = newVal;
44
+ this.#$lastName.textContent = newVal;
87
45
  break;
88
46
  }
89
47
 
90
48
  case 'timestamp':
91
49
  {
92
- _classPrivateFieldGet(this, _$timeStamp).textContent = newVal;
50
+ this.#$timeStamp.textContent = newVal;
93
51
  break;
94
52
  }
95
53
 
96
54
  case 'type':
97
55
  {
98
- _classPrivateMethodGet(this, _updateBubbleTypes, _updateBubbleTypes2).call(this);
99
-
56
+ this.#updateBubbleTypes();
100
57
  break;
101
58
  }
102
59
  }
@@ -115,7 +72,7 @@ defineCustomElement('sinch-chat-block', (_$firstName = new WeakMap(), _$lastName
115
72
  }
116
73
 
117
74
  get firstName() {
118
- return getAttribute(this, 'firstname', null);
75
+ return getAttribute(this, 'firstname');
119
76
  }
120
77
 
121
78
  set lastName(value) {
@@ -123,7 +80,7 @@ defineCustomElement('sinch-chat-block', (_$firstName = new WeakMap(), _$lastName
123
80
  }
124
81
 
125
82
  get lastName() {
126
- return getAttribute(this, 'lastname', null);
83
+ return getAttribute(this, 'lastname');
127
84
  }
128
85
 
129
86
  set timestamp(value) {
@@ -131,15 +88,18 @@ defineCustomElement('sinch-chat-block', (_$firstName = new WeakMap(), _$lastName
131
88
  }
132
89
 
133
90
  get timestamp() {
134
- return getAttribute(this, 'timestamp', null);
91
+ return getAttribute(this, 'timestamp');
135
92
  }
136
93
 
137
- }));
94
+ #onBubbleSlotChange = () => {
95
+ this.#updateBubbleTypes();
96
+ };
138
97
 
139
- function _updateBubbleTypes2() {
140
- const typeValue = getAttribute(this, 'type');
98
+ #updateBubbleTypes() {
99
+ const typeValue = getAttribute(this, 'type');
100
+ this.#$bubbleSlot.assignedElements().forEach(el => {
101
+ updateAttribute(el, 'data-type', typeValue);
102
+ });
103
+ }
141
104
 
142
- _classPrivateFieldGet(this, _$bubbleSlot).assignedElements().forEach(el => {
143
- updateAttribute(el, 'data-type', typeValue);
144
- });
145
- }
105
+ });
@@ -1,12 +1,3 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$text;
5
-
6
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
-
8
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
-
10
1
  import '../icons/query-builder';
11
2
  import '../icons/check';
12
3
  import '../icons/done-all';
@@ -16,19 +7,14 @@ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:rel
16
7
  import { statusValues, typeValues } from './utils';
17
8
  const template = document.createElement('template');
18
9
  template.innerHTML = templateHTML;
19
- defineCustomElement('sinch-chat-bubble', (_$text = new WeakMap(), class extends NectaryElement {
10
+ defineCustomElement('sinch-chat-bubble', class extends NectaryElement {
11
+ #$text;
12
+
20
13
  constructor() {
21
14
  super();
22
-
23
- _classPrivateFieldInitSpec(this, _$text, {
24
- writable: true,
25
- value: void 0
26
- });
27
-
28
15
  const shadowRoot = this.attachShadow();
29
16
  shadowRoot.appendChild(template.content.cloneNode(true));
30
-
31
- _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
17
+ this.#$text = shadowRoot.querySelector('#text');
32
18
  }
33
19
 
34
20
  static get observedAttributes() {
@@ -39,7 +25,7 @@ defineCustomElement('sinch-chat-bubble', (_$text = new WeakMap(), class extends
39
25
  switch (name) {
40
26
  case 'text':
41
27
  {
42
- _classPrivateFieldGet(this, _$text).textContent = newVal;
28
+ this.#$text.textContent = newVal;
43
29
  break;
44
30
  }
45
31
  }
@@ -65,4 +51,4 @@ defineCustomElement('sinch-chat-bubble', (_$text = new WeakMap(), class extends
65
51
  return getLiteralAttribute(this, statusValues, 'status', null);
66
52
  }
67
53
 
68
- }));
54
+ });
package/checkbox/index.js CHANGED
@@ -1,115 +1,36 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$input, _$label, _onCheckboxInput, _onCheckboxFocus, _onCheckboxBlur, _onChangeReactHandler, _onFocusReactHandler, _onBlurReactHandler;
5
-
6
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
-
8
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
-
10
1
  import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
11
- 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-800);--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-stormy-200);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-body);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::before{background-color:var(--sinch-color-checkbox-circle-focus)}#checkbox:focus::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:checked::before{background-color:var(--sinch-color-checkbox-circle-focus-checked)}#checkbox:focus: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{--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-body);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::before{background-color:var(--sinch-color-checkbox-circle-focus)}#checkbox:focus::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:checked::before{background-color:var(--sinch-color-checkbox-circle-focus-checked)}#checkbox:focus: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>';
12
3
  const template = document.createElement('template');
13
4
  template.innerHTML = templateHTML;
14
- defineCustomElement('sinch-checkbox', (_$input = new WeakMap(), _$label = new WeakMap(), _onCheckboxInput = new WeakMap(), _onCheckboxFocus = new WeakMap(), _onCheckboxBlur = new WeakMap(), _onChangeReactHandler = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
5
+ defineCustomElement('sinch-checkbox', class extends NectaryElement {
6
+ #$input;
7
+ #$label;
8
+
15
9
  constructor() {
16
10
  super();
17
-
18
- _classPrivateFieldInitSpec(this, _$input, {
19
- writable: true,
20
- value: void 0
21
- });
22
-
23
- _classPrivateFieldInitSpec(this, _$label, {
24
- writable: true,
25
- value: void 0
26
- });
27
-
28
- _classPrivateFieldInitSpec(this, _onCheckboxInput, {
29
- writable: true,
30
- value: e => {
31
- e.stopPropagation();
32
-
33
- const isChecked = _classPrivateFieldGet(this, _$input).checked;
34
-
35
- _classPrivateFieldGet(this, _$input).checked = this.checked;
36
- this.dispatchEvent(new CustomEvent('change', {
37
- detail: isChecked,
38
- bubbles: true
39
- }));
40
- this.dispatchEvent(new CustomEvent('-change', {
41
- detail: isChecked
42
- }));
43
- }
44
- });
45
-
46
- _classPrivateFieldInitSpec(this, _onCheckboxFocus, {
47
- writable: true,
48
- value: () => {
49
- this.dispatchEvent(new CustomEvent('-focus'));
50
- }
51
- });
52
-
53
- _classPrivateFieldInitSpec(this, _onCheckboxBlur, {
54
- writable: true,
55
- value: () => {
56
- this.dispatchEvent(new CustomEvent('-blur'));
57
- }
58
- });
59
-
60
- _classPrivateFieldInitSpec(this, _onChangeReactHandler, {
61
- writable: true,
62
- value: e => {
63
- getReactEventHandler(this, 'on-change')?.(e);
64
- }
65
- });
66
-
67
- _classPrivateFieldInitSpec(this, _onFocusReactHandler, {
68
- writable: true,
69
- value: e => {
70
- getReactEventHandler(this, 'on-focus')?.(e);
71
- }
72
- });
73
-
74
- _classPrivateFieldInitSpec(this, _onBlurReactHandler, {
75
- writable: true,
76
- value: e => {
77
- getReactEventHandler(this, 'on-blur')?.(e);
78
- }
79
- });
80
-
81
11
  const shadowRoot = this.attachShadow();
82
12
  shadowRoot.appendChild(template.content.cloneNode(true));
83
-
84
- _classPrivateFieldSet(this, _$input, shadowRoot.querySelector('input'));
85
-
86
- _classPrivateFieldSet(this, _$label, shadowRoot.querySelector('label'));
13
+ this.#$input = shadowRoot.querySelector('input');
14
+ this.#$label = shadowRoot.querySelector('label');
87
15
  }
88
16
 
89
17
  connectedCallback() {
90
18
  this.setAttribute('role', 'checkbox');
91
-
92
- _classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onCheckboxInput));
93
-
94
- _classPrivateFieldGet(this, _$input).addEventListener('focus', _classPrivateFieldGet(this, _onCheckboxFocus));
95
-
96
- _classPrivateFieldGet(this, _$input).addEventListener('blur', _classPrivateFieldGet(this, _onCheckboxBlur));
97
-
98
- this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
99
- this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
100
- this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
19
+ this.#$input.addEventListener('input', this.#onCheckboxInput);
20
+ this.#$input.addEventListener('focus', this.#onCheckboxFocus);
21
+ this.#$input.addEventListener('blur', this.#onCheckboxBlur);
22
+ this.addEventListener('-change', this.#onChangeReactHandler);
23
+ this.addEventListener('-focus', this.#onFocusReactHandler);
24
+ this.addEventListener('-blur', this.#onBlurReactHandler);
101
25
  }
102
26
 
103
27
  disconnectedCallback() {
104
- _classPrivateFieldGet(this, _$input).removeEventListener('input', _classPrivateFieldGet(this, _onCheckboxInput));
105
-
106
- _classPrivateFieldGet(this, _$input).removeEventListener('focus', _classPrivateFieldGet(this, _onCheckboxFocus));
107
-
108
- _classPrivateFieldGet(this, _$input).removeEventListener('blur', _classPrivateFieldGet(this, _onCheckboxBlur));
109
-
110
- this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
111
- this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
112
- this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
28
+ this.#$input.removeEventListener('input', this.#onCheckboxInput);
29
+ this.#$input.removeEventListener('focus', this.#onCheckboxFocus);
30
+ this.#$input.removeEventListener('blur', this.#onCheckboxBlur);
31
+ this.removeEventListener('-change', this.#onChangeReactHandler);
32
+ this.removeEventListener('-focus', this.#onFocusReactHandler);
33
+ this.removeEventListener('-blur', this.#onBlurReactHandler);
113
34
  }
114
35
 
115
36
  static get observedAttributes() {
@@ -161,21 +82,21 @@ defineCustomElement('sinch-checkbox', (_$input = new WeakMap(), _$label = new We
161
82
  }
162
83
 
163
84
  get text() {
164
- return getAttribute(this, 'text', null);
85
+ return getAttribute(this, 'text');
165
86
  }
166
87
 
167
88
  attributeChangedCallback(name, _, newVal) {
168
89
  switch (name) {
169
90
  case 'text':
170
91
  {
171
- _classPrivateFieldGet(this, _$label).textContent = newVal;
92
+ this.#$label.textContent = newVal;
172
93
  break;
173
94
  }
174
95
 
175
96
  case 'checked':
176
97
  {
177
98
  const isChecked = isAttrTrue(newVal);
178
- _classPrivateFieldGet(this, _$input).checked = isChecked;
99
+ this.#$input.checked = isChecked;
179
100
  updateExplicitBooleanAttribute(this, 'aria-checked', isChecked);
180
101
  break;
181
102
  }
@@ -183,7 +104,7 @@ defineCustomElement('sinch-checkbox', (_$input = new WeakMap(), _$label = new We
183
104
  case 'disabled':
184
105
  {
185
106
  const isDisabled = isAttrTrue(newVal);
186
- _classPrivateFieldGet(this, _$input).disabled = isDisabled;
107
+ this.#$input.disabled = isDisabled;
187
108
  updateBooleanAttribute(this, 'disabled', isDisabled);
188
109
  break;
189
110
  }
@@ -191,11 +112,38 @@ defineCustomElement('sinch-checkbox', (_$input = new WeakMap(), _$label = new We
191
112
  }
192
113
 
193
114
  focus() {
194
- _classPrivateFieldGet(this, _$input).focus();
115
+ this.#$input.focus();
195
116
  }
196
117
 
197
118
  blur() {
198
- _classPrivateFieldGet(this, _$input).blur();
199
- }
200
-
201
- }));
119
+ this.#$input.blur();
120
+ }
121
+
122
+ #onCheckboxInput = e => {
123
+ e.stopPropagation();
124
+ const isChecked = this.#$input.checked;
125
+ this.#$input.checked = this.checked;
126
+ this.dispatchEvent(new CustomEvent('change', {
127
+ detail: isChecked,
128
+ bubbles: true
129
+ }));
130
+ this.dispatchEvent(new CustomEvent('-change', {
131
+ detail: isChecked
132
+ }));
133
+ };
134
+ #onCheckboxFocus = () => {
135
+ this.dispatchEvent(new CustomEvent('-focus'));
136
+ };
137
+ #onCheckboxBlur = () => {
138
+ this.dispatchEvent(new CustomEvent('-blur'));
139
+ };
140
+ #onChangeReactHandler = e => {
141
+ getReactEventHandler(this, 'on-change')?.(e);
142
+ };
143
+ #onFocusReactHandler = e => {
144
+ getReactEventHandler(this, 'on-focus')?.(e);
145
+ };
146
+ #onBlurReactHandler = e => {
147
+ getReactEventHandler(this, 'on-blur')?.(e);
148
+ };
149
+ });
@@ -0,0 +1,13 @@
1
+ import '../text';
2
+ import '../icons/cancel';
3
+ import type { TSinchChipElement, TSinchChipReact } from './types';
4
+ declare global {
5
+ namespace JSX {
6
+ interface IntrinsicElements {
7
+ 'sinch-chip': TSinchChipReact;
8
+ }
9
+ }
10
+ interface HTMLElementTagNameMap {
11
+ 'sinch-chip': TSinchChipElement;
12
+ }
13
+ }
package/chip/index.js ADDED
@@ -0,0 +1,137 @@
1
+ import '../text';
2
+ import '../icons/cancel';
3
+ import { defineCustomElement, getBooleanAttribute, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, setClass, getReactEventHandler } from '../utils';
4
+ import { assertColorNameValue, colorMap, colorNameValues, NO_COLOR } from '../utils/colors';
5
+ 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 12px;border-radius:12px;color:var(--sinch-color-text-default);box-sizing:border-box;cursor:pointer;--sinch-color-icon:var(--sinch-color-stormy-500);--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}@supports not selector(:focus-visible){#button:focus::after{content:"";position:absolute;inset:-4px;border-radius:16px;border:2px solid var(--sinch-color-border-focus);pointer-events:none}:host([small]:not([small=false])) #button:focus::after{border-radius:14px}}#button.no-color{background-color:var(--sinch-color-snow-500)}#button.inverted{color:var(--sinch-color-text-inverted);--sinch-color-icon:var(--sinch-color-snow-100)}#text{flex:1}:host([small]:not([small=false])) #button{height:20px;border-radius:10px;padding:0 3px 0 8px}:host([small]:not([small=false])) #button:focus-visible::after{border-radius:14px}::slotted(*){margin-left:-4px}:host([small]:not([small=false])) ::slotted(*){margin-left:-2px}</style><button id="button"><slot name="icon"></slot><sinch-text id="text" type="xs" ellipsis></sinch-text><sinch-icon-cancel id="close"></sinch-icon-cancel></button>';
6
+ const template = document.createElement('template');
7
+ template.innerHTML = templateHTML;
8
+ defineCustomElement('sinch-chip', class extends NectaryElement {
9
+ #$text;
10
+ #$button;
11
+ #controller = new AbortController();
12
+
13
+ constructor() {
14
+ super();
15
+ const shadowRoot = this.attachShadow();
16
+ shadowRoot.appendChild(template.content.cloneNode(true));
17
+ this.#$button = shadowRoot.querySelector('#button');
18
+ this.#$text = shadowRoot.querySelector('#text');
19
+ }
20
+
21
+ connectedCallback() {
22
+ const {
23
+ signal
24
+ } = this.#controller;
25
+ this.setAttribute('role', 'button');
26
+ this.#$button.addEventListener('click', this.#onButtonClick, {
27
+ signal
28
+ });
29
+ this.#$button.addEventListener('focus', this.#onButtonFocus, {
30
+ signal
31
+ });
32
+ this.#$button.addEventListener('blur', this.#onButtonBlur, {
33
+ signal
34
+ });
35
+ this.addEventListener('-click', this.#onClickReactHandler, {
36
+ signal
37
+ });
38
+ this.addEventListener('-focus', this.#onFocusReactHandler, {
39
+ signal
40
+ });
41
+ this.addEventListener('-blur', this.#onBlurReactHandler, {
42
+ signal
43
+ });
44
+ this.#updateColor();
45
+ }
46
+
47
+ disconnectedCallback() {
48
+ this.#controller.abort();
49
+ }
50
+
51
+ get color() {
52
+ return getLiteralAttribute(this, colorNameValues, 'color', null);
53
+ }
54
+
55
+ set color(value) {
56
+ updateLiteralAttribute(this, colorNameValues, 'color', value);
57
+ }
58
+
59
+ get text() {
60
+ return getAttribute(this, 'text', '');
61
+ }
62
+
63
+ set text(value) {
64
+ updateAttribute(this, 'text', value);
65
+ }
66
+
67
+ get small() {
68
+ return getBooleanAttribute(this, 'small');
69
+ }
70
+
71
+ set small(isSmall) {
72
+ updateBooleanAttribute(this, 'small', isSmall);
73
+ }
74
+
75
+ static get observedAttributes() {
76
+ return ['text', 'color'];
77
+ }
78
+
79
+ attributeChangedCallback(name, _, newVal) {
80
+ switch (name) {
81
+ case 'color':
82
+ {
83
+ assertColorNameValue(newVal);
84
+ this.#updateColor();
85
+ break;
86
+ }
87
+
88
+ case 'text':
89
+ {
90
+ this.#$text.textContent = newVal;
91
+ break;
92
+ }
93
+ }
94
+ }
95
+
96
+ #updateColor() {
97
+ const colorName = this.color ?? NO_COLOR;
98
+ const {
99
+ value,
100
+ isInverted
101
+ } = colorMap[colorName];
102
+
103
+ if (value !== NO_COLOR) {
104
+ this.#$button.style.backgroundColor = `var(--sinch-color-${value})`;
105
+ }
106
+
107
+ setClass(this.#$button, 'no-color', value === NO_COLOR);
108
+ setClass(this.#$button, 'inverted', isInverted);
109
+ }
110
+
111
+ focus() {
112
+ this.#$button.focus();
113
+ }
114
+
115
+ blur() {
116
+ this.#$button.blur();
117
+ }
118
+
119
+ #onButtonClick = () => {
120
+ this.dispatchEvent(new CustomEvent('-click'));
121
+ };
122
+ #onButtonFocus = () => {
123
+ this.dispatchEvent(new CustomEvent('-focus'));
124
+ };
125
+ #onButtonBlur = () => {
126
+ this.dispatchEvent(new CustomEvent('-blur'));
127
+ };
128
+ #onFocusReactHandler = () => {
129
+ getReactEventHandler(this, 'on-focus')?.();
130
+ };
131
+ #onBlurReactHandler = () => {
132
+ getReactEventHandler(this, 'on-blur')?.();
133
+ };
134
+ #onClickReactHandler = e => {
135
+ getReactEventHandler(this, 'on-click')?.(e);
136
+ };
137
+ });
@@ -0,0 +1,38 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ import type { TSinchColorName } from '../utils/colors';
3
+ export declare type TSinchChipElement = HTMLElement & {
4
+ /** Text */
5
+ text: string;
6
+ /** Color, gray by default */
7
+ color: TSinchColorName | null;
8
+ /** Small */
9
+ small: boolean;
10
+ /** Click event */
11
+ addEventListener(type: '-click', listener: (e: CustomEvent<void>) => void): void;
12
+ /** Focus event */
13
+ addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
14
+ /** Blur event */
15
+ addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
16
+ /** Text */
17
+ setAttribute(name: 'text', value: string): void;
18
+ /** Color, gray by default */
19
+ setAttribute(name: 'color', value: TSinchColorName): void;
20
+ /** Small */
21
+ setAttribute(name: 'small', value: ''): void;
22
+ };
23
+ export declare type TSinchChipReact = TSinchElementReact<TSinchChipElement> & {
24
+ /** Text */
25
+ text: string;
26
+ /** Color, gray by default */
27
+ color?: TSinchColorName;
28
+ /** Small */
29
+ small?: boolean;
30
+ /** Click event handler */
31
+ 'on-click'?: (e: CustomEvent<void>) => void;
32
+ /** Focus event handler */
33
+ 'on-focus'?: (e: CustomEvent<void>) => void;
34
+ /** Blur event handler */
35
+ 'on-blur'?: (e: CustomEvent<void>) => void;
36
+ /** Label that is used for a11y` */
37
+ 'aria-label': string;
38
+ };
@@ -0,0 +1,13 @@
1
+ import '../color-swatch';
2
+ import '../icons/check';
3
+ import type { TSinchSelectMenuElement, TSinchSelectMenuReact } from './types';
4
+ declare global {
5
+ namespace JSX {
6
+ interface IntrinsicElements {
7
+ 'sinch-color-menu': TSinchSelectMenuReact;
8
+ }
9
+ }
10
+ interface HTMLElementTagNameMap {
11
+ 'sinch-color-menu': TSinchSelectMenuElement;
12
+ }
13
+ }