@mintplayer/web-components 2.21.0 → 3.0.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.
@@ -1,2 +1 @@
1
- export { MintTileManagerElement } from './mint-tile-manager.element';
2
- export type { MintTile, TileDragMode, TileResizeMode } from './mint-tile-manager.element';
1
+ export { MintTileManagerElement } from './mp-tile-manager';
@@ -0,0 +1,107 @@
1
+ import { LitElement, PropertyValues, TemplateResult } from 'lit';
2
+ import { TileManagerMachine, MintTile, TileBreakpoint, TileDragMode, TileLayouts, TileLayoutSnapshot, TileManagerMessages, TileResizeMode } from '@mintplayer/ui-core/tile-manager';
3
+ /**
4
+ * `<mp-tile-manager>`: the Lit front of `TileManagerMachine` (#440). Every decision (layout per
5
+ * column count, gestures, keyboard, ARIA) is the machine's; this element measures the grid,
6
+ * renders `connect()`'s bags, owns pointer capture and the FLIP animation, and re-dispatches the
7
+ * machine's events (`layoutchange`, `layoutpreview`, `columncountchange`, `gestureblocked`).
8
+ *
9
+ * Keeps its shadow root: tile content arrives only through the named slots `${id}-header` and
10
+ * `${id}-content`, so it is never starved of page CSS (light-tier admission rule). The scoped
11
+ * sheet is adopted into the shadow root.
12
+ *
13
+ * No-JS: Tier 2. Before the first measure the tiles render as named groups with no tab stop,
14
+ * grips or instructions.
15
+ */
16
+ export declare class MintTileManagerElement extends LitElement {
17
+ #private;
18
+ static styles: import('lit').CSSResult;
19
+ static properties: {
20
+ tiles: {
21
+ attribute: boolean;
22
+ };
23
+ layouts: {
24
+ attribute: boolean;
25
+ };
26
+ breakpoints: {
27
+ attribute: boolean;
28
+ };
29
+ stackBelow: {
30
+ type: NumberConstructor;
31
+ attribute: string;
32
+ };
33
+ maxColumns: {
34
+ type: NumberConstructor;
35
+ attribute: string;
36
+ };
37
+ minColumnWidth: {
38
+ type: NumberConstructor;
39
+ attribute: string;
40
+ };
41
+ minRowHeight: {
42
+ type: StringConstructor;
43
+ attribute: string;
44
+ };
45
+ gap: {
46
+ type: NumberConstructor;
47
+ };
48
+ dragMode: {
49
+ type: StringConstructor;
50
+ attribute: string;
51
+ reflect: boolean;
52
+ };
53
+ resizeMode: {
54
+ type: StringConstructor;
55
+ attribute: string;
56
+ reflect: boolean;
57
+ };
58
+ animateReflow: {
59
+ type: BooleanConstructor;
60
+ attribute: string;
61
+ };
62
+ label: {
63
+ type: StringConstructor;
64
+ };
65
+ messages: {
66
+ attribute: boolean;
67
+ };
68
+ };
69
+ tiles: readonly MintTile[];
70
+ /** Per column count; two-way through `layoutchange`'s `layouts`. */
71
+ layouts: TileLayouts;
72
+ breakpoints: readonly TileBreakpoint[] | null;
73
+ stackBelow: number | null;
74
+ maxColumns: number;
75
+ /** px */
76
+ minColumnWidth: number;
77
+ minRowHeight: string;
78
+ /** px */
79
+ gap: number;
80
+ dragMode: TileDragMode;
81
+ resizeMode: TileResizeMode;
82
+ animateReflow: boolean;
83
+ label: string | null;
84
+ messages: Partial<TileManagerMessages>;
85
+ readonly machine: TileManagerMachine;
86
+ constructor();
87
+ /** What is rendered: the resolved column count and its layout (the preview while editing). */
88
+ captureLayout(): {
89
+ columnCount: number;
90
+ layout: TileLayoutSnapshot;
91
+ };
92
+ /** Drops `layouts[count]` and commits, so that count derives again (D15). */
93
+ resetLayout(count: number): void;
94
+ /** True while a pointer drag or resize is in flight. */
95
+ get isGestureActive(): boolean;
96
+ connectedCallback(): void;
97
+ disconnectedCallback(): void;
98
+ protected willUpdate(changed: PropertyValues<this>): void;
99
+ protected firstUpdated(): void;
100
+ protected updated(): void;
101
+ render(): TemplateResult;
102
+ }
103
+ declare global {
104
+ interface HTMLElementTagNameMap {
105
+ 'mp-tile-manager': MintTileManagerElement;
106
+ }
107
+ }
@@ -1,4 +1,3 @@
1
1
  export { MintTileManagerElement } from './components';
2
- export type { MintTile, TileDragMode, TileResizeMode } from './components';
3
- export * from './types';
4
- export * from './utils';
2
+ export { withoutNarrowerLayouts } from '@mintplayer/ui-core/tile-manager';
3
+ export type { MintTile, TileBreakpoint, TileDragMode, TileGestureBlocked, TileLayoutChange, TileLayouts, TileLayoutSnapshot, TileManagerMessages, TilePosition, TileResizeMode, TileSize, } from '@mintplayer/ui-core/tile-manager';
@@ -1,212 +0,0 @@
1
- import { LitElement, TemplateResult, PropertyValues } from 'lit';
2
- import { TilePosition } from '../types/tile-position';
3
- import { TileLayoutSnapshot } from '../types/tile-layout-snapshot';
4
- import { GridRect } from '../types/grid-rect';
5
- export interface MintTile {
6
- id: string;
7
- position: TilePosition;
8
- disableMove?: boolean;
9
- disableResize?: boolean;
10
- label?: string | null;
11
- }
12
- export type TileDragMode = 'tile' | 'header' | 'off';
13
- export type TileResizeMode = 'hover' | 'always' | 'off';
14
- type GestureState = {
15
- kind: 'idle';
16
- } | {
17
- kind: 'arming-touch-drag';
18
- pointerId: number;
19
- tileId: string;
20
- startX: number;
21
- startY: number;
22
- timer: number | null;
23
- pressingTimer: number | null;
24
- } | {
25
- kind: 'drag';
26
- pointerId: number;
27
- tileId: string;
28
- pointerOffset: {
29
- dx: number;
30
- dy: number;
31
- };
32
- currentRect: GridRect;
33
- blocked: boolean;
34
- } | {
35
- kind: 'resize';
36
- pointerId: number;
37
- tileId: string;
38
- mode: 'side' | 'bottom' | 'corner';
39
- startPointer: {
40
- x: number;
41
- y: number;
42
- };
43
- startSpans: {
44
- colSpan: number;
45
- rowSpan: number;
46
- };
47
- currentRect: GridRect;
48
- blocked: boolean;
49
- };
50
- export declare class MintTileManagerElement extends LitElement {
51
- static styles: import('lit').CSSResult[];
52
- static get observedAttributes(): string[];
53
- static properties: {
54
- tiles: {
55
- attribute: boolean;
56
- };
57
- columnCount: {
58
- attribute: string;
59
- type: NumberConstructor;
60
- };
61
- minColumnWidth: {
62
- attribute: string;
63
- type: StringConstructor;
64
- };
65
- minRowHeight: {
66
- attribute: string;
67
- type: StringConstructor;
68
- };
69
- gap: {
70
- attribute: string;
71
- type: StringConstructor;
72
- };
73
- dragMode: {
74
- attribute: string;
75
- type: StringConstructor;
76
- reflect: boolean;
77
- };
78
- resizeMode: {
79
- attribute: string;
80
- type: StringConstructor;
81
- reflect: boolean;
82
- };
83
- animateReflow: {
84
- attribute: string;
85
- type: BooleanConstructor;
86
- };
87
- label: {
88
- attribute: string;
89
- type: StringConstructor;
90
- };
91
- previewLayout: {
92
- state: boolean;
93
- };
94
- gestureKind: {
95
- state: boolean;
96
- };
97
- blocked: {
98
- state: boolean;
99
- };
100
- focusedTileId: {
101
- state: boolean;
102
- };
103
- };
104
- tiles: ReadonlyArray<MintTile>;
105
- columnCount: number | null;
106
- minColumnWidth: string;
107
- minRowHeight: string;
108
- gap: string;
109
- dragMode: TileDragMode;
110
- resizeMode: TileResizeMode;
111
- animateReflow: boolean;
112
- label: string | null;
113
- private gestureState;
114
- private keyboardState;
115
- protected previewLayout: TileLayoutSnapshot | null;
116
- protected gestureKind: GestureState['kind'];
117
- protected blocked: boolean;
118
- protected effectiveColumnCount: number;
119
- protected focusedTileId: string | null;
120
- private readonly liveAnnouncer;
121
- private readonly instanceId;
122
- private get instructionsId();
123
- private hostResizeObserver;
124
- private flipPreviousRects;
125
- private cellMetrics;
126
- private readonly onWindowPointerMove;
127
- private readonly onWindowPointerUp;
128
- private readonly onWindowPointerCancel;
129
- private readonly onWindowKeyDown;
130
- private readonly onVisibilityChange;
131
- render(): TemplateResult;
132
- private renderTile;
133
- private computeGridStyle;
134
- /**
135
- * Refresh the cached layout metrics by reading layout / computed-style state
136
- * once. Called from firstUpdated, the ResizeObserver tick, and updated()
137
- * when an input that affects metrics changes — never from render().
138
- */
139
- private updateLayoutCache;
140
- private computeActiveTransform;
141
- /** The numbers the pure drag geometry needs: pointer, live grid origin, grab offset. */
142
- private dragPointer;
143
- connectedCallback(): void;
144
- disconnectedCallback(): void;
145
- protected firstUpdated(): void;
146
- attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
147
- protected willUpdate(_changed: PropertyValues): void;
148
- protected updated(changed: PropertyValues): void;
149
- private shouldAnimate;
150
- private lastPointerPosition;
151
- private onTilePointerDown;
152
- private onResizeHandlePointerDown;
153
- private armPointerDrag;
154
- private armTouchDrag;
155
- private cleanupTouchArming;
156
- private beginDragFromTouchArm;
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;
164
- private beginResize;
165
- private announceDragBegin;
166
- private announceResizeBegin;
167
- private attachWindowListeners;
168
- private detachWindowListeners;
169
- private handleEscapeKey;
170
- private handlePointerMove;
171
- private handlePointerUp;
172
- private handlePointerCancel;
173
- private runPackerForCurrentGesture;
174
- private computeDragRect;
175
- private computeResizeRect;
176
- private commitGesture;
177
- private cancelGesture;
178
- private cleanupGesture;
179
- private positionsEqual;
180
- private cloneSnapshot;
181
- private activeTileId;
182
- /** Read-only snapshot of the current layout. Mirrors `BsDockManagerComponent.captureLayout()`. */
183
- captureLayout(): TileLayoutSnapshot;
184
- /**
185
- * True while a drag or resize is in flight. The Angular wrapper uses this to
186
- * avoid clobbering `tiles` mid-gesture. Touch long-press arming does NOT
187
- * count — the WC isn't yet owning the layout during the hold.
188
- */
189
- get isGestureActive(): boolean;
190
- private onTileKeyDown;
191
- /**
192
- * Outside move mode, arrow keys move *focus* between tiles (row-major
193
- * order — top-to-bottom, left-to-right by gridcell position). Home/End
194
- * jump to first/last enabled tile. Returns true if the event was handled.
195
- */
196
- private handleFocusNavigation;
197
- private onTileFocus;
198
- /**
199
- * The single tile that should carry `tabindex="0"` to act as the board's
200
- * tab stop. Defaults to the previously-focused tile, then the first tile in
201
- * row-major order. All other tiles render with `tabindex="-1"` so Tab from
202
- * outside the board lands on exactly one tile.
203
- */
204
- private resolveFocusableTileId;
205
- private applyKeyboardStep;
206
- }
207
- declare global {
208
- interface HTMLElementTagNameMap {
209
- 'mp-tile-manager': MintTileManagerElement;
210
- }
211
- }
212
- export {};
@@ -1,2 +0,0 @@
1
- export declare const template: import('lit-html').TemplateResult<1>;
2
- export declare const styles: import('lit').CSSResult;
@@ -1,12 +0,0 @@
1
- /**
2
- * Half-open rectangle in grid coordinates: `[colStart, colStart + colSpan) × [rowStart, rowStart + rowSpan)`.
3
- * Same shape as `TilePosition` but used internally for overlap math; kept
4
- * as its own type so call-sites read clearly.
5
- */
6
- export interface GridRect {
7
- colStart: number;
8
- rowStart: number;
9
- colSpan: number;
10
- rowSpan: number;
11
- }
12
- export declare function rectsOverlap(a: GridRect, b: GridRect): boolean;
@@ -1,3 +0,0 @@
1
- export * from './grid-rect';
2
- export * from './tile-layout-snapshot';
3
- export * from './tile-position';
@@ -1,15 +0,0 @@
1
- import { TilePosition } from './tile-position';
2
- /**
3
- * Stable, JSON-serializable snapshot of the manager's layout.
4
- * One entry per tile, keyed by stable id. Host apps `JSON.stringify`
5
- * this for persistence and project it back into per-tile `position`
6
- * inputs to restore.
7
- */
8
- export type TileLayoutSnapshot = Array<{
9
- id: string;
10
- position: TilePosition;
11
- }>;
12
- export interface TileGestureBlocked {
13
- id: string;
14
- reason: 'locked-overlap' | 'no-valid-layout';
15
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * Grid placement of a single tile, in CSS Grid 1-based coordinates.
3
- * `colStart` / `rowStart` are inclusive; `colSpan` / `rowSpan` are counts of cells.
4
- */
5
- export interface TilePosition {
6
- colStart: number;
7
- rowStart: number;
8
- colSpan: number;
9
- rowSpan: number;
10
- }
@@ -1,49 +0,0 @@
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;
@@ -1 +0,0 @@
1
- export * from './pack';
@@ -1,24 +0,0 @@
1
- import { TilePosition } from '../types/tile-position';
2
- import { TileLayoutSnapshot } from '../types/tile-layout-snapshot';
3
- import { GridRect } from '../types/grid-rect';
4
- interface PackInputTile {
5
- id: string;
6
- position: TilePosition;
7
- locked: boolean;
8
- }
9
- /**
10
- * Vertical-compact packer. The pinned tile's rect is the user's gesture; all
11
- * other tiles flow around it (locked tiles stay put; movable tiles get pushed
12
- * out of the way and gravity-compacted upward).
13
- *
14
- * Returns `blocked: true` if the pinned rect overlaps a locked tile or no
15
- * valid layout exists; the caller should snap back and not commit.
16
- */
17
- export declare function pack(tiles: ReadonlyArray<PackInputTile>, pinned: {
18
- id: string;
19
- rect: GridRect;
20
- }, columnCount: number): {
21
- layout: TileLayoutSnapshot;
22
- blocked: boolean;
23
- };
24
- export {};