@razaman2/reactive-view 0.0.30 → 0.0.33

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?: {}) => {};
@@ -44,6 +44,7 @@ declare const _default: {
44
44
  props: {
45
45
  setup: {};
46
46
  ReactiveView: {
47
+ type: BooleanConstructor;
47
48
  default: boolean;
48
49
  };
49
50
  instance: {
@@ -65,7 +66,6 @@ declare const _default: {
65
66
  logging: {
66
67
  validator: (logging: boolean) => boolean;
67
68
  };
68
- loading: {};
69
69
  modelName: {
70
70
  type: StringConstructor;
71
71
  default: string;
@@ -116,5 +116,6 @@ declare function useSubscription(): {
116
116
  };
117
117
  declare function StyleParser(styles?: Array<string> | Record<string, boolean> | string): {};
118
118
  declare function MergeStyles(...params: any): any;
119
+ 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>;
119
120
 
120
- export { MergeStyles, StyleParser, access, _default as default, getDate, getProps, getReactiveViewComponent, safeRequest, setup, useSubscription };
121
+ export { MergeStyles, StyleParser, access, _default as default, extendVnode, getDate, getProps, getReactiveViewComponent, safeRequest, setup, useSubscription };
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?: {}) => {};
@@ -44,6 +44,7 @@ declare const _default: {
44
44
  props: {
45
45
  setup: {};
46
46
  ReactiveView: {
47
+ type: BooleanConstructor;
47
48
  default: boolean;
48
49
  };
49
50
  instance: {
@@ -65,7 +66,6 @@ declare const _default: {
65
66
  logging: {
66
67
  validator: (logging: boolean) => boolean;
67
68
  };
68
- loading: {};
69
69
  modelName: {
70
70
  type: StringConstructor;
71
71
  default: string;
@@ -116,5 +116,6 @@ declare function useSubscription(): {
116
116
  };
117
117
  declare function StyleParser(styles?: Array<string> | Record<string, boolean> | string): {};
118
118
  declare function MergeStyles(...params: any): any;
119
+ 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>;
119
120
 
120
- export { MergeStyles, StyleParser, access, _default as default, getDate, getProps, getReactiveViewComponent, safeRequest, setup, useSubscription };
121
+ 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,
@@ -56,7 +69,6 @@ __export(index_exports, {
56
69
  useSubscription: () => useSubscription
57
70
  });
58
71
  module.exports = __toCommonJS(index_exports);
59
- var import_date_fns_tz = require("date-fns-tz");
60
72
 
61
73
  // src/Subscription.ts
62
74
  var Subscription = class _Subscription {
@@ -81,23 +93,26 @@ var Subscription = class _Subscription {
81
93
  this.unsubscribe(name2);
82
94
  return this.subscribe(name2, handler, data);
83
95
  }
84
- unsubscribe(subscriptions) {
85
- if (!Array.isArray(subscriptions)) {
86
- subscriptions = subscriptions ? [subscriptions] : [];
96
+ unsubscribe(param1) {
97
+ if (!Array.isArray(param1)) {
98
+ param1 = param1 ? [param1] : [];
87
99
  }
88
- if (subscriptions.length) {
89
- subscriptions.forEach((name2) => {
100
+ const log = (name2) => {
101
+ return console.log(`%cUnsubscribed From Subscription (${name2})`, "background-color: yellow; color: green; font-weight: bold; padding: 3px;");
102
+ };
103
+ if (param1.length) {
104
+ param1.forEach((name2) => {
90
105
  const subscription = this.find(name2);
91
106
  if (subscription) {
92
107
  subscription.handler();
93
108
  this.remove(subscription);
94
- console.log(`%cUnsubscribed From Subscription (${name2})`, "background-color: yellow; color: green; font-weight: bold; padding: 3px;");
109
+ log(name2);
95
110
  }
96
111
  });
97
112
  } else {
98
113
  this.subscriptions.forEach((subscription) => {
99
114
  subscription.handler();
100
- console.log(`%cUnsubscribed From Subscription (${subscription.name})`, "background-color: yellow; color: red; font-weight: bold; padding: 3px;");
115
+ log(subscription.name);
101
116
  });
102
117
  this.subscriptions = [];
103
118
  }
@@ -146,9 +161,6 @@ var _Subscriptions = class _Subscriptions extends Subscription {
146
161
  _Subscriptions.subscriptions = _Subscriptions.create();
147
162
  var Subscriptions = _Subscriptions;
148
163
 
149
- // src/index.ts
150
- var import_vue2 = require("vue");
151
-
152
164
  // src/ReactiveView.ts
153
165
  var import_object_manager = __toESM(require("@razaman2/object-manager"));
154
166
  var import_data_manager = __toESM(require("@razaman2/data-manager"));
@@ -156,7 +168,7 @@ var import_vue = require("vue");
156
168
 
157
169
  // package.json
158
170
  var name = "@razaman2/reactive-view";
159
- var version = "0.0.30";
171
+ var version = "0.0.33";
160
172
 
161
173
  // src/ReactiveView.ts
162
174
  var setup = {
@@ -168,6 +180,7 @@ var ReactiveView_default = {
168
180
  props: {
169
181
  setup: {},
170
182
  ReactiveView: {
183
+ type: Boolean,
171
184
  default: true
172
185
  },
173
186
  instance: {
@@ -191,7 +204,6 @@ var ReactiveView_default = {
191
204
  return ["Boolean"].includes(logging.constructor.name);
192
205
  }
193
206
  },
194
- loading: {},
195
207
  modelName: {
196
208
  type: String,
197
209
  default: "ReactiveView"
@@ -204,16 +216,13 @@ var ReactiveView_default = {
204
216
  setup(props, context) {
205
217
  var _a, _b, _c, _d, _e, _f, _g;
206
218
  const template = (component2, vue2) => {
207
- return context.slots.default ? (0, import_vue.createVNode)(
219
+ return (0, import_vue.createVNode)(
208
220
  "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}`);
221
+ context.slots.default ? context.attrs : __spreadValues({
222
+ style: { color: "red", textAlign: "center" }
223
+ }, context.attrs),
224
+ context.slots.default ? context.slots.default({ component: component2, vue: vue2, props, context }) : `${props.modelName}: ${name}@${version}`
225
+ );
217
226
  };
218
227
  const isValid = (0, import_vue.ref)(false);
219
228
  const ready = (0, import_vue.ref)(false);
@@ -227,9 +236,6 @@ var ReactiveView_default = {
227
236
  if (async && !((_a = vue.vnode.props) == null ? void 0 : _a.hasOwnProperty("defaultData"))) {
228
237
  console.error("[ReactiveView]: defaultData is required for async data.");
229
238
  }
230
- if (props.loading && !props.defer) {
231
- console.warn("[ReactiveView]: loading prop should be used with defer prop.");
232
- }
233
239
  const defaultData = props.getDefaultData(
234
240
  ((_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
241
  );
@@ -265,22 +271,32 @@ var ReactiveView_default = {
265
271
  }
266
272
  });
267
273
  const watchDataProp = (dataProp) => {
268
- var _a2;
269
- const config2 = typeof context.attrs["onUpdate:data"] === "function" ? {
270
- callback: context.attrs["onUpdate:data"]
271
- } : (_a2 = context.attrs["onUpdate:data"]) != null ? _a2 : {};
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({
278
+ immediate: context.attrs["data:immediate"],
279
+ deep: context.attrs["data:deep"],
280
+ once: context.attrs["data:once"]
281
+ }, ((_c2 = context.attrs["onUpdate:data"]) != null ? _c2 : {}).options)
282
+ };
283
+ if (context.attrs["data:log"]) {
284
+ console.log(`[data:prop]:`, config2);
285
+ }
272
286
  (0, import_vue.watch)(typeof dataProp === "function" || (0, import_vue.isRef)(dataProp) || (0, import_vue.isReactive)(dataProp) ? dataProp : () => dataProp, (after, before) => {
273
287
  var _a3;
274
288
  const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
275
289
  if (typeof config2.callback === "function") {
276
- model.replaceData((_a3 = config2.callback(diff, model)) != null ? _a3 : after);
290
+ model.replaceData((_a3 = config2.callback(diff, { component })) != null ? _a3 : after);
277
291
  } else {
278
292
  model.replaceData(after);
279
293
  }
280
294
  }, config2.options);
281
295
  };
282
296
  setTimeout(async () => {
283
- watchDataProp(await data);
297
+ var _a2;
298
+ const [dataProp] = await Promise.all([data, (_a2 = defer.value) != null ? _a2 : true]);
299
+ watchDataProp(dataProp);
284
300
  });
285
301
  setTimeout(async () => {
286
302
  var _a2;
@@ -292,7 +308,7 @@ var ReactiveView_default = {
292
308
  } : (_g = context.attrs["onUpdate:model"]) != null ? _g : {};
293
309
  (0, import_vue.watch)(() => model.getData(), (after, before) => {
294
310
  const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
295
- config2.callback(diff, model);
311
+ config2.callback(diff, { component });
296
312
  }, config2.options);
297
313
  }
298
314
  const component = (0, import_vue.ref)({ parent: { self: vue.proxy }, self: { template, model, isValid } });
@@ -314,16 +330,19 @@ var ReactiveView_default = {
314
330
  }, component.value);
315
331
  props.instance.value = typeof props.instance === "function" ? props.instance(component.value) : component.value;
316
332
  return (vue2) => {
333
+ var _a2, _b2;
317
334
  if (ready.value) {
318
335
  return access(component).template(component, vue2);
319
336
  } else {
320
- return props.loading;
337
+ return (_b2 = (_a2 = context.slots).loading) == null ? void 0 : _b2.call(_a2, { component });
321
338
  }
322
339
  };
323
340
  }
324
341
  };
325
342
 
326
343
  // src/index.ts
344
+ var import_vue2 = require("vue");
345
+ var import_date_fns_tz = require("date-fns-tz");
327
346
  var index_default = ReactiveView_default;
328
347
  function safeRequest(request) {
329
348
  return new Promise(async (resolve) => {
@@ -478,21 +497,59 @@ function MergeStyles(...params) {
478
497
  return __spreadValues(__spreadValues({}, StyleParser(typeof item === "function" ? item(items.slice(0, index - 1)) : item)), styles);
479
498
  }, {}), {
480
499
  get: (target, key, receiver) => {
500
+ const styles = Object.entries(target).reduce((styles2, [key2, val]) => {
501
+ return val ? styles2.concat(key2) : styles2;
502
+ }, []);
481
503
  if (key === "string") {
482
- return Object.entries(target).reduce((styles, [key2, val]) => {
483
- return val ? styles.concat(key2) : styles;
484
- }, []).join(" ");
504
+ return styles.join(" ");
505
+ } else if (key === "array") {
506
+ return styles;
485
507
  } else {
486
508
  return Reflect.get(target, key, receiver);
487
509
  }
488
510
  }
489
511
  });
490
512
  }
513
+ var extendVnode = (component, element) => {
514
+ return new Proxy(access(component), {
515
+ get: (target, key) => {
516
+ const getVnode = () => {
517
+ try {
518
+ return target[key]();
519
+ } catch (e) {
520
+ throw new Error(`${key} does not exist as vnode on component.`);
521
+ }
522
+ };
523
+ const vnode = getVnode();
524
+ return (props = {}, slots) => {
525
+ var _a;
526
+ const _b = getProps((_a = vnode.props) != null ? _a : {}, []), { class: classes, style: styles } = _b, rest = __objRest(_b, ["class", "style"]);
527
+ const finalClasses = MergeStyles(classes, typeof props.class === "function" ? props.class(classes) : props.class);
528
+ const functionalProps = Object.entries(props).reduce((props2, [key2, value]) => {
529
+ if (![
530
+ "class"
531
+ /*, "style"*/
532
+ ].includes(key2) && typeof value === "function") {
533
+ props2[key2] = value(vnode.props[key2]);
534
+ }
535
+ return props2;
536
+ }, props);
537
+ const finalProps = Object.assign(rest, functionalProps, {
538
+ class: finalClasses
539
+ /*, style: finalStyles*/
540
+ });
541
+ const finalSlots = typeof slots === "function" ? slots(vnode.children) : vnode.children;
542
+ return (0, import_vue2.h)(["string", "undefined"].includes(typeof element) ? vnode : element, finalProps, finalSlots);
543
+ };
544
+ }
545
+ });
546
+ };
491
547
  // Annotate the CommonJS export names for ESM import in node:
492
548
  0 && (module.exports = {
493
549
  MergeStyles,
494
550
  StyleParser,
495
551
  access,
552
+ extendVnode,
496
553
  getDate,
497
554
  getProps,
498
555
  getReactiveViewComponent,
package/dist/index.mjs CHANGED
@@ -14,9 +14,18 @@ var __spreadValues = (a, b) => {
14
14
  }
15
15
  return a;
16
16
  };
17
-
18
- // src/index.ts
19
- import { formatInTimeZone } from "date-fns-tz";
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
+ };
20
29
 
21
30
  // src/Subscription.ts
22
31
  var Subscription = class _Subscription {
@@ -41,23 +50,26 @@ var Subscription = class _Subscription {
41
50
  this.unsubscribe(name2);
42
51
  return this.subscribe(name2, handler, data);
43
52
  }
44
- unsubscribe(subscriptions) {
45
- if (!Array.isArray(subscriptions)) {
46
- subscriptions = subscriptions ? [subscriptions] : [];
53
+ unsubscribe(param1) {
54
+ if (!Array.isArray(param1)) {
55
+ param1 = param1 ? [param1] : [];
47
56
  }
48
- if (subscriptions.length) {
49
- subscriptions.forEach((name2) => {
57
+ const log = (name2) => {
58
+ return console.log(`%cUnsubscribed From Subscription (${name2})`, "background-color: yellow; color: green; font-weight: bold; padding: 3px;");
59
+ };
60
+ if (param1.length) {
61
+ param1.forEach((name2) => {
50
62
  const subscription = this.find(name2);
51
63
  if (subscription) {
52
64
  subscription.handler();
53
65
  this.remove(subscription);
54
- console.log(`%cUnsubscribed From Subscription (${name2})`, "background-color: yellow; color: green; font-weight: bold; padding: 3px;");
66
+ log(name2);
55
67
  }
56
68
  });
57
69
  } else {
58
70
  this.subscriptions.forEach((subscription) => {
59
71
  subscription.handler();
60
- console.log(`%cUnsubscribed From Subscription (${subscription.name})`, "background-color: yellow; color: red; font-weight: bold; padding: 3px;");
72
+ log(subscription.name);
61
73
  });
62
74
  this.subscriptions = [];
63
75
  }
@@ -106,9 +118,6 @@ var _Subscriptions = class _Subscriptions extends Subscription {
106
118
  _Subscriptions.subscriptions = _Subscriptions.create();
107
119
  var Subscriptions = _Subscriptions;
108
120
 
109
- // src/index.ts
110
- import { createVNode as createVNode2, isRef as isRef2 } from "vue";
111
-
112
121
  // src/ReactiveView.ts
113
122
  import ObjectManager from "@razaman2/object-manager";
114
123
  import DataManager from "@razaman2/data-manager";
@@ -116,7 +125,7 @@ import { ref, reactive, watch, isRef, isReactive, createVNode, getCurrentInstanc
116
125
 
117
126
  // package.json
118
127
  var name = "@razaman2/reactive-view";
119
- var version = "0.0.30";
128
+ var version = "0.0.33";
120
129
 
121
130
  // src/ReactiveView.ts
122
131
  var setup = {
@@ -128,6 +137,7 @@ var ReactiveView_default = {
128
137
  props: {
129
138
  setup: {},
130
139
  ReactiveView: {
140
+ type: Boolean,
131
141
  default: true
132
142
  },
133
143
  instance: {
@@ -151,7 +161,6 @@ var ReactiveView_default = {
151
161
  return ["Boolean"].includes(logging.constructor.name);
152
162
  }
153
163
  },
154
- loading: {},
155
164
  modelName: {
156
165
  type: String,
157
166
  default: "ReactiveView"
@@ -164,16 +173,13 @@ var ReactiveView_default = {
164
173
  setup(props, context) {
165
174
  var _a, _b, _c, _d, _e, _f, _g;
166
175
  const template = (component2, vue2) => {
167
- return context.slots.default ? createVNode(
176
+ return createVNode(
168
177
  "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}`);
178
+ context.slots.default ? context.attrs : __spreadValues({
179
+ style: { color: "red", textAlign: "center" }
180
+ }, context.attrs),
181
+ context.slots.default ? context.slots.default({ component: component2, vue: vue2, props, context }) : `${props.modelName}: ${name}@${version}`
182
+ );
177
183
  };
178
184
  const isValid = ref(false);
179
185
  const ready = ref(false);
@@ -187,9 +193,6 @@ var ReactiveView_default = {
187
193
  if (async && !((_a = vue.vnode.props) == null ? void 0 : _a.hasOwnProperty("defaultData"))) {
188
194
  console.error("[ReactiveView]: defaultData is required for async data.");
189
195
  }
190
- if (props.loading && !props.defer) {
191
- console.warn("[ReactiveView]: loading prop should be used with defer prop.");
192
- }
193
196
  const defaultData = props.getDefaultData(
194
197
  ((_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
198
  );
@@ -225,22 +228,32 @@ var ReactiveView_default = {
225
228
  }
226
229
  });
227
230
  const watchDataProp = (dataProp) => {
228
- var _a2;
229
- const config2 = typeof context.attrs["onUpdate:data"] === "function" ? {
230
- callback: context.attrs["onUpdate:data"]
231
- } : (_a2 = context.attrs["onUpdate:data"]) != null ? _a2 : {};
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({
235
+ immediate: context.attrs["data:immediate"],
236
+ deep: context.attrs["data:deep"],
237
+ once: context.attrs["data:once"]
238
+ }, ((_c2 = context.attrs["onUpdate:data"]) != null ? _c2 : {}).options)
239
+ };
240
+ if (context.attrs["data:log"]) {
241
+ console.log(`[data:prop]:`, config2);
242
+ }
232
243
  watch(typeof dataProp === "function" || isRef(dataProp) || isReactive(dataProp) ? dataProp : () => dataProp, (after, before) => {
233
244
  var _a3;
234
245
  const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
235
246
  if (typeof config2.callback === "function") {
236
- model.replaceData((_a3 = config2.callback(diff, model)) != null ? _a3 : after);
247
+ model.replaceData((_a3 = config2.callback(diff, { component })) != null ? _a3 : after);
237
248
  } else {
238
249
  model.replaceData(after);
239
250
  }
240
251
  }, config2.options);
241
252
  };
242
253
  setTimeout(async () => {
243
- watchDataProp(await data);
254
+ var _a2;
255
+ const [dataProp] = await Promise.all([data, (_a2 = defer.value) != null ? _a2 : true]);
256
+ watchDataProp(dataProp);
244
257
  });
245
258
  setTimeout(async () => {
246
259
  var _a2;
@@ -252,7 +265,7 @@ var ReactiveView_default = {
252
265
  } : (_g = context.attrs["onUpdate:model"]) != null ? _g : {};
253
266
  watch(() => model.getData(), (after, before) => {
254
267
  const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
255
- config2.callback(diff, model);
268
+ config2.callback(diff, { component });
256
269
  }, config2.options);
257
270
  }
258
271
  const component = ref({ parent: { self: vue.proxy }, self: { template, model, isValid } });
@@ -274,16 +287,19 @@ var ReactiveView_default = {
274
287
  }, component.value);
275
288
  props.instance.value = typeof props.instance === "function" ? props.instance(component.value) : component.value;
276
289
  return (vue2) => {
290
+ var _a2, _b2;
277
291
  if (ready.value) {
278
292
  return access(component).template(component, vue2);
279
293
  } else {
280
- return props.loading;
294
+ return (_b2 = (_a2 = context.slots).loading) == null ? void 0 : _b2.call(_a2, { component });
281
295
  }
282
296
  };
283
297
  }
284
298
  };
285
299
 
286
300
  // src/index.ts
301
+ import { createVNode as createVNode2, isRef as isRef2, h } from "vue";
302
+ import { formatInTimeZone } from "date-fns-tz";
287
303
  var index_default = ReactiveView_default;
288
304
  function safeRequest(request) {
289
305
  return new Promise(async (resolve) => {
@@ -438,21 +454,59 @@ function MergeStyles(...params) {
438
454
  return __spreadValues(__spreadValues({}, StyleParser(typeof item === "function" ? item(items.slice(0, index - 1)) : item)), styles);
439
455
  }, {}), {
440
456
  get: (target, key, receiver) => {
457
+ const styles = Object.entries(target).reduce((styles2, [key2, val]) => {
458
+ return val ? styles2.concat(key2) : styles2;
459
+ }, []);
441
460
  if (key === "string") {
442
- return Object.entries(target).reduce((styles, [key2, val]) => {
443
- return val ? styles.concat(key2) : styles;
444
- }, []).join(" ");
461
+ return styles.join(" ");
462
+ } else if (key === "array") {
463
+ return styles;
445
464
  } else {
446
465
  return Reflect.get(target, key, receiver);
447
466
  }
448
467
  }
449
468
  });
450
469
  }
470
+ var extendVnode = (component, element) => {
471
+ return new Proxy(access(component), {
472
+ get: (target, key) => {
473
+ const getVnode = () => {
474
+ try {
475
+ return target[key]();
476
+ } catch (e) {
477
+ throw new Error(`${key} does not exist as vnode on component.`);
478
+ }
479
+ };
480
+ const vnode = getVnode();
481
+ return (props = {}, slots) => {
482
+ var _a;
483
+ const _b = getProps((_a = vnode.props) != null ? _a : {}, []), { class: classes, style: styles } = _b, rest = __objRest(_b, ["class", "style"]);
484
+ const finalClasses = MergeStyles(classes, typeof props.class === "function" ? props.class(classes) : props.class);
485
+ const functionalProps = Object.entries(props).reduce((props2, [key2, value]) => {
486
+ if (![
487
+ "class"
488
+ /*, "style"*/
489
+ ].includes(key2) && typeof value === "function") {
490
+ props2[key2] = value(vnode.props[key2]);
491
+ }
492
+ return props2;
493
+ }, props);
494
+ const finalProps = Object.assign(rest, functionalProps, {
495
+ class: finalClasses
496
+ /*, style: finalStyles*/
497
+ });
498
+ const finalSlots = typeof slots === "function" ? slots(vnode.children) : vnode.children;
499
+ return h(["string", "undefined"].includes(typeof element) ? vnode : element, finalProps, finalSlots);
500
+ };
501
+ }
502
+ });
503
+ };
451
504
  export {
452
505
  MergeStyles,
453
506
  StyleParser,
454
507
  access,
455
508
  index_default as default,
509
+ extendVnode,
456
510
  getDate,
457
511
  getProps,
458
512
  getReactiveViewComponent,
package/package.json CHANGED
@@ -1,45 +1,46 @@
1
- {
2
- "name": "@razaman2/reactive-view",
3
- "version": "0.0.30",
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.11",
25
- "@razaman2/object-manager": "^3.4.2",
26
- "date-fns": "^4.1.0",
27
- "date-fns-tz": "^3.2.0",
28
- "uuid": "^11.1.0"
29
- },
30
- "peerDependencies": {
31
- "vue": "^3.5.13"
32
- },
33
- "devDependencies": {
34
- "@types/uuid": "^10.0.0",
35
- "tsup": "^8.4.0",
36
- "typescript": "^5.8.3",
37
- "vitest": "^3.1.1"
38
- },
39
- "publishConfig": {
40
- "access": "public"
41
- },
42
- "files": [
43
- "dist"
44
- ]
45
- }
1
+ {
2
+ "name": "@razaman2/reactive-view",
3
+ "version": "0.0.33",
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.16"
33
+ },
34
+ "devDependencies": {
35
+ "@types/uuid": "^10.0.0",
36
+ "tsup": "^8.5.0",
37
+ "typescript": "^5.8.3",
38
+ "vitest": "^3.2.3"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "files": [
44
+ "dist"
45
+ ]
46
+ }