@nectary/components 0.41.1 → 0.42.1
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 +0 -16
- package/accordion/types.d.ts +9 -1
- package/accordion-item/index.js +0 -24
- package/accordion-item/types.d.ts +18 -3
- package/action-menu/index.js +1 -45
- package/action-menu-option/index.js +0 -18
- package/alert/index.js +0 -10
- package/alert/types.d.ts +6 -0
- package/avatar/index.js +57 -20
- package/avatar/types.d.ts +25 -7
- package/avatar/utils.d.ts +10 -2
- package/avatar/utils.js +23 -2
- package/badge/index.d.ts +11 -0
- package/badge/index.js +140 -0
- package/badge/types.d.ts +38 -0
- package/badge/utils.d.ts +11 -0
- package/badge/utils.js +23 -0
- package/button/index.js +0 -18
- package/card/index.js +0 -16
- package/card/types.d.ts +15 -3
- package/card-container/index.js +0 -1
- package/chat/index.js +0 -1
- package/chat-block/index.js +0 -19
- package/chat-block/types.d.ts +16 -4
- package/chat-bubble/index.js +0 -9
- package/chat-bubble/types.d.ts +6 -0
- package/checkbox/index.js +0 -23
- package/chip/index.js +16 -25
- package/chip/utils.d.ts +3 -0
- package/chip/utils.js +11 -0
- package/color-menu/index.js +8 -86
- package/color-menu/utils.js +0 -4
- package/color-swatch/index.js +17 -17
- package/color-swatch/types.d.ts +2 -2
- package/color-swatch/utils.d.ts +3 -0
- package/color-swatch/utils.js +11 -0
- package/date-picker/index.js +1 -50
- package/date-picker/utils.js +0 -7
- package/dialog/index.js +1 -17
- package/field/index.js +0 -19
- package/file-drop/index.js +0 -40
- package/file-drop/utils.js +0 -6
- package/file-picker/index.js +0 -17
- package/file-picker/utils.js +0 -1
- package/file-status/index.js +0 -12
- package/grid/index.js +0 -1
- package/grid-item/index.js +0 -9
- package/help-tooltip/index.js +0 -14
- package/horizontal-stepper/index.js +0 -12
- package/horizontal-stepper-item/index.js +0 -14
- package/icon-button/index.js +0 -15
- package/icons/create-icon-class.js +0 -2
- package/icons-branded/create-icon-class.js +0 -8
- package/icons-channel/create-icon-class.js +0 -6
- package/illustrations/create-illustration-class.js +0 -11
- package/inline-alert/index.js +0 -14
- package/input/index.js +0 -37
- package/link/index.js +0 -25
- package/list/index.js +0 -2
- package/list-item/index.js +0 -2
- package/logo/create-logo-class.js +0 -9
- package/package.json +3 -1
- package/pagination/index.js +0 -31
- package/pop/index.js +26 -68
- package/pop/utils.js +0 -1
- package/popover/index.js +0 -33
- package/popover/utils.js +0 -2
- package/progress/index.js +0 -10
- package/radio/index.js +0 -30
- package/radio-option/index.js +0 -20
- package/segment/index.js +0 -15
- package/segment-collapse/index.js +0 -13
- package/segmented-control/index.js +0 -12
- package/segmented-control-option/index.js +0 -18
- package/segmented-icon-control/index.js +0 -16
- package/segmented-icon-control-option/index.js +0 -14
- package/select-button/index.js +0 -23
- package/select-menu/index.js +1 -63
- package/select-menu-option/index.js +0 -14
- package/spinner/index.js +0 -4
- package/stop-events/index.js +0 -5
- package/table/index.js +0 -2
- package/table-body/index.js +0 -2
- package/table-cell/index.js +0 -4
- package/table-head/index.js +0 -2
- package/table-head-cell/index.js +0 -11
- package/table-row/index.js +0 -6
- package/tabs/index.js +0 -30
- package/tabs-option/index.js +0 -19
- package/tag/index.js +18 -21
- package/tag/utils.d.ts +3 -0
- package/tag/utils.js +11 -0
- package/text/index.js +1 -12
- package/textarea/index.js +0 -40
- package/theme/avatar.css +25 -0
- package/theme/badge.css +15 -0
- package/theme/chip.css +53 -0
- package/theme/color-swatch.css +65 -0
- package/{utils → theme}/colors.d.ts +0 -1
- package/{utils → theme}/colors.js +0 -1
- package/theme/elevation.css +7 -0
- package/theme/fonts.css +76 -0
- package/theme/fonts.json +79 -0
- package/theme/palette.css +90 -0
- package/theme/shapes.css +7 -0
- package/theme/tag.css +53 -0
- package/theme/typography.css +16 -0
- package/theme.css +13 -209
- package/tile-control/index.js +0 -24
- package/tile-control-option/index.js +0 -18
- package/time-picker/index.js +2 -51
- package/time-picker/utils.js +0 -18
- package/title/index.js +1 -12
- package/title/utils.js +0 -5
- package/toast/index.js +0 -19
- package/toast-manager/index.js +0 -27
- package/toggle/index.js +0 -23
- package/tooltip/index.js +0 -27
- package/tooltip/utils.js +0 -4
- package/utils/animation.js +0 -20
- package/utils/context.js +0 -6
- package/utils/index.d.ts +1 -0
- package/utils/index.js +11 -52
- package/vertical-stepper/index.js +0 -12
- package/vertical-stepper-item/index.js +0 -14
- package/avatar-badge/index.d.ts +0 -11
- package/avatar-badge/index.js +0 -38
- package/avatar-badge/types.d.ts +0 -8
- package/avatar-status/index.d.ts +0 -11
- package/avatar-status/index.js +0 -37
- package/avatar-status/types.d.ts +0 -9
- package/avatar-status/types.js +0 -1
- package/avatar-status/utils.d.ts +0 -5
- package/avatar-status/utils.js +0 -6
- package/chat-avatar/index.d.ts +0 -12
- package/chat-avatar/index.js +0 -52
- package/chat-avatar/types.d.ts +0 -12
- package/chat-avatar/types.js +0 -1
- /package/{avatar-badge → badge}/types.js +0 -0
package/date-picker/index.js
CHANGED
|
@@ -25,7 +25,6 @@ defineCustomElement('sinch-date-picker', class extends NectaryElement {
|
|
|
25
25
|
#$nextYear;
|
|
26
26
|
#$date;
|
|
27
27
|
#monthNames;
|
|
28
|
-
|
|
29
28
|
constructor() {
|
|
30
29
|
super();
|
|
31
30
|
const shadowRoot = this.attachShadow();
|
|
@@ -48,7 +47,6 @@ defineCustomElement('sinch-date-picker', class extends NectaryElement {
|
|
|
48
47
|
});
|
|
49
48
|
this.#$weekDayNames = Array.from(shadowRoot.querySelectorAll('#week-day-names > .week-day-name'));
|
|
50
49
|
}
|
|
51
|
-
|
|
52
50
|
connectedCallback() {
|
|
53
51
|
this.#$prevMonth.addEventListener('click', this.#onPrevMonthClick);
|
|
54
52
|
this.#$nextMonth.addEventListener('click', this.#onNextMonthClick);
|
|
@@ -56,6 +54,7 @@ defineCustomElement('sinch-date-picker', class extends NectaryElement {
|
|
|
56
54
|
this.#$nextYear.addEventListener('click', this.#onNextYearClick);
|
|
57
55
|
this.#$month.addEventListener('click', this.#onDateClick);
|
|
58
56
|
this.addEventListener('-change', this.#onChangeReactHandler);
|
|
57
|
+
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
disconnectedCallback() {
|
|
@@ -66,22 +65,18 @@ defineCustomElement('sinch-date-picker', class extends NectaryElement {
|
|
|
66
65
|
this.#$month.removeEventListener('click', this.#onDateClick);
|
|
67
66
|
this.removeEventListener('-change', this.#onChangeReactHandler);
|
|
68
67
|
}
|
|
69
|
-
|
|
70
68
|
static get observedAttributes() {
|
|
71
69
|
return ['value', 'min', 'max', 'locale', 'prev-year-aria-label', 'next-year-aria-label', 'prev-month-aria-label', 'next-month-aria-label'];
|
|
72
70
|
}
|
|
73
|
-
|
|
74
71
|
attributeChangedCallback(name, prevValue, newVal) {
|
|
75
72
|
if (newVal === prevValue) {
|
|
76
73
|
return;
|
|
77
74
|
}
|
|
78
|
-
|
|
79
75
|
switch (name) {
|
|
80
76
|
case 'value':
|
|
81
77
|
{
|
|
82
78
|
assertValue(newVal);
|
|
83
79
|
this.#date = newVal.length > 0 ? isoToDate(newVal) : today();
|
|
84
|
-
|
|
85
80
|
if (!isValidDate(this.#date)) {
|
|
86
81
|
this.#date = today();
|
|
87
82
|
}
|
|
@@ -93,11 +88,9 @@ defineCustomElement('sinch-date-picker', class extends NectaryElement {
|
|
|
93
88
|
if (this.#maxDate !== null) {
|
|
94
89
|
clampMaxDate(this.#date, this.#maxDate);
|
|
95
90
|
}
|
|
96
|
-
|
|
97
91
|
this.#render();
|
|
98
92
|
break;
|
|
99
93
|
}
|
|
100
|
-
|
|
101
94
|
case 'min':
|
|
102
95
|
{
|
|
103
96
|
assertMinMax(newVal, name);
|
|
@@ -107,11 +100,9 @@ defineCustomElement('sinch-date-picker', class extends NectaryElement {
|
|
|
107
100
|
if (this.#date !== null) {
|
|
108
101
|
clampMinDate(this.#date, this.#minDate);
|
|
109
102
|
}
|
|
110
|
-
|
|
111
103
|
this.#render();
|
|
112
104
|
break;
|
|
113
105
|
}
|
|
114
|
-
|
|
115
106
|
case 'max':
|
|
116
107
|
{
|
|
117
108
|
assertMinMax(newVal, name);
|
|
@@ -121,11 +112,9 @@ defineCustomElement('sinch-date-picker', class extends NectaryElement {
|
|
|
121
112
|
if (this.#date !== null) {
|
|
122
113
|
clampMaxDate(this.#date, this.#maxDate);
|
|
123
114
|
}
|
|
124
|
-
|
|
125
115
|
this.#render();
|
|
126
116
|
break;
|
|
127
117
|
}
|
|
128
|
-
|
|
129
118
|
case 'locale':
|
|
130
119
|
{
|
|
131
120
|
assertLocale(newVal);
|
|
@@ -137,25 +126,21 @@ defineCustomElement('sinch-date-picker', class extends NectaryElement {
|
|
|
137
126
|
this.#render();
|
|
138
127
|
break;
|
|
139
128
|
}
|
|
140
|
-
|
|
141
129
|
case 'prev-year-aria-label':
|
|
142
130
|
{
|
|
143
131
|
updateAttribute(this.#$prevYear, 'aria-label', newVal);
|
|
144
132
|
break;
|
|
145
133
|
}
|
|
146
|
-
|
|
147
134
|
case 'next-year-aria-label':
|
|
148
135
|
{
|
|
149
136
|
updateAttribute(this.#$nextYear, 'aria-label', newVal);
|
|
150
137
|
break;
|
|
151
138
|
}
|
|
152
|
-
|
|
153
139
|
case 'prev-month-aria-label':
|
|
154
140
|
{
|
|
155
141
|
updateAttribute(this.#$prevMonth, 'aria-label', newVal);
|
|
156
142
|
break;
|
|
157
143
|
}
|
|
158
|
-
|
|
159
144
|
case 'next-month-aria-label':
|
|
160
145
|
{
|
|
161
146
|
updateAttribute(this.#$nextMonth, 'aria-label', newVal);
|
|
@@ -163,97 +148,73 @@ defineCustomElement('sinch-date-picker', class extends NectaryElement {
|
|
|
163
148
|
}
|
|
164
149
|
}
|
|
165
150
|
}
|
|
166
|
-
|
|
167
151
|
get nodeName() {
|
|
168
152
|
return 'select';
|
|
169
153
|
}
|
|
170
|
-
|
|
171
154
|
set locale(value) {
|
|
172
155
|
updateAttribute(this, 'locale', value);
|
|
173
156
|
}
|
|
174
|
-
|
|
175
157
|
get locale() {
|
|
176
158
|
return getAttribute(this, 'locale');
|
|
177
159
|
}
|
|
178
|
-
|
|
179
160
|
set value(value) {
|
|
180
161
|
updateAttribute(this, 'value', value);
|
|
181
162
|
}
|
|
182
|
-
|
|
183
163
|
get value() {
|
|
184
164
|
return getAttribute(this, 'value', '');
|
|
185
165
|
}
|
|
186
|
-
|
|
187
166
|
set min(value) {
|
|
188
167
|
updateAttribute(this, 'min', value);
|
|
189
168
|
}
|
|
190
|
-
|
|
191
169
|
get min() {
|
|
192
170
|
return getAttribute(this, 'min', '');
|
|
193
171
|
}
|
|
194
|
-
|
|
195
172
|
set max(value) {
|
|
196
173
|
updateAttribute(this, 'max', value);
|
|
197
174
|
}
|
|
198
|
-
|
|
199
175
|
get max() {
|
|
200
176
|
return getAttribute(this, 'max', '');
|
|
201
177
|
}
|
|
202
|
-
|
|
203
178
|
set prevMonthAriaLabel(value) {
|
|
204
179
|
updateAttribute(this, 'prev-month-aria-label', value);
|
|
205
180
|
}
|
|
206
|
-
|
|
207
181
|
get prevMonthAriaLabel() {
|
|
208
182
|
return getAttribute(this, 'prev-month-aria-label', '');
|
|
209
183
|
}
|
|
210
|
-
|
|
211
184
|
set nextMonthAriaLabel(value) {
|
|
212
185
|
updateAttribute(this, 'next-month-aria-label', value);
|
|
213
186
|
}
|
|
214
|
-
|
|
215
187
|
get nextMonthAriaLabel() {
|
|
216
188
|
return getAttribute(this, 'next-month-aria-label', '');
|
|
217
189
|
}
|
|
218
|
-
|
|
219
190
|
get prevYearButtonRect() {
|
|
220
191
|
return getRect(this.#$prevYear);
|
|
221
192
|
}
|
|
222
|
-
|
|
223
193
|
get nextYearButtonRect() {
|
|
224
194
|
return getRect(this.#$nextYear);
|
|
225
195
|
}
|
|
226
|
-
|
|
227
196
|
get prevMonthButtonRect() {
|
|
228
197
|
return getRect(this.#$prevMonth);
|
|
229
198
|
}
|
|
230
|
-
|
|
231
199
|
get nextMonthButtonRect() {
|
|
232
200
|
return getRect(this.#$nextMonth);
|
|
233
201
|
}
|
|
234
|
-
|
|
235
202
|
nthButtonRect(index) {
|
|
236
203
|
if (index < 0 || index > 30) {
|
|
237
204
|
return null;
|
|
238
205
|
}
|
|
239
|
-
|
|
240
206
|
const indexOffset = this.#$days[0].findIndex(el => el.getAttribute('data-date') !== null);
|
|
241
|
-
|
|
242
207
|
if (indexOffset < 0) {
|
|
243
208
|
return null;
|
|
244
209
|
}
|
|
245
|
-
|
|
246
210
|
const rowIndex = Math.floor((indexOffset + index) / 7);
|
|
247
211
|
const colIndex = (indexOffset + index) % 7;
|
|
248
212
|
const $el = this.#$days[rowIndex]?.[colIndex];
|
|
249
|
-
|
|
250
213
|
if ($el == null) {
|
|
251
214
|
return null;
|
|
252
215
|
}
|
|
253
|
-
|
|
254
216
|
return getRect($el);
|
|
255
217
|
}
|
|
256
|
-
|
|
257
218
|
#onPrevMonthClick = e => {
|
|
258
219
|
e.stopPropagation();
|
|
259
220
|
decMonth(this.#date, this.#minDate);
|
|
@@ -277,19 +238,15 @@ defineCustomElement('sinch-date-picker', class extends NectaryElement {
|
|
|
277
238
|
#onDateClick = e => {
|
|
278
239
|
e.stopPropagation();
|
|
279
240
|
const dateIso = e.target.getAttribute('data-date');
|
|
280
|
-
|
|
281
241
|
if (dateIso === null || dateIso.length === 0) {
|
|
282
242
|
return;
|
|
283
243
|
}
|
|
284
|
-
|
|
285
244
|
this.#dispatchChangeEvent(dateIso);
|
|
286
245
|
};
|
|
287
|
-
|
|
288
246
|
#render() {
|
|
289
247
|
if (this.#date === null || this.#minDate === null || this.#maxDate === null || this.locale === null) {
|
|
290
248
|
return;
|
|
291
249
|
}
|
|
292
|
-
|
|
293
250
|
const valueDate = isoToDate(this.value);
|
|
294
251
|
const todayDate = new Date();
|
|
295
252
|
const month = getCalendarMonth(this.#date);
|
|
@@ -305,7 +262,6 @@ defineCustomElement('sinch-date-picker', class extends NectaryElement {
|
|
|
305
262
|
const day = week?.[di];
|
|
306
263
|
$day.classList.remove('selected');
|
|
307
264
|
$day.classList.remove('today');
|
|
308
|
-
|
|
309
265
|
if (day == null) {
|
|
310
266
|
$day.textContent = '';
|
|
311
267
|
$day.removeAttribute('data-date');
|
|
@@ -315,7 +271,6 @@ defineCustomElement('sinch-date-picker', class extends NectaryElement {
|
|
|
315
271
|
const dayIso = dateToIso(day);
|
|
316
272
|
$day.textContent = day.getDate().toString();
|
|
317
273
|
$day.setAttribute('data-date', dayIso);
|
|
318
|
-
|
|
319
274
|
if (isDateBetween(day, this.#minDate, this.#maxDate)) {
|
|
320
275
|
$day.removeAttribute('disabled');
|
|
321
276
|
$day.removeAttribute('aria-hidden');
|
|
@@ -323,20 +278,17 @@ defineCustomElement('sinch-date-picker', class extends NectaryElement {
|
|
|
323
278
|
$day.setAttribute('disabled', '');
|
|
324
279
|
$day.setAttribute('aria-hidden', 'true');
|
|
325
280
|
}
|
|
326
|
-
|
|
327
281
|
if (areDatesEqual(day, valueDate)) {
|
|
328
282
|
$day.classList.add('selected');
|
|
329
283
|
} else if (areDatesEqual(day, todayDate)) {
|
|
330
284
|
$day.classList.add('today');
|
|
331
285
|
}
|
|
332
|
-
|
|
333
286
|
isEmptyWeek = false;
|
|
334
287
|
}
|
|
335
288
|
});
|
|
336
289
|
setClass(this.#$weeks[wi], 'empty', isEmptyWeek);
|
|
337
290
|
});
|
|
338
291
|
}
|
|
339
|
-
|
|
340
292
|
#dispatchChangeEvent(value) {
|
|
341
293
|
this.dispatchEvent(new CustomEvent('change', {
|
|
342
294
|
detail: value,
|
|
@@ -346,7 +298,6 @@ defineCustomElement('sinch-date-picker', class extends NectaryElement {
|
|
|
346
298
|
detail: value
|
|
347
299
|
}));
|
|
348
300
|
}
|
|
349
|
-
|
|
350
301
|
#onChangeReactHandler = e => {
|
|
351
302
|
getReactEventHandler(this, 'on-change')?.(e);
|
|
352
303
|
};
|
package/date-picker/utils.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
const DAYS_IN_WEEK = 7;
|
|
2
|
-
|
|
3
2
|
const pad = value => {
|
|
4
3
|
return value.toString().padStart(2, '0');
|
|
5
4
|
};
|
|
6
|
-
|
|
7
5
|
export const getCalendarMonth = (date, options) => {
|
|
8
6
|
const {
|
|
9
7
|
firstDayOfWeek
|
|
@@ -20,7 +18,6 @@ export const getCalendarMonth = (date, options) => {
|
|
|
20
18
|
const daysToAppend = (DAYS_IN_WEEK - 1 - lastWeekdayOfMonth + firstDayOfWeek) % DAYS_IN_WEEK;
|
|
21
19
|
const month = [];
|
|
22
20
|
let week = [];
|
|
23
|
-
|
|
24
21
|
for (let i = 1 - daysToPrepend; i <= daysInMonth + daysToAppend + 1; i++) {
|
|
25
22
|
if (i <= 0 || i > daysInMonth) {
|
|
26
23
|
week.push(null);
|
|
@@ -29,13 +26,11 @@ export const getCalendarMonth = (date, options) => {
|
|
|
29
26
|
result.setDate(i);
|
|
30
27
|
week.push(result);
|
|
31
28
|
}
|
|
32
|
-
|
|
33
29
|
if (week.length === 7) {
|
|
34
30
|
month.push(week);
|
|
35
31
|
week = [];
|
|
36
32
|
}
|
|
37
33
|
}
|
|
38
|
-
|
|
39
34
|
return month;
|
|
40
35
|
};
|
|
41
36
|
export const today = () => {
|
|
@@ -90,11 +85,9 @@ export const assertDate = (value, attrName, attrValue) => {
|
|
|
90
85
|
throw new Error(`sinch-date-picker: invalid "${attrName}" attribute: ${attrValue}`);
|
|
91
86
|
}
|
|
92
87
|
};
|
|
93
|
-
|
|
94
88
|
const compareDates = (a, b) => {
|
|
95
89
|
return a.getTime() - b.getTime();
|
|
96
90
|
};
|
|
97
|
-
|
|
98
91
|
export const clampMinDate = (date, min) => {
|
|
99
92
|
if (compareDates(min, date) > 0) {
|
|
100
93
|
date.setTime(min.getTime());
|
package/dialog/index.js
CHANGED
|
@@ -13,7 +13,6 @@ defineCustomElement('sinch-dialog', class extends NectaryElement {
|
|
|
13
13
|
#$caption;
|
|
14
14
|
#isConnected = false;
|
|
15
15
|
#prevOverflowValue = '';
|
|
16
|
-
|
|
17
16
|
constructor() {
|
|
18
17
|
super();
|
|
19
18
|
const shadowRoot = this.attachShadow();
|
|
@@ -23,7 +22,6 @@ defineCustomElement('sinch-dialog', class extends NectaryElement {
|
|
|
23
22
|
this.#$caption = shadowRoot.querySelector('#caption');
|
|
24
23
|
dialogPolyfill.registerDialog(this.#$dialog);
|
|
25
24
|
}
|
|
26
|
-
|
|
27
25
|
connectedCallback() {
|
|
28
26
|
this.setAttribute('role', 'dialog');
|
|
29
27
|
this.#$closeButton.addEventListener('click', this.#onCloseClick);
|
|
@@ -31,9 +29,9 @@ defineCustomElement('sinch-dialog', class extends NectaryElement {
|
|
|
31
29
|
this.#$dialog.addEventListener('cancel', this.#onCancel);
|
|
32
30
|
this.addEventListener('-close', this.#onCloseReactHandler);
|
|
33
31
|
this.#isConnected = true;
|
|
32
|
+
|
|
34
33
|
this.#setOpen(getBooleanAttribute(this, 'open'));
|
|
35
34
|
}
|
|
36
|
-
|
|
37
35
|
disconnectedCallback() {
|
|
38
36
|
this.#$closeButton.removeEventListener('click', this.#onCloseClick);
|
|
39
37
|
this.#$dialog.removeEventListener('mousedown', this.#onBackdropClick);
|
|
@@ -42,11 +40,9 @@ defineCustomElement('sinch-dialog', class extends NectaryElement {
|
|
|
42
40
|
this.#setOpen(false);
|
|
43
41
|
this.#isConnected = false;
|
|
44
42
|
}
|
|
45
|
-
|
|
46
43
|
static get observedAttributes() {
|
|
47
44
|
return ['caption', 'open', 'close-aria-label'];
|
|
48
45
|
}
|
|
49
|
-
|
|
50
46
|
attributeChangedCallback(name, _, newVal) {
|
|
51
47
|
switch (name) {
|
|
52
48
|
case 'caption':
|
|
@@ -54,7 +50,6 @@ defineCustomElement('sinch-dialog', class extends NectaryElement {
|
|
|
54
50
|
updateAttribute(this.#$caption, 'text', newVal);
|
|
55
51
|
break;
|
|
56
52
|
}
|
|
57
|
-
|
|
58
53
|
case 'open':
|
|
59
54
|
{
|
|
60
55
|
const shouldOpen = isAttrTrue(newVal);
|
|
@@ -62,7 +57,6 @@ defineCustomElement('sinch-dialog', class extends NectaryElement {
|
|
|
62
57
|
updateBooleanAttribute(this, 'open', shouldOpen);
|
|
63
58
|
break;
|
|
64
59
|
}
|
|
65
|
-
|
|
66
60
|
case 'close-aria-label':
|
|
67
61
|
{
|
|
68
62
|
updateAttribute(this.#$closeButton, 'aria-label', newVal);
|
|
@@ -70,15 +64,12 @@ defineCustomElement('sinch-dialog', class extends NectaryElement {
|
|
|
70
64
|
}
|
|
71
65
|
}
|
|
72
66
|
}
|
|
73
|
-
|
|
74
67
|
set caption(caption) {
|
|
75
68
|
updateAttribute(this, 'caption', caption);
|
|
76
69
|
}
|
|
77
|
-
|
|
78
70
|
get caption() {
|
|
79
71
|
return getAttribute(this, 'caption', '');
|
|
80
72
|
}
|
|
81
|
-
|
|
82
73
|
#onCancel = e => {
|
|
83
74
|
e.preventDefault();
|
|
84
75
|
this.#dispatchCloseEvent();
|
|
@@ -90,10 +81,8 @@ defineCustomElement('sinch-dialog', class extends NectaryElement {
|
|
|
90
81
|
if (e.target !== this.#$dialog) {
|
|
91
82
|
return;
|
|
92
83
|
}
|
|
93
|
-
|
|
94
84
|
const rect = this.dialogRect;
|
|
95
85
|
const isInside = e.x >= rect.x && e.x < rect.x + rect.width && e.y >= rect.y && e.y < rect.y + rect.height;
|
|
96
|
-
|
|
97
86
|
if (!isInside) {
|
|
98
87
|
this.#dispatchCloseEvent();
|
|
99
88
|
}
|
|
@@ -102,11 +91,9 @@ defineCustomElement('sinch-dialog', class extends NectaryElement {
|
|
|
102
91
|
getReactEventHandler(this, 'onClose')?.();
|
|
103
92
|
getReactEventHandler(this, 'on-close')?.(e);
|
|
104
93
|
};
|
|
105
|
-
|
|
106
94
|
#dispatchCloseEvent() {
|
|
107
95
|
this.dispatchEvent(new CustomEvent('-close'));
|
|
108
96
|
}
|
|
109
|
-
|
|
110
97
|
#setOpen(shouldOpen) {
|
|
111
98
|
if (shouldOpen) {
|
|
112
99
|
if (this.#isConnected && !getBooleanAttribute(this.#$dialog, 'open')) {
|
|
@@ -119,13 +106,10 @@ defineCustomElement('sinch-dialog', class extends NectaryElement {
|
|
|
119
106
|
document.body.style.overflow = this.#prevOverflowValue;
|
|
120
107
|
}
|
|
121
108
|
}
|
|
122
|
-
|
|
123
109
|
get dialogRect() {
|
|
124
110
|
return getRect(this.#$dialog);
|
|
125
111
|
}
|
|
126
|
-
|
|
127
112
|
get closeButtonRect() {
|
|
128
113
|
return getRect(this.#$closeButton);
|
|
129
114
|
}
|
|
130
|
-
|
|
131
115
|
});
|
package/field/index.js
CHANGED
|
@@ -11,7 +11,6 @@ defineCustomElement('sinch-field', class extends NectaryElement {
|
|
|
11
11
|
#$tooltipWrapper;
|
|
12
12
|
#$tooltipSlot;
|
|
13
13
|
#controller = null;
|
|
14
|
-
|
|
15
14
|
constructor() {
|
|
16
15
|
super();
|
|
17
16
|
const shadowRoot = this.attachShadow();
|
|
@@ -24,7 +23,6 @@ defineCustomElement('sinch-field', class extends NectaryElement {
|
|
|
24
23
|
this.#$tooltipSlot = shadowRoot.querySelector('slot[name="tooltip"]');
|
|
25
24
|
this.#$tooltipWrapper = shadowRoot.querySelector('#tooltip');
|
|
26
25
|
}
|
|
27
|
-
|
|
28
26
|
connectedCallback() {
|
|
29
27
|
this.#controller = new AbortController();
|
|
30
28
|
const {
|
|
@@ -37,55 +35,42 @@ defineCustomElement('sinch-field', class extends NectaryElement {
|
|
|
37
35
|
signal
|
|
38
36
|
});
|
|
39
37
|
}
|
|
40
|
-
|
|
41
38
|
disconnectedCallback() {
|
|
42
39
|
this.#controller.abort();
|
|
43
40
|
}
|
|
44
|
-
|
|
45
41
|
static get observedAttributes() {
|
|
46
42
|
return ['label', 'optionaltext', 'additionaltext', 'invalidtext'];
|
|
47
43
|
}
|
|
48
|
-
|
|
49
44
|
set label(value) {
|
|
50
45
|
updateAttribute(this, 'label', value);
|
|
51
46
|
}
|
|
52
|
-
|
|
53
47
|
get label() {
|
|
54
48
|
return getAttribute(this, 'label', '');
|
|
55
49
|
}
|
|
56
|
-
|
|
57
50
|
set optionalText(value) {
|
|
58
51
|
updateAttribute(this, 'optionaltext', value);
|
|
59
52
|
}
|
|
60
|
-
|
|
61
53
|
get optionalText() {
|
|
62
54
|
return getAttribute(this, 'optionaltext');
|
|
63
55
|
}
|
|
64
|
-
|
|
65
56
|
set additionalText(value) {
|
|
66
57
|
updateAttribute(this, 'additionaltext', value);
|
|
67
58
|
}
|
|
68
|
-
|
|
69
59
|
get additionalText() {
|
|
70
60
|
return getAttribute(this, 'additionaltext');
|
|
71
61
|
}
|
|
72
|
-
|
|
73
62
|
set invalidText(value) {
|
|
74
63
|
updateAttribute(this, 'invalidtext', value);
|
|
75
64
|
}
|
|
76
|
-
|
|
77
65
|
get invalidText() {
|
|
78
66
|
return getAttribute(this, 'invalidtext');
|
|
79
67
|
}
|
|
80
|
-
|
|
81
68
|
set disabled(isDisabled) {
|
|
82
69
|
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
83
70
|
}
|
|
84
|
-
|
|
85
71
|
get disabled() {
|
|
86
72
|
return getBooleanAttribute(this, 'disabled');
|
|
87
73
|
}
|
|
88
|
-
|
|
89
74
|
attributeChangedCallback(name, _, newVal) {
|
|
90
75
|
switch (name) {
|
|
91
76
|
case 'label':
|
|
@@ -93,19 +78,16 @@ defineCustomElement('sinch-field', class extends NectaryElement {
|
|
|
93
78
|
this.#$label.textContent = newVal;
|
|
94
79
|
break;
|
|
95
80
|
}
|
|
96
|
-
|
|
97
81
|
case 'optionaltext':
|
|
98
82
|
{
|
|
99
83
|
this.#$optionalText.textContent = newVal;
|
|
100
84
|
break;
|
|
101
85
|
}
|
|
102
|
-
|
|
103
86
|
case 'additionaltext':
|
|
104
87
|
{
|
|
105
88
|
this.#$additionalText.textContent = newVal;
|
|
106
89
|
break;
|
|
107
90
|
}
|
|
108
|
-
|
|
109
91
|
case 'invalidtext':
|
|
110
92
|
{
|
|
111
93
|
this.#$invalidText.textContent = newVal;
|
|
@@ -113,7 +95,6 @@ defineCustomElement('sinch-field', class extends NectaryElement {
|
|
|
113
95
|
}
|
|
114
96
|
}
|
|
115
97
|
}
|
|
116
|
-
|
|
117
98
|
#onLabelClick = () => {
|
|
118
99
|
getFirstSlotElement(this.#$inputSlot)?.focus?.();
|
|
119
100
|
};
|