@razaman2/reactive-view 0.0.1 → 0.0.4
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 +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +15 -20
- package/dist/index.mjs +16 -21
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
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.
|
|
194
|
+
var version = "0.0.4";
|
|
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 = {
|
|
@@ -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
|
-
|
|
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,27 +278,23 @@ ${(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
|
-
props2.subscriptions.addSubscription(subscriptionName, subscription);
|
|
289
|
-
(0, import_vue.onBeforeUnmount)(() => props2.subscriptions.removeSubscription(subscriptionName, false));
|
|
290
287
|
}
|
|
291
|
-
if (context.attrs["onUpdate:propsState"]) {
|
|
288
|
+
if (context.attrs["onUpdate:propsState"] || props2.sync) {
|
|
292
289
|
const config2 = typeof context.attrs["onUpdate:propsState"] === "function" ? { callback: context.attrs["onUpdate:propsState"] } : context.attrs["onUpdate:propsState"];
|
|
293
|
-
const subscriptionName = `
|
|
294
|
-
${props2.modelName}
|
|
295
|
-
onUpdate:propsState
|
|
296
|
-
${(0, import_uuid.v4)()}`;
|
|
297
290
|
const subscription = (0, import_vue.watch)(() => props2.state, (after, before) => {
|
|
298
|
-
config2.callback
|
|
299
|
-
|
|
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;
|
|
300
297
|
}, config2.options);
|
|
301
|
-
props2.subscriptions.addSubscription(subscriptionName, subscription);
|
|
302
|
-
(0, import_vue.onBeforeUnmount)(() => props2.subscriptions.removeSubscription(subscriptionName, false));
|
|
303
298
|
}
|
|
304
299
|
return ($vue) => {
|
|
305
300
|
const setup3 = { $vue, options: parent };
|
package/dist/index.mjs
CHANGED
|
@@ -144,14 +144,13 @@ var Subscriptions = _Subscriptions;
|
|
|
144
144
|
// src/ReactiveView.ts
|
|
145
145
|
import ObjectManager from "@razaman2/object-manager";
|
|
146
146
|
import DataManager from "@razaman2/data-manager";
|
|
147
|
-
import { h, ref, watch
|
|
147
|
+
import { h, ref, watch } from "vue";
|
|
148
148
|
|
|
149
149
|
// package.json
|
|
150
150
|
var name = "@razaman2/reactive-view";
|
|
151
|
-
var version = "0.0.
|
|
151
|
+
var version = "0.0.4";
|
|
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 = {
|
|
@@ -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
|
-
|
|
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,27 +235,23 @@ ${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
|
-
props2.subscriptions.addSubscription(subscriptionName, subscription);
|
|
246
|
-
onBeforeUnmount(() => props2.subscriptions.removeSubscription(subscriptionName, false));
|
|
247
244
|
}
|
|
248
|
-
if (context.attrs["onUpdate:propsState"]) {
|
|
245
|
+
if (context.attrs["onUpdate:propsState"] || props2.sync) {
|
|
249
246
|
const config2 = typeof context.attrs["onUpdate:propsState"] === "function" ? { callback: context.attrs["onUpdate:propsState"] } : context.attrs["onUpdate:propsState"];
|
|
250
|
-
const subscriptionName = `
|
|
251
|
-
${props2.modelName}
|
|
252
|
-
onUpdate:propsState
|
|
253
|
-
${uuid()}`;
|
|
254
247
|
const subscription = watch(() => props2.state, (after, before) => {
|
|
255
|
-
config2.callback
|
|
256
|
-
|
|
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;
|
|
257
254
|
}, config2.options);
|
|
258
|
-
props2.subscriptions.addSubscription(subscriptionName, subscription);
|
|
259
|
-
onBeforeUnmount(() => props2.subscriptions.removeSubscription(subscriptionName, false));
|
|
260
255
|
}
|
|
261
256
|
return ($vue) => {
|
|
262
257
|
const setup3 = { $vue, options: parent };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razaman2/reactive-view",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
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",
|