@razaman2/reactive-view 0.0.30 → 0.0.31

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
@@ -1,11 +1,23 @@
1
1
  import * as vue from 'vue';
2
2
  import { SetupContext, ComponentPublicInstance, UnwrapRef } from 'vue';
3
3
 
4
+ type ComponentExtension = {
5
+ parent?: ComponentExtension;
6
+ self?: Record<string | symbol, any>;
7
+ access?: () => ComponentExtension;
8
+ value?: ComponentExtension;
9
+ };
10
+ type PropOptions = {
11
+ exclude: string | Array<string>;
12
+ include: Record<string, any>;
13
+ };
4
14
  type SubscriptionItem = {
5
15
  name: string;
6
16
  handler: Function;
7
17
  data?: any;
8
18
  };
19
+ type PropExclusions = Array<string> | string;
20
+
9
21
  declare class Subscription {
10
22
  private subscriptions;
11
23
  private data;
@@ -23,18 +35,6 @@ declare class Subscription {
23
35
  get(name: string): SubscriptionItem;
24
36
  }
25
37
 
26
- type ComponentExtension = {
27
- parent?: ComponentExtension;
28
- self?: Record<string | symbol, any>;
29
- access?: () => ComponentExtension;
30
- value?: ComponentExtension;
31
- };
32
- type PropOptions = {
33
- exclude: string | Array<string>;
34
- include: Record<string, any>;
35
- };
36
- type PropExclusions = Array<string> | string;
37
-
38
38
  declare const setup: {
39
39
  type: FunctionConstructor;
40
40
  default: (parent?: {}, self?: {}) => {};
@@ -65,7 +65,6 @@ declare const _default: {
65
65
  logging: {
66
66
  validator: (logging: boolean) => boolean;
67
67
  };
68
- loading: {};
69
68
  modelName: {
70
69
  type: StringConstructor;
71
70
  default: string;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,23 @@
1
1
  import * as vue from 'vue';
2
2
  import { SetupContext, ComponentPublicInstance, UnwrapRef } from 'vue';
3
3
 
4
+ type ComponentExtension = {
5
+ parent?: ComponentExtension;
6
+ self?: Record<string | symbol, any>;
7
+ access?: () => ComponentExtension;
8
+ value?: ComponentExtension;
9
+ };
10
+ type PropOptions = {
11
+ exclude: string | Array<string>;
12
+ include: Record<string, any>;
13
+ };
4
14
  type SubscriptionItem = {
5
15
  name: string;
6
16
  handler: Function;
7
17
  data?: any;
8
18
  };
19
+ type PropExclusions = Array<string> | string;
20
+
9
21
  declare class Subscription {
10
22
  private subscriptions;
11
23
  private data;
@@ -23,18 +35,6 @@ declare class Subscription {
23
35
  get(name: string): SubscriptionItem;
24
36
  }
25
37
 
26
- type ComponentExtension = {
27
- parent?: ComponentExtension;
28
- self?: Record<string | symbol, any>;
29
- access?: () => ComponentExtension;
30
- value?: ComponentExtension;
31
- };
32
- type PropOptions = {
33
- exclude: string | Array<string>;
34
- include: Record<string, any>;
35
- };
36
- type PropExclusions = Array<string> | string;
37
-
38
38
  declare const setup: {
39
39
  type: FunctionConstructor;
40
40
  default: (parent?: {}, self?: {}) => {};
@@ -65,7 +65,6 @@ declare const _default: {
65
65
  logging: {
66
66
  validator: (logging: boolean) => boolean;
67
67
  };
68
- loading: {};
69
68
  modelName: {
70
69
  type: StringConstructor;
71
70
  default: string;
package/dist/index.js CHANGED
@@ -56,7 +56,6 @@ __export(index_exports, {
56
56
  useSubscription: () => useSubscription
57
57
  });
58
58
  module.exports = __toCommonJS(index_exports);
59
- var import_date_fns_tz = require("date-fns-tz");
60
59
 
61
60
  // src/Subscription.ts
62
61
  var Subscription = class _Subscription {
@@ -81,23 +80,26 @@ var Subscription = class _Subscription {
81
80
  this.unsubscribe(name2);
82
81
  return this.subscribe(name2, handler, data);
83
82
  }
84
- unsubscribe(subscriptions) {
85
- if (!Array.isArray(subscriptions)) {
86
- subscriptions = subscriptions ? [subscriptions] : [];
83
+ unsubscribe(param1) {
84
+ if (!Array.isArray(param1)) {
85
+ param1 = param1 ? [param1] : [];
87
86
  }
88
- if (subscriptions.length) {
89
- subscriptions.forEach((name2) => {
87
+ const log = (name2) => {
88
+ return console.log(`%cUnsubscribed From Subscription (${name2})`, "background-color: yellow; color: green; font-weight: bold; padding: 3px;");
89
+ };
90
+ if (param1.length) {
91
+ param1.forEach((name2) => {
90
92
  const subscription = this.find(name2);
91
93
  if (subscription) {
92
94
  subscription.handler();
93
95
  this.remove(subscription);
94
- console.log(`%cUnsubscribed From Subscription (${name2})`, "background-color: yellow; color: green; font-weight: bold; padding: 3px;");
96
+ log(name2);
95
97
  }
96
98
  });
97
99
  } else {
98
100
  this.subscriptions.forEach((subscription) => {
99
101
  subscription.handler();
100
- console.log(`%cUnsubscribed From Subscription (${subscription.name})`, "background-color: yellow; color: red; font-weight: bold; padding: 3px;");
102
+ log(subscription.name);
101
103
  });
102
104
  this.subscriptions = [];
103
105
  }
@@ -146,9 +148,6 @@ var _Subscriptions = class _Subscriptions extends Subscription {
146
148
  _Subscriptions.subscriptions = _Subscriptions.create();
147
149
  var Subscriptions = _Subscriptions;
148
150
 
149
- // src/index.ts
150
- var import_vue2 = require("vue");
151
-
152
151
  // src/ReactiveView.ts
153
152
  var import_object_manager = __toESM(require("@razaman2/object-manager"));
154
153
  var import_data_manager = __toESM(require("@razaman2/data-manager"));
@@ -156,7 +155,7 @@ var import_vue = require("vue");
156
155
 
157
156
  // package.json
158
157
  var name = "@razaman2/reactive-view";
159
- var version = "0.0.30";
158
+ var version = "0.0.31";
160
159
 
161
160
  // src/ReactiveView.ts
162
161
  var setup = {
@@ -191,7 +190,6 @@ var ReactiveView_default = {
191
190
  return ["Boolean"].includes(logging.constructor.name);
192
191
  }
193
192
  },
194
- loading: {},
195
193
  modelName: {
196
194
  type: String,
197
195
  default: "ReactiveView"
@@ -204,16 +202,13 @@ var ReactiveView_default = {
204
202
  setup(props, context) {
205
203
  var _a, _b, _c, _d, _e, _f, _g;
206
204
  const template = (component2, vue2) => {
207
- return context.slots.default ? (0, import_vue.createVNode)(
205
+ return (0, import_vue.createVNode)(
208
206
  "div",
209
- context.attrs,
210
- context.slots.default({ vue: vue2, component: component2, props, context })
211
- ) : (0, import_vue.createVNode)("div", __spreadValues({
212
- style: {
213
- color: "red",
214
- textAlign: "center"
215
- }
216
- }, context.attrs), `${props.modelName}: ${name}@${version}`);
207
+ context.slots.default ? context.attrs : __spreadValues({
208
+ style: { color: "red", textAlign: "center" }
209
+ }, context.attrs),
210
+ context.slots.default ? context.slots.default({ vue: vue2, component: component2, props, context }) : `${props.modelName}: ${name}@${version}`
211
+ );
217
212
  };
218
213
  const isValid = (0, import_vue.ref)(false);
219
214
  const ready = (0, import_vue.ref)(false);
@@ -227,9 +222,6 @@ var ReactiveView_default = {
227
222
  if (async && !((_a = vue.vnode.props) == null ? void 0 : _a.hasOwnProperty("defaultData"))) {
228
223
  console.error("[ReactiveView]: defaultData is required for async data.");
229
224
  }
230
- if (props.loading && !props.defer) {
231
- console.warn("[ReactiveView]: loading prop should be used with defer prop.");
232
- }
233
225
  const defaultData = props.getDefaultData(
234
226
  ((_b = vue.vnode.props) == null ? void 0 : _b.hasOwnProperty("defaultData")) ? vue.vnode.props.defaultData : typeof ((_c = vue.vnode.props) == null ? void 0 : _c.data) === "object" ? Array.isArray(vue.vnode.props.data) ? [] : {} : ((_d = vue.vnode.props) == null ? void 0 : _d.hasOwnProperty("data")) ? (_e = vue.vnode.props) == null ? void 0 : _e.data : {}
235
227
  );
@@ -280,7 +272,9 @@ var ReactiveView_default = {
280
272
  }, config2.options);
281
273
  };
282
274
  setTimeout(async () => {
283
- watchDataProp(await data);
275
+ var _a2;
276
+ const [dataProp] = await Promise.all([data, (_a2 = defer.value) != null ? _a2 : true]);
277
+ watchDataProp(dataProp);
284
278
  });
285
279
  setTimeout(async () => {
286
280
  var _a2;
@@ -314,16 +308,19 @@ var ReactiveView_default = {
314
308
  }, component.value);
315
309
  props.instance.value = typeof props.instance === "function" ? props.instance(component.value) : component.value;
316
310
  return (vue2) => {
311
+ var _a2, _b2;
317
312
  if (ready.value) {
318
313
  return access(component).template(component, vue2);
319
314
  } else {
320
- return props.loading;
315
+ return (_b2 = (_a2 = context.slots).loading) == null ? void 0 : _b2.call(_a2, { component });
321
316
  }
322
317
  };
323
318
  }
324
319
  };
325
320
 
326
321
  // src/index.ts
322
+ var import_vue2 = require("vue");
323
+ var import_date_fns_tz = require("date-fns-tz");
327
324
  var index_default = ReactiveView_default;
328
325
  function safeRequest(request) {
329
326
  return new Promise(async (resolve) => {
@@ -478,10 +475,13 @@ function MergeStyles(...params) {
478
475
  return __spreadValues(__spreadValues({}, StyleParser(typeof item === "function" ? item(items.slice(0, index - 1)) : item)), styles);
479
476
  }, {}), {
480
477
  get: (target, key, receiver) => {
478
+ const styles = Object.entries(target).reduce((styles2, [key2, val]) => {
479
+ return val ? styles2.concat(key2) : styles2;
480
+ }, []);
481
481
  if (key === "string") {
482
- return Object.entries(target).reduce((styles, [key2, val]) => {
483
- return val ? styles.concat(key2) : styles;
484
- }, []).join(" ");
482
+ return styles.join(" ");
483
+ } else if (key === "array") {
484
+ return styles;
485
485
  } else {
486
486
  return Reflect.get(target, key, receiver);
487
487
  }
package/dist/index.mjs CHANGED
@@ -15,9 +15,6 @@ var __spreadValues = (a, b) => {
15
15
  return a;
16
16
  };
17
17
 
18
- // src/index.ts
19
- import { formatInTimeZone } from "date-fns-tz";
20
-
21
18
  // src/Subscription.ts
22
19
  var Subscription = class _Subscription {
23
20
  constructor() {
@@ -41,23 +38,26 @@ var Subscription = class _Subscription {
41
38
  this.unsubscribe(name2);
42
39
  return this.subscribe(name2, handler, data);
43
40
  }
44
- unsubscribe(subscriptions) {
45
- if (!Array.isArray(subscriptions)) {
46
- subscriptions = subscriptions ? [subscriptions] : [];
41
+ unsubscribe(param1) {
42
+ if (!Array.isArray(param1)) {
43
+ param1 = param1 ? [param1] : [];
47
44
  }
48
- if (subscriptions.length) {
49
- subscriptions.forEach((name2) => {
45
+ const log = (name2) => {
46
+ return console.log(`%cUnsubscribed From Subscription (${name2})`, "background-color: yellow; color: green; font-weight: bold; padding: 3px;");
47
+ };
48
+ if (param1.length) {
49
+ param1.forEach((name2) => {
50
50
  const subscription = this.find(name2);
51
51
  if (subscription) {
52
52
  subscription.handler();
53
53
  this.remove(subscription);
54
- console.log(`%cUnsubscribed From Subscription (${name2})`, "background-color: yellow; color: green; font-weight: bold; padding: 3px;");
54
+ log(name2);
55
55
  }
56
56
  });
57
57
  } else {
58
58
  this.subscriptions.forEach((subscription) => {
59
59
  subscription.handler();
60
- console.log(`%cUnsubscribed From Subscription (${subscription.name})`, "background-color: yellow; color: red; font-weight: bold; padding: 3px;");
60
+ log(subscription.name);
61
61
  });
62
62
  this.subscriptions = [];
63
63
  }
@@ -106,9 +106,6 @@ var _Subscriptions = class _Subscriptions extends Subscription {
106
106
  _Subscriptions.subscriptions = _Subscriptions.create();
107
107
  var Subscriptions = _Subscriptions;
108
108
 
109
- // src/index.ts
110
- import { createVNode as createVNode2, isRef as isRef2 } from "vue";
111
-
112
109
  // src/ReactiveView.ts
113
110
  import ObjectManager from "@razaman2/object-manager";
114
111
  import DataManager from "@razaman2/data-manager";
@@ -116,7 +113,7 @@ import { ref, reactive, watch, isRef, isReactive, createVNode, getCurrentInstanc
116
113
 
117
114
  // package.json
118
115
  var name = "@razaman2/reactive-view";
119
- var version = "0.0.30";
116
+ var version = "0.0.31";
120
117
 
121
118
  // src/ReactiveView.ts
122
119
  var setup = {
@@ -151,7 +148,6 @@ var ReactiveView_default = {
151
148
  return ["Boolean"].includes(logging.constructor.name);
152
149
  }
153
150
  },
154
- loading: {},
155
151
  modelName: {
156
152
  type: String,
157
153
  default: "ReactiveView"
@@ -164,16 +160,13 @@ var ReactiveView_default = {
164
160
  setup(props, context) {
165
161
  var _a, _b, _c, _d, _e, _f, _g;
166
162
  const template = (component2, vue2) => {
167
- return context.slots.default ? createVNode(
163
+ return createVNode(
168
164
  "div",
169
- context.attrs,
170
- context.slots.default({ vue: vue2, component: component2, props, context })
171
- ) : createVNode("div", __spreadValues({
172
- style: {
173
- color: "red",
174
- textAlign: "center"
175
- }
176
- }, context.attrs), `${props.modelName}: ${name}@${version}`);
165
+ context.slots.default ? context.attrs : __spreadValues({
166
+ style: { color: "red", textAlign: "center" }
167
+ }, context.attrs),
168
+ context.slots.default ? context.slots.default({ vue: vue2, component: component2, props, context }) : `${props.modelName}: ${name}@${version}`
169
+ );
177
170
  };
178
171
  const isValid = ref(false);
179
172
  const ready = ref(false);
@@ -187,9 +180,6 @@ var ReactiveView_default = {
187
180
  if (async && !((_a = vue.vnode.props) == null ? void 0 : _a.hasOwnProperty("defaultData"))) {
188
181
  console.error("[ReactiveView]: defaultData is required for async data.");
189
182
  }
190
- if (props.loading && !props.defer) {
191
- console.warn("[ReactiveView]: loading prop should be used with defer prop.");
192
- }
193
183
  const defaultData = props.getDefaultData(
194
184
  ((_b = vue.vnode.props) == null ? void 0 : _b.hasOwnProperty("defaultData")) ? vue.vnode.props.defaultData : typeof ((_c = vue.vnode.props) == null ? void 0 : _c.data) === "object" ? Array.isArray(vue.vnode.props.data) ? [] : {} : ((_d = vue.vnode.props) == null ? void 0 : _d.hasOwnProperty("data")) ? (_e = vue.vnode.props) == null ? void 0 : _e.data : {}
195
185
  );
@@ -240,7 +230,9 @@ var ReactiveView_default = {
240
230
  }, config2.options);
241
231
  };
242
232
  setTimeout(async () => {
243
- watchDataProp(await data);
233
+ var _a2;
234
+ const [dataProp] = await Promise.all([data, (_a2 = defer.value) != null ? _a2 : true]);
235
+ watchDataProp(dataProp);
244
236
  });
245
237
  setTimeout(async () => {
246
238
  var _a2;
@@ -274,16 +266,19 @@ var ReactiveView_default = {
274
266
  }, component.value);
275
267
  props.instance.value = typeof props.instance === "function" ? props.instance(component.value) : component.value;
276
268
  return (vue2) => {
269
+ var _a2, _b2;
277
270
  if (ready.value) {
278
271
  return access(component).template(component, vue2);
279
272
  } else {
280
- return props.loading;
273
+ return (_b2 = (_a2 = context.slots).loading) == null ? void 0 : _b2.call(_a2, { component });
281
274
  }
282
275
  };
283
276
  }
284
277
  };
285
278
 
286
279
  // src/index.ts
280
+ import { createVNode as createVNode2, isRef as isRef2 } from "vue";
281
+ import { formatInTimeZone } from "date-fns-tz";
287
282
  var index_default = ReactiveView_default;
288
283
  function safeRequest(request) {
289
284
  return new Promise(async (resolve) => {
@@ -438,10 +433,13 @@ function MergeStyles(...params) {
438
433
  return __spreadValues(__spreadValues({}, StyleParser(typeof item === "function" ? item(items.slice(0, index - 1)) : item)), styles);
439
434
  }, {}), {
440
435
  get: (target, key, receiver) => {
436
+ const styles = Object.entries(target).reduce((styles2, [key2, val]) => {
437
+ return val ? styles2.concat(key2) : styles2;
438
+ }, []);
441
439
  if (key === "string") {
442
- return Object.entries(target).reduce((styles, [key2, val]) => {
443
- return val ? styles.concat(key2) : styles;
444
- }, []).join(" ");
440
+ return styles.join(" ");
441
+ } else if (key === "array") {
442
+ return styles;
445
443
  } else {
446
444
  return Reflect.get(target, key, receiver);
447
445
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@razaman2/reactive-view",
3
- "version": "0.0.30",
3
+ "version": "0.0.31",
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",
@@ -21,20 +21,20 @@
21
21
  "author": "razaman2",
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@razaman2/data-manager": "^3.2.11",
24
+ "@razaman2/data-manager": "^3.2.12",
25
25
  "@razaman2/object-manager": "^3.4.2",
26
26
  "date-fns": "^4.1.0",
27
27
  "date-fns-tz": "^3.2.0",
28
28
  "uuid": "^11.1.0"
29
29
  },
30
30
  "peerDependencies": {
31
- "vue": "^3.5.13"
31
+ "vue": "^3.5.16"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/uuid": "^10.0.0",
35
- "tsup": "^8.4.0",
35
+ "tsup": "^8.5.0",
36
36
  "typescript": "^5.8.3",
37
- "vitest": "^3.1.1"
37
+ "vitest": "^3.2.3"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public"