@razaman2/reactive-view 0.0.26 → 0.0.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 CHANGED
@@ -37,7 +37,7 @@ type PropExclusions = Array<string> | string;
37
37
 
38
38
  declare const setup: {
39
39
  type: FunctionConstructor;
40
- default: (parent?: {}) => {};
40
+ default: (parent?: {}, self?: {}) => {};
41
41
  };
42
42
  declare const _default: {
43
43
  props: {
@@ -45,7 +45,9 @@ declare const _default: {
45
45
  ReactiveView: {
46
46
  default: boolean;
47
47
  };
48
- instance: {};
48
+ instance: {
49
+ default: vue.Ref<any, any>;
50
+ };
49
51
  notifications: ObjectConstructor;
50
52
  subscriptions: ObjectConstructor;
51
53
  beforeSetData: FunctionConstructor;
package/dist/index.d.ts CHANGED
@@ -37,7 +37,7 @@ type PropExclusions = Array<string> | string;
37
37
 
38
38
  declare const setup: {
39
39
  type: FunctionConstructor;
40
- default: (parent?: {}) => {};
40
+ default: (parent?: {}, self?: {}) => {};
41
41
  };
42
42
  declare const _default: {
43
43
  props: {
@@ -45,7 +45,9 @@ declare const _default: {
45
45
  ReactiveView: {
46
46
  default: boolean;
47
47
  };
48
- instance: {};
48
+ instance: {
49
+ default: vue.Ref<any, any>;
50
+ };
49
51
  notifications: ObjectConstructor;
50
52
  subscriptions: ObjectConstructor;
51
53
  beforeSetData: FunctionConstructor;
package/dist/index.js CHANGED
@@ -159,12 +159,12 @@ var import_vue = require("vue");
159
159
 
160
160
  // package.json
161
161
  var name = "@razaman2/reactive-view";
162
- var version = "0.0.26";
162
+ var version = "0.0.28";
163
163
 
164
164
  // src/ReactiveView.ts
165
165
  var setup = {
166
166
  type: Function,
167
- default: (parent = {}) => parent
167
+ default: (parent = {}, self = {}) => self
168
168
  };
169
169
  var ReactiveView_default = {
170
170
  props: {
@@ -172,7 +172,9 @@ var ReactiveView_default = {
172
172
  ReactiveView: {
173
173
  default: true
174
174
  },
175
- instance: {},
175
+ instance: {
176
+ default: (0, import_vue.ref)()
177
+ },
176
178
  notifications: Object,
177
179
  subscriptions: Object,
178
180
  beforeSetData: Function,
@@ -203,11 +205,11 @@ var ReactiveView_default = {
203
205
  },
204
206
  setup(props, context) {
205
207
  var _a, _b, _c, _d, _e, _f, _g;
206
- const template = (component2, vue) => {
208
+ const template = (component2, vue2) => {
207
209
  return context.slots.default ? (0, import_vue.createVNode)(
208
210
  "div",
209
211
  context.attrs,
210
- context.slots.default({ vue, component: component2, props, context })
212
+ context.slots.default({ vue: vue2, component: component2, props, context })
211
213
  ) : (0, import_vue.createVNode)("div", __spreadValues({
212
214
  style: {
213
215
  color: "red",
@@ -217,26 +219,26 @@ var ReactiveView_default = {
217
219
  };
218
220
  const isValid = (0, import_vue.ref)(false);
219
221
  const ready = (0, import_vue.ref)(false);
220
- const instance = (0, import_vue.getCurrentInstance)();
221
- const deferred = (0, import_vue.ref)(typeof props.defer === "function" ? props.defer() : props.defer);
222
+ const vue = (0, import_vue.getCurrentInstance)();
223
+ const defer = (0, import_vue.ref)(typeof props.defer === "function" ? props.defer() : props.defer);
222
224
  const data = typeof props.data === "function" ? props.data() : props.data;
223
225
  const async = data instanceof Promise;
224
226
  if (props.debug) {
225
- console.log("[ReactiveView]:", { props, context, isValid, ready, instance, deferred, data, async });
227
+ console.log("[ReactiveView]:", { props, context, isValid, ready, vue, defer, data, async });
226
228
  }
227
- if (async && !((_a = instance.vnode.props) == null ? void 0 : _a.hasOwnProperty("defaultData"))) {
229
+ if (async && !((_a = vue.vnode.props) == null ? void 0 : _a.hasOwnProperty("defaultData"))) {
228
230
  console.error("[ReactiveView]: defaultData is required for async data.");
229
231
  }
230
232
  if (props.loading && !props.defer) {
231
233
  console.warn("[ReactiveView]: loading prop should be used with defer prop.");
232
234
  }
233
235
  const defaultData = props.getDefaultData(
234
- ((_b = instance.vnode.props) == null ? void 0 : _b.hasOwnProperty("defaultData")) ? instance.vnode.props.defaultData : typeof ((_c = instance.vnode.props) == null ? void 0 : _c.data) === "object" ? Array.isArray(instance.vnode.props.data) ? [] : {} : ((_d = instance.vnode.props) == null ? void 0 : _d.hasOwnProperty("data")) ? (_e = instance.vnode.props) == null ? void 0 : _e.data : {}
236
+ ((_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
237
  );
236
238
  const datatype = Array.isArray(defaultData) ? [] : {};
237
239
  const config = {
238
240
  data: (0, import_vue.reactive)(
239
- import_object_manager.default.on(async ? datatype : ((_f = instance.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? data : datatype).clone()
241
+ import_object_manager.default.on(async ? datatype : ((_f = vue.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? data : datatype).clone()
240
242
  ),
241
243
  defaultData: import_object_manager.default.on(defaultData).clone(),
242
244
  notifications: props.notifications,
@@ -284,7 +286,7 @@ var ReactiveView_default = {
284
286
  });
285
287
  setTimeout(async () => {
286
288
  var _a2;
287
- ready.value = (_a2 = await deferred.value) != null ? _a2 : true;
289
+ ready.value = (_a2 = await defer.value) != null ? _a2 : true;
288
290
  });
289
291
  if (context.attrs["onUpdate:model"]) {
290
292
  const config2 = typeof context.attrs["onUpdate:model"] === "function" ? {
@@ -295,32 +297,27 @@ var ReactiveView_default = {
295
297
  config2.callback(diff, model);
296
298
  }, config2.options);
297
299
  }
298
- const component = (0, import_vue.ref)({ parent: { self: instance.proxy }, self: { template, model, isValid } });
299
- if (access(component).ReactiveView) {
300
- component.value = [access(component)].reduce((options, parent) => {
301
- var _a2, _b2;
302
- while (parent) {
303
- if (typeof parent.setup === "function") {
304
- const ups = parent.setup(component, options);
305
- options = { parent: options, self: (_b2 = (_a2 = ups.value) != null ? _a2 : ups) != null ? _b2 : {} };
306
- if (access(parent.$parent).ReactiveView) {
307
- break;
308
- } else {
309
- parent = parent.$parent;
310
- }
311
- } else {
300
+ const component = (0, import_vue.ref)({ parent: { self: vue.proxy }, self: { template, model, isValid } });
301
+ component.value = [access(component)].reduce((options, parent) => {
302
+ var _a2;
303
+ while (parent) {
304
+ if (typeof parent.setup === "function") {
305
+ options = { parent: options, self: (_a2 = parent.setup(component, options)) != null ? _a2 : {} };
306
+ if (access(parent.$parent).ReactiveView) {
312
307
  break;
308
+ } else {
309
+ parent = access(parent.$parent);
313
310
  }
311
+ } else {
312
+ break;
314
313
  }
315
- return options;
316
- }, component.value);
317
- }
318
- if (props.instance) {
319
- props.instance.value = component.value;
320
- }
321
- return (vue) => {
314
+ }
315
+ return options;
316
+ }, component.value);
317
+ props.instance.value = component.value;
318
+ return (vue2) => {
322
319
  if (ready.value) {
323
- return access(component).template(component, vue);
320
+ return access(component).template(component, vue2);
324
321
  } else {
325
322
  return props.loading;
326
323
  }
package/dist/index.mjs CHANGED
@@ -119,12 +119,12 @@ import { ref, reactive, watch, isRef, isReactive, createVNode, getCurrentInstanc
119
119
 
120
120
  // package.json
121
121
  var name = "@razaman2/reactive-view";
122
- var version = "0.0.26";
122
+ var version = "0.0.28";
123
123
 
124
124
  // src/ReactiveView.ts
125
125
  var setup = {
126
126
  type: Function,
127
- default: (parent = {}) => parent
127
+ default: (parent = {}, self = {}) => self
128
128
  };
129
129
  var ReactiveView_default = {
130
130
  props: {
@@ -132,7 +132,9 @@ var ReactiveView_default = {
132
132
  ReactiveView: {
133
133
  default: true
134
134
  },
135
- instance: {},
135
+ instance: {
136
+ default: ref()
137
+ },
136
138
  notifications: Object,
137
139
  subscriptions: Object,
138
140
  beforeSetData: Function,
@@ -163,11 +165,11 @@ var ReactiveView_default = {
163
165
  },
164
166
  setup(props, context) {
165
167
  var _a, _b, _c, _d, _e, _f, _g;
166
- const template = (component2, vue) => {
168
+ const template = (component2, vue2) => {
167
169
  return context.slots.default ? createVNode(
168
170
  "div",
169
171
  context.attrs,
170
- context.slots.default({ vue, component: component2, props, context })
172
+ context.slots.default({ vue: vue2, component: component2, props, context })
171
173
  ) : createVNode("div", __spreadValues({
172
174
  style: {
173
175
  color: "red",
@@ -177,26 +179,26 @@ var ReactiveView_default = {
177
179
  };
178
180
  const isValid = ref(false);
179
181
  const ready = ref(false);
180
- const instance = getCurrentInstance();
181
- const deferred = ref(typeof props.defer === "function" ? props.defer() : props.defer);
182
+ const vue = getCurrentInstance();
183
+ const defer = ref(typeof props.defer === "function" ? props.defer() : props.defer);
182
184
  const data = typeof props.data === "function" ? props.data() : props.data;
183
185
  const async = data instanceof Promise;
184
186
  if (props.debug) {
185
- console.log("[ReactiveView]:", { props, context, isValid, ready, instance, deferred, data, async });
187
+ console.log("[ReactiveView]:", { props, context, isValid, ready, vue, defer, data, async });
186
188
  }
187
- if (async && !((_a = instance.vnode.props) == null ? void 0 : _a.hasOwnProperty("defaultData"))) {
189
+ if (async && !((_a = vue.vnode.props) == null ? void 0 : _a.hasOwnProperty("defaultData"))) {
188
190
  console.error("[ReactiveView]: defaultData is required for async data.");
189
191
  }
190
192
  if (props.loading && !props.defer) {
191
193
  console.warn("[ReactiveView]: loading prop should be used with defer prop.");
192
194
  }
193
195
  const defaultData = props.getDefaultData(
194
- ((_b = instance.vnode.props) == null ? void 0 : _b.hasOwnProperty("defaultData")) ? instance.vnode.props.defaultData : typeof ((_c = instance.vnode.props) == null ? void 0 : _c.data) === "object" ? Array.isArray(instance.vnode.props.data) ? [] : {} : ((_d = instance.vnode.props) == null ? void 0 : _d.hasOwnProperty("data")) ? (_e = instance.vnode.props) == null ? void 0 : _e.data : {}
196
+ ((_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
197
  );
196
198
  const datatype = Array.isArray(defaultData) ? [] : {};
197
199
  const config = {
198
200
  data: reactive(
199
- ObjectManager.on(async ? datatype : ((_f = instance.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? data : datatype).clone()
201
+ ObjectManager.on(async ? datatype : ((_f = vue.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? data : datatype).clone()
200
202
  ),
201
203
  defaultData: ObjectManager.on(defaultData).clone(),
202
204
  notifications: props.notifications,
@@ -244,7 +246,7 @@ var ReactiveView_default = {
244
246
  });
245
247
  setTimeout(async () => {
246
248
  var _a2;
247
- ready.value = (_a2 = await deferred.value) != null ? _a2 : true;
249
+ ready.value = (_a2 = await defer.value) != null ? _a2 : true;
248
250
  });
249
251
  if (context.attrs["onUpdate:model"]) {
250
252
  const config2 = typeof context.attrs["onUpdate:model"] === "function" ? {
@@ -255,32 +257,27 @@ var ReactiveView_default = {
255
257
  config2.callback(diff, model);
256
258
  }, config2.options);
257
259
  }
258
- const component = ref({ parent: { self: instance.proxy }, self: { template, model, isValid } });
259
- if (access(component).ReactiveView) {
260
- component.value = [access(component)].reduce((options, parent) => {
261
- var _a2, _b2;
262
- while (parent) {
263
- if (typeof parent.setup === "function") {
264
- const ups = parent.setup(component, options);
265
- options = { parent: options, self: (_b2 = (_a2 = ups.value) != null ? _a2 : ups) != null ? _b2 : {} };
266
- if (access(parent.$parent).ReactiveView) {
267
- break;
268
- } else {
269
- parent = parent.$parent;
270
- }
271
- } else {
260
+ const component = ref({ parent: { self: vue.proxy }, self: { template, model, isValid } });
261
+ component.value = [access(component)].reduce((options, parent) => {
262
+ var _a2;
263
+ while (parent) {
264
+ if (typeof parent.setup === "function") {
265
+ options = { parent: options, self: (_a2 = parent.setup(component, options)) != null ? _a2 : {} };
266
+ if (access(parent.$parent).ReactiveView) {
272
267
  break;
268
+ } else {
269
+ parent = access(parent.$parent);
273
270
  }
271
+ } else {
272
+ break;
274
273
  }
275
- return options;
276
- }, component.value);
277
- }
278
- if (props.instance) {
279
- props.instance.value = component.value;
280
- }
281
- return (vue) => {
274
+ }
275
+ return options;
276
+ }, component.value);
277
+ props.instance.value = component.value;
278
+ return (vue2) => {
282
279
  if (ready.value) {
283
- return access(component).template(component, vue);
280
+ return access(component).template(component, vue2);
284
281
  } else {
285
282
  return props.loading;
286
283
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@razaman2/reactive-view",
3
- "version": "0.0.26",
3
+ "version": "0.0.28",
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",