@razaman2/reactive-view 0.0.29 → 0.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +39 -21
- package/dist/index.mjs +37 -19
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -38,6 +38,7 @@ type PropExclusions = Array<string> | string;
|
|
|
38
38
|
declare const setup: {
|
|
39
39
|
type: FunctionConstructor;
|
|
40
40
|
default: (parent?: {}, self?: {}) => {};
|
|
41
|
+
ReactiveView: boolean;
|
|
41
42
|
};
|
|
42
43
|
declare const _default: {
|
|
43
44
|
props: {
|
|
@@ -104,7 +105,7 @@ declare function getDate(timestamp: {
|
|
|
104
105
|
timezone?: string;
|
|
105
106
|
}): string;
|
|
106
107
|
declare function access(view?: ComponentExtension | UnwrapRef<any> | (() => ComponentExtension), alternative?: any): any;
|
|
107
|
-
declare function
|
|
108
|
+
declare function useSubscription(): {
|
|
108
109
|
addSubscription(name: string, handler?: () => boolean, data?: any): void;
|
|
109
110
|
replaceSubscription(name: string, handler?: () => boolean, data?: any): void;
|
|
110
111
|
removeSubscriptions(): void;
|
|
@@ -116,4 +117,4 @@ declare function getSubscription(): {
|
|
|
116
117
|
declare function StyleParser(styles?: Array<string> | Record<string, boolean> | string): {};
|
|
117
118
|
declare function MergeStyles(...params: any): any;
|
|
118
119
|
|
|
119
|
-
export { MergeStyles, StyleParser, access, _default as default, getDate, getProps, getReactiveViewComponent,
|
|
120
|
+
export { MergeStyles, StyleParser, access, _default as default, getDate, getProps, getReactiveViewComponent, safeRequest, setup, useSubscription };
|
package/dist/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ type PropExclusions = Array<string> | string;
|
|
|
38
38
|
declare const setup: {
|
|
39
39
|
type: FunctionConstructor;
|
|
40
40
|
default: (parent?: {}, self?: {}) => {};
|
|
41
|
+
ReactiveView: boolean;
|
|
41
42
|
};
|
|
42
43
|
declare const _default: {
|
|
43
44
|
props: {
|
|
@@ -104,7 +105,7 @@ declare function getDate(timestamp: {
|
|
|
104
105
|
timezone?: string;
|
|
105
106
|
}): string;
|
|
106
107
|
declare function access(view?: ComponentExtension | UnwrapRef<any> | (() => ComponentExtension), alternative?: any): any;
|
|
107
|
-
declare function
|
|
108
|
+
declare function useSubscription(): {
|
|
108
109
|
addSubscription(name: string, handler?: () => boolean, data?: any): void;
|
|
109
110
|
replaceSubscription(name: string, handler?: () => boolean, data?: any): void;
|
|
110
111
|
removeSubscriptions(): void;
|
|
@@ -116,4 +117,4 @@ declare function getSubscription(): {
|
|
|
116
117
|
declare function StyleParser(styles?: Array<string> | Record<string, boolean> | string): {};
|
|
117
118
|
declare function MergeStyles(...params: any): any;
|
|
118
119
|
|
|
119
|
-
export { MergeStyles, StyleParser, access, _default as default, getDate, getProps, getReactiveViewComponent,
|
|
120
|
+
export { MergeStyles, StyleParser, access, _default as default, getDate, getProps, getReactiveViewComponent, safeRequest, setup, useSubscription };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
6
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
@@ -21,7 +19,6 @@ var __spreadValues = (a, b) => {
|
|
|
21
19
|
}
|
|
22
20
|
return a;
|
|
23
21
|
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
22
|
var __export = (target, all) => {
|
|
26
23
|
for (var name2 in all)
|
|
27
24
|
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
@@ -54,9 +51,9 @@ __export(index_exports, {
|
|
|
54
51
|
getDate: () => getDate,
|
|
55
52
|
getProps: () => getProps,
|
|
56
53
|
getReactiveViewComponent: () => getReactiveViewComponent,
|
|
57
|
-
getSubscription: () => getSubscription,
|
|
58
54
|
safeRequest: () => safeRequest,
|
|
59
|
-
setup: () => setup
|
|
55
|
+
setup: () => setup,
|
|
56
|
+
useSubscription: () => useSubscription
|
|
60
57
|
});
|
|
61
58
|
module.exports = __toCommonJS(index_exports);
|
|
62
59
|
var import_date_fns_tz = require("date-fns-tz");
|
|
@@ -159,12 +156,13 @@ var import_vue = require("vue");
|
|
|
159
156
|
|
|
160
157
|
// package.json
|
|
161
158
|
var name = "@razaman2/reactive-view";
|
|
162
|
-
var version = "0.0.
|
|
159
|
+
var version = "0.0.30";
|
|
163
160
|
|
|
164
161
|
// src/ReactiveView.ts
|
|
165
162
|
var setup = {
|
|
166
163
|
type: Function,
|
|
167
|
-
default: (parent = {}, self = {}) => self
|
|
164
|
+
default: (parent = {}, self = {}) => self,
|
|
165
|
+
ReactiveView: true
|
|
168
166
|
};
|
|
169
167
|
var ReactiveView_default = {
|
|
170
168
|
props: {
|
|
@@ -238,7 +236,7 @@ var ReactiveView_default = {
|
|
|
238
236
|
const datatype = Array.isArray(defaultData) ? [] : {};
|
|
239
237
|
const config = {
|
|
240
238
|
data: (0, import_vue.reactive)(
|
|
241
|
-
import_object_manager.default.on(async ? datatype : ((_f = vue.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? data : datatype).clone()
|
|
239
|
+
import_object_manager.default.on(async ? datatype : ((_f = vue.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? typeof data === "function" ? datatype : data : datatype).clone()
|
|
242
240
|
),
|
|
243
241
|
defaultData: import_object_manager.default.on(defaultData).clone(),
|
|
244
242
|
notifications: props.notifications,
|
|
@@ -253,7 +251,7 @@ var ReactiveView_default = {
|
|
|
253
251
|
var _a2;
|
|
254
252
|
const beforeSetData = (_a2 = access(component).beforeSetData) != null ? _a2 : props.beforeSetData;
|
|
255
253
|
if (typeof beforeSetData === "function") {
|
|
256
|
-
const after = import_object_manager.default.on(datatype).set(...params).get();
|
|
254
|
+
const after = import_object_manager.default.on(datatype).set(...params.length ? params : [defaultData]).get();
|
|
257
255
|
const before = target.getData();
|
|
258
256
|
beforeSetData({ before, after }, target);
|
|
259
257
|
} else {
|
|
@@ -314,7 +312,7 @@ var ReactiveView_default = {
|
|
|
314
312
|
}
|
|
315
313
|
return options;
|
|
316
314
|
}, component.value);
|
|
317
|
-
props.instance.value = component.value;
|
|
315
|
+
props.instance.value = typeof props.instance === "function" ? props.instance(component.value) : component.value;
|
|
318
316
|
return (vue2) => {
|
|
319
317
|
if (ready.value) {
|
|
320
318
|
return access(component).template(component, vue2);
|
|
@@ -428,7 +426,7 @@ function access(view = {}, alternative) {
|
|
|
428
426
|
return resolve(view);
|
|
429
427
|
}
|
|
430
428
|
}
|
|
431
|
-
function
|
|
429
|
+
function useSubscription() {
|
|
432
430
|
const subscriptions = [];
|
|
433
431
|
const subscription = Subscriptions.get();
|
|
434
432
|
return {
|
|
@@ -456,19 +454,39 @@ function getSubscription() {
|
|
|
456
454
|
};
|
|
457
455
|
}
|
|
458
456
|
function StyleParser(styles = {}) {
|
|
459
|
-
const transform = (style, status = true) =>
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
457
|
+
const transform = (style, status = true) => {
|
|
458
|
+
const remove = style.split(/(-{[^}]+})/);
|
|
459
|
+
return remove.reduce((object, style2) => {
|
|
460
|
+
var _a;
|
|
461
|
+
const remove2 = /-{(.+?)}/.exec(style2);
|
|
462
|
+
(remove2 ? (_a = remove2[1]) != null ? _a : style2 : style2).split(/\s+/).forEach((item) => {
|
|
463
|
+
if (item) {
|
|
464
|
+
Object.assign(object, { [item]: remove2 ? false : status });
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
return object;
|
|
468
|
+
}, {});
|
|
469
|
+
};
|
|
464
470
|
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]) => {
|
|
465
471
|
return __spreadValues(__spreadValues({}, acc), transform(styles2, value));
|
|
466
472
|
}, {});
|
|
467
473
|
}
|
|
468
474
|
function MergeStyles(...params) {
|
|
469
|
-
return params.reduce((styles, style, index,
|
|
470
|
-
|
|
471
|
-
|
|
475
|
+
return new Proxy(params.reduce((styles, style, index, items) => {
|
|
476
|
+
var _a;
|
|
477
|
+
const item = (_a = items[items.length - index - 1]) != null ? _a : {};
|
|
478
|
+
return __spreadValues(__spreadValues({}, StyleParser(typeof item === "function" ? item(items.slice(0, index - 1)) : item)), styles);
|
|
479
|
+
}, {}), {
|
|
480
|
+
get: (target, key, receiver) => {
|
|
481
|
+
if (key === "string") {
|
|
482
|
+
return Object.entries(target).reduce((styles, [key2, val]) => {
|
|
483
|
+
return val ? styles.concat(key2) : styles;
|
|
484
|
+
}, []).join(" ");
|
|
485
|
+
} else {
|
|
486
|
+
return Reflect.get(target, key, receiver);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
});
|
|
472
490
|
}
|
|
473
491
|
// Annotate the CommonJS export names for ESM import in node:
|
|
474
492
|
0 && (module.exports = {
|
|
@@ -478,7 +496,7 @@ function MergeStyles(...params) {
|
|
|
478
496
|
getDate,
|
|
479
497
|
getProps,
|
|
480
498
|
getReactiveViewComponent,
|
|
481
|
-
getSubscription,
|
|
482
499
|
safeRequest,
|
|
483
|
-
setup
|
|
500
|
+
setup,
|
|
501
|
+
useSubscription
|
|
484
502
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
2
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
3
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
4
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -16,7 +14,6 @@ var __spreadValues = (a, b) => {
|
|
|
16
14
|
}
|
|
17
15
|
return a;
|
|
18
16
|
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
17
|
|
|
21
18
|
// src/index.ts
|
|
22
19
|
import { formatInTimeZone } from "date-fns-tz";
|
|
@@ -119,12 +116,13 @@ import { ref, reactive, watch, isRef, isReactive, createVNode, getCurrentInstanc
|
|
|
119
116
|
|
|
120
117
|
// package.json
|
|
121
118
|
var name = "@razaman2/reactive-view";
|
|
122
|
-
var version = "0.0.
|
|
119
|
+
var version = "0.0.30";
|
|
123
120
|
|
|
124
121
|
// src/ReactiveView.ts
|
|
125
122
|
var setup = {
|
|
126
123
|
type: Function,
|
|
127
|
-
default: (parent = {}, self = {}) => self
|
|
124
|
+
default: (parent = {}, self = {}) => self,
|
|
125
|
+
ReactiveView: true
|
|
128
126
|
};
|
|
129
127
|
var ReactiveView_default = {
|
|
130
128
|
props: {
|
|
@@ -198,7 +196,7 @@ var ReactiveView_default = {
|
|
|
198
196
|
const datatype = Array.isArray(defaultData) ? [] : {};
|
|
199
197
|
const config = {
|
|
200
198
|
data: reactive(
|
|
201
|
-
ObjectManager.on(async ? datatype : ((_f = vue.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? data : datatype).clone()
|
|
199
|
+
ObjectManager.on(async ? datatype : ((_f = vue.vnode.props) == null ? void 0 : _f.hasOwnProperty("data")) ? typeof data === "function" ? datatype : data : datatype).clone()
|
|
202
200
|
),
|
|
203
201
|
defaultData: ObjectManager.on(defaultData).clone(),
|
|
204
202
|
notifications: props.notifications,
|
|
@@ -213,7 +211,7 @@ var ReactiveView_default = {
|
|
|
213
211
|
var _a2;
|
|
214
212
|
const beforeSetData = (_a2 = access(component).beforeSetData) != null ? _a2 : props.beforeSetData;
|
|
215
213
|
if (typeof beforeSetData === "function") {
|
|
216
|
-
const after = ObjectManager.on(datatype).set(...params).get();
|
|
214
|
+
const after = ObjectManager.on(datatype).set(...params.length ? params : [defaultData]).get();
|
|
217
215
|
const before = target.getData();
|
|
218
216
|
beforeSetData({ before, after }, target);
|
|
219
217
|
} else {
|
|
@@ -274,7 +272,7 @@ var ReactiveView_default = {
|
|
|
274
272
|
}
|
|
275
273
|
return options;
|
|
276
274
|
}, component.value);
|
|
277
|
-
props.instance.value = component.value;
|
|
275
|
+
props.instance.value = typeof props.instance === "function" ? props.instance(component.value) : component.value;
|
|
278
276
|
return (vue2) => {
|
|
279
277
|
if (ready.value) {
|
|
280
278
|
return access(component).template(component, vue2);
|
|
@@ -388,7 +386,7 @@ function access(view = {}, alternative) {
|
|
|
388
386
|
return resolve(view);
|
|
389
387
|
}
|
|
390
388
|
}
|
|
391
|
-
function
|
|
389
|
+
function useSubscription() {
|
|
392
390
|
const subscriptions = [];
|
|
393
391
|
const subscription = Subscriptions.get();
|
|
394
392
|
return {
|
|
@@ -416,19 +414,39 @@ function getSubscription() {
|
|
|
416
414
|
};
|
|
417
415
|
}
|
|
418
416
|
function StyleParser(styles = {}) {
|
|
419
|
-
const transform = (style, status = true) =>
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
417
|
+
const transform = (style, status = true) => {
|
|
418
|
+
const remove = style.split(/(-{[^}]+})/);
|
|
419
|
+
return remove.reduce((object, style2) => {
|
|
420
|
+
var _a;
|
|
421
|
+
const remove2 = /-{(.+?)}/.exec(style2);
|
|
422
|
+
(remove2 ? (_a = remove2[1]) != null ? _a : style2 : style2).split(/\s+/).forEach((item) => {
|
|
423
|
+
if (item) {
|
|
424
|
+
Object.assign(object, { [item]: remove2 ? false : status });
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
return object;
|
|
428
|
+
}, {});
|
|
429
|
+
};
|
|
424
430
|
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]) => {
|
|
425
431
|
return __spreadValues(__spreadValues({}, acc), transform(styles2, value));
|
|
426
432
|
}, {});
|
|
427
433
|
}
|
|
428
434
|
function MergeStyles(...params) {
|
|
429
|
-
return params.reduce((styles, style, index,
|
|
430
|
-
|
|
431
|
-
|
|
435
|
+
return new Proxy(params.reduce((styles, style, index, items) => {
|
|
436
|
+
var _a;
|
|
437
|
+
const item = (_a = items[items.length - index - 1]) != null ? _a : {};
|
|
438
|
+
return __spreadValues(__spreadValues({}, StyleParser(typeof item === "function" ? item(items.slice(0, index - 1)) : item)), styles);
|
|
439
|
+
}, {}), {
|
|
440
|
+
get: (target, key, receiver) => {
|
|
441
|
+
if (key === "string") {
|
|
442
|
+
return Object.entries(target).reduce((styles, [key2, val]) => {
|
|
443
|
+
return val ? styles.concat(key2) : styles;
|
|
444
|
+
}, []).join(" ");
|
|
445
|
+
} else {
|
|
446
|
+
return Reflect.get(target, key, receiver);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
});
|
|
432
450
|
}
|
|
433
451
|
export {
|
|
434
452
|
MergeStyles,
|
|
@@ -438,7 +456,7 @@ export {
|
|
|
438
456
|
getDate,
|
|
439
457
|
getProps,
|
|
440
458
|
getReactiveViewComponent,
|
|
441
|
-
getSubscription,
|
|
442
459
|
safeRequest,
|
|
443
|
-
setup
|
|
460
|
+
setup,
|
|
461
|
+
useSubscription
|
|
444
462
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razaman2/reactive-view",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.30",
|
|
4
4
|
"description": "This library enables you to build vue apps in an object oriented way. It provides a convenient approach to extend and override ui components. It provides a built in eventing system along with component data management.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|