@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.
Files changed (90) 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/animate-children-directive.md +1 -1
  5. package/src/animations/animate-css-driver.js +1 -1
  6. package/src/animations/animate-css.html +2 -2
  7. package/src/animations/animate-js.html +5 -2
  8. package/src/animations/animate-queue.js +5 -5
  9. package/src/animations/animate-swap.md +1 -1
  10. package/src/{core/animate → animations}/animate.html +1 -1
  11. package/src/{core/animate → animations}/animate.js +4 -138
  12. package/src/animations/raf-scheduler.js +7 -3
  13. package/src/animations/raf-scheduler.spec.js +3 -3
  14. package/src/animations/shared.js +2 -2
  15. package/src/binding.spec.js +4 -3
  16. package/src/core/compile/attributes.js +8 -1
  17. package/src/core/compile/compile.spec.js +44 -28
  18. package/src/core/controller/controller.js +9 -3
  19. package/src/core/di/injector.md +1 -1
  20. package/src/core/di/ng-module.js +46 -3
  21. package/src/core/prop.spec.js +15 -11
  22. package/src/core/q/q.js +2 -1
  23. package/src/directive/bind/bind.spec.js +80 -44
  24. package/src/directive/change/change.js +3 -1
  25. package/src/directive/class/class.js +43 -14
  26. package/src/directive/class/class.spec.js +7 -4
  27. package/src/directive/form/form.js +5 -4
  28. package/src/directive/form/form.spec.js +3 -4
  29. package/src/directive/if/if-animate-css.html +5 -7
  30. package/src/directive/if/if.js +1 -1
  31. package/src/directive/if/if.spec.js +3 -2
  32. package/src/directive/include/include.js +1 -1
  33. package/src/directive/input/input.spec.js +6 -4
  34. package/src/directive/list/list.js +3 -3
  35. package/src/directive/list/list.spec.js +4 -2
  36. package/src/directive/messages/messages.js +177 -172
  37. package/src/directive/messages/messages.spec.js +4 -4
  38. package/src/directive/model/model.js +261 -471
  39. package/src/directive/model/model.spec.js +4 -3
  40. package/src/directive/model-options/model-options.spec.js +3 -1
  41. package/src/directive/repeat/repeat.md +1 -1
  42. package/src/directive/repeat/repeat.spec.js +1 -1
  43. package/src/directive/select/select.spec.js +3 -3
  44. package/src/directive/show-hide/show-hide.js +36 -6
  45. package/src/directive/switch/switch.js +4 -4
  46. package/src/directive/switch/switch.spec.js +5 -2
  47. package/src/directive/validators/validators.spec.js +6 -4
  48. package/src/loader.js +1 -2
  49. package/src/public.js +22 -10
  50. package/src/router/directives/state-directives.js +2 -9
  51. package/src/router/hooks/core-resolvables.js +5 -3
  52. package/src/router/path/path-utils.js +1 -2
  53. package/src/router/resolve/resolve-context.js +14 -29
  54. package/src/router/state/state-queue-manager.js +1 -2
  55. package/src/router/state/state-service.js +2 -3
  56. package/src/router/transition/transition.js +2 -2
  57. package/src/router/view/view.js +2 -8
  58. package/src/services/anchor-scroll.html +1 -1
  59. package/src/shared/common.js +3 -8
  60. package/src/shared/common.spec.js +1 -19
  61. package/src/shared/hof.js +1 -8
  62. package/src/shared/jqlite/jqlite.js +2 -2
  63. package/src/shared/predicates.js +3 -2
  64. package/src/types.js +2 -3
  65. package/types/animations/animate-css-driver.d.ts +1 -1
  66. package/types/animations/animate-queue.d.ts +1 -2
  67. package/types/{core/animate → animations}/animate.d.ts +2 -12
  68. package/types/animations/raf-scheduler.d.ts +7 -2
  69. package/types/core/compile/attributes.d.ts +10 -1
  70. package/types/core/di/ng-module.d.ts +55 -12
  71. package/types/core/q/q.d.ts +4 -2
  72. package/types/directive/form/form.d.ts +3 -1
  73. package/types/directive/messages/messages.d.ts +76 -0
  74. package/types/directive/model/model.d.ts +101 -239
  75. package/types/router/resolve/resolve-context.d.ts +0 -2
  76. package/types/router/transition/transition.d.ts +0 -1
  77. package/types/shared/common.d.ts +0 -3
  78. package/types/shared/hof.d.ts +0 -1
  79. package/types/shared/jqlite/jqlite.d.ts +4 -4
  80. package/types/types.d.ts +4 -2
  81. package/src/animations/module.js +0 -25
  82. package/src/core/animate/animate-css.js +0 -88
  83. package/src/core/animate/anomate.md +0 -13
  84. package/types/animations/module.d.ts +0 -1
  85. package/types/core/animate/animate-css.d.ts +0 -19
  86. /package/src/{core/animate → animations}/animate-runner.js +0 -0
  87. /package/src/{core/animate → animations}/animate.spec.js +0 -0
  88. /package/src/{core/animate → animations}/helpers.js +0 -0
  89. /package/types/{core/animate → animations}/animate-runner.d.ts +0 -0
  90. /package/types/{core/animate → animations}/helpers.d.ts +0 -0
@@ -1,198 +1,203 @@
1
- import { forEach, isString } from "../../shared/utils";
2
-
3
- ngMessagesDirective.$inject = ["$animate"];
4
- export function ngMessagesDirective($animate) {
5
- const ACTIVE_CLASS = "ng-active";
6
- const INACTIVE_CLASS = "ng-inactive";
7
- return {
8
- require: "ngMessages",
9
- restrict: "AE",
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
- };
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
- 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
- }
34
+ getAttachId() {
35
+ return this.nextAttachId++;
36
+ }
66
37
 
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);
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
- const messageMatched = unmatchedMessages.length !== totalMessages;
83
- const attachDefault = ctrl.default && !messageMatched && truthyKeys > 0;
74
+ if (messageUsed) {
75
+ messageFound = !multiple;
76
+ } else {
77
+ unmatchedMessages.push(messageCtrl);
78
+ }
84
79
 
85
- if (attachDefault) {
86
- ctrl.default.attach();
87
- } else if (ctrl.default) {
88
- ctrl.default.detach();
89
- }
80
+ messageItem = messageItem.next;
81
+ }
90
82
 
91
- if (messageMatched || attachDefault) {
92
- $animate.setClass($element, ACTIVE_CLASS, INACTIVE_CLASS);
93
- } else {
94
- $animate.setClass($element, INACTIVE_CLASS, ACTIVE_CLASS);
95
- }
96
- };
83
+ unmatchedMessages.forEach((messageCtrl) => {
84
+ messageCtrl.detach();
85
+ });
97
86
 
98
- $scope.$watchCollection($attrs.ngMessages || $attrs.for, ctrl.render);
87
+ const messageMatched = unmatchedMessages.length !== totalMessages;
88
+ const attachDefault = this.default && !messageMatched && truthyKeys > 0;
99
89
 
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
- };
90
+ if (attachDefault) {
91
+ this.default.attach();
92
+ } else if (this.default) {
93
+ this.default.detach();
94
+ }
110
95
 
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++;
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
- ctrl.reRender();
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
- 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
- };
127
+ this.reRender();
128
+ }
138
129
 
139
- function findPreviousMessage(parent, comment) {
140
- let prevNode = comment;
141
- const parentLookup = [];
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
- while (prevNode && prevNode !== parent) {
144
- const prevKey = prevNode.$$ngMessageNode;
145
- if (prevKey && prevKey.length) {
146
- return messages[prevKey];
147
- }
142
+ findPreviousMessage(parent, comment) {
143
+ let prevNode = comment;
144
+ const parentLookup = [];
148
145
 
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;
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
- function insertMessageNode(parent, comment, key) {
167
- const messageNode = messages[key];
168
- if (!ctrl.head) {
169
- ctrl.head = messageNode;
170
- } else {
171
- const match = findPreviousMessage(parent, comment);
172
- if (match) {
173
- messageNode.next = match.next;
174
- match.next = messageNode;
175
- } else {
176
- messageNode.next = ctrl.head;
177
- ctrl.head = messageNode;
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
- function removeMessageNode(parent, comment, key) {
183
- const messageNode = messages[key];
180
+ removeMessageNode(parent, comment, key) {
181
+ const messageNode = this.messages[key];
184
182
 
185
- // This message node may have already been removed by a call to deregister()
186
- if (!messageNode) return;
183
+ if (!messageNode) return;
187
184
 
188
- const match = findPreviousMessage(parent, comment);
189
- if (match) {
190
- match.next = messageNode.next;
191
- } else {
192
- ctrl.head = messageNode.next;
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
- createInjector(["app"]).invoke(
21
- (_$rootScope_, _$compile_, _$templateCache_) => {
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) {