@razaman2/reactive-view 0.0.34-beta.1 → 0.0.34-beta.3
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/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +21 -15
- package/dist/index.mjs +21 -15
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -53,7 +53,9 @@ declare const _default: {
|
|
|
53
53
|
notifications: ObjectConstructor;
|
|
54
54
|
subscriptions: ObjectConstructor;
|
|
55
55
|
beforeSetData: FunctionConstructor;
|
|
56
|
-
data: {
|
|
56
|
+
data: {
|
|
57
|
+
default: () => {};
|
|
58
|
+
};
|
|
57
59
|
defaultData: {};
|
|
58
60
|
getDefaultData: {
|
|
59
61
|
type: FunctionConstructor;
|
package/dist/index.d.ts
CHANGED
|
@@ -53,7 +53,9 @@ declare const _default: {
|
|
|
53
53
|
notifications: ObjectConstructor;
|
|
54
54
|
subscriptions: ObjectConstructor;
|
|
55
55
|
beforeSetData: FunctionConstructor;
|
|
56
|
-
data: {
|
|
56
|
+
data: {
|
|
57
|
+
default: () => {};
|
|
58
|
+
};
|
|
57
59
|
defaultData: {};
|
|
58
60
|
getDefaultData: {
|
|
59
61
|
type: FunctionConstructor;
|
package/dist/index.js
CHANGED
|
@@ -168,7 +168,7 @@ var import_vue = require("vue");
|
|
|
168
168
|
|
|
169
169
|
// package.json
|
|
170
170
|
var name = "@razaman2/reactive-view";
|
|
171
|
-
var version = "0.0.34-beta.
|
|
171
|
+
var version = "0.0.34-beta.3";
|
|
172
172
|
|
|
173
173
|
// src/ReactiveView.ts
|
|
174
174
|
var setup = {
|
|
@@ -189,7 +189,9 @@ var ReactiveView_default = {
|
|
|
189
189
|
notifications: Object,
|
|
190
190
|
subscriptions: Object,
|
|
191
191
|
beforeSetData: Function,
|
|
192
|
-
data: {
|
|
192
|
+
data: {
|
|
193
|
+
default: () => ({})
|
|
194
|
+
},
|
|
193
195
|
defaultData: {},
|
|
194
196
|
getDefaultData: {
|
|
195
197
|
type: Function,
|
|
@@ -212,7 +214,7 @@ var ReactiveView_default = {
|
|
|
212
214
|
}
|
|
213
215
|
},
|
|
214
216
|
setup(props, context) {
|
|
215
|
-
var _a, _b, _c, _d, _e, _f
|
|
217
|
+
var _a, _b, _c, _d, _e, _f;
|
|
216
218
|
const template = (component2, vue2) => {
|
|
217
219
|
return (0, import_vue.createVNode)(
|
|
218
220
|
"div",
|
|
@@ -224,24 +226,21 @@ var ReactiveView_default = {
|
|
|
224
226
|
};
|
|
225
227
|
const isValid = (0, import_vue.ref)(false);
|
|
226
228
|
const isReady = (0, import_vue.ref)(false);
|
|
227
|
-
const isFunctionData = ["Function"].includes(
|
|
228
|
-
const isAsyncFunctionData = ["AsyncFunction"].includes(
|
|
229
|
-
const isPromiseData = ["Promise"].includes(
|
|
229
|
+
const isFunctionData = ["Function"].includes(props.data.constructor.name);
|
|
230
|
+
const isAsyncFunctionData = ["AsyncFunction"].includes(props.data.constructor.name);
|
|
231
|
+
const isPromiseData = ["Promise"].includes(props.data.constructor.name) || isAsyncFunctionData;
|
|
230
232
|
const defer = (0, import_vue.ref)(typeof props.defer === "function" ? props.defer() : props.defer);
|
|
231
233
|
const vue = (0, import_vue.getCurrentInstance)();
|
|
232
|
-
if (props.debug) {
|
|
233
|
-
console.log("[ReactiveView]:", { props, context, vue, defer, data: props.data, isValid, isReady, isFunctionData, isAsyncFunctionData, isPromiseData });
|
|
234
|
-
}
|
|
235
234
|
if ((isPromiseData || isFunctionData) && !("defaultData" in vue.vnode.props)) {
|
|
236
235
|
console.error("[ReactiveView]: defaultData is required for promise or async function data.");
|
|
237
236
|
}
|
|
238
237
|
const defaultData = props.getDefaultData(
|
|
239
|
-
((
|
|
238
|
+
((_a = vue.vnode.props) == null ? void 0 : _a.hasOwnProperty("defaultData")) ? vue.vnode.props.defaultData : ((_b = vue.vnode.props) == null ? void 0 : _b.hasOwnProperty("data")) ? Array.isArray(vue.vnode.props.data) ? [] : {} : {}
|
|
240
239
|
);
|
|
241
240
|
const datatype = Array.isArray(defaultData) ? [] : {};
|
|
242
241
|
const config = {
|
|
243
242
|
data: (0, import_vue.reactive)(import_object_manager.default.on(
|
|
244
|
-
isPromiseData || isFunctionData || (0, import_vue.isRef)(props.data) || (0, import_vue.isReactive)(props.data) ? datatype : ((
|
|
243
|
+
isPromiseData || isFunctionData || (0, import_vue.isRef)(props.data) || (0, import_vue.isReactive)(props.data) ? datatype : ((_c = vue.vnode.props) == null ? void 0 : _c.hasOwnProperty("data")) ? props.data : datatype
|
|
245
244
|
).clone()),
|
|
246
245
|
defaultData: import_object_manager.default.on(defaultData).clone(),
|
|
247
246
|
notifications: props.notifications,
|
|
@@ -256,9 +255,11 @@ var ReactiveView_default = {
|
|
|
256
255
|
var _a2;
|
|
257
256
|
const beforeSetData = (_a2 = access(component).beforeSetData) != null ? _a2 : props.beforeSetData;
|
|
258
257
|
if (typeof beforeSetData === "function") {
|
|
259
|
-
const after = import_object_manager.default.on(datatype).set(...params.length ? params : [defaultData]).get();
|
|
260
258
|
const before = target.getData();
|
|
261
|
-
|
|
259
|
+
const after = (params.length ? import_object_manager.default.on(datatype).set(...params) : import_object_manager.default.on(datatype).set(defaultData)).get();
|
|
260
|
+
if (beforeSetData({ before, after }, target)) {
|
|
261
|
+
target[key](...params);
|
|
262
|
+
}
|
|
262
263
|
} else {
|
|
263
264
|
target[key](...params);
|
|
264
265
|
}
|
|
@@ -270,6 +271,9 @@ var ReactiveView_default = {
|
|
|
270
271
|
}
|
|
271
272
|
});
|
|
272
273
|
const component = (0, import_vue.ref)({ parent: { self: vue.proxy }, self: { template, model, isValid } });
|
|
274
|
+
if (props.debug) {
|
|
275
|
+
console.log("[ReactiveView]:", { props, context, vue, defer, config, model, component, datatype, defaultData, isValid, isReady, isFunctionData, isAsyncFunctionData, isPromiseData });
|
|
276
|
+
}
|
|
273
277
|
const watchDataProp = (dataProp) => {
|
|
274
278
|
var _a2, _b2, _c2;
|
|
275
279
|
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? { callback: context.attrs["onUpdate:data"] } : {
|
|
@@ -292,8 +296,10 @@ var ReactiveView_default = {
|
|
|
292
296
|
if (context.attrs["onUpdate:model"] || context.attrs["update:model"]) {
|
|
293
297
|
const config2 = typeof context.attrs["onUpdate:model"] === "function" ? {
|
|
294
298
|
callback: context.attrs["onUpdate:model"],
|
|
295
|
-
options: Object.assign(__spreadValues(__spreadValues(
|
|
296
|
-
|
|
299
|
+
options: Object.assign(__spreadValues(__spreadValues({
|
|
300
|
+
deep: (_d = context.attrs["model:deep"]) != null ? _d : true
|
|
301
|
+
}, context.attrs["model:immediate"] ? { immediate: context.attrs["model:immediate"] } : {}), context.attrs["model:once"] ? { once: context.attrs["model:once"] } : {}), ((_e = context.attrs["onUpdate:model"]) != null ? _e : {}).options)
|
|
302
|
+
} : (_f = context.attrs["onUpdate:model"]) != null ? _f : {};
|
|
297
303
|
if (context.attrs["model:log"]) {
|
|
298
304
|
console.log(`[ReactiveView]:model`, { config: config2 });
|
|
299
305
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -125,7 +125,7 @@ import { ref, reactive, watch, isRef, isReactive, createVNode, getCurrentInstanc
|
|
|
125
125
|
|
|
126
126
|
// package.json
|
|
127
127
|
var name = "@razaman2/reactive-view";
|
|
128
|
-
var version = "0.0.34-beta.
|
|
128
|
+
var version = "0.0.34-beta.3";
|
|
129
129
|
|
|
130
130
|
// src/ReactiveView.ts
|
|
131
131
|
var setup = {
|
|
@@ -146,7 +146,9 @@ var ReactiveView_default = {
|
|
|
146
146
|
notifications: Object,
|
|
147
147
|
subscriptions: Object,
|
|
148
148
|
beforeSetData: Function,
|
|
149
|
-
data: {
|
|
149
|
+
data: {
|
|
150
|
+
default: () => ({})
|
|
151
|
+
},
|
|
150
152
|
defaultData: {},
|
|
151
153
|
getDefaultData: {
|
|
152
154
|
type: Function,
|
|
@@ -169,7 +171,7 @@ var ReactiveView_default = {
|
|
|
169
171
|
}
|
|
170
172
|
},
|
|
171
173
|
setup(props, context) {
|
|
172
|
-
var _a, _b, _c, _d, _e, _f
|
|
174
|
+
var _a, _b, _c, _d, _e, _f;
|
|
173
175
|
const template = (component2, vue2) => {
|
|
174
176
|
return createVNode(
|
|
175
177
|
"div",
|
|
@@ -181,24 +183,21 @@ var ReactiveView_default = {
|
|
|
181
183
|
};
|
|
182
184
|
const isValid = ref(false);
|
|
183
185
|
const isReady = ref(false);
|
|
184
|
-
const isFunctionData = ["Function"].includes(
|
|
185
|
-
const isAsyncFunctionData = ["AsyncFunction"].includes(
|
|
186
|
-
const isPromiseData = ["Promise"].includes(
|
|
186
|
+
const isFunctionData = ["Function"].includes(props.data.constructor.name);
|
|
187
|
+
const isAsyncFunctionData = ["AsyncFunction"].includes(props.data.constructor.name);
|
|
188
|
+
const isPromiseData = ["Promise"].includes(props.data.constructor.name) || isAsyncFunctionData;
|
|
187
189
|
const defer = ref(typeof props.defer === "function" ? props.defer() : props.defer);
|
|
188
190
|
const vue = getCurrentInstance();
|
|
189
|
-
if (props.debug) {
|
|
190
|
-
console.log("[ReactiveView]:", { props, context, vue, defer, data: props.data, isValid, isReady, isFunctionData, isAsyncFunctionData, isPromiseData });
|
|
191
|
-
}
|
|
192
191
|
if ((isPromiseData || isFunctionData) && !("defaultData" in vue.vnode.props)) {
|
|
193
192
|
console.error("[ReactiveView]: defaultData is required for promise or async function data.");
|
|
194
193
|
}
|
|
195
194
|
const defaultData = props.getDefaultData(
|
|
196
|
-
((
|
|
195
|
+
((_a = vue.vnode.props) == null ? void 0 : _a.hasOwnProperty("defaultData")) ? vue.vnode.props.defaultData : ((_b = vue.vnode.props) == null ? void 0 : _b.hasOwnProperty("data")) ? Array.isArray(vue.vnode.props.data) ? [] : {} : {}
|
|
197
196
|
);
|
|
198
197
|
const datatype = Array.isArray(defaultData) ? [] : {};
|
|
199
198
|
const config = {
|
|
200
199
|
data: reactive(ObjectManager.on(
|
|
201
|
-
isPromiseData || isFunctionData || isRef(props.data) || isReactive(props.data) ? datatype : ((
|
|
200
|
+
isPromiseData || isFunctionData || isRef(props.data) || isReactive(props.data) ? datatype : ((_c = vue.vnode.props) == null ? void 0 : _c.hasOwnProperty("data")) ? props.data : datatype
|
|
202
201
|
).clone()),
|
|
203
202
|
defaultData: ObjectManager.on(defaultData).clone(),
|
|
204
203
|
notifications: props.notifications,
|
|
@@ -213,9 +212,11 @@ var ReactiveView_default = {
|
|
|
213
212
|
var _a2;
|
|
214
213
|
const beforeSetData = (_a2 = access(component).beforeSetData) != null ? _a2 : props.beforeSetData;
|
|
215
214
|
if (typeof beforeSetData === "function") {
|
|
216
|
-
const after = ObjectManager.on(datatype).set(...params.length ? params : [defaultData]).get();
|
|
217
215
|
const before = target.getData();
|
|
218
|
-
|
|
216
|
+
const after = (params.length ? ObjectManager.on(datatype).set(...params) : ObjectManager.on(datatype).set(defaultData)).get();
|
|
217
|
+
if (beforeSetData({ before, after }, target)) {
|
|
218
|
+
target[key](...params);
|
|
219
|
+
}
|
|
219
220
|
} else {
|
|
220
221
|
target[key](...params);
|
|
221
222
|
}
|
|
@@ -227,6 +228,9 @@ var ReactiveView_default = {
|
|
|
227
228
|
}
|
|
228
229
|
});
|
|
229
230
|
const component = ref({ parent: { self: vue.proxy }, self: { template, model, isValid } });
|
|
231
|
+
if (props.debug) {
|
|
232
|
+
console.log("[ReactiveView]:", { props, context, vue, defer, config, model, component, datatype, defaultData, isValid, isReady, isFunctionData, isAsyncFunctionData, isPromiseData });
|
|
233
|
+
}
|
|
230
234
|
const watchDataProp = (dataProp) => {
|
|
231
235
|
var _a2, _b2, _c2;
|
|
232
236
|
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? { callback: context.attrs["onUpdate:data"] } : {
|
|
@@ -249,8 +253,10 @@ var ReactiveView_default = {
|
|
|
249
253
|
if (context.attrs["onUpdate:model"] || context.attrs["update:model"]) {
|
|
250
254
|
const config2 = typeof context.attrs["onUpdate:model"] === "function" ? {
|
|
251
255
|
callback: context.attrs["onUpdate:model"],
|
|
252
|
-
options: Object.assign(__spreadValues(__spreadValues(
|
|
253
|
-
|
|
256
|
+
options: Object.assign(__spreadValues(__spreadValues({
|
|
257
|
+
deep: (_d = context.attrs["model:deep"]) != null ? _d : true
|
|
258
|
+
}, context.attrs["model:immediate"] ? { immediate: context.attrs["model:immediate"] } : {}), context.attrs["model:once"] ? { once: context.attrs["model:once"] } : {}), ((_e = context.attrs["onUpdate:model"]) != null ? _e : {}).options)
|
|
259
|
+
} : (_f = context.attrs["onUpdate:model"]) != null ? _f : {};
|
|
254
260
|
if (context.attrs["model:log"]) {
|
|
255
261
|
console.log(`[ReactiveView]:model`, { config: config2 });
|
|
256
262
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razaman2/reactive-view",
|
|
3
|
-
"version": "0.0.34-beta.
|
|
3
|
+
"version": "0.0.34-beta.3",
|
|
4
4
|
"description": "This library enables you to build vue apps in an object oriented way. It provides a convenient approach to extend and override ui components. It provides a built in eventing system along with component data management.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"uuid": "^11.1.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"vue": "^3.5.
|
|
32
|
+
"vue": "^3.5.19"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/uuid": "^10.0.0",
|