@razaman2/reactive-view 0.0.31 → 0.0.33
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 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +65 -8
- package/dist/index.mjs +65 -9
- package/package.json +46 -45
package/dist/index.d.mts
CHANGED
|
@@ -44,6 +44,7 @@ declare const _default: {
|
|
|
44
44
|
props: {
|
|
45
45
|
setup: {};
|
|
46
46
|
ReactiveView: {
|
|
47
|
+
type: BooleanConstructor;
|
|
47
48
|
default: boolean;
|
|
48
49
|
};
|
|
49
50
|
instance: {
|
|
@@ -115,5 +116,6 @@ declare function useSubscription(): {
|
|
|
115
116
|
};
|
|
116
117
|
declare function StyleParser(styles?: Array<string> | Record<string, boolean> | string): {};
|
|
117
118
|
declare function MergeStyles(...params: any): any;
|
|
119
|
+
declare const extendVnode: (component: Record<string, any>, element: any) => Record<string, (props?: Record<string, any>, slots?: Record<string, any> | ((slots: Record<string, any>) => Record<string, any>)) => any>;
|
|
118
120
|
|
|
119
|
-
export { MergeStyles, StyleParser, access, _default as default, getDate, getProps, getReactiveViewComponent, safeRequest, setup, useSubscription };
|
|
121
|
+
export { MergeStyles, StyleParser, access, _default as default, extendVnode, getDate, getProps, getReactiveViewComponent, safeRequest, setup, useSubscription };
|
package/dist/index.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ declare const _default: {
|
|
|
44
44
|
props: {
|
|
45
45
|
setup: {};
|
|
46
46
|
ReactiveView: {
|
|
47
|
+
type: BooleanConstructor;
|
|
47
48
|
default: boolean;
|
|
48
49
|
};
|
|
49
50
|
instance: {
|
|
@@ -115,5 +116,6 @@ declare function useSubscription(): {
|
|
|
115
116
|
};
|
|
116
117
|
declare function StyleParser(styles?: Array<string> | Record<string, boolean> | string): {};
|
|
117
118
|
declare function MergeStyles(...params: any): any;
|
|
119
|
+
declare const extendVnode: (component: Record<string, any>, element: any) => Record<string, (props?: Record<string, any>, slots?: Record<string, any> | ((slots: Record<string, any>) => Record<string, any>)) => any>;
|
|
118
120
|
|
|
119
|
-
export { MergeStyles, StyleParser, access, _default as default, getDate, getProps, getReactiveViewComponent, safeRequest, setup, useSubscription };
|
|
121
|
+
export { MergeStyles, StyleParser, access, _default as default, extendVnode, getDate, getProps, getReactiveViewComponent, safeRequest, setup, useSubscription };
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,18 @@ var __spreadValues = (a, b) => {
|
|
|
19
19
|
}
|
|
20
20
|
return a;
|
|
21
21
|
};
|
|
22
|
+
var __objRest = (source, exclude) => {
|
|
23
|
+
var target = {};
|
|
24
|
+
for (var prop in source)
|
|
25
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
26
|
+
target[prop] = source[prop];
|
|
27
|
+
if (source != null && __getOwnPropSymbols)
|
|
28
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
29
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
30
|
+
target[prop] = source[prop];
|
|
31
|
+
}
|
|
32
|
+
return target;
|
|
33
|
+
};
|
|
22
34
|
var __export = (target, all) => {
|
|
23
35
|
for (var name2 in all)
|
|
24
36
|
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
@@ -48,6 +60,7 @@ __export(index_exports, {
|
|
|
48
60
|
StyleParser: () => StyleParser,
|
|
49
61
|
access: () => access,
|
|
50
62
|
default: () => index_default,
|
|
63
|
+
extendVnode: () => extendVnode,
|
|
51
64
|
getDate: () => getDate,
|
|
52
65
|
getProps: () => getProps,
|
|
53
66
|
getReactiveViewComponent: () => getReactiveViewComponent,
|
|
@@ -155,7 +168,7 @@ var import_vue = require("vue");
|
|
|
155
168
|
|
|
156
169
|
// package.json
|
|
157
170
|
var name = "@razaman2/reactive-view";
|
|
158
|
-
var version = "0.0.
|
|
171
|
+
var version = "0.0.33";
|
|
159
172
|
|
|
160
173
|
// src/ReactiveView.ts
|
|
161
174
|
var setup = {
|
|
@@ -167,6 +180,7 @@ var ReactiveView_default = {
|
|
|
167
180
|
props: {
|
|
168
181
|
setup: {},
|
|
169
182
|
ReactiveView: {
|
|
183
|
+
type: Boolean,
|
|
170
184
|
default: true
|
|
171
185
|
},
|
|
172
186
|
instance: {
|
|
@@ -207,7 +221,7 @@ var ReactiveView_default = {
|
|
|
207
221
|
context.slots.default ? context.attrs : __spreadValues({
|
|
208
222
|
style: { color: "red", textAlign: "center" }
|
|
209
223
|
}, context.attrs),
|
|
210
|
-
context.slots.default ? context.slots.default({
|
|
224
|
+
context.slots.default ? context.slots.default({ component: component2, vue: vue2, props, context }) : `${props.modelName}: ${name}@${version}`
|
|
211
225
|
);
|
|
212
226
|
};
|
|
213
227
|
const isValid = (0, import_vue.ref)(false);
|
|
@@ -257,15 +271,23 @@ var ReactiveView_default = {
|
|
|
257
271
|
}
|
|
258
272
|
});
|
|
259
273
|
const watchDataProp = (dataProp) => {
|
|
260
|
-
var _a2;
|
|
261
|
-
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? {
|
|
262
|
-
callback: context.attrs["onUpdate:data"]
|
|
263
|
-
|
|
274
|
+
var _a2, _b2, _c2;
|
|
275
|
+
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? { callback: context.attrs["onUpdate:data"] } : {
|
|
276
|
+
callback: (_b2 = ((_a2 = context.attrs["onUpdate:data"]) != null ? _a2 : {}).callback) != null ? _b2 : context.attrs["data:callback"],
|
|
277
|
+
options: Object.assign({
|
|
278
|
+
immediate: context.attrs["data:immediate"],
|
|
279
|
+
deep: context.attrs["data:deep"],
|
|
280
|
+
once: context.attrs["data:once"]
|
|
281
|
+
}, ((_c2 = context.attrs["onUpdate:data"]) != null ? _c2 : {}).options)
|
|
282
|
+
};
|
|
283
|
+
if (context.attrs["data:log"]) {
|
|
284
|
+
console.log(`[data:prop]:`, config2);
|
|
285
|
+
}
|
|
264
286
|
(0, import_vue.watch)(typeof dataProp === "function" || (0, import_vue.isRef)(dataProp) || (0, import_vue.isReactive)(dataProp) ? dataProp : () => dataProp, (after, before) => {
|
|
265
287
|
var _a3;
|
|
266
288
|
const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
|
|
267
289
|
if (typeof config2.callback === "function") {
|
|
268
|
-
model.replaceData((_a3 = config2.callback(diff,
|
|
290
|
+
model.replaceData((_a3 = config2.callback(diff, { component })) != null ? _a3 : after);
|
|
269
291
|
} else {
|
|
270
292
|
model.replaceData(after);
|
|
271
293
|
}
|
|
@@ -286,7 +308,7 @@ var ReactiveView_default = {
|
|
|
286
308
|
} : (_g = context.attrs["onUpdate:model"]) != null ? _g : {};
|
|
287
309
|
(0, import_vue.watch)(() => model.getData(), (after, before) => {
|
|
288
310
|
const diff = { before: import_object_manager.default.on(before).get(), after: import_object_manager.default.on(after).get() };
|
|
289
|
-
config2.callback(diff,
|
|
311
|
+
config2.callback(diff, { component });
|
|
290
312
|
}, config2.options);
|
|
291
313
|
}
|
|
292
314
|
const component = (0, import_vue.ref)({ parent: { self: vue.proxy }, self: { template, model, isValid } });
|
|
@@ -488,11 +510,46 @@ function MergeStyles(...params) {
|
|
|
488
510
|
}
|
|
489
511
|
});
|
|
490
512
|
}
|
|
513
|
+
var extendVnode = (component, element) => {
|
|
514
|
+
return new Proxy(access(component), {
|
|
515
|
+
get: (target, key) => {
|
|
516
|
+
const getVnode = () => {
|
|
517
|
+
try {
|
|
518
|
+
return target[key]();
|
|
519
|
+
} catch (e) {
|
|
520
|
+
throw new Error(`${key} does not exist as vnode on component.`);
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
const vnode = getVnode();
|
|
524
|
+
return (props = {}, slots) => {
|
|
525
|
+
var _a;
|
|
526
|
+
const _b = getProps((_a = vnode.props) != null ? _a : {}, []), { class: classes, style: styles } = _b, rest = __objRest(_b, ["class", "style"]);
|
|
527
|
+
const finalClasses = MergeStyles(classes, typeof props.class === "function" ? props.class(classes) : props.class);
|
|
528
|
+
const functionalProps = Object.entries(props).reduce((props2, [key2, value]) => {
|
|
529
|
+
if (![
|
|
530
|
+
"class"
|
|
531
|
+
/*, "style"*/
|
|
532
|
+
].includes(key2) && typeof value === "function") {
|
|
533
|
+
props2[key2] = value(vnode.props[key2]);
|
|
534
|
+
}
|
|
535
|
+
return props2;
|
|
536
|
+
}, props);
|
|
537
|
+
const finalProps = Object.assign(rest, functionalProps, {
|
|
538
|
+
class: finalClasses
|
|
539
|
+
/*, style: finalStyles*/
|
|
540
|
+
});
|
|
541
|
+
const finalSlots = typeof slots === "function" ? slots(vnode.children) : vnode.children;
|
|
542
|
+
return (0, import_vue2.h)(["string", "undefined"].includes(typeof element) ? vnode : element, finalProps, finalSlots);
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
};
|
|
491
547
|
// Annotate the CommonJS export names for ESM import in node:
|
|
492
548
|
0 && (module.exports = {
|
|
493
549
|
MergeStyles,
|
|
494
550
|
StyleParser,
|
|
495
551
|
access,
|
|
552
|
+
extendVnode,
|
|
496
553
|
getDate,
|
|
497
554
|
getProps,
|
|
498
555
|
getReactiveViewComponent,
|
package/dist/index.mjs
CHANGED
|
@@ -14,6 +14,18 @@ var __spreadValues = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
+
var __objRest = (source, exclude) => {
|
|
18
|
+
var target = {};
|
|
19
|
+
for (var prop in source)
|
|
20
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
21
|
+
target[prop] = source[prop];
|
|
22
|
+
if (source != null && __getOwnPropSymbols)
|
|
23
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
24
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
17
29
|
|
|
18
30
|
// src/Subscription.ts
|
|
19
31
|
var Subscription = class _Subscription {
|
|
@@ -113,7 +125,7 @@ import { ref, reactive, watch, isRef, isReactive, createVNode, getCurrentInstanc
|
|
|
113
125
|
|
|
114
126
|
// package.json
|
|
115
127
|
var name = "@razaman2/reactive-view";
|
|
116
|
-
var version = "0.0.
|
|
128
|
+
var version = "0.0.33";
|
|
117
129
|
|
|
118
130
|
// src/ReactiveView.ts
|
|
119
131
|
var setup = {
|
|
@@ -125,6 +137,7 @@ var ReactiveView_default = {
|
|
|
125
137
|
props: {
|
|
126
138
|
setup: {},
|
|
127
139
|
ReactiveView: {
|
|
140
|
+
type: Boolean,
|
|
128
141
|
default: true
|
|
129
142
|
},
|
|
130
143
|
instance: {
|
|
@@ -165,7 +178,7 @@ var ReactiveView_default = {
|
|
|
165
178
|
context.slots.default ? context.attrs : __spreadValues({
|
|
166
179
|
style: { color: "red", textAlign: "center" }
|
|
167
180
|
}, context.attrs),
|
|
168
|
-
context.slots.default ? context.slots.default({
|
|
181
|
+
context.slots.default ? context.slots.default({ component: component2, vue: vue2, props, context }) : `${props.modelName}: ${name}@${version}`
|
|
169
182
|
);
|
|
170
183
|
};
|
|
171
184
|
const isValid = ref(false);
|
|
@@ -215,15 +228,23 @@ var ReactiveView_default = {
|
|
|
215
228
|
}
|
|
216
229
|
});
|
|
217
230
|
const watchDataProp = (dataProp) => {
|
|
218
|
-
var _a2;
|
|
219
|
-
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? {
|
|
220
|
-
callback: context.attrs["onUpdate:data"]
|
|
221
|
-
|
|
231
|
+
var _a2, _b2, _c2;
|
|
232
|
+
const config2 = typeof context.attrs["onUpdate:data"] === "function" ? { callback: context.attrs["onUpdate:data"] } : {
|
|
233
|
+
callback: (_b2 = ((_a2 = context.attrs["onUpdate:data"]) != null ? _a2 : {}).callback) != null ? _b2 : context.attrs["data:callback"],
|
|
234
|
+
options: Object.assign({
|
|
235
|
+
immediate: context.attrs["data:immediate"],
|
|
236
|
+
deep: context.attrs["data:deep"],
|
|
237
|
+
once: context.attrs["data:once"]
|
|
238
|
+
}, ((_c2 = context.attrs["onUpdate:data"]) != null ? _c2 : {}).options)
|
|
239
|
+
};
|
|
240
|
+
if (context.attrs["data:log"]) {
|
|
241
|
+
console.log(`[data:prop]:`, config2);
|
|
242
|
+
}
|
|
222
243
|
watch(typeof dataProp === "function" || isRef(dataProp) || isReactive(dataProp) ? dataProp : () => dataProp, (after, before) => {
|
|
223
244
|
var _a3;
|
|
224
245
|
const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
|
|
225
246
|
if (typeof config2.callback === "function") {
|
|
226
|
-
model.replaceData((_a3 = config2.callback(diff,
|
|
247
|
+
model.replaceData((_a3 = config2.callback(diff, { component })) != null ? _a3 : after);
|
|
227
248
|
} else {
|
|
228
249
|
model.replaceData(after);
|
|
229
250
|
}
|
|
@@ -244,7 +265,7 @@ var ReactiveView_default = {
|
|
|
244
265
|
} : (_g = context.attrs["onUpdate:model"]) != null ? _g : {};
|
|
245
266
|
watch(() => model.getData(), (after, before) => {
|
|
246
267
|
const diff = { before: ObjectManager.on(before).get(), after: ObjectManager.on(after).get() };
|
|
247
|
-
config2.callback(diff,
|
|
268
|
+
config2.callback(diff, { component });
|
|
248
269
|
}, config2.options);
|
|
249
270
|
}
|
|
250
271
|
const component = ref({ parent: { self: vue.proxy }, self: { template, model, isValid } });
|
|
@@ -277,7 +298,7 @@ var ReactiveView_default = {
|
|
|
277
298
|
};
|
|
278
299
|
|
|
279
300
|
// src/index.ts
|
|
280
|
-
import { createVNode as createVNode2, isRef as isRef2 } from "vue";
|
|
301
|
+
import { createVNode as createVNode2, isRef as isRef2, h } from "vue";
|
|
281
302
|
import { formatInTimeZone } from "date-fns-tz";
|
|
282
303
|
var index_default = ReactiveView_default;
|
|
283
304
|
function safeRequest(request) {
|
|
@@ -446,11 +467,46 @@ function MergeStyles(...params) {
|
|
|
446
467
|
}
|
|
447
468
|
});
|
|
448
469
|
}
|
|
470
|
+
var extendVnode = (component, element) => {
|
|
471
|
+
return new Proxy(access(component), {
|
|
472
|
+
get: (target, key) => {
|
|
473
|
+
const getVnode = () => {
|
|
474
|
+
try {
|
|
475
|
+
return target[key]();
|
|
476
|
+
} catch (e) {
|
|
477
|
+
throw new Error(`${key} does not exist as vnode on component.`);
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
const vnode = getVnode();
|
|
481
|
+
return (props = {}, slots) => {
|
|
482
|
+
var _a;
|
|
483
|
+
const _b = getProps((_a = vnode.props) != null ? _a : {}, []), { class: classes, style: styles } = _b, rest = __objRest(_b, ["class", "style"]);
|
|
484
|
+
const finalClasses = MergeStyles(classes, typeof props.class === "function" ? props.class(classes) : props.class);
|
|
485
|
+
const functionalProps = Object.entries(props).reduce((props2, [key2, value]) => {
|
|
486
|
+
if (![
|
|
487
|
+
"class"
|
|
488
|
+
/*, "style"*/
|
|
489
|
+
].includes(key2) && typeof value === "function") {
|
|
490
|
+
props2[key2] = value(vnode.props[key2]);
|
|
491
|
+
}
|
|
492
|
+
return props2;
|
|
493
|
+
}, props);
|
|
494
|
+
const finalProps = Object.assign(rest, functionalProps, {
|
|
495
|
+
class: finalClasses
|
|
496
|
+
/*, style: finalStyles*/
|
|
497
|
+
});
|
|
498
|
+
const finalSlots = typeof slots === "function" ? slots(vnode.children) : vnode.children;
|
|
499
|
+
return h(["string", "undefined"].includes(typeof element) ? vnode : element, finalProps, finalSlots);
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
};
|
|
449
504
|
export {
|
|
450
505
|
MergeStyles,
|
|
451
506
|
StyleParser,
|
|
452
507
|
access,
|
|
453
508
|
index_default as default,
|
|
509
|
+
extendVnode,
|
|
454
510
|
getDate,
|
|
455
511
|
getProps,
|
|
456
512
|
getReactiveViewComponent,
|
package/package.json
CHANGED
|
@@ -1,45 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@razaman2/reactive-view",
|
|
3
|
-
"version": "0.0.
|
|
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
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.mjs",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"prepublishOnly": "npm run build",
|
|
10
|
-
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
11
|
-
"lint": "tsc",
|
|
12
|
-
"test": "cd tests/vue-ts && npm run dev"
|
|
13
|
-
},
|
|
14
|
-
"keywords": [
|
|
15
|
-
"vue",
|
|
16
|
-
"vue-helper",
|
|
17
|
-
"reactive-view",
|
|
18
|
-
"vue-class-component",
|
|
19
|
-
"reactive-ui"
|
|
20
|
-
],
|
|
21
|
-
"author": "razaman2",
|
|
22
|
-
"license": "MIT",
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"@razaman2/data-manager": "^3.2.12",
|
|
25
|
-
"@razaman2/
|
|
26
|
-
"
|
|
27
|
-
"date-fns
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@razaman2/reactive-view",
|
|
3
|
+
"version": "0.0.33",
|
|
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
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"prepublishOnly": "npm run build",
|
|
10
|
+
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
11
|
+
"lint": "tsc",
|
|
12
|
+
"test": "cd tests/vue-ts && npm run dev"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"vue",
|
|
16
|
+
"vue-helper",
|
|
17
|
+
"reactive-view",
|
|
18
|
+
"vue-class-component",
|
|
19
|
+
"reactive-ui"
|
|
20
|
+
],
|
|
21
|
+
"author": "razaman2",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@razaman2/data-manager": "^3.2.12",
|
|
25
|
+
"@razaman2/event-emitter": "^2.1.1",
|
|
26
|
+
"@razaman2/object-manager": "^3.4.2",
|
|
27
|
+
"date-fns": "^4.1.0",
|
|
28
|
+
"date-fns-tz": "^3.2.0",
|
|
29
|
+
"uuid": "^11.1.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"vue": "^3.5.16"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/uuid": "^10.0.0",
|
|
36
|
+
"tsup": "^8.5.0",
|
|
37
|
+
"typescript": "^5.8.3",
|
|
38
|
+
"vitest": "^3.2.3"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist"
|
|
45
|
+
]
|
|
46
|
+
}
|