vasille 2.3.9 → 3.0.2
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/README.md +57 -155
- package/lib/binding/attribute.js +4 -5
- package/lib/binding/binding.js +4 -5
- package/lib/binding/class.js +2 -4
- package/lib/binding/style.js +12 -4
- package/lib/core/config.js +3 -0
- package/lib/core/core.js +39 -177
- package/lib/core/destroyable.js +1 -36
- package/lib/core/ivalue.js +6 -49
- package/lib/functional/safety.js +7 -0
- package/lib/index.js +7 -8
- package/lib/models/array-model.js +40 -107
- package/lib/models/listener.js +16 -80
- package/lib/models/map-model.js +6 -13
- package/lib/models/object-model.js +6 -6
- package/lib/models/set-model.js +5 -12
- package/lib/node/app.js +8 -27
- package/lib/node/node.js +294 -524
- package/lib/node/watch.js +10 -8
- package/lib/tsconfig-build.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/value/expression.js +16 -41
- package/lib/value/mirror.js +9 -23
- package/lib/value/pointer.js +64 -16
- package/lib/value/reference.js +24 -29
- package/lib/views/array-view.js +5 -6
- package/lib/views/base-view.js +14 -26
- package/lib/views/map-view.js +4 -5
- package/lib/views/repeat-node.js +17 -34
- package/lib/views/set-view.js +7 -5
- package/lib-node/binding/attribute.js +4 -5
- package/lib-node/binding/binding.js +4 -5
- package/lib-node/binding/class.js +2 -4
- package/lib-node/binding/style.js +13 -4
- package/lib-node/core/config.js +6 -0
- package/lib-node/core/core.js +39 -180
- package/lib-node/core/destroyable.js +1 -36
- package/lib-node/core/ivalue.js +7 -51
- package/lib-node/functional/safety.js +12 -0
- package/lib-node/index.js +7 -12
- package/lib-node/models/array-model.js +41 -107
- package/lib-node/models/listener.js +16 -80
- package/lib-node/models/map-model.js +6 -13
- package/lib-node/models/object-model.js +6 -6
- package/lib-node/models/set-model.js +5 -12
- package/lib-node/node/app.js +8 -28
- package/lib-node/node/node.js +294 -529
- package/lib-node/node/watch.js +10 -8
- package/lib-node/tsconfig-build-node.tsbuildinfo +1 -1
- package/lib-node/value/expression.js +16 -41
- package/lib-node/value/mirror.js +9 -23
- package/lib-node/value/pointer.js +66 -17
- package/lib-node/value/reference.js +24 -29
- package/lib-node/views/array-view.js +5 -6
- package/lib-node/views/base-view.js +14 -27
- package/lib-node/views/map-view.js +4 -5
- package/lib-node/views/repeat-node.js +17 -35
- package/lib-node/views/set-view.js +7 -5
- package/package.json +9 -6
- package/types/binding/attribute.d.ts +2 -2
- package/types/binding/binding.d.ts +1 -1
- package/types/binding/style.d.ts +3 -2
- package/types/core/config.d.ts +3 -0
- package/types/core/core.d.ts +18 -93
- package/types/core/destroyable.d.ts +11 -6
- package/types/core/ivalue.d.ts +7 -24
- package/types/functional/options.d.ts +7 -22
- package/types/functional/safety.d.ts +2 -0
- package/types/index.d.ts +8 -10
- package/types/models/array-model.d.ts +6 -55
- package/types/models/listener.d.ts +0 -26
- package/types/models/map-model.d.ts +3 -4
- package/types/models/model.d.ts +2 -9
- package/types/models/set-model.d.ts +1 -2
- package/types/node/app.d.ts +7 -25
- package/types/node/node.d.ts +105 -222
- package/types/node/watch.d.ts +4 -5
- package/types/spec/html.d.ts +231 -231
- package/types/spec/svg.d.ts +166 -166
- package/types/tsconfig-types.tsbuildinfo +1 -1
- package/types/value/expression.d.ts +5 -7
- package/types/value/mirror.d.ts +4 -6
- package/types/value/pointer.d.ts +26 -9
- package/types/value/reference.d.ts +6 -7
- package/types/views/array-view.d.ts +3 -3
- package/types/views/base-view.d.ts +15 -23
- package/types/views/map-view.d.ts +2 -2
- package/types/views/repeat-node.d.ts +9 -23
- package/types/views/set-view.d.ts +3 -2
- package/cdn/es2015.js +0 -2480
- package/flow-typed/vasille.js +0 -2613
package/lib/node/watch.js
CHANGED
|
@@ -5,16 +5,18 @@ import { Fragment } from "./node";
|
|
|
5
5
|
* @extends Fragment
|
|
6
6
|
*/
|
|
7
7
|
export class Watch extends Fragment {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
constructor(input) {
|
|
9
|
+
super(input, ":watch");
|
|
10
|
+
}
|
|
11
|
+
compose() {
|
|
12
|
+
this.watch(value => {
|
|
13
|
+
var _a, _b;
|
|
10
14
|
this.children.forEach(child => {
|
|
11
|
-
child
|
|
15
|
+
child.destroy();
|
|
12
16
|
});
|
|
13
17
|
this.children.clear();
|
|
14
|
-
this.lastChild =
|
|
15
|
-
input.slot
|
|
16
|
-
}, input.model);
|
|
17
|
-
input.slot(this, input.model.$);
|
|
18
|
-
return {};
|
|
18
|
+
this.lastChild = undefined;
|
|
19
|
+
(_b = (_a = this.input).slot) === null || _b === void 0 ? void 0 : _b.call(_a, this, value);
|
|
20
|
+
}, this.input.model);
|
|
19
21
|
}
|
|
20
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/index.ts","../src/binding/attribute.ts","../src/binding/binding.ts","../src/binding/class.ts","../src/binding/style.ts","../src/core/core.ts","../src/core/destroyable.ts","../src/core/errors.ts","../src/core/ivalue.ts","../src/functional/options.ts","../src/models/array-model.ts","../src/models/listener.ts","../src/models/map-model.ts","../src/models/model.ts","../src/models/object-model.ts","../src/models/set-model.ts","../src/node/app.ts","../src/node/node.ts","../src/node/watch.ts","../src/spec/html.ts","../src/spec/react.ts","../src/spec/svg.ts","../src/value/expression.ts","../src/value/mirror.ts","../src/value/pointer.ts","../src/value/reference.ts","../src/views/array-view.ts","../src/views/base-view.ts","../src/views/map-view.ts","../src/views/object-view.ts","../src/views/repeat-node.ts","../src/views/set-view.ts"],"version":"5.6.2"}
|
|
1
|
+
{"root":["../src/index.ts","../src/binding/attribute.ts","../src/binding/binding.ts","../src/binding/class.ts","../src/binding/style.ts","../src/core/core.ts","../src/core/destroyable.ts","../src/core/errors.ts","../src/core/ivalue.ts","../src/functional/options.ts","../src/functional/safety.ts","../src/models/array-model.ts","../src/models/listener.ts","../src/models/map-model.ts","../src/models/model.ts","../src/models/object-model.ts","../src/models/set-model.ts","../src/node/app.ts","../src/node/node.ts","../src/node/watch.ts","../src/spec/html.ts","../src/spec/react.ts","../src/spec/svg.ts","../src/value/expression.ts","../src/value/mirror.ts","../src/value/pointer.ts","../src/value/reference.ts","../src/views/array-view.ts","../src/views/base-view.ts","../src/views/map-view.ts","../src/views/object-view.ts","../src/views/repeat-node.ts","../src/views/set-view.ts"],"version":"5.6.2"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../src/index.ts","../src/binding/attribute.ts","../src/binding/binding.ts","../src/binding/class.ts","../src/binding/style.ts","../src/core/config.ts","../src/core/core.ts","../src/core/destroyable.ts","../src/core/errors.ts","../src/core/ivalue.ts","../src/functional/options.ts","../src/functional/safety.ts","../src/models/array-model.ts","../src/models/listener.ts","../src/models/map-model.ts","../src/models/model.ts","../src/models/set-model.ts","../src/node/app.ts","../src/node/node.ts","../src/node/watch.ts","../src/value/expression.ts","../src/value/pointer.ts","../src/value/reference.ts","../src/views/array-view.ts","../src/views/base-view.ts","../src/views/map-view.ts","../src/views/repeat-node.ts","../src/views/set-view.ts"],"version":"5.6.2"}
|
package/lib/value/expression.js
CHANGED
|
@@ -12,14 +12,14 @@ export class Expression extends IValue {
|
|
|
12
12
|
* @param values
|
|
13
13
|
* @param link {Boolean} links immediately if true
|
|
14
14
|
*/
|
|
15
|
-
constructor(func,
|
|
16
|
-
super(
|
|
15
|
+
constructor(func, ...values) {
|
|
16
|
+
super();
|
|
17
17
|
/**
|
|
18
|
-
* Expression will link different handler for each value of list
|
|
18
|
+
* Expression will link different handler for each value of the list
|
|
19
19
|
*/
|
|
20
20
|
this.linkedFunc = [];
|
|
21
21
|
const handler = (i) => {
|
|
22
|
-
if (i
|
|
22
|
+
if (typeof i === "number") {
|
|
23
23
|
this.valuesCache[i] = this.values[i].$;
|
|
24
24
|
}
|
|
25
25
|
this.sync.$ = func.apply(this, this.valuesCache);
|
|
@@ -29,18 +29,13 @@ export class Expression extends IValue {
|
|
|
29
29
|
this.valuesCache = values.map(item => item.$);
|
|
30
30
|
this.sync = new Reference(func.apply(this, this.valuesCache));
|
|
31
31
|
let i = 0;
|
|
32
|
-
values.forEach(
|
|
33
|
-
|
|
32
|
+
values.forEach(value => {
|
|
33
|
+
const updater = handler.bind(this, Number(i++));
|
|
34
|
+
this.linkedFunc.push(updater);
|
|
35
|
+
value.on(updater);
|
|
34
36
|
});
|
|
35
37
|
this.values = values;
|
|
36
38
|
this.func = handler;
|
|
37
|
-
if (link) {
|
|
38
|
-
this.$enable();
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
handler();
|
|
42
|
-
}
|
|
43
|
-
this.$seal();
|
|
44
39
|
}
|
|
45
40
|
get $() {
|
|
46
41
|
return this.sync.$;
|
|
@@ -48,39 +43,19 @@ export class Expression extends IValue {
|
|
|
48
43
|
set $(value) {
|
|
49
44
|
this.sync.$ = value;
|
|
50
45
|
}
|
|
51
|
-
|
|
52
|
-
this.sync
|
|
53
|
-
return this;
|
|
46
|
+
on(handler) {
|
|
47
|
+
this.sync.on(handler);
|
|
54
48
|
}
|
|
55
|
-
|
|
56
|
-
this.sync
|
|
57
|
-
return this;
|
|
58
|
-
}
|
|
59
|
-
$enable() {
|
|
60
|
-
if (!this.isEnabled) {
|
|
61
|
-
for (let i = 0; i < this.values.length; i++) {
|
|
62
|
-
this.values[i].$on(this.linkedFunc[i]);
|
|
63
|
-
this.valuesCache[i] = this.values[i].$;
|
|
64
|
-
}
|
|
65
|
-
this.func();
|
|
66
|
-
this.isEnabled = true;
|
|
67
|
-
}
|
|
68
|
-
return this;
|
|
49
|
+
off(handler) {
|
|
50
|
+
this.sync.off(handler);
|
|
69
51
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
this.values[i].$off(this.linkedFunc[i]);
|
|
74
|
-
}
|
|
75
|
-
this.isEnabled = false;
|
|
52
|
+
destroy() {
|
|
53
|
+
for (let i = 0; i < this.values.length; i++) {
|
|
54
|
+
this.values[i].off(this.linkedFunc[i]);
|
|
76
55
|
}
|
|
77
|
-
return this;
|
|
78
|
-
}
|
|
79
|
-
$destroy() {
|
|
80
|
-
this.$disable();
|
|
81
56
|
this.values.splice(0);
|
|
82
57
|
this.valuesCache.splice(0);
|
|
83
58
|
this.linkedFunc.splice(0);
|
|
84
|
-
super
|
|
59
|
+
super.destroy();
|
|
85
60
|
}
|
|
86
61
|
}
|
package/lib/value/mirror.js
CHANGED
|
@@ -13,13 +13,12 @@ export class Mirror extends Reference {
|
|
|
13
13
|
*/
|
|
14
14
|
constructor(value, forwardOnly = false) {
|
|
15
15
|
super(value.$);
|
|
16
|
-
this
|
|
16
|
+
this.handler = (v) => {
|
|
17
17
|
this.$ = v;
|
|
18
18
|
};
|
|
19
|
-
this
|
|
20
|
-
this
|
|
21
|
-
value
|
|
22
|
-
this.$seal();
|
|
19
|
+
this.value = value;
|
|
20
|
+
this.forward = forwardOnly;
|
|
21
|
+
value.on(this.handler);
|
|
23
22
|
}
|
|
24
23
|
get $() {
|
|
25
24
|
// this is a ts bug
|
|
@@ -28,29 +27,16 @@ export class Mirror extends Reference {
|
|
|
28
27
|
return super.$;
|
|
29
28
|
}
|
|
30
29
|
set $(v) {
|
|
31
|
-
if (!this
|
|
32
|
-
this.$
|
|
30
|
+
if (!this.forward) {
|
|
31
|
+
this.value.$ = v;
|
|
33
32
|
}
|
|
34
33
|
// this is a ts bug
|
|
35
34
|
// eslint-disable-next-line
|
|
36
35
|
// @ts-ignore
|
|
37
36
|
super.$ = v;
|
|
38
37
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this.$pointedValue.$on(this.$handler);
|
|
43
|
-
this.$ = this.$pointedValue.$;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
$disable() {
|
|
47
|
-
if (this.isEnabled) {
|
|
48
|
-
this.$pointedValue.$off(this.$handler);
|
|
49
|
-
this.isEnabled = false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
$destroy() {
|
|
53
|
-
this.$disable();
|
|
54
|
-
super.$destroy();
|
|
38
|
+
destroy() {
|
|
39
|
+
this.value.off(this.handler);
|
|
40
|
+
super.destroy();
|
|
55
41
|
}
|
|
56
42
|
}
|
package/lib/value/pointer.js
CHANGED
|
@@ -1,26 +1,74 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IValue } from "../core/ivalue";
|
|
2
|
+
import { Reference } from "./reference";
|
|
2
3
|
/**
|
|
3
4
|
* r/w pointer to a value
|
|
4
5
|
* @class Pointer
|
|
5
|
-
* @extends
|
|
6
|
+
* @extends IValue
|
|
6
7
|
*/
|
|
7
|
-
export class Pointer extends
|
|
8
|
+
export class Pointer extends IValue {
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
-
* @param
|
|
10
|
+
* Constructs a notifiable bind to a value
|
|
11
|
+
* @param value {IValue} is initial valu
|
|
11
12
|
*/
|
|
12
|
-
constructor(value
|
|
13
|
-
super(
|
|
13
|
+
constructor(value) {
|
|
14
|
+
super();
|
|
15
|
+
this.handler = (v) => {
|
|
16
|
+
this.reference.$ = v;
|
|
17
|
+
};
|
|
18
|
+
this.target = value;
|
|
19
|
+
this.reference = new Reference(value.$);
|
|
20
|
+
value.on(this.handler);
|
|
14
21
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
get $() {
|
|
23
|
+
return this.reference.$;
|
|
24
|
+
}
|
|
25
|
+
set $(v) {
|
|
26
|
+
var _a;
|
|
27
|
+
(_a = this.target) === null || _a === void 0 ? void 0 : _a.off(this.handler);
|
|
28
|
+
this.target = null;
|
|
29
|
+
this.reference.$ = v;
|
|
30
|
+
}
|
|
31
|
+
get $$() {
|
|
32
|
+
return this.reference.$;
|
|
33
|
+
}
|
|
34
|
+
set $$(v) {
|
|
35
|
+
if (this.target !== v) {
|
|
36
|
+
this.disconnectTarget();
|
|
37
|
+
}
|
|
38
|
+
if (v instanceof IValue) {
|
|
39
|
+
this.target = v;
|
|
40
|
+
this.target.on(this.handler);
|
|
41
|
+
this.reference.$ = v.$;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.$ = v;
|
|
24
45
|
}
|
|
25
46
|
}
|
|
47
|
+
on(handler) {
|
|
48
|
+
this.reference.on(handler);
|
|
49
|
+
}
|
|
50
|
+
off(handler) {
|
|
51
|
+
this.reference.off(handler);
|
|
52
|
+
}
|
|
53
|
+
destroy() {
|
|
54
|
+
var _a;
|
|
55
|
+
(_a = this.target) === null || _a === void 0 ? void 0 : _a.off(this.handler);
|
|
56
|
+
this.reference.destroy();
|
|
57
|
+
super.destroy();
|
|
58
|
+
}
|
|
59
|
+
disconnectTarget() {
|
|
60
|
+
var _a;
|
|
61
|
+
(_a = this.target) === null || _a === void 0 ? void 0 : _a.off(this.handler);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export class OwningPointer extends Pointer {
|
|
65
|
+
destroy() {
|
|
66
|
+
var _a;
|
|
67
|
+
(_a = this.target) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
68
|
+
super.destroy();
|
|
69
|
+
}
|
|
70
|
+
disconnectTarget() {
|
|
71
|
+
var _a;
|
|
72
|
+
(_a = this.target) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
73
|
+
}
|
|
26
74
|
}
|
package/lib/value/reference.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IValue } from "../core/ivalue";
|
|
2
|
+
import { reportError } from "../functional/safety";
|
|
2
3
|
/**
|
|
3
4
|
* Declares a notifiable value
|
|
4
5
|
* @class Reference
|
|
@@ -9,43 +10,37 @@ export class Reference extends IValue {
|
|
|
9
10
|
* @param value {any} the initial value
|
|
10
11
|
*/
|
|
11
12
|
constructor(value) {
|
|
12
|
-
super(
|
|
13
|
-
this
|
|
14
|
-
this
|
|
15
|
-
this.$seal();
|
|
13
|
+
super();
|
|
14
|
+
this.state = value;
|
|
15
|
+
this.onChange = new Set();
|
|
16
16
|
}
|
|
17
17
|
get $() {
|
|
18
|
-
return this
|
|
18
|
+
return this.state;
|
|
19
19
|
}
|
|
20
20
|
set $(value) {
|
|
21
|
-
if (this
|
|
22
|
-
this
|
|
23
|
-
|
|
24
|
-
this.$onchange.forEach(handler => {
|
|
25
|
-
handler(value);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
$enable() {
|
|
31
|
-
if (!this.isEnabled) {
|
|
32
|
-
this.$onchange.forEach(handler => {
|
|
33
|
-
handler(this.$value);
|
|
34
|
-
});
|
|
35
|
-
this.isEnabled = true;
|
|
21
|
+
if (this.state !== value) {
|
|
22
|
+
this.state = value;
|
|
23
|
+
this.updateDeps(value);
|
|
36
24
|
}
|
|
37
25
|
}
|
|
38
|
-
|
|
39
|
-
this.
|
|
26
|
+
on(handler) {
|
|
27
|
+
this.onChange.add(handler);
|
|
40
28
|
}
|
|
41
|
-
|
|
42
|
-
this
|
|
29
|
+
off(handler) {
|
|
30
|
+
this.onChange.delete(handler);
|
|
43
31
|
}
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
destroy() {
|
|
33
|
+
super.destroy();
|
|
34
|
+
this.onChange.clear();
|
|
46
35
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
updateDeps(value) {
|
|
37
|
+
this.onChange.forEach(handler => {
|
|
38
|
+
try {
|
|
39
|
+
handler(value);
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
reportError(e);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
50
45
|
}
|
|
51
46
|
}
|
package/lib/views/array-view.js
CHANGED
|
@@ -6,13 +6,12 @@ import { BaseView } from "./base-view";
|
|
|
6
6
|
*/
|
|
7
7
|
export class ArrayView extends BaseView {
|
|
8
8
|
createChild(input, id, item, before) {
|
|
9
|
-
super.createChild(input, item, item, before || this
|
|
9
|
+
super.createChild(input, item, item, before || this.nodes.get(id));
|
|
10
10
|
}
|
|
11
|
-
compose(
|
|
12
|
-
super.compose(
|
|
13
|
-
input.model.forEach(item => {
|
|
14
|
-
this.createChild(input, item, item);
|
|
11
|
+
compose() {
|
|
12
|
+
super.compose();
|
|
13
|
+
this.input.model.forEach(item => {
|
|
14
|
+
this.createChild(this.input, item, item);
|
|
15
15
|
});
|
|
16
|
-
return {};
|
|
17
16
|
}
|
|
18
17
|
}
|
package/lib/views/base-view.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import { RepeatNode
|
|
2
|
-
/**
|
|
3
|
-
* Private part of BaseView
|
|
4
|
-
* @class BaseViewPrivate
|
|
5
|
-
* @extends RepeatNodePrivate
|
|
6
|
-
*/
|
|
7
|
-
export class BaseViewPrivate extends RepeatNodePrivate {
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
this.$seal();
|
|
11
|
-
}
|
|
12
|
-
}
|
|
1
|
+
import { RepeatNode } from "./repeat-node";
|
|
13
2
|
/**
|
|
14
3
|
* Base class of default views
|
|
15
4
|
* @class BaseView
|
|
@@ -17,23 +6,22 @@ export class BaseViewPrivate extends RepeatNodePrivate {
|
|
|
17
6
|
* @implements IModel
|
|
18
7
|
*/
|
|
19
8
|
export class BaseView extends RepeatNode {
|
|
20
|
-
constructor(input,
|
|
21
|
-
super(input,
|
|
9
|
+
constructor(input, name) {
|
|
10
|
+
super(input, name);
|
|
22
11
|
}
|
|
23
|
-
compose(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.createChild(input, id, item);
|
|
12
|
+
compose() {
|
|
13
|
+
this.addHandler = (id, item) => {
|
|
14
|
+
this.createChild(this.input, id, item);
|
|
27
15
|
};
|
|
28
|
-
|
|
16
|
+
this.removeHandler = (id, item) => {
|
|
29
17
|
this.destroyChild(id, item);
|
|
30
18
|
};
|
|
31
|
-
input.model.listener.onAdd(
|
|
32
|
-
input.model.listener.onRemove(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
19
|
+
this.input.model.listener.onAdd(this.addHandler);
|
|
20
|
+
this.input.model.listener.onRemove(this.removeHandler);
|
|
21
|
+
}
|
|
22
|
+
destroy() {
|
|
23
|
+
this.input.model.listener.offAdd(this.addHandler);
|
|
24
|
+
this.input.model.listener.offRemove(this.removeHandler);
|
|
25
|
+
super.destroy();
|
|
38
26
|
}
|
|
39
27
|
}
|
package/lib/views/map-view.js
CHANGED
|
@@ -5,11 +5,10 @@ import { BaseView } from "./base-view";
|
|
|
5
5
|
* @extends BaseView
|
|
6
6
|
*/
|
|
7
7
|
export class MapView extends BaseView {
|
|
8
|
-
compose(
|
|
9
|
-
super.compose(
|
|
10
|
-
input.model.forEach((value, key) => {
|
|
11
|
-
this.createChild(input, key, value);
|
|
8
|
+
compose() {
|
|
9
|
+
super.compose();
|
|
10
|
+
this.input.model.forEach((value, key) => {
|
|
11
|
+
this.createChild(this.input, key, value);
|
|
12
12
|
});
|
|
13
|
-
return {};
|
|
14
13
|
}
|
|
15
14
|
}
|
package/lib/views/repeat-node.js
CHANGED
|
@@ -1,39 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
* Private part of repeat node
|
|
4
|
-
* @class RepeatNodePrivate
|
|
5
|
-
* @extends INodePrivate
|
|
6
|
-
*/
|
|
7
|
-
export class RepeatNodePrivate extends INodePrivate {
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
/**
|
|
11
|
-
* Children node hash
|
|
12
|
-
* @type {Map}
|
|
13
|
-
*/
|
|
14
|
-
this.nodes = new Map();
|
|
15
|
-
this.$seal();
|
|
16
|
-
}
|
|
17
|
-
$destroy() {
|
|
18
|
-
this.nodes.clear();
|
|
19
|
-
super.$destroy();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
import { config } from "../core/config";
|
|
2
|
+
import { Fragment } from "../node/node";
|
|
22
3
|
/**
|
|
23
4
|
* Repeat node repeats its children
|
|
24
5
|
* @class RepeatNode
|
|
25
6
|
* @extends Fragment
|
|
26
7
|
*/
|
|
27
8
|
export class RepeatNode extends Fragment {
|
|
28
|
-
constructor(input,
|
|
29
|
-
super(input,
|
|
9
|
+
constructor(input, name) {
|
|
10
|
+
super(input, name);
|
|
30
11
|
/**
|
|
31
|
-
*
|
|
12
|
+
* Children node hash
|
|
13
|
+
* @type {Map}
|
|
32
14
|
*/
|
|
33
|
-
this.
|
|
15
|
+
this.nodes = new Map();
|
|
34
16
|
}
|
|
35
17
|
createChild(opts, id, item, before) {
|
|
36
|
-
const
|
|
18
|
+
const _id = id && typeof id === "object" && "id" in id ? id.id : config.debugUi ? JSON.stringify(id) : id;
|
|
19
|
+
const node = new Fragment({}, `${_id}`);
|
|
20
|
+
node.parent = this;
|
|
37
21
|
this.destroyChild(id, item);
|
|
38
22
|
if (before) {
|
|
39
23
|
this.children.add(node);
|
|
@@ -47,20 +31,19 @@ export class RepeatNode extends Fragment {
|
|
|
47
31
|
this.children.add(node);
|
|
48
32
|
}
|
|
49
33
|
this.lastChild = node;
|
|
50
|
-
node.preinit(this.$.app, this);
|
|
51
|
-
node.init();
|
|
52
34
|
opts.slot && opts.slot(node, item, id);
|
|
53
|
-
|
|
54
|
-
this.$.nodes.set(id, node);
|
|
35
|
+
this.nodes.set(id, node);
|
|
55
36
|
}
|
|
56
37
|
destroyChild(id, item) {
|
|
57
|
-
const
|
|
58
|
-
const child = $.nodes.get(id);
|
|
38
|
+
const child = this.nodes.get(id);
|
|
59
39
|
if (child) {
|
|
60
40
|
child.remove();
|
|
61
|
-
child
|
|
62
|
-
this
|
|
41
|
+
child.destroy();
|
|
42
|
+
this.nodes.delete(id);
|
|
63
43
|
this.children.delete(child);
|
|
64
44
|
}
|
|
65
45
|
}
|
|
46
|
+
destroy() {
|
|
47
|
+
this.nodes.clear();
|
|
48
|
+
}
|
|
66
49
|
}
|
package/lib/views/set-view.js
CHANGED
|
@@ -5,11 +5,13 @@ import { BaseView } from "./base-view";
|
|
|
5
5
|
* @extends BaseView
|
|
6
6
|
*/
|
|
7
7
|
export class SetView extends BaseView {
|
|
8
|
-
|
|
9
|
-
super
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
constructor(input) {
|
|
9
|
+
super(input, ":set-view");
|
|
10
|
+
}
|
|
11
|
+
compose() {
|
|
12
|
+
super.compose();
|
|
13
|
+
this.input.model.forEach(item => {
|
|
14
|
+
this.createChild(this.input, item, item);
|
|
13
15
|
});
|
|
14
16
|
return {};
|
|
15
17
|
}
|
|
@@ -18,18 +18,17 @@ class AttributeBinding extends binding_1.Binding {
|
|
|
18
18
|
super(value);
|
|
19
19
|
this.init((value) => {
|
|
20
20
|
if (value) {
|
|
21
|
-
if (typeof value ===
|
|
22
|
-
node.
|
|
21
|
+
if (typeof value === "boolean") {
|
|
22
|
+
node.element.setAttribute(name, "");
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
|
-
node.
|
|
25
|
+
node.element.setAttribute(name, `${value}`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
|
-
node.
|
|
29
|
+
node.element.removeAttribute(name);
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
|
-
this.$seal();
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
exports.AttributeBinding = AttributeBinding;
|
|
@@ -15,19 +15,18 @@ class Binding extends destroyable_1.Destroyable {
|
|
|
15
15
|
constructor(value) {
|
|
16
16
|
super();
|
|
17
17
|
this.binding = value;
|
|
18
|
-
this.$seal();
|
|
19
18
|
}
|
|
20
19
|
init(bounded) {
|
|
21
20
|
this.func = bounded;
|
|
22
|
-
this.binding
|
|
21
|
+
this.binding.on(this.func);
|
|
23
22
|
this.func(this.binding.$);
|
|
24
23
|
}
|
|
25
24
|
/**
|
|
26
25
|
* Just clear bindings
|
|
27
26
|
*/
|
|
28
|
-
|
|
29
|
-
this.binding
|
|
30
|
-
super
|
|
27
|
+
destroy() {
|
|
28
|
+
this.binding.off(this.func);
|
|
29
|
+
super.destroy();
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
exports.Binding = Binding;
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DynamicalClassBinding = exports.StaticClassBinding = void 0;
|
|
4
4
|
const binding_1 = require("./binding");
|
|
5
5
|
function addClass(node, cl) {
|
|
6
|
-
node.
|
|
6
|
+
node.element.classList.add(cl);
|
|
7
7
|
}
|
|
8
8
|
function removeClass(node, cl) {
|
|
9
|
-
node.
|
|
9
|
+
node.element.classList.remove(cl);
|
|
10
10
|
}
|
|
11
11
|
class StaticClassBinding extends binding_1.Binding {
|
|
12
12
|
constructor(node, name, value) {
|
|
@@ -23,7 +23,6 @@ class StaticClassBinding extends binding_1.Binding {
|
|
|
23
23
|
this.current = value;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
this.$seal();
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
exports.StaticClassBinding = StaticClassBinding;
|
|
@@ -42,7 +41,6 @@ class DynamicalClassBinding extends binding_1.Binding {
|
|
|
42
41
|
this.current = value;
|
|
43
42
|
}
|
|
44
43
|
});
|
|
45
|
-
this.$seal();
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
46
|
exports.DynamicalClassBinding = DynamicalClassBinding;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StyleBinding = void 0;
|
|
4
|
+
exports.stringifyStyleValue = stringifyStyleValue;
|
|
4
5
|
const binding_1 = require("./binding");
|
|
6
|
+
function stringifyStyleValue(value) {
|
|
7
|
+
if (value instanceof Array) {
|
|
8
|
+
return value.map(item => `${item}px`).join(" ");
|
|
9
|
+
}
|
|
10
|
+
if (typeof value === "number") {
|
|
11
|
+
return `${value}px`;
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
5
15
|
/**
|
|
6
16
|
* Describes a style attribute binding
|
|
7
17
|
* @class StyleBinding
|
|
@@ -16,12 +26,11 @@ class StyleBinding extends binding_1.Binding {
|
|
|
16
26
|
*/
|
|
17
27
|
constructor(node, name, value) {
|
|
18
28
|
super(value);
|
|
19
|
-
this.init(
|
|
20
|
-
if (node.
|
|
21
|
-
node.
|
|
29
|
+
this.init(value => {
|
|
30
|
+
if (node.element instanceof HTMLElement) {
|
|
31
|
+
node.element.style.setProperty(name, stringifyStyleValue(value));
|
|
22
32
|
}
|
|
23
33
|
});
|
|
24
|
-
this.$seal();
|
|
25
34
|
}
|
|
26
35
|
}
|
|
27
36
|
exports.StyleBinding = StyleBinding;
|