@mk-kit/ui 0.34.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/LICENSE +21 -0
- package/README.md +115 -0
- package/block-editor/README.md +254 -0
- package/fesm2022/mk-kit-ui-block-editor.mjs +2158 -0
- package/fesm2022/mk-kit-ui-block-editor.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-button.mjs +81 -0
- package/fesm2022/mk-kit-ui-button.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-checkbox.mjs +136 -0
- package/fesm2022/mk-kit-ui-checkbox.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-chip.mjs +122 -0
- package/fesm2022/mk-kit-ui-chip.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-context-menu.mjs +144 -0
- package/fesm2022/mk-kit-ui-context-menu.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-core.mjs +1576 -0
- package/fesm2022/mk-kit-ui-core.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-data.mjs +6055 -0
- package/fesm2022/mk-kit-ui-data.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-datetime.mjs +3409 -0
- package/fesm2022/mk-kit-ui-datetime.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-directives.mjs +1779 -0
- package/fesm2022/mk-kit-ui-directives.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-dnd.mjs +1073 -0
- package/fesm2022/mk-kit-ui-dnd.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-feedback.mjs +2426 -0
- package/fesm2022/mk-kit-ui-feedback.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-forms.mjs +9208 -0
- package/fesm2022/mk-kit-ui-forms.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-icon.mjs +470 -0
- package/fesm2022/mk-kit-ui-icon.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-media.mjs +896 -0
- package/fesm2022/mk-kit-ui-media.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-navigation.mjs +2542 -0
- package/fesm2022/mk-kit-ui-navigation.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-rich-text.mjs +565 -0
- package/fesm2022/mk-kit-ui-rich-text.mjs.map +1 -0
- package/fesm2022/mk-kit-ui-table.mjs +1378 -0
- package/fesm2022/mk-kit-ui-table.mjs.map +1 -0
- package/fesm2022/mk-kit-ui.mjs +32 -0
- package/fesm2022/mk-kit-ui.mjs.map +1 -0
- package/package.json +130 -0
- package/schematics/collection.json +10 -0
- package/schematics/ng-add/index.js +113 -0
- package/schematics/ng-add/schema.json +22 -0
- package/schematics/package.json +3 -0
- package/styles/mk-kit.css +750 -0
- package/types/mk-kit-ui-block-editor.d.ts +292 -0
- package/types/mk-kit-ui-button.d.ts +40 -0
- package/types/mk-kit-ui-checkbox.d.ts +62 -0
- package/types/mk-kit-ui-chip.d.ts +59 -0
- package/types/mk-kit-ui-context-menu.d.ts +57 -0
- package/types/mk-kit-ui-core.d.ts +1105 -0
- package/types/mk-kit-ui-data.d.ts +2580 -0
- package/types/mk-kit-ui-datetime.d.ts +1171 -0
- package/types/mk-kit-ui-directives.d.ts +807 -0
- package/types/mk-kit-ui-dnd.d.ts +423 -0
- package/types/mk-kit-ui-feedback.d.ts +1270 -0
- package/types/mk-kit-ui-forms.d.ts +3586 -0
- package/types/mk-kit-ui-icon.d.ts +108 -0
- package/types/mk-kit-ui-media.d.ts +549 -0
- package/types/mk-kit-ui-navigation.d.ts +1169 -0
- package/types/mk-kit-ui-rich-text.d.ts +187 -0
- package/types/mk-kit-ui-table.d.ts +739 -0
- package/types/mk-kit-ui.d.ts +17 -0
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { TemplateRef } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Optional grip that restricts where a pointer drag of the enclosing
|
|
6
|
+
* `[mkDrag]` may begin. Place it on the element the user should press to drag;
|
|
7
|
+
* without any handle the whole item is draggable.
|
|
8
|
+
*
|
|
9
|
+
* A directive (not a component), so it composes onto anything — a `<span>`,
|
|
10
|
+
* a `<button>`, or another component's host such as `<mk-icon mkDragHandle />`.
|
|
11
|
+
* Its look (grab cursor, muted colour, `touch-action: none`) ships as the
|
|
12
|
+
* global `.mk-drag-handle` class in the theme stylesheet.
|
|
13
|
+
*
|
|
14
|
+
* ```html
|
|
15
|
+
* <div mkDrag [mkDragData]="row">
|
|
16
|
+
* <span mkDragHandle aria-hidden="true">⠿</span>
|
|
17
|
+
* {{ row.name }}
|
|
18
|
+
* </div>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare class MkDragHandle {
|
|
22
|
+
/** The handle's host element. */
|
|
23
|
+
readonly element: HTMLElement;
|
|
24
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MkDragHandle, never>;
|
|
25
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<MkDragHandle, "[mkDragHandle]", ["mkDragHandle"], {}, {}, never, never, true, never>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Makes an item inside a `[mkDropList]` draggable — by pointer (mouse / touch /
|
|
30
|
+
* pen) **and** by keyboard (WCAG 2.1.1). The item is focusable, exposes
|
|
31
|
+
* `role="button"` + `aria-roledescription="Draggable item"`, and every move is
|
|
32
|
+
* announced via {@link MkLiveAnnouncer}.
|
|
33
|
+
*
|
|
34
|
+
* Keyboard: focus an item and press **Space/Enter** to pick it up, **Arrow**
|
|
35
|
+
* keys to move it (crossing into connected lists at the ends / across the
|
|
36
|
+
* perpendicular axis), **Space/Enter** to drop, **Escape** to cancel.
|
|
37
|
+
*
|
|
38
|
+
* Touch: a swipe scrolls the page as usual — the drag only arms after a
|
|
39
|
+
* long-press ({@link mkDragTouchDelay}, default 300 ms). While armed the item
|
|
40
|
+
* gets the `mk-drag--armed` class so consumers can style the lift moment.
|
|
41
|
+
* Mouse and pen drags start immediately, as before.
|
|
42
|
+
*
|
|
43
|
+
* Performance: pointer moves are rAF-coalesced (one hit-test + one set of
|
|
44
|
+
* style/DOM writes per frame) against list/item rects snapshotted when the
|
|
45
|
+
* drag lifts, so a move never forces layout. The pending frame is flushed
|
|
46
|
+
* synchronously on release so drops land exactly where the pointer ended.
|
|
47
|
+
*
|
|
48
|
+
* ```html
|
|
49
|
+
* <li mkDrag [mkDragData]="row" [mkDragDisabled]="row.locked">
|
|
50
|
+
* <span mkDragHandle aria-hidden="true">⠿</span> {{ row.title }}
|
|
51
|
+
* </li>
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @typeParam T item data type.
|
|
55
|
+
*/
|
|
56
|
+
declare class MkDrag<T = unknown> {
|
|
57
|
+
private readonly doc;
|
|
58
|
+
private readonly registry;
|
|
59
|
+
private readonly announcer;
|
|
60
|
+
private readonly i18n;
|
|
61
|
+
private readonly home;
|
|
62
|
+
/** The item's host element. */
|
|
63
|
+
readonly element: HTMLElement;
|
|
64
|
+
/** Arbitrary payload associated with this item. */
|
|
65
|
+
readonly mkDragData: _angular_core.InputSignal<T | undefined>;
|
|
66
|
+
/** Disable dragging this specific item. */
|
|
67
|
+
readonly mkDragDisabled: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
68
|
+
/**
|
|
69
|
+
* Long-press delay (ms) before a *touch* pointer arms the drag. Until it
|
|
70
|
+
* elapses a swipe scrolls natively; moving more than {@link TOUCH_SLOP}
|
|
71
|
+
* pixels abandons the pending drag. `0` arms immediately (legacy behavior).
|
|
72
|
+
* Mouse and pen are never delayed.
|
|
73
|
+
*/
|
|
74
|
+
readonly mkDragTouchDelay: _angular_core.InputSignalWithTransform<number, unknown>;
|
|
75
|
+
/** Every handle in the projected subtree, including those of nested drags. */
|
|
76
|
+
private readonly handles;
|
|
77
|
+
/**
|
|
78
|
+
* Handles that belong to *this* drag — i.e. whose nearest `[mkDrag]` ancestor
|
|
79
|
+
* is this item, not a nested one. A nested `[mkDropList]`/`[mkDrag]` (a
|
|
80
|
+
* product list inside a draggable category, say) would otherwise have its
|
|
81
|
+
* handles captured by the outer item via `descendants: true`, so pressing an
|
|
82
|
+
* inner handle would start the outer drag and inner dnd would never work.
|
|
83
|
+
*/
|
|
84
|
+
protected readonly ownHandles: _angular_core.Signal<MkDragHandle[]>;
|
|
85
|
+
/** True while a pointer drag is in progress. */
|
|
86
|
+
protected readonly dragging: _angular_core.WritableSignal<boolean>;
|
|
87
|
+
/** True while the item is "picked up" for keyboard movement. */
|
|
88
|
+
protected readonly lifted: _angular_core.WritableSignal<boolean>;
|
|
89
|
+
/** True from the moment a touch long-press arms the drag until release. */
|
|
90
|
+
protected readonly armed: _angular_core.WritableSignal<boolean>;
|
|
91
|
+
/** Whether the home list lays items out horizontally (scopes touch-action). */
|
|
92
|
+
protected readonly inHorizontalList: _angular_core.Signal<boolean>;
|
|
93
|
+
/** Effective disabled state (item- or list-level). */
|
|
94
|
+
readonly disabled: _angular_core.Signal<boolean>;
|
|
95
|
+
private targetList;
|
|
96
|
+
private targetIndex;
|
|
97
|
+
private homeIndex;
|
|
98
|
+
private placeholder;
|
|
99
|
+
private pointerId;
|
|
100
|
+
private started;
|
|
101
|
+
private startX;
|
|
102
|
+
private startY;
|
|
103
|
+
private offsetX;
|
|
104
|
+
private offsetY;
|
|
105
|
+
private originLeft;
|
|
106
|
+
private originTop;
|
|
107
|
+
private preview;
|
|
108
|
+
private readonly moveHandler;
|
|
109
|
+
private readonly upHandler;
|
|
110
|
+
private readonly cancelHandler;
|
|
111
|
+
/** Gate for the move handler: mouse/pen arm on pointerdown, touch on timer. */
|
|
112
|
+
private pointerArmed;
|
|
113
|
+
private touchTimer;
|
|
114
|
+
/** Inline `touch-action` to restore after a drag locked it (null = not locked). */
|
|
115
|
+
private savedTouchAction;
|
|
116
|
+
/**
|
|
117
|
+
* `touch-action: pan-y` (see drag.scss) keeps native scrolling alive while
|
|
118
|
+
* the long-press is pending, but that also means the browser may still start
|
|
119
|
+
* a scroll once we *are* dragging — so the armed drag must eat `touchmove`.
|
|
120
|
+
* Registered with `passive: false` for `preventDefault` to register.
|
|
121
|
+
*/
|
|
122
|
+
private readonly touchMoveHandler;
|
|
123
|
+
/** Android fires `contextmenu` on long-press — keep it off the gesture. */
|
|
124
|
+
private readonly contextMenuHandler;
|
|
125
|
+
/** Pending rAF id for the coalesced move pass, if any. */
|
|
126
|
+
private moveRaf;
|
|
127
|
+
private pendingX;
|
|
128
|
+
private pendingY;
|
|
129
|
+
private hasPendingMove;
|
|
130
|
+
/** Connected lists resolved once at lift (stable for the drag's duration). */
|
|
131
|
+
private cachedGroup;
|
|
132
|
+
/** List bounds snapshotted at lift / after invalidation. */
|
|
133
|
+
private readonly listRects;
|
|
134
|
+
/** Item bounds per list, aligned with `itemElementsExcept(this)`. */
|
|
135
|
+
private readonly itemRects;
|
|
136
|
+
/** Lists whose snapshots a placeholder move invalidated (re-measured next frame). */
|
|
137
|
+
private readonly dirtyLists;
|
|
138
|
+
/** Any scroll moves everything — re-snapshot every list on the next frame. */
|
|
139
|
+
private scrollDirty;
|
|
140
|
+
private readonly scrollHandler;
|
|
141
|
+
/** Last placeholder sync target — makes `syncPlaceholder` idempotent. */
|
|
142
|
+
private lastSyncList;
|
|
143
|
+
private lastSyncIndex;
|
|
144
|
+
protected onPointerDown(event: Event): void;
|
|
145
|
+
private onPointerMove;
|
|
146
|
+
/** The long-press delay elapsed with the finger still down — lift. */
|
|
147
|
+
private armTouch;
|
|
148
|
+
private lockTouchAction;
|
|
149
|
+
private unlockTouchAction;
|
|
150
|
+
/** Undo everything the touch path set up (timer, listeners, lock, class). */
|
|
151
|
+
private clearTouchState;
|
|
152
|
+
private onPointerUp;
|
|
153
|
+
private beginPointer;
|
|
154
|
+
/** Coalesce move handling to at most one layout pass per animation frame. */
|
|
155
|
+
private scheduleMoveFrame;
|
|
156
|
+
/**
|
|
157
|
+
* Cancel the scheduled frame; when `apply` is set, process the pending
|
|
158
|
+
* coordinates synchronously (flush-on-end, like the table column resize) so
|
|
159
|
+
* a drop lands exactly where the pointer stopped.
|
|
160
|
+
*/
|
|
161
|
+
private flushMoveFrame;
|
|
162
|
+
/**
|
|
163
|
+
* The per-frame move pass. Ordered reads → writes: refresh invalidated
|
|
164
|
+
* snapshots first, resolve the hovered list/index from the cache, then do
|
|
165
|
+
* all style/DOM writes — no read ever follows a write within the frame.
|
|
166
|
+
*/
|
|
167
|
+
private applyPendingMove;
|
|
168
|
+
private finishPointer;
|
|
169
|
+
private commitPointer;
|
|
170
|
+
protected onKeyDown(event: Event): void;
|
|
171
|
+
protected onBlur(): void;
|
|
172
|
+
private pickUp;
|
|
173
|
+
private stepPrimary;
|
|
174
|
+
private stepList;
|
|
175
|
+
private moveToList;
|
|
176
|
+
private dropKeyboard;
|
|
177
|
+
private cancelKeyboard;
|
|
178
|
+
/** "Picked up…" instructions when a keyboard drag starts. */
|
|
179
|
+
private announcePickedUp;
|
|
180
|
+
/** Position update after each keyboard step (names the list when crossing). */
|
|
181
|
+
private announceMove;
|
|
182
|
+
/** Confirmation after a successful drop (pointer: polite; keyboard: assertive). */
|
|
183
|
+
private announceDropped;
|
|
184
|
+
/** The drag was cancelled and the item snapped back. */
|
|
185
|
+
private announceCancelled;
|
|
186
|
+
/** Highest valid target index for `list` given the item is being removed. */
|
|
187
|
+
private maxIndex;
|
|
188
|
+
private adjacentList;
|
|
189
|
+
/** Snapshot every connected list's bounds + item bounds (at lift / scroll). */
|
|
190
|
+
private snapshotRects;
|
|
191
|
+
/** (Re)measure one list's bounds and item bounds into the cache. */
|
|
192
|
+
private measureList;
|
|
193
|
+
/**
|
|
194
|
+
* Which connected list (if any) the pointer is currently over. Pointer path
|
|
195
|
+
* only — reads the rects snapshotted at lift, not live layout.
|
|
196
|
+
*/
|
|
197
|
+
private listUnderPoint;
|
|
198
|
+
/**
|
|
199
|
+
* Insertion index for the pointer position within `list`. Pointer path only
|
|
200
|
+
* — reads the cached item rects (live measurement is the fallback for a
|
|
201
|
+
* list that somehow joined the group mid-drag).
|
|
202
|
+
*/
|
|
203
|
+
private indexInList;
|
|
204
|
+
private syncPlaceholder;
|
|
205
|
+
private createPlaceholder;
|
|
206
|
+
private createPreview;
|
|
207
|
+
/** Remove the body-level preview + placeholder if destroyed mid-drag. */
|
|
208
|
+
ngOnDestroy(): void;
|
|
209
|
+
private destroyed;
|
|
210
|
+
private cleanupDom;
|
|
211
|
+
private emit;
|
|
212
|
+
private isHandleTarget;
|
|
213
|
+
private prefersReducedMotion;
|
|
214
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MkDrag<any>, never>;
|
|
215
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MkDrag<any>, "[mkDrag]", ["mkDrag"], { "mkDragData": { "alias": "mkDragData"; "required": false; "isSignal": true; }; "mkDragDisabled": { "alias": "mkDragDisabled"; "required": false; "isSignal": true; }; "mkDragTouchDelay": { "alias": "mkDragTouchDelay"; "required": false; "isSignal": true; }; }, {}, ["handles"], ["*"], true, never>;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* A drop container for reorderable `[mkDrag]` items.
|
|
220
|
+
*
|
|
221
|
+
* - **Sort list:** a single `[mkDropList]` over an array — items reorder within it.
|
|
222
|
+
* - **Buckets / kanban:** several `[mkDropList]`s wired together with
|
|
223
|
+
* `mkDropListConnectedTo` so items transfer between them (both by pointer and
|
|
224
|
+
* by keyboard at the ends of a list).
|
|
225
|
+
*
|
|
226
|
+
* The array bound to `mkDropListData` is **not** mutated for you — handle
|
|
227
|
+
* `mkDropListDropped` and call {@link mkMoveItemInArray} / {@link mkTransferArrayItem}.
|
|
228
|
+
*
|
|
229
|
+
* ```html
|
|
230
|
+
* <ul mkDropList [mkDropListData]="todo()"
|
|
231
|
+
* mkDropListId="todo" [mkDropListConnectedTo]="['done']"
|
|
232
|
+
* (mkDropListDropped)="drop($event)">
|
|
233
|
+
* @for (t of todo(); track t.id) {
|
|
234
|
+
* <li mkDrag [mkDragData]="t">{{ t.title }}</li>
|
|
235
|
+
* }
|
|
236
|
+
* </ul>
|
|
237
|
+
* ```
|
|
238
|
+
*
|
|
239
|
+
* @typeParam T item data type.
|
|
240
|
+
*/
|
|
241
|
+
declare class MkDropList<T = unknown> {
|
|
242
|
+
private readonly registry;
|
|
243
|
+
/** The list's host element (drop target bounds). */
|
|
244
|
+
readonly element: HTMLElement;
|
|
245
|
+
/** The array backing the list. Bound, never mutated by the directive. */
|
|
246
|
+
readonly mkDropListData: _angular_core.InputSignal<readonly T[]>;
|
|
247
|
+
/** Stable id used to connect lists. Auto-generated when omitted. */
|
|
248
|
+
readonly mkDropListId: _angular_core.InputSignal<string | undefined>;
|
|
249
|
+
/** Ids of other lists items may be transferred into. */
|
|
250
|
+
readonly mkDropListConnectedTo: _angular_core.InputSignal<readonly string[]>;
|
|
251
|
+
/**
|
|
252
|
+
* Human-readable name used in screen-reader announcements when an item is
|
|
253
|
+
* moved into this list (e.g. `"In progress"`). Falls back to the list `id`
|
|
254
|
+
* — which may be auto-generated gibberish — so set it wherever users can
|
|
255
|
+
* move items across lists by keyboard.
|
|
256
|
+
*/
|
|
257
|
+
readonly mkDropListLabel: _angular_core.InputSignal<string>;
|
|
258
|
+
/** Layout axis; controls pointer hit-testing and arrow-key direction. */
|
|
259
|
+
readonly mkDropListOrientation: _angular_core.InputSignal<MkDropListOrientation>;
|
|
260
|
+
/** Disable dropping into (and dragging out of) this list. */
|
|
261
|
+
readonly mkDropListDisabled: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
262
|
+
/** Fires when an item is dropped into this list (pointer or keyboard). */
|
|
263
|
+
readonly mkDropListDropped: _angular_core.OutputEmitterRef<MkDropEvent<T>>;
|
|
264
|
+
/** Resolved id (input or generated). */
|
|
265
|
+
readonly id: _angular_core.Signal<string>;
|
|
266
|
+
private readonly autoId;
|
|
267
|
+
/** Announceable name: the label when set, otherwise the resolved id. */
|
|
268
|
+
readonly label: _angular_core.Signal<string>;
|
|
269
|
+
/** Connected-list ids, normalised to a plain array. */
|
|
270
|
+
readonly connectedTo: _angular_core.Signal<readonly string[]>;
|
|
271
|
+
/** The `mkDrag` items projected into this list, in DOM order. */
|
|
272
|
+
private readonly drags;
|
|
273
|
+
/** Highlight while a drag is hovering this list. */
|
|
274
|
+
protected readonly _receiving: _angular_core.WritableSignal<boolean>;
|
|
275
|
+
constructor();
|
|
276
|
+
/** Number of drag items currently in the list. */
|
|
277
|
+
size(): number;
|
|
278
|
+
/** Index of `drag` among this list's items, or -1. */
|
|
279
|
+
indexOf(drag: MkDrag<any>): number;
|
|
280
|
+
/** Host elements of this list's items, excluding `exclude`, in DOM order. */
|
|
281
|
+
itemElementsExcept(exclude: MkDrag<any>): HTMLElement[];
|
|
282
|
+
/** Toggle the "receiving" highlight (called by the active drag). */
|
|
283
|
+
setReceiving(value: boolean): void;
|
|
284
|
+
/** Emit a drop into this list. Called by the active `MkDrag`. */
|
|
285
|
+
emitDrop(event: MkDropEvent<any>): void;
|
|
286
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MkDropList<any>, never>;
|
|
287
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MkDropList<any>, "[mkDropList]", ["mkDropList"], { "mkDropListData": { "alias": "mkDropListData"; "required": false; "isSignal": true; }; "mkDropListId": { "alias": "mkDropListId"; "required": false; "isSignal": true; }; "mkDropListConnectedTo": { "alias": "mkDropListConnectedTo"; "required": false; "isSignal": true; }; "mkDropListLabel": { "alias": "mkDropListLabel"; "required": false; "isSignal": true; }; "mkDropListOrientation": { "alias": "mkDropListOrientation"; "required": false; "isSignal": true; }; "mkDropListDisabled": { "alias": "mkDropListDisabled"; "required": false; "isSignal": true; }; }, { "mkDropListDropped": "mkDropListDropped"; }, ["drags"], ["*"], true, never>;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** Layout axis a drop list lays its items along. */
|
|
291
|
+
type MkDropListOrientation = 'vertical' | 'horizontal';
|
|
292
|
+
/**
|
|
293
|
+
* Emitted by `[mkDropList]` (`mkDropListDropped`) when an item is dropped.
|
|
294
|
+
*
|
|
295
|
+
* Mirrors the shape of Angular CDK's `CdkDragDrop` so the exported
|
|
296
|
+
* {@link mkMoveItemInArray} / {@link mkTransferArrayItem} helpers can be used
|
|
297
|
+
* exactly as their CDK counterparts:
|
|
298
|
+
*
|
|
299
|
+
* ```ts
|
|
300
|
+
* onDrop(e: MkDropEvent) {
|
|
301
|
+
* if (e.previousContainer === e.container) {
|
|
302
|
+
* mkMoveItemInArray(e.container.mkDropListData(), e.previousIndex, e.currentIndex);
|
|
303
|
+
* } else {
|
|
304
|
+
* mkTransferArrayItem(
|
|
305
|
+
* e.previousContainer.mkDropListData(),
|
|
306
|
+
* e.container.mkDropListData(),
|
|
307
|
+
* e.previousIndex, e.currentIndex,
|
|
308
|
+
* );
|
|
309
|
+
* }
|
|
310
|
+
* }
|
|
311
|
+
* ```
|
|
312
|
+
*
|
|
313
|
+
* @typeParam T item data type.
|
|
314
|
+
*/
|
|
315
|
+
interface MkDropEvent<T = unknown> {
|
|
316
|
+
/** Index of the item within `previousContainer`'s data before the drop. */
|
|
317
|
+
previousIndex: number;
|
|
318
|
+
/** Index the item should occupy within `container`'s data after the drop. */
|
|
319
|
+
currentIndex: number;
|
|
320
|
+
/** The `MkDrag` directive instance that was moved. */
|
|
321
|
+
item: MkDrag<T>;
|
|
322
|
+
/** The list the item came from. */
|
|
323
|
+
previousContainer: MkDropList<T>;
|
|
324
|
+
/** The list the item was dropped into (same as `previousContainer` for a re-sort). */
|
|
325
|
+
container: MkDropList<T>;
|
|
326
|
+
/** `true` for pointer (mouse/touch/pen) drops, `false` for keyboard drops. */
|
|
327
|
+
isPointerEvent: boolean;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Pure array helpers for applying an {@link MkDropEvent}. They mutate the passed
|
|
332
|
+
* array(s) in place and also return the (target) array, mirroring the behaviour
|
|
333
|
+
* of Angular CDK's `moveItemInArray` / `transferArrayItem`.
|
|
334
|
+
*/
|
|
335
|
+
/**
|
|
336
|
+
* Move an item within a single array from `fromIndex` to `toIndex`.
|
|
337
|
+
* Mutates and returns `array`.
|
|
338
|
+
*
|
|
339
|
+
* ```ts
|
|
340
|
+
* mkMoveItemInArray(rows, e.previousIndex, e.currentIndex);
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
declare function mkMoveItemInArray<T>(array: T[], fromIndex: number, toIndex: number): T[];
|
|
344
|
+
/**
|
|
345
|
+
* Move an item from one array (`from`) to another (`to`), removing it from
|
|
346
|
+
* `from[fromIndex]` and inserting it at `to[toIndex]`. Mutates both arrays and
|
|
347
|
+
* returns the target (`to`) array.
|
|
348
|
+
*
|
|
349
|
+
* ```ts
|
|
350
|
+
* mkTransferArrayItem(todo, done, e.previousIndex, e.currentIndex);
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
declare function mkTransferArrayItem<T>(from: T[], to: T[], fromIndex: number, toIndex: number): T[];
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Central registry of every live `[mkDropList]` on the page, keyed by id.
|
|
357
|
+
*
|
|
358
|
+
* Connected lists (kanban "buckets") use it to resolve the sibling lists named
|
|
359
|
+
* in `mkDropListConnectedTo`, and both pointer and keyboard dragging use it to
|
|
360
|
+
* find the group of lists an item may travel between.
|
|
361
|
+
*
|
|
362
|
+
* Registration is automatic — you never call this service directly; it is
|
|
363
|
+
* documented so tooling/tests can inspect the wiring.
|
|
364
|
+
*/
|
|
365
|
+
declare class MkDragDropRegistry {
|
|
366
|
+
private readonly lists;
|
|
367
|
+
/** Register (or replace) the list published under `id`. */
|
|
368
|
+
register(id: string, list: MkDropList<any>): void;
|
|
369
|
+
/** Remove `list` from the registry if it is still the holder of `id`. */
|
|
370
|
+
unregister(id: string, list: MkDropList<any>): void;
|
|
371
|
+
/** Look up a list by its `mkDropListId`. */
|
|
372
|
+
get(id: string): MkDropList<any> | undefined;
|
|
373
|
+
/** All registered lists, in registration order. */
|
|
374
|
+
all(): MkDropList<any>[];
|
|
375
|
+
/**
|
|
376
|
+
* The ordered travel group for `list`: `list` itself plus every enabled list
|
|
377
|
+
* it is `mkDropListConnectedTo`, in registration (roughly DOM) order. Used to
|
|
378
|
+
* resolve "adjacent" lists for keyboard column-to-column movement and to
|
|
379
|
+
* hit-test the pointer against candidate targets.
|
|
380
|
+
*/
|
|
381
|
+
connectedGroup(list: MkDropList<any>): MkDropList<any>[];
|
|
382
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MkDragDropRegistry, never>;
|
|
383
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<MkDragDropRegistry>;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Thin convenience wrapper over a single `[mkDropList]` for the common
|
|
388
|
+
* "reorderable list" case. Bind `items` two-way and provide an `<ng-template>`
|
|
389
|
+
* to render each row; drops are applied to the model for you (via
|
|
390
|
+
* {@link mkMoveItemInArray}).
|
|
391
|
+
*
|
|
392
|
+
* For connected buckets / kanban, use `[mkDropList]` + `[mkDrag]` directly.
|
|
393
|
+
*
|
|
394
|
+
* ```html
|
|
395
|
+
* <mk-sortable-list [(items)]="rows">
|
|
396
|
+
* <ng-template let-row let-i="index">
|
|
397
|
+
* <span mkDragHandle aria-hidden="true">⠿</span> {{ i + 1 }}. {{ row.name }}
|
|
398
|
+
* </ng-template>
|
|
399
|
+
* </mk-sortable-list>
|
|
400
|
+
* ```
|
|
401
|
+
*
|
|
402
|
+
* @typeParam T item data type.
|
|
403
|
+
*/
|
|
404
|
+
declare class MkSortableList<T = unknown> {
|
|
405
|
+
/** The ordered items (two-way). Reordered in place on drop. */
|
|
406
|
+
readonly items: _angular_core.ModelSignal<T[]>;
|
|
407
|
+
/** Layout axis of the list. */
|
|
408
|
+
readonly orientation: _angular_core.InputSignal<MkDropListOrientation>;
|
|
409
|
+
/** Disable reordering. */
|
|
410
|
+
readonly disabled: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
411
|
+
/** `@for` tracking function. Defaults to identity (track by item). */
|
|
412
|
+
readonly trackBy: _angular_core.InputSignal<(index: number, item: T) => unknown>;
|
|
413
|
+
/** Emitted after the model has been reordered. */
|
|
414
|
+
readonly sorted: _angular_core.OutputEmitterRef<MkDropEvent<T>>;
|
|
415
|
+
/** The row template projected as `<ng-template>`. */
|
|
416
|
+
protected readonly itemTemplate: _angular_core.Signal<TemplateRef<any>>;
|
|
417
|
+
protected onDrop(event: MkDropEvent<T>): void;
|
|
418
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MkSortableList<any>, never>;
|
|
419
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<MkSortableList<any>, "mk-sortable-list", never, { "items": { "alias": "items"; "required": false; "isSignal": true; }; "orientation": { "alias": "orientation"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "trackBy": { "alias": "trackBy"; "required": false; "isSignal": true; }; }, { "items": "itemsChange"; "sorted": "sorted"; }, ["itemTemplate"], never, true, never>;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export { MkDrag, MkDragDropRegistry, MkDragHandle, MkDropList, MkSortableList, mkMoveItemInArray, mkTransferArrayItem };
|
|
423
|
+
export type { MkDropEvent, MkDropListOrientation };
|