@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/.build-manifest.json
CHANGED
package/README.md
CHANGED
|
@@ -179,6 +179,39 @@ import "@telperion/elements/details-set";
|
|
|
179
179
|
|
|
180
180
|
---
|
|
181
181
|
|
|
182
|
+
### Drag & Drop
|
|
183
|
+
|
|
184
|
+
Declarative drag and drop on top of the native HTML Drag and Drop API. The dragged element itself follows the pointer (no browser ghost image) and animates into its drop target, or back home.
|
|
185
|
+
|
|
186
|
+
**Includes:**
|
|
187
|
+
- `<tp-drag>` — a draggable element
|
|
188
|
+
- `<tp-drag-handle>` — restricts where its `<tp-drag>` can be grabbed
|
|
189
|
+
- `<tp-dropzone>` — a drop target
|
|
190
|
+
|
|
191
|
+
**Features:**
|
|
192
|
+
- Style the drag with plain CSS: `[dragging]`, `[dragend]`, `[dropaccepted]` on the element; `[acceptabledrag]`, `[itemdragged]` on drop zones
|
|
193
|
+
- `accept="task, bug"` filters drop zones by the dragged element's `name`
|
|
194
|
+
- `event.acceptDrop(rect)` animates the element into a target rectangle; move it in the DOM on `tp-dropzone-drop-end`
|
|
195
|
+
- `data-drag-*` attributes travel with the drag as `event.dragData`
|
|
196
|
+
- `replaceclone` leaves a placeholder in place while the element is away
|
|
197
|
+
- Typed, bubbling `DragDropEvent`s for every step of the drag
|
|
198
|
+
|
|
199
|
+
#### JS/TS
|
|
200
|
+
```ts
|
|
201
|
+
import "@telperion/elements/drag-drop";
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
#### HTML
|
|
205
|
+
```html
|
|
206
|
+
<tp-drag name="task" data-drag-id="42" replaceclone>Write the docs</tp-drag>
|
|
207
|
+
|
|
208
|
+
<tp-dropzone name="done" accept="task">Done</tp-dropzone>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
[Drag & Drop Documentation →](./src/drag-drop/README.md)
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
182
215
|
### Popover
|
|
183
216
|
|
|
184
217
|
Framework-agnostic popover element built on the native [Popover API](https://developer.mozilla.org/docs/Web/API/Popover_API) and [CSS Anchor Positioning](https://developer.mozilla.org/docs/Web/CSS/CSS_anchor_positioning). Placement is **pure CSS** — JavaScript only parses attributes, resolves the anchor, and (optionally) wires triggers.
|
package/custom-elements.json
CHANGED
|
@@ -3371,13 +3371,115 @@
|
|
|
3371
3371
|
}
|
|
3372
3372
|
]
|
|
3373
3373
|
},
|
|
3374
|
+
{
|
|
3375
|
+
"kind": "javascript-module",
|
|
3376
|
+
"path": "src/drag-drop/drag-drop-event.ts",
|
|
3377
|
+
"declarations": [
|
|
3378
|
+
{
|
|
3379
|
+
"kind": "class",
|
|
3380
|
+
"description": "The event type of every `tp-drag-*` / `tp-dropzone-*` event. It extends `DragEvent`\r\n(pointer coordinates, modifier keys, … come from the native event it wraps)\r\nand bubbles like the native drag events do.",
|
|
3381
|
+
"name": "DragDropEvent",
|
|
3382
|
+
"members": [
|
|
3383
|
+
{
|
|
3384
|
+
"kind": "field",
|
|
3385
|
+
"name": "#DragElementEvents",
|
|
3386
|
+
"privacy": "private",
|
|
3387
|
+
"type": {
|
|
3388
|
+
"text": "DragElementEventTypes[]"
|
|
3389
|
+
},
|
|
3390
|
+
"static": true,
|
|
3391
|
+
"default": "['tp-drag-move', 'tp-drag-start', 'tp-drag-end', 'tp-drag-zone-enter', 'tp-drag-zone-leave', 'tp-drag-zone-over', 'tp-drag-drop']"
|
|
3392
|
+
},
|
|
3393
|
+
{
|
|
3394
|
+
"kind": "field",
|
|
3395
|
+
"name": "#DropElementEvents",
|
|
3396
|
+
"privacy": "private",
|
|
3397
|
+
"type": {
|
|
3398
|
+
"text": "DropElementEventTypes[]"
|
|
3399
|
+
},
|
|
3400
|
+
"static": true,
|
|
3401
|
+
"default": "['tp-dropzone-drop', 'tp-dropzone-drop-end', 'tp-dropzone-enter', 'tp-dropzone-leave', 'tp-dropzone-over']"
|
|
3402
|
+
},
|
|
3403
|
+
{
|
|
3404
|
+
"kind": "field",
|
|
3405
|
+
"name": "dragTarget",
|
|
3406
|
+
"type": {
|
|
3407
|
+
"text": "WeakRef<DragElement>"
|
|
3408
|
+
},
|
|
3409
|
+
"readonly": true,
|
|
3410
|
+
"description": "The `<tp-drag>` being dragged.",
|
|
3411
|
+
"default": "dragTarget"
|
|
3412
|
+
},
|
|
3413
|
+
{
|
|
3414
|
+
"kind": "field",
|
|
3415
|
+
"name": "dropzoneTarget",
|
|
3416
|
+
"type": {
|
|
3417
|
+
"text": "WeakRef<DropZoneElement> | undefined"
|
|
3418
|
+
},
|
|
3419
|
+
"readonly": true,
|
|
3420
|
+
"description": "The `<tp-dropzone>` involved; `undefined` for `tp-drag-start` / `tp-drag-end`.",
|
|
3421
|
+
"default": "dropzoneTarget"
|
|
3422
|
+
},
|
|
3423
|
+
{
|
|
3424
|
+
"kind": "field",
|
|
3425
|
+
"name": "#target",
|
|
3426
|
+
"privacy": "private",
|
|
3427
|
+
"readonly": true
|
|
3428
|
+
},
|
|
3429
|
+
{
|
|
3430
|
+
"kind": "field",
|
|
3431
|
+
"name": "name",
|
|
3432
|
+
"type": {
|
|
3433
|
+
"text": "string | undefined"
|
|
3434
|
+
},
|
|
3435
|
+
"description": "The `name` of the element the event is dispatched on: the drop zone's name for\r\ndrop zone events, the dragged element's name for drag element events.\r\nUse `dragTarget.deref()?.name` for the dragged element's name in drop zone listeners.",
|
|
3436
|
+
"readonly": true
|
|
3437
|
+
},
|
|
3438
|
+
{
|
|
3439
|
+
"kind": "field",
|
|
3440
|
+
"name": "dragData",
|
|
3441
|
+
"description": "The dragged element's `data-drag-*` values (see `DragElement.dragData`).",
|
|
3442
|
+
"readonly": true
|
|
3443
|
+
},
|
|
3444
|
+
{
|
|
3445
|
+
"kind": "method",
|
|
3446
|
+
"name": "acceptDrop",
|
|
3447
|
+
"parameters": [
|
|
3448
|
+
{
|
|
3449
|
+
"name": "rect",
|
|
3450
|
+
"optional": true,
|
|
3451
|
+
"type": {
|
|
3452
|
+
"text": "DOMRect"
|
|
3453
|
+
}
|
|
3454
|
+
}
|
|
3455
|
+
],
|
|
3456
|
+
"description": "Accepts the drop on `dropzoneTarget`. Call it in a `tp-dropzone-drop` listener.\r\nThe dragged element then animates into `rect` (viewport coordinates, e.g. from\r\n`getBoundingClientRect()`), or back to where it started without one, and\r\n`tp-dropzone-drop-end` fires on the drop zone when the animation is over."
|
|
3457
|
+
}
|
|
3458
|
+
],
|
|
3459
|
+
"superclass": {
|
|
3460
|
+
"name": "DragEvent",
|
|
3461
|
+
"module": "src/drag-drop/drag-drop-event.ts"
|
|
3462
|
+
}
|
|
3463
|
+
}
|
|
3464
|
+
],
|
|
3465
|
+
"exports": [
|
|
3466
|
+
{
|
|
3467
|
+
"kind": "js",
|
|
3468
|
+
"name": "DragDropEvent",
|
|
3469
|
+
"declaration": {
|
|
3470
|
+
"name": "DragDropEvent",
|
|
3471
|
+
"module": "src/drag-drop/drag-drop-event.ts"
|
|
3472
|
+
}
|
|
3473
|
+
}
|
|
3474
|
+
]
|
|
3475
|
+
},
|
|
3374
3476
|
{
|
|
3375
3477
|
"kind": "javascript-module",
|
|
3376
3478
|
"path": "src/drag-drop/drag-element.ts",
|
|
3377
3479
|
"declarations": [
|
|
3378
3480
|
{
|
|
3379
3481
|
"kind": "class",
|
|
3380
|
-
"description": "
|
|
3482
|
+
"description": "Makes its content draggable. While dragged, the element itself follows the\npointer (`position: fixed`, driven by CSS custom properties) instead of the\nbrowser's translucent drag image. On release it animates back to where it\ncame from, or into the rectangle a `<tp-dropzone>` accepted it into.\n\nGive it a `name` so drop zones can filter it with `accept`, and carry data\nwith `data-drag-*` attributes (read back from `event.dragData`).\n\nCustom elements are `display: inline` by default: give `tp-drag` (and\n`tp-drag-clone`, when using `replaceclone`) a `display` of your choice.\n\n#### Examples\n\n```html\n<tp-drag name=\"card\" data-drag-id=\"42\" replaceclone>Drag me</tp-drag>\n\n<tp-dropzone accept=\"card\">Drop here</tp-dropzone>\n```",
|
|
3381
3483
|
"name": "DragElement",
|
|
3382
3484
|
"members": [
|
|
3383
3485
|
{
|
|
@@ -3416,7 +3518,7 @@
|
|
|
3416
3518
|
},
|
|
3417
3519
|
"readonly": true,
|
|
3418
3520
|
"default": "{}",
|
|
3419
|
-
"description": "
|
|
3521
|
+
"description": "Values of the element's `data-drag-*` attributes, keyed without the prefix\r\n(`data-drag-id=\"42\"` → `{ id: \"42\" }`). Kept in sync with attribute changes."
|
|
3420
3522
|
},
|
|
3421
3523
|
{
|
|
3422
3524
|
"kind": "field",
|
|
@@ -3477,8 +3579,8 @@
|
|
|
3477
3579
|
"text": "'move' | 'copyMove'"
|
|
3478
3580
|
},
|
|
3479
3581
|
"default": "'move'",
|
|
3480
|
-
"description": "The
|
|
3481
|
-
"attribute": "
|
|
3582
|
+
"description": "The `dataTransfer.effectAllowed` of the drag. Both values animate the same way;\r\nthe element itself always moves (nothing is copied).",
|
|
3583
|
+
"attribute": "draggingstrategy",
|
|
3482
3584
|
"reflects": true
|
|
3483
3585
|
},
|
|
3484
3586
|
{
|
|
@@ -3488,7 +3590,7 @@
|
|
|
3488
3590
|
"text": "string"
|
|
3489
3591
|
},
|
|
3490
3592
|
"description": "The group name for the drag element.\r\nThis is used to group elements together for drag-and-drop operations.\r\nElements with the same group name can interact with each other during drag-and-drop.\r\n\r\n!!! Not implemented yet !!!",
|
|
3491
|
-
"attribute": "
|
|
3593
|
+
"attribute": "draggroup"
|
|
3492
3594
|
},
|
|
3493
3595
|
{
|
|
3494
3596
|
"kind": "field",
|
|
@@ -3496,8 +3598,8 @@
|
|
|
3496
3598
|
"type": {
|
|
3497
3599
|
"text": "boolean"
|
|
3498
3600
|
},
|
|
3499
|
-
"description": "
|
|
3500
|
-
"attribute": "
|
|
3601
|
+
"description": "Leaves a `<tp-drag-clone>` placeholder in the element's place while it is dragged,\r\nso surrounding content doesn't reflow. The placeholder copies the element's attributes\r\n(except `dragging`, `replaceclone` and `draggable`) and child nodes; style it with the\r\n`tp-drag-clone` selector. It is removed when the drag ends.",
|
|
3602
|
+
"attribute": "replaceclone"
|
|
3501
3603
|
},
|
|
3502
3604
|
{
|
|
3503
3605
|
"kind": "field",
|
|
@@ -3529,7 +3631,7 @@
|
|
|
3529
3631
|
},
|
|
3530
3632
|
"default": "null",
|
|
3531
3633
|
"description": "The ID of the drop zone the element is currently over.",
|
|
3532
|
-
"attribute": "
|
|
3634
|
+
"attribute": "draggedover",
|
|
3533
3635
|
"reflects": true
|
|
3534
3636
|
},
|
|
3535
3637
|
{
|
|
@@ -3540,7 +3642,7 @@
|
|
|
3540
3642
|
},
|
|
3541
3643
|
"default": "false",
|
|
3542
3644
|
"description": "Indicates whether the element has been accepted by a drop zone.\r\nThis is used to manage the state of the element during drag-and-drop operations.",
|
|
3543
|
-
"attribute": "
|
|
3645
|
+
"attribute": "dropaccepted",
|
|
3544
3646
|
"reflects": true
|
|
3545
3647
|
},
|
|
3546
3648
|
{
|
|
@@ -3657,7 +3759,7 @@
|
|
|
3657
3759
|
"description": "Handles the drop zone enter event.\r\nThis updates the draggedOver property to indicate which drop zone the element is currently over.",
|
|
3658
3760
|
"parameters": [
|
|
3659
3761
|
{
|
|
3660
|
-
"description": "The
|
|
3762
|
+
"description": "The DragDropEvent for the drop zone enter.",
|
|
3661
3763
|
"name": "event"
|
|
3662
3764
|
}
|
|
3663
3765
|
]
|
|
@@ -3669,7 +3771,7 @@
|
|
|
3669
3771
|
"description": "Handles the drop zone leave event.\r\nThis clears the draggedOver property when the element leaves a drop zone.",
|
|
3670
3772
|
"parameters": [
|
|
3671
3773
|
{
|
|
3672
|
-
"description": "The
|
|
3774
|
+
"description": "The DragDropEvent for the drop zone leave.",
|
|
3673
3775
|
"name": "event"
|
|
3674
3776
|
}
|
|
3675
3777
|
]
|
|
@@ -3752,16 +3854,16 @@
|
|
|
3752
3854
|
"fieldName": "name"
|
|
3753
3855
|
},
|
|
3754
3856
|
{
|
|
3755
|
-
"name": "
|
|
3857
|
+
"name": "draggingstrategy",
|
|
3756
3858
|
"type": {
|
|
3757
3859
|
"text": "'move' | 'copyMove'"
|
|
3758
3860
|
},
|
|
3759
3861
|
"default": "'move'",
|
|
3760
|
-
"description": "The
|
|
3862
|
+
"description": "The `dataTransfer.effectAllowed` of the drag. Both values animate the same way;\r\nthe element itself always moves (nothing is copied).",
|
|
3761
3863
|
"fieldName": "draggingStrategy"
|
|
3762
3864
|
},
|
|
3763
3865
|
{
|
|
3764
|
-
"name": "
|
|
3866
|
+
"name": "draggroup",
|
|
3765
3867
|
"type": {
|
|
3766
3868
|
"text": "string"
|
|
3767
3869
|
},
|
|
@@ -3769,11 +3871,11 @@
|
|
|
3769
3871
|
"fieldName": "dragGroup"
|
|
3770
3872
|
},
|
|
3771
3873
|
{
|
|
3772
|
-
"name": "
|
|
3874
|
+
"name": "replaceclone",
|
|
3773
3875
|
"type": {
|
|
3774
3876
|
"text": "boolean"
|
|
3775
3877
|
},
|
|
3776
|
-
"description": "
|
|
3878
|
+
"description": "Leaves a `<tp-drag-clone>` placeholder in the element's place while it is dragged,\r\nso surrounding content doesn't reflow. The placeholder copies the element's attributes\r\n(except `dragging`, `replaceclone` and `draggable`) and child nodes; style it with the\r\n`tp-drag-clone` selector. It is removed when the drag ends.",
|
|
3777
3879
|
"fieldName": "replaceClone"
|
|
3778
3880
|
},
|
|
3779
3881
|
{
|
|
@@ -3795,7 +3897,7 @@
|
|
|
3795
3897
|
"fieldName": "dragend"
|
|
3796
3898
|
},
|
|
3797
3899
|
{
|
|
3798
|
-
"name": "
|
|
3900
|
+
"name": "draggedover",
|
|
3799
3901
|
"type": {
|
|
3800
3902
|
"text": "string | null"
|
|
3801
3903
|
},
|
|
@@ -3804,7 +3906,7 @@
|
|
|
3804
3906
|
"fieldName": "draggedOver"
|
|
3805
3907
|
},
|
|
3806
3908
|
{
|
|
3807
|
-
"name": "
|
|
3909
|
+
"name": "dropaccepted",
|
|
3808
3910
|
"type": {
|
|
3809
3911
|
"text": "boolean"
|
|
3810
3912
|
},
|
|
@@ -3825,8 +3927,44 @@
|
|
|
3825
3927
|
"name": "LitElement",
|
|
3826
3928
|
"package": "lit"
|
|
3827
3929
|
},
|
|
3828
|
-
"tagName": "
|
|
3829
|
-
"customElement": true
|
|
3930
|
+
"tagName": "tp-drag",
|
|
3931
|
+
"customElement": true,
|
|
3932
|
+
"events": [
|
|
3933
|
+
{
|
|
3934
|
+
"name": "tp-drag-start",
|
|
3935
|
+
"description": "Dragging started (the element is already `[dragging]`)."
|
|
3936
|
+
},
|
|
3937
|
+
{
|
|
3938
|
+
"name": "tp-drag-end",
|
|
3939
|
+
"description": "Dragging finished, after the release animation."
|
|
3940
|
+
},
|
|
3941
|
+
{
|
|
3942
|
+
"name": "tp-drag-zone-enter",
|
|
3943
|
+
"description": "The pointer entered an accepting drop zone."
|
|
3944
|
+
},
|
|
3945
|
+
{
|
|
3946
|
+
"name": "tp-drag-zone-leave",
|
|
3947
|
+
"description": "The pointer left an accepting drop zone."
|
|
3948
|
+
},
|
|
3949
|
+
{
|
|
3950
|
+
"name": "tp-drag-zone-over",
|
|
3951
|
+
"description": "The pointer moves over an accepting drop zone (fires continuously)."
|
|
3952
|
+
},
|
|
3953
|
+
{
|
|
3954
|
+
"name": "tp-drag-drop",
|
|
3955
|
+
"description": "The element was dropped on an accepting drop zone."
|
|
3956
|
+
}
|
|
3957
|
+
],
|
|
3958
|
+
"cssProperties": [
|
|
3959
|
+
{
|
|
3960
|
+
"name": "--tp-drag-offset-x",
|
|
3961
|
+
"description": "Horizontal offset of the dragged element from the pointer. Defaults to `0px`."
|
|
3962
|
+
},
|
|
3963
|
+
{
|
|
3964
|
+
"name": "--tp-drag-offset-y",
|
|
3965
|
+
"description": "Vertical offset of the dragged element from the pointer. Defaults to `0px`."
|
|
3966
|
+
}
|
|
3967
|
+
]
|
|
3830
3968
|
}
|
|
3831
3969
|
],
|
|
3832
3970
|
"exports": [
|
|
@@ -3840,7 +3978,7 @@
|
|
|
3840
3978
|
},
|
|
3841
3979
|
{
|
|
3842
3980
|
"kind": "custom-element-definition",
|
|
3843
|
-
"name": "
|
|
3981
|
+
"name": "tp-drag",
|
|
3844
3982
|
"declaration": {
|
|
3845
3983
|
"name": "DragElement",
|
|
3846
3984
|
"module": "src/drag-drop/drag-element.ts"
|
|
@@ -3854,7 +3992,7 @@
|
|
|
3854
3992
|
"declarations": [
|
|
3855
3993
|
{
|
|
3856
3994
|
"kind": "class",
|
|
3857
|
-
"description": "",
|
|
3995
|
+
"description": "Restricts where a `<tp-drag>` can be grabbed. Once a `<tp-drag>` has at\nleast one handle among its descendants, dragging only starts from one of\nthem. A handle belongs to its nearest `<tp-drag>` ancestor.\n\n#### Examples\n\n```html\n<tp-drag>\n <tp-drag-handle>⠿</tp-drag-handle>\n Only the dots start a drag; this text can be selected.\n</tp-drag>\n```",
|
|
3858
3996
|
"name": "DragHandleElement",
|
|
3859
3997
|
"members": [
|
|
3860
3998
|
{
|
|
@@ -3871,7 +4009,7 @@
|
|
|
3871
4009
|
"name": "LitElement",
|
|
3872
4010
|
"package": "lit"
|
|
3873
4011
|
},
|
|
3874
|
-
"tagName": "
|
|
4012
|
+
"tagName": "tp-drag-handle",
|
|
3875
4013
|
"customElement": true
|
|
3876
4014
|
}
|
|
3877
4015
|
],
|
|
@@ -3886,7 +4024,7 @@
|
|
|
3886
4024
|
},
|
|
3887
4025
|
{
|
|
3888
4026
|
"kind": "custom-element-definition",
|
|
3889
|
-
"name": "
|
|
4027
|
+
"name": "tp-drag-handle",
|
|
3890
4028
|
"declaration": {
|
|
3891
4029
|
"name": "DragHandleElement",
|
|
3892
4030
|
"module": "src/drag-drop/drag-handle-element.ts"
|
|
@@ -3900,7 +4038,7 @@
|
|
|
3900
4038
|
"declarations": [
|
|
3901
4039
|
{
|
|
3902
4040
|
"kind": "class",
|
|
3903
|
-
"description": "",
|
|
4041
|
+
"description": "A drop target for `<tp-drag>` elements. It reports drags over it with\nevents and reflected attributes; it does not move anything by itself.\n\nTo accept a drop, call `event.acceptDrop(rect?)` in a `tp-dropzone-drop` listener:\nthe dragged element then animates into `rect` (or back to its origin\nwithout one). Move the element in the DOM in the `tp-dropzone-drop-end` listener,\nwhich fires once that animation is over.\n\n#### Examples\n\n```html\n<tp-dropzone name=\"done\" accept=\"task, bug\">Done</tp-dropzone>\n\n<script>\n const zone = document.querySelector('tp-dropzone');\n\n zone.addEventListener('tp-dropzone-drop', event => event.acceptDrop(zone.getBoundingClientRect()));\n zone.addEventListener('tp-dropzone-drop-end', event => zone.append(event.dragTarget.deref()));\n</script>\n```",
|
|
3904
4042
|
"name": "DropZoneElement",
|
|
3905
4043
|
"members": [
|
|
3906
4044
|
{
|
|
@@ -3919,6 +4057,7 @@
|
|
|
3919
4057
|
"text": "string[]"
|
|
3920
4058
|
},
|
|
3921
4059
|
"default": "[]",
|
|
4060
|
+
"description": "`<tp-drag>` names this zone reacts to (`accept=\"task, bug\"`). Empty: every name.",
|
|
3922
4061
|
"attribute": "accept"
|
|
3923
4062
|
},
|
|
3924
4063
|
{
|
|
@@ -3928,6 +4067,7 @@
|
|
|
3928
4067
|
"text": "string"
|
|
3929
4068
|
},
|
|
3930
4069
|
"default": "''",
|
|
4070
|
+
"description": "Identifies the zone; reflected on the dragged element as `draggedover`.",
|
|
3931
4071
|
"attribute": "name"
|
|
3932
4072
|
},
|
|
3933
4073
|
{
|
|
@@ -3937,7 +4077,8 @@
|
|
|
3937
4077
|
"text": "string | null"
|
|
3938
4078
|
},
|
|
3939
4079
|
"default": "null",
|
|
3940
|
-
"
|
|
4080
|
+
"description": "The `name` of the accepted element currently over the zone, or `null`.",
|
|
4081
|
+
"attribute": "itemdragged",
|
|
3941
4082
|
"reflects": true
|
|
3942
4083
|
},
|
|
3943
4084
|
{
|
|
@@ -3947,7 +4088,8 @@
|
|
|
3947
4088
|
"text": "boolean"
|
|
3948
4089
|
},
|
|
3949
4090
|
"default": "false",
|
|
3950
|
-
"
|
|
4091
|
+
"description": "Whether a drag this zone accepts is in progress anywhere on the page.",
|
|
4092
|
+
"attribute": "acceptabledrag",
|
|
3951
4093
|
"reflects": true
|
|
3952
4094
|
},
|
|
3953
4095
|
{
|
|
@@ -4020,8 +4162,28 @@
|
|
|
4020
4162
|
{
|
|
4021
4163
|
"name": "eventName",
|
|
4022
4164
|
"type": {
|
|
4023
|
-
"text": "
|
|
4165
|
+
"text": "DragDropEvent"
|
|
4024
4166
|
}
|
|
4167
|
+
},
|
|
4168
|
+
{
|
|
4169
|
+
"name": "tp-dropzone-enter",
|
|
4170
|
+
"description": "An accepted element entered the zone."
|
|
4171
|
+
},
|
|
4172
|
+
{
|
|
4173
|
+
"name": "tp-dropzone-leave",
|
|
4174
|
+
"description": "An accepted element left the zone."
|
|
4175
|
+
},
|
|
4176
|
+
{
|
|
4177
|
+
"name": "tp-dropzone-over",
|
|
4178
|
+
"description": "An accepted element moves over the zone (fires continuously)."
|
|
4179
|
+
},
|
|
4180
|
+
{
|
|
4181
|
+
"name": "tp-dropzone-drop",
|
|
4182
|
+
"description": "An accepted element was released over the zone. Call `event.acceptDrop(rect?)` here."
|
|
4183
|
+
},
|
|
4184
|
+
{
|
|
4185
|
+
"name": "tp-dropzone-drop-end",
|
|
4186
|
+
"description": "The drop accepted by this zone finished animating. Move the element in the DOM here."
|
|
4025
4187
|
}
|
|
4026
4188
|
],
|
|
4027
4189
|
"attributes": [
|
|
@@ -4031,6 +4193,7 @@
|
|
|
4031
4193
|
"text": "string[]"
|
|
4032
4194
|
},
|
|
4033
4195
|
"default": "[]",
|
|
4196
|
+
"description": "`<tp-drag>` names this zone reacts to (`accept=\"task, bug\"`). Empty: every name.",
|
|
4034
4197
|
"fieldName": "accept"
|
|
4035
4198
|
},
|
|
4036
4199
|
{
|
|
@@ -4039,22 +4202,25 @@
|
|
|
4039
4202
|
"text": "string"
|
|
4040
4203
|
},
|
|
4041
4204
|
"default": "''",
|
|
4205
|
+
"description": "Identifies the zone; reflected on the dragged element as `draggedover`.",
|
|
4042
4206
|
"fieldName": "name"
|
|
4043
4207
|
},
|
|
4044
4208
|
{
|
|
4045
|
-
"name": "
|
|
4209
|
+
"name": "itemdragged",
|
|
4046
4210
|
"type": {
|
|
4047
4211
|
"text": "string | null"
|
|
4048
4212
|
},
|
|
4049
4213
|
"default": "null",
|
|
4214
|
+
"description": "The `name` of the accepted element currently over the zone, or `null`.",
|
|
4050
4215
|
"fieldName": "itemDragged"
|
|
4051
4216
|
},
|
|
4052
4217
|
{
|
|
4053
|
-
"name": "
|
|
4218
|
+
"name": "acceptabledrag",
|
|
4054
4219
|
"type": {
|
|
4055
4220
|
"text": "boolean"
|
|
4056
4221
|
},
|
|
4057
4222
|
"default": "false",
|
|
4223
|
+
"description": "Whether a drag this zone accepts is in progress anywhere on the page.",
|
|
4058
4224
|
"fieldName": "acceptableDrag"
|
|
4059
4225
|
}
|
|
4060
4226
|
],
|
|
@@ -4062,7 +4228,7 @@
|
|
|
4062
4228
|
"name": "LitElement",
|
|
4063
4229
|
"package": "lit"
|
|
4064
4230
|
},
|
|
4065
|
-
"tagName": "
|
|
4231
|
+
"tagName": "tp-dropzone",
|
|
4066
4232
|
"customElement": true
|
|
4067
4233
|
}
|
|
4068
4234
|
],
|
|
@@ -4077,7 +4243,7 @@
|
|
|
4077
4243
|
},
|
|
4078
4244
|
{
|
|
4079
4245
|
"kind": "custom-element-definition",
|
|
4080
|
-
"name": "
|
|
4246
|
+
"name": "tp-dropzone",
|
|
4081
4247
|
"declaration": {
|
|
4082
4248
|
"name": "DropZoneElement",
|
|
4083
4249
|
"module": "src/drag-drop/dropzone-element.ts"
|
|
@@ -4129,103 +4295,6 @@
|
|
|
4129
4295
|
}
|
|
4130
4296
|
]
|
|
4131
4297
|
},
|
|
4132
|
-
{
|
|
4133
|
-
"kind": "javascript-module",
|
|
4134
|
-
"path": "src/drag-drop/tha-drag-event.ts",
|
|
4135
|
-
"declarations": [
|
|
4136
|
-
{
|
|
4137
|
-
"kind": "class",
|
|
4138
|
-
"description": "",
|
|
4139
|
-
"name": "ThaDragEvent",
|
|
4140
|
-
"members": [
|
|
4141
|
-
{
|
|
4142
|
-
"kind": "field",
|
|
4143
|
-
"name": "#DragElementEvents",
|
|
4144
|
-
"privacy": "private",
|
|
4145
|
-
"type": {
|
|
4146
|
-
"text": "DragElementEventTypes[]"
|
|
4147
|
-
},
|
|
4148
|
-
"static": true,
|
|
4149
|
-
"default": "['thadrag', 'thadragstart', 'thadragend', 'thadropzoneenter', 'thadropzoneleave', 'thadropzoneover', 'thadropped']"
|
|
4150
|
-
},
|
|
4151
|
-
{
|
|
4152
|
-
"kind": "field",
|
|
4153
|
-
"name": "#DropElementEvents",
|
|
4154
|
-
"privacy": "private",
|
|
4155
|
-
"type": {
|
|
4156
|
-
"text": "DropElementEventTypes[]"
|
|
4157
|
-
},
|
|
4158
|
-
"static": true,
|
|
4159
|
-
"default": "['thadrop', 'thadropend', 'thadragenter', 'thadragleave', 'thadragover']"
|
|
4160
|
-
},
|
|
4161
|
-
{
|
|
4162
|
-
"kind": "field",
|
|
4163
|
-
"name": "dragTarget",
|
|
4164
|
-
"type": {
|
|
4165
|
-
"text": "WeakRef<DragElement>"
|
|
4166
|
-
},
|
|
4167
|
-
"readonly": true,
|
|
4168
|
-
"default": "dragTarget"
|
|
4169
|
-
},
|
|
4170
|
-
{
|
|
4171
|
-
"kind": "field",
|
|
4172
|
-
"name": "dropzoneTarget",
|
|
4173
|
-
"type": {
|
|
4174
|
-
"text": "WeakRef<DropZoneElement> | undefined"
|
|
4175
|
-
},
|
|
4176
|
-
"readonly": true,
|
|
4177
|
-
"default": "dropzoneTarget"
|
|
4178
|
-
},
|
|
4179
|
-
{
|
|
4180
|
-
"kind": "field",
|
|
4181
|
-
"name": "#target",
|
|
4182
|
-
"privacy": "private",
|
|
4183
|
-
"readonly": true
|
|
4184
|
-
},
|
|
4185
|
-
{
|
|
4186
|
-
"kind": "field",
|
|
4187
|
-
"name": "name",
|
|
4188
|
-
"type": {
|
|
4189
|
-
"text": "string | undefined"
|
|
4190
|
-
},
|
|
4191
|
-
"readonly": true
|
|
4192
|
-
},
|
|
4193
|
-
{
|
|
4194
|
-
"kind": "field",
|
|
4195
|
-
"name": "dragData",
|
|
4196
|
-
"readonly": true
|
|
4197
|
-
},
|
|
4198
|
-
{
|
|
4199
|
-
"kind": "method",
|
|
4200
|
-
"name": "acceptDrop",
|
|
4201
|
-
"parameters": [
|
|
4202
|
-
{
|
|
4203
|
-
"name": "rect",
|
|
4204
|
-
"optional": true,
|
|
4205
|
-
"type": {
|
|
4206
|
-
"text": "DOMRect"
|
|
4207
|
-
}
|
|
4208
|
-
}
|
|
4209
|
-
]
|
|
4210
|
-
}
|
|
4211
|
-
],
|
|
4212
|
-
"superclass": {
|
|
4213
|
-
"name": "DragEvent",
|
|
4214
|
-
"module": "src/drag-drop/tha-drag-event.ts"
|
|
4215
|
-
}
|
|
4216
|
-
}
|
|
4217
|
-
],
|
|
4218
|
-
"exports": [
|
|
4219
|
-
{
|
|
4220
|
-
"kind": "js",
|
|
4221
|
-
"name": "ThaDragEvent",
|
|
4222
|
-
"declaration": {
|
|
4223
|
-
"name": "ThaDragEvent",
|
|
4224
|
-
"module": "src/drag-drop/tha-drag-event.ts"
|
|
4225
|
-
}
|
|
4226
|
-
}
|
|
4227
|
-
]
|
|
4228
|
-
},
|
|
4229
4298
|
{
|
|
4230
4299
|
"kind": "javascript-module",
|
|
4231
4300
|
"path": "src/icon/icon-element.ts",
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var privateProps = require('./private-props.cjs');
|
|
4
|
+
|
|
5
|
+
var _a;
|
|
6
|
+
/**
|
|
7
|
+
* The event type of every `tp-drag-*` / `tp-dropzone-*` event. It extends `DragEvent`
|
|
8
|
+
* (pointer coordinates, modifier keys, … come from the native event it wraps)
|
|
9
|
+
* and bubbles like the native drag events do.
|
|
10
|
+
*/
|
|
11
|
+
class DragDropEvent extends DragEvent {
|
|
12
|
+
static #DragElementEvents = ['tp-drag-move', 'tp-drag-start', 'tp-drag-end', 'tp-drag-zone-enter', 'tp-drag-zone-leave', 'tp-drag-zone-over', 'tp-drag-drop'];
|
|
13
|
+
static #DropElementEvents = ['tp-dropzone-drop', 'tp-dropzone-drop-end', 'tp-dropzone-enter', 'tp-dropzone-leave', 'tp-dropzone-over'];
|
|
14
|
+
get #target() {
|
|
15
|
+
if (_a.#DropElementEvents.includes(this.type)) {
|
|
16
|
+
return this.dropzoneTarget;
|
|
17
|
+
}
|
|
18
|
+
else if (_a.#DragElementEvents.includes(this.type)) {
|
|
19
|
+
return this.dragTarget;
|
|
20
|
+
}
|
|
21
|
+
return new WeakRef(this.target);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The `name` of the element the event is dispatched on: the drop zone's name for
|
|
25
|
+
* drop zone events, the dragged element's name for drag element events.
|
|
26
|
+
* Use `dragTarget.deref()?.name` for the dragged element's name in drop zone listeners.
|
|
27
|
+
*/
|
|
28
|
+
get name() {
|
|
29
|
+
return this.#target.deref()?.name;
|
|
30
|
+
}
|
|
31
|
+
/** The dragged element's `data-drag-*` values (see `DragElement.dragData`). */
|
|
32
|
+
get dragData() {
|
|
33
|
+
return this.dragTarget.deref()?.dragData;
|
|
34
|
+
}
|
|
35
|
+
constructor(type, { dragTarget, dropzoneTarget }, eventInitDict) {
|
|
36
|
+
super(type, eventInitDict);
|
|
37
|
+
this.dragTarget = dragTarget;
|
|
38
|
+
this.dropzoneTarget = dropzoneTarget;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Accepts the drop on `dropzoneTarget`. Call it in a `tp-dropzone-drop` listener.
|
|
42
|
+
* The dragged element then animates into `rect` (viewport coordinates, e.g. from
|
|
43
|
+
* `getBoundingClientRect()`), or back to where it started without one, and
|
|
44
|
+
* `tp-dropzone-drop-end` fires on the drop zone when the animation is over.
|
|
45
|
+
*/
|
|
46
|
+
acceptDrop(rect) {
|
|
47
|
+
this.dragTarget.deref()?.[privateProps.ACCEPT_DROP_PROP](this.dropzoneTarget, rect);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
_a = DragDropEvent;
|
|
51
|
+
|
|
52
|
+
exports.DragDropEvent = DragDropEvent;
|
|
53
|
+
//# sourceMappingURL=drag-drop-event.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drag-drop-event.cjs","sources":["../../../../libs/elements/src/drag-drop/drag-drop-event.ts"],"sourcesContent":[null],"names":["ACCEPT_DROP_PROP"],"mappings":";;;;;AAeA;;;;AAIG;AACG,MAAO,aAAc,SAAQ,SAAS,CAAA;AAC1C,IAAA,OAAO,kBAAkB,GAA4B,CAAC,cAAc,EAAE,eAAe,EAAE,aAAa,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,cAAc,CAAC;AACtL,IAAA,OAAO,kBAAkB,GAA4B,CAAC,kBAAkB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,kBAAkB,CAAC;AAO/J,IAAA,IAAI,OAAO,GAAA;QACT,IAAI,EAAa,CAAC,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAA6B,CAAC,EAAE;YACjF,OAAO,IAAI,CAAC,cAAe;QAC7B;aAAO,IAAI,EAAa,CAAC,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAA6B,CAAC,EAAE;YACxF,OAAO,IAAI,CAAC,UAAU;QACxB;AAEA,QAAA,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,MAAyC,CAAC;IACpE;AAEA;;;;AAIG;AACH,IAAA,IAAI,IAAI,GAAA;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,IAAI;IACnC;;AAGA,IAAA,IAAI,QAAQ,GAAA;QACV,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,QAAQ;IAC1C;IAEA,WAAA,CACE,IAAwB,EACxB,EAAE,UAAU,EAAE,cAAc,EAAqB,EACjD,aAA6B,EAAA;AAE7B,QAAA,KAAK,CAAC,IAAI,EAAE,aAAa,CAAC;AAE1B,QAAA,IAAI,CAAC,UAAU,GAAG,UAAU;AAC5B,QAAA,IAAI,CAAC,cAAc,GAAG,cAAc;IACtC;AAEA;;;;;AAKG;AACH,IAAA,UAAU,CAAC,IAAc,EAAA;AACvB,QAAA,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,GAAGA,6BAAgB,CAAC,CAAC,IAAI,CAAC,cAAe,EAAE,IAAI,CAAC;IACzE;;;;;;"}
|