@rozie-ui/sortable-list-lit 0.1.5
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 +91 -0
- package/dist/index.cjs +772 -0
- package/dist/index.d.cts +97 -0
- package/dist/index.d.mts +97 -0
- package/dist/index.mjs +744 -0
- package/package.json +72 -0
- package/src/SortableList.ts +419 -0
- package/src/index.ts +2 -0
- package/src/internal/useSortableJS.ts +475 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dan Krieger and Rozie.js contributors
|
|
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
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# @rozie-ui/sortable-list-lit
|
|
2
|
+
|
|
3
|
+
Idiomatic **lit** `SortableList` — a cross-framework drag-and-drop list compiled from one [Rozie](https://github.com/One-Learning-Community/rozie.js) source via SortableJS. This package is generated; do not edit `src/` by hand.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @rozie-ui/sortable-list-lit
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies: `sortablejs ^1.15` + `lit`. Install them alongside this package.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import '@rozie-ui/sortable-list-lit';
|
|
17
|
+
|
|
18
|
+
// <sortable-list> is a custom element. Bind `items` as a property and
|
|
19
|
+
// listen for the `items-change` event to receive the reordered array.
|
|
20
|
+
const el = document.querySelector('sortable-list');
|
|
21
|
+
el.items = [
|
|
22
|
+
{ id: '1', label: 'Apple' },
|
|
23
|
+
{ id: '2', label: 'Banana' },
|
|
24
|
+
];
|
|
25
|
+
el.itemKey = 'id';
|
|
26
|
+
el.addEventListener('items-change', (e) => {
|
|
27
|
+
el.items = e.detail;
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Props
|
|
32
|
+
|
|
33
|
+
| Name | Type | Default | Two-way (model) | Required |
|
|
34
|
+
| --- | --- | --- | :---: | :---: |
|
|
35
|
+
| `items` | `Array` | `[]` | ✓ | |
|
|
36
|
+
| `itemKey` | `String \| Function` | `null` | | |
|
|
37
|
+
| `handle` | `String` | `null` | | |
|
|
38
|
+
| `group` | `String` | `null` | | |
|
|
39
|
+
| `animation` | `Number` | `150` | | |
|
|
40
|
+
| `disabled` | `Boolean` | `false` | | |
|
|
41
|
+
| `disableKeyboard` | `Boolean` | `false` | | |
|
|
42
|
+
| `options` | `Object` | `{}` | | |
|
|
43
|
+
| `labelFor` | `Function` | `null` | | |
|
|
44
|
+
| `ghostClass` | `String` | `null` | | |
|
|
45
|
+
| `chosenClass` | `String` | `null` | | |
|
|
46
|
+
| `dragClass` | `String` | `null` | | |
|
|
47
|
+
| `filter` | `String` | `null` | | |
|
|
48
|
+
| `easing` | `String` | `null` | | |
|
|
49
|
+
| `forceFallback` | `Boolean` | `false` | | |
|
|
50
|
+
| `swapThreshold` | `Number` | `1` | | |
|
|
51
|
+
| `cloneable` | `Boolean` | `false` | | |
|
|
52
|
+
| `listClass` | `String \| Array \| Object` | `""` | | |
|
|
53
|
+
| `itemClass` | `String \| Array \| Object \| Function` | `""` | | |
|
|
54
|
+
| `itemStyle` | `String \| Object \| Function` | `null` | | |
|
|
55
|
+
|
|
56
|
+
## Events
|
|
57
|
+
|
|
58
|
+
| Event | Description |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| `change` | Fired after the list order changes (same-list reorder commit). |
|
|
61
|
+
| `add` | Fired when an item is added from another list (cross-list destination commit). |
|
|
62
|
+
| `remove` | Fired when an item is moved out to another list (cross-list source commit; not fired in clone mode). |
|
|
63
|
+
| `start` | Fired when dragging starts. |
|
|
64
|
+
| `end` | Fired when dragging ends (source side). |
|
|
65
|
+
|
|
66
|
+
## Imperative handle
|
|
67
|
+
|
|
68
|
+
Beyond props, the component exposes imperative methods (declared once in the Rozie source via `$expose`). Grab a handle with the native ref mechanism and call them directly:
|
|
69
|
+
|
|
70
|
+
| Method | Description |
|
|
71
|
+
| --- | --- |
|
|
72
|
+
| `getInstance` | Return the underlying SortableJS instance for direct API access (the raw-engine escape hatch — `save`, `closest`, etc. are one hop away). `null` before mount and after destroy. |
|
|
73
|
+
| `toArray` | Return the current order as an array of `data-id` strings (each row carries `data-id="<key>"`). `[]` before mount. |
|
|
74
|
+
| `sort` | Reorder the list by an array of `data-id` strings — `sort(order, useAnimation = true)`. |
|
|
75
|
+
| `option` | Read or set a live SortableJS option — `option(name)` gets, `option(name, value)` sets. The runtime escape hatch for options beyond the curated props. |
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
// The custom element IS the handle — its exposed methods are public
|
|
79
|
+
// element methods.
|
|
80
|
+
const el = document.querySelector('rozie-sortable-list');
|
|
81
|
+
const order = el.toArray();
|
|
82
|
+
el.option('disabled', true);
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Slots
|
|
86
|
+
|
|
87
|
+
| Slot | Params |
|
|
88
|
+
| --- | --- |
|
|
89
|
+
| header | |
|
|
90
|
+
| (default) | item, index |
|
|
91
|
+
| footer | |
|