@razaman2/reactive-view 0.1.0-beta.14 → 0.1.0-beta.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.mjs CHANGED
@@ -1,44 +1,10 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
-
33
1
  // src/index.ts
34
- import ObjectManager2 from "@razaman2/object-manager";
2
+ import OM from "@razaman2/object-manager";
35
3
 
36
4
  // src/Subscription.ts
37
5
  var Subscription = class _Subscription {
38
- constructor() {
39
- this.subscriptions = [];
40
- this.data = {};
41
- }
6
+ subscriptions = [];
7
+ data = {};
42
8
  static create() {
43
9
  return new _Subscription();
44
10
  }
@@ -116,13 +82,12 @@ var Subscription = class _Subscription {
116
82
  };
117
83
 
118
84
  // src/Subscriptions.ts
119
- var _Subscriptions = class _Subscriptions extends Subscription {
85
+ var Subscriptions = class _Subscriptions extends Subscription {
86
+ static subscriptions = _Subscriptions.create();
120
87
  static get() {
121
88
  return this.subscriptions;
122
89
  }
123
90
  };
124
- _Subscriptions.subscriptions = _Subscriptions.create();
125
- var Subscriptions = _Subscriptions;
126
91
 
127
92
  // src/ReactiveView.ts
128
93
  import ObjectManager from "@razaman2/object-manager";
@@ -130,19 +95,26 @@ import DataManager from "@razaman2/data-manager";
130
95
  import { ref, reactive, watch, unref, isRef, isReactive, createVNode, getCurrentInstance, onBeforeUnmount } from "vue";
131
96
 
132
97
  // package.json
133
- var version = "0.1.0-beta.14";
134
98
  var package_default = {
135
99
  name: "@razaman2/reactive-view",
136
- version,
100
+ version: "0.1.0-beta.16",
137
101
  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.",
138
102
  main: "dist/index.js",
139
103
  module: "dist/index.mjs",
140
104
  types: "dist/index.d.ts",
105
+ exports: {
106
+ ".": {
107
+ types: "./dist/index.d.ts",
108
+ require: "./dist/index.js",
109
+ import: "./dist/index.mjs"
110
+ }
111
+ },
141
112
  scripts: {
142
113
  prepublishOnly: "npm run build",
143
114
  build: "tsup src/index.ts --format cjs,esm --dts",
144
115
  lint: "tsc",
145
- test: "cd tests/vue-ts && npm run dev",
116
+ test: "vitest run",
117
+ "test:watch": "vitest",
146
118
  pr: "sh pr.sh"
147
119
  },
148
120
  keywords: [
@@ -152,10 +124,18 @@ var package_default = {
152
124
  "vue-class-component",
153
125
  "reactive-ui"
154
126
  ],
127
+ repository: {
128
+ type: "git",
129
+ url: "git+https://github.com/razaman2/reactive-view.git"
130
+ },
131
+ bugs: {
132
+ url: "https://github.com/razaman2/reactive-view/issues"
133
+ },
134
+ homepage: "https://github.com/razaman2/reactive-view#readme",
155
135
  author: "razaman2",
156
136
  license: "MIT",
157
137
  dependencies: {
158
- "@razaman2/data-manager": "^3.3.8",
138
+ "@razaman2/data-manager": "^3.3.12",
159
139
  "@razaman2/event-emitter": "^2.1.1",
160
140
  "@razaman2/object-manager": "^3.4.7",
161
141
  "date-fns": "^4.1.0",
@@ -222,7 +202,6 @@ var ReactiveView_default = {
222
202
  state: { default: reactive({}) }
223
203
  },
224
204
  setup(props, context) {
225
- var _a, _b, _c;
226
205
  const subscriptions = [];
227
206
  onBeforeUnmount(() => subscriptions.forEach((subscription) => subscription()));
228
207
  const diff = (before, after) => {
@@ -238,30 +217,27 @@ var ReactiveView_default = {
238
217
  return { before: before.get(), after: after.get(), changes: changes.get(), changed: changed.value };
239
218
  };
240
219
  const dataPath2 = (path) => {
241
- try {
242
- return context.attrs["data:path"](path);
243
- } catch (e) {
244
- return path;
245
- }
220
+ const handler = context.attrs["data:path"];
221
+ return typeof handler === "function" ? handler(path) : path;
246
222
  };
247
223
  const template = (component, vue2) => {
248
- return createVNode("div", context.slots.default ? context.attrs : __spreadValues({
249
- style: { color: "red", textAlign: "center" }
250
- }, context.attrs), context.slots.default ? context.slots.default({ component, vue: vue2, props, context }) : `${props.modelName}: ${package_default.name}@${package_default.version}`);
224
+ return createVNode("div", context.slots.default ? context.attrs : {
225
+ style: { color: "red", textAlign: "center" },
226
+ ...context.attrs
227
+ }, context.slots.default ? context.slots.default({ component, vue: vue2, props, context }) : `${props.modelName}: ${package_default.name}@${package_default.version}`);
251
228
  };
252
229
  const isValid = ref(false);
253
230
  const isReady = ref(false);
254
231
  const defer = ref(typeof props.defer === "function" ? props.defer() : props.defer);
255
- const isFunctionData = ["Function"].includes((_a = props.data) == null ? void 0 : _a.constructor.name);
256
- const isAsyncFunctionData = ["AsyncFunction"].includes((_b = props.data) == null ? void 0 : _b.constructor.name);
257
- const isAsyncData = ["Promise"].includes((_c = props.data) == null ? void 0 : _c.constructor.name) || isAsyncFunctionData;
232
+ const isFunctionData = ["Function"].includes(props.data?.constructor.name);
233
+ const isAsyncFunctionData = ["AsyncFunction"].includes(props.data?.constructor.name);
234
+ const isAsyncData = ["Promise"].includes(props.data?.constructor.name) || isAsyncFunctionData;
258
235
  const vue = getCurrentInstance();
259
236
  const defaultData = props.getDefaultData(
260
237
  "defaultData" in vue.vnode.props ? vue.vnode.props.defaultData : "data" in vue.vnode.props ? Array.isArray(unref(vue.vnode.props.data)) ? [] : {} : {}
261
238
  );
262
239
  const datatype = Array.isArray(defaultData) ? [] : {};
263
240
  const beta = () => {
264
- var _a2;
265
241
  const emit = (after, before) => {
266
242
  if (vue && vue.vnode.el) {
267
243
  const event = new CustomEvent("data:emit", {
@@ -281,8 +257,7 @@ var ReactiveView_default = {
281
257
  get(target, key, receiver) {
282
258
  if (["setData", "replaceData"].includes(key.toString())) {
283
259
  return (...params) => {
284
- var _a3;
285
- const beforeSetData = (_a3 = access(component).beforeSetData) != null ? _a3 : props.beforeSetData;
260
+ const beforeSetData = access(component).beforeSetData ?? props.beforeSetData;
286
261
  if (typeof beforeSetData === "function") {
287
262
  const before = ObjectManager.on(target.getData());
288
263
  const after = params.length ? ObjectManager.on(datatype).set(...params) : ObjectManager.on(datatype).set(defaultData);
@@ -309,18 +284,18 @@ var ReactiveView_default = {
309
284
  } else {
310
285
  const props2 = "data" in vue.vnode.props;
311
286
  try {
312
- if (["Array", "Object"].includes(data.constructor.name)) {
287
+ if (["Array", "Object"].includes(data?.constructor?.name)) {
313
288
  return ref(data);
314
289
  } else {
315
290
  return ref(props2 ? { "": data } : datatype);
316
291
  }
317
- } catch (e) {
292
+ } catch {
318
293
  return ref(props2 ? { "": data } : datatype);
319
294
  }
320
295
  }
321
296
  };
322
297
  const config = {
323
- data: normalize((_a2 = vue.vnode.props) == null ? void 0 : _a2.data),
298
+ data: normalize(vue.vnode.props?.data),
324
299
  defaultData: ObjectManager.on(defaultData).clone(),
325
300
  notifications: props.notifications,
326
301
  subscriptions: props.subscriptions,
@@ -349,48 +324,41 @@ var ReactiveView_default = {
349
324
  }
350
325
  }, config2.options));
351
326
  }
352
- const track = (source, options = {}) => {
353
- var _a3, _b2, _c2, _d, _e;
354
- subscriptions.push(watch(source, async (after, before) => {
355
- const diff2 = access(component).diff(ObjectManager.on(before), ObjectManager.on(after));
356
- const callback = context.attrs["data:callback"];
357
- if (typeof callback === "function") {
358
- callback(diff2, { component });
359
- } else {
360
- model.replaceData(after);
361
- }
362
- }, {
363
- immediate: (_b2 = (_a3 = context.attrs["data:immediate"]) != null ? _a3 : options.immediate) != null ? _b2 : true,
364
- deep: (_d = (_c2 = context.attrs["data:deep"]) != null ? _c2 : options.deep) != null ? _d : true,
365
- once: (_e = context.attrs["data:once"]) != null ? _e : options.once
366
- }));
367
- };
368
327
  setTimeout(async () => {
369
- var _a3;
370
- if (props.model !== false) {
371
- if (isFunctionData || isAsyncData) {
372
- if (!("defaultData" in vue.vnode.props)) {
373
- console.warn(`${props.modelName}: defaultData is required for promise or function data.`, props.data);
374
- }
375
- const [data] = isAsyncData ? await Promise.all([
376
- isAsyncFunctionData ? props.data() : props.data,
377
- (_a3 = defer.value) != null ? _a3 : true
378
- ]) : [props.data];
379
- track(typeof data === "function" ? data : (() => data));
380
- } else {
381
- track(isRef(props.data) || isReactive(props.data) ? props.data : () => props.data, { immediate: false, deep: false });
328
+ if (props.model !== false && (isFunctionData || isAsyncData)) {
329
+ if (!("defaultData" in vue.vnode.props)) {
330
+ console.warn(`${props.modelName}: defaultData is required for promise or function data.`, props.data);
382
331
  }
332
+ const [data] = isAsyncData ? await Promise.all([
333
+ isAsyncFunctionData ? props.data() : props.data,
334
+ defer.value ?? true
335
+ ]) : [props.data];
336
+ const source = typeof data === "function" ? data : (() => data);
337
+ subscriptions.push(watch(source, async (after, before) => {
338
+ const diff2 = access(component).diff(ObjectManager.on(before), ObjectManager.on(after));
339
+ const callback = context.attrs["data:callback"];
340
+ if (props.debug) {
341
+ console.warn(`[${props.modelName}]:data`, { diff: diff2, data, callback, before, after, props, context, component });
342
+ }
343
+ if (typeof callback === "function") {
344
+ callback(diff2, { component });
345
+ } else {
346
+ model.replaceData(after);
347
+ }
348
+ }, {
349
+ immediate: context.attrs["data:immediate"] ?? true,
350
+ deep: context.attrs["data:deep"],
351
+ once: context.attrs["data:once"]
352
+ }));
383
353
  }
384
354
  });
385
355
  setTimeout(async () => {
386
- var _a3;
387
- isReady.value = (_a3 = await defer.value) != null ? _a3 : true;
356
+ isReady.value = await defer.value ?? true;
388
357
  });
389
358
  component.value = [access(component)].reduce((options, parent) => {
390
- var _a3;
391
359
  while (parent) {
392
360
  if (typeof parent.setup === "function") {
393
- options = { parent: options, self: (_a3 = parent.setup(component, options)) != null ? _a3 : {} };
361
+ options = { parent: options, self: parent.setup(component, options) ?? {} };
394
362
  if (access(parent.$parent).ReactiveView) {
395
363
  break;
396
364
  } else {
@@ -404,16 +372,14 @@ var ReactiveView_default = {
404
372
  }, component.value);
405
373
  props.instance.value = typeof props.instance === "function" ? props.instance(component.value) : component.value;
406
374
  return (vue2) => {
407
- var _a3, _b2;
408
375
  if (isReady.value) {
409
376
  return access(component).template(component, vue2);
410
377
  } else {
411
- return (_b2 = (_a3 = context.slots).loading) == null ? void 0 : _b2.call(_a3, { component });
378
+ return context.slots.loading?.({ component });
412
379
  }
413
380
  };
414
381
  };
415
382
  const current = () => {
416
- var _a2, _b2, _c2, _d;
417
383
  const emit = (after, before) => {
418
384
  if (vue && vue.vnode.el) {
419
385
  const event = new CustomEvent("data:emit", {
@@ -439,19 +405,19 @@ var ReactiveView_default = {
439
405
  } else {
440
406
  const props2 = "data" in vue.vnode.props;
441
407
  try {
442
- if (["Array", "Object"].includes(data.constructor.name)) {
408
+ if (["Array", "Object"].includes(data?.constructor?.name)) {
443
409
  return reactive(props2 ? data : datatype);
444
410
  } else {
445
411
  return reactive(props2 ? { "": data } : datatype);
446
412
  }
447
- } catch (e) {
413
+ } catch {
448
414
  return reactive(props2 ? { "": data } : datatype);
449
415
  }
450
416
  }
451
417
  }
452
418
  };
453
419
  const config = {
454
- data: props.beta ? normalize((_a2 = vue.vnode.props) == null ? void 0 : _a2.data) : reactive(ObjectManager.on(
420
+ data: props.beta ? normalize(vue.vnode.props?.data) : reactive(ObjectManager.on(
455
421
  isAsyncData || isFunctionData || isRef(props.data) || isReactive(props.data) ? datatype : "data" in vue.vnode.props ? props.data : datatype
456
422
  ).clone()),
457
423
  defaultData: ObjectManager.on(defaultData).clone(),
@@ -464,8 +430,7 @@ var ReactiveView_default = {
464
430
  get(target, key, receiver) {
465
431
  if (["setData", "replaceData"].includes(key.toString())) {
466
432
  return (...params) => {
467
- var _a3;
468
- const beforeSetData = (_a3 = access(component).beforeSetData) != null ? _a3 : props.beforeSetData;
433
+ const beforeSetData = access(component).beforeSetData ?? props.beforeSetData;
469
434
  if (typeof beforeSetData === "function") {
470
435
  const before = ObjectManager.on(target.getData());
471
436
  const after = params.length ? ObjectManager.on(datatype).set(...params) : ObjectManager.on(datatype).set(defaultData);
@@ -487,20 +452,20 @@ var ReactiveView_default = {
487
452
  console.warn("[ReactiveView]:", { props, context, vue, defer, config, model, component, datatype, defaultData, isValid, isReady, isFunctionData, isAsyncFunctionData, isAsyncData });
488
453
  }
489
454
  const watchDataProp = (dataProp) => {
490
- var _a3, _b3, _c3, _d2;
491
455
  const config2 = typeof context.attrs["onUpdate:data"] === "function" ? { callback: context.attrs["onUpdate:data"] } : {
492
- callback: (_b3 = ((_a3 = context.attrs["onUpdate:data"]) != null ? _a3 : {}).callback) != null ? _b3 : context.attrs["data:callback"],
493
- options: Object.assign(__spreadValues(__spreadValues({
494
- deep: (_c3 = context.attrs["data:deep"]) != null ? _c3 : true
495
- }, context.attrs["data:immediate"] ? { immediate: context.attrs["data:immediate"] } : {}), context.attrs["data:once"] ? { once: context.attrs["data:once"] } : {}), ((_d2 = context.attrs["onUpdate:data"]) != null ? _d2 : {}).options)
456
+ callback: (context.attrs["onUpdate:data"] ?? {}).callback ?? context.attrs["data:callback"],
457
+ options: Object.assign({
458
+ deep: context.attrs["data:deep"] ?? true,
459
+ ...context.attrs["data:immediate"] ? { immediate: context.attrs["data:immediate"] } : {},
460
+ ...context.attrs["data:once"] ? { once: context.attrs["data:once"] } : {}
461
+ }, (context.attrs["onUpdate:data"] ?? {}).options)
496
462
  };
497
463
  if (context.attrs["data:log"]) {
498
464
  console.warn(`[ReactiveView]:data`, { config: config2, dataProp });
499
465
  }
500
466
  subscriptions.push(watch(isFunctionData || isRef(dataProp) || isReactive(dataProp) ? dataProp : () => dataProp, (after, before) => {
501
- var _a4;
502
467
  if (typeof config2.callback === "function") {
503
- model.replaceData((_a4 = config2.callback(access(component).diff(ObjectManager.on(before), ObjectManager.on(after)), { component })) != null ? _a4 : after);
468
+ model.replaceData(config2.callback(access(component).diff(ObjectManager.on(before), ObjectManager.on(after)), { component }) ?? after);
504
469
  } else {
505
470
  model.replaceData(after);
506
471
  }
@@ -509,10 +474,12 @@ var ReactiveView_default = {
509
474
  if (context.attrs["onUpdate:model"] || context.attrs["update:model"]) {
510
475
  const config2 = typeof context.attrs["onUpdate:model"] === "function" ? {
511
476
  callback: context.attrs["onUpdate:model"],
512
- options: Object.assign(__spreadValues(__spreadValues({
513
- deep: (_b2 = context.attrs["model:deep"]) != null ? _b2 : true
514
- }, context.attrs["model:immediate"] ? { immediate: context.attrs["model:immediate"] } : {}), context.attrs["model:once"] ? { once: context.attrs["model:once"] } : {}), ((_c2 = context.attrs["onUpdate:model"]) != null ? _c2 : {}).options)
515
- } : (_d = context.attrs["onUpdate:model"]) != null ? _d : {};
477
+ options: Object.assign({
478
+ deep: context.attrs["model:deep"] ?? true,
479
+ ...context.attrs["model:immediate"] ? { immediate: context.attrs["model:immediate"] } : {},
480
+ ...context.attrs["model:once"] ? { once: context.attrs["model:once"] } : {}
481
+ }, (context.attrs["onUpdate:model"] ?? {}).options)
482
+ } : context.attrs["onUpdate:model"] ?? {};
516
483
  if (context.attrs["model:log"]) {
517
484
  console.warn(`[ReactiveView]:model`, { config: config2 });
518
485
  }
@@ -524,48 +491,43 @@ var ReactiveView_default = {
524
491
  const isRefData = isRef(props.data);
525
492
  if (isRefData || isFunctionData || isAsyncData) {
526
493
  setTimeout(async () => {
527
- var _a3, _b3, _c3;
528
494
  const [data] = isAsyncData ? await Promise.all([
529
495
  isAsyncFunctionData ? props.data() : props.data,
530
- (_a3 = defer.value) != null ? _a3 : true
496
+ defer.value ?? true
531
497
  ]) : [props.data];
532
498
  subscriptions.push(watch(isRefData ? data : isFunctionData ? data : typeof data === "function" ? data : () => data, (after, before) => {
533
- var _a4;
534
499
  if (before !== void 0 || after !== void 0) {
535
500
  const callback = context.attrs["data:callback"];
536
501
  if (typeof callback === "function") {
537
502
  const diff2 = access(component).diff(ObjectManager.on(before), ObjectManager.on(after));
538
- model.replaceData((_a4 = callback(diff2, { component })) != null ? _a4 : after);
503
+ model.replaceData(callback(diff2, { component }) ?? after);
539
504
  } else {
540
505
  model.replaceData(after);
541
506
  }
542
507
  }
543
508
  }, {
544
- immediate: (_b3 = context.attrs["data:immediate"]) != null ? _b3 : true,
545
- deep: (_c3 = context.attrs["data:deep"]) != null ? _c3 : true,
509
+ immediate: context.attrs["data:immediate"] ?? true,
510
+ deep: context.attrs["data:deep"] ?? true,
546
511
  once: context.attrs["data:once"]
547
512
  }));
548
513
  });
549
514
  }
550
515
  } else {
551
516
  setTimeout(async () => {
552
- var _a3;
553
517
  const [data] = await Promise.all([
554
518
  isAsyncFunctionData ? props.data() : props.data,
555
- (_a3 = defer.value) != null ? _a3 : true
519
+ defer.value ?? true
556
520
  ]);
557
521
  watchDataProp(data);
558
522
  });
559
523
  }
560
524
  setTimeout(async () => {
561
- var _a3;
562
- isReady.value = (_a3 = await defer.value) != null ? _a3 : true;
525
+ isReady.value = await defer.value ?? true;
563
526
  });
564
527
  component.value = [access(component)].reduce((options, parent) => {
565
- var _a3;
566
528
  while (parent) {
567
529
  if (typeof parent.setup === "function") {
568
- options = { parent: options, self: (_a3 = parent.setup(component, options)) != null ? _a3 : {} };
530
+ options = { parent: options, self: parent.setup(component, options) ?? {} };
569
531
  if (access(parent.$parent).ReactiveView) {
570
532
  break;
571
533
  } else {
@@ -579,11 +541,10 @@ var ReactiveView_default = {
579
541
  }, component.value);
580
542
  props.instance.value = typeof props.instance === "function" ? props.instance(component.value) : component.value;
581
543
  return (vue2) => {
582
- var _a3, _b3;
583
544
  if (isReady.value) {
584
545
  return access(component).template(component, vue2);
585
546
  } else {
586
- return (_b3 = (_a3 = context.slots).loading) == null ? void 0 : _b3.call(_a3, { component });
547
+ return context.slots.loading?.({ component });
587
548
  }
588
549
  };
589
550
  };
@@ -595,12 +556,13 @@ var ReactiveView_default = {
595
556
  import { h, ref as ref2, unref as unref2, toRaw, isRef as isRef2, isReactive as isReactive2, createApp, createVNode as createVNode2, defineComponent } from "vue";
596
557
  import { formatInTimeZone } from "date-fns-tz";
597
558
  import { twMerge } from "tailwind-merge";
559
+ var ObjectManager2 = OM.default || OM;
560
+ var { version } = package_default;
598
561
  console.log(`%c[ReactiveView]: ${version}`, "background-color: red; color: yellow;");
599
562
  var index_default = ReactiveView_default;
600
563
  function safeRequest(request) {
601
564
  return new Promise(async (resolve) => {
602
- var _a, _b, _c, _d;
603
- const { message } = (_a = request.loading) != null ? _a : {};
565
+ const { message } = request.loading ?? {};
604
566
  if (request.loading) {
605
567
  request.loading.status = true;
606
568
  if (request.message) {
@@ -610,26 +572,25 @@ function safeRequest(request) {
610
572
  try {
611
573
  resolve(await request.try());
612
574
  } catch (e) {
613
- if ((_b = request.alternative) != null ? _b : true) {
575
+ if (request.alternative ?? true) {
614
576
  resolve(request.catch ? await request.catch(e) : console.log(e));
615
577
  }
616
578
  } finally {
617
- await ((_c = request.finally) == null ? void 0 : _c.call(request));
579
+ await request.finally?.();
618
580
  if (request.loading) {
619
581
  request.loading.status = false;
620
582
  }
621
583
  if (request.loading && message) {
622
584
  request.loading.message = message;
623
585
  }
624
- await ((_d = request.complete) == null ? void 0 : _d.call(request));
586
+ await request.complete?.();
625
587
  }
626
588
  });
627
589
  }
628
590
  function getProps(props = {}, param2) {
629
- var _a;
630
591
  const exclude = Array.isArray(param2) || typeof param2 === "string" ? param2 : param2.exclude;
631
592
  const exclusions = (Array.isArray(exclude) ? exclude : [exclude]).join("|");
632
- const include = (_a = param2.include) != null ? _a : {};
593
+ const include = param2.include ?? {};
633
594
  return Object.entries(include).reduce((props2, [key, val]) => {
634
595
  props2[key] = val;
635
596
  return props2;
@@ -644,7 +605,7 @@ function getReactiveViewComponent(component, options = {}) {
644
605
  const model = (component2) => {
645
606
  try {
646
607
  return (component2.type || component2).props.hasOwnProperty("model");
647
- } catch (e) {
608
+ } catch {
648
609
  return false;
649
610
  }
650
611
  };
@@ -655,10 +616,9 @@ function getReactiveViewComponent(component, options = {}) {
655
616
  return model(component) ? createVNode2(component, props) : createVNode2(ReactiveView_default, props, slots);
656
617
  }
657
618
  function getDate(param1, param2) {
658
- var _a, _b;
659
619
  const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
660
620
  const format = "MM/dd/yyyy h:mm a";
661
- const options = typeof param2 === "string" ? { format: param2, timezone } : { format: (_a = param2 == null ? void 0 : param2.format) != null ? _a : format, timezone: (_b = param2 == null ? void 0 : param2.timezone) != null ? _b : timezone };
621
+ const options = typeof param2 === "string" ? { format: param2, timezone } : { format: param2?.format ?? format, timezone: param2?.timezone ?? timezone };
662
622
  const datetime = () => {
663
623
  try {
664
624
  return param1 instanceof Date ? param1 : param1.toDate();
@@ -669,7 +629,6 @@ function getDate(param1, param2) {
669
629
  return formatInTimeZone(datetime(), options.timezone, options.format);
670
630
  }
671
631
  function access(view = {}, alternative) {
672
- var _a;
673
632
  const resolve = (target) => {
674
633
  return new Proxy(toRaw(target), {
675
634
  get(target2, key) {
@@ -685,16 +644,16 @@ function access(view = {}, alternative) {
685
644
  } while (component.tree);
686
645
  try {
687
646
  return new alternative();
688
- } catch (e) {
647
+ } catch {
689
648
  return alternative;
690
649
  }
691
650
  }
692
651
  });
693
652
  };
694
653
  try {
695
- const component = (_a = unref2(typeof view === "function" ? view() : view)) != null ? _a : {};
654
+ const component = unref2(typeof view === "function" ? view() : view) ?? {};
696
655
  return resolve("instance" in component ? component.instance : component);
697
- } catch (e) {
656
+ } catch {
698
657
  return resolve(view);
699
658
  }
700
659
  }
@@ -726,28 +685,28 @@ function useSubscription() {
726
685
  };
727
686
  }
728
687
  var Prop = ({ default: value, type, validator, required } = {}) => {
729
- const types1 = Array.isArray(type) ? type : [type != null ? type : Array];
688
+ const types1 = Array.isArray(type) ? type : [type ?? Array];
730
689
  const types2 = types1.includes(Object) ? types1 : types1.concat(Object);
731
- return __spreadProps(__spreadValues({}, value ? { default: isRef2(value) || isReactive2(value) ? value : ref2(value) } : {}), {
690
+ return {
691
+ ...value ? { default: isRef2(value) || isReactive2(value) ? value : ref2(value) } : {},
732
692
  required,
733
693
  validator: (value2) => {
734
694
  try {
735
695
  return validator ? validator(unref2(value2)) : Array.from(new Set(types2.map((type2) => {
736
696
  return typeof type2 === "function" ? type2().constructor.name : type2;
737
697
  }))).includes(unref2(value2).constructor.name);
738
- } catch (e) {
739
- return required;
698
+ } catch {
699
+ return !required;
740
700
  }
741
701
  }
742
- });
702
+ };
743
703
  };
744
704
  function StyleParser(styles = {}) {
745
705
  const transform = (style, status = true) => {
746
706
  const remove = style.split(/(-{[^}]+})/);
747
707
  return remove.reduce((object, style2) => {
748
- var _a;
749
708
  const remove2 = /-{(.+?)}/.exec(style2);
750
- (remove2 ? (_a = remove2[1]) != null ? _a : style2 : style2).split(/\s+/).forEach((item) => {
709
+ (remove2 ? remove2[1] ?? style2 : style2).split(/\s+/).forEach((item) => {
751
710
  if (item) {
752
711
  Object.assign(object, { [item]: remove2 ? false : status });
753
712
  }
@@ -756,14 +715,19 @@ function StyleParser(styles = {}) {
756
715
  }, {});
757
716
  };
758
717
  return Array.isArray(styles) ? styles.reduce((styles2, style) => Object.assign(transform(style), styles2), {}) : typeof styles === "string" ? transform(styles) : Object.entries(styles).reduce((acc, [styles2, value]) => {
759
- return __spreadValues(__spreadValues({}, acc), transform(styles2, value));
718
+ return {
719
+ ...acc,
720
+ ...transform(styles2, value)
721
+ };
760
722
  }, {});
761
723
  }
762
724
  function MergeStyles(...params) {
763
725
  return new Proxy(params.reduce((styles, style, index, items) => {
764
- var _a;
765
- const item = (_a = items[items.length - index - 1]) != null ? _a : {};
766
- return __spreadValues(__spreadValues({}, StyleParser(typeof item === "function" ? item(items.slice(0, index - 1)) : item)), styles);
726
+ const item = items[items.length - index - 1] ?? {};
727
+ return {
728
+ ...StyleParser(typeof item === "function" ? item(items.slice(0, index - 1)) : item),
729
+ ...styles
730
+ };
767
731
  }, {}), {
768
732
  get: (target, key, receiver) => {
769
733
  const styles = Object.entries(target).reduce((styles2, [key2, val]) => {
@@ -785,22 +749,20 @@ var extendVnode = (component, element) => {
785
749
  const getVnode = () => {
786
750
  try {
787
751
  return target[key]();
788
- } catch (e) {
752
+ } catch {
789
753
  throw new Error(`${key} does not exist as vnode on component.`);
790
754
  }
791
755
  };
792
756
  const vnode = getVnode();
793
757
  return (props = {}, slots) => {
794
- var _a;
795
758
  const isFunctionClass = typeof props.class === "function";
796
759
  const isFunctionStyle = typeof props.style === "function";
797
- const _b = (_a = vnode.props) != null ? _a : {}, { class: classes, style: styles } = _b, rest = __objRest(_b, ["class", "style"]);
760
+ const { class: classes, style: styles, ...rest } = vnode.props ?? {};
798
761
  const finalClasses = twMerge(isFunctionClass ? "" : classes, MergeStyles(isFunctionClass ? props.class(classes) : props.class).string);
799
762
  const finalStyles = MergeStyles(styles, isFunctionStyle ? props.style(styles) : props.style);
800
763
  const functionalProps = Object.entries(props).reduce((props2, [key2, value]) => {
801
- var _a2;
802
764
  if (!["class", "style", "setup"].includes(key2) && typeof value === "function") {
803
- props2[key2] = value((_a2 = vnode.props) == null ? void 0 : _a2[key2]);
765
+ props2[key2] = value(vnode.props?.[key2]);
804
766
  }
805
767
  return props2;
806
768
  }, props);
@@ -815,26 +777,27 @@ var extendVnode = (component, element) => {
815
777
  function defineReactiveView(param1, param2) {
816
778
  const instance = ref2();
817
779
  return defineComponent({
818
- name: param1 == null ? void 0 : param1.modelName,
819
- props: __spreadValues({ setup }, param1 ? param1.props : {}),
780
+ name: param1?.modelName,
781
+ props: { setup, ...param1 ? param1.props : {} },
820
782
  setup() {
821
- const _a = param1 != null ? param1 : {}, { setup: setup2, props } = _a, rest = __objRest(_a, ["setup", "props"]);
783
+ const { setup: setup2, props, ...rest } = param1 ?? {};
822
784
  return (component) => {
823
785
  const props2 = Object.entries(rest).reduce((props3, [key, val]) => {
824
786
  return Object.assign(props3, { [key]: typeof val === "function" ? val(component, instance) : val });
825
787
  }, {});
826
- const slots = typeof (param1 == null ? void 0 : param1.slots) === "function" ? param1.slots(component) : Array.isArray(param1 == null ? void 0 : param1.slots) ? () => param1.slots : param1 == null ? void 0 : param1.slots;
827
- return createVNode2(param2 != null ? param2 : ReactiveView_default, __spreadProps(__spreadValues(__spreadValues({}, props2), Object.assign({}, props2, typeof setup2 === "function" ? {
828
- setup: (self, parent) => setup2(self, parent, component)
829
- } : {})), {
788
+ const slots = typeof param1?.slots === "function" ? param1.slots(component) : Array.isArray(param1?.slots) ? () => param1.slots : param1?.slots;
789
+ return createVNode2(param2 ?? ReactiveView_default, {
790
+ ...props2,
791
+ ...Object.assign({}, props2, typeof setup2 === "function" ? {
792
+ setup: (self, parent) => setup2(self, parent, component)
793
+ } : {}),
830
794
  instance
831
- }), slots);
795
+ }, slots);
832
796
  };
833
797
  }
834
798
  });
835
799
  }
836
800
  function showComponent(component, options = {}) {
837
- var _a;
838
801
  if (options.router) {
839
802
  console.warn("[ReactiveView]: Deprecated {router} option used with {showComponent()}. \nUse {plugins} option instead.");
840
803
  }
@@ -846,7 +809,7 @@ function showComponent(component, options = {}) {
846
809
  document.body.appendChild(dialogs);
847
810
  }
848
811
  const dialog = document.createElement("div");
849
- const id = (_a = options.key) != null ? _a : `dialog_${dialogs.children.length + 1}`;
812
+ const id = options.key ?? `dialog_${dialogs.children.length + 1}`;
850
813
  dialog.setAttribute("id", id);
851
814
  dialogs.appendChild(dialog);
852
815
  const app = createApp(