@razaman2/reactive-view 0.0.21 → 0.0.23
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 +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js +83 -47
- package/dist/index.mjs +85 -50
- package/package.json +45 -45
package/dist/index.d.mts
CHANGED
|
@@ -41,10 +41,7 @@ declare const setup: {
|
|
|
41
41
|
};
|
|
42
42
|
declare const _default: {
|
|
43
43
|
props: {
|
|
44
|
-
setup: {
|
|
45
|
-
type: FunctionConstructor;
|
|
46
|
-
default: (parent?: {}) => {};
|
|
47
|
-
};
|
|
44
|
+
setup: {};
|
|
48
45
|
ReactiveView: {
|
|
49
46
|
default: boolean;
|
|
50
47
|
};
|
|
@@ -72,6 +69,10 @@ declare const _default: {
|
|
|
72
69
|
type: StringConstructor;
|
|
73
70
|
default: string;
|
|
74
71
|
};
|
|
72
|
+
debug: {
|
|
73
|
+
type: BooleanConstructor;
|
|
74
|
+
default: boolean;
|
|
75
|
+
};
|
|
75
76
|
};
|
|
76
77
|
setup(props: Record<string, any>, context: SetupContext): (vue: ComponentPublicInstance) => any;
|
|
77
78
|
};
|
|
@@ -112,6 +113,7 @@ declare function getSubscription(): {
|
|
|
112
113
|
subscriptions: any[];
|
|
113
114
|
subscription: Subscription;
|
|
114
115
|
};
|
|
115
|
-
declare function StyleParser(styles?: Array<string> | Record<string,
|
|
116
|
+
declare function StyleParser(styles?: Array<string> | Record<string, boolean> | string): {};
|
|
117
|
+
declare function MergeStyles(...params: any): any;
|
|
116
118
|
|
|
117
|
-
export { StyleParser, access, _default as default, getDate, getProps, getReactiveViewComponent, getSubscription, safeRequest, setup };
|
|
119
|
+
export { MergeStyles, StyleParser, access, _default as default, getDate, getProps, getReactiveViewComponent, getSubscription, safeRequest, setup };
|
package/dist/index.d.ts
CHANGED
|
@@ -41,10 +41,7 @@ declare const setup: {
|
|
|
41
41
|
};
|
|
42
42
|
declare const _default: {
|
|
43
43
|
props: {
|
|
44
|
-
setup: {
|
|
45
|
-
type: FunctionConstructor;
|
|
46
|
-
default: (parent?: {}) => {};
|
|
47
|
-
};
|
|
44
|
+
setup: {};
|
|
48
45
|
ReactiveView: {
|
|
49
46
|
default: boolean;
|
|
50
47
|
};
|
|
@@ -72,6 +69,10 @@ declare const _default: {
|
|
|
72
69
|
type: StringConstructor;
|
|
73
70
|
default: string;
|
|
74
71
|
};
|
|
72
|
+
debug: {
|
|
73
|
+
type: BooleanConstructor;
|
|
74
|
+
default: boolean;
|
|
75
|
+
};
|
|
75
76
|
};
|
|
76
77
|
setup(props: Record<string, any>, context: SetupContext): (vue: ComponentPublicInstance) => any;
|
|
77
78
|
};
|
|
@@ -112,6 +113,7 @@ declare function getSubscription(): {
|
|
|
112
113
|
subscriptions: any[];
|
|
113
114
|
subscription: Subscription;
|
|
114
115
|
};
|
|
115
|
-
declare function StyleParser(styles?: Array<string> | Record<string,
|
|
116
|
+
declare function StyleParser(styles?: Array<string> | Record<string, boolean> | string): {};
|
|
117
|
+
declare function MergeStyles(...params: any): any;
|
|
116
118
|
|
|
117
|
-
export { StyleParser, access, _default as default, getDate, getProps, getReactiveViewComponent, getSubscription, safeRequest, setup };
|
|
119
|
+
export { MergeStyles, StyleParser, access, _default as default, getDate, getProps, getReactiveViewComponent, getSubscription, safeRequest, setup };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
8
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
9
|
var __getProtoOf = Object.getPrototypeOf;
|
|
@@ -19,6 +21,7 @@ var __spreadValues = (a, b) => {
|
|
|
19
21
|
}
|
|
20
22
|
return a;
|
|
21
23
|
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
25
|
var __export = (target, all) => {
|
|
23
26
|
for (var name2 in all)
|
|
24
27
|
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
@@ -44,6 +47,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
44
47
|
// src/index.ts
|
|
45
48
|
var index_exports = {};
|
|
46
49
|
__export(index_exports, {
|
|
50
|
+
MergeStyles: () => MergeStyles,
|
|
47
51
|
StyleParser: () => StyleParser,
|
|
48
52
|
access: () => access,
|
|
49
53
|
default: () => index_default,
|
|
@@ -155,7 +159,7 @@ var import_vue = require("vue");
|
|
|
155
159
|
|
|
156
160
|
// package.json
|
|
157
161
|
var name = "@razaman2/reactive-view";
|
|
158
|
-
var version = "0.0.
|
|
162
|
+
var version = "0.0.23";
|
|
159
163
|
|
|
160
164
|
// src/ReactiveView.ts
|
|
161
165
|
var setup = {
|
|
@@ -164,7 +168,7 @@ var setup = {
|
|
|
164
168
|
};
|
|
165
169
|
var ReactiveView_default = {
|
|
166
170
|
props: {
|
|
167
|
-
setup,
|
|
171
|
+
setup: {},
|
|
168
172
|
ReactiveView: {
|
|
169
173
|
default: true
|
|
170
174
|
},
|
|
@@ -193,33 +197,37 @@ var ReactiveView_default = {
|
|
|
193
197
|
modelName: {
|
|
194
198
|
type: String,
|
|
195
199
|
default: "ReactiveView"
|
|
200
|
+
},
|
|
201
|
+
debug: {
|
|
202
|
+
type: Boolean,
|
|
203
|
+
default: false
|
|
196
204
|
}
|
|
197
205
|
},
|
|
198
206
|
setup(props, context) {
|
|
199
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
200
|
-
const template = (
|
|
201
|
-
|
|
202
|
-
const params = { vue, component: component2, props, context };
|
|
203
|
-
const vnode = context.slots.default ? (0, import_vue.createVNode)(
|
|
207
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
208
|
+
const template = (component2, vue) => {
|
|
209
|
+
return context.slots.default ? (0, import_vue.createVNode)(
|
|
204
210
|
"div",
|
|
205
211
|
context.attrs,
|
|
206
|
-
context.slots.default(
|
|
212
|
+
context.slots.default({ vue, component: component2, props, context })
|
|
207
213
|
) : (0, import_vue.createVNode)("div", __spreadValues({
|
|
208
214
|
style: {
|
|
209
215
|
color: "red",
|
|
210
216
|
textAlign: "center"
|
|
211
217
|
}
|
|
212
218
|
}, context.attrs), `${props.modelName}: ${name}@${version}`);
|
|
213
|
-
return (_c2 = (_b2 = (_a2 = context.slots).template) == null ? void 0 : _b2.call(_a2, params)) != null ? _c2 : vnode;
|
|
214
219
|
};
|
|
215
220
|
const isValid = (0, import_vue.ref)(false);
|
|
216
221
|
const ready = (0, import_vue.ref)(false);
|
|
217
222
|
const instance = (0, import_vue.getCurrentInstance)();
|
|
218
223
|
const deferred = (0, import_vue.ref)(typeof props.defer === "function" ? props.defer() : props.defer);
|
|
219
224
|
const state = typeof props.data === "function" ? props.data() : props.data;
|
|
220
|
-
const
|
|
221
|
-
if (
|
|
222
|
-
|
|
225
|
+
const async = state instanceof Promise;
|
|
226
|
+
if (props.debug) {
|
|
227
|
+
console.log("[ReactiveView]:", { props, context });
|
|
228
|
+
}
|
|
229
|
+
if (async && !((_a = instance.vnode.props) == null ? void 0 : _a.hasOwnProperty("defaultData"))) {
|
|
230
|
+
console.error("[ReactiveView]: defaultData is required for async data.");
|
|
223
231
|
}
|
|
224
232
|
if (props.loading && !props.defer) {
|
|
225
233
|
console.warn("[ReactiveView]: loading prop should be used with defer prop.");
|
|
@@ -228,7 +236,7 @@ var ReactiveView_default = {
|
|
|
228
236
|
((_b = instance.vnode.props) == null ? void 0 : _b.hasOwnProperty("defaultData")) ? instance.vnode.props.defaultData : typeof ((_c = instance.vnode.props) == null ? void 0 : _c.data) === "object" ? Array.isArray(instance.vnode.props.data) ? [] : {} : ((_d = instance.vnode.props) == null ? void 0 : _d.hasOwnProperty("data")) ? (_e = instance.vnode.props) == null ? void 0 : _e.data : {}
|
|
229
237
|
);
|
|
230
238
|
const datatype = Array.isArray(defaultData) ? [] : {};
|
|
231
|
-
const data =
|
|
239
|
+
const data = async ? datatype : ((_f = instance.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? state : datatype;
|
|
232
240
|
const config = {
|
|
233
241
|
name: props.modelName,
|
|
234
242
|
defaultData: import_object_manager.default.on(defaultData).clone(),
|
|
@@ -244,7 +252,9 @@ var ReactiveView_default = {
|
|
|
244
252
|
var _a2;
|
|
245
253
|
const beforeSetData = (_a2 = access(component).beforeSetData) != null ? _a2 : props.beforeSetData;
|
|
246
254
|
if (typeof beforeSetData === "function") {
|
|
247
|
-
|
|
255
|
+
const after = import_object_manager.default.on(datatype).set(...params).get();
|
|
256
|
+
const before = target.getData();
|
|
257
|
+
beforeSetData({ before, after }, target);
|
|
248
258
|
} else {
|
|
249
259
|
target[key](...params);
|
|
250
260
|
}
|
|
@@ -255,12 +265,30 @@ var ReactiveView_default = {
|
|
|
255
265
|
}
|
|
256
266
|
}
|
|
257
267
|
});
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
268
|
+
const watchDataProp = (dataProp) => {
|
|
269
|
+
var _a2;
|
|
270
|
+
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? {
|
|
271
|
+
callback: context.attrs["onUpdate:data"]
|
|
272
|
+
} : (_a2 = context.attrs["onUpdate:data"]) != null ? _a2 : {};
|
|
273
|
+
console.log("log dataProp:", dataProp);
|
|
274
|
+
(0, import_vue.watch)(typeof dataProp === "function" || (0, import_vue.isRef)(dataProp) ? dataProp : () => dataProp, (after, before) => {
|
|
275
|
+
var _a3;
|
|
276
|
+
const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
|
|
277
|
+
if (typeof config2.callback === "function") {
|
|
278
|
+
model.replaceData((_a3 = config2.callback(diff, model)) != null ? _a3 : after);
|
|
279
|
+
} else {
|
|
280
|
+
model.replaceData(after);
|
|
281
|
+
}
|
|
282
|
+
}, config2.options);
|
|
283
|
+
};
|
|
284
|
+
if (async) {
|
|
285
|
+
setTimeout(async () => {
|
|
286
|
+
watchDataProp(await state);
|
|
261
287
|
});
|
|
288
|
+
} else {
|
|
289
|
+
watchDataProp(state);
|
|
262
290
|
}
|
|
263
|
-
(
|
|
291
|
+
setTimeout(async () => {
|
|
264
292
|
var _a2;
|
|
265
293
|
ready.value = (_a2 = await deferred.value) != null ? _a2 : true;
|
|
266
294
|
});
|
|
@@ -273,29 +301,29 @@ var ReactiveView_default = {
|
|
|
273
301
|
config2.callback(diff, model);
|
|
274
302
|
}, config2.options);
|
|
275
303
|
}
|
|
276
|
-
if ((_h = context.attrs["onUpdate:data"]) != null ? _h : true) {
|
|
277
|
-
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? {
|
|
278
|
-
callback: context.attrs["onUpdate:data"]
|
|
279
|
-
} : (_i = context.attrs["onUpdate:data"]) != null ? _i : {};
|
|
280
|
-
(0, import_vue.watch)(async () => typeof props.data === "function" ? await props.data() : await props.data, async (after, before) => {
|
|
281
|
-
const diff = { before: import_object_manager.default.on(await before).get(), after: import_object_manager.default.on(await after).get() };
|
|
282
|
-
if (typeof config2.callback === "function") {
|
|
283
|
-
config2.callback(diff, model);
|
|
284
|
-
} else {
|
|
285
|
-
model.replaceData(await after);
|
|
286
|
-
}
|
|
287
|
-
}, config2.options);
|
|
288
|
-
}
|
|
289
304
|
const component = (0, import_vue.ref)({ parent: { self: instance.proxy }, self: { template, model, isValid } });
|
|
290
|
-
if (
|
|
291
|
-
component.value =
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
305
|
+
if (access(component).ReactiveView) {
|
|
306
|
+
component.value = [access(component)].reduce((options, parent) => {
|
|
307
|
+
var _a2;
|
|
308
|
+
while (parent) {
|
|
309
|
+
if (typeof parent.setup === "function") {
|
|
310
|
+
options = { parent: options, self: (_a2 = parent.setup(component, options)) != null ? _a2 : {} };
|
|
311
|
+
if (access(parent.$parent).ReactiveView) {
|
|
312
|
+
break;
|
|
313
|
+
} else {
|
|
314
|
+
parent = parent.$parent;
|
|
315
|
+
}
|
|
316
|
+
} else {
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return options;
|
|
321
|
+
}, component.value);
|
|
295
322
|
}
|
|
323
|
+
props.instance.value = component.value;
|
|
296
324
|
return (vue) => {
|
|
297
325
|
if (ready.value) {
|
|
298
|
-
return access(component).template(
|
|
326
|
+
return access(component).template(component, vue);
|
|
299
327
|
} else {
|
|
300
328
|
return props.loading;
|
|
301
329
|
}
|
|
@@ -390,7 +418,11 @@ function access(view = {}, alternative) {
|
|
|
390
418
|
component.tree = "parent" in component.tree && component.tree.parent;
|
|
391
419
|
}
|
|
392
420
|
} while (component.tree);
|
|
393
|
-
|
|
421
|
+
try {
|
|
422
|
+
return new alternative();
|
|
423
|
+
} catch (e) {
|
|
424
|
+
return alternative;
|
|
425
|
+
}
|
|
394
426
|
}
|
|
395
427
|
});
|
|
396
428
|
};
|
|
@@ -430,19 +462,23 @@ function getSubscription() {
|
|
|
430
462
|
};
|
|
431
463
|
}
|
|
432
464
|
function StyleParser(styles = {}) {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
}, {});
|
|
437
|
-
return (_a = Array.isArray(styles) ? object(styles) : typeof styles === "string" ? object(styles.split(/\s+/)) : Object.entries(styles).reduce((acc, [styles2, value]) => {
|
|
438
|
-
styles2.split(/\s+/).forEach((style) => {
|
|
439
|
-
acc[style] = value;
|
|
465
|
+
const transform = (style, status = true) => style.split(/\s+/).reduce((object, style2) => {
|
|
466
|
+
return __spreadProps(__spreadValues({}, object), {
|
|
467
|
+
[style2]: status
|
|
440
468
|
});
|
|
441
|
-
|
|
442
|
-
|
|
469
|
+
}, {});
|
|
470
|
+
return Array.isArray(styles) ? styles.reduce((styles2, style) => Object.assign(transform(style), styles2), {}) : typeof styles === "string" ? transform(styles) : Object.entries(styles).reduce((acc, [styles2, value]) => {
|
|
471
|
+
return __spreadValues(__spreadValues({}, acc), transform(styles2, value));
|
|
472
|
+
}, {});
|
|
473
|
+
}
|
|
474
|
+
function MergeStyles(...params) {
|
|
475
|
+
return params.reduce((styles, style, index, array) => {
|
|
476
|
+
return __spreadValues(__spreadValues({}, StyleParser(array[array.length - index - 1])), styles);
|
|
477
|
+
}, {});
|
|
443
478
|
}
|
|
444
479
|
// Annotate the CommonJS export names for ESM import in node:
|
|
445
480
|
0 && (module.exports = {
|
|
481
|
+
MergeStyles,
|
|
446
482
|
StyleParser,
|
|
447
483
|
access,
|
|
448
484
|
getDate,
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
2
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -14,6 +16,7 @@ var __spreadValues = (a, b) => {
|
|
|
14
16
|
}
|
|
15
17
|
return a;
|
|
16
18
|
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
17
20
|
|
|
18
21
|
// src/index.ts
|
|
19
22
|
import { formatInTimeZone } from "date-fns-tz";
|
|
@@ -107,16 +110,16 @@ _Subscriptions.subscriptions = _Subscriptions.create();
|
|
|
107
110
|
var Subscriptions = _Subscriptions;
|
|
108
111
|
|
|
109
112
|
// src/index.ts
|
|
110
|
-
import { createVNode as createVNode2, isRef } from "vue";
|
|
113
|
+
import { createVNode as createVNode2, isRef as isRef2 } from "vue";
|
|
111
114
|
|
|
112
115
|
// src/ReactiveView.ts
|
|
113
116
|
import ObjectManager from "@razaman2/object-manager";
|
|
114
117
|
import DataManager from "@razaman2/data-manager";
|
|
115
|
-
import { ref, reactive, watch,
|
|
118
|
+
import { ref, reactive, watch, isRef, createVNode, getCurrentInstance } from "vue";
|
|
116
119
|
|
|
117
120
|
// package.json
|
|
118
121
|
var name = "@razaman2/reactive-view";
|
|
119
|
-
var version = "0.0.
|
|
122
|
+
var version = "0.0.23";
|
|
120
123
|
|
|
121
124
|
// src/ReactiveView.ts
|
|
122
125
|
var setup = {
|
|
@@ -125,7 +128,7 @@ var setup = {
|
|
|
125
128
|
};
|
|
126
129
|
var ReactiveView_default = {
|
|
127
130
|
props: {
|
|
128
|
-
setup,
|
|
131
|
+
setup: {},
|
|
129
132
|
ReactiveView: {
|
|
130
133
|
default: true
|
|
131
134
|
},
|
|
@@ -154,33 +157,37 @@ var ReactiveView_default = {
|
|
|
154
157
|
modelName: {
|
|
155
158
|
type: String,
|
|
156
159
|
default: "ReactiveView"
|
|
160
|
+
},
|
|
161
|
+
debug: {
|
|
162
|
+
type: Boolean,
|
|
163
|
+
default: false
|
|
157
164
|
}
|
|
158
165
|
},
|
|
159
166
|
setup(props, context) {
|
|
160
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
161
|
-
const template = (
|
|
162
|
-
|
|
163
|
-
const params = { vue, component: component2, props, context };
|
|
164
|
-
const vnode = context.slots.default ? createVNode(
|
|
167
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
168
|
+
const template = (component2, vue) => {
|
|
169
|
+
return context.slots.default ? createVNode(
|
|
165
170
|
"div",
|
|
166
171
|
context.attrs,
|
|
167
|
-
context.slots.default(
|
|
172
|
+
context.slots.default({ vue, component: component2, props, context })
|
|
168
173
|
) : createVNode("div", __spreadValues({
|
|
169
174
|
style: {
|
|
170
175
|
color: "red",
|
|
171
176
|
textAlign: "center"
|
|
172
177
|
}
|
|
173
178
|
}, context.attrs), `${props.modelName}: ${name}@${version}`);
|
|
174
|
-
return (_c2 = (_b2 = (_a2 = context.slots).template) == null ? void 0 : _b2.call(_a2, params)) != null ? _c2 : vnode;
|
|
175
179
|
};
|
|
176
180
|
const isValid = ref(false);
|
|
177
181
|
const ready = ref(false);
|
|
178
182
|
const instance = getCurrentInstance();
|
|
179
183
|
const deferred = ref(typeof props.defer === "function" ? props.defer() : props.defer);
|
|
180
184
|
const state = typeof props.data === "function" ? props.data() : props.data;
|
|
181
|
-
const
|
|
182
|
-
if (
|
|
183
|
-
|
|
185
|
+
const async = state instanceof Promise;
|
|
186
|
+
if (props.debug) {
|
|
187
|
+
console.log("[ReactiveView]:", { props, context });
|
|
188
|
+
}
|
|
189
|
+
if (async && !((_a = instance.vnode.props) == null ? void 0 : _a.hasOwnProperty("defaultData"))) {
|
|
190
|
+
console.error("[ReactiveView]: defaultData is required for async data.");
|
|
184
191
|
}
|
|
185
192
|
if (props.loading && !props.defer) {
|
|
186
193
|
console.warn("[ReactiveView]: loading prop should be used with defer prop.");
|
|
@@ -189,7 +196,7 @@ var ReactiveView_default = {
|
|
|
189
196
|
((_b = instance.vnode.props) == null ? void 0 : _b.hasOwnProperty("defaultData")) ? instance.vnode.props.defaultData : typeof ((_c = instance.vnode.props) == null ? void 0 : _c.data) === "object" ? Array.isArray(instance.vnode.props.data) ? [] : {} : ((_d = instance.vnode.props) == null ? void 0 : _d.hasOwnProperty("data")) ? (_e = instance.vnode.props) == null ? void 0 : _e.data : {}
|
|
190
197
|
);
|
|
191
198
|
const datatype = Array.isArray(defaultData) ? [] : {};
|
|
192
|
-
const data =
|
|
199
|
+
const data = async ? datatype : ((_f = instance.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? state : datatype;
|
|
193
200
|
const config = {
|
|
194
201
|
name: props.modelName,
|
|
195
202
|
defaultData: ObjectManager.on(defaultData).clone(),
|
|
@@ -205,7 +212,9 @@ var ReactiveView_default = {
|
|
|
205
212
|
var _a2;
|
|
206
213
|
const beforeSetData = (_a2 = access(component).beforeSetData) != null ? _a2 : props.beforeSetData;
|
|
207
214
|
if (typeof beforeSetData === "function") {
|
|
208
|
-
|
|
215
|
+
const after = ObjectManager.on(datatype).set(...params).get();
|
|
216
|
+
const before = target.getData();
|
|
217
|
+
beforeSetData({ before, after }, target);
|
|
209
218
|
} else {
|
|
210
219
|
target[key](...params);
|
|
211
220
|
}
|
|
@@ -216,12 +225,30 @@ var ReactiveView_default = {
|
|
|
216
225
|
}
|
|
217
226
|
}
|
|
218
227
|
});
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
228
|
+
const watchDataProp = (dataProp) => {
|
|
229
|
+
var _a2;
|
|
230
|
+
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? {
|
|
231
|
+
callback: context.attrs["onUpdate:data"]
|
|
232
|
+
} : (_a2 = context.attrs["onUpdate:data"]) != null ? _a2 : {};
|
|
233
|
+
console.log("log dataProp:", dataProp);
|
|
234
|
+
watch(typeof dataProp === "function" || isRef(dataProp) ? dataProp : () => dataProp, (after, before) => {
|
|
235
|
+
var _a3;
|
|
236
|
+
const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
|
|
237
|
+
if (typeof config2.callback === "function") {
|
|
238
|
+
model.replaceData((_a3 = config2.callback(diff, model)) != null ? _a3 : after);
|
|
239
|
+
} else {
|
|
240
|
+
model.replaceData(after);
|
|
241
|
+
}
|
|
242
|
+
}, config2.options);
|
|
243
|
+
};
|
|
244
|
+
if (async) {
|
|
245
|
+
setTimeout(async () => {
|
|
246
|
+
watchDataProp(await state);
|
|
222
247
|
});
|
|
248
|
+
} else {
|
|
249
|
+
watchDataProp(state);
|
|
223
250
|
}
|
|
224
|
-
|
|
251
|
+
setTimeout(async () => {
|
|
225
252
|
var _a2;
|
|
226
253
|
ready.value = (_a2 = await deferred.value) != null ? _a2 : true;
|
|
227
254
|
});
|
|
@@ -234,29 +261,29 @@ var ReactiveView_default = {
|
|
|
234
261
|
config2.callback(diff, model);
|
|
235
262
|
}, config2.options);
|
|
236
263
|
}
|
|
237
|
-
if ((_h = context.attrs["onUpdate:data"]) != null ? _h : true) {
|
|
238
|
-
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? {
|
|
239
|
-
callback: context.attrs["onUpdate:data"]
|
|
240
|
-
} : (_i = context.attrs["onUpdate:data"]) != null ? _i : {};
|
|
241
|
-
watch(async () => typeof props.data === "function" ? await props.data() : await props.data, async (after, before) => {
|
|
242
|
-
const diff = { before: ObjectManager.on(await before).get(), after: ObjectManager.on(await after).get() };
|
|
243
|
-
if (typeof config2.callback === "function") {
|
|
244
|
-
config2.callback(diff, model);
|
|
245
|
-
} else {
|
|
246
|
-
model.replaceData(await after);
|
|
247
|
-
}
|
|
248
|
-
}, config2.options);
|
|
249
|
-
}
|
|
250
264
|
const component = ref({ parent: { self: instance.proxy }, self: { template, model, isValid } });
|
|
251
|
-
if (
|
|
252
|
-
component.value =
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
265
|
+
if (access(component).ReactiveView) {
|
|
266
|
+
component.value = [access(component)].reduce((options, parent) => {
|
|
267
|
+
var _a2;
|
|
268
|
+
while (parent) {
|
|
269
|
+
if (typeof parent.setup === "function") {
|
|
270
|
+
options = { parent: options, self: (_a2 = parent.setup(component, options)) != null ? _a2 : {} };
|
|
271
|
+
if (access(parent.$parent).ReactiveView) {
|
|
272
|
+
break;
|
|
273
|
+
} else {
|
|
274
|
+
parent = parent.$parent;
|
|
275
|
+
}
|
|
276
|
+
} else {
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return options;
|
|
281
|
+
}, component.value);
|
|
256
282
|
}
|
|
283
|
+
props.instance.value = component.value;
|
|
257
284
|
return (vue) => {
|
|
258
285
|
if (ready.value) {
|
|
259
|
-
return access(component).template(
|
|
286
|
+
return access(component).template(component, vue);
|
|
260
287
|
} else {
|
|
261
288
|
return props.loading;
|
|
262
289
|
}
|
|
@@ -351,13 +378,17 @@ function access(view = {}, alternative) {
|
|
|
351
378
|
component.tree = "parent" in component.tree && component.tree.parent;
|
|
352
379
|
}
|
|
353
380
|
} while (component.tree);
|
|
354
|
-
|
|
381
|
+
try {
|
|
382
|
+
return new alternative();
|
|
383
|
+
} catch (e) {
|
|
384
|
+
return alternative;
|
|
385
|
+
}
|
|
355
386
|
}
|
|
356
387
|
});
|
|
357
388
|
};
|
|
358
389
|
try {
|
|
359
390
|
const component = typeof view === "function" ? view() : view;
|
|
360
|
-
const ref2 =
|
|
391
|
+
const ref2 = isRef2(component) ? component.value : component;
|
|
361
392
|
return resolve(ref2.ReactiveView ? access(ref2.instance) : ref2);
|
|
362
393
|
} catch (e) {
|
|
363
394
|
return resolve(view);
|
|
@@ -391,18 +422,22 @@ function getSubscription() {
|
|
|
391
422
|
};
|
|
392
423
|
}
|
|
393
424
|
function StyleParser(styles = {}) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
}, {});
|
|
398
|
-
return (_a = Array.isArray(styles) ? object(styles) : typeof styles === "string" ? object(styles.split(/\s+/)) : Object.entries(styles).reduce((acc, [styles2, value]) => {
|
|
399
|
-
styles2.split(/\s+/).forEach((style) => {
|
|
400
|
-
acc[style] = value;
|
|
425
|
+
const transform = (style, status = true) => style.split(/\s+/).reduce((object, style2) => {
|
|
426
|
+
return __spreadProps(__spreadValues({}, object), {
|
|
427
|
+
[style2]: status
|
|
401
428
|
});
|
|
402
|
-
|
|
403
|
-
|
|
429
|
+
}, {});
|
|
430
|
+
return Array.isArray(styles) ? styles.reduce((styles2, style) => Object.assign(transform(style), styles2), {}) : typeof styles === "string" ? transform(styles) : Object.entries(styles).reduce((acc, [styles2, value]) => {
|
|
431
|
+
return __spreadValues(__spreadValues({}, acc), transform(styles2, value));
|
|
432
|
+
}, {});
|
|
433
|
+
}
|
|
434
|
+
function MergeStyles(...params) {
|
|
435
|
+
return params.reduce((styles, style, index, array) => {
|
|
436
|
+
return __spreadValues(__spreadValues({}, StyleParser(array[array.length - index - 1])), styles);
|
|
437
|
+
}, {});
|
|
404
438
|
}
|
|
405
439
|
export {
|
|
440
|
+
MergeStyles,
|
|
406
441
|
StyleParser,
|
|
407
442
|
access,
|
|
408
443
|
index_default as default,
|
package/package.json
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@razaman2/reactive-view",
|
|
3
|
-
"version": "0.0.
|
|
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
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.mjs",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"prepublishOnly": "npm run build",
|
|
10
|
-
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
11
|
-
"lint": "tsc",
|
|
12
|
-
"test": "cd tests/vue-ts && npm run dev"
|
|
13
|
-
},
|
|
14
|
-
"keywords": [
|
|
15
|
-
"vue",
|
|
16
|
-
"vue-helper",
|
|
17
|
-
"reactive-view",
|
|
18
|
-
"vue-class-component",
|
|
19
|
-
"reactive-ui"
|
|
20
|
-
],
|
|
21
|
-
"author": "razaman2",
|
|
22
|
-
"license": "MIT",
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"@razaman2/data-manager": "^3.2.11",
|
|
25
|
-
"@razaman2/object-manager": "^3.4.2",
|
|
26
|
-
"date-fns": "^4.1.0",
|
|
27
|
-
"date-fns-tz": "^3.2.0",
|
|
28
|
-
"uuid": "^11.1.0"
|
|
29
|
-
},
|
|
30
|
-
"peerDependencies": {
|
|
31
|
-
"vue": "^3.5.13"
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@types/uuid": "^10.0.0",
|
|
35
|
-
"tsup": "^8.4.0",
|
|
36
|
-
"typescript": "^5.8.
|
|
37
|
-
"vitest": "^3.1.1"
|
|
38
|
-
},
|
|
39
|
-
"publishConfig": {
|
|
40
|
-
"access": "public"
|
|
41
|
-
},
|
|
42
|
-
"files": [
|
|
43
|
-
"dist"
|
|
44
|
-
]
|
|
45
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@razaman2/reactive-view",
|
|
3
|
+
"version": "0.0.23",
|
|
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
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"prepublishOnly": "npm run build",
|
|
10
|
+
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
11
|
+
"lint": "tsc",
|
|
12
|
+
"test": "cd tests/vue-ts && npm run dev"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"vue",
|
|
16
|
+
"vue-helper",
|
|
17
|
+
"reactive-view",
|
|
18
|
+
"vue-class-component",
|
|
19
|
+
"reactive-ui"
|
|
20
|
+
],
|
|
21
|
+
"author": "razaman2",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@razaman2/data-manager": "^3.2.11",
|
|
25
|
+
"@razaman2/object-manager": "^3.4.2",
|
|
26
|
+
"date-fns": "^4.1.0",
|
|
27
|
+
"date-fns-tz": "^3.2.0",
|
|
28
|
+
"uuid": "^11.1.0"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"vue": "^3.5.13"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/uuid": "^10.0.0",
|
|
35
|
+
"tsup": "^8.4.0",
|
|
36
|
+
"typescript": "^5.8.3",
|
|
37
|
+
"vitest": "^3.1.1"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist"
|
|
44
|
+
]
|
|
45
|
+
}
|