@nectary/components 0.38.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 (148) hide show
  1. package/accordion/index.js +47 -84
  2. package/accordion/types.d.ts +1 -0
  3. package/accordion-item/index.js +26 -53
  4. package/action-menu/index.d.ts +0 -1
  5. package/action-menu/index.js +179 -223
  6. package/action-menu/types.d.ts +8 -18
  7. package/action-menu-option/index.d.ts +1 -0
  8. package/action-menu-option/index.js +51 -62
  9. package/action-menu-option/types.d.ts +9 -0
  10. package/action-menu-option/utils.d.ts +2 -0
  11. package/action-menu-option/utils.js +3 -0
  12. package/alert/index.js +6 -20
  13. package/avatar/index.js +12 -31
  14. package/avatar-badge/index.js +8 -22
  15. package/avatar-status/index.js +1 -1
  16. package/button/index.js +42 -92
  17. package/card/index.d.ts +2 -0
  18. package/card/index.js +24 -87
  19. package/chat-avatar/index.js +8 -22
  20. package/chat-block/index.js +29 -69
  21. package/chat-bubble/index.js +6 -20
  22. package/checkbox/index.js +55 -107
  23. package/chip/index.d.ts +13 -0
  24. package/chip/index.js +137 -0
  25. package/chip/types.d.ts +38 -0
  26. package/color-menu/index.d.ts +13 -0
  27. package/color-menu/index.js +464 -0
  28. package/color-menu/types.d.ts +37 -0
  29. package/color-swatch/index.d.ts +13 -0
  30. package/color-swatch/index.js +59 -0
  31. package/color-swatch/types.d.ts +12 -0
  32. package/colors.json +57 -49
  33. package/date-picker/index.js +196 -287
  34. package/date-picker/types.d.ts +25 -1
  35. package/dialog/index.d.ts +1 -0
  36. package/dialog/index.js +72 -143
  37. package/dropdown-checkbox-option/index.js +6 -20
  38. package/dropdown-radio-option/index.js +6 -20
  39. package/field/index.js +25 -63
  40. package/file-drop/index.js +123 -200
  41. package/file-picker/index.d.ts +0 -1
  42. package/file-picker/index.js +55 -108
  43. package/file-status/index.js +15 -39
  44. package/help-tooltip/index.js +1 -1
  45. package/horizontal-stepper/index.js +33 -59
  46. package/horizontal-stepper-item/index.js +13 -37
  47. package/icon-button/index.js +39 -84
  48. package/icons-channel/notify/index.d.ts +11 -0
  49. package/icons-channel/notify/index.js +4 -0
  50. package/illustrations/create-illustration-class.js +1 -1
  51. package/inline-alert/index.js +30 -82
  52. package/input/index.js +113 -222
  53. package/link/index.js +46 -96
  54. package/list-item/index.js +1 -1
  55. package/package.json +12 -14
  56. package/pagination/index.js +109 -163
  57. package/pagination/types.d.ts +1 -0
  58. package/popover/index.js +224 -294
  59. package/progress/index.js +9 -28
  60. package/radio/index.js +103 -169
  61. package/radio/types.d.ts +1 -0
  62. package/radio-option/index.js +24 -48
  63. package/segment/index.js +50 -131
  64. package/segment-collapse/index.js +24 -49
  65. package/segment-collapse/types.d.ts +1 -0
  66. package/segmented-control/index.js +36 -73
  67. package/segmented-control/types.d.ts +1 -0
  68. package/segmented-control-option/index.js +41 -87
  69. package/segmented-icon-control/index.js +47 -84
  70. package/segmented-icon-control/types.d.ts +1 -0
  71. package/segmented-icon-control-option/index.js +38 -79
  72. package/select-button/index.d.ts +13 -0
  73. package/select-button/index.js +153 -0
  74. package/select-button/types.d.ts +43 -0
  75. package/select-menu/index.d.ts +11 -0
  76. package/select-menu/index.js +346 -0
  77. package/select-menu/types.d.ts +29 -0
  78. package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
  79. package/select-menu-option/index.js +76 -0
  80. package/{select-option → select-menu-option}/types.d.ts +8 -9
  81. package/stop-events/index.js +7 -20
  82. package/table-head-cell/index.js +7 -21
  83. package/tabs/index.js +103 -165
  84. package/tabs/types.d.ts +1 -0
  85. package/tabs-option/index.js +20 -44
  86. package/tag/index.d.ts +1 -1
  87. package/tag/index.js +42 -36
  88. package/tag/types.d.ts +13 -7
  89. package/textarea/index.js +92 -167
  90. package/theme.css +80 -49
  91. package/tile-control/index.js +55 -96
  92. package/tile-control-option/index.js +40 -86
  93. package/time-picker/index.js +224 -368
  94. package/time-picker/types.d.ts +5 -1
  95. package/title/index.js +6 -20
  96. package/toast/index.d.ts +17 -0
  97. package/toast/index.js +115 -0
  98. package/toast/types.d.ts +28 -0
  99. package/toast/utils.d.ts +5 -0
  100. package/toast/utils.js +6 -0
  101. package/toast-manager/index.d.ts +17 -0
  102. package/toast-manager/index.js +195 -0
  103. package/toast-manager/types.d.ts +7 -0
  104. package/toggle/index.js +55 -108
  105. package/toggle/types.d.ts +1 -0
  106. package/types.d.ts +7 -0
  107. package/utils/colors.d.ts +10 -0
  108. package/utils/colors.js +121 -0
  109. package/{utils.d.ts → utils/index.d.ts} +18 -9
  110. package/{utils.js → utils/index.js} +118 -39
  111. package/vertical-stepper/index.js +29 -50
  112. package/vertical-stepper-item/index.js +13 -37
  113. package/card-button/index.d.ts +0 -11
  114. package/card-button/index.js +0 -77
  115. package/card-button/types.d.ts +0 -12
  116. package/card-link/index.d.ts +0 -12
  117. package/card-link/index.js +0 -115
  118. package/card-link/types.d.ts +0 -14
  119. package/dropdown/index.d.ts +0 -12
  120. package/dropdown/index.js +0 -415
  121. package/dropdown/types.d.ts +0 -30
  122. package/dropdown-text-option/index.js +0 -104
  123. package/dropdown-text-option/types.d.ts +0 -16
  124. package/search/index.d.ts +0 -14
  125. package/search/index.js +0 -523
  126. package/search/types.d.ts +0 -25
  127. package/search-option/index.d.ts +0 -11
  128. package/search-option/index.js +0 -55
  129. package/search-option/types.d.ts +0 -9
  130. package/select/index.d.ts +0 -13
  131. package/select/index.js +0 -316
  132. package/select/types.d.ts +0 -53
  133. package/select-option/index.d.ts +0 -11
  134. package/select-option/index.js +0 -8
  135. package/tag/utils.d.ts +0 -2
  136. package/tag/utils.js +0 -1
  137. package/tag-close/index.d.ts +0 -12
  138. package/tag-close/index.js +0 -38
  139. package/tag-close/types.d.ts +0 -3
  140. package/tag-close/types.js +0 -1
  141. /package/{card-button → chip}/types.js +0 -0
  142. /package/{card-link → color-menu}/types.js +0 -0
  143. /package/{dropdown-text-option → color-swatch}/types.js +0 -0
  144. /package/{dropdown → select-button}/types.js +0 -0
  145. /package/{search → select-menu}/types.js +0 -0
  146. /package/{search-option → select-menu-option}/types.js +0 -0
  147. /package/{select → toast}/types.js +0 -0
  148. /package/{select-option → toast-manager}/types.js +0 -0
@@ -1,84 +1,28 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$slot, _onSlotChange, _onOptionChange, _onValueChange, _onChangeReactHandler;
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 { defineCustomElement, getAttribute, getBooleanAttribute, getCsvSet, getFirstCsvValue, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv } from '../utils';
15
2
  const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row}</style><div id="wrapper"><slot></slot></div>';
16
3
  const template = document.createElement('template');
17
4
  template.innerHTML = templateHTML;
18
- defineCustomElement('sinch-segmented-icon-control', (_$slot = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), _onValueChange = new WeakSet(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
5
+ defineCustomElement('sinch-segmented-icon-control', class extends NectaryElement {
6
+ #$slot;
7
+
19
8
  constructor() {
20
9
  super();
21
-
22
- _classPrivateMethodInitSpec(this, _onValueChange);
23
-
24
- _classPrivateFieldInitSpec(this, _$slot, {
25
- writable: true,
26
- value: void 0
27
- });
28
-
29
- _classPrivateFieldInitSpec(this, _onSlotChange, {
30
- writable: true,
31
- value: () => {
32
- _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
33
- }
34
- });
35
-
36
- _classPrivateFieldInitSpec(this, _onOptionChange, {
37
- writable: true,
38
- value: e => {
39
- e.stopPropagation();
40
- const $elem = e.target;
41
- const value = e.detail;
42
- const detail = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute($elem, 'data-checked')) : value;
43
- this.dispatchEvent(new CustomEvent('change', {
44
- detail,
45
- bubbles: true
46
- }));
47
- this.dispatchEvent(new CustomEvent('-change', {
48
- detail
49
- }));
50
- }
51
- });
52
-
53
- _classPrivateFieldInitSpec(this, _onChangeReactHandler, {
54
- writable: true,
55
- value: e => {
56
- getReactEventHandler(this, 'on-change')?.(e);
57
- }
58
- });
59
-
60
10
  const shadowRoot = this.attachShadow();
61
11
  shadowRoot.appendChild(template.content.cloneNode(true));
62
-
63
- _classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
12
+ this.#$slot = shadowRoot.querySelector('slot');
64
13
  }
65
14
 
66
15
  connectedCallback() {
67
16
  this.setAttribute('role', 'tablist');
68
-
69
- _classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
70
-
71
- _classPrivateFieldGet(this, _$slot).addEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
72
-
73
- this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
17
+ this.#$slot.addEventListener('slotchange', this.#onSlotChange);
18
+ this.#$slot.addEventListener('option-change', this.#onOptionChange);
19
+ this.addEventListener('-change', this.#onChangeReactHandler);
74
20
  }
75
21
 
76
22
  disconnectedCallback() {
77
- _classPrivateFieldGet(this, _$slot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
78
-
79
- _classPrivateFieldGet(this, _$slot).removeEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
80
-
81
- this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
23
+ this.#$slot.removeEventListener('slotchange', this.#onSlotChange);
24
+ this.#$slot.removeEventListener('option-change', this.#onOptionChange);
25
+ this.removeEventListener('-change', this.#onChangeReactHandler);
82
26
  }
83
27
 
84
28
  static get observedAttributes() {
@@ -113,29 +57,48 @@ defineCustomElement('sinch-segmented-icon-control', (_$slot = new WeakMap(), _on
113
57
  switch (name) {
114
58
  case 'value':
115
59
  {
116
- _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, newVal ?? '');
117
-
60
+ this.#onValueChange(newVal ?? '');
118
61
  break;
119
62
  }
120
63
  }
121
64
  }
122
65
 
123
- }));
124
-
125
- function _onValueChange2(csv) {
126
- if (this.multiple) {
127
- const values = getCsvSet(csv);
128
-
129
- for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
130
- const isChecked = !getBooleanAttribute($option, 'disabled') && values.has(getAttribute($option, 'value', ''));
131
- updateBooleanAttribute($option, 'data-checked', isChecked);
132
- }
133
- } else {
134
- const value = getFirstCsvValue(csv);
66
+ #onSlotChange = () => {
67
+ this.#onValueChange(this.value);
68
+ };
69
+ #onOptionChange = e => {
70
+ e.stopPropagation();
71
+ const $elem = e.target;
72
+ const value = e.detail;
73
+ const detail = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute($elem, 'data-checked')) : value;
74
+ this.dispatchEvent(new CustomEvent('change', {
75
+ detail,
76
+ bubbles: true
77
+ }));
78
+ this.dispatchEvent(new CustomEvent('-change', {
79
+ detail
80
+ }));
81
+ };
82
+
83
+ #onValueChange(csv) {
84
+ if (this.multiple) {
85
+ const values = getCsvSet(csv);
86
+
87
+ for (const $option of this.#$slot.assignedElements()) {
88
+ const isChecked = !getBooleanAttribute($option, 'disabled') && values.has(getAttribute($option, 'value', ''));
89
+ updateBooleanAttribute($option, 'data-checked', isChecked);
90
+ }
91
+ } else {
92
+ const value = getFirstCsvValue(csv);
135
93
 
136
- for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
137
- const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
138
- updateBooleanAttribute($option, 'data-checked', isChecked);
94
+ for (const $option of this.#$slot.assignedElements()) {
95
+ const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
96
+ updateBooleanAttribute($option, 'data-checked', isChecked);
97
+ }
139
98
  }
140
99
  }
141
- }
100
+
101
+ #onChangeReactHandler = e => {
102
+ getReactEventHandler(this, 'on-change')?.(e);
103
+ };
104
+ });
@@ -11,6 +11,7 @@ export declare type TSinchSegmentedIconControlReact = TSinchElementReact<TSinchS
11
11
  value: string;
12
12
  multiple?: boolean;
13
13
  'aria-label': string;
14
+ /** @deprecated */
14
15
  onChange?: (event: SyntheticEvent<TSinchSegmentedIconControlElement, CustomEvent<string>>) => void;
15
16
  'on-change'?: (e: CustomEvent<string>) => void;
16
17
  };
@@ -1,92 +1,32 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$button, _onButtonClick, _onButtonFocus, _onButtonBlur, _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{display:block;outline:0}#wrapper{position:relative;width:56px;height:32px;padding:3px 16px;box-sizing:border-box;border:1px solid var(--sinch-color-snow-600);border-left-width:0;border-right-width:0;color:var(--sinch-color-stormy-500);background-color:var(--sinch-color-snow-100);--sinch-color-icon:var(--sinch-color-stormy-500);--sinch-size-icon:24px}#wrapper:hover{background-color:var(--sinch-color-snow-500)}:host(:first-child) #wrapper{border-left-width:1px;border-top-left-radius:4px;border-bottom-left-radius:4px}:host(:last-child) #wrapper{border-right-width:1px;border-top-right-radius:4px;border-bottom-right-radius:4px}:host([data-checked]) #wrapper{border-color:var(--sinch-color-stormy-500)}:host([data-checked]:not(:first-child)) #wrapper::before{content:"";width:1px;background-color:var(--sinch-color-stormy-500);position:absolute;left:-1px;top:-1px;bottom:-1px}:host([data-checked]:not(:last-child)) #wrapper::after{content:"";width:1px;background-color:var(--sinch-color-stormy-500);position:absolute;right:0;top:-1px;bottom:-1px}#button{all:initial;position:absolute;left:0;top:0;box-sizing:border-box;width:100%;height:100%;cursor:pointer;z-index:1}#button:disabled{cursor:unset}#button:focus::before{content:"";position:absolute;left:-4px;right:-3px;top:-4px;bottom:-4px;border-style:solid;border-color:var(--sinch-color-aqua-400);border-width:0}#button:focus-visible::before{border-width:2px}:host(:first-child) #button:focus::before{left:-4px;border-top-left-radius:6px;border-bottom-left-radius:6px}:host(:last-child) #button:focus::before{right:-4px;border-top-right-radius:6px;border-bottom-right-radius:6px}@supports not selector(:focus-visible){#button:focus::before{border-width:2px}}:host([disabled]:not([disabled=false])) #wrapper{background-color:var(--sinch-color-snow-100);color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}::slotted(*){display:block}</style><div id="wrapper"><slot name="icon"></slot><button id="button"></button></div>';
2
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;width:56px;height:32px;padding:3px 16px;box-sizing:border-box;border:1px solid var(--sinch-color-snow-600);border-left-width:0;border-right-width:0;color:var(--sinch-color-stormy-500);background-color:var(--sinch-color-snow-100);--sinch-color-icon:var(--sinch-color-stormy-500);--sinch-size-icon:24px}#wrapper:hover{background-color:var(--sinch-color-snow-400)}:host(:first-child) #wrapper{border-left-width:1px;border-top-left-radius:4px;border-bottom-left-radius:4px}:host(:last-child) #wrapper{border-right-width:1px;border-top-right-radius:4px;border-bottom-right-radius:4px}:host([data-checked]) #wrapper{border-color:var(--sinch-color-stormy-500)}:host([data-checked]:not(:first-child)) #wrapper::before{content:"";width:1px;background-color:var(--sinch-color-stormy-500);position:absolute;left:-1px;top:-1px;bottom:-1px}:host([data-checked]:not(:last-child)) #wrapper::after{content:"";width:1px;background-color:var(--sinch-color-stormy-500);position:absolute;right:0;top:-1px;bottom:-1px}#button{all:initial;position:absolute;left:0;top:0;box-sizing:border-box;width:100%;height:100%;cursor:pointer;z-index:1}#button:disabled{cursor:unset}#button:focus::before{content:"";position:absolute;left:-4px;right:-3px;top:-4px;bottom:-4px;border-style:solid;border-color:var(--sinch-color-aqua-400);border-width:0}#button:focus-visible::before{border-width:2px}:host(:first-child) #button:focus::before{left:-4px;border-top-left-radius:6px;border-bottom-left-radius:6px}:host(:last-child) #button:focus::before{right:-4px;border-top-right-radius:6px;border-bottom-right-radius:6px}@supports not selector(:focus-visible){#button:focus::before{border-width:2px}}:host([disabled]:not([disabled=false])) #wrapper{background-color:var(--sinch-color-snow-100);color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}::slotted(*){display:block}</style><div id="wrapper"><slot name="icon"></slot><button id="button"></button></div>';
12
3
  const template = document.createElement('template');
13
4
  template.innerHTML = templateHTML;
14
- defineCustomElement('sinch-segmented-icon-control-option', (_$button = new WeakMap(), _onButtonClick = new WeakMap(), _onButtonFocus = new WeakMap(), _onButtonBlur = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
5
+ defineCustomElement('sinch-segmented-icon-control-option', class extends NectaryElement {
6
+ #$button;
7
+
15
8
  constructor() {
16
9
  super();
17
-
18
- _classPrivateFieldInitSpec(this, _$button, {
19
- writable: true,
20
- value: void 0
21
- });
22
-
23
- _classPrivateFieldInitSpec(this, _onButtonClick, {
24
- writable: true,
25
- value: e => {
26
- e.stopPropagation();
27
- this.dispatchEvent(new CustomEvent('option-change', {
28
- detail: this.value,
29
- bubbles: true
30
- }));
31
- }
32
- });
33
-
34
- _classPrivateFieldInitSpec(this, _onButtonFocus, {
35
- writable: true,
36
- value: () => {
37
- this.dispatchEvent(new CustomEvent('-focus'));
38
- }
39
- });
40
-
41
- _classPrivateFieldInitSpec(this, _onButtonBlur, {
42
- writable: true,
43
- value: () => {
44
- this.dispatchEvent(new CustomEvent('-blur'));
45
- }
46
- });
47
-
48
- _classPrivateFieldInitSpec(this, _onFocusReactHandler, {
49
- writable: true,
50
- value: () => {
51
- getReactEventHandler(this, 'on-focus')?.();
52
- }
53
- });
54
-
55
- _classPrivateFieldInitSpec(this, _onBlurReactHandler, {
56
- writable: true,
57
- value: () => {
58
- getReactEventHandler(this, 'on-blur')?.();
59
- }
60
- });
61
-
62
10
  const shadowRoot = this.attachShadow();
63
11
  shadowRoot.appendChild(template.content.cloneNode(true));
64
-
65
- _classPrivateFieldSet(this, _$button, shadowRoot.querySelector('#button'));
12
+ this.#$button = shadowRoot.querySelector('#button');
66
13
  }
67
14
 
68
15
  connectedCallback() {
69
16
  this.setAttribute('role', 'tab');
70
-
71
- _classPrivateFieldGet(this, _$button).addEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
72
-
73
- _classPrivateFieldGet(this, _$button).addEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
74
-
75
- _classPrivateFieldGet(this, _$button).addEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
76
-
77
- this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
78
- this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
17
+ this.#$button.addEventListener('click', this.#onButtonClick);
18
+ this.#$button.addEventListener('focus', this.#onButtonFocus);
19
+ this.#$button.addEventListener('blur', this.#onButtonBlur);
20
+ this.addEventListener('-focus', this.#onFocusReactHandler);
21
+ this.addEventListener('-blur', this.#onBlurReactHandler);
79
22
  }
80
23
 
81
24
  disconnectedCallback() {
82
- _classPrivateFieldGet(this, _$button).removeEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
83
-
84
- _classPrivateFieldGet(this, _$button).removeEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
85
-
86
- _classPrivateFieldGet(this, _$button).removeEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
87
-
88
- this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
89
- this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
25
+ this.#$button.removeEventListener('click', this.#onButtonClick);
26
+ this.#$button.removeEventListener('focus', this.#onButtonFocus);
27
+ this.#$button.removeEventListener('blur', this.#onButtonBlur);
28
+ this.removeEventListener('-focus', this.#onFocusReactHandler);
29
+ this.removeEventListener('-blur', this.#onBlurReactHandler);
90
30
  }
91
31
 
92
32
  static get observedAttributes() {
@@ -119,18 +59,37 @@ defineCustomElement('sinch-segmented-icon-control-option', (_$button = new WeakM
119
59
 
120
60
  case 'disabled':
121
61
  {
122
- _classPrivateFieldGet(this, _$button).disabled = isAttrTrue(newVal);
62
+ this.#$button.disabled = isAttrTrue(newVal);
123
63
  break;
124
64
  }
125
65
  }
126
66
  }
127
67
 
128
68
  focus() {
129
- _classPrivateFieldGet(this, _$button).focus();
69
+ this.#$button.focus();
130
70
  }
131
71
 
132
72
  blur() {
133
- _classPrivateFieldGet(this, _$button).blur();
73
+ this.#$button.blur();
134
74
  }
135
75
 
136
- }));
76
+ #onButtonClick = e => {
77
+ e.stopPropagation();
78
+ this.dispatchEvent(new CustomEvent('option-change', {
79
+ detail: this.value,
80
+ bubbles: true
81
+ }));
82
+ };
83
+ #onButtonFocus = () => {
84
+ this.dispatchEvent(new CustomEvent('-focus'));
85
+ };
86
+ #onButtonBlur = () => {
87
+ this.dispatchEvent(new CustomEvent('-blur'));
88
+ };
89
+ #onFocusReactHandler = () => {
90
+ getReactEventHandler(this, 'on-focus')?.();
91
+ };
92
+ #onBlurReactHandler = () => {
93
+ getReactEventHandler(this, 'on-blur')?.();
94
+ };
95
+ });
@@ -0,0 +1,13 @@
1
+ import '../text';
2
+ import '../icons/keyboard-arrow-down';
3
+ import type { TSinchSelectButtonElement, TSinchSelectButtonReact } from './types';
4
+ declare global {
5
+ namespace JSX {
6
+ interface IntrinsicElements {
7
+ 'sinch-select-button': TSinchSelectButtonReact;
8
+ }
9
+ }
10
+ interface HTMLElementTagNameMap {
11
+ 'sinch-select-button': TSinchSelectButtonElement;
12
+ }
13
+ }
@@ -0,0 +1,153 @@
1
+ import '../text';
2
+ import '../icons/keyboard-arrow-down';
3
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
4
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:48px;padding:0 12px;background-color:var(--sinch-color-snow-100);border-radius:var(--sinch-shape-radius-s);--sinch-size-icon:24px;--sinch-color-icon:var(--sinch-color-stormy-500)}#button{all:initial;cursor:pointer;position:absolute;left:0;top:0;width:100%;height:100%;z-index:1;border-radius:var(--sinch-shape-radius-s);border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box}#text{flex:1;min-width:0;color:var(--sinch-color-text-muted)}:host([text]:not([text=""])) #text{color:var(--sinch-color-text-default)}#button:disabled{border-color:var(--sinch-color-snow-500);cursor:initial}#button:focus-visible{border-color:var(--sinch-color-stormy-600)}@supports not selector(:focus-visible){#button:focus{border-color:var(--sinch-color-stormy-600)}}:host([invalid]) #button:enabled{border-color:var(--sinch-color-text-invalid)}#button:disabled~#text{color:var(--sinch-color-stormy-100)}:host([disabled]) #wrapper{--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><button id="button"></button><slot name="icon"></slot><sinch-text id="text" type="m" ellipsis></sinch-text><sinch-icon-keyboard-arrow-down></sinch-icon-keyboard-arrow-down></div>';
5
+ const template = document.createElement('template');
6
+ template.innerHTML = templateHTML;
7
+ defineCustomElement('sinch-select-button', class extends NectaryElement {
8
+ #$button;
9
+ #$text;
10
+ #controller = new AbortController();
11
+
12
+ constructor() {
13
+ super();
14
+ const shadowRoot = this.attachShadow();
15
+ shadowRoot.appendChild(template.content.cloneNode(true));
16
+ this.#$button = shadowRoot.querySelector('#button');
17
+ this.#$text = shadowRoot.querySelector('#text');
18
+ }
19
+
20
+ connectedCallback() {
21
+ const {
22
+ signal
23
+ } = this.#controller;
24
+ this.setAttribute('role', 'button');
25
+ this.#$button.addEventListener('click', this.#onButtonClick, {
26
+ signal
27
+ });
28
+ this.#$button.addEventListener('focus', this.#onButtonFocus, {
29
+ signal
30
+ });
31
+ this.#$button.addEventListener('blur', this.#onButtonBlur, {
32
+ signal
33
+ });
34
+ this.addEventListener('-click', this.#onClickReactHandler, {
35
+ signal
36
+ });
37
+ this.addEventListener('-focus', this.#onFocusReactHandler, {
38
+ signal
39
+ });
40
+ this.addEventListener('-blur', this.#onBlurReactHandler, {
41
+ signal
42
+ });
43
+ }
44
+
45
+ disconnectedCallback() {
46
+ this.#controller.abort();
47
+ }
48
+
49
+ static get observedAttributes() {
50
+ return ['text', 'placeholder', 'invalid', 'disabled'];
51
+ }
52
+
53
+ set text(value) {
54
+ updateAttribute(this, 'text', value);
55
+ }
56
+
57
+ get text() {
58
+ return getAttribute(this, 'text', '');
59
+ }
60
+
61
+ set placeholder(value) {
62
+ updateAttribute(this, 'placeholder', value);
63
+ }
64
+
65
+ get placeholder() {
66
+ return getAttribute(this, 'placeholder');
67
+ }
68
+
69
+ set invalid(isInvalid) {
70
+ updateBooleanAttribute(this, 'invalid', isInvalid);
71
+ }
72
+
73
+ get invalid() {
74
+ return getBooleanAttribute(this, 'invalid');
75
+ }
76
+
77
+ set disabled(isDisabled) {
78
+ updateBooleanAttribute(this, 'disabled', isDisabled);
79
+ }
80
+
81
+ get disabled() {
82
+ return getBooleanAttribute(this, 'disabled');
83
+ }
84
+
85
+ attributeChangedCallback(name, oldVal, newVal) {
86
+ if (oldVal === newVal) {
87
+ return;
88
+ }
89
+
90
+ switch (name) {
91
+ case 'text':
92
+ {
93
+ const value = newVal ?? '';
94
+ this.#$text.textContent = value.length > 0 ? value : this.placeholder;
95
+ break;
96
+ }
97
+
98
+ case 'placeholder':
99
+ {
100
+ const value = this.text;
101
+
102
+ if (value.length === 0) {
103
+ this.#$text.textContent = newVal ?? '';
104
+ }
105
+
106
+ break;
107
+ }
108
+
109
+ case 'invalid':
110
+ {
111
+ const isInvalid = isAttrTrue(newVal);
112
+ updateBooleanAttribute(this, 'invalid', isInvalid);
113
+ updateExplicitBooleanAttribute(this, 'aria-invalid', isInvalid);
114
+ break;
115
+ }
116
+
117
+ case 'disabled':
118
+ {
119
+ const isDisabled = isAttrTrue(newVal);
120
+ this.#$button.disabled = isDisabled;
121
+ updateBooleanAttribute(this, 'disabled', isDisabled);
122
+ break;
123
+ }
124
+ }
125
+ }
126
+
127
+ focus() {
128
+ this.#$button.focus();
129
+ }
130
+
131
+ blur() {
132
+ this.#$button.blur();
133
+ }
134
+
135
+ #onButtonFocus = () => {
136
+ this.dispatchEvent(new CustomEvent('-focus'));
137
+ };
138
+ #onButtonBlur = () => {
139
+ this.dispatchEvent(new CustomEvent('-blur'));
140
+ };
141
+ #onButtonClick = () => {
142
+ this.dispatchEvent(new CustomEvent('-click'));
143
+ };
144
+ #onClickReactHandler = e => {
145
+ getReactEventHandler(this, 'on-click')?.(e);
146
+ };
147
+ #onFocusReactHandler = () => {
148
+ getReactEventHandler(this, 'on-focus')?.();
149
+ };
150
+ #onBlurReactHandler = () => {
151
+ getReactEventHandler(this, 'on-blur')?.();
152
+ };
153
+ });
@@ -0,0 +1,43 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ export declare type TSinchSelectButtonElement = HTMLElement & {
3
+ /** Text */
4
+ text: string;
5
+ /** Text that appears in the text field when it has no text set */
6
+ placeholder: string;
7
+ /** Invalid state */
8
+ invalid: boolean;
9
+ /** Disabled */
10
+ disabled: boolean;
11
+ /** Click event */
12
+ addEventListener(type: '-click', listener: (e: CustomEvent<void>) => void): void;
13
+ /** Focus event */
14
+ addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
15
+ /** Blur event */
16
+ addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
17
+ /** Text */
18
+ setAttribute(name: 'text', value: string): void;
19
+ /** Text that appears in the text field when it has no value set */
20
+ setAttribute(name: 'placeholder', value: string): void;
21
+ /** Invalid state */
22
+ setAttribute(name: 'invalid', value: ''): void;
23
+ /** Disabled */
24
+ setAttribute(name: 'disabled', value: ''): void;
25
+ };
26
+ export declare type TSinchSelectButtonReact = TSinchElementReact<TSinchSelectButtonElement> & {
27
+ /** Text */
28
+ text: string;
29
+ /** Label that is used for a11y` */
30
+ 'aria-label': string;
31
+ /** Text that appears in the text field when it has no text set */
32
+ placeholder: string;
33
+ /** Invalid state */
34
+ invalid?: boolean;
35
+ /** Disabled */
36
+ disabled?: boolean;
37
+ /** Click handler */
38
+ 'on-click'?: (e: CustomEvent<void>) => void;
39
+ /** Focus handler */
40
+ 'on-focus'?: (e: CustomEvent<void>) => void;
41
+ /** Blur handler */
42
+ 'on-blur'?: (e: CustomEvent<void>) => void;
43
+ };
@@ -0,0 +1,11 @@
1
+ import type { TSinchSelectMenuElement, TSinchSelectMenuReact } from './types';
2
+ declare global {
3
+ namespace JSX {
4
+ interface IntrinsicElements {
5
+ 'sinch-select-menu': TSinchSelectMenuReact;
6
+ }
7
+ }
8
+ interface HTMLElementTagNameMap {
9
+ 'sinch-select-menu': TSinchSelectMenuElement;
10
+ }
11
+ }