@razaman2/reactive-view 0.1.0-beta.16 → 0.1.0-beta.17

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,880 +1,942 @@
1
- // src/index.ts
2
- import OM from "@razaman2/object-manager";
3
-
4
- // src/Subscription.ts
5
- var Subscription = class _Subscription {
6
- subscriptions = [];
7
- data = {};
8
- static create() {
9
- return new _Subscription();
10
- }
11
- subscribe(name, handler, data) {
12
- if (this.isNameAvailable(name)) {
13
- this.subscriptions.push({
14
- name,
15
- handler
16
- });
17
- this.data[name] = data;
18
- }
19
- return this;
20
- }
21
- replace(name, handler, data) {
22
- this.unsubscribe(name);
23
- return this.subscribe(name, handler, data);
24
- }
25
- unsubscribe(param1) {
26
- if (!Array.isArray(param1)) {
27
- param1 = param1 ? [param1] : [];
28
- }
29
- const log = (name) => {
30
- return console.log(`%cUnsubscribed From Subscription (${name})`, "background-color: yellow; color: green; font-weight: bold; padding: 3px;");
31
- };
32
- if (param1.length) {
33
- param1.forEach((name) => {
34
- const subscription = this.find(name);
35
- if (subscription) {
36
- subscription.handler();
37
- this.remove(subscription);
38
- log(name);
39
- }
40
- });
41
- } else {
42
- this.subscriptions.forEach((subscription) => {
43
- subscription.handler();
44
- log(subscription.name);
45
- });
46
- this.subscriptions = [];
47
- }
48
- return this;
49
- }
50
- size() {
51
- return this.subscriptions.length;
52
- }
53
- hasSubscription(name) {
54
- return Boolean(this.find(name));
55
- }
56
- remove(subscription) {
57
- this.subscriptions.splice(this.subscriptions.indexOf(subscription), 1);
58
- }
59
- find(name) {
60
- return this.subscriptions.find((subscription) => {
61
- return subscription.name === name;
62
- });
63
- }
64
- isNameAvailable(name) {
65
- if (this.hasSubscription(name)) {
66
- throw new Error(`There is already a subscription called "${name}".`);
67
- } else {
68
- return true;
69
- }
70
- }
71
- registrations() {
72
- return this.subscriptions;
73
- }
74
- get(name) {
75
- const subscription = this.find(name);
76
- if (subscription) {
77
- return subscription;
78
- } else {
79
- throw new Error(`Subscription "${name}" doesn't exist!`);
80
- }
81
- }
1
+ import e from "@razaman2/object-manager";
2
+ import t from "@razaman2/data-manager";
3
+ import { computed as n, createTextVNode as r, createVNode as i, defineComponent as a, getCurrentInstance as o, h as s, isReactive as c, isRef as l, mergeProps as u, nextTick as d, onBeforeUnmount as f, onMounted as p, provide as m, reactive as h, ref as g, render as _, resolveComponent as v, toRaw as y, unref as b, watch as x, watchEffect as S } from "vue";
4
+ import { formatInTimeZone as C } from "date-fns-tz";
5
+ import { twMerge as w } from "tailwind-merge";
6
+ //#region src/Subscription.ts
7
+ var T = class e {
8
+ subscriptions = [];
9
+ data = {};
10
+ static create() {
11
+ return new e();
12
+ }
13
+ subscribe(e, t, n) {
14
+ return this.isNameAvailable(e) && (this.subscriptions.push({
15
+ name: e,
16
+ handler: t
17
+ }), this.data[e] = n), this;
18
+ }
19
+ replace(e, t, n) {
20
+ return this.unsubscribe(e), this.subscribe(e, t, n);
21
+ }
22
+ unsubscribe(e) {
23
+ Array.isArray(e) || (e = e ? [e] : []);
24
+ let t = (e) => console.log(`%cUnsubscribed From Subscription (${e})`, "background-color: yellow; color: green; font-weight: bold; padding: 3px;");
25
+ return e.length ? e.forEach((e) => {
26
+ let n = this.find(e);
27
+ n && (n.handler(), this.remove(n), t(e));
28
+ }) : (this.subscriptions.forEach((e) => {
29
+ e.handler(), t(e.name);
30
+ }), this.subscriptions = []), this;
31
+ }
32
+ size() {
33
+ return this.subscriptions.length;
34
+ }
35
+ hasSubscription(e) {
36
+ return !!this.find(e);
37
+ }
38
+ remove(e) {
39
+ this.subscriptions.splice(this.subscriptions.indexOf(e), 1);
40
+ }
41
+ find(e) {
42
+ return this.subscriptions.find((t) => t.name === e);
43
+ }
44
+ isNameAvailable(e) {
45
+ if (this.hasSubscription(e)) throw Error(`There is already a subscription called "${e}".`);
46
+ return !0;
47
+ }
48
+ registrations() {
49
+ return this.subscriptions;
50
+ }
51
+ get(e) {
52
+ let t = this.find(e);
53
+ if (t) return t;
54
+ throw Error(`Subscription "${e}" doesn't exist!`);
55
+ }
56
+ }, E = class e extends T {
57
+ static subscriptions = e.create();
58
+ static get() {
59
+ return this.subscriptions;
60
+ }
61
+ }, D = {
62
+ name: "@razaman2/reactive-view",
63
+ version: "0.1.0-beta.17",
64
+ 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.",
65
+ main: "dist/index.js",
66
+ module: "dist/index.mjs",
67
+ types: "dist/index.d.ts",
68
+ exports: { ".": {
69
+ types: "./dist/index.d.ts",
70
+ require: "./dist/index.js",
71
+ import: "./dist/index.mjs"
72
+ } },
73
+ scripts: {
74
+ prepublishOnly: "npm run build",
75
+ build: "vue-tsc -p tsconfig.build.json && vite build",
76
+ lint: "eslint \"src/**/*.ts\" \"tests/**/*.ts\"",
77
+ "lint:fix": "eslint \"src/**/*.ts\" \"tests/**/*.ts\" --fix",
78
+ format: "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
79
+ typecheck: "tsc",
80
+ test: "vitest run",
81
+ "test:watch": "vitest",
82
+ pr: "sh pr.sh"
83
+ },
84
+ keywords: [
85
+ "vue",
86
+ "vue-helper",
87
+ "reactive-view",
88
+ "vue-class-component",
89
+ "reactive-ui"
90
+ ],
91
+ repository: {
92
+ type: "git",
93
+ url: "git+https://github.com/razaman2/reactive-view.git"
94
+ },
95
+ bugs: { url: "https://github.com/razaman2/reactive-view/issues" },
96
+ homepage: "https://github.com/razaman2/reactive-view#readme",
97
+ author: "razaman2",
98
+ license: "MIT",
99
+ dependencies: {
100
+ "@razaman2/data-manager": "^3.3.12",
101
+ "@razaman2/event-emitter": "^2.1.1",
102
+ "@razaman2/object-manager": "^3.4.7",
103
+ "date-fns": "^4.1.0",
104
+ "date-fns-tz": "^3.2.0",
105
+ "tailwind-merge": "^3.5.0"
106
+ },
107
+ peerDependencies: { vue: ">=3.0.0" },
108
+ devDependencies: {
109
+ "@eslint/js": "^10.0.1",
110
+ "@stylistic/eslint-plugin": "^5.10.0",
111
+ "@typescript-eslint/eslint-plugin": "^8.59.2",
112
+ "@typescript-eslint/parser": "^8.59.2",
113
+ "@vitejs/plugin-vue": "^6.0.6",
114
+ "@vitejs/plugin-vue-jsx": "^5.1.5",
115
+ "@vue/server-renderer": "^3.5.34",
116
+ "@vue/test-utils": "^2.4.10",
117
+ eslint: "^10.3.0",
118
+ "eslint-config-prettier": "^10.1.8",
119
+ "eslint-plugin-prettier": "^5.5.5",
120
+ "eslint-plugin-vue": "^10.9.1",
121
+ jsdom: "^29.1.1",
122
+ prettier: "^3.8.3",
123
+ typescript: "^5.9.3",
124
+ "typescript-eslint": "^8.59.2",
125
+ vite: "^8.0.11",
126
+ vitest: "^4.1.5",
127
+ "vue-tsc": "^3.2.8"
128
+ },
129
+ publishConfig: { access: "public" },
130
+ files: ["dist"]
131
+ }, O = {
132
+ type: Function,
133
+ default: (e = {}, t = {}) => t,
134
+ ReactiveView: !0
135
+ }, k = {
136
+ props: {
137
+ setup: {},
138
+ beta: [Boolean, String],
139
+ ReactiveView: {
140
+ type: Boolean,
141
+ default: !0
142
+ },
143
+ instance: { default: g() },
144
+ notifications: Object,
145
+ subscriptions: Object,
146
+ beforeSetData: Function,
147
+ data: { default: h({}) },
148
+ defaultData: {},
149
+ getDefaultData: {
150
+ type: Function,
151
+ default: (e) => e
152
+ },
153
+ model: {},
154
+ defer: {},
155
+ logging: { validator: (e) => ["Boolean"].includes(e.constructor.name) },
156
+ modelName: {
157
+ type: String,
158
+ default: "ReactiveView"
159
+ },
160
+ debug: {
161
+ type: Boolean,
162
+ default: !1
163
+ },
164
+ state: { default: h({}) }
165
+ },
166
+ setup(n, r) {
167
+ let a = [];
168
+ f(() => a.forEach((e) => e()));
169
+ let s = (t, n) => {
170
+ let r = g(!1), i = Array.from(new Set(t.paths().concat(n.paths()))).reduce((e, i) => (t.get(i) !== n.get(i) && (e.set(i, n.get(i)), r.value = !0), e), e.on({}));
171
+ return {
172
+ before: t.get(),
173
+ after: n.get(),
174
+ changes: i.get(),
175
+ changed: r.value
176
+ };
177
+ }, u = (e) => {
178
+ let t = r.attrs["data:path"];
179
+ return typeof t == "function" ? t(e) : e;
180
+ }, p = (e, t) => i("div", r.slots.default ? r.attrs : {
181
+ style: {
182
+ color: "red",
183
+ textAlign: "center"
184
+ },
185
+ ...r.attrs
186
+ }, r.slots.default ? r.slots.default({
187
+ component: e,
188
+ vue: t,
189
+ props: n,
190
+ context: r
191
+ }) : `${n.modelName}: ${D.name}@${D.version}`), m = g(!1), _ = g(!1), v = g(typeof n.defer == "function" ? n.defer() : n.defer), y = ["Function"].includes(n.data?.constructor.name), S = ["AsyncFunction"].includes(n.data?.constructor.name), C = ["Promise"].includes(n.data?.constructor.name) || S, w = o(), T = n.getDefaultData("defaultData" in w.vnode.props ? w.vnode.props.defaultData : "data" in w.vnode.props && Array.isArray(b(w.vnode.props.data)) ? [] : {}), E = Array.isArray(T) ? [] : {};
192
+ return n.beta === "current" ? (() => {
193
+ let i = (e, t) => {
194
+ if (w && w.vnode.el) {
195
+ let n = new CustomEvent("data:emit", {
196
+ bubbles: !0,
197
+ composed: !0,
198
+ detail: {
199
+ before: t,
200
+ after: e
201
+ }
202
+ });
203
+ w.vnode.el.dispatchEvent(n);
204
+ }
205
+ }, o = {
206
+ data: n.beta ? ((e) => {
207
+ if (n.debug && console.warn(`[ReactiveView]: using beta props data in [${n.modelName}] component`, {
208
+ vue: w,
209
+ data: e,
210
+ defaultData: T,
211
+ isRef: l(e),
212
+ isReactive: c(e)
213
+ }), c(e)) return e;
214
+ if (l(e) || y || C) return h(E);
215
+ {
216
+ let t = "data" in w.vnode.props;
217
+ try {
218
+ return ["Array", "Object"].includes(e?.constructor?.name) ? h(t ? e : E) : h(t ? { "": e } : E);
219
+ } catch {
220
+ return h(t ? { "": e } : E);
221
+ }
222
+ }
223
+ })(w.vnode.props?.data) : h(e.on(C || y || l(n.data) || c(n.data) ? E : "data" in w.vnode.props ? n.data : E).clone()),
224
+ defaultData: e.on(T).clone(),
225
+ notifications: n.notifications,
226
+ subscriptions: n.subscriptions,
227
+ name: n.modelName,
228
+ logging: n.logging
229
+ }, d = new Proxy(n.model ? typeof n.model == "function" ? n.model(o) : n.model : new t(o), { get(t, r, i) {
230
+ return ["setData", "replaceData"].includes(r.toString()) ? (...i) => {
231
+ let a = B(f).beforeSetData ?? n.beforeSetData;
232
+ if (typeof a == "function") {
233
+ let n = e.on(t.getData()), o = i.length ? e.on(E).set(...i) : e.on(E).set(T);
234
+ a(B(f).diff(n, o), t) && t[r](...i);
235
+ } else t[r](...i);
236
+ return t;
237
+ } : Reflect.get(t, r, i);
238
+ } }), f = g({
239
+ parent: { self: w.proxy },
240
+ self: {
241
+ template: p,
242
+ model: d,
243
+ diff: s,
244
+ emit: i,
245
+ dataPath: u,
246
+ isValid: m
247
+ }
248
+ });
249
+ n.debug && console.warn("[ReactiveView]:", {
250
+ props: n,
251
+ context: r,
252
+ vue: w,
253
+ defer: v,
254
+ config: o,
255
+ model: d,
256
+ component: f,
257
+ datatype: E,
258
+ defaultData: T,
259
+ isValid: m,
260
+ isReady: _,
261
+ isFunctionData: y,
262
+ isAsyncFunctionData: S,
263
+ isAsyncData: C
264
+ });
265
+ let b = (t) => {
266
+ let n = typeof r.attrs["onUpdate:data"] == "function" ? { callback: r.attrs["onUpdate:data"] } : {
267
+ callback: (r.attrs["onUpdate:data"] ?? {}).callback ?? r.attrs["data:callback"],
268
+ options: Object.assign({
269
+ deep: r.attrs["data:deep"] ?? !0,
270
+ ...r.attrs["data:immediate"] ? { immediate: r.attrs["data:immediate"] } : {},
271
+ ...r.attrs["data:once"] ? { once: r.attrs["data:once"] } : {}
272
+ }, (r.attrs["onUpdate:data"] ?? {}).options)
273
+ };
274
+ r.attrs["data:log"] && console.warn("[ReactiveView]:data", {
275
+ config: n,
276
+ dataProp: t
277
+ }), a.push(x(y || l(t) || c(t) ? t : () => t, (t, r) => {
278
+ typeof n.callback == "function" ? d.replaceData(n.callback(B(f).diff(e.on(r), e.on(t)), { component: f }) ?? t) : d.replaceData(t);
279
+ }, n.options));
280
+ };
281
+ if (r.attrs["onUpdate:model"] || r.attrs["update:model"]) {
282
+ let t = typeof r.attrs["onUpdate:model"] == "function" ? {
283
+ callback: r.attrs["onUpdate:model"],
284
+ options: Object.assign({
285
+ deep: r.attrs["model:deep"] ?? !0,
286
+ ...r.attrs["model:immediate"] ? { immediate: r.attrs["model:immediate"] } : {},
287
+ ...r.attrs["model:once"] ? { once: r.attrs["model:once"] } : {}
288
+ }, (r.attrs["onUpdate:model"] ?? {}).options)
289
+ } : r.attrs["onUpdate:model"] ?? {};
290
+ r.attrs["model:log"] && console.warn("[ReactiveView]:model", { config: t }), a.push(x(() => e.on(d.getData()).clone(), (n, r) => {
291
+ t.callback(B(f).diff(e.on(r), e.on(n)), { component: f });
292
+ }, t.options));
293
+ }
294
+ if (n.beta) {
295
+ let t = l(n.data);
296
+ (t || y || C) && setTimeout(async () => {
297
+ let [i] = C ? await Promise.all([S ? n.data() : n.data, v.value ?? !0]) : [n.data];
298
+ a.push(x(t || y || typeof i == "function" ? i : () => i, (t, n) => {
299
+ if (n !== void 0 || t !== void 0) {
300
+ let i = r.attrs["data:callback"];
301
+ if (typeof i == "function") {
302
+ let r = B(f).diff(e.on(n), e.on(t));
303
+ d.replaceData(i(r, { component: f }) ?? t);
304
+ } else d.replaceData(t);
305
+ }
306
+ }, {
307
+ immediate: r.attrs["data:immediate"] ?? !0,
308
+ deep: r.attrs["data:deep"] ?? !0,
309
+ once: r.attrs["data:once"]
310
+ }));
311
+ });
312
+ } else setTimeout(async () => {
313
+ let [e] = await Promise.all([S ? n.data() : n.data, v.value ?? !0]);
314
+ b(e);
315
+ });
316
+ return setTimeout(async () => {
317
+ _.value = await v.value ?? !0;
318
+ }), f.value = [B(f)].reduce((e, t) => {
319
+ for (; t && typeof t.setup == "function" && (e = {
320
+ parent: e,
321
+ self: t.setup(f, e) ?? {}
322
+ }, !B(t.$parent).ReactiveView);) t = B(t.$parent);
323
+ return e;
324
+ }, f.value), n.instance.value = typeof n.instance == "function" ? n.instance(f.value) : f.value, (e) => _.value ? B(f).template(f, e) : r.slots.loading?.({ component: f });
325
+ })() : (() => {
326
+ let i = (e, t) => {
327
+ if (w && w.vnode.el) {
328
+ let n = new CustomEvent("emit:data", {
329
+ bubbles: !0,
330
+ composed: !0,
331
+ detail: {
332
+ before: t,
333
+ after: e
334
+ }
335
+ });
336
+ B(O).setData(e), w.vnode.el.dispatchEvent(n), w.vnode.el.dispatchEvent(new CustomEvent("data:emit", {
337
+ bubbles: !0,
338
+ composed: !0,
339
+ detail: {
340
+ before: t,
341
+ after: e
342
+ }
343
+ }));
344
+ }
345
+ }, o = (e) => B(O).model.setData(e), f = (t) => new Proxy(t, { get(t, r, i) {
346
+ return ["setData", "replaceData"].includes(r.toString()) ? (...i) => {
347
+ let a = B(O).beforeSetData ?? n.beforeSetData;
348
+ if (typeof a == "function") {
349
+ let n = e.on(t.getData()), o = i.length ? e.on(E).set(...i) : e.on(E).set(T);
350
+ a(B(O).diff(n, o), t) && t[r](...i);
351
+ } else t[r](...i);
352
+ return t;
353
+ } : Reflect.get(t, r, i);
354
+ } }), h = {
355
+ data: ((e) => {
356
+ if (l(e) || c(e)) return e;
357
+ if (y || C) return g(E);
358
+ {
359
+ let t = "data" in w.vnode.props;
360
+ try {
361
+ return ["Array", "Object"].includes(e?.constructor?.name) ? g(e) : g(t ? { "": e } : E);
362
+ } catch {
363
+ return g(t ? { "": e } : E);
364
+ }
365
+ }
366
+ })(w.vnode.props?.data),
367
+ defaultData: e.on(T).clone(),
368
+ notifications: n.notifications,
369
+ subscriptions: n.subscriptions,
370
+ name: n.modelName,
371
+ logging: n.logging
372
+ }, D = n.model ? typeof n.model == "function" ? n.model(h) : n.model : t.setConfig({ beforeGetData: (e) => l(e) ? b(e) : e }, h), O = g({
373
+ parent: { self: w.proxy },
374
+ self: {
375
+ template: p,
376
+ diff: s,
377
+ emit: i,
378
+ setData: o,
379
+ dataPath: u,
380
+ model: f(D),
381
+ isValid: m
382
+ }
383
+ });
384
+ if (r.attrs["onUpdate:model"] || r.attrs["update:model"]) {
385
+ let t = {
386
+ callback: typeof r.attrs["onUpdate:model"] == "function" ? r.attrs["onUpdate:model"] : r.attrs["update:model"],
387
+ options: {
388
+ immediate: r.attrs["model:immediate"],
389
+ deep: r.attrs["model:deep"],
390
+ once: r.attrs["model:once"]
391
+ }
392
+ };
393
+ a.push(x(() => e.on(D.getData()).clone(), (r, i) => {
394
+ let a = B(O).diff(e.on(i), e.on(r));
395
+ n.debug && console.warn(`[${n.modelName}]:model`, {
396
+ diff: a,
397
+ before: i,
398
+ after: r
399
+ }), a.changed && t.callback(a, { component: O });
400
+ }, t.options));
401
+ }
402
+ return d(async () => {
403
+ if (n.model !== !1) {
404
+ (y || C) && !("defaultData" in w.vnode.props) && console.warn(`${n.modelName}: defaultData is required for promise or function data.`, n.data);
405
+ let [t] = C ? await Promise.all([S ? n.data() : n.data, v.value ?? !0]) : [n.data], i = l(t) || c(t), o = typeof t == "function" || i ? t : () => t;
406
+ a.push(x(o, async (i, a) => {
407
+ let o = B(O).diff(e.on(a), e.on(i)), s = r.attrs["data:callback"];
408
+ n.debug && console.warn(`[${n.modelName}]:data`, {
409
+ diff: o,
410
+ data: t,
411
+ callback: s,
412
+ props: n,
413
+ context: r,
414
+ component: O
415
+ }), typeof s == "function" ? s(o, { component: O }) : D.replaceData(i);
416
+ }, {
417
+ immediate: r.attrs["data:immediate"] ?? !i,
418
+ deep: r.attrs["data:deep"],
419
+ once: r.attrs["data:once"]
420
+ }));
421
+ }
422
+ }), d(async () => {
423
+ _.value = await v.value ?? !0;
424
+ }), O.value = [B(O)].reduce((e, t) => {
425
+ for (; t && typeof t.setup == "function" && (e = {
426
+ parent: e,
427
+ self: t.setup(O, e) ?? {}
428
+ }, !B(t.$parent).ReactiveView);) t = B(t.$parent);
429
+ return e;
430
+ }, O.value), n.instance.value = typeof n.instance == "function" ? n.instance(O.value) : O.value, (e) => _.value ? B(O).template(O, e) : r.slots.loading?.({ component: O });
431
+ })();
432
+ }
82
433
  };
83
-
84
- // src/Subscriptions.ts
85
- var Subscriptions = class _Subscriptions extends Subscription {
86
- static subscriptions = _Subscriptions.create();
87
- static get() {
88
- return this.subscriptions;
89
- }
90
- };
91
-
92
- // src/ReactiveView.ts
93
- import ObjectManager from "@razaman2/object-manager";
94
- import DataManager from "@razaman2/data-manager";
95
- import { ref, reactive, watch, unref, isRef, isReactive, createVNode, getCurrentInstance, onBeforeUnmount } from "vue";
96
-
97
- // package.json
98
- var package_default = {
99
- name: "@razaman2/reactive-view",
100
- version: "0.1.0-beta.16",
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.",
102
- main: "dist/index.js",
103
- module: "dist/index.mjs",
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
- },
112
- scripts: {
113
- prepublishOnly: "npm run build",
114
- build: "tsup src/index.ts --format cjs,esm --dts",
115
- lint: "tsc",
116
- test: "vitest run",
117
- "test:watch": "vitest",
118
- pr: "sh pr.sh"
119
- },
120
- keywords: [
121
- "vue",
122
- "vue-helper",
123
- "reactive-view",
124
- "vue-class-component",
125
- "reactive-ui"
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",
135
- author: "razaman2",
136
- license: "MIT",
137
- dependencies: {
138
- "@razaman2/data-manager": "^3.3.12",
139
- "@razaman2/event-emitter": "^2.1.1",
140
- "@razaman2/object-manager": "^3.4.7",
141
- "date-fns": "^4.1.0",
142
- "date-fns-tz": "^3.2.0",
143
- "tailwind-merge": "^3.5.0",
144
- uuid: "^13.0.0"
145
- },
146
- peerDependencies: {
147
- vue: ">=3.0.0"
148
- },
149
- devDependencies: {
150
- "@types/uuid": "^11.0.0",
151
- tsup: "^8.5.1",
152
- typescript: "^5.9.3",
153
- vitest: "^4.1.2"
154
- },
155
- publishConfig: {
156
- access: "public"
157
- },
158
- files: [
159
- "dist"
160
- ]
161
- };
162
-
163
- // src/ReactiveView.ts
164
- var setup = {
165
- type: Function,
166
- default: (parent = {}, self = {}) => self,
167
- ReactiveView: true
168
- };
169
- var ReactiveView_default = {
170
- props: {
171
- setup: {},
172
- beta: [Boolean, String],
173
- ReactiveView: {
174
- type: Boolean,
175
- default: true
176
- },
177
- instance: { default: ref() },
178
- notifications: Object,
179
- subscriptions: Object,
180
- beforeSetData: Function,
181
- data: { default: reactive({}) },
182
- defaultData: {},
183
- getDefaultData: {
184
- type: Function,
185
- default: (data) => data
186
- },
187
- model: {},
188
- defer: {},
189
- logging: {
190
- validator: (logging) => {
191
- return ["Boolean"].includes(logging.constructor.name);
192
- }
193
- },
194
- modelName: {
195
- type: String,
196
- default: "ReactiveView"
197
- },
198
- debug: {
199
- type: Boolean,
200
- default: false
201
- },
202
- state: { default: reactive({}) }
203
- },
204
- setup(props, context) {
205
- const subscriptions = [];
206
- onBeforeUnmount(() => subscriptions.forEach((subscription) => subscription()));
207
- const diff = (before, after) => {
208
- const changed = ref(false);
209
- const paths = Array.from(new Set(before.paths().concat(after.paths())));
210
- const changes = paths.reduce((changes2, path) => {
211
- if (before.get(path) !== after.get(path)) {
212
- changes2.set(path, after.get(path));
213
- changed.value = true;
214
- }
215
- return changes2;
216
- }, ObjectManager.on({}));
217
- return { before: before.get(), after: after.get(), changes: changes.get(), changed: changed.value };
218
- };
219
- const dataPath2 = (path) => {
220
- const handler = context.attrs["data:path"];
221
- return typeof handler === "function" ? handler(path) : path;
222
- };
223
- const template = (component, vue2) => {
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}`);
228
- };
229
- const isValid = ref(false);
230
- const isReady = ref(false);
231
- const defer = ref(typeof props.defer === "function" ? props.defer() : props.defer);
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;
235
- const vue = getCurrentInstance();
236
- const defaultData = props.getDefaultData(
237
- "defaultData" in vue.vnode.props ? vue.vnode.props.defaultData : "data" in vue.vnode.props ? Array.isArray(unref(vue.vnode.props.data)) ? [] : {} : {}
238
- );
239
- const datatype = Array.isArray(defaultData) ? [] : {};
240
- const beta = () => {
241
- const emit = (after, before) => {
242
- if (vue && vue.vnode.el) {
243
- const event = new CustomEvent("data:emit", {
244
- bubbles: true,
245
- // Key: allows it to travel up
246
- composed: true,
247
- // Key: allows it to cross Shadow DOM boundaries
248
- detail: { before, after }
249
- // Payload goes here
250
- });
251
- access(component).model.setData(after);
252
- vue.vnode.el.dispatchEvent(event);
253
- }
254
- };
255
- const proxy = (data) => {
256
- return new Proxy(data, {
257
- get(target, key, receiver) {
258
- if (["setData", "replaceData"].includes(key.toString())) {
259
- return (...params) => {
260
- const beforeSetData = access(component).beforeSetData ?? props.beforeSetData;
261
- if (typeof beforeSetData === "function") {
262
- const before = ObjectManager.on(target.getData());
263
- const after = params.length ? ObjectManager.on(datatype).set(...params) : ObjectManager.on(datatype).set(defaultData);
264
- const diff2 = access(component).diff(before, after);
265
- if (beforeSetData(diff2, target)) {
266
- target[key](...params);
267
- }
268
- } else {
269
- target[key](...params);
270
- }
271
- return target;
272
- };
273
- } else {
274
- return Reflect.get(target, key, receiver);
275
- }
276
- }
277
- });
278
- };
279
- const normalize = (data) => {
280
- if (isRef(data) || isReactive(data)) {
281
- return data;
282
- } else if (isFunctionData || isAsyncData) {
283
- return ref(datatype);
284
- } else {
285
- const props2 = "data" in vue.vnode.props;
286
- try {
287
- if (["Array", "Object"].includes(data?.constructor?.name)) {
288
- return ref(data);
289
- } else {
290
- return ref(props2 ? { "": data } : datatype);
291
- }
292
- } catch {
293
- return ref(props2 ? { "": data } : datatype);
294
- }
295
- }
296
- };
297
- const config = {
298
- data: normalize(vue.vnode.props?.data),
299
- defaultData: ObjectManager.on(defaultData).clone(),
300
- notifications: props.notifications,
301
- subscriptions: props.subscriptions,
302
- name: props.modelName,
303
- logging: props.logging
304
- };
305
- const model = props.model ? typeof props.model === "function" ? props.model(config) : props.model : DataManager.setConfig({ beforeGetData: (data) => isRef(data) ? unref(data) : data }, config);
306
- const component = ref({ parent: { self: vue.proxy }, self: { template, diff, emit, dataPath: dataPath2, model: proxy(model), isValid } });
307
- if (context.attrs["onUpdate:model"] || context.attrs["update:model"]) {
308
- const config2 = {
309
- callback: typeof context.attrs["onUpdate:model"] === "function" ? context.attrs["onUpdate:model"] : context.attrs["update:model"],
310
- options: {
311
- immediate: context.attrs["model:immediate"],
312
- deep: context.attrs["model:deep"],
313
- once: context.attrs["model:once"]
314
- }
315
- };
316
- const source = () => ObjectManager.on(model.getData()).clone();
317
- subscriptions.push(watch(source, (after, before) => {
318
- const diff2 = access(component).diff(ObjectManager.on(before), ObjectManager.on(after));
319
- if (props.debug) {
320
- console.warn(`[${props.modelName}]:model`, { diff: diff2, before, after });
321
- }
322
- if (diff2.changed) {
323
- config2.callback(diff2, { component });
324
- }
325
- }, config2.options));
326
- }
327
- setTimeout(async () => {
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);
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
- }));
353
- }
354
- });
355
- setTimeout(async () => {
356
- isReady.value = await defer.value ?? true;
357
- });
358
- component.value = [access(component)].reduce((options, parent) => {
359
- while (parent) {
360
- if (typeof parent.setup === "function") {
361
- options = { parent: options, self: parent.setup(component, options) ?? {} };
362
- if (access(parent.$parent).ReactiveView) {
363
- break;
364
- } else {
365
- parent = access(parent.$parent);
366
- }
367
- } else {
368
- break;
369
- }
370
- }
371
- return options;
372
- }, component.value);
373
- props.instance.value = typeof props.instance === "function" ? props.instance(component.value) : component.value;
374
- return (vue2) => {
375
- if (isReady.value) {
376
- return access(component).template(component, vue2);
377
- } else {
378
- return context.slots.loading?.({ component });
379
- }
380
- };
381
- };
382
- const current = () => {
383
- const emit = (after, before) => {
384
- if (vue && vue.vnode.el) {
385
- const event = new CustomEvent("data:emit", {
386
- bubbles: true,
387
- // Key: allows it to travel up
388
- composed: true,
389
- // Key: allows it to cross Shadow DOM boundaries
390
- detail: { before, after }
391
- // Payload goes here
392
- });
393
- vue.vnode.el.dispatchEvent(event);
394
- }
395
- };
396
- const normalize = (data) => {
397
- if (props.debug) {
398
- console.warn(`[ReactiveView]: using beta props data in [${props.modelName}] component`, { vue, data, defaultData, isRef: isRef(data), isReactive: isReactive(data) });
399
- }
400
- if (isReactive(data)) {
401
- return data;
402
- } else {
403
- if (isRef(data) || isFunctionData || isAsyncData) {
404
- return reactive(datatype);
405
- } else {
406
- const props2 = "data" in vue.vnode.props;
407
- try {
408
- if (["Array", "Object"].includes(data?.constructor?.name)) {
409
- return reactive(props2 ? data : datatype);
410
- } else {
411
- return reactive(props2 ? { "": data } : datatype);
412
- }
413
- } catch {
414
- return reactive(props2 ? { "": data } : datatype);
415
- }
416
- }
417
- }
418
- };
419
- const config = {
420
- data: props.beta ? normalize(vue.vnode.props?.data) : reactive(ObjectManager.on(
421
- isAsyncData || isFunctionData || isRef(props.data) || isReactive(props.data) ? datatype : "data" in vue.vnode.props ? props.data : datatype
422
- ).clone()),
423
- defaultData: ObjectManager.on(defaultData).clone(),
424
- notifications: props.notifications,
425
- subscriptions: props.subscriptions,
426
- name: props.modelName,
427
- logging: props.logging
428
- };
429
- const model = new Proxy(props.model ? typeof props.model === "function" ? props.model(config) : props.model : new DataManager(config), {
430
- get(target, key, receiver) {
431
- if (["setData", "replaceData"].includes(key.toString())) {
432
- return (...params) => {
433
- const beforeSetData = access(component).beforeSetData ?? props.beforeSetData;
434
- if (typeof beforeSetData === "function") {
435
- const before = ObjectManager.on(target.getData());
436
- const after = params.length ? ObjectManager.on(datatype).set(...params) : ObjectManager.on(datatype).set(defaultData);
437
- if (beforeSetData(access(component).diff(before, after), target)) {
438
- target[key](...params);
439
- }
440
- } else {
441
- target[key](...params);
442
- }
443
- return target;
444
- };
445
- } else {
446
- return Reflect.get(target, key, receiver);
447
- }
448
- }
449
- });
450
- const component = ref({ parent: { self: vue.proxy }, self: { template, model, diff, emit, dataPath: dataPath2, isValid } });
451
- if (props.debug) {
452
- console.warn("[ReactiveView]:", { props, context, vue, defer, config, model, component, datatype, defaultData, isValid, isReady, isFunctionData, isAsyncFunctionData, isAsyncData });
453
- }
454
- const watchDataProp = (dataProp) => {
455
- const config2 = typeof context.attrs["onUpdate:data"] === "function" ? { callback: context.attrs["onUpdate:data"] } : {
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)
462
- };
463
- if (context.attrs["data:log"]) {
464
- console.warn(`[ReactiveView]:data`, { config: config2, dataProp });
465
- }
466
- subscriptions.push(watch(isFunctionData || isRef(dataProp) || isReactive(dataProp) ? dataProp : () => dataProp, (after, before) => {
467
- if (typeof config2.callback === "function") {
468
- model.replaceData(config2.callback(access(component).diff(ObjectManager.on(before), ObjectManager.on(after)), { component }) ?? after);
469
- } else {
470
- model.replaceData(after);
471
- }
472
- }, config2.options));
473
- };
474
- if (context.attrs["onUpdate:model"] || context.attrs["update:model"]) {
475
- const config2 = typeof context.attrs["onUpdate:model"] === "function" ? {
476
- callback: context.attrs["onUpdate:model"],
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"] ?? {};
483
- if (context.attrs["model:log"]) {
484
- console.warn(`[ReactiveView]:model`, { config: config2 });
485
- }
486
- subscriptions.push(watch(() => ObjectManager.on(model.getData()).clone(), (after, before) => {
487
- config2.callback(access(component).diff(ObjectManager.on(before), ObjectManager.on(after)), { component });
488
- }, config2.options));
489
- }
490
- if (props.beta) {
491
- const isRefData = isRef(props.data);
492
- if (isRefData || isFunctionData || isAsyncData) {
493
- setTimeout(async () => {
494
- const [data] = isAsyncData ? await Promise.all([
495
- isAsyncFunctionData ? props.data() : props.data,
496
- defer.value ?? true
497
- ]) : [props.data];
498
- subscriptions.push(watch(isRefData ? data : isFunctionData ? data : typeof data === "function" ? data : () => data, (after, before) => {
499
- if (before !== void 0 || after !== void 0) {
500
- const callback = context.attrs["data:callback"];
501
- if (typeof callback === "function") {
502
- const diff2 = access(component).diff(ObjectManager.on(before), ObjectManager.on(after));
503
- model.replaceData(callback(diff2, { component }) ?? after);
504
- } else {
505
- model.replaceData(after);
506
- }
507
- }
508
- }, {
509
- immediate: context.attrs["data:immediate"] ?? true,
510
- deep: context.attrs["data:deep"] ?? true,
511
- once: context.attrs["data:once"]
512
- }));
513
- });
514
- }
515
- } else {
516
- setTimeout(async () => {
517
- const [data] = await Promise.all([
518
- isAsyncFunctionData ? props.data() : props.data,
519
- defer.value ?? true
520
- ]);
521
- watchDataProp(data);
522
- });
523
- }
524
- setTimeout(async () => {
525
- isReady.value = await defer.value ?? true;
526
- });
527
- component.value = [access(component)].reduce((options, parent) => {
528
- while (parent) {
529
- if (typeof parent.setup === "function") {
530
- options = { parent: options, self: parent.setup(component, options) ?? {} };
531
- if (access(parent.$parent).ReactiveView) {
532
- break;
533
- } else {
534
- parent = access(parent.$parent);
535
- }
536
- } else {
537
- break;
538
- }
539
- }
540
- return options;
541
- }, component.value);
542
- props.instance.value = typeof props.instance === "function" ? props.instance(component.value) : component.value;
543
- return (vue2) => {
544
- if (isReady.value) {
545
- return access(component).template(component, vue2);
546
- } else {
547
- return context.slots.loading?.({ component });
548
- }
549
- };
550
- };
551
- return props.beta === "next" ? beta() : current();
552
- }
553
- };
554
-
555
- // src/index.ts
556
- import { h, ref as ref2, unref as unref2, toRaw, isRef as isRef2, isReactive as isReactive2, createApp, createVNode as createVNode2, defineComponent } from "vue";
557
- import { formatInTimeZone } from "date-fns-tz";
558
- import { twMerge } from "tailwind-merge";
559
- var ObjectManager2 = OM.default || OM;
560
- var { version } = package_default;
561
- console.log(`%c[ReactiveView]: ${version}`, "background-color: red; color: yellow;");
562
- var index_default = ReactiveView_default;
563
- function safeRequest(request) {
564
- return new Promise(async (resolve) => {
565
- const { message } = request.loading ?? {};
566
- if (request.loading) {
567
- request.loading.status = true;
568
- if (request.message) {
569
- request.loading.message = request.message;
570
- }
571
- }
572
- try {
573
- resolve(await request.try());
574
- } catch (e) {
575
- if (request.alternative ?? true) {
576
- resolve(request.catch ? await request.catch(e) : console.log(e));
577
- }
578
- } finally {
579
- await request.finally?.();
580
- if (request.loading) {
581
- request.loading.status = false;
582
- }
583
- if (request.loading && message) {
584
- request.loading.message = message;
585
- }
586
- await request.complete?.();
587
- }
588
- });
589
- }
590
- function getProps(props = {}, param2) {
591
- const exclude = Array.isArray(param2) || typeof param2 === "string" ? param2 : param2.exclude;
592
- const exclusions = (Array.isArray(exclude) ? exclude : [exclude]).join("|");
593
- const include = param2.include ?? {};
594
- return Object.entries(include).reduce((props2, [key, val]) => {
595
- props2[key] = val;
596
- return props2;
597
- }, Object.entries(props).reduce((props2, [key, val]) => {
598
- if (!RegExp(`(^|\\|)${key}($|\\|)`, "i").test(exclusions)) {
599
- props2[key] = val;
600
- }
601
- return props2;
602
- }, {}));
434
+ //#endregion
435
+ //#region src/showComponent.ts
436
+ function A(e, t = {}) {
437
+ let n = (e) => {
438
+ let n = t.id ?? `dialog_${e.children.length + 1}`, r = document.createElement("div");
439
+ return r.setAttribute("id", n), e.appendChild(r), r;
440
+ }, r = (e) => {
441
+ let t = document.getElementById(e);
442
+ if (t) return n(t);
443
+ {
444
+ let t = document.createElement("div");
445
+ return t.setAttribute("id", e), document.body.appendChild(t), n(t);
446
+ }
447
+ }, a = t.container || "app-dialogs", o = r(a), s = i({ setup: () => () => e }, {
448
+ container: a,
449
+ unmount: () => {
450
+ _(null, o), o.remove();
451
+ }
452
+ }), c = t.app ?? document.querySelector("[data-v-app]");
453
+ try {
454
+ s.appContext = c.__vue_app__._context, _(s, o);
455
+ } catch {
456
+ console.warn("[ReactiveView]: showComponent called without an active app context.");
457
+ }
603
458
  }
604
- function getReactiveViewComponent(component, options = {}) {
605
- const model = (component2) => {
606
- try {
607
- return (component2.type || component2).props.hasOwnProperty("model");
608
- } catch {
609
- return false;
610
- }
611
- };
612
- const props = getProps(options, "setup");
613
- const slots = typeof component === "function" ? component : () => {
614
- return (component.type || component).setup ? createVNode2(component, component.setup ? {} : props) : component;
615
- };
616
- return model(component) ? createVNode2(component, props) : createVNode2(ReactiveView_default, props, slots);
459
+ //#endregion
460
+ //#region src/components/CustomButton.vue
461
+ var j = K({
462
+ modelName: "CustomButton",
463
+ props: {
464
+ label: [Number, String],
465
+ tag: {
466
+ type: String,
467
+ default: "button"
468
+ },
469
+ loading: {
470
+ type: [Boolean, Function],
471
+ default: !1
472
+ },
473
+ padding: {
474
+ type: Boolean,
475
+ default: !0
476
+ },
477
+ buttonClass: {},
478
+ loadingClass: {}
479
+ },
480
+ setup(e, t, n) {
481
+ let r = typeof n.loading == "function" ? n.loading : () => n.loading, a = g(!1);
482
+ return S(() => {
483
+ a.value = r();
484
+ }), {
485
+ template: () => i(n.tag, { class: w(W({
486
+ "px-0 h-min": !n.padding,
487
+ "btn uppercase rounded-lg text-sm font-normal leading-none": !0
488
+ }).string, W(n.buttonClass).string) }, { default: () => [B(e).buttonLoading(), i("div", { class: {
489
+ hidden: a.value,
490
+ contents: !0
491
+ } }, [B(e).buttonIcon(), n.$slots.default ? n.$slots.default({ component: e }) : n.label])] }),
492
+ buttonIcon: () => {
493
+ if (n.$slots.icon) return n.$slots.icon({ component: e });
494
+ },
495
+ buttonLoading: () => {
496
+ if (a.value) return n.$slots.loading ? n.$slots.loading({ component: e }) : i("span", { class: W("loading", n.loadingClass) }, null);
497
+ }
498
+ };
499
+ }
500
+ }), M = K({
501
+ modelName: "CustomModal",
502
+ props: {
503
+ title: {
504
+ type: [
505
+ Boolean,
506
+ Number,
507
+ String
508
+ ],
509
+ default: "Modal Title"
510
+ },
511
+ persistent: {
512
+ type: Boolean,
513
+ default: !1
514
+ },
515
+ header: {
516
+ type: Boolean,
517
+ default: !0
518
+ },
519
+ actions: {
520
+ type: Boolean,
521
+ default: !0
522
+ },
523
+ ok: {
524
+ type: Boolean,
525
+ default: !0
526
+ },
527
+ cancel: {
528
+ type: Boolean,
529
+ default: !1
530
+ },
531
+ close: {
532
+ type: Boolean,
533
+ default: !0
534
+ },
535
+ show: {
536
+ type: Boolean,
537
+ default: !0
538
+ },
539
+ whenOk: {
540
+ type: Function,
541
+ default: () => {}
542
+ },
543
+ whenCancel: {
544
+ type: Function,
545
+ default: () => {}
546
+ },
547
+ whenClose: {
548
+ type: Function,
549
+ default: () => {}
550
+ },
551
+ whenEscape: {
552
+ type: Function,
553
+ default: () => {}
554
+ },
555
+ whenDismiss: {
556
+ type: Function,
557
+ default: () => {}
558
+ },
559
+ whenRouteChange: {
560
+ type: Function,
561
+ default: () => {}
562
+ },
563
+ class: {},
564
+ headerClass: {},
565
+ titleClass: {},
566
+ actionsClass: {},
567
+ backdropClass: {},
568
+ timeout: {
569
+ default: !1,
570
+ validator: (e) => typeof e == "number" || e === !1
571
+ },
572
+ modal: {
573
+ type: Boolean,
574
+ default: !1
575
+ },
576
+ id: [Number, String]
577
+ },
578
+ setup: (e, t, a) => {
579
+ m("dialog", e);
580
+ let o = g(), s = g(), c = document.getElementById(a.$attrs.container ?? "app-dialogs"), l = n(() => B(e).trigger ?? a.$slots.trigger), d = n(() => l.value ? !1 : a.show), f = n(() => !0), p = (e) => {
581
+ throw Error(e);
582
+ }, h = () => i("div", null, [i("dialog", u({
583
+ class: "modal",
584
+ ref: o
585
+ }, l.value || B(e).watch ? {} : c ? { id: c.lastChild?.id } : p("Modal should be called with showComponent.ts | trigger element | trigger slot")), [B(e).modalBox(), B(e).modalBackdrop()]), l.value?.({ component: e })]), _ = () => i("div", { class: w(W("modal-box flex flex-col p-0", a.class).string, W(a.class).string) }, [
586
+ B(e).modalHeader(),
587
+ B(e).modalContent(),
588
+ B(e).modalActions()
589
+ ]), y = () => a.$slots.default ? a.$slots.default({ component: e }) : i("div", { class: "px-4" }, [r("No Content")]), b = () => i("div", {
590
+ class: w("modal-backdrop", W({ "pointer-events-none": a.persistent }).string, W(a.backdropClass).string),
591
+ onClick: () => B(e).hide("backdrop")
592
+ }, null), S = () => {
593
+ if (a.actions) return i("div", {
594
+ style: "margin: 0;",
595
+ class: w("modal-action px-4 pb-4", W(a.actionsClass).string)
596
+ }, [B(e).okButton(), B(e).cancelButton()]);
597
+ }, C = () => {
598
+ if (a.header) return i("div", { class: w("flex items-center justify-between px-4 pt-4", W(a.headerClass).string) }, [B(e).title(), B(e).closeButton()]);
599
+ }, T = () => {
600
+ if (a.close) return i(v("i-mdi-close"), {
601
+ class: "cursor-pointer rounded-full text-xl transition duration-500 hover:scale-80 hover:ring",
602
+ onClick: async () => {
603
+ await a.whenClose(), B(e).hide("close");
604
+ }
605
+ }, null);
606
+ }, E = () => {
607
+ if (a.ok) return i(j, {
608
+ label: "ok",
609
+ class: "btn-sm btn-success text-white",
610
+ onClick: () => B(e).triggerOk(),
611
+ disabled: !B(e).isValid
612
+ }, null);
613
+ }, D = () => {
614
+ if (a.cancel) return i(j, {
615
+ label: "cancel",
616
+ class: "btn-sm btn-error text-white",
617
+ onClick: async () => {
618
+ await a.whenCancel(), B(e).hide("cancel");
619
+ }
620
+ }, null);
621
+ }, O = () => {
622
+ if (["String", "Number"].includes(a.title.constructor.name)) return i("h3", { class: w("w-full text-center font-bold", W(a.titleClass).string) }, [a.title]);
623
+ }, k = () => o.value[a.modal ? "showModal" : "show"](), A = (e) => o.value.close(e), M = () => o.value.open, N = (e) => {
624
+ a.$attrs.unmount?.(e), clearTimeout(s.value);
625
+ };
626
+ return setTimeout(() => {
627
+ let t = "open";
628
+ o.value && (new MutationObserver(async () => {
629
+ if (B(e).showing()) try {
630
+ await (await import("@razaman2/event-emitter")).default.global().emit(`dialog:${t}`, {
631
+ type: t,
632
+ component: e,
633
+ id: a.id
634
+ });
635
+ } finally {}
636
+ }).observe(o.value, {
637
+ attributes: !0,
638
+ attributeFilter: [t]
639
+ }), o.value.addEventListener("close", async (t) => {
640
+ let n = t.target.returnValue || "escape";
641
+ try {
642
+ await (await import("@razaman2/event-emitter")).default.global().emit("dialog:close", {
643
+ e: t,
644
+ type: n,
645
+ component: e,
646
+ id: a.id
647
+ });
648
+ } finally {
649
+ await a.whenDismiss({ type: n }), N({ type: n });
650
+ }
651
+ }), typeof a.timeout == "number" && (s.value = setTimeout(() => B(e).hide("timeout"), a.timeout)), B(e).watch ? x(B(e).watch, (t) => {
652
+ o.value && t ? B(e).show() : o.value && B(e).hide();
653
+ }, { deep: !0 }) : d.value && B(e).show()), document.addEventListener("keydown", async (e) => {
654
+ let t = e.key === "Escape";
655
+ a.persistent && t ? (e.stopPropagation(), e.preventDefault()) : t && await a.whenEscape();
656
+ });
657
+ }), {
658
+ template: h,
659
+ title: O,
660
+ modalBox: _,
661
+ modalHeader: C,
662
+ modalContent: y,
663
+ modalActions: S,
664
+ modalBackdrop: b,
665
+ closeButton: T,
666
+ okButton: E,
667
+ cancelButton: D,
668
+ show: k,
669
+ hide: A,
670
+ showing: M,
671
+ triggerOk: async () => {
672
+ await a.whenOk(B(e).model.getData()), B(e).hide("ok");
673
+ },
674
+ isValid: f,
675
+ modalRef: o
676
+ };
677
+ }
678
+ }), N = {
679
+ props: {
680
+ setup: O,
681
+ title: { type: String },
682
+ description: { type: String },
683
+ close: {
684
+ type: Boolean,
685
+ default: !0
686
+ },
687
+ timeout: {
688
+ default: 3e3,
689
+ validator: (e) => typeof e == "number" || e === !1
690
+ }
691
+ },
692
+ setup(e, t) {
693
+ return (e) => i(F, {
694
+ modelName: "CustomAlert",
695
+ setup: (n) => {
696
+ let r = {
697
+ default: i("path", {
698
+ "stroke-linecap": "round",
699
+ "stroke-linejoin": "round",
700
+ "stroke-width": "2",
701
+ d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
702
+ }, null),
703
+ "alert-info": i("path", {
704
+ "stroke-linecap": "round",
705
+ "stroke-linejoin": "round",
706
+ "stroke-width": "2",
707
+ d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
708
+ }, null),
709
+ "alert-success": i("path", {
710
+ "stroke-linecap": "round",
711
+ "stroke-linejoin": "round",
712
+ "stroke-width": "2",
713
+ d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
714
+ }, null),
715
+ "alert-warning": i("path", {
716
+ "stroke-linecap": "round",
717
+ "stroke-linejoin": "round",
718
+ "stroke-width": "2",
719
+ d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
720
+ }, null),
721
+ "alert-error": i("path", {
722
+ "stroke-linecap": "round",
723
+ "stroke-linejoin": "round",
724
+ "stroke-width": "2",
725
+ d: "M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"
726
+ }, null)
727
+ }, a = /alert-(info|success|warning|error)/.exec(e.$attrs.class)?.shift();
728
+ return e.timeout && p(() => {
729
+ setTimeout(() => B(n).hide("timeout"), e.timeout);
730
+ }), {
731
+ template: () => i("div", {
732
+ role: "alert",
733
+ class: "alert"
734
+ }, [
735
+ B(n).alertIcon(),
736
+ i("div", null, [B(n).alertTitle(), e.$slots.default ? e.$slots.default({ component: n }) : B(n).alertDescription()]),
737
+ B(n).alertClose()
738
+ ]),
739
+ alertIcon: () => i("svg", {
740
+ xmlns: "http://www.w3.org/2000/svg",
741
+ class: {
742
+ [a ? "stroke-current" : "stroke-black"]: !0,
743
+ "h-6 w-6 shrink-0": !0
744
+ },
745
+ fill: "none",
746
+ viewBox: "0 0 24 24"
747
+ }, [r[a] || r.default]),
748
+ alertTitle: () => i("h3", { class: "font-bold" }, [e.title]),
749
+ alertDescription: () => i("div", { class: "text-xs" }, [e.description]),
750
+ alertClose: () => {
751
+ if (e.close) return i(v("i-mdi-close"), {
752
+ id: "alert-close",
753
+ class: "text-xl cursor-pointer rounded-full hover:scale-80 hover:ring transition duration-500",
754
+ onClick: () => B(n).hide("close")
755
+ }, null);
756
+ },
757
+ hide: (n) => {
758
+ e.$el.remove(), t.emit("close", n);
759
+ }
760
+ };
761
+ }
762
+ }, e.$slots);
763
+ }
764
+ }, P = e.default || e;
765
+ console.log(`%c[ReactiveView]: ${D.version}`, "background-color: red; color: yellow;");
766
+ var F = k;
767
+ async function I(e) {
768
+ let { message: t } = e.loading ?? {};
769
+ e.loading && (e.loading.status = !0, e.message && (e.loading.message = e.message));
770
+ try {
771
+ return await e.try();
772
+ } catch (t) {
773
+ if (e.alternative ?? !0) return e.catch ? await e.catch(t) : console.log(t);
774
+ } finally {
775
+ await e.finally?.(), e.loading && (e.loading.status = !1), e.loading && t && (e.loading.message = t), await e.complete?.();
776
+ }
617
777
  }
618
- function getDate(param1, param2) {
619
- const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
620
- const format = "MM/dd/yyyy h:mm a";
621
- const options = typeof param2 === "string" ? { format: param2, timezone } : { format: param2?.format ?? format, timezone: param2?.timezone ?? timezone };
622
- const datetime = () => {
623
- try {
624
- return param1 instanceof Date ? param1 : param1.toDate();
625
- } catch (e) {
626
- return /* @__PURE__ */ new Date();
627
- }
628
- };
629
- return formatInTimeZone(datetime(), options.timezone, options.format);
778
+ function L(e = {}, t) {
779
+ let n = Array.isArray(t) || typeof t == "string" ? t : t.exclude, r = (Array.isArray(n) ? n : [n]).join("|"), i = t.include ?? {};
780
+ return Object.entries(i).reduce((e, [t, n]) => (e[t] = n, e), Object.entries(e).reduce((e, [t, n]) => (RegExp(`(^|\\|)${t}($|\\|)`, "i").test(r) || (e[t] = n), e), {}));
630
781
  }
631
- function access(view = {}, alternative) {
632
- const resolve = (target) => {
633
- return new Proxy(toRaw(target), {
634
- get(target2, key) {
635
- const component = { tree: target2 };
636
- do {
637
- if (key in component.tree) {
638
- return component.tree[key];
639
- } else if ("self" in component.tree && key in component.tree.self) {
640
- return component.tree.self[key];
641
- } else {
642
- component.tree = "parent" in component.tree && component.tree.parent;
643
- }
644
- } while (component.tree);
645
- try {
646
- return new alternative();
647
- } catch {
648
- return alternative;
649
- }
650
- }
651
- });
652
- };
653
- try {
654
- const component = unref2(typeof view === "function" ? view() : view) ?? {};
655
- return resolve("instance" in component ? component.instance : component);
656
- } catch {
657
- return resolve(view);
658
- }
782
+ function R(e, t = {}) {
783
+ let n = (e) => {
784
+ try {
785
+ let t = (e.type || e).props;
786
+ return t && Object.prototype.hasOwnProperty.call(t, "model");
787
+ } catch {
788
+ return !1;
789
+ }
790
+ }, r = L(t, "setup"), a = typeof e == "function" ? e : () => (e.type || e).setup ? i(e, e.setup ? {} : r) : e;
791
+ return n(e) ? i(e, r) : i(k, r, a);
659
792
  }
660
- function useSubscription() {
661
- const subscriptions = [];
662
- const subscription = Subscriptions.get();
663
- return {
664
- addSubscription(name, handler = () => false, data) {
665
- subscription.subscribe(name, handler, data);
666
- subscriptions.push(() => subscription.unsubscribe(name));
667
- },
668
- replaceSubscription(name, handler = () => false, data) {
669
- subscription.replace(name, handler, data);
670
- subscriptions.push(() => subscription.unsubscribe(name));
671
- },
672
- removeSubscriptions() {
673
- subscriptions.forEach((subscription2) => safeRequest({
674
- try: () => subscription2()
675
- }));
676
- },
677
- removeSubscription(name) {
678
- subscription.unsubscribe(name);
679
- },
680
- hasSubscription(name) {
681
- return subscription.hasSubscription(name);
682
- },
683
- subscriptions,
684
- subscription
685
- };
793
+ function z(e, t) {
794
+ let n = Intl.DateTimeFormat().resolvedOptions().timeZone, r = typeof t == "string" ? {
795
+ format: t,
796
+ timezone: n
797
+ } : {
798
+ format: t?.format ?? "MM/dd/yyyy h:mm a",
799
+ timezone: t?.timezone ?? n
800
+ };
801
+ return C((() => {
802
+ try {
803
+ return e instanceof Date ? e : e.toDate();
804
+ } catch {
805
+ return /* @__PURE__ */ new Date();
806
+ }
807
+ })(), r.timezone, r.format);
686
808
  }
687
- var Prop = ({ default: value, type, validator, required } = {}) => {
688
- const types1 = Array.isArray(type) ? type : [type ?? Array];
689
- const types2 = types1.includes(Object) ? types1 : types1.concat(Object);
690
- return {
691
- ...value ? { default: isRef2(value) || isReactive2(value) ? value : ref2(value) } : {},
692
- required,
693
- validator: (value2) => {
694
- try {
695
- return validator ? validator(unref2(value2)) : Array.from(new Set(types2.map((type2) => {
696
- return typeof type2 === "function" ? type2().constructor.name : type2;
697
- }))).includes(unref2(value2).constructor.name);
698
- } catch {
699
- return !required;
700
- }
701
- }
702
- };
703
- };
704
- function StyleParser(styles = {}) {
705
- const transform = (style, status = true) => {
706
- const remove = style.split(/(-{[^}]+})/);
707
- return remove.reduce((object, style2) => {
708
- const remove2 = /-{(.+?)}/.exec(style2);
709
- (remove2 ? remove2[1] ?? style2 : style2).split(/\s+/).forEach((item) => {
710
- if (item) {
711
- Object.assign(object, { [item]: remove2 ? false : status });
712
- }
713
- });
714
- return object;
715
- }, {});
716
- };
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]) => {
718
- return {
719
- ...acc,
720
- ...transform(styles2, value)
721
- };
722
- }, {});
809
+ function B(e = {}, t) {
810
+ let n = (e) => new Proxy(y(e), { get(e, n) {
811
+ let r = { tree: e };
812
+ do
813
+ if (n in r.tree) return r.tree[n];
814
+ else if ("self" in r.tree && n in r.tree.self) return r.tree.self[n];
815
+ else r.tree = "parent" in r.tree && r.tree.parent;
816
+ while (r.tree);
817
+ try {
818
+ return new t();
819
+ } catch {
820
+ return t;
821
+ }
822
+ } });
823
+ try {
824
+ let t = b(typeof e == "function" ? e() : e) ?? {};
825
+ return n("instance" in t ? t.instance : t);
826
+ } catch {
827
+ return n(e);
828
+ }
723
829
  }
724
- function MergeStyles(...params) {
725
- return new Proxy(params.reduce((styles, style, index, items) => {
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
- };
731
- }, {}), {
732
- get: (target, key, receiver) => {
733
- const styles = Object.entries(target).reduce((styles2, [key2, val]) => {
734
- return val ? styles2.concat(key2) : styles2;
735
- }, []);
736
- if (key === "string") {
737
- return styles.join(" ");
738
- } else if (key === "array") {
739
- return styles;
740
- } else {
741
- return Reflect.get(target, key, receiver);
742
- }
743
- }
744
- });
830
+ function V() {
831
+ let e = [], t = E.get();
832
+ return {
833
+ addSubscription(n, r, i) {
834
+ t.subscribe(n, r, i), e.push(() => t.unsubscribe(n));
835
+ },
836
+ replaceSubscription(n, r, i) {
837
+ t.replace(n, r, i), e.push(() => t.unsubscribe(n));
838
+ },
839
+ removeSubscriptions() {
840
+ e.forEach((e) => I({ try: () => e() }));
841
+ },
842
+ removeSubscription(e) {
843
+ t.unsubscribe(e);
844
+ },
845
+ hasSubscription(e) {
846
+ return t.hasSubscription(e);
847
+ },
848
+ subscriptions: e,
849
+ subscription: t
850
+ };
745
851
  }
746
- var extendVnode = (component, element) => {
747
- return new Proxy(access(component), {
748
- get: (target, key) => {
749
- const getVnode = () => {
750
- try {
751
- return target[key]();
752
- } catch {
753
- throw new Error(`${key} does not exist as vnode on component.`);
754
- }
755
- };
756
- const vnode = getVnode();
757
- return (props = {}, slots) => {
758
- const isFunctionClass = typeof props.class === "function";
759
- const isFunctionStyle = typeof props.style === "function";
760
- const { class: classes, style: styles, ...rest } = vnode.props ?? {};
761
- const finalClasses = twMerge(isFunctionClass ? "" : classes, MergeStyles(isFunctionClass ? props.class(classes) : props.class).string);
762
- const finalStyles = MergeStyles(styles, isFunctionStyle ? props.style(styles) : props.style);
763
- const functionalProps = Object.entries(props).reduce((props2, [key2, value]) => {
764
- if (!["class", "style", "setup"].includes(key2) && typeof value === "function") {
765
- props2[key2] = value(vnode.props?.[key2]);
766
- }
767
- return props2;
768
- }, props);
769
- const finalProps = Object.assign(rest, functionalProps, { class: finalClasses, style: finalStyles });
770
- const finalSlots = slots ? typeof slots === "function" ? slots(vnode.children) : slots : vnode.children;
771
- const finalElement = ["undefined"].includes(typeof element) ? vnode.type : element;
772
- return h(finalElement, finalProps, finalSlots);
773
- };
774
- }
775
- });
852
+ var H = ({ default: e, type: t, validator: n, required: r } = {}) => {
853
+ let i = Array.isArray(t) ? t : [t ?? Array], a = i.includes(Object) ? i : i.concat(Object);
854
+ return {
855
+ ...e ? { default: l(e) || c(e) ? e : g(e) } : {},
856
+ required: r,
857
+ validator: (e) => {
858
+ try {
859
+ return n ? n(b(e)) : Array.from(new Set(a.map((e) => typeof e == "function" ? e().constructor.name : e))).includes(b(e).constructor.name);
860
+ } catch {
861
+ return !r;
862
+ }
863
+ }
864
+ };
776
865
  };
777
- function defineReactiveView(param1, param2) {
778
- const instance = ref2();
779
- return defineComponent({
780
- name: param1?.modelName,
781
- props: { setup, ...param1 ? param1.props : {} },
782
- setup() {
783
- const { setup: setup2, props, ...rest } = param1 ?? {};
784
- return (component) => {
785
- const props2 = Object.entries(rest).reduce((props3, [key, val]) => {
786
- return Object.assign(props3, { [key]: typeof val === "function" ? val(component, instance) : val });
787
- }, {});
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
- } : {}),
794
- instance
795
- }, slots);
796
- };
797
- }
798
- });
866
+ function U(e = {}) {
867
+ let t = (e, t = !0) => e.split(/(-{[^}]+})/).reduce((e, n) => {
868
+ let r = /-{(.+?)}/.exec(n);
869
+ return (r ? r[1] ?? n : n).split(/\s+/).forEach((n) => {
870
+ n && Object.assign(e, { [n]: r ? !1 : t });
871
+ }), e;
872
+ }, {});
873
+ return Array.isArray(e) ? e.reduce((e, n) => Object.assign(t(n), e), {}) : typeof e == "string" ? t(e) : Object.entries(e).reduce((e, [n, r]) => ({
874
+ ...e,
875
+ ...t(n, r)
876
+ }), {});
799
877
  }
800
- function showComponent(component, options = {}) {
801
- if (options.router) {
802
- console.warn("[ReactiveView]: Deprecated {router} option used with {showComponent()}. \nUse {plugins} option instead.");
803
- }
804
- if (!options.key || !document.getElementById(options.key)) {
805
- const container = options.container || "app-dialogs";
806
- const dialogs = document.getElementById(container) || document.createElement("div");
807
- if (!dialogs.hasAttribute("id")) {
808
- dialogs.setAttribute("id", container);
809
- document.body.appendChild(dialogs);
810
- }
811
- const dialog = document.createElement("div");
812
- const id = options.key ?? `dialog_${dialogs.children.length + 1}`;
813
- dialog.setAttribute("id", id);
814
- dialogs.appendChild(dialog);
815
- const app = createApp(
816
- {
817
- setup() {
818
- return () => component;
819
- }
820
- },
821
- {
822
- __cleanup__: () => {
823
- document.querySelectorAll(`#${id}`).forEach((element) => element.remove());
824
- app.unmount();
825
- }
826
- }
827
- );
828
- if (options.router) {
829
- return app.use(options.router).mount(`#${id}`);
830
- } else if (options.plugins) {
831
- return options.plugins.reduce((app2, plugin) => {
832
- return app2.use(...Array.isArray(plugin) ? plugin : [plugin]);
833
- }, app).mount(`#${id}`);
834
- } else {
835
- return app.mount(`#${id}`);
836
- }
837
- }
878
+ function W(...e) {
879
+ return new Proxy(e.reduce((e, t, n, r) => {
880
+ let i = r[r.length - n - 1] ?? {};
881
+ return {
882
+ ...U(typeof i == "function" ? i(r.slice(0, n - 1)) : i),
883
+ ...e
884
+ };
885
+ }, {}), { get: (e, t, n) => {
886
+ let r = Object.entries(e).reduce((e, [t, n]) => n ? e.concat(t) : e, []);
887
+ return t === "string" ? r.join(" ") : t === "array" ? r : Reflect.get(e, t, n);
888
+ } });
838
889
  }
839
- var getData = (component, path, alternative) => {
840
- const vue = access(component);
841
- const data = ObjectManager2.on(componentState(vue));
842
- if (path) {
843
- return data.get(dataPath(vue, path), alternative);
844
- } else {
845
- return data.get();
846
- }
847
- };
848
- var setData = (component, data, path) => {
849
- const vue = access(component);
850
- const diff = {
851
- before: ObjectManager2.on(componentState(vue)).clone(),
852
- after: path ? ObjectManager2.on(componentState(vue)).set(dataPath(vue, path), data).get() : ObjectManager2.on(componentState(vue)).set(data).get()
853
- };
854
- return "state" in vue ? diff : vue.$emit("update:state", diff);
855
- };
856
- var componentState = (component) => {
857
- return unref2("state" in component ? component.state : component.$attrs.state);
858
- };
859
- var dataPath = (component, path) => {
860
- return typeof component.$attrs["data:path"] === "function" ? component.$attrs["data:path"](path) : path;
861
- };
862
- export {
863
- MergeStyles,
864
- Prop,
865
- StyleParser,
866
- access,
867
- dataPath,
868
- index_default as default,
869
- defineReactiveView,
870
- extendVnode,
871
- getData,
872
- getDate,
873
- getProps,
874
- getReactiveViewComponent,
875
- safeRequest,
876
- setData,
877
- setup,
878
- showComponent,
879
- useSubscription
880
- };
890
+ var G = (e, t) => new Proxy(B(e), { get: (e, n) => {
891
+ let r = (() => {
892
+ try {
893
+ return e[n]();
894
+ } catch {
895
+ throw Error(`${n} does not exist as vnode on component.`);
896
+ }
897
+ })();
898
+ return (e = {}, n) => {
899
+ let i = typeof e.class == "function", a = typeof e.style == "function", { class: o, style: c, ...l } = r.props ?? {}, u = w(i ? "" : o, W(i ? e.class(o) : e.class).string), d = W(c, a ? e.style(c) : e.style), f = Object.entries(e).reduce((e, [t, n]) => (![
900
+ "class",
901
+ "style",
902
+ "setup"
903
+ ].includes(t) && typeof n == "function" && (e[t] = n(r.props?.[t])), e), e), p = Object.assign(l, f, {
904
+ class: u,
905
+ style: d
906
+ }), m = n ? typeof n == "function" ? n(r.children) : n : r.children;
907
+ return s(["undefined"].includes(typeof t) ? r.type : t, p, m);
908
+ };
909
+ } });
910
+ function K(e, t) {
911
+ let n = g();
912
+ return a({
913
+ name: e?.modelName,
914
+ props: {
915
+ setup: O,
916
+ ...e ? e.props : {}
917
+ },
918
+ setup() {
919
+ let { setup: r, props: a, ...o } = e ?? {};
920
+ return (a) => {
921
+ let s = Object.entries(o).reduce((e, [t, r]) => Object.assign(e, { [t]: typeof r == "function" ? r(a, n) : r }), {}), c = typeof e?.slots == "function" ? e.slots(a) : Array.isArray(e?.slots) ? () => e.slots : e?.slots;
922
+ return i(t ?? k, {
923
+ ...s,
924
+ ...Object.assign({}, s, typeof r == "function" ? { setup: (e, t) => r(e, t, a) } : {}),
925
+ instance: n
926
+ }, c);
927
+ };
928
+ }
929
+ });
930
+ }
931
+ var q = (e, t, n) => {
932
+ let r = B(e), i = P.on(Y(r));
933
+ return t ? i.get(X(r, t), n) : i.get();
934
+ }, J = (e, t, n) => {
935
+ let r = B(e), i = {
936
+ before: P.on(Y(r)).clone(),
937
+ after: n ? P.on(Y(r)).set(X(r, n), t).get() : P.on(Y(r)).set(t).get()
938
+ };
939
+ return "state" in r ? i : r.$emit("update:state", i);
940
+ }, Y = (e) => b("state" in e ? e.state : e.$attrs.state), X = (e, t) => typeof e.$attrs["data:path"] == "function" ? e.$attrs["data:path"](t) : t;
941
+ //#endregion
942
+ export { N as CustomAlert, j as CustomButton, M as CustomModal, W as MergeStyles, H as Prop, U as StyleParser, B as access, X as dataPath, F as default, K as defineReactiveView, G as extendVnode, q as getData, z as getDate, L as getProps, R as getReactiveViewComponent, I as safeRequest, J as setData, O as setup, A as showComponent, V as useSubscription };