@molecule/app-reorderable-list-vue 0.0.1-stage → 1.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/README.md +192 -4
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,11 +1,199 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
3
|
+
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
|
+
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
|
+
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
+
Generated: 2026-11-21T12:47:09.430Z
|
|
7
|
+
-->
|
|
8
|
+
|
|
1
9
|
# @molecule/app-reorderable-list-vue
|
|
2
10
|
|
|
3
|
-
|
|
11
|
+
Vue drag-handle reorderable list (HTML5 drag-and-drop).
|
|
12
|
+
|
|
13
|
+
Exports `<ReorderableList>` and the `ReorderableItem<T>` type
|
|
14
|
+
(`{ id: string; data: T }`). Fully controlled: it renders rows and calls
|
|
15
|
+
`onReorder(next)` with the complete reordered array — the app owns state.
|
|
16
|
+
Props: `items`, `onReorder`, `renderItem(item, isDragging)`,
|
|
17
|
+
`renderHandle?` (when set, only the handle is draggable — e.g. a "≡"
|
|
18
|
+
glyph; otherwise the whole row drags), `className?`.
|
|
19
|
+
|
|
20
|
+
It is the Vue counterpart of `@molecule/app-reorderable-list-react`: the
|
|
21
|
+
same props and the same DOM for the same input, so an app switches
|
|
22
|
+
framework by changing only the package name in its imports.
|
|
23
|
+
|
|
24
|
+
Reordering works with a mouse (HTML5 drag) AND the keyboard: every row has
|
|
25
|
+
move-up/move-down buttons (`data-mol-id="reorderable-move-{up,down}-<id>"`),
|
|
26
|
+
and Alt+ArrowUp / Alt+ArrowDown on a focused move button reorders its row.
|
|
27
|
+
Focus follows the item: a move that disables the used button (the item
|
|
28
|
+
reached the top or the bottom) moves focus to the same row's other button.
|
|
29
|
+
|
|
30
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
31
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
32
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { defineComponent, h, ref } from 'vue'
|
|
38
|
+
|
|
39
|
+
import { ReorderableList } from '@molecule/app-reorderable-list-vue'
|
|
40
|
+
import type { ReorderableItem } from '@molecule/app-reorderable-list-vue'
|
|
41
|
+
|
|
42
|
+
const Steps = defineComponent({
|
|
43
|
+
setup() {
|
|
44
|
+
const items = ref<ReorderableItem<{ label: string }>[]>([
|
|
45
|
+
{ id: '1', data: { label: 'First' } },
|
|
46
|
+
{ id: '2', data: { label: 'Second' } },
|
|
47
|
+
{ id: '3', data: { label: 'Third' } },
|
|
48
|
+
])
|
|
49
|
+
return () =>
|
|
50
|
+
h(ReorderableList, {
|
|
51
|
+
items: items.value,
|
|
52
|
+
onReorder: (next) => (items.value = next),
|
|
53
|
+
renderItem: (item) => h('span', item.data.label),
|
|
54
|
+
})
|
|
55
|
+
},
|
|
56
|
+
})
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Type
|
|
60
|
+
|
|
61
|
+
`feature`
|
|
62
|
+
|
|
63
|
+
## Installation
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npm install @molecule/app-reorderable-list-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## API
|
|
70
|
+
|
|
71
|
+
### Interfaces
|
|
72
|
+
|
|
73
|
+
#### `ReorderableItem`
|
|
74
|
+
|
|
75
|
+
A single item in a {@link ReorderableList}, pairing a stable string id with arbitrary data.
|
|
4
76
|
|
|
77
|
+
```typescript
|
|
78
|
+
interface ReorderableItem<T> {
|
|
79
|
+
/** The item's stable identity — drop resolution matches by it. */
|
|
80
|
+
id: string
|
|
81
|
+
/** The item's data, handed to the renderer untouched. */
|
|
82
|
+
data: T
|
|
83
|
+
}
|
|
5
84
|
```
|
|
6
|
-
|
|
85
|
+
|
|
86
|
+
#### `ReorderableListProps`
|
|
87
|
+
|
|
88
|
+
Props accepted by the {@link ReorderableList} component.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
interface ReorderableListProps<T> {
|
|
92
|
+
/** Items in display order. */
|
|
93
|
+
items: readonly ReorderableItem<T>[]
|
|
94
|
+
/** Called with the new order (full list). */
|
|
95
|
+
onReorder: (next: ReorderableItem<T>[]) => void
|
|
96
|
+
/** Per-item renderer. Receives item + isDragging flag. */
|
|
97
|
+
renderItem: (item: ReorderableItem<T>, isDragging: boolean) => VNodeChild
|
|
98
|
+
/** Optional drag-handle slot — when omitted, the entire row is the drag target. */
|
|
99
|
+
renderHandle?: () => VNodeChild
|
|
100
|
+
/** Extra classes on the list. */
|
|
101
|
+
className?: string
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Constants
|
|
106
|
+
|
|
107
|
+
#### `ReorderableList`
|
|
108
|
+
|
|
109
|
+
Drag-handle reorderable list with HTML5 DnD AND keyboard reordering. Apps own
|
|
110
|
+
the data; this component only renders + emits new order on `onReorder`.
|
|
111
|
+
|
|
112
|
+
Use the optional `renderHandle` slot to limit drag to a specific element
|
|
113
|
+
(e.g. a "≡" handle on the left). Every row also ships explicit
|
|
114
|
+
move-up/move-down buttons; Alt+ArrowUp / Alt+ArrowDown on a focused move
|
|
115
|
+
button reorders too, and focus follows the item: when a move disables the
|
|
116
|
+
button that was used (the item reached the top or the bottom), focus moves
|
|
117
|
+
to the same row's other button. The list is fully reorderable without a
|
|
118
|
+
mouse.
|
|
119
|
+
|
|
120
|
+
Each row renders its position ("Item 2 of 3") in a screen-reader-only span
|
|
121
|
+
that both of its move buttons reference through `aria-describedby`, so the
|
|
122
|
+
buttons announce where the item sits.
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
const ReorderableList: DefineComponent<
|
|
126
|
+
ExtractPropTypes<{
|
|
127
|
+
items: { type: PropType<readonly ReorderableItem<unknown>[]>; required: true }
|
|
128
|
+
onReorder: { type: PropType<ReorderHandler>; required: true }
|
|
129
|
+
renderItem: { type: PropType<ItemRenderer>; required: true }
|
|
130
|
+
renderHandle: { type: PropType<(() => VNodeChild) | undefined>; default: undefined }
|
|
131
|
+
className: { type: PropType<string | undefined>; default: undefined }
|
|
132
|
+
}>,
|
|
133
|
+
() => VNode,
|
|
134
|
+
{},
|
|
135
|
+
{},
|
|
136
|
+
{},
|
|
137
|
+
ComponentOptionsMixin,
|
|
138
|
+
ComponentOptionsMixin,
|
|
139
|
+
{},
|
|
140
|
+
string,
|
|
141
|
+
PublicProps,
|
|
142
|
+
Readonly<
|
|
143
|
+
ExtractPropTypes<{
|
|
144
|
+
items: { type: PropType<readonly ReorderableItem<unknown>[]>; required: true }
|
|
145
|
+
onReorder: { type: PropType<ReorderHandler>; required: true }
|
|
146
|
+
renderItem: { type: PropType<ItemRenderer>; required: true }
|
|
147
|
+
renderHandle: { type: PropType<(() => VNodeChild) | undefined>; default: undefined }
|
|
148
|
+
className: { type: PropType<string | undefined>; default: undefined }
|
|
149
|
+
}>
|
|
150
|
+
> &
|
|
151
|
+
Readonly<{}>,
|
|
152
|
+
{ renderHandle: (() => VNodeChild) | undefined; className: string | undefined },
|
|
153
|
+
{},
|
|
154
|
+
{},
|
|
155
|
+
{},
|
|
156
|
+
string,
|
|
157
|
+
ComponentProvideOptions,
|
|
158
|
+
true,
|
|
159
|
+
{},
|
|
160
|
+
any
|
|
161
|
+
>
|
|
7
162
|
```
|
|
8
163
|
|
|
9
|
-
|
|
164
|
+
- `props` — Component props (see `ReorderableListProps`).
|
|
165
|
+
|
|
166
|
+
**Returns:** The reorderable list component.
|
|
167
|
+
|
|
168
|
+
## Injection Notes
|
|
169
|
+
|
|
170
|
+
### Requirements
|
|
171
|
+
|
|
172
|
+
Peer dependencies:
|
|
173
|
+
|
|
174
|
+
- `@molecule/app-ui` ^1.0.1
|
|
175
|
+
- `@molecule/app-ui-vue` ^1.1.0
|
|
176
|
+
- `@molecule/app-vue` ^3.5.0
|
|
177
|
+
- `vue` ^3.5.0
|
|
178
|
+
|
|
179
|
+
### Runtime Dependencies
|
|
180
|
+
|
|
181
|
+
- `@molecule/app-ui`
|
|
182
|
+
- `@molecule/app-ui-vue`
|
|
183
|
+
- `@molecule/app-vue`
|
|
184
|
+
- `vue`
|
|
185
|
+
|
|
186
|
+
- Native HTML5 drag works with MOUSE/POINTER only — touch devices
|
|
187
|
+
(iOS/Android) fire no HTML5 drag events. The keyboard path (move buttons +
|
|
188
|
+
Alt+Arrow) is the a11y/touch-safe fallback and is always present; add a
|
|
189
|
+
pointer/touch drag library only if you also need touch DRAG specifically.
|
|
190
|
+
- Requires a bonded ClassMap (`setClassMap()` at startup) and an i18n
|
|
191
|
+
provider (for the control labels) or rendering throws.
|
|
192
|
+
- Item `id`s must be unique — drop resolution matches by id.
|
|
193
|
+
- Control labels ("Move up/down", "Drag to reorder", row position) render
|
|
194
|
+
through `t(...)` under `reorderableList.*`, translated by the
|
|
195
|
+
`@molecule/app-locales-reorderable-list` companion bond.
|
|
196
|
+
|
|
197
|
+
## Translations
|
|
10
198
|
|
|
11
|
-
|
|
199
|
+
Translation strings are provided by `@molecule/app-locales-reorderable-list`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-reorderable-list-vue",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Vertical drag-handle reorder list with onReorder callback (HTML5 drag — mouse/pointer only, no touch)",
|
|
5
5
|
"homepage": "https://www.molecule.dev/packages/app-reorderable-list-vue",
|
|
6
6
|
"type": "module",
|
|
@@ -45,15 +45,15 @@
|
|
|
45
45
|
"@molecule/app-ui": "^1.0.1",
|
|
46
46
|
"@molecule/app-ui-vue": "^1.1.0",
|
|
47
47
|
"@molecule/app-vue": "^3.5.0",
|
|
48
|
-
"vue": "^3.
|
|
48
|
+
"vue": "^3.5.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@molecule/app-framework-conformance": "0.0.0",
|
|
52
52
|
"@molecule/app-i18n": "1.2.2",
|
|
53
53
|
"@molecule/app-icons": "1.0.4",
|
|
54
|
-
"@molecule/app-ui": "1.
|
|
55
|
-
"@molecule/app-ui-vue": "1.1
|
|
56
|
-
"@molecule/app-vue": "3.
|
|
54
|
+
"@molecule/app-ui": "1.5.0",
|
|
55
|
+
"@molecule/app-ui-vue": "1.2.1",
|
|
56
|
+
"@molecule/app-vue": "3.9.0",
|
|
57
57
|
"@types/node": "26.6.5",
|
|
58
58
|
"jsdom": "30.1.3",
|
|
59
59
|
"typescript": "6.0.3",
|