@mintplayer/web-components 2.15.0 → 2.17.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.mjs +5 -5
- package/calendar/index.mjs +1 -1
- package/carousel/index.mjs +57 -143
- package/charts/core/index.mjs +30 -20
- package/charts/core/src/attributes.d.ts +18 -0
- package/charts/core/src/index.d.ts +2 -0
- package/charts/core/src/view-window.d.ts +46 -0
- package/charts/hierarchy/index.mjs +245 -256
- package/charts/hierarchy/src/components/mp-hierarchy-chart.d.ts +1 -3
- package/charts/sparkline/index.mjs +27 -26
- package/charts/trend/index.mjs +21 -20
- package/checkbox/index.mjs +1 -1
- package/checkbox/src/components/mp-checkbox.d.ts +1 -0
- package/chunks/attributes-L3eKsbdy.mjs +16 -0
- package/chunks/color-mode-warning-71FmlzWX.mjs +13 -0
- package/chunks/{form-check.styles-B0pxJ6YC.mjs → form-check.styles-DqvBnspm.mjs} +24 -3
- package/chunks/{mp-calendar.element-CJ8-t-Zn.mjs → mp-calendar.element-BIHS9SZZ.mjs} +11 -6
- package/chunks/{mp-checkbox-CzwS7Y_t.mjs → mp-checkbox-zV83gILn.mjs} +44 -36
- package/chunks/mp-datatable-eRpl7-2V.mjs +2238 -0
- package/chunks/{mp-datetime-picker.element-D1CiLbHm.mjs → mp-datetime-picker.element-Cxu5-qRE.mjs} +29 -32
- package/chunks/{mp-pagination-Dea75mD4.mjs → mp-pagination-hGy4dL7p.mjs} +9 -4
- package/chunks/{mp-radio-cL46sUA0.mjs → mp-radio-BhRVNdKp.mjs} +32 -28
- package/chunks/{mp-select-BNrbPwN4.mjs → mp-select-CgqYFvUj.mjs} +41 -26
- package/chunks/{mp-splitter-Ckn1kN4v.mjs → mp-splitter-DLehrw3Y.mjs} +144 -120
- package/chunks/{mp-timepicker.element-COZEUIoE.mjs → mp-timepicker.element-BiB9lkgc.mjs} +58 -45
- package/chunks/{mp-toggle-button-eo_aTQtu.mjs → mp-toggle-button-CaS9uYLE.mjs} +26 -24
- package/chunks/{mp-treeview-C8iltDbq.mjs → mp-treeview-CaMTDrvY.mjs} +51 -50
- package/chunks/{overlay-controller-D6agzzOI.mjs → overlay-controller-BHDagokg.mjs} +130 -70
- package/chunks/{id-DNZVAnGC.mjs → resource.service--lqLwEqk.mjs} +144 -206
- package/chunks/view-window-DGvFiDnW.mjs +263 -0
- package/code-snippet/index.mjs +70 -66
- package/code-snippet/src/hljs-loaders.generated.d.ts +1 -1
- package/custom-elements.json +65750 -0
- package/datatable/index.mjs +6 -5
- package/datatable/src/components/column-resize.d.ts +11 -0
- package/datatable/src/components/mp-datatable.d.ts +206 -1
- package/datatable/src/index.d.ts +3 -1
- package/datatable/src/types/column-def.d.ts +61 -0
- package/datatable/src/types/filter.d.ts +138 -0
- package/datatable/src/types/index.d.ts +3 -2
- package/datatable/src/types/labels.d.ts +58 -0
- package/datepicker/index.mjs +10 -9
- package/datetime-picker/index.mjs +1 -1
- package/datetime-picker/src/mp-datetime-picker.element.d.ts +3 -0
- package/dock/index.mjs +430 -463
- package/dock/src/components/mint-dock-manager.element.d.ts +25 -2
- package/dock/src/core/resize.d.ts +60 -0
- package/dropdown-menu/index.mjs +4 -2
- package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +6 -1
- package/dropdown-menu/src/index.d.ts +1 -1
- package/dropdown-menu/src/types/dropdown.d.ts +14 -1
- package/dropdown-menu/src/types/index.d.ts +1 -1
- package/file-manager/index.mjs +63 -61
- package/file-manager/src/components/mp-file-manager.d.ts +4 -3
- package/multi-range/index.mjs +56 -50
- package/multi-range/src/mint-multi-range.element.d.ts +4 -10
- package/multi-range/src/pointer-geometry.d.ts +31 -0
- package/navbar/index.mjs +89 -439
- package/overlay/index.mjs +5 -2
- package/overlay/src/index.d.ts +2 -0
- package/overlay/src/overlay-controller.d.ts +27 -14
- package/overlay/src/overlay-portal.d.ts +53 -0
- package/overlay/src/placement.d.ts +48 -0
- package/package.json +7 -1
- package/pagination/index.mjs +1 -1
- package/phone-input/index.mjs +44 -40
- package/phone-input/src/components/stack.d.ts +8 -0
- package/query-builder/index.mjs +418 -466
- package/query-builder/src/dnd/drag-controller.d.ts +12 -8
- package/query-builder/src/mp-query-builder.element.d.ts +5 -1
- package/query-builder/src/mp-query-condition.element.d.ts +1 -0
- package/radio/index.mjs +1 -1
- package/radio-group/index.mjs +1 -1
- package/ribbon/index.mjs +477 -498
- package/ribbon/src/core/band-text-color.d.ts +10 -0
- package/ribbon/src/core/key-tip-allocator.d.ts +10 -0
- package/ribbon/src/core/plan-reduce-steps.d.ts +62 -0
- package/ribbon/src/mp-ribbon.element.d.ts +0 -27
- package/scheduler/index.mjs +726 -711
- package/scheduler/src/components/mp-scheduler.d.ts +19 -3
- package/scheduler/src/drag/drag-manager.d.ts +1 -9
- package/scheduler/src/input/input-handler.d.ts +12 -2
- package/scheduler/src/utils/geometry.d.ts +39 -0
- package/scheduler/src/views/timeline-view.d.ts +0 -1
- package/scheduler-core/index.mjs +84 -71
- package/scheduler-core/src/services/resource.service.d.ts +0 -12
- package/scheduler-core/src/services/timeline.service.d.ts +0 -9
- package/select/index.mjs +1 -1
- package/select/src/components/mp-select.d.ts +1 -0
- package/signature-pad/index.mjs +21 -23
- package/signature-pad/src/canvas-point.d.ts +26 -0
- package/signature-pad/src/mp-signature-pad.element.d.ts +1 -7
- package/splitter/index.mjs +1 -1
- package/splitter/src/components/mp-splitter.d.ts +16 -0
- package/splitter/src/managers/index.d.ts +1 -0
- package/splitter/src/managers/rescale-panel-sizes.d.ts +14 -0
- package/swiper-core/index.mjs +2 -2
- package/theming/bs-theme-preboot.js +1 -0
- package/theming/color-mode.css +36 -0
- package/theming/index.d.ts +1 -0
- package/theming/index.mjs +327 -0
- package/theming/src/components/mp-theme-toggle.d.ts +71 -0
- package/theming/src/cookie.d.ts +31 -0
- package/theming/src/index.d.ts +5 -0
- package/theming/src/preboot.d.ts +1 -0
- package/theming/src/resolve.d.ts +36 -0
- package/theming/src/store.d.ts +27 -0
- package/theming/src/styles/theme-toggle.styles.d.ts +2 -0
- package/theming/src/testing/fake-broadcast-channel.d.ts +35 -0
- package/theming/src/toggle-modes.d.ts +23 -0
- package/tile-manager/index.mjs +252 -211
- package/tile-manager/src/components/mint-tile-manager.element.d.ts +8 -0
- package/tile-manager/src/utils/grid-geometry.d.ts +49 -0
- package/timeline/index.mjs +156 -164
- package/timeline/src/components/mp-timeline.d.ts +41 -7
- package/timepicker/index.mjs +7 -4
- package/timepicker/src/mp-time-list.element.d.ts +26 -0
- package/timepicker/src/mp-timepicker.element.d.ts +3 -0
- package/toggle-button/index.mjs +1 -1
- package/tree-select/index.mjs +21 -9
- package/treeview/index.mjs +1 -1
- package/treeview/src/components/mp-treeview.d.ts +6 -4
- package/chunks/color-DIeST-IS.mjs +0 -224
- package/chunks/mp-datatable-UJI8E73X.mjs +0 -1400
- package/datatable/src/styles/datatable.styles.d.ts +0 -2
- package/query-builder/src/mp-query-condition.element.template.d.ts +0 -2
|
@@ -138,6 +138,8 @@ export declare class MintTileManagerElement extends LitElement {
|
|
|
138
138
|
*/
|
|
139
139
|
private updateLayoutCache;
|
|
140
140
|
private computeActiveTransform;
|
|
141
|
+
/** The numbers the pure drag geometry needs: pointer, live grid origin, grab offset. */
|
|
142
|
+
private dragPointer;
|
|
141
143
|
connectedCallback(): void;
|
|
142
144
|
disconnectedCallback(): void;
|
|
143
145
|
protected firstUpdated(): void;
|
|
@@ -153,6 +155,12 @@ export declare class MintTileManagerElement extends LitElement {
|
|
|
153
155
|
private cleanupTouchArming;
|
|
154
156
|
private beginDragFromTouchArm;
|
|
155
157
|
private beginDrag;
|
|
158
|
+
/**
|
|
159
|
+
* Enter the drag state for a pointer at (x, y). Refreshes the layout cache
|
|
160
|
+
* once at gesture start, so the metrics are fresh even if the grid resized
|
|
161
|
+
* since the last cache tick. Returns false when there is no grid to drag in.
|
|
162
|
+
*/
|
|
163
|
+
private startDrag;
|
|
156
164
|
private beginResize;
|
|
157
165
|
private announceDragBegin;
|
|
158
166
|
private announceResizeBegin;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { GridRect } from '../types/grid-rect';
|
|
2
|
+
import { TilePosition } from '../types/tile-position';
|
|
3
|
+
/**
|
|
4
|
+
* Pure grid geometry for `mp-tile-manager`'s pointer gestures. Everything here
|
|
5
|
+
* takes plain numbers, so the snapping maths is testable without a layout
|
|
6
|
+
* engine; the element only reads the rects and hands the numbers over.
|
|
7
|
+
*/
|
|
8
|
+
/** Cached per-cell layout metrics, in CSS pixels. */
|
|
9
|
+
export interface CellMetrics {
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
gapX: number;
|
|
13
|
+
gapY: number;
|
|
14
|
+
}
|
|
15
|
+
export interface GridPoint {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
}
|
|
19
|
+
/** Inputs shared by the drag helpers: where the pointer is, relative to what. */
|
|
20
|
+
export interface DragPointer {
|
|
21
|
+
/** Pointer position in viewport coordinates. */
|
|
22
|
+
pointer: GridPoint;
|
|
23
|
+
/** The grid's top-left corner in viewport coordinates. */
|
|
24
|
+
gridOrigin: GridPoint;
|
|
25
|
+
/** Where on the tile the pointer grabbed it, relative to the tile's top-left. */
|
|
26
|
+
pointerOffset: GridPoint;
|
|
27
|
+
}
|
|
28
|
+
/** Grid-relative top-left pixel of the cell a tile starts in. */
|
|
29
|
+
export declare function cellOrigin(position: Pick<TilePosition, 'colStart' | 'rowStart'>, cell: CellMetrics): GridPoint;
|
|
30
|
+
/**
|
|
31
|
+
* Snap a dragged tile to the nearest cell. The column is clamped so the whole
|
|
32
|
+
* span stays inside `cols`; the row is only clamped at the top (the grid grows
|
|
33
|
+
* downwards). Returns null when the cell has no size, so the gesture keeps its
|
|
34
|
+
* last valid target instead of handing NaN to the packer.
|
|
35
|
+
*/
|
|
36
|
+
export declare function pointerToGridRect(drag: DragPointer, span: Pick<TilePosition, 'colSpan' | 'rowSpan'>, cell: CellMetrics, cols: number): GridRect | null;
|
|
37
|
+
/**
|
|
38
|
+
* The visual offset of a dragged tile from its snapped cell, so the tile
|
|
39
|
+
* tracks the pointer between snaps. Rounded to whole pixels.
|
|
40
|
+
*/
|
|
41
|
+
export declare function dragTranslate(drag: DragPointer, snapped: GridRect, cell: CellMetrics): GridPoint;
|
|
42
|
+
export type ResizeHandle = 'side' | 'bottom' | 'corner';
|
|
43
|
+
/**
|
|
44
|
+
* Spans for a resize gesture: the pointer delta since pointerdown, snapped to
|
|
45
|
+
* whole cells. The side handle changes only columns, the bottom handle only
|
|
46
|
+
* rows. Columns are clamped so the tile never crosses the last column. Null
|
|
47
|
+
* when the cell has no size (same reason as pointerToGridRect).
|
|
48
|
+
*/
|
|
49
|
+
export declare function resizeSpans(delta: GridPoint, handle: ResizeHandle, startSpans: Pick<TilePosition, 'colSpan' | 'rowSpan'>, colStart: number, cell: CellMetrics, cols: number): Pick<TilePosition, 'colSpan' | 'rowSpan'> | null;
|
package/timeline/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { unsafeCSS as
|
|
1
|
+
import { unsafeCSS as v, LitElement as x, nothing as a, html as u, isServer as p } from "lit";
|
|
2
2
|
import "lit/directives/ref.js";
|
|
3
|
-
import { H as
|
|
4
|
-
import { resolveSides as
|
|
5
|
-
const
|
|
3
|
+
import { H as I } from "../chunks/host-aria-WSGs7SPQ.mjs";
|
|
4
|
+
import { resolveSides as g } from "../timeline-core/index.mjs";
|
|
5
|
+
const y = v(`:host {
|
|
6
6
|
display: block;
|
|
7
7
|
box-sizing: border-box;
|
|
8
8
|
--mp-tl-gap: 1rem;
|
|
@@ -49,7 +49,7 @@ const S = g(`:host {
|
|
|
49
49
|
|
|
50
50
|
:host([orientation=horizontal][reverse]) .timeline {
|
|
51
51
|
flex-direction: row-reverse;
|
|
52
|
-
}`),
|
|
52
|
+
}`), A = v(`:host {
|
|
53
53
|
display: block;
|
|
54
54
|
box-sizing: border-box;
|
|
55
55
|
outline: none;
|
|
@@ -207,12 +207,12 @@ const S = g(`:host {
|
|
|
207
207
|
min-height: 0;
|
|
208
208
|
min-width: var(--mp-tl-gap);
|
|
209
209
|
}`);
|
|
210
|
-
class
|
|
210
|
+
class k extends x {
|
|
211
211
|
constructor() {
|
|
212
212
|
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;
|
|
213
213
|
}
|
|
214
214
|
static {
|
|
215
|
-
this.styles = [
|
|
215
|
+
this.styles = [A];
|
|
216
216
|
}
|
|
217
217
|
static get observedAttributes() {
|
|
218
218
|
return [
|
|
@@ -340,7 +340,7 @@ class y extends _ {
|
|
|
340
340
|
e ? this.hasAttribute(t) || this.setAttribute(t, "") : this.hasAttribute(t) && this.removeAttribute(t);
|
|
341
341
|
}
|
|
342
342
|
render() {
|
|
343
|
-
return
|
|
343
|
+
return u`
|
|
344
344
|
<div class="item ${this._itemClass ?? ""}">
|
|
345
345
|
<div class="opposite">
|
|
346
346
|
<slot name="opposite"><slot name="timestamp">${this._time ?? a}</slot></slot>
|
|
@@ -349,7 +349,7 @@ class y extends _ {
|
|
|
349
349
|
<span class="marker">
|
|
350
350
|
<slot name="marker">
|
|
351
351
|
<span class="marker-dot">
|
|
352
|
-
${this._icon ?
|
|
352
|
+
${this._icon ? u`<i class=${this._icon} aria-hidden="true"></i>` : a}
|
|
353
353
|
</span>
|
|
354
354
|
</slot>
|
|
355
355
|
</span>
|
|
@@ -369,75 +369,50 @@ class y extends _ {
|
|
|
369
369
|
`;
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
|
-
typeof customElements < "u" && !customElements.get("mp-timeline-item") && customElements.define("mp-timeline-item",
|
|
373
|
-
const
|
|
372
|
+
typeof customElements < "u" && !customElements.get("mp-timeline-item") && customElements.define("mp-timeline-item", k);
|
|
373
|
+
const f = /* @__PURE__ */ new Set([
|
|
374
374
|
"start",
|
|
375
375
|
"end",
|
|
376
376
|
"alternate",
|
|
377
377
|
"alternate-reverse"
|
|
378
|
-
]),
|
|
379
|
-
class
|
|
378
|
+
]), _ = /* @__PURE__ */ new Set(["none", "single", "multiple"]);
|
|
379
|
+
class E extends x {
|
|
380
380
|
constructor() {
|
|
381
|
-
super(...arguments), this._items = [], this._selectedSet = /* @__PURE__ */ new Set(), this._orientation = "vertical", this._align = "start", this._reverse = !1, this._selectable = "none", this._activatable = !1, this._isServerSide = !1, this._inputLabel = null, this.hostAria = new
|
|
381
|
+
super(...arguments), this._items = [], this._selectedSet = /* @__PURE__ */ new Set(), this._orientation = "vertical", this._align = "start", this._reverse = !1, this._selectable = "none", this._activatable = !1, this._isServerSide = !1, this._inputLabel = null, this.hostAria = new I(this, {
|
|
382
382
|
referenceTarget: () => this.renderRoot?.querySelector(".timeline") ?? null
|
|
383
|
-
}), this._selectionExplicit = !1, this._selectionSeeded = !1, this._activeIndex = -1, this._anchorIndex = -1, this._observer = null, this.
|
|
383
|
+
}), this._selectionExplicit = !1, this._selectionSeeded = !1, this._activeIndex = -1, this._anchorIndex = -1, this._observer = null, this.syncDeclarative = () => {
|
|
384
384
|
this.seedDeclarativeSelection(), this.enhanceDeclarativeItems();
|
|
385
385
|
}, this.onClick = (t) => {
|
|
386
|
-
const {
|
|
387
|
-
if (
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
composed: !0
|
|
394
|
-
})
|
|
395
|
-
), this._selectable !== "none") {
|
|
396
|
-
const s = t;
|
|
397
|
-
this.applySelection(i, { toggle: s.ctrlKey || s.metaKey, range: s.shiftKey }), this.setActiveIndex(i);
|
|
398
|
-
}
|
|
386
|
+
const { index: e } = this.itemFromEvent(t);
|
|
387
|
+
if (this.emitItemClick(e, t) && this.roving)
|
|
388
|
+
if (this.setActiveIndex(e), this._selectable !== "none") {
|
|
389
|
+
const i = t;
|
|
390
|
+
this.applySelection(e, { toggle: i.ctrlKey || i.metaKey, range: i.shiftKey });
|
|
391
|
+
} else
|
|
392
|
+
this.refreshItems();
|
|
399
393
|
}, this.onKeydown = (t) => {
|
|
400
|
-
if (this.
|
|
401
|
-
if (!this._activatable) return;
|
|
402
|
-
this.onActivatableKeydown(t);
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
394
|
+
if (!this.roving) return;
|
|
405
395
|
const e = this.itemElements;
|
|
406
396
|
if (!e.length) return;
|
|
407
|
-
const i = this.itemFromEvent(t).index;
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
case "ArrowLeft": {
|
|
416
|
-
t.preventDefault(), this.moveFocus(i, -1, e);
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
case "Home": {
|
|
420
|
-
t.preventDefault(), this.moveFocusTo(this.firstFocusable(e), e);
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
case "End": {
|
|
424
|
-
t.preventDefault(), this.moveFocusTo(this.lastFocusable(e), e);
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
case "Enter":
|
|
428
|
-
case " ": {
|
|
429
|
-
if (i < 0) return;
|
|
430
|
-
t.preventDefault(), this.applySelection(i, {
|
|
431
|
-
toggle: t.key === " " && this._selectable === "multiple",
|
|
432
|
-
range: t.shiftKey
|
|
433
|
-
});
|
|
397
|
+
const i = this.itemFromEvent(t).index, s = this.navigationTarget(t.key, i, e);
|
|
398
|
+
if (s !== void 0) {
|
|
399
|
+
t.preventDefault(), this.moveFocusTo(s, e);
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
if (!(t.key !== "Enter" && t.key !== " " || i < 0)) {
|
|
403
|
+
if (t.preventDefault(), this._selectable === "none") {
|
|
404
|
+
this.emitItemClick(i, t);
|
|
434
405
|
return;
|
|
435
406
|
}
|
|
407
|
+
this.applySelection(i, {
|
|
408
|
+
toggle: t.key === " " && this._selectable === "multiple",
|
|
409
|
+
range: t.shiftKey
|
|
410
|
+
});
|
|
436
411
|
}
|
|
437
412
|
};
|
|
438
413
|
}
|
|
439
414
|
static {
|
|
440
|
-
this.styles = [
|
|
415
|
+
this.styles = [y];
|
|
441
416
|
}
|
|
442
417
|
static get observedAttributes() {
|
|
443
418
|
return [
|
|
@@ -495,7 +470,7 @@ class k extends _ {
|
|
|
495
470
|
return this._align;
|
|
496
471
|
}
|
|
497
472
|
set align(t) {
|
|
498
|
-
const e =
|
|
473
|
+
const e = f.has(t) ? t : "start";
|
|
499
474
|
this._align !== e && (this._align = e, this.reflectString("align", e), this.requestUpdate());
|
|
500
475
|
}
|
|
501
476
|
get reverse() {
|
|
@@ -509,9 +484,21 @@ class k extends _ {
|
|
|
509
484
|
return this._selectable;
|
|
510
485
|
}
|
|
511
486
|
set selectable(t) {
|
|
512
|
-
const e =
|
|
487
|
+
const e = _.has(t) ? t : "none";
|
|
513
488
|
this._selectable !== e && (this._selectable = e, this.reflectString("selectable", e), this.requestUpdate());
|
|
514
489
|
}
|
|
490
|
+
/**
|
|
491
|
+
* Opt-in keyboard reachability for click-only consumers (no selection): rows
|
|
492
|
+
* become buttons in a group with a roving tab stop, and Enter/Space emit
|
|
493
|
+
* `item-click`.
|
|
494
|
+
*/
|
|
495
|
+
get activatable() {
|
|
496
|
+
return this._activatable;
|
|
497
|
+
}
|
|
498
|
+
set activatable(t) {
|
|
499
|
+
const e = !!t;
|
|
500
|
+
this._activatable !== e && (this._activatable = e, this.reflectBoolean("activatable", e), this.requestUpdate());
|
|
501
|
+
}
|
|
515
502
|
get isServerSide() {
|
|
516
503
|
return this._isServerSide;
|
|
517
504
|
}
|
|
@@ -521,9 +508,7 @@ class k extends _ {
|
|
|
521
508
|
}
|
|
522
509
|
// ----- lifecycle ---------------------------------------------------------
|
|
523
510
|
connectedCallback() {
|
|
524
|
-
super.connectedCallback(), !
|
|
525
|
-
this.seedDeclarativeSelection(), this.enhanceDeclarativeItems();
|
|
526
|
-
}), this._observer.observe(this, {
|
|
511
|
+
super.connectedCallback(), !p && !this._observer && (this._observer = new MutationObserver(this.syncDeclarative), this._observer.observe(this, {
|
|
527
512
|
childList: !0,
|
|
528
513
|
subtree: !0,
|
|
529
514
|
attributes: !0,
|
|
@@ -540,13 +525,13 @@ class k extends _ {
|
|
|
540
525
|
this._orientation = i === "horizontal" ? "horizontal" : "vertical";
|
|
541
526
|
break;
|
|
542
527
|
case "align":
|
|
543
|
-
this._align = i &&
|
|
528
|
+
this._align = i && f.has(i) ? i : "start";
|
|
544
529
|
break;
|
|
545
530
|
case "reverse":
|
|
546
531
|
this._reverse = i !== null && i !== "false";
|
|
547
532
|
break;
|
|
548
533
|
case "selectable":
|
|
549
|
-
this._selectable = i &&
|
|
534
|
+
this._selectable = i && _.has(i) ? i : "none";
|
|
550
535
|
break;
|
|
551
536
|
case "is-server-side":
|
|
552
537
|
this._isServerSide = i !== null && i !== "false";
|
|
@@ -566,7 +551,7 @@ class k extends _ {
|
|
|
566
551
|
}
|
|
567
552
|
}
|
|
568
553
|
updated() {
|
|
569
|
-
!
|
|
554
|
+
!p && this._items.length === 0 && this.syncDeclarative(), this.hostAria.syncReferences();
|
|
570
555
|
}
|
|
571
556
|
reflectString(t, e) {
|
|
572
557
|
this.getAttribute(t) !== e && this.setAttribute(t, e);
|
|
@@ -587,7 +572,7 @@ class k extends _ {
|
|
|
587
572
|
// ----- render ------------------------------------------------------------
|
|
588
573
|
render() {
|
|
589
574
|
const t = this._selectable !== "none" ? "listbox" : this._activatable ? "group" : "list";
|
|
590
|
-
return
|
|
575
|
+
return u`
|
|
591
576
|
<div
|
|
592
577
|
class="timeline"
|
|
593
578
|
role=${t}
|
|
@@ -599,32 +584,32 @@ class k extends _ {
|
|
|
599
584
|
@click=${this.onClick}
|
|
600
585
|
@keydown=${this.onKeydown}
|
|
601
586
|
>
|
|
602
|
-
${this._items.length ? this.renderDataItems() :
|
|
587
|
+
${this._items.length ? this.renderDataItems() : u`<slot @slotchange=${this.syncDeclarative}></slot>`}
|
|
603
588
|
</div>
|
|
604
589
|
`;
|
|
605
590
|
}
|
|
606
591
|
renderDataItems() {
|
|
607
|
-
const t = this._items, e = this._orientation, i = this._selectable,
|
|
608
|
-
return
|
|
609
|
-
${t.map((r,
|
|
610
|
-
const
|
|
611
|
-
return
|
|
592
|
+
const t = this._items, e = this._orientation, i = this._selectable, s = this._reverse, n = g(t.length, this._align, s), l = this.resolvedActiveIndex(t.length, (r) => !t[r].disabled);
|
|
593
|
+
return u`
|
|
594
|
+
${t.map((r, c) => {
|
|
595
|
+
const o = this.idForItem(r, c), h = s ? c === 0 : c === t.length - 1, m = i !== "none" && this.isSelected(o), S = r.time instanceof Date ? r.time.toLocaleDateString() : r.time;
|
|
596
|
+
return u`<mp-timeline-item
|
|
612
597
|
item-id=${r.id ?? a}
|
|
613
598
|
title=${r.title ?? a}
|
|
614
599
|
description=${r.description ?? a}
|
|
615
|
-
time=${
|
|
600
|
+
time=${S ?? a}
|
|
616
601
|
icon=${r.icon ?? a}
|
|
617
602
|
color=${r.color ?? a}
|
|
618
603
|
item-class=${r.cssClass ?? a}
|
|
619
604
|
?disabled=${!!r.disabled}
|
|
620
|
-
side=${
|
|
605
|
+
side=${n[c]}
|
|
621
606
|
orientation=${e}
|
|
622
607
|
?last=${h}
|
|
623
|
-
role=${
|
|
624
|
-
?selected=${
|
|
625
|
-
aria-selected=${i !== "none" ?
|
|
626
|
-
tabindex=${
|
|
627
|
-
data-index=${
|
|
608
|
+
role=${this.itemRole}
|
|
609
|
+
?selected=${m}
|
|
610
|
+
aria-selected=${i !== "none" ? m ? "true" : "false" : a}
|
|
611
|
+
tabindex=${this.roving ? c === l ? "0" : "-1" : a}
|
|
612
|
+
data-index=${c}
|
|
628
613
|
></mp-timeline-item>`;
|
|
629
614
|
})}
|
|
630
615
|
`;
|
|
@@ -639,70 +624,83 @@ class k extends _ {
|
|
|
639
624
|
seedDeclarativeSelection() {
|
|
640
625
|
if (this._selectionExplicit || this._selectionSeeded) return;
|
|
641
626
|
const t = this.declarativeItems;
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
627
|
+
if (!t.length) return;
|
|
628
|
+
const e = t.flatMap(
|
|
629
|
+
(i, s) => i.hasAttribute("selected") ? [this.idForElement(i, s)] : []
|
|
630
|
+
);
|
|
631
|
+
this._selectedSet = /* @__PURE__ */ new Set([...this._selectedSet, ...e]), this._selectionSeeded = !0;
|
|
645
632
|
}
|
|
633
|
+
/**
|
|
634
|
+
* Projects the container state onto slotted items — the same role, selection
|
|
635
|
+
* and roving-tabindex contract `renderDataItems` renders in data mode.
|
|
636
|
+
*/
|
|
646
637
|
enhanceDeclarativeItems() {
|
|
647
638
|
const t = this.declarativeItems;
|
|
648
639
|
if (!t.length) return;
|
|
649
|
-
const e = this._orientation, i = this._selectable, n = this.
|
|
650
|
-
t.
|
|
651
|
-
if (o.setAttribute("side",
|
|
652
|
-
const
|
|
653
|
-
o.
|
|
640
|
+
const e = this._orientation, i = this._selectable !== "none", s = this.roving, n = this.itemRole, l = g(t.length, this._align, this._reverse), r = this._reverse ? 0 : t.length - 1, c = this.resolvedActiveIndex(t.length, (o) => d(t[o]));
|
|
641
|
+
t.map((o, h) => {
|
|
642
|
+
if (o.setAttribute("side", l[h]), o.setAttribute("orientation", e), o.toggleAttribute("last", h === r), o.setAttribute("role", n), i) {
|
|
643
|
+
const m = this.isSelected(this.idForElement(o, h));
|
|
644
|
+
o.toggleAttribute("selected", m), o.setAttribute("aria-selected", m ? "true" : "false");
|
|
654
645
|
} else
|
|
655
|
-
o.
|
|
646
|
+
o.removeAttribute("aria-selected");
|
|
647
|
+
return s ? o.setAttribute("tabindex", h === c ? "0" : "-1") : o.removeAttribute("tabindex"), o;
|
|
656
648
|
});
|
|
657
649
|
}
|
|
658
|
-
/**
|
|
650
|
+
/** Re-applies roving tabindex / selection state after an interaction. */
|
|
651
|
+
refreshItems() {
|
|
652
|
+
this._items.length ? this.requestUpdate() : this.enhanceDeclarativeItems();
|
|
653
|
+
}
|
|
654
|
+
// ----- interaction -------------------------------------------------------
|
|
655
|
+
/** Items are keyboard-reachable when selectable, or opted in via `activatable`. */
|
|
656
|
+
get roving() {
|
|
657
|
+
return this._selectable !== "none" || this._activatable;
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* activatable-without-selection = buttons in a group: a `listitem` may not be
|
|
661
|
+
* interactive, so the item role follows what the items actually are.
|
|
662
|
+
*/
|
|
663
|
+
get itemRole() {
|
|
664
|
+
return this._selectable !== "none" ? "option" : this._activatable ? "button" : "listitem";
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* The item-click emission shared by pointer and keyboard activation.
|
|
668
|
+
* Returns false when there is no enabled item at `index`.
|
|
669
|
+
*/
|
|
659
670
|
emitItemClick(t, e) {
|
|
660
671
|
const i = this.itemElements[t];
|
|
661
|
-
|
|
662
|
-
const n = this.modelFor(i, t);
|
|
663
|
-
this.dispatchEvent(
|
|
672
|
+
return !i || !d(i) ? !1 : (this.dispatchEvent(
|
|
664
673
|
new CustomEvent("item-click", {
|
|
665
|
-
detail: { item:
|
|
674
|
+
detail: { item: this.modelFor(i, t), index: t, originalEvent: e },
|
|
666
675
|
bubbles: !0,
|
|
667
676
|
composed: !0
|
|
668
677
|
})
|
|
669
|
-
);
|
|
678
|
+
), !0);
|
|
670
679
|
}
|
|
671
|
-
/**
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
if (!e.length) return;
|
|
675
|
-
const i = this.itemFromEvent(t).index;
|
|
676
|
-
switch (t.key) {
|
|
680
|
+
/** The index a navigation key moves to, or undefined for a non-navigation key. */
|
|
681
|
+
navigationTarget(t, e, i) {
|
|
682
|
+
switch (t) {
|
|
677
683
|
case "ArrowDown":
|
|
678
684
|
case "ArrowRight":
|
|
679
|
-
|
|
680
|
-
return;
|
|
685
|
+
return this.stepFrom(e, 1, i);
|
|
681
686
|
case "ArrowUp":
|
|
682
687
|
case "ArrowLeft":
|
|
683
|
-
|
|
684
|
-
return;
|
|
688
|
+
return this.stepFrom(e, -1, i);
|
|
685
689
|
case "Home":
|
|
686
|
-
|
|
687
|
-
return;
|
|
690
|
+
return i.findIndex(d);
|
|
688
691
|
case "End":
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
case "Enter":
|
|
692
|
-
case " ": {
|
|
693
|
-
if (i < 0) return;
|
|
694
|
-
t.preventDefault(), this.emitItemClick(i, t);
|
|
692
|
+
return i.reduce((s, n, l) => d(n) ? l : s, -1);
|
|
693
|
+
default:
|
|
695
694
|
return;
|
|
696
|
-
}
|
|
697
695
|
}
|
|
698
696
|
}
|
|
699
697
|
itemFromEvent(t) {
|
|
700
698
|
const i = t.composedPath().find(
|
|
701
|
-
(
|
|
699
|
+
(n) => n instanceof HTMLElement && n.tagName === "MP-TIMELINE-ITEM"
|
|
702
700
|
);
|
|
703
701
|
if (!i) return { el: null, index: -1 };
|
|
704
|
-
const
|
|
705
|
-
return { el: i, index:
|
|
702
|
+
const s = this.itemElements.indexOf(i);
|
|
703
|
+
return { el: i, index: s };
|
|
706
704
|
}
|
|
707
705
|
modelFor(t, e) {
|
|
708
706
|
return this._items.length ? this._items[e] : {
|
|
@@ -717,38 +715,34 @@ class k extends _ {
|
|
|
717
715
|
}
|
|
718
716
|
// ----- selection ---------------------------------------------------------
|
|
719
717
|
applySelection(t, e) {
|
|
720
|
-
const i = this.itemElements,
|
|
721
|
-
if (!
|
|
722
|
-
const
|
|
718
|
+
const i = this.itemElements, s = i[t];
|
|
719
|
+
if (!s || !d(s)) return;
|
|
720
|
+
const n = this.idForId(t, s), l = new Set(this._selectedSet);
|
|
723
721
|
if (this._selectable === "single")
|
|
724
|
-
this._selectedSet = /* @__PURE__ */ new Set([
|
|
722
|
+
this._selectedSet = /* @__PURE__ */ new Set([n]);
|
|
725
723
|
else if (e.range && this._anchorIndex >= 0) {
|
|
726
|
-
const
|
|
727
|
-
|
|
728
|
-
const d = i[h];
|
|
729
|
-
d && !d.hasAttribute("disabled") && c.add(this.idForId(h, d));
|
|
730
|
-
}
|
|
731
|
-
this._selectedSet = c;
|
|
724
|
+
const r = Math.min(this._anchorIndex, t), c = Math.max(this._anchorIndex, t), o = i.slice(r, c + 1).flatMap((h, m) => d(h) ? [this.idForId(r + m, h)] : []);
|
|
725
|
+
this._selectedSet = /* @__PURE__ */ new Set([...this._selectedSet, ...o]);
|
|
732
726
|
} else if (e.toggle) {
|
|
733
727
|
const r = new Set(this._selectedSet);
|
|
734
|
-
r.has(
|
|
728
|
+
r.has(n) ? r.delete(n) : r.add(n), this._selectedSet = r, this._anchorIndex = t;
|
|
735
729
|
} else
|
|
736
|
-
this._selectedSet = /* @__PURE__ */ new Set([
|
|
730
|
+
this._selectedSet = /* @__PURE__ */ new Set([n]), this._anchorIndex = t;
|
|
737
731
|
this.emitSelectionChange(l), this.requestUpdate(), this._items.length === 0 && this.enhanceDeclarativeItems();
|
|
738
732
|
}
|
|
739
733
|
idForId(t, e) {
|
|
740
734
|
return this._items.length ? this.idForItem(this._items[t], t) : this.idForElement(e, t);
|
|
741
735
|
}
|
|
742
736
|
emitSelectionChange(t) {
|
|
743
|
-
const e = this._selectedSet, i = [...e].filter((l) => !t.has(l)),
|
|
744
|
-
if (!i.length && !
|
|
745
|
-
const
|
|
737
|
+
const e = this._selectedSet, i = [...e].filter((l) => !t.has(l)), s = [...t].filter((l) => !e.has(l));
|
|
738
|
+
if (!i.length && !s.length) return;
|
|
739
|
+
const n = (l) => l.map((r) => this.modelById(r)).filter((r) => r !== null);
|
|
746
740
|
this.dispatchEvent(
|
|
747
741
|
new CustomEvent("selection-change", {
|
|
748
742
|
detail: {
|
|
749
|
-
selected:
|
|
750
|
-
added:
|
|
751
|
-
removed: s
|
|
743
|
+
selected: n([...e]),
|
|
744
|
+
added: n(i),
|
|
745
|
+
removed: n(s)
|
|
752
746
|
},
|
|
753
747
|
bubbles: !0,
|
|
754
748
|
composed: !0
|
|
@@ -757,44 +751,42 @@ class k extends _ {
|
|
|
757
751
|
}
|
|
758
752
|
modelById(t) {
|
|
759
753
|
if (this._items.length) {
|
|
760
|
-
const
|
|
761
|
-
return
|
|
754
|
+
const s = this._items.findIndex((n, l) => this.idForItem(n, l) === t);
|
|
755
|
+
return s >= 0 ? this._items[s] : null;
|
|
762
756
|
}
|
|
763
|
-
const e = this.declarativeItems, i = e.findIndex((
|
|
757
|
+
const e = this.declarativeItems, i = e.findIndex((s, n) => this.idForElement(s, n) === t);
|
|
764
758
|
return i >= 0 ? this.modelFor(e[i], i) : null;
|
|
765
759
|
}
|
|
766
760
|
// ----- roving tabindex ---------------------------------------------------
|
|
767
761
|
resolvedActiveIndex(t, e) {
|
|
768
|
-
|
|
769
|
-
return this._activeIndex;
|
|
770
|
-
for (let i = 0; i < t; i++) if (e(i)) return i;
|
|
771
|
-
return -1;
|
|
762
|
+
return this._activeIndex >= 0 && this._activeIndex < t && e(this._activeIndex) ? this._activeIndex : Array.from({ length: t }, (i, s) => s).find(e) ?? -1;
|
|
772
763
|
}
|
|
773
764
|
setActiveIndex(t) {
|
|
774
765
|
this._activeIndex = t;
|
|
775
766
|
}
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
767
|
+
/**
|
|
768
|
+
* The next enabled item from `from` in direction `dir`, wrapping; -1 when no
|
|
769
|
+
* item is enabled. A `from` of -1 (focus not on an item) starts at the
|
|
770
|
+
* current tab stop.
|
|
771
|
+
*/
|
|
772
|
+
stepFrom(t, e, i) {
|
|
773
|
+
const s = i.length, n = t < 0 ? this.resolvedActiveIndex(s, (l) => d(i[l])) : t;
|
|
774
|
+
return Array.from({ length: s }, (l, r) => ((n + e * (r + 1)) % s + s) % s).find(
|
|
775
|
+
(l) => d(i[l])
|
|
776
|
+
) ?? -1;
|
|
781
777
|
}
|
|
782
778
|
moveFocusTo(t, e) {
|
|
783
|
-
t < 0 || t >= e.length || (this.setActiveIndex(t), this.
|
|
784
|
-
}
|
|
785
|
-
firstFocusable(t) {
|
|
786
|
-
return t.findIndex((e) => !e.hasAttribute("disabled"));
|
|
787
|
-
}
|
|
788
|
-
lastFocusable(t) {
|
|
789
|
-
for (let e = t.length - 1; e >= 0; e--) if (!t[e].hasAttribute("disabled")) return e;
|
|
790
|
-
return -1;
|
|
779
|
+
t < 0 || t >= e.length || (this.setActiveIndex(t), this.refreshItems(), requestAnimationFrame(() => this.itemElements[t]?.focus()));
|
|
791
780
|
}
|
|
792
781
|
}
|
|
793
|
-
|
|
782
|
+
function d(b) {
|
|
783
|
+
return !b.hasAttribute("disabled");
|
|
784
|
+
}
|
|
785
|
+
typeof customElements < "u" && !customElements.get("mp-timeline") && customElements.define("mp-timeline", E);
|
|
794
786
|
export {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
787
|
+
E as MpTimeline,
|
|
788
|
+
k as MpTimelineItem,
|
|
789
|
+
g as resolveSides,
|
|
790
|
+
A as timelineItemStyles,
|
|
791
|
+
y as timelineStyles
|
|
800
792
|
};
|