@razaman2/reactive-view 0.0.34-beta.20 → 0.0.34-beta.22
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 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +28 -18
- package/dist/index.mjs +31 -21
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -121,7 +121,9 @@ declare function useSubscription(): {
|
|
|
121
121
|
declare function StyleParser(styles?: Array<string> | Record<string, boolean> | string): {};
|
|
122
122
|
declare function MergeStyles(...params: any): any;
|
|
123
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
|
-
declare function defineReactiveView(
|
|
124
|
+
declare function defineReactiveView(): ReturnType<typeof defineComponent>;
|
|
125
|
+
declare function defineReactiveView(options: Record<string, any>): ReturnType<typeof defineComponent>;
|
|
126
|
+
declare function defineReactiveView(options: Record<string, any>, component: typeof _default): ReturnType<typeof defineComponent>;
|
|
125
127
|
declare function showComponent(component: any, options?: {
|
|
126
128
|
container?: string;
|
|
127
129
|
key?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -121,7 +121,9 @@ declare function useSubscription(): {
|
|
|
121
121
|
declare function StyleParser(styles?: Array<string> | Record<string, boolean> | string): {};
|
|
122
122
|
declare function MergeStyles(...params: any): any;
|
|
123
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
|
-
declare function defineReactiveView(
|
|
124
|
+
declare function defineReactiveView(): ReturnType<typeof defineComponent>;
|
|
125
|
+
declare function defineReactiveView(options: Record<string, any>): ReturnType<typeof defineComponent>;
|
|
126
|
+
declare function defineReactiveView(options: Record<string, any>, component: typeof _default): ReturnType<typeof defineComponent>;
|
|
125
127
|
declare function showComponent(component: any, options?: {
|
|
126
128
|
container?: string;
|
|
127
129
|
key?: string;
|
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.22";
|
|
178
178
|
|
|
179
179
|
// src/ReactiveView.ts
|
|
180
180
|
var setup = {
|
|
@@ -218,7 +218,7 @@ var ReactiveView_default = {
|
|
|
218
218
|
state: { default: () => (0, import_vue.reactive)({}) }
|
|
219
219
|
},
|
|
220
220
|
setup(props, context) {
|
|
221
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
221
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
222
222
|
const diff = (before, after) => {
|
|
223
223
|
const change = after.paths().reduce((change2, path) => {
|
|
224
224
|
if (before.get(path) !== after.get(path)) {
|
|
@@ -255,12 +255,11 @@ var ReactiveView_default = {
|
|
|
255
255
|
console.error("[ReactiveView]: defaultData is required for promise or async function data.");
|
|
256
256
|
}
|
|
257
257
|
const defaultData = props.getDefaultData(
|
|
258
|
-
|
|
258
|
+
"defaultData" in vue.vnode.props ? vue.vnode.props.defaultData : "data" in vue.vnode.props ? Array.isArray(vue.vnode.props.data) ? [] : {} : {}
|
|
259
259
|
);
|
|
260
260
|
const datatype = Array.isArray(defaultData) ? [] : {};
|
|
261
261
|
const normalize = (data) => {
|
|
262
|
-
|
|
263
|
-
console.warn(`[ReactiveView]: using beta props data in [${props.modelName}] component`, data, defaultData);
|
|
262
|
+
console.warn(`[ReactiveView]: using beta props data in [${props.modelName}] component`, { vue, data, defaultData });
|
|
264
263
|
if ((0, import_vue.isReactive)(data)) {
|
|
265
264
|
return data;
|
|
266
265
|
} else if ((0, import_vue.isRef)(data)) {
|
|
@@ -275,22 +274,23 @@ var ReactiveView_default = {
|
|
|
275
274
|
}
|
|
276
275
|
} else {
|
|
277
276
|
if (isFunctionData || isPromiseData) {
|
|
277
|
+
return (0, import_vue.reactive)(datatype);
|
|
278
278
|
} else {
|
|
279
279
|
try {
|
|
280
280
|
if (["Array", "Object"].includes(data.constructor.name)) {
|
|
281
|
-
return (0, import_vue.reactive)(
|
|
281
|
+
return (0, import_vue.reactive)("data" in vue.vnode.props ? data : defaultData);
|
|
282
282
|
} else {
|
|
283
|
-
return (0, import_vue.reactive)(
|
|
283
|
+
return (0, import_vue.reactive)("data" in vue.vnode.props ? { "": data } : defaultData);
|
|
284
284
|
}
|
|
285
285
|
} catch (e) {
|
|
286
|
-
return (0, import_vue.reactive)(
|
|
286
|
+
return (0, import_vue.reactive)("data" in vue.vnode.props ? { "": data } : defaultData);
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
};
|
|
291
291
|
const config = {
|
|
292
|
-
data: props.beta ? normalize((
|
|
293
|
-
isPromiseData || isFunctionData || (0, import_vue.isRef)(props.data) || (0, import_vue.isReactive)(props.data) ? datatype :
|
|
292
|
+
data: props.beta ? normalize((_d = vue.vnode.props) == null ? void 0 : _d.data) : (0, import_vue.reactive)(import_object_manager.default.on(
|
|
293
|
+
isPromiseData || isFunctionData || (0, import_vue.isRef)(props.data) || (0, import_vue.isReactive)(props.data) ? datatype : "data" in vue.vnode.props ? props.data : datatype
|
|
294
294
|
).clone()),
|
|
295
295
|
defaultData: import_object_manager.default.on(defaultData).clone(),
|
|
296
296
|
notifications: props.notifications,
|
|
@@ -348,9 +348,9 @@ var ReactiveView_default = {
|
|
|
348
348
|
const config2 = typeof context.attrs["onUpdate:model"] === "function" ? {
|
|
349
349
|
callback: context.attrs["onUpdate:model"],
|
|
350
350
|
options: Object.assign(__spreadValues(__spreadValues({
|
|
351
|
-
deep: (
|
|
352
|
-
}, context.attrs["model:immediate"] ? { immediate: context.attrs["model:immediate"] } : {}), context.attrs["model:once"] ? { once: context.attrs["model:once"] } : {}), ((
|
|
353
|
-
} : (
|
|
351
|
+
deep: (_e = context.attrs["model:deep"]) != null ? _e : true
|
|
352
|
+
}, context.attrs["model:immediate"] ? { immediate: context.attrs["model:immediate"] } : {}), context.attrs["model:once"] ? { once: context.attrs["model:once"] } : {}), ((_f = context.attrs["onUpdate:model"]) != null ? _f : {}).options)
|
|
353
|
+
} : (_g = context.attrs["onUpdate:model"]) != null ? _g : {};
|
|
354
354
|
if (context.attrs["model:log"]) {
|
|
355
355
|
console.log(`[ReactiveView]:model`, { config: config2 });
|
|
356
356
|
}
|
|
@@ -364,6 +364,12 @@ var ReactiveView_default = {
|
|
|
364
364
|
const [data] = await Promise.all([isAsyncFunctionData ? props.data() : props.data, (_a2 = defer.value) != null ? _a2 : true]);
|
|
365
365
|
watchDataProp(data);
|
|
366
366
|
});
|
|
367
|
+
} else if (props.beta && (isFunctionData || isPromiseData)) {
|
|
368
|
+
setTimeout(async () => {
|
|
369
|
+
var _a2;
|
|
370
|
+
const [data] = await Promise.all([isFunctionData || isAsyncFunctionData ? props.data() : props.data, (_a2 = defer.value) != null ? _a2 : true]);
|
|
371
|
+
model.replaceData((0, import_vue.toRaw)((0, import_vue.unref)(data)));
|
|
372
|
+
});
|
|
367
373
|
}
|
|
368
374
|
setTimeout(async () => {
|
|
369
375
|
var _a2;
|
|
@@ -603,14 +609,18 @@ var extendVnode = (component, element) => {
|
|
|
603
609
|
function defineReactiveView(param1, param2) {
|
|
604
610
|
console.log(`log params:`, { param1, param2 });
|
|
605
611
|
return (0, import_vue2.defineComponent)({
|
|
606
|
-
|
|
612
|
+
name: param1 == null ? void 0 : param1.modelName,
|
|
613
|
+
props: __spreadValues({ setup }, param1 ? param1.props : {}),
|
|
607
614
|
setup() {
|
|
608
|
-
const _a = param1, { setup: setup2, props } = _a, rest = __objRest(_a, ["setup", "props"]);
|
|
615
|
+
const _a = param1 != null ? param1 : {}, { setup: setup2, props } = _a, rest = __objRest(_a, ["setup", "props"]);
|
|
609
616
|
return (component) => {
|
|
610
|
-
|
|
617
|
+
const props2 = Object.entries(rest).reduce((props3, [key, val]) => {
|
|
618
|
+
return Object.assign(props3, { [key]: typeof val === "function" ? val(component) : val });
|
|
619
|
+
}, {});
|
|
620
|
+
const slots = typeof (param1 == null ? void 0 : param1.slots) === "function" ? param1.slots(component) : Array.isArray(param1 == null ? void 0 : param1.slots) ? () => param1.slots : param1 == null ? void 0 : param1.slots;
|
|
621
|
+
return (0, import_vue2.createVNode)(param2 != null ? param2 : ReactiveView_default, __spreadValues(__spreadValues({}, props2), Object.assign({}, props2, typeof setup2 === "function" ? {
|
|
611
622
|
setup: (self, parent) => setup2(self, parent, component)
|
|
612
|
-
|
|
613
|
-
} : {}), typeof param1.slots === "function" ? param1.slots(component) : param1.slots);
|
|
623
|
+
} : {})), slots);
|
|
614
624
|
};
|
|
615
625
|
}
|
|
616
626
|
});
|
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, unref, isRef, isReactive, createVNode, getCurrentInstance } from "vue";
|
|
127
|
+
import { ref, reactive, watch, unref, toRaw, 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.22";
|
|
132
132
|
|
|
133
133
|
// src/ReactiveView.ts
|
|
134
134
|
var setup = {
|
|
@@ -172,7 +172,7 @@ var ReactiveView_default = {
|
|
|
172
172
|
state: { default: () => reactive({}) }
|
|
173
173
|
},
|
|
174
174
|
setup(props, context) {
|
|
175
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
175
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
176
176
|
const diff = (before, after) => {
|
|
177
177
|
const change = after.paths().reduce((change2, path) => {
|
|
178
178
|
if (before.get(path) !== after.get(path)) {
|
|
@@ -209,12 +209,11 @@ var ReactiveView_default = {
|
|
|
209
209
|
console.error("[ReactiveView]: defaultData is required for promise or async function data.");
|
|
210
210
|
}
|
|
211
211
|
const defaultData = props.getDefaultData(
|
|
212
|
-
|
|
212
|
+
"defaultData" in vue.vnode.props ? vue.vnode.props.defaultData : "data" in vue.vnode.props ? Array.isArray(vue.vnode.props.data) ? [] : {} : {}
|
|
213
213
|
);
|
|
214
214
|
const datatype = Array.isArray(defaultData) ? [] : {};
|
|
215
215
|
const normalize = (data) => {
|
|
216
|
-
|
|
217
|
-
console.warn(`[ReactiveView]: using beta props data in [${props.modelName}] component`, data, defaultData);
|
|
216
|
+
console.warn(`[ReactiveView]: using beta props data in [${props.modelName}] component`, { vue, data, defaultData });
|
|
218
217
|
if (isReactive(data)) {
|
|
219
218
|
return data;
|
|
220
219
|
} else if (isRef(data)) {
|
|
@@ -229,22 +228,23 @@ var ReactiveView_default = {
|
|
|
229
228
|
}
|
|
230
229
|
} else {
|
|
231
230
|
if (isFunctionData || isPromiseData) {
|
|
231
|
+
return reactive(datatype);
|
|
232
232
|
} else {
|
|
233
233
|
try {
|
|
234
234
|
if (["Array", "Object"].includes(data.constructor.name)) {
|
|
235
|
-
return reactive(
|
|
235
|
+
return reactive("data" in vue.vnode.props ? data : defaultData);
|
|
236
236
|
} else {
|
|
237
|
-
return reactive(
|
|
237
|
+
return reactive("data" in vue.vnode.props ? { "": data } : defaultData);
|
|
238
238
|
}
|
|
239
239
|
} catch (e) {
|
|
240
|
-
return reactive(
|
|
240
|
+
return reactive("data" in vue.vnode.props ? { "": data } : defaultData);
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
};
|
|
245
245
|
const config = {
|
|
246
|
-
data: props.beta ? normalize((
|
|
247
|
-
isPromiseData || isFunctionData || isRef(props.data) || isReactive(props.data) ? datatype :
|
|
246
|
+
data: props.beta ? normalize((_d = vue.vnode.props) == null ? void 0 : _d.data) : reactive(ObjectManager.on(
|
|
247
|
+
isPromiseData || isFunctionData || isRef(props.data) || isReactive(props.data) ? datatype : "data" in vue.vnode.props ? props.data : datatype
|
|
248
248
|
).clone()),
|
|
249
249
|
defaultData: ObjectManager.on(defaultData).clone(),
|
|
250
250
|
notifications: props.notifications,
|
|
@@ -302,9 +302,9 @@ var ReactiveView_default = {
|
|
|
302
302
|
const config2 = typeof context.attrs["onUpdate:model"] === "function" ? {
|
|
303
303
|
callback: context.attrs["onUpdate:model"],
|
|
304
304
|
options: Object.assign(__spreadValues(__spreadValues({
|
|
305
|
-
deep: (
|
|
306
|
-
}, context.attrs["model:immediate"] ? { immediate: context.attrs["model:immediate"] } : {}), context.attrs["model:once"] ? { once: context.attrs["model:once"] } : {}), ((
|
|
307
|
-
} : (
|
|
305
|
+
deep: (_e = context.attrs["model:deep"]) != null ? _e : true
|
|
306
|
+
}, context.attrs["model:immediate"] ? { immediate: context.attrs["model:immediate"] } : {}), context.attrs["model:once"] ? { once: context.attrs["model:once"] } : {}), ((_f = context.attrs["onUpdate:model"]) != null ? _f : {}).options)
|
|
307
|
+
} : (_g = context.attrs["onUpdate:model"]) != null ? _g : {};
|
|
308
308
|
if (context.attrs["model:log"]) {
|
|
309
309
|
console.log(`[ReactiveView]:model`, { config: config2 });
|
|
310
310
|
}
|
|
@@ -318,6 +318,12 @@ var ReactiveView_default = {
|
|
|
318
318
|
const [data] = await Promise.all([isAsyncFunctionData ? props.data() : props.data, (_a2 = defer.value) != null ? _a2 : true]);
|
|
319
319
|
watchDataProp(data);
|
|
320
320
|
});
|
|
321
|
+
} else if (props.beta && (isFunctionData || isPromiseData)) {
|
|
322
|
+
setTimeout(async () => {
|
|
323
|
+
var _a2;
|
|
324
|
+
const [data] = await Promise.all([isFunctionData || isAsyncFunctionData ? props.data() : props.data, (_a2 = defer.value) != null ? _a2 : true]);
|
|
325
|
+
model.replaceData(toRaw(unref(data)));
|
|
326
|
+
});
|
|
321
327
|
}
|
|
322
328
|
setTimeout(async () => {
|
|
323
329
|
var _a2;
|
|
@@ -352,7 +358,7 @@ var ReactiveView_default = {
|
|
|
352
358
|
};
|
|
353
359
|
|
|
354
360
|
// src/index.ts
|
|
355
|
-
import { h, unref as unref2, toRaw, createApp, createVNode as createVNode2, defineComponent } from "vue";
|
|
361
|
+
import { h, unref as unref2, toRaw as toRaw2, createApp, createVNode as createVNode2, defineComponent } from "vue";
|
|
356
362
|
import { formatInTimeZone } from "date-fns-tz";
|
|
357
363
|
import { twMerge } from "tailwind-merge";
|
|
358
364
|
console.log(`%c[ReactiveView]: ${version}`, "background-color: red; color: yellow;");
|
|
@@ -430,7 +436,7 @@ function getDate(param1, param2) {
|
|
|
430
436
|
}
|
|
431
437
|
function access(view = {}, alternative) {
|
|
432
438
|
const resolve = (target) => {
|
|
433
|
-
return new Proxy(
|
|
439
|
+
return new Proxy(toRaw2(target), {
|
|
434
440
|
get(target2, key) {
|
|
435
441
|
const component = { tree: target2 };
|
|
436
442
|
do {
|
|
@@ -557,14 +563,18 @@ var extendVnode = (component, element) => {
|
|
|
557
563
|
function defineReactiveView(param1, param2) {
|
|
558
564
|
console.log(`log params:`, { param1, param2 });
|
|
559
565
|
return defineComponent({
|
|
560
|
-
|
|
566
|
+
name: param1 == null ? void 0 : param1.modelName,
|
|
567
|
+
props: __spreadValues({ setup }, param1 ? param1.props : {}),
|
|
561
568
|
setup() {
|
|
562
|
-
const _a = param1, { setup: setup2, props } = _a, rest = __objRest(_a, ["setup", "props"]);
|
|
569
|
+
const _a = param1 != null ? param1 : {}, { setup: setup2, props } = _a, rest = __objRest(_a, ["setup", "props"]);
|
|
563
570
|
return (component) => {
|
|
564
|
-
|
|
571
|
+
const props2 = Object.entries(rest).reduce((props3, [key, val]) => {
|
|
572
|
+
return Object.assign(props3, { [key]: typeof val === "function" ? val(component) : val });
|
|
573
|
+
}, {});
|
|
574
|
+
const slots = typeof (param1 == null ? void 0 : param1.slots) === "function" ? param1.slots(component) : Array.isArray(param1 == null ? void 0 : param1.slots) ? () => param1.slots : param1 == null ? void 0 : param1.slots;
|
|
575
|
+
return createVNode2(param2 != null ? param2 : ReactiveView_default, __spreadValues(__spreadValues({}, props2), Object.assign({}, props2, typeof setup2 === "function" ? {
|
|
565
576
|
setup: (self, parent) => setup2(self, parent, component)
|
|
566
|
-
|
|
567
|
-
} : {}), typeof param1.slots === "function" ? param1.slots(component) : param1.slots);
|
|
577
|
+
} : {})), slots);
|
|
568
578
|
};
|
|
569
579
|
}
|
|
570
580
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razaman2/reactive-view",
|
|
3
|
-
"version": "0.0.34-beta.
|
|
3
|
+
"version": "0.0.34-beta.22",
|
|
4
4
|
"description": "This library enables you to build vue apps in an object oriented way. It provides a convenient approach to extend and override ui components. It provides a built in eventing system along with component data management.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|