@angular-wave/angular.ts 0.0.71 → 0.0.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular-ts.esm.js +2 -2
- package/dist/angular-ts.umd.js +2 -2
- package/package.json +1 -1
- package/src/animations/animate-children-directive.md +1 -1
- package/src/animations/animate-css-driver.js +1 -1
- package/src/animations/animate-css.html +2 -2
- package/src/animations/animate-js.html +5 -2
- package/src/animations/animate-queue.js +5 -5
- package/src/animations/animate-swap.md +1 -1
- package/src/{core/animate → animations}/animate.html +1 -1
- package/src/{core/animate → animations}/animate.js +4 -138
- package/src/animations/raf-scheduler.js +7 -3
- package/src/animations/raf-scheduler.spec.js +3 -3
- package/src/animations/shared.js +2 -2
- package/src/binding.spec.js +4 -3
- package/src/core/compile/attributes.js +8 -1
- package/src/core/compile/compile.spec.js +44 -28
- package/src/core/controller/controller.js +9 -3
- package/src/core/di/injector.md +1 -1
- package/src/core/di/ng-module.js +46 -3
- package/src/core/prop.spec.js +15 -11
- package/src/core/q/q.js +2 -1
- package/src/directive/bind/bind.spec.js +80 -44
- package/src/directive/change/change.js +3 -1
- package/src/directive/class/class.js +43 -14
- package/src/directive/class/class.spec.js +7 -4
- package/src/directive/form/form.js +5 -4
- package/src/directive/form/form.spec.js +3 -4
- package/src/directive/if/if-animate-css.html +5 -7
- package/src/directive/if/if.js +1 -1
- package/src/directive/if/if.spec.js +3 -2
- package/src/directive/include/include.js +1 -1
- package/src/directive/input/input.spec.js +6 -4
- package/src/directive/list/list.js +3 -3
- package/src/directive/list/list.spec.js +4 -2
- package/src/directive/messages/messages.js +177 -172
- package/src/directive/messages/messages.spec.js +4 -4
- package/src/directive/model/model.js +261 -471
- package/src/directive/model/model.spec.js +4 -3
- package/src/directive/model-options/model-options.spec.js +3 -1
- package/src/directive/repeat/repeat.md +1 -1
- package/src/directive/repeat/repeat.spec.js +1 -1
- package/src/directive/select/select.spec.js +3 -3
- package/src/directive/show-hide/show-hide.js +36 -6
- package/src/directive/switch/switch.js +4 -4
- package/src/directive/switch/switch.spec.js +5 -2
- package/src/directive/validators/validators.spec.js +6 -4
- package/src/loader.js +1 -2
- package/src/public.js +22 -10
- package/src/router/directives/state-directives.js +2 -9
- package/src/router/hooks/core-resolvables.js +5 -3
- package/src/router/path/path-utils.js +1 -2
- package/src/router/resolve/resolve-context.js +14 -29
- package/src/router/state/state-queue-manager.js +1 -2
- package/src/router/state/state-service.js +2 -3
- package/src/router/transition/transition.js +2 -2
- package/src/router/view/view.js +2 -8
- package/src/services/anchor-scroll.html +1 -1
- package/src/shared/common.js +3 -8
- package/src/shared/common.spec.js +1 -19
- package/src/shared/hof.js +1 -8
- package/src/shared/jqlite/jqlite.js +2 -2
- package/src/shared/predicates.js +3 -2
- package/src/types.js +2 -3
- package/types/animations/animate-css-driver.d.ts +1 -1
- package/types/animations/animate-queue.d.ts +1 -2
- package/types/{core/animate → animations}/animate.d.ts +2 -12
- package/types/animations/raf-scheduler.d.ts +7 -2
- package/types/core/compile/attributes.d.ts +10 -1
- package/types/core/di/ng-module.d.ts +55 -12
- package/types/core/q/q.d.ts +4 -2
- package/types/directive/form/form.d.ts +3 -1
- package/types/directive/messages/messages.d.ts +76 -0
- package/types/directive/model/model.d.ts +101 -239
- package/types/router/resolve/resolve-context.d.ts +0 -2
- package/types/router/transition/transition.d.ts +0 -1
- package/types/shared/common.d.ts +0 -3
- package/types/shared/hof.d.ts +0 -1
- package/types/shared/jqlite/jqlite.d.ts +4 -4
- package/types/types.d.ts +4 -2
- package/src/animations/module.js +0 -25
- package/src/core/animate/animate-css.js +0 -88
- package/src/core/animate/anomate.md +0 -13
- package/types/animations/module.d.ts +0 -1
- package/types/core/animate/animate-css.d.ts +0 -19
- /package/src/{core/animate → animations}/animate-runner.js +0 -0
- /package/src/{core/animate → animations}/animate.spec.js +0 -0
- /package/src/{core/animate → animations}/helpers.js +0 -0
- /package/types/{core/animate → animations}/animate-runner.d.ts +0 -0
- /package/types/{core/animate → animations}/helpers.d.ts +0 -0
|
@@ -1,198 +1,203 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import { isString } from "../../shared/utils";
|
|
2
|
+
|
|
3
|
+
const ACTIVE_CLASS = "ng-active";
|
|
4
|
+
const INACTIVE_CLASS = "ng-inactive";
|
|
5
|
+
|
|
6
|
+
class NgMessageCtrl {
|
|
7
|
+
/**
|
|
8
|
+
* @param {import('../../shared/jqlite/jqlite').JQLite} $element
|
|
9
|
+
* @param {import('../../core/scope/scope').Scope} $scope
|
|
10
|
+
* @param {import('../../core/compile/attributes').Attributes} $attrs
|
|
11
|
+
* @param {*} $animate
|
|
12
|
+
*/
|
|
13
|
+
constructor($element, $scope, $attrs, $animate) {
|
|
14
|
+
this.$element = $element;
|
|
15
|
+
this.$scope = $scope;
|
|
16
|
+
this.$attrs = $attrs;
|
|
17
|
+
this.$animate = $animate;
|
|
18
|
+
|
|
19
|
+
this.latestKey = 0;
|
|
20
|
+
this.nextAttachId = 0;
|
|
21
|
+
this.messages = {};
|
|
22
|
+
this.renderLater = false;
|
|
23
|
+
this.cachedCollection = null;
|
|
24
|
+
|
|
25
|
+
this.head = undefined;
|
|
26
|
+
this.default = undefined;
|
|
27
|
+
|
|
28
|
+
this.$scope.$watchCollection(
|
|
29
|
+
this.$attrs["ngMessages"] || this.$attrs["for"],
|
|
30
|
+
this.render.bind(this),
|
|
31
|
+
);
|
|
32
|
+
}
|
|
25
33
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
renderLater = false;
|
|
30
|
-
cachedCollection = collection;
|
|
31
|
-
|
|
32
|
-
// this is true if the attribute is empty or if the attribute value is truthy
|
|
33
|
-
const multiple =
|
|
34
|
-
isAttrTruthy($scope, $attrs.ngMessagesMultiple) ||
|
|
35
|
-
isAttrTruthy($scope, $attrs.multiple);
|
|
36
|
-
|
|
37
|
-
const unmatchedMessages = [];
|
|
38
|
-
const matchedKeys = {};
|
|
39
|
-
let truthyKeys = 0;
|
|
40
|
-
let messageItem = ctrl.head;
|
|
41
|
-
let messageFound = false;
|
|
42
|
-
let totalMessages = 0;
|
|
43
|
-
|
|
44
|
-
// we use != instead of !== to allow for both undefined and null values
|
|
45
|
-
while (messageItem != null) {
|
|
46
|
-
totalMessages++;
|
|
47
|
-
const messageCtrl = messageItem.message;
|
|
48
|
-
|
|
49
|
-
let messageUsed = false;
|
|
50
|
-
if (!messageFound) {
|
|
51
|
-
forEach(collection, (value, key) => {
|
|
52
|
-
if (truthy(value) && !messageUsed) {
|
|
53
|
-
truthyKeys++;
|
|
54
|
-
|
|
55
|
-
if (messageCtrl.test(key)) {
|
|
56
|
-
// this is to prevent the same error name from showing up twice
|
|
57
|
-
if (matchedKeys[key]) return;
|
|
58
|
-
matchedKeys[key] = true;
|
|
59
|
-
|
|
60
|
-
messageUsed = true;
|
|
61
|
-
messageCtrl.attach();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
34
|
+
getAttachId() {
|
|
35
|
+
return this.nextAttachId++;
|
|
36
|
+
}
|
|
66
37
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
38
|
+
render(collection = {}) {
|
|
39
|
+
this.renderLater = false;
|
|
40
|
+
this.cachedCollection = collection;
|
|
41
|
+
|
|
42
|
+
const multiple =
|
|
43
|
+
isAttrTruthy(this.$scope, this.$attrs["ngMessagesMultiple"]) ||
|
|
44
|
+
isAttrTruthy(this.$scope, this.$attrs["multiple"]);
|
|
45
|
+
|
|
46
|
+
const unmatchedMessages = [];
|
|
47
|
+
const matchedKeys = {};
|
|
48
|
+
let truthyKeys = 0;
|
|
49
|
+
let messageItem = this.head;
|
|
50
|
+
let messageFound = false;
|
|
51
|
+
let totalMessages = 0;
|
|
52
|
+
|
|
53
|
+
while (messageItem != null) {
|
|
54
|
+
totalMessages++;
|
|
55
|
+
const messageCtrl = messageItem.message;
|
|
56
|
+
let messageUsed = false;
|
|
57
|
+
|
|
58
|
+
if (!messageFound) {
|
|
59
|
+
Object.entries(collection).forEach(([key, value]) => {
|
|
60
|
+
if (truthy(value) && !messageUsed) {
|
|
61
|
+
truthyKeys++;
|
|
62
|
+
|
|
63
|
+
if (messageCtrl.test(key)) {
|
|
64
|
+
if (matchedKeys[key]) return;
|
|
65
|
+
matchedKeys[key] = true;
|
|
66
|
+
|
|
67
|
+
messageUsed = true;
|
|
68
|
+
messageCtrl.attach();
|
|
69
|
+
}
|
|
73
70
|
}
|
|
74
|
-
|
|
75
|
-
messageItem = messageItem.next;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
forEach(unmatchedMessages, (messageCtrl) => {
|
|
79
|
-
messageCtrl.detach();
|
|
80
71
|
});
|
|
72
|
+
}
|
|
81
73
|
|
|
82
|
-
|
|
83
|
-
|
|
74
|
+
if (messageUsed) {
|
|
75
|
+
messageFound = !multiple;
|
|
76
|
+
} else {
|
|
77
|
+
unmatchedMessages.push(messageCtrl);
|
|
78
|
+
}
|
|
84
79
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
} else if (ctrl.default) {
|
|
88
|
-
ctrl.default.detach();
|
|
89
|
-
}
|
|
80
|
+
messageItem = messageItem.next;
|
|
81
|
+
}
|
|
90
82
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
$animate.setClass($element, INACTIVE_CLASS, ACTIVE_CLASS);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
83
|
+
unmatchedMessages.forEach((messageCtrl) => {
|
|
84
|
+
messageCtrl.detach();
|
|
85
|
+
});
|
|
97
86
|
|
|
98
|
-
|
|
87
|
+
const messageMatched = unmatchedMessages.length !== totalMessages;
|
|
88
|
+
const attachDefault = this.default && !messageMatched && truthyKeys > 0;
|
|
99
89
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
ctrl.render(cachedCollection);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
};
|
|
90
|
+
if (attachDefault) {
|
|
91
|
+
this.default.attach();
|
|
92
|
+
} else if (this.default) {
|
|
93
|
+
this.default.detach();
|
|
94
|
+
}
|
|
110
95
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
96
|
+
if (messageMatched || attachDefault) {
|
|
97
|
+
this.$animate.setClass(this.$element, ACTIVE_CLASS, INACTIVE_CLASS);
|
|
98
|
+
} else {
|
|
99
|
+
this.$animate.setClass(this.$element, INACTIVE_CLASS, ACTIVE_CLASS);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
reRender() {
|
|
104
|
+
if (!this.renderLater) {
|
|
105
|
+
this.renderLater = true;
|
|
106
|
+
this.$scope.$evalAsync(() => {
|
|
107
|
+
if (this.renderLater && this.cachedCollection) {
|
|
108
|
+
this.render(this.cachedCollection);
|
|
122
109
|
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
123
113
|
|
|
124
|
-
|
|
114
|
+
register(comment, messageCtrl, isDefault) {
|
|
115
|
+
if (isDefault) {
|
|
116
|
+
this.default = messageCtrl;
|
|
117
|
+
} else {
|
|
118
|
+
const nextKey = this.latestKey.toString();
|
|
119
|
+
this.messages[nextKey] = {
|
|
120
|
+
message: messageCtrl,
|
|
125
121
|
};
|
|
122
|
+
this.insertMessageNode(this.$element[0], comment, nextKey);
|
|
123
|
+
comment.$$ngMessageNode = nextKey;
|
|
124
|
+
this.latestKey++;
|
|
125
|
+
}
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
delete ctrl.default;
|
|
130
|
-
} else {
|
|
131
|
-
const key = comment.$$ngMessageNode;
|
|
132
|
-
delete comment.$$ngMessageNode;
|
|
133
|
-
removeMessageNode($element[0], comment, key);
|
|
134
|
-
delete messages[key];
|
|
135
|
-
}
|
|
136
|
-
ctrl.reRender();
|
|
137
|
-
};
|
|
127
|
+
this.reRender();
|
|
128
|
+
}
|
|
138
129
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
130
|
+
deregister(comment, isDefault) {
|
|
131
|
+
if (isDefault) {
|
|
132
|
+
delete this.default;
|
|
133
|
+
} else {
|
|
134
|
+
const key = comment.$$ngMessageNode;
|
|
135
|
+
delete comment.$$ngMessageNode;
|
|
136
|
+
this.removeMessageNode(this.$element[0], comment, key);
|
|
137
|
+
delete this.messages[key];
|
|
138
|
+
}
|
|
139
|
+
this.reRender();
|
|
140
|
+
}
|
|
142
141
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return messages[prevKey];
|
|
147
|
-
}
|
|
142
|
+
findPreviousMessage(parent, comment) {
|
|
143
|
+
let prevNode = comment;
|
|
144
|
+
const parentLookup = [];
|
|
148
145
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
parentLookup.indexOf(prevNode) === -1
|
|
154
|
-
) {
|
|
155
|
-
parentLookup.push(prevNode);
|
|
156
|
-
prevNode = prevNode.childNodes[prevNode.childNodes.length - 1];
|
|
157
|
-
} else if (prevNode.previousSibling) {
|
|
158
|
-
prevNode = prevNode.previousSibling;
|
|
159
|
-
} else {
|
|
160
|
-
prevNode = prevNode.parentNode;
|
|
161
|
-
parentLookup.push(prevNode);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
146
|
+
while (prevNode && prevNode !== parent) {
|
|
147
|
+
const prevKey = prevNode.$$ngMessageNode;
|
|
148
|
+
if (prevKey && prevKey.length) {
|
|
149
|
+
return this.messages[prevKey];
|
|
164
150
|
}
|
|
165
151
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
152
|
+
if (prevNode.childNodes.length && parentLookup.indexOf(prevNode) === -1) {
|
|
153
|
+
parentLookup.push(prevNode);
|
|
154
|
+
prevNode = prevNode.childNodes[prevNode.childNodes.length - 1];
|
|
155
|
+
} else if (prevNode.previousSibling) {
|
|
156
|
+
prevNode = prevNode.previousSibling;
|
|
157
|
+
} else {
|
|
158
|
+
prevNode = prevNode.parentNode;
|
|
159
|
+
parentLookup.push(prevNode);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
insertMessageNode(parent, comment, key) {
|
|
165
|
+
const messageNode = this.messages[key];
|
|
166
|
+
if (!this.head) {
|
|
167
|
+
this.head = messageNode;
|
|
168
|
+
} else {
|
|
169
|
+
const match = this.findPreviousMessage(parent, comment);
|
|
170
|
+
if (match) {
|
|
171
|
+
messageNode.next = match.next;
|
|
172
|
+
match.next = messageNode;
|
|
173
|
+
} else {
|
|
174
|
+
messageNode.next = this.head;
|
|
175
|
+
this.head = messageNode;
|
|
180
176
|
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
181
179
|
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
removeMessageNode(parent, comment, key) {
|
|
181
|
+
const messageNode = this.messages[key];
|
|
184
182
|
|
|
185
|
-
|
|
186
|
-
if (!messageNode) return;
|
|
183
|
+
if (!messageNode) return;
|
|
187
184
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
185
|
+
const match = this.findPreviousMessage(parent, comment);
|
|
186
|
+
if (match) {
|
|
187
|
+
match.next = messageNode.next;
|
|
188
|
+
} else {
|
|
189
|
+
this.head = messageNode.next;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
ngMessagesDirective.$inject = ["$animate"];
|
|
195
|
+
export function ngMessagesDirective($animate) {
|
|
196
|
+
return {
|
|
197
|
+
require: "ngMessages",
|
|
198
|
+
restrict: "AE",
|
|
199
|
+
controller: ($element, $scope, $attrs) =>
|
|
200
|
+
new NgMessageCtrl($element, $scope, $attrs, $animate),
|
|
196
201
|
};
|
|
197
202
|
}
|
|
198
203
|
|
|
@@ -17,13 +17,13 @@ describe("ngMessages", () => {
|
|
|
17
17
|
template: '<div ng-messages="col"><ng-transclude></ng-transclude></div>',
|
|
18
18
|
}));
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
(
|
|
20
|
+
window.angular
|
|
21
|
+
.bootstrap(document.getElementById("dummy"), ["app"])
|
|
22
|
+
.invoke((_$rootScope_, _$compile_, _$templateCache_) => {
|
|
22
23
|
$rootScope = _$rootScope_;
|
|
23
24
|
$compile = _$compile_;
|
|
24
25
|
$templateCache = _$templateCache_;
|
|
25
|
-
}
|
|
26
|
-
);
|
|
26
|
+
});
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
function messageChildren(element) {
|