render-core 1.4.8 → 1.4.10
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/index.d.ts +14 -8
- package/index.js +18 -13
- package/kernel/delivery/delivery.js +3 -3
- package/kernel/directive/property/v-bind.js +2 -2
- package/kernel/directive/react/v-model.js +1 -1
- package/kernel/proxyer/getProxy.d.ts +0 -3
- package/kernel/proxyer/getProxy.js +3 -7
- package/kernel/renderer/initRender.js +9 -10
- package/kernel/renderer/postRender.js +10 -11
- package/kernel/renderer/rawRender.js +10 -11
- package/kernel/renderer/updateRender.js +14 -13
- package/kernel/router/router.js +3 -3
- package/package.json +1 -4
- package/system/generic/component/ComponentGeneric.d.ts +1 -1
- package/system/generic/controller/ControllerGeneric.d.ts +10 -4
- package/system/generic/data/ComputedDataGeneric.d.ts +13 -0
- package/system/generic/data/ComputedDataGeneric.js +1 -0
- package/system/generic/data/WatcherDataGeneric.d.ts +13 -0
- package/system/generic/data/WatcherDataGeneric.js +1 -0
- package/system/injection/injection.d.ts +8 -3
- package/system/injection/injection.js +22 -12
- package/system/injection/injector.d.ts +30 -0
- package/system/injection/injector.js +77 -0
- package/system/lifecycle/mount.js +5 -8
- package/system/loader/loader.js +1 -1
- package/system/output/errorUtility.d.ts +3 -0
- package/system/output/errorUtility.js +9 -0
- package/system/prototype/ContextController.d.ts +9 -8
- package/system/prototype/ContextController.js +1 -7
- package/system/recorder/table2/system_func_2.d.ts +5 -0
- package/system/recorder/table2/system_func_2.js +8 -0
- package/system/utility/data/dataUtility.d.ts +5 -0
- package/system/utility/data/dataUtility.js +12 -0
- package/system/utility/directive/cmdUtility.d.ts +15 -0
- package/system/utility/directive/cmdUtility.js +43 -0
- package/system/utility/initiate/miscUtility.d.ts +6 -0
- package/system/utility/initiate/miscUtility.js +12 -0
- package/system/utility/initiate/templateUtility.d.ts +6 -0
- package/system/utility/initiate/templateUtility.js +11 -0
- package/system/utility/react/inputType.d.ts +25 -0
- package/system/utility/react/inputType.js +40 -0
- package/system/utility/react/inputUtility.d.ts +19 -0
- package/system/utility/react/inputUtility.js +125 -0
- package/system/utility/react/modelUtility.d.ts +15 -0
- package/system/utility/react/modelUtility.js +64 -0
- package/system/utility/react/sectionUtility.d.ts +6 -0
- package/system/utility/react/sectionUtility.js +123 -0
- package/system/utility/style/styleUtility.d.ts +29 -0
- package/system/utility/style/styleUtility.js +102 -0
- package/tension/prototype/AbstractComponent.d.ts +1 -1
- package/tension/prototype/HooksAction.js +1 -1
- package/xboot/Entrance.d.ts +3 -3
- package/xboot/Entrance.js +4 -5
- package/xboot/RenderProcessor.js +2 -2
- package/xboot/TagProcessor.js +4 -8
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { resolve_props } from "../resolver/props";
|
|
2
|
+
import { parse_directive_refs } from "../../kernel/directive/ref/v-ref";
|
|
3
|
+
import { get_user_anonymous_ext, get_user_ext_http } from "../recorder/table3/system_func_3";
|
|
4
|
+
import { get_path_variable } from "../recorder/table1/system_func_1";
|
|
5
|
+
export function inject_$name_to_data(name, origin) {
|
|
6
|
+
Reflect.set(origin, "$name", name);
|
|
7
|
+
}
|
|
8
|
+
export function inject_$props_to_data(childNode, meta, origin) {
|
|
9
|
+
var props = resolve_props(childNode, meta);
|
|
10
|
+
Reflect.set(origin, "$props", props);
|
|
11
|
+
}
|
|
12
|
+
export function inject_$refs_to_data(template, origin) {
|
|
13
|
+
var refs = new Map();
|
|
14
|
+
parse_directive_refs(template.children, refs);
|
|
15
|
+
Reflect.set(origin, "$refs", refs);
|
|
16
|
+
}
|
|
17
|
+
export function inject_$http_to_data(origin) {
|
|
18
|
+
Reflect.set(origin, "$http", get_user_ext_http());
|
|
19
|
+
}
|
|
20
|
+
export function inject_$pathVariable_to_data(origin) {
|
|
21
|
+
Reflect.set(origin, "$pathVariable", get_path_variable());
|
|
22
|
+
}
|
|
23
|
+
export function inject_$plugin_to_data(config) {
|
|
24
|
+
Reflect.set(config, "$plugins", function (name) {
|
|
25
|
+
return get_user_anonymous_ext(name);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//注入对象
|
|
29
|
+
export function inject_$commit_to_data(data, commit) {
|
|
30
|
+
Reflect.set(data, "$commit", commit);
|
|
31
|
+
}
|
|
32
|
+
//注入对象
|
|
33
|
+
export function inject_$publish_to_data(data, publisher) {
|
|
34
|
+
Reflect.set(data, "$publish", publisher);
|
|
35
|
+
}
|
|
36
|
+
export function inject_$setter_to_data(data, setter) {
|
|
37
|
+
Reflect.set(data, "$set", setter);
|
|
38
|
+
}
|
|
39
|
+
export function inject_$getter_to_data(data, getter) {
|
|
40
|
+
Reflect.set(data, "$get", getter);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @param controller
|
|
45
|
+
* @param proto
|
|
46
|
+
*/
|
|
47
|
+
export function inject_method_to_data(controller, proto) {
|
|
48
|
+
var methods = Object.getOwnPropertyNames(proto.getMethods());
|
|
49
|
+
methods.forEach(function (value) {
|
|
50
|
+
if (value.match(/^\$\$[a-zA-Z0-9_]*/) !== null)
|
|
51
|
+
Reflect.set(controller.originalData, value, proto.getMethods()[value].bind(controller.originalData));
|
|
52
|
+
else
|
|
53
|
+
Reflect.set(controller.originalData, value, proto.getMethods()[value].bind(controller.dataForMethod));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @param controller
|
|
59
|
+
* @param proto
|
|
60
|
+
*/
|
|
61
|
+
export function inject_watcher_to_controller(controller, proto) {
|
|
62
|
+
var methods = Object.getOwnPropertyNames(proto.getWatcher());
|
|
63
|
+
methods.forEach(function (value) {
|
|
64
|
+
Reflect.set(controller.watcher, value, proto.getWatcher()[value].bind(controller.originalData));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
*
|
|
69
|
+
* @param controller
|
|
70
|
+
* @param proto
|
|
71
|
+
*/
|
|
72
|
+
export function inject_computed_to_controller(controller, proto) {
|
|
73
|
+
var methods = Object.getOwnPropertyNames(proto.getComputed());
|
|
74
|
+
methods.forEach(function (value) {
|
|
75
|
+
Reflect.set(controller.computed, value, proto.getComputed()[value].bind(controller.originalData));
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -15,9 +15,8 @@ export function archive_mount(controller, proto, parent, child, tagTemplate) {
|
|
|
15
15
|
controller.componentAttachedRootElement = renderSpace;
|
|
16
16
|
//开始渲染
|
|
17
17
|
parent.replaceChild(renderSpace, child);
|
|
18
|
-
while (tagTemplate.hasChildNodes())
|
|
18
|
+
while (tagTemplate.hasChildNodes())
|
|
19
19
|
renderSpace.append(tagTemplate.firstChild);
|
|
20
|
-
}
|
|
21
20
|
}
|
|
22
21
|
/**
|
|
23
22
|
* Insert elements without div element
|
|
@@ -28,16 +27,14 @@ export function extract_mount(root) {
|
|
|
28
27
|
begin.setAttribute("anchor", "begin");
|
|
29
28
|
begin.setAttribute("style", "display:none");
|
|
30
29
|
root.componentAttachedRootElement.parentNode.insertBefore(begin, root.componentAttachedRootElement);
|
|
31
|
-
root.
|
|
32
|
-
while (root.componentAttachedRootElement.hasChildNodes())
|
|
33
|
-
//插入元素到根之前
|
|
30
|
+
root.anchorBegin = begin;
|
|
31
|
+
while (root.componentAttachedRootElement.hasChildNodes())
|
|
34
32
|
root.componentAttachedRootElement.parentNode.insertBefore(root.componentAttachedRootElement.firstChild, root.componentAttachedRootElement);
|
|
35
|
-
}
|
|
36
33
|
var parent = root.componentAttachedRootElement.parentNode;
|
|
37
34
|
// @ts-ignore
|
|
38
35
|
root.anchor = root.componentAttachedRootElement;
|
|
39
|
-
root.
|
|
40
|
-
root.
|
|
36
|
+
root.anchorEnd.setAttribute("anchor", "end");
|
|
37
|
+
root.anchorBegin.setAttribute("style", "display:none");
|
|
41
38
|
root.componentAttachedRootElement = parent;
|
|
42
39
|
}
|
|
43
40
|
export function mountForUpdate(tagTemplate) {
|
package/system/loader/loader.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { ControllerGeneric } from "../generic/controller/ControllerGeneric";
|
|
2
2
|
import { Component } from "../../index";
|
|
3
|
+
import { OriginalDataGeneric } from "../generic/data/OriginalDataGeneric";
|
|
4
|
+
import { ComputedDataGeneric } from "../generic/data/ComputedDataGeneric";
|
|
5
|
+
import { WatcherDataGeneric } from "../generic/data/WatcherDataGeneric";
|
|
3
6
|
export declare class ContextController implements ControllerGeneric {
|
|
4
7
|
componentAttachedRootElement: ParentNode | Element;
|
|
5
8
|
prototypeOfComponent: Component;
|
|
6
9
|
parentController: ContextController;
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
anchorBegin: HTMLElement;
|
|
11
|
+
anchorEnd: HTMLElement;
|
|
9
12
|
componentConfig: {
|
|
10
13
|
boxMode: boolean;
|
|
11
14
|
plugins?: Map<string, any>;
|
|
12
15
|
};
|
|
13
|
-
originalData:
|
|
14
|
-
dataForMethod:
|
|
15
|
-
dataForComputed:
|
|
16
|
-
dataForWatcher:
|
|
16
|
+
originalData: OriginalDataGeneric;
|
|
17
|
+
dataForMethod: OriginalDataGeneric;
|
|
18
|
+
dataForComputed: ComputedDataGeneric;
|
|
19
|
+
dataForWatcher: WatcherDataGeneric;
|
|
17
20
|
salt: Map<string, any>;
|
|
18
21
|
lazyComponent: Map<string, {}>;
|
|
19
22
|
slaveComponent: ContextController[];
|
|
@@ -22,8 +25,6 @@ export declare class ContextController implements ControllerGeneric {
|
|
|
22
25
|
watcher: {};
|
|
23
26
|
constructor(config: {
|
|
24
27
|
boxMode: boolean;
|
|
25
|
-
$plugins?: Map<string, any>;
|
|
26
28
|
});
|
|
27
29
|
receiver(method: string, ...args: any[]): any;
|
|
28
|
-
flush(): void;
|
|
29
30
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { update_Render } from "../../kernel/renderer/updateRender";
|
|
2
1
|
var ContextController = /** @class */ (function () {
|
|
3
|
-
//构造函数
|
|
4
2
|
function ContextController(config) {
|
|
3
|
+
this.componentConfig = config;
|
|
5
4
|
this.lazyComponent = new Map();
|
|
6
5
|
this.slaveComponent = Array();
|
|
7
6
|
this.salt = new Map();
|
|
8
|
-
this.componentConfig = config;
|
|
9
7
|
}
|
|
10
|
-
//接收器
|
|
11
8
|
ContextController.prototype.receiver = function (method) {
|
|
12
9
|
var args = [];
|
|
13
10
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
@@ -15,9 +12,6 @@ var ContextController = /** @class */ (function () {
|
|
|
15
12
|
}
|
|
16
13
|
return this.prototypeOfComponent.getMethods()[method].apply(this.dataForMethod, args);
|
|
17
14
|
};
|
|
18
|
-
ContextController.prototype.flush = function () {
|
|
19
|
-
update_Render(this);
|
|
20
|
-
};
|
|
21
15
|
return ContextController;
|
|
22
16
|
}());
|
|
23
17
|
export { ContextController };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This func used to generate a new original data form prototype
|
|
3
|
+
* @param data
|
|
4
|
+
*/
|
|
5
|
+
export function dataInject(data) {
|
|
6
|
+
var out = {};
|
|
7
|
+
var keys = Object.getOwnPropertyNames(data);
|
|
8
|
+
keys.forEach(function (value) {
|
|
9
|
+
out[value] = data[value];
|
|
10
|
+
});
|
|
11
|
+
return out;
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ContextController } from "../../prototype/ContextController";
|
|
2
|
+
import { Component } from "../../../index";
|
|
3
|
+
/**
|
|
4
|
+
* This function is used to parse_directive those commands which should be executed before mount.
|
|
5
|
+
* @param tagTemplate
|
|
6
|
+
* @param proto
|
|
7
|
+
* @param controller
|
|
8
|
+
*/
|
|
9
|
+
export declare function directive_parse_collection_for_before(tagTemplate: Element, proto: Component, controller: ContextController): void;
|
|
10
|
+
/**
|
|
11
|
+
* This function is used to parse_directive those commands which should be executed after mount.
|
|
12
|
+
* @param templateSpace
|
|
13
|
+
* @param controller
|
|
14
|
+
*/
|
|
15
|
+
export declare function directive_parse_collection_for_after(templateSpace: ParentNode, controller: ContextController): void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { add_label_to_element } from "../initiate/miscUtility";
|
|
2
|
+
import { parse_directive_event } from "../../../kernel/directive/method/v-on";
|
|
3
|
+
import { parse_directive_html } from "../../../kernel/directive/data/v-html";
|
|
4
|
+
import { parse_directive_txt } from "../../../kernel/directive/data/v-txt";
|
|
5
|
+
import { parse_directive_model } from "../../../kernel/directive/react/v-model";
|
|
6
|
+
import { parse_directive_bind } from "../../../kernel/directive/property/v-bind";
|
|
7
|
+
import { parse_directive_show } from "../../../kernel/directive/justify/v-show";
|
|
8
|
+
import { parse_directive_render } from "../../../kernel/directive/justify/v-render";
|
|
9
|
+
import { parse_directive_if } from "../../../kernel/directive/justify/v-if";
|
|
10
|
+
import { parse_directive_switch } from "../../../kernel/directive/justify/v-switch";
|
|
11
|
+
import { parse_directive_for_of } from "../../../kernel/directive/loop/v-for";
|
|
12
|
+
import { parse_directive_salt_extract } from "../../../kernel/directive/salt/v-solt";
|
|
13
|
+
import { parse_directive_expression } from "../../../kernel/directive/data/v-el";
|
|
14
|
+
import { parse_directive_for_map } from "../../../kernel/directive/loop/v-map";
|
|
15
|
+
/**
|
|
16
|
+
* This function is used to parse_directive those commands which should be executed before mount.
|
|
17
|
+
* @param tagTemplate
|
|
18
|
+
* @param proto
|
|
19
|
+
* @param controller
|
|
20
|
+
*/
|
|
21
|
+
export function directive_parse_collection_for_before(tagTemplate, proto, controller) {
|
|
22
|
+
add_label_to_element(tagTemplate.children, proto.getName());
|
|
23
|
+
parse_directive_event(tagTemplate.children, proto.getMethods(), controller.dataForMethod, controller.originalData);
|
|
24
|
+
parse_directive_html(tagTemplate.children, controller.dataForMethod, controller);
|
|
25
|
+
parse_directive_txt(tagTemplate.children, controller.dataForMethod, controller);
|
|
26
|
+
parse_directive_model(tagTemplate.children, controller.dataForMethod);
|
|
27
|
+
parse_directive_bind(tagTemplate.children, controller.dataForMethod);
|
|
28
|
+
parse_directive_salt_extract(tagTemplate.children, controller);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* This function is used to parse_directive those commands which should be executed after mount.
|
|
32
|
+
* @param templateSpace
|
|
33
|
+
* @param controller
|
|
34
|
+
*/
|
|
35
|
+
export function directive_parse_collection_for_after(templateSpace, controller) {
|
|
36
|
+
parse_directive_show(templateSpace.children, controller.dataForMethod);
|
|
37
|
+
parse_directive_render(templateSpace.children, controller.dataForMethod);
|
|
38
|
+
parse_directive_if(templateSpace.children, controller.dataForMethod);
|
|
39
|
+
parse_directive_switch(templateSpace.children, controller.dataForMethod);
|
|
40
|
+
parse_directive_for_map(templateSpace.children, controller.dataForMethod);
|
|
41
|
+
parse_directive_for_of(templateSpace.children, controller.dataForMethod);
|
|
42
|
+
parse_directive_expression(controller.componentAttachedRootElement, controller.dataForMethod, controller);
|
|
43
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This func used to add tag label to the content of the user tag
|
|
3
|
+
* @param nodes
|
|
4
|
+
* @param component
|
|
5
|
+
*/
|
|
6
|
+
export function add_label_to_element(nodes, component) {
|
|
7
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
8
|
+
nodes[i].setAttribute("cpn", component);
|
|
9
|
+
var kk = nodes[i].children;
|
|
10
|
+
add_label_to_element(kk, component);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This func used to get the view tag from the template
|
|
3
|
+
* @param proto
|
|
4
|
+
*/
|
|
5
|
+
export function getTemplate(proto) {
|
|
6
|
+
var temp = document.createElement("div");
|
|
7
|
+
temp.innerHTML = proto.getTemplate();
|
|
8
|
+
var template = temp.getElementsByTagName("template")[0];
|
|
9
|
+
var content = template.content;
|
|
10
|
+
return content.querySelector("view");
|
|
11
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ContextController } from "../../prototype/ContextController";
|
|
2
|
+
/**
|
|
3
|
+
* This func used to resolve input-data which is the text type
|
|
4
|
+
* @param target
|
|
5
|
+
* @param doc
|
|
6
|
+
* @param controller
|
|
7
|
+
*/
|
|
8
|
+
export declare function textType(target: any, doc: any, controller: ContextController): void;
|
|
9
|
+
/**
|
|
10
|
+
* This func used to resolve input-data which is the assign type
|
|
11
|
+
* @param target
|
|
12
|
+
* @param controller
|
|
13
|
+
*/
|
|
14
|
+
export declare function assignType(target: any, controller: ContextController): void;
|
|
15
|
+
/**
|
|
16
|
+
* This func used to resolve input-data which is the file type
|
|
17
|
+
* @param target
|
|
18
|
+
* @param controller
|
|
19
|
+
*/
|
|
20
|
+
export declare function fileType(target: any, controller: ContextController): void;
|
|
21
|
+
/**
|
|
22
|
+
* This func used to resolve input-data which is the check type
|
|
23
|
+
* @param target
|
|
24
|
+
*/
|
|
25
|
+
export declare function checkType(target: any): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This func used to resolve input-data which is the text type
|
|
3
|
+
* @param target
|
|
4
|
+
* @param doc
|
|
5
|
+
* @param controller
|
|
6
|
+
*/
|
|
7
|
+
export function textType(target, doc, controller) {
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
target.value = controller.dataForMethod[target.getAttribute("name")];
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
target.focus();
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
target.setSelectionRange(doc.start, doc.start);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* This func used to resolve input-data which is the assign type
|
|
17
|
+
* @param target
|
|
18
|
+
* @param controller
|
|
19
|
+
*/
|
|
20
|
+
export function assignType(target, controller) {
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
target.value = controller.dataForMethod[target.getAttribute("name")];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* This func used to resolve input-data which is the file type
|
|
26
|
+
* @param target
|
|
27
|
+
* @param controller
|
|
28
|
+
*/
|
|
29
|
+
export function fileType(target, controller) {
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
target.files = controller.dataForMethod[target.getAttribute("name")];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* This func used to resolve input-data which is the check type
|
|
35
|
+
* @param target
|
|
36
|
+
*/
|
|
37
|
+
export function checkType(target) {
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
target.checked = "checked";
|
|
40
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare function inputUtility(element: Element, space: Object): void;
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param element
|
|
5
|
+
* @param space
|
|
6
|
+
*/
|
|
7
|
+
export declare function filesType(element: Element, space: Object): void;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param element
|
|
11
|
+
* @param space
|
|
12
|
+
*/
|
|
13
|
+
export declare function selectUtility(element: Element, space: Object): void;
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param element
|
|
17
|
+
* @param space
|
|
18
|
+
*/
|
|
19
|
+
export declare function textareaUtility(element: Element, space: Object): void;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export function inputUtility(element, space) {
|
|
2
|
+
switch (element.getAttribute("type")) {
|
|
3
|
+
case "text":
|
|
4
|
+
editType(element, space);
|
|
5
|
+
break;
|
|
6
|
+
case "color":
|
|
7
|
+
assignType(element, space);
|
|
8
|
+
break;
|
|
9
|
+
case "date":
|
|
10
|
+
assignType(element, space);
|
|
11
|
+
break;
|
|
12
|
+
case "time":
|
|
13
|
+
assignType(element, space);
|
|
14
|
+
break;
|
|
15
|
+
case "email":
|
|
16
|
+
editType(element, space);
|
|
17
|
+
break;
|
|
18
|
+
case "url":
|
|
19
|
+
editType(element, space);
|
|
20
|
+
break;
|
|
21
|
+
case "week":
|
|
22
|
+
assignType(element, space);
|
|
23
|
+
break;
|
|
24
|
+
case "tel":
|
|
25
|
+
editType(element, space);
|
|
26
|
+
break;
|
|
27
|
+
case "search":
|
|
28
|
+
editType(element, space);
|
|
29
|
+
break;
|
|
30
|
+
case "range":
|
|
31
|
+
assignType(element, space);
|
|
32
|
+
break;
|
|
33
|
+
case "radio":
|
|
34
|
+
assignType(element, space);
|
|
35
|
+
break;
|
|
36
|
+
case "password":
|
|
37
|
+
editType(element, space);
|
|
38
|
+
break;
|
|
39
|
+
case "number":
|
|
40
|
+
editType(element, space);
|
|
41
|
+
break;
|
|
42
|
+
case "month":
|
|
43
|
+
assignType(element, space);
|
|
44
|
+
break;
|
|
45
|
+
case "hidden":
|
|
46
|
+
editType(element, space);
|
|
47
|
+
break;
|
|
48
|
+
case "file":
|
|
49
|
+
filesType(element, space);
|
|
50
|
+
break;
|
|
51
|
+
case "datetime-local":
|
|
52
|
+
assignType(element, space);
|
|
53
|
+
break;
|
|
54
|
+
case "datetime":
|
|
55
|
+
assignType(element, space);
|
|
56
|
+
break;
|
|
57
|
+
case "checkbox":
|
|
58
|
+
assignType(element, space);
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
console.log("This type input can`t be tackled!");
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* @param element
|
|
68
|
+
* @param space
|
|
69
|
+
*/
|
|
70
|
+
function assignType(element, space) {
|
|
71
|
+
Reflect.set(space, "origin", {
|
|
72
|
+
tag: element.tagName,
|
|
73
|
+
id: element.getAttribute("id"),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
*
|
|
78
|
+
* @param element
|
|
79
|
+
* @param space
|
|
80
|
+
*/
|
|
81
|
+
function editType(element, space) {
|
|
82
|
+
Reflect.set(space, "origin", {
|
|
83
|
+
tag: element.tagName,
|
|
84
|
+
id: element.getAttribute("id"),
|
|
85
|
+
// @ts-ignore
|
|
86
|
+
start: element.selectionStart
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
* @param element
|
|
92
|
+
* @param space
|
|
93
|
+
*/
|
|
94
|
+
export function filesType(element, space) {
|
|
95
|
+
Reflect.set(space, "origin", {
|
|
96
|
+
tag: element.tagName,
|
|
97
|
+
id: element.getAttribute("id")
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
* @param element
|
|
103
|
+
* @param space
|
|
104
|
+
*/
|
|
105
|
+
export function selectUtility(element, space) {
|
|
106
|
+
Reflect.set(space, "origin", {
|
|
107
|
+
tag: element.tagName,
|
|
108
|
+
id: element.getAttribute("id"),
|
|
109
|
+
// @ts-ignore
|
|
110
|
+
selected: element.value
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
*
|
|
115
|
+
* @param element
|
|
116
|
+
* @param space
|
|
117
|
+
*/
|
|
118
|
+
export function textareaUtility(element, space) {
|
|
119
|
+
Reflect.set(space, "origin", {
|
|
120
|
+
tag: element.tagName,
|
|
121
|
+
id: element.getAttribute("id"),
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
start: element.selectionStart
|
|
124
|
+
});
|
|
125
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This func used to make a flag to the input element
|
|
3
|
+
* @param evt
|
|
4
|
+
*/
|
|
5
|
+
export declare function compositionstart(evt: any): void;
|
|
6
|
+
/**
|
|
7
|
+
* This func used to make a flag to the input element
|
|
8
|
+
* @param evt
|
|
9
|
+
*/
|
|
10
|
+
export declare function listener(evt: any): void;
|
|
11
|
+
/**
|
|
12
|
+
* This func used to make a flag to the input element
|
|
13
|
+
* @param evt
|
|
14
|
+
*/
|
|
15
|
+
export declare function compositionend(evt: any): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { inputUtility, selectUtility, textareaUtility } from "./inputUtility";
|
|
2
|
+
/**
|
|
3
|
+
* This func used to make a flag to the input element
|
|
4
|
+
* @param evt
|
|
5
|
+
*/
|
|
6
|
+
export function compositionstart(evt) {
|
|
7
|
+
evt.target.setAttribute("flag", "false");
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* This func used to make a flag to the input element
|
|
11
|
+
* @param evt
|
|
12
|
+
*/
|
|
13
|
+
export function listener(evt) {
|
|
14
|
+
if (!evt.target.hasAttribute("flag")) {
|
|
15
|
+
//Get the event element
|
|
16
|
+
var element = evt.target;
|
|
17
|
+
switch (element.nodeName.toUpperCase()) {
|
|
18
|
+
case "INPUT":
|
|
19
|
+
inputUtility(element, this);
|
|
20
|
+
break;
|
|
21
|
+
case "SELECT":
|
|
22
|
+
selectUtility(element, this);
|
|
23
|
+
break;
|
|
24
|
+
case "TEXTAREA":
|
|
25
|
+
textareaUtility(element, this);
|
|
26
|
+
break;
|
|
27
|
+
default:
|
|
28
|
+
console.error("Can`t bind this type input tag!");
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
//Update the value
|
|
32
|
+
if (element.type === "file")
|
|
33
|
+
this[element.name] = element.files;
|
|
34
|
+
else
|
|
35
|
+
this[element.name] = element.value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* This func used to make a flag to the input element
|
|
40
|
+
* @param evt
|
|
41
|
+
*/
|
|
42
|
+
export function compositionend(evt) {
|
|
43
|
+
evt.target.setAttribute("flag", "true");
|
|
44
|
+
//Get the event element
|
|
45
|
+
var element = evt.target;
|
|
46
|
+
//Get the name attribute
|
|
47
|
+
var dataName = element.name;
|
|
48
|
+
switch (element.nodeName.toUpperCase()) {
|
|
49
|
+
case "INPUT":
|
|
50
|
+
inputUtility(element, this);
|
|
51
|
+
break;
|
|
52
|
+
case "SELECT":
|
|
53
|
+
selectUtility(element, this);
|
|
54
|
+
break;
|
|
55
|
+
case "TEXTAREA":
|
|
56
|
+
textareaUtility(element, this);
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
console.error("Can`t bind this type input tag!");
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
//Update the value
|
|
63
|
+
this[dataName] = element.value;
|
|
64
|
+
}
|