@razaman2/reactive-view 0.0.8 → 0.0.9
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.js +27 -26
- package/dist/index.mjs +28 -27
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -161,7 +161,7 @@ var import_data_manager = __toESM(require("@razaman2/data-manager"));
|
|
|
161
161
|
|
|
162
162
|
// package.json
|
|
163
163
|
var name = "@razaman2/reactive-view";
|
|
164
|
-
var version = "0.0.
|
|
164
|
+
var version = "0.0.9";
|
|
165
165
|
|
|
166
166
|
// src/ReactiveView.ts
|
|
167
167
|
var import_vue = require("vue");
|
|
@@ -201,7 +201,7 @@ var setup = {
|
|
|
201
201
|
var ReactiveView_default = {
|
|
202
202
|
props: __spreadValues(__spreadValues({}, setup), props),
|
|
203
203
|
setup(props2, context) {
|
|
204
|
-
var _a, _b, _c, _d,
|
|
204
|
+
var _a, _b, _c, _d, _f;
|
|
205
205
|
const template = (vue, options2) => {
|
|
206
206
|
var _a2, _b2, _c2;
|
|
207
207
|
const vnode = context.slots.default ? (0, import_vue.h)(
|
|
@@ -233,10 +233,10 @@ var ReactiveView_default = {
|
|
|
233
233
|
const getState = props2.model ? typeof props2.model === "function" ? props2.model(config) : props2.model : new import_data_manager.default(config);
|
|
234
234
|
const sync = (0, import_vue.ref)(false);
|
|
235
235
|
const options = {
|
|
236
|
-
parent: { self: (
|
|
236
|
+
parent: { self: (0, import_vue.getCurrentInstance)().proxy },
|
|
237
237
|
self: { template, isValid, getState }
|
|
238
238
|
};
|
|
239
|
-
const
|
|
239
|
+
const _e = (_d = props2.setup(options)) != null ? _d : options, { parent = {}, self = {} } = _e, rest = __objRest(_e, ["parent", "self"]);
|
|
240
240
|
if (props2.await instanceof Promise) {
|
|
241
241
|
(0, import_vue.nextTick)(async () => {
|
|
242
242
|
getState.replaceData(await props2.await);
|
|
@@ -244,30 +244,31 @@ var ReactiveView_default = {
|
|
|
244
244
|
}
|
|
245
245
|
if (context.attrs["onUpdate:modelState"]) {
|
|
246
246
|
const config2 = typeof context.attrs["onUpdate:modelState"] === "function" ? { callback: context.attrs["onUpdate:modelState"] } : context.attrs["onUpdate:modelState"];
|
|
247
|
-
(0, import_vue.
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
before: (before
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}, config2.options);
|
|
247
|
+
(0, import_vue.onMounted)(() => {
|
|
248
|
+
(0, import_vue.watch)(() => import_object_manager.default.on(state).clone(), (after, before) => {
|
|
249
|
+
var _a2;
|
|
250
|
+
const beforeStateUpdate = (_a2 = config2.beforeStateUpdate) != null ? _a2 : access({ parent, self }).beforeStateUpdate;
|
|
251
|
+
const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
|
|
252
|
+
if (sync.value) {
|
|
253
|
+
sync.value = false;
|
|
254
|
+
} else {
|
|
255
|
+
config2.callback(beforeStateUpdate ? beforeStateUpdate(diff) : diff, getState);
|
|
256
|
+
}
|
|
257
|
+
}, config2.options);
|
|
258
|
+
});
|
|
260
259
|
}
|
|
261
260
|
if (context.attrs["onUpdate:propsState"] || props2.sync) {
|
|
262
|
-
const config2 = (
|
|
263
|
-
(0, import_vue.
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
config2.callback
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
261
|
+
const config2 = (_f = typeof context.attrs["onUpdate:propsState"] === "function" ? { callback: context.attrs["onUpdate:propsState"] } : context.attrs["onUpdate:propsState"]) != null ? _f : {};
|
|
262
|
+
(0, import_vue.onMounted)(() => {
|
|
263
|
+
(0, import_vue.watch)(() => props2.state, (after, before) => {
|
|
264
|
+
if (props2.sync && typeof config2.callback !== "function") {
|
|
265
|
+
getState.replaceData(after);
|
|
266
|
+
} else if (typeof config2.callback === "function") {
|
|
267
|
+
config2.callback({ before, after }, getState);
|
|
268
|
+
}
|
|
269
|
+
sync.value = true;
|
|
270
|
+
}, config2.options);
|
|
271
|
+
});
|
|
271
272
|
}
|
|
272
273
|
return ($vue) => {
|
|
273
274
|
const setup2 = { $vue, options: parent };
|
package/dist/index.mjs
CHANGED
|
@@ -124,10 +124,10 @@ import DataManager from "@razaman2/data-manager";
|
|
|
124
124
|
|
|
125
125
|
// package.json
|
|
126
126
|
var name = "@razaman2/reactive-view";
|
|
127
|
-
var version = "0.0.
|
|
127
|
+
var version = "0.0.9";
|
|
128
128
|
|
|
129
129
|
// src/ReactiveView.ts
|
|
130
|
-
import { h, ref, reactive, watch, nextTick, getCurrentInstance } from "vue";
|
|
130
|
+
import { h, ref, reactive, watch, nextTick, getCurrentInstance, onMounted } from "vue";
|
|
131
131
|
var props = {
|
|
132
132
|
notifications: Object,
|
|
133
133
|
subscriptions: Object,
|
|
@@ -164,7 +164,7 @@ var setup = {
|
|
|
164
164
|
var ReactiveView_default = {
|
|
165
165
|
props: __spreadValues(__spreadValues({}, setup), props),
|
|
166
166
|
setup(props2, context) {
|
|
167
|
-
var _a, _b, _c, _d,
|
|
167
|
+
var _a, _b, _c, _d, _f;
|
|
168
168
|
const template = (vue, options2) => {
|
|
169
169
|
var _a2, _b2, _c2;
|
|
170
170
|
const vnode = context.slots.default ? h(
|
|
@@ -196,10 +196,10 @@ var ReactiveView_default = {
|
|
|
196
196
|
const getState = props2.model ? typeof props2.model === "function" ? props2.model(config) : props2.model : new DataManager(config);
|
|
197
197
|
const sync = ref(false);
|
|
198
198
|
const options = {
|
|
199
|
-
parent: { self:
|
|
199
|
+
parent: { self: getCurrentInstance().proxy },
|
|
200
200
|
self: { template, isValid, getState }
|
|
201
201
|
};
|
|
202
|
-
const
|
|
202
|
+
const _e = (_d = props2.setup(options)) != null ? _d : options, { parent = {}, self = {} } = _e, rest = __objRest(_e, ["parent", "self"]);
|
|
203
203
|
if (props2.await instanceof Promise) {
|
|
204
204
|
nextTick(async () => {
|
|
205
205
|
getState.replaceData(await props2.await);
|
|
@@ -207,30 +207,31 @@ var ReactiveView_default = {
|
|
|
207
207
|
}
|
|
208
208
|
if (context.attrs["onUpdate:modelState"]) {
|
|
209
209
|
const config2 = typeof context.attrs["onUpdate:modelState"] === "function" ? { callback: context.attrs["onUpdate:modelState"] } : context.attrs["onUpdate:modelState"];
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
before: (before
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}, config2.options);
|
|
210
|
+
onMounted(() => {
|
|
211
|
+
watch(() => ObjectManager.on(state).clone(), (after, before) => {
|
|
212
|
+
var _a2;
|
|
213
|
+
const beforeStateUpdate = (_a2 = config2.beforeStateUpdate) != null ? _a2 : access({ parent, self }).beforeStateUpdate;
|
|
214
|
+
const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
|
|
215
|
+
if (sync.value) {
|
|
216
|
+
sync.value = false;
|
|
217
|
+
} else {
|
|
218
|
+
config2.callback(beforeStateUpdate ? beforeStateUpdate(diff) : diff, getState);
|
|
219
|
+
}
|
|
220
|
+
}, config2.options);
|
|
221
|
+
});
|
|
223
222
|
}
|
|
224
223
|
if (context.attrs["onUpdate:propsState"] || props2.sync) {
|
|
225
|
-
const config2 = (
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
config2.callback
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
224
|
+
const config2 = (_f = typeof context.attrs["onUpdate:propsState"] === "function" ? { callback: context.attrs["onUpdate:propsState"] } : context.attrs["onUpdate:propsState"]) != null ? _f : {};
|
|
225
|
+
onMounted(() => {
|
|
226
|
+
watch(() => props2.state, (after, before) => {
|
|
227
|
+
if (props2.sync && typeof config2.callback !== "function") {
|
|
228
|
+
getState.replaceData(after);
|
|
229
|
+
} else if (typeof config2.callback === "function") {
|
|
230
|
+
config2.callback({ before, after }, getState);
|
|
231
|
+
}
|
|
232
|
+
sync.value = true;
|
|
233
|
+
}, config2.options);
|
|
234
|
+
});
|
|
234
235
|
}
|
|
235
236
|
return ($vue) => {
|
|
236
237
|
const setup2 = { $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.9",
|
|
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",
|