@razaman2/reactive-view 0.0.26 → 0.0.27

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.27";
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)();
222
+ const vue = (0, import_vue.getCurrentInstance)();
221
223
  const deferred = (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, deferred, 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,
@@ -295,14 +297,13 @@ 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 } });
300
+ const component = (0, import_vue.ref)({ parent: { self: vue.proxy }, self: { template, model, isValid } });
299
301
  if (access(component).ReactiveView) {
300
302
  component.value = [access(component)].reduce((options, parent) => {
301
- var _a2, _b2;
303
+ var _a2;
302
304
  while (parent) {
303
305
  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
+ options = { parent: options, self: (_a2 = parent.setup(component, options)) != null ? _a2 : {} };
306
307
  if (access(parent.$parent).ReactiveView) {
307
308
  break;
308
309
  } else {
@@ -315,12 +316,10 @@ var ReactiveView_default = {
315
316
  return options;
316
317
  }, component.value);
317
318
  }
318
- if (props.instance) {
319
- props.instance.value = component.value;
320
- }
321
- return (vue) => {
319
+ props.instance.value = component.value;
320
+ return (vue2) => {
322
321
  if (ready.value) {
323
- return access(component).template(component, vue);
322
+ return access(component).template(component, vue2);
324
323
  } else {
325
324
  return props.loading;
326
325
  }
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.27";
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();
182
+ const vue = getCurrentInstance();
181
183
  const deferred = 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, deferred, 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,
@@ -255,14 +257,13 @@ 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 } });
260
+ const component = ref({ parent: { self: vue.proxy }, self: { template, model, isValid } });
259
261
  if (access(component).ReactiveView) {
260
262
  component.value = [access(component)].reduce((options, parent) => {
261
- var _a2, _b2;
263
+ var _a2;
262
264
  while (parent) {
263
265
  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
+ options = { parent: options, self: (_a2 = parent.setup(component, options)) != null ? _a2 : {} };
266
267
  if (access(parent.$parent).ReactiveView) {
267
268
  break;
268
269
  } else {
@@ -275,12 +276,10 @@ var ReactiveView_default = {
275
276
  return options;
276
277
  }, component.value);
277
278
  }
278
- if (props.instance) {
279
- props.instance.value = component.value;
280
- }
281
- return (vue) => {
279
+ props.instance.value = component.value;
280
+ return (vue2) => {
282
281
  if (ready.value) {
283
- return access(component).template(component, vue);
282
+ return access(component).template(component, vue2);
284
283
  } else {
285
284
  return props.loading;
286
285
  }
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.27",
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",