@nectary/components 0.24.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 (295) hide show
  1. package/colors.json +2 -0
  2. package/dialog/index.js +2 -2
  3. package/icons/add/index.d.ts +11 -0
  4. package/icons/add/index.js +4 -0
  5. package/icons/add-box/index.d.ts +11 -0
  6. package/icons/add-box/index.js +4 -0
  7. package/icons/add-circle/index.d.ts +11 -0
  8. package/icons/add-circle/index.js +4 -0
  9. package/icons/add-circle-outline/index.d.ts +11 -0
  10. package/icons/add-circle-outline/index.js +4 -0
  11. package/icons/amp-stories/index.d.ts +11 -0
  12. package/icons/amp-stories/index.js +4 -0
  13. package/icons/archive/index.d.ts +11 -0
  14. package/icons/archive/index.js +4 -0
  15. package/icons/attach-file/index.d.ts +11 -0
  16. package/icons/attach-file/index.js +4 -0
  17. package/icons/attach-money/index.d.ts +11 -0
  18. package/icons/attach-money/index.js +4 -0
  19. package/icons/attribution/index.d.ts +11 -0
  20. package/icons/attribution/index.js +4 -0
  21. package/icons/backspace/index.d.ts +11 -0
  22. package/icons/backspace/index.js +4 -0
  23. package/icons/ballot/index.d.ts +11 -0
  24. package/icons/ballot/index.js +4 -0
  25. package/icons/bar-chart/index.d.ts +11 -0
  26. package/icons/bar-chart/index.js +4 -0
  27. package/icons/biotech/index.d.ts +11 -0
  28. package/icons/biotech/index.js +4 -0
  29. package/icons/block/index.d.ts +11 -0
  30. package/icons/block/index.js +4 -0
  31. package/icons/border-all/index.d.ts +11 -0
  32. package/icons/border-all/index.js +4 -0
  33. package/icons/border-bottom/index.d.ts +11 -0
  34. package/icons/border-bottom/index.js +4 -0
  35. package/icons/border-clear/index.d.ts +11 -0
  36. package/icons/border-clear/index.js +4 -0
  37. package/icons/border-horizontal/index.d.ts +11 -0
  38. package/icons/border-horizontal/index.js +4 -0
  39. package/icons/border-inner/index.d.ts +11 -0
  40. package/icons/border-inner/index.js +4 -0
  41. package/icons/border-left/index.d.ts +11 -0
  42. package/icons/border-left/index.js +4 -0
  43. package/icons/border-outer/index.d.ts +11 -0
  44. package/icons/border-outer/index.js +4 -0
  45. package/icons/border-right/index.d.ts +11 -0
  46. package/icons/border-right/index.js +4 -0
  47. package/icons/border-style/index.d.ts +11 -0
  48. package/icons/border-style/index.js +4 -0
  49. package/icons/border-top/index.d.ts +11 -0
  50. package/icons/border-top/index.js +4 -0
  51. package/icons/border-vertical/index.d.ts +11 -0
  52. package/icons/border-vertical/index.js +4 -0
  53. package/icons/bubble-chart/index.d.ts +11 -0
  54. package/icons/bubble-chart/index.js +4 -0
  55. package/icons/calculate/index.d.ts +11 -0
  56. package/icons/calculate/index.js +4 -0
  57. package/icons/clear/index.d.ts +11 -0
  58. package/icons/clear/index.js +4 -0
  59. package/icons/content-copy/index.d.ts +11 -0
  60. package/icons/content-copy/index.js +4 -0
  61. package/icons/content-cut/index.d.ts +11 -0
  62. package/icons/content-cut/index.js +4 -0
  63. package/icons/content-paste/index.d.ts +11 -0
  64. package/icons/content-paste/index.js +4 -0
  65. package/icons/delete-sweep/index.d.ts +11 -0
  66. package/icons/delete-sweep/index.js +4 -0
  67. package/icons/drafts/index.d.ts +11 -0
  68. package/icons/drafts/index.js +4 -0
  69. package/icons/drag-handle/index.d.ts +11 -0
  70. package/icons/drag-handle/index.js +4 -0
  71. package/icons/dynamic-feed/index.d.ts +11 -0
  72. package/icons/dynamic-feed/index.js +4 -0
  73. package/icons/file-copy/index.d.ts +11 -0
  74. package/icons/file-copy/index.js +4 -0
  75. package/icons/flag/index.d.ts +11 -0
  76. package/icons/flag/index.js +4 -0
  77. package/icons/font-download/index.d.ts +11 -0
  78. package/icons/font-download/index.js +4 -0
  79. package/icons/format-align-center/index.d.ts +11 -0
  80. package/icons/format-align-center/index.js +4 -0
  81. package/icons/format-align-justify/index.d.ts +11 -0
  82. package/icons/format-align-justify/index.js +4 -0
  83. package/icons/format-align-left/index.d.ts +11 -0
  84. package/icons/format-align-left/index.js +4 -0
  85. package/icons/format-align-right/index.d.ts +11 -0
  86. package/icons/format-align-right/index.js +4 -0
  87. package/icons/format-bold/index.d.ts +11 -0
  88. package/icons/format-bold/index.js +4 -0
  89. package/icons/format-clear/index.d.ts +11 -0
  90. package/icons/format-clear/index.js +4 -0
  91. package/icons/format-color-reset/index.d.ts +11 -0
  92. package/icons/format-color-reset/index.js +4 -0
  93. package/icons/format-indent-decrease/index.d.ts +11 -0
  94. package/icons/format-indent-decrease/index.js +4 -0
  95. package/icons/format-indent-increase/index.d.ts +11 -0
  96. package/icons/format-indent-increase/index.js +4 -0
  97. package/icons/format-italic/index.d.ts +11 -0
  98. package/icons/format-italic/index.js +4 -0
  99. package/icons/format-line-spacing/index.d.ts +11 -0
  100. package/icons/format-line-spacing/index.js +4 -0
  101. package/icons/format-list-bulleted/index.d.ts +11 -0
  102. package/icons/format-list-bulleted/index.js +4 -0
  103. package/icons/format-list-numbered/index.d.ts +11 -0
  104. package/icons/format-list-numbered/index.js +4 -0
  105. package/icons/format-list-numbered-rtl/index.d.ts +11 -0
  106. package/icons/format-list-numbered-rtl/index.js +4 -0
  107. package/icons/format-paint/index.d.ts +11 -0
  108. package/icons/format-paint/index.js +4 -0
  109. package/icons/format-quote/index.d.ts +11 -0
  110. package/icons/format-quote/index.js +4 -0
  111. package/icons/format-shapes/index.d.ts +11 -0
  112. package/icons/format-shapes/index.js +4 -0
  113. package/icons/format-size/index.d.ts +11 -0
  114. package/icons/format-size/index.js +4 -0
  115. package/icons/format-strikethrough/index.d.ts +11 -0
  116. package/icons/format-strikethrough/index.js +4 -0
  117. package/icons/format-textdirection-l-to-r/index.d.ts +11 -0
  118. package/icons/format-textdirection-l-to-r/index.js +4 -0
  119. package/icons/format-textdirection-r-to-l/index.d.ts +11 -0
  120. package/icons/format-textdirection-r-to-l/index.js +4 -0
  121. package/icons/format-underlined/index.d.ts +11 -0
  122. package/icons/format-underlined/index.js +4 -0
  123. package/icons/forward/index.d.ts +11 -0
  124. package/icons/forward/index.js +4 -0
  125. package/icons/functions/index.d.ts +11 -0
  126. package/icons/functions/index.js +4 -0
  127. package/icons/gesture/index.d.ts +11 -0
  128. package/icons/gesture/index.js +4 -0
  129. package/icons/height/index.d.ts +11 -0
  130. package/icons/height/index.js +4 -0
  131. package/icons/highlight/index.d.ts +11 -0
  132. package/icons/highlight/index.js +4 -0
  133. package/icons/horizontal-rule/index.d.ts +11 -0
  134. package/icons/horizontal-rule/index.js +4 -0
  135. package/icons/how-to-reg/index.d.ts +11 -0
  136. package/icons/how-to-reg/index.js +4 -0
  137. package/icons/how-to-vote/index.d.ts +11 -0
  138. package/icons/how-to-vote/index.js +4 -0
  139. package/icons/inbox/index.d.ts +11 -0
  140. package/icons/inbox/index.js +4 -0
  141. package/icons/insert-chart/index.d.ts +11 -0
  142. package/icons/insert-chart/index.js +4 -0
  143. package/icons/insert-chart-outlined/index.d.ts +11 -0
  144. package/icons/insert-chart-outlined/index.js +4 -0
  145. package/icons/insert-comment/index.d.ts +11 -0
  146. package/icons/insert-comment/index.js +4 -0
  147. package/icons/insert-drive-file/index.d.ts +11 -0
  148. package/icons/insert-drive-file/index.js +4 -0
  149. package/icons/insert-emoticon/index.js +1 -1
  150. package/icons/insert-invitation/index.d.ts +11 -0
  151. package/icons/insert-invitation/index.js +4 -0
  152. package/icons/insert-link/index.d.ts +11 -0
  153. package/icons/insert-link/index.js +4 -0
  154. package/icons/insert-photo/index.d.ts +11 -0
  155. package/icons/insert-photo/index.js +4 -0
  156. package/icons/insights/index.d.ts +11 -0
  157. package/icons/insights/index.js +4 -0
  158. package/icons/linear-scale/index.d.ts +11 -0
  159. package/icons/linear-scale/index.js +4 -0
  160. package/icons/link/index.d.ts +11 -0
  161. package/icons/link/index.js +4 -0
  162. package/icons/link-off/index.d.ts +11 -0
  163. package/icons/link-off/index.js +4 -0
  164. package/icons/low-priority/index.d.ts +11 -0
  165. package/icons/low-priority/index.js +4 -0
  166. package/icons/mail/index.d.ts +11 -0
  167. package/icons/mail/index.js +4 -0
  168. package/icons/markunread/index.d.ts +11 -0
  169. package/icons/markunread/index.js +4 -0
  170. package/icons/merge-type/index.d.ts +11 -0
  171. package/icons/merge-type/index.js +4 -0
  172. package/icons/mode/index.d.ts +11 -0
  173. package/icons/mode/index.js +4 -0
  174. package/icons/mode-comment/index.d.ts +11 -0
  175. package/icons/mode-comment/index.js +4 -0
  176. package/icons/monetization-on/index.d.ts +11 -0
  177. package/icons/monetization-on/index.js +4 -0
  178. package/icons/money-off/index.d.ts +11 -0
  179. package/icons/money-off/index.js +4 -0
  180. package/icons/money-off-csred/index.d.ts +11 -0
  181. package/icons/money-off-csred/index.js +4 -0
  182. package/icons/move-to-inbox/index.d.ts +11 -0
  183. package/icons/move-to-inbox/index.js +4 -0
  184. package/icons/multiline-chart/index.d.ts +11 -0
  185. package/icons/multiline-chart/index.js +4 -0
  186. package/icons/next-week/index.d.ts +11 -0
  187. package/icons/next-week/index.js +4 -0
  188. package/icons/notes/index.js +1 -1
  189. package/icons/outlined-flag/index.d.ts +11 -0
  190. package/icons/outlined-flag/index.js +4 -0
  191. package/icons/pie-chart/index.d.ts +11 -0
  192. package/icons/pie-chart/index.js +4 -0
  193. package/icons/pie-chart-outline/index.d.ts +11 -0
  194. package/icons/pie-chart-outline/index.js +4 -0
  195. package/icons/policy/index.d.ts +11 -0
  196. package/icons/policy/index.js +4 -0
  197. package/icons/post-add/index.d.ts +11 -0
  198. package/icons/post-add/index.js +4 -0
  199. package/icons/publish/index.d.ts +11 -0
  200. package/icons/publish/index.js +4 -0
  201. package/icons/push-pin/index.d.ts +11 -0
  202. package/icons/push-pin/index.js +4 -0
  203. package/icons/redo/index.d.ts +11 -0
  204. package/icons/redo/index.js +4 -0
  205. package/icons/remove/index.d.ts +11 -0
  206. package/icons/remove/index.js +4 -0
  207. package/icons/remove-circle/index.d.ts +11 -0
  208. package/icons/remove-circle/index.js +4 -0
  209. package/icons/remove-circle-outline/index.d.ts +11 -0
  210. package/icons/remove-circle-outline/index.js +4 -0
  211. package/icons/reply-all/index.d.ts +11 -0
  212. package/icons/reply-all/index.js +4 -0
  213. package/icons/report/index.d.ts +11 -0
  214. package/icons/report/index.js +4 -0
  215. package/icons/report-off/index.d.ts +11 -0
  216. package/icons/report-off/index.js +4 -0
  217. package/icons/report-outline/index.d.ts +11 -0
  218. package/icons/report-outline/index.js +4 -0
  219. package/icons/save/index.d.ts +11 -0
  220. package/icons/save/index.js +4 -0
  221. package/icons/save-alt/index.d.ts +11 -0
  222. package/icons/save-alt/index.js +4 -0
  223. package/icons/scatter-plot/index.d.ts +11 -0
  224. package/icons/scatter-plot/index.js +4 -0
  225. package/icons/score/index.d.ts +11 -0
  226. package/icons/score/index.js +4 -0
  227. package/icons/select-all/index.d.ts +11 -0
  228. package/icons/select-all/index.js +4 -0
  229. package/icons/short-text/index.d.ts +11 -0
  230. package/icons/short-text/index.js +4 -0
  231. package/icons/show-chart/index.d.ts +11 -0
  232. package/icons/show-chart/index.js +4 -0
  233. package/icons/smart-toy/index.d.ts +11 -0
  234. package/icons/smart-toy/index.js +4 -0
  235. package/icons/sort/index.d.ts +11 -0
  236. package/icons/sort/index.js +4 -0
  237. package/icons/space-bar/index.d.ts +11 -0
  238. package/icons/space-bar/index.js +4 -0
  239. package/icons/square-foot/index.d.ts +11 -0
  240. package/icons/square-foot/index.js +4 -0
  241. package/icons/stacked-line-chart/index.d.ts +11 -0
  242. package/icons/stacked-line-chart/index.js +4 -0
  243. package/icons/strikethrough-s/index.d.ts +11 -0
  244. package/icons/strikethrough-s/index.js +4 -0
  245. package/icons/subscript/index.d.ts +11 -0
  246. package/icons/subscript/index.js +4 -0
  247. package/icons/superscript/index.d.ts +11 -0
  248. package/icons/superscript/index.js +4 -0
  249. package/icons/table-chart/index.d.ts +11 -0
  250. package/icons/table-chart/index.js +4 -0
  251. package/icons/table-rows/index.d.ts +11 -0
  252. package/icons/table-rows/index.js +4 -0
  253. package/icons/text-fields/index.d.ts +11 -0
  254. package/icons/text-fields/index.js +4 -0
  255. package/icons/text-format/index.d.ts +11 -0
  256. package/icons/text-format/index.js +4 -0
  257. package/icons/title/index.d.ts +11 -0
  258. package/icons/title/index.js +4 -0
  259. package/icons/unarchive/index.d.ts +11 -0
  260. package/icons/unarchive/index.js +4 -0
  261. package/icons/vertical-align-bottom/index.d.ts +11 -0
  262. package/icons/vertical-align-bottom/index.js +4 -0
  263. package/icons/vertical-align-center/index.d.ts +11 -0
  264. package/icons/vertical-align-center/index.js +4 -0
  265. package/icons/vertical-align-top/index.d.ts +11 -0
  266. package/icons/vertical-align-top/index.js +4 -0
  267. package/icons/waves/index.d.ts +11 -0
  268. package/icons/waves/index.js +4 -0
  269. package/icons/weekend/index.d.ts +11 -0
  270. package/icons/weekend/index.js +4 -0
  271. package/icons/where-to-vote/index.d.ts +11 -0
  272. package/icons/where-to-vote/index.js +4 -0
  273. package/icons/wrap-text/index.d.ts +11 -0
  274. package/icons/wrap-text/index.js +4 -0
  275. package/index.d.ts +137 -0
  276. package/index.js +138 -1
  277. package/package.json +3 -5
  278. package/popover/index.js +1 -1
  279. package/search/index.js +55 -42
  280. package/search-option/index.d.ts +1 -1
  281. package/search-option/index.js +4 -4
  282. package/segment/index.d.ts +2 -1
  283. package/segment/index.js +16 -3
  284. package/segment-collapse/index.d.ts +1 -0
  285. package/segment-collapse/index.js +23 -25
  286. package/segmented-control/index.d.ts +20 -0
  287. package/segmented-control/index.js +208 -0
  288. package/segmented-control-option/index.d.ts +29 -0
  289. package/segmented-control-option/index.js +112 -0
  290. package/segmented-icon-control/index.d.ts +22 -0
  291. package/segmented-icon-control/index.js +126 -0
  292. package/segmented-icon-control-option/index.d.ts +27 -0
  293. package/segmented-icon-control-option/index.js +103 -0
  294. package/tabs/index.js +1 -1
  295. package/tabs-option/index.js +10 -26
@@ -0,0 +1,208 @@
1
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
2
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
3
+
4
+ var _$slot, _onOptionKeyDown, _onSlotChange, _onOptionChange, _onValueChange, _dispatchChangeEvent, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _getEnabledRadioElements;
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 { isSegmentedControlOptionElement } from '../segmented-control-option';
15
+ import { defineCustomElement, getAttribute, NectaryElement, updateAttribute } from '../utils';
16
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row;width:100%;box-sizing:border-box}</style><div id="wrapper"><slot></slot></div>';
17
+
18
+ const findSelectedOption = elements => {
19
+ return elements.find(el => el.checked) ?? null;
20
+ };
21
+
22
+ const template = document.createElement('template');
23
+ template.innerHTML = templateHTML;
24
+ defineCustomElement('sinch-segmented-control', (_$slot = new WeakMap(), _onOptionKeyDown = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), _onValueChange = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _getEnabledRadioElements = new WeakSet(), class extends NectaryElement {
25
+ constructor() {
26
+ super();
27
+
28
+ _classPrivateMethodInitSpec(this, _getEnabledRadioElements);
29
+
30
+ _classPrivateMethodInitSpec(this, _getPrevOption);
31
+
32
+ _classPrivateMethodInitSpec(this, _getNextOption);
33
+
34
+ _classPrivateMethodInitSpec(this, _getLastOption);
35
+
36
+ _classPrivateMethodInitSpec(this, _getFirstOption);
37
+
38
+ _classPrivateMethodInitSpec(this, _dispatchChangeEvent);
39
+
40
+ _classPrivateMethodInitSpec(this, _onValueChange);
41
+
42
+ _classPrivateFieldInitSpec(this, _$slot, {
43
+ writable: true,
44
+ value: void 0
45
+ });
46
+
47
+ _classPrivateFieldInitSpec(this, _onOptionKeyDown, {
48
+ writable: true,
49
+ value: e => {
50
+ switch (e.code) {
51
+ case 'ArrowUp':
52
+ case 'ArrowLeft':
53
+ {
54
+ e.preventDefault();
55
+
56
+ const $option = _classPrivateMethodGet(this, _getPrevOption, _getPrevOption2).call(this);
57
+
58
+ if ($option !== null) {
59
+ $option.focus();
60
+
61
+ _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, $option.value);
62
+ }
63
+
64
+ break;
65
+ }
66
+
67
+ case 'ArrowDown':
68
+ case 'ArrowRight':
69
+ {
70
+ e.preventDefault();
71
+
72
+ const $option = _classPrivateMethodGet(this, _getNextOption, _getNextOption2).call(this);
73
+
74
+ if ($option !== null) {
75
+ $option.focus();
76
+
77
+ _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, $option.value);
78
+ }
79
+
80
+ break;
81
+ }
82
+ }
83
+ }
84
+ });
85
+
86
+ _classPrivateFieldInitSpec(this, _onSlotChange, {
87
+ writable: true,
88
+ value: () => {
89
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
90
+ }
91
+ });
92
+
93
+ _classPrivateFieldInitSpec(this, _onOptionChange, {
94
+ writable: true,
95
+ value: e => {
96
+ e.stopPropagation();
97
+
98
+ _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, e.detail);
99
+ }
100
+ });
101
+
102
+ const shadowRoot = this.attachShadow();
103
+ shadowRoot.appendChild(template.content.cloneNode(true));
104
+ shadowRoot.addEventListener('keydown', _classPrivateFieldGet(this, _onOptionKeyDown));
105
+ shadowRoot.addEventListener('change', _classPrivateFieldGet(this, _onOptionChange));
106
+
107
+ _classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
108
+
109
+ _classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
110
+ }
111
+
112
+ connectedCallback() {
113
+ this.setAttribute('role', 'tablist');
114
+ }
115
+
116
+ static get observedAttributes() {
117
+ return ['value'];
118
+ }
119
+
120
+ get nodeName() {
121
+ return 'select';
122
+ }
123
+
124
+ set value(value) {
125
+ updateAttribute(this, 'value', value);
126
+ }
127
+
128
+ get value() {
129
+ return getAttribute(this, 'value', '');
130
+ }
131
+
132
+ attributeChangedCallback(name, oldVal, newVal) {
133
+ switch (name) {
134
+ case 'value':
135
+ {
136
+ _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, newVal);
137
+
138
+ break;
139
+ }
140
+ }
141
+ }
142
+
143
+ }));
144
+
145
+ function _onValueChange2(value) {
146
+ for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
147
+ if (isSegmentedControlOptionElement($option)) {
148
+ $option.checked = $option.disabled !== true && $option.value === value;
149
+ }
150
+ }
151
+ }
152
+
153
+ function _dispatchChangeEvent2(value) {
154
+ this.dispatchEvent(new CustomEvent('change', {
155
+ detail: value,
156
+ bubbles: true
157
+ }));
158
+ }
159
+
160
+ function _getFirstOption2() {
161
+ for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
162
+ if (isSegmentedControlOptionElement($option) && $option.disabled !== true) {
163
+ return $option;
164
+ }
165
+ }
166
+
167
+ return null;
168
+ }
169
+
170
+ function _getLastOption2() {
171
+ for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements().reverse()) {
172
+ if (isSegmentedControlOptionElement($option) && $option.disabled !== true) {
173
+ return $option;
174
+ }
175
+ }
176
+
177
+ return null;
178
+ }
179
+
180
+ function _getNextOption2() {
181
+ const $options = _classPrivateMethodGet(this, _getEnabledRadioElements, _getEnabledRadioElements2).call(this);
182
+
183
+ const $selectedOption = findSelectedOption($options);
184
+ const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
185
+
186
+ if (currentIndex < 0) {
187
+ return _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this);
188
+ }
189
+
190
+ return $options[(currentIndex + 1) % $options.length];
191
+ }
192
+
193
+ function _getPrevOption2() {
194
+ const $options = _classPrivateMethodGet(this, _getEnabledRadioElements, _getEnabledRadioElements2).call(this);
195
+
196
+ const $selectedOption = findSelectedOption($options);
197
+ const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
198
+
199
+ if (currentIndex < 0) {
200
+ return _classPrivateMethodGet(this, _getLastOption, _getLastOption2).call(this);
201
+ }
202
+
203
+ return $options[(currentIndex - 1 + $options.length) % $options.length];
204
+ }
205
+
206
+ function _getEnabledRadioElements2() {
207
+ return _classPrivateFieldGet(this, _$slot).assignedElements().filter(opt => isSegmentedControlOptionElement(opt) && opt.disabled !== true);
208
+ }
@@ -0,0 +1,29 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ import type { FocusEvent } from 'react';
3
+ export declare const isSegmentedControlOptionElement: (element: EventTarget | Element | null) => element is TSinchSegmentedControlOptionElement;
4
+ export declare type TSinchSegmentedControlOptionElement = HTMLElement & {
5
+ value: string;
6
+ disabled: boolean;
7
+ checked: boolean;
8
+ text: string;
9
+ focus(): void;
10
+ blur(): void;
11
+ };
12
+ export declare type TSinchSegmentedControlOptionReact = TSinchElementReact<TSinchSegmentedControlOptionElement> & {
13
+ value: string;
14
+ disabled?: boolean;
15
+ text: string;
16
+ 'aria-label': string;
17
+ onFocus?: (e: FocusEvent<TSinchSegmentedControlOptionElement>) => void;
18
+ onBlur?: (e: FocusEvent<TSinchSegmentedControlOptionElement>) => void;
19
+ };
20
+ declare global {
21
+ namespace JSX {
22
+ interface IntrinsicElements {
23
+ 'sinch-segmented-control-option': TSinchSegmentedControlOptionReact;
24
+ }
25
+ }
26
+ interface HTMLElementTagNameMap {
27
+ 'sinch-segmented-control-option': TSinchSegmentedControlOptionElement;
28
+ }
29
+ }
@@ -0,0 +1,112 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+
3
+ var _onClick;
4
+
5
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
6
+
7
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
8
+
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-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
+ export const isSegmentedControlOptionElement = element => {
12
+ return element instanceof Element && element.tagName === 'SINCH-SEGMENTED-CONTROL-OPTION';
13
+ };
14
+ const template = document.createElement('template');
15
+ template.innerHTML = templateHTML;
16
+ defineCustomElement('sinch-segmented-control-option', (_onClick = new WeakMap(), class extends NectaryElement {
17
+ constructor() {
18
+ super();
19
+
20
+ _classPrivateFieldInitSpec(this, _onClick, {
21
+ writable: true,
22
+ value: e => {
23
+ e.stopPropagation();
24
+ this.dispatchEvent(new CustomEvent('change', {
25
+ bubbles: true,
26
+ detail: this.value
27
+ }));
28
+ }
29
+ });
30
+
31
+ const shadowRoot = this.attachShadow();
32
+ shadowRoot.appendChild(template.content.cloneNode(true));
33
+ this.$button = shadowRoot.querySelector('#button');
34
+ this.$label = shadowRoot.querySelector('#content');
35
+ }
36
+
37
+ connectedCallback() {
38
+ this.setAttribute('role', 'tab');
39
+ this.$button.addEventListener('click', _classPrivateFieldGet(this, _onClick));
40
+ }
41
+
42
+ disconnectedCallback() {
43
+ this.$button.removeEventListener('click', _classPrivateFieldGet(this, _onClick));
44
+ }
45
+
46
+ static get observedAttributes() {
47
+ return ['checked', 'disabled', 'text', 'value'];
48
+ }
49
+
50
+ set checked(isChecked) {
51
+ updateBooleanAttribute(this, 'checked', isChecked);
52
+ }
53
+
54
+ get checked() {
55
+ return getBooleanAttribute(this, 'checked');
56
+ }
57
+
58
+ set value(value) {
59
+ updateAttribute(this, 'value', value);
60
+ }
61
+
62
+ get value() {
63
+ return getAttribute(this, 'value', '');
64
+ }
65
+
66
+ set disabled(isDisabled) {
67
+ updateBooleanAttribute(this, 'disabled', isDisabled);
68
+ }
69
+
70
+ get disabled() {
71
+ return getBooleanAttribute(this, 'disabled');
72
+ }
73
+
74
+ set text(value) {
75
+ updateAttribute(this, 'text', value);
76
+ }
77
+
78
+ get text() {
79
+ return getAttribute(this, 'text', '');
80
+ }
81
+
82
+ attributeChangedCallback(name, _, newVal) {
83
+ switch (name) {
84
+ case 'text':
85
+ {
86
+ this.$label.textContent = newVal;
87
+ break;
88
+ }
89
+
90
+ case 'checked':
91
+ {
92
+ updateAttribute(this, 'aria-selected', isAttrTrue(newVal));
93
+ break;
94
+ }
95
+
96
+ case 'disabled':
97
+ {
98
+ this.$button.disabled = isAttrTrue(newVal);
99
+ break;
100
+ }
101
+ }
102
+ }
103
+
104
+ focus() {
105
+ this.$button.focus();
106
+ }
107
+
108
+ blur() {
109
+ this.$button.blur();
110
+ }
111
+
112
+ }));
@@ -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
+ }
@@ -0,0 +1,103 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+
3
+ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
4
+
5
+ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
6
+
7
+ import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
8
+ 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([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:-1px;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:-4px;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)}::slotted(*){display:block}</style><div id="wrapper"><slot name="icon"></slot><button id="button"></button></div>';
9
+ const template = document.createElement('template');
10
+ template.innerHTML = templateHTML;
11
+
12
+ var _onClick = new WeakMap();
13
+
14
+ class SinchSegmentedIconControlOption extends NectaryElement {
15
+ constructor() {
16
+ super();
17
+
18
+ _classPrivateFieldInitSpec(this, _onClick, {
19
+ writable: true,
20
+ value: e => {
21
+ e.stopPropagation();
22
+ this.dispatchEvent(new CustomEvent('change', {
23
+ bubbles: true,
24
+ detail: {
25
+ value: this.value,
26
+ isChecked: !this.checked
27
+ }
28
+ }));
29
+ }
30
+ });
31
+
32
+ const shadowRoot = this.attachShadow();
33
+ shadowRoot.appendChild(template.content.cloneNode(true));
34
+ this.$button = shadowRoot.querySelector('#button');
35
+ }
36
+
37
+ connectedCallback() {
38
+ this.setAttribute('role', 'tab');
39
+ this.$button.addEventListener('click', _classPrivateFieldGet(this, _onClick));
40
+ }
41
+
42
+ disconnectedCallback() {
43
+ this.$button.removeEventListener('click', _classPrivateFieldGet(this, _onClick));
44
+ }
45
+
46
+ static get observedAttributes() {
47
+ return ['checked', 'disabled', 'value'];
48
+ }
49
+
50
+ set checked(isChecked) {
51
+ updateBooleanAttribute(this, 'checked', isChecked);
52
+ }
53
+
54
+ get checked() {
55
+ return getBooleanAttribute(this, 'checked');
56
+ }
57
+
58
+ set value(value) {
59
+ updateAttribute(this, 'value', value);
60
+ }
61
+
62
+ get value() {
63
+ return getAttribute(this, 'value', '');
64
+ }
65
+
66
+ set disabled(isDisabled) {
67
+ updateBooleanAttribute(this, 'disabled', isDisabled);
68
+ }
69
+
70
+ get disabled() {
71
+ return getBooleanAttribute(this, 'disabled');
72
+ }
73
+
74
+ attributeChangedCallback(name, _, newVal) {
75
+ switch (name) {
76
+ case 'checked':
77
+ {
78
+ updateAttribute(this, 'aria-selected', isAttrTrue(newVal));
79
+ break;
80
+ }
81
+
82
+ case 'disabled':
83
+ {
84
+ this.$button.disabled = isAttrTrue(newVal);
85
+ break;
86
+ }
87
+ }
88
+ }
89
+
90
+ focus() {
91
+ this.$button.focus();
92
+ }
93
+
94
+ blur() {
95
+ this.$button.blur();
96
+ }
97
+
98
+ }
99
+
100
+ defineCustomElement('sinch-segmented-icon-control-option', SinchSegmentedIconControlOption);
101
+ export const isSegmentedIconControlOptionElement = element => {
102
+ return element instanceof SinchSegmentedIconControlOption;
103
+ };
package/tabs/index.js CHANGED
@@ -13,7 +13,7 @@ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(
13
13
 
14
14
  import { isTabsOptionElement } from '../tabs-option';
15
15
  import { defineCustomElement, getAttribute, NectaryElement, updateAttribute } from '../utils';
16
- const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row;height:60px;width:100%;box-sizing:border-box;overflow-x:auto}</style><div id="wrapper"><slot></slot></div>';
16
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row;height:44px;width:100%;box-sizing:border-box}</style><div id="wrapper"><slot></slot></div>';
17
17
 
18
18
  const findSelectedOption = elements => {
19
19
  return elements.find(el => el.checked) ?? null;