@telperion/elements 8.0.0 → 8.1.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/.build-manifest.json +1 -1
- package/README.md +33 -0
- package/custom-elements.json +198 -129
- package/drag-drop/drag-drop-event.cjs +53 -0
- package/drag-drop/drag-drop-event.cjs.map +1 -0
- package/drag-drop/drag-drop-event.js +51 -0
- package/drag-drop/drag-drop-event.js.map +1 -0
- package/drag-drop/drag-element.cjs +44 -43
- package/drag-drop/drag-element.cjs.map +1 -1
- package/drag-drop/drag-element.js +44 -43
- package/drag-drop/drag-element.js.map +1 -1
- package/drag-drop/drag-handle-element.cjs +1 -1
- package/drag-drop/drag-handle-element.cjs.map +1 -1
- package/drag-drop/drag-handle-element.js +1 -1
- package/drag-drop/drag-handle-element.js.map +1 -1
- package/drag-drop/dropzone-element.cjs +21 -17
- package/drag-drop/dropzone-element.cjs.map +1 -1
- package/drag-drop/dropzone-element.js +21 -17
- package/drag-drop/dropzone-element.js.map +1 -1
- package/drag-drop/index.cjs +2 -2
- package/drag-drop/index.d.cts +136 -33
- package/drag-drop/index.d.ts +136 -33
- package/drag-drop/index.js +1 -1
- package/fesm/elements.mjs +86 -64
- package/fesm/elements.mjs.map +1 -1
- package/iife/drag-drop/index.js +20 -20
- package/iife/drag-drop/index.js.map +1 -1
- package/iife/elements.js +34 -34
- package/iife/elements.js.map +1 -1
- package/index.cjs +2 -2
- package/index.d.cts +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/drag-drop/tha-drag-event.cjs +0 -36
- package/drag-drop/tha-drag-event.cjs.map +0 -1
- package/drag-drop/tha-drag-event.js +0 -34
- package/drag-drop/tha-drag-event.js.map +0 -1
package/drag-drop/index.d.ts
CHANGED
|
@@ -2,15 +2,51 @@ import { LitElement, CSSResultGroup, TemplateResult } from 'lit';
|
|
|
2
2
|
|
|
3
3
|
declare global {
|
|
4
4
|
interface HTMLElementTagNameMap {
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* A drop target for `<tp-drag>` elements. It reports drags over it with
|
|
7
|
+
* events and reflected attributes; it does not move anything by itself.
|
|
8
|
+
*
|
|
9
|
+
* To accept a drop, call `event.acceptDrop(rect?)` in a `tp-dropzone-drop` listener:
|
|
10
|
+
* the dragged element then animates into `rect` (or back to its origin
|
|
11
|
+
* without one). Move the element in the DOM in the `tp-dropzone-drop-end` listener,
|
|
12
|
+
* which fires once that animation is over.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```html
|
|
16
|
+
* <tp-dropzone name="done" accept="task, bug">Done</tp-dropzone>
|
|
17
|
+
*
|
|
18
|
+
* <script>
|
|
19
|
+
* const zone = document.querySelector('tp-dropzone');
|
|
20
|
+
*
|
|
21
|
+
* zone.addEventListener('tp-dropzone-drop', event => event.acceptDrop(zone.getBoundingClientRect()));
|
|
22
|
+
* zone.addEventListener('tp-dropzone-drop-end', event => zone.append(event.dragTarget.deref()));
|
|
23
|
+
* </script>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @attr {string} name - Identifies the zone; reflected on the dragged element as `draggedover`.
|
|
27
|
+
* @attr {string} accept - Comma-separated `<tp-drag>` names this zone reacts to. Empty or missing: every name.
|
|
28
|
+
* @attr {boolean} acceptabledrag - Read-only. Set while a drag this zone accepts is in progress anywhere on the page.
|
|
29
|
+
* @attr {string} itemdragged - Read-only. The `name` of the accepted element currently over the zone.
|
|
30
|
+
*
|
|
31
|
+
* @fires tp-dropzone-enter - An accepted element entered the zone.
|
|
32
|
+
* @fires tp-dropzone-leave - An accepted element left the zone.
|
|
33
|
+
* @fires tp-dropzone-over - An accepted element moves over the zone (fires continuously).
|
|
34
|
+
* @fires tp-dropzone-drop - An accepted element was released over the zone. Call `event.acceptDrop(rect?)` here.
|
|
35
|
+
* @fires tp-dropzone-drop-end - The drop accepted by this zone finished animating. Move the element in the DOM here.
|
|
36
|
+
*/
|
|
37
|
+
"tp-dropzone": DropZoneElement;
|
|
6
38
|
}
|
|
7
39
|
}
|
|
8
40
|
declare class DropZoneElement extends LitElement {
|
|
9
41
|
#private;
|
|
10
42
|
static styles?: CSSResultGroup;
|
|
43
|
+
/** `<tp-drag>` names this zone reacts to (`accept="task, bug"`). Empty: every name. */
|
|
11
44
|
accept: string[];
|
|
45
|
+
/** Identifies the zone; reflected on the dragged element as `draggedover`. */
|
|
12
46
|
name: string;
|
|
47
|
+
/** The `name` of the accepted element currently over the zone, or `null`. */
|
|
13
48
|
itemDragged: string | null;
|
|
49
|
+
/** Whether a drag this zone accepts is in progress anywhere on the page. */
|
|
14
50
|
acceptableDrag: boolean;
|
|
15
51
|
protected render(): TemplateResult;
|
|
16
52
|
connectedCallback(): void;
|
|
@@ -23,7 +59,20 @@ declare const UNREGISTER_HANDLE_PROP: unique symbol;
|
|
|
23
59
|
|
|
24
60
|
declare global {
|
|
25
61
|
interface HTMLElementTagNameMap {
|
|
26
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Restricts where a `<tp-drag>` can be grabbed. Once a `<tp-drag>` has at
|
|
64
|
+
* least one handle among its descendants, dragging only starts from one of
|
|
65
|
+
* them. A handle belongs to its nearest `<tp-drag>` ancestor.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```html
|
|
69
|
+
* <tp-drag>
|
|
70
|
+
* <tp-drag-handle>⠿</tp-drag-handle>
|
|
71
|
+
* Only the dots start a drag; this text can be selected.
|
|
72
|
+
* </tp-drag>
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
"tp-drag-handle": DragHandleElement;
|
|
27
76
|
}
|
|
28
77
|
}
|
|
29
78
|
declare class DragHandleElement extends LitElement {
|
|
@@ -36,14 +85,44 @@ declare class DragHandleElement extends LitElement {
|
|
|
36
85
|
declare global {
|
|
37
86
|
interface HTMLElementTagNameMap {
|
|
38
87
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* the
|
|
43
|
-
* The `draggingstrategy` attribute defines the drag behavior, such as 'move' or 'copyMove'.
|
|
88
|
+
* Makes its content draggable. While dragged, the element itself follows the
|
|
89
|
+
* pointer (`position: fixed`, driven by CSS custom properties) instead of the
|
|
90
|
+
* browser's translucent drag image. On release it animates back to where it
|
|
91
|
+
* came from, or into the rectangle a `<tp-dropzone>` accepted it into.
|
|
44
92
|
*
|
|
93
|
+
* Give it a `name` so drop zones can filter it with `accept`, and carry data
|
|
94
|
+
* with `data-drag-*` attributes (read back from `event.dragData`).
|
|
95
|
+
*
|
|
96
|
+
* Custom elements are `display: inline` by default: give `tp-drag` (and
|
|
97
|
+
* `tp-drag-clone`, when using `replaceclone`) a `display` of your choice.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```html
|
|
101
|
+
* <tp-drag name="card" data-drag-id="42" replaceclone>Drag me</tp-drag>
|
|
102
|
+
*
|
|
103
|
+
* <tp-dropzone accept="card">Drop here</tp-dropzone>
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @attr {string} name - Identifies the element to drop zones; matched against their `accept` list.
|
|
107
|
+
* @attr {"move" | "copyMove"} [draggingstrategy=move] - Sets `dataTransfer.effectAllowed`. Both values animate the same way.
|
|
108
|
+
* @attr {boolean} replaceclone - Leaves a `<tp-drag-clone>` copy in place while dragging, so the layout doesn't collapse.
|
|
109
|
+
* @attr {boolean} disabled - Prevents dragging.
|
|
110
|
+
* @attr {boolean} dragging - Read-only. Set while the element is being dragged.
|
|
111
|
+
* @attr {boolean} dragend - Read-only. Set during the release animation.
|
|
112
|
+
* @attr {string} draggedover - Read-only. The `name` of the accepting drop zone under the pointer (empty if it has none).
|
|
113
|
+
* @attr {boolean} dropaccepted - Read-only. Set once a drop zone called `acceptDrop()`, until the release animation ends.
|
|
114
|
+
*
|
|
115
|
+
* @fires tp-drag-start - Dragging started (the element is already `[dragging]`).
|
|
116
|
+
* @fires tp-drag-end - Dragging finished, after the release animation.
|
|
117
|
+
* @fires tp-drag-zone-enter - The pointer entered an accepting drop zone.
|
|
118
|
+
* @fires tp-drag-zone-leave - The pointer left an accepting drop zone.
|
|
119
|
+
* @fires tp-drag-zone-over - The pointer moves over an accepting drop zone (fires continuously).
|
|
120
|
+
* @fires tp-drag-drop - The element was dropped on an accepting drop zone.
|
|
121
|
+
*
|
|
122
|
+
* @cssprop --tp-drag-offset-x - Horizontal offset of the dragged element from the pointer. Defaults to `0px`.
|
|
123
|
+
* @cssprop --tp-drag-offset-y - Vertical offset of the dragged element from the pointer. Defaults to `0px`.
|
|
45
124
|
*/
|
|
46
|
-
"
|
|
125
|
+
"tp-drag": DragElement;
|
|
47
126
|
}
|
|
48
127
|
}
|
|
49
128
|
declare class DragElement extends LitElement {
|
|
@@ -64,7 +143,8 @@ declare class DragElement extends LitElement {
|
|
|
64
143
|
private static DRAG_DATA_OBSERVER;
|
|
65
144
|
static styles: CSSResultGroup;
|
|
66
145
|
/**
|
|
67
|
-
*
|
|
146
|
+
* Values of the element's `data-drag-*` attributes, keyed without the prefix
|
|
147
|
+
* (`data-drag-id="42"` → `{ id: "42" }`). Kept in sync with attribute changes.
|
|
68
148
|
*/
|
|
69
149
|
readonly dragData: Record<string, string>;
|
|
70
150
|
/**
|
|
@@ -88,8 +168,8 @@ declare class DragElement extends LitElement {
|
|
|
88
168
|
*/
|
|
89
169
|
name: string;
|
|
90
170
|
/**
|
|
91
|
-
* The
|
|
92
|
-
*
|
|
171
|
+
* The `dataTransfer.effectAllowed` of the drag. Both values animate the same way;
|
|
172
|
+
* the element itself always moves (nothing is copied).
|
|
93
173
|
*/
|
|
94
174
|
draggingStrategy: 'move' | 'copyMove';
|
|
95
175
|
/**
|
|
@@ -101,8 +181,10 @@ declare class DragElement extends LitElement {
|
|
|
101
181
|
*/
|
|
102
182
|
dragGroup: string;
|
|
103
183
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
184
|
+
* Leaves a `<tp-drag-clone>` placeholder in the element's place while it is dragged,
|
|
185
|
+
* so surrounding content doesn't reflow. The placeholder copies the element's attributes
|
|
186
|
+
* (except `dragging`, `replaceclone` and `draggable`) and child nodes; style it with the
|
|
187
|
+
* `tp-drag-clone` selector. It is removed when the drag ends.
|
|
106
188
|
*/
|
|
107
189
|
replaceClone: boolean;
|
|
108
190
|
/**
|
|
@@ -150,39 +232,60 @@ declare class DragElement extends LitElement {
|
|
|
150
232
|
[UNREGISTER_HANDLE_PROP](handle: DragHandleElement): void;
|
|
151
233
|
}
|
|
152
234
|
|
|
153
|
-
|
|
154
|
-
type
|
|
155
|
-
|
|
156
|
-
|
|
235
|
+
/** Events dispatched on the `<tp-drag>` element */
|
|
236
|
+
type DragElementEventTypes = 'tp-drag-move' | 'tp-drag-start' | 'tp-drag-end' | 'tp-drag-zone-enter' | 'tp-drag-zone-leave' | 'tp-drag-zone-over' | 'tp-drag-drop';
|
|
237
|
+
/** Events dispatched on the `<tp-dropzone>` element */
|
|
238
|
+
type DropElementEventTypes = 'tp-dropzone-drop' | 'tp-dropzone-drop-end' | 'tp-dropzone-enter' | 'tp-dropzone-leave' | 'tp-dropzone-over';
|
|
239
|
+
type DragDropEventTypes = DragElementEventTypes | DropElementEventTypes;
|
|
240
|
+
interface DragDropEventDict {
|
|
157
241
|
dragTarget: WeakRef<DragElement>;
|
|
158
242
|
dropzoneTarget?: WeakRef<DropZoneElement>;
|
|
159
243
|
}
|
|
160
|
-
|
|
244
|
+
/**
|
|
245
|
+
* The event type of every `tp-drag-*` / `tp-dropzone-*` event. It extends `DragEvent`
|
|
246
|
+
* (pointer coordinates, modifier keys, … come from the native event it wraps)
|
|
247
|
+
* and bubbles like the native drag events do.
|
|
248
|
+
*/
|
|
249
|
+
declare class DragDropEvent extends DragEvent {
|
|
161
250
|
#private;
|
|
251
|
+
/** The `<tp-drag>` being dragged. */
|
|
162
252
|
readonly dragTarget: WeakRef<DragElement>;
|
|
253
|
+
/** The `<tp-dropzone>` involved; `undefined` for `tp-drag-start` / `tp-drag-end`. */
|
|
163
254
|
readonly dropzoneTarget?: WeakRef<DropZoneElement>;
|
|
255
|
+
/**
|
|
256
|
+
* The `name` of the element the event is dispatched on: the drop zone's name for
|
|
257
|
+
* drop zone events, the dragged element's name for drag element events.
|
|
258
|
+
* Use `dragTarget.deref()?.name` for the dragged element's name in drop zone listeners.
|
|
259
|
+
*/
|
|
164
260
|
get name(): string | undefined;
|
|
261
|
+
/** The dragged element's `data-drag-*` values (see `DragElement.dragData`). */
|
|
165
262
|
get dragData(): Record<string, string> | undefined;
|
|
166
|
-
constructor(type:
|
|
263
|
+
constructor(type: DragDropEventTypes, { dragTarget, dropzoneTarget }: DragDropEventDict, eventInitDict?: DragEventInit);
|
|
264
|
+
/**
|
|
265
|
+
* Accepts the drop on `dropzoneTarget`. Call it in a `tp-dropzone-drop` listener.
|
|
266
|
+
* The dragged element then animates into `rect` (viewport coordinates, e.g. from
|
|
267
|
+
* `getBoundingClientRect()`), or back to where it started without one, and
|
|
268
|
+
* `tp-dropzone-drop-end` fires on the drop zone when the animation is over.
|
|
269
|
+
*/
|
|
167
270
|
acceptDrop(rect?: DOMRect): void;
|
|
168
271
|
}
|
|
169
272
|
|
|
170
273
|
declare global {
|
|
171
274
|
interface GlobalEventHandlersEventMap {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
275
|
+
'tp-drag-move': DragDropEvent;
|
|
276
|
+
'tp-drag-start': DragDropEvent;
|
|
277
|
+
'tp-drag-end': DragDropEvent;
|
|
278
|
+
'tp-dropzone-drop': DragDropEvent;
|
|
279
|
+
'tp-dropzone-drop-end': DragDropEvent;
|
|
280
|
+
'tp-drag-drop': DragDropEvent;
|
|
281
|
+
'tp-dropzone-enter': DragDropEvent;
|
|
282
|
+
'tp-dropzone-leave': DragDropEvent;
|
|
283
|
+
'tp-dropzone-over': DragDropEvent;
|
|
284
|
+
'tp-drag-zone-enter': DragDropEvent;
|
|
285
|
+
'tp-drag-zone-leave': DragDropEvent;
|
|
286
|
+
'tp-drag-zone-over': DragDropEvent;
|
|
184
287
|
}
|
|
185
288
|
}
|
|
186
289
|
|
|
187
|
-
export { DragElement, DragHandleElement, DropZoneElement
|
|
188
|
-
export type { DragElementEventTypes, DropElementEventTypes
|
|
290
|
+
export { DragDropEvent, DragElement, DragHandleElement, DropZoneElement };
|
|
291
|
+
export type { DragDropEventTypes, DragElementEventTypes, DropElementEventTypes };
|
package/drag-drop/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { DragElement } from './drag-element.js';
|
|
2
2
|
export { DropZoneElement } from './dropzone-element.js';
|
|
3
3
|
export { DragHandleElement } from './drag-handle-element.js';
|
|
4
|
-
export {
|
|
4
|
+
export { DragDropEvent } from './drag-drop-event.js';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|