@naptics/vue-collection 0.1.5 → 0.1.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/components/NCrudModal.js
CHANGED
|
@@ -87,21 +87,22 @@ export default createComponentWithSlots('NCrudModal', nCrudModalProps, ['modal',
|
|
|
87
87
|
cancel
|
|
88
88
|
}) => _createVNode("div", {
|
|
89
89
|
"class": "flex justify-between"
|
|
90
|
-
}, [_createVNode("div", null, [_createVNode(NButton, {
|
|
90
|
+
}, [_createVNode("div", null, [!props.hideRemove && _createVNode(NButton, {
|
|
91
91
|
"color": props.removeColor,
|
|
92
92
|
"onClick": remove,
|
|
93
93
|
"disabled": props.removeDisabled
|
|
94
94
|
}, {
|
|
95
95
|
default: () => [props.removeText]
|
|
96
|
-
})]), _createVNode("div",
|
|
96
|
+
})]), _createVNode("div", {
|
|
97
|
+
"class": "flex justify-end space-x-2"
|
|
98
|
+
}, [!props.hideCancel && _createVNode(NButton, {
|
|
97
99
|
"color": props.cancelColor,
|
|
98
100
|
"onClick": cancel
|
|
99
101
|
}, {
|
|
100
102
|
default: () => [props.cancelText]
|
|
101
|
-
}), _createVNode(NButton, {
|
|
103
|
+
}), !props.hideOk && _createVNode(NButton, {
|
|
102
104
|
"color": props.okColor,
|
|
103
105
|
"onClick": ok,
|
|
104
|
-
"class": "ml-2",
|
|
105
106
|
"disabled": props.okDisabled
|
|
106
107
|
}, {
|
|
107
108
|
default: () => [props.okText]
|
package/components/NFormModal.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createVNode as _createVNode } from "vue";
|
|
2
2
|
import { createComponentWithSlots } from '../utils/component';
|
|
3
|
-
import {
|
|
3
|
+
import { computed } from 'vue';
|
|
4
4
|
import NForm from './NForm';
|
|
5
5
|
import NModal, { nModalProps } from './NModal';
|
|
6
6
|
export const nFormModalProps = {
|
|
@@ -34,8 +34,8 @@ export const nFormModalProps = {
|
|
|
34
34
|
export default createComponentWithSlots('NFormModal', nFormModalProps, ['modal', 'header', 'footer'], (props, {
|
|
35
35
|
slots
|
|
36
36
|
}) => {
|
|
37
|
-
const childProps =
|
|
38
|
-
...
|
|
37
|
+
const childProps = computed(() => ({
|
|
38
|
+
...props,
|
|
39
39
|
onOk: () => {
|
|
40
40
|
if (!props.form || props.form.validate().isValid) {
|
|
41
41
|
props.onOk?.();
|
|
@@ -43,8 +43,8 @@ export default createComponentWithSlots('NFormModal', nFormModalProps, ['modal',
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
closeOnOk: false
|
|
46
|
-
});
|
|
47
|
-
return () => _createVNode(NModal, childProps, {
|
|
46
|
+
}));
|
|
47
|
+
return () => _createVNode(NModal, childProps.value, {
|
|
48
48
|
default: () => [_createVNode(NForm, {
|
|
49
49
|
"form": props.form
|
|
50
50
|
}, {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@naptics/vue-collection",
|
|
3
3
|
"author": "Timo Siegenthaler",
|
|
4
4
|
"description": "Vue Collection is a collection of styled and fully functional Vue components which can easily be integrated into our projects.",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.7",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
package/utils/component.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createVNode as _createVNode, Fragment as _Fragment } from "vue";
|
|
2
|
-
import { defineComponent, reactive, toRef } from 'vue';
|
|
2
|
+
import { defineComponent, reactive, toRef, toRefs, ref } from 'vue';
|
|
3
3
|
/**
|
|
4
4
|
* Components should be created using this helper function.
|
|
5
5
|
* It only takes three arguments, the name and the props of the component and the setup function.
|
|
@@ -62,14 +62,15 @@ export function extractProps(props, ...keys) {
|
|
|
62
62
|
for (const key of keys) partial[key] = toRef(props, key);
|
|
63
63
|
return reactive(partial);
|
|
64
64
|
}
|
|
65
|
-
// operates on same reference of props to not break reactivity
|
|
66
65
|
function createSlotProps(props, slots, ...keys) {
|
|
67
|
-
|
|
66
|
+
// create refs, don't touch all props which are not slots
|
|
67
|
+
const newProps = toRefs(props);
|
|
68
68
|
keys.forEach(key => {
|
|
69
|
-
// if a slot is set once, it is basically always set. The changing content is not a problem.
|
|
69
|
+
// if a slot is set once, it is basically always set. The changing content is not a problem as it is inside the function.
|
|
70
70
|
const slot = slots[key];
|
|
71
|
+
// if the slot is set, overwrite the props
|
|
71
72
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
73
|
if (slot) newProps[key] = (...args) => _createVNode(_Fragment, null, [slot?.(...args)]);
|
|
73
74
|
});
|
|
74
|
-
return newProps;
|
|
75
|
+
return ref(newProps).value;
|
|
75
76
|
}
|