cosey 0.4.18 → 0.4.19
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/hooks/useUpsert.d.ts +1 -1
- package/hooks/useUpsert.js +10 -8
- package/package.json +1 -1
package/hooks/useUpsert.d.ts
CHANGED
|
@@ -52,6 +52,6 @@ export interface UseExternalUpsertReturn<Row extends Record<string, any>, Data>
|
|
|
52
52
|
edit: (...args: any[]) => void;
|
|
53
53
|
setData: (data: Data) => void;
|
|
54
54
|
expose: Readonly<ShallowRef<UseUpsertExpose<Row, Data> | null>>;
|
|
55
|
-
ref:
|
|
55
|
+
ref: (_expose: any) => void;
|
|
56
56
|
}
|
|
57
57
|
export declare function useOuterUpsert<Row extends Record<string, any>, Data>(options: UseExternalUpsertOptions): UseExternalUpsertReturn<Row, Data>;
|
package/hooks/useUpsert.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ElMessage } from 'element-plus';
|
|
2
2
|
import { cloneDeep, pick } from 'lodash-es';
|
|
3
|
-
import {
|
|
3
|
+
import { ref, computed, unref, reactive, useTemplateRef, shallowRef, readonly } from 'vue';
|
|
4
4
|
import { toRefs } from '@vueuse/core';
|
|
5
|
-
import { uuid } from '../utils/string.js';
|
|
6
5
|
import { useLocale } from './useLocale.js';
|
|
6
|
+
import { uuid } from '../utils/string.js';
|
|
7
7
|
import { deepAssign } from '../utils/object.js';
|
|
8
8
|
|
|
9
9
|
const mapTypeTitle = {
|
|
@@ -112,8 +112,13 @@ function useUpsert(options) {
|
|
|
112
112
|
return result;
|
|
113
113
|
}
|
|
114
114
|
function useOuterUpsert(options) {
|
|
115
|
-
const
|
|
116
|
-
const
|
|
115
|
+
const expose = ref(null);
|
|
116
|
+
const vnodeRef = (_expose) => {
|
|
117
|
+
expose.value = _expose;
|
|
118
|
+
if (_expose) {
|
|
119
|
+
_expose.setOptions(options);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
117
122
|
const add = (...args) => {
|
|
118
123
|
expose.value?.add(...args);
|
|
119
124
|
};
|
|
@@ -123,15 +128,12 @@ function useOuterUpsert(options) {
|
|
|
123
128
|
const setData = (data) => {
|
|
124
129
|
expose.value?.setData(data);
|
|
125
130
|
};
|
|
126
|
-
onMounted(() => {
|
|
127
|
-
expose.value?.setOptions(options);
|
|
128
|
-
});
|
|
129
131
|
const result = {
|
|
130
132
|
add,
|
|
131
133
|
edit,
|
|
132
134
|
setData,
|
|
133
135
|
expose,
|
|
134
|
-
ref:
|
|
136
|
+
ref: vnodeRef
|
|
135
137
|
};
|
|
136
138
|
return result;
|
|
137
139
|
}
|