@mustib/web-components 0.0.0-alpha.1 → 0.0.0-alpha.3
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/components/mu-element.d.ts +15 -6
- package/components/mu-element.js +1 -2
- package/components/mu-icon.d.ts +8 -2
- package/components/mu-icon.js +16 -11
- package/components/mu-range-fill.d.ts +9 -2
- package/components/mu-range-fill.js +7 -5
- package/components/mu-range-thumb-value.d.ts +9 -2
- package/components/mu-range-thumb-value.js +12 -10
- package/components/mu-range-thumb.d.ts +16 -2
- package/components/mu-range-thumb.js +32 -21
- package/components/mu-range.d.ts +15 -3
- package/components/mu-range.js +126 -56
- package/components/mu-select-item.d.ts +12 -3
- package/components/mu-select-item.js +17 -12
- package/components/mu-select-items.d.ts +26 -14
- package/components/mu-select-items.js +122 -60
- package/components/mu-select-label-content.d.ts +10 -3
- package/components/mu-select-label-content.js +16 -11
- package/components/mu-select-label.d.ts +12 -3
- package/components/mu-select-label.js +40 -26
- package/components/mu-select.d.ts +16 -8
- package/components/mu-select.js +66 -34
- package/components/mu-transparent.d.ts +10 -4
- package/components/mu-transparent.js +4 -6
- package/components/mu-trigger.d.ts +20 -4
- package/components/mu-trigger.js +57 -21
- package/index.d.ts +46 -13
- package/index.js +13 -14
- package/{mu-element-CZDI_RCY.js → mu-element-C36Rgp-m.js} +39 -30
- package/package.json +2 -7
- package/decorators.d.ts +0 -34
- package/decorators.js +0 -50
package/components/mu-range.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { M as
|
|
1
|
+
import { M as MuElement, _ as __decorate, t as throttle, d as debounce, w as wait, g as getElementBoundaries } from '../mu-element-C36Rgp-m.js';
|
|
2
2
|
import { css, html } from 'lit';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
|
-
import { MuRangeThumb } from './mu-range-thumb.js';
|
|
5
4
|
import { MuTransparent } from './mu-transparent.js';
|
|
6
5
|
import { MuRangeFill } from './mu-range-fill.js';
|
|
7
|
-
import '
|
|
6
|
+
import { MuRangeThumb } from './mu-range-thumb.js';
|
|
8
7
|
import './mu-range-thumb-value.js';
|
|
9
8
|
|
|
10
|
-
class MuRange extends
|
|
9
|
+
class MuRange extends MuElement {
|
|
11
10
|
get isControlled() {
|
|
12
11
|
return this.value !== undefined;
|
|
13
12
|
}
|
|
14
13
|
set activeThumb(thumb) {
|
|
15
|
-
if (thumb &&
|
|
14
|
+
if (thumb &&
|
|
15
|
+
(thumb.element.transparent ||
|
|
16
|
+
thumb.element.disabled ||
|
|
17
|
+
thumb.element.readonly))
|
|
16
18
|
return;
|
|
17
19
|
const prev = this._activeThumb;
|
|
18
20
|
if (prev)
|
|
@@ -96,7 +98,10 @@ class MuRange extends MUElement {
|
|
|
96
98
|
fillElements.push(element);
|
|
97
99
|
}
|
|
98
100
|
};
|
|
99
|
-
this.renderRoot
|
|
101
|
+
this.renderRoot
|
|
102
|
+
.querySelector('slot')
|
|
103
|
+
?.assignedElements({ flatten: true })
|
|
104
|
+
.forEach((el) => {
|
|
100
105
|
if (el instanceof MuTransparent) {
|
|
101
106
|
el.contents.forEach(assignElement);
|
|
102
107
|
}
|
|
@@ -111,7 +116,9 @@ class MuRange extends MUElement {
|
|
|
111
116
|
this.sortThumbs();
|
|
112
117
|
}
|
|
113
118
|
fillElements.forEach((element, i) => {
|
|
114
|
-
const thumbsNames = element.for
|
|
119
|
+
const thumbsNames = element.for
|
|
120
|
+
? element.for.split(',')
|
|
121
|
+
: [this._thumbs[i]?.name];
|
|
115
122
|
if (thumbsNames.length === 0) {
|
|
116
123
|
console.warn(`mu-range-fill has no thumb names`, element);
|
|
117
124
|
return;
|
|
@@ -129,9 +136,9 @@ class MuRange extends MUElement {
|
|
|
129
136
|
}, []);
|
|
130
137
|
const rangeFill = {
|
|
131
138
|
element,
|
|
132
|
-
linkedThumbs: thumbs
|
|
139
|
+
linkedThumbs: thumbs,
|
|
133
140
|
};
|
|
134
|
-
thumbs.forEach(thumb => {
|
|
141
|
+
thumbs.forEach((thumb) => {
|
|
135
142
|
if (thumb.linkedFillElements)
|
|
136
143
|
thumb.linkedFillElements.push(rangeFill);
|
|
137
144
|
else
|
|
@@ -143,8 +150,8 @@ class MuRange extends MUElement {
|
|
|
143
150
|
this._isReadyPromise.resolve();
|
|
144
151
|
}
|
|
145
152
|
else {
|
|
146
|
-
const deletedThumbs = [...previousThumbsElementsMap.values()].filter(thumb => !this._thumbsElementsMap.has(thumb.element));
|
|
147
|
-
const newThumbs = this._thumbs.filter(thumb => !previousThumbsElementsMap.has(thumb.element));
|
|
153
|
+
const deletedThumbs = [...previousThumbsElementsMap.values()].filter((thumb) => !this._thumbsElementsMap.has(thumb.element));
|
|
154
|
+
const newThumbs = this._thumbs.filter((thumb) => !previousThumbsElementsMap.has(thumb.element));
|
|
148
155
|
if (newThumbs.length) {
|
|
149
156
|
const eventName = 'mu-range-added-thumbs';
|
|
150
157
|
const event = new CustomEvent(eventName, {
|
|
@@ -152,8 +159,11 @@ class MuRange extends MUElement {
|
|
|
152
159
|
cancelable: true,
|
|
153
160
|
composed: true,
|
|
154
161
|
detail: {
|
|
155
|
-
data: newThumbs.map(thumb => ({
|
|
156
|
-
|
|
162
|
+
data: newThumbs.map((thumb) => ({
|
|
163
|
+
name: thumb.name,
|
|
164
|
+
value: thumb.value,
|
|
165
|
+
})),
|
|
166
|
+
},
|
|
157
167
|
});
|
|
158
168
|
this.dispatchEvent(event);
|
|
159
169
|
}
|
|
@@ -164,8 +174,11 @@ class MuRange extends MUElement {
|
|
|
164
174
|
cancelable: true,
|
|
165
175
|
composed: true,
|
|
166
176
|
detail: {
|
|
167
|
-
data: deletedThumbs.map(thumb => ({
|
|
168
|
-
|
|
177
|
+
data: deletedThumbs.map((thumb) => ({
|
|
178
|
+
name: thumb.name,
|
|
179
|
+
value: thumb.value,
|
|
180
|
+
})),
|
|
181
|
+
},
|
|
169
182
|
});
|
|
170
183
|
this.dispatchEvent(event);
|
|
171
184
|
}
|
|
@@ -182,15 +195,15 @@ class MuRange extends MUElement {
|
|
|
182
195
|
increaseKey = 'ArrowRight';
|
|
183
196
|
decreaseKey = 'ArrowLeft';
|
|
184
197
|
break;
|
|
185
|
-
case
|
|
198
|
+
case '-x':
|
|
186
199
|
decreaseKey = 'ArrowRight';
|
|
187
200
|
increaseKey = 'ArrowLeft';
|
|
188
201
|
break;
|
|
189
|
-
case
|
|
202
|
+
case 'y':
|
|
190
203
|
decreaseKey = 'ArrowDown';
|
|
191
204
|
increaseKey = 'ArrowUp';
|
|
192
205
|
break;
|
|
193
|
-
case
|
|
206
|
+
case '-y':
|
|
194
207
|
decreaseKey = 'ArrowUp';
|
|
195
208
|
increaseKey = 'ArrowDown';
|
|
196
209
|
break;
|
|
@@ -218,6 +231,7 @@ class MuRange extends MUElement {
|
|
|
218
231
|
break;
|
|
219
232
|
case 'End':
|
|
220
233
|
setValue(thumb.element.maxValue);
|
|
234
|
+
break;
|
|
221
235
|
case 'PageUp':
|
|
222
236
|
setValue(thumb.value + jumpStepValue);
|
|
223
237
|
break;
|
|
@@ -226,19 +240,21 @@ class MuRange extends MUElement {
|
|
|
226
240
|
break;
|
|
227
241
|
case 'Tab':
|
|
228
242
|
{
|
|
229
|
-
this.switchNavigationActiveItem(e.shiftKey ? 'prev' : 'next') &&
|
|
243
|
+
this.switchNavigationActiveItem(e.shiftKey ? 'prev' : 'next') &&
|
|
244
|
+
e.preventDefault();
|
|
230
245
|
}
|
|
231
246
|
break;
|
|
232
247
|
}
|
|
233
248
|
};
|
|
234
|
-
this._pointerdownHandler = (
|
|
249
|
+
this._pointerdownHandler = (e) => {
|
|
235
250
|
if (this.disabled || this.readonly || e.defaultPrevented)
|
|
236
251
|
return;
|
|
237
252
|
this._isPointerDown = true;
|
|
238
253
|
document.addEventListener('pointermove', this._documentPointermoveHandler);
|
|
239
254
|
document.addEventListener('pointerup', this._documentPointerupHandler);
|
|
240
|
-
const thumbEl =
|
|
241
|
-
if ((thumbEl && (thumbEl.disabled || thumbEl.readonly) ||
|
|
255
|
+
const thumbEl = MuElement.closestPierce('mu-range-thumb', e.target);
|
|
256
|
+
if ((thumbEl && (thumbEl.disabled || thumbEl.readonly)) ||
|
|
257
|
+
this.emptyArea === 'prevent')
|
|
242
258
|
return;
|
|
243
259
|
if (thumbEl && !thumbEl.transparent) {
|
|
244
260
|
const activeThumb = this._thumbsElementsMap.get(thumbEl);
|
|
@@ -251,7 +267,7 @@ class MuRange extends MUElement {
|
|
|
251
267
|
bubbles: true,
|
|
252
268
|
cancelable: true,
|
|
253
269
|
composed: true,
|
|
254
|
-
detail: { values: this._getValuesFromEvent(e) }
|
|
270
|
+
detail: { values: this._getValuesFromEvent(e) },
|
|
255
271
|
});
|
|
256
272
|
this.dispatchEvent(event);
|
|
257
273
|
return;
|
|
@@ -259,10 +275,14 @@ class MuRange extends MUElement {
|
|
|
259
275
|
this.emptyArea;
|
|
260
276
|
const { value } = this._getValuesFromEvent(e);
|
|
261
277
|
const shouldBreak = (item) => {
|
|
262
|
-
return ((item.element.disabled || item.element.readonly) &&
|
|
278
|
+
return ((item.element.disabled || item.element.readonly) &&
|
|
279
|
+
!(item.element.intersectBehavior === 'pass-over' ||
|
|
280
|
+
item.element.transparent));
|
|
263
281
|
};
|
|
264
282
|
const isNavigable = (item) => {
|
|
265
|
-
return !(item.element.transparent ||
|
|
283
|
+
return !(item.element.transparent ||
|
|
284
|
+
item.element.disabled ||
|
|
285
|
+
item.element.readonly);
|
|
266
286
|
};
|
|
267
287
|
const leftThumb = this.getNavigationItem({
|
|
268
288
|
direction: 'next',
|
|
@@ -291,13 +311,16 @@ class MuRange extends MUElement {
|
|
|
291
311
|
else if (!leftThumb)
|
|
292
312
|
candidateThumb = rightThumb;
|
|
293
313
|
else {
|
|
294
|
-
candidateThumb =
|
|
314
|
+
candidateThumb =
|
|
315
|
+
value - rightThumb.value > leftThumb.value - value
|
|
316
|
+
? leftThumb
|
|
317
|
+
: rightThumb;
|
|
295
318
|
}
|
|
296
319
|
if (candidateThumb) {
|
|
297
320
|
this._setThumbValue(candidateThumb, value);
|
|
298
321
|
this.activeThumb = candidateThumb;
|
|
299
322
|
}
|
|
300
|
-
}
|
|
323
|
+
};
|
|
301
324
|
this._documentPointerupHandler = (e) => {
|
|
302
325
|
this._isPointerDown = false;
|
|
303
326
|
document.removeEventListener('pointermove', this._documentPointermoveHandler);
|
|
@@ -326,7 +349,10 @@ class MuRange extends MUElement {
|
|
|
326
349
|
}
|
|
327
350
|
});
|
|
328
351
|
this.addEventListener('focus', (e) => {
|
|
329
|
-
if (this._isPointerDown ||
|
|
352
|
+
if (this._isPointerDown ||
|
|
353
|
+
this.disabled ||
|
|
354
|
+
this.readonly ||
|
|
355
|
+
e.defaultPrevented)
|
|
330
356
|
return;
|
|
331
357
|
if (this._activeThumb) {
|
|
332
358
|
e.preventDefault();
|
|
@@ -349,7 +375,10 @@ class MuRange extends MUElement {
|
|
|
349
375
|
* @returns an array of objects containing the name and value of each thumb
|
|
350
376
|
*/
|
|
351
377
|
getValue() {
|
|
352
|
-
return this._thumbs.map(thumb => ({
|
|
378
|
+
return this._thumbs.map((thumb) => ({
|
|
379
|
+
name: thumb.name,
|
|
380
|
+
value: thumb.value,
|
|
381
|
+
}));
|
|
353
382
|
}
|
|
354
383
|
/**
|
|
355
384
|
* Programmatically insert a thumb element
|
|
@@ -373,7 +402,9 @@ class MuRange extends MUElement {
|
|
|
373
402
|
items: this._thumbs,
|
|
374
403
|
fromIndex: this._activeThumb?.index,
|
|
375
404
|
isNavigable(item) {
|
|
376
|
-
return !(item.element.transparent ||
|
|
405
|
+
return !(item.element.transparent ||
|
|
406
|
+
item.element.disabled ||
|
|
407
|
+
item.element.readonly);
|
|
377
408
|
},
|
|
378
409
|
});
|
|
379
410
|
if (!navigationThumb)
|
|
@@ -385,8 +416,13 @@ class MuRange extends MUElement {
|
|
|
385
416
|
}
|
|
386
417
|
dispatchChangeEvent(thumbs = this._thumbs) {
|
|
387
418
|
const eventName = 'mu-range-change';
|
|
388
|
-
const data = thumbs.map(thumb => ({ name: thumb.name, value: thumb.value }));
|
|
389
|
-
this.dispatchEvent(new CustomEvent(eventName, {
|
|
419
|
+
const data = thumbs.map((thumb) => ({ name: thumb.name, value: thumb.value }));
|
|
420
|
+
this.dispatchEvent(new CustomEvent(eventName, {
|
|
421
|
+
bubbles: true,
|
|
422
|
+
composed: true,
|
|
423
|
+
detail: { data: data },
|
|
424
|
+
cancelable: true,
|
|
425
|
+
}));
|
|
390
426
|
}
|
|
391
427
|
_setThumbValue(thumb, value) {
|
|
392
428
|
const stepValue = this._getThumbStepValue(thumb, value);
|
|
@@ -394,7 +430,10 @@ class MuRange extends MUElement {
|
|
|
394
430
|
return;
|
|
395
431
|
if (this.isControlled) {
|
|
396
432
|
this.sortThumbs();
|
|
397
|
-
const sortedThumbs = this._thumbs.map(_thumb => ({
|
|
433
|
+
const sortedThumbs = this._thumbs.map((_thumb) => ({
|
|
434
|
+
name: _thumb.name,
|
|
435
|
+
value: _thumb.name === thumb.name ? stepValue : thumb.value,
|
|
436
|
+
}));
|
|
398
437
|
this.dispatchChangeEvent(sortedThumbs);
|
|
399
438
|
return;
|
|
400
439
|
}
|
|
@@ -421,11 +460,11 @@ class MuRange extends MUElement {
|
|
|
421
460
|
start = firstThumb.element.minValue;
|
|
422
461
|
end = firstThumb.element.value;
|
|
423
462
|
break;
|
|
424
|
-
case
|
|
463
|
+
case 'end':
|
|
425
464
|
start = firstThumb.element.value;
|
|
426
465
|
end = firstThumb.element.maxValue;
|
|
427
466
|
break;
|
|
428
|
-
case
|
|
467
|
+
case 'both':
|
|
429
468
|
start = firstThumb.element.minValue;
|
|
430
469
|
end = firstThumb.element.maxValue;
|
|
431
470
|
break;
|
|
@@ -433,12 +472,18 @@ class MuRange extends MUElement {
|
|
|
433
472
|
rangeFillEl.type;
|
|
434
473
|
break;
|
|
435
474
|
}
|
|
436
|
-
rangeFillEl.setPercentage([
|
|
475
|
+
rangeFillEl.setPercentage([
|
|
476
|
+
firstThumb.element.getPercentageFromValue(start),
|
|
477
|
+
firstThumb.element.getPercentageFromValue(end),
|
|
478
|
+
]);
|
|
437
479
|
}
|
|
438
480
|
else if (firstThumb && secondThumb) {
|
|
439
481
|
await firstThumb.element.updateComplete;
|
|
440
482
|
await secondThumb.element.updateComplete;
|
|
441
|
-
rangeFillEl.setPercentage([
|
|
483
|
+
rangeFillEl.setPercentage([
|
|
484
|
+
firstThumb.element.getPercentageFromValue(firstThumb.element.value),
|
|
485
|
+
secondThumb.element.getPercentageFromValue(secondThumb.element.value),
|
|
486
|
+
]);
|
|
442
487
|
}
|
|
443
488
|
}
|
|
444
489
|
/**
|
|
@@ -450,17 +495,18 @@ class MuRange extends MUElement {
|
|
|
450
495
|
const numOfSteps = Math.round(value / step);
|
|
451
496
|
let stepValue;
|
|
452
497
|
if (isAdd) {
|
|
453
|
-
stepValue = Math.min(thumb.element.maxValue, Math.max(thumb.element.minValue,
|
|
498
|
+
stepValue = Math.min(thumb.element.maxValue, Math.max(thumb.element.minValue, numOfSteps * step));
|
|
454
499
|
}
|
|
455
500
|
else {
|
|
456
|
-
stepValue = Math.min(thumb.element.maxValue, Math.max(thumb.element.minValue,
|
|
501
|
+
stepValue = Math.min(thumb.element.maxValue, Math.max(thumb.element.minValue, numOfSteps * step));
|
|
457
502
|
}
|
|
458
503
|
const nextThumb = this.getNavigationItem({
|
|
459
504
|
direction: 'next',
|
|
460
505
|
items: this._thumbs,
|
|
461
506
|
fromIndex: thumb.index,
|
|
462
507
|
isNavigable(item) {
|
|
463
|
-
return !(item.element.transparent ||
|
|
508
|
+
return !(item.element.transparent ||
|
|
509
|
+
item.element.intersectBehavior === 'pass-over');
|
|
464
510
|
},
|
|
465
511
|
});
|
|
466
512
|
const prevThumb = this.getNavigationItem({
|
|
@@ -468,12 +514,17 @@ class MuRange extends MUElement {
|
|
|
468
514
|
items: this._thumbs,
|
|
469
515
|
fromIndex: thumb.index,
|
|
470
516
|
isNavigable(item) {
|
|
471
|
-
return !(item.element.transparent ||
|
|
517
|
+
return !(item.element.transparent ||
|
|
518
|
+
item.element.intersectBehavior === 'pass-over');
|
|
472
519
|
},
|
|
473
520
|
});
|
|
474
|
-
if (isAdd &&
|
|
521
|
+
if (isAdd &&
|
|
522
|
+
nextThumb &&
|
|
523
|
+
nextThumb.element.intersectBehavior === 'prevent') {
|
|
475
524
|
const nextRemainder = nextThumb.value % step;
|
|
476
|
-
if (thumb.element.forceStep &&
|
|
525
|
+
if (thumb.element.forceStep &&
|
|
526
|
+
stepValue > nextThumb.value &&
|
|
527
|
+
nextRemainder !== 0) {
|
|
477
528
|
const newStep = nextThumb.value - nextRemainder;
|
|
478
529
|
const newStepRemainder = newStep % step;
|
|
479
530
|
stepValue = newStep - newStepRemainder;
|
|
@@ -481,9 +532,13 @@ class MuRange extends MUElement {
|
|
|
481
532
|
else
|
|
482
533
|
stepValue = Math.min(nextThumb.value, stepValue);
|
|
483
534
|
}
|
|
484
|
-
else if (!isAdd &&
|
|
535
|
+
else if (!isAdd &&
|
|
536
|
+
prevThumb &&
|
|
537
|
+
prevThumb.element.intersectBehavior === 'prevent') {
|
|
485
538
|
const prevRemainder = prevThumb.value % step;
|
|
486
|
-
if (thumb.element.forceStep &&
|
|
539
|
+
if (thumb.element.forceStep &&
|
|
540
|
+
stepValue < prevThumb.value &&
|
|
541
|
+
prevRemainder !== 0) {
|
|
487
542
|
const newStep = prevRemainder + prevThumb.value;
|
|
488
543
|
const newStepRemainder = newStep % step;
|
|
489
544
|
stepValue = newStep - newStepRemainder;
|
|
@@ -499,15 +554,25 @@ class MuRange extends MUElement {
|
|
|
499
554
|
_getValuesFromEvent(e) {
|
|
500
555
|
const direction = getComputedStyle(this).direction;
|
|
501
556
|
const boundaries = getElementBoundaries(this);
|
|
502
|
-
const xPoint =
|
|
503
|
-
const yPoint =
|
|
504
|
-
const mousePoint = this.axis === 'x'
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
557
|
+
const xPoint = e.clientX - boundaries.elementLeft;
|
|
558
|
+
const yPoint = e.clientY - boundaries.elementTop;
|
|
559
|
+
const mousePoint = this.axis === 'x'
|
|
560
|
+
? xPoint
|
|
561
|
+
: this.axis === '-x'
|
|
562
|
+
? boundaries.width - xPoint
|
|
563
|
+
: this.axis === 'y'
|
|
564
|
+
? yPoint
|
|
565
|
+
: boundaries.height - yPoint;
|
|
566
|
+
const elementSize = this.axis === 'x' || this.axis === '-x'
|
|
567
|
+
? boundaries.width
|
|
568
|
+
: boundaries.height;
|
|
569
|
+
const rawPercentage = Math.max(0, Math.min((mousePoint / elementSize) * 100, 100));
|
|
570
|
+
const percentage = direction === 'rtl' || this.axis === 'y' || this.axis === '-y'
|
|
571
|
+
? 100 - rawPercentage
|
|
572
|
+
: rawPercentage;
|
|
508
573
|
const minValue = this.min;
|
|
509
574
|
const maxValue = this.max;
|
|
510
|
-
const roundedPercentage =
|
|
575
|
+
const roundedPercentage = Math.round(percentage * 100) / 100;
|
|
511
576
|
const value = (percentage / 100) * (maxValue - minValue) + minValue;
|
|
512
577
|
return { roundedPercentage, value, percentage, rawPercentage };
|
|
513
578
|
}
|
|
@@ -515,7 +580,9 @@ class MuRange extends MUElement {
|
|
|
515
580
|
* sorts the thumbs
|
|
516
581
|
*/
|
|
517
582
|
sortThumbs() {
|
|
518
|
-
this._thumbs
|
|
583
|
+
this._thumbs
|
|
584
|
+
.sort((a, b) => a.value - b.value)
|
|
585
|
+
.forEach((thumb, i) => {
|
|
519
586
|
thumb.index = i;
|
|
520
587
|
});
|
|
521
588
|
}
|
|
@@ -597,7 +664,9 @@ class MuRange extends MUElement {
|
|
|
597
664
|
`;
|
|
598
665
|
}
|
|
599
666
|
}
|
|
600
|
-
MuRange.styles = [
|
|
667
|
+
MuRange.styles = [
|
|
668
|
+
MuElement.cssBase,
|
|
669
|
+
css `
|
|
601
670
|
#container {
|
|
602
671
|
--range-background-color: var(--mu-range-background-color, var(--mu-color-100));
|
|
603
672
|
--range-thickness: var(--mu-range-thickness, calc(var(--mu-base-rem) * .7));
|
|
@@ -611,7 +680,7 @@ MuRange.styles = [MUElement.cssBase, css `
|
|
|
611
680
|
position: absolute;
|
|
612
681
|
inset: -4px;
|
|
613
682
|
border-radius: inherit;
|
|
614
|
-
${
|
|
683
|
+
${MuElement.css.focus}
|
|
615
684
|
}
|
|
616
685
|
|
|
617
686
|
:host([axis='x']) #container,
|
|
@@ -636,7 +705,8 @@ MuRange.styles = [MUElement.cssBase, css `
|
|
|
636
705
|
}
|
|
637
706
|
}
|
|
638
707
|
|
|
639
|
-
|
|
708
|
+
`,
|
|
709
|
+
];
|
|
640
710
|
__decorate([
|
|
641
711
|
property({ reflect: true, type: String })
|
|
642
712
|
], MuRange.prototype, "axis", void 0);
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import { MUElement } from './mu-element.js';
|
|
2
1
|
import { PropertyValues } from 'lit';
|
|
2
|
+
import { MuElement, MuElementComponent } from './mu-element.js';
|
|
3
3
|
import '@mustib/utils/browser';
|
|
4
4
|
|
|
5
|
+
type MuSelectItemComponent = {
|
|
6
|
+
attributes: MuElementComponent['attributes'] & {
|
|
7
|
+
value: MuSelectItem['value'];
|
|
8
|
+
selected: MuSelectItem['selected'];
|
|
9
|
+
active: MuSelectItem['active'];
|
|
10
|
+
'filtered-out': MuSelectItem['filteredOut'];
|
|
11
|
+
};
|
|
12
|
+
};
|
|
5
13
|
/**
|
|
6
14
|
* This element is designed to be stateless, its purpose is to provide a means of adding custom markup and attributes
|
|
7
15
|
* without the need for controlling its state externally. It should not be modified by other parties, and its state is
|
|
8
16
|
* solely controlled by its controller.
|
|
9
17
|
*/
|
|
10
|
-
declare class MuSelectItem extends
|
|
18
|
+
declare class MuSelectItem extends MuElement {
|
|
11
19
|
static styles: any[];
|
|
12
20
|
eventActionData: undefined;
|
|
13
21
|
value: any;
|
|
@@ -22,8 +30,9 @@ declare class MuSelectItem extends MUElement {
|
|
|
22
30
|
}
|
|
23
31
|
declare global {
|
|
24
32
|
interface HTMLElementTagNameMap {
|
|
25
|
-
|
|
33
|
+
'mu-select-item': MuSelectItem;
|
|
26
34
|
}
|
|
27
35
|
}
|
|
28
36
|
|
|
29
37
|
export { MuSelectItem };
|
|
38
|
+
export type { MuSelectItemComponent };
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { M as
|
|
2
|
-
import { property } from 'lit/decorators.js';
|
|
1
|
+
import { M as MuElement, _ as __decorate } from '../mu-element-C36Rgp-m.js';
|
|
3
2
|
import { css, html } from 'lit';
|
|
4
|
-
import {
|
|
3
|
+
import { property } from 'lit/decorators.js';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* This element is designed to be stateless, its purpose is to provide a means of adding custom markup and attributes
|
|
8
7
|
* without the need for controlling its state externally. It should not be modified by other parties, and its state is
|
|
9
8
|
* solely controlled by its controller.
|
|
10
9
|
*/
|
|
11
|
-
class MuSelectItem extends
|
|
10
|
+
class MuSelectItem extends MuElement {
|
|
12
11
|
constructor() {
|
|
13
12
|
super(...arguments);
|
|
14
13
|
this.eventActionData = undefined;
|
|
@@ -51,7 +50,9 @@ class MuSelectItem extends MUElement {
|
|
|
51
50
|
`;
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
|
-
MuSelectItem.styles = [
|
|
53
|
+
MuSelectItem.styles = [
|
|
54
|
+
MuElement.cssBase,
|
|
55
|
+
css `
|
|
55
56
|
:host {
|
|
56
57
|
overflow: hidden;
|
|
57
58
|
}
|
|
@@ -61,7 +62,7 @@ MuSelectItem.styles = [MUElement.cssBase, css `
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
:host(:focus-visible) #container {
|
|
64
|
-
${
|
|
65
|
+
${MuElement.css.focus}
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
:host([active]) #container {
|
|
@@ -99,26 +100,30 @@ MuSelectItem.styles = [MUElement.cssBase, css `
|
|
|
99
100
|
--select-items-background-color: var(--mu-color-300);
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
|
-
|
|
103
|
+
`,
|
|
104
|
+
];
|
|
103
105
|
__decorate([
|
|
104
|
-
|
|
106
|
+
property()
|
|
105
107
|
], MuSelectItem.prototype, "value", void 0);
|
|
106
108
|
__decorate([
|
|
107
109
|
property({
|
|
108
|
-
reflect: true,
|
|
110
|
+
reflect: true,
|
|
111
|
+
type: Boolean,
|
|
109
112
|
})
|
|
110
113
|
], MuSelectItem.prototype, "selected", void 0);
|
|
111
114
|
__decorate([
|
|
112
115
|
property({
|
|
113
|
-
reflect: true,
|
|
116
|
+
reflect: true,
|
|
117
|
+
type: Boolean,
|
|
114
118
|
})
|
|
115
119
|
], MuSelectItem.prototype, "active", void 0);
|
|
116
120
|
__decorate([
|
|
117
121
|
property({
|
|
118
|
-
reflect: true,
|
|
122
|
+
reflect: true,
|
|
123
|
+
type: Boolean,
|
|
119
124
|
attribute: 'filtered-out',
|
|
120
125
|
})
|
|
121
126
|
], MuSelectItem.prototype, "filteredOut", void 0);
|
|
122
|
-
MuSelectItem.register(
|
|
127
|
+
MuSelectItem.register('mu-select-item');
|
|
123
128
|
|
|
124
129
|
export { MuSelectItem };
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EventAction, GenerateData } from '@mustib/utils/browser';
|
|
2
2
|
import { PropertyValues } from 'lit';
|
|
3
|
+
import { MuElement, MuElementComponent } from './mu-element.js';
|
|
3
4
|
import { MuSelectItem } from './mu-select-item.js';
|
|
4
|
-
import { EventAction, GenerateData } from '@mustib/utils/browser';
|
|
5
5
|
|
|
6
|
+
type MuSelectItemsComponent = {
|
|
7
|
+
attributes: MuElementComponent['attributes'] & {
|
|
8
|
+
opened: MuSelectItems['opened'];
|
|
9
|
+
multiple: MuSelectItems['multiple'];
|
|
10
|
+
value: MuSelectItems['value'];
|
|
11
|
+
'no-clear-active-on-close': MuSelectItems['noClearActiveOnClose'];
|
|
12
|
+
'default-value': MuSelectItems['defaultValue'];
|
|
13
|
+
position: MuSelectItems['position'];
|
|
14
|
+
'open-mode': MuSelectItems['openMode'];
|
|
15
|
+
};
|
|
16
|
+
events: Events;
|
|
17
|
+
};
|
|
6
18
|
type SelectItem = {
|
|
7
19
|
element: MuSelectItem;
|
|
8
20
|
value: string;
|
|
@@ -10,11 +22,11 @@ type SelectItem = {
|
|
|
10
22
|
active: boolean;
|
|
11
23
|
index: number;
|
|
12
24
|
};
|
|
13
|
-
type
|
|
25
|
+
type Events = {
|
|
14
26
|
/**
|
|
15
27
|
* this event is dispatched whenever the user selects an item
|
|
16
28
|
*/
|
|
17
|
-
|
|
29
|
+
'mu-select-items-change': CustomEvent<{
|
|
18
30
|
/**
|
|
19
31
|
* selected values
|
|
20
32
|
*/
|
|
@@ -31,7 +43,7 @@ type MuSelectItemsEvents = {
|
|
|
31
43
|
/**
|
|
32
44
|
* this event is dispatched whenever a slot items change and there are selected items that are no longer in the slot
|
|
33
45
|
*/
|
|
34
|
-
|
|
46
|
+
'mu-select-items-change-orphans': CustomEvent<{
|
|
35
47
|
/**
|
|
36
48
|
* selected values that are no longer in the slot
|
|
37
49
|
*/
|
|
@@ -52,7 +64,7 @@ type MuSelectItemsEvents = {
|
|
|
52
64
|
*
|
|
53
65
|
* In the default value case, the normal event should not be dispatched either, because the user didn't interact with the select, and the value is forced initially.
|
|
54
66
|
*/
|
|
55
|
-
|
|
67
|
+
'mu-select-items-change-forced': CustomEvent<{
|
|
56
68
|
/**
|
|
57
69
|
* selected values that are forced
|
|
58
70
|
*/
|
|
@@ -61,7 +73,7 @@ type MuSelectItemsEvents = {
|
|
|
61
73
|
/**
|
|
62
74
|
* this event is dispatched whenever the active item changes
|
|
63
75
|
*/
|
|
64
|
-
|
|
76
|
+
'mu-select-items-active-item-change': CustomEvent<{
|
|
65
77
|
id: string | undefined;
|
|
66
78
|
}>;
|
|
67
79
|
};
|
|
@@ -71,7 +83,7 @@ type SwitchActiveItemOptions = Partial<{
|
|
|
71
83
|
*/
|
|
72
84
|
switchBack: boolean;
|
|
73
85
|
}>;
|
|
74
|
-
declare class MuSelectItems extends
|
|
86
|
+
declare class MuSelectItems extends MuElement {
|
|
75
87
|
static styles: any[];
|
|
76
88
|
static eventAction: EventAction<GenerateData<MuSelectItems>>;
|
|
77
89
|
opened: boolean;
|
|
@@ -132,7 +144,7 @@ declare class MuSelectItems extends MUElement {
|
|
|
132
144
|
* Used by parent to focus the first or last navigable item when opened
|
|
133
145
|
*/
|
|
134
146
|
focusFirstNavigableItem(direction: 'next' | 'prev'): void;
|
|
135
|
-
protected _getNavigationItem({ direction, switchBack, fromIndex }: {
|
|
147
|
+
protected _getNavigationItem({ direction, switchBack, fromIndex, }: {
|
|
136
148
|
fromIndex?: number;
|
|
137
149
|
direction: 'next' | 'prev';
|
|
138
150
|
switchBack: boolean;
|
|
@@ -174,8 +186,8 @@ declare class MuSelectItems extends MUElement {
|
|
|
174
186
|
*
|
|
175
187
|
*/
|
|
176
188
|
protected _clearSelectState(): void;
|
|
177
|
-
_dispatchChangeEvent(detail:
|
|
178
|
-
_debounceDispatchChangeEvent: (detail:
|
|
189
|
+
_dispatchChangeEvent(detail: Events['mu-select-items-change']['detail']): void;
|
|
190
|
+
_debounceDispatchChangeEvent: (detail: Events["mu-select-items-change"]["detail"]) => void;
|
|
179
191
|
/**
|
|
180
192
|
* Modifies the selection state of a specified item.
|
|
181
193
|
* @param type Specifies the operation to perform:
|
|
@@ -208,11 +220,11 @@ declare class MuSelectItems extends MUElement {
|
|
|
208
220
|
}
|
|
209
221
|
declare global {
|
|
210
222
|
interface HTMLElementTagNameMap {
|
|
211
|
-
|
|
223
|
+
'mu-select-items': MuSelectItems;
|
|
212
224
|
}
|
|
213
|
-
interface GlobalEventHandlersEventMap extends
|
|
225
|
+
interface GlobalEventHandlersEventMap extends Events {
|
|
214
226
|
}
|
|
215
227
|
}
|
|
216
228
|
|
|
217
229
|
export { MuSelectItems };
|
|
218
|
-
export type {
|
|
230
|
+
export type { Events, MuSelectItemsComponent };
|