@nectary/components 0.25.0 → 0.26.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 (290) hide show
  1. package/dialog/index.js +2 -2
  2. package/icons/add/index.d.ts +11 -0
  3. package/icons/add/index.js +4 -0
  4. package/icons/add-box/index.d.ts +11 -0
  5. package/icons/add-box/index.js +4 -0
  6. package/icons/add-circle/index.d.ts +11 -0
  7. package/icons/add-circle/index.js +4 -0
  8. package/icons/add-circle-outline/index.d.ts +11 -0
  9. package/icons/add-circle-outline/index.js +4 -0
  10. package/icons/amp-stories/index.d.ts +11 -0
  11. package/icons/amp-stories/index.js +4 -0
  12. package/icons/archive/index.d.ts +11 -0
  13. package/icons/archive/index.js +4 -0
  14. package/icons/attach-file/index.d.ts +11 -0
  15. package/icons/attach-file/index.js +4 -0
  16. package/icons/attach-money/index.d.ts +11 -0
  17. package/icons/attach-money/index.js +4 -0
  18. package/icons/attribution/index.d.ts +11 -0
  19. package/icons/attribution/index.js +4 -0
  20. package/icons/backspace/index.d.ts +11 -0
  21. package/icons/backspace/index.js +4 -0
  22. package/icons/ballot/index.d.ts +11 -0
  23. package/icons/ballot/index.js +4 -0
  24. package/icons/bar-chart/index.d.ts +11 -0
  25. package/icons/bar-chart/index.js +4 -0
  26. package/icons/biotech/index.d.ts +11 -0
  27. package/icons/biotech/index.js +4 -0
  28. package/icons/block/index.d.ts +11 -0
  29. package/icons/block/index.js +4 -0
  30. package/icons/border-all/index.d.ts +11 -0
  31. package/icons/border-all/index.js +4 -0
  32. package/icons/border-bottom/index.d.ts +11 -0
  33. package/icons/border-bottom/index.js +4 -0
  34. package/icons/border-clear/index.d.ts +11 -0
  35. package/icons/border-clear/index.js +4 -0
  36. package/icons/border-horizontal/index.d.ts +11 -0
  37. package/icons/border-horizontal/index.js +4 -0
  38. package/icons/border-inner/index.d.ts +11 -0
  39. package/icons/border-inner/index.js +4 -0
  40. package/icons/border-left/index.d.ts +11 -0
  41. package/icons/border-left/index.js +4 -0
  42. package/icons/border-outer/index.d.ts +11 -0
  43. package/icons/border-outer/index.js +4 -0
  44. package/icons/border-right/index.d.ts +11 -0
  45. package/icons/border-right/index.js +4 -0
  46. package/icons/border-style/index.d.ts +11 -0
  47. package/icons/border-style/index.js +4 -0
  48. package/icons/border-top/index.d.ts +11 -0
  49. package/icons/border-top/index.js +4 -0
  50. package/icons/border-vertical/index.d.ts +11 -0
  51. package/icons/border-vertical/index.js +4 -0
  52. package/icons/bubble-chart/index.d.ts +11 -0
  53. package/icons/bubble-chart/index.js +4 -0
  54. package/icons/calculate/index.d.ts +11 -0
  55. package/icons/calculate/index.js +4 -0
  56. package/icons/clear/index.d.ts +11 -0
  57. package/icons/clear/index.js +4 -0
  58. package/icons/content-copy/index.d.ts +11 -0
  59. package/icons/content-copy/index.js +4 -0
  60. package/icons/content-cut/index.d.ts +11 -0
  61. package/icons/content-cut/index.js +4 -0
  62. package/icons/content-paste/index.d.ts +11 -0
  63. package/icons/content-paste/index.js +4 -0
  64. package/icons/delete-sweep/index.d.ts +11 -0
  65. package/icons/delete-sweep/index.js +4 -0
  66. package/icons/drafts/index.d.ts +11 -0
  67. package/icons/drafts/index.js +4 -0
  68. package/icons/drag-handle/index.d.ts +11 -0
  69. package/icons/drag-handle/index.js +4 -0
  70. package/icons/dynamic-feed/index.d.ts +11 -0
  71. package/icons/dynamic-feed/index.js +4 -0
  72. package/icons/file-copy/index.d.ts +11 -0
  73. package/icons/file-copy/index.js +4 -0
  74. package/icons/flag/index.d.ts +11 -0
  75. package/icons/flag/index.js +4 -0
  76. package/icons/font-download/index.d.ts +11 -0
  77. package/icons/font-download/index.js +4 -0
  78. package/icons/format-align-center/index.d.ts +11 -0
  79. package/icons/format-align-center/index.js +4 -0
  80. package/icons/format-align-justify/index.d.ts +11 -0
  81. package/icons/format-align-justify/index.js +4 -0
  82. package/icons/format-align-left/index.d.ts +11 -0
  83. package/icons/format-align-left/index.js +4 -0
  84. package/icons/format-align-right/index.d.ts +11 -0
  85. package/icons/format-align-right/index.js +4 -0
  86. package/icons/format-bold/index.d.ts +11 -0
  87. package/icons/format-bold/index.js +4 -0
  88. package/icons/format-clear/index.d.ts +11 -0
  89. package/icons/format-clear/index.js +4 -0
  90. package/icons/format-color-reset/index.d.ts +11 -0
  91. package/icons/format-color-reset/index.js +4 -0
  92. package/icons/format-indent-decrease/index.d.ts +11 -0
  93. package/icons/format-indent-decrease/index.js +4 -0
  94. package/icons/format-indent-increase/index.d.ts +11 -0
  95. package/icons/format-indent-increase/index.js +4 -0
  96. package/icons/format-italic/index.d.ts +11 -0
  97. package/icons/format-italic/index.js +4 -0
  98. package/icons/format-line-spacing/index.d.ts +11 -0
  99. package/icons/format-line-spacing/index.js +4 -0
  100. package/icons/format-list-bulleted/index.d.ts +11 -0
  101. package/icons/format-list-bulleted/index.js +4 -0
  102. package/icons/format-list-numbered/index.d.ts +11 -0
  103. package/icons/format-list-numbered/index.js +4 -0
  104. package/icons/format-list-numbered-rtl/index.d.ts +11 -0
  105. package/icons/format-list-numbered-rtl/index.js +4 -0
  106. package/icons/format-paint/index.d.ts +11 -0
  107. package/icons/format-paint/index.js +4 -0
  108. package/icons/format-quote/index.d.ts +11 -0
  109. package/icons/format-quote/index.js +4 -0
  110. package/icons/format-shapes/index.d.ts +11 -0
  111. package/icons/format-shapes/index.js +4 -0
  112. package/icons/format-size/index.d.ts +11 -0
  113. package/icons/format-size/index.js +4 -0
  114. package/icons/format-strikethrough/index.d.ts +11 -0
  115. package/icons/format-strikethrough/index.js +4 -0
  116. package/icons/format-textdirection-l-to-r/index.d.ts +11 -0
  117. package/icons/format-textdirection-l-to-r/index.js +4 -0
  118. package/icons/format-textdirection-r-to-l/index.d.ts +11 -0
  119. package/icons/format-textdirection-r-to-l/index.js +4 -0
  120. package/icons/format-underlined/index.d.ts +11 -0
  121. package/icons/format-underlined/index.js +4 -0
  122. package/icons/forward/index.d.ts +11 -0
  123. package/icons/forward/index.js +4 -0
  124. package/icons/functions/index.d.ts +11 -0
  125. package/icons/functions/index.js +4 -0
  126. package/icons/gesture/index.d.ts +11 -0
  127. package/icons/gesture/index.js +4 -0
  128. package/icons/height/index.d.ts +11 -0
  129. package/icons/height/index.js +4 -0
  130. package/icons/highlight/index.d.ts +11 -0
  131. package/icons/highlight/index.js +4 -0
  132. package/icons/horizontal-rule/index.d.ts +11 -0
  133. package/icons/horizontal-rule/index.js +4 -0
  134. package/icons/how-to-reg/index.d.ts +11 -0
  135. package/icons/how-to-reg/index.js +4 -0
  136. package/icons/how-to-vote/index.d.ts +11 -0
  137. package/icons/how-to-vote/index.js +4 -0
  138. package/icons/inbox/index.d.ts +11 -0
  139. package/icons/inbox/index.js +4 -0
  140. package/icons/insert-chart/index.d.ts +11 -0
  141. package/icons/insert-chart/index.js +4 -0
  142. package/icons/insert-chart-outlined/index.d.ts +11 -0
  143. package/icons/insert-chart-outlined/index.js +4 -0
  144. package/icons/insert-comment/index.d.ts +11 -0
  145. package/icons/insert-comment/index.js +4 -0
  146. package/icons/insert-drive-file/index.d.ts +11 -0
  147. package/icons/insert-drive-file/index.js +4 -0
  148. package/icons/insert-emoticon/index.js +1 -1
  149. package/icons/insert-invitation/index.d.ts +11 -0
  150. package/icons/insert-invitation/index.js +4 -0
  151. package/icons/insert-link/index.d.ts +11 -0
  152. package/icons/insert-link/index.js +4 -0
  153. package/icons/insert-photo/index.d.ts +11 -0
  154. package/icons/insert-photo/index.js +4 -0
  155. package/icons/insights/index.d.ts +11 -0
  156. package/icons/insights/index.js +4 -0
  157. package/icons/linear-scale/index.d.ts +11 -0
  158. package/icons/linear-scale/index.js +4 -0
  159. package/icons/link/index.d.ts +11 -0
  160. package/icons/link/index.js +4 -0
  161. package/icons/link-off/index.d.ts +11 -0
  162. package/icons/link-off/index.js +4 -0
  163. package/icons/low-priority/index.d.ts +11 -0
  164. package/icons/low-priority/index.js +4 -0
  165. package/icons/mail/index.d.ts +11 -0
  166. package/icons/mail/index.js +4 -0
  167. package/icons/markunread/index.d.ts +11 -0
  168. package/icons/markunread/index.js +4 -0
  169. package/icons/merge-type/index.d.ts +11 -0
  170. package/icons/merge-type/index.js +4 -0
  171. package/icons/mode/index.d.ts +11 -0
  172. package/icons/mode/index.js +4 -0
  173. package/icons/mode-comment/index.d.ts +11 -0
  174. package/icons/mode-comment/index.js +4 -0
  175. package/icons/monetization-on/index.d.ts +11 -0
  176. package/icons/monetization-on/index.js +4 -0
  177. package/icons/money-off/index.d.ts +11 -0
  178. package/icons/money-off/index.js +4 -0
  179. package/icons/money-off-csred/index.d.ts +11 -0
  180. package/icons/money-off-csred/index.js +4 -0
  181. package/icons/move-to-inbox/index.d.ts +11 -0
  182. package/icons/move-to-inbox/index.js +4 -0
  183. package/icons/multiline-chart/index.d.ts +11 -0
  184. package/icons/multiline-chart/index.js +4 -0
  185. package/icons/next-week/index.d.ts +11 -0
  186. package/icons/next-week/index.js +4 -0
  187. package/icons/notes/index.js +1 -1
  188. package/icons/outlined-flag/index.d.ts +11 -0
  189. package/icons/outlined-flag/index.js +4 -0
  190. package/icons/pie-chart/index.d.ts +11 -0
  191. package/icons/pie-chart/index.js +4 -0
  192. package/icons/pie-chart-outline/index.d.ts +11 -0
  193. package/icons/pie-chart-outline/index.js +4 -0
  194. package/icons/policy/index.d.ts +11 -0
  195. package/icons/policy/index.js +4 -0
  196. package/icons/post-add/index.d.ts +11 -0
  197. package/icons/post-add/index.js +4 -0
  198. package/icons/publish/index.d.ts +11 -0
  199. package/icons/publish/index.js +4 -0
  200. package/icons/push-pin/index.d.ts +11 -0
  201. package/icons/push-pin/index.js +4 -0
  202. package/icons/redo/index.d.ts +11 -0
  203. package/icons/redo/index.js +4 -0
  204. package/icons/remove/index.d.ts +11 -0
  205. package/icons/remove/index.js +4 -0
  206. package/icons/remove-circle/index.d.ts +11 -0
  207. package/icons/remove-circle/index.js +4 -0
  208. package/icons/remove-circle-outline/index.d.ts +11 -0
  209. package/icons/remove-circle-outline/index.js +4 -0
  210. package/icons/reply-all/index.d.ts +11 -0
  211. package/icons/reply-all/index.js +4 -0
  212. package/icons/report/index.d.ts +11 -0
  213. package/icons/report/index.js +4 -0
  214. package/icons/report-off/index.d.ts +11 -0
  215. package/icons/report-off/index.js +4 -0
  216. package/icons/report-outline/index.d.ts +11 -0
  217. package/icons/report-outline/index.js +4 -0
  218. package/icons/save/index.d.ts +11 -0
  219. package/icons/save/index.js +4 -0
  220. package/icons/save-alt/index.d.ts +11 -0
  221. package/icons/save-alt/index.js +4 -0
  222. package/icons/scatter-plot/index.d.ts +11 -0
  223. package/icons/scatter-plot/index.js +4 -0
  224. package/icons/score/index.d.ts +11 -0
  225. package/icons/score/index.js +4 -0
  226. package/icons/select-all/index.d.ts +11 -0
  227. package/icons/select-all/index.js +4 -0
  228. package/icons/short-text/index.d.ts +11 -0
  229. package/icons/short-text/index.js +4 -0
  230. package/icons/show-chart/index.d.ts +11 -0
  231. package/icons/show-chart/index.js +4 -0
  232. package/icons/smart-toy/index.d.ts +11 -0
  233. package/icons/smart-toy/index.js +4 -0
  234. package/icons/sort/index.d.ts +11 -0
  235. package/icons/sort/index.js +4 -0
  236. package/icons/space-bar/index.d.ts +11 -0
  237. package/icons/space-bar/index.js +4 -0
  238. package/icons/square-foot/index.d.ts +11 -0
  239. package/icons/square-foot/index.js +4 -0
  240. package/icons/stacked-line-chart/index.d.ts +11 -0
  241. package/icons/stacked-line-chart/index.js +4 -0
  242. package/icons/strikethrough-s/index.d.ts +11 -0
  243. package/icons/strikethrough-s/index.js +4 -0
  244. package/icons/subscript/index.d.ts +11 -0
  245. package/icons/subscript/index.js +4 -0
  246. package/icons/superscript/index.d.ts +11 -0
  247. package/icons/superscript/index.js +4 -0
  248. package/icons/table-chart/index.d.ts +11 -0
  249. package/icons/table-chart/index.js +4 -0
  250. package/icons/table-rows/index.d.ts +11 -0
  251. package/icons/table-rows/index.js +4 -0
  252. package/icons/text-fields/index.d.ts +11 -0
  253. package/icons/text-fields/index.js +4 -0
  254. package/icons/text-format/index.d.ts +11 -0
  255. package/icons/text-format/index.js +4 -0
  256. package/icons/title/index.d.ts +11 -0
  257. package/icons/title/index.js +4 -0
  258. package/icons/unarchive/index.d.ts +11 -0
  259. package/icons/unarchive/index.js +4 -0
  260. package/icons/vertical-align-bottom/index.d.ts +11 -0
  261. package/icons/vertical-align-bottom/index.js +4 -0
  262. package/icons/vertical-align-center/index.d.ts +11 -0
  263. package/icons/vertical-align-center/index.js +4 -0
  264. package/icons/vertical-align-top/index.d.ts +11 -0
  265. package/icons/vertical-align-top/index.js +4 -0
  266. package/icons/waves/index.d.ts +11 -0
  267. package/icons/waves/index.js +4 -0
  268. package/icons/weekend/index.d.ts +11 -0
  269. package/icons/weekend/index.js +4 -0
  270. package/icons/where-to-vote/index.d.ts +11 -0
  271. package/icons/where-to-vote/index.js +4 -0
  272. package/icons/wrap-text/index.d.ts +11 -0
  273. package/icons/wrap-text/index.js +4 -0
  274. package/index.d.ts +136 -0
  275. package/index.js +137 -1
  276. package/package.json +1 -1
  277. package/popover/index.js +1 -1
  278. package/search/index.js +44 -46
  279. package/search-option/index.d.ts +1 -1
  280. package/search-option/index.js +4 -4
  281. package/segment/index.d.ts +2 -1
  282. package/segment/index.js +16 -3
  283. package/segment-collapse/index.d.ts +1 -0
  284. package/segment-collapse/index.js +19 -3
  285. package/segmented-control/index.d.ts +5 -5
  286. package/segmented-control-option/index.js +1 -1
  287. package/segmented-icon-control/index.d.ts +22 -0
  288. package/segmented-icon-control/index.js +126 -0
  289. package/segmented-icon-control-option/index.d.ts +27 -0
  290. package/segmented-icon-control-option/index.js +103 -0
package/search/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$label, _$input, _selectionStart, _selectionEnd, _$optionSlot, _$listbox, _$clear, _isPendingDk, _sh, _onCompositionStart, _onInput, _onValueChange, _onClearMouseDown, _onClear, _onInputFocus, _onInputBlur, _onListboxClick, _onListboxKeyUp, _onListboxKeyDown, _onOptionSlotChange, _onExpand, _onCollapse, _setOpen, _isOpen, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _selectOption, _getOptionElements;
4
+ var _$label, _$input, _selectionStart, _selectionEnd, _$optionSlot, _$listbox, _$clear, _isPendingDk, _sh, _onCompositionStart, _onInput, _onValueChange, _onClearMouseDown, _onClear, _onInputFocus, _onInputBlur, _onListboxClick, _onListboxKeyUp, _onListboxKeyDown, _onOptionSlotChange, _onExpand, _onCollapse, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _selectOption, _findSelectedOption;
5
5
 
6
6
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
7
 
@@ -11,31 +11,20 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
11
11
 
12
12
  function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
13
13
 
14
- import { isSearchOptionElement } from '../search-option';
14
+ import { isSinchSearchOptionElement } from '../search-option';
15
15
  import { attrValueToPixels, defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, getRect, NectaryElement, updateAttribute, updateIntegerAttribute } from '../utils';
16
16
  const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:100%;box-sizing:border-box;--sinch-size-icon:24px}#label{display:none;font:var(--sinch-font-title-s);color:var(--sinch-color-text-default);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%;height:24px;margin-bottom:2px}#input{all:initial;display:block;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:4px;width:100%;height:48px;padding:0 44px;padding-right:12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto);background-color:var(--sinch-color-snow-100)}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:focus{border-color:var(--sinch-color-stormy-600)}#icon-search{position:absolute;left:12px;top:12px;pointer-events:none;--sinch-color-icon:var(--sinch-color-stormy-500)}#clear{position:absolute;right:8px;top:8px;display:none;--sinch-color-icon:red}#clear:focus{--sinch-color-icon:var(--sinch-color-stormy-500)}:host([value]:not([value=""])) #clear{display:flex}:host([value]:not([value=""])) #input{padding-right:44px}#listbox{display:none;position:absolute;z-index:1;left:0;top:calc(100% + 8px);width:100%;box-sizing:border-box;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);box-shadow:1px 2px 4px rgba(0,0,0,.15);overflow-y:auto}:host([aria-expanded=true]) #listbox{display:block}:host([label]:not([label=""])) #label{display:block}</style><label id="label" for="input"></label><div id="wrapper"><input id="input" type="text"/><sinch-icon-search id="icon-search"></sinch-icon-search><sinch-icon-button id="clear" small><sinch-icon-close id="icon-close" slot="icon"></sinch-icon-close></sinch-icon-button><div id="listbox"><slot name="option"></slot></div></div>';
17
17
  import '../icons/search';
18
18
  import '../icons/close';
19
19
  import '../icon-button';
20
20
  const ITEM_HEIGHT = 40;
21
-
22
- const findSelectedOption = elements => {
23
- for (const el of elements) {
24
- if (el.selected) {
25
- return el;
26
- }
27
- }
28
-
29
- return null;
30
- };
31
-
32
21
  const template = document.createElement('template');
33
22
  template.innerHTML = templateHTML;
34
- defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new WeakMap(), _selectionStart = new WeakMap(), _selectionEnd = new WeakMap(), _$optionSlot = new WeakMap(), _$listbox = new WeakMap(), _$clear = new WeakMap(), _isPendingDk = new WeakMap(), _sh = new WeakMap(), _onCompositionStart = new WeakMap(), _onInput = new WeakMap(), _onValueChange = new WeakSet(), _onClearMouseDown = new WeakMap(), _onClear = new WeakMap(), _onInputFocus = new WeakMap(), _onInputBlur = new WeakMap(), _onListboxClick = new WeakMap(), _onListboxKeyUp = new WeakMap(), _onListboxKeyDown = new WeakMap(), _onOptionSlotChange = new WeakMap(), _onExpand = new WeakSet(), _onCollapse = new WeakSet(), _setOpen = new WeakSet(), _isOpen = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _selectOption = new WeakSet(), _getOptionElements = new WeakSet(), class extends NectaryElement {
23
+ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new WeakMap(), _selectionStart = new WeakMap(), _selectionEnd = new WeakMap(), _$optionSlot = new WeakMap(), _$listbox = new WeakMap(), _$clear = new WeakMap(), _isPendingDk = new WeakMap(), _sh = new WeakMap(), _onCompositionStart = new WeakMap(), _onInput = new WeakMap(), _onValueChange = new WeakSet(), _onClearMouseDown = new WeakMap(), _onClear = new WeakMap(), _onInputFocus = new WeakMap(), _onInputBlur = new WeakMap(), _onListboxClick = new WeakMap(), _onListboxKeyUp = new WeakMap(), _onListboxKeyDown = new WeakMap(), _onOptionSlotChange = new WeakMap(), _onExpand = new WeakSet(), _onCollapse = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _selectOption = new WeakSet(), _findSelectedOption = new WeakSet(), class extends NectaryElement {
35
24
  constructor() {
36
25
  super();
37
26
 
38
- _classPrivateMethodInitSpec(this, _getOptionElements);
27
+ _classPrivateMethodInitSpec(this, _findSelectedOption);
39
28
 
40
29
  _classPrivateMethodInitSpec(this, _selectOption);
41
30
 
@@ -47,10 +36,6 @@ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new Weak
47
36
 
48
37
  _classPrivateMethodInitSpec(this, _getFirstOption);
49
38
 
50
- _classPrivateMethodInitSpec(this, _isOpen);
51
-
52
- _classPrivateMethodInitSpec(this, _setOpen);
53
-
54
39
  _classPrivateMethodInitSpec(this, _onCollapse);
55
40
 
56
41
  _classPrivateMethodInitSpec(this, _onExpand);
@@ -156,7 +141,7 @@ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new Weak
156
141
  e.stopPropagation();
157
142
  const $elem = e.target;
158
143
 
159
- if (isSearchOptionElement($elem)) {
144
+ if (isSinchSearchOptionElement($elem)) {
160
145
  _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, $elem.text);
161
146
  }
162
147
 
@@ -171,10 +156,11 @@ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new Weak
171
156
  case 'Enter':
172
157
  {
173
158
  e.preventDefault();
174
- const $elem = findSelectedOption(_classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this));
175
159
 
176
- if ($elem != null) {
177
- _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, $elem.text);
160
+ const $opt = _classPrivateMethodGet(this, _findSelectedOption, _findSelectedOption2).call(this);
161
+
162
+ if ($opt != null) {
163
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, $opt.text);
178
164
  }
179
165
 
180
166
  _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
@@ -191,6 +177,9 @@ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new Weak
191
177
  switch (e.code) {
192
178
  case 'ArrowUp':
193
179
  {
180
+ e.preventDefault();
181
+ e.stopPropagation();
182
+
194
183
  _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getPrevOption, _getPrevOption2).call(this));
195
184
 
196
185
  break;
@@ -198,6 +187,9 @@ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new Weak
198
187
 
199
188
  case 'ArrowDown':
200
189
  {
190
+ e.preventDefault();
191
+ e.stopPropagation();
192
+
201
193
  _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getNextOption, _getNextOption2).call(this));
202
194
 
203
195
  break;
@@ -218,9 +210,9 @@ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new Weak
218
210
  _classPrivateFieldInitSpec(this, _onOptionSlotChange, {
219
211
  writable: true,
220
212
  value: () => {
221
- const elems = _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this);
213
+ const $opts = _classPrivateFieldGet(this, _$optionSlot).assignedElements();
222
214
 
223
- if (elems.length === 0) {
215
+ if ($opts.length === 0) {
224
216
  return _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
225
217
  }
226
218
 
@@ -457,37 +449,36 @@ function _onValueChange2(nextValue) {
457
449
  }
458
450
 
459
451
  function _onExpand2() {
460
- if (!_classPrivateMethodGet(this, _isOpen, _isOpen2).call(this) && _classPrivateFieldGet(this, _sh).activeElement === _classPrivateFieldGet(this, _$input)) {
461
- _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this));
452
+ const isOpen = getBooleanAttribute(this, 'aria-expanded');
462
453
 
463
- _classPrivateMethodGet(this, _setOpen, _setOpen2).call(this, true);
464
- }
465
- }
454
+ const $opts = _classPrivateFieldGet(this, _$optionSlot).assignedElements();
466
455
 
467
- function _onCollapse2() {
468
- _classPrivateMethodGet(this, _setOpen, _setOpen2).call(this, false);
469
- }
456
+ if (!isOpen && $opts.length > 0 && _classPrivateFieldGet(this, _sh).activeElement === _classPrivateFieldGet(this, _$input)) {
457
+ const opt = _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this);
470
458
 
471
- function _setOpen2(isOpen) {
472
- this.setAttribute('aria-expanded', String(isOpen));
459
+ _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, opt);
460
+
461
+ this.setAttribute('aria-expanded', 'true');
462
+ }
473
463
  }
474
464
 
475
- function _isOpen2() {
476
- return getBooleanAttribute(this, 'aria-expanded');
465
+ function _onCollapse2() {
466
+ this.setAttribute('aria-expanded', 'false');
477
467
  }
478
468
 
479
469
  function _getFirstOption2() {
480
- return _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)[0] ?? null;
470
+ return _classPrivateFieldGet(this, _$optionSlot).assignedElements().filter(isSinchSearchOptionElement)[0] ?? null;
481
471
  }
482
472
 
483
473
  function _getLastOption2() {
484
- return _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this).reverse()[0] ?? null;
474
+ return _classPrivateFieldGet(this, _$optionSlot).assignedElements().filter(isSinchSearchOptionElement).reverse()[0] ?? null;
485
475
  }
486
476
 
487
477
  function _getNextOption2() {
488
- const $options = _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this);
478
+ const $options = _classPrivateFieldGet(this, _$optionSlot).assignedElements().filter(isSinchSearchOptionElement);
479
+
480
+ const $selectedOption = _classPrivateMethodGet(this, _findSelectedOption, _findSelectedOption2).call(this);
489
481
 
490
- const $selectedOption = findSelectedOption($options);
491
482
  const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
492
483
 
493
484
  if (currentIndex < 0) {
@@ -498,9 +489,10 @@ function _getNextOption2() {
498
489
  }
499
490
 
500
491
  function _getPrevOption2() {
501
- const $options = _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this);
492
+ const $options = _classPrivateFieldGet(this, _$optionSlot).assignedElements().filter(isSinchSearchOptionElement);
493
+
494
+ const $selectedOption = _classPrivateMethodGet(this, _findSelectedOption, _findSelectedOption2).call(this);
502
495
 
503
- const $selectedOption = findSelectedOption($options);
504
496
  const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
505
497
 
506
498
  if (currentIndex < 0) {
@@ -511,7 +503,7 @@ function _getPrevOption2() {
511
503
  }
512
504
 
513
505
  function _selectOption2($option) {
514
- for (const $op of _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)) {
506
+ for (const $op of _classPrivateFieldGet(this, _$optionSlot).assignedElements()) {
515
507
  const isSelected = $op === $option;
516
508
  $op.selected = isSelected;
517
509
 
@@ -523,6 +515,12 @@ function _selectOption2($option) {
523
515
  }
524
516
  }
525
517
 
526
- function _getOptionElements2() {
527
- return _classPrivateFieldGet(this, _$optionSlot).assignedElements().filter(isSearchOptionElement);
518
+ function _findSelectedOption2() {
519
+ for (const el of _classPrivateFieldGet(this, _$optionSlot).assignedElements()) {
520
+ if (isSinchSearchOptionElement(el) && el.selected) {
521
+ return el;
522
+ }
523
+ }
524
+
525
+ return null;
528
526
  }
@@ -1,5 +1,5 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- export declare const isSearchOptionElement: (element: EventTarget | Element | null) => element is TSinchSearchOptionElement;
2
+ export declare const isSinchSearchOptionElement: (element: EventTarget | Element | null) => element is TSinchSearchOptionElement;
3
3
  export declare type TSinchSearchOptionElement = HTMLElement & {
4
4
  text: string;
5
5
  selected: boolean;
@@ -12,7 +12,7 @@ template.innerHTML = templateHTML;
12
12
 
13
13
  var _$content = new WeakMap();
14
14
 
15
- class SearchOption extends NectaryElement {
15
+ class SinchSearchOption extends NectaryElement {
16
16
  constructor() {
17
17
  super();
18
18
 
@@ -68,7 +68,7 @@ class SearchOption extends NectaryElement {
68
68
 
69
69
  }
70
70
 
71
- defineCustomElement('sinch-search-option', SearchOption);
72
- export const isSearchOptionElement = element => {
73
- return element instanceof SearchOption;
71
+ defineCustomElement('sinch-search-option', SinchSearchOption);
72
+ export const isSinchSearchOptionElement = element => {
73
+ return element instanceof SinchSearchOption;
74
74
  };
@@ -1,7 +1,8 @@
1
- import type { TSinchElementReact } from '../types';
1
+ import type { TRect, TSinchElementReact } from '../types';
2
2
  declare type TSinchSegmentElement = HTMLElement & {
3
3
  caption: string;
4
4
  collapsed: boolean;
5
+ readonly collapseButtonRect: TRect | null;
5
6
  };
6
7
  declare type TSinchSegmentReact = TSinchElementReact<TSinchSegmentElement> & {
7
8
  caption: string;
package/segment/index.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$caption;
4
+ var _$caption, _$collapseSlot;
5
5
 
6
6
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
7
 
8
8
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
9
 
10
- import { defineCustomElement, getAttribute, getBooleanAttribute, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
10
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getRect, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
11
11
  const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;width:100%;height:100%;border-radius:4px;box-sizing:border-box;background-color:var(--sinch-color-snow-100);color:var(--sinch-color-text-default);font:var(--sinch-font-body);border:none;box-shadow:1px 2px 8px rgba(0,0,0,.1)}#header{position:relative;display:flex;flex-direction:row;align-items:center;gap:16px;height:32px;padding:24px 32px 16px;--sinch-size-icon:32px}#caption{font:var(--sinch-font-title-l);color:var(--sinch-color-text-default);flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#content-wrapper{padding:0 32px;flex:1;min-height:0;overflow:auto}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;padding:16px 32px 24px}#info{position:relative;display:flex;flex-direction:row;align-items:center;gap:16px;z-index:1}:host([collapsed]:not([collapsed=false])) :is(#content-wrapper,#action){display:none}:host([collapsed]:not([collapsed=false])) #header{padding-bottom:24px}</style><div id="wrapper"><div id="header"><slot name="icon"></slot><span id="caption"></span><div id="info"><slot name="info"></slot></div><slot name="collapse"></slot></div><div id="content-wrapper"><slot name="content"></slot></div><div id="action"><slot name="action"></slot></div></div>';
12
12
  const template = document.createElement('template');
13
13
  template.innerHTML = templateHTML;
14
- defineCustomElement('sinch-segment', (_$caption = new WeakMap(), class extends NectaryElement {
14
+ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$collapseSlot = new WeakMap(), class extends NectaryElement {
15
15
  constructor() {
16
16
  super();
17
17
 
@@ -20,10 +20,17 @@ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), class extends N
20
20
  value: void 0
21
21
  });
22
22
 
23
+ _classPrivateFieldInitSpec(this, _$collapseSlot, {
24
+ writable: true,
25
+ value: void 0
26
+ });
27
+
23
28
  const shadowRoot = this.attachShadow();
24
29
  shadowRoot.appendChild(template.content.cloneNode(true));
25
30
 
26
31
  _classPrivateFieldSet(this, _$caption, shadowRoot.querySelector('#caption'));
32
+
33
+ _classPrivateFieldSet(this, _$collapseSlot, shadowRoot.querySelector('slot[name="collapse"]'));
27
34
  }
28
35
 
29
36
  static get observedAttributes() {
@@ -56,4 +63,10 @@ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), class extends N
56
63
  return getBooleanAttribute(this, 'collapsed');
57
64
  }
58
65
 
66
+ get collapseButtonRect() {
67
+ const $collapseButton = _classPrivateFieldGet(this, _$collapseSlot).assignedElements()[0];
68
+
69
+ return $collapseButton != null ? getRect($collapseButton) : null;
70
+ }
71
+
59
72
  }));
@@ -1,5 +1,6 @@
1
1
  import '../icons/expand-less';
2
2
  import '../icons/expand-more';
3
+ import '../icon-button';
3
4
  import type { TSinchElementReact } from '../types';
4
5
  import type { FocusEvent, SyntheticEvent } from 'react';
5
6
  export declare type TSinchSegmentExpandElement = HTMLElement & {
@@ -10,8 +10,9 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
10
10
 
11
11
  import '../icons/expand-less';
12
12
  import '../icons/expand-more';
13
- import { defineCustomElement, getBooleanAttribute, NectaryElement, updateBooleanAttribute } from '../utils';
14
- const templateHTML = '<style>:host{display:contents;--sinch-size-icon:32px}button{all:initial;position:absolute;left:0;top:0;width:100%;height:100%;box-sizing:border-box;cursor:pointer}button:focus~sinch-icon-expand-less,button:focus~sinch-icon-expand-more{border-radius:4px;box-shadow:0 0 0 1px var(--sinch-color-stormy-500) inset}#up{display:block}#down{display:none}:host([value]:not([value=false])) #up{display:none}:host([value]:not([value=false])) #down{display:block}</style><button></button><sinch-icon-expand-less id="up"></sinch-icon-expand-less><sinch-icon-expand-more id="down"></sinch-icon-expand-more>';
13
+ import '../icon-button';
14
+ import { defineCustomElement, getBooleanAttribute, isAttrTrue, NectaryElement, updateBooleanAttribute } from '../utils';
15
+ const templateHTML = '<style>:host{display:block;--sinch-size-icon:32px}#up{display:block}#down{display:none}:host([value]:not([value=false])) #up{display:none}:host([value]:not([value=false])) #down{display:block}</style><sinch-icon-button id="button" small><sinch-icon-expand-less id="up" slot="icon"></sinch-icon-expand-less><sinch-icon-expand-more id="down" slot="icon"></sinch-icon-expand-more></sinch-icon-button>';
15
16
  const template = document.createElement('template');
16
17
  template.innerHTML = templateHTML;
17
18
  defineCustomElement('sinch-segment-collapse', (_$button = new WeakMap(), class extends NectaryElement {
@@ -34,11 +35,12 @@ defineCustomElement('sinch-segment-collapse', (_$button = new WeakMap(), class e
34
35
  const shadowRoot = this.attachShadow();
35
36
  shadowRoot.appendChild(template.content.cloneNode(true));
36
37
 
37
- _classPrivateFieldSet(this, _$button, shadowRoot.querySelector('button'));
38
+ _classPrivateFieldSet(this, _$button, shadowRoot.querySelector('#button'));
38
39
  }
39
40
 
40
41
  connectedCallback() {
41
42
  this.setAttribute('role', 'checkbox');
43
+ this.setAttribute('aria-checked', String(getBooleanAttribute(this, 'value')));
42
44
 
43
45
  _classPrivateFieldGet(this, _$button).addEventListener('click', this.onClick);
44
46
  }
@@ -47,6 +49,20 @@ defineCustomElement('sinch-segment-collapse', (_$button = new WeakMap(), class e
47
49
  _classPrivateFieldGet(this, _$button).removeEventListener('click', this.onClick);
48
50
  }
49
51
 
52
+ static get observedAttributes() {
53
+ return ['value'];
54
+ }
55
+
56
+ attributeChangedCallback(name, oldVal, newVal) {
57
+ switch (name) {
58
+ case 'value':
59
+ {
60
+ this.setAttribute('aria-checked', String(isAttrTrue(newVal)));
61
+ break;
62
+ }
63
+ }
64
+ }
65
+
50
66
  get type() {
51
67
  return 'text';
52
68
  }
@@ -1,20 +1,20 @@
1
1
  import type { TSinchElementReact } from '../types';
2
2
  import type { SyntheticEvent } from 'react';
3
- export declare type TSinchTabsElement = HTMLElement & {
3
+ export declare type TSinchSegmentedControlElement = HTMLElement & {
4
4
  value: string;
5
5
  };
6
- export declare type TSinchTabsReact = TSinchElementReact<TSinchTabsElement> & {
6
+ export declare type TSinchSegmentedControlReact = TSinchElementReact<TSinchSegmentedControlElement> & {
7
7
  value: string;
8
8
  'aria-label': string;
9
- onChange: (event: SyntheticEvent<TSinchTabsElement, CustomEvent<string>>) => void;
9
+ onChange: (event: SyntheticEvent<TSinchSegmentedControlElement, CustomEvent<string>>) => void;
10
10
  };
11
11
  declare global {
12
12
  namespace JSX {
13
13
  interface IntrinsicElements {
14
- 'sinch-segmented-control': TSinchTabsReact;
14
+ 'sinch-segmented-control': TSinchSegmentedControlReact;
15
15
  }
16
16
  }
17
17
  interface HTMLElementTagNameMap {
18
- 'sinch-segmented-control': TSinchTabsElement;
18
+ 'sinch-segmented-control': TSinchSegmentedControlElement;
19
19
  }
20
20
  }
@@ -7,7 +7,7 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
7
7
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
8
8
 
9
9
  import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
10
- const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;position:relative;flex-direction:row;align-items:center;gap:12px;width:100%;height:42px;padding:8px 20px;box-sizing:border-box;border:1px solid var(--sinch-color-stormy-100);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:16px}#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}#content{font:var(--sinch-font-title-s);flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host([checked]:not([checked=false])) #wrapper{border-color:var(--sinch-color-stormy-500)}:host([checked]:not([checked=false]):not(:first-child)) #wrapper::before{content:"";width:1px;background-color:var(--sinch-color-stormy-500);position:absolute;left:0;top:-1px;bottom:-1px}:host([checked]:not([checked=false]):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:focus::before{content:"";position:absolute;left:-3px;right:-3px;top:-4px;bottom:-4px;border:2px solid var(--sinch-color-aqua-400)}#button:disabled{cursor:unset}: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}: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)}</style><div id="wrapper"><slot name="icon"></slot><label for="button" id="content"></label> <button id="button"></button></div>';
10
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;position:relative;flex-direction:row;align-items:center;gap:12px;width:100%;height:42px;padding:8px 20px;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:16px}#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}#content{font:var(--sinch-font-title-s);flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host([checked]:not([checked=false])) #wrapper{border-color:var(--sinch-color-stormy-500)}:host([checked]:not([checked=false]):not(:first-child)) #wrapper::before{content:"";width:1px;background-color:var(--sinch-color-stormy-500);position:absolute;left:0;top:-1px;bottom:-1px}:host([checked]:not([checked=false]):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:focus::before{content:"";position:absolute;left:-3px;right:-3px;top:-4px;bottom:-4px;border:2px solid var(--sinch-color-aqua-400)}#button:disabled{cursor:unset}: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}: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)}</style><div id="wrapper"><slot name="icon"></slot><label for="button" id="content"></label> <button id="button"></button></div>';
11
11
  export const isSegmentedControlOptionElement = element => {
12
12
  return element instanceof Element && element.tagName === 'SINCH-SEGMENTED-CONTROL-OPTION';
13
13
  };
@@ -0,0 +1,22 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ import type { SyntheticEvent } from 'react';
3
+ export declare type TSinchSegmentedIconControlElement = HTMLElement & {
4
+ value: string;
5
+ multiple: boolean;
6
+ };
7
+ export declare type TSinchSegmentedIconControlReact = TSinchElementReact<TSinchSegmentedIconControlElement> & {
8
+ value: string;
9
+ multiple?: boolean;
10
+ 'aria-label': string;
11
+ onChange: (event: SyntheticEvent<TSinchSegmentedIconControlElement, CustomEvent<string>>) => void;
12
+ };
13
+ declare global {
14
+ namespace JSX {
15
+ interface IntrinsicElements {
16
+ 'sinch-segmented-icon-control': TSinchSegmentedIconControlReact;
17
+ }
18
+ }
19
+ interface HTMLElementTagNameMap {
20
+ 'sinch-segmented-icon-control': TSinchSegmentedIconControlElement;
21
+ }
22
+ }
@@ -0,0 +1,126 @@
1
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
2
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
3
+
4
+ var _$slot, _onSlotChange, _onOptionChange, _onValueChange;
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
+ import { isSegmentedIconControlOptionElement } from '../segmented-icon-control-option';
15
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getCSVSet, getFirstCSValue, NectaryElement, updateAttribute, updateBooleanAttribute, updateCSV } from '../utils';
16
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row}</style><div id="wrapper"><slot></slot></div>';
17
+ const template = document.createElement('template');
18
+ template.innerHTML = templateHTML;
19
+ defineCustomElement('sinch-segmented-icon-control', (_$slot = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), _onValueChange = new WeakSet(), class extends NectaryElement {
20
+ constructor() {
21
+ super();
22
+
23
+ _classPrivateMethodInitSpec(this, _onValueChange);
24
+
25
+ _classPrivateFieldInitSpec(this, _$slot, {
26
+ writable: true,
27
+ value: void 0
28
+ });
29
+
30
+ _classPrivateFieldInitSpec(this, _onSlotChange, {
31
+ writable: true,
32
+ value: () => {
33
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
34
+ }
35
+ });
36
+
37
+ _classPrivateFieldInitSpec(this, _onOptionChange, {
38
+ writable: true,
39
+ value: e => {
40
+ e.stopPropagation();
41
+
42
+ if (!isSegmentedIconControlOptionElement(e.target)) {
43
+ return;
44
+ }
45
+
46
+ const {
47
+ value,
48
+ isChecked
49
+ } = e.detail;
50
+ const result = this.multiple ? updateCSV(this.value, value, isChecked) : value;
51
+ this.dispatchEvent(new CustomEvent('change', {
52
+ detail: result,
53
+ bubbles: true
54
+ }));
55
+ }
56
+ });
57
+
58
+ const shadowRoot = this.attachShadow();
59
+ shadowRoot.appendChild(template.content.cloneNode(true));
60
+ shadowRoot.addEventListener('change', _classPrivateFieldGet(this, _onOptionChange));
61
+
62
+ _classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
63
+
64
+ _classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
65
+ }
66
+
67
+ connectedCallback() {
68
+ this.setAttribute('role', 'tablist');
69
+ }
70
+
71
+ static get observedAttributes() {
72
+ return ['value'];
73
+ }
74
+
75
+ get nodeName() {
76
+ return 'select';
77
+ }
78
+
79
+ set value(value) {
80
+ updateAttribute(this, 'value', value);
81
+ }
82
+
83
+ get value() {
84
+ return getAttribute(this, 'value', '');
85
+ }
86
+
87
+ set multiple(isMultiple) {
88
+ updateBooleanAttribute(this, 'multiple', isMultiple);
89
+ }
90
+
91
+ get multiple() {
92
+ return getBooleanAttribute(this, 'multiple');
93
+ }
94
+
95
+ attributeChangedCallback(name, oldVal, newVal) {
96
+ switch (name) {
97
+ case 'value':
98
+ {
99
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, newVal ?? '');
100
+
101
+ break;
102
+ }
103
+ }
104
+ }
105
+
106
+ }));
107
+
108
+ function _onValueChange2(csv) {
109
+ if (this.multiple) {
110
+ const values = getCSVSet(csv);
111
+
112
+ for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
113
+ if (isSegmentedIconControlOptionElement($option)) {
114
+ $option.checked = $option.disabled !== true && values.has($option.value);
115
+ }
116
+ }
117
+ } else {
118
+ const value = getFirstCSValue(csv);
119
+
120
+ for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
121
+ if (isSegmentedIconControlOptionElement($option)) {
122
+ $option.checked = $option.disabled !== true && $option.value === value;
123
+ }
124
+ }
125
+ }
126
+ }
@@ -0,0 +1,27 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ import type { FocusEvent } from 'react';
3
+ export declare const isSegmentedIconControlOptionElement: (element: EventTarget | Element | null) => element is TSinchSegmentedIconControlOptionElement;
4
+ export declare type TSinchSegmentedIconControlOptionElement = HTMLElement & {
5
+ value: string;
6
+ disabled: boolean;
7
+ checked: boolean;
8
+ focus(): void;
9
+ blur(): void;
10
+ };
11
+ export declare type TSinchSegmentedIconControlOptionReact = TSinchElementReact<TSinchSegmentedIconControlOptionElement> & {
12
+ value: string;
13
+ disabled?: boolean;
14
+ 'aria-label': string;
15
+ onFocus?: (e: FocusEvent<TSinchSegmentedIconControlOptionElement>) => void;
16
+ onBlur?: (e: FocusEvent<TSinchSegmentedIconControlOptionElement>) => void;
17
+ };
18
+ declare global {
19
+ namespace JSX {
20
+ interface IntrinsicElements {
21
+ 'sinch-segmented-icon-control-option': TSinchSegmentedIconControlOptionReact;
22
+ }
23
+ }
24
+ interface HTMLElementTagNameMap {
25
+ 'sinch-segmented-icon-control-option': TSinchSegmentedIconControlOptionElement;
26
+ }
27
+ }