@razaman2/reactive-view 0.0.14 → 0.0.16
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 +36 -29
- package/dist/index.mjs +37 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -164,7 +164,7 @@ var import_vue = require("vue");
|
|
|
164
164
|
|
|
165
165
|
// package.json
|
|
166
166
|
var name = "@razaman2/reactive-view";
|
|
167
|
-
var version = "0.0.
|
|
167
|
+
var version = "0.0.16";
|
|
168
168
|
|
|
169
169
|
// src/ReactiveView.ts
|
|
170
170
|
var props = {
|
|
@@ -204,29 +204,30 @@ var setup = {
|
|
|
204
204
|
var ReactiveView_default = {
|
|
205
205
|
props: __spreadValues(__spreadValues({}, setup), props),
|
|
206
206
|
setup(props2, context) {
|
|
207
|
-
var _a, _b, _c;
|
|
208
|
-
const template = (vue,
|
|
207
|
+
var _a, _b, _c, _d, _e;
|
|
208
|
+
const template = (vue, options2) => {
|
|
209
209
|
var _a2, _b2, _c2;
|
|
210
210
|
const vnode = context.slots.default ? (0, import_vue.h)(
|
|
211
211
|
"div",
|
|
212
212
|
context.attrs,
|
|
213
|
-
context.slots.default({ vue, options, props: props2, context })
|
|
213
|
+
context.slots.default({ vue, options: options2, props: props2, context })
|
|
214
214
|
) : (0, import_vue.h)("div", __spreadValues({
|
|
215
215
|
style: {
|
|
216
216
|
color: "red",
|
|
217
217
|
textAlign: "center"
|
|
218
218
|
}
|
|
219
219
|
}, context.attrs), `${props2.modelName}: ${name}@${version}`);
|
|
220
|
-
return (_c2 = (_b2 = (_a2 = context.slots).template) == null ? void 0 : _b2.call(_a2, { vue, options, props: props2, context })) != null ? _c2 : vnode;
|
|
220
|
+
return (_c2 = (_b2 = (_a2 = context.slots).template) == null ? void 0 : _b2.call(_a2, { vue, options: options2, props: props2, context })) != null ? _c2 : vnode;
|
|
221
221
|
};
|
|
222
222
|
const isValid = (0, import_vue.ref)(false);
|
|
223
223
|
const sync = (0, import_vue.ref)(false);
|
|
224
224
|
const rendered = (0, import_vue.ref)(false);
|
|
225
|
+
const component = (0, import_vue.ref)((_a = (0, import_vue.getCurrentInstance)()) == null ? void 0 : _a.proxy);
|
|
225
226
|
const defaultData = props2.getDefaultData(
|
|
226
|
-
Array.isArray(props2.state) ? (
|
|
227
|
+
Array.isArray(props2.state) ? (_b = props2.defaultData) != null ? _b : [] : (_c = props2.defaultData) != null ? _c : {}
|
|
227
228
|
);
|
|
228
229
|
const type = Array.isArray(defaultData) ? [] : {};
|
|
229
|
-
const state = (0, import_vue.reactive)(import_data_manager.default.transform(props2.await ? type : (
|
|
230
|
+
const state = (0, import_vue.reactive)(import_data_manager.default.transform(props2.await ? type : (_d = props2.state) != null ? _d : type));
|
|
230
231
|
const config = {
|
|
231
232
|
defaultData,
|
|
232
233
|
data: state,
|
|
@@ -235,22 +236,33 @@ var ReactiveView_default = {
|
|
|
235
236
|
notifications: props2.notifications,
|
|
236
237
|
subscriptions: props2.subscriptions
|
|
237
238
|
};
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
239
|
+
const getState = new Proxy(props2.model ? typeof props2.model === "function" ? props2.model(config) : props2.model : new import_data_manager.default(config), {
|
|
240
|
+
get(target, property, receiver) {
|
|
241
|
+
if (["setData", "replaceData"].includes(property)) {
|
|
242
|
+
return (...params) => {
|
|
243
|
+
const type2 = Array.isArray(defaultData) ? [] : {};
|
|
244
|
+
(0, import_vue.nextTick)(() => {
|
|
245
|
+
var _a2, _b2;
|
|
246
|
+
const beforeSetData = (_b2 = (_a2 = context.attrs["onUpdate:modelState"]) == null ? void 0 : _a2.beforeSetData) != null ? _b2 : access(component).beforeSetData;
|
|
247
|
+
if (typeof beforeSetData === "function") {
|
|
248
|
+
beforeSetData(import_object_manager.default.on(type2).set(...params).get(), target);
|
|
249
|
+
} else {
|
|
250
|
+
target[property](...params);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
};
|
|
254
|
+
} else {
|
|
255
|
+
return Reflect.get(target, property, receiver);
|
|
252
256
|
}
|
|
253
|
-
}
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
const options = {
|
|
260
|
+
parent: { self: component.value },
|
|
261
|
+
self: { template, getState, isValid }
|
|
262
|
+
};
|
|
263
|
+
const _f = (_e = props2.setup(options)) != null ? _e : options, { parent = {}, self = {} } = _f, rest = __objRest(_f, ["parent", "self"]);
|
|
264
|
+
return ($vue) => {
|
|
265
|
+
var _a2, _b2;
|
|
254
266
|
if (props2.await instanceof Promise) {
|
|
255
267
|
(0, import_vue.nextTick)(async () => {
|
|
256
268
|
getState.replaceData(await props2.await);
|
|
@@ -264,15 +276,10 @@ var ReactiveView_default = {
|
|
|
264
276
|
} else {
|
|
265
277
|
rendered.value = true;
|
|
266
278
|
}
|
|
267
|
-
const options = {
|
|
268
|
-
parent: { self: $vue },
|
|
269
|
-
self: { template, getState, isValid }
|
|
270
|
-
};
|
|
271
|
-
const _b2 = (_a2 = props2.setup(options)) != null ? _a2 : options, { parent = {}, self = {} } = _b2, rest = __objRest(_b2, ["parent", "self"]);
|
|
272
279
|
if (context.attrs["onUpdate:modelState"]) {
|
|
273
280
|
const config2 = typeof context.attrs["onUpdate:modelState"] === "function" ? {
|
|
274
281
|
callback: context.attrs["onUpdate:modelState"]
|
|
275
|
-
} : (
|
|
282
|
+
} : (_a2 = context.attrs["onUpdate:modelState"]) != null ? _a2 : {};
|
|
276
283
|
(0, import_vue.watch)(() => import_object_manager.default.on(state).clone(), (after, before) => {
|
|
277
284
|
var _a3;
|
|
278
285
|
const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
|
|
@@ -287,7 +294,7 @@ var ReactiveView_default = {
|
|
|
287
294
|
if (context.attrs["onUpdate:propsState"] || props2.sync) {
|
|
288
295
|
const config2 = typeof context.attrs["onUpdate:propsState"] === "function" ? {
|
|
289
296
|
callback: context.attrs["onUpdate:propsState"]
|
|
290
|
-
} : (
|
|
297
|
+
} : (_b2 = context.attrs["onUpdate:propsState"]) != null ? _b2 : {};
|
|
291
298
|
(0, import_vue.watch)(() => import_object_manager.default.on(props2.state).clone(), (after, before) => {
|
|
292
299
|
const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
|
|
293
300
|
if (props2.sync && typeof config2.callback !== "function") {
|
package/dist/index.mjs
CHANGED
|
@@ -122,11 +122,11 @@ var Subscriptions = _Subscriptions;
|
|
|
122
122
|
// src/ReactiveView.ts
|
|
123
123
|
import ObjectManager from "@razaman2/object-manager";
|
|
124
124
|
import DataManager from "@razaman2/data-manager";
|
|
125
|
-
import { h, ref, reactive, watch, nextTick } from "vue";
|
|
125
|
+
import { h, ref, reactive, watch, nextTick, getCurrentInstance } from "vue";
|
|
126
126
|
|
|
127
127
|
// package.json
|
|
128
128
|
var name = "@razaman2/reactive-view";
|
|
129
|
-
var version = "0.0.
|
|
129
|
+
var version = "0.0.16";
|
|
130
130
|
|
|
131
131
|
// src/ReactiveView.ts
|
|
132
132
|
var props = {
|
|
@@ -166,29 +166,30 @@ var setup = {
|
|
|
166
166
|
var ReactiveView_default = {
|
|
167
167
|
props: __spreadValues(__spreadValues({}, setup), props),
|
|
168
168
|
setup(props2, context) {
|
|
169
|
-
var _a, _b, _c;
|
|
170
|
-
const template = (vue,
|
|
169
|
+
var _a, _b, _c, _d, _e;
|
|
170
|
+
const template = (vue, options2) => {
|
|
171
171
|
var _a2, _b2, _c2;
|
|
172
172
|
const vnode = context.slots.default ? h(
|
|
173
173
|
"div",
|
|
174
174
|
context.attrs,
|
|
175
|
-
context.slots.default({ vue, options, props: props2, context })
|
|
175
|
+
context.slots.default({ vue, options: options2, props: props2, context })
|
|
176
176
|
) : h("div", __spreadValues({
|
|
177
177
|
style: {
|
|
178
178
|
color: "red",
|
|
179
179
|
textAlign: "center"
|
|
180
180
|
}
|
|
181
181
|
}, context.attrs), `${props2.modelName}: ${name}@${version}`);
|
|
182
|
-
return (_c2 = (_b2 = (_a2 = context.slots).template) == null ? void 0 : _b2.call(_a2, { vue, options, props: props2, context })) != null ? _c2 : vnode;
|
|
182
|
+
return (_c2 = (_b2 = (_a2 = context.slots).template) == null ? void 0 : _b2.call(_a2, { vue, options: options2, props: props2, context })) != null ? _c2 : vnode;
|
|
183
183
|
};
|
|
184
184
|
const isValid = ref(false);
|
|
185
185
|
const sync = ref(false);
|
|
186
186
|
const rendered = ref(false);
|
|
187
|
+
const component = ref((_a = getCurrentInstance()) == null ? void 0 : _a.proxy);
|
|
187
188
|
const defaultData = props2.getDefaultData(
|
|
188
|
-
Array.isArray(props2.state) ? (
|
|
189
|
+
Array.isArray(props2.state) ? (_b = props2.defaultData) != null ? _b : [] : (_c = props2.defaultData) != null ? _c : {}
|
|
189
190
|
);
|
|
190
191
|
const type = Array.isArray(defaultData) ? [] : {};
|
|
191
|
-
const state = reactive(DataManager.transform(props2.await ? type : (
|
|
192
|
+
const state = reactive(DataManager.transform(props2.await ? type : (_d = props2.state) != null ? _d : type));
|
|
192
193
|
const config = {
|
|
193
194
|
defaultData,
|
|
194
195
|
data: state,
|
|
@@ -197,22 +198,33 @@ var ReactiveView_default = {
|
|
|
197
198
|
notifications: props2.notifications,
|
|
198
199
|
subscriptions: props2.subscriptions
|
|
199
200
|
};
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
201
|
+
const getState = new Proxy(props2.model ? typeof props2.model === "function" ? props2.model(config) : props2.model : new DataManager(config), {
|
|
202
|
+
get(target, property, receiver) {
|
|
203
|
+
if (["setData", "replaceData"].includes(property)) {
|
|
204
|
+
return (...params) => {
|
|
205
|
+
const type2 = Array.isArray(defaultData) ? [] : {};
|
|
206
|
+
nextTick(() => {
|
|
207
|
+
var _a2, _b2;
|
|
208
|
+
const beforeSetData = (_b2 = (_a2 = context.attrs["onUpdate:modelState"]) == null ? void 0 : _a2.beforeSetData) != null ? _b2 : access(component).beforeSetData;
|
|
209
|
+
if (typeof beforeSetData === "function") {
|
|
210
|
+
beforeSetData(ObjectManager.on(type2).set(...params).get(), target);
|
|
211
|
+
} else {
|
|
212
|
+
target[property](...params);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
} else {
|
|
217
|
+
return Reflect.get(target, property, receiver);
|
|
214
218
|
}
|
|
215
|
-
}
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
const options = {
|
|
222
|
+
parent: { self: component.value },
|
|
223
|
+
self: { template, getState, isValid }
|
|
224
|
+
};
|
|
225
|
+
const _f = (_e = props2.setup(options)) != null ? _e : options, { parent = {}, self = {} } = _f, rest = __objRest(_f, ["parent", "self"]);
|
|
226
|
+
return ($vue) => {
|
|
227
|
+
var _a2, _b2;
|
|
216
228
|
if (props2.await instanceof Promise) {
|
|
217
229
|
nextTick(async () => {
|
|
218
230
|
getState.replaceData(await props2.await);
|
|
@@ -226,15 +238,10 @@ var ReactiveView_default = {
|
|
|
226
238
|
} else {
|
|
227
239
|
rendered.value = true;
|
|
228
240
|
}
|
|
229
|
-
const options = {
|
|
230
|
-
parent: { self: $vue },
|
|
231
|
-
self: { template, getState, isValid }
|
|
232
|
-
};
|
|
233
|
-
const _b2 = (_a2 = props2.setup(options)) != null ? _a2 : options, { parent = {}, self = {} } = _b2, rest = __objRest(_b2, ["parent", "self"]);
|
|
234
241
|
if (context.attrs["onUpdate:modelState"]) {
|
|
235
242
|
const config2 = typeof context.attrs["onUpdate:modelState"] === "function" ? {
|
|
236
243
|
callback: context.attrs["onUpdate:modelState"]
|
|
237
|
-
} : (
|
|
244
|
+
} : (_a2 = context.attrs["onUpdate:modelState"]) != null ? _a2 : {};
|
|
238
245
|
watch(() => ObjectManager.on(state).clone(), (after, before) => {
|
|
239
246
|
var _a3;
|
|
240
247
|
const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
|
|
@@ -249,7 +256,7 @@ var ReactiveView_default = {
|
|
|
249
256
|
if (context.attrs["onUpdate:propsState"] || props2.sync) {
|
|
250
257
|
const config2 = typeof context.attrs["onUpdate:propsState"] === "function" ? {
|
|
251
258
|
callback: context.attrs["onUpdate:propsState"]
|
|
252
|
-
} : (
|
|
259
|
+
} : (_b2 = context.attrs["onUpdate:propsState"]) != null ? _b2 : {};
|
|
253
260
|
watch(() => ObjectManager.on(props2.state).clone(), (after, before) => {
|
|
254
261
|
const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
|
|
255
262
|
if (props2.sync && typeof config2.callback !== "function") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razaman2/reactive-view",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
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",
|