@sfxcode/nuxt-ui-formkit 1.0.5 → 1.0.6
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
|
@@ -2,20 +2,20 @@ import { createInput } from "@formkit/vue";
|
|
|
2
2
|
import { useFormKitSchema } from "../../composables/useFormKitSchema.js";
|
|
3
3
|
const { addList, addElement, addListGroup, addComponent } = useFormKitSchema();
|
|
4
4
|
function addButtonGroup(buttonGroupClass = "", buttonGroupItemClass = "", buttonSize, render = "true") {
|
|
5
|
-
const addActionButtonComponent = (onClick = "", icon = "", color = "", render2 = "true", disabled) => {
|
|
5
|
+
const addActionButtonComponent = (onClick = "", icon = "", color = "", render2 = "true", disabled = "false") => {
|
|
6
6
|
return addElement("div", [addComponent("UButton", { onClick, icon, color, disabled, size: buttonSize })], { class: buttonGroupItemClass }, render2);
|
|
7
7
|
};
|
|
8
8
|
return addElement("div", [
|
|
9
9
|
addActionButtonComponent("$moveNodeUp($node.parent, $index)", "i-lucide-arrow-up", "primary", "$renderMoveButtons", "$index === 0"),
|
|
10
|
-
addActionButtonComponent("$removeNode($node.parent, $index)", "i-lucide-trash", "error", "$displayDeleteButton"),
|
|
11
|
-
addActionButtonComponent("$cloneNode($node.parent, $index)", "i-lucide-copy", "secondary", "$displayCloneButton"),
|
|
12
|
-
addActionButtonComponent("$addNode($node.parent, $index)", "i-lucide-plus", "secondary", "$displayAddButton"),
|
|
10
|
+
addActionButtonComponent("$removeNode($node.parent, $index)", "i-lucide-trash", "error", "$displayDeleteButton", "$node.parent.value.length === $minItems"),
|
|
11
|
+
addActionButtonComponent("$cloneNode($node.parent, $index)", "i-lucide-copy", "secondary", "$displayCloneButton", "$node.parent.value.length > $maxItems -1"),
|
|
12
|
+
addActionButtonComponent("$addNode($node.parent, $index)", "i-lucide-plus", "secondary", "$displayAddButton", "$node.parent.value.length > $maxItems -1"),
|
|
13
13
|
addActionButtonComponent("$moveNodeDown($node.parent, $index)", "i-lucide-arrow-down", "primary", "$renderMoveButtons", "$index === $node.parent.value.length -1")
|
|
14
14
|
], { class: buttonGroupClass }, render);
|
|
15
15
|
}
|
|
16
16
|
function addInsertButton(label = "Add Item", icon = "i-lucide-plus", styleClass = "", buttonSize, render = "true") {
|
|
17
17
|
return addElement("div", [
|
|
18
|
-
addComponent("UButton", { onClick: "$insertNode($node)", label, icon, size: buttonSize })
|
|
18
|
+
addComponent("UButton", { onClick: "$insertNode($node)", label, icon, size: buttonSize, disabled: "$node.value.length > $maxItems -1" })
|
|
19
19
|
], { class: styleClass }, render);
|
|
20
20
|
}
|
|
21
21
|
export const nuxtUIRepeaterDefinition = createInput(
|
|
@@ -47,18 +47,20 @@ export const nuxtUIRepeaterDefinition = createInput(
|
|
|
47
47
|
"buttonSize",
|
|
48
48
|
"displayCloneButton",
|
|
49
49
|
"displayAddButton",
|
|
50
|
-
"displayDeleteButton"
|
|
50
|
+
"displayDeleteButton",
|
|
51
|
+
"minItems",
|
|
52
|
+
"maxItems"
|
|
51
53
|
],
|
|
52
54
|
features: [addRepeaterHandler]
|
|
53
55
|
}
|
|
54
56
|
);
|
|
55
57
|
function addRepeaterHandler(node) {
|
|
56
58
|
const swapElements = (array, index1, index2) => {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return
|
|
59
|
+
const [element] = array.splice(index1, 1);
|
|
60
|
+
if (element !== void 0) {
|
|
61
|
+
array.splice(index2, 0, element);
|
|
62
|
+
}
|
|
63
|
+
return array;
|
|
62
64
|
};
|
|
63
65
|
node.on("created", () => {
|
|
64
66
|
node.context.listName = node.name;
|
|
@@ -68,44 +70,47 @@ function addRepeaterHandler(node) {
|
|
|
68
70
|
node.context.renderMoveButtons = !node.context.hideMoveButtons;
|
|
69
71
|
node.context.internalListClass = node.context.listClass ? `formkit-items ${node.context.listClass}` : "formkit-items";
|
|
70
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;
|
|
71
75
|
node.context.insertNode = (parentNode) => () => {
|
|
72
|
-
if (parentNode && parentNode._value
|
|
76
|
+
if (parentNode && Array.isArray(parentNode._value)) {
|
|
73
77
|
const item = node.context.newItem ? { ...node.context.newItem } : {};
|
|
74
|
-
const
|
|
75
|
-
|
|
78
|
+
const array = parentNode.value;
|
|
79
|
+
array.push(item);
|
|
80
|
+
parentNode.input(array, false);
|
|
76
81
|
}
|
|
77
82
|
};
|
|
78
83
|
node.context.removeNode = (parentNode, index) => () => {
|
|
79
|
-
if (parentNode && parentNode._value
|
|
84
|
+
if (parentNode && Array.isArray(parentNode._value)) {
|
|
80
85
|
parentNode.input(parentNode._value.filter((_, i) => i !== index), false);
|
|
81
86
|
}
|
|
82
87
|
};
|
|
83
88
|
node.context.addNode = (parentNode, index) => () => {
|
|
84
|
-
if (parentNode && parentNode._value
|
|
89
|
+
if (parentNode && Array.isArray(parentNode._value)) {
|
|
90
|
+
const array = parentNode.value;
|
|
85
91
|
const item = node.context.newItem ? { ...node.context.newItem } : {};
|
|
86
|
-
|
|
87
|
-
parentNode.input(
|
|
92
|
+
array.splice(index + 1, 0, item);
|
|
93
|
+
parentNode.input(array, false);
|
|
88
94
|
}
|
|
89
95
|
};
|
|
90
96
|
node.context.cloneNode = (parentNode, index) => () => {
|
|
91
|
-
if (parentNode && parentNode._value
|
|
92
|
-
const item = parentNode.
|
|
93
|
-
const
|
|
94
|
-
|
|
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);
|
|
95
102
|
}
|
|
96
103
|
};
|
|
97
104
|
node.context.moveNodeUp = (parentNode, index) => () => {
|
|
98
|
-
if (parentNode && parentNode._value
|
|
99
|
-
const array = [...parentNode._value];
|
|
105
|
+
if (parentNode && Array.isArray(parentNode._value)) {
|
|
100
106
|
if (index > 0)
|
|
101
|
-
parentNode.input(swapElements(
|
|
107
|
+
parentNode.input(swapElements(parentNode.value, index - 1, index), false);
|
|
102
108
|
}
|
|
103
109
|
};
|
|
104
110
|
node.context.moveNodeDown = (parentNode, index) => () => {
|
|
105
|
-
if (parentNode && parentNode._value
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
parentNode.input(swapElements(array, index, index + 1), false);
|
|
111
|
+
if (parentNode && Array.isArray(parentNode._value)) {
|
|
112
|
+
if (index < parentNode.value.length - 1)
|
|
113
|
+
parentNode.input(swapElements(parentNode.value, index, index + 1), false);
|
|
109
114
|
}
|
|
110
115
|
};
|
|
111
116
|
});
|
|
@@ -2,20 +2,20 @@ import { createInput } from "@formkit/vue";
|
|
|
2
2
|
import { useFormKitSchema } from "../../composables/useFormKitSchema";
|
|
3
3
|
const { addList, addElement, addListGroup, addComponent } = useFormKitSchema();
|
|
4
4
|
function addButtonGroup(buttonGroupClass = "", buttonGroupItemClass = "", buttonSize, render = "true") {
|
|
5
|
-
const addActionButtonComponent = (onClick = "", icon = "", color = "", render2 = "true", disabled) => {
|
|
5
|
+
const addActionButtonComponent = (onClick = "", icon = "", color = "", render2 = "true", disabled = "false") => {
|
|
6
6
|
return addElement("div", [addComponent("UButton", { onClick, icon, color, disabled, size: buttonSize })], { class: buttonGroupItemClass }, render2);
|
|
7
7
|
};
|
|
8
8
|
return addElement("div", [
|
|
9
9
|
addActionButtonComponent("$moveNodeUp($node.parent, $index)", "i-lucide-arrow-up", "primary", "$renderMoveButtons", "$index === 0"),
|
|
10
|
-
addActionButtonComponent("$removeNode($node.parent, $index)", "i-lucide-trash", "error", "$displayDeleteButton"),
|
|
11
|
-
addActionButtonComponent("$cloneNode($node.parent, $index)", "i-lucide-copy", "secondary", "$displayCloneButton"),
|
|
12
|
-
addActionButtonComponent("$addNode($node.parent, $index)", "i-lucide-plus", "secondary", "$displayAddButton"),
|
|
10
|
+
addActionButtonComponent("$removeNode($node.parent, $index)", "i-lucide-trash", "error", "$displayDeleteButton", "$node.parent.value.length === $minItems"),
|
|
11
|
+
addActionButtonComponent("$cloneNode($node.parent, $index)", "i-lucide-copy", "secondary", "$displayCloneButton", "$node.parent.value.length > $maxItems -1"),
|
|
12
|
+
addActionButtonComponent("$addNode($node.parent, $index)", "i-lucide-plus", "secondary", "$displayAddButton", "$node.parent.value.length > $maxItems -1"),
|
|
13
13
|
addActionButtonComponent("$moveNodeDown($node.parent, $index)", "i-lucide-arrow-down", "primary", "$renderMoveButtons", "$index === $node.parent.value.length -1")
|
|
14
14
|
], { class: buttonGroupClass }, render);
|
|
15
15
|
}
|
|
16
16
|
function addInsertButton(label = "Add Item", icon = "i-lucide-plus", styleClass = "", buttonSize, render = "true") {
|
|
17
17
|
return addElement("div", [
|
|
18
|
-
addComponent("UButton", { onClick: "$insertNode($node)", label, icon, size: buttonSize })
|
|
18
|
+
addComponent("UButton", { onClick: "$insertNode($node)", label, icon, size: buttonSize, disabled: "$node.value.length > $maxItems -1" })
|
|
19
19
|
], { class: styleClass }, render);
|
|
20
20
|
}
|
|
21
21
|
export const nuxtUIRepeaterDefinition = createInput(
|
|
@@ -47,18 +47,20 @@ export const nuxtUIRepeaterDefinition = createInput(
|
|
|
47
47
|
"buttonSize",
|
|
48
48
|
"displayCloneButton",
|
|
49
49
|
"displayAddButton",
|
|
50
|
-
"displayDeleteButton"
|
|
50
|
+
"displayDeleteButton",
|
|
51
|
+
"minItems",
|
|
52
|
+
"maxItems"
|
|
51
53
|
],
|
|
52
54
|
features: [addRepeaterHandler]
|
|
53
55
|
}
|
|
54
56
|
);
|
|
55
57
|
function addRepeaterHandler(node) {
|
|
56
58
|
const swapElements = (array, index1, index2) => {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return
|
|
59
|
+
const [element] = array.splice(index1, 1);
|
|
60
|
+
if (element !== void 0) {
|
|
61
|
+
array.splice(index2, 0, element);
|
|
62
|
+
}
|
|
63
|
+
return array;
|
|
62
64
|
};
|
|
63
65
|
node.on("created", () => {
|
|
64
66
|
node.context.listName = node.name;
|
|
@@ -68,44 +70,47 @@ function addRepeaterHandler(node) {
|
|
|
68
70
|
node.context.renderMoveButtons = !node.context.hideMoveButtons;
|
|
69
71
|
node.context.internalListClass = node.context.listClass ? `formkit-items ${node.context.listClass}` : "formkit-items";
|
|
70
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;
|
|
71
75
|
node.context.insertNode = (parentNode) => () => {
|
|
72
|
-
if (parentNode && parentNode._value
|
|
76
|
+
if (parentNode && Array.isArray(parentNode._value)) {
|
|
73
77
|
const item = node.context.newItem ? { ...node.context.newItem } : {};
|
|
74
|
-
const
|
|
75
|
-
|
|
78
|
+
const array = parentNode.value;
|
|
79
|
+
array.push(item);
|
|
80
|
+
parentNode.input(array, false);
|
|
76
81
|
}
|
|
77
82
|
};
|
|
78
83
|
node.context.removeNode = (parentNode, index) => () => {
|
|
79
|
-
if (parentNode && parentNode._value
|
|
84
|
+
if (parentNode && Array.isArray(parentNode._value)) {
|
|
80
85
|
parentNode.input(parentNode._value.filter((_, i) => i !== index), false);
|
|
81
86
|
}
|
|
82
87
|
};
|
|
83
88
|
node.context.addNode = (parentNode, index) => () => {
|
|
84
|
-
if (parentNode && parentNode._value
|
|
89
|
+
if (parentNode && Array.isArray(parentNode._value)) {
|
|
90
|
+
const array = parentNode.value;
|
|
85
91
|
const item = node.context.newItem ? { ...node.context.newItem } : {};
|
|
86
|
-
|
|
87
|
-
parentNode.input(
|
|
92
|
+
array.splice(index + 1, 0, item);
|
|
93
|
+
parentNode.input(array, false);
|
|
88
94
|
}
|
|
89
95
|
};
|
|
90
96
|
node.context.cloneNode = (parentNode, index) => () => {
|
|
91
|
-
if (parentNode && parentNode._value
|
|
92
|
-
const item = parentNode.
|
|
93
|
-
const
|
|
94
|
-
|
|
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);
|
|
95
102
|
}
|
|
96
103
|
};
|
|
97
104
|
node.context.moveNodeUp = (parentNode, index) => () => {
|
|
98
|
-
if (parentNode && parentNode._value
|
|
99
|
-
const array = [...parentNode._value];
|
|
105
|
+
if (parentNode && Array.isArray(parentNode._value)) {
|
|
100
106
|
if (index > 0)
|
|
101
|
-
parentNode.input(swapElements(
|
|
107
|
+
parentNode.input(swapElements(parentNode.value, index - 1, index), false);
|
|
102
108
|
}
|
|
103
109
|
};
|
|
104
110
|
node.context.moveNodeDown = (parentNode, index) => () => {
|
|
105
|
-
if (parentNode && parentNode._value
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
parentNode.input(swapElements(array, index, index + 1), false);
|
|
111
|
+
if (parentNode && Array.isArray(parentNode._value)) {
|
|
112
|
+
if (index < parentNode.value.length - 1)
|
|
113
|
+
parentNode.input(swapElements(parentNode.value, index, index + 1), false);
|
|
109
114
|
}
|
|
110
115
|
};
|
|
111
116
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sfxcode/nuxt-ui-formkit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "FormKit integration for Nuxt UI - Seamlessly connect FormKit form handling with Nuxt UI components",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Tom",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"dependencies": {
|
|
91
91
|
"@formkit/addons": "^2.0.0",
|
|
92
92
|
"@formkit/nuxt": "^2.0.0",
|
|
93
|
-
"@nuxt/kit": "
|
|
93
|
+
"@nuxt/kit": "4.4.6",
|
|
94
94
|
"@nuxt/ui": "^4.8.2",
|
|
95
95
|
"@vue/compiler-dom": "^3.5.35"
|
|
96
96
|
},
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"@nuxt/devtools": "4.0.0-alpha.7",
|
|
102
102
|
"@nuxt/eslint-config": "^1.15.2",
|
|
103
103
|
"@nuxt/module-builder": "^1.0.2",
|
|
104
|
-
"@nuxt/schema": "
|
|
104
|
+
"@nuxt/schema": "4.4.6",
|
|
105
105
|
"@nuxt/test-utils": "^4.0.3",
|
|
106
106
|
"@types/node": "latest",
|
|
107
107
|
"@vitejs/plugin-vue": "^6.0.7",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"eslint": "^10.4.1",
|
|
110
110
|
"jsdom": "^29.1.1",
|
|
111
111
|
"mkdist": "^2.4.1",
|
|
112
|
-
"nuxt": "
|
|
112
|
+
"nuxt": "4.4.6",
|
|
113
113
|
"sass-embedded": "^1.100.0",
|
|
114
114
|
"typescript": "~6.0.3",
|
|
115
115
|
"unbuild": "^3.6.1",
|