@naptics/vue-collection 0.1.5 → 0.1.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.
@@ -1,6 +1,6 @@
1
1
  import { createVNode as _createVNode } from "vue";
2
2
  import { createComponentWithSlots } from '../utils/component';
3
- import { reactive, toRefs } from 'vue';
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 = reactive({
38
- ...toRefs(props),
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",
5
+ "version": "0.1.6",
6
6
  "main": "./index.js",
7
7
  "repository": {
8
8
  "type": "git",
@@ -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
- const newProps = props;
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
  }