@razaman2/reactive-view 0.0.34-beta.26 → 0.0.34-beta.28
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 +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +64 -46
- package/dist/index.mjs +69 -51
- package/package.json +48 -48
package/dist/index.d.mts
CHANGED
|
@@ -120,7 +120,7 @@ declare function useSubscription(): {
|
|
|
120
120
|
};
|
|
121
121
|
declare function StyleParser(styles?: Array<string> | Record<string, boolean> | string): {};
|
|
122
122
|
declare function MergeStyles(...params: any): any;
|
|
123
|
-
declare const extendVnode: (
|
|
123
|
+
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>;
|
|
124
124
|
declare function defineReactiveView(): ReturnType<typeof defineComponent>;
|
|
125
125
|
declare function defineReactiveView(options: Record<string, any>): ReturnType<typeof defineComponent>;
|
|
126
126
|
declare function defineReactiveView(options: Record<string, any>, component: typeof _default): ReturnType<typeof defineComponent>;
|
|
@@ -128,7 +128,8 @@ declare function showComponent(component: any, options?: {
|
|
|
128
128
|
container?: string;
|
|
129
129
|
key?: string;
|
|
130
130
|
router?: any;
|
|
131
|
-
|
|
131
|
+
plugins?: Array<any>;
|
|
132
|
+
}): any;
|
|
132
133
|
declare const getData: (component: any, path: number | string, alternative: any) => any;
|
|
133
134
|
declare const setData: (component: any, data: any, path?: string) => any;
|
|
134
135
|
declare const dataPath: (component: any, path: string | number) => any;
|
package/dist/index.d.ts
CHANGED
|
@@ -120,7 +120,7 @@ declare function useSubscription(): {
|
|
|
120
120
|
};
|
|
121
121
|
declare function StyleParser(styles?: Array<string> | Record<string, boolean> | string): {};
|
|
122
122
|
declare function MergeStyles(...params: any): any;
|
|
123
|
-
declare const extendVnode: (
|
|
123
|
+
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>;
|
|
124
124
|
declare function defineReactiveView(): ReturnType<typeof defineComponent>;
|
|
125
125
|
declare function defineReactiveView(options: Record<string, any>): ReturnType<typeof defineComponent>;
|
|
126
126
|
declare function defineReactiveView(options: Record<string, any>, component: typeof _default): ReturnType<typeof defineComponent>;
|
|
@@ -128,7 +128,8 @@ declare function showComponent(component: any, options?: {
|
|
|
128
128
|
container?: string;
|
|
129
129
|
key?: string;
|
|
130
130
|
router?: any;
|
|
131
|
-
|
|
131
|
+
plugins?: Array<any>;
|
|
132
|
+
}): any;
|
|
132
133
|
declare const getData: (component: any, path: number | string, alternative: any) => any;
|
|
133
134
|
declare const setData: (component: any, data: any, path?: string) => any;
|
|
134
135
|
declare const dataPath: (component: any, path: string | number) => any;
|
package/dist/index.js
CHANGED
|
@@ -174,7 +174,7 @@ var import_vue = require("vue");
|
|
|
174
174
|
|
|
175
175
|
// package.json
|
|
176
176
|
var name = "@razaman2/reactive-view";
|
|
177
|
-
var version = "0.0.34-beta.
|
|
177
|
+
var version = "0.0.34-beta.28";
|
|
178
178
|
|
|
179
179
|
// src/ReactiveView.ts
|
|
180
180
|
var setup = {
|
|
@@ -194,7 +194,7 @@ var ReactiveView_default = {
|
|
|
194
194
|
notifications: Object,
|
|
195
195
|
subscriptions: Object,
|
|
196
196
|
beforeSetData: Function,
|
|
197
|
-
data: { default: () => ({}) },
|
|
197
|
+
data: { default: () => (0, import_vue.reactive)({}) },
|
|
198
198
|
defaultData: {},
|
|
199
199
|
getDefaultData: {
|
|
200
200
|
type: Function,
|
|
@@ -264,28 +264,19 @@ var ReactiveView_default = {
|
|
|
264
264
|
}
|
|
265
265
|
if ((0, import_vue.isReactive)(data)) {
|
|
266
266
|
return data;
|
|
267
|
-
} else if ((0, import_vue.isRef)(data)) {
|
|
268
|
-
try {
|
|
269
|
-
if (["Array", "Object"].includes((0, import_vue.unref)(data).constructor.name)) {
|
|
270
|
-
return (0, import_vue.unref)(data);
|
|
271
|
-
} else {
|
|
272
|
-
return (0, import_vue.reactive)({ "": (0, import_vue.unref)(data) });
|
|
273
|
-
}
|
|
274
|
-
} catch (e) {
|
|
275
|
-
return (0, import_vue.reactive)({ "": (0, import_vue.unref)(data) });
|
|
276
|
-
}
|
|
277
267
|
} else {
|
|
278
|
-
if (isFunctionData || isPromiseData) {
|
|
268
|
+
if ((0, import_vue.isRef)(data) || isFunctionData || isPromiseData) {
|
|
279
269
|
return (0, import_vue.reactive)(datatype);
|
|
280
270
|
} else {
|
|
271
|
+
const props2 = "data" in vue.vnode.props;
|
|
281
272
|
try {
|
|
282
273
|
if (["Array", "Object"].includes(data.constructor.name)) {
|
|
283
|
-
return (0, import_vue.reactive)(
|
|
274
|
+
return (0, import_vue.reactive)(props2 ? data : datatype);
|
|
284
275
|
} else {
|
|
285
|
-
return (0, import_vue.reactive)(
|
|
276
|
+
return (0, import_vue.reactive)(props2 ? { "": data } : datatype);
|
|
286
277
|
}
|
|
287
278
|
} catch (e) {
|
|
288
|
-
return (0, import_vue.reactive)(
|
|
279
|
+
return (0, import_vue.reactive)(props2 ? { "": data } : datatype);
|
|
289
280
|
}
|
|
290
281
|
}
|
|
291
282
|
}
|
|
@@ -297,17 +288,17 @@ var ReactiveView_default = {
|
|
|
297
288
|
defaultData: import_object_manager.default.on(defaultData).clone(),
|
|
298
289
|
notifications: props.notifications,
|
|
299
290
|
subscriptions: props.subscriptions,
|
|
300
|
-
|
|
301
|
-
|
|
291
|
+
name: props.modelName,
|
|
292
|
+
logging: props.logging
|
|
302
293
|
};
|
|
303
294
|
const model = new Proxy(props.model ? typeof props.model === "function" ? props.model(config) : props.model : new import_data_manager.default(config), {
|
|
304
295
|
get(target, key, receiver) {
|
|
305
|
-
if (
|
|
296
|
+
if (["setData", "replaceData"].includes(key.toString())) {
|
|
306
297
|
return (...params) => {
|
|
307
298
|
var _a2;
|
|
308
299
|
const beforeSetData = (_a2 = access(component).beforeSetData) != null ? _a2 : props.beforeSetData;
|
|
309
300
|
if (typeof beforeSetData === "function") {
|
|
310
|
-
const before = import_object_manager.default.on(target.getData())
|
|
301
|
+
const before = import_object_manager.default.on(target.getData());
|
|
311
302
|
const after = params.length ? import_object_manager.default.on(datatype).set(...params) : import_object_manager.default.on(datatype).set(defaultData);
|
|
312
303
|
if (beforeSetData(access(component).diff(before, after), target)) {
|
|
313
304
|
target[key](...params);
|
|
@@ -360,16 +351,39 @@ var ReactiveView_default = {
|
|
|
360
351
|
config2.callback(access(component).diff(import_object_manager.default.on(before), import_object_manager.default.on(after)), { component });
|
|
361
352
|
}, config2.options);
|
|
362
353
|
}
|
|
363
|
-
if (
|
|
354
|
+
if (props.beta) {
|
|
355
|
+
const isRefData = (0, import_vue.isRef)(props.data);
|
|
356
|
+
if (isRefData || isFunctionData || isPromiseData) {
|
|
357
|
+
setTimeout(async () => {
|
|
358
|
+
var _a2, _b2, _c2;
|
|
359
|
+
const [data] = isPromiseData ? await Promise.all([
|
|
360
|
+
isAsyncFunctionData ? props.data() : props.data,
|
|
361
|
+
(_a2 = defer.value) != null ? _a2 : true
|
|
362
|
+
]) : [props.data];
|
|
363
|
+
(0, import_vue.watch)(isRefData ? data : isFunctionData ? data : typeof data === "function" ? data : () => data, (after, before) => {
|
|
364
|
+
var _a3;
|
|
365
|
+
const callback = context.attrs["data:callback"];
|
|
366
|
+
if (typeof callback === "function") {
|
|
367
|
+
model.replaceData((_a3 = callback(access(component).diff(import_object_manager.default.on(before), import_object_manager.default.on(after)), { component })) != null ? _a3 : after);
|
|
368
|
+
} else {
|
|
369
|
+
model.replaceData(after);
|
|
370
|
+
}
|
|
371
|
+
}, {
|
|
372
|
+
immediate: (_b2 = context.attrs["data:immediate"]) != null ? _b2 : true,
|
|
373
|
+
deep: (_c2 = context.attrs["data:deep"]) != null ? _c2 : true,
|
|
374
|
+
once: context.attrs["data:once"]
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
} else {
|
|
364
379
|
setTimeout(async () => {
|
|
365
380
|
var _a2;
|
|
366
|
-
const [data] = await Promise.all([
|
|
381
|
+
const [data] = await Promise.all([
|
|
382
|
+
isAsyncFunctionData ? props.data() : props.data,
|
|
383
|
+
(_a2 = defer.value) != null ? _a2 : true
|
|
384
|
+
]);
|
|
367
385
|
watchDataProp(data);
|
|
368
386
|
});
|
|
369
|
-
} else if (props.beta && (isFunctionData || isPromiseData)) {
|
|
370
|
-
(0, import_vue.watch)(props.data, (data) => {
|
|
371
|
-
model.replaceData(data);
|
|
372
|
-
});
|
|
373
387
|
}
|
|
374
388
|
setTimeout(async () => {
|
|
375
389
|
var _a2;
|
|
@@ -575,8 +589,8 @@ function MergeStyles(...params) {
|
|
|
575
589
|
}
|
|
576
590
|
});
|
|
577
591
|
}
|
|
578
|
-
var extendVnode = (
|
|
579
|
-
return new Proxy(access(
|
|
592
|
+
var extendVnode = (component, element) => {
|
|
593
|
+
return new Proxy(access(component), {
|
|
580
594
|
get: (target, key) => {
|
|
581
595
|
const getVnode = () => {
|
|
582
596
|
try {
|
|
@@ -587,31 +601,28 @@ var extendVnode = (...params) => {
|
|
|
587
601
|
};
|
|
588
602
|
const vnode = getVnode();
|
|
589
603
|
return (props = {}, slots) => {
|
|
590
|
-
var
|
|
591
|
-
const
|
|
592
|
-
const
|
|
593
|
-
const
|
|
594
|
-
const
|
|
595
|
-
const
|
|
596
|
-
const functionalProps = Object.entries(
|
|
597
|
-
|
|
598
|
-
|
|
604
|
+
var _a;
|
|
605
|
+
const isFunctionClass = typeof props.class === "function";
|
|
606
|
+
const isFunctionStyle = typeof props.style === "function";
|
|
607
|
+
const _b = (_a = vnode.props) != null ? _a : {}, { class: classes, style: styles } = _b, rest = __objRest(_b, ["class", "style"]);
|
|
608
|
+
const finalClasses = (0, import_tailwind_merge.twMerge)(isFunctionClass ? "" : classes, MergeStyles(isFunctionClass ? props.class(classes) : props.class).string);
|
|
609
|
+
const finalStyles = MergeStyles(styles, isFunctionStyle ? props.style(styles) : props.style);
|
|
610
|
+
const functionalProps = Object.entries(props).reduce((props2, [key2, value]) => {
|
|
611
|
+
var _a2;
|
|
612
|
+
if (!["class", "style", "setup"].includes(key2) && typeof value === "function") {
|
|
613
|
+
props2[key2] = value((_a2 = vnode.props) == null ? void 0 : _a2[key2]);
|
|
599
614
|
}
|
|
600
615
|
return props2;
|
|
601
|
-
},
|
|
602
|
-
const
|
|
603
|
-
const
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
const children = slots ? isFunctionSlots ? slots(vnode.children) : slots : vnode.children;
|
|
607
|
-
return (0, import_vue2.createVNode)(params.length > 1 ? params[1] : vnode, props2, children);
|
|
608
|
-
}
|
|
616
|
+
}, props);
|
|
617
|
+
const finalProps = Object.assign(rest, functionalProps, { class: finalClasses, style: finalStyles });
|
|
618
|
+
const finalSlots = slots ? typeof slots === "function" ? slots(vnode.children) : slots : vnode.children;
|
|
619
|
+
const finalElement = ["undefined"].includes(typeof element) ? vnode.type : element;
|
|
620
|
+
return (0, import_vue2.h)(finalElement, finalProps, finalSlots);
|
|
609
621
|
};
|
|
610
622
|
}
|
|
611
623
|
});
|
|
612
624
|
};
|
|
613
625
|
function defineReactiveView(param1, param2) {
|
|
614
|
-
console.log(`log params:`, { param1, param2 });
|
|
615
626
|
return (0, import_vue2.defineComponent)({
|
|
616
627
|
name: param1 == null ? void 0 : param1.modelName,
|
|
617
628
|
props: __spreadValues({ setup }, param1 ? param1.props : {}),
|
|
@@ -631,6 +642,9 @@ function defineReactiveView(param1, param2) {
|
|
|
631
642
|
}
|
|
632
643
|
function showComponent(component, options = {}) {
|
|
633
644
|
var _a;
|
|
645
|
+
if (options.router) {
|
|
646
|
+
console.warn("[ReactiveView]: Deprecated {router} option used with {showComponent()}. \nUse {plugins} option instead.");
|
|
647
|
+
}
|
|
634
648
|
if (!options.key || !document.getElementById(options.key)) {
|
|
635
649
|
const container = options.container || "app-dialogs";
|
|
636
650
|
const dialogs = document.getElementById(container) || document.createElement("div");
|
|
@@ -657,6 +671,10 @@ function showComponent(component, options = {}) {
|
|
|
657
671
|
);
|
|
658
672
|
if (options.router) {
|
|
659
673
|
return app.use(options.router).mount(`#${id}`);
|
|
674
|
+
} else if (options.plugins) {
|
|
675
|
+
return options.plugins.reduce((app2, plugin) => {
|
|
676
|
+
return app2.use(...Array.isArray(plugin) ? plugin : [plugin]);
|
|
677
|
+
}, app).mount(`#${id}`);
|
|
660
678
|
} else {
|
|
661
679
|
return app.mount(`#${id}`);
|
|
662
680
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -124,11 +124,11 @@ var Subscriptions = _Subscriptions;
|
|
|
124
124
|
// src/ReactiveView.ts
|
|
125
125
|
import ObjectManager from "@razaman2/object-manager";
|
|
126
126
|
import DataManager from "@razaman2/data-manager";
|
|
127
|
-
import { ref, reactive, watch,
|
|
127
|
+
import { ref, reactive, watch, isRef, isReactive, createVNode, getCurrentInstance } from "vue";
|
|
128
128
|
|
|
129
129
|
// package.json
|
|
130
130
|
var name = "@razaman2/reactive-view";
|
|
131
|
-
var version = "0.0.34-beta.
|
|
131
|
+
var version = "0.0.34-beta.28";
|
|
132
132
|
|
|
133
133
|
// src/ReactiveView.ts
|
|
134
134
|
var setup = {
|
|
@@ -148,7 +148,7 @@ var ReactiveView_default = {
|
|
|
148
148
|
notifications: Object,
|
|
149
149
|
subscriptions: Object,
|
|
150
150
|
beforeSetData: Function,
|
|
151
|
-
data: { default: () => ({}) },
|
|
151
|
+
data: { default: () => reactive({}) },
|
|
152
152
|
defaultData: {},
|
|
153
153
|
getDefaultData: {
|
|
154
154
|
type: Function,
|
|
@@ -218,28 +218,19 @@ var ReactiveView_default = {
|
|
|
218
218
|
}
|
|
219
219
|
if (isReactive(data)) {
|
|
220
220
|
return data;
|
|
221
|
-
} else if (isRef(data)) {
|
|
222
|
-
try {
|
|
223
|
-
if (["Array", "Object"].includes(unref(data).constructor.name)) {
|
|
224
|
-
return unref(data);
|
|
225
|
-
} else {
|
|
226
|
-
return reactive({ "": unref(data) });
|
|
227
|
-
}
|
|
228
|
-
} catch (e) {
|
|
229
|
-
return reactive({ "": unref(data) });
|
|
230
|
-
}
|
|
231
221
|
} else {
|
|
232
|
-
if (isFunctionData || isPromiseData) {
|
|
222
|
+
if (isRef(data) || isFunctionData || isPromiseData) {
|
|
233
223
|
return reactive(datatype);
|
|
234
224
|
} else {
|
|
225
|
+
const props2 = "data" in vue.vnode.props;
|
|
235
226
|
try {
|
|
236
227
|
if (["Array", "Object"].includes(data.constructor.name)) {
|
|
237
|
-
return reactive(
|
|
228
|
+
return reactive(props2 ? data : datatype);
|
|
238
229
|
} else {
|
|
239
|
-
return reactive(
|
|
230
|
+
return reactive(props2 ? { "": data } : datatype);
|
|
240
231
|
}
|
|
241
232
|
} catch (e) {
|
|
242
|
-
return reactive(
|
|
233
|
+
return reactive(props2 ? { "": data } : datatype);
|
|
243
234
|
}
|
|
244
235
|
}
|
|
245
236
|
}
|
|
@@ -251,17 +242,17 @@ var ReactiveView_default = {
|
|
|
251
242
|
defaultData: ObjectManager.on(defaultData).clone(),
|
|
252
243
|
notifications: props.notifications,
|
|
253
244
|
subscriptions: props.subscriptions,
|
|
254
|
-
|
|
255
|
-
|
|
245
|
+
name: props.modelName,
|
|
246
|
+
logging: props.logging
|
|
256
247
|
};
|
|
257
248
|
const model = new Proxy(props.model ? typeof props.model === "function" ? props.model(config) : props.model : new DataManager(config), {
|
|
258
249
|
get(target, key, receiver) {
|
|
259
|
-
if (
|
|
250
|
+
if (["setData", "replaceData"].includes(key.toString())) {
|
|
260
251
|
return (...params) => {
|
|
261
252
|
var _a2;
|
|
262
253
|
const beforeSetData = (_a2 = access(component).beforeSetData) != null ? _a2 : props.beforeSetData;
|
|
263
254
|
if (typeof beforeSetData === "function") {
|
|
264
|
-
const before = ObjectManager.on(target.getData())
|
|
255
|
+
const before = ObjectManager.on(target.getData());
|
|
265
256
|
const after = params.length ? ObjectManager.on(datatype).set(...params) : ObjectManager.on(datatype).set(defaultData);
|
|
266
257
|
if (beforeSetData(access(component).diff(before, after), target)) {
|
|
267
258
|
target[key](...params);
|
|
@@ -314,16 +305,39 @@ var ReactiveView_default = {
|
|
|
314
305
|
config2.callback(access(component).diff(ObjectManager.on(before), ObjectManager.on(after)), { component });
|
|
315
306
|
}, config2.options);
|
|
316
307
|
}
|
|
317
|
-
if (
|
|
308
|
+
if (props.beta) {
|
|
309
|
+
const isRefData = isRef(props.data);
|
|
310
|
+
if (isRefData || isFunctionData || isPromiseData) {
|
|
311
|
+
setTimeout(async () => {
|
|
312
|
+
var _a2, _b2, _c2;
|
|
313
|
+
const [data] = isPromiseData ? await Promise.all([
|
|
314
|
+
isAsyncFunctionData ? props.data() : props.data,
|
|
315
|
+
(_a2 = defer.value) != null ? _a2 : true
|
|
316
|
+
]) : [props.data];
|
|
317
|
+
watch(isRefData ? data : isFunctionData ? data : typeof data === "function" ? data : () => data, (after, before) => {
|
|
318
|
+
var _a3;
|
|
319
|
+
const callback = context.attrs["data:callback"];
|
|
320
|
+
if (typeof callback === "function") {
|
|
321
|
+
model.replaceData((_a3 = callback(access(component).diff(ObjectManager.on(before), ObjectManager.on(after)), { component })) != null ? _a3 : after);
|
|
322
|
+
} else {
|
|
323
|
+
model.replaceData(after);
|
|
324
|
+
}
|
|
325
|
+
}, {
|
|
326
|
+
immediate: (_b2 = context.attrs["data:immediate"]) != null ? _b2 : true,
|
|
327
|
+
deep: (_c2 = context.attrs["data:deep"]) != null ? _c2 : true,
|
|
328
|
+
once: context.attrs["data:once"]
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
} else {
|
|
318
333
|
setTimeout(async () => {
|
|
319
334
|
var _a2;
|
|
320
|
-
const [data] = await Promise.all([
|
|
335
|
+
const [data] = await Promise.all([
|
|
336
|
+
isAsyncFunctionData ? props.data() : props.data,
|
|
337
|
+
(_a2 = defer.value) != null ? _a2 : true
|
|
338
|
+
]);
|
|
321
339
|
watchDataProp(data);
|
|
322
340
|
});
|
|
323
|
-
} else if (props.beta && (isFunctionData || isPromiseData)) {
|
|
324
|
-
watch(props.data, (data) => {
|
|
325
|
-
model.replaceData(data);
|
|
326
|
-
});
|
|
327
341
|
}
|
|
328
342
|
setTimeout(async () => {
|
|
329
343
|
var _a2;
|
|
@@ -358,7 +372,7 @@ var ReactiveView_default = {
|
|
|
358
372
|
};
|
|
359
373
|
|
|
360
374
|
// src/index.ts
|
|
361
|
-
import { unref
|
|
375
|
+
import { h, unref, toRaw, createApp, createVNode as createVNode2, defineComponent } from "vue";
|
|
362
376
|
import { formatInTimeZone } from "date-fns-tz";
|
|
363
377
|
import { twMerge } from "tailwind-merge";
|
|
364
378
|
console.log(`%c[ReactiveView]: ${version}`, "background-color: red; color: yellow;");
|
|
@@ -437,7 +451,7 @@ function getDate(param1, param2) {
|
|
|
437
451
|
function access(view = {}, alternative) {
|
|
438
452
|
var _a;
|
|
439
453
|
const resolve = (target) => {
|
|
440
|
-
return new Proxy(
|
|
454
|
+
return new Proxy(toRaw(target), {
|
|
441
455
|
get(target2, key) {
|
|
442
456
|
const component = { tree: target2 };
|
|
443
457
|
do {
|
|
@@ -458,7 +472,7 @@ function access(view = {}, alternative) {
|
|
|
458
472
|
});
|
|
459
473
|
};
|
|
460
474
|
try {
|
|
461
|
-
const component = (_a =
|
|
475
|
+
const component = (_a = unref(typeof view === "function" ? view() : view)) != null ? _a : {};
|
|
462
476
|
return resolve("instance" in component ? component.instance : component);
|
|
463
477
|
} catch (e) {
|
|
464
478
|
return resolve(view);
|
|
@@ -529,8 +543,8 @@ function MergeStyles(...params) {
|
|
|
529
543
|
}
|
|
530
544
|
});
|
|
531
545
|
}
|
|
532
|
-
var extendVnode = (
|
|
533
|
-
return new Proxy(access(
|
|
546
|
+
var extendVnode = (component, element) => {
|
|
547
|
+
return new Proxy(access(component), {
|
|
534
548
|
get: (target, key) => {
|
|
535
549
|
const getVnode = () => {
|
|
536
550
|
try {
|
|
@@ -541,31 +555,28 @@ var extendVnode = (...params) => {
|
|
|
541
555
|
};
|
|
542
556
|
const vnode = getVnode();
|
|
543
557
|
return (props = {}, slots) => {
|
|
544
|
-
var
|
|
545
|
-
const
|
|
546
|
-
const
|
|
547
|
-
const
|
|
548
|
-
const
|
|
549
|
-
const
|
|
550
|
-
const functionalProps = Object.entries(
|
|
551
|
-
|
|
552
|
-
|
|
558
|
+
var _a;
|
|
559
|
+
const isFunctionClass = typeof props.class === "function";
|
|
560
|
+
const isFunctionStyle = typeof props.style === "function";
|
|
561
|
+
const _b = (_a = vnode.props) != null ? _a : {}, { class: classes, style: styles } = _b, rest = __objRest(_b, ["class", "style"]);
|
|
562
|
+
const finalClasses = twMerge(isFunctionClass ? "" : classes, MergeStyles(isFunctionClass ? props.class(classes) : props.class).string);
|
|
563
|
+
const finalStyles = MergeStyles(styles, isFunctionStyle ? props.style(styles) : props.style);
|
|
564
|
+
const functionalProps = Object.entries(props).reduce((props2, [key2, value]) => {
|
|
565
|
+
var _a2;
|
|
566
|
+
if (!["class", "style", "setup"].includes(key2) && typeof value === "function") {
|
|
567
|
+
props2[key2] = value((_a2 = vnode.props) == null ? void 0 : _a2[key2]);
|
|
553
568
|
}
|
|
554
569
|
return props2;
|
|
555
|
-
},
|
|
556
|
-
const
|
|
557
|
-
const
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
const children = slots ? isFunctionSlots ? slots(vnode.children) : slots : vnode.children;
|
|
561
|
-
return createVNode2(params.length > 1 ? params[1] : vnode, props2, children);
|
|
562
|
-
}
|
|
570
|
+
}, props);
|
|
571
|
+
const finalProps = Object.assign(rest, functionalProps, { class: finalClasses, style: finalStyles });
|
|
572
|
+
const finalSlots = slots ? typeof slots === "function" ? slots(vnode.children) : slots : vnode.children;
|
|
573
|
+
const finalElement = ["undefined"].includes(typeof element) ? vnode.type : element;
|
|
574
|
+
return h(finalElement, finalProps, finalSlots);
|
|
563
575
|
};
|
|
564
576
|
}
|
|
565
577
|
});
|
|
566
578
|
};
|
|
567
579
|
function defineReactiveView(param1, param2) {
|
|
568
|
-
console.log(`log params:`, { param1, param2 });
|
|
569
580
|
return defineComponent({
|
|
570
581
|
name: param1 == null ? void 0 : param1.modelName,
|
|
571
582
|
props: __spreadValues({ setup }, param1 ? param1.props : {}),
|
|
@@ -585,6 +596,9 @@ function defineReactiveView(param1, param2) {
|
|
|
585
596
|
}
|
|
586
597
|
function showComponent(component, options = {}) {
|
|
587
598
|
var _a;
|
|
599
|
+
if (options.router) {
|
|
600
|
+
console.warn("[ReactiveView]: Deprecated {router} option used with {showComponent()}. \nUse {plugins} option instead.");
|
|
601
|
+
}
|
|
588
602
|
if (!options.key || !document.getElementById(options.key)) {
|
|
589
603
|
const container = options.container || "app-dialogs";
|
|
590
604
|
const dialogs = document.getElementById(container) || document.createElement("div");
|
|
@@ -611,6 +625,10 @@ function showComponent(component, options = {}) {
|
|
|
611
625
|
);
|
|
612
626
|
if (options.router) {
|
|
613
627
|
return app.use(options.router).mount(`#${id}`);
|
|
628
|
+
} else if (options.plugins) {
|
|
629
|
+
return options.plugins.reduce((app2, plugin) => {
|
|
630
|
+
return app2.use(...Array.isArray(plugin) ? plugin : [plugin]);
|
|
631
|
+
}, app).mount(`#${id}`);
|
|
614
632
|
} else {
|
|
615
633
|
return app.mount(`#${id}`);
|
|
616
634
|
}
|
|
@@ -634,7 +652,7 @@ var setData = (component, data, path) => {
|
|
|
634
652
|
return "state" in vue ? diff : vue.$emit("update:state", diff);
|
|
635
653
|
};
|
|
636
654
|
var componentState = (component) => {
|
|
637
|
-
return
|
|
655
|
+
return unref("state" in component ? component.state : component.$attrs.state);
|
|
638
656
|
};
|
|
639
657
|
var dataPath = (component, path) => {
|
|
640
658
|
return typeof component.$attrs["data:path"] === "function" ? component.$attrs["data:path"](path) : path;
|
package/package.json
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@razaman2/reactive-view",
|
|
3
|
-
"version": "0.0.34-beta.
|
|
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
|
-
"pr": "sh pr.sh"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
"vue",
|
|
17
|
-
"vue-helper",
|
|
18
|
-
"reactive-view",
|
|
19
|
-
"vue-class-component",
|
|
20
|
-
"reactive-ui"
|
|
21
|
-
],
|
|
22
|
-
"author": "razaman2",
|
|
23
|
-
"license": "MIT",
|
|
24
|
-
"dependencies": {
|
|
25
|
-
"@razaman2/data-manager": "^3.2.12",
|
|
26
|
-
"@razaman2/event-emitter": "^2.1.1",
|
|
27
|
-
"@razaman2/object-manager": "^3.4.7",
|
|
28
|
-
"date-fns": "^4.1.0",
|
|
29
|
-
"date-fns-tz": "^3.2.0",
|
|
30
|
-
"tailwind-merge": "^3.3.1",
|
|
31
|
-
"uuid": "^13.0.0"
|
|
32
|
-
},
|
|
33
|
-
"peerDependencies": {
|
|
34
|
-
"vue": ">=3.0.0"
|
|
35
|
-
},
|
|
36
|
-
"devDependencies": {
|
|
37
|
-
"@types/uuid": "^11.0.0",
|
|
38
|
-
"tsup": "^8.5.0",
|
|
39
|
-
"typescript": "^5.9.3",
|
|
40
|
-
"vitest": "^4.0.5"
|
|
41
|
-
},
|
|
42
|
-
"publishConfig": {
|
|
43
|
-
"access": "public"
|
|
44
|
-
},
|
|
45
|
-
"files": [
|
|
46
|
-
"dist"
|
|
47
|
-
]
|
|
48
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@razaman2/reactive-view",
|
|
3
|
+
"version": "0.0.34-beta.28",
|
|
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
|
+
"pr": "sh pr.sh"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"vue",
|
|
17
|
+
"vue-helper",
|
|
18
|
+
"reactive-view",
|
|
19
|
+
"vue-class-component",
|
|
20
|
+
"reactive-ui"
|
|
21
|
+
],
|
|
22
|
+
"author": "razaman2",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@razaman2/data-manager": "^3.2.12",
|
|
26
|
+
"@razaman2/event-emitter": "^2.1.1",
|
|
27
|
+
"@razaman2/object-manager": "^3.4.7",
|
|
28
|
+
"date-fns": "^4.1.0",
|
|
29
|
+
"date-fns-tz": "^3.2.0",
|
|
30
|
+
"tailwind-merge": "^3.3.1",
|
|
31
|
+
"uuid": "^13.0.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"vue": ">=3.0.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/uuid": "^11.0.0",
|
|
38
|
+
"tsup": "^8.5.0",
|
|
39
|
+
"typescript": "^5.9.3",
|
|
40
|
+
"vitest": "^4.0.5"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"dist"
|
|
47
|
+
]
|
|
48
|
+
}
|