@razaman2/reactive-view 0.0.3 → 0.0.5

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
@@ -63,6 +63,10 @@ declare const _default$1: {
63
63
  subscription: Subscription;
64
64
  };
65
65
  };
66
+ sync: {
67
+ type: BooleanConstructor;
68
+ default: boolean;
69
+ };
66
70
  setup: {
67
71
  type: FunctionConstructor;
68
72
  default: (param1?: {}, param2?: {}) => {};
package/dist/index.d.ts CHANGED
@@ -63,6 +63,10 @@ declare const _default$1: {
63
63
  subscription: Subscription;
64
64
  };
65
65
  };
66
+ sync: {
67
+ type: BooleanConstructor;
68
+ default: boolean;
69
+ };
66
70
  setup: {
67
71
  type: FunctionConstructor;
68
72
  default: (param1?: {}, param2?: {}) => {};
package/dist/index.js CHANGED
@@ -191,10 +191,9 @@ var import_vue = require("vue");
191
191
 
192
192
  // package.json
193
193
  var name = "@razaman2/reactive-view";
194
- var version = "0.0.3";
194
+ var version = "0.0.5";
195
195
 
196
196
  // src/ReactiveView.ts
197
- var import_uuid = require("uuid");
198
197
  var props = {
199
198
  defaultData: {},
200
199
  getDefaultData: {
@@ -217,6 +216,10 @@ var props = {
217
216
  subscriptions: {
218
217
  type: Object,
219
218
  default: getSubscription()
219
+ },
220
+ sync: {
221
+ type: Boolean,
222
+ default: true
220
223
  }
221
224
  };
222
225
  var setup = {
@@ -230,7 +233,7 @@ var setup = {
230
233
  var ReactiveView_default = {
231
234
  props: __spreadValues(__spreadValues({}, setup), props),
232
235
  setup(props2, context) {
233
- var _a, _b, _c, _d;
236
+ var _a, _b, _c, _d, _f;
234
237
  const template = (vue, options2) => {
235
238
  var _a2, _b2, _c2;
236
239
  const vnode = context.slots.default ? (0, import_vue.h)(
@@ -265,13 +268,9 @@ var ReactiveView_default = {
265
268
  };
266
269
  const setup2 = (_d = props2.setup(options)) != null ? _d : options;
267
270
  const _e = setup2, { parent = {}, self = {} } = _e, rest = __objRest(_e, ["parent", "self"]);
268
- let sync = false;
271
+ const sync = (0, import_vue.ref)(false);
269
272
  if (context.attrs["onUpdate:modelState"]) {
270
273
  const config2 = typeof context.attrs["onUpdate:modelState"] === "function" ? { callback: context.attrs["onUpdate:modelState"] } : context.attrs["onUpdate:modelState"];
271
- const subscriptionName = `
272
- ${props2.modelName}
273
- onUpdate:modelState
274
- ${(0, import_uuid.v4)()}`;
275
274
  const subscription = (0, import_vue.watch)(() => import_object_manager.default.on(stateRef.value).clone(), (after, before) => {
276
275
  var _a2;
277
276
  const transform = (_a2 = config2.transform) != null ? _a2 : access(setup2).$transform;
@@ -279,22 +278,22 @@ ${(0, import_uuid.v4)()}`;
279
278
  before: (before == null ? void 0 : before.hasOwnProperty("")) ? before[""] : before,
280
279
  after: (after == null ? void 0 : after.hasOwnProperty("")) ? after[""] : after
281
280
  };
282
- if (sync) {
283
- sync = false;
281
+ if (sync.value) {
282
+ sync.value = false;
284
283
  } else {
285
284
  config2.callback(transform ? transform(diff) : diff, getState);
286
285
  }
287
286
  }, config2.options);
288
287
  }
289
- if (context.attrs["onUpdate:propsState"]) {
290
- const config2 = typeof context.attrs["onUpdate:propsState"] === "function" ? { callback: context.attrs["onUpdate:propsState"] } : context.attrs["onUpdate:propsState"];
291
- const subscriptionName = `
292
- ${props2.modelName}
293
- onUpdate:propsState
294
- ${(0, import_uuid.v4)()}`;
288
+ if (context.attrs["onUpdate:propsState"] || props2.sync) {
289
+ const config2 = (_f = typeof context.attrs["onUpdate:propsState"] === "function" ? { callback: context.attrs["onUpdate:propsState"] } : context.attrs["onUpdate:propsState"]) != null ? _f : {};
295
290
  const subscription = (0, import_vue.watch)(() => props2.state, (after, before) => {
296
- config2.callback({ before, after }, getState);
297
- sync = true;
291
+ if (props2.sync && typeof config2.callback !== "function") {
292
+ getState.replaceData(after);
293
+ } else if (typeof config2.callback === "function") {
294
+ config2.callback({ before, after }, getState);
295
+ }
296
+ sync.value = true;
298
297
  }, config2.options);
299
298
  }
300
299
  return ($vue) => {
package/dist/index.mjs CHANGED
@@ -148,10 +148,9 @@ import { h, ref, watch } from "vue";
148
148
 
149
149
  // package.json
150
150
  var name = "@razaman2/reactive-view";
151
- var version = "0.0.3";
151
+ var version = "0.0.5";
152
152
 
153
153
  // src/ReactiveView.ts
154
- import { v4 as uuid } from "uuid";
155
154
  var props = {
156
155
  defaultData: {},
157
156
  getDefaultData: {
@@ -174,6 +173,10 @@ var props = {
174
173
  subscriptions: {
175
174
  type: Object,
176
175
  default: getSubscription()
176
+ },
177
+ sync: {
178
+ type: Boolean,
179
+ default: true
177
180
  }
178
181
  };
179
182
  var setup = {
@@ -187,7 +190,7 @@ var setup = {
187
190
  var ReactiveView_default = {
188
191
  props: __spreadValues(__spreadValues({}, setup), props),
189
192
  setup(props2, context) {
190
- var _a, _b, _c, _d;
193
+ var _a, _b, _c, _d, _f;
191
194
  const template = (vue, options2) => {
192
195
  var _a2, _b2, _c2;
193
196
  const vnode = context.slots.default ? h(
@@ -222,13 +225,9 @@ var ReactiveView_default = {
222
225
  };
223
226
  const setup2 = (_d = props2.setup(options)) != null ? _d : options;
224
227
  const _e = setup2, { parent = {}, self = {} } = _e, rest = __objRest(_e, ["parent", "self"]);
225
- let sync = false;
228
+ const sync = ref(false);
226
229
  if (context.attrs["onUpdate:modelState"]) {
227
230
  const config2 = typeof context.attrs["onUpdate:modelState"] === "function" ? { callback: context.attrs["onUpdate:modelState"] } : context.attrs["onUpdate:modelState"];
228
- const subscriptionName = `
229
- ${props2.modelName}
230
- onUpdate:modelState
231
- ${uuid()}`;
232
231
  const subscription = watch(() => ObjectManager.on(stateRef.value).clone(), (after, before) => {
233
232
  var _a2;
234
233
  const transform = (_a2 = config2.transform) != null ? _a2 : access(setup2).$transform;
@@ -236,22 +235,22 @@ ${uuid()}`;
236
235
  before: (before == null ? void 0 : before.hasOwnProperty("")) ? before[""] : before,
237
236
  after: (after == null ? void 0 : after.hasOwnProperty("")) ? after[""] : after
238
237
  };
239
- if (sync) {
240
- sync = false;
238
+ if (sync.value) {
239
+ sync.value = false;
241
240
  } else {
242
241
  config2.callback(transform ? transform(diff) : diff, getState);
243
242
  }
244
243
  }, config2.options);
245
244
  }
246
- if (context.attrs["onUpdate:propsState"]) {
247
- const config2 = typeof context.attrs["onUpdate:propsState"] === "function" ? { callback: context.attrs["onUpdate:propsState"] } : context.attrs["onUpdate:propsState"];
248
- const subscriptionName = `
249
- ${props2.modelName}
250
- onUpdate:propsState
251
- ${uuid()}`;
245
+ if (context.attrs["onUpdate:propsState"] || props2.sync) {
246
+ const config2 = (_f = typeof context.attrs["onUpdate:propsState"] === "function" ? { callback: context.attrs["onUpdate:propsState"] } : context.attrs["onUpdate:propsState"]) != null ? _f : {};
252
247
  const subscription = watch(() => props2.state, (after, before) => {
253
- config2.callback({ before, after }, getState);
254
- sync = true;
248
+ if (props2.sync && typeof config2.callback !== "function") {
249
+ getState.replaceData(after);
250
+ } else if (typeof config2.callback === "function") {
251
+ config2.callback({ before, after }, getState);
252
+ }
253
+ sync.value = true;
255
254
  }, config2.options);
256
255
  }
257
256
  return ($vue) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@razaman2/reactive-view",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
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",