vasille 1.2.8 → 2.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/.gitlab-ci.yml +20 -0
- package/LICENSE.md +21 -0
- package/README.md +160 -119
- package/cdn/es2015.js +3221 -0
- package/cdn/es5.js +3673 -0
- package/flow-typed/vasille.js +837 -0
- package/lib/binding/attribute.js +32 -0
- package/lib/binding/binding.js +39 -0
- package/lib/binding/class.js +51 -0
- package/lib/binding/style.js +29 -0
- package/lib/core/core.js +178 -0
- package/lib/core/destroyable.js +45 -0
- package/lib/core/errors.js +16 -0
- package/lib/core/executor.js +154 -0
- package/lib/core/ivalue.js +56 -0
- package/lib/core/signal.js +50 -0
- package/lib/core/slot.js +47 -0
- package/lib/index.js +27 -22
- package/lib/models/array-model.js +208 -0
- package/lib/models/listener.js +130 -0
- package/lib/models/map-model.js +66 -0
- package/lib/models/model.js +1 -0
- package/lib/models/object-model.js +78 -0
- package/lib/models/set-model.js +62 -0
- package/lib/node/app.js +38 -0
- package/lib/node/interceptor.js +83 -0
- package/lib/node/node.js +1202 -0
- package/lib/node/watch.js +27 -0
- package/lib/value/expression.js +83 -0
- package/lib/value/mirror.js +58 -0
- package/lib/value/pointer.js +26 -0
- package/lib/value/reference.js +55 -0
- package/lib/views/array-view.js +23 -0
- package/lib/views/base-view.js +49 -0
- package/lib/views/map-view.js +20 -0
- package/lib/views/object-view.js +20 -0
- package/lib/views/repeat-node.js +106 -0
- package/lib/views/repeater.js +63 -0
- package/lib/views/set-view.js +23 -0
- package/package.json +27 -19
- package/types/binding/attribute.d.ts +23 -0
- package/types/binding/binding.d.ts +30 -0
- package/types/binding/class.d.ts +23 -0
- package/types/binding/style.d.ts +23 -0
- package/types/core/core.d.ts +140 -0
- package/types/core/destroyable.d.ts +15 -0
- package/types/core/errors.d.ts +4 -0
- package/types/core/executor.d.ts +87 -0
- package/types/core/ivalue.d.ts +45 -0
- package/types/core/signal.d.ts +35 -0
- package/types/core/slot.d.ts +45 -0
- package/types/index.d.ts +27 -21
- package/types/models/array-model.d.ts +103 -0
- package/types/models/listener.d.ts +74 -0
- package/types/models/map-model.d.ts +35 -0
- package/types/models/model.d.ts +19 -0
- package/types/models/object-model.d.ts +36 -0
- package/types/models/set-model.d.ts +34 -0
- package/types/node/app.d.ts +37 -0
- package/types/node/interceptor.d.ts +50 -0
- package/types/node/node.d.ts +741 -0
- package/types/node/watch.d.ts +23 -0
- package/types/value/expression.d.ts +60 -0
- package/types/value/mirror.d.ts +35 -0
- package/types/value/pointer.d.ts +19 -0
- package/types/value/reference.d.ts +30 -0
- package/types/views/array-view.d.ts +13 -0
- package/types/views/base-view.d.ts +43 -0
- package/types/views/map-view.d.ts +11 -0
- package/types/views/object-view.d.ts +11 -0
- package/types/views/repeat-node.d.ts +35 -0
- package/types/views/repeater.d.ts +38 -0
- package/types/views/set-view.d.ts +11 -0
- package/CHANGELOG.md +0 -23
- package/img/favicon.svg +0 -441
- package/img/getLocus.svg +0 -18
- package/img/logo.png +0 -0
- package/img/logo.svg +0 -550
- package/img/scores-o-log.png +0 -0
- package/img/scores-o.png +0 -0
- package/img/scores-wo-log.png +0 -0
- package/img/scores-wo.png +0 -0
- package/img/x1-x32.png +0 -0
- package/lib/attribute.js +0 -71
- package/lib/attribute.js.map +0 -1
- package/lib/bind.js +0 -286
- package/lib/bind.js.map +0 -1
- package/lib/class.js +0 -97
- package/lib/class.js.map +0 -1
- package/lib/executor.js +0 -167
- package/lib/executor.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/interfaces/core.js +0 -247
- package/lib/interfaces/core.js.map +0 -1
- package/lib/interfaces/destroyable.js +0 -39
- package/lib/interfaces/destroyable.js.map +0 -1
- package/lib/interfaces/errors.js +0 -49
- package/lib/interfaces/errors.js.map +0 -1
- package/lib/interfaces/ibind.js +0 -31
- package/lib/interfaces/ibind.js.map +0 -1
- package/lib/interfaces/idefinition.js +0 -64
- package/lib/interfaces/idefinition.js.map +0 -1
- package/lib/interfaces/ivalue.js +0 -60
- package/lib/interfaces/ivalue.js.map +0 -1
- package/lib/models.js +0 -579
- package/lib/models.js.map +0 -1
- package/lib/node.js +0 -2155
- package/lib/node.js.map +0 -1
- package/lib/property.js +0 -38
- package/lib/property.js.map +0 -1
- package/lib/style.js +0 -66
- package/lib/style.js.map +0 -1
- package/lib/value.js +0 -203
- package/lib/value.js.map +0 -1
- package/lib/views.js +0 -688
- package/lib/views.js.map +0 -1
- package/src/attribute.js +0 -70
- package/src/bind.js +0 -285
- package/src/class.js +0 -96
- package/src/executor.js +0 -165
- package/src/index.js +0 -20
- package/src/interfaces/core.js +0 -248
- package/src/interfaces/destroyable.js +0 -37
- package/src/interfaces/errors.js +0 -47
- package/src/interfaces/ibind.js +0 -29
- package/src/interfaces/idefinition.js +0 -62
- package/src/interfaces/ivalue.js +0 -58
- package/src/models.js +0 -577
- package/src/node.js +0 -2162
- package/src/property.js +0 -36
- package/src/style.js +0 -65
- package/src/value.js +0 -201
- package/src/views.js +0 -686
- package/types/attribute.d.ts +0 -18
- package/types/bind.d.ts +0 -72
- package/types/class.d.ts +0 -19
- package/types/data.d.ts +0 -11
- package/types/event.d.ts +0 -10
- package/types/executor.d.ts +0 -57
- package/types/interfaces/core.d.ts +0 -129
- package/types/interfaces/destroyable.d.ts +0 -11
- package/types/interfaces/errors.d.ts +0 -24
- package/types/interfaces/ibind.d.ts +0 -19
- package/types/interfaces/idefinition.d.ts +0 -29
- package/types/interfaces/ivalue.d.ts +0 -40
- package/types/models.d.ts +0 -179
- package/types/node.d.ts +0 -906
- package/types/property.d.ts +0 -9
- package/types/style.d.ts +0 -28
- package/types/value.d.ts +0 -43
- package/types/views.d.ts +0 -135
package/src/attribute.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import { Binding } from "./bind.js";
|
|
3
|
-
import { Callable } from "./interfaces/idefinition.js";
|
|
4
|
-
import { IValue } from "./interfaces/ivalue.js";
|
|
5
|
-
import type { INode } from "./node";
|
|
6
|
-
import { propertify } from "./property.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Creates a attribute 1 to 1 bind
|
|
12
|
-
* @param rt {INode} is the root component
|
|
13
|
-
* @param ts {INode} is the this component
|
|
14
|
-
* @param name {String} is attribute name
|
|
15
|
-
* @param value {?any} is attribute value
|
|
16
|
-
* @param func {?Callable} is attribute value calculation function
|
|
17
|
-
* @returns {AttributeBinding} 1 to 1 bind of attribute
|
|
18
|
-
*/
|
|
19
|
-
export function attributify (
|
|
20
|
-
rt : INode,
|
|
21
|
-
ts : INode,
|
|
22
|
-
name : string,
|
|
23
|
-
value : ?any = null,
|
|
24
|
-
func : ?Callable = null
|
|
25
|
-
) : AttributeBinding {
|
|
26
|
-
return new AttributeBinding(rt, ts, name, null, propertify(value, func));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Represents a Attribute binding description
|
|
31
|
-
* @extends Binding
|
|
32
|
-
*/
|
|
33
|
-
export class AttributeBinding extends Binding {
|
|
34
|
-
/**
|
|
35
|
-
* Constructs a attribute binding description
|
|
36
|
-
* @param rt {INode} is root component
|
|
37
|
-
* @param ts {INode} is this component
|
|
38
|
-
* @param name {String} is the name of attribute
|
|
39
|
-
* @param func {?Function} is the function to bound
|
|
40
|
-
* @param values {Array<IValue>} is the array of values to bind to
|
|
41
|
-
*/
|
|
42
|
-
constructor (
|
|
43
|
-
rt : INode,
|
|
44
|
-
ts : INode,
|
|
45
|
-
name : string,
|
|
46
|
-
func : ?Function,
|
|
47
|
-
...values : Array<IValue<any>>
|
|
48
|
-
) {
|
|
49
|
-
super(rt, ts, name, func, ...values);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Generates a function which updates the attribute value
|
|
54
|
-
* @param name {String} The name of attribute
|
|
55
|
-
* @returns {Function} a function which will update attribute value
|
|
56
|
-
*/
|
|
57
|
-
bound (name : string) : Function {
|
|
58
|
-
return function (rt : any, ts : any, value : string) {
|
|
59
|
-
|
|
60
|
-
if (value) {
|
|
61
|
-
rt.$.app.$run.setAttribute(ts.$.el, name, value);
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
rt.$.app.$run.removeAttribute(ts.$.el, name);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return value;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}
|
package/src/bind.js
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import { notOverwritten, typeError, wrongBinding } from "./interfaces/errors";
|
|
3
|
-
import { IBind } from "./interfaces/ibind.js";
|
|
4
|
-
import { checkType } from "./interfaces/idefinition";
|
|
5
|
-
import { IValue } from "./interfaces/ivalue.js";
|
|
6
|
-
import type { INode } from "./node";
|
|
7
|
-
import { Reference } from "./value.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Bind some values to one expression
|
|
13
|
-
* @implements IBind
|
|
14
|
-
*/
|
|
15
|
-
export class Expression extends IBind {
|
|
16
|
-
/**
|
|
17
|
-
* The array of value which will trigger recalculation
|
|
18
|
-
* @type {Array<IValue<*>>}
|
|
19
|
-
*/
|
|
20
|
-
values : Array<IValue<any>>;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Cache the values of expression variables
|
|
24
|
-
* @type {Array<*>}
|
|
25
|
-
* @version 1.1
|
|
26
|
-
*/
|
|
27
|
-
valuesCache : Array<any> = [];
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* The function which will be executed on recalculation
|
|
31
|
-
* @type {Function}
|
|
32
|
-
*/
|
|
33
|
-
func : Function;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Expression will link different handler for each value of list
|
|
37
|
-
* @type {Array<Function>}
|
|
38
|
-
* @version 1.1
|
|
39
|
-
*/
|
|
40
|
-
linkedFunc : Array<Function> = [];
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* The current linking state
|
|
44
|
-
* @type {boolean}
|
|
45
|
-
*/
|
|
46
|
-
linked : boolean;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* The buffer to keep the last calculated value
|
|
50
|
-
* @type {Reference<*>}
|
|
51
|
-
*/
|
|
52
|
-
sync : Reference<any> = new Reference(null);
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Creates a function bounded to N value
|
|
56
|
-
* @param func {Function} The function to bound
|
|
57
|
-
* @param values {Array<IValue<*>>} Values to bound to
|
|
58
|
-
* @param link {Boolean} If true links immediately
|
|
59
|
-
*/
|
|
60
|
-
constructor (
|
|
61
|
-
func : Function,
|
|
62
|
-
values : Array<IValue<any>>,
|
|
63
|
-
link : boolean = true
|
|
64
|
-
) {
|
|
65
|
-
super();
|
|
66
|
-
let handler = (i : ?number) => {
|
|
67
|
-
if (i != null) {
|
|
68
|
-
this.valuesCache[i] = this.values[i].$;
|
|
69
|
-
}
|
|
70
|
-
let value = func.apply(this, this.valuesCache);
|
|
71
|
-
|
|
72
|
-
if (this.type) {
|
|
73
|
-
if (!checkType(value, this.type)) {
|
|
74
|
-
throw typeError("expression returns wrong incompatible value");
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
this.sync.$ = value;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
let i = 0;
|
|
82
|
-
for (let value of values) {
|
|
83
|
-
this.valuesCache.push(value.$);
|
|
84
|
-
this.linkedFunc.push(handler.bind(this, Number(i++)));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
this.values = values;
|
|
88
|
-
this.func = handler;
|
|
89
|
-
this.linked = false;
|
|
90
|
-
|
|
91
|
-
if (link) {
|
|
92
|
-
this.link();
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
handler(null);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
this.seal();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Gets the last calculated value
|
|
103
|
-
* @return {*} The last calculated value
|
|
104
|
-
*/
|
|
105
|
-
get $ () : any {
|
|
106
|
-
return this.sync.$;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Sets the last calculated value in manual mode
|
|
111
|
-
* @param value {*} New value for last calculated value
|
|
112
|
-
* @return {Expression<*>} A pointer to this
|
|
113
|
-
*/
|
|
114
|
-
set $ (value : any) : this {
|
|
115
|
-
this.sync.$ = value;
|
|
116
|
-
return this;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Sets a user handler on value change
|
|
121
|
-
* @param handler {Function} User defined handler
|
|
122
|
-
* @return {this} A pointer to this
|
|
123
|
-
*/
|
|
124
|
-
on (handler : Function) : this {
|
|
125
|
-
this.sync.on(handler);
|
|
126
|
-
return this;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Unsets a user handler from value change
|
|
131
|
-
* @param handler {Function} User installed handler
|
|
132
|
-
* @return {this} A pointer to this
|
|
133
|
-
*/
|
|
134
|
-
off (handler : Function) : this {
|
|
135
|
-
this.sync.off(handler);
|
|
136
|
-
return this;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Binds function to each value
|
|
141
|
-
* @returns {this} A pointer to this
|
|
142
|
-
*/
|
|
143
|
-
link () : this {
|
|
144
|
-
if (!this.linked) {
|
|
145
|
-
for (let i = 0; i < this.values.length; i++) {
|
|
146
|
-
this.values[i].on(this.linkedFunc[i]);
|
|
147
|
-
this.valuesCache[i] = this.values[i].$;
|
|
148
|
-
}
|
|
149
|
-
this.func(null);
|
|
150
|
-
this.linked = true;
|
|
151
|
-
}
|
|
152
|
-
return this;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Unbind function from each value
|
|
157
|
-
* @returns {this} A pointer to this
|
|
158
|
-
*/
|
|
159
|
-
unlink () : this {
|
|
160
|
-
if (this.linked) {
|
|
161
|
-
for (let i = 0; i < this.values.length; i++) {
|
|
162
|
-
this.values[i].off(this.linkedFunc[i]);
|
|
163
|
-
}
|
|
164
|
-
this.linked = false;
|
|
165
|
-
}
|
|
166
|
-
return this;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Clear bindings on destroy
|
|
171
|
-
*/
|
|
172
|
-
$destroy () : void {
|
|
173
|
-
this.unlink();
|
|
174
|
-
this.values.splice(0);
|
|
175
|
-
this.valuesCache.splice(0);
|
|
176
|
-
this.linkedFunc.splice(0);
|
|
177
|
-
this.func = null;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Describe a common binding logic
|
|
183
|
-
* @implements IValue
|
|
184
|
-
*/
|
|
185
|
-
export class Binding extends IValue<any> {
|
|
186
|
-
binding : IValue<any>;
|
|
187
|
-
func : Function;
|
|
188
|
-
owner : boolean;
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Constructs a common binding logic
|
|
192
|
-
* @param rt {INode} Root component
|
|
193
|
-
* @param ts {INode} This component
|
|
194
|
-
* @param name {String} Name of property/attribute
|
|
195
|
-
* @param func {?Function} A function to run on value change
|
|
196
|
-
* @param values {Array<IValue>} values array to bind
|
|
197
|
-
*/
|
|
198
|
-
constructor (
|
|
199
|
-
rt : INode,
|
|
200
|
-
ts : INode,
|
|
201
|
-
name : string,
|
|
202
|
-
func : ?Function,
|
|
203
|
-
...values : Array<IValue<any>>
|
|
204
|
-
) {
|
|
205
|
-
super();
|
|
206
|
-
|
|
207
|
-
this.func = this.bound(name).bind(null, rt, ts);
|
|
208
|
-
|
|
209
|
-
if (!func && values.length === 1) {
|
|
210
|
-
this.binding = values[0];
|
|
211
|
-
this.owner = false;
|
|
212
|
-
}
|
|
213
|
-
else if (func && values.length) {
|
|
214
|
-
this.binding = new Expression(func, values);
|
|
215
|
-
this.owner = true;
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
throw wrongBinding("Binding request a value as minimum");
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
this.binding.on(this.func);
|
|
222
|
-
this.func(this.binding.$);
|
|
223
|
-
|
|
224
|
-
this.seal();
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Is a virtual function to get the specific bind function
|
|
229
|
-
* @param name {String} The name of attribute/property
|
|
230
|
-
* @returns {Function} A function to update attribute/property value
|
|
231
|
-
* @throws Always trows and must be overloaded in child class
|
|
232
|
-
*/
|
|
233
|
-
bound (name : string) : Function {
|
|
234
|
-
throw notOverwritten();
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Gets the binding value
|
|
239
|
-
* @return {*} The binding value
|
|
240
|
-
*/
|
|
241
|
-
get $ () : any {
|
|
242
|
-
return this.binding.$;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Sets the binding value
|
|
247
|
-
* @param any {*} The new binding value
|
|
248
|
-
* @return {this} A pointer to this
|
|
249
|
-
*/
|
|
250
|
-
set $ (any : any) : this {
|
|
251
|
-
this.binding.$ = any;
|
|
252
|
-
return this;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Adds a user handler to the binding value change event
|
|
257
|
-
* @param func {Function} User defined handler
|
|
258
|
-
* @return {Binding} A pointer to this
|
|
259
|
-
*/
|
|
260
|
-
on (func : Function) : this {
|
|
261
|
-
this.binding.on(func);
|
|
262
|
-
return this;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Removes a user handler from binding value change event
|
|
267
|
-
* @param func {Function} User installed handler
|
|
268
|
-
* @return {Binding} A pointer to this
|
|
269
|
-
*/
|
|
270
|
-
off (func : Function) : this {
|
|
271
|
-
this.binding.off(func);
|
|
272
|
-
return this;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Just clear bindings
|
|
277
|
-
*/
|
|
278
|
-
$destroy () {
|
|
279
|
-
this.binding.off(this.func);
|
|
280
|
-
|
|
281
|
-
if (this.owner) {
|
|
282
|
-
this.binding.$destroy();
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
package/src/class.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import { Binding } from "./bind.js";
|
|
3
|
-
import { Callable } from "./interfaces/idefinition.js";
|
|
4
|
-
import { IValue } from "./interfaces/ivalue.js";
|
|
5
|
-
import type { INode } from "./node.js";
|
|
6
|
-
import { propertify } from "./property.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Creates a class target 1 to 1 bind
|
|
12
|
-
* @param rt {INode} is the root component
|
|
13
|
-
* @param ts {INode} is the this component
|
|
14
|
-
* @param name {String} is attribute name
|
|
15
|
-
* @param value {?any} is attribute value
|
|
16
|
-
* @param func {?Callable} is attribute value calculation function
|
|
17
|
-
* @returns {AttributeBinding} 1 to 1 bind of attribute
|
|
18
|
-
*/
|
|
19
|
-
export function classify (
|
|
20
|
-
rt : INode,
|
|
21
|
-
ts : INode,
|
|
22
|
-
name : string,
|
|
23
|
-
value : ?any = null,
|
|
24
|
-
func : ?Callable = null
|
|
25
|
-
) : ClassBinding {
|
|
26
|
-
return new ClassBinding(rt, ts, name, null, propertify(value, func));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Represents a HTML class binding description
|
|
31
|
-
* @extends Binding
|
|
32
|
-
*/
|
|
33
|
-
export class ClassBinding extends Binding {
|
|
34
|
-
current : ? string | boolean = null;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Constructs a HTML class binding description
|
|
38
|
-
* @param rt {INode} is root component
|
|
39
|
-
* @param ts {INode} is this component
|
|
40
|
-
* @param name {String} is the name of attribute
|
|
41
|
-
* @param func {?Function} is the function to bound
|
|
42
|
-
* @param values {Array<IValue>} is the array of values to bind to
|
|
43
|
-
*/
|
|
44
|
-
constructor (
|
|
45
|
-
rt : INode,
|
|
46
|
-
ts : INode,
|
|
47
|
-
name : string,
|
|
48
|
-
func : ?Function,
|
|
49
|
-
...values : Array<IValue<any>>
|
|
50
|
-
) {
|
|
51
|
-
super(rt, ts, name, func, ...values);
|
|
52
|
-
|
|
53
|
-
this.seal();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Generates a function which updates the html class value
|
|
58
|
-
* @param name {String} The name of attribute
|
|
59
|
-
* @returns {Function} a function which will update attribute value
|
|
60
|
-
*/
|
|
61
|
-
bound (name : string) : Function {
|
|
62
|
-
|
|
63
|
-
function addClass (rt : INode, ts : INode, cl : string) {
|
|
64
|
-
rt.$.app.$run.addClass(ts.$.el, cl);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function removeClass (rt : INode, ts : INode, cl : string) {
|
|
68
|
-
rt.$.app.$run.removeClass(ts.$.el, cl);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return (rt : INode, ts : INode, value : string | boolean) => {
|
|
72
|
-
let current : ? string | boolean = this.current;
|
|
73
|
-
|
|
74
|
-
if (value !== current) {
|
|
75
|
-
if (typeof current === "string" && current !== "") {
|
|
76
|
-
removeClass(rt, ts, current);
|
|
77
|
-
}
|
|
78
|
-
if (typeof value === "boolean") {
|
|
79
|
-
if (value) {
|
|
80
|
-
addClass(rt, ts, name);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
removeClass(rt, ts, name);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
else if (typeof value === "string" && value !== "") {
|
|
87
|
-
addClass(rt, ts, value);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
this.current = value;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return value;
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
package/src/executor.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import { notOverwritten } from "./interfaces/errors";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Represents an executor unit interface
|
|
8
|
-
*/
|
|
9
|
-
export class Executor {
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Adds a CSS class
|
|
13
|
-
* @param el {HTMLElement} HTML element
|
|
14
|
-
* @param cl {string}
|
|
15
|
-
*/
|
|
16
|
-
addClass (el : HTMLElement, cl : string) {
|
|
17
|
-
throw notOverwritten();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Removes a CSS class
|
|
22
|
-
* @param el {HTMLElement} HTML element
|
|
23
|
-
* @param cl {string}
|
|
24
|
-
*/
|
|
25
|
-
removeClass (el : HTMLElement, cl : string) {
|
|
26
|
-
throw notOverwritten();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Sets a tag attribute
|
|
31
|
-
* @param el {HTMLElement} HTML element
|
|
32
|
-
* @param name {string}
|
|
33
|
-
* @param value {string}
|
|
34
|
-
*/
|
|
35
|
-
setAttribute (el : HTMLElement, name : string, value : string) {
|
|
36
|
-
throw notOverwritten();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Removes a tag attribute
|
|
41
|
-
* @param el {HTMLElement} HTML element
|
|
42
|
-
* @param name {string}
|
|
43
|
-
*/
|
|
44
|
-
removeAttribute (el : HTMLElement, name : string) {
|
|
45
|
-
throw notOverwritten();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Sets a style attribute
|
|
50
|
-
* @param el {HTMLElement} HTML element
|
|
51
|
-
* @param prop {string}
|
|
52
|
-
* @param value {string}
|
|
53
|
-
*/
|
|
54
|
-
setStyle (el : HTMLElement, prop : string, value : string) {
|
|
55
|
-
throw notOverwritten();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Inserts a child
|
|
60
|
-
* @param el {HTMLElement} HTML element
|
|
61
|
-
* @param child {HTMLElement | Text | Comment} Child to insert
|
|
62
|
-
* @param before {HTMLElement | Text | Comment} Child used as position locator
|
|
63
|
-
*/
|
|
64
|
-
insertBefore (el : HTMLElement, child : HTMLElement | Text | Comment, before : HTMLElement | Text | Comment) {
|
|
65
|
-
throw notOverwritten();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Appends a child
|
|
70
|
-
* @param el {HTMLElement} HTML element
|
|
71
|
-
* @param child {HTMLElement | Text | Comment} Child to append
|
|
72
|
-
*/
|
|
73
|
-
appendChild (el : HTMLElement, child : HTMLElement | Text | Comment) {
|
|
74
|
-
throw notOverwritten();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Calls a call-back function
|
|
79
|
-
* @param cb {Function} call-back function
|
|
80
|
-
*/
|
|
81
|
-
callCallback (cb : Function) {
|
|
82
|
-
throw notOverwritten();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export class InstantExecutor extends Executor {
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Adds a CSS class
|
|
90
|
-
* @param el {HTMLElement} HTML element
|
|
91
|
-
* @param cl {string}
|
|
92
|
-
*/
|
|
93
|
-
addClass (el : HTMLElement, cl : string) {
|
|
94
|
-
if (el) {
|
|
95
|
-
el.classList.add(cl);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Removes a CSS class
|
|
101
|
-
* @param el {HTMLElement} HTML element
|
|
102
|
-
* @param cl {string}
|
|
103
|
-
*/
|
|
104
|
-
removeClass (el : HTMLElement, cl : string) {
|
|
105
|
-
if (el) {
|
|
106
|
-
el.classList.remove(cl);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Sets a tag attribute
|
|
112
|
-
* @param el {HTMLElement} HTML element
|
|
113
|
-
* @param name {string}
|
|
114
|
-
* @param value {string}
|
|
115
|
-
*/
|
|
116
|
-
setAttribute (el : HTMLElement, name : string, value : string) {
|
|
117
|
-
el.setAttribute(name, value);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Removes a tag attribute
|
|
122
|
-
* @param el {HTMLElement} HTML element
|
|
123
|
-
* @param name {string}
|
|
124
|
-
*/
|
|
125
|
-
removeAttribute (el : HTMLElement, name : string) {
|
|
126
|
-
el.removeAttribute(name);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Sets a style attribute
|
|
131
|
-
* @param el {HTMLElement} HTML element
|
|
132
|
-
* @param prop {string}
|
|
133
|
-
* @param value {string}
|
|
134
|
-
*/
|
|
135
|
-
setStyle (el : HTMLElement, prop : string, value : string) {
|
|
136
|
-
el.style.setProperty(prop, value);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Inserts a child
|
|
141
|
-
* @param el {HTMLElement} HTML element
|
|
142
|
-
* @param child {HTMLElement | Text | Comment} Child to insert
|
|
143
|
-
* @param before {HTMLElement | Text | Comment} Child used as position locator
|
|
144
|
-
*/
|
|
145
|
-
insertBefore (el : HTMLElement, child : HTMLElement | Text | Comment, before : HTMLElement | Text | Comment) {
|
|
146
|
-
el.insertBefore(child, before);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Appends a child
|
|
151
|
-
* @param el {HTMLElement} HTML element
|
|
152
|
-
* @param child {HTMLElement | Text | Comment} Child to append
|
|
153
|
-
*/
|
|
154
|
-
appendChild (el : HTMLElement, child : HTMLElement | Text | Comment) {
|
|
155
|
-
el.appendChild(child);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Calls a call-back function
|
|
160
|
-
* @param cb {Function} call-back function
|
|
161
|
-
*/
|
|
162
|
-
callCallback (cb : Function) {
|
|
163
|
-
cb();
|
|
164
|
-
}
|
|
165
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Expression } from "./bind.js";
|
|
2
|
-
import { Destroyable } from "./interfaces/destroyable.js";
|
|
3
|
-
import { IBind } from "./interfaces/ibind.js";
|
|
4
|
-
import { IValue } from "./interfaces/ivalue.js";
|
|
5
|
-
import { ArrayModel, MapModel, ObjectModel, SetModel } from "./models.js";
|
|
6
|
-
import { App, INode, Extension, Tag, TextNode, Component } from "./node.js";
|
|
7
|
-
import { Pointer, Reference } from "./value.js";
|
|
8
|
-
import { ArrayView, MapView, ObjectView, SetView } from "./views.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
Expression,
|
|
14
|
-
Destroyable,
|
|
15
|
-
IBind, IValue,
|
|
16
|
-
ArrayModel, MapModel, ObjectModel, SetModel,
|
|
17
|
-
App, INode, Tag, Extension, TextNode, Component,
|
|
18
|
-
Pointer, Reference,
|
|
19
|
-
ArrayView, MapView, ObjectView, SetView
|
|
20
|
-
};
|