@base-framework/base 2.6.1 → 2.6.3
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 +1 -0
- package/dist/base.js +1 -0
- package/package.json +30 -26
- package/.jshintrc +0 -3
- package/base.js +0 -41
- package/base.min.js +0 -1
- package/core.js +0 -1
- package/data-tracker.js +0 -351
- package/es5/base.js +0 -2968
- package/es5/modules/ajax.js +0 -663
- package/es5/modules/animation.js +0 -188
- package/es5/modules/animations.js +0 -1080
- package/es5/modules/atom.js +0 -65
- package/es5/modules/component.js +0 -1310
- package/es5/modules/data-binder.js +0 -1131
- package/es5/modules/data.js +0 -1808
- package/es5/modules/date.js +0 -525
- package/es5/modules/form-validator.js +0 -324
- package/es5/modules/history.js +0 -126
- package/es5/modules/html-builder.js +0 -461
- package/es5/modules/layout.js +0 -1679
- package/es5/modules/mouse.js +0 -124
- package/es5/modules/nav-link.js +0 -123
- package/es5/modules/olderversions/animations-ease.js +0 -1095
- package/es5/modules/olderversions/animations-update.js +0 -1048
- package/es5/modules/olderversions/base-animations.js +0 -636
- package/es5/modules/olderversions/base-component-class.js +0 -100
- package/es5/modules/olderversions/base-data-binder-1.js +0 -407
- package/es5/modules/olderversions/base-data-binder-class.js +0 -358
- package/es5/modules/olderversions/base-layout-parser-class.js +0 -172
- package/es5/modules/olderversions/base-mode-1.js +0 -777
- package/es5/modules/olderversions/base-model-class.js +0 -585
- package/es5/modules/olderversions/data-binder/element-binding/base-data-binder-class.js +0 -358
- package/es5/modules/olderversions/data-binder/element-binding/base-model-class.js +0 -585
- package/es5/modules/olderversions/data-binder/model-binding/base-data-binder-class.js +0 -353
- package/es5/modules/olderversions/data-binder/model-binding/base-model-class.js +0 -604
- package/es5/modules/olderversions/data-binder-update-watcher.js +0 -640
- package/es5/modules/olderversions/data-tracker.js +0 -187
- package/es5/modules/olderversions/event-update.js +0 -666
- package/es5/modules/olderversions/nav-link.js +0 -119
- package/es5/modules/olderversions/router-with-templates-1.js +0 -785
- package/es5/modules/olderversions/router-with-templates.js +0 -701
- package/es5/modules/prototypes/ajax.js +0 -657
- package/es5/modules/prototypes/atom.js +0 -65
- package/es5/modules/prototypes/component.js +0 -972
- package/es5/modules/prototypes/data-binder.js +0 -1089
- package/es5/modules/prototypes/data.js +0 -1290
- package/es5/modules/prototypes/html-builder.js +0 -414
- package/es5/modules/prototypes/layout.js +0 -879
- package/es5/modules/router.js +0 -1680
- package/es5/modules/state.js +0 -274
- package/es6/.jshintrc +0 -3
- package/es6/base.js +0 -41
- package/es6/core.js +0 -1
- package/es6/data-tracker.js +0 -351
- package/es6/events.js +0 -602
- package/es6/legacy/es5/base.js +0 -2968
- package/es6/legacy/es5/modules/ajax.js +0 -663
- package/es6/legacy/es5/modules/animation.js +0 -188
- package/es6/legacy/es5/modules/animations.js +0 -1080
- package/es6/legacy/es5/modules/atom.js +0 -65
- package/es6/legacy/es5/modules/component.js +0 -1310
- package/es6/legacy/es5/modules/data-binder.js +0 -1131
- package/es6/legacy/es5/modules/data.js +0 -1808
- package/es6/legacy/es5/modules/date.js +0 -525
- package/es6/legacy/es5/modules/form-validator.js +0 -324
- package/es6/legacy/es5/modules/history.js +0 -126
- package/es6/legacy/es5/modules/html-builder.js +0 -461
- package/es6/legacy/es5/modules/layout.js +0 -1679
- package/es6/legacy/es5/modules/mouse.js +0 -124
- package/es6/legacy/es5/modules/nav-link.js +0 -123
- package/es6/legacy/es5/modules/olderversions/animations-ease.js +0 -1095
- package/es6/legacy/es5/modules/olderversions/animations-update.js +0 -1048
- package/es6/legacy/es5/modules/olderversions/base-animations.js +0 -636
- package/es6/legacy/es5/modules/olderversions/base-component-class.js +0 -100
- package/es6/legacy/es5/modules/olderversions/base-data-binder-1.js +0 -407
- package/es6/legacy/es5/modules/olderversions/base-data-binder-class.js +0 -358
- package/es6/legacy/es5/modules/olderversions/base-layout-parser-class.js +0 -172
- package/es6/legacy/es5/modules/olderversions/base-mode-1.js +0 -777
- package/es6/legacy/es5/modules/olderversions/base-model-class.js +0 -585
- package/es6/legacy/es5/modules/olderversions/data-binder/element-binding/base-data-binder-class.js +0 -358
- package/es6/legacy/es5/modules/olderversions/data-binder/element-binding/base-model-class.js +0 -585
- package/es6/legacy/es5/modules/olderversions/data-binder/model-binding/base-data-binder-class.js +0 -353
- package/es6/legacy/es5/modules/olderversions/data-binder/model-binding/base-model-class.js +0 -604
- package/es6/legacy/es5/modules/olderversions/data-binder-update-watcher.js +0 -640
- package/es6/legacy/es5/modules/olderversions/data-tracker.js +0 -187
- package/es6/legacy/es5/modules/olderversions/event-update.js +0 -666
- package/es6/legacy/es5/modules/olderversions/nav-link.js +0 -119
- package/es6/legacy/es5/modules/olderversions/router-with-templates-1.js +0 -785
- package/es6/legacy/es5/modules/olderversions/router-with-templates.js +0 -701
- package/es6/legacy/es5/modules/prototypes/ajax.js +0 -657
- package/es6/legacy/es5/modules/prototypes/atom.js +0 -65
- package/es6/legacy/es5/modules/prototypes/component.js +0 -972
- package/es6/legacy/es5/modules/prototypes/data-binder.js +0 -1089
- package/es6/legacy/es5/modules/prototypes/data.js +0 -1290
- package/es6/legacy/es5/modules/prototypes/html-builder.js +0 -414
- package/es6/legacy/es5/modules/prototypes/layout.js +0 -879
- package/es6/legacy/es5/modules/router.js +0 -1680
- package/es6/legacy/es5/modules/state.js +0 -274
- package/es6/main.js +0 -1331
- package/es6/modules/ajax/ajax.js +0 -514
- package/es6/modules/animation/animation.js +0 -236
- package/es6/modules/animations/animation-controller.js +0 -231
- package/es6/modules/animations/animation.js +0 -64
- package/es6/modules/animations/attr-movement.js +0 -66
- package/es6/modules/animations/css-movement.js +0 -170
- package/es6/modules/animations/movement.js +0 -131
- package/es6/modules/animations/value.js +0 -187
- package/es6/modules/atom/atom.js +0 -54
- package/es6/modules/component/component.js +0 -230
- package/es6/modules/component/event-helper.js +0 -119
- package/es6/modules/component/jot.js +0 -144
- package/es6/modules/component/state-helper.js +0 -262
- package/es6/modules/component/unit.js +0 -551
- package/es6/modules/data/attrs.js +0 -40
- package/es6/modules/data/basic-data.js +0 -500
- package/es6/modules/data/data-utils.js +0 -29
- package/es6/modules/data/data.js +0 -3
- package/es6/modules/data/deep-data.js +0 -541
- package/es6/modules/data/model-service.js +0 -528
- package/es6/modules/data/model.js +0 -133
- package/es6/modules/data/simple-data.js +0 -33
- package/es6/modules/data-binder/connection-tracker.js +0 -113
- package/es6/modules/data-binder/connection.js +0 -16
- package/es6/modules/data-binder/data-binder.js +0 -352
- package/es6/modules/data-binder/data-pub-sub.js +0 -141
- package/es6/modules/data-binder/data-source.js +0 -56
- package/es6/modules/data-binder/element-source.js +0 -219
- package/es6/modules/data-binder/one-way-connection.js +0 -46
- package/es6/modules/data-binder/one-way-source.js +0 -43
- package/es6/modules/data-binder/source.js +0 -36
- package/es6/modules/data-binder/two-way-connection.js +0 -75
- package/es6/modules/data-binder/two-way-source.js +0 -41
- package/es6/modules/date/date.js +0 -544
- package/es6/modules/history/history.js +0 -89
- package/es6/modules/html-builder/html-builder.js +0 -434
- package/es6/modules/import/import.js +0 -390
- package/es6/modules/layout/layout-builder.js +0 -1269
- package/es6/modules/layout/layout-parser.js +0 -134
- package/es6/modules/layout/watcher-helper.js +0 -282
- package/es6/modules/mouse/mouse.js +0 -114
- package/es6/modules/router/component-helper.js +0 -163
- package/es6/modules/router/history-controller.js +0 -216
- package/es6/modules/router/nav-link.js +0 -124
- package/es6/modules/router/route.js +0 -401
- package/es6/modules/router/router.js +0 -789
- package/es6/modules/router/utils.js +0 -31
- package/es6/modules/state/state-target.js +0 -91
- package/es6/modules/state/state.js +0 -171
- package/es6/package-lock.json +0 -13
- package/es6/package.json +0 -28
- package/es6/shared/objects.js +0 -99
- package/events.js +0 -602
- package/legacy/es5/base.js +0 -2968
- package/legacy/es5/modules/ajax.js +0 -663
- package/legacy/es5/modules/animation.js +0 -188
- package/legacy/es5/modules/animations.js +0 -1080
- package/legacy/es5/modules/atom.js +0 -65
- package/legacy/es5/modules/component.js +0 -1310
- package/legacy/es5/modules/data-binder.js +0 -1131
- package/legacy/es5/modules/data.js +0 -1808
- package/legacy/es5/modules/date.js +0 -525
- package/legacy/es5/modules/form-validator.js +0 -324
- package/legacy/es5/modules/history.js +0 -126
- package/legacy/es5/modules/html-builder.js +0 -461
- package/legacy/es5/modules/layout.js +0 -1679
- package/legacy/es5/modules/mouse.js +0 -124
- package/legacy/es5/modules/nav-link.js +0 -123
- package/legacy/es5/modules/olderversions/animations-ease.js +0 -1095
- package/legacy/es5/modules/olderversions/animations-update.js +0 -1048
- package/legacy/es5/modules/olderversions/base-animations.js +0 -636
- package/legacy/es5/modules/olderversions/base-component-class.js +0 -100
- package/legacy/es5/modules/olderversions/base-data-binder-1.js +0 -407
- package/legacy/es5/modules/olderversions/base-data-binder-class.js +0 -358
- package/legacy/es5/modules/olderversions/base-layout-parser-class.js +0 -172
- package/legacy/es5/modules/olderversions/base-mode-1.js +0 -777
- package/legacy/es5/modules/olderversions/base-model-class.js +0 -585
- package/legacy/es5/modules/olderversions/data-binder/element-binding/base-data-binder-class.js +0 -358
- package/legacy/es5/modules/olderversions/data-binder/element-binding/base-model-class.js +0 -585
- package/legacy/es5/modules/olderversions/data-binder/model-binding/base-data-binder-class.js +0 -353
- package/legacy/es5/modules/olderversions/data-binder/model-binding/base-model-class.js +0 -604
- package/legacy/es5/modules/olderversions/data-binder-update-watcher.js +0 -640
- package/legacy/es5/modules/olderversions/data-tracker.js +0 -187
- package/legacy/es5/modules/olderversions/event-update.js +0 -666
- package/legacy/es5/modules/olderversions/nav-link.js +0 -119
- package/legacy/es5/modules/olderversions/router-with-templates-1.js +0 -785
- package/legacy/es5/modules/olderversions/router-with-templates.js +0 -701
- package/legacy/es5/modules/prototypes/ajax.js +0 -657
- package/legacy/es5/modules/prototypes/atom.js +0 -65
- package/legacy/es5/modules/prototypes/component.js +0 -972
- package/legacy/es5/modules/prototypes/data-binder.js +0 -1089
- package/legacy/es5/modules/prototypes/data.js +0 -1290
- package/legacy/es5/modules/prototypes/html-builder.js +0 -414
- package/legacy/es5/modules/prototypes/layout.js +0 -879
- package/legacy/es5/modules/router.js +0 -1680
- package/legacy/es5/modules/state.js +0 -274
- package/main.js +0 -1331
- package/modules/ajax/ajax.js +0 -514
- package/modules/animation/animation.js +0 -236
- package/modules/animations/animation-controller.js +0 -231
- package/modules/animations/animation.js +0 -64
- package/modules/animations/attr-movement.js +0 -66
- package/modules/animations/css-movement.js +0 -170
- package/modules/animations/movement.js +0 -131
- package/modules/animations/value.js +0 -187
- package/modules/atom/atom.js +0 -54
- package/modules/component/component.js +0 -230
- package/modules/component/event-helper.js +0 -119
- package/modules/component/jot.js +0 -144
- package/modules/component/state-helper.js +0 -262
- package/modules/component/unit.js +0 -551
- package/modules/data/attrs.js +0 -40
- package/modules/data/basic-data.js +0 -500
- package/modules/data/data-utils.js +0 -29
- package/modules/data/data.js +0 -3
- package/modules/data/deep-data.js +0 -541
- package/modules/data/model-service.js +0 -528
- package/modules/data/model.js +0 -133
- package/modules/data/simple-data.js +0 -33
- package/modules/data-binder/connection-tracker.js +0 -113
- package/modules/data-binder/connection.js +0 -16
- package/modules/data-binder/data-binder.js +0 -352
- package/modules/data-binder/data-pub-sub.js +0 -141
- package/modules/data-binder/data-source.js +0 -56
- package/modules/data-binder/element-source.js +0 -219
- package/modules/data-binder/one-way-connection.js +0 -46
- package/modules/data-binder/one-way-source.js +0 -43
- package/modules/data-binder/source.js +0 -36
- package/modules/data-binder/two-way-connection.js +0 -75
- package/modules/data-binder/two-way-source.js +0 -41
- package/modules/date/date.js +0 -544
- package/modules/history/history.js +0 -89
- package/modules/html-builder/html-builder.js +0 -434
- package/modules/import/import.js +0 -390
- package/modules/layout/layout-builder.js +0 -1269
- package/modules/layout/layout-parser.js +0 -134
- package/modules/layout/watcher-helper.js +0 -282
- package/modules/mouse/mouse.js +0 -114
- package/modules/router/component-helper.js +0 -163
- package/modules/router/history-controller.js +0 -216
- package/modules/router/nav-link.js +0 -124
- package/modules/router/route.js +0 -401
- package/modules/router/router.js +0 -789
- package/modules/router/utils.js +0 -31
- package/modules/state/state-target.js +0 -91
- package/modules/state/state.js +0 -171
- package/shared/objects.js +0 -99
- package/update +0 -16
package/modules/import/import.js
DELETED
|
@@ -1,390 +0,0 @@
|
|
|
1
|
-
import {builder} from '../layout/layout-builder.js';
|
|
2
|
-
import {Jot} from "../component/jot.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* This will track previously loaded scripts and styles.
|
|
6
|
-
*/
|
|
7
|
-
const loaded = [];
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* This will check if a script or style has been loaded.
|
|
11
|
-
*
|
|
12
|
-
* @param {string} src
|
|
13
|
-
* @return {bool}
|
|
14
|
-
*/
|
|
15
|
-
const isLoaded = (src) => loaded.indexOf(src) !== -1;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* This will create a script atom.
|
|
19
|
-
*
|
|
20
|
-
* @param {object} props
|
|
21
|
-
* @return {object}
|
|
22
|
-
*/
|
|
23
|
-
const Script = (props) => ({
|
|
24
|
-
tag: 'script',
|
|
25
|
-
src: props.src,
|
|
26
|
-
async: false,
|
|
27
|
-
load(e)
|
|
28
|
-
{
|
|
29
|
-
loaded.push(props.src);
|
|
30
|
-
|
|
31
|
-
const callBack = props.load;
|
|
32
|
-
if(callBack)
|
|
33
|
-
{
|
|
34
|
-
callBack();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* This will create a style atom.
|
|
41
|
-
*
|
|
42
|
-
* @param {object} props
|
|
43
|
-
* @return {object}
|
|
44
|
-
*/
|
|
45
|
-
const Style = (props) => ({
|
|
46
|
-
tag: 'link',
|
|
47
|
-
rel: 'stylesheet',
|
|
48
|
-
type: 'text/css',
|
|
49
|
-
href: props.src,
|
|
50
|
-
load(e)
|
|
51
|
-
{
|
|
52
|
-
loaded.push(props.src);
|
|
53
|
-
|
|
54
|
-
const callBack = props.load;
|
|
55
|
-
if(callBack)
|
|
56
|
-
{
|
|
57
|
-
callBack();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Group
|
|
64
|
-
*
|
|
65
|
-
* This will setup a depends group to load all
|
|
66
|
-
* dependencies before loaded the script.
|
|
67
|
-
*/
|
|
68
|
-
class Group
|
|
69
|
-
{
|
|
70
|
-
constructor(callBack)
|
|
71
|
-
{
|
|
72
|
-
this.percent = 0;
|
|
73
|
-
this.loaded = 0;
|
|
74
|
-
this.total = 0;
|
|
75
|
-
this.callBack = callBack || null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* This will add the resource to the document.
|
|
80
|
-
*
|
|
81
|
-
* @param {string} src
|
|
82
|
-
*/
|
|
83
|
-
add(src)
|
|
84
|
-
{
|
|
85
|
-
this.total++;
|
|
86
|
-
let atom;
|
|
87
|
-
|
|
88
|
-
const load = this.update.bind(this);
|
|
89
|
-
if(src.indexOf('.css') !== -1)
|
|
90
|
-
{
|
|
91
|
-
atom = Style({
|
|
92
|
-
load,
|
|
93
|
-
src
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
else
|
|
97
|
-
{
|
|
98
|
-
atom = Script({
|
|
99
|
-
load,
|
|
100
|
-
src
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
builder.build(atom, document.head);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* This will add the dependencies to the document.
|
|
109
|
-
*
|
|
110
|
-
* @param {array} files
|
|
111
|
-
*/
|
|
112
|
-
addFiles(files)
|
|
113
|
-
{
|
|
114
|
-
if(!files)
|
|
115
|
-
{
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
for(var i = 0, length = files.length; i < length; i++)
|
|
120
|
-
{
|
|
121
|
-
var src = files[i];
|
|
122
|
-
if(!isLoaded(src))
|
|
123
|
-
{
|
|
124
|
-
this.add(src);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
update()
|
|
130
|
-
{
|
|
131
|
-
const percent = this.updateProgress();
|
|
132
|
-
if(percent >= 100)
|
|
133
|
-
{
|
|
134
|
-
var callBack = this.callBack;
|
|
135
|
-
if(callBack)
|
|
136
|
-
{
|
|
137
|
-
callBack();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
updateProgress()
|
|
143
|
-
{
|
|
144
|
-
++this.loaded;
|
|
145
|
-
return (this.percent = Math.floor(this.loaded / this.total * 100));
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* This will load the module.
|
|
151
|
-
*
|
|
152
|
-
* @param {string} src
|
|
153
|
-
* @param {function} callBack
|
|
154
|
-
* @return {object}
|
|
155
|
-
*/
|
|
156
|
-
const loadModule = (src, callBack) =>
|
|
157
|
-
{
|
|
158
|
-
import(src).then(module =>
|
|
159
|
-
{
|
|
160
|
-
if(callBack)
|
|
161
|
-
{
|
|
162
|
-
callBack(module);
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* This will check if an object is a contructor.
|
|
169
|
-
*
|
|
170
|
-
* @param {object|function} object
|
|
171
|
-
* @returns {bool}
|
|
172
|
-
*/
|
|
173
|
-
const isConstructor = (object) =>
|
|
174
|
-
{
|
|
175
|
-
if(!object)
|
|
176
|
-
{
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return (typeof object?.prototype?.constructor === 'function');
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* This will render the module.
|
|
185
|
-
*
|
|
186
|
-
* @param {object} layout
|
|
187
|
-
* @param {object} ele
|
|
188
|
-
* @param {object} parent
|
|
189
|
-
* @param {function} callBack
|
|
190
|
-
* @return {object}
|
|
191
|
-
*/
|
|
192
|
-
const render = (layout, ele, parent) =>
|
|
193
|
-
{
|
|
194
|
-
const frag = builder.build(layout, null, parent);
|
|
195
|
-
const firstChild = frag.firstChild;
|
|
196
|
-
ele.after(frag);
|
|
197
|
-
return firstChild;
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* This will create a comment.
|
|
202
|
-
*
|
|
203
|
-
* @param {object} props
|
|
204
|
-
* @returns {object}
|
|
205
|
-
*/
|
|
206
|
-
const Comment = (props) => ({
|
|
207
|
-
tag: 'comment',
|
|
208
|
-
text: 'import placeholder',
|
|
209
|
-
onCreated: props.onCreated
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* This will create an import wrapper component that
|
|
214
|
-
* will wrap the comment atom to pass route to the
|
|
215
|
-
* imported layout.
|
|
216
|
-
*
|
|
217
|
-
* @param {object} props
|
|
218
|
-
* @returns {object}
|
|
219
|
-
*/
|
|
220
|
-
const ImportWrapper = Jot(
|
|
221
|
-
{
|
|
222
|
-
render()
|
|
223
|
-
{
|
|
224
|
-
return Comment(
|
|
225
|
-
{
|
|
226
|
-
onCreated: (ele) =>
|
|
227
|
-
{
|
|
228
|
-
const src = this.src;
|
|
229
|
-
if(!src)
|
|
230
|
-
{
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* This will set up a resource group to load the
|
|
236
|
-
* depends before the module.
|
|
237
|
-
*/
|
|
238
|
-
if(this.depends)
|
|
239
|
-
{
|
|
240
|
-
const group = new Group(() =>
|
|
241
|
-
{
|
|
242
|
-
this.loadAndRender(ele);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
group.addFiles(this.depends);
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
this.loadAndRender(ele);
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
},
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* This will get the layout.
|
|
256
|
-
*
|
|
257
|
-
* @param {object} module
|
|
258
|
-
* @returns {object|null}
|
|
259
|
-
*/
|
|
260
|
-
getLayout(module)
|
|
261
|
-
{
|
|
262
|
-
let layout = module.default;
|
|
263
|
-
if(!layout)
|
|
264
|
-
{
|
|
265
|
-
return null;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* This will check if the import is useing a custom
|
|
270
|
-
* callback to set up the module.
|
|
271
|
-
*/
|
|
272
|
-
const callBack = this.callBack;
|
|
273
|
-
if(callBack)
|
|
274
|
-
{
|
|
275
|
-
layout = callBack(layout);
|
|
276
|
-
}
|
|
277
|
-
else
|
|
278
|
-
{
|
|
279
|
-
if(isConstructor(layout))
|
|
280
|
-
{
|
|
281
|
-
/**
|
|
282
|
-
* This will set up the layout as a component and pass
|
|
283
|
-
* the import props like persist and route.
|
|
284
|
-
*/
|
|
285
|
-
layout = new layout();
|
|
286
|
-
layout.route = this.route;
|
|
287
|
-
|
|
288
|
-
if(this.persist)
|
|
289
|
-
{
|
|
290
|
-
layout.persist = true;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
else
|
|
294
|
-
{
|
|
295
|
-
/**
|
|
296
|
-
* This will set up the layout as a n atom.
|
|
297
|
-
*/
|
|
298
|
-
layout = layout();
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
return (this.layout = layout);
|
|
303
|
-
},
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* This will load the module and render the layout.
|
|
307
|
-
*
|
|
308
|
-
* @param {object} ele
|
|
309
|
-
*/
|
|
310
|
-
loadAndRender(ele)
|
|
311
|
-
{
|
|
312
|
-
loadModule(this.src, (module) =>
|
|
313
|
-
{
|
|
314
|
-
this.loaded = true;
|
|
315
|
-
const layout = this.layout || this.getLayout(module);
|
|
316
|
-
this.layoutRoot = render(layout, ele, this.parent);
|
|
317
|
-
});
|
|
318
|
-
},
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* This will check if the layout should be updated.
|
|
322
|
-
*
|
|
323
|
-
* @param {object} layout
|
|
324
|
-
* @returns {bool}
|
|
325
|
-
*/
|
|
326
|
-
shouldUpdate(layout)
|
|
327
|
-
{
|
|
328
|
-
if(this.updateLayout === true)
|
|
329
|
-
{
|
|
330
|
-
return true;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
return (this.updateLayout = (layout && layout.isUnit && typeof layout.update === 'function'));
|
|
334
|
-
},
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* This will update the module layout.
|
|
338
|
-
*
|
|
339
|
-
* @param {object} params
|
|
340
|
-
*/
|
|
341
|
-
updateModuleLayout(params)
|
|
342
|
-
{
|
|
343
|
-
const layout = this.layout;
|
|
344
|
-
if(this.shouldUpdate(layout))
|
|
345
|
-
{
|
|
346
|
-
layout.update(params);
|
|
347
|
-
}
|
|
348
|
-
},
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* This will call if the import is added to a route. This will pass
|
|
352
|
-
* the update params to the imported layout.
|
|
353
|
-
*
|
|
354
|
-
* @param {object} params
|
|
355
|
-
*/
|
|
356
|
-
update(params)
|
|
357
|
-
{
|
|
358
|
-
if(this.loaded === true)
|
|
359
|
-
{
|
|
360
|
-
this.updateModuleLayout(params);
|
|
361
|
-
}
|
|
362
|
-
},
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* This will remove the imported layout when the
|
|
366
|
-
* comment is being removed.
|
|
367
|
-
*
|
|
368
|
-
* @returns {void}
|
|
369
|
-
*/
|
|
370
|
-
beforeDestroy()
|
|
371
|
-
{
|
|
372
|
-
if(!this.layoutRoot)
|
|
373
|
-
{
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
builder.removeElement(this.layoutRoot);
|
|
378
|
-
}
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* This will import a module.
|
|
383
|
-
*
|
|
384
|
-
* @param {object} props
|
|
385
|
-
* @returns {object}
|
|
386
|
-
*/
|
|
387
|
-
export const Import = (props) =>
|
|
388
|
-
{
|
|
389
|
-
return new ImportWrapper(props);
|
|
390
|
-
};
|