@razaman2/reactive-view 0.0.34-beta.23 → 0.0.34-beta.25
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.js +14 -13
- package/dist/index.mjs +15 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -174,7 +174,7 @@ var import_vue = require("vue");
|
|
|
174
174
|
|
|
175
175
|
// package.json
|
|
176
176
|
var name = "@razaman2/reactive-view";
|
|
177
|
-
var version = "0.0.34-beta.
|
|
177
|
+
var version = "0.0.34-beta.25";
|
|
178
178
|
|
|
179
179
|
// src/ReactiveView.ts
|
|
180
180
|
var setup = {
|
|
@@ -259,7 +259,9 @@ var ReactiveView_default = {
|
|
|
259
259
|
);
|
|
260
260
|
const datatype = Array.isArray(defaultData) ? [] : {};
|
|
261
261
|
const normalize = (data) => {
|
|
262
|
-
|
|
262
|
+
if (props.debug) {
|
|
263
|
+
console.warn(`[ReactiveView]: using beta props data in [${props.modelName}] component`, { vue, data, defaultData });
|
|
264
|
+
}
|
|
263
265
|
if ((0, import_vue.isReactive)(data)) {
|
|
264
266
|
return data;
|
|
265
267
|
} else if ((0, import_vue.isRef)(data)) {
|
|
@@ -305,9 +307,9 @@ var ReactiveView_default = {
|
|
|
305
307
|
var _a2;
|
|
306
308
|
const beforeSetData = (_a2 = access(component).beforeSetData) != null ? _a2 : props.beforeSetData;
|
|
307
309
|
if (typeof beforeSetData === "function") {
|
|
308
|
-
const before = target.getData();
|
|
310
|
+
const before = import_object_manager.default.on(target.getData()).clone();
|
|
309
311
|
const after = params.length ? import_object_manager.default.on(datatype).set(...params) : import_object_manager.default.on(datatype).set(defaultData);
|
|
310
|
-
if (beforeSetData(
|
|
312
|
+
if (beforeSetData(access(component).diff(before, after), target)) {
|
|
311
313
|
target[key](...params);
|
|
312
314
|
}
|
|
313
315
|
} else {
|
|
@@ -320,7 +322,7 @@ var ReactiveView_default = {
|
|
|
320
322
|
}
|
|
321
323
|
}
|
|
322
324
|
});
|
|
323
|
-
const component = (0, import_vue.ref)({ parent: { self: vue.proxy }, self: { template, model, dataPath: dataPath2, isValid } });
|
|
325
|
+
const component = (0, import_vue.ref)({ parent: { self: vue.proxy }, self: { template, model, diff, dataPath: dataPath2, isValid } });
|
|
324
326
|
if (props.debug) {
|
|
325
327
|
console.log("[ReactiveView]:", { props, context, vue, defer, config, model, component, datatype, defaultData, isValid, isReady, isFunctionData, isAsyncFunctionData, isPromiseData });
|
|
326
328
|
}
|
|
@@ -338,7 +340,7 @@ var ReactiveView_default = {
|
|
|
338
340
|
(0, import_vue.watch)(isFunctionData || (0, import_vue.isRef)(dataProp) || (0, import_vue.isReactive)(dataProp) ? dataProp : () => dataProp, (after, before) => {
|
|
339
341
|
var _a3;
|
|
340
342
|
if (typeof config2.callback === "function") {
|
|
341
|
-
model.replaceData((_a3 = config2.callback(diff(import_object_manager.default.on(before), import_object_manager.default.on(after)), { component })) != null ? _a3 : after);
|
|
343
|
+
model.replaceData((_a3 = config2.callback(access(component).diff(import_object_manager.default.on(before), import_object_manager.default.on(after)), { component })) != null ? _a3 : after);
|
|
342
344
|
} else {
|
|
343
345
|
model.replaceData(after);
|
|
344
346
|
}
|
|
@@ -354,8 +356,8 @@ var ReactiveView_default = {
|
|
|
354
356
|
if (context.attrs["model:log"]) {
|
|
355
357
|
console.log(`[ReactiveView]:model`, { config: config2 });
|
|
356
358
|
}
|
|
357
|
-
(0, import_vue.watch)(() => model.getData(), (after, before) => {
|
|
358
|
-
config2.callback(diff(import_object_manager.default.on(before), import_object_manager.default.on(after)), { component });
|
|
359
|
+
(0, import_vue.watch)(() => import_object_manager.default.on(model.getData()).clone(), (after, before) => {
|
|
360
|
+
config2.callback(access(component).diff(import_object_manager.default.on(before), import_object_manager.default.on(after)), { component });
|
|
359
361
|
}, config2.options);
|
|
360
362
|
}
|
|
361
363
|
if (!props.beta) {
|
|
@@ -365,10 +367,8 @@ var ReactiveView_default = {
|
|
|
365
367
|
watchDataProp(data);
|
|
366
368
|
});
|
|
367
369
|
} else if (props.beta && (isFunctionData || isPromiseData)) {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
const [data] = await Promise.all([isFunctionData || isAsyncFunctionData ? props.data() : props.data, (_a2 = defer.value) != null ? _a2 : true]);
|
|
371
|
-
model.replaceData((0, import_vue.toRaw)((0, import_vue.unref)(data)));
|
|
370
|
+
(0, import_vue.watch)(props.data, (data) => {
|
|
371
|
+
model.replaceData(data);
|
|
372
372
|
});
|
|
373
373
|
}
|
|
374
374
|
setTimeout(async () => {
|
|
@@ -588,9 +588,10 @@ var extendVnode = (component, element) => {
|
|
|
588
588
|
return (props = {}, slots) => {
|
|
589
589
|
var _a;
|
|
590
590
|
const isFunctionClass = typeof props.class === "function";
|
|
591
|
+
const isFunctionStyle = typeof props.style === "function";
|
|
591
592
|
const _b = (_a = vnode.props) != null ? _a : {}, { class: classes, style: styles } = _b, rest = __objRest(_b, ["class", "style"]);
|
|
592
593
|
const finalClasses = (0, import_tailwind_merge.twMerge)(isFunctionClass ? "" : classes, MergeStyles(isFunctionClass ? props.class(classes) : props.class).string);
|
|
593
|
-
const finalStyles = MergeStyles(styles,
|
|
594
|
+
const finalStyles = MergeStyles(styles, isFunctionStyle ? props.style(styles) : props.style);
|
|
594
595
|
const functionalProps = Object.entries(props).reduce((props2, [key2, value]) => {
|
|
595
596
|
var _a2;
|
|
596
597
|
if (!["class", "style", "setup"].includes(key2) && typeof value === "function") {
|
package/dist/index.mjs
CHANGED
|
@@ -124,11 +124,11 @@ var Subscriptions = _Subscriptions;
|
|
|
124
124
|
// src/ReactiveView.ts
|
|
125
125
|
import ObjectManager from "@razaman2/object-manager";
|
|
126
126
|
import DataManager from "@razaman2/data-manager";
|
|
127
|
-
import { ref, reactive, watch, unref,
|
|
127
|
+
import { ref, reactive, watch, unref, isRef, isReactive, createVNode, getCurrentInstance } from "vue";
|
|
128
128
|
|
|
129
129
|
// package.json
|
|
130
130
|
var name = "@razaman2/reactive-view";
|
|
131
|
-
var version = "0.0.34-beta.
|
|
131
|
+
var version = "0.0.34-beta.25";
|
|
132
132
|
|
|
133
133
|
// src/ReactiveView.ts
|
|
134
134
|
var setup = {
|
|
@@ -213,7 +213,9 @@ var ReactiveView_default = {
|
|
|
213
213
|
);
|
|
214
214
|
const datatype = Array.isArray(defaultData) ? [] : {};
|
|
215
215
|
const normalize = (data) => {
|
|
216
|
-
|
|
216
|
+
if (props.debug) {
|
|
217
|
+
console.warn(`[ReactiveView]: using beta props data in [${props.modelName}] component`, { vue, data, defaultData });
|
|
218
|
+
}
|
|
217
219
|
if (isReactive(data)) {
|
|
218
220
|
return data;
|
|
219
221
|
} else if (isRef(data)) {
|
|
@@ -259,9 +261,9 @@ var ReactiveView_default = {
|
|
|
259
261
|
var _a2;
|
|
260
262
|
const beforeSetData = (_a2 = access(component).beforeSetData) != null ? _a2 : props.beforeSetData;
|
|
261
263
|
if (typeof beforeSetData === "function") {
|
|
262
|
-
const before = target.getData();
|
|
264
|
+
const before = ObjectManager.on(target.getData()).clone();
|
|
263
265
|
const after = params.length ? ObjectManager.on(datatype).set(...params) : ObjectManager.on(datatype).set(defaultData);
|
|
264
|
-
if (beforeSetData(
|
|
266
|
+
if (beforeSetData(access(component).diff(before, after), target)) {
|
|
265
267
|
target[key](...params);
|
|
266
268
|
}
|
|
267
269
|
} else {
|
|
@@ -274,7 +276,7 @@ var ReactiveView_default = {
|
|
|
274
276
|
}
|
|
275
277
|
}
|
|
276
278
|
});
|
|
277
|
-
const component = ref({ parent: { self: vue.proxy }, self: { template, model, dataPath: dataPath2, isValid } });
|
|
279
|
+
const component = ref({ parent: { self: vue.proxy }, self: { template, model, diff, dataPath: dataPath2, isValid } });
|
|
278
280
|
if (props.debug) {
|
|
279
281
|
console.log("[ReactiveView]:", { props, context, vue, defer, config, model, component, datatype, defaultData, isValid, isReady, isFunctionData, isAsyncFunctionData, isPromiseData });
|
|
280
282
|
}
|
|
@@ -292,7 +294,7 @@ var ReactiveView_default = {
|
|
|
292
294
|
watch(isFunctionData || isRef(dataProp) || isReactive(dataProp) ? dataProp : () => dataProp, (after, before) => {
|
|
293
295
|
var _a3;
|
|
294
296
|
if (typeof config2.callback === "function") {
|
|
295
|
-
model.replaceData((_a3 = config2.callback(diff(ObjectManager.on(before), ObjectManager.on(after)), { component })) != null ? _a3 : after);
|
|
297
|
+
model.replaceData((_a3 = config2.callback(access(component).diff(ObjectManager.on(before), ObjectManager.on(after)), { component })) != null ? _a3 : after);
|
|
296
298
|
} else {
|
|
297
299
|
model.replaceData(after);
|
|
298
300
|
}
|
|
@@ -308,8 +310,8 @@ var ReactiveView_default = {
|
|
|
308
310
|
if (context.attrs["model:log"]) {
|
|
309
311
|
console.log(`[ReactiveView]:model`, { config: config2 });
|
|
310
312
|
}
|
|
311
|
-
watch(() => model.getData(), (after, before) => {
|
|
312
|
-
config2.callback(diff(ObjectManager.on(before), ObjectManager.on(after)), { component });
|
|
313
|
+
watch(() => ObjectManager.on(model.getData()).clone(), (after, before) => {
|
|
314
|
+
config2.callback(access(component).diff(ObjectManager.on(before), ObjectManager.on(after)), { component });
|
|
313
315
|
}, config2.options);
|
|
314
316
|
}
|
|
315
317
|
if (!props.beta) {
|
|
@@ -319,10 +321,8 @@ var ReactiveView_default = {
|
|
|
319
321
|
watchDataProp(data);
|
|
320
322
|
});
|
|
321
323
|
} else if (props.beta && (isFunctionData || isPromiseData)) {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const [data] = await Promise.all([isFunctionData || isAsyncFunctionData ? props.data() : props.data, (_a2 = defer.value) != null ? _a2 : true]);
|
|
325
|
-
model.replaceData(toRaw(unref(data)));
|
|
324
|
+
watch(props.data, (data) => {
|
|
325
|
+
model.replaceData(data);
|
|
326
326
|
});
|
|
327
327
|
}
|
|
328
328
|
setTimeout(async () => {
|
|
@@ -542,9 +542,10 @@ var extendVnode = (component, element) => {
|
|
|
542
542
|
return (props = {}, slots) => {
|
|
543
543
|
var _a;
|
|
544
544
|
const isFunctionClass = typeof props.class === "function";
|
|
545
|
+
const isFunctionStyle = typeof props.style === "function";
|
|
545
546
|
const _b = (_a = vnode.props) != null ? _a : {}, { class: classes, style: styles } = _b, rest = __objRest(_b, ["class", "style"]);
|
|
546
547
|
const finalClasses = twMerge(isFunctionClass ? "" : classes, MergeStyles(isFunctionClass ? props.class(classes) : props.class).string);
|
|
547
|
-
const finalStyles = MergeStyles(styles,
|
|
548
|
+
const finalStyles = MergeStyles(styles, isFunctionStyle ? props.style(styles) : props.style);
|
|
548
549
|
const functionalProps = Object.entries(props).reduce((props2, [key2, value]) => {
|
|
549
550
|
var _a2;
|
|
550
551
|
if (!["class", "style", "setup"].includes(key2) && typeof value === "function") {
|
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.25",
|
|
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",
|