@nectary/components 0.39.0 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/accordion/index.js +47 -84
  2. package/accordion-item/index.js +26 -53
  3. package/action-menu/index.d.ts +0 -1
  4. package/action-menu/index.js +179 -223
  5. package/action-menu/types.d.ts +8 -18
  6. package/action-menu-option/index.d.ts +1 -0
  7. package/action-menu-option/index.js +51 -62
  8. package/action-menu-option/types.d.ts +9 -0
  9. package/action-menu-option/utils.d.ts +2 -0
  10. package/action-menu-option/utils.js +3 -0
  11. package/alert/index.js +6 -20
  12. package/avatar/index.js +12 -31
  13. package/avatar-badge/index.js +8 -22
  14. package/avatar-status/index.js +1 -1
  15. package/button/index.js +42 -92
  16. package/card/index.js +21 -59
  17. package/chat-avatar/index.js +8 -22
  18. package/chat-block/index.js +29 -69
  19. package/chat-bubble/index.js +6 -20
  20. package/checkbox/index.js +55 -107
  21. package/chip/index.d.ts +13 -0
  22. package/chip/index.js +137 -0
  23. package/chip/types.d.ts +38 -0
  24. package/color-menu/index.d.ts +13 -0
  25. package/color-menu/index.js +464 -0
  26. package/color-menu/types.d.ts +37 -0
  27. package/color-swatch/index.d.ts +13 -0
  28. package/color-swatch/index.js +59 -0
  29. package/color-swatch/types.d.ts +12 -0
  30. package/colors.json +57 -49
  31. package/date-picker/index.js +161 -292
  32. package/dialog/index.js +70 -142
  33. package/dropdown-checkbox-option/index.js +6 -20
  34. package/dropdown-radio-option/index.js +6 -20
  35. package/field/index.js +25 -63
  36. package/file-drop/index.js +123 -200
  37. package/file-picker/index.d.ts +0 -1
  38. package/file-picker/index.js +55 -108
  39. package/file-status/index.js +15 -39
  40. package/help-tooltip/index.js +1 -1
  41. package/horizontal-stepper/index.js +33 -59
  42. package/horizontal-stepper-item/index.js +13 -37
  43. package/icon-button/index.js +39 -84
  44. package/icons-channel/notify/index.d.ts +11 -0
  45. package/icons-channel/notify/index.js +4 -0
  46. package/illustrations/create-illustration-class.js +1 -1
  47. package/inline-alert/index.js +29 -81
  48. package/input/index.js +113 -222
  49. package/link/index.js +46 -96
  50. package/list-item/index.js +1 -1
  51. package/package.json +12 -14
  52. package/pagination/index.js +109 -163
  53. package/popover/index.js +224 -294
  54. package/progress/index.js +9 -28
  55. package/radio/index.js +103 -169
  56. package/radio-option/index.js +24 -48
  57. package/segment/index.js +49 -130
  58. package/segment-collapse/index.js +24 -49
  59. package/segmented-control/index.js +36 -73
  60. package/segmented-control-option/index.js +41 -87
  61. package/segmented-icon-control/index.js +47 -84
  62. package/segmented-icon-control-option/index.js +38 -79
  63. package/select-button/index.d.ts +13 -0
  64. package/select-button/index.js +153 -0
  65. package/select-button/types.d.ts +43 -0
  66. package/select-menu/index.d.ts +11 -0
  67. package/select-menu/index.js +346 -0
  68. package/select-menu/types.d.ts +29 -0
  69. package/select-menu/types.js +1 -0
  70. package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
  71. package/select-menu-option/index.js +76 -0
  72. package/{select-option → select-menu-option}/types.d.ts +8 -9
  73. package/stop-events/index.js +7 -20
  74. package/table-head-cell/index.js +7 -21
  75. package/tabs/index.js +103 -165
  76. package/tabs-option/index.js +20 -44
  77. package/tag/index.d.ts +0 -1
  78. package/tag/index.js +37 -38
  79. package/tag/types.d.ts +13 -7
  80. package/textarea/index.js +92 -167
  81. package/theme.css +80 -49
  82. package/tile-control/index.js +55 -96
  83. package/tile-control-option/index.js +40 -86
  84. package/time-picker/index.js +216 -368
  85. package/title/index.js +6 -20
  86. package/toast/index.js +32 -70
  87. package/toast-manager/index.js +141 -217
  88. package/toggle/index.js +54 -106
  89. package/types.d.ts +7 -0
  90. package/utils/colors.d.ts +10 -0
  91. package/utils/colors.js +121 -0
  92. package/{utils.d.ts → utils/index.d.ts} +17 -9
  93. package/{utils.js → utils/index.js} +96 -39
  94. package/vertical-stepper/index.js +29 -50
  95. package/vertical-stepper-item/index.js +13 -37
  96. package/dropdown/index.d.ts +0 -12
  97. package/dropdown/index.js +0 -415
  98. package/dropdown/types.d.ts +0 -32
  99. package/dropdown-text-option/index.js +0 -104
  100. package/dropdown-text-option/types.d.ts +0 -16
  101. package/select/index.d.ts +0 -13
  102. package/select/index.js +0 -316
  103. package/select/types.d.ts +0 -53
  104. package/select-option/index.d.ts +0 -11
  105. package/select-option/index.js +0 -8
  106. package/tag/utils.d.ts +0 -5
  107. package/tag/utils.js +0 -6
  108. package/tag-close/index.d.ts +0 -12
  109. package/tag-close/index.js +0 -42
  110. package/tag-close/types.d.ts +0 -5
  111. /package/{dropdown-text-option → chip}/types.js +0 -0
  112. /package/{dropdown → color-menu}/types.js +0 -0
  113. /package/{select-option → color-swatch}/types.js +0 -0
  114. /package/{select → select-button}/types.js +0 -0
  115. /package/{tag-close → select-menu-option}/types.js +0 -0
@@ -1,16 +1,3 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$left, _$right, _$buttons, _$wrapper, _onValueChange, _onButtonClick, _clamp, _dispatchChangeEvent, _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 '../icons/keyboard-arrow-left';
15
2
  import '../icons/keyboard-arrow-right';
16
3
  import { defineCustomElement, updateAttribute, getIntegerAttribute, setClass, NectaryElement, getRect, getReactEventHandler } from '../utils';
@@ -23,106 +10,31 @@ const DOTS_LEFT_INDEX = 1;
23
10
  const DOTS_RIGHT_INDEX = LAST_BTN_INDEX - 1;
24
11
  const template = document.createElement('template');
25
12
  template.innerHTML = templateHTML;
26
- defineCustomElement('sinch-pagination', (_$left = new WeakMap(), _$right = new WeakMap(), _$buttons = new WeakMap(), _$wrapper = new WeakMap(), _onValueChange = new WeakSet(), _onButtonClick = new WeakMap(), _clamp = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
13
+ defineCustomElement('sinch-pagination', class extends NectaryElement {
14
+ #$left;
15
+ #$right;
16
+ #$buttons;
17
+ #$wrapper;
18
+
27
19
  constructor() {
28
20
  super();
29
-
30
- _classPrivateMethodInitSpec(this, _dispatchChangeEvent);
31
-
32
- _classPrivateMethodInitSpec(this, _clamp);
33
-
34
- _classPrivateMethodInitSpec(this, _onValueChange);
35
-
36
- _classPrivateFieldInitSpec(this, _$left, {
37
- writable: true,
38
- value: void 0
39
- });
40
-
41
- _classPrivateFieldInitSpec(this, _$right, {
42
- writable: true,
43
- value: void 0
44
- });
45
-
46
- _classPrivateFieldInitSpec(this, _$buttons, {
47
- writable: true,
48
- value: void 0
49
- });
50
-
51
- _classPrivateFieldInitSpec(this, _$wrapper, {
52
- writable: true,
53
- value: void 0
54
- });
55
-
56
- _classPrivateFieldInitSpec(this, _onButtonClick, {
57
- writable: true,
58
- value: e => {
59
- e.stopPropagation();
60
- const value = getIntegerAttribute(this, 'value', 0) - 1;
61
- const max = Math.max(0, getIntegerAttribute(this, 'max', 0));
62
-
63
- if (e.target === _classPrivateFieldGet(this, _$left)) {
64
- return _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, value - 1);
65
- }
66
-
67
- if (e.target === _classPrivateFieldGet(this, _$right)) {
68
- return _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, value + 1);
69
- }
70
-
71
- const btnIndex = Array.prototype.indexOf.call(_classPrivateFieldGet(this, _$wrapper).children, e.target) - 1;
72
-
73
- if (btnIndex >= 0 && btnIndex < _classPrivateFieldGet(this, _$buttons).length) {
74
- if (btnIndex === FIRST_BTN_INDEX) {
75
- return _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, 0);
76
- }
77
-
78
- if (btnIndex === _classPrivateFieldGet(this, _$buttons).length - 1) {
79
- return _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, max - 1);
80
- }
81
-
82
- if (btnIndex === DOTS_LEFT_INDEX && max > NUM_BUTTONS && value > MIDDLE_BTN_INDEX) {
83
- return _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, Math.floor(value / 2));
84
- }
85
-
86
- if (btnIndex === DOTS_RIGHT_INDEX && max > NUM_BUTTONS && value <= max - DOTS_RIGHT_INDEX) {
87
- return _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, Math.floor((max - value) / 2 + value));
88
- }
89
-
90
- return _classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, btnIndex + Math.min(Math.max(0, value - MIDDLE_BTN_INDEX), Math.max(0, max - NUM_BUTTONS)));
91
- }
92
- }
93
- });
94
-
95
- _classPrivateFieldInitSpec(this, _onChangeReactHandler, {
96
- writable: true,
97
- value: e => {
98
- getReactEventHandler(this, 'on-change')?.(e);
99
- }
100
- });
101
-
102
21
  const shadowRoot = this.attachShadow();
103
22
  shadowRoot.appendChild(template.content.cloneNode(true));
104
-
105
- _classPrivateFieldSet(this, _$left, shadowRoot.querySelector('#left'));
106
-
107
- _classPrivateFieldSet(this, _$right, shadowRoot.querySelector('#right'));
108
-
109
- _classPrivateFieldSet(this, _$buttons, shadowRoot.querySelectorAll('.page'));
110
-
111
- _classPrivateFieldSet(this, _$wrapper, shadowRoot.querySelector('#wrapper'));
23
+ this.#$left = shadowRoot.querySelector('#left');
24
+ this.#$right = shadowRoot.querySelector('#right');
25
+ this.#$buttons = shadowRoot.querySelectorAll('.page');
26
+ this.#$wrapper = shadowRoot.querySelector('#wrapper');
112
27
  }
113
28
 
114
29
  connectedCallback() {
115
- _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this);
116
-
117
- _classPrivateFieldGet(this, _$wrapper).addEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
118
-
119
- this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
30
+ this.#onValueChange();
31
+ this.#$wrapper.addEventListener('click', this.#onButtonClick);
32
+ this.addEventListener('-change', this.#onChangeReactHandler);
120
33
  }
121
34
 
122
35
  disconnectedCallback() {
123
- _classPrivateFieldGet(this, _$wrapper).removeEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
124
-
125
- this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
36
+ this.#$wrapper.removeEventListener('click', this.#onButtonClick);
37
+ this.removeEventListener('-change', this.#onChangeReactHandler);
126
38
  }
127
39
 
128
40
  static get observedAttributes() {
@@ -133,15 +45,13 @@ defineCustomElement('sinch-pagination', (_$left = new WeakMap(), _$right = new W
133
45
  switch (name) {
134
46
  case 'value':
135
47
  {
136
- _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this);
137
-
48
+ this.#onValueChange();
138
49
  break;
139
50
  }
140
51
 
141
52
  case 'max':
142
53
  {
143
- _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this);
144
-
54
+ this.#onValueChange();
145
55
  break;
146
56
  }
147
57
  }
@@ -167,80 +77,116 @@ defineCustomElement('sinch-pagination', (_$left = new WeakMap(), _$right = new W
167
77
  return getIntegerAttribute(this, 'value', 0);
168
78
  }
169
79
 
170
- focus() {
171
- _classPrivateFieldGet(this, _$left).focus();
172
- }
80
+ #onValueChange() {
81
+ const value = getIntegerAttribute(this, 'value', 0) - 1;
82
+ const max = Math.max(0, getIntegerAttribute(this, 'max', 0));
83
+ const valueOffset = Math.min(Math.max(0, value - MIDDLE_BTN_INDEX), Math.max(0, max - NUM_BUTTONS));
173
84
 
174
- blur() {
175
- _classPrivateFieldGet(this, _$left).blur();
85
+ for (let i = 0; i < this.#$buttons.length; i++) {
86
+ const $b = this.#$buttons[i];
176
87
 
177
- _classPrivateFieldGet(this, _$right).blur();
88
+ if (value < 3) {
89
+ setClass($b, 'active', value === i);
90
+ } else if (value >= max - MIDDLE_BTN_INDEX) {
91
+ setClass($b, 'active', i + valueOffset === value);
92
+ } else {
93
+ setClass($b, 'active', i === MIDDLE_BTN_INDEX);
94
+ }
178
95
 
179
- _classPrivateFieldGet(this, _$buttons).forEach($b => $b.blur());
180
- }
96
+ if (max > NUM_BUTTONS) {
97
+ setClass($b, 'dots', i === DOTS_LEFT_INDEX && value > MIDDLE_BTN_INDEX || i === DOTS_RIGHT_INDEX && value <= max - DOTS_RIGHT_INDEX);
98
+ }
181
99
 
182
- get prevButtonRect() {
183
- return getRect(_classPrivateFieldGet(this, _$left));
184
- }
100
+ setClass($b, 'hidden', i >= max);
101
+ const btnText = $b.firstElementChild;
185
102
 
186
- get nextButtonRect() {
187
- return getRect(_classPrivateFieldGet(this, _$right));
103
+ if (btnText != null) {
104
+ btnText.textContent = i === FIRST_BTN_INDEX ? '1' : i === LAST_BTN_INDEX ? String(max) : String(i + 1 + valueOffset);
105
+ }
106
+ }
107
+
108
+ const isValueBad = value < 0 || value >= max;
109
+ this.#$left.disabled = isValueBad || value === 0;
110
+ this.#$right.disabled = isValueBad || value === max - 1;
188
111
  }
189
112
 
190
- nthButtonRect(index) {
191
- const btn = _classPrivateFieldGet(this, _$buttons)[index];
113
+ #onButtonClick = e => {
114
+ e.stopPropagation();
115
+ const value = getIntegerAttribute(this, 'value', 0) - 1;
116
+ const max = Math.max(0, getIntegerAttribute(this, 'max', 0));
192
117
 
193
- return btn == null ? null : getRect(btn);
194
- }
118
+ if (e.target === this.#$left) {
119
+ return this.#dispatchChangeEvent(value - 1);
120
+ }
195
121
 
196
- }));
122
+ if (e.target === this.#$right) {
123
+ return this.#dispatchChangeEvent(value + 1);
124
+ }
197
125
 
198
- function _onValueChange2() {
199
- const value = getIntegerAttribute(this, 'value', 0) - 1;
200
- const max = Math.max(0, getIntegerAttribute(this, 'max', 0));
201
- const valueOffset = Math.min(Math.max(0, value - MIDDLE_BTN_INDEX), Math.max(0, max - NUM_BUTTONS));
126
+ const btnIndex = Array.prototype.indexOf.call(this.#$wrapper.children, e.target) - 1;
202
127
 
203
- for (let i = 0; i < _classPrivateFieldGet(this, _$buttons).length; i++) {
204
- const $b = _classPrivateFieldGet(this, _$buttons)[i];
128
+ if (btnIndex >= 0 && btnIndex < this.#$buttons.length) {
129
+ if (btnIndex === FIRST_BTN_INDEX) {
130
+ return this.#dispatchChangeEvent(0);
131
+ }
205
132
 
206
- if (value < 3) {
207
- setClass($b, 'active', value === i);
208
- } else if (value >= max - MIDDLE_BTN_INDEX) {
209
- setClass($b, 'active', i + valueOffset === value);
210
- } else {
211
- setClass($b, 'active', i === MIDDLE_BTN_INDEX);
212
- }
133
+ if (btnIndex === this.#$buttons.length - 1) {
134
+ return this.#dispatchChangeEvent(max - 1);
135
+ }
213
136
 
214
- if (max > NUM_BUTTONS) {
215
- setClass($b, 'dots', i === DOTS_LEFT_INDEX && value > MIDDLE_BTN_INDEX || i === DOTS_RIGHT_INDEX && value <= max - DOTS_RIGHT_INDEX);
216
- }
137
+ if (btnIndex === DOTS_LEFT_INDEX && max > NUM_BUTTONS && value > MIDDLE_BTN_INDEX) {
138
+ return this.#dispatchChangeEvent(Math.floor(value / 2));
139
+ }
217
140
 
218
- setClass($b, 'hidden', i >= max);
219
- const btnText = $b.firstElementChild;
141
+ if (btnIndex === DOTS_RIGHT_INDEX && max > NUM_BUTTONS && value <= max - DOTS_RIGHT_INDEX) {
142
+ return this.#dispatchChangeEvent(Math.floor((max - value) / 2 + value));
143
+ }
220
144
 
221
- if (btnText != null) {
222
- btnText.textContent = i === FIRST_BTN_INDEX ? '1' : i === LAST_BTN_INDEX ? String(max) : String(i + 1 + valueOffset);
145
+ return this.#dispatchChangeEvent(btnIndex + Math.min(Math.max(0, value - MIDDLE_BTN_INDEX), Math.max(0, max - NUM_BUTTONS)));
223
146
  }
147
+ };
148
+
149
+ #clamp(value) {
150
+ const max = getIntegerAttribute(this, 'max', 0);
151
+ return Math.max(0, Math.min(max - 1, value)) + 1;
152
+ }
153
+
154
+ #dispatchChangeEvent(value) {
155
+ const detail = this.#clamp(value);
156
+ this.dispatchEvent(new CustomEvent('change', {
157
+ detail,
158
+ bubbles: true
159
+ }));
160
+ this.dispatchEvent(new CustomEvent('-change', {
161
+ detail
162
+ }));
224
163
  }
225
164
 
226
- const isValueBad = value < 0 || value >= max;
227
- _classPrivateFieldGet(this, _$left).disabled = isValueBad || value === 0;
228
- _classPrivateFieldGet(this, _$right).disabled = isValueBad || value === max - 1;
229
- }
165
+ #onChangeReactHandler = e => {
166
+ getReactEventHandler(this, 'on-change')?.(e);
167
+ };
230
168
 
231
- function _clamp2(value) {
232
- const max = getIntegerAttribute(this, 'max', 0);
233
- return Math.max(0, Math.min(max - 1, value)) + 1;
234
- }
169
+ focus() {
170
+ this.#$left.focus();
171
+ }
172
+
173
+ blur() {
174
+ this.#$left.blur();
175
+ this.#$right.blur();
176
+ this.#$buttons.forEach($b => $b.blur());
177
+ }
235
178
 
236
- function _dispatchChangeEvent2(value) {
237
- const detail = _classPrivateMethodGet(this, _clamp, _clamp2).call(this, value);
179
+ get prevButtonRect() {
180
+ return getRect(this.#$left);
181
+ }
182
+
183
+ get nextButtonRect() {
184
+ return getRect(this.#$right);
185
+ }
186
+
187
+ nthButtonRect(index) {
188
+ const btn = this.#$buttons[index];
189
+ return btn == null ? null : getRect(btn);
190
+ }
238
191
 
239
- this.dispatchEvent(new CustomEvent('change', {
240
- detail,
241
- bubbles: true
242
- }));
243
- this.dispatchEvent(new CustomEvent('-change', {
244
- detail
245
- }));
246
- }
192
+ });