@razaman2/reactive-view 0.0.31 → 0.0.34-beta.1
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 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +94 -38
- package/dist/index.mjs +94 -39
- package/package.json +46 -45
package/dist/index.d.mts
CHANGED
|
@@ -44,17 +44,16 @@ declare const _default: {
|
|
|
44
44
|
props: {
|
|
45
45
|
setup: {};
|
|
46
46
|
ReactiveView: {
|
|
47
|
+
type: BooleanConstructor;
|
|
47
48
|
default: boolean;
|
|
48
49
|
};
|
|
49
50
|
instance: {
|
|
50
|
-
default: vue.Ref<any, any>;
|
|
51
|
+
default: () => vue.Ref<any, any>;
|
|
51
52
|
};
|
|
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,17 +44,16 @@ declare const _default: {
|
|
|
44
44
|
props: {
|
|
45
45
|
setup: {};
|
|
46
46
|
ReactiveView: {
|
|
47
|
+
type: BooleanConstructor;
|
|
47
48
|
default: boolean;
|
|
48
49
|
};
|
|
49
50
|
instance: {
|
|
50
|
-
default: vue.Ref<any, any>;
|
|
51
|
+
default: () => vue.Ref<any, any>;
|
|
51
52
|
};
|
|
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-beta.1";
|
|
159
172
|
|
|
160
173
|
// src/ReactiveView.ts
|
|
161
174
|
var setup = {
|
|
@@ -167,17 +180,16 @@ var ReactiveView_default = {
|
|
|
167
180
|
props: {
|
|
168
181
|
setup: {},
|
|
169
182
|
ReactiveView: {
|
|
183
|
+
type: Boolean,
|
|
170
184
|
default: true
|
|
171
185
|
},
|
|
172
186
|
instance: {
|
|
173
|
-
default: (0, import_vue.ref)()
|
|
187
|
+
default: () => (0, import_vue.ref)()
|
|
174
188
|
},
|
|
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,
|
|
@@ -200,36 +212,37 @@ var ReactiveView_default = {
|
|
|
200
212
|
}
|
|
201
213
|
},
|
|
202
214
|
setup(props, context) {
|
|
203
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
215
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
204
216
|
const template = (component2, vue2) => {
|
|
205
217
|
return (0, import_vue.createVNode)(
|
|
206
218
|
"div",
|
|
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 promise or async function 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,
|
|
@@ -256,40 +269,48 @@ var ReactiveView_default = {
|
|
|
256
269
|
}
|
|
257
270
|
}
|
|
258
271
|
});
|
|
272
|
+
const component = (0, import_vue.ref)({ parent: { self: vue.proxy }, self: { template, model, isValid } });
|
|
259
273
|
const watchDataProp = (dataProp) => {
|
|
260
|
-
var _a2;
|
|
261
|
-
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? {
|
|
262
|
-
callback: context.attrs["onUpdate:data"]
|
|
263
|
-
|
|
264
|
-
|
|
274
|
+
var _a2, _b2, _c2;
|
|
275
|
+
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? { callback: context.attrs["onUpdate:data"] } : {
|
|
276
|
+
callback: (_b2 = ((_a2 = context.attrs["onUpdate:data"]) != null ? _a2 : {}).callback) != null ? _b2 : context.attrs["data:callback"],
|
|
277
|
+
options: Object.assign(__spreadValues(__spreadValues(__spreadValues({}, context.attrs["data:immediate"] ? { immediate: context.attrs["data:immediate"] } : {}), context.attrs["data:deep"] ? { deep: context.attrs["data:deep"] } : {}), context.attrs["data:once"] ? { once: context.attrs["data:once"] } : {}), ((_c2 = context.attrs["onUpdate:data"]) != null ? _c2 : {}).options)
|
|
278
|
+
};
|
|
279
|
+
if (context.attrs["data:log"]) {
|
|
280
|
+
console.log(`[ReactiveView]:data`, { config: config2, dataProp });
|
|
281
|
+
}
|
|
282
|
+
(0, import_vue.watch)(isFunctionData || (0, import_vue.isRef)(dataProp) || (0, import_vue.isReactive)(dataProp) ? dataProp : () => dataProp, (after, before) => {
|
|
265
283
|
var _a3;
|
|
266
284
|
const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
|
|
267
285
|
if (typeof config2.callback === "function") {
|
|
268
|
-
model.replaceData((_a3 = config2.callback(diff,
|
|
286
|
+
model.replaceData((_a3 = config2.callback(diff, { component })) != null ? _a3 : after);
|
|
269
287
|
} else {
|
|
270
288
|
model.replaceData(after);
|
|
271
289
|
}
|
|
272
290
|
}, config2.options);
|
|
273
291
|
};
|
|
292
|
+
if (context.attrs["onUpdate:model"] || context.attrs["update:model"]) {
|
|
293
|
+
const config2 = typeof context.attrs["onUpdate:model"] === "function" ? {
|
|
294
|
+
callback: context.attrs["onUpdate:model"],
|
|
295
|
+
options: Object.assign(__spreadValues(__spreadValues(__spreadValues({}, context.attrs["model:immediate"] ? { immediate: context.attrs["model:immediate"] } : {}), context.attrs["model:deep"] ? { deep: context.attrs["model:deep"] } : {}), context.attrs["model:once"] ? { once: context.attrs["model:once"] } : {}), ((_g = context.attrs["onUpdate:model"]) != null ? _g : {}).options)
|
|
296
|
+
} : (_h = context.attrs["onUpdate:model"]) != null ? _h : {};
|
|
297
|
+
if (context.attrs["model:log"]) {
|
|
298
|
+
console.log(`[ReactiveView]:model`, { config: config2 });
|
|
299
|
+
}
|
|
300
|
+
(0, import_vue.watch)(() => model.getData(), (after, before) => {
|
|
301
|
+
const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
|
|
302
|
+
config2.callback(diff, { component });
|
|
303
|
+
}, config2.options);
|
|
304
|
+
}
|
|
274
305
|
setTimeout(async () => {
|
|
275
306
|
var _a2;
|
|
276
|
-
const [
|
|
277
|
-
watchDataProp(
|
|
307
|
+
const [data] = await Promise.all([isAsyncFunctionData ? props.data() : props.data, (_a2 = defer.value) != null ? _a2 : true]);
|
|
308
|
+
watchDataProp(data);
|
|
278
309
|
});
|
|
279
310
|
setTimeout(async () => {
|
|
280
311
|
var _a2;
|
|
281
|
-
|
|
312
|
+
isReady.value = (_a2 = await defer.value) != null ? _a2 : true;
|
|
282
313
|
});
|
|
283
|
-
if (context.attrs["onUpdate:model"]) {
|
|
284
|
-
const config2 = typeof context.attrs["onUpdate:model"] === "function" ? {
|
|
285
|
-
callback: context.attrs["onUpdate:model"]
|
|
286
|
-
} : (_g = context.attrs["onUpdate:model"]) != null ? _g : {};
|
|
287
|
-
(0, import_vue.watch)(() => model.getData(), (after, before) => {
|
|
288
|
-
const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
|
|
289
|
-
config2.callback(diff, model);
|
|
290
|
-
}, config2.options);
|
|
291
|
-
}
|
|
292
|
-
const component = (0, import_vue.ref)({ parent: { self: vue.proxy }, self: { template, model, isValid } });
|
|
293
314
|
component.value = [access(component)].reduce((options, parent) => {
|
|
294
315
|
var _a2;
|
|
295
316
|
while (parent) {
|
|
@@ -309,7 +330,7 @@ var ReactiveView_default = {
|
|
|
309
330
|
props.instance.value = typeof props.instance === "function" ? props.instance(component.value) : component.value;
|
|
310
331
|
return (vue2) => {
|
|
311
332
|
var _a2, _b2;
|
|
312
|
-
if (
|
|
333
|
+
if (isReady.value) {
|
|
313
334
|
return access(component).template(component, vue2);
|
|
314
335
|
} else {
|
|
315
336
|
return (_b2 = (_a2 = context.slots).loading) == null ? void 0 : _b2.call(_a2, { component });
|
|
@@ -488,11 +509,46 @@ function MergeStyles(...params) {
|
|
|
488
509
|
}
|
|
489
510
|
});
|
|
490
511
|
}
|
|
512
|
+
var extendVnode = (component, element) => {
|
|
513
|
+
return new Proxy(access(component), {
|
|
514
|
+
get: (target, key) => {
|
|
515
|
+
const getVnode = () => {
|
|
516
|
+
try {
|
|
517
|
+
return target[key]();
|
|
518
|
+
} catch (e) {
|
|
519
|
+
throw new Error(`${key} does not exist as vnode on component.`);
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
const vnode = getVnode();
|
|
523
|
+
return (props = {}, slots) => {
|
|
524
|
+
var _a;
|
|
525
|
+
const _b = getProps((_a = vnode.props) != null ? _a : {}, []), { class: classes, style: styles } = _b, rest = __objRest(_b, ["class", "style"]);
|
|
526
|
+
const finalClasses = MergeStyles(classes, typeof props.class === "function" ? props.class(classes) : props.class);
|
|
527
|
+
const functionalProps = Object.entries(props).reduce((props2, [key2, value]) => {
|
|
528
|
+
if (![
|
|
529
|
+
"class"
|
|
530
|
+
/*, "style"*/
|
|
531
|
+
].includes(key2) && typeof value === "function") {
|
|
532
|
+
props2[key2] = value(vnode.props[key2]);
|
|
533
|
+
}
|
|
534
|
+
return props2;
|
|
535
|
+
}, props);
|
|
536
|
+
const finalProps = Object.assign(rest, functionalProps, {
|
|
537
|
+
class: finalClasses
|
|
538
|
+
/*, style: finalStyles*/
|
|
539
|
+
});
|
|
540
|
+
const finalSlots = typeof slots === "function" ? slots(vnode.children) : vnode.children;
|
|
541
|
+
return (0, import_vue2.h)(["string", "undefined"].includes(typeof element) ? vnode : element, finalProps, finalSlots);
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
};
|
|
491
546
|
// Annotate the CommonJS export names for ESM import in node:
|
|
492
547
|
0 && (module.exports = {
|
|
493
548
|
MergeStyles,
|
|
494
549
|
StyleParser,
|
|
495
550
|
access,
|
|
551
|
+
extendVnode,
|
|
496
552
|
getDate,
|
|
497
553
|
getProps,
|
|
498
554
|
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-beta.1";
|
|
117
129
|
|
|
118
130
|
// src/ReactiveView.ts
|
|
119
131
|
var setup = {
|
|
@@ -125,17 +137,16 @@ var ReactiveView_default = {
|
|
|
125
137
|
props: {
|
|
126
138
|
setup: {},
|
|
127
139
|
ReactiveView: {
|
|
140
|
+
type: Boolean,
|
|
128
141
|
default: true
|
|
129
142
|
},
|
|
130
143
|
instance: {
|
|
131
|
-
default: ref()
|
|
144
|
+
default: () => ref()
|
|
132
145
|
},
|
|
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,
|
|
@@ -158,36 +169,37 @@ var ReactiveView_default = {
|
|
|
158
169
|
}
|
|
159
170
|
},
|
|
160
171
|
setup(props, context) {
|
|
161
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
172
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
162
173
|
const template = (component2, vue2) => {
|
|
163
174
|
return createVNode(
|
|
164
175
|
"div",
|
|
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 promise or async function 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,
|
|
@@ -214,40 +226,48 @@ var ReactiveView_default = {
|
|
|
214
226
|
}
|
|
215
227
|
}
|
|
216
228
|
});
|
|
229
|
+
const component = ref({ parent: { self: vue.proxy }, self: { template, model, isValid } });
|
|
217
230
|
const watchDataProp = (dataProp) => {
|
|
218
|
-
var _a2;
|
|
219
|
-
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? {
|
|
220
|
-
callback: context.attrs["onUpdate:data"]
|
|
221
|
-
|
|
222
|
-
|
|
231
|
+
var _a2, _b2, _c2;
|
|
232
|
+
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? { callback: context.attrs["onUpdate:data"] } : {
|
|
233
|
+
callback: (_b2 = ((_a2 = context.attrs["onUpdate:data"]) != null ? _a2 : {}).callback) != null ? _b2 : context.attrs["data:callback"],
|
|
234
|
+
options: Object.assign(__spreadValues(__spreadValues(__spreadValues({}, context.attrs["data:immediate"] ? { immediate: context.attrs["data:immediate"] } : {}), context.attrs["data:deep"] ? { deep: context.attrs["data:deep"] } : {}), context.attrs["data:once"] ? { once: context.attrs["data:once"] } : {}), ((_c2 = context.attrs["onUpdate:data"]) != null ? _c2 : {}).options)
|
|
235
|
+
};
|
|
236
|
+
if (context.attrs["data:log"]) {
|
|
237
|
+
console.log(`[ReactiveView]:data`, { config: config2, dataProp });
|
|
238
|
+
}
|
|
239
|
+
watch(isFunctionData || isRef(dataProp) || isReactive(dataProp) ? dataProp : () => dataProp, (after, before) => {
|
|
223
240
|
var _a3;
|
|
224
241
|
const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
|
|
225
242
|
if (typeof config2.callback === "function") {
|
|
226
|
-
model.replaceData((_a3 = config2.callback(diff,
|
|
243
|
+
model.replaceData((_a3 = config2.callback(diff, { component })) != null ? _a3 : after);
|
|
227
244
|
} else {
|
|
228
245
|
model.replaceData(after);
|
|
229
246
|
}
|
|
230
247
|
}, config2.options);
|
|
231
248
|
};
|
|
249
|
+
if (context.attrs["onUpdate:model"] || context.attrs["update:model"]) {
|
|
250
|
+
const config2 = typeof context.attrs["onUpdate:model"] === "function" ? {
|
|
251
|
+
callback: context.attrs["onUpdate:model"],
|
|
252
|
+
options: Object.assign(__spreadValues(__spreadValues(__spreadValues({}, context.attrs["model:immediate"] ? { immediate: context.attrs["model:immediate"] } : {}), context.attrs["model:deep"] ? { deep: context.attrs["model:deep"] } : {}), context.attrs["model:once"] ? { once: context.attrs["model:once"] } : {}), ((_g = context.attrs["onUpdate:model"]) != null ? _g : {}).options)
|
|
253
|
+
} : (_h = context.attrs["onUpdate:model"]) != null ? _h : {};
|
|
254
|
+
if (context.attrs["model:log"]) {
|
|
255
|
+
console.log(`[ReactiveView]:model`, { config: config2 });
|
|
256
|
+
}
|
|
257
|
+
watch(() => model.getData(), (after, before) => {
|
|
258
|
+
const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
|
|
259
|
+
config2.callback(diff, { component });
|
|
260
|
+
}, config2.options);
|
|
261
|
+
}
|
|
232
262
|
setTimeout(async () => {
|
|
233
263
|
var _a2;
|
|
234
|
-
const [
|
|
235
|
-
watchDataProp(
|
|
264
|
+
const [data] = await Promise.all([isAsyncFunctionData ? props.data() : props.data, (_a2 = defer.value) != null ? _a2 : true]);
|
|
265
|
+
watchDataProp(data);
|
|
236
266
|
});
|
|
237
267
|
setTimeout(async () => {
|
|
238
268
|
var _a2;
|
|
239
|
-
|
|
269
|
+
isReady.value = (_a2 = await defer.value) != null ? _a2 : true;
|
|
240
270
|
});
|
|
241
|
-
if (context.attrs["onUpdate:model"]) {
|
|
242
|
-
const config2 = typeof context.attrs["onUpdate:model"] === "function" ? {
|
|
243
|
-
callback: context.attrs["onUpdate:model"]
|
|
244
|
-
} : (_g = context.attrs["onUpdate:model"]) != null ? _g : {};
|
|
245
|
-
watch(() => model.getData(), (after, before) => {
|
|
246
|
-
const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
|
|
247
|
-
config2.callback(diff, model);
|
|
248
|
-
}, config2.options);
|
|
249
|
-
}
|
|
250
|
-
const component = ref({ parent: { self: vue.proxy }, self: { template, model, isValid } });
|
|
251
271
|
component.value = [access(component)].reduce((options, parent) => {
|
|
252
272
|
var _a2;
|
|
253
273
|
while (parent) {
|
|
@@ -267,7 +287,7 @@ var ReactiveView_default = {
|
|
|
267
287
|
props.instance.value = typeof props.instance === "function" ? props.instance(component.value) : component.value;
|
|
268
288
|
return (vue2) => {
|
|
269
289
|
var _a2, _b2;
|
|
270
|
-
if (
|
|
290
|
+
if (isReady.value) {
|
|
271
291
|
return access(component).template(component, vue2);
|
|
272
292
|
} else {
|
|
273
293
|
return (_b2 = (_a2 = context.slots).loading) == null ? void 0 : _b2.call(_a2, { component });
|
|
@@ -277,7 +297,7 @@ var ReactiveView_default = {
|
|
|
277
297
|
};
|
|
278
298
|
|
|
279
299
|
// src/index.ts
|
|
280
|
-
import { createVNode as createVNode2, isRef as isRef2 } from "vue";
|
|
300
|
+
import { createVNode as createVNode2, isRef as isRef2, h } from "vue";
|
|
281
301
|
import { formatInTimeZone } from "date-fns-tz";
|
|
282
302
|
var index_default = ReactiveView_default;
|
|
283
303
|
function safeRequest(request) {
|
|
@@ -446,11 +466,46 @@ function MergeStyles(...params) {
|
|
|
446
466
|
}
|
|
447
467
|
});
|
|
448
468
|
}
|
|
469
|
+
var extendVnode = (component, element) => {
|
|
470
|
+
return new Proxy(access(component), {
|
|
471
|
+
get: (target, key) => {
|
|
472
|
+
const getVnode = () => {
|
|
473
|
+
try {
|
|
474
|
+
return target[key]();
|
|
475
|
+
} catch (e) {
|
|
476
|
+
throw new Error(`${key} does not exist as vnode on component.`);
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
const vnode = getVnode();
|
|
480
|
+
return (props = {}, slots) => {
|
|
481
|
+
var _a;
|
|
482
|
+
const _b = getProps((_a = vnode.props) != null ? _a : {}, []), { class: classes, style: styles } = _b, rest = __objRest(_b, ["class", "style"]);
|
|
483
|
+
const finalClasses = MergeStyles(classes, typeof props.class === "function" ? props.class(classes) : props.class);
|
|
484
|
+
const functionalProps = Object.entries(props).reduce((props2, [key2, value]) => {
|
|
485
|
+
if (![
|
|
486
|
+
"class"
|
|
487
|
+
/*, "style"*/
|
|
488
|
+
].includes(key2) && typeof value === "function") {
|
|
489
|
+
props2[key2] = value(vnode.props[key2]);
|
|
490
|
+
}
|
|
491
|
+
return props2;
|
|
492
|
+
}, props);
|
|
493
|
+
const finalProps = Object.assign(rest, functionalProps, {
|
|
494
|
+
class: finalClasses
|
|
495
|
+
/*, style: finalStyles*/
|
|
496
|
+
});
|
|
497
|
+
const finalSlots = typeof slots === "function" ? slots(vnode.children) : vnode.children;
|
|
498
|
+
return h(["string", "undefined"].includes(typeof element) ? vnode : element, finalProps, finalSlots);
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
};
|
|
449
503
|
export {
|
|
450
504
|
MergeStyles,
|
|
451
505
|
StyleParser,
|
|
452
506
|
access,
|
|
453
507
|
index_default as default,
|
|
508
|
+
extendVnode,
|
|
454
509
|
getDate,
|
|
455
510
|
getProps,
|
|
456
511
|
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-beta.1",
|
|
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.18"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/uuid": "^10.0.0",
|
|
36
|
+
"tsup": "^8.5.0",
|
|
37
|
+
"typescript": "^5.9.2",
|
|
38
|
+
"vitest": "^3.2.4"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist"
|
|
45
|
+
]
|
|
46
|
+
}
|