@nectary/components 0.39.0 → 0.41.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 (142) hide show
  1. package/accordion/index.js +47 -84
  2. package/accordion-item/index.js +30 -53
  3. package/action-menu/index.d.ts +0 -1
  4. package/action-menu/index.js +177 -223
  5. package/action-menu/types.d.ts +8 -18
  6. package/action-menu-option/index.d.ts +1 -0
  7. package/action-menu-option/index.js +52 -62
  8. package/action-menu-option/types.d.ts +9 -0
  9. package/action-menu-option/utils.d.ts +2 -0
  10. package/action-menu-option/utils.js +3 -0
  11. package/alert/index.js +6 -20
  12. package/avatar/index.js +12 -31
  13. package/avatar-badge/index.js +8 -22
  14. package/avatar-status/index.js +1 -1
  15. package/button/index.js +46 -92
  16. package/button/types.d.ts +1 -1
  17. package/card/index.js +21 -59
  18. package/chat-avatar/index.js +8 -22
  19. package/chat-block/index.js +29 -69
  20. package/chat-bubble/index.js +6 -20
  21. package/checkbox/index.js +59 -107
  22. package/chip/index.d.ts +13 -0
  23. package/chip/index.js +140 -0
  24. package/chip/types.d.ts +37 -0
  25. package/color-menu/index.d.ts +14 -0
  26. package/color-menu/index.js +450 -0
  27. package/color-menu/types.d.ts +36 -0
  28. package/color-menu/utils.d.ts +1 -0
  29. package/color-menu/utils.js +15 -0
  30. package/color-swatch/index.d.ts +13 -0
  31. package/color-swatch/index.js +60 -0
  32. package/color-swatch/types.d.ts +11 -0
  33. package/colors.json +61 -49
  34. package/date-picker/index.js +162 -293
  35. package/dialog/index.js +70 -142
  36. package/field/index.js +44 -65
  37. package/file-drop/index.js +123 -200
  38. package/file-picker/index.d.ts +0 -1
  39. package/file-picker/index.js +55 -108
  40. package/file-status/index.js +15 -39
  41. package/help-tooltip/index.js +11 -28
  42. package/horizontal-stepper/index.js +33 -59
  43. package/horizontal-stepper-item/index.js +13 -37
  44. package/icon-button/index.d.ts +1 -0
  45. package/icon-button/index.js +51 -85
  46. package/icon-button/types.d.ts +16 -2
  47. package/icons-channel/notify/index.d.ts +11 -0
  48. package/icons-channel/notify/index.js +4 -0
  49. package/illustrations/create-illustration-class.js +1 -1
  50. package/inline-alert/index.js +29 -81
  51. package/input/index.js +117 -222
  52. package/link/index.js +51 -97
  53. package/list-item/index.js +1 -1
  54. package/package.json +12 -14
  55. package/pagination/index.js +113 -163
  56. package/pop/index.d.ts +11 -0
  57. package/pop/index.js +391 -0
  58. package/pop/types.d.ts +35 -0
  59. package/pop/utils.d.ts +7 -0
  60. package/pop/utils.js +18 -0
  61. package/popover/index.d.ts +1 -0
  62. package/popover/index.js +105 -314
  63. package/popover/types.d.ts +8 -1
  64. package/popover/utils.d.ts +5 -0
  65. package/popover/utils.js +17 -1
  66. package/progress/index.js +9 -28
  67. package/radio/index.js +103 -169
  68. package/radio-option/index.js +28 -48
  69. package/segment/index.js +49 -130
  70. package/segment-collapse/index.js +28 -49
  71. package/segmented-control/index.js +36 -73
  72. package/segmented-control-option/index.js +45 -87
  73. package/segmented-icon-control/index.js +47 -84
  74. package/segmented-icon-control-option/index.js +42 -79
  75. package/select-button/index.d.ts +13 -0
  76. package/select-button/index.js +158 -0
  77. package/select-button/types.d.ts +43 -0
  78. package/select-menu/index.d.ts +11 -0
  79. package/select-menu/index.js +345 -0
  80. package/select-menu/types.d.ts +29 -0
  81. package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
  82. package/select-menu-option/index.js +76 -0
  83. package/{select-option → select-menu-option}/types.d.ts +8 -9
  84. package/stop-events/index.js +7 -20
  85. package/table-head-cell/index.js +7 -21
  86. package/tabs/index.js +103 -165
  87. package/tabs-option/index.js +24 -44
  88. package/tag/index.d.ts +0 -1
  89. package/tag/index.js +35 -38
  90. package/tag/types.d.ts +12 -7
  91. package/textarea/index.js +96 -167
  92. package/theme.css +146 -49
  93. package/tile-control/index.js +55 -96
  94. package/tile-control-option/index.js +45 -87
  95. package/time-picker/index.js +216 -368
  96. package/title/index.js +6 -20
  97. package/toast/index.js +32 -70
  98. package/toast-manager/index.js +141 -217
  99. package/toggle/index.js +59 -107
  100. package/tooltip/index.d.ts +2 -0
  101. package/tooltip/index.js +160 -17
  102. package/tooltip/types.d.ts +13 -0
  103. package/tooltip/utils.d.ts +5 -0
  104. package/tooltip/utils.js +25 -1
  105. package/utils/animation.d.ts +17 -0
  106. package/utils/animation.js +142 -0
  107. package/utils/colors.d.ts +5 -0
  108. package/utils/colors.js +5 -0
  109. package/utils/context.d.ts +15 -0
  110. package/utils/context.js +57 -0
  111. package/{utils.d.ts → utils/index.d.ts} +15 -11
  112. package/{utils.js → utils/index.js} +104 -48
  113. package/vertical-stepper/index.js +29 -50
  114. package/vertical-stepper-item/index.js +13 -37
  115. package/dropdown/index.d.ts +0 -12
  116. package/dropdown/index.js +0 -415
  117. package/dropdown/types.d.ts +0 -32
  118. package/dropdown-checkbox-option/index.d.ts +0 -11
  119. package/dropdown-checkbox-option/index.js +0 -88
  120. package/dropdown-checkbox-option/types.d.ts +0 -15
  121. package/dropdown-radio-option/index.d.ts +0 -11
  122. package/dropdown-radio-option/index.js +0 -88
  123. package/dropdown-radio-option/types.d.ts +0 -15
  124. package/dropdown-text-option/index.js +0 -104
  125. package/dropdown-text-option/types.d.ts +0 -16
  126. package/select/index.d.ts +0 -13
  127. package/select/index.js +0 -316
  128. package/select/types.d.ts +0 -53
  129. package/select-option/index.d.ts +0 -11
  130. package/select-option/index.js +0 -8
  131. package/tag/utils.d.ts +0 -5
  132. package/tag/utils.js +0 -6
  133. package/tag-close/index.d.ts +0 -12
  134. package/tag-close/index.js +0 -42
  135. package/tag-close/types.d.ts +0 -5
  136. /package/{dropdown-checkbox-option → chip}/types.js +0 -0
  137. /package/{dropdown-radio-option → color-menu}/types.js +0 -0
  138. /package/{dropdown-text-option → color-swatch}/types.js +0 -0
  139. /package/{dropdown → pop}/types.js +0 -0
  140. /package/{select-option → select-button}/types.js +0 -0
  141. /package/{tag-close → select-menu}/types.js +0 -0
  142. /package/{select → select-menu-option}/types.js +0 -0
package/segment/index.js CHANGED
@@ -1,12 +1,3 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$caption, _$previewSlot, _$previewWrapper, _$infoSlot, _$infoWrapper, _$collapseSlot, _$collapseWrapper, _$actionSlot, _$actionWrapper, _onPreviewSlotChange, _onInfoSlotChange, _onCollapseSlotChange, _onActionSlotChange;
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 '../title';
11
2
  import { getTitleLevelFromType } from '../title/utils';
12
3
  import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getRect, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
@@ -14,131 +5,48 @@ const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-dire
14
5
  import { assertSize, sizeValues } from './utils';
15
6
  const template = document.createElement('template');
16
7
  template.innerHTML = templateHTML;
17
- defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$previewSlot = new WeakMap(), _$previewWrapper = new WeakMap(), _$infoSlot = new WeakMap(), _$infoWrapper = new WeakMap(), _$collapseSlot = new WeakMap(), _$collapseWrapper = new WeakMap(), _$actionSlot = new WeakMap(), _$actionWrapper = new WeakMap(), _onPreviewSlotChange = new WeakMap(), _onInfoSlotChange = new WeakMap(), _onCollapseSlotChange = new WeakMap(), _onActionSlotChange = new WeakMap(), class extends NectaryElement {
8
+ defineCustomElement('sinch-segment', class extends NectaryElement {
9
+ #$caption;
10
+ #$previewSlot;
11
+ #$previewWrapper;
12
+ #$infoSlot;
13
+ #$infoWrapper;
14
+ #$collapseSlot;
15
+ #$collapseWrapper;
16
+ #$actionSlot;
17
+ #$actionWrapper;
18
+
18
19
  constructor() {
19
20
  super();
20
-
21
- _classPrivateFieldInitSpec(this, _$caption, {
22
- writable: true,
23
- value: void 0
24
- });
25
-
26
- _classPrivateFieldInitSpec(this, _$previewSlot, {
27
- writable: true,
28
- value: void 0
29
- });
30
-
31
- _classPrivateFieldInitSpec(this, _$previewWrapper, {
32
- writable: true,
33
- value: void 0
34
- });
35
-
36
- _classPrivateFieldInitSpec(this, _$infoSlot, {
37
- writable: true,
38
- value: void 0
39
- });
40
-
41
- _classPrivateFieldInitSpec(this, _$infoWrapper, {
42
- writable: true,
43
- value: void 0
44
- });
45
-
46
- _classPrivateFieldInitSpec(this, _$collapseSlot, {
47
- writable: true,
48
- value: void 0
49
- });
50
-
51
- _classPrivateFieldInitSpec(this, _$collapseWrapper, {
52
- writable: true,
53
- value: void 0
54
- });
55
-
56
- _classPrivateFieldInitSpec(this, _$actionSlot, {
57
- writable: true,
58
- value: void 0
59
- });
60
-
61
- _classPrivateFieldInitSpec(this, _$actionWrapper, {
62
- writable: true,
63
- value: void 0
64
- });
65
-
66
- _classPrivateFieldInitSpec(this, _onPreviewSlotChange, {
67
- writable: true,
68
- value: () => {
69
- setClass(_classPrivateFieldGet(this, _$previewWrapper), 'empty', _classPrivateFieldGet(this, _$previewSlot).assignedElements().length === 0);
70
- }
71
- });
72
-
73
- _classPrivateFieldInitSpec(this, _onInfoSlotChange, {
74
- writable: true,
75
- value: () => {
76
- setClass(_classPrivateFieldGet(this, _$infoWrapper), 'empty', _classPrivateFieldGet(this, _$infoSlot).assignedElements().length === 0);
77
- }
78
- });
79
-
80
- _classPrivateFieldInitSpec(this, _onCollapseSlotChange, {
81
- writable: true,
82
- value: () => {
83
- setClass(_classPrivateFieldGet(this, _$collapseWrapper), 'empty', _classPrivateFieldGet(this, _$collapseSlot).assignedElements().length === 0);
84
- }
85
- });
86
-
87
- _classPrivateFieldInitSpec(this, _onActionSlotChange, {
88
- writable: true,
89
- value: () => {
90
- setClass(_classPrivateFieldGet(this, _$actionWrapper), 'empty', _classPrivateFieldGet(this, _$actionSlot).assignedElements().length === 0);
91
- }
92
- });
93
-
94
21
  const shadowRoot = this.attachShadow();
95
22
  shadowRoot.appendChild(template.content.cloneNode(true));
96
-
97
- _classPrivateFieldSet(this, _$caption, shadowRoot.querySelector('#caption'));
98
-
99
- _classPrivateFieldSet(this, _$previewSlot, shadowRoot.querySelector('slot[name="preview"]'));
100
-
101
- _classPrivateFieldSet(this, _$infoSlot, shadowRoot.querySelector('slot[name="info"]'));
102
-
103
- _classPrivateFieldSet(this, _$collapseSlot, shadowRoot.querySelector('slot[name="collapse"]'));
104
-
105
- _classPrivateFieldSet(this, _$actionSlot, shadowRoot.querySelector('slot[name="action"]'));
106
-
107
- _classPrivateFieldSet(this, _$previewWrapper, shadowRoot.querySelector('#preview'));
108
-
109
- _classPrivateFieldSet(this, _$infoWrapper, shadowRoot.querySelector('#info'));
110
-
111
- _classPrivateFieldSet(this, _$collapseWrapper, shadowRoot.querySelector('#collapse'));
112
-
113
- _classPrivateFieldSet(this, _$actionWrapper, shadowRoot.querySelector('#action'));
23
+ this.#$caption = shadowRoot.querySelector('#caption');
24
+ this.#$previewSlot = shadowRoot.querySelector('slot[name="preview"]');
25
+ this.#$infoSlot = shadowRoot.querySelector('slot[name="info"]');
26
+ this.#$collapseSlot = shadowRoot.querySelector('slot[name="collapse"]');
27
+ this.#$actionSlot = shadowRoot.querySelector('slot[name="action"]');
28
+ this.#$previewWrapper = shadowRoot.querySelector('#preview');
29
+ this.#$infoWrapper = shadowRoot.querySelector('#info');
30
+ this.#$collapseWrapper = shadowRoot.querySelector('#collapse');
31
+ this.#$actionWrapper = shadowRoot.querySelector('#action');
114
32
  }
115
33
 
116
34
  connectedCallback() {
117
- _classPrivateFieldGet(this, _$previewSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onPreviewSlotChange));
118
-
119
- _classPrivateFieldGet(this, _$infoSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onInfoSlotChange));
120
-
121
- _classPrivateFieldGet(this, _$collapseSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onCollapseSlotChange));
122
-
123
- _classPrivateFieldGet(this, _$actionSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onActionSlotChange));
124
-
125
- _classPrivateFieldGet(this, _onPreviewSlotChange).call(this);
126
-
127
- _classPrivateFieldGet(this, _onInfoSlotChange).call(this);
128
-
129
- _classPrivateFieldGet(this, _onCollapseSlotChange).call(this);
130
-
131
- _classPrivateFieldGet(this, _onActionSlotChange).call(this);
35
+ this.#$previewSlot.addEventListener('slotchange', this.#onPreviewSlotChange);
36
+ this.#$infoSlot.addEventListener('slotchange', this.#onInfoSlotChange);
37
+ this.#$collapseSlot.addEventListener('slotchange', this.#onCollapseSlotChange);
38
+ this.#$actionSlot.addEventListener('slotchange', this.#onActionSlotChange);
39
+ this.#onPreviewSlotChange();
40
+ this.#onInfoSlotChange();
41
+ this.#onCollapseSlotChange();
42
+ this.#onActionSlotChange();
132
43
  }
133
44
 
134
45
  disconnectedCallback() {
135
- _classPrivateFieldGet(this, _$previewSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onPreviewSlotChange));
136
-
137
- _classPrivateFieldGet(this, _$infoSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onInfoSlotChange));
138
-
139
- _classPrivateFieldGet(this, _$collapseSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onCollapseSlotChange));
140
-
141
- _classPrivateFieldGet(this, _$actionSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onActionSlotChange));
46
+ this.#$previewSlot.removeEventListener('slotchange', this.#onPreviewSlotChange);
47
+ this.#$infoSlot.removeEventListener('slotchange', this.#onInfoSlotChange);
48
+ this.#$collapseSlot.removeEventListener('slotchange', this.#onCollapseSlotChange);
49
+ this.#$actionSlot.removeEventListener('slotchange', this.#onActionSlotChange);
142
50
  }
143
51
 
144
52
  static get observedAttributes() {
@@ -149,7 +57,7 @@ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$previewSlot =
149
57
  switch (name) {
150
58
  case 'caption':
151
59
  {
152
- updateAttribute(_classPrivateFieldGet(this, _$caption), 'text', newVal);
60
+ updateAttribute(this.#$caption, 'text', newVal);
153
61
  break;
154
62
  }
155
63
 
@@ -162,8 +70,8 @@ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$previewSlot =
162
70
  case 'size':
163
71
  {
164
72
  assertSize(newVal);
165
- updateAttribute(_classPrivateFieldGet(this, _$caption), 'type', newVal);
166
- updateAttribute(_classPrivateFieldGet(this, _$caption), 'level', getTitleLevelFromType(newVal));
73
+ updateAttribute(this.#$caption, 'type', newVal);
74
+ updateAttribute(this.#$caption, 'level', getTitleLevelFromType(newVal));
167
75
  break;
168
76
  }
169
77
  }
@@ -194,9 +102,20 @@ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$previewSlot =
194
102
  }
195
103
 
196
104
  get collapseButtonRect() {
197
- const $collapseButton = _classPrivateFieldGet(this, _$collapseSlot).assignedElements()[0];
198
-
105
+ const $collapseButton = this.#$collapseSlot.assignedElements()[0];
199
106
  return $collapseButton != null ? getRect($collapseButton) : null;
200
107
  }
201
108
 
202
- }));
109
+ #onPreviewSlotChange = () => {
110
+ setClass(this.#$previewWrapper, 'empty', this.#$previewSlot.assignedElements().length === 0);
111
+ };
112
+ #onInfoSlotChange = () => {
113
+ setClass(this.#$infoWrapper, 'empty', this.#$infoSlot.assignedElements().length === 0);
114
+ };
115
+ #onCollapseSlotChange = () => {
116
+ setClass(this.#$collapseWrapper, 'empty', this.#$collapseSlot.assignedElements().length === 0);
117
+ };
118
+ #onActionSlotChange = () => {
119
+ setClass(this.#$actionWrapper, 'empty', this.#$actionSlot.assignedElements().length === 0);
120
+ };
121
+ });
@@ -1,12 +1,3 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$button, _onClick, _onChangeReactHandler;
5
-
6
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
-
8
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
-
10
1
  import '../icons/expand-less';
11
2
  import '../icons/expand-more';
12
3
  import '../icon-button';
@@ -14,54 +5,25 @@ import { defineCustomElement, getBooleanAttribute, getReactEventHandler, isAttrT
14
5
  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
6
  const template = document.createElement('template');
16
7
  template.innerHTML = templateHTML;
17
- defineCustomElement('sinch-segment-collapse', (_$button = new WeakMap(), _onClick = new WeakMap(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
8
+ defineCustomElement('sinch-segment-collapse', class extends NectaryElement {
9
+ #$button;
10
+
18
11
  constructor() {
19
12
  super();
20
-
21
- _classPrivateFieldInitSpec(this, _$button, {
22
- writable: true,
23
- value: void 0
24
- });
25
-
26
- _classPrivateFieldInitSpec(this, _onClick, {
27
- writable: true,
28
- value: () => {
29
- const detail = !this.value;
30
- this.dispatchEvent(new CustomEvent('change', {
31
- detail,
32
- bubbles: true
33
- }));
34
- this.dispatchEvent(new CustomEvent('-change', {
35
- detail
36
- }));
37
- }
38
- });
39
-
40
- _classPrivateFieldInitSpec(this, _onChangeReactHandler, {
41
- writable: true,
42
- value: e => {
43
- getReactEventHandler(this, 'on-change')?.(e);
44
- }
45
- });
46
-
47
13
  const shadowRoot = this.attachShadow();
48
14
  shadowRoot.appendChild(template.content.cloneNode(true));
49
-
50
- _classPrivateFieldSet(this, _$button, shadowRoot.querySelector('#button'));
15
+ this.#$button = shadowRoot.querySelector('#button');
51
16
  }
52
17
 
53
18
  connectedCallback() {
54
19
  this.setAttribute('role', 'checkbox');
55
-
56
- _classPrivateFieldGet(this, _$button).addEventListener('click', _classPrivateFieldGet(this, _onClick));
57
-
58
- this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
20
+ this.#$button.addEventListener('click', this.#onClick);
21
+ this.addEventListener('-change', this.#onChangeReactHandler);
59
22
  }
60
23
 
61
24
  disconnectedCallback() {
62
- _classPrivateFieldGet(this, _$button).removeEventListener('click', _classPrivateFieldGet(this, _onClick));
63
-
64
- this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
25
+ this.#$button.removeEventListener('click', this.#onClick);
26
+ this.removeEventListener('-change', this.#onChangeReactHandler);
65
27
  }
66
28
 
67
29
  static get observedAttributes() {
@@ -94,12 +56,29 @@ defineCustomElement('sinch-segment-collapse', (_$button = new WeakMap(), _onClic
94
56
  return getBooleanAttribute(this, 'value');
95
57
  }
96
58
 
59
+ get focusable() {
60
+ return true;
61
+ }
62
+
97
63
  focus() {
98
- _classPrivateFieldGet(this, _$button).focus();
64
+ this.#$button.focus();
99
65
  }
100
66
 
101
67
  blur() {
102
- _classPrivateFieldGet(this, _$button).blur();
68
+ this.#$button.blur();
103
69
  }
104
70
 
105
- }));
71
+ #onClick = () => {
72
+ const detail = !this.value;
73
+ this.dispatchEvent(new CustomEvent('change', {
74
+ detail,
75
+ bubbles: true
76
+ }));
77
+ this.dispatchEvent(new CustomEvent('-change', {
78
+ detail
79
+ }));
80
+ };
81
+ #onChangeReactHandler = e => {
82
+ getReactEventHandler(this, 'on-change')?.(e);
83
+ };
84
+ });
@@ -1,82 +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, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
15
2
  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>';
16
3
  const template = document.createElement('template');
17
4
  template.innerHTML = templateHTML;
18
- defineCustomElement('sinch-segmented-control', (_$slot = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), _onValueChange = new WeakSet(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
5
+ defineCustomElement('sinch-segmented-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 detail = e.detail;
41
- this.dispatchEvent(new CustomEvent('change', {
42
- detail,
43
- bubbles: true
44
- }));
45
- this.dispatchEvent(new CustomEvent('-change', {
46
- detail
47
- }));
48
- }
49
- });
50
-
51
- _classPrivateFieldInitSpec(this, _onChangeReactHandler, {
52
- writable: true,
53
- value: e => {
54
- getReactEventHandler(this, 'on-change')?.(e);
55
- }
56
- });
57
-
58
10
  const shadowRoot = this.attachShadow();
59
11
  shadowRoot.appendChild(template.content.cloneNode(true));
60
-
61
- _classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
12
+ this.#$slot = shadowRoot.querySelector('slot');
62
13
  }
63
14
 
64
15
  connectedCallback() {
65
16
  this.setAttribute('role', 'tablist');
66
-
67
- _classPrivateFieldGet(this, _$slot).addEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
68
-
69
- _classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
70
-
71
- this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
17
+ this.#$slot.addEventListener('option-change', this.#onOptionChange);
18
+ this.#$slot.addEventListener('slotchange', this.#onSlotChange);
19
+ this.addEventListener('-change', this.#onChangeReactHandler);
72
20
  }
73
21
 
74
22
  disconnectedCallback() {
75
- _classPrivateFieldGet(this, _$slot).removeEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
76
-
77
- _classPrivateFieldGet(this, _$slot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
78
-
79
- this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
23
+ this.#$slot.removeEventListener('option-change', this.#onOptionChange);
24
+ this.#$slot.removeEventListener('slotchange', this.#onSlotChange);
25
+ this.removeEventListener('-change', this.#onChangeReactHandler);
80
26
  }
81
27
 
82
28
  static get observedAttributes() {
@@ -103,18 +49,35 @@ defineCustomElement('sinch-segmented-control', (_$slot = new WeakMap(), _onSlotC
103
49
  switch (name) {
104
50
  case 'value':
105
51
  {
106
- _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, newVal);
107
-
52
+ this.#onValueChange(newVal);
108
53
  break;
109
54
  }
110
55
  }
111
56
  }
112
57
 
113
- }));
114
-
115
- function _onValueChange2(value) {
116
- for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
117
- const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
118
- updateBooleanAttribute($option, 'data-checked', isChecked);
58
+ #onSlotChange = () => {
59
+ this.#onValueChange(this.value);
60
+ };
61
+ #onOptionChange = e => {
62
+ e.stopPropagation();
63
+ const detail = e.detail;
64
+ this.dispatchEvent(new CustomEvent('change', {
65
+ detail,
66
+ bubbles: true
67
+ }));
68
+ this.dispatchEvent(new CustomEvent('-change', {
69
+ detail
70
+ }));
71
+ };
72
+
73
+ #onValueChange(value) {
74
+ for (const $option of this.#$slot.assignedElements()) {
75
+ const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
76
+ updateBooleanAttribute($option, 'data-checked', isChecked);
77
+ }
119
78
  }
120
- }
79
+
80
+ #onChangeReactHandler = e => {
81
+ getReactEventHandler(this, 'on-change')?.(e);
82
+ };
83
+ });
@@ -1,99 +1,34 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$button, _$label, _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{display:flex;position:relative;flex-direction:row;align-items:center;gap:12px;width:100%;height:32px;padding:0 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: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([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:0;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:-3px;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)}</style><div id="wrapper"><slot name="icon"></slot><label for="button" id="content"></label><button id="button"></button></div>';
2
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;position:relative;flex-direction:row;align-items:center;gap:12px;width:100%;height:32px;padding:0 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:16px}#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}#content{font:var(--sinch-font-title-s);flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}: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:0;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:-3px;right:-3px;top:-4px;bottom:-4px;border-style:solid;border-color:var(--sinch-color-border-focus);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)}</style><div id="wrapper"><slot name="icon"></slot><label for="button" id="content"></label><button id="button"></button></div>';
12
3
  const template = document.createElement('template');
13
4
  template.innerHTML = templateHTML;
14
- defineCustomElement('sinch-segmented-control-option', (_$button = new WeakMap(), _$label = new WeakMap(), _onButtonClick = new WeakMap(), _onButtonFocus = new WeakMap(), _onButtonBlur = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
5
+ defineCustomElement('sinch-segmented-control-option', class extends NectaryElement {
6
+ #$button;
7
+ #$label;
8
+
15
9
  constructor() {
16
10
  super();
17
-
18
- _classPrivateFieldInitSpec(this, _$button, {
19
- writable: true,
20
- value: void 0
21
- });
22
-
23
- _classPrivateFieldInitSpec(this, _$label, {
24
- writable: true,
25
- value: void 0
26
- });
27
-
28
- _classPrivateFieldInitSpec(this, _onButtonClick, {
29
- writable: true,
30
- value: e => {
31
- e.stopPropagation();
32
- this.dispatchEvent(new CustomEvent('option-change', {
33
- detail: this.value,
34
- bubbles: true
35
- }));
36
- }
37
- });
38
-
39
- _classPrivateFieldInitSpec(this, _onButtonFocus, {
40
- writable: true,
41
- value: () => {
42
- this.dispatchEvent(new CustomEvent('-focus'));
43
- }
44
- });
45
-
46
- _classPrivateFieldInitSpec(this, _onButtonBlur, {
47
- writable: true,
48
- value: () => {
49
- this.dispatchEvent(new CustomEvent('-blur'));
50
- }
51
- });
52
-
53
- _classPrivateFieldInitSpec(this, _onFocusReactHandler, {
54
- writable: true,
55
- value: () => {
56
- getReactEventHandler(this, 'on-focus')?.();
57
- }
58
- });
59
-
60
- _classPrivateFieldInitSpec(this, _onBlurReactHandler, {
61
- writable: true,
62
- value: () => {
63
- getReactEventHandler(this, 'on-blur')?.();
64
- }
65
- });
66
-
67
11
  const shadowRoot = this.attachShadow();
68
12
  shadowRoot.appendChild(template.content.cloneNode(true));
69
-
70
- _classPrivateFieldSet(this, _$button, shadowRoot.querySelector('#button'));
71
-
72
- _classPrivateFieldSet(this, _$label, shadowRoot.querySelector('#content'));
13
+ this.#$button = shadowRoot.querySelector('#button');
14
+ this.#$label = shadowRoot.querySelector('#content');
73
15
  }
74
16
 
75
17
  connectedCallback() {
76
18
  this.setAttribute('role', 'tab');
77
-
78
- _classPrivateFieldGet(this, _$button).addEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
79
-
80
- _classPrivateFieldGet(this, _$button).addEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
81
-
82
- _classPrivateFieldGet(this, _$button).addEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
83
-
84
- this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
85
- this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
19
+ this.#$button.addEventListener('click', this.#onButtonClick);
20
+ this.#$button.addEventListener('focus', this.#onButtonFocus);
21
+ this.#$button.addEventListener('blur', this.#onButtonBlur);
22
+ this.addEventListener('-focus', this.#onFocusReactHandler);
23
+ this.addEventListener('-blur', this.#onBlurReactHandler);
86
24
  }
87
25
 
88
26
  disconnectedCallback() {
89
- _classPrivateFieldGet(this, _$button).removeEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
90
-
91
- _classPrivateFieldGet(this, _$button).removeEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
92
-
93
- _classPrivateFieldGet(this, _$button).removeEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
94
-
95
- this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
96
- this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
27
+ this.#$button.removeEventListener('click', this.#onButtonClick);
28
+ this.#$button.removeEventListener('focus', this.#onButtonFocus);
29
+ this.#$button.removeEventListener('blur', this.#onButtonBlur);
30
+ this.removeEventListener('-focus', this.#onFocusReactHandler);
31
+ this.removeEventListener('-blur', this.#onBlurReactHandler);
97
32
  }
98
33
 
99
34
  static get observedAttributes() {
@@ -132,7 +67,7 @@ defineCustomElement('sinch-segmented-control-option', (_$button = new WeakMap(),
132
67
  switch (name) {
133
68
  case 'text':
134
69
  {
135
- _classPrivateFieldGet(this, _$label).textContent = newVal;
70
+ this.#$label.textContent = newVal;
136
71
  break;
137
72
  }
138
73
 
@@ -144,18 +79,41 @@ defineCustomElement('sinch-segmented-control-option', (_$button = new WeakMap(),
144
79
 
145
80
  case 'disabled':
146
81
  {
147
- _classPrivateFieldGet(this, _$button).disabled = isAttrTrue(newVal);
82
+ this.#$button.disabled = isAttrTrue(newVal);
148
83
  break;
149
84
  }
150
85
  }
151
86
  }
152
87
 
88
+ get focusable() {
89
+ return true;
90
+ }
91
+
153
92
  focus() {
154
- _classPrivateFieldGet(this, _$button).focus();
93
+ this.#$button.focus();
155
94
  }
156
95
 
157
96
  blur() {
158
- _classPrivateFieldGet(this, _$button).blur();
97
+ this.#$button.blur();
159
98
  }
160
99
 
161
- }));
100
+ #onButtonClick = e => {
101
+ e.stopPropagation();
102
+ this.dispatchEvent(new CustomEvent('option-change', {
103
+ detail: this.value,
104
+ bubbles: true
105
+ }));
106
+ };
107
+ #onButtonFocus = () => {
108
+ this.dispatchEvent(new CustomEvent('-focus'));
109
+ };
110
+ #onButtonBlur = () => {
111
+ this.dispatchEvent(new CustomEvent('-blur'));
112
+ };
113
+ #onFocusReactHandler = () => {
114
+ getReactEventHandler(this, 'on-focus')?.();
115
+ };
116
+ #onBlurReactHandler = () => {
117
+ getReactEventHandler(this, 'on-blur')?.();
118
+ };
119
+ });