@razaman2/reactive-view 0.0.34-beta.3 → 0.0.34-beta.5
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 +24 -20
- package/dist/index.mjs +24 -20
- package/package.json +2 -1
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.5";
|
|
172
172
|
|
|
173
173
|
// src/ReactiveView.ts
|
|
174
174
|
var setup = {
|
|
@@ -215,6 +215,15 @@ var ReactiveView_default = {
|
|
|
215
215
|
},
|
|
216
216
|
setup(props, context) {
|
|
217
217
|
var _a, _b, _c, _d, _e, _f;
|
|
218
|
+
const diff = (before, after) => {
|
|
219
|
+
const change = after.paths().reduce((change2, path) => {
|
|
220
|
+
if (before.get(path) !== after.get(path)) {
|
|
221
|
+
change2.set(path, after.get(path));
|
|
222
|
+
}
|
|
223
|
+
return change2;
|
|
224
|
+
}, import_object_manager.default.on({}));
|
|
225
|
+
return { before: before.get(), after: after.get(), change: change.get() };
|
|
226
|
+
};
|
|
218
227
|
const template = (component2, vue2) => {
|
|
219
228
|
return (0, import_vue.createVNode)(
|
|
220
229
|
"div",
|
|
@@ -256,8 +265,8 @@ var ReactiveView_default = {
|
|
|
256
265
|
const beforeSetData = (_a2 = access(component).beforeSetData) != null ? _a2 : props.beforeSetData;
|
|
257
266
|
if (typeof beforeSetData === "function") {
|
|
258
267
|
const before = target.getData();
|
|
259
|
-
const after =
|
|
260
|
-
if (beforeSetData(
|
|
268
|
+
const after = params.length ? import_object_manager.default.on(datatype).set(...params) : import_object_manager.default.on(datatype).set(defaultData);
|
|
269
|
+
if (beforeSetData(diff(import_object_manager.default.on(before), after), target)) {
|
|
261
270
|
target[key](...params);
|
|
262
271
|
}
|
|
263
272
|
} else {
|
|
@@ -285,9 +294,8 @@ var ReactiveView_default = {
|
|
|
285
294
|
}
|
|
286
295
|
(0, import_vue.watch)(isFunctionData || (0, import_vue.isRef)(dataProp) || (0, import_vue.isReactive)(dataProp) ? dataProp : () => dataProp, (after, before) => {
|
|
287
296
|
var _a3;
|
|
288
|
-
const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
|
|
289
297
|
if (typeof config2.callback === "function") {
|
|
290
|
-
model.replaceData((_a3 = config2.callback(diff, { component })) != null ? _a3 : after);
|
|
298
|
+
model.replaceData((_a3 = config2.callback(diff(import_object_manager.default.on(before), import_object_manager.default.on(after)), { component })) != null ? _a3 : after);
|
|
291
299
|
} else {
|
|
292
300
|
model.replaceData(after);
|
|
293
301
|
}
|
|
@@ -304,8 +312,7 @@ var ReactiveView_default = {
|
|
|
304
312
|
console.log(`[ReactiveView]:model`, { config: config2 });
|
|
305
313
|
}
|
|
306
314
|
(0, import_vue.watch)(() => model.getData(), (after, before) => {
|
|
307
|
-
|
|
308
|
-
config2.callback(diff, { component });
|
|
315
|
+
config2.callback(diff(import_object_manager.default.on(before), import_object_manager.default.on(after)), { component });
|
|
309
316
|
}, config2.options);
|
|
310
317
|
}
|
|
311
318
|
setTimeout(async () => {
|
|
@@ -348,6 +355,7 @@ var ReactiveView_default = {
|
|
|
348
355
|
// src/index.ts
|
|
349
356
|
var import_vue2 = require("vue");
|
|
350
357
|
var import_date_fns_tz = require("date-fns-tz");
|
|
358
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
351
359
|
var index_default = ReactiveView_default;
|
|
352
360
|
function safeRequest(request) {
|
|
353
361
|
return new Promise(async (resolve) => {
|
|
@@ -377,7 +385,7 @@ function safeRequest(request) {
|
|
|
377
385
|
}
|
|
378
386
|
});
|
|
379
387
|
}
|
|
380
|
-
function getProps(props, param2) {
|
|
388
|
+
function getProps(props = {}, param2) {
|
|
381
389
|
var _a;
|
|
382
390
|
const exclude = Array.isArray(param2) || typeof param2 === "string" ? param2 : param2.exclude;
|
|
383
391
|
const exclusions = (Array.isArray(exclude) ? exclude : [exclude]).join("|");
|
|
@@ -529,22 +537,18 @@ var extendVnode = (component, element) => {
|
|
|
529
537
|
return (props = {}, slots) => {
|
|
530
538
|
var _a;
|
|
531
539
|
const _b = getProps((_a = vnode.props) != null ? _a : {}, []), { class: classes, style: styles } = _b, rest = __objRest(_b, ["class", "style"]);
|
|
532
|
-
const finalClasses = MergeStyles(classes, typeof props.class === "function" ? props.class(classes) : props.class);
|
|
540
|
+
const finalClasses = (0, import_tailwind_merge.twMerge)(MergeStyles(classes).string, MergeStyles(typeof props.class === "function" ? props.class(classes) : props.class).string);
|
|
541
|
+
const finalStyles = MergeStyles(styles, typeof props.style === "function" ? props.style(styles) : props.style);
|
|
533
542
|
const functionalProps = Object.entries(props).reduce((props2, [key2, value]) => {
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
].includes(key2) && typeof value === "function") {
|
|
538
|
-
props2[key2] = value(vnode.props[key2]);
|
|
543
|
+
var _a2;
|
|
544
|
+
if (!["class", "style"].includes(key2) && typeof value === "function") {
|
|
545
|
+
props2[key2] = value((_a2 = vnode.props) == null ? void 0 : _a2[key2]);
|
|
539
546
|
}
|
|
540
547
|
return props2;
|
|
541
548
|
}, props);
|
|
542
|
-
const finalProps = Object.assign(rest, functionalProps, {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
});
|
|
546
|
-
const finalSlots = typeof slots === "function" ? slots(vnode.children) : vnode.children;
|
|
547
|
-
return (0, import_vue2.h)(["string", "undefined"].includes(typeof element) ? vnode : element, finalProps, finalSlots);
|
|
549
|
+
const finalProps = Object.assign(rest, functionalProps, { class: finalClasses, style: finalStyles });
|
|
550
|
+
const finalSlots = slots ? typeof slots === "function" ? slots(vnode.children) : slots : vnode.children;
|
|
551
|
+
return (0, import_vue2.h)(["undefined"].includes(typeof element) ? vnode.type : element, finalProps, finalSlots);
|
|
548
552
|
};
|
|
549
553
|
}
|
|
550
554
|
});
|
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.5";
|
|
129
129
|
|
|
130
130
|
// src/ReactiveView.ts
|
|
131
131
|
var setup = {
|
|
@@ -172,6 +172,15 @@ var ReactiveView_default = {
|
|
|
172
172
|
},
|
|
173
173
|
setup(props, context) {
|
|
174
174
|
var _a, _b, _c, _d, _e, _f;
|
|
175
|
+
const diff = (before, after) => {
|
|
176
|
+
const change = after.paths().reduce((change2, path) => {
|
|
177
|
+
if (before.get(path) !== after.get(path)) {
|
|
178
|
+
change2.set(path, after.get(path));
|
|
179
|
+
}
|
|
180
|
+
return change2;
|
|
181
|
+
}, ObjectManager.on({}));
|
|
182
|
+
return { before: before.get(), after: after.get(), change: change.get() };
|
|
183
|
+
};
|
|
175
184
|
const template = (component2, vue2) => {
|
|
176
185
|
return createVNode(
|
|
177
186
|
"div",
|
|
@@ -213,8 +222,8 @@ var ReactiveView_default = {
|
|
|
213
222
|
const beforeSetData = (_a2 = access(component).beforeSetData) != null ? _a2 : props.beforeSetData;
|
|
214
223
|
if (typeof beforeSetData === "function") {
|
|
215
224
|
const before = target.getData();
|
|
216
|
-
const after =
|
|
217
|
-
if (beforeSetData(
|
|
225
|
+
const after = params.length ? ObjectManager.on(datatype).set(...params) : ObjectManager.on(datatype).set(defaultData);
|
|
226
|
+
if (beforeSetData(diff(ObjectManager.on(before), after), target)) {
|
|
218
227
|
target[key](...params);
|
|
219
228
|
}
|
|
220
229
|
} else {
|
|
@@ -242,9 +251,8 @@ var ReactiveView_default = {
|
|
|
242
251
|
}
|
|
243
252
|
watch(isFunctionData || isRef(dataProp) || isReactive(dataProp) ? dataProp : () => dataProp, (after, before) => {
|
|
244
253
|
var _a3;
|
|
245
|
-
const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
|
|
246
254
|
if (typeof config2.callback === "function") {
|
|
247
|
-
model.replaceData((_a3 = config2.callback(diff, { component })) != null ? _a3 : after);
|
|
255
|
+
model.replaceData((_a3 = config2.callback(diff(ObjectManager.on(before), ObjectManager.on(after)), { component })) != null ? _a3 : after);
|
|
248
256
|
} else {
|
|
249
257
|
model.replaceData(after);
|
|
250
258
|
}
|
|
@@ -261,8 +269,7 @@ var ReactiveView_default = {
|
|
|
261
269
|
console.log(`[ReactiveView]:model`, { config: config2 });
|
|
262
270
|
}
|
|
263
271
|
watch(() => model.getData(), (after, before) => {
|
|
264
|
-
|
|
265
|
-
config2.callback(diff, { component });
|
|
272
|
+
config2.callback(diff(ObjectManager.on(before), ObjectManager.on(after)), { component });
|
|
266
273
|
}, config2.options);
|
|
267
274
|
}
|
|
268
275
|
setTimeout(async () => {
|
|
@@ -305,6 +312,7 @@ var ReactiveView_default = {
|
|
|
305
312
|
// src/index.ts
|
|
306
313
|
import { createVNode as createVNode2, isRef as isRef2, h } from "vue";
|
|
307
314
|
import { formatInTimeZone } from "date-fns-tz";
|
|
315
|
+
import { twMerge } from "tailwind-merge";
|
|
308
316
|
var index_default = ReactiveView_default;
|
|
309
317
|
function safeRequest(request) {
|
|
310
318
|
return new Promise(async (resolve) => {
|
|
@@ -334,7 +342,7 @@ function safeRequest(request) {
|
|
|
334
342
|
}
|
|
335
343
|
});
|
|
336
344
|
}
|
|
337
|
-
function getProps(props, param2) {
|
|
345
|
+
function getProps(props = {}, param2) {
|
|
338
346
|
var _a;
|
|
339
347
|
const exclude = Array.isArray(param2) || typeof param2 === "string" ? param2 : param2.exclude;
|
|
340
348
|
const exclusions = (Array.isArray(exclude) ? exclude : [exclude]).join("|");
|
|
@@ -486,22 +494,18 @@ var extendVnode = (component, element) => {
|
|
|
486
494
|
return (props = {}, slots) => {
|
|
487
495
|
var _a;
|
|
488
496
|
const _b = getProps((_a = vnode.props) != null ? _a : {}, []), { class: classes, style: styles } = _b, rest = __objRest(_b, ["class", "style"]);
|
|
489
|
-
const finalClasses = MergeStyles(classes, typeof props.class === "function" ? props.class(classes) : props.class);
|
|
497
|
+
const finalClasses = twMerge(MergeStyles(classes).string, MergeStyles(typeof props.class === "function" ? props.class(classes) : props.class).string);
|
|
498
|
+
const finalStyles = MergeStyles(styles, typeof props.style === "function" ? props.style(styles) : props.style);
|
|
490
499
|
const functionalProps = Object.entries(props).reduce((props2, [key2, value]) => {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
].includes(key2) && typeof value === "function") {
|
|
495
|
-
props2[key2] = value(vnode.props[key2]);
|
|
500
|
+
var _a2;
|
|
501
|
+
if (!["class", "style"].includes(key2) && typeof value === "function") {
|
|
502
|
+
props2[key2] = value((_a2 = vnode.props) == null ? void 0 : _a2[key2]);
|
|
496
503
|
}
|
|
497
504
|
return props2;
|
|
498
505
|
}, props);
|
|
499
|
-
const finalProps = Object.assign(rest, functionalProps, {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
});
|
|
503
|
-
const finalSlots = typeof slots === "function" ? slots(vnode.children) : vnode.children;
|
|
504
|
-
return h(["string", "undefined"].includes(typeof element) ? vnode : element, finalProps, finalSlots);
|
|
506
|
+
const finalProps = Object.assign(rest, functionalProps, { class: finalClasses, style: finalStyles });
|
|
507
|
+
const finalSlots = slots ? typeof slots === "function" ? slots(vnode.children) : slots : vnode.children;
|
|
508
|
+
return h(["undefined"].includes(typeof element) ? vnode.type : element, finalProps, finalSlots);
|
|
505
509
|
};
|
|
506
510
|
}
|
|
507
511
|
});
|
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.5",
|
|
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",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"@razaman2/object-manager": "^3.4.2",
|
|
27
27
|
"date-fns": "^4.1.0",
|
|
28
28
|
"date-fns-tz": "^3.2.0",
|
|
29
|
+
"tailwind-merge": "^3.3.1",
|
|
29
30
|
"uuid": "^11.1.0"
|
|
30
31
|
},
|
|
31
32
|
"peerDependencies": {
|