@lit-material/sortable 0.0.0-stage → 0.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/LICENSE +21 -0
- package/README.md +59 -2
- package/custom-elements.json +453 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/sortable.d.ts +85 -0
- package/dist/sortable.d.ts.map +1 -0
- package/dist/sortable.js +364 -0
- package/dist/sortable.js.map +1 -0
- package/package.json +62 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 bohdaq
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,60 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @lit-material/sortable
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Lets people reorder a list by dragging a handle (mouse, pen or touch) or from the keyboard, within a list or between lists, with each step announced to screen readers. Built with [Lit](https://lit.dev/). Part of [lit-material](https://github.com/bohdaq/lit-material).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @lit-material/sortable @lit-material/tokens
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import "@lit-material/sortable";
|
|
15
|
+
|
|
16
|
+
html`<lit-material-sortable label="Requests" @sort=${(e) => {
|
|
17
|
+
const { from, to } = e.detail;
|
|
18
|
+
const [moved] = requests.splice(from, 1);
|
|
19
|
+
requests.splice(to, 0, moved);
|
|
20
|
+
this.requestUpdate();
|
|
21
|
+
}}>
|
|
22
|
+
${repeat(requests, (r) => r.id, (r) => html`
|
|
23
|
+
<div data-sort-id=${r.id}>
|
|
24
|
+
<button data-sort-handle aria-label=${`Reorder ${r.name}`}>⋮⋮</button>${r.name}
|
|
25
|
+
</div>`)}
|
|
26
|
+
</lit-material-sortable>`;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
It never moves elements itself: it shows a drop line and fires `sort`; your code reorders its data
|
|
30
|
+
and re-renders. That keeps it safe with Lit, React or any renderer that owns its DOM. Key repeated
|
|
31
|
+
items (`repeat`, React `key`) so the moved element keeps keyboard focus.
|
|
32
|
+
|
|
33
|
+
## API
|
|
34
|
+
|
|
35
|
+
| Property | Attribute | Type | Default |
|
|
36
|
+
| ---------- | ---------- | --------- | ------- |
|
|
37
|
+
| `group` | `group` | `string` | `""` (this list only) |
|
|
38
|
+
| `label` | `label` | `string` | `""` (names the list in announcements) |
|
|
39
|
+
| `disabled` | `disabled` (reflected) | `boolean` | `false` |
|
|
40
|
+
|
|
41
|
+
Event `sort`: `detail: { item, id, from, to, fromList, toList }` — `to` is the item's index in
|
|
42
|
+
`toList` after the move. Between lists it fires on the list the item left; check
|
|
43
|
+
`toList !== fromList`. Item attributes: `data-sort-id`, `data-sort-label` (announcement name,
|
|
44
|
+
default the text), `data-sort-handle` on the handle (default: the item). While dragged an item has
|
|
45
|
+
`data-sort-dragging`, while picked up from the keyboard `data-sort-grabbed`.
|
|
46
|
+
`--lit-material-sortable-indicator-color` colours the drop line.
|
|
47
|
+
|
|
48
|
+
## Behavior
|
|
49
|
+
|
|
50
|
+
- Pointer: press a handle and move 4px to start; the drop line follows; release drops, Escape
|
|
51
|
+
cancels. Handles get `touch-action: none` so touch drags don't scroll.
|
|
52
|
+
- Keyboard: focus a handle, Space or Enter picks the item up, ↑/↓ (or Home/End) move it — each move
|
|
53
|
+
fires `sort` — Space drops, Escape puts it back where it started. Moving focus away drops it.
|
|
54
|
+
- Handles get `aria-description="Press Space to reorder"` unless they have one; pick-up, moves and
|
|
55
|
+
drops are announced from a live region.
|
|
56
|
+
- Lists that share a `group` accept each other's items by pointer.
|
|
57
|
+
|
|
58
|
+
## License
|
|
59
|
+
|
|
60
|
+
MIT
|
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"readme": "",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "src/index.ts",
|
|
8
|
+
"declarations": [],
|
|
9
|
+
"exports": [
|
|
10
|
+
{
|
|
11
|
+
"kind": "js",
|
|
12
|
+
"name": "LitMaterialSortable",
|
|
13
|
+
"declaration": {
|
|
14
|
+
"name": "LitMaterialSortable",
|
|
15
|
+
"module": "./sortable.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"kind": "js",
|
|
20
|
+
"name": "SortDetail",
|
|
21
|
+
"declaration": {
|
|
22
|
+
"name": "SortDetail",
|
|
23
|
+
"module": "./sortable.js"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"kind": "javascript-module",
|
|
30
|
+
"path": "src/sortable.ts",
|
|
31
|
+
"declarations": [
|
|
32
|
+
{
|
|
33
|
+
"kind": "class",
|
|
34
|
+
"description": "Lets people reorder a list: by dragging a handle with a mouse, pen or\nfinger, or from the keyboard — focus a handle, Space (or Enter) picks the\nitem up, ↑/↓ move it, Space drops it and Escape puts it back. Each step is\nannounced to screen readers.\n\nEvery element child is an item. An item's handle is its\n`[data-sort-handle]` descendant (a button, ideally), or the item itself.\nGive items a `data-sort-id` and, when their text isn't a good name, a\n`data-sort-label` for the announcements.\n\nIt never moves elements itself: it shows where the item would land and\nfires `sort` with `{ from, to }`, and your code reorders its data and\nre-renders — so it works with Lit, React or plain DOM, which each own\ntheir own nodes. Lists that share a `group` accept each other's items by\npointer; `sort` then fires on the list the item left, with `toList` set.",
|
|
35
|
+
"name": "LitMaterialSortable",
|
|
36
|
+
"cssProperties": [
|
|
37
|
+
{
|
|
38
|
+
"description": "The drop line (default `--md-sys-color-primary`).",
|
|
39
|
+
"name": "--lit-material-sortable-indicator-color"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"slots": [
|
|
43
|
+
{
|
|
44
|
+
"description": "The items.",
|
|
45
|
+
"name": ""
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"members": [
|
|
49
|
+
{
|
|
50
|
+
"kind": "field",
|
|
51
|
+
"name": "group",
|
|
52
|
+
"type": {
|
|
53
|
+
"text": "string"
|
|
54
|
+
},
|
|
55
|
+
"default": "\"\"",
|
|
56
|
+
"description": "Lists with the same group accept each other's items. Empty: this list only.",
|
|
57
|
+
"attribute": "group",
|
|
58
|
+
"reflects": true
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"kind": "field",
|
|
62
|
+
"name": "label",
|
|
63
|
+
"type": {
|
|
64
|
+
"text": "string"
|
|
65
|
+
},
|
|
66
|
+
"default": "\"\"",
|
|
67
|
+
"description": "Names the list in announcements, e.g. \"Requests\".",
|
|
68
|
+
"attribute": "label"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"kind": "field",
|
|
72
|
+
"name": "disabled",
|
|
73
|
+
"type": {
|
|
74
|
+
"text": "boolean"
|
|
75
|
+
},
|
|
76
|
+
"default": "false",
|
|
77
|
+
"attribute": "disabled",
|
|
78
|
+
"reflects": true
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"kind": "field",
|
|
82
|
+
"name": "dropIndex",
|
|
83
|
+
"type": {
|
|
84
|
+
"text": "number | null"
|
|
85
|
+
},
|
|
86
|
+
"privacy": "private",
|
|
87
|
+
"default": "null",
|
|
88
|
+
"description": "Where a dragged item would land (index among the other items), or `null`."
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"kind": "field",
|
|
92
|
+
"name": "announcement",
|
|
93
|
+
"type": {
|
|
94
|
+
"text": "string"
|
|
95
|
+
},
|
|
96
|
+
"privacy": "private",
|
|
97
|
+
"default": "\"\""
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"kind": "field",
|
|
101
|
+
"name": "drag",
|
|
102
|
+
"type": {
|
|
103
|
+
"text": "{\n item: HTMLElement;\n from: number;\n pointerId: number;\n startX: number;\n startY: number;\n active: boolean;\n target: LitMaterialSortable | null;\n } | undefined"
|
|
104
|
+
},
|
|
105
|
+
"privacy": "private"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"kind": "field",
|
|
109
|
+
"name": "grabbed",
|
|
110
|
+
"type": {
|
|
111
|
+
"text": "{ item: HTMLElement; origin: number; index: number; refocusing?: boolean } | undefined"
|
|
112
|
+
},
|
|
113
|
+
"privacy": "private",
|
|
114
|
+
"description": "Keyboard pick-up: the item, where it started, where it is now."
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"kind": "field",
|
|
118
|
+
"name": "items",
|
|
119
|
+
"type": {
|
|
120
|
+
"text": "HTMLElement[]"
|
|
121
|
+
},
|
|
122
|
+
"description": "The items, in order.",
|
|
123
|
+
"readonly": true
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"kind": "field",
|
|
127
|
+
"name": "onSlotChange",
|
|
128
|
+
"privacy": "private",
|
|
129
|
+
"readonly": true
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"kind": "method",
|
|
133
|
+
"name": "handleOf",
|
|
134
|
+
"privacy": "private",
|
|
135
|
+
"return": {
|
|
136
|
+
"type": {
|
|
137
|
+
"text": "HTMLElement"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"parameters": [
|
|
141
|
+
{
|
|
142
|
+
"name": "item",
|
|
143
|
+
"type": {
|
|
144
|
+
"text": "HTMLElement"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"kind": "method",
|
|
151
|
+
"name": "itemFromHandle",
|
|
152
|
+
"privacy": "private",
|
|
153
|
+
"return": {
|
|
154
|
+
"type": {
|
|
155
|
+
"text": "HTMLElement | undefined"
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"parameters": [
|
|
159
|
+
{
|
|
160
|
+
"name": "path",
|
|
161
|
+
"type": {
|
|
162
|
+
"text": "EventTarget[]"
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
],
|
|
166
|
+
"description": "The item that `node` is the handle of (or inside), if any."
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"kind": "method",
|
|
170
|
+
"name": "nameOf",
|
|
171
|
+
"privacy": "private",
|
|
172
|
+
"return": {
|
|
173
|
+
"type": {
|
|
174
|
+
"text": "string"
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"parameters": [
|
|
178
|
+
{
|
|
179
|
+
"name": "item",
|
|
180
|
+
"type": {
|
|
181
|
+
"text": "HTMLElement"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"kind": "method",
|
|
188
|
+
"name": "announce",
|
|
189
|
+
"privacy": "private",
|
|
190
|
+
"return": {
|
|
191
|
+
"type": {
|
|
192
|
+
"text": "void"
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
"parameters": [
|
|
196
|
+
{
|
|
197
|
+
"name": "message",
|
|
198
|
+
"type": {
|
|
199
|
+
"text": "string"
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
]
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"kind": "method",
|
|
206
|
+
"name": "emit",
|
|
207
|
+
"privacy": "private",
|
|
208
|
+
"return": {
|
|
209
|
+
"type": {
|
|
210
|
+
"text": "void"
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
"parameters": [
|
|
214
|
+
{
|
|
215
|
+
"name": "item",
|
|
216
|
+
"type": {
|
|
217
|
+
"text": "HTMLElement"
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"name": "from",
|
|
222
|
+
"type": {
|
|
223
|
+
"text": "number"
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"name": "to",
|
|
228
|
+
"type": {
|
|
229
|
+
"text": "number"
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"name": "toList",
|
|
234
|
+
"type": {
|
|
235
|
+
"text": "LitMaterialSortable"
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"kind": "field",
|
|
242
|
+
"name": "onPointerDown",
|
|
243
|
+
"privacy": "private",
|
|
244
|
+
"readonly": true
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"kind": "field",
|
|
248
|
+
"name": "onPointerMove",
|
|
249
|
+
"privacy": "private",
|
|
250
|
+
"readonly": true
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"kind": "field",
|
|
254
|
+
"name": "onPointerUp",
|
|
255
|
+
"privacy": "private",
|
|
256
|
+
"readonly": true
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"kind": "field",
|
|
260
|
+
"name": "onPointerCancel",
|
|
261
|
+
"privacy": "private",
|
|
262
|
+
"readonly": true
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"kind": "field",
|
|
266
|
+
"name": "onDragKeyDown",
|
|
267
|
+
"privacy": "private",
|
|
268
|
+
"readonly": true
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"kind": "method",
|
|
272
|
+
"name": "endPointerDrag",
|
|
273
|
+
"privacy": "private",
|
|
274
|
+
"return": {
|
|
275
|
+
"type": {
|
|
276
|
+
"text": "void"
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
"kind": "method",
|
|
282
|
+
"name": "listAt",
|
|
283
|
+
"privacy": "private",
|
|
284
|
+
"return": {
|
|
285
|
+
"type": {
|
|
286
|
+
"text": "LitMaterialSortable | null"
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
"parameters": [
|
|
290
|
+
{
|
|
291
|
+
"name": "x",
|
|
292
|
+
"type": {
|
|
293
|
+
"text": "number"
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
"name": "y",
|
|
298
|
+
"type": {
|
|
299
|
+
"text": "number"
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
],
|
|
303
|
+
"description": "The sortable under a point that accepts this list's items."
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"kind": "method",
|
|
307
|
+
"name": "indexAt",
|
|
308
|
+
"return": {
|
|
309
|
+
"type": {
|
|
310
|
+
"text": "number"
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
"parameters": [
|
|
314
|
+
{
|
|
315
|
+
"name": "y",
|
|
316
|
+
"type": {
|
|
317
|
+
"text": "number"
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"name": "dragged",
|
|
322
|
+
"type": {
|
|
323
|
+
"text": "HTMLElement"
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
],
|
|
327
|
+
"description": "Index among the items other than `dragged` before which `y` falls."
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
"kind": "method",
|
|
331
|
+
"name": "indicatorTop",
|
|
332
|
+
"privacy": "private",
|
|
333
|
+
"return": {
|
|
334
|
+
"type": {
|
|
335
|
+
"text": "number | null"
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
"kind": "field",
|
|
341
|
+
"name": "onKeyDown",
|
|
342
|
+
"privacy": "private",
|
|
343
|
+
"readonly": true
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
"kind": "method",
|
|
347
|
+
"name": "moveGrabbed",
|
|
348
|
+
"privacy": "private",
|
|
349
|
+
"return": {
|
|
350
|
+
"type": {
|
|
351
|
+
"text": "void"
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
"parameters": [
|
|
355
|
+
{
|
|
356
|
+
"name": "to",
|
|
357
|
+
"type": {
|
|
358
|
+
"text": "number"
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
]
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
"kind": "method",
|
|
365
|
+
"name": "drop",
|
|
366
|
+
"privacy": "private",
|
|
367
|
+
"return": {
|
|
368
|
+
"type": {
|
|
369
|
+
"text": "void"
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
"parameters": [
|
|
373
|
+
{
|
|
374
|
+
"name": "message",
|
|
375
|
+
"type": {
|
|
376
|
+
"text": "string"
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
]
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
"kind": "field",
|
|
383
|
+
"name": "onFocusOut",
|
|
384
|
+
"privacy": "private",
|
|
385
|
+
"readonly": true
|
|
386
|
+
}
|
|
387
|
+
],
|
|
388
|
+
"events": [
|
|
389
|
+
{
|
|
390
|
+
"name": "sort",
|
|
391
|
+
"type": {
|
|
392
|
+
"text": "CustomEvent"
|
|
393
|
+
},
|
|
394
|
+
"description": "When an item is dropped somewhere new; `detail` is `SortDetail`."
|
|
395
|
+
}
|
|
396
|
+
],
|
|
397
|
+
"attributes": [
|
|
398
|
+
{
|
|
399
|
+
"name": "group",
|
|
400
|
+
"type": {
|
|
401
|
+
"text": "string"
|
|
402
|
+
},
|
|
403
|
+
"default": "\"\"",
|
|
404
|
+
"description": "Lists with the same group accept each other's items. Empty: this list only.",
|
|
405
|
+
"fieldName": "group"
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
"name": "label",
|
|
409
|
+
"type": {
|
|
410
|
+
"text": "string"
|
|
411
|
+
},
|
|
412
|
+
"default": "\"\"",
|
|
413
|
+
"description": "Names the list in announcements, e.g. \"Requests\".",
|
|
414
|
+
"fieldName": "label"
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
"name": "disabled",
|
|
418
|
+
"type": {
|
|
419
|
+
"text": "boolean"
|
|
420
|
+
},
|
|
421
|
+
"default": "false",
|
|
422
|
+
"fieldName": "disabled"
|
|
423
|
+
}
|
|
424
|
+
],
|
|
425
|
+
"superclass": {
|
|
426
|
+
"name": "LitElement",
|
|
427
|
+
"package": "lit"
|
|
428
|
+
},
|
|
429
|
+
"tagName": "lit-material-sortable",
|
|
430
|
+
"customElement": true
|
|
431
|
+
}
|
|
432
|
+
],
|
|
433
|
+
"exports": [
|
|
434
|
+
{
|
|
435
|
+
"kind": "js",
|
|
436
|
+
"name": "LitMaterialSortable",
|
|
437
|
+
"declaration": {
|
|
438
|
+
"name": "LitMaterialSortable",
|
|
439
|
+
"module": "src/sortable.ts"
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
"kind": "custom-element-definition",
|
|
444
|
+
"name": "lit-material-sortable",
|
|
445
|
+
"declaration": {
|
|
446
|
+
"name": "LitMaterialSortable",
|
|
447
|
+
"module": "src/sortable.ts"
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
]
|
|
451
|
+
}
|
|
452
|
+
]
|
|
453
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAmB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
export interface SortDetail {
|
|
3
|
+
/** The moved element. */
|
|
4
|
+
item: HTMLElement;
|
|
5
|
+
/** Its `data-sort-id`, or `""`. */
|
|
6
|
+
id: string;
|
|
7
|
+
/** Index in `fromList` before the move. */
|
|
8
|
+
from: number;
|
|
9
|
+
/** Index in `toList` after the move. */
|
|
10
|
+
to: number;
|
|
11
|
+
fromList: LitMaterialSortable;
|
|
12
|
+
toList: LitMaterialSortable;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Lets people reorder a list: by dragging a handle with a mouse, pen or
|
|
16
|
+
* finger, or from the keyboard — focus a handle, Space (or Enter) picks the
|
|
17
|
+
* item up, ↑/↓ move it, Space drops it and Escape puts it back. Each step is
|
|
18
|
+
* announced to screen readers.
|
|
19
|
+
*
|
|
20
|
+
* Every element child is an item. An item's handle is its
|
|
21
|
+
* `[data-sort-handle]` descendant (a button, ideally), or the item itself.
|
|
22
|
+
* Give items a `data-sort-id` and, when their text isn't a good name, a
|
|
23
|
+
* `data-sort-label` for the announcements.
|
|
24
|
+
*
|
|
25
|
+
* It never moves elements itself: it shows where the item would land and
|
|
26
|
+
* fires `sort` with `{ from, to }`, and your code reorders its data and
|
|
27
|
+
* re-renders — so it works with Lit, React or plain DOM, which each own
|
|
28
|
+
* their own nodes. Lists that share a `group` accept each other's items by
|
|
29
|
+
* pointer; `sort` then fires on the list the item left, with `toList` set.
|
|
30
|
+
*
|
|
31
|
+
* @element lit-material-sortable
|
|
32
|
+
*
|
|
33
|
+
* @slot - The items.
|
|
34
|
+
*
|
|
35
|
+
* @fires sort - When an item is dropped somewhere new; `detail` is `SortDetail`.
|
|
36
|
+
*
|
|
37
|
+
* @cssprop --lit-material-sortable-indicator-color - The drop line (default `--md-sys-color-primary`).
|
|
38
|
+
*/
|
|
39
|
+
export declare class LitMaterialSortable extends LitElement {
|
|
40
|
+
static styles: import("lit").CSSResult;
|
|
41
|
+
/** Lists with the same group accept each other's items. Empty: this list only. */
|
|
42
|
+
group: string;
|
|
43
|
+
/** Names the list in announcements, e.g. "Requests". */
|
|
44
|
+
label: string;
|
|
45
|
+
disabled: boolean;
|
|
46
|
+
/** Where a dragged item would land (index among the other items), or `null`. */
|
|
47
|
+
private dropIndex;
|
|
48
|
+
private announcement;
|
|
49
|
+
private drag?;
|
|
50
|
+
/** Keyboard pick-up: the item, where it started, where it is now. */
|
|
51
|
+
private grabbed?;
|
|
52
|
+
/** The items, in order. */
|
|
53
|
+
get items(): HTMLElement[];
|
|
54
|
+
connectedCallback(): void;
|
|
55
|
+
disconnectedCallback(): void;
|
|
56
|
+
private readonly onSlotChange;
|
|
57
|
+
private handleOf;
|
|
58
|
+
/** The item that `node` is the handle of (or inside), if any. */
|
|
59
|
+
private itemFromHandle;
|
|
60
|
+
private nameOf;
|
|
61
|
+
private announce;
|
|
62
|
+
private emit;
|
|
63
|
+
private readonly onPointerDown;
|
|
64
|
+
private readonly onPointerMove;
|
|
65
|
+
private readonly onPointerUp;
|
|
66
|
+
private readonly onPointerCancel;
|
|
67
|
+
private readonly onDragKeyDown;
|
|
68
|
+
private endPointerDrag;
|
|
69
|
+
/** The sortable under a point that accepts this list's items. */
|
|
70
|
+
private listAt;
|
|
71
|
+
/** Index among the items other than `dragged` before which `y` falls. */
|
|
72
|
+
indexAt(y: number, dragged: HTMLElement): number;
|
|
73
|
+
private indicatorTop;
|
|
74
|
+
private readonly onKeyDown;
|
|
75
|
+
private moveGrabbed;
|
|
76
|
+
private drop;
|
|
77
|
+
private readonly onFocusOut;
|
|
78
|
+
render(): import("lit").TemplateResult<1>;
|
|
79
|
+
}
|
|
80
|
+
declare global {
|
|
81
|
+
interface HTMLElementTagNameMap {
|
|
82
|
+
"lit-material-sortable": LitMaterialSortable;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=sortable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortable.d.ts","sourceRoot":"","sources":["../src/sortable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAG5C,MAAM,WAAW,UAAU;IACzB,yBAAyB;IACzB,IAAI,EAAE,WAAW,CAAC;IAClB,mCAAmC;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,MAAM,EAAE,mBAAmB,CAAC;CAC7B;AAKD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBACa,mBAAoB,SAAQ,UAAU;IACjD,OAAgB,MAAM,0BAgCpB;IAEF,kFAAkF;IACrD,KAAK,SAAM;IAExC,wDAAwD;IAC5C,KAAK,SAAM;IAEqB,QAAQ,UAAS;IAE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arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var LitMaterialSortable_1;
|
|
8
|
+
import { css, html, LitElement } from "lit";
|
|
9
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
10
|
+
/** Pixels the pointer must travel before a press becomes a drag. */
|
|
11
|
+
const DRAG_THRESHOLD = 4;
|
|
12
|
+
/**
|
|
13
|
+
* Lets people reorder a list: by dragging a handle with a mouse, pen or
|
|
14
|
+
* finger, or from the keyboard — focus a handle, Space (or Enter) picks the
|
|
15
|
+
* item up, ↑/↓ move it, Space drops it and Escape puts it back. Each step is
|
|
16
|
+
* announced to screen readers.
|
|
17
|
+
*
|
|
18
|
+
* Every element child is an item. An item's handle is its
|
|
19
|
+
* `[data-sort-handle]` descendant (a button, ideally), or the item itself.
|
|
20
|
+
* Give items a `data-sort-id` and, when their text isn't a good name, a
|
|
21
|
+
* `data-sort-label` for the announcements.
|
|
22
|
+
*
|
|
23
|
+
* It never moves elements itself: it shows where the item would land and
|
|
24
|
+
* fires `sort` with `{ from, to }`, and your code reorders its data and
|
|
25
|
+
* re-renders — so it works with Lit, React or plain DOM, which each own
|
|
26
|
+
* their own nodes. Lists that share a `group` accept each other's items by
|
|
27
|
+
* pointer; `sort` then fires on the list the item left, with `toList` set.
|
|
28
|
+
*
|
|
29
|
+
* @element lit-material-sortable
|
|
30
|
+
*
|
|
31
|
+
* @slot - The items.
|
|
32
|
+
*
|
|
33
|
+
* @fires sort - When an item is dropped somewhere new; `detail` is `SortDetail`.
|
|
34
|
+
*
|
|
35
|
+
* @cssprop --lit-material-sortable-indicator-color - The drop line (default `--md-sys-color-primary`).
|
|
36
|
+
*/
|
|
37
|
+
let LitMaterialSortable = class LitMaterialSortable extends LitElement {
|
|
38
|
+
constructor() {
|
|
39
|
+
super(...arguments);
|
|
40
|
+
/** Lists with the same group accept each other's items. Empty: this list only. */
|
|
41
|
+
this.group = "";
|
|
42
|
+
/** Names the list in announcements, e.g. "Requests". */
|
|
43
|
+
this.label = "";
|
|
44
|
+
this.disabled = false;
|
|
45
|
+
/** Where a dragged item would land (index among the other items), or `null`. */
|
|
46
|
+
this.dropIndex = null;
|
|
47
|
+
this.announcement = "";
|
|
48
|
+
this.onSlotChange = () => {
|
|
49
|
+
for (const item of this.items) {
|
|
50
|
+
const handle = this.handleOf(item);
|
|
51
|
+
handle.style.touchAction = "none";
|
|
52
|
+
if (!handle.hasAttribute("aria-description")) {
|
|
53
|
+
handle.setAttribute("aria-description", "Press Space to reorder");
|
|
54
|
+
}
|
|
55
|
+
if (handle.tabIndex < 0 && !handle.hasAttribute("tabindex"))
|
|
56
|
+
handle.tabIndex = 0;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
// ---- Pointer ----
|
|
60
|
+
this.onPointerDown = (event) => {
|
|
61
|
+
if (this.disabled || event.button !== 0 || this.grabbed)
|
|
62
|
+
return;
|
|
63
|
+
const item = this.itemFromHandle(event.composedPath());
|
|
64
|
+
if (!item)
|
|
65
|
+
return;
|
|
66
|
+
this.drag = {
|
|
67
|
+
item,
|
|
68
|
+
from: this.items.indexOf(item),
|
|
69
|
+
pointerId: event.pointerId,
|
|
70
|
+
startX: event.clientX,
|
|
71
|
+
startY: event.clientY,
|
|
72
|
+
active: false,
|
|
73
|
+
target: null,
|
|
74
|
+
};
|
|
75
|
+
document.addEventListener("pointermove", this.onPointerMove);
|
|
76
|
+
document.addEventListener("pointerup", this.onPointerUp);
|
|
77
|
+
document.addEventListener("pointercancel", this.onPointerCancel);
|
|
78
|
+
document.addEventListener("keydown", this.onDragKeyDown, true);
|
|
79
|
+
};
|
|
80
|
+
this.onPointerMove = (event) => {
|
|
81
|
+
const drag = this.drag;
|
|
82
|
+
if (!drag || event.pointerId !== drag.pointerId)
|
|
83
|
+
return;
|
|
84
|
+
if (!drag.active) {
|
|
85
|
+
if (Math.hypot(event.clientX - drag.startX, event.clientY - drag.startY) < DRAG_THRESHOLD)
|
|
86
|
+
return;
|
|
87
|
+
drag.active = true;
|
|
88
|
+
drag.item.setAttribute("data-sort-dragging", "");
|
|
89
|
+
document.documentElement.style.setProperty("user-select", "none");
|
|
90
|
+
}
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
const target = this.listAt(event.clientX, event.clientY);
|
|
93
|
+
if (drag.target && drag.target !== target)
|
|
94
|
+
drag.target.dropIndex = null;
|
|
95
|
+
drag.target = target;
|
|
96
|
+
if (target)
|
|
97
|
+
target.dropIndex = target.indexAt(event.clientY, drag.item);
|
|
98
|
+
};
|
|
99
|
+
this.onPointerUp = (event) => {
|
|
100
|
+
const drag = this.drag;
|
|
101
|
+
if (!drag || event.pointerId !== drag.pointerId)
|
|
102
|
+
return;
|
|
103
|
+
const target = drag.target;
|
|
104
|
+
const to = target?.dropIndex ?? null;
|
|
105
|
+
this.endPointerDrag();
|
|
106
|
+
if (!drag.active || !target || to === null)
|
|
107
|
+
return;
|
|
108
|
+
if (target === this && to === drag.from)
|
|
109
|
+
return;
|
|
110
|
+
this.emit(drag.item, drag.from, to, target);
|
|
111
|
+
this.announce(`${this.nameOf(drag.item)} moved to position ${to + 1}${target === this ? "" : ` in ${target.label || "the other list"}`}`);
|
|
112
|
+
};
|
|
113
|
+
this.onPointerCancel = () => this.endPointerDrag();
|
|
114
|
+
this.onDragKeyDown = (event) => {
|
|
115
|
+
if (event.key === "Escape" && this.drag?.active) {
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
event.stopPropagation();
|
|
118
|
+
this.endPointerDrag();
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
// ---- Keyboard ----
|
|
122
|
+
this.onKeyDown = (event) => {
|
|
123
|
+
if (this.disabled || event.defaultPrevented)
|
|
124
|
+
return;
|
|
125
|
+
const item = this.itemFromHandle(event.composedPath());
|
|
126
|
+
if (!item || event.composedPath()[0] !== this.handleOf(item))
|
|
127
|
+
return;
|
|
128
|
+
const grabbed = this.grabbed;
|
|
129
|
+
const count = this.items.length;
|
|
130
|
+
if (event.key === " " || event.key === "Enter") {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
if (!grabbed) {
|
|
133
|
+
const index = this.items.indexOf(item);
|
|
134
|
+
this.grabbed = { item, origin: index, index };
|
|
135
|
+
item.setAttribute("data-sort-grabbed", "");
|
|
136
|
+
this.announce(`${this.nameOf(item)} picked up, position ${index + 1} of ${count}. ↑ and ↓ to move, Space to drop, Escape to cancel.`);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
this.drop(`${this.nameOf(item)} dropped at position ${grabbed.index + 1} of ${count}.`);
|
|
140
|
+
}
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (!grabbed)
|
|
144
|
+
return;
|
|
145
|
+
if (event.key === "Escape") {
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
event.stopPropagation();
|
|
148
|
+
if (grabbed.index !== grabbed.origin)
|
|
149
|
+
this.moveGrabbed(grabbed.origin);
|
|
150
|
+
this.drop(`${this.nameOf(item)} back at position ${grabbed.origin + 1} of ${count}.`);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const step = { ArrowUp: -1, ArrowDown: 1, ArrowLeft: -1, ArrowRight: 1 }[event.key];
|
|
154
|
+
const jump = event.key === "Home" ? 0 : event.key === "End" ? count - 1 : undefined;
|
|
155
|
+
if (step === undefined && jump === undefined)
|
|
156
|
+
return;
|
|
157
|
+
event.preventDefault();
|
|
158
|
+
const to = jump ?? Math.min(count - 1, Math.max(0, grabbed.index + step));
|
|
159
|
+
if (to === grabbed.index)
|
|
160
|
+
return;
|
|
161
|
+
this.moveGrabbed(to);
|
|
162
|
+
this.announce(`${this.nameOf(item)} moved to position ${to + 1} of ${count}.`);
|
|
163
|
+
};
|
|
164
|
+
this.onFocusOut = (event) => {
|
|
165
|
+
const grabbed = this.grabbed;
|
|
166
|
+
// A re-render moving the item blurs it for a moment (refocused after the move).
|
|
167
|
+
if (!grabbed || grabbed.refocusing)
|
|
168
|
+
return;
|
|
169
|
+
// Only a real move elsewhere drops it.
|
|
170
|
+
requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
171
|
+
if (this.grabbed !== grabbed)
|
|
172
|
+
return;
|
|
173
|
+
const active = document.activeElement;
|
|
174
|
+
if (active && this.contains(active))
|
|
175
|
+
return;
|
|
176
|
+
if (event.relatedTarget && this.contains(event.relatedTarget))
|
|
177
|
+
return;
|
|
178
|
+
this.drop(`${this.nameOf(grabbed.item)} dropped at position ${grabbed.index + 1}.`);
|
|
179
|
+
}));
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
static { LitMaterialSortable_1 = this; }
|
|
183
|
+
static { this.styles = css `
|
|
184
|
+
:host {
|
|
185
|
+
display: block;
|
|
186
|
+
position: relative;
|
|
187
|
+
}
|
|
188
|
+
:host([hidden]) {
|
|
189
|
+
display: none;
|
|
190
|
+
}
|
|
191
|
+
::slotted([data-sort-dragging]) {
|
|
192
|
+
opacity: 0.4;
|
|
193
|
+
}
|
|
194
|
+
::slotted([data-sort-grabbed]) {
|
|
195
|
+
outline: 2px solid var(--lit-material-sortable-indicator-color, var(--md-sys-color-primary, light-dark(#6750a4, #d0bcff)));
|
|
196
|
+
outline-offset: -2px;
|
|
197
|
+
}
|
|
198
|
+
.indicator {
|
|
199
|
+
position: absolute;
|
|
200
|
+
inset-inline: 0;
|
|
201
|
+
height: 2px;
|
|
202
|
+
margin-top: -1px;
|
|
203
|
+
border-radius: 1px;
|
|
204
|
+
background: var(--lit-material-sortable-indicator-color, var(--md-sys-color-primary, light-dark(#6750a4, #d0bcff)));
|
|
205
|
+
pointer-events: none;
|
|
206
|
+
}
|
|
207
|
+
.sr {
|
|
208
|
+
position: absolute;
|
|
209
|
+
width: 1px;
|
|
210
|
+
height: 1px;
|
|
211
|
+
overflow: hidden;
|
|
212
|
+
clip-path: inset(50%);
|
|
213
|
+
white-space: nowrap;
|
|
214
|
+
}
|
|
215
|
+
`; }
|
|
216
|
+
/** The items, in order. */
|
|
217
|
+
get items() {
|
|
218
|
+
return Array.from(this.children).filter((el) => el instanceof HTMLElement);
|
|
219
|
+
}
|
|
220
|
+
connectedCallback() {
|
|
221
|
+
super.connectedCallback();
|
|
222
|
+
this.addEventListener("pointerdown", this.onPointerDown);
|
|
223
|
+
this.addEventListener("keydown", this.onKeyDown);
|
|
224
|
+
this.addEventListener("focusout", this.onFocusOut);
|
|
225
|
+
}
|
|
226
|
+
disconnectedCallback() {
|
|
227
|
+
super.disconnectedCallback();
|
|
228
|
+
this.removeEventListener("pointerdown", this.onPointerDown);
|
|
229
|
+
this.removeEventListener("keydown", this.onKeyDown);
|
|
230
|
+
this.removeEventListener("focusout", this.onFocusOut);
|
|
231
|
+
this.endPointerDrag();
|
|
232
|
+
}
|
|
233
|
+
handleOf(item) {
|
|
234
|
+
return item.querySelector("[data-sort-handle]") ?? item;
|
|
235
|
+
}
|
|
236
|
+
/** The item that `node` is the handle of (or inside), if any. */
|
|
237
|
+
itemFromHandle(path) {
|
|
238
|
+
for (const item of this.items) {
|
|
239
|
+
const handle = this.handleOf(item);
|
|
240
|
+
if (path.includes(handle))
|
|
241
|
+
return item;
|
|
242
|
+
}
|
|
243
|
+
return undefined;
|
|
244
|
+
}
|
|
245
|
+
nameOf(item) {
|
|
246
|
+
return item.dataset.sortLabel || item.textContent?.trim().replace(/\s+/g, " ") || "Item";
|
|
247
|
+
}
|
|
248
|
+
announce(message) {
|
|
249
|
+
// Re-announce identical text by clearing first.
|
|
250
|
+
this.announcement = "";
|
|
251
|
+
requestAnimationFrame(() => (this.announcement = message));
|
|
252
|
+
}
|
|
253
|
+
emit(item, from, to, toList) {
|
|
254
|
+
this.dispatchEvent(new CustomEvent("sort", {
|
|
255
|
+
bubbles: true,
|
|
256
|
+
composed: true,
|
|
257
|
+
detail: { item, id: item.dataset.sortId ?? "", from, to, fromList: this, toList },
|
|
258
|
+
}));
|
|
259
|
+
}
|
|
260
|
+
endPointerDrag() {
|
|
261
|
+
const drag = this.drag;
|
|
262
|
+
if (!drag)
|
|
263
|
+
return;
|
|
264
|
+
drag.item.removeAttribute("data-sort-dragging");
|
|
265
|
+
if (drag.target)
|
|
266
|
+
drag.target.dropIndex = null;
|
|
267
|
+
this.drag = undefined;
|
|
268
|
+
document.documentElement.style.removeProperty("user-select");
|
|
269
|
+
document.removeEventListener("pointermove", this.onPointerMove);
|
|
270
|
+
document.removeEventListener("pointerup", this.onPointerUp);
|
|
271
|
+
document.removeEventListener("pointercancel", this.onPointerCancel);
|
|
272
|
+
document.removeEventListener("keydown", this.onDragKeyDown, true);
|
|
273
|
+
}
|
|
274
|
+
/** The sortable under a point that accepts this list's items. */
|
|
275
|
+
listAt(x, y) {
|
|
276
|
+
// A list inside a shadow root isn't in the document's hit list, only its host is.
|
|
277
|
+
const root = this.getRootNode();
|
|
278
|
+
const hits = root === document ? document.elementsFromPoint(x, y) : [...root.elementsFromPoint(x, y), ...document.elementsFromPoint(x, y)];
|
|
279
|
+
for (const el of hits) {
|
|
280
|
+
const list = el instanceof LitMaterialSortable_1 ? el : el.closest("lit-material-sortable");
|
|
281
|
+
if (!list || list.disabled)
|
|
282
|
+
continue;
|
|
283
|
+
if (list === this || (this.group && list.group === this.group))
|
|
284
|
+
return list;
|
|
285
|
+
}
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
/** Index among the items other than `dragged` before which `y` falls. */
|
|
289
|
+
indexAt(y, dragged) {
|
|
290
|
+
const others = this.items.filter((item) => item !== dragged);
|
|
291
|
+
const index = others.findIndex((item) => {
|
|
292
|
+
const box = item.getBoundingClientRect();
|
|
293
|
+
return y < box.top + box.height / 2;
|
|
294
|
+
});
|
|
295
|
+
return index === -1 ? others.length : index;
|
|
296
|
+
}
|
|
297
|
+
indicatorTop() {
|
|
298
|
+
if (this.dropIndex === null)
|
|
299
|
+
return null;
|
|
300
|
+
const dragged = this.drag?.item ?? document.querySelector("[data-sort-dragging]");
|
|
301
|
+
const others = this.items.filter((item) => item !== dragged);
|
|
302
|
+
const host = this.getBoundingClientRect();
|
|
303
|
+
if (others.length === 0)
|
|
304
|
+
return 0;
|
|
305
|
+
const next = others[this.dropIndex];
|
|
306
|
+
if (next)
|
|
307
|
+
return next.getBoundingClientRect().top - host.top;
|
|
308
|
+
return others[others.length - 1].getBoundingClientRect().bottom - host.top;
|
|
309
|
+
}
|
|
310
|
+
moveGrabbed(to) {
|
|
311
|
+
const grabbed = this.grabbed;
|
|
312
|
+
const { item } = grabbed;
|
|
313
|
+
const from = grabbed.index;
|
|
314
|
+
grabbed.index = to;
|
|
315
|
+
grabbed.refocusing = true;
|
|
316
|
+
this.emit(item, from, to, this);
|
|
317
|
+
// The app re-renders the list; moving a focused node drops focus, so put it back.
|
|
318
|
+
requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
319
|
+
const current = (item.isConnected && this.contains(item) ? item : undefined) ??
|
|
320
|
+
this.items.find((el) => item.dataset.sortId && el.dataset.sortId === item.dataset.sortId);
|
|
321
|
+
if (this.grabbed)
|
|
322
|
+
this.grabbed.refocusing = false;
|
|
323
|
+
if (!current || !this.grabbed)
|
|
324
|
+
return;
|
|
325
|
+
if (current !== this.grabbed.item) {
|
|
326
|
+
this.grabbed.item.removeAttribute("data-sort-grabbed");
|
|
327
|
+
this.grabbed.item = current;
|
|
328
|
+
current.setAttribute("data-sort-grabbed", "");
|
|
329
|
+
}
|
|
330
|
+
this.handleOf(current).focus();
|
|
331
|
+
}));
|
|
332
|
+
}
|
|
333
|
+
drop(message) {
|
|
334
|
+
this.grabbed?.item.removeAttribute("data-sort-grabbed");
|
|
335
|
+
this.grabbed = undefined;
|
|
336
|
+
this.announce(message);
|
|
337
|
+
}
|
|
338
|
+
render() {
|
|
339
|
+
const top = this.indicatorTop();
|
|
340
|
+
return html `<slot @slotchange=${this.onSlotChange}></slot>${top === null
|
|
341
|
+
? ""
|
|
342
|
+
: html `<div class="indicator" style="top: ${top}px"></div>`}<div class="sr" role="status" aria-live="assertive">${this.announcement}</div>`;
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
__decorate([
|
|
346
|
+
property({ reflect: true })
|
|
347
|
+
], LitMaterialSortable.prototype, "group", void 0);
|
|
348
|
+
__decorate([
|
|
349
|
+
property()
|
|
350
|
+
], LitMaterialSortable.prototype, "label", void 0);
|
|
351
|
+
__decorate([
|
|
352
|
+
property({ type: Boolean, reflect: true })
|
|
353
|
+
], LitMaterialSortable.prototype, "disabled", void 0);
|
|
354
|
+
__decorate([
|
|
355
|
+
state()
|
|
356
|
+
], LitMaterialSortable.prototype, "dropIndex", void 0);
|
|
357
|
+
__decorate([
|
|
358
|
+
state()
|
|
359
|
+
], LitMaterialSortable.prototype, "announcement", void 0);
|
|
360
|
+
LitMaterialSortable = LitMaterialSortable_1 = __decorate([
|
|
361
|
+
customElement("lit-material-sortable")
|
|
362
|
+
], LitMaterialSortable);
|
|
363
|
+
export { LitMaterialSortable };
|
|
364
|
+
//# sourceMappingURL=sortable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortable.js","sourceRoot":"","sources":["../src/sortable.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAenE,oEAAoE;AACpE,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,UAAU;IAA5C;;QA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C,OAAO,IAAI,CAAA,qBAAqB,IAAI,CAAC,YAAY,WAAW,GAAG,KAAK,IAAI;YACpE,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,IAAI,CAAA,sCAAsC,GAAG,YAAY,uDAAuD,IAAI,CAAC,YAAY,QAAQ,CAAC;IAClJ,CAAC;;AA5R4B;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDAAY;AAG5B;IAAX,QAAQ,EAAE;kDAAY;AAEqB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qDAAkB;AAG5C;IAAhB,KAAK,EAAE;sDAAyC;AAEhC;IAAhB,KAAK,EAAE;yDAA2B;AA9CxB,mBAAmB;IAD/B,aAAa,CAAC,uBAAuB,CAAC;GAC1B,mBAAmB,CAiU/B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lit-material/sortable",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Sortable list for lit-material: reorder items by pointer, touch or keyboard, within a list or between lists, with screen reader announcements.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "bohdaq",
|
|
8
|
+
"email": "bohdaq@gmail.com",
|
|
9
|
+
"url": "https://github.com/bohdaq"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/bohdaq/lit-material#readme",
|
|
12
|
+
"bugs": "https://github.com/bohdaq/lit-material/issues",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+ssh://git@github.com/bohdaq/lit-material.git",
|
|
16
|
+
"directory": "packages/sortable"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"lit",
|
|
20
|
+
"web-components",
|
|
21
|
+
"lit-material",
|
|
22
|
+
"material-design",
|
|
23
|
+
"material-design-3",
|
|
24
|
+
"sortable",
|
|
25
|
+
"reorder",
|
|
26
|
+
"drag-and-drop"
|
|
27
|
+
],
|
|
28
|
+
"type": "module",
|
|
29
|
+
"main": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"custom-elements.json"
|
|
40
|
+
],
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"lit": "^3.2.0",
|
|
46
|
+
"@lit-material/tokens": "0.0.2"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@lit-labs/ssr": "^3.3.1",
|
|
50
|
+
"@open-wc/testing": "^4.0.0",
|
|
51
|
+
"@web/dev-server-esbuild": "^1.0.0",
|
|
52
|
+
"@web/test-runner": "^0.19.0",
|
|
53
|
+
"@web/test-runner-commands": "^0.9.0",
|
|
54
|
+
"@web/test-runner-playwright": "^0.11.0",
|
|
55
|
+
"tsx": "^4.19.0",
|
|
56
|
+
"typescript": "^5.7.0"
|
|
57
|
+
},
|
|
58
|
+
"customElements": "custom-elements.json",
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "tsc -p tsconfig.json",
|
|
61
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
62
|
+
"test": "web-test-runner && node --import tsx --test src/*.ssr.test.ts",
|
|
63
|
+
"analyze": "custom-elements-manifest analyze --litelement --globs \"src/**/*.ts\" --exclude \"src/**/*.test.ts\" --exclude \"src/**/*.ssr.test.ts\""
|
|
64
|
+
}
|
|
6
65
|
}
|