@razaman2/reactive-view 0.0.34-beta.24 → 0.0.34-beta.26

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 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: (component: Record<string, any>, element: any) => Record<string, (props?: Record<string, any>, slots?: Record<string, any> | ((slots: Record<string, any>) => Record<string, any>)) => any>;
123
+ declare const extendVnode: (...params: [Record<string, any>, any]) => Record<string, (props: Record<string, any>, slots?: any | ((slots1: any) => 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>;
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: (component: Record<string, any>, element: any) => Record<string, (props?: Record<string, any>, slots?: Record<string, any> | ((slots: Record<string, any>) => Record<string, any>)) => any>;
123
+ declare const extendVnode: (...params: [Record<string, any>, any]) => Record<string, (props: Record<string, any>, slots?: any | ((slots1: any) => 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>;
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.24";
177
+ var version = "0.0.34-beta.26";
178
178
 
179
179
  // src/ReactiveView.ts
180
180
  var setup = {
@@ -259,7 +259,9 @@ var ReactiveView_default = {
259
259
  );
260
260
  const datatype = Array.isArray(defaultData) ? [] : {};
261
261
  const normalize = (data) => {
262
- console.warn(`[ReactiveView]: using beta props data in [${props.modelName}] component`, { vue, data, defaultData });
262
+ if (props.debug) {
263
+ console.warn(`[ReactiveView]: using beta props data in [${props.modelName}] component`, { vue, data, defaultData, ref: (0, import_vue.isRef)(data), reactive: (0, import_vue.isReactive)(data) });
264
+ }
263
265
  if ((0, import_vue.isReactive)(data)) {
264
266
  return data;
265
267
  } else if ((0, import_vue.isRef)(data)) {
@@ -365,10 +367,8 @@ var ReactiveView_default = {
365
367
  watchDataProp(data);
366
368
  });
367
369
  } 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)));
370
+ (0, import_vue.watch)(props.data, (data) => {
371
+ model.replaceData(data);
372
372
  });
373
373
  }
374
374
  setTimeout(async () => {
@@ -481,6 +481,7 @@ function getDate(param1, param2) {
481
481
  return (0, import_date_fns_tz.formatInTimeZone)(datetime(), options.timezone, options.format);
482
482
  }
483
483
  function access(view = {}, alternative) {
484
+ var _a;
484
485
  const resolve = (target) => {
485
486
  return new Proxy((0, import_vue2.toRaw)(target), {
486
487
  get(target2, key) {
@@ -503,7 +504,7 @@ function access(view = {}, alternative) {
503
504
  });
504
505
  };
505
506
  try {
506
- const component = (0, import_vue2.unref)(typeof view === "function" ? view() : view);
507
+ const component = (_a = (0, import_vue2.unref)(typeof view === "function" ? view() : view)) != null ? _a : {};
507
508
  return resolve("instance" in component ? component.instance : component);
508
509
  } catch (e) {
509
510
  return resolve(view);
@@ -574,8 +575,8 @@ function MergeStyles(...params) {
574
575
  }
575
576
  });
576
577
  }
577
- var extendVnode = (component, element) => {
578
- return new Proxy(access(component), {
578
+ var extendVnode = (...params) => {
579
+ return new Proxy(access(params[0]), {
579
580
  get: (target, key) => {
580
581
  const getVnode = () => {
581
582
  try {
@@ -586,23 +587,25 @@ var extendVnode = (component, element) => {
586
587
  };
587
588
  const vnode = getVnode();
588
589
  return (props = {}, slots) => {
589
- var _a;
590
- const isFunctionClass = typeof props.class === "function";
591
- const isFunctionStyle = typeof props.style === "function";
592
- const _b = (_a = vnode.props) != null ? _a : {}, { class: classes, style: styles } = _b, rest = __objRest(_b, ["class", "style"]);
593
- const finalClasses = (0, import_tailwind_merge.twMerge)(isFunctionClass ? "" : classes, MergeStyles(isFunctionClass ? props.class(classes) : props.class).string);
594
- const finalStyles = MergeStyles(styles, isFunctionStyle ? props.style(styles) : props.style);
595
- const functionalProps = Object.entries(props).reduce((props2, [key2, value]) => {
596
- var _a2;
597
- if (!["class", "style", "setup"].includes(key2) && typeof value === "function") {
598
- props2[key2] = value((_a2 = vnode.props) == null ? void 0 : _a2[key2]);
590
+ var _b;
591
+ const _a = props, { class: providedClasses, style: providedStyles } = _a, providedProps = __objRest(_a, ["class", "style"]);
592
+ const _c = (_b = vnode.props) != null ? _b : {}, { class: vnodeClasses, style: vnodeStyles } = _c, vnodeProps = __objRest(_c, ["class", "style"]);
593
+ const isFunctionClass = typeof providedClasses === "function";
594
+ const isFunctionStyle = typeof providedStyles === "function";
595
+ const isFunctionSlots = typeof slots === "function";
596
+ const functionalProps = Object.entries(providedProps).reduce((props2, [key2, value]) => {
597
+ if (typeof value === "function" && !["setup"].includes(key2)) {
598
+ props2[key2] = value(vnodeProps[key2]);
599
599
  }
600
600
  return props2;
601
- }, props);
602
- const finalProps = Object.assign(rest, functionalProps, { class: finalClasses, style: finalStyles });
603
- const finalSlots = slots ? typeof slots === "function" ? slots(vnode.children) : slots : vnode.children;
604
- const finalElement = ["undefined"].includes(typeof element) ? vnode.type : element;
605
- return (0, import_vue2.h)(finalElement, finalProps, finalSlots);
601
+ }, providedProps);
602
+ const finalClasses = (0, import_tailwind_merge.twMerge)(isFunctionClass ? "" : vnodeClasses, MergeStyles(isFunctionClass ? providedClasses(vnodeClasses) : providedClasses).string);
603
+ const finalStyles = isFunctionStyle ? providedStyles(vnodeStyles) : providedStyles;
604
+ {
605
+ const props2 = Object.assign({}, vnodeProps, functionalProps, { class: finalClasses, style: finalStyles });
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
+ }
606
609
  };
607
610
  }
608
611
  });
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, toRaw, isRef, isReactive, createVNode, getCurrentInstance } from "vue";
127
+ import { ref, reactive, watch, unref, 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.24";
131
+ var version = "0.0.34-beta.26";
132
132
 
133
133
  // src/ReactiveView.ts
134
134
  var setup = {
@@ -213,7 +213,9 @@ var ReactiveView_default = {
213
213
  );
214
214
  const datatype = Array.isArray(defaultData) ? [] : {};
215
215
  const normalize = (data) => {
216
- console.warn(`[ReactiveView]: using beta props data in [${props.modelName}] component`, { vue, data, defaultData });
216
+ if (props.debug) {
217
+ console.warn(`[ReactiveView]: using beta props data in [${props.modelName}] component`, { vue, data, defaultData, ref: isRef(data), reactive: isReactive(data) });
218
+ }
217
219
  if (isReactive(data)) {
218
220
  return data;
219
221
  } else if (isRef(data)) {
@@ -319,10 +321,8 @@ var ReactiveView_default = {
319
321
  watchDataProp(data);
320
322
  });
321
323
  } 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)));
324
+ watch(props.data, (data) => {
325
+ model.replaceData(data);
326
326
  });
327
327
  }
328
328
  setTimeout(async () => {
@@ -358,7 +358,7 @@ var ReactiveView_default = {
358
358
  };
359
359
 
360
360
  // src/index.ts
361
- import { h, unref as unref2, toRaw as toRaw2, createApp, createVNode as createVNode2, defineComponent } from "vue";
361
+ import { unref as unref2, toRaw as toRaw2, createApp, createVNode as createVNode2, defineComponent } from "vue";
362
362
  import { formatInTimeZone } from "date-fns-tz";
363
363
  import { twMerge } from "tailwind-merge";
364
364
  console.log(`%c[ReactiveView]: ${version}`, "background-color: red; color: yellow;");
@@ -435,6 +435,7 @@ function getDate(param1, param2) {
435
435
  return formatInTimeZone(datetime(), options.timezone, options.format);
436
436
  }
437
437
  function access(view = {}, alternative) {
438
+ var _a;
438
439
  const resolve = (target) => {
439
440
  return new Proxy(toRaw2(target), {
440
441
  get(target2, key) {
@@ -457,7 +458,7 @@ function access(view = {}, alternative) {
457
458
  });
458
459
  };
459
460
  try {
460
- const component = unref2(typeof view === "function" ? view() : view);
461
+ const component = (_a = unref2(typeof view === "function" ? view() : view)) != null ? _a : {};
461
462
  return resolve("instance" in component ? component.instance : component);
462
463
  } catch (e) {
463
464
  return resolve(view);
@@ -528,8 +529,8 @@ function MergeStyles(...params) {
528
529
  }
529
530
  });
530
531
  }
531
- var extendVnode = (component, element) => {
532
- return new Proxy(access(component), {
532
+ var extendVnode = (...params) => {
533
+ return new Proxy(access(params[0]), {
533
534
  get: (target, key) => {
534
535
  const getVnode = () => {
535
536
  try {
@@ -540,23 +541,25 @@ var extendVnode = (component, element) => {
540
541
  };
541
542
  const vnode = getVnode();
542
543
  return (props = {}, slots) => {
543
- var _a;
544
- const isFunctionClass = typeof props.class === "function";
545
- const isFunctionStyle = typeof props.style === "function";
546
- const _b = (_a = vnode.props) != null ? _a : {}, { class: classes, style: styles } = _b, rest = __objRest(_b, ["class", "style"]);
547
- const finalClasses = twMerge(isFunctionClass ? "" : classes, MergeStyles(isFunctionClass ? props.class(classes) : props.class).string);
548
- const finalStyles = MergeStyles(styles, isFunctionStyle ? props.style(styles) : props.style);
549
- const functionalProps = Object.entries(props).reduce((props2, [key2, value]) => {
550
- var _a2;
551
- if (!["class", "style", "setup"].includes(key2) && typeof value === "function") {
552
- props2[key2] = value((_a2 = vnode.props) == null ? void 0 : _a2[key2]);
544
+ var _b;
545
+ const _a = props, { class: providedClasses, style: providedStyles } = _a, providedProps = __objRest(_a, ["class", "style"]);
546
+ const _c = (_b = vnode.props) != null ? _b : {}, { class: vnodeClasses, style: vnodeStyles } = _c, vnodeProps = __objRest(_c, ["class", "style"]);
547
+ const isFunctionClass = typeof providedClasses === "function";
548
+ const isFunctionStyle = typeof providedStyles === "function";
549
+ const isFunctionSlots = typeof slots === "function";
550
+ const functionalProps = Object.entries(providedProps).reduce((props2, [key2, value]) => {
551
+ if (typeof value === "function" && !["setup"].includes(key2)) {
552
+ props2[key2] = value(vnodeProps[key2]);
553
553
  }
554
554
  return props2;
555
- }, props);
556
- const finalProps = Object.assign(rest, functionalProps, { class: finalClasses, style: finalStyles });
557
- const finalSlots = slots ? typeof slots === "function" ? slots(vnode.children) : slots : vnode.children;
558
- const finalElement = ["undefined"].includes(typeof element) ? vnode.type : element;
559
- return h(finalElement, finalProps, finalSlots);
555
+ }, providedProps);
556
+ const finalClasses = twMerge(isFunctionClass ? "" : vnodeClasses, MergeStyles(isFunctionClass ? providedClasses(vnodeClasses) : providedClasses).string);
557
+ const finalStyles = isFunctionStyle ? providedStyles(vnodeStyles) : providedStyles;
558
+ {
559
+ const props2 = Object.assign({}, vnodeProps, functionalProps, { class: finalClasses, style: finalStyles });
560
+ const children = slots ? isFunctionSlots ? slots(vnode.children) : slots : vnode.children;
561
+ return createVNode2(params.length > 1 ? params[1] : vnode, props2, children);
562
+ }
560
563
  };
561
564
  }
562
565
  });
package/package.json CHANGED
@@ -1,48 +1,48 @@
1
- {
2
- "name": "@razaman2/reactive-view",
3
- "version": "0.0.34-beta.24",
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.5",
28
- "date-fns": "^4.1.0",
29
- "date-fns-tz": "^3.2.0",
30
- "tailwind-merge": "^3.3.1",
31
- "uuid": "^11.1.0"
32
- },
33
- "peerDependencies": {
34
- "vue": "^3.5.20"
35
- },
36
- "devDependencies": {
37
- "@types/uuid": "^10.0.0",
38
- "tsup": "^8.5.0",
39
- "typescript": "^5.9.2",
40
- "vitest": "^3.2.4"
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.26",
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
+ }