@mintplayer/web-components 2.20.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.
Files changed (41) hide show
  1. package/chunks/{datatable-qkYf-N0c.mjs → datatable-CrK1ZNq-.mjs} +132 -130
  2. package/chunks/{pagination-Bcz1TwlS.mjs → pagination-DgDp3v3u.mjs} +1 -1
  3. package/custom-elements.json +3119 -3416
  4. package/datatable/index.mjs +1 -1
  5. package/datatable/src/components/mp-datatable.d.ts +4 -0
  6. package/datatable/src/types/tree.d.ts +7 -0
  7. package/dropdown-menu/index.mjs +16 -23
  8. package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +5 -8
  9. package/dropdown-menu/src/index.d.ts +1 -1
  10. package/dropdown-menu/src/types/dropdown.d.ts +0 -2
  11. package/dropdown-menu/src/types/index.d.ts +1 -1
  12. package/file-manager/index.mjs +1 -1
  13. package/light-dom/index.mjs +61 -121
  14. package/light-dom/src/install-light-styles.d.ts +10 -22
  15. package/light-dom/src/scoped-html.d.ts +0 -6
  16. package/machine/index.d.ts +1 -0
  17. package/machine/index.mjs +47 -0
  18. package/machine/src/index.d.ts +2 -0
  19. package/machine/src/machine-controller.d.ts +25 -0
  20. package/machine/src/props-directive.d.ts +21 -0
  21. package/package.json +10 -1
  22. package/pagination/index.mjs +1 -1
  23. package/tile-manager/index.mjs +150 -731
  24. package/tile-manager/src/components/index.d.ts +1 -2
  25. package/tile-manager/src/components/mp-tile-manager.d.ts +107 -0
  26. package/tile-manager/src/index.d.ts +2 -3
  27. package/tree-select/index.mjs +63 -55
  28. package/tree-select/src/components/mp-tree-select.d.ts +16 -5
  29. package/typeahead/index.d.ts +1 -0
  30. package/typeahead/index.mjs +220 -0
  31. package/typeahead/src/components/mp-typeahead.d.ts +67 -0
  32. package/typeahead/src/index.d.ts +3 -0
  33. package/tile-manager/src/components/mint-tile-manager.element.d.ts +0 -212
  34. package/tile-manager/src/components/mint-tile-manager.element.template.d.ts +0 -2
  35. package/tile-manager/src/types/grid-rect.d.ts +0 -12
  36. package/tile-manager/src/types/index.d.ts +0 -3
  37. package/tile-manager/src/types/tile-layout-snapshot.d.ts +0 -15
  38. package/tile-manager/src/types/tile-position.d.ts +0 -10
  39. package/tile-manager/src/utils/grid-geometry.d.ts +0 -49
  40. package/tile-manager/src/utils/index.d.ts +0 -1
  41. package/tile-manager/src/utils/pack.d.ts +0 -24
@@ -0,0 +1,67 @@
1
+ import { LitElement, PropertyValues } from 'lit';
2
+ import { TypeaheadMachine, TypeaheadProvider } from '@mintplayer/ui-core/typeahead';
3
+ /** Renders one suggestion row. The returned node is the consumer's: it is never scope-stamped. */
4
+ export type TypeaheadItemRenderer<T> = (item: T, term: string) => Node | null | undefined;
5
+ declare const MpTypeahead_base: typeof LitElement & (new (...args: any[]) => import('@mintplayer/web-components/a11y').FormAssociatedElement);
6
+ /**
7
+ * `<mp-typeahead>` — a text input with asynchronous suggestions and free text.
8
+ *
9
+ * The web-component front of the headless `TypeaheadMachine`
10
+ * (`@mintplayer/ui-core/typeahead`, #436): the same core, the same ARIA bags,
11
+ * the same scoped stylesheet as `bs-typeahead` (Angular), `BsTypeahead`
12
+ * (React) and `BsTypeahead.vue`.
13
+ *
14
+ * Tier L (emulated encapsulation): no shadow root, because `itemRenderer`
15
+ * mounts consumer DOM, and so the combobox input and its options share one
16
+ * tree (aria-activedescendant resolves). Form-associated: the term is the
17
+ * submitted value under `name`; `fieldset[disabled]` reaches it.
18
+ *
19
+ * No-JS: not server-rendered (light-tier elements are emitted empty); the
20
+ * Angular front is the one with a server-rendered input.
21
+ */
22
+ export declare class MpTypeahead<T = unknown> extends MpTypeahead_base {
23
+ #private;
24
+ static get observedAttributes(): string[];
25
+ protected createRenderRoot(): HTMLElement;
26
+ /** The machine behind this element (shared contract with the framework fronts). */
27
+ get machine(): TypeaheadMachine<T>;
28
+ /** The term. Setting it never queries. */
29
+ get value(): string;
30
+ set value(next: string);
31
+ /** The last picked item; null once the text changes after the pick. */
32
+ get selectedItem(): T | null;
33
+ get provider(): TypeaheadProvider<T> | null;
34
+ set provider(next: TypeaheadProvider<T> | null);
35
+ get debounceMs(): number;
36
+ set debounceMs(next: number);
37
+ get minLength(): number;
38
+ set minLength(next: number);
39
+ set itemText(fn: ((item: T) => string) | undefined);
40
+ set itemKey(fn: ((item: T) => unknown) | undefined);
41
+ get itemRenderer(): TypeaheadItemRenderer<T> | null;
42
+ set itemRenderer(fn: TypeaheadItemRenderer<T> | null);
43
+ set resultsLabel(fn: ((count: number) => string) | undefined);
44
+ get name(): string | null;
45
+ set name(next: string | null);
46
+ get disabled(): boolean;
47
+ set disabled(next: boolean);
48
+ get errorText(): string | null;
49
+ set errorText(next: string | null);
50
+ attributeChangedCallback(name: string, old: string | null, value: string | null): void;
51
+ formValue(): string | null;
52
+ formReset(): void;
53
+ formRestore(state: string | FormData | File | null): void;
54
+ formValidityAnchor(): HTMLElement | null;
55
+ protected willUpdate(changed: PropertyValues): void;
56
+ protected updated(changed: PropertyValues): void;
57
+ disconnectedCallback(): void;
58
+ /** Focus the input. */
59
+ focus(options?: FocusOptions): void;
60
+ protected render(): import('lit-html').TemplateResult;
61
+ }
62
+ declare global {
63
+ interface HTMLElementTagNameMap {
64
+ 'mp-typeahead': MpTypeahead;
65
+ }
66
+ }
67
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './components/mp-typeahead';
2
+ export { typeaheadScopedStyles, inMemoryTypeaheadProvider } from '@mintplayer/ui-core/typeahead';
3
+ export type { TypeaheadProvider, TypeaheadRequest, TypeaheadLabels } from '@mintplayer/ui-core/typeahead';
@@ -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 {};