@mintplayer/web-components 1.1.0 → 1.3.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/src/styles/accordion.styles.d.ts +2 -0
- package/card/index.mjs +246 -363
- package/card/src/card-classes.d.ts +0 -7
- package/card/src/card-global.styles.d.ts +2 -0
- package/card/src/index.d.ts +0 -9
- package/card/src/mp-card.element.d.ts +45 -18
- package/chunks/mp-datatable-Con0yQue.mjs +1125 -0
- package/datatable/index.mjs +1 -1
- package/datatable/src/components/mp-datatable.d.ts +105 -1
- package/datatable/src/index.d.ts +1 -1
- package/datatable/src/types/column-def.d.ts +12 -1
- package/datatable/src/types/index.d.ts +2 -1
- package/datatable/src/types/tree.d.ts +42 -0
- package/file-manager/index.mjs +1 -1
- package/package.json +1 -1
- package/timeline/index.mjs +716 -0
- package/timeline/src/components/index.d.ts +2 -0
- package/timeline/src/components/mp-timeline-item.d.ts +63 -0
- package/timeline/src/components/mp-timeline.d.ts +85 -0
- package/timeline/src/index.d.ts +5 -0
- package/timeline/src/styles/index.d.ts +2 -0
- package/timeline/src/styles/timeline-item.styles.d.ts +2 -0
- package/timeline/src/styles/timeline.styles.d.ts +2 -0
- package/timeline-core/index.mjs +23 -0
- package/timeline-core/src/index.d.ts +2 -0
- package/timeline-core/src/models/context.d.ts +39 -0
- package/timeline-core/src/models/index.d.ts +2 -0
- package/timeline-core/src/models/timeline-item.d.ts +44 -0
- package/timeline-core/src/resolve-sides.d.ts +12 -0
- package/card/src/mp-card-body.element.d.ts +0 -12
- package/card/src/mp-card-footer.element.d.ts +0 -14
- package/card/src/mp-card-group.element.d.ts +0 -9
- package/card/src/mp-card-header.element.d.ts +0 -24
- package/card/src/mp-card-img.element.d.ts +0 -28
- package/card/src/mp-card-link.element.d.ts +0 -24
- package/card/src/mp-card-subtitle.element.d.ts +0 -9
- package/card/src/mp-card-text.element.d.ts +0 -9
- package/card/src/mp-card-title.element.d.ts +0 -13
- package/chunks/mp-datatable-CpAu8JJD.mjs +0 -750
|
@@ -0,0 +1,716 @@
|
|
|
1
|
+
import { unsafeCSS as f, LitElement as _, nothing as a, html as m, isServer as u } from "lit";
|
|
2
|
+
import { resolveSides as b } from "../timeline-core/index.mjs";
|
|
3
|
+
const S = f(`:host {
|
|
4
|
+
display: block;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
--mp-tl-gap: 1rem;
|
|
7
|
+
--mp-tl-line-width: 2px;
|
|
8
|
+
--mp-tl-line-color: var(--bs-border-color, #dee2e6);
|
|
9
|
+
--mp-tl-marker-size: 1rem;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
* {
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.timeline {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
margin: 0;
|
|
20
|
+
padding: 0;
|
|
21
|
+
list-style: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.timeline > slot {
|
|
25
|
+
display: contents;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
::slotted(mp-timeline-item),
|
|
29
|
+
.timeline mp-timeline-item {
|
|
30
|
+
display: block;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
:host([orientation=horizontal]) .timeline {
|
|
34
|
+
flex-direction: row;
|
|
35
|
+
align-items: stretch;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
:host([orientation=horizontal]) ::slotted(mp-timeline-item),
|
|
39
|
+
:host([orientation=horizontal]) .timeline mp-timeline-item {
|
|
40
|
+
flex: 1 1 0;
|
|
41
|
+
min-width: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
:host([reverse]) .timeline {
|
|
45
|
+
flex-direction: column-reverse;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
:host([orientation=horizontal][reverse]) .timeline {
|
|
49
|
+
flex-direction: row-reverse;
|
|
50
|
+
}`), A = f(`:host {
|
|
51
|
+
display: block;
|
|
52
|
+
box-sizing: border-box;
|
|
53
|
+
outline: none;
|
|
54
|
+
--mp-tl-gap: 1rem;
|
|
55
|
+
--mp-tl-line-width: 2px;
|
|
56
|
+
--mp-tl-line-color: var(--bs-border-color, #dee2e6);
|
|
57
|
+
--mp-tl-marker-size: 1rem;
|
|
58
|
+
--mp-tl-marker-color: var(--mp-tl-item-color, var(--bs-primary, #0d6efd));
|
|
59
|
+
--mp-tl-connector-color: var(--mp-tl-item-color, var(--mp-tl-line-color));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
* {
|
|
63
|
+
box-sizing: border-box;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.item {
|
|
67
|
+
display: grid;
|
|
68
|
+
grid-template-columns: 1fr auto 1fr;
|
|
69
|
+
column-gap: var(--mp-tl-gap);
|
|
70
|
+
align-items: start;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.content {
|
|
74
|
+
grid-row: 1;
|
|
75
|
+
grid-column: 1;
|
|
76
|
+
min-width: 0;
|
|
77
|
+
padding-bottom: var(--mp-tl-gap);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.line {
|
|
81
|
+
grid-row: 1;
|
|
82
|
+
grid-column: 2;
|
|
83
|
+
display: flex;
|
|
84
|
+
flex-direction: column;
|
|
85
|
+
align-items: center;
|
|
86
|
+
align-self: stretch;
|
|
87
|
+
min-height: 100%;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.opposite {
|
|
91
|
+
grid-row: 1;
|
|
92
|
+
grid-column: 3;
|
|
93
|
+
min-width: 0;
|
|
94
|
+
padding-bottom: var(--mp-tl-gap);
|
|
95
|
+
color: var(--bs-secondary-color, #6c757d);
|
|
96
|
+
font-size: 0.875rem;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
:host([side=end]) .content {
|
|
100
|
+
grid-column: 3;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
:host([side=end]) .opposite {
|
|
104
|
+
grid-column: 1;
|
|
105
|
+
text-align: end;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.marker {
|
|
109
|
+
flex: 0 0 auto;
|
|
110
|
+
display: inline-flex;
|
|
111
|
+
align-items: center;
|
|
112
|
+
justify-content: center;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.marker-dot {
|
|
116
|
+
flex: 0 0 auto;
|
|
117
|
+
width: var(--mp-tl-marker-size);
|
|
118
|
+
height: var(--mp-tl-marker-size);
|
|
119
|
+
border-radius: 50%;
|
|
120
|
+
background: var(--mp-tl-marker-color);
|
|
121
|
+
display: inline-flex;
|
|
122
|
+
align-items: center;
|
|
123
|
+
justify-content: center;
|
|
124
|
+
color: #fff;
|
|
125
|
+
font-size: calc(var(--mp-tl-marker-size) * 0.7);
|
|
126
|
+
line-height: 1;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.connector {
|
|
130
|
+
flex: 1 1 auto;
|
|
131
|
+
width: var(--mp-tl-line-width);
|
|
132
|
+
min-height: var(--mp-tl-gap);
|
|
133
|
+
background: var(--mp-tl-connector-color);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
:host([last]) .connector {
|
|
137
|
+
display: none;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.title {
|
|
141
|
+
font-weight: 600;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.body {
|
|
145
|
+
color: var(--bs-body-color);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
:host([disabled]) {
|
|
149
|
+
opacity: 0.55;
|
|
150
|
+
pointer-events: none;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
:host([selected]) .marker-dot {
|
|
154
|
+
box-shadow: 0 0 0 3px var(--bs-primary-bg-subtle, rgba(13, 110, 253, 0.35));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
:host(:focus-visible) .item {
|
|
158
|
+
outline: 2px solid var(--bs-primary, #0d6efd);
|
|
159
|
+
outline-offset: 2px;
|
|
160
|
+
border-radius: var(--bs-border-radius, 0.375rem);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
:host([orientation=horizontal]) .item {
|
|
164
|
+
grid-template-columns: minmax(0, 1fr);
|
|
165
|
+
grid-template-rows: 1fr auto 1fr;
|
|
166
|
+
row-gap: var(--mp-tl-gap);
|
|
167
|
+
column-gap: 0;
|
|
168
|
+
height: 100%;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
:host([orientation=horizontal]) .content {
|
|
172
|
+
grid-row: 3;
|
|
173
|
+
grid-column: 1;
|
|
174
|
+
padding: 0 var(--mp-tl-gap) 0 0;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
:host([orientation=horizontal]) .opposite {
|
|
178
|
+
grid-row: 1;
|
|
179
|
+
grid-column: 1;
|
|
180
|
+
padding: 0 var(--mp-tl-gap) 0 0;
|
|
181
|
+
text-align: start;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
:host([orientation=horizontal][side=end]) .content {
|
|
185
|
+
grid-row: 1;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
:host([orientation=horizontal][side=end]) .opposite {
|
|
189
|
+
grid-row: 3;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
:host([orientation=horizontal]) .line {
|
|
193
|
+
grid-row: 2;
|
|
194
|
+
grid-column: 1;
|
|
195
|
+
flex-direction: row;
|
|
196
|
+
align-self: center;
|
|
197
|
+
justify-self: stretch;
|
|
198
|
+
min-height: 0;
|
|
199
|
+
min-width: 100%;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
:host([orientation=horizontal]) .connector {
|
|
203
|
+
width: auto;
|
|
204
|
+
height: var(--mp-tl-line-width);
|
|
205
|
+
min-height: 0;
|
|
206
|
+
min-width: var(--mp-tl-gap);
|
|
207
|
+
}`);
|
|
208
|
+
class I extends _ {
|
|
209
|
+
constructor() {
|
|
210
|
+
super(...arguments), this._itemId = null, this._title = null, this._description = null, this._time = null, this._icon = null, this._color = null, this._itemClass = null, this._disabled = !1, this._selected = !1;
|
|
211
|
+
}
|
|
212
|
+
static {
|
|
213
|
+
this.styles = [A];
|
|
214
|
+
}
|
|
215
|
+
static get observedAttributes() {
|
|
216
|
+
return [
|
|
217
|
+
...super.observedAttributes ?? [],
|
|
218
|
+
"item-id",
|
|
219
|
+
"title",
|
|
220
|
+
"description",
|
|
221
|
+
"time",
|
|
222
|
+
"icon",
|
|
223
|
+
"color",
|
|
224
|
+
"disabled",
|
|
225
|
+
"item-class",
|
|
226
|
+
"selected",
|
|
227
|
+
// Parent-managed layout attributes (CSS-only; no backing property).
|
|
228
|
+
"side",
|
|
229
|
+
"orientation",
|
|
230
|
+
"last"
|
|
231
|
+
];
|
|
232
|
+
}
|
|
233
|
+
get itemId() {
|
|
234
|
+
return this._itemId;
|
|
235
|
+
}
|
|
236
|
+
set itemId(t) {
|
|
237
|
+
const e = t ?? null;
|
|
238
|
+
this._itemId !== e && (this._itemId = e, this.reflectString("item-id", e === null ? null : String(e)));
|
|
239
|
+
}
|
|
240
|
+
// `title` is intentionally NOT redefined: the native HTMLElement.title
|
|
241
|
+
// property already reflects to the `title` attribute, which we mirror into
|
|
242
|
+
// `_title` via attributeChangedCallback. (Redefining it would conflict with
|
|
243
|
+
// the inherited `string` typing.)
|
|
244
|
+
get description() {
|
|
245
|
+
return this._description;
|
|
246
|
+
}
|
|
247
|
+
set description(t) {
|
|
248
|
+
const e = t ?? null;
|
|
249
|
+
this._description !== e && (this._description = e, this.reflectString("description", e), this.requestUpdate());
|
|
250
|
+
}
|
|
251
|
+
get time() {
|
|
252
|
+
return this._time;
|
|
253
|
+
}
|
|
254
|
+
set time(t) {
|
|
255
|
+
const e = t ?? null;
|
|
256
|
+
this._time !== e && (this._time = e, this.reflectString("time", e), this.requestUpdate());
|
|
257
|
+
}
|
|
258
|
+
get icon() {
|
|
259
|
+
return this._icon;
|
|
260
|
+
}
|
|
261
|
+
set icon(t) {
|
|
262
|
+
const e = t ?? null;
|
|
263
|
+
this._icon !== e && (this._icon = e, this.reflectString("icon", e), this.requestUpdate());
|
|
264
|
+
}
|
|
265
|
+
get color() {
|
|
266
|
+
return this._color;
|
|
267
|
+
}
|
|
268
|
+
set color(t) {
|
|
269
|
+
const e = t ?? null;
|
|
270
|
+
this._color !== e && (this._color = e, this.reflectString("color", e), this.requestUpdate());
|
|
271
|
+
}
|
|
272
|
+
get itemClass() {
|
|
273
|
+
return this._itemClass;
|
|
274
|
+
}
|
|
275
|
+
set itemClass(t) {
|
|
276
|
+
const e = t ?? null;
|
|
277
|
+
this._itemClass !== e && (this._itemClass = e, this.reflectString("item-class", e), this.requestUpdate());
|
|
278
|
+
}
|
|
279
|
+
get disabled() {
|
|
280
|
+
return this._disabled;
|
|
281
|
+
}
|
|
282
|
+
set disabled(t) {
|
|
283
|
+
const e = !!t;
|
|
284
|
+
this._disabled !== e && (this._disabled = e, this.reflectBoolean("disabled", e));
|
|
285
|
+
}
|
|
286
|
+
get selected() {
|
|
287
|
+
return this._selected;
|
|
288
|
+
}
|
|
289
|
+
set selected(t) {
|
|
290
|
+
const e = !!t;
|
|
291
|
+
this._selected !== e && (this._selected = e, this.reflectBoolean("selected", e));
|
|
292
|
+
}
|
|
293
|
+
connectedCallback() {
|
|
294
|
+
super.connectedCallback(), this.hasAttribute("role") || this.setAttribute("role", "listitem");
|
|
295
|
+
}
|
|
296
|
+
attributeChangedCallback(t, e, i) {
|
|
297
|
+
if (super.attributeChangedCallback(t, e, i), e !== i) {
|
|
298
|
+
switch (t) {
|
|
299
|
+
case "item-id":
|
|
300
|
+
(this._itemId === null || String(this._itemId) !== i) && (this._itemId = i);
|
|
301
|
+
break;
|
|
302
|
+
case "title":
|
|
303
|
+
this._title = i;
|
|
304
|
+
break;
|
|
305
|
+
case "description":
|
|
306
|
+
this._description = i;
|
|
307
|
+
break;
|
|
308
|
+
case "time":
|
|
309
|
+
this._time = i;
|
|
310
|
+
break;
|
|
311
|
+
case "icon":
|
|
312
|
+
this._icon = i;
|
|
313
|
+
break;
|
|
314
|
+
case "color":
|
|
315
|
+
this._color = i;
|
|
316
|
+
break;
|
|
317
|
+
case "item-class":
|
|
318
|
+
this._itemClass = i;
|
|
319
|
+
break;
|
|
320
|
+
case "disabled":
|
|
321
|
+
this._disabled = i !== null;
|
|
322
|
+
break;
|
|
323
|
+
case "selected":
|
|
324
|
+
this._selected = i !== null;
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
this.requestUpdate();
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/** Mirror the per-item accent colour onto a CSS custom property. */
|
|
331
|
+
updated() {
|
|
332
|
+
this._color ? this.style.setProperty("--mp-tl-item-color", this._color) : this.style.removeProperty("--mp-tl-item-color");
|
|
333
|
+
}
|
|
334
|
+
reflectString(t, e) {
|
|
335
|
+
e === null ? this.hasAttribute(t) && this.removeAttribute(t) : this.getAttribute(t) !== e && this.setAttribute(t, e);
|
|
336
|
+
}
|
|
337
|
+
reflectBoolean(t, e) {
|
|
338
|
+
e ? this.hasAttribute(t) || this.setAttribute(t, "") : this.hasAttribute(t) && this.removeAttribute(t);
|
|
339
|
+
}
|
|
340
|
+
render() {
|
|
341
|
+
return m`
|
|
342
|
+
<div class="item ${this._itemClass ?? ""}">
|
|
343
|
+
<div class="opposite">
|
|
344
|
+
<slot name="opposite"><slot name="timestamp">${this._time ?? a}</slot></slot>
|
|
345
|
+
</div>
|
|
346
|
+
<div class="line">
|
|
347
|
+
<span class="marker">
|
|
348
|
+
<slot name="marker">
|
|
349
|
+
<span class="marker-dot">
|
|
350
|
+
${this._icon ? m`<i class=${this._icon} aria-hidden="true"></i>` : a}
|
|
351
|
+
</span>
|
|
352
|
+
</slot>
|
|
353
|
+
</span>
|
|
354
|
+
<span class="connector"><slot name="connector"></slot></span>
|
|
355
|
+
</div>
|
|
356
|
+
<div class="content">
|
|
357
|
+
<div class="title"><slot name="title">${this._title ?? a}</slot></div>
|
|
358
|
+
<div class="body">
|
|
359
|
+
<!-- Only the named content slot - no default slot. A default slot
|
|
360
|
+
would let stray whitespace in the consumer's light DOM claim it
|
|
361
|
+
(and suppress any nested fallback), leaving slotted content with
|
|
362
|
+
no rendered box. The description attribute is the fallback. -->
|
|
363
|
+
<slot name="content">${this._description ?? a}</slot>
|
|
364
|
+
</div>
|
|
365
|
+
</div>
|
|
366
|
+
</div>
|
|
367
|
+
`;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
typeof customElements < "u" && !customElements.get("mp-timeline-item") && customElements.define("mp-timeline-item", I);
|
|
371
|
+
const p = /* @__PURE__ */ new Set([
|
|
372
|
+
"start",
|
|
373
|
+
"end",
|
|
374
|
+
"alternate",
|
|
375
|
+
"alternate-reverse"
|
|
376
|
+
]), g = /* @__PURE__ */ new Set(["none", "single", "multiple"]);
|
|
377
|
+
class y extends _ {
|
|
378
|
+
constructor() {
|
|
379
|
+
super(...arguments), this._items = [], this._selectedSet = /* @__PURE__ */ new Set(), this._orientation = "vertical", this._align = "start", this._reverse = !1, this._selectable = "none", this._isServerSide = !1, this._selectionExplicit = !1, this._selectionSeeded = !1, this._activeIndex = -1, this._anchorIndex = -1, this._observer = null, this.onSlotChange = () => {
|
|
380
|
+
this.seedDeclarativeSelection(), this.enhanceDeclarativeItems();
|
|
381
|
+
}, this.onClick = (t) => {
|
|
382
|
+
const { el: e, index: i } = this.itemFromEvent(t);
|
|
383
|
+
if (!e || i < 0 || e.hasAttribute("disabled")) return;
|
|
384
|
+
const o = this.modelFor(e, i);
|
|
385
|
+
if (this.dispatchEvent(
|
|
386
|
+
new CustomEvent("item-click", {
|
|
387
|
+
detail: { item: o, index: i, originalEvent: t },
|
|
388
|
+
bubbles: !0,
|
|
389
|
+
composed: !0
|
|
390
|
+
})
|
|
391
|
+
), this._selectable !== "none") {
|
|
392
|
+
const s = t;
|
|
393
|
+
this.applySelection(i, { toggle: s.ctrlKey || s.metaKey, range: s.shiftKey }), this.setActiveIndex(i);
|
|
394
|
+
}
|
|
395
|
+
}, this.onKeydown = (t) => {
|
|
396
|
+
if (this._selectable === "none") return;
|
|
397
|
+
const e = this.itemElements;
|
|
398
|
+
if (!e.length) return;
|
|
399
|
+
const i = this.itemFromEvent(t).index;
|
|
400
|
+
switch (t.key) {
|
|
401
|
+
case "ArrowDown":
|
|
402
|
+
case "ArrowRight": {
|
|
403
|
+
t.preventDefault(), this.moveFocus(i, 1, e);
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
case "ArrowUp":
|
|
407
|
+
case "ArrowLeft": {
|
|
408
|
+
t.preventDefault(), this.moveFocus(i, -1, e);
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
case "Home": {
|
|
412
|
+
t.preventDefault(), this.moveFocusTo(this.firstFocusable(e), e);
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
case "End": {
|
|
416
|
+
t.preventDefault(), this.moveFocusTo(this.lastFocusable(e), e);
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
case "Enter":
|
|
420
|
+
case " ": {
|
|
421
|
+
if (i < 0) return;
|
|
422
|
+
t.preventDefault(), this.applySelection(i, {
|
|
423
|
+
toggle: t.key === " " && this._selectable === "multiple",
|
|
424
|
+
range: t.shiftKey
|
|
425
|
+
});
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
static {
|
|
432
|
+
this.styles = [S];
|
|
433
|
+
}
|
|
434
|
+
static get observedAttributes() {
|
|
435
|
+
return [
|
|
436
|
+
...super.observedAttributes ?? [],
|
|
437
|
+
"orientation",
|
|
438
|
+
"align",
|
|
439
|
+
"reverse",
|
|
440
|
+
"selectable",
|
|
441
|
+
"is-server-side"
|
|
442
|
+
];
|
|
443
|
+
}
|
|
444
|
+
// ----- properties --------------------------------------------------------
|
|
445
|
+
get items() {
|
|
446
|
+
return this._items;
|
|
447
|
+
}
|
|
448
|
+
set items(t) {
|
|
449
|
+
this._items = Array.isArray(t) ? t : [], this.requestUpdate();
|
|
450
|
+
}
|
|
451
|
+
get selectedIds() {
|
|
452
|
+
return Array.from(this._selectedSet);
|
|
453
|
+
}
|
|
454
|
+
set selectedIds(t) {
|
|
455
|
+
this._selectionExplicit = !0, this._selectedSet = new Set(t ?? []), this.requestUpdate();
|
|
456
|
+
}
|
|
457
|
+
get orientation() {
|
|
458
|
+
return this._orientation;
|
|
459
|
+
}
|
|
460
|
+
set orientation(t) {
|
|
461
|
+
const e = t === "horizontal" ? "horizontal" : "vertical";
|
|
462
|
+
this._orientation !== e && (this._orientation = e, this.reflectString("orientation", e), this.requestUpdate());
|
|
463
|
+
}
|
|
464
|
+
get align() {
|
|
465
|
+
return this._align;
|
|
466
|
+
}
|
|
467
|
+
set align(t) {
|
|
468
|
+
const e = p.has(t) ? t : "start";
|
|
469
|
+
this._align !== e && (this._align = e, this.reflectString("align", e), this.requestUpdate());
|
|
470
|
+
}
|
|
471
|
+
get reverse() {
|
|
472
|
+
return this._reverse;
|
|
473
|
+
}
|
|
474
|
+
set reverse(t) {
|
|
475
|
+
const e = !!t;
|
|
476
|
+
this._reverse !== e && (this._reverse = e, this.reflectBoolean("reverse", e), this.requestUpdate());
|
|
477
|
+
}
|
|
478
|
+
get selectable() {
|
|
479
|
+
return this._selectable;
|
|
480
|
+
}
|
|
481
|
+
set selectable(t) {
|
|
482
|
+
const e = g.has(t) ? t : "none";
|
|
483
|
+
this._selectable !== e && (this._selectable = e, this.reflectString("selectable", e), this.requestUpdate());
|
|
484
|
+
}
|
|
485
|
+
get isServerSide() {
|
|
486
|
+
return this._isServerSide;
|
|
487
|
+
}
|
|
488
|
+
set isServerSide(t) {
|
|
489
|
+
const e = !!t;
|
|
490
|
+
this._isServerSide !== e && (this._isServerSide = e, this.reflectBoolean("is-server-side", e));
|
|
491
|
+
}
|
|
492
|
+
// ----- lifecycle ---------------------------------------------------------
|
|
493
|
+
connectedCallback() {
|
|
494
|
+
super.connectedCallback(), !u && !this._observer && (this._observer = new MutationObserver(() => {
|
|
495
|
+
this.seedDeclarativeSelection(), this.enhanceDeclarativeItems();
|
|
496
|
+
}), this._observer.observe(this, {
|
|
497
|
+
childList: !0,
|
|
498
|
+
subtree: !0,
|
|
499
|
+
attributes: !0,
|
|
500
|
+
attributeFilter: ["disabled", "item-id"]
|
|
501
|
+
}));
|
|
502
|
+
}
|
|
503
|
+
disconnectedCallback() {
|
|
504
|
+
super.disconnectedCallback(), this._observer?.disconnect(), this._observer = null;
|
|
505
|
+
}
|
|
506
|
+
attributeChangedCallback(t, e, i) {
|
|
507
|
+
if (super.attributeChangedCallback(t, e, i), e !== i) {
|
|
508
|
+
switch (t) {
|
|
509
|
+
case "orientation":
|
|
510
|
+
this._orientation = i === "horizontal" ? "horizontal" : "vertical";
|
|
511
|
+
break;
|
|
512
|
+
case "align":
|
|
513
|
+
this._align = i && p.has(i) ? i : "start";
|
|
514
|
+
break;
|
|
515
|
+
case "reverse":
|
|
516
|
+
this._reverse = i !== null && i !== "false";
|
|
517
|
+
break;
|
|
518
|
+
case "selectable":
|
|
519
|
+
this._selectable = i && g.has(i) ? i : "none";
|
|
520
|
+
break;
|
|
521
|
+
case "is-server-side":
|
|
522
|
+
this._isServerSide = i !== null && i !== "false";
|
|
523
|
+
break;
|
|
524
|
+
}
|
|
525
|
+
this.requestUpdate();
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
updated() {
|
|
529
|
+
!u && this._items.length === 0 && this.enhanceDeclarativeItems();
|
|
530
|
+
}
|
|
531
|
+
reflectString(t, e) {
|
|
532
|
+
this.getAttribute(t) !== e && this.setAttribute(t, e);
|
|
533
|
+
}
|
|
534
|
+
reflectBoolean(t, e) {
|
|
535
|
+
e ? this.hasAttribute(t) || this.setAttribute(t, "") : this.hasAttribute(t) && this.removeAttribute(t);
|
|
536
|
+
}
|
|
537
|
+
// ----- identity ----------------------------------------------------------
|
|
538
|
+
idForItem(t, e) {
|
|
539
|
+
return t.id ?? e;
|
|
540
|
+
}
|
|
541
|
+
idForElement(t, e) {
|
|
542
|
+
return t.getAttribute("item-id") ?? e;
|
|
543
|
+
}
|
|
544
|
+
isSelected(t) {
|
|
545
|
+
return this._selectedSet.has(t);
|
|
546
|
+
}
|
|
547
|
+
// ----- render ------------------------------------------------------------
|
|
548
|
+
render() {
|
|
549
|
+
const t = this._selectable !== "none" ? "listbox" : "list";
|
|
550
|
+
return m`
|
|
551
|
+
<div
|
|
552
|
+
class="timeline"
|
|
553
|
+
role=${t}
|
|
554
|
+
aria-orientation=${this._orientation}
|
|
555
|
+
aria-multiselectable=${this._selectable === "multiple" ? "true" : a}
|
|
556
|
+
@click=${this.onClick}
|
|
557
|
+
@keydown=${this.onKeydown}
|
|
558
|
+
>
|
|
559
|
+
${this._items.length ? this.renderDataItems() : m`<slot @slotchange=${this.onSlotChange}></slot>`}
|
|
560
|
+
</div>
|
|
561
|
+
`;
|
|
562
|
+
}
|
|
563
|
+
renderDataItems() {
|
|
564
|
+
const t = this._items, e = this._orientation, i = this._selectable, o = this._reverse, s = b(t.length, this._align, o), l = this.resolvedActiveIndex(t.length, (r) => !t[r].disabled);
|
|
565
|
+
return m`
|
|
566
|
+
${t.map((r, n) => {
|
|
567
|
+
const c = this.idForItem(r, n), d = o ? n === 0 : n === t.length - 1, h = i !== "none" && this.isSelected(c), x = r.time instanceof Date ? r.time.toLocaleDateString() : r.time;
|
|
568
|
+
return m`<mp-timeline-item
|
|
569
|
+
item-id=${r.id ?? a}
|
|
570
|
+
title=${r.title ?? a}
|
|
571
|
+
description=${r.description ?? a}
|
|
572
|
+
time=${x ?? a}
|
|
573
|
+
icon=${r.icon ?? a}
|
|
574
|
+
color=${r.color ?? a}
|
|
575
|
+
item-class=${r.cssClass ?? a}
|
|
576
|
+
?disabled=${!!r.disabled}
|
|
577
|
+
side=${s[n]}
|
|
578
|
+
orientation=${e}
|
|
579
|
+
?last=${d}
|
|
580
|
+
role=${i !== "none" ? "option" : "listitem"}
|
|
581
|
+
?selected=${h}
|
|
582
|
+
aria-selected=${i !== "none" ? h ? "true" : "false" : a}
|
|
583
|
+
tabindex=${i !== "none" ? n === l ? "0" : "-1" : a}
|
|
584
|
+
data-index=${n}
|
|
585
|
+
></mp-timeline-item>`;
|
|
586
|
+
})}
|
|
587
|
+
`;
|
|
588
|
+
}
|
|
589
|
+
get declarativeItems() {
|
|
590
|
+
const t = this.renderRoot.querySelector("slot");
|
|
591
|
+
return t ? t.assignedElements({ flatten: !0 }).filter((e) => e.tagName === "MP-TIMELINE-ITEM") : [];
|
|
592
|
+
}
|
|
593
|
+
get itemElements() {
|
|
594
|
+
return this._items.length ? Array.from(this.renderRoot.querySelectorAll("mp-timeline-item")) : this.declarativeItems;
|
|
595
|
+
}
|
|
596
|
+
seedDeclarativeSelection() {
|
|
597
|
+
if (this._selectionExplicit || this._selectionSeeded) return;
|
|
598
|
+
const t = this.declarativeItems;
|
|
599
|
+
t.length && (t.forEach((e, i) => {
|
|
600
|
+
e.hasAttribute("selected") && this._selectedSet.add(this.idForElement(e, i));
|
|
601
|
+
}), this._selectionSeeded = !0);
|
|
602
|
+
}
|
|
603
|
+
enhanceDeclarativeItems() {
|
|
604
|
+
const t = this.declarativeItems;
|
|
605
|
+
if (!t.length) return;
|
|
606
|
+
const e = this._orientation, i = this._selectable, o = this._reverse, s = b(t.length, this._align, o), l = o ? 0 : t.length - 1, r = this.resolvedActiveIndex(t.length, (n) => !t[n].hasAttribute("disabled"));
|
|
607
|
+
t.forEach((n, c) => {
|
|
608
|
+
if (n.setAttribute("side", s[c]), n.setAttribute("orientation", e), c === l ? n.setAttribute("last", "") : n.removeAttribute("last"), i !== "none") {
|
|
609
|
+
const d = this.isSelected(this.idForElement(n, c));
|
|
610
|
+
n.setAttribute("role", "option"), d ? n.setAttribute("selected", "") : n.removeAttribute("selected"), n.setAttribute("aria-selected", d ? "true" : "false"), n.setAttribute("tabindex", c === r ? "0" : "-1");
|
|
611
|
+
} else
|
|
612
|
+
n.setAttribute("role", "listitem"), n.removeAttribute("aria-selected"), n.removeAttribute("tabindex");
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
itemFromEvent(t) {
|
|
616
|
+
const i = t.composedPath().find(
|
|
617
|
+
(s) => s instanceof HTMLElement && s.tagName === "MP-TIMELINE-ITEM"
|
|
618
|
+
);
|
|
619
|
+
if (!i) return { el: null, index: -1 };
|
|
620
|
+
const o = this.itemElements.indexOf(i);
|
|
621
|
+
return { el: i, index: o };
|
|
622
|
+
}
|
|
623
|
+
modelFor(t, e) {
|
|
624
|
+
return this._items.length ? this._items[e] : {
|
|
625
|
+
id: t.getAttribute("item-id") ?? void 0,
|
|
626
|
+
title: t.getAttribute("title") ?? void 0,
|
|
627
|
+
description: t.getAttribute("description") ?? void 0,
|
|
628
|
+
time: t.getAttribute("time") ?? void 0,
|
|
629
|
+
icon: t.getAttribute("icon") ?? void 0,
|
|
630
|
+
color: t.getAttribute("color") ?? void 0,
|
|
631
|
+
disabled: t.hasAttribute("disabled")
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
// ----- selection ---------------------------------------------------------
|
|
635
|
+
applySelection(t, e) {
|
|
636
|
+
const i = this.itemElements, o = i[t];
|
|
637
|
+
if (!o || o.hasAttribute("disabled")) return;
|
|
638
|
+
const s = this.idForId(t, o), l = new Set(this._selectedSet);
|
|
639
|
+
if (this._selectable === "single")
|
|
640
|
+
this._selectedSet = /* @__PURE__ */ new Set([s]);
|
|
641
|
+
else if (e.range && this._anchorIndex >= 0) {
|
|
642
|
+
const [r, n] = [Math.min(this._anchorIndex, t), Math.max(this._anchorIndex, t)], c = new Set(this._selectedSet);
|
|
643
|
+
for (let d = r; d <= n; d++) {
|
|
644
|
+
const h = i[d];
|
|
645
|
+
h && !h.hasAttribute("disabled") && c.add(this.idForId(d, h));
|
|
646
|
+
}
|
|
647
|
+
this._selectedSet = c;
|
|
648
|
+
} else if (e.toggle) {
|
|
649
|
+
const r = new Set(this._selectedSet);
|
|
650
|
+
r.has(s) ? r.delete(s) : r.add(s), this._selectedSet = r, this._anchorIndex = t;
|
|
651
|
+
} else
|
|
652
|
+
this._selectedSet = /* @__PURE__ */ new Set([s]), this._anchorIndex = t;
|
|
653
|
+
this.emitSelectionChange(l), this.requestUpdate(), this._items.length === 0 && this.enhanceDeclarativeItems();
|
|
654
|
+
}
|
|
655
|
+
idForId(t, e) {
|
|
656
|
+
return this._items.length ? this.idForItem(this._items[t], t) : this.idForElement(e, t);
|
|
657
|
+
}
|
|
658
|
+
emitSelectionChange(t) {
|
|
659
|
+
const e = this._selectedSet, i = [...e].filter((l) => !t.has(l)), o = [...t].filter((l) => !e.has(l));
|
|
660
|
+
if (!i.length && !o.length) return;
|
|
661
|
+
const s = (l) => l.map((r) => this.modelById(r)).filter((r) => r !== null);
|
|
662
|
+
this.dispatchEvent(
|
|
663
|
+
new CustomEvent("selection-change", {
|
|
664
|
+
detail: {
|
|
665
|
+
selected: s([...e]),
|
|
666
|
+
added: s(i),
|
|
667
|
+
removed: s(o)
|
|
668
|
+
},
|
|
669
|
+
bubbles: !0,
|
|
670
|
+
composed: !0
|
|
671
|
+
})
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
modelById(t) {
|
|
675
|
+
if (this._items.length) {
|
|
676
|
+
const o = this._items.findIndex((s, l) => this.idForItem(s, l) === t);
|
|
677
|
+
return o >= 0 ? this._items[o] : null;
|
|
678
|
+
}
|
|
679
|
+
const e = this.declarativeItems, i = e.findIndex((o, s) => this.idForElement(o, s) === t);
|
|
680
|
+
return i >= 0 ? this.modelFor(e[i], i) : null;
|
|
681
|
+
}
|
|
682
|
+
// ----- roving tabindex ---------------------------------------------------
|
|
683
|
+
resolvedActiveIndex(t, e) {
|
|
684
|
+
if (this._activeIndex >= 0 && this._activeIndex < t && e(this._activeIndex))
|
|
685
|
+
return this._activeIndex;
|
|
686
|
+
for (let i = 0; i < t; i++) if (e(i)) return i;
|
|
687
|
+
return -1;
|
|
688
|
+
}
|
|
689
|
+
setActiveIndex(t) {
|
|
690
|
+
this._activeIndex = t;
|
|
691
|
+
}
|
|
692
|
+
moveFocus(t, e, i) {
|
|
693
|
+
let s = t < 0 ? this.resolvedActiveIndex(i.length, (l) => !i[l].hasAttribute("disabled")) : t;
|
|
694
|
+
for (let l = 0; l < i.length && (s = (s + e + i.length) % i.length, !!i[s].hasAttribute("disabled")); l++)
|
|
695
|
+
;
|
|
696
|
+
this.moveFocusTo(s, i);
|
|
697
|
+
}
|
|
698
|
+
moveFocusTo(t, e) {
|
|
699
|
+
t < 0 || t >= e.length || (this.setActiveIndex(t), this._items.length ? this.requestUpdate() : this.enhanceDeclarativeItems(), requestAnimationFrame(() => this.itemElements[t]?.focus()));
|
|
700
|
+
}
|
|
701
|
+
firstFocusable(t) {
|
|
702
|
+
return t.findIndex((e) => !e.hasAttribute("disabled"));
|
|
703
|
+
}
|
|
704
|
+
lastFocusable(t) {
|
|
705
|
+
for (let e = t.length - 1; e >= 0; e--) if (!t[e].hasAttribute("disabled")) return e;
|
|
706
|
+
return -1;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
typeof customElements < "u" && !customElements.get("mp-timeline") && customElements.define("mp-timeline", y);
|
|
710
|
+
export {
|
|
711
|
+
y as MpTimeline,
|
|
712
|
+
I as MpTimelineItem,
|
|
713
|
+
b as resolveSides,
|
|
714
|
+
A as timelineItemStyles,
|
|
715
|
+
S as timelineStyles
|
|
716
|
+
};
|