@razaman2/reactive-view 0.0.18 → 0.0.20
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 +20 -22
- package/dist/index.d.ts +20 -22
- package/dist/index.js +72 -48
- package/dist/index.mjs +69 -46
- package/package.json +8 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { SetupContext, ComponentPublicInstance,
|
|
2
|
+
import { SetupContext, ComponentPublicInstance, UnwrapRef } from 'vue';
|
|
3
3
|
|
|
4
4
|
type SubscriptionItem = {
|
|
5
5
|
name: string;
|
|
@@ -23,7 +23,22 @@ declare class Subscription {
|
|
|
23
23
|
get(name: string): SubscriptionItem;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
type Accessible = {
|
|
27
|
+
parent: {
|
|
28
|
+
self: Record<string | symbol, any>;
|
|
29
|
+
};
|
|
30
|
+
self: Record<string | symbol, any>;
|
|
31
|
+
access?: () => Accessible;
|
|
32
|
+
value?: Accessible;
|
|
33
|
+
};
|
|
34
|
+
type PropOptions = {
|
|
35
|
+
exclude: string | Array<string>;
|
|
36
|
+
include: Record<string, any>;
|
|
37
|
+
};
|
|
38
|
+
type PropExclusions = Array<string> | string;
|
|
39
|
+
|
|
26
40
|
declare const setup: {
|
|
41
|
+
ReactiveView: boolean;
|
|
27
42
|
setup: {
|
|
28
43
|
type: FunctionConstructor;
|
|
29
44
|
default: (param1?: {}, param2?: {}) => {};
|
|
@@ -53,6 +68,7 @@ declare const _default: {
|
|
|
53
68
|
type: BooleanConstructor;
|
|
54
69
|
default: boolean;
|
|
55
70
|
};
|
|
71
|
+
ReactiveView: boolean;
|
|
56
72
|
setup: {
|
|
57
73
|
type: FunctionConstructor;
|
|
58
74
|
default: (param1?: {}, param2?: {}) => {};
|
|
@@ -61,25 +77,6 @@ declare const _default: {
|
|
|
61
77
|
setup(props: Record<string, any>, context: SetupContext): ($vue: ComponentPublicInstance & any) => any;
|
|
62
78
|
};
|
|
63
79
|
|
|
64
|
-
type StateUpdate = {
|
|
65
|
-
callback: Function;
|
|
66
|
-
beforeStateUpdate?: Function;
|
|
67
|
-
options?: WatchOptions;
|
|
68
|
-
};
|
|
69
|
-
type Accessible = {
|
|
70
|
-
parent: {
|
|
71
|
-
self: Record<string | symbol, any>;
|
|
72
|
-
};
|
|
73
|
-
self: Record<string | symbol, any>;
|
|
74
|
-
access?: () => Accessible;
|
|
75
|
-
value?: Accessible;
|
|
76
|
-
};
|
|
77
|
-
type PropOptions = {
|
|
78
|
-
exclude: string | Array<string>;
|
|
79
|
-
include: Record<string, any>;
|
|
80
|
-
};
|
|
81
|
-
type PropExclusions = Array<string> | string;
|
|
82
|
-
|
|
83
80
|
declare function safeRequest(request: {
|
|
84
81
|
try: () => Promise<any> | any;
|
|
85
82
|
catch?: ((error: any) => Promise<any> | any) | false;
|
|
@@ -106,7 +103,7 @@ declare function getDate(timestamp: {
|
|
|
106
103
|
format?: string;
|
|
107
104
|
timezone?: string;
|
|
108
105
|
}): string;
|
|
109
|
-
declare function access<T extends ComponentPublicInstance & Accessible>($vue?: T | UnwrapRef<any
|
|
106
|
+
declare function access<T extends ComponentPublicInstance & Accessible>($vue?: T | UnwrapRef<any>, alternative?: any): Record<string | symbol, any>;
|
|
110
107
|
declare function getSubscription(): {
|
|
111
108
|
addSubscription(name: string, handler?: () => boolean, data?: any): void;
|
|
112
109
|
replaceSubscription(name: string, handler?: () => boolean, data?: any): void;
|
|
@@ -116,5 +113,6 @@ declare function getSubscription(): {
|
|
|
116
113
|
subscriptions: any[];
|
|
117
114
|
subscription: Subscription;
|
|
118
115
|
};
|
|
116
|
+
declare function StyleParser(styles: Array<string> | Record<string, any> | string): any;
|
|
119
117
|
|
|
120
|
-
export {
|
|
118
|
+
export { StyleParser, access, _default as default, getDate, getProps, getReactiveViewComponent, getSubscription, safeRequest, setup };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { SetupContext, ComponentPublicInstance,
|
|
2
|
+
import { SetupContext, ComponentPublicInstance, UnwrapRef } from 'vue';
|
|
3
3
|
|
|
4
4
|
type SubscriptionItem = {
|
|
5
5
|
name: string;
|
|
@@ -23,7 +23,22 @@ declare class Subscription {
|
|
|
23
23
|
get(name: string): SubscriptionItem;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
type Accessible = {
|
|
27
|
+
parent: {
|
|
28
|
+
self: Record<string | symbol, any>;
|
|
29
|
+
};
|
|
30
|
+
self: Record<string | symbol, any>;
|
|
31
|
+
access?: () => Accessible;
|
|
32
|
+
value?: Accessible;
|
|
33
|
+
};
|
|
34
|
+
type PropOptions = {
|
|
35
|
+
exclude: string | Array<string>;
|
|
36
|
+
include: Record<string, any>;
|
|
37
|
+
};
|
|
38
|
+
type PropExclusions = Array<string> | string;
|
|
39
|
+
|
|
26
40
|
declare const setup: {
|
|
41
|
+
ReactiveView: boolean;
|
|
27
42
|
setup: {
|
|
28
43
|
type: FunctionConstructor;
|
|
29
44
|
default: (param1?: {}, param2?: {}) => {};
|
|
@@ -53,6 +68,7 @@ declare const _default: {
|
|
|
53
68
|
type: BooleanConstructor;
|
|
54
69
|
default: boolean;
|
|
55
70
|
};
|
|
71
|
+
ReactiveView: boolean;
|
|
56
72
|
setup: {
|
|
57
73
|
type: FunctionConstructor;
|
|
58
74
|
default: (param1?: {}, param2?: {}) => {};
|
|
@@ -61,25 +77,6 @@ declare const _default: {
|
|
|
61
77
|
setup(props: Record<string, any>, context: SetupContext): ($vue: ComponentPublicInstance & any) => any;
|
|
62
78
|
};
|
|
63
79
|
|
|
64
|
-
type StateUpdate = {
|
|
65
|
-
callback: Function;
|
|
66
|
-
beforeStateUpdate?: Function;
|
|
67
|
-
options?: WatchOptions;
|
|
68
|
-
};
|
|
69
|
-
type Accessible = {
|
|
70
|
-
parent: {
|
|
71
|
-
self: Record<string | symbol, any>;
|
|
72
|
-
};
|
|
73
|
-
self: Record<string | symbol, any>;
|
|
74
|
-
access?: () => Accessible;
|
|
75
|
-
value?: Accessible;
|
|
76
|
-
};
|
|
77
|
-
type PropOptions = {
|
|
78
|
-
exclude: string | Array<string>;
|
|
79
|
-
include: Record<string, any>;
|
|
80
|
-
};
|
|
81
|
-
type PropExclusions = Array<string> | string;
|
|
82
|
-
|
|
83
80
|
declare function safeRequest(request: {
|
|
84
81
|
try: () => Promise<any> | any;
|
|
85
82
|
catch?: ((error: any) => Promise<any> | any) | false;
|
|
@@ -106,7 +103,7 @@ declare function getDate(timestamp: {
|
|
|
106
103
|
format?: string;
|
|
107
104
|
timezone?: string;
|
|
108
105
|
}): string;
|
|
109
|
-
declare function access<T extends ComponentPublicInstance & Accessible>($vue?: T | UnwrapRef<any
|
|
106
|
+
declare function access<T extends ComponentPublicInstance & Accessible>($vue?: T | UnwrapRef<any>, alternative?: any): Record<string | symbol, any>;
|
|
110
107
|
declare function getSubscription(): {
|
|
111
108
|
addSubscription(name: string, handler?: () => boolean, data?: any): void;
|
|
112
109
|
replaceSubscription(name: string, handler?: () => boolean, data?: any): void;
|
|
@@ -116,5 +113,6 @@ declare function getSubscription(): {
|
|
|
116
113
|
subscriptions: any[];
|
|
117
114
|
subscription: Subscription;
|
|
118
115
|
};
|
|
116
|
+
declare function StyleParser(styles: Array<string> | Record<string, any> | string): any;
|
|
119
117
|
|
|
120
|
-
export {
|
|
118
|
+
export { StyleParser, access, _default as default, getDate, getProps, getReactiveViewComponent, getSubscription, safeRequest, setup };
|
package/dist/index.js
CHANGED
|
@@ -54,10 +54,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
54
54
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
55
55
|
|
|
56
56
|
// src/index.ts
|
|
57
|
-
var
|
|
58
|
-
__export(
|
|
57
|
+
var index_exports = {};
|
|
58
|
+
__export(index_exports, {
|
|
59
|
+
StyleParser: () => StyleParser,
|
|
59
60
|
access: () => access,
|
|
60
|
-
default: () =>
|
|
61
|
+
default: () => index_default,
|
|
61
62
|
getDate: () => getDate,
|
|
62
63
|
getProps: () => getProps,
|
|
63
64
|
getReactiveViewComponent: () => getReactiveViewComponent,
|
|
@@ -65,9 +66,8 @@ __export(src_exports, {
|
|
|
65
66
|
safeRequest: () => safeRequest,
|
|
66
67
|
setup: () => setup
|
|
67
68
|
});
|
|
68
|
-
module.exports = __toCommonJS(
|
|
69
|
+
module.exports = __toCommonJS(index_exports);
|
|
69
70
|
var import_date_fns_tz = require("date-fns-tz");
|
|
70
|
-
var import_vue2 = require("vue");
|
|
71
71
|
|
|
72
72
|
// src/Subscription.ts
|
|
73
73
|
var Subscription = class _Subscription {
|
|
@@ -157,6 +157,9 @@ var _Subscriptions = class _Subscriptions extends Subscription {
|
|
|
157
157
|
_Subscriptions.subscriptions = _Subscriptions.create();
|
|
158
158
|
var Subscriptions = _Subscriptions;
|
|
159
159
|
|
|
160
|
+
// src/index.ts
|
|
161
|
+
var import_vue2 = require("vue");
|
|
162
|
+
|
|
160
163
|
// src/ReactiveView.ts
|
|
161
164
|
var import_object_manager = __toESM(require("@razaman2/object-manager"));
|
|
162
165
|
var import_data_manager = __toESM(require("@razaman2/data-manager"));
|
|
@@ -164,7 +167,7 @@ var import_vue = require("vue");
|
|
|
164
167
|
|
|
165
168
|
// package.json
|
|
166
169
|
var name = "@razaman2/reactive-view";
|
|
167
|
-
var version = "0.0.
|
|
170
|
+
var version = "0.0.20";
|
|
168
171
|
|
|
169
172
|
// src/ReactiveView.ts
|
|
170
173
|
var props = {
|
|
@@ -194,6 +197,7 @@ var props = {
|
|
|
194
197
|
}
|
|
195
198
|
};
|
|
196
199
|
var setup = {
|
|
200
|
+
ReactiveView: true,
|
|
197
201
|
setup: {
|
|
198
202
|
type: Function,
|
|
199
203
|
default: (param1 = {}, param2 = {}) => {
|
|
@@ -241,16 +245,15 @@ var ReactiveView_default = {
|
|
|
241
245
|
get(target, property, receiver) {
|
|
242
246
|
if (["setData", "replaceData"].includes(property)) {
|
|
243
247
|
return (...params) => {
|
|
248
|
+
var _a2, _b2;
|
|
244
249
|
const type2 = Array.isArray(defaultData) ? [] : {};
|
|
245
|
-
(0
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
});
|
|
250
|
+
const beforeSetData = (_b2 = (_a2 = context.attrs["onUpdate:modelState"]) == null ? void 0 : _a2.beforeSetData) != null ? _b2 : access(component).beforeSetData;
|
|
251
|
+
if (typeof beforeSetData === "function") {
|
|
252
|
+
beforeSetData(import_object_manager.default.on(type2).set(...params).get(), target);
|
|
253
|
+
} else {
|
|
254
|
+
target[property](...params);
|
|
255
|
+
}
|
|
256
|
+
return target;
|
|
254
257
|
};
|
|
255
258
|
} else {
|
|
256
259
|
return Reflect.get(target, property, receiver);
|
|
@@ -259,9 +262,12 @@ var ReactiveView_default = {
|
|
|
259
262
|
});
|
|
260
263
|
const options = {
|
|
261
264
|
parent: { self: component.value },
|
|
262
|
-
self: { template,
|
|
265
|
+
self: { template, isValid, getState }
|
|
263
266
|
};
|
|
264
267
|
const _f = (_e = props2.setup(options)) != null ? _e : options, { parent = {}, self = {} } = _f, rest = __objRest(_f, ["parent", "self"]);
|
|
268
|
+
if (typeof context.attrs.debug === "function") {
|
|
269
|
+
context.attrs.debug({ isValid, component, type, data, state, config, options, props: props2, context, setup: __spreadValues({ parent, self }, rest), defaultData, getState });
|
|
270
|
+
}
|
|
265
271
|
if (props2.await instanceof Promise) {
|
|
266
272
|
(0, import_vue.nextTick)(async () => {
|
|
267
273
|
getState.replaceData(await props2.await);
|
|
@@ -279,30 +285,34 @@ var ReactiveView_default = {
|
|
|
279
285
|
const config2 = typeof context.attrs["onUpdate:modelState"] === "function" ? {
|
|
280
286
|
callback: context.attrs["onUpdate:modelState"]
|
|
281
287
|
} : (_g = context.attrs["onUpdate:modelState"]) != null ? _g : {};
|
|
282
|
-
(0, import_vue.
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
sync.value
|
|
288
|
-
|
|
289
|
-
config2.callback
|
|
290
|
-
|
|
291
|
-
|
|
288
|
+
(0, import_vue.onMounted)(() => {
|
|
289
|
+
(0, import_vue.watch)(() => import_object_manager.default.on(state).clone(), (after, before) => {
|
|
290
|
+
var _a2;
|
|
291
|
+
const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
|
|
292
|
+
const beforeStateUpdate = (_a2 = config2.beforeStateUpdate) != null ? _a2 : access(component).beforeStateUpdate;
|
|
293
|
+
if (sync.value) {
|
|
294
|
+
sync.value = false;
|
|
295
|
+
} else if (typeof config2.callback === "function") {
|
|
296
|
+
config2.callback(beforeStateUpdate ? beforeStateUpdate(diff) : diff, getState);
|
|
297
|
+
}
|
|
298
|
+
}, config2.options);
|
|
299
|
+
});
|
|
292
300
|
}
|
|
293
301
|
if (context.attrs["onUpdate:propsState"] || props2.sync) {
|
|
294
302
|
const config2 = typeof context.attrs["onUpdate:propsState"] === "function" ? {
|
|
295
303
|
callback: context.attrs["onUpdate:propsState"]
|
|
296
304
|
} : (_h = context.attrs["onUpdate:propsState"]) != null ? _h : {};
|
|
297
|
-
(0, import_vue.
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
config2.callback
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
305
|
+
(0, import_vue.onMounted)(() => {
|
|
306
|
+
(0, import_vue.watch)(() => import_object_manager.default.on(props2.state).clone(), (after, before) => {
|
|
307
|
+
const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
|
|
308
|
+
if (typeof config2.callback === "function") {
|
|
309
|
+
config2.callback(diff, getState);
|
|
310
|
+
} else {
|
|
311
|
+
getState.replaceData(after);
|
|
312
|
+
}
|
|
313
|
+
sync.value = true;
|
|
314
|
+
}, config2.options);
|
|
315
|
+
});
|
|
306
316
|
}
|
|
307
317
|
return ($vue) => {
|
|
308
318
|
const setup2 = { $vue, options: parent };
|
|
@@ -324,7 +334,7 @@ var ReactiveView_default = {
|
|
|
324
334
|
};
|
|
325
335
|
|
|
326
336
|
// src/index.ts
|
|
327
|
-
var
|
|
337
|
+
var index_default = ReactiveView_default;
|
|
328
338
|
function safeRequest(request) {
|
|
329
339
|
return new Promise(async (resolve) => {
|
|
330
340
|
var _a, _b, _c, _d;
|
|
@@ -396,32 +406,33 @@ function getDate(param1, param2) {
|
|
|
396
406
|
};
|
|
397
407
|
return (0, import_date_fns_tz.formatInTimeZone)(datetime(), options.timezone, options.format);
|
|
398
408
|
}
|
|
399
|
-
function access($vue = {}) {
|
|
409
|
+
function access($vue = {}, alternative) {
|
|
400
410
|
var _a, _b;
|
|
401
411
|
const proxy = (target) => {
|
|
402
412
|
return new Proxy(target, {
|
|
403
413
|
get(target2, key) {
|
|
404
|
-
|
|
405
|
-
const component = { $vue: target2 };
|
|
414
|
+
const component2 = { $vue: target2 };
|
|
406
415
|
do {
|
|
407
|
-
if (
|
|
408
|
-
return
|
|
409
|
-
} else if (
|
|
410
|
-
return
|
|
416
|
+
if (key in component2.$vue) {
|
|
417
|
+
return component2.$vue[key];
|
|
418
|
+
} else if ("self" in component2.$vue && key in component2.$vue.self) {
|
|
419
|
+
return component2.$vue.self[key];
|
|
411
420
|
} else {
|
|
412
|
-
|
|
421
|
+
component2.$vue = "parent" in component2.$vue && component2.$vue.parent;
|
|
413
422
|
}
|
|
414
|
-
} while (
|
|
423
|
+
} while (component2.$vue);
|
|
424
|
+
return alternative;
|
|
415
425
|
}
|
|
416
426
|
});
|
|
417
427
|
};
|
|
428
|
+
const component = typeof $vue === "function" ? $vue() : $vue;
|
|
418
429
|
try {
|
|
419
|
-
return proxy(
|
|
430
|
+
return proxy(component.access());
|
|
420
431
|
} catch (e) {
|
|
421
432
|
try {
|
|
422
|
-
return proxy(
|
|
433
|
+
return proxy(component.value.access());
|
|
423
434
|
} catch (e2) {
|
|
424
|
-
return proxy((_b = (_a =
|
|
435
|
+
return proxy(((_b = (_a = component.value) != null ? _a : component) != null ? _b : {}) || {});
|
|
425
436
|
}
|
|
426
437
|
}
|
|
427
438
|
}
|
|
@@ -452,8 +463,21 @@ function getSubscription() {
|
|
|
452
463
|
subscription
|
|
453
464
|
};
|
|
454
465
|
}
|
|
466
|
+
function StyleParser(styles) {
|
|
467
|
+
var _a;
|
|
468
|
+
const object = (items) => items.reduce((object2, item) => {
|
|
469
|
+
return Object.assign(object2, { [item]: true });
|
|
470
|
+
}, {});
|
|
471
|
+
return (_a = Array.isArray(styles) ? object(styles) : typeof styles === "string" ? object(styles.split(/\s+/)) : Object.entries(styles).reduce((acc, [styles2, value]) => {
|
|
472
|
+
styles2.split(/\s+/).forEach((style) => {
|
|
473
|
+
acc[style] = value;
|
|
474
|
+
});
|
|
475
|
+
return acc;
|
|
476
|
+
}, {})) != null ? _a : {};
|
|
477
|
+
}
|
|
455
478
|
// Annotate the CommonJS export names for ESM import in node:
|
|
456
479
|
0 && (module.exports = {
|
|
480
|
+
StyleParser,
|
|
457
481
|
access,
|
|
458
482
|
getDate,
|
|
459
483
|
getProps,
|
package/dist/index.mjs
CHANGED
|
@@ -29,7 +29,6 @@ var __objRest = (source, exclude) => {
|
|
|
29
29
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
import { formatInTimeZone } from "date-fns-tz";
|
|
32
|
-
import { createVNode } from "vue";
|
|
33
32
|
|
|
34
33
|
// src/Subscription.ts
|
|
35
34
|
var Subscription = class _Subscription {
|
|
@@ -119,14 +118,17 @@ var _Subscriptions = class _Subscriptions extends Subscription {
|
|
|
119
118
|
_Subscriptions.subscriptions = _Subscriptions.create();
|
|
120
119
|
var Subscriptions = _Subscriptions;
|
|
121
120
|
|
|
121
|
+
// src/index.ts
|
|
122
|
+
import { createVNode } from "vue";
|
|
123
|
+
|
|
122
124
|
// src/ReactiveView.ts
|
|
123
125
|
import ObjectManager from "@razaman2/object-manager";
|
|
124
126
|
import DataManager from "@razaman2/data-manager";
|
|
125
|
-
import { h, ref, reactive, watch, nextTick, getCurrentInstance } from "vue";
|
|
127
|
+
import { h, ref, reactive, watch, nextTick, onMounted, getCurrentInstance } from "vue";
|
|
126
128
|
|
|
127
129
|
// package.json
|
|
128
130
|
var name = "@razaman2/reactive-view";
|
|
129
|
-
var version = "0.0.
|
|
131
|
+
var version = "0.0.20";
|
|
130
132
|
|
|
131
133
|
// src/ReactiveView.ts
|
|
132
134
|
var props = {
|
|
@@ -156,6 +158,7 @@ var props = {
|
|
|
156
158
|
}
|
|
157
159
|
};
|
|
158
160
|
var setup = {
|
|
161
|
+
ReactiveView: true,
|
|
159
162
|
setup: {
|
|
160
163
|
type: Function,
|
|
161
164
|
default: (param1 = {}, param2 = {}) => {
|
|
@@ -203,16 +206,15 @@ var ReactiveView_default = {
|
|
|
203
206
|
get(target, property, receiver) {
|
|
204
207
|
if (["setData", "replaceData"].includes(property)) {
|
|
205
208
|
return (...params) => {
|
|
209
|
+
var _a2, _b2;
|
|
206
210
|
const type2 = Array.isArray(defaultData) ? [] : {};
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
});
|
|
211
|
+
const beforeSetData = (_b2 = (_a2 = context.attrs["onUpdate:modelState"]) == null ? void 0 : _a2.beforeSetData) != null ? _b2 : access(component).beforeSetData;
|
|
212
|
+
if (typeof beforeSetData === "function") {
|
|
213
|
+
beforeSetData(ObjectManager.on(type2).set(...params).get(), target);
|
|
214
|
+
} else {
|
|
215
|
+
target[property](...params);
|
|
216
|
+
}
|
|
217
|
+
return target;
|
|
216
218
|
};
|
|
217
219
|
} else {
|
|
218
220
|
return Reflect.get(target, property, receiver);
|
|
@@ -221,9 +223,12 @@ var ReactiveView_default = {
|
|
|
221
223
|
});
|
|
222
224
|
const options = {
|
|
223
225
|
parent: { self: component.value },
|
|
224
|
-
self: { template,
|
|
226
|
+
self: { template, isValid, getState }
|
|
225
227
|
};
|
|
226
228
|
const _f = (_e = props2.setup(options)) != null ? _e : options, { parent = {}, self = {} } = _f, rest = __objRest(_f, ["parent", "self"]);
|
|
229
|
+
if (typeof context.attrs.debug === "function") {
|
|
230
|
+
context.attrs.debug({ isValid, component, type, data, state, config, options, props: props2, context, setup: __spreadValues({ parent, self }, rest), defaultData, getState });
|
|
231
|
+
}
|
|
227
232
|
if (props2.await instanceof Promise) {
|
|
228
233
|
nextTick(async () => {
|
|
229
234
|
getState.replaceData(await props2.await);
|
|
@@ -241,30 +246,34 @@ var ReactiveView_default = {
|
|
|
241
246
|
const config2 = typeof context.attrs["onUpdate:modelState"] === "function" ? {
|
|
242
247
|
callback: context.attrs["onUpdate:modelState"]
|
|
243
248
|
} : (_g = context.attrs["onUpdate:modelState"]) != null ? _g : {};
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
sync.value
|
|
250
|
-
|
|
251
|
-
config2.callback
|
|
252
|
-
|
|
253
|
-
|
|
249
|
+
onMounted(() => {
|
|
250
|
+
watch(() => ObjectManager.on(state).clone(), (after, before) => {
|
|
251
|
+
var _a2;
|
|
252
|
+
const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
|
|
253
|
+
const beforeStateUpdate = (_a2 = config2.beforeStateUpdate) != null ? _a2 : access(component).beforeStateUpdate;
|
|
254
|
+
if (sync.value) {
|
|
255
|
+
sync.value = false;
|
|
256
|
+
} else if (typeof config2.callback === "function") {
|
|
257
|
+
config2.callback(beforeStateUpdate ? beforeStateUpdate(diff) : diff, getState);
|
|
258
|
+
}
|
|
259
|
+
}, config2.options);
|
|
260
|
+
});
|
|
254
261
|
}
|
|
255
262
|
if (context.attrs["onUpdate:propsState"] || props2.sync) {
|
|
256
263
|
const config2 = typeof context.attrs["onUpdate:propsState"] === "function" ? {
|
|
257
264
|
callback: context.attrs["onUpdate:propsState"]
|
|
258
265
|
} : (_h = context.attrs["onUpdate:propsState"]) != null ? _h : {};
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
config2.callback
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
onMounted(() => {
|
|
267
|
+
watch(() => ObjectManager.on(props2.state).clone(), (after, before) => {
|
|
268
|
+
const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
|
|
269
|
+
if (typeof config2.callback === "function") {
|
|
270
|
+
config2.callback(diff, getState);
|
|
271
|
+
} else {
|
|
272
|
+
getState.replaceData(after);
|
|
273
|
+
}
|
|
274
|
+
sync.value = true;
|
|
275
|
+
}, config2.options);
|
|
276
|
+
});
|
|
268
277
|
}
|
|
269
278
|
return ($vue) => {
|
|
270
279
|
const setup2 = { $vue, options: parent };
|
|
@@ -286,7 +295,7 @@ var ReactiveView_default = {
|
|
|
286
295
|
};
|
|
287
296
|
|
|
288
297
|
// src/index.ts
|
|
289
|
-
var
|
|
298
|
+
var index_default = ReactiveView_default;
|
|
290
299
|
function safeRequest(request) {
|
|
291
300
|
return new Promise(async (resolve) => {
|
|
292
301
|
var _a, _b, _c, _d;
|
|
@@ -358,32 +367,33 @@ function getDate(param1, param2) {
|
|
|
358
367
|
};
|
|
359
368
|
return formatInTimeZone(datetime(), options.timezone, options.format);
|
|
360
369
|
}
|
|
361
|
-
function access($vue = {}) {
|
|
370
|
+
function access($vue = {}, alternative) {
|
|
362
371
|
var _a, _b;
|
|
363
372
|
const proxy = (target) => {
|
|
364
373
|
return new Proxy(target, {
|
|
365
374
|
get(target2, key) {
|
|
366
|
-
|
|
367
|
-
const component = { $vue: target2 };
|
|
375
|
+
const component2 = { $vue: target2 };
|
|
368
376
|
do {
|
|
369
|
-
if (
|
|
370
|
-
return
|
|
371
|
-
} else if (
|
|
372
|
-
return
|
|
377
|
+
if (key in component2.$vue) {
|
|
378
|
+
return component2.$vue[key];
|
|
379
|
+
} else if ("self" in component2.$vue && key in component2.$vue.self) {
|
|
380
|
+
return component2.$vue.self[key];
|
|
373
381
|
} else {
|
|
374
|
-
|
|
382
|
+
component2.$vue = "parent" in component2.$vue && component2.$vue.parent;
|
|
375
383
|
}
|
|
376
|
-
} while (
|
|
384
|
+
} while (component2.$vue);
|
|
385
|
+
return alternative;
|
|
377
386
|
}
|
|
378
387
|
});
|
|
379
388
|
};
|
|
389
|
+
const component = typeof $vue === "function" ? $vue() : $vue;
|
|
380
390
|
try {
|
|
381
|
-
return proxy(
|
|
391
|
+
return proxy(component.access());
|
|
382
392
|
} catch (e) {
|
|
383
393
|
try {
|
|
384
|
-
return proxy(
|
|
394
|
+
return proxy(component.value.access());
|
|
385
395
|
} catch (e2) {
|
|
386
|
-
return proxy((_b = (_a =
|
|
396
|
+
return proxy(((_b = (_a = component.value) != null ? _a : component) != null ? _b : {}) || {});
|
|
387
397
|
}
|
|
388
398
|
}
|
|
389
399
|
}
|
|
@@ -414,9 +424,22 @@ function getSubscription() {
|
|
|
414
424
|
subscription
|
|
415
425
|
};
|
|
416
426
|
}
|
|
427
|
+
function StyleParser(styles) {
|
|
428
|
+
var _a;
|
|
429
|
+
const object = (items) => items.reduce((object2, item) => {
|
|
430
|
+
return Object.assign(object2, { [item]: true });
|
|
431
|
+
}, {});
|
|
432
|
+
return (_a = Array.isArray(styles) ? object(styles) : typeof styles === "string" ? object(styles.split(/\s+/)) : Object.entries(styles).reduce((acc, [styles2, value]) => {
|
|
433
|
+
styles2.split(/\s+/).forEach((style) => {
|
|
434
|
+
acc[style] = value;
|
|
435
|
+
});
|
|
436
|
+
return acc;
|
|
437
|
+
}, {})) != null ? _a : {};
|
|
438
|
+
}
|
|
417
439
|
export {
|
|
440
|
+
StyleParser,
|
|
418
441
|
access,
|
|
419
|
-
|
|
442
|
+
index_default as default,
|
|
420
443
|
getDate,
|
|
421
444
|
getProps,
|
|
422
445
|
getReactiveViewComponent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razaman2/reactive-view",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
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",
|
|
@@ -21,17 +21,19 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@razaman2/data-manager": "^3.2.11",
|
|
24
|
-
"@razaman2/object-manager": "^3.
|
|
24
|
+
"@razaman2/object-manager": "^3.4.2",
|
|
25
25
|
"date-fns": "^4.1.0",
|
|
26
26
|
"date-fns-tz": "^3.2.0",
|
|
27
|
-
"uuid": "^11.0
|
|
27
|
+
"uuid": "^11.1.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
28
30
|
"vue": "^3.5.13"
|
|
29
31
|
},
|
|
30
32
|
"devDependencies": {
|
|
31
33
|
"@types/uuid": "^10.0.0",
|
|
32
|
-
"tsup": "^8.
|
|
33
|
-
"typescript": "^5.
|
|
34
|
-
"vitest": "^
|
|
34
|
+
"tsup": "^8.4.0",
|
|
35
|
+
"typescript": "^5.8.2",
|
|
36
|
+
"vitest": "^3.0.8"
|
|
35
37
|
},
|
|
36
38
|
"publishConfig": {
|
|
37
39
|
"access": "public"
|