@angular-wave/angular.ts 0.0.69 → 0.0.71

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.
Files changed (45) hide show
  1. package/dist/angular-ts.esm.js +2 -2
  2. package/dist/angular-ts.umd.js +2 -2
  3. package/package.json +1 -1
  4. package/src/animations/shared.js +14 -5
  5. package/src/core/compile/attributes.js +326 -0
  6. package/src/core/compile/compile.js +76 -434
  7. package/src/core/compile/compile.spec.js +2 -2
  8. package/src/core/interpolate/interpolate.js +1 -12
  9. package/src/core/location/location.js +26 -4
  10. package/src/core/parser/parse.js +50 -47
  11. package/src/core/scope/scope.js +4 -8
  12. package/src/{exts → directive}/aria/aria.html +1 -1
  13. package/src/directive/aria/aria.js +382 -0
  14. package/src/{exts → directive}/aria/aria.spec.js +12 -12
  15. package/src/{exts → directive}/aria/aria.test.js +1 -1
  16. package/src/directive/form/form.js +3 -1
  17. package/src/directive/messages/messages.js +268 -274
  18. package/src/filters/filter.js +0 -3
  19. package/src/filters/limit-to.js +0 -1
  20. package/src/public.js +27 -3
  21. package/src/router/state/state-object.js +4 -9
  22. package/src/router/url/url-matcher.js +1 -1
  23. package/src/router/url/url-rule.js +5 -1
  24. package/src/router/url/url-service.js +1 -1
  25. package/src/shared/jqlite/jqlite.js +13 -1
  26. package/src/shared/utils.js +0 -2
  27. package/src/types.js +1 -1
  28. package/types/animations/shared.d.ts +11 -6
  29. package/types/core/compile/attributes.d.ts +101 -0
  30. package/types/core/compile/compile.d.ts +10 -67
  31. package/types/core/interpolate/interpolate.d.ts +1 -12
  32. package/types/core/location/location.d.ts +12 -2
  33. package/types/core/parser/parse.d.ts +10 -10
  34. package/types/core/scope/scope.d.ts +21 -22
  35. package/types/directive/aria/aria.d.ts +94 -0
  36. package/types/directive/form/form.d.ts +2 -11
  37. package/types/router/state/state-object.d.ts +0 -2
  38. package/types/router/url/url-matcher.d.ts +2 -2
  39. package/types/router/url/url-rule.d.ts +2 -1
  40. package/types/shared/jqlite/jqlite.d.ts +8 -4
  41. package/types/shared/utils.d.ts +0 -2
  42. package/types/types.d.ts +1 -1
  43. package/src/exts/aria/aria.js +0 -415
  44. package/types/exts/aria/aria.d.ts +0 -1
  45. /package/src/{exts → directive}/aria/aria.md +0 -0
@@ -7,209 +7,204 @@ export function ngMessagesDirective($animate) {
7
7
  return {
8
8
  require: "ngMessages",
9
9
  restrict: "AE",
10
- controller: [
11
- "$element",
12
- "$scope",
13
- "$attrs",
14
- function ($element, $scope, $attrs) {
15
- const ctrl = this;
16
- let latestKey = 0;
17
- let nextAttachId = 0;
18
- this.head = undefined;
19
- this.default = undefined;
20
-
21
- this.getAttachId = function getAttachId() {
22
- return nextAttachId++;
23
- };
24
-
25
- const messages = (this.messages = {});
26
- let renderLater;
27
- let cachedCollection;
28
-
29
- this.render = function (collection) {
30
- collection = collection || {};
31
-
32
- renderLater = false;
33
- cachedCollection = collection;
34
-
35
- // this is true if the attribute is empty or if the attribute value is truthy
36
- const multiple =
37
- isAttrTruthy($scope, $attrs.ngMessagesMultiple) ||
38
- isAttrTruthy($scope, $attrs.multiple);
39
-
40
- const unmatchedMessages = [];
41
- const matchedKeys = {};
42
- let truthyKeys = 0;
43
- let messageItem = ctrl.head;
44
- let messageFound = false;
45
- let totalMessages = 0;
46
-
47
- // we use != instead of !== to allow for both undefined and null values
48
- while (messageItem != null) {
49
- totalMessages++;
50
- const messageCtrl = messageItem.message;
51
-
52
- let messageUsed = false;
53
- if (!messageFound) {
54
- forEach(collection, (value, key) => {
55
- if (truthy(value) && !messageUsed) {
56
- truthyKeys++;
57
-
58
- if (messageCtrl.test(key)) {
59
- // this is to prevent the same error name from showing up twice
60
- if (matchedKeys[key]) return;
61
- matchedKeys[key] = true;
62
-
63
- messageUsed = true;
64
- messageCtrl.attach();
65
- }
66
- }
67
- });
68
- }
10
+ controller: function ($element, $scope, $attrs) {
11
+ const ctrl = this;
12
+ let latestKey = 0;
13
+ let nextAttachId = 0;
14
+ const messages = {};
15
+ let renderLater;
16
+ let cachedCollection;
17
+
18
+ this.head = undefined;
19
+ this.default = undefined;
20
+ this.messages = messages;
21
+
22
+ this.getAttachId = function getAttachId() {
23
+ return nextAttachId++;
24
+ };
69
25
 
70
- if (messageUsed) {
71
- // unless we want to display multiple messages then we should
72
- // set a flag here to avoid displaying the next message in the list
73
- messageFound = !multiple;
74
- } else {
75
- unmatchedMessages.push(messageCtrl);
76
- }
26
+ this.render = function (collection) {
27
+ collection = collection || {};
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
+ }
77
66
 
78
- messageItem = messageItem.next;
67
+ if (messageUsed) {
68
+ // unless we want to display multiple messages then we should
69
+ // set a flag here to avoid displaying the next message in the list
70
+ messageFound = !multiple;
71
+ } else {
72
+ unmatchedMessages.push(messageCtrl);
79
73
  }
80
74
 
81
- forEach(unmatchedMessages, (messageCtrl) => {
82
- messageCtrl.detach();
83
- });
75
+ messageItem = messageItem.next;
76
+ }
84
77
 
85
- const messageMatched = unmatchedMessages.length !== totalMessages;
86
- const attachDefault =
87
- ctrl.default && !messageMatched && truthyKeys > 0;
78
+ forEach(unmatchedMessages, (messageCtrl) => {
79
+ messageCtrl.detach();
80
+ });
88
81
 
89
- if (attachDefault) {
90
- ctrl.default.attach();
91
- } else if (ctrl.default) {
92
- ctrl.default.detach();
93
- }
82
+ const messageMatched = unmatchedMessages.length !== totalMessages;
83
+ const attachDefault = ctrl.default && !messageMatched && truthyKeys > 0;
94
84
 
95
- if (messageMatched || attachDefault) {
96
- $animate.setClass($element, ACTIVE_CLASS, INACTIVE_CLASS);
97
- } else {
98
- $animate.setClass($element, INACTIVE_CLASS, ACTIVE_CLASS);
99
- }
100
- };
85
+ if (attachDefault) {
86
+ ctrl.default.attach();
87
+ } else if (ctrl.default) {
88
+ ctrl.default.detach();
89
+ }
101
90
 
102
- $scope.$watchCollection($attrs.ngMessages || $attrs.for, ctrl.render);
91
+ if (messageMatched || attachDefault) {
92
+ $animate.setClass($element, ACTIVE_CLASS, INACTIVE_CLASS);
93
+ } else {
94
+ $animate.setClass($element, INACTIVE_CLASS, ACTIVE_CLASS);
95
+ }
96
+ };
103
97
 
104
- this.reRender = function () {
105
- if (!renderLater) {
106
- renderLater = true;
107
- $scope.$evalAsync(() => {
108
- if (renderLater && cachedCollection) {
109
- ctrl.render(cachedCollection);
110
- }
111
- });
112
- }
113
- };
98
+ $scope.$watchCollection($attrs.ngMessages || $attrs.for, ctrl.render);
114
99
 
115
- this.register = function (comment, messageCtrl, isDefault) {
116
- if (isDefault) {
117
- ctrl.default = messageCtrl;
118
- } else {
119
- const nextKey = latestKey.toString();
120
- messages[nextKey] = {
121
- message: messageCtrl,
122
- };
123
- insertMessageNode($element[0], comment, nextKey);
124
- comment.$$ngMessageNode = nextKey;
125
- latestKey++;
126
- }
100
+ this.reRender = function () {
101
+ if (!renderLater) {
102
+ renderLater = true;
103
+ $scope.$evalAsync(() => {
104
+ if (renderLater && cachedCollection) {
105
+ ctrl.render(cachedCollection);
106
+ }
107
+ });
108
+ }
109
+ };
127
110
 
128
- ctrl.reRender();
129
- };
111
+ this.register = function (comment, messageCtrl, isDefault) {
112
+ if (isDefault) {
113
+ ctrl.default = messageCtrl;
114
+ } else {
115
+ const nextKey = latestKey.toString();
116
+ messages[nextKey] = {
117
+ message: messageCtrl,
118
+ };
119
+ insertMessageNode($element[0], comment, nextKey);
120
+ comment.$$ngMessageNode = nextKey;
121
+ latestKey++;
122
+ }
130
123
 
131
- this.deregister = function (comment, isDefault) {
132
- if (isDefault) {
133
- delete ctrl.default;
134
- } else {
135
- const key = comment.$$ngMessageNode;
136
- delete comment.$$ngMessageNode;
137
- removeMessageNode($element[0], comment, key);
138
- delete messages[key];
139
- }
140
- ctrl.reRender();
141
- };
124
+ ctrl.reRender();
125
+ };
142
126
 
143
- function findPreviousMessage(parent, comment) {
144
- let prevNode = comment;
145
- const parentLookup = [];
127
+ this.deregister = function (comment, isDefault) {
128
+ if (isDefault) {
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
+ };
146
138
 
147
- while (prevNode && prevNode !== parent) {
148
- const prevKey = prevNode.$$ngMessageNode;
149
- if (prevKey && prevKey.length) {
150
- return messages[prevKey];
151
- }
139
+ function findPreviousMessage(parent, comment) {
140
+ let prevNode = comment;
141
+ const parentLookup = [];
152
142
 
153
- // dive deeper into the DOM and examine its children for any ngMessage
154
- // comments that may be in an element that appears deeper in the list
155
- if (
156
- prevNode.childNodes.length &&
157
- parentLookup.indexOf(prevNode) === -1
158
- ) {
159
- parentLookup.push(prevNode);
160
- prevNode = prevNode.childNodes[prevNode.childNodes.length - 1];
161
- } else if (prevNode.previousSibling) {
162
- prevNode = prevNode.previousSibling;
163
- } else {
164
- prevNode = prevNode.parentNode;
165
- parentLookup.push(prevNode);
166
- }
143
+ while (prevNode && prevNode !== parent) {
144
+ const prevKey = prevNode.$$ngMessageNode;
145
+ if (prevKey && prevKey.length) {
146
+ return messages[prevKey];
167
147
  }
168
- }
169
148
 
170
- function insertMessageNode(parent, comment, key) {
171
- const messageNode = messages[key];
172
- if (!ctrl.head) {
173
- ctrl.head = messageNode;
149
+ // dive deeper into the DOM and examine its children for any ngMessage
150
+ // comments that may be in an element that appears deeper in the list
151
+ if (
152
+ prevNode.childNodes.length &&
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;
174
159
  } else {
175
- const match = findPreviousMessage(parent, comment);
176
- if (match) {
177
- messageNode.next = match.next;
178
- match.next = messageNode;
179
- } else {
180
- messageNode.next = ctrl.head;
181
- ctrl.head = messageNode;
182
- }
160
+ prevNode = prevNode.parentNode;
161
+ parentLookup.push(prevNode);
183
162
  }
184
163
  }
164
+ }
185
165
 
186
- function removeMessageNode(parent, comment, key) {
187
- const messageNode = messages[key];
188
-
189
- // This message node may have already been removed by a call to deregister()
190
- if (!messageNode) return;
191
-
166
+ function insertMessageNode(parent, comment, key) {
167
+ const messageNode = messages[key];
168
+ if (!ctrl.head) {
169
+ ctrl.head = messageNode;
170
+ } else {
192
171
  const match = findPreviousMessage(parent, comment);
193
172
  if (match) {
194
- match.next = messageNode.next;
173
+ messageNode.next = match.next;
174
+ match.next = messageNode;
195
175
  } else {
196
- ctrl.head = messageNode.next;
176
+ messageNode.next = ctrl.head;
177
+ ctrl.head = messageNode;
197
178
  }
198
179
  }
199
- },
200
- ],
180
+ }
181
+
182
+ function removeMessageNode(parent, comment, key) {
183
+ const messageNode = messages[key];
184
+
185
+ // This message node may have already been removed by a call to deregister()
186
+ if (!messageNode) return;
187
+
188
+ const match = findPreviousMessage(parent, comment);
189
+ if (match) {
190
+ match.next = messageNode.next;
191
+ } else {
192
+ ctrl.head = messageNode.next;
193
+ }
194
+ }
195
+ },
201
196
  };
197
+ }
202
198
 
203
- function isAttrTruthy(scope, attr) {
204
- return (
205
- (isString(attr) && attr.length === 0) || // empty attribute
206
- truthy(scope.$eval(attr))
207
- );
208
- }
199
+ function isAttrTruthy(scope, attr) {
200
+ return (
201
+ (isString(attr) && attr.length === 0) || // empty attribute
202
+ truthy(scope.$eval(attr))
203
+ );
204
+ }
209
205
 
210
- function truthy(val) {
211
- return isString(val) ? val.length : !!val;
212
- }
206
+ function truthy(val) {
207
+ return isString(val) ? val.length : !!val;
213
208
  }
214
209
 
215
210
  ngMessagesIncludeDirective.$inject = ["$templateRequest", "$compile"];
@@ -239,108 +234,107 @@ export const ngMessageExpDirective = ngMessageDirectiveFactory(false);
239
234
  export const ngMessageDefaultDirective = ngMessageDirectiveFactory(true);
240
235
 
241
236
  function ngMessageDirectiveFactory(isDefault) {
242
- return [
243
- "$animate",
244
- function ($animate) {
245
- return {
246
- restrict: "AE",
247
- transclude: "element",
248
- priority: 1, // must run before ngBind, otherwise the text is set on the comment
249
- terminal: true,
250
- require: "^^ngMessages",
251
- link(scope, element, attrs, ngMessagesCtrl, $transclude) {
252
- let commentNode;
253
- let records;
254
- let staticExp;
255
- let dynamicExp;
256
-
257
- if (!isDefault) {
258
- commentNode = element[0];
259
- staticExp = attrs.ngMessage || attrs.when;
260
- dynamicExp = attrs.ngMessageExp || attrs.whenExp;
261
-
262
- const assignRecords = function (items) {
263
- records = items
264
- ? Array.isArray(items)
265
- ? items
266
- : items.split(/[\s,]+/)
267
- : null;
268
- ngMessagesCtrl.reRender();
269
- };
270
-
271
- if (dynamicExp) {
272
- assignRecords(scope.$eval(dynamicExp));
273
- scope.$watchCollection(dynamicExp, assignRecords);
274
- } else {
275
- assignRecords(staticExp);
276
- }
237
+ ngMessageDirective.$inject = ["$animate"];
238
+ function ngMessageDirective($animate) {
239
+ return {
240
+ restrict: "AE",
241
+ transclude: "element",
242
+ priority: 1, // must run before ngBind, otherwise the text is set on the comment
243
+ terminal: true,
244
+ require: "^^ngMessages",
245
+ link(scope, element, attrs, ngMessagesCtrl, $transclude) {
246
+ let commentNode;
247
+ let records;
248
+ let staticExp;
249
+ let dynamicExp;
250
+
251
+ if (!isDefault) {
252
+ commentNode = element[0];
253
+ staticExp = attrs.ngMessage || attrs.when;
254
+ dynamicExp = attrs.ngMessageExp || attrs.whenExp;
255
+
256
+ const assignRecords = function (items) {
257
+ records = items
258
+ ? Array.isArray(items)
259
+ ? items
260
+ : items.split(/[\s,]+/)
261
+ : null;
262
+ ngMessagesCtrl.reRender();
263
+ };
264
+
265
+ if (dynamicExp) {
266
+ assignRecords(scope.$eval(dynamicExp));
267
+ scope.$watchCollection(dynamicExp, assignRecords);
268
+ } else {
269
+ assignRecords(staticExp);
277
270
  }
271
+ }
278
272
 
279
- let currentElement;
280
- let messageCtrl;
281
- ngMessagesCtrl.register(
282
- commentNode,
283
- (messageCtrl = {
284
- test(name) {
285
- return contains(records, name);
286
- },
287
- attach() {
288
- if (!currentElement) {
289
- $transclude((elm, newScope) => {
290
- $animate.enter(elm, null, element);
291
- currentElement = elm;
292
-
293
- // Each time we attach this node to a message we get a new id that we can match
294
- // when we are destroying the node later.
295
- const $$attachId = (currentElement.$$attachId =
296
- ngMessagesCtrl.getAttachId());
297
-
298
- // in the event that the element or a parent element is destroyed
299
- // by another structural directive then it's time
300
- // to deregister the message from the controller
301
- currentElement.on("$destroy", () => {
302
- // If the message element was removed via a call to `detach` then `currentElement` will be null
303
- // So this handler only handles cases where something else removed the message element.
304
- if (
305
- currentElement &&
306
- currentElement.$$attachId === $$attachId
307
- ) {
308
- ngMessagesCtrl.deregister(commentNode, isDefault);
309
- messageCtrl.detach();
310
- }
311
- newScope.$destroy();
312
- });
273
+ let currentElement;
274
+ let messageCtrl;
275
+ ngMessagesCtrl.register(
276
+ commentNode,
277
+ (messageCtrl = {
278
+ test(name) {
279
+ return contains(records, name);
280
+ },
281
+ attach() {
282
+ if (!currentElement) {
283
+ $transclude((elm, newScope) => {
284
+ $animate.enter(elm, null, element);
285
+ currentElement = elm;
286
+
287
+ // Each time we attach this node to a message we get a new id that we can match
288
+ // when we are destroying the node later.
289
+ const $$attachId = (currentElement.$$attachId =
290
+ ngMessagesCtrl.getAttachId());
291
+
292
+ // in the event that the element or a parent element is destroyed
293
+ // by another structural directive then it's time
294
+ // to deregister the message from the controller
295
+ currentElement.on("$destroy", () => {
296
+ // If the message element was removed via a call to `detach` then `currentElement` will be null
297
+ // So this handler only handles cases where something else removed the message element.
298
+ if (
299
+ currentElement &&
300
+ currentElement.$$attachId === $$attachId
301
+ ) {
302
+ ngMessagesCtrl.deregister(commentNode, isDefault);
303
+ messageCtrl.detach();
304
+ }
305
+ newScope.$destroy();
313
306
  });
314
- }
315
- },
316
- detach() {
317
- if (currentElement) {
318
- const elm = currentElement;
319
- currentElement = null;
320
- $animate.leave(elm);
321
- }
322
- },
323
- }),
324
- isDefault,
325
- );
326
-
327
- // We need to ensure that this directive deregisters itself when it no longer exists
328
- // Normally this is done when the attached element is destroyed; but if this directive
329
- // gets removed before we attach the message to the DOM there is nothing to watch
330
- // in which case we must deregister when the containing scope is destroyed.
331
- scope.$on("$destroy", () => {
332
- ngMessagesCtrl.deregister(commentNode, isDefault);
333
- });
334
- },
335
- };
336
- },
337
- ];
338
-
339
- function contains(collection, key) {
340
- if (collection) {
341
- return Array.isArray(collection)
342
- ? collection.indexOf(key) >= 0
343
- : Object.prototype.hasOwnProperty.call(collection, key);
344
- }
307
+ });
308
+ }
309
+ },
310
+ detach() {
311
+ if (currentElement) {
312
+ const elm = currentElement;
313
+ currentElement = null;
314
+ $animate.leave(elm);
315
+ }
316
+ },
317
+ }),
318
+ isDefault,
319
+ );
320
+
321
+ // We need to ensure that this directive deregisters itself when it no longer exists
322
+ // Normally this is done when the attached element is destroyed; but if this directive
323
+ // gets removed before we attach the message to the DOM there is nothing to watch
324
+ // in which case we must deregister when the containing scope is destroyed.
325
+ scope.$on("$destroy", () => {
326
+ ngMessagesCtrl.deregister(commentNode, isDefault);
327
+ });
328
+ },
329
+ };
330
+ }
331
+ return ngMessageDirective;
332
+ }
333
+
334
+ function contains(collection, key) {
335
+ if (collection) {
336
+ return Array.isArray(collection)
337
+ ? collection.indexOf(key) >= 0
338
+ : Object.prototype.hasOwnProperty.call(collection, key);
345
339
  }
346
340
  }
@@ -65,7 +65,6 @@ export function filterFilter() {
65
65
  }
66
66
 
67
67
  // Helper functions for `filterFilter`
68
- /** @private */
69
68
  function createPredicateFn(
70
69
  expression,
71
70
  comparator,
@@ -124,7 +123,6 @@ function createPredicateFn(
124
123
  return predicateFn;
125
124
  }
126
125
 
127
- /** @private */
128
126
  function deepCompare(
129
127
  actual,
130
128
  expected,
@@ -211,7 +209,6 @@ function deepCompare(
211
209
  }
212
210
 
213
211
  // Used for easily differentiating between `null` and actual `object`
214
- /** @private */
215
212
  function getTypeForFilter(val) {
216
213
  return val === null ? "null" : typeof val;
217
214
  }
@@ -45,7 +45,6 @@ export function limitToFilter() {
45
45
  };
46
46
  }
47
47
 
48
- /** @private */
49
48
  function sliceFn(input, begin, end) {
50
49
  if (isString(input)) return input.slice(begin, end);
51
50