@sfxcode/nuxt-ui-formkit 1.0.6 → 1.0.7

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/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=4.0.0"
6
6
  },
7
- "version": "1.0.6",
7
+ "version": "1.0.7",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -1,6 +1,6 @@
1
- declare var __VLS_7: {};
1
+ declare var __VLS_19: {};
2
2
  type __VLS_Slots = {} & {
3
- default?: (props: typeof __VLS_7) => any;
3
+ default?: (props: typeof __VLS_19) => any;
4
4
  };
5
5
  declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
6
6
  data: {
@@ -6,7 +6,7 @@ defineProps({
6
6
  },
7
7
  header: {
8
8
  type: String,
9
- default: "Debug"
9
+ default: "Debug Data"
10
10
  },
11
11
  textClass: {
12
12
  type: String,
@@ -18,15 +18,26 @@ defineProps({
18
18
  <template>
19
19
  <div class="formkit-debug">
20
20
  <client-only>
21
- <h3 class="text-lg font-semibold mb-2">
22
- {{ header }}
23
- </h3>
24
- <slot />
25
- <pre
26
- v-if="data"
27
- :class="textClass"
28
- >{{ data }}</pre>
29
- <span v-else>No Data available</span>
21
+ <UCollapsible class="flex flex-col gap-2">
22
+ <UButton
23
+ :label="header"
24
+ color="neutral"
25
+ variant="outline"
26
+ leading-icon="i-lucide-bug"
27
+ trailing-icon="i-lucide-chevron-down"
28
+ block
29
+ />
30
+ <template #content>
31
+ <div>
32
+ <slot />
33
+ </div>
34
+ <pre
35
+ v-if="data"
36
+ :class="textClass"
37
+ >{{ data }}</pre>
38
+ <span v-else>No Data available</span>
39
+ </template>
40
+ </UCollapsible>
30
41
  </client-only>
31
42
  </div>
32
43
  </template>
@@ -1,6 +1,6 @@
1
- declare var __VLS_7: {};
1
+ declare var __VLS_19: {};
2
2
  type __VLS_Slots = {} & {
3
- default?: (props: typeof __VLS_7) => any;
3
+ default?: (props: typeof __VLS_19) => any;
4
4
  };
5
5
  declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
6
6
  data: {
@@ -140,12 +140,12 @@ function handleReset() {
140
140
  <FUDataDebug
141
141
  v-if="debugData"
142
142
  :data="formData"
143
- header="Data"
143
+ header="Debug Data"
144
144
  />
145
145
  <FUDataDebug
146
146
  v-if="debugSchema"
147
147
  :data="formSchema"
148
- header="Schema"
148
+ header="Debug Schema"
149
149
  />
150
150
  </div>
151
151
  </template>
@@ -58,7 +58,7 @@ if (props.data) {
58
58
  <FuDataDebug
59
59
  v-if="debugData"
60
60
  :data="formData"
61
- header="Data"
61
+ header="Debug Data"
62
62
  />
63
63
  <FuDataDebug
64
64
  v-if="debugSchema"
@@ -18,19 +18,36 @@ function addInsertButton(label = "Add Item", icon = "i-lucide-plus", styleClass
18
18
  addComponent("UButton", { onClick: "$insertNode($node)", label, icon, size: buttonSize, disabled: "$node.value.length > $maxItems -1" })
19
19
  ], { class: styleClass }, render);
20
20
  }
21
+ function addDragHandle(handleClass = "", iconName = "", render = "true") {
22
+ return addElement("span", [
23
+ addComponent("UIcon", { name: iconName })
24
+ ], {
25
+ "class": handleClass,
26
+ "aria-label": "Drag to reorder"
27
+ }, render);
28
+ }
21
29
  export const nuxtUIRepeaterDefinition = createInput(
22
- addElement("ul", [
30
+ addElement("div", [
23
31
  addList("$listName", [
24
32
  addInsertButton("$insertButtonLabel", "i-lucide-plus", "$insertButtonClass", "$insertButtonSize", "$node.children.length == 0 || $alwaysDisplayInsertButton"),
25
33
  addListGroup([
26
- addElement(
27
- "li",
28
- [{ children: "$slots.default" }, addButtonGroup("$buttonGroupClass", "$buttonGroupItemClass", "$buttonSize", "$renderButtons")],
29
- { class: "$internalListItemClass" }
30
- )
34
+ addElement("div", [
35
+ addDragHandle("$internalDragHandleClass", "$dragHandleIconName", "$renderDragHandle"),
36
+ { children: "$slots.default" },
37
+ addButtonGroup("$buttonGroupClass", "$buttonGroupItemClass", "$buttonSize", "$renderButtons")
38
+ ], {
39
+ id: "$getListItemId($index)",
40
+ class: "$getListItemClass($index)",
41
+ draggable: "$draggable",
42
+ onDragstart: "$dragNodeStart($node.parent, $index)",
43
+ onDragover: "$dragNodeOver($index)",
44
+ onDragleave: "$dragNodeLeave($index)",
45
+ onDrop: "$dropNode($node.parent, $index)",
46
+ onDragend: "$dragNodeEnd"
47
+ })
31
48
  ], true, {})
32
49
  ], true, "true")
33
- ], { class: "$internalListClass" }, true),
50
+ ], { class: "$internalListClass", id: "$internalListId" }, true),
34
51
  {
35
52
  props: [
36
53
  "insertButtonLabel",
@@ -49,7 +66,11 @@ export const nuxtUIRepeaterDefinition = createInput(
49
66
  "displayAddButton",
50
67
  "displayDeleteButton",
51
68
  "minItems",
52
- "maxItems"
69
+ "maxItems",
70
+ "draggable",
71
+ "displayDragHandle",
72
+ "dragHandleClass",
73
+ "dragHandleIconName"
53
74
  ],
54
75
  features: [addRepeaterHandler]
55
76
  }
@@ -62,56 +83,113 @@ function addRepeaterHandler(node) {
62
83
  }
63
84
  return array;
64
85
  };
86
+ const uuid = typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : Math.random().toString(36).slice(2);
65
87
  node.on("created", () => {
66
- node.context.listName = node.name;
67
- node.context.renderButtons = !node.context.hideButtonGroup;
68
- node.context.insertButtonSize = node.context.insertButtonSize ? node.context.insertButtonSize : "md";
69
- node.context.buttonSize = node.context.buttonSize ? node.context.buttonSize : "md";
70
- node.context.renderMoveButtons = !node.context.hideMoveButtons;
71
- node.context.internalListClass = node.context.listClass ? `formkit-items ${node.context.listClass}` : "formkit-items";
72
- node.context.internalListItemClass = node.context.listItemClass ? `formkit-item ${node.context.listItemClass}` : "formkit-item";
73
- node.context.minItems = node.context.minItems !== void 0 ? node.context.minItems : 0;
74
- node.context.maxItems = node.context.maxItems !== void 0 ? node.context.maxItems : Number.POSITIVE_INFINITY;
75
- node.context.insertNode = (parentNode) => () => {
76
- if (parentNode && Array.isArray(parentNode._value)) {
77
- const item = node.context.newItem ? { ...node.context.newItem } : {};
78
- const array = parentNode.value;
79
- array.push(item);
80
- parentNode.input(array, false);
81
- }
82
- };
83
- node.context.removeNode = (parentNode, index) => () => {
84
- if (parentNode && Array.isArray(parentNode._value)) {
85
- parentNode.input(parentNode._value.filter((_, i) => i !== index), false);
86
- }
87
- };
88
- node.context.addNode = (parentNode, index) => () => {
89
- if (parentNode && Array.isArray(parentNode._value)) {
90
- const array = parentNode.value;
91
- const item = node.context.newItem ? { ...node.context.newItem } : {};
92
- array.splice(index + 1, 0, item);
93
- parentNode.input(array, false);
94
- }
95
- };
96
- node.context.cloneNode = (parentNode, index) => () => {
97
- if (parentNode && Array.isArray(parentNode._value)) {
98
- const item = parentNode.value[index];
99
- const array = parentNode.value;
100
- array.splice(index + 1, 0, item);
101
- parentNode.input(array, false);
102
- }
103
- };
104
- node.context.moveNodeUp = (parentNode, index) => () => {
105
- if (parentNode && Array.isArray(parentNode._value)) {
106
- if (index > 0)
107
- parentNode.input(swapElements(parentNode.value, index - 1, index), false);
108
- }
109
- };
110
- node.context.moveNodeDown = (parentNode, index) => () => {
111
- if (parentNode && Array.isArray(parentNode._value)) {
112
- if (index < parentNode.value.length - 1)
113
- parentNode.input(swapElements(parentNode.value, index, index + 1), false);
114
- }
115
- };
88
+ if (node.context) {
89
+ let dragStartIndex = null;
90
+ let dragOverIndex = null;
91
+ const newItem = node.context.newItem || {};
92
+ node.context.listName = node.name;
93
+ node.context.renderButtons = !node.context.hideButtonGroup;
94
+ node.context.insertButtonSize = node.context.insertButtonSize ? node.context.insertButtonSize : "md";
95
+ node.context.buttonSize = node.context.buttonSize ? node.context.buttonSize : "md";
96
+ node.context.renderMoveButtons = !node.context.hideMoveButtons;
97
+ node.context.draggable = !!node.context.draggable;
98
+ node.context.renderDragHandle = !!node.context.displayDragHandle;
99
+ node.context.dragHandleIconName = node.context.dragHandleIconName || "i-lucide-grip-vertical";
100
+ node.context.internalDragHandleClass = node.context.dragHandleClass ? `formkit-repeater-drag-handle ${node.context.dragHandleClass}` : "formkit-repeater-drag-handle";
101
+ node.context.internalListClass = node.context.listClass ? `formkit-items ${node.context.listClass}` : "formkit-items";
102
+ node.context.internalListItemClass = node.context.listItemClass ? `formkit-item ${node.context.listItemClass}` : "formkit-item";
103
+ node.context.internalListId = `formkit-items-${uuid}`;
104
+ node.context.minItems = node.context.minItems !== void 0 ? node.context.minItems : 0;
105
+ node.context.maxItems = node.context.maxItems !== void 0 ? node.context.maxItems : Number.POSITIVE_INFINITY;
106
+ node.context.getListItemClass = (index) => {
107
+ if (dragOverIndex === index && dragStartIndex !== index)
108
+ return `${node.context?.internalListItemClass} formkit-repeater-drop-target`;
109
+ return node.context?.internalListItemClass?.toString() ?? "";
110
+ };
111
+ node.context.getListItemId = (index) => {
112
+ return `formkit-item-${index}-${uuid}`;
113
+ };
114
+ node.context.insertNode = (parentNode) => () => {
115
+ if (parentNode && Array.isArray(parentNode._value)) {
116
+ const newArray = [{ ...newItem }, ...parentNode.value];
117
+ parentNode.input(newArray, false);
118
+ }
119
+ };
120
+ node.context.removeNode = (parentNode, index) => () => {
121
+ if (parentNode && Array.isArray(parentNode._value)) {
122
+ parentNode.input(parentNode._value.filter((_, i) => i !== index), false);
123
+ }
124
+ };
125
+ node.context.addNode = (parentNode, index) => () => {
126
+ if (parentNode && Array.isArray(parentNode._value)) {
127
+ const array = parentNode.value;
128
+ array.splice(index + 1, 0, { ...newItem });
129
+ parentNode.input(array, false);
130
+ }
131
+ };
132
+ node.context.cloneNode = (parentNode, index) => () => {
133
+ if (parentNode && Array.isArray(parentNode._value)) {
134
+ const item = parentNode.value[index];
135
+ const array = parentNode.value;
136
+ array.splice(index + 1, 0, { ...item });
137
+ parentNode.input(array, false);
138
+ }
139
+ };
140
+ node.context.moveNodeUp = (parentNode, index) => () => {
141
+ if (parentNode && Array.isArray(parentNode._value)) {
142
+ if (index > 0)
143
+ parentNode.input(swapElements(parentNode.value, index - 1, index), false);
144
+ }
145
+ };
146
+ node.context.moveNodeDown = (parentNode, index) => () => {
147
+ if (parentNode && Array.isArray(parentNode._value)) {
148
+ if (index < parentNode.value.length - 1)
149
+ parentNode.input(swapElements(parentNode.value, index, index + 1), false);
150
+ }
151
+ };
152
+ node.context.dragNodeStart = (_parentNode, index) => (event) => {
153
+ dragStartIndex = index;
154
+ if (event?.dataTransfer) {
155
+ event.dataTransfer.effectAllowed = "move";
156
+ event.dataTransfer.setData("text/plain", String(index));
157
+ }
158
+ };
159
+ node.context.dragNodeOver = (targetIndex) => (event) => {
160
+ event?.preventDefault();
161
+ dragOverIndex = targetIndex;
162
+ if (event?.dataTransfer)
163
+ event.dataTransfer.dropEffect = "move";
164
+ };
165
+ node.context.dragNodeLeave = (targetIndex) => () => {
166
+ if (dragOverIndex === targetIndex)
167
+ dragOverIndex = null;
168
+ };
169
+ node.context.dropNode = (parentNode, targetIndex) => (event) => {
170
+ event?.preventDefault();
171
+ if (!parentNode || !Array.isArray(parentNode._value)) {
172
+ dragOverIndex = null;
173
+ return;
174
+ }
175
+ const sourceFromEvent = Number.parseInt(event?.dataTransfer?.getData("text/plain") || "", 10);
176
+ const sourceIndex = Number.isInteger(sourceFromEvent) ? sourceFromEvent : dragStartIndex;
177
+ if (sourceIndex === null || sourceIndex === targetIndex) {
178
+ dragOverIndex = null;
179
+ return;
180
+ }
181
+ if (sourceIndex < 0 || sourceIndex >= parentNode.value.length) {
182
+ dragOverIndex = null;
183
+ return;
184
+ }
185
+ parentNode.input(swapElements(parentNode.value, sourceIndex, targetIndex), false);
186
+ dragStartIndex = null;
187
+ dragOverIndex = null;
188
+ };
189
+ node.context.dragNodeEnd = () => {
190
+ dragStartIndex = null;
191
+ dragOverIndex = null;
192
+ };
193
+ }
116
194
  });
117
195
  }
@@ -18,19 +18,36 @@ function addInsertButton(label = "Add Item", icon = "i-lucide-plus", styleClass
18
18
  addComponent("UButton", { onClick: "$insertNode($node)", label, icon, size: buttonSize, disabled: "$node.value.length > $maxItems -1" })
19
19
  ], { class: styleClass }, render);
20
20
  }
21
+ function addDragHandle(handleClass = "", iconName = "", render = "true") {
22
+ return addElement("span", [
23
+ addComponent("UIcon", { name: iconName })
24
+ ], {
25
+ "class": handleClass,
26
+ "aria-label": "Drag to reorder"
27
+ }, render);
28
+ }
21
29
  export const nuxtUIRepeaterDefinition = createInput(
22
- addElement("ul", [
30
+ addElement("div", [
23
31
  addList("$listName", [
24
32
  addInsertButton("$insertButtonLabel", "i-lucide-plus", "$insertButtonClass", "$insertButtonSize", "$node.children.length == 0 || $alwaysDisplayInsertButton"),
25
33
  addListGroup([
26
- addElement(
27
- "li",
28
- [{ children: "$slots.default" }, addButtonGroup("$buttonGroupClass", "$buttonGroupItemClass", "$buttonSize", "$renderButtons")],
29
- { class: "$internalListItemClass" }
30
- )
34
+ addElement("div", [
35
+ addDragHandle("$internalDragHandleClass", "$dragHandleIconName", "$renderDragHandle"),
36
+ { children: "$slots.default" },
37
+ addButtonGroup("$buttonGroupClass", "$buttonGroupItemClass", "$buttonSize", "$renderButtons")
38
+ ], {
39
+ id: "$getListItemId($index)",
40
+ class: "$getListItemClass($index)",
41
+ draggable: "$draggable",
42
+ onDragstart: "$dragNodeStart($node.parent, $index)",
43
+ onDragover: "$dragNodeOver($index)",
44
+ onDragleave: "$dragNodeLeave($index)",
45
+ onDrop: "$dropNode($node.parent, $index)",
46
+ onDragend: "$dragNodeEnd"
47
+ })
31
48
  ], true, {})
32
49
  ], true, "true")
33
- ], { class: "$internalListClass" }, true),
50
+ ], { class: "$internalListClass", id: "$internalListId" }, true),
34
51
  {
35
52
  props: [
36
53
  "insertButtonLabel",
@@ -49,7 +66,11 @@ export const nuxtUIRepeaterDefinition = createInput(
49
66
  "displayAddButton",
50
67
  "displayDeleteButton",
51
68
  "minItems",
52
- "maxItems"
69
+ "maxItems",
70
+ "draggable",
71
+ "displayDragHandle",
72
+ "dragHandleClass",
73
+ "dragHandleIconName"
53
74
  ],
54
75
  features: [addRepeaterHandler]
55
76
  }
@@ -62,56 +83,113 @@ function addRepeaterHandler(node) {
62
83
  }
63
84
  return array;
64
85
  };
86
+ const uuid = typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : Math.random().toString(36).slice(2);
65
87
  node.on("created", () => {
66
- node.context.listName = node.name;
67
- node.context.renderButtons = !node.context.hideButtonGroup;
68
- node.context.insertButtonSize = node.context.insertButtonSize ? node.context.insertButtonSize : "md";
69
- node.context.buttonSize = node.context.buttonSize ? node.context.buttonSize : "md";
70
- node.context.renderMoveButtons = !node.context.hideMoveButtons;
71
- node.context.internalListClass = node.context.listClass ? `formkit-items ${node.context.listClass}` : "formkit-items";
72
- node.context.internalListItemClass = node.context.listItemClass ? `formkit-item ${node.context.listItemClass}` : "formkit-item";
73
- node.context.minItems = node.context.minItems !== void 0 ? node.context.minItems : 0;
74
- node.context.maxItems = node.context.maxItems !== void 0 ? node.context.maxItems : Number.POSITIVE_INFINITY;
75
- node.context.insertNode = (parentNode) => () => {
76
- if (parentNode && Array.isArray(parentNode._value)) {
77
- const item = node.context.newItem ? { ...node.context.newItem } : {};
78
- const array = parentNode.value;
79
- array.push(item);
80
- parentNode.input(array, false);
81
- }
82
- };
83
- node.context.removeNode = (parentNode, index) => () => {
84
- if (parentNode && Array.isArray(parentNode._value)) {
85
- parentNode.input(parentNode._value.filter((_, i) => i !== index), false);
86
- }
87
- };
88
- node.context.addNode = (parentNode, index) => () => {
89
- if (parentNode && Array.isArray(parentNode._value)) {
90
- const array = parentNode.value;
91
- const item = node.context.newItem ? { ...node.context.newItem } : {};
92
- array.splice(index + 1, 0, item);
93
- parentNode.input(array, false);
94
- }
95
- };
96
- node.context.cloneNode = (parentNode, index) => () => {
97
- if (parentNode && Array.isArray(parentNode._value)) {
98
- const item = parentNode.value[index];
99
- const array = parentNode.value;
100
- array.splice(index + 1, 0, item);
101
- parentNode.input(array, false);
102
- }
103
- };
104
- node.context.moveNodeUp = (parentNode, index) => () => {
105
- if (parentNode && Array.isArray(parentNode._value)) {
106
- if (index > 0)
107
- parentNode.input(swapElements(parentNode.value, index - 1, index), false);
108
- }
109
- };
110
- node.context.moveNodeDown = (parentNode, index) => () => {
111
- if (parentNode && Array.isArray(parentNode._value)) {
112
- if (index < parentNode.value.length - 1)
113
- parentNode.input(swapElements(parentNode.value, index, index + 1), false);
114
- }
115
- };
88
+ if (node.context) {
89
+ let dragStartIndex = null;
90
+ let dragOverIndex = null;
91
+ const newItem = node.context.newItem || {};
92
+ node.context.listName = node.name;
93
+ node.context.renderButtons = !node.context.hideButtonGroup;
94
+ node.context.insertButtonSize = node.context.insertButtonSize ? node.context.insertButtonSize : "md";
95
+ node.context.buttonSize = node.context.buttonSize ? node.context.buttonSize : "md";
96
+ node.context.renderMoveButtons = !node.context.hideMoveButtons;
97
+ node.context.draggable = !!node.context.draggable;
98
+ node.context.renderDragHandle = !!node.context.displayDragHandle;
99
+ node.context.dragHandleIconName = node.context.dragHandleIconName || "i-lucide-grip-vertical";
100
+ node.context.internalDragHandleClass = node.context.dragHandleClass ? `formkit-repeater-drag-handle ${node.context.dragHandleClass}` : "formkit-repeater-drag-handle";
101
+ node.context.internalListClass = node.context.listClass ? `formkit-items ${node.context.listClass}` : "formkit-items";
102
+ node.context.internalListItemClass = node.context.listItemClass ? `formkit-item ${node.context.listItemClass}` : "formkit-item";
103
+ node.context.internalListId = `formkit-items-${uuid}`;
104
+ node.context.minItems = node.context.minItems !== void 0 ? node.context.minItems : 0;
105
+ node.context.maxItems = node.context.maxItems !== void 0 ? node.context.maxItems : Number.POSITIVE_INFINITY;
106
+ node.context.getListItemClass = (index) => {
107
+ if (dragOverIndex === index && dragStartIndex !== index)
108
+ return `${node.context?.internalListItemClass} formkit-repeater-drop-target`;
109
+ return node.context?.internalListItemClass?.toString() ?? "";
110
+ };
111
+ node.context.getListItemId = (index) => {
112
+ return `formkit-item-${index}-${uuid}`;
113
+ };
114
+ node.context.insertNode = (parentNode) => () => {
115
+ if (parentNode && Array.isArray(parentNode._value)) {
116
+ const newArray = [{ ...newItem }, ...parentNode.value];
117
+ parentNode.input(newArray, false);
118
+ }
119
+ };
120
+ node.context.removeNode = (parentNode, index) => () => {
121
+ if (parentNode && Array.isArray(parentNode._value)) {
122
+ parentNode.input(parentNode._value.filter((_, i) => i !== index), false);
123
+ }
124
+ };
125
+ node.context.addNode = (parentNode, index) => () => {
126
+ if (parentNode && Array.isArray(parentNode._value)) {
127
+ const array = parentNode.value;
128
+ array.splice(index + 1, 0, { ...newItem });
129
+ parentNode.input(array, false);
130
+ }
131
+ };
132
+ node.context.cloneNode = (parentNode, index) => () => {
133
+ if (parentNode && Array.isArray(parentNode._value)) {
134
+ const item = parentNode.value[index];
135
+ const array = parentNode.value;
136
+ array.splice(index + 1, 0, { ...item });
137
+ parentNode.input(array, false);
138
+ }
139
+ };
140
+ node.context.moveNodeUp = (parentNode, index) => () => {
141
+ if (parentNode && Array.isArray(parentNode._value)) {
142
+ if (index > 0)
143
+ parentNode.input(swapElements(parentNode.value, index - 1, index), false);
144
+ }
145
+ };
146
+ node.context.moveNodeDown = (parentNode, index) => () => {
147
+ if (parentNode && Array.isArray(parentNode._value)) {
148
+ if (index < parentNode.value.length - 1)
149
+ parentNode.input(swapElements(parentNode.value, index, index + 1), false);
150
+ }
151
+ };
152
+ node.context.dragNodeStart = (_parentNode, index) => (event) => {
153
+ dragStartIndex = index;
154
+ if (event?.dataTransfer) {
155
+ event.dataTransfer.effectAllowed = "move";
156
+ event.dataTransfer.setData("text/plain", String(index));
157
+ }
158
+ };
159
+ node.context.dragNodeOver = (targetIndex) => (event) => {
160
+ event?.preventDefault();
161
+ dragOverIndex = targetIndex;
162
+ if (event?.dataTransfer)
163
+ event.dataTransfer.dropEffect = "move";
164
+ };
165
+ node.context.dragNodeLeave = (targetIndex) => () => {
166
+ if (dragOverIndex === targetIndex)
167
+ dragOverIndex = null;
168
+ };
169
+ node.context.dropNode = (parentNode, targetIndex) => (event) => {
170
+ event?.preventDefault();
171
+ if (!parentNode || !Array.isArray(parentNode._value)) {
172
+ dragOverIndex = null;
173
+ return;
174
+ }
175
+ const sourceFromEvent = Number.parseInt(event?.dataTransfer?.getData("text/plain") || "", 10);
176
+ const sourceIndex = Number.isInteger(sourceFromEvent) ? sourceFromEvent : dragStartIndex;
177
+ if (sourceIndex === null || sourceIndex === targetIndex) {
178
+ dragOverIndex = null;
179
+ return;
180
+ }
181
+ if (sourceIndex < 0 || sourceIndex >= parentNode.value.length) {
182
+ dragOverIndex = null;
183
+ return;
184
+ }
185
+ parentNode.input(swapElements(parentNode.value, sourceIndex, targetIndex), false);
186
+ dragStartIndex = null;
187
+ dragOverIndex = null;
188
+ };
189
+ node.context.dragNodeEnd = () => {
190
+ dragStartIndex = null;
191
+ dragOverIndex = null;
192
+ };
193
+ }
116
194
  });
117
195
  }
@@ -1,3 +1,6 @@
1
1
  import { defineNuxtPlugin } from "#app";
2
+ import { UButton, UIcon } from "#components";
2
3
  export default defineNuxtPlugin((_nuxtApp) => {
4
+ _nuxtApp.vueApp.component("UButton", UButton);
5
+ _nuxtApp.vueApp.component("UIcon", UIcon);
3
6
  });
@@ -3,7 +3,7 @@ export declare function useFormKitInput(context: FormKitFrameworkContext): {
3
3
  isInvalid: import("vue").ComputedRef<any>;
4
4
  validSlotNames: import("vue").ComputedRef<string[]>;
5
5
  styleClass: import("vue").ComputedRef<string>;
6
- color: import("vue").ComputedRef<"primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral">;
6
+ color: import("vue").ComputedRef<"neutral" | "primary" | "secondary" | "success" | "info" | "warning" | "error">;
7
7
  handleBlur: (event: FocusEvent) => void;
8
8
  handleChange: (_: unknown) => void;
9
9
  handleInput: (_: unknown) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfxcode/nuxt-ui-formkit",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "FormKit integration for Nuxt UI - Seamlessly connect FormKit form handling with Nuxt UI components",
5
5
  "author": {
6
6
  "name": "Tom",