@razaman2/reactive-view 0.0.31 → 0.0.34
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 +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +86 -27
- package/dist/index.mjs +86 -28
- package/package.json +46 -45
package/dist/index.d.mts
CHANGED
|
@@ -44,6 +44,7 @@ declare const _default: {
|
|
|
44
44
|
props: {
|
|
45
45
|
setup: {};
|
|
46
46
|
ReactiveView: {
|
|
47
|
+
type: BooleanConstructor;
|
|
47
48
|
default: boolean;
|
|
48
49
|
};
|
|
49
50
|
instance: {
|
|
@@ -52,9 +53,7 @@ declare const _default: {
|
|
|
52
53
|
notifications: ObjectConstructor;
|
|
53
54
|
subscriptions: ObjectConstructor;
|
|
54
55
|
beforeSetData: FunctionConstructor;
|
|
55
|
-
data: {
|
|
56
|
-
default: {};
|
|
57
|
-
};
|
|
56
|
+
data: {};
|
|
58
57
|
defaultData: {};
|
|
59
58
|
getDefaultData: {
|
|
60
59
|
type: FunctionConstructor;
|
|
@@ -115,5 +114,6 @@ declare function useSubscription(): {
|
|
|
115
114
|
};
|
|
116
115
|
declare function StyleParser(styles?: Array<string> | Record<string, boolean> | string): {};
|
|
117
116
|
declare function MergeStyles(...params: any): any;
|
|
117
|
+
declare const extendVnode: (component: Record<string, any>, element: any) => Record<string, (props?: Record<string, any>, slots?: Record<string, any> | ((slots: Record<string, any>) => Record<string, any>)) => any>;
|
|
118
118
|
|
|
119
|
-
export { MergeStyles, StyleParser, access, _default as default, getDate, getProps, getReactiveViewComponent, safeRequest, setup, useSubscription };
|
|
119
|
+
export { MergeStyles, StyleParser, access, _default as default, extendVnode, getDate, getProps, getReactiveViewComponent, safeRequest, setup, useSubscription };
|
package/dist/index.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ declare const _default: {
|
|
|
44
44
|
props: {
|
|
45
45
|
setup: {};
|
|
46
46
|
ReactiveView: {
|
|
47
|
+
type: BooleanConstructor;
|
|
47
48
|
default: boolean;
|
|
48
49
|
};
|
|
49
50
|
instance: {
|
|
@@ -52,9 +53,7 @@ declare const _default: {
|
|
|
52
53
|
notifications: ObjectConstructor;
|
|
53
54
|
subscriptions: ObjectConstructor;
|
|
54
55
|
beforeSetData: FunctionConstructor;
|
|
55
|
-
data: {
|
|
56
|
-
default: {};
|
|
57
|
-
};
|
|
56
|
+
data: {};
|
|
58
57
|
defaultData: {};
|
|
59
58
|
getDefaultData: {
|
|
60
59
|
type: FunctionConstructor;
|
|
@@ -115,5 +114,6 @@ declare function useSubscription(): {
|
|
|
115
114
|
};
|
|
116
115
|
declare function StyleParser(styles?: Array<string> | Record<string, boolean> | string): {};
|
|
117
116
|
declare function MergeStyles(...params: any): any;
|
|
117
|
+
declare const extendVnode: (component: Record<string, any>, element: any) => Record<string, (props?: Record<string, any>, slots?: Record<string, any> | ((slots: Record<string, any>) => Record<string, any>)) => any>;
|
|
118
118
|
|
|
119
|
-
export { MergeStyles, StyleParser, access, _default as default, getDate, getProps, getReactiveViewComponent, safeRequest, setup, useSubscription };
|
|
119
|
+
export { MergeStyles, StyleParser, access, _default as default, extendVnode, getDate, getProps, getReactiveViewComponent, safeRequest, setup, useSubscription };
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,18 @@ var __spreadValues = (a, b) => {
|
|
|
19
19
|
}
|
|
20
20
|
return a;
|
|
21
21
|
};
|
|
22
|
+
var __objRest = (source, exclude) => {
|
|
23
|
+
var target = {};
|
|
24
|
+
for (var prop in source)
|
|
25
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
26
|
+
target[prop] = source[prop];
|
|
27
|
+
if (source != null && __getOwnPropSymbols)
|
|
28
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
29
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
30
|
+
target[prop] = source[prop];
|
|
31
|
+
}
|
|
32
|
+
return target;
|
|
33
|
+
};
|
|
22
34
|
var __export = (target, all) => {
|
|
23
35
|
for (var name2 in all)
|
|
24
36
|
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
@@ -48,6 +60,7 @@ __export(index_exports, {
|
|
|
48
60
|
StyleParser: () => StyleParser,
|
|
49
61
|
access: () => access,
|
|
50
62
|
default: () => index_default,
|
|
63
|
+
extendVnode: () => extendVnode,
|
|
51
64
|
getDate: () => getDate,
|
|
52
65
|
getProps: () => getProps,
|
|
53
66
|
getReactiveViewComponent: () => getReactiveViewComponent,
|
|
@@ -155,7 +168,7 @@ var import_vue = require("vue");
|
|
|
155
168
|
|
|
156
169
|
// package.json
|
|
157
170
|
var name = "@razaman2/reactive-view";
|
|
158
|
-
var version = "0.0.
|
|
171
|
+
var version = "0.0.34";
|
|
159
172
|
|
|
160
173
|
// src/ReactiveView.ts
|
|
161
174
|
var setup = {
|
|
@@ -167,6 +180,7 @@ var ReactiveView_default = {
|
|
|
167
180
|
props: {
|
|
168
181
|
setup: {},
|
|
169
182
|
ReactiveView: {
|
|
183
|
+
type: Boolean,
|
|
170
184
|
default: true
|
|
171
185
|
},
|
|
172
186
|
instance: {
|
|
@@ -175,9 +189,7 @@ var ReactiveView_default = {
|
|
|
175
189
|
notifications: Object,
|
|
176
190
|
subscriptions: Object,
|
|
177
191
|
beforeSetData: Function,
|
|
178
|
-
data: {
|
|
179
|
-
default: {}
|
|
180
|
-
},
|
|
192
|
+
data: {},
|
|
181
193
|
defaultData: {},
|
|
182
194
|
getDefaultData: {
|
|
183
195
|
type: Function,
|
|
@@ -207,29 +219,30 @@ var ReactiveView_default = {
|
|
|
207
219
|
context.slots.default ? context.attrs : __spreadValues({
|
|
208
220
|
style: { color: "red", textAlign: "center" }
|
|
209
221
|
}, context.attrs),
|
|
210
|
-
context.slots.default ? context.slots.default({
|
|
222
|
+
context.slots.default ? context.slots.default({ component: component2, vue: vue2, props, context }) : `${props.modelName}: ${name}@${version}`
|
|
211
223
|
);
|
|
212
224
|
};
|
|
213
225
|
const isValid = (0, import_vue.ref)(false);
|
|
214
|
-
const
|
|
215
|
-
const
|
|
226
|
+
const isReady = (0, import_vue.ref)(false);
|
|
227
|
+
const isFunctionData = ["Function"].includes(((_a = props.data) != null ? _a : {}).constructor.name);
|
|
228
|
+
const isAsyncFunctionData = ["AsyncFunction"].includes(((_b = props.data) != null ? _b : {}).constructor.name);
|
|
229
|
+
const isPromiseData = ["Promise"].includes(((_c = props.data) != null ? _c : {}).constructor.name) || isAsyncFunctionData;
|
|
216
230
|
const defer = (0, import_vue.ref)(typeof props.defer === "function" ? props.defer() : props.defer);
|
|
217
|
-
const
|
|
218
|
-
const async = data instanceof Promise;
|
|
231
|
+
const vue = (0, import_vue.getCurrentInstance)();
|
|
219
232
|
if (props.debug) {
|
|
220
|
-
console.log("[ReactiveView]:", { props, context,
|
|
233
|
+
console.log("[ReactiveView]:", { props, context, vue, defer, data: props.data, isValid, isReady, isFunctionData, isAsyncFunctionData, isPromiseData });
|
|
221
234
|
}
|
|
222
|
-
if (
|
|
223
|
-
console.error("[ReactiveView]: defaultData is required for async data.");
|
|
235
|
+
if ((isPromiseData || isFunctionData) && !("defaultData" in vue.vnode.props)) {
|
|
236
|
+
console.error("[ReactiveView]: defaultData is required for function or async data.");
|
|
224
237
|
}
|
|
225
238
|
const defaultData = props.getDefaultData(
|
|
226
|
-
((
|
|
239
|
+
((_d = vue.vnode.props) == null ? void 0 : _d.hasOwnProperty("defaultData")) ? vue.vnode.props.defaultData : ((_e = vue.vnode.props) == null ? void 0 : _e.hasOwnProperty("data")) ? Array.isArray(vue.vnode.props.data) ? [] : {} : {}
|
|
227
240
|
);
|
|
228
241
|
const datatype = Array.isArray(defaultData) ? [] : {};
|
|
229
242
|
const config = {
|
|
230
|
-
data: (0, import_vue.reactive)(
|
|
231
|
-
|
|
232
|
-
),
|
|
243
|
+
data: (0, import_vue.reactive)(import_object_manager.default.on(
|
|
244
|
+
isPromiseData || isFunctionData || (0, import_vue.isRef)(props.data) || (0, import_vue.isReactive)(props.data) ? datatype : ((_f = vue.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? props.data : datatype
|
|
245
|
+
).clone()),
|
|
233
246
|
defaultData: import_object_manager.default.on(defaultData).clone(),
|
|
234
247
|
notifications: props.notifications,
|
|
235
248
|
subscriptions: props.subscriptions,
|
|
@@ -257,15 +270,23 @@ var ReactiveView_default = {
|
|
|
257
270
|
}
|
|
258
271
|
});
|
|
259
272
|
const watchDataProp = (dataProp) => {
|
|
260
|
-
var _a2;
|
|
261
|
-
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? {
|
|
262
|
-
callback: context.attrs["onUpdate:data"]
|
|
263
|
-
|
|
264
|
-
|
|
273
|
+
var _a2, _b2, _c2;
|
|
274
|
+
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? { callback: context.attrs["onUpdate:data"] } : {
|
|
275
|
+
callback: (_b2 = ((_a2 = context.attrs["onUpdate:data"]) != null ? _a2 : {}).callback) != null ? _b2 : context.attrs["data:callback"],
|
|
276
|
+
options: Object.assign({
|
|
277
|
+
immediate: context.attrs["data:immediate"],
|
|
278
|
+
deep: context.attrs["data:deep"],
|
|
279
|
+
once: context.attrs["data:once"]
|
|
280
|
+
}, ((_c2 = context.attrs["onUpdate:data"]) != null ? _c2 : {}).options)
|
|
281
|
+
};
|
|
282
|
+
if (context.attrs["data:log"]) {
|
|
283
|
+
console.log(`[ReactiveView]:data`, { config: config2, dataProp });
|
|
284
|
+
}
|
|
285
|
+
(0, import_vue.watch)(isFunctionData || (0, import_vue.isRef)(dataProp) || (0, import_vue.isReactive)(dataProp) ? dataProp : () => dataProp, (after, before) => {
|
|
265
286
|
var _a3;
|
|
266
287
|
const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
|
|
267
288
|
if (typeof config2.callback === "function") {
|
|
268
|
-
model.replaceData((_a3 = config2.callback(diff,
|
|
289
|
+
model.replaceData((_a3 = config2.callback(diff, { component })) != null ? _a3 : after);
|
|
269
290
|
} else {
|
|
270
291
|
model.replaceData(after);
|
|
271
292
|
}
|
|
@@ -273,20 +294,23 @@ var ReactiveView_default = {
|
|
|
273
294
|
};
|
|
274
295
|
setTimeout(async () => {
|
|
275
296
|
var _a2;
|
|
276
|
-
const [
|
|
277
|
-
watchDataProp(
|
|
297
|
+
const [data] = await Promise.all([isAsyncFunctionData ? props.data() : props.data, (_a2 = defer.value) != null ? _a2 : true]);
|
|
298
|
+
watchDataProp(data);
|
|
278
299
|
});
|
|
279
300
|
setTimeout(async () => {
|
|
280
301
|
var _a2;
|
|
281
|
-
|
|
302
|
+
isReady.value = (_a2 = await defer.value) != null ? _a2 : true;
|
|
282
303
|
});
|
|
283
304
|
if (context.attrs["onUpdate:model"]) {
|
|
284
305
|
const config2 = typeof context.attrs["onUpdate:model"] === "function" ? {
|
|
285
306
|
callback: context.attrs["onUpdate:model"]
|
|
286
307
|
} : (_g = context.attrs["onUpdate:model"]) != null ? _g : {};
|
|
308
|
+
if (context.attrs["model:log"]) {
|
|
309
|
+
console.log(`[ReactiveView]:model`, { config: config2 });
|
|
310
|
+
}
|
|
287
311
|
(0, import_vue.watch)(() => model.getData(), (after, before) => {
|
|
288
312
|
const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
|
|
289
|
-
config2.callback(diff,
|
|
313
|
+
config2.callback(diff, { component });
|
|
290
314
|
}, config2.options);
|
|
291
315
|
}
|
|
292
316
|
const component = (0, import_vue.ref)({ parent: { self: vue.proxy }, self: { template, model, isValid } });
|
|
@@ -309,7 +333,7 @@ var ReactiveView_default = {
|
|
|
309
333
|
props.instance.value = typeof props.instance === "function" ? props.instance(component.value) : component.value;
|
|
310
334
|
return (vue2) => {
|
|
311
335
|
var _a2, _b2;
|
|
312
|
-
if (
|
|
336
|
+
if (isReady.value) {
|
|
313
337
|
return access(component).template(component, vue2);
|
|
314
338
|
} else {
|
|
315
339
|
return (_b2 = (_a2 = context.slots).loading) == null ? void 0 : _b2.call(_a2, { component });
|
|
@@ -488,11 +512,46 @@ function MergeStyles(...params) {
|
|
|
488
512
|
}
|
|
489
513
|
});
|
|
490
514
|
}
|
|
515
|
+
var extendVnode = (component, element) => {
|
|
516
|
+
return new Proxy(access(component), {
|
|
517
|
+
get: (target, key) => {
|
|
518
|
+
const getVnode = () => {
|
|
519
|
+
try {
|
|
520
|
+
return target[key]();
|
|
521
|
+
} catch (e) {
|
|
522
|
+
throw new Error(`${key} does not exist as vnode on component.`);
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
const vnode = getVnode();
|
|
526
|
+
return (props = {}, slots) => {
|
|
527
|
+
var _a;
|
|
528
|
+
const _b = getProps((_a = vnode.props) != null ? _a : {}, []), { class: classes, style: styles } = _b, rest = __objRest(_b, ["class", "style"]);
|
|
529
|
+
const finalClasses = MergeStyles(classes, typeof props.class === "function" ? props.class(classes) : props.class);
|
|
530
|
+
const functionalProps = Object.entries(props).reduce((props2, [key2, value]) => {
|
|
531
|
+
if (![
|
|
532
|
+
"class"
|
|
533
|
+
/*, "style"*/
|
|
534
|
+
].includes(key2) && typeof value === "function") {
|
|
535
|
+
props2[key2] = value(vnode.props[key2]);
|
|
536
|
+
}
|
|
537
|
+
return props2;
|
|
538
|
+
}, props);
|
|
539
|
+
const finalProps = Object.assign(rest, functionalProps, {
|
|
540
|
+
class: finalClasses
|
|
541
|
+
/*, style: finalStyles*/
|
|
542
|
+
});
|
|
543
|
+
const finalSlots = typeof slots === "function" ? slots(vnode.children) : vnode.children;
|
|
544
|
+
return (0, import_vue2.h)(["string", "undefined"].includes(typeof element) ? vnode : element, finalProps, finalSlots);
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
};
|
|
491
549
|
// Annotate the CommonJS export names for ESM import in node:
|
|
492
550
|
0 && (module.exports = {
|
|
493
551
|
MergeStyles,
|
|
494
552
|
StyleParser,
|
|
495
553
|
access,
|
|
554
|
+
extendVnode,
|
|
496
555
|
getDate,
|
|
497
556
|
getProps,
|
|
498
557
|
getReactiveViewComponent,
|
package/dist/index.mjs
CHANGED
|
@@ -14,6 +14,18 @@ var __spreadValues = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
+
var __objRest = (source, exclude) => {
|
|
18
|
+
var target = {};
|
|
19
|
+
for (var prop in source)
|
|
20
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
21
|
+
target[prop] = source[prop];
|
|
22
|
+
if (source != null && __getOwnPropSymbols)
|
|
23
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
24
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
17
29
|
|
|
18
30
|
// src/Subscription.ts
|
|
19
31
|
var Subscription = class _Subscription {
|
|
@@ -113,7 +125,7 @@ import { ref, reactive, watch, isRef, isReactive, createVNode, getCurrentInstanc
|
|
|
113
125
|
|
|
114
126
|
// package.json
|
|
115
127
|
var name = "@razaman2/reactive-view";
|
|
116
|
-
var version = "0.0.
|
|
128
|
+
var version = "0.0.34";
|
|
117
129
|
|
|
118
130
|
// src/ReactiveView.ts
|
|
119
131
|
var setup = {
|
|
@@ -125,6 +137,7 @@ var ReactiveView_default = {
|
|
|
125
137
|
props: {
|
|
126
138
|
setup: {},
|
|
127
139
|
ReactiveView: {
|
|
140
|
+
type: Boolean,
|
|
128
141
|
default: true
|
|
129
142
|
},
|
|
130
143
|
instance: {
|
|
@@ -133,9 +146,7 @@ var ReactiveView_default = {
|
|
|
133
146
|
notifications: Object,
|
|
134
147
|
subscriptions: Object,
|
|
135
148
|
beforeSetData: Function,
|
|
136
|
-
data: {
|
|
137
|
-
default: {}
|
|
138
|
-
},
|
|
149
|
+
data: {},
|
|
139
150
|
defaultData: {},
|
|
140
151
|
getDefaultData: {
|
|
141
152
|
type: Function,
|
|
@@ -165,29 +176,30 @@ var ReactiveView_default = {
|
|
|
165
176
|
context.slots.default ? context.attrs : __spreadValues({
|
|
166
177
|
style: { color: "red", textAlign: "center" }
|
|
167
178
|
}, context.attrs),
|
|
168
|
-
context.slots.default ? context.slots.default({
|
|
179
|
+
context.slots.default ? context.slots.default({ component: component2, vue: vue2, props, context }) : `${props.modelName}: ${name}@${version}`
|
|
169
180
|
);
|
|
170
181
|
};
|
|
171
182
|
const isValid = ref(false);
|
|
172
|
-
const
|
|
173
|
-
const
|
|
183
|
+
const isReady = ref(false);
|
|
184
|
+
const isFunctionData = ["Function"].includes(((_a = props.data) != null ? _a : {}).constructor.name);
|
|
185
|
+
const isAsyncFunctionData = ["AsyncFunction"].includes(((_b = props.data) != null ? _b : {}).constructor.name);
|
|
186
|
+
const isPromiseData = ["Promise"].includes(((_c = props.data) != null ? _c : {}).constructor.name) || isAsyncFunctionData;
|
|
174
187
|
const defer = ref(typeof props.defer === "function" ? props.defer() : props.defer);
|
|
175
|
-
const
|
|
176
|
-
const async = data instanceof Promise;
|
|
188
|
+
const vue = getCurrentInstance();
|
|
177
189
|
if (props.debug) {
|
|
178
|
-
console.log("[ReactiveView]:", { props, context,
|
|
190
|
+
console.log("[ReactiveView]:", { props, context, vue, defer, data: props.data, isValid, isReady, isFunctionData, isAsyncFunctionData, isPromiseData });
|
|
179
191
|
}
|
|
180
|
-
if (
|
|
181
|
-
console.error("[ReactiveView]: defaultData is required for async data.");
|
|
192
|
+
if ((isPromiseData || isFunctionData) && !("defaultData" in vue.vnode.props)) {
|
|
193
|
+
console.error("[ReactiveView]: defaultData is required for function or async data.");
|
|
182
194
|
}
|
|
183
195
|
const defaultData = props.getDefaultData(
|
|
184
|
-
((
|
|
196
|
+
((_d = vue.vnode.props) == null ? void 0 : _d.hasOwnProperty("defaultData")) ? vue.vnode.props.defaultData : ((_e = vue.vnode.props) == null ? void 0 : _e.hasOwnProperty("data")) ? Array.isArray(vue.vnode.props.data) ? [] : {} : {}
|
|
185
197
|
);
|
|
186
198
|
const datatype = Array.isArray(defaultData) ? [] : {};
|
|
187
199
|
const config = {
|
|
188
|
-
data: reactive(
|
|
189
|
-
|
|
190
|
-
),
|
|
200
|
+
data: reactive(ObjectManager.on(
|
|
201
|
+
isPromiseData || isFunctionData || isRef(props.data) || isReactive(props.data) ? datatype : ((_f = vue.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? props.data : datatype
|
|
202
|
+
).clone()),
|
|
191
203
|
defaultData: ObjectManager.on(defaultData).clone(),
|
|
192
204
|
notifications: props.notifications,
|
|
193
205
|
subscriptions: props.subscriptions,
|
|
@@ -215,15 +227,23 @@ var ReactiveView_default = {
|
|
|
215
227
|
}
|
|
216
228
|
});
|
|
217
229
|
const watchDataProp = (dataProp) => {
|
|
218
|
-
var _a2;
|
|
219
|
-
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? {
|
|
220
|
-
callback: context.attrs["onUpdate:data"]
|
|
221
|
-
|
|
222
|
-
|
|
230
|
+
var _a2, _b2, _c2;
|
|
231
|
+
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? { callback: context.attrs["onUpdate:data"] } : {
|
|
232
|
+
callback: (_b2 = ((_a2 = context.attrs["onUpdate:data"]) != null ? _a2 : {}).callback) != null ? _b2 : context.attrs["data:callback"],
|
|
233
|
+
options: Object.assign({
|
|
234
|
+
immediate: context.attrs["data:immediate"],
|
|
235
|
+
deep: context.attrs["data:deep"],
|
|
236
|
+
once: context.attrs["data:once"]
|
|
237
|
+
}, ((_c2 = context.attrs["onUpdate:data"]) != null ? _c2 : {}).options)
|
|
238
|
+
};
|
|
239
|
+
if (context.attrs["data:log"]) {
|
|
240
|
+
console.log(`[ReactiveView]:data`, { config: config2, dataProp });
|
|
241
|
+
}
|
|
242
|
+
watch(isFunctionData || isRef(dataProp) || isReactive(dataProp) ? dataProp : () => dataProp, (after, before) => {
|
|
223
243
|
var _a3;
|
|
224
244
|
const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
|
|
225
245
|
if (typeof config2.callback === "function") {
|
|
226
|
-
model.replaceData((_a3 = config2.callback(diff,
|
|
246
|
+
model.replaceData((_a3 = config2.callback(diff, { component })) != null ? _a3 : after);
|
|
227
247
|
} else {
|
|
228
248
|
model.replaceData(after);
|
|
229
249
|
}
|
|
@@ -231,20 +251,23 @@ var ReactiveView_default = {
|
|
|
231
251
|
};
|
|
232
252
|
setTimeout(async () => {
|
|
233
253
|
var _a2;
|
|
234
|
-
const [
|
|
235
|
-
watchDataProp(
|
|
254
|
+
const [data] = await Promise.all([isAsyncFunctionData ? props.data() : props.data, (_a2 = defer.value) != null ? _a2 : true]);
|
|
255
|
+
watchDataProp(data);
|
|
236
256
|
});
|
|
237
257
|
setTimeout(async () => {
|
|
238
258
|
var _a2;
|
|
239
|
-
|
|
259
|
+
isReady.value = (_a2 = await defer.value) != null ? _a2 : true;
|
|
240
260
|
});
|
|
241
261
|
if (context.attrs["onUpdate:model"]) {
|
|
242
262
|
const config2 = typeof context.attrs["onUpdate:model"] === "function" ? {
|
|
243
263
|
callback: context.attrs["onUpdate:model"]
|
|
244
264
|
} : (_g = context.attrs["onUpdate:model"]) != null ? _g : {};
|
|
265
|
+
if (context.attrs["model:log"]) {
|
|
266
|
+
console.log(`[ReactiveView]:model`, { config: config2 });
|
|
267
|
+
}
|
|
245
268
|
watch(() => model.getData(), (after, before) => {
|
|
246
269
|
const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
|
|
247
|
-
config2.callback(diff,
|
|
270
|
+
config2.callback(diff, { component });
|
|
248
271
|
}, config2.options);
|
|
249
272
|
}
|
|
250
273
|
const component = ref({ parent: { self: vue.proxy }, self: { template, model, isValid } });
|
|
@@ -267,7 +290,7 @@ var ReactiveView_default = {
|
|
|
267
290
|
props.instance.value = typeof props.instance === "function" ? props.instance(component.value) : component.value;
|
|
268
291
|
return (vue2) => {
|
|
269
292
|
var _a2, _b2;
|
|
270
|
-
if (
|
|
293
|
+
if (isReady.value) {
|
|
271
294
|
return access(component).template(component, vue2);
|
|
272
295
|
} else {
|
|
273
296
|
return (_b2 = (_a2 = context.slots).loading) == null ? void 0 : _b2.call(_a2, { component });
|
|
@@ -277,7 +300,7 @@ var ReactiveView_default = {
|
|
|
277
300
|
};
|
|
278
301
|
|
|
279
302
|
// src/index.ts
|
|
280
|
-
import { createVNode as createVNode2, isRef as isRef2 } from "vue";
|
|
303
|
+
import { createVNode as createVNode2, isRef as isRef2, h } from "vue";
|
|
281
304
|
import { formatInTimeZone } from "date-fns-tz";
|
|
282
305
|
var index_default = ReactiveView_default;
|
|
283
306
|
function safeRequest(request) {
|
|
@@ -446,11 +469,46 @@ function MergeStyles(...params) {
|
|
|
446
469
|
}
|
|
447
470
|
});
|
|
448
471
|
}
|
|
472
|
+
var extendVnode = (component, element) => {
|
|
473
|
+
return new Proxy(access(component), {
|
|
474
|
+
get: (target, key) => {
|
|
475
|
+
const getVnode = () => {
|
|
476
|
+
try {
|
|
477
|
+
return target[key]();
|
|
478
|
+
} catch (e) {
|
|
479
|
+
throw new Error(`${key} does not exist as vnode on component.`);
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
const vnode = getVnode();
|
|
483
|
+
return (props = {}, slots) => {
|
|
484
|
+
var _a;
|
|
485
|
+
const _b = getProps((_a = vnode.props) != null ? _a : {}, []), { class: classes, style: styles } = _b, rest = __objRest(_b, ["class", "style"]);
|
|
486
|
+
const finalClasses = MergeStyles(classes, typeof props.class === "function" ? props.class(classes) : props.class);
|
|
487
|
+
const functionalProps = Object.entries(props).reduce((props2, [key2, value]) => {
|
|
488
|
+
if (![
|
|
489
|
+
"class"
|
|
490
|
+
/*, "style"*/
|
|
491
|
+
].includes(key2) && typeof value === "function") {
|
|
492
|
+
props2[key2] = value(vnode.props[key2]);
|
|
493
|
+
}
|
|
494
|
+
return props2;
|
|
495
|
+
}, props);
|
|
496
|
+
const finalProps = Object.assign(rest, functionalProps, {
|
|
497
|
+
class: finalClasses
|
|
498
|
+
/*, style: finalStyles*/
|
|
499
|
+
});
|
|
500
|
+
const finalSlots = typeof slots === "function" ? slots(vnode.children) : vnode.children;
|
|
501
|
+
return h(["string", "undefined"].includes(typeof element) ? vnode : element, finalProps, finalSlots);
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
};
|
|
449
506
|
export {
|
|
450
507
|
MergeStyles,
|
|
451
508
|
StyleParser,
|
|
452
509
|
access,
|
|
453
510
|
index_default as default,
|
|
511
|
+
extendVnode,
|
|
454
512
|
getDate,
|
|
455
513
|
getProps,
|
|
456
514
|
getReactiveViewComponent,
|
package/package.json
CHANGED
|
@@ -1,45 +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
|
-
"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.12",
|
|
25
|
-
"@razaman2/
|
|
26
|
-
"
|
|
27
|
-
"date-fns
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@razaman2/reactive-view",
|
|
3
|
+
"version": "0.0.34",
|
|
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.12",
|
|
25
|
+
"@razaman2/event-emitter": "^2.1.1",
|
|
26
|
+
"@razaman2/object-manager": "^3.4.2",
|
|
27
|
+
"date-fns": "^4.1.0",
|
|
28
|
+
"date-fns-tz": "^3.2.0",
|
|
29
|
+
"uuid": "^11.1.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"vue": "^3.5.16"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/uuid": "^10.0.0",
|
|
36
|
+
"tsup": "^8.5.0",
|
|
37
|
+
"typescript": "^5.8.3",
|
|
38
|
+
"vitest": "^3.2.3"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist"
|
|
45
|
+
]
|
|
46
|
+
}
|