@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.
- package/accordion/index.js +47 -84
- package/accordion-item/index.js +26 -53
- package/action-menu/index.d.ts +0 -1
- package/action-menu/index.js +179 -223
- package/action-menu/types.d.ts +8 -18
- package/action-menu-option/index.d.ts +1 -0
- package/action-menu-option/index.js +51 -62
- package/action-menu-option/types.d.ts +9 -0
- package/action-menu-option/utils.d.ts +2 -0
- package/action-menu-option/utils.js +3 -0
- package/alert/index.js +6 -20
- package/avatar/index.js +12 -31
- package/avatar-badge/index.js +8 -22
- package/avatar-status/index.js +1 -1
- package/button/index.js +42 -92
- package/card/index.js +21 -59
- package/chat-avatar/index.js +8 -22
- package/chat-block/index.js +29 -69
- package/chat-bubble/index.js +6 -20
- package/checkbox/index.js +55 -107
- package/chip/index.d.ts +13 -0
- package/chip/index.js +137 -0
- package/chip/types.d.ts +38 -0
- package/color-menu/index.d.ts +13 -0
- package/color-menu/index.js +464 -0
- package/color-menu/types.d.ts +37 -0
- package/color-swatch/index.d.ts +13 -0
- package/color-swatch/index.js +59 -0
- package/color-swatch/types.d.ts +12 -0
- package/colors.json +57 -49
- package/date-picker/index.js +161 -292
- package/dialog/index.js +70 -142
- package/dropdown-checkbox-option/index.js +6 -20
- package/dropdown-radio-option/index.js +6 -20
- package/field/index.js +25 -63
- package/file-drop/index.js +123 -200
- package/file-picker/index.d.ts +0 -1
- package/file-picker/index.js +55 -108
- package/file-status/index.js +15 -39
- package/help-tooltip/index.js +1 -1
- package/horizontal-stepper/index.js +33 -59
- package/horizontal-stepper-item/index.js +13 -37
- package/icon-button/index.js +39 -84
- package/icons-channel/notify/index.d.ts +11 -0
- package/icons-channel/notify/index.js +4 -0
- package/illustrations/create-illustration-class.js +1 -1
- package/inline-alert/index.js +29 -81
- package/input/index.js +113 -222
- package/link/index.js +46 -96
- package/list-item/index.js +1 -1
- package/package.json +12 -14
- package/pagination/index.js +109 -163
- package/popover/index.js +224 -294
- package/progress/index.js +9 -28
- package/radio/index.js +103 -169
- package/radio-option/index.js +24 -48
- package/segment/index.js +49 -130
- package/segment-collapse/index.js +24 -49
- package/segmented-control/index.js +36 -73
- package/segmented-control-option/index.js +41 -87
- package/segmented-icon-control/index.js +47 -84
- package/segmented-icon-control-option/index.js +38 -79
- package/select-button/index.d.ts +13 -0
- package/select-button/index.js +153 -0
- package/select-button/types.d.ts +43 -0
- package/select-menu/index.d.ts +11 -0
- package/select-menu/index.js +346 -0
- package/select-menu/types.d.ts +29 -0
- package/select-menu/types.js +1 -0
- package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
- package/select-menu-option/index.js +76 -0
- package/{select-option → select-menu-option}/types.d.ts +8 -9
- package/stop-events/index.js +7 -20
- package/table-head-cell/index.js +7 -21
- package/tabs/index.js +103 -165
- package/tabs-option/index.js +20 -44
- package/tag/index.d.ts +0 -1
- package/tag/index.js +37 -38
- package/tag/types.d.ts +13 -7
- package/textarea/index.js +92 -167
- package/theme.css +80 -49
- package/tile-control/index.js +55 -96
- package/tile-control-option/index.js +40 -86
- package/time-picker/index.js +216 -368
- package/title/index.js +6 -20
- package/toast/index.js +32 -70
- package/toast-manager/index.js +141 -217
- package/toggle/index.js +54 -106
- package/types.d.ts +7 -0
- package/utils/colors.d.ts +10 -0
- package/utils/colors.js +121 -0
- package/{utils.d.ts → utils/index.d.ts} +17 -9
- package/{utils.js → utils/index.js} +96 -39
- package/vertical-stepper/index.js +29 -50
- package/vertical-stepper-item/index.js +13 -37
- package/dropdown/index.d.ts +0 -12
- package/dropdown/index.js +0 -415
- package/dropdown/types.d.ts +0 -32
- package/dropdown-text-option/index.js +0 -104
- package/dropdown-text-option/types.d.ts +0 -16
- package/select/index.d.ts +0 -13
- package/select/index.js +0 -316
- package/select/types.d.ts +0 -53
- package/select-option/index.d.ts +0 -11
- package/select-option/index.js +0 -8
- package/tag/utils.d.ts +0 -5
- package/tag/utils.js +0 -6
- package/tag-close/index.d.ts +0 -12
- package/tag-close/index.js +0 -42
- package/tag-close/types.d.ts +0 -5
- /package/{dropdown-text-option → chip}/types.js +0 -0
- /package/{dropdown → color-menu}/types.js +0 -0
- /package/{select-option → color-swatch}/types.js +0 -0
- /package/{select → select-button}/types.js +0 -0
- /package/{tag-close → select-menu-option}/types.js +0 -0
package/pagination/index.js
CHANGED
|
@@ -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',
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
|
|
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
|
-
|
|
137
|
-
|
|
48
|
+
this.#onValueChange();
|
|
138
49
|
break;
|
|
139
50
|
}
|
|
140
51
|
|
|
141
52
|
case 'max':
|
|
142
53
|
{
|
|
143
|
-
|
|
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
|
-
|
|
171
|
-
|
|
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
|
-
|
|
175
|
-
|
|
85
|
+
for (let i = 0; i < this.#$buttons.length; i++) {
|
|
86
|
+
const $b = this.#$buttons[i];
|
|
176
87
|
|
|
177
|
-
|
|
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
|
-
|
|
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
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
100
|
+
setClass($b, 'hidden', i >= max);
|
|
101
|
+
const btnText = $b.firstElementChild;
|
|
185
102
|
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
|
|
191
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
204
|
-
|
|
128
|
+
if (btnIndex >= 0 && btnIndex < this.#$buttons.length) {
|
|
129
|
+
if (btnIndex === FIRST_BTN_INDEX) {
|
|
130
|
+
return this.#dispatchChangeEvent(0);
|
|
131
|
+
}
|
|
205
132
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
|
|
215
|
-
|
|
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
|
-
|
|
219
|
-
|
|
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
|
-
|
|
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
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
165
|
+
#onChangeReactHandler = e => {
|
|
166
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
167
|
+
};
|
|
230
168
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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
|
-
|
|
237
|
-
|
|
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
|
-
|
|
240
|
-
detail,
|
|
241
|
-
bubbles: true
|
|
242
|
-
}));
|
|
243
|
-
this.dispatchEvent(new CustomEvent('-change', {
|
|
244
|
-
detail
|
|
245
|
-
}));
|
|
246
|
-
}
|
|
192
|
+
});
|