@razaman2/reactive-view 0.0.18 → 0.0.19

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
@@ -24,6 +24,7 @@ declare class Subscription {
24
24
  }
25
25
 
26
26
  declare const setup: {
27
+ ReactiveView: boolean;
27
28
  setup: {
28
29
  type: FunctionConstructor;
29
30
  default: (param1?: {}, param2?: {}) => {};
@@ -53,6 +54,7 @@ declare const _default: {
53
54
  type: BooleanConstructor;
54
55
  default: boolean;
55
56
  };
57
+ ReactiveView: boolean;
56
58
  setup: {
57
59
  type: FunctionConstructor;
58
60
  default: (param1?: {}, param2?: {}) => {};
@@ -116,5 +118,6 @@ declare function getSubscription(): {
116
118
  subscriptions: any[];
117
119
  subscription: Subscription;
118
120
  };
121
+ declare function StyleParser(styles: Array<string> | Record<string, any> | string): any;
119
122
 
120
- export { type StateUpdate, access, _default as default, getDate, getProps, getReactiveViewComponent, getSubscription, safeRequest, setup };
123
+ export { type StateUpdate, StyleParser, access, _default as default, getDate, getProps, getReactiveViewComponent, getSubscription, safeRequest, setup };
package/dist/index.d.ts CHANGED
@@ -24,6 +24,7 @@ declare class Subscription {
24
24
  }
25
25
 
26
26
  declare const setup: {
27
+ ReactiveView: boolean;
27
28
  setup: {
28
29
  type: FunctionConstructor;
29
30
  default: (param1?: {}, param2?: {}) => {};
@@ -53,6 +54,7 @@ declare const _default: {
53
54
  type: BooleanConstructor;
54
55
  default: boolean;
55
56
  };
57
+ ReactiveView: boolean;
56
58
  setup: {
57
59
  type: FunctionConstructor;
58
60
  default: (param1?: {}, param2?: {}) => {};
@@ -116,5 +118,6 @@ declare function getSubscription(): {
116
118
  subscriptions: any[];
117
119
  subscription: Subscription;
118
120
  };
121
+ declare function StyleParser(styles: Array<string> | Record<string, any> | string): any;
119
122
 
120
- export { type StateUpdate, access, _default as default, getDate, getProps, getReactiveViewComponent, getSubscription, safeRequest, setup };
123
+ export { type StateUpdate, StyleParser, access, _default as default, getDate, getProps, getReactiveViewComponent, getSubscription, safeRequest, setup };
package/dist/index.js CHANGED
@@ -56,6 +56,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
56
56
  // src/index.ts
57
57
  var src_exports = {};
58
58
  __export(src_exports, {
59
+ StyleParser: () => StyleParser,
59
60
  access: () => access,
60
61
  default: () => src_default,
61
62
  getDate: () => getDate,
@@ -164,7 +165,7 @@ var import_vue = require("vue");
164
165
 
165
166
  // package.json
166
167
  var name = "@razaman2/reactive-view";
167
- var version = "0.0.18";
168
+ var version = "0.0.19";
168
169
 
169
170
  // src/ReactiveView.ts
170
171
  var props = {
@@ -194,6 +195,7 @@ var props = {
194
195
  }
195
196
  };
196
197
  var setup = {
198
+ ReactiveView: true,
197
199
  setup: {
198
200
  type: Function,
199
201
  default: (param1 = {}, param2 = {}) => {
@@ -241,16 +243,15 @@ var ReactiveView_default = {
241
243
  get(target, property, receiver) {
242
244
  if (["setData", "replaceData"].includes(property)) {
243
245
  return (...params) => {
246
+ var _a2, _b2;
244
247
  const type2 = Array.isArray(defaultData) ? [] : {};
245
- (0, import_vue.nextTick)(() => {
246
- var _a2, _b2;
247
- const beforeSetData = (_b2 = (_a2 = context.attrs["onUpdate:modelState"]) == null ? void 0 : _a2.beforeSetData) != null ? _b2 : access(component).beforeSetData;
248
- if (typeof beforeSetData === "function") {
249
- beforeSetData(import_object_manager.default.on(type2).set(...params).get(), target);
250
- } else {
251
- target[property](...params);
252
- }
253
- });
248
+ const beforeSetData = (_b2 = (_a2 = context.attrs["onUpdate:modelState"]) == null ? void 0 : _a2.beforeSetData) != null ? _b2 : access(component).beforeSetData;
249
+ if (typeof beforeSetData === "function") {
250
+ beforeSetData(import_object_manager.default.on(type2).set(...params).get(), target);
251
+ } else {
252
+ target[property](...params);
253
+ }
254
+ return target;
254
255
  };
255
256
  } else {
256
257
  return Reflect.get(target, property, receiver);
@@ -259,9 +260,12 @@ var ReactiveView_default = {
259
260
  });
260
261
  const options = {
261
262
  parent: { self: component.value },
262
- self: { template, getState, isValid }
263
+ self: { template, isValid, getState }
263
264
  };
264
265
  const _f = (_e = props2.setup(options)) != null ? _e : options, { parent = {}, self = {} } = _f, rest = __objRest(_f, ["parent", "self"]);
266
+ if (typeof context.attrs.debug === "function") {
267
+ context.attrs.debug({ isValid, component, type, data, state, config, options, props: props2, context, setup: __spreadValues({ parent, self }, rest), defaultData, getState });
268
+ }
265
269
  if (props2.await instanceof Promise) {
266
270
  (0, import_vue.nextTick)(async () => {
267
271
  getState.replaceData(await props2.await);
@@ -279,30 +283,34 @@ var ReactiveView_default = {
279
283
  const config2 = typeof context.attrs["onUpdate:modelState"] === "function" ? {
280
284
  callback: context.attrs["onUpdate:modelState"]
281
285
  } : (_g = context.attrs["onUpdate:modelState"]) != null ? _g : {};
282
- (0, import_vue.watch)(() => import_object_manager.default.on(state).clone(), (after, before) => {
283
- var _a2;
284
- const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
285
- const beforeStateUpdate = (_a2 = config2.beforeStateUpdate) != null ? _a2 : access(component).beforeStateUpdate;
286
- if (sync.value) {
287
- sync.value = false;
288
- } else if (typeof config2.callback === "function") {
289
- config2.callback(beforeStateUpdate ? beforeStateUpdate(diff) : diff, getState);
290
- }
291
- }, config2.options);
286
+ (0, import_vue.onMounted)(() => {
287
+ (0, import_vue.watch)(() => import_object_manager.default.on(state).clone(), (after, before) => {
288
+ var _a2;
289
+ const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
290
+ const beforeStateUpdate = (_a2 = config2.beforeStateUpdate) != null ? _a2 : access(component).beforeStateUpdate;
291
+ if (sync.value) {
292
+ sync.value = false;
293
+ } else if (typeof config2.callback === "function") {
294
+ config2.callback(beforeStateUpdate ? beforeStateUpdate(diff) : diff, getState);
295
+ }
296
+ }, config2.options);
297
+ });
292
298
  }
293
299
  if (context.attrs["onUpdate:propsState"] || props2.sync) {
294
300
  const config2 = typeof context.attrs["onUpdate:propsState"] === "function" ? {
295
301
  callback: context.attrs["onUpdate:propsState"]
296
302
  } : (_h = context.attrs["onUpdate:propsState"]) != null ? _h : {};
297
- (0, import_vue.watch)(() => import_object_manager.default.on(props2.state).clone(), (after, before) => {
298
- const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
299
- if (typeof config2.callback === "function") {
300
- config2.callback(diff, getState);
301
- } else {
302
- getState.replaceData(after);
303
- }
304
- sync.value = true;
305
- }, config2.options);
303
+ (0, import_vue.onMounted)(() => {
304
+ (0, import_vue.watch)(() => import_object_manager.default.on(props2.state).clone(), (after, before) => {
305
+ const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
306
+ if (typeof config2.callback === "function") {
307
+ config2.callback(diff, getState);
308
+ } else {
309
+ getState.replaceData(after);
310
+ }
311
+ sync.value = true;
312
+ }, config2.options);
313
+ });
306
314
  }
307
315
  return ($vue) => {
308
316
  const setup2 = { $vue, options: parent };
@@ -401,15 +409,14 @@ function access($vue = {}) {
401
409
  const proxy = (target) => {
402
410
  return new Proxy(target, {
403
411
  get(target2, key) {
404
- var _a2, _b2;
405
412
  const component = { $vue: target2 };
406
413
  do {
407
- if ((_a2 = component.$vue) == null ? void 0 : _a2[key]) {
414
+ if (key in component.$vue) {
408
415
  return component.$vue[key];
409
- } else if ((_b2 = component.$vue.self) == null ? void 0 : _b2[key]) {
416
+ } else if ("self" in component.$vue && key in component.$vue.self) {
410
417
  return component.$vue.self[key];
411
418
  } else {
412
- component.$vue = component.$vue.parent;
419
+ component.$vue = "parent" in component.$vue && component.$vue.parent;
413
420
  }
414
421
  } while (component.$vue);
415
422
  }
@@ -452,8 +459,16 @@ function getSubscription() {
452
459
  subscription
453
460
  };
454
461
  }
462
+ function StyleParser(styles) {
463
+ var _a;
464
+ const object = (items) => items.reduce((object2, item) => {
465
+ return Object.assign(object2, { [item]: true });
466
+ }, {});
467
+ return (_a = Array.isArray(styles) ? object(styles) : typeof styles === "string" ? object(styles.split(/\s+/)) : styles) != null ? _a : {};
468
+ }
455
469
  // Annotate the CommonJS export names for ESM import in node:
456
470
  0 && (module.exports = {
471
+ StyleParser,
457
472
  access,
458
473
  getDate,
459
474
  getProps,
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, getCurrentInstance } from "vue";
125
+ import { h, ref, reactive, watch, nextTick, onMounted, getCurrentInstance } from "vue";
126
126
 
127
127
  // package.json
128
128
  var name = "@razaman2/reactive-view";
129
- var version = "0.0.18";
129
+ var version = "0.0.19";
130
130
 
131
131
  // src/ReactiveView.ts
132
132
  var props = {
@@ -156,6 +156,7 @@ var props = {
156
156
  }
157
157
  };
158
158
  var setup = {
159
+ ReactiveView: true,
159
160
  setup: {
160
161
  type: Function,
161
162
  default: (param1 = {}, param2 = {}) => {
@@ -203,16 +204,15 @@ var ReactiveView_default = {
203
204
  get(target, property, receiver) {
204
205
  if (["setData", "replaceData"].includes(property)) {
205
206
  return (...params) => {
207
+ var _a2, _b2;
206
208
  const type2 = Array.isArray(defaultData) ? [] : {};
207
- nextTick(() => {
208
- var _a2, _b2;
209
- const beforeSetData = (_b2 = (_a2 = context.attrs["onUpdate:modelState"]) == null ? void 0 : _a2.beforeSetData) != null ? _b2 : access(component).beforeSetData;
210
- if (typeof beforeSetData === "function") {
211
- beforeSetData(ObjectManager.on(type2).set(...params).get(), target);
212
- } else {
213
- target[property](...params);
214
- }
215
- });
209
+ const beforeSetData = (_b2 = (_a2 = context.attrs["onUpdate:modelState"]) == null ? void 0 : _a2.beforeSetData) != null ? _b2 : access(component).beforeSetData;
210
+ if (typeof beforeSetData === "function") {
211
+ beforeSetData(ObjectManager.on(type2).set(...params).get(), target);
212
+ } else {
213
+ target[property](...params);
214
+ }
215
+ return target;
216
216
  };
217
217
  } else {
218
218
  return Reflect.get(target, property, receiver);
@@ -221,9 +221,12 @@ var ReactiveView_default = {
221
221
  });
222
222
  const options = {
223
223
  parent: { self: component.value },
224
- self: { template, getState, isValid }
224
+ self: { template, isValid, getState }
225
225
  };
226
226
  const _f = (_e = props2.setup(options)) != null ? _e : options, { parent = {}, self = {} } = _f, rest = __objRest(_f, ["parent", "self"]);
227
+ if (typeof context.attrs.debug === "function") {
228
+ context.attrs.debug({ isValid, component, type, data, state, config, options, props: props2, context, setup: __spreadValues({ parent, self }, rest), defaultData, getState });
229
+ }
227
230
  if (props2.await instanceof Promise) {
228
231
  nextTick(async () => {
229
232
  getState.replaceData(await props2.await);
@@ -241,30 +244,34 @@ var ReactiveView_default = {
241
244
  const config2 = typeof context.attrs["onUpdate:modelState"] === "function" ? {
242
245
  callback: context.attrs["onUpdate:modelState"]
243
246
  } : (_g = context.attrs["onUpdate:modelState"]) != null ? _g : {};
244
- watch(() => ObjectManager.on(state).clone(), (after, before) => {
245
- var _a2;
246
- const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
247
- const beforeStateUpdate = (_a2 = config2.beforeStateUpdate) != null ? _a2 : access(component).beforeStateUpdate;
248
- if (sync.value) {
249
- sync.value = false;
250
- } else if (typeof config2.callback === "function") {
251
- config2.callback(beforeStateUpdate ? beforeStateUpdate(diff) : diff, getState);
252
- }
253
- }, config2.options);
247
+ onMounted(() => {
248
+ watch(() => ObjectManager.on(state).clone(), (after, before) => {
249
+ var _a2;
250
+ const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
251
+ const beforeStateUpdate = (_a2 = config2.beforeStateUpdate) != null ? _a2 : access(component).beforeStateUpdate;
252
+ if (sync.value) {
253
+ sync.value = false;
254
+ } else if (typeof config2.callback === "function") {
255
+ config2.callback(beforeStateUpdate ? beforeStateUpdate(diff) : diff, getState);
256
+ }
257
+ }, config2.options);
258
+ });
254
259
  }
255
260
  if (context.attrs["onUpdate:propsState"] || props2.sync) {
256
261
  const config2 = typeof context.attrs["onUpdate:propsState"] === "function" ? {
257
262
  callback: context.attrs["onUpdate:propsState"]
258
263
  } : (_h = context.attrs["onUpdate:propsState"]) != null ? _h : {};
259
- watch(() => ObjectManager.on(props2.state).clone(), (after, before) => {
260
- const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
261
- if (typeof config2.callback === "function") {
262
- config2.callback(diff, getState);
263
- } else {
264
- getState.replaceData(after);
265
- }
266
- sync.value = true;
267
- }, config2.options);
264
+ onMounted(() => {
265
+ watch(() => ObjectManager.on(props2.state).clone(), (after, before) => {
266
+ const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
267
+ if (typeof config2.callback === "function") {
268
+ config2.callback(diff, getState);
269
+ } else {
270
+ getState.replaceData(after);
271
+ }
272
+ sync.value = true;
273
+ }, config2.options);
274
+ });
268
275
  }
269
276
  return ($vue) => {
270
277
  const setup2 = { $vue, options: parent };
@@ -363,15 +370,14 @@ function access($vue = {}) {
363
370
  const proxy = (target) => {
364
371
  return new Proxy(target, {
365
372
  get(target2, key) {
366
- var _a2, _b2;
367
373
  const component = { $vue: target2 };
368
374
  do {
369
- if ((_a2 = component.$vue) == null ? void 0 : _a2[key]) {
375
+ if (key in component.$vue) {
370
376
  return component.$vue[key];
371
- } else if ((_b2 = component.$vue.self) == null ? void 0 : _b2[key]) {
377
+ } else if ("self" in component.$vue && key in component.$vue.self) {
372
378
  return component.$vue.self[key];
373
379
  } else {
374
- component.$vue = component.$vue.parent;
380
+ component.$vue = "parent" in component.$vue && component.$vue.parent;
375
381
  }
376
382
  } while (component.$vue);
377
383
  }
@@ -414,7 +420,15 @@ function getSubscription() {
414
420
  subscription
415
421
  };
416
422
  }
423
+ function StyleParser(styles) {
424
+ var _a;
425
+ const object = (items) => items.reduce((object2, item) => {
426
+ return Object.assign(object2, { [item]: true });
427
+ }, {});
428
+ return (_a = Array.isArray(styles) ? object(styles) : typeof styles === "string" ? object(styles.split(/\s+/)) : styles) != null ? _a : {};
429
+ }
417
430
  export {
431
+ StyleParser,
418
432
  access,
419
433
  src_default as default,
420
434
  getDate,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@razaman2/reactive-view",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
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",
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "@razaman2/data-manager": "^3.2.11",
24
- "@razaman2/object-manager": "^3.3.9",
24
+ "@razaman2/object-manager": "^3.4.1",
25
25
  "date-fns": "^4.1.0",
26
26
  "date-fns-tz": "^3.2.0",
27
27
  "uuid": "^11.0.3",
@@ -31,7 +31,7 @@
31
31
  "@types/uuid": "^10.0.0",
32
32
  "tsup": "^8.3.5",
33
33
  "typescript": "^5.7.2",
34
- "vitest": "^2.1.5"
34
+ "vitest": "^2.1.8"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"