@molecule/app-reorderable-list-vue 0.0.0-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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,199 @@
1
- # Temporary Holding Version
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
+ -->
2
8
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
9
+ # @molecule/app-reorderable-list-vue
10
+
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.
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
+ }
84
+ ```
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
+ >
162
+ ```
163
+
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
198
+
199
+ Translation strings are provided by `@molecule/app-locales-reorderable-list`.
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Vue drag-handle reorderable list with HTML5 DnD AND keyboard reordering.
3
+ *
4
+ * Vue counterpart of `@molecule/app-reorderable-list-react`'s
5
+ * `ReorderableList` — the same props (React names), the same ClassMap tokens,
6
+ * and the same DOM for the same input. Apps own the data; this component only
7
+ * renders rows and emits the new order on `onReorder`.
8
+ *
9
+ * @module
10
+ */
11
+ import { type PropType, type VNode, type VNodeChild } from 'vue';
12
+ import type { ReorderableItem } from './types.js';
13
+ /**
14
+ * A per-item render function, declared with a `never` parameter so that any
15
+ * `(item: T, isDragging: boolean) => VNodeChild` an app passes is assignable
16
+ * to it (a function parameter is checked contravariantly).
17
+ */
18
+ type ItemRenderer = (item: never, isDragging: boolean) => VNodeChild;
19
+ /**
20
+ * A reorder handler, declared with a `never` parameter so that any
21
+ * `(next: ReorderableItem<T>[]) => void` an app passes is assignable to it
22
+ * (a function parameter is checked contravariantly).
23
+ */
24
+ type ReorderHandler = (next: never[]) => void;
25
+ /**
26
+ * Drag-handle reorderable list with HTML5 DnD AND keyboard reordering. Apps own
27
+ * the data; this component only renders + emits new order on `onReorder`.
28
+ *
29
+ * Use the optional `renderHandle` slot to limit drag to a specific element
30
+ * (e.g. a "≡" handle on the left). Every row also ships explicit
31
+ * move-up/move-down buttons; Alt+ArrowUp / Alt+ArrowDown on a focused move
32
+ * button reorders too, and focus follows the item: when a move disables the
33
+ * button that was used (the item reached the top or the bottom), focus moves
34
+ * to the same row's other button. The list is fully reorderable without a
35
+ * mouse.
36
+ *
37
+ * Each row renders its position ("Item 2 of 3") in a screen-reader-only span
38
+ * that both of its move buttons reference through `aria-describedby`, so the
39
+ * buttons announce where the item sits.
40
+ *
41
+ * @param props - Component props (see `ReorderableListProps`).
42
+ * @returns The reorderable list component.
43
+ */
44
+ export declare const ReorderableList: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
45
+ /** Items in display order. */
46
+ items: {
47
+ type: PropType<readonly ReorderableItem<unknown>[]>;
48
+ required: true;
49
+ };
50
+ /** Called with the new order (full list). */
51
+ onReorder: {
52
+ type: PropType<ReorderHandler>;
53
+ required: true;
54
+ };
55
+ /** Per-item renderer. Receives item + isDragging flag. */
56
+ renderItem: {
57
+ type: PropType<ItemRenderer>;
58
+ required: true;
59
+ };
60
+ /** Optional drag-handle slot — when omitted, the entire row is the drag target. */
61
+ renderHandle: {
62
+ type: PropType<(() => VNodeChild) | undefined>;
63
+ default: undefined;
64
+ };
65
+ /** Extra classes on the list. */
66
+ className: {
67
+ type: PropType<string | undefined>;
68
+ default: undefined;
69
+ };
70
+ }>, () => VNode, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
71
+ /** Items in display order. */
72
+ items: {
73
+ type: PropType<readonly ReorderableItem<unknown>[]>;
74
+ required: true;
75
+ };
76
+ /** Called with the new order (full list). */
77
+ onReorder: {
78
+ type: PropType<ReorderHandler>;
79
+ required: true;
80
+ };
81
+ /** Per-item renderer. Receives item + isDragging flag. */
82
+ renderItem: {
83
+ type: PropType<ItemRenderer>;
84
+ required: true;
85
+ };
86
+ /** Optional drag-handle slot — when omitted, the entire row is the drag target. */
87
+ renderHandle: {
88
+ type: PropType<(() => VNodeChild) | undefined>;
89
+ default: undefined;
90
+ };
91
+ /** Extra classes on the list. */
92
+ className: {
93
+ type: PropType<string | undefined>;
94
+ default: undefined;
95
+ };
96
+ }>> & Readonly<{}>, {
97
+ renderHandle: (() => VNodeChild) | undefined;
98
+ className: string | undefined;
99
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
100
+ export {};
101
+ //# sourceMappingURL=ReorderableList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReorderableList.d.ts","sourceRoot":"","sources":["../src/ReorderableList.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAGL,KAAK,QAAQ,EAGb,KAAK,KAAK,EACV,KAAK,UAAU,EAGhB,MAAM,KAAK,CAAA;AAKZ,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD;;;;GAIG;AACH,KAAK,YAAY,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,KAAK,UAAU,CAAA;AAapE;;;;GAIG;AACH,KAAK,cAAc,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,IAAI,CAAA;AAW7C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,eAAe;IAGxB,8BAA8B;;cAEb,QAAQ,CAAC,SAAS,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;;;IAG9D,6CAA6C;;cAEzB,QAAQ,CAAC,cAAc,CAAC;;;IAG5C,0DAA0D;;cAEtC,QAAQ,CAAC,YAAY,CAAC;;;IAG1C,mFAAmF;;cAE/D,QAAQ,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,SAAS,CAAC;;;IAG5D,iCAAiC;;cAEf,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC;;;UA0MnC,KAAK;IAhOhB,8BAA8B;;cAEb,QAAQ,CAAC,SAAS,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;;;IAG9D,6CAA6C;;cAEzB,QAAQ,CAAC,cAAc,CAAC;;;IAG5C,0DAA0D;;cAEtC,QAAQ,CAAC,YAAY,CAAC;;;IAG1C,mFAAmF;;cAE/D,QAAQ,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,SAAS,CAAC;;;IAG5D,iCAAiC;;cAEf,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC;;;;yBALV,UAAU;;4EAmShD,CAAA"}
@@ -0,0 +1,318 @@
1
+ /**
2
+ * Vue drag-handle reorderable list with HTML5 DnD AND keyboard reordering.
3
+ *
4
+ * Vue counterpart of `@molecule/app-reorderable-list-react`'s
5
+ * `ReorderableList` — the same props (React names), the same ClassMap tokens,
6
+ * and the same DOM for the same input. Apps own the data; this component only
7
+ * renders rows and emits the new order on `onReorder`.
8
+ *
9
+ * @module
10
+ */
11
+ import { defineComponent, h, ref, useId, watch, } from 'vue';
12
+ import { getClassMap } from '@molecule/app-ui';
13
+ import { useTranslation } from '@molecule/app-vue';
14
+ /**
15
+ * Calls the caller's item renderer with the item it belongs to.
16
+ *
17
+ * @param render - The caller's render function.
18
+ * @param item - The row's item.
19
+ * @param isDragging - Whether the row is being dragged.
20
+ * @returns The node(s) the caller rendered.
21
+ */
22
+ const renderRow = (render, item, isDragging) => render(item, isDragging);
23
+ /**
24
+ * Calls the caller's reorder handler with the new order.
25
+ *
26
+ * @param handler - The caller's handler.
27
+ * @param next - The full new order.
28
+ */
29
+ const emitReorder = (handler, next) => handler(next);
30
+ /**
31
+ * Drag-handle reorderable list with HTML5 DnD AND keyboard reordering. Apps own
32
+ * the data; this component only renders + emits new order on `onReorder`.
33
+ *
34
+ * Use the optional `renderHandle` slot to limit drag to a specific element
35
+ * (e.g. a "≡" handle on the left). Every row also ships explicit
36
+ * move-up/move-down buttons; Alt+ArrowUp / Alt+ArrowDown on a focused move
37
+ * button reorders too, and focus follows the item: when a move disables the
38
+ * button that was used (the item reached the top or the bottom), focus moves
39
+ * to the same row's other button. The list is fully reorderable without a
40
+ * mouse.
41
+ *
42
+ * Each row renders its position ("Item 2 of 3") in a screen-reader-only span
43
+ * that both of its move buttons reference through `aria-describedby`, so the
44
+ * buttons announce where the item sits.
45
+ *
46
+ * @param props - Component props (see `ReorderableListProps`).
47
+ * @returns The reorderable list component.
48
+ */
49
+ export const ReorderableList = defineComponent({
50
+ name: 'ReorderableList',
51
+ props: {
52
+ /** Items in display order. */
53
+ items: {
54
+ type: Array,
55
+ required: true,
56
+ },
57
+ /** Called with the new order (full list). */
58
+ onReorder: {
59
+ type: Function,
60
+ required: true,
61
+ },
62
+ /** Per-item renderer. Receives item + isDragging flag. */
63
+ renderItem: {
64
+ type: Function,
65
+ required: true,
66
+ },
67
+ /** Optional drag-handle slot — when omitted, the entire row is the drag target. */
68
+ renderHandle: {
69
+ type: Function,
70
+ default: undefined,
71
+ },
72
+ /** Extra classes on the list. */
73
+ className: {
74
+ type: String,
75
+ default: undefined,
76
+ },
77
+ },
78
+ setup(props) {
79
+ const cm = getClassMap();
80
+ const { t } = useTranslation();
81
+ const draggingId = ref(null);
82
+ const overId = ref(null);
83
+ /** The list's id prefix; each row's position span is `${baseId}-position-${index}`. */
84
+ const baseId = useId();
85
+ /** The rows' move buttons, keyed by item id — the focus watcher's targets. */
86
+ const moveButtons = new Map();
87
+ /** The move whose focus settles once `items` changes: the item id and the button used. */
88
+ const focusRequest = ref(null);
89
+ /**
90
+ * Moves the item at `index` by `delta` positions and emits the new order.
91
+ * No-ops at the list boundaries. Shared by the move buttons and the
92
+ * keyboard (Alt+Arrow) path so mouse and keyboard reordering stay identical.
93
+ *
94
+ * @param index - Current position of the item to move.
95
+ * @param delta - -1 to move up, 1 to move down.
96
+ */
97
+ function moveItem(index, delta) {
98
+ const to = index + delta;
99
+ if (to < 0 || to >= props.items.length)
100
+ return;
101
+ const next = [...props.items];
102
+ const [moved] = next.splice(index, 1);
103
+ next.splice(to, 0, moved);
104
+ emitReorder(props.onReorder, next);
105
+ }
106
+ /**
107
+ * Keyboard reordering for a focused row: Alt+ArrowUp / Alt+ArrowDown move it.
108
+ * Alt is required so plain arrows still scroll/move the caret and browser
109
+ * history navigation is left untouched.
110
+ *
111
+ * @param index - Position of the focused row.
112
+ * @param e - The keyboard event.
113
+ */
114
+ function onItemKeyDown(index, e) {
115
+ if (!e.altKey)
116
+ return;
117
+ if (e.key === 'ArrowUp') {
118
+ e.preventDefault();
119
+ moveItem(index, -1);
120
+ }
121
+ else if (e.key === 'ArrowDown') {
122
+ e.preventDefault();
123
+ moveItem(index, 1);
124
+ }
125
+ }
126
+ /**
127
+ * Registers one move button under its item id (a function ref), so the
128
+ * focus watcher can reach either button of that row.
129
+ *
130
+ * @param id - The row's item id.
131
+ * @param button - Which button of the row this is.
132
+ * @returns The function ref for the button.
133
+ */
134
+ function registerMoveButton(id, button) {
135
+ return (el) => {
136
+ const row = moveButtons.get(id) ?? { up: null, down: null };
137
+ row[button] = el instanceof HTMLButtonElement ? el : null;
138
+ moveButtons.set(id, row);
139
+ };
140
+ }
141
+ /**
142
+ * Moves the item with a move button, recording which button was used so the
143
+ * focus watcher can settle focus after the new order lands.
144
+ *
145
+ * @param id - The moved item's id.
146
+ * @param index - Current position of the item to move.
147
+ * @param delta - -1 to move up, 1 to move down.
148
+ * @param button - The button the move came from.
149
+ */
150
+ function moveFromButton(id, index, delta, button) {
151
+ focusRequest.value = { id, button };
152
+ moveItem(index, delta);
153
+ }
154
+ /**
155
+ * Keyboard reordering for a focused move button: Alt+ArrowUp / Alt+ArrowDown
156
+ * move its item. A key that moves also records the button used, for the same
157
+ * focus settling a click gets.
158
+ *
159
+ * @param id - The row's item id.
160
+ * @param index - Current position of the row's item.
161
+ * @param button - Which button of the row this is.
162
+ * @param e - The keyboard event.
163
+ */
164
+ function onButtonKeyDown(id, index, button, e) {
165
+ if (e.altKey && (e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
166
+ focusRequest.value = { id, button };
167
+ }
168
+ onItemKeyDown(index, e);
169
+ }
170
+ // Focus settles after a move: when the button that was used is disabled by
171
+ // the new order (the item reached the top or the bottom), focus moves to
172
+ // the same row's other move button; otherwise it stays (the row is keyed by
173
+ // item id, so the focused button moves with its row). Runs after `items`
174
+ // changes and consumes the request the move recorded.
175
+ watch(() => props.items, () => {
176
+ const request = focusRequest.value;
177
+ focusRequest.value = null;
178
+ if (!request)
179
+ return;
180
+ const index = props.items.findIndex((item) => item.id === request.id);
181
+ if (index < 0)
182
+ return;
183
+ const row = moveButtons.get(request.id);
184
+ if (!row)
185
+ return;
186
+ const usedDisabled = request.button === 'up' ? index === 0 : index === props.items.length - 1;
187
+ if (!usedDisabled)
188
+ return;
189
+ const other = request.button === 'up' ? row.down : row.up;
190
+ other?.focus();
191
+ }, { flush: 'post' });
192
+ /**
193
+ * Initiates a drag operation, storing the dragged item id in the transfer payload.
194
+ *
195
+ * @param id - The dragged item's id.
196
+ * @param e - The drag start event.
197
+ */
198
+ function onDragStart(id, e) {
199
+ e.dataTransfer?.setData('text/plain', id);
200
+ if (e.dataTransfer)
201
+ e.dataTransfer.effectAllowed = 'move';
202
+ draggingId.value = id;
203
+ }
204
+ /**
205
+ * Marks the hovered item as the current drop target and allows the drop.
206
+ *
207
+ * @param id - The hovered item's id.
208
+ * @param e - The drag over event.
209
+ */
210
+ function onDragOver(id, e) {
211
+ e.preventDefault();
212
+ if (e.dataTransfer)
213
+ e.dataTransfer.dropEffect = 'move';
214
+ overId.value = id;
215
+ }
216
+ /**
217
+ * Handles a drop event by computing the new item order and calling `onReorder`.
218
+ *
219
+ * @param targetId - The id of the row dropped onto.
220
+ * @param e - The drop event.
221
+ */
222
+ function onDrop(targetId, e) {
223
+ e.preventDefault();
224
+ const sourceId = e.dataTransfer?.getData('text/plain');
225
+ if (!sourceId || sourceId === targetId) {
226
+ reset();
227
+ return;
228
+ }
229
+ const from = props.items.findIndex((i) => i.id === sourceId);
230
+ const to = props.items.findIndex((i) => i.id === targetId);
231
+ if (from < 0 || to < 0) {
232
+ reset();
233
+ return;
234
+ }
235
+ const next = [...props.items];
236
+ const [moved] = next.splice(from, 1);
237
+ next.splice(to, 0, moved);
238
+ emitReorder(props.onReorder, next);
239
+ reset();
240
+ }
241
+ /** Clears dragging and over-target state after a drop or drag-end event. */
242
+ function reset() {
243
+ draggingId.value = null;
244
+ overId.value = null;
245
+ }
246
+ /**
247
+ * The translated row position label, rendered in the row's
248
+ * screen-reader-only span.
249
+ *
250
+ * @param index - The row's index.
251
+ * @returns The label.
252
+ */
253
+ function positionLabel(index) {
254
+ return t('reorderableList.position', { index: index + 1, total: props.items.length }, { defaultValue: 'Item {{index}} of {{total}}' });
255
+ }
256
+ return () => h('ul', { class: cm.cn(cm.stack(1), props.className) }, [
257
+ props.items.map((item, index) => {
258
+ const isDragging = draggingId.value === item.id;
259
+ const isOver = overId.value === item.id && draggingId.value !== item.id;
260
+ const positionId = `${baseId}-position-${index}`;
261
+ return h('li', {
262
+ key: item.id,
263
+ draggable: !props.renderHandle,
264
+ onDragstart: props.renderHandle
265
+ ? undefined
266
+ : (event) => onDragStart(item.id, event),
267
+ onDragend: reset,
268
+ onDragover: (event) => onDragOver(item.id, event),
269
+ onDrop: (event) => onDrop(item.id, event),
270
+ class: cm.cn(cm.flex({ align: 'center', gap: 'sm' })),
271
+ style: {
272
+ opacity: isDragging ? 0.4 : 1,
273
+ borderTop: isOver ? '2px solid currentColor' : undefined,
274
+ },
275
+ }, [
276
+ ...(props.renderHandle
277
+ ? [
278
+ h('span', {
279
+ draggable: true,
280
+ onDragstart: (event) => onDragStart(item.id, event),
281
+ onDragend: reset,
282
+ class: cm.cursorPointer,
283
+ 'aria-label': t('reorderableList.dragHandle', {}, { defaultValue: 'Drag to reorder' }),
284
+ }, [props.renderHandle()]),
285
+ ]
286
+ : []),
287
+ h('div', { class: cm.flex1 }, [renderRow(props.renderItem, item, isDragging)]),
288
+ h('div', { class: cm.cn(cm.flex({ align: 'center', gap: 'xs' })) }, [
289
+ h('button', {
290
+ type: 'button',
291
+ 'data-mol-id': `reorderable-move-up-${item.id}`,
292
+ ref: registerMoveButton(item.id, 'up'),
293
+ onClick: () => moveFromButton(item.id, index, -1, 'up'),
294
+ onKeydown: (event) => onButtonKeyDown(item.id, index, 'up', event),
295
+ disabled: index === 0,
296
+ 'aria-label': t('reorderableList.moveUp', {}, { defaultValue: 'Move up' }),
297
+ 'aria-describedby': positionId,
298
+ class: cm.cn(cm.cursorPointer, cm.sp('p', 1)),
299
+ }, [h('span', { 'aria-hidden': 'true' }, '↑')]),
300
+ h('button', {
301
+ type: 'button',
302
+ 'data-mol-id': `reorderable-move-down-${item.id}`,
303
+ ref: registerMoveButton(item.id, 'down'),
304
+ onClick: () => moveFromButton(item.id, index, 1, 'down'),
305
+ onKeydown: (event) => onButtonKeyDown(item.id, index, 'down', event),
306
+ disabled: index === props.items.length - 1,
307
+ 'aria-label': t('reorderableList.moveDown', {}, { defaultValue: 'Move down' }),
308
+ 'aria-describedby': positionId,
309
+ class: cm.cn(cm.cursorPointer, cm.sp('p', 1)),
310
+ }, [h('span', { 'aria-hidden': 'true' }, '↓')]),
311
+ ]),
312
+ h('span', { id: positionId, class: cm.srOnly }, positionLabel(index)),
313
+ ]);
314
+ }),
315
+ ]);
316
+ },
317
+ });
318
+ //# sourceMappingURL=ReorderableList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReorderableList.js","sourceRoot":"","sources":["../src/ReorderableList.ts"],"names":[],"mappings":"AAAA;;;;;;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EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;yBAC9C,EACD,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,GAAG,CAAC,CAAC,CAC5C;qBACF,CAAC;oBACF,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,EAAE,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;iBACtE,CACF,CAAA;YACH,CAAC,CAAC;SACH,CAAC,CAAA;IACN,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Vue drag-handle reorderable list (HTML5 drag-and-drop).
3
+ *
4
+ * Exports `<ReorderableList>` and the `ReorderableItem<T>` type
5
+ * (`{ id: string; data: T }`). Fully controlled: it renders rows and calls
6
+ * `onReorder(next)` with the complete reordered array — the app owns state.
7
+ * Props: `items`, `onReorder`, `renderItem(item, isDragging)`,
8
+ * `renderHandle?` (when set, only the handle is draggable — e.g. a "≡"
9
+ * glyph; otherwise the whole row drags), `className?`.
10
+ *
11
+ * It is the Vue counterpart of `@molecule/app-reorderable-list-react`: the
12
+ * same props and the same DOM for the same input, so an app switches
13
+ * framework by changing only the package name in its imports.
14
+ *
15
+ * Reordering works with a mouse (HTML5 drag) AND the keyboard: every row has
16
+ * move-up/move-down buttons (`data-mol-id="reorderable-move-{up,down}-<id>"`),
17
+ * and Alt+ArrowUp / Alt+ArrowDown on a focused move button reorders its row.
18
+ * Focus follows the item: a move that disables the used button (the item
19
+ * reached the top or the bottom) moves focus to the same row's other button.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { defineComponent, h, ref } from 'vue'
24
+ *
25
+ * import { ReorderableList } from '@molecule/app-reorderable-list-vue'
26
+ * import type { ReorderableItem } from '@molecule/app-reorderable-list-vue'
27
+ *
28
+ * const Steps = defineComponent({
29
+ * setup() {
30
+ * const items = ref<ReorderableItem<{ label: string }>[]>([
31
+ * { id: '1', data: { label: 'First' } },
32
+ * { id: '2', data: { label: 'Second' } },
33
+ * { id: '3', data: { label: 'Third' } },
34
+ * ])
35
+ * return () =>
36
+ * h(ReorderableList, {
37
+ * items: items.value,
38
+ * onReorder: (next) => (items.value = next),
39
+ * renderItem: (item) => h('span', item.data.label),
40
+ * })
41
+ * },
42
+ * })
43
+ * ```
44
+ *
45
+ * @remarks
46
+ * - Native HTML5 drag works with MOUSE/POINTER only — touch devices
47
+ * (iOS/Android) fire no HTML5 drag events. The keyboard path (move buttons +
48
+ * Alt+Arrow) is the a11y/touch-safe fallback and is always present; add a
49
+ * pointer/touch drag library only if you also need touch DRAG specifically.
50
+ * - Requires a bonded ClassMap (`setClassMap()` at startup) and an i18n
51
+ * provider (for the control labels) or rendering throws.
52
+ * - Item `id`s must be unique — drop resolution matches by id.
53
+ * - Control labels ("Move up/down", "Drag to reorder", row position) render
54
+ * through `t(...)` under `reorderableList.*`, translated by the
55
+ * `@molecule/app-locales-reorderable-list` companion bond.
56
+ *
57
+ * @module
58
+ */
59
+ export * from './ReorderableList.js';
60
+ export * from './types.js';
61
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH,cAAc,sBAAsB,CAAA;AACpC,cAAc,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Vue drag-handle reorderable list (HTML5 drag-and-drop).
3
+ *
4
+ * Exports `<ReorderableList>` and the `ReorderableItem<T>` type
5
+ * (`{ id: string; data: T }`). Fully controlled: it renders rows and calls
6
+ * `onReorder(next)` with the complete reordered array — the app owns state.
7
+ * Props: `items`, `onReorder`, `renderItem(item, isDragging)`,
8
+ * `renderHandle?` (when set, only the handle is draggable — e.g. a "≡"
9
+ * glyph; otherwise the whole row drags), `className?`.
10
+ *
11
+ * It is the Vue counterpart of `@molecule/app-reorderable-list-react`: the
12
+ * same props and the same DOM for the same input, so an app switches
13
+ * framework by changing only the package name in its imports.
14
+ *
15
+ * Reordering works with a mouse (HTML5 drag) AND the keyboard: every row has
16
+ * move-up/move-down buttons (`data-mol-id="reorderable-move-{up,down}-<id>"`),
17
+ * and Alt+ArrowUp / Alt+ArrowDown on a focused move button reorders its row.
18
+ * Focus follows the item: a move that disables the used button (the item
19
+ * reached the top or the bottom) moves focus to the same row's other button.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { defineComponent, h, ref } from 'vue'
24
+ *
25
+ * import { ReorderableList } from '@molecule/app-reorderable-list-vue'
26
+ * import type { ReorderableItem } from '@molecule/app-reorderable-list-vue'
27
+ *
28
+ * const Steps = defineComponent({
29
+ * setup() {
30
+ * const items = ref<ReorderableItem<{ label: string }>[]>([
31
+ * { id: '1', data: { label: 'First' } },
32
+ * { id: '2', data: { label: 'Second' } },
33
+ * { id: '3', data: { label: 'Third' } },
34
+ * ])
35
+ * return () =>
36
+ * h(ReorderableList, {
37
+ * items: items.value,
38
+ * onReorder: (next) => (items.value = next),
39
+ * renderItem: (item) => h('span', item.data.label),
40
+ * })
41
+ * },
42
+ * })
43
+ * ```
44
+ *
45
+ * @remarks
46
+ * - Native HTML5 drag works with MOUSE/POINTER only — touch devices
47
+ * (iOS/Android) fire no HTML5 drag events. The keyboard path (move buttons +
48
+ * Alt+Arrow) is the a11y/touch-safe fallback and is always present; add a
49
+ * pointer/touch drag library only if you also need touch DRAG specifically.
50
+ * - Requires a bonded ClassMap (`setClassMap()` at startup) and an i18n
51
+ * provider (for the control labels) or rendering throws.
52
+ * - Item `id`s must be unique — drop resolution matches by id.
53
+ * - Control labels ("Move up/down", "Drag to reorder", row position) render
54
+ * through `t(...)` under `reorderableList.*`, translated by the
55
+ * `@molecule/app-locales-reorderable-list` companion bond.
56
+ *
57
+ * @module
58
+ */
59
+ export * from './ReorderableList.js';
60
+ export * from './types.js';
61
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH,cAAc,sBAAsB,CAAA;AACpC,cAAc,YAAY,CAAA"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Types for the Vue drag-handle reorder list.
3
+ *
4
+ * @module
5
+ */
6
+ import type { VNodeChild } from 'vue';
7
+ /** A single item in a {@link ReorderableList}, pairing a stable string id with arbitrary data. */
8
+ export interface ReorderableItem<T> {
9
+ /** The item's stable identity — drop resolution matches by it. */
10
+ id: string;
11
+ /** The item's data, handed to the renderer untouched. */
12
+ data: T;
13
+ }
14
+ /** Props accepted by the {@link ReorderableList} component. */
15
+ export interface ReorderableListProps<T> {
16
+ /** Items in display order. */
17
+ items: readonly ReorderableItem<T>[];
18
+ /** Called with the new order (full list). */
19
+ onReorder: (next: ReorderableItem<T>[]) => void;
20
+ /** Per-item renderer. Receives item + isDragging flag. */
21
+ renderItem: (item: ReorderableItem<T>, isDragging: boolean) => VNodeChild;
22
+ /** Optional drag-handle slot — when omitted, the entire row is the drag target. */
23
+ renderHandle?: () => VNodeChild;
24
+ /** Extra classes on the list. */
25
+ className?: string;
26
+ }
27
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAErC,kGAAkG;AAClG,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,kEAAkE;IAClE,EAAE,EAAE,MAAM,CAAA;IACV,yDAAyD;IACzD,IAAI,EAAE,CAAC,CAAA;CACR;AAED,+DAA+D;AAC/D,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,8BAA8B;IAC9B,KAAK,EAAE,SAAS,eAAe,CAAC,CAAC,CAAC,EAAE,CAAA;IACpC,6CAA6C;IAC7C,SAAS,EAAE,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAA;IAC/C,0DAA0D;IAC1D,UAAU,EAAE,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,KAAK,UAAU,CAAA;IACzE,mFAAmF;IACnF,YAAY,CAAC,EAAE,MAAM,UAAU,CAAA;IAC/B,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
package/dist/types.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Types for the Vue drag-handle reorder list.
3
+ *
4
+ * @module
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "@molecule/app-reorderable-list-vue",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.1.0",
4
+ "description": "Vertical drag-handle reorder list with onReorder callback (HTML5 drag — mouse/pointer only, no touch)",
5
+ "homepage": "https://www.molecule.dev/packages/app-reorderable-list-vue",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "dev": "vue-tsc --watch",
22
+ "test": "vitest run",
23
+ "test:watch": "vitest"
24
+ },
25
+ "keywords": [
26
+ "molecule",
27
+ "reorderable-list",
28
+ "vue"
29
+ ],
30
+ "author": "Molecule Dev, Inc. (https://molecule.dev)",
31
+ "license": "Apache-2.0",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/molecule-dev/molecule.git",
35
+ "directory": "packages/app/features/reorderable-list-vue"
36
+ },
37
+ "engines": {
38
+ "node": ">=20"
39
+ },
40
+ "bugs": "https://github.com/molecule-dev/molecule/issues",
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "peerDependencies": {
45
+ "@molecule/app-ui": "^1.0.1",
46
+ "@molecule/app-ui-vue": "^1.1.0",
47
+ "@molecule/app-vue": "^3.5.0",
48
+ "vue": "^3.5.0"
49
+ },
50
+ "devDependencies": {
51
+ "@molecule/app-framework-conformance": "0.0.0",
52
+ "@molecule/app-i18n": "1.2.2",
53
+ "@molecule/app-icons": "1.0.4",
54
+ "@molecule/app-ui": "1.5.0",
55
+ "@molecule/app-ui-vue": "1.2.1",
56
+ "@molecule/app-vue": "3.9.0",
57
+ "@types/node": "26.6.5",
58
+ "jsdom": "30.1.3",
59
+ "typescript": "6.0.3",
60
+ "vite": "8.3.5",
61
+ "vitest": "4.1.12",
62
+ "vue": "3.5.44",
63
+ "vue-tsc": "3.3.13"
64
+ }
65
+ }