@razaman2/reactive-view 0.0.7 → 0.0.8
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 +5 -36
- package/dist/index.d.ts +5 -36
- package/dist/index.js +51 -70
- package/dist/index.mjs +51 -65
- package/package.json +46 -46
package/dist/index.d.mts
CHANGED
|
@@ -35,6 +35,7 @@ declare const _default: {
|
|
|
35
35
|
defaultData: {};
|
|
36
36
|
model: {};
|
|
37
37
|
state: {};
|
|
38
|
+
await: {};
|
|
38
39
|
getDefaultData: {
|
|
39
40
|
type: FunctionConstructor;
|
|
40
41
|
default: (data?: {}) => {};
|
|
@@ -58,45 +59,13 @@ declare const _default: {
|
|
|
58
59
|
setup(props: Record<string, any>, context: SetupContext): ($vue: ComponentPublicInstance & any) => any;
|
|
59
60
|
};
|
|
60
61
|
|
|
61
|
-
/**
|
|
62
|
-
* uppercase the first character of each word in the input string.
|
|
63
|
-
* @deprecated
|
|
64
|
-
* @description
|
|
65
|
-
* (test -> Test), (TEST -> Test), (test test -> Test Test)
|
|
66
|
-
*/
|
|
67
|
-
declare function ucf(string: string): string;
|
|
68
|
-
/**
|
|
69
|
-
* uppercase the first character of each word that follows a specified token
|
|
70
|
-
* @deprecated
|
|
71
|
-
* @description
|
|
72
|
-
* (test-test -> test-Test), (TEST-TEST -> TEST-Test), (test/test -> test/Test)
|
|
73
|
-
*/
|
|
74
|
-
declare function ucfat(string: string, tokens: Array<string>): string;
|
|
75
|
-
/**
|
|
76
|
-
* @deprecated
|
|
77
|
-
*/
|
|
78
|
-
declare function getRoot(vue: ComponentPublicInstance): any;
|
|
79
|
-
/**
|
|
80
|
-
* @deprecated
|
|
81
|
-
*/
|
|
82
|
-
declare function getRef(component: ComponentPublicInstance, ref: UnwrapRef<any>): ComponentPublicInstance;
|
|
83
|
-
/**
|
|
84
|
-
* @deprecated
|
|
85
|
-
*/
|
|
86
|
-
declare function expose(vue: any, props: Record<string, any>): Record<string, any>;
|
|
87
62
|
type Accessible = {
|
|
88
63
|
parent: {
|
|
89
64
|
self: Record<string | symbol, any>;
|
|
90
65
|
};
|
|
91
66
|
self: Record<string | symbol, any>;
|
|
92
|
-
access?:
|
|
93
|
-
value?:
|
|
94
|
-
parent: {
|
|
95
|
-
self: Record<string | symbol, any>;
|
|
96
|
-
};
|
|
97
|
-
self: Record<string | symbol, any>;
|
|
98
|
-
access?: Function;
|
|
99
|
-
};
|
|
67
|
+
access?: () => Accessible;
|
|
68
|
+
value?: Accessible;
|
|
100
69
|
};
|
|
101
70
|
type PropOptions = {
|
|
102
71
|
exclude: string | Array<string>;
|
|
@@ -126,6 +95,7 @@ declare function getDate(timestamp: {
|
|
|
126
95
|
format?: string;
|
|
127
96
|
timezone?: string;
|
|
128
97
|
}): string;
|
|
98
|
+
declare function access<T extends ComponentPublicInstance & Accessible>($vue?: T | UnwrapRef<any>): Record<string | symbol, any>;
|
|
129
99
|
declare function getSubscription(): {
|
|
130
100
|
addSubscription(name: string, handler?: () => boolean, data?: any): void;
|
|
131
101
|
replaceSubscription(name: string, handler?: () => boolean, data?: any): void;
|
|
@@ -135,6 +105,5 @@ declare function getSubscription(): {
|
|
|
135
105
|
subscriptions: any[];
|
|
136
106
|
subscription: Subscription;
|
|
137
107
|
};
|
|
138
|
-
declare function access<T extends ComponentPublicInstance & Accessible>($vue?: T | UnwrapRef<any>): any;
|
|
139
108
|
|
|
140
|
-
export { access, _default as default,
|
|
109
|
+
export { access, _default as default, getDate, getProps, getSubscription, safeRequest, setup };
|
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ declare const _default: {
|
|
|
35
35
|
defaultData: {};
|
|
36
36
|
model: {};
|
|
37
37
|
state: {};
|
|
38
|
+
await: {};
|
|
38
39
|
getDefaultData: {
|
|
39
40
|
type: FunctionConstructor;
|
|
40
41
|
default: (data?: {}) => {};
|
|
@@ -58,45 +59,13 @@ declare const _default: {
|
|
|
58
59
|
setup(props: Record<string, any>, context: SetupContext): ($vue: ComponentPublicInstance & any) => any;
|
|
59
60
|
};
|
|
60
61
|
|
|
61
|
-
/**
|
|
62
|
-
* uppercase the first character of each word in the input string.
|
|
63
|
-
* @deprecated
|
|
64
|
-
* @description
|
|
65
|
-
* (test -> Test), (TEST -> Test), (test test -> Test Test)
|
|
66
|
-
*/
|
|
67
|
-
declare function ucf(string: string): string;
|
|
68
|
-
/**
|
|
69
|
-
* uppercase the first character of each word that follows a specified token
|
|
70
|
-
* @deprecated
|
|
71
|
-
* @description
|
|
72
|
-
* (test-test -> test-Test), (TEST-TEST -> TEST-Test), (test/test -> test/Test)
|
|
73
|
-
*/
|
|
74
|
-
declare function ucfat(string: string, tokens: Array<string>): string;
|
|
75
|
-
/**
|
|
76
|
-
* @deprecated
|
|
77
|
-
*/
|
|
78
|
-
declare function getRoot(vue: ComponentPublicInstance): any;
|
|
79
|
-
/**
|
|
80
|
-
* @deprecated
|
|
81
|
-
*/
|
|
82
|
-
declare function getRef(component: ComponentPublicInstance, ref: UnwrapRef<any>): ComponentPublicInstance;
|
|
83
|
-
/**
|
|
84
|
-
* @deprecated
|
|
85
|
-
*/
|
|
86
|
-
declare function expose(vue: any, props: Record<string, any>): Record<string, any>;
|
|
87
62
|
type Accessible = {
|
|
88
63
|
parent: {
|
|
89
64
|
self: Record<string | symbol, any>;
|
|
90
65
|
};
|
|
91
66
|
self: Record<string | symbol, any>;
|
|
92
|
-
access?:
|
|
93
|
-
value?:
|
|
94
|
-
parent: {
|
|
95
|
-
self: Record<string | symbol, any>;
|
|
96
|
-
};
|
|
97
|
-
self: Record<string | symbol, any>;
|
|
98
|
-
access?: Function;
|
|
99
|
-
};
|
|
67
|
+
access?: () => Accessible;
|
|
68
|
+
value?: Accessible;
|
|
100
69
|
};
|
|
101
70
|
type PropOptions = {
|
|
102
71
|
exclude: string | Array<string>;
|
|
@@ -126,6 +95,7 @@ declare function getDate(timestamp: {
|
|
|
126
95
|
format?: string;
|
|
127
96
|
timezone?: string;
|
|
128
97
|
}): string;
|
|
98
|
+
declare function access<T extends ComponentPublicInstance & Accessible>($vue?: T | UnwrapRef<any>): Record<string | symbol, any>;
|
|
129
99
|
declare function getSubscription(): {
|
|
130
100
|
addSubscription(name: string, handler?: () => boolean, data?: any): void;
|
|
131
101
|
replaceSubscription(name: string, handler?: () => boolean, data?: any): void;
|
|
@@ -135,6 +105,5 @@ declare function getSubscription(): {
|
|
|
135
105
|
subscriptions: any[];
|
|
136
106
|
subscription: Subscription;
|
|
137
107
|
};
|
|
138
|
-
declare function access<T extends ComponentPublicInstance & Accessible>($vue?: T | UnwrapRef<any>): any;
|
|
139
108
|
|
|
140
|
-
export { access, _default as default,
|
|
109
|
+
export { access, _default as default, getDate, getProps, getSubscription, safeRequest, setup };
|
package/dist/index.js
CHANGED
|
@@ -58,16 +58,11 @@ var src_exports = {};
|
|
|
58
58
|
__export(src_exports, {
|
|
59
59
|
access: () => access,
|
|
60
60
|
default: () => src_default,
|
|
61
|
-
expose: () => expose,
|
|
62
61
|
getDate: () => getDate,
|
|
63
62
|
getProps: () => getProps,
|
|
64
|
-
getRef: () => getRef,
|
|
65
|
-
getRoot: () => getRoot,
|
|
66
63
|
getSubscription: () => getSubscription,
|
|
67
64
|
safeRequest: () => safeRequest,
|
|
68
|
-
setup: () => setup
|
|
69
|
-
ucf: () => ucf,
|
|
70
|
-
ucfat: () => ucfat
|
|
65
|
+
setup: () => setup
|
|
71
66
|
});
|
|
72
67
|
module.exports = __toCommonJS(src_exports);
|
|
73
68
|
var import_date_fns_tz = require("date-fns-tz");
|
|
@@ -166,7 +161,7 @@ var import_data_manager = __toESM(require("@razaman2/data-manager"));
|
|
|
166
161
|
|
|
167
162
|
// package.json
|
|
168
163
|
var name = "@razaman2/reactive-view";
|
|
169
|
-
var version = "0.0.
|
|
164
|
+
var version = "0.0.8";
|
|
170
165
|
|
|
171
166
|
// src/ReactiveView.ts
|
|
172
167
|
var import_vue = require("vue");
|
|
@@ -176,6 +171,7 @@ var props = {
|
|
|
176
171
|
defaultData: {},
|
|
177
172
|
model: {},
|
|
178
173
|
state: {},
|
|
174
|
+
await: {},
|
|
179
175
|
getDefaultData: {
|
|
180
176
|
type: Function,
|
|
181
177
|
default: (data = {}) => data
|
|
@@ -205,7 +201,7 @@ var setup = {
|
|
|
205
201
|
var ReactiveView_default = {
|
|
206
202
|
props: __spreadValues(__spreadValues({}, setup), props),
|
|
207
203
|
setup(props2, context) {
|
|
208
|
-
var _a, _b, _c, _d, _e;
|
|
204
|
+
var _a, _b, _c, _d, _e, _g;
|
|
209
205
|
const template = (vue, options2) => {
|
|
210
206
|
var _a2, _b2, _c2;
|
|
211
207
|
const vnode = context.slots.default ? (0, import_vue.h)(
|
|
@@ -218,28 +214,39 @@ var ReactiveView_default = {
|
|
|
218
214
|
textAlign: "center"
|
|
219
215
|
}
|
|
220
216
|
}, context.attrs), `${props2.modelName}: ${name}@${version}`);
|
|
221
|
-
return (_c2 = (_b2 = (_a2 = context.slots).template) == null ? void 0 : _b2.call(_a2, { vue, vnode })) != null ? _c2 : vnode;
|
|
217
|
+
return (_c2 = (_b2 = (_a2 = context.slots).template) == null ? void 0 : _b2.call(_a2, { $vue: vue, vnode })) != null ? _c2 : vnode;
|
|
222
218
|
};
|
|
223
219
|
const isValid = (0, import_vue.ref)(false);
|
|
224
220
|
const defaultData = props2.getDefaultData(
|
|
225
221
|
Array.isArray(props2.state) ? (_a = props2.defaultData) != null ? _a : [] : (_b = props2.defaultData) != null ? _b : {}
|
|
226
222
|
);
|
|
227
223
|
const defaultType = Array.isArray(defaultData) ? [] : {};
|
|
228
|
-
const state = (0, import_vue.reactive)(import_data_manager.default.transform((_c = props2.state) != null ? _c : defaultType));
|
|
224
|
+
const state = (0, import_vue.reactive)(import_data_manager.default.transform(props2.await ? defaultType : (_c = props2.state) != null ? _c : defaultType));
|
|
229
225
|
const config = {
|
|
230
226
|
defaultData,
|
|
231
227
|
data: state,
|
|
232
228
|
name: props2.modelName,
|
|
233
229
|
logging: props2.logging,
|
|
234
|
-
notifications: props2.notifications
|
|
230
|
+
notifications: props2.notifications,
|
|
231
|
+
subscriptions: props2.subscriptions
|
|
235
232
|
};
|
|
236
233
|
const getState = props2.model ? typeof props2.model === "function" ? props2.model(config) : props2.model : new import_data_manager.default(config);
|
|
237
234
|
const sync = (0, import_vue.ref)(false);
|
|
235
|
+
const options = {
|
|
236
|
+
parent: { self: (_d = (0, import_vue.getCurrentInstance)()) == null ? void 0 : _d.proxy },
|
|
237
|
+
self: { template, isValid, getState }
|
|
238
|
+
};
|
|
239
|
+
const _f = (_e = props2.setup(options)) != null ? _e : options, { parent = {}, self = {} } = _f, rest = __objRest(_f, ["parent", "self"]);
|
|
240
|
+
if (props2.await instanceof Promise) {
|
|
241
|
+
(0, import_vue.nextTick)(async () => {
|
|
242
|
+
getState.replaceData(await props2.await);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
238
245
|
if (context.attrs["onUpdate:modelState"]) {
|
|
239
246
|
const config2 = typeof context.attrs["onUpdate:modelState"] === "function" ? { callback: context.attrs["onUpdate:modelState"] } : context.attrs["onUpdate:modelState"];
|
|
240
247
|
(0, import_vue.watch)(() => import_object_manager.default.on(state).clone(), (after, before) => {
|
|
241
248
|
var _a2;
|
|
242
|
-
const transform = (_a2 = config2.transform) != null ? _a2 : access(
|
|
249
|
+
const transform = (_a2 = config2.transform) != null ? _a2 : access({ parent, self }).$transform;
|
|
243
250
|
const diff = {
|
|
244
251
|
before: (before == null ? void 0 : before.hasOwnProperty("")) ? before[""] : before,
|
|
245
252
|
after: (after == null ? void 0 : after.hasOwnProperty("")) ? after[""] : after
|
|
@@ -252,7 +259,7 @@ var ReactiveView_default = {
|
|
|
252
259
|
}, config2.options);
|
|
253
260
|
}
|
|
254
261
|
if (context.attrs["onUpdate:propsState"] || props2.sync) {
|
|
255
|
-
const config2 = (
|
|
262
|
+
const config2 = (_g = typeof context.attrs["onUpdate:propsState"] === "function" ? { callback: context.attrs["onUpdate:propsState"] } : context.attrs["onUpdate:propsState"]) != null ? _g : {};
|
|
256
263
|
(0, import_vue.watch)(() => props2.state, (after, before) => {
|
|
257
264
|
if (props2.sync && typeof config2.callback !== "function") {
|
|
258
265
|
getState.replaceData(after);
|
|
@@ -262,13 +269,8 @@ var ReactiveView_default = {
|
|
|
262
269
|
sync.value = true;
|
|
263
270
|
}, config2.options);
|
|
264
271
|
}
|
|
265
|
-
const options = {
|
|
266
|
-
parent: {},
|
|
267
|
-
self: { template, isValid, getState }
|
|
268
|
-
};
|
|
269
|
-
const _f = (_e = props2.setup(options)) != null ? _e : options, { parent = options.parent, self = options.self } = _f, rest = __objRest(_f, ["parent", "self"]);
|
|
270
272
|
return ($vue) => {
|
|
271
|
-
const setup2 = { $vue, options:
|
|
273
|
+
const setup2 = { $vue, options: parent };
|
|
272
274
|
while (setup2.options) {
|
|
273
275
|
Object.defineProperties(setup2.$vue, Object.assign({
|
|
274
276
|
access: {
|
|
@@ -286,32 +288,6 @@ var ReactiveView_default = {
|
|
|
286
288
|
|
|
287
289
|
// src/index.ts
|
|
288
290
|
var src_default = ReactiveView_default;
|
|
289
|
-
function ucf(string) {
|
|
290
|
-
return string.split(/\s+/).map((string2) => {
|
|
291
|
-
return string2.toLowerCase().replace(/^(\w)/, ($1) => $1.toUpperCase());
|
|
292
|
-
}).join(" ");
|
|
293
|
-
}
|
|
294
|
-
function ucfat(string, tokens) {
|
|
295
|
-
const pattern = RegExp(`(?<=(?:${tokens.join("|")}))(\\w)(\\w*)`, "g");
|
|
296
|
-
return string.replace(pattern, ($1, $2, $3) => `${$2.toUpperCase()}${$3.toLowerCase()}`);
|
|
297
|
-
}
|
|
298
|
-
function getRoot(vue) {
|
|
299
|
-
var _a, _b, _c;
|
|
300
|
-
return (_c = (_a = typeof vue.$attrs.root === "function" ? vue.$attrs.root() : vue.$attrs.root) != null ? _a : vue.$root) != null ? _c : (_b = vue.$parent) == null ? void 0 : _b.$root;
|
|
301
|
-
}
|
|
302
|
-
function getRef(component, ref2) {
|
|
303
|
-
safeRequest({
|
|
304
|
-
try: async () => component.$props.ref.value = component,
|
|
305
|
-
alternative: false
|
|
306
|
-
});
|
|
307
|
-
return ref2.value = component;
|
|
308
|
-
}
|
|
309
|
-
function expose(vue, props2) {
|
|
310
|
-
Object.entries(Object.getOwnPropertyDescriptors(props2)).forEach(([key, val]) => {
|
|
311
|
-
Object.defineProperty(vue, key, val);
|
|
312
|
-
});
|
|
313
|
-
return props2;
|
|
314
|
-
}
|
|
315
291
|
function safeRequest(request) {
|
|
316
292
|
return new Promise(async (resolve) => {
|
|
317
293
|
var _a, _b, _c, _d;
|
|
@@ -369,6 +345,35 @@ function getDate(param1, param2) {
|
|
|
369
345
|
};
|
|
370
346
|
return (0, import_date_fns_tz.formatInTimeZone)(datetime(), options.timezone, options.format);
|
|
371
347
|
}
|
|
348
|
+
function access($vue = {}) {
|
|
349
|
+
var _a, _b;
|
|
350
|
+
const proxy = (target) => {
|
|
351
|
+
return new Proxy(target, {
|
|
352
|
+
get(target2, key) {
|
|
353
|
+
var _a2, _b2;
|
|
354
|
+
const component = { $vue: target2 };
|
|
355
|
+
do {
|
|
356
|
+
if ((_a2 = component.$vue) == null ? void 0 : _a2[key]) {
|
|
357
|
+
return component.$vue[key];
|
|
358
|
+
} else if ((_b2 = component.$vue.self) == null ? void 0 : _b2[key]) {
|
|
359
|
+
return component.$vue.self[key];
|
|
360
|
+
} else {
|
|
361
|
+
component.$vue = component.$vue.parent;
|
|
362
|
+
}
|
|
363
|
+
} while (component.$vue);
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
};
|
|
367
|
+
try {
|
|
368
|
+
return proxy($vue.access());
|
|
369
|
+
} catch (e) {
|
|
370
|
+
try {
|
|
371
|
+
return proxy($vue.value.access());
|
|
372
|
+
} catch (e2) {
|
|
373
|
+
return proxy((_b = (_a = $vue.value) != null ? _a : $vue) != null ? _b : {});
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
372
377
|
function getSubscription() {
|
|
373
378
|
const subscriptions = [];
|
|
374
379
|
const subscription = Subscriptions.get();
|
|
@@ -396,36 +401,12 @@ function getSubscription() {
|
|
|
396
401
|
subscription
|
|
397
402
|
};
|
|
398
403
|
}
|
|
399
|
-
function access($vue = {}) {
|
|
400
|
-
var _a, _b, _c;
|
|
401
|
-
const target = typeof ($vue == null ? void 0 : $vue.access) === "function" ? $vue.access() : (_c = (_b = ($vue == null ? void 0 : $vue.value) && typeof ((_a = $vue.value) == null ? void 0 : _a.access) === "function" ? $vue.value.access() : $vue == null ? void 0 : $vue.value) != null ? _b : $vue) != null ? _c : {};
|
|
402
|
-
return new Proxy(target, {
|
|
403
|
-
get(target2, key) {
|
|
404
|
-
var _a2, _b2;
|
|
405
|
-
const component = { $vue: target2 };
|
|
406
|
-
do {
|
|
407
|
-
if ((_a2 = component.$vue) == null ? void 0 : _a2[key]) {
|
|
408
|
-
return component.$vue[key];
|
|
409
|
-
} else if ((_b2 = component.$vue.self) == null ? void 0 : _b2[key]) {
|
|
410
|
-
return component.$vue.self[key];
|
|
411
|
-
} else {
|
|
412
|
-
component.$vue = component.$vue.parent;
|
|
413
|
-
}
|
|
414
|
-
} while (component.$vue);
|
|
415
|
-
}
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
404
|
// Annotate the CommonJS export names for ESM import in node:
|
|
419
405
|
0 && (module.exports = {
|
|
420
406
|
access,
|
|
421
|
-
expose,
|
|
422
407
|
getDate,
|
|
423
408
|
getProps,
|
|
424
|
-
getRef,
|
|
425
|
-
getRoot,
|
|
426
409
|
getSubscription,
|
|
427
410
|
safeRequest,
|
|
428
|
-
setup
|
|
429
|
-
ucf,
|
|
430
|
-
ucfat
|
|
411
|
+
setup
|
|
431
412
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -124,16 +124,17 @@ import DataManager from "@razaman2/data-manager";
|
|
|
124
124
|
|
|
125
125
|
// package.json
|
|
126
126
|
var name = "@razaman2/reactive-view";
|
|
127
|
-
var version = "0.0.
|
|
127
|
+
var version = "0.0.8";
|
|
128
128
|
|
|
129
129
|
// src/ReactiveView.ts
|
|
130
|
-
import { h, ref, reactive, watch } from "vue";
|
|
130
|
+
import { h, ref, reactive, watch, nextTick, getCurrentInstance } from "vue";
|
|
131
131
|
var props = {
|
|
132
132
|
notifications: Object,
|
|
133
133
|
subscriptions: Object,
|
|
134
134
|
defaultData: {},
|
|
135
135
|
model: {},
|
|
136
136
|
state: {},
|
|
137
|
+
await: {},
|
|
137
138
|
getDefaultData: {
|
|
138
139
|
type: Function,
|
|
139
140
|
default: (data = {}) => data
|
|
@@ -163,7 +164,7 @@ var setup = {
|
|
|
163
164
|
var ReactiveView_default = {
|
|
164
165
|
props: __spreadValues(__spreadValues({}, setup), props),
|
|
165
166
|
setup(props2, context) {
|
|
166
|
-
var _a, _b, _c, _d, _e;
|
|
167
|
+
var _a, _b, _c, _d, _e, _g;
|
|
167
168
|
const template = (vue, options2) => {
|
|
168
169
|
var _a2, _b2, _c2;
|
|
169
170
|
const vnode = context.slots.default ? h(
|
|
@@ -176,28 +177,39 @@ var ReactiveView_default = {
|
|
|
176
177
|
textAlign: "center"
|
|
177
178
|
}
|
|
178
179
|
}, context.attrs), `${props2.modelName}: ${name}@${version}`);
|
|
179
|
-
return (_c2 = (_b2 = (_a2 = context.slots).template) == null ? void 0 : _b2.call(_a2, { vue, vnode })) != null ? _c2 : vnode;
|
|
180
|
+
return (_c2 = (_b2 = (_a2 = context.slots).template) == null ? void 0 : _b2.call(_a2, { $vue: vue, vnode })) != null ? _c2 : vnode;
|
|
180
181
|
};
|
|
181
182
|
const isValid = ref(false);
|
|
182
183
|
const defaultData = props2.getDefaultData(
|
|
183
184
|
Array.isArray(props2.state) ? (_a = props2.defaultData) != null ? _a : [] : (_b = props2.defaultData) != null ? _b : {}
|
|
184
185
|
);
|
|
185
186
|
const defaultType = Array.isArray(defaultData) ? [] : {};
|
|
186
|
-
const state = reactive(DataManager.transform((_c = props2.state) != null ? _c : defaultType));
|
|
187
|
+
const state = reactive(DataManager.transform(props2.await ? defaultType : (_c = props2.state) != null ? _c : defaultType));
|
|
187
188
|
const config = {
|
|
188
189
|
defaultData,
|
|
189
190
|
data: state,
|
|
190
191
|
name: props2.modelName,
|
|
191
192
|
logging: props2.logging,
|
|
192
|
-
notifications: props2.notifications
|
|
193
|
+
notifications: props2.notifications,
|
|
194
|
+
subscriptions: props2.subscriptions
|
|
193
195
|
};
|
|
194
196
|
const getState = props2.model ? typeof props2.model === "function" ? props2.model(config) : props2.model : new DataManager(config);
|
|
195
197
|
const sync = ref(false);
|
|
198
|
+
const options = {
|
|
199
|
+
parent: { self: (_d = getCurrentInstance()) == null ? void 0 : _d.proxy },
|
|
200
|
+
self: { template, isValid, getState }
|
|
201
|
+
};
|
|
202
|
+
const _f = (_e = props2.setup(options)) != null ? _e : options, { parent = {}, self = {} } = _f, rest = __objRest(_f, ["parent", "self"]);
|
|
203
|
+
if (props2.await instanceof Promise) {
|
|
204
|
+
nextTick(async () => {
|
|
205
|
+
getState.replaceData(await props2.await);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
196
208
|
if (context.attrs["onUpdate:modelState"]) {
|
|
197
209
|
const config2 = typeof context.attrs["onUpdate:modelState"] === "function" ? { callback: context.attrs["onUpdate:modelState"] } : context.attrs["onUpdate:modelState"];
|
|
198
210
|
watch(() => ObjectManager.on(state).clone(), (after, before) => {
|
|
199
211
|
var _a2;
|
|
200
|
-
const transform = (_a2 = config2.transform) != null ? _a2 : access(
|
|
212
|
+
const transform = (_a2 = config2.transform) != null ? _a2 : access({ parent, self }).$transform;
|
|
201
213
|
const diff = {
|
|
202
214
|
before: (before == null ? void 0 : before.hasOwnProperty("")) ? before[""] : before,
|
|
203
215
|
after: (after == null ? void 0 : after.hasOwnProperty("")) ? after[""] : after
|
|
@@ -210,7 +222,7 @@ var ReactiveView_default = {
|
|
|
210
222
|
}, config2.options);
|
|
211
223
|
}
|
|
212
224
|
if (context.attrs["onUpdate:propsState"] || props2.sync) {
|
|
213
|
-
const config2 = (
|
|
225
|
+
const config2 = (_g = typeof context.attrs["onUpdate:propsState"] === "function" ? { callback: context.attrs["onUpdate:propsState"] } : context.attrs["onUpdate:propsState"]) != null ? _g : {};
|
|
214
226
|
watch(() => props2.state, (after, before) => {
|
|
215
227
|
if (props2.sync && typeof config2.callback !== "function") {
|
|
216
228
|
getState.replaceData(after);
|
|
@@ -220,13 +232,8 @@ var ReactiveView_default = {
|
|
|
220
232
|
sync.value = true;
|
|
221
233
|
}, config2.options);
|
|
222
234
|
}
|
|
223
|
-
const options = {
|
|
224
|
-
parent: {},
|
|
225
|
-
self: { template, isValid, getState }
|
|
226
|
-
};
|
|
227
|
-
const _f = (_e = props2.setup(options)) != null ? _e : options, { parent = options.parent, self = options.self } = _f, rest = __objRest(_f, ["parent", "self"]);
|
|
228
235
|
return ($vue) => {
|
|
229
|
-
const setup2 = { $vue, options:
|
|
236
|
+
const setup2 = { $vue, options: parent };
|
|
230
237
|
while (setup2.options) {
|
|
231
238
|
Object.defineProperties(setup2.$vue, Object.assign({
|
|
232
239
|
access: {
|
|
@@ -244,32 +251,6 @@ var ReactiveView_default = {
|
|
|
244
251
|
|
|
245
252
|
// src/index.ts
|
|
246
253
|
var src_default = ReactiveView_default;
|
|
247
|
-
function ucf(string) {
|
|
248
|
-
return string.split(/\s+/).map((string2) => {
|
|
249
|
-
return string2.toLowerCase().replace(/^(\w)/, ($1) => $1.toUpperCase());
|
|
250
|
-
}).join(" ");
|
|
251
|
-
}
|
|
252
|
-
function ucfat(string, tokens) {
|
|
253
|
-
const pattern = RegExp(`(?<=(?:${tokens.join("|")}))(\\w)(\\w*)`, "g");
|
|
254
|
-
return string.replace(pattern, ($1, $2, $3) => `${$2.toUpperCase()}${$3.toLowerCase()}`);
|
|
255
|
-
}
|
|
256
|
-
function getRoot(vue) {
|
|
257
|
-
var _a, _b, _c;
|
|
258
|
-
return (_c = (_a = typeof vue.$attrs.root === "function" ? vue.$attrs.root() : vue.$attrs.root) != null ? _a : vue.$root) != null ? _c : (_b = vue.$parent) == null ? void 0 : _b.$root;
|
|
259
|
-
}
|
|
260
|
-
function getRef(component, ref2) {
|
|
261
|
-
safeRequest({
|
|
262
|
-
try: async () => component.$props.ref.value = component,
|
|
263
|
-
alternative: false
|
|
264
|
-
});
|
|
265
|
-
return ref2.value = component;
|
|
266
|
-
}
|
|
267
|
-
function expose(vue, props2) {
|
|
268
|
-
Object.entries(Object.getOwnPropertyDescriptors(props2)).forEach(([key, val]) => {
|
|
269
|
-
Object.defineProperty(vue, key, val);
|
|
270
|
-
});
|
|
271
|
-
return props2;
|
|
272
|
-
}
|
|
273
254
|
function safeRequest(request) {
|
|
274
255
|
return new Promise(async (resolve) => {
|
|
275
256
|
var _a, _b, _c, _d;
|
|
@@ -327,6 +308,35 @@ function getDate(param1, param2) {
|
|
|
327
308
|
};
|
|
328
309
|
return formatInTimeZone(datetime(), options.timezone, options.format);
|
|
329
310
|
}
|
|
311
|
+
function access($vue = {}) {
|
|
312
|
+
var _a, _b;
|
|
313
|
+
const proxy = (target) => {
|
|
314
|
+
return new Proxy(target, {
|
|
315
|
+
get(target2, key) {
|
|
316
|
+
var _a2, _b2;
|
|
317
|
+
const component = { $vue: target2 };
|
|
318
|
+
do {
|
|
319
|
+
if ((_a2 = component.$vue) == null ? void 0 : _a2[key]) {
|
|
320
|
+
return component.$vue[key];
|
|
321
|
+
} else if ((_b2 = component.$vue.self) == null ? void 0 : _b2[key]) {
|
|
322
|
+
return component.$vue.self[key];
|
|
323
|
+
} else {
|
|
324
|
+
component.$vue = component.$vue.parent;
|
|
325
|
+
}
|
|
326
|
+
} while (component.$vue);
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
};
|
|
330
|
+
try {
|
|
331
|
+
return proxy($vue.access());
|
|
332
|
+
} catch (e) {
|
|
333
|
+
try {
|
|
334
|
+
return proxy($vue.value.access());
|
|
335
|
+
} catch (e2) {
|
|
336
|
+
return proxy((_b = (_a = $vue.value) != null ? _a : $vue) != null ? _b : {});
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
330
340
|
function getSubscription() {
|
|
331
341
|
const subscriptions = [];
|
|
332
342
|
const subscription = Subscriptions.get();
|
|
@@ -354,36 +364,12 @@ function getSubscription() {
|
|
|
354
364
|
subscription
|
|
355
365
|
};
|
|
356
366
|
}
|
|
357
|
-
function access($vue = {}) {
|
|
358
|
-
var _a, _b, _c;
|
|
359
|
-
const target = typeof ($vue == null ? void 0 : $vue.access) === "function" ? $vue.access() : (_c = (_b = ($vue == null ? void 0 : $vue.value) && typeof ((_a = $vue.value) == null ? void 0 : _a.access) === "function" ? $vue.value.access() : $vue == null ? void 0 : $vue.value) != null ? _b : $vue) != null ? _c : {};
|
|
360
|
-
return new Proxy(target, {
|
|
361
|
-
get(target2, key) {
|
|
362
|
-
var _a2, _b2;
|
|
363
|
-
const component = { $vue: target2 };
|
|
364
|
-
do {
|
|
365
|
-
if ((_a2 = component.$vue) == null ? void 0 : _a2[key]) {
|
|
366
|
-
return component.$vue[key];
|
|
367
|
-
} else if ((_b2 = component.$vue.self) == null ? void 0 : _b2[key]) {
|
|
368
|
-
return component.$vue.self[key];
|
|
369
|
-
} else {
|
|
370
|
-
component.$vue = component.$vue.parent;
|
|
371
|
-
}
|
|
372
|
-
} while (component.$vue);
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
367
|
export {
|
|
377
368
|
access,
|
|
378
369
|
src_default as default,
|
|
379
|
-
expose,
|
|
380
370
|
getDate,
|
|
381
371
|
getProps,
|
|
382
|
-
getRef,
|
|
383
|
-
getRoot,
|
|
384
372
|
getSubscription,
|
|
385
373
|
safeRequest,
|
|
386
|
-
setup
|
|
387
|
-
ucf,
|
|
388
|
-
ucfat
|
|
374
|
+
setup
|
|
389
375
|
};
|
package/package.json
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
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
|
-
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"vue",
|
|
15
|
-
"vue-helper",
|
|
16
|
-
"reactive-view",
|
|
17
|
-
"vue-class-component"
|
|
18
|
-
],
|
|
19
|
-
"author": "razaman2",
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"@razaman2/
|
|
23
|
-
"@razaman2/
|
|
24
|
-
"@razaman2/object-manager": "^3.3.
|
|
25
|
-
"date-fns": "^
|
|
26
|
-
"date-fns-tz": "^
|
|
27
|
-
"uuid": "^9.0.1",
|
|
28
|
-
"vue": "^3.
|
|
29
|
-
},
|
|
30
|
-
"devDependencies": {
|
|
31
|
-
"@types/uuid": "^9.0.
|
|
32
|
-
"tsup": "^8.0.
|
|
33
|
-
"typescript": "^5.
|
|
34
|
-
"vitest": "^1.
|
|
35
|
-
},
|
|
36
|
-
"publishConfig": {
|
|
37
|
-
"access": "public"
|
|
38
|
-
},
|
|
39
|
-
"files": [
|
|
40
|
-
"dist"
|
|
41
|
-
],
|
|
42
|
-
"repository": {
|
|
43
|
-
"type": "git",
|
|
44
|
-
"url": "https://github.com/razaman2/reactive-view.git"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@razaman2/reactive-view",
|
|
3
|
+
"version": "0.0.8",
|
|
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
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"vue",
|
|
15
|
+
"vue-helper",
|
|
16
|
+
"reactive-view",
|
|
17
|
+
"vue-class-component"
|
|
18
|
+
],
|
|
19
|
+
"author": "razaman2",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@razaman2/collection-proxy": "^0.0.11",
|
|
23
|
+
"@razaman2/data-manager": "^3.2.8",
|
|
24
|
+
"@razaman2/object-manager": "^3.3.9",
|
|
25
|
+
"date-fns": "^3.6.0",
|
|
26
|
+
"date-fns-tz": "^3.1.3",
|
|
27
|
+
"uuid": "^9.0.1",
|
|
28
|
+
"vue": "^3.4.27"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/uuid": "^9.0.8",
|
|
32
|
+
"tsup": "^8.0.2",
|
|
33
|
+
"typescript": "^5.4.5",
|
|
34
|
+
"vitest": "^1.6.0"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist"
|
|
41
|
+
],
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/razaman2/reactive-view.git"
|
|
45
|
+
}
|
|
46
|
+
}
|