@angular-wave/angular.ts 0.0.50 → 0.0.52

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 (59) hide show
  1. package/README.md +3 -1
  2. package/dist/angular-ts.esm.js +2 -2
  3. package/dist/angular-ts.umd.js +2 -2
  4. package/package.json +1 -1
  5. package/src/animations/animate-children-directive.js +19 -99
  6. package/src/animations/animate-children-directive.md +80 -0
  7. package/src/animations/animate-css-driver.js +250 -256
  8. package/src/animations/animate-css.js +646 -875
  9. package/src/animations/animate-css.md +263 -0
  10. package/src/animations/animate-js-driver.js +54 -56
  11. package/src/animations/animate-js.js +303 -306
  12. package/src/animations/animate-queue.js +707 -716
  13. package/src/animations/animate-swap.js +30 -119
  14. package/src/animations/animate-swap.md +88 -0
  15. package/src/animations/animation.js +3 -3
  16. package/src/animations/shared.js +2 -1
  17. package/src/core/animate/animate-runner.js +147 -145
  18. package/src/core/animate/animate.js +568 -582
  19. package/src/core/animate/anomate.md +13 -0
  20. package/src/core/compile/compile.spec.js +5 -6
  21. package/src/core/core.html +0 -1
  22. package/src/core/parser/ast-type.js +21 -20
  23. package/src/core/parser/ast.js +34 -35
  24. package/src/core/parser/interpreter.js +405 -136
  25. package/src/core/parser/lexer.js +14 -13
  26. package/src/core/parser/parse.js +31 -45
  27. package/src/core/parser/parse.spec.js +429 -444
  28. package/src/core/parser/parser.js +17 -9
  29. package/src/directive/select/select.js +301 -305
  30. package/src/loader.js +5 -1
  31. package/src/public.js +0 -1
  32. package/src/router/directives/state-directives.js +256 -574
  33. package/src/router/directives/state-directives.md +435 -0
  34. package/src/router/directives/view-directive.js +3 -3
  35. package/src/router/index.js +7 -7
  36. package/src/types.js +0 -13
  37. package/types/animations/animate-children-directive.d.ts +5 -80
  38. package/types/animations/animate-css-driver.d.ts +11 -0
  39. package/types/animations/animate-css.d.ts +8 -0
  40. package/types/animations/animate-js-driver.d.ts +8 -0
  41. package/types/animations/animate-js.d.ts +12 -0
  42. package/types/animations/animate-queue.d.ts +19 -0
  43. package/types/animations/animate-swap.d.ts +5 -89
  44. package/types/animations/shared.d.ts +1 -1
  45. package/types/core/animate/animate-runner.d.ts +32 -0
  46. package/types/core/animate/animate.d.ts +509 -0
  47. package/types/core/parser/ast-type.d.ts +24 -20
  48. package/types/core/parser/ast.d.ts +13 -14
  49. package/types/core/parser/interpreter.d.ts +24 -19
  50. package/types/core/parser/lexer.d.ts +6 -2
  51. package/types/core/parser/parse.d.ts +44 -38
  52. package/types/core/parser/parser.d.ts +2 -10
  53. package/types/directive/select/select.d.ts +79 -0
  54. package/types/loader.d.ts +397 -0
  55. package/types/router/directives/state-directives.d.ts +31 -0
  56. package/types/types.d.ts +0 -1
  57. package/src/core/document.spec.js +0 -52
  58. package/src/core/parser/shared.js +0 -234
  59. package/types/core/parser/shared.d.ts +0 -35
@@ -5,363 +5,360 @@ import {
5
5
  prepareAnimationOptions,
6
6
  } from "./shared";
7
7
 
8
- // TODO(matsko): use caching here to speed things up for detection
9
- // TODO(matsko): add documentation
10
- // by the time...
11
-
12
- export const $$AnimateJsProvider = [
13
- "$animateProvider",
14
- function ($animateProvider) {
15
- this.$get = [
16
- "$injector",
17
- "$$AnimateRunner",
18
- function ($injector, $$AnimateRunner) {
19
- const applyAnimationClasses = applyAnimationClassesFactory();
20
- // $animateJs(element, 'enter');
21
- return function (element, event, classes, options) {
22
- let animationClosed = false;
23
-
24
- // the `classes` argument is optional and if it is not used
25
- // then the classes will be resolved from the element's className
26
- // property as well as options.addClass/options.removeClass.
27
- if (arguments.length === 3 && isObject(classes)) {
28
- options = classes;
29
- classes = null;
30
- }
8
+ // TODO: use caching here to speed things up for detection
9
+ // TODO: add documentation
10
+
11
+ $$AnimateJsProvider.$inject = ["$animateProvider"];
12
+ export function $$AnimateJsProvider($animateProvider) {
13
+ this.$get = [
14
+ "$injector",
15
+ "$$AnimateRunner",
16
+ function ($injector, $$AnimateRunner) {
17
+ const applyAnimationClasses = applyAnimationClassesFactory();
18
+ // $animateJs(element, 'enter');
19
+ return function (element, event, classes, options) {
20
+ let animationClosed = false;
21
+
22
+ // the `classes` argument is optional and if it is not used
23
+ // then the classes will be resolved from the element's className
24
+ // property as well as options.addClass/options.removeClass.
25
+ if (arguments.length === 3 && isObject(classes)) {
26
+ options = classes;
27
+ classes = null;
28
+ }
31
29
 
32
- options = prepareAnimationOptions(options);
33
- if (!classes) {
34
- classes = element.attr("class") || "";
35
- if (options.addClass) {
36
- classes += ` ${options.addClass}`;
37
- }
38
- if (options.removeClass) {
39
- classes += ` ${options.removeClass}`;
40
- }
30
+ options = prepareAnimationOptions(options);
31
+ if (!classes) {
32
+ classes = element.attr("class") || "";
33
+ if (options.addClass) {
34
+ classes += ` ${options.addClass}`;
41
35
  }
36
+ if (options.removeClass) {
37
+ classes += ` ${options.removeClass}`;
38
+ }
39
+ }
42
40
 
43
- const classesToAdd = options.addClass;
44
- const classesToRemove = options.removeClass;
45
-
46
- // the lookupAnimations function returns a series of animation objects that are
47
- // matched up with one or more of the CSS classes. These animation objects are
48
- // defined via the module.animation factory function. If nothing is detected then
49
- // we don't return anything which then makes $animation query the next driver.
50
- const animations = lookupAnimations(classes);
51
- let before;
52
- let after;
53
- if (animations.length) {
54
- let afterFn;
55
- let beforeFn;
56
- if (event === "leave") {
57
- beforeFn = "leave";
58
- afterFn = "afterLeave"; // TODO(matsko): get rid of this
59
- } else {
60
- beforeFn = `before${event.charAt(0).toUpperCase()}${event.substr(1)}`;
61
- afterFn = event;
62
- }
41
+ const classesToAdd = options.addClass;
42
+ const classesToRemove = options.removeClass;
43
+
44
+ // the lookupAnimations function returns a series of animation objects that are
45
+ // matched up with one or more of the CSS classes. These animation objects are
46
+ // defined via the module.animation factory function. If nothing is detected then
47
+ // we don't return anything which then makes $animation query the next driver.
48
+ const animations = lookupAnimations(classes);
49
+ let before;
50
+ let after;
51
+ if (animations.length) {
52
+ let afterFn;
53
+ let beforeFn;
54
+ if (event === "leave") {
55
+ beforeFn = "leave";
56
+ afterFn = "afterLeave"; // TODO(matsko): get rid of this
57
+ } else {
58
+ beforeFn = `before${event.charAt(0).toUpperCase()}${event.substr(1)}`;
59
+ afterFn = event;
60
+ }
63
61
 
64
- if (event !== "enter" && event !== "move") {
65
- before = packageAnimations(
66
- element,
67
- event,
68
- options,
69
- animations,
70
- beforeFn,
71
- );
72
- }
73
- after = packageAnimations(
62
+ if (event !== "enter" && event !== "move") {
63
+ before = packageAnimations(
74
64
  element,
75
65
  event,
76
66
  options,
77
67
  animations,
78
- afterFn,
68
+ beforeFn,
79
69
  );
80
70
  }
71
+ after = packageAnimations(
72
+ element,
73
+ event,
74
+ options,
75
+ animations,
76
+ afterFn,
77
+ );
78
+ }
81
79
 
82
- // no matching animations
83
- if (!before && !after) return;
80
+ // no matching animations
81
+ if (!before && !after) return;
84
82
 
85
- function applyOptions() {
86
- options.domOperation();
87
- applyAnimationClasses(element, options);
88
- }
83
+ function applyOptions() {
84
+ options.domOperation();
85
+ applyAnimationClasses(element, options);
86
+ }
89
87
 
90
- function close() {
91
- animationClosed = true;
92
- applyOptions();
93
- applyAnimationStyles(element, options);
94
- }
88
+ function close() {
89
+ animationClosed = true;
90
+ applyOptions();
91
+ applyAnimationStyles(element, options);
92
+ }
95
93
 
96
- let runner;
97
-
98
- return {
99
- $$willAnimate: true,
100
- end() {
101
- if (runner) {
102
- runner.end();
103
- } else {
104
- close();
105
- runner = new $$AnimateRunner();
106
- runner.complete(true);
107
- }
108
- return runner;
109
- },
110
- start() {
111
- if (runner) {
112
- return runner;
113
- }
94
+ let runner;
114
95
 
96
+ return {
97
+ $$willAnimate: true,
98
+ end() {
99
+ if (runner) {
100
+ runner.end();
101
+ } else {
102
+ close();
115
103
  runner = new $$AnimateRunner();
116
- let closeActiveAnimations;
117
- const chain = [];
104
+ runner.complete(true);
105
+ }
106
+ return runner;
107
+ },
108
+ start() {
109
+ if (runner) {
110
+ return runner;
111
+ }
118
112
 
119
- if (before) {
120
- chain.push((fn) => {
121
- closeActiveAnimations = before(fn);
122
- });
123
- }
113
+ runner = new $$AnimateRunner();
114
+ let closeActiveAnimations;
115
+ const chain = [];
124
116
 
125
- if (chain.length) {
126
- chain.push((fn) => {
127
- applyOptions();
128
- fn(true);
129
- });
130
- } else {
131
- applyOptions();
132
- }
117
+ if (before) {
118
+ chain.push((fn) => {
119
+ closeActiveAnimations = before(fn);
120
+ });
121
+ }
133
122
 
134
- if (after) {
135
- chain.push((fn) => {
136
- closeActiveAnimations = after(fn);
137
- });
138
- }
123
+ if (chain.length) {
124
+ chain.push((fn) => {
125
+ applyOptions();
126
+ fn(true);
127
+ });
128
+ } else {
129
+ applyOptions();
130
+ }
139
131
 
140
- runner.setHost({
141
- end() {
142
- endAnimations();
143
- },
144
- cancel() {
145
- endAnimations(true);
146
- },
132
+ if (after) {
133
+ chain.push((fn) => {
134
+ closeActiveAnimations = after(fn);
147
135
  });
136
+ }
148
137
 
149
- $$AnimateRunner.chain(chain, onComplete);
150
- return runner;
138
+ runner.setHost({
139
+ end() {
140
+ endAnimations();
141
+ },
142
+ cancel() {
143
+ endAnimations(true);
144
+ },
145
+ });
151
146
 
152
- function onComplete(success) {
153
- close();
154
- runner.complete(success);
155
- }
147
+ $$AnimateRunner.chain(chain, onComplete);
148
+ return runner;
156
149
 
157
- function endAnimations(cancelled) {
158
- if (!animationClosed) {
159
- (closeActiveAnimations || (() => {}))(cancelled);
160
- onComplete(cancelled);
161
- }
162
- }
163
- },
164
- };
150
+ function onComplete(success) {
151
+ close();
152
+ runner.complete(success);
153
+ }
165
154
 
166
- function executeAnimationFn(fn, element, event, options, onDone) {
167
- let args;
168
- switch (event) {
169
- case "animate":
170
- args = [element, options.from, options.to, onDone];
171
- break;
155
+ function endAnimations(cancelled) {
156
+ if (!animationClosed) {
157
+ (closeActiveAnimations || (() => {}))(cancelled);
158
+ onComplete(cancelled);
159
+ }
160
+ }
161
+ },
162
+ };
172
163
 
173
- case "setClass":
174
- args = [element, classesToAdd, classesToRemove, onDone];
175
- break;
164
+ function executeAnimationFn(fn, element, event, options, onDone) {
165
+ let args;
166
+ switch (event) {
167
+ case "animate":
168
+ args = [element, options.from, options.to, onDone];
169
+ break;
176
170
 
177
- case "addClass":
178
- args = [element, classesToAdd, onDone];
179
- break;
171
+ case "setClass":
172
+ args = [element, classesToAdd, classesToRemove, onDone];
173
+ break;
180
174
 
181
- case "removeClass":
182
- args = [element, classesToRemove, onDone];
183
- break;
175
+ case "addClass":
176
+ args = [element, classesToAdd, onDone];
177
+ break;
184
178
 
185
- default:
186
- args = [element, onDone];
187
- break;
188
- }
179
+ case "removeClass":
180
+ args = [element, classesToRemove, onDone];
181
+ break;
189
182
 
190
- args.push(options);
183
+ default:
184
+ args = [element, onDone];
185
+ break;
186
+ }
191
187
 
192
- let value = fn.apply(fn, args);
193
- if (value) {
194
- if (isFunction(value.start)) {
195
- value = value.start();
196
- }
188
+ args.push(options);
197
189
 
198
- if (value instanceof $$AnimateRunner) {
199
- value.done(onDone);
200
- } else if (isFunction(value)) {
201
- // optional onEnd / onCancel callback
202
- return value;
203
- }
190
+ let value = fn.apply(fn, args);
191
+ if (value) {
192
+ if (isFunction(value.start)) {
193
+ value = value.start();
204
194
  }
205
195
 
206
- return () => {};
196
+ if (value instanceof $$AnimateRunner) {
197
+ value.done(onDone);
198
+ } else if (isFunction(value)) {
199
+ // optional onEnd / onCancel callback
200
+ return value;
201
+ }
207
202
  }
208
203
 
209
- function groupEventedAnimations(
210
- element,
211
- event,
212
- options,
213
- animations,
214
- fnName,
215
- ) {
216
- const operations = [];
217
- forEach(animations, (ani) => {
218
- const animation = ani[fnName];
219
- if (!animation) return;
220
-
221
- // note that all of these animations will run in parallel
222
- operations.push(() => {
223
- let runner;
224
- let endProgressCb;
225
-
226
- let resolved = false;
227
- const onAnimationComplete = function (rejected) {
228
- if (!resolved) {
229
- resolved = true;
230
- (endProgressCb || (() => {}))(rejected);
231
- runner.complete(!rejected);
232
- }
233
- };
234
-
235
- runner = new $$AnimateRunner({
236
- end() {
237
- onAnimationComplete();
238
- },
239
- cancel() {
240
- onAnimationComplete(true);
241
- },
242
- });
243
-
244
- endProgressCb = executeAnimationFn(
245
- animation,
246
- element,
247
- event,
248
- options,
249
- (result) => {
250
- const cancelled = result === false;
251
- onAnimationComplete(cancelled);
252
- },
253
- );
254
-
255
- return runner;
204
+ return () => {};
205
+ }
206
+
207
+ function groupEventedAnimations(
208
+ element,
209
+ event,
210
+ options,
211
+ animations,
212
+ fnName,
213
+ ) {
214
+ const operations = [];
215
+ forEach(animations, (ani) => {
216
+ const animation = ani[fnName];
217
+ if (!animation) return;
218
+
219
+ // note that all of these animations will run in parallel
220
+ operations.push(() => {
221
+ let runner;
222
+ let endProgressCb;
223
+
224
+ let resolved = false;
225
+ const onAnimationComplete = function (rejected) {
226
+ if (!resolved) {
227
+ resolved = true;
228
+ (endProgressCb || (() => {}))(rejected);
229
+ runner.complete(!rejected);
230
+ }
231
+ };
232
+
233
+ runner = new $$AnimateRunner({
234
+ end() {
235
+ onAnimationComplete();
236
+ },
237
+ cancel() {
238
+ onAnimationComplete(true);
239
+ },
256
240
  });
241
+
242
+ endProgressCb = executeAnimationFn(
243
+ animation,
244
+ element,
245
+ event,
246
+ options,
247
+ (result) => {
248
+ const cancelled = result === false;
249
+ onAnimationComplete(cancelled);
250
+ },
251
+ );
252
+
253
+ return runner;
257
254
  });
255
+ });
258
256
 
259
- return operations;
260
- }
257
+ return operations;
258
+ }
261
259
 
262
- function packageAnimations(
260
+ function packageAnimations(
261
+ element,
262
+ event,
263
+ options,
264
+ animations,
265
+ fnName,
266
+ ) {
267
+ let operations = groupEventedAnimations(
263
268
  element,
264
269
  event,
265
270
  options,
266
271
  animations,
267
272
  fnName,
268
- ) {
269
- let operations = groupEventedAnimations(
270
- element,
271
- event,
272
- options,
273
- animations,
274
- fnName,
275
- );
276
- if (operations.length === 0) {
277
- let a;
278
- let b;
279
- if (fnName === "beforeSetClass") {
280
- a = groupEventedAnimations(
281
- element,
282
- "removeClass",
283
- options,
284
- animations,
285
- "beforeRemoveClass",
286
- );
287
- b = groupEventedAnimations(
288
- element,
289
- "addClass",
290
- options,
291
- animations,
292
- "beforeAddClass",
293
- );
294
- } else if (fnName === "setClass") {
295
- a = groupEventedAnimations(
296
- element,
297
- "removeClass",
298
- options,
299
- animations,
300
- "removeClass",
301
- );
302
- b = groupEventedAnimations(
303
- element,
304
- "addClass",
305
- options,
306
- animations,
307
- "addClass",
308
- );
309
- }
273
+ );
274
+ if (operations.length === 0) {
275
+ let a;
276
+ let b;
277
+ if (fnName === "beforeSetClass") {
278
+ a = groupEventedAnimations(
279
+ element,
280
+ "removeClass",
281
+ options,
282
+ animations,
283
+ "beforeRemoveClass",
284
+ );
285
+ b = groupEventedAnimations(
286
+ element,
287
+ "addClass",
288
+ options,
289
+ animations,
290
+ "beforeAddClass",
291
+ );
292
+ } else if (fnName === "setClass") {
293
+ a = groupEventedAnimations(
294
+ element,
295
+ "removeClass",
296
+ options,
297
+ animations,
298
+ "removeClass",
299
+ );
300
+ b = groupEventedAnimations(
301
+ element,
302
+ "addClass",
303
+ options,
304
+ animations,
305
+ "addClass",
306
+ );
307
+ }
310
308
 
311
- if (a) {
312
- operations = operations.concat(a);
313
- }
314
- if (b) {
315
- operations = operations.concat(b);
316
- }
309
+ if (a) {
310
+ operations = operations.concat(a);
317
311
  }
312
+ if (b) {
313
+ operations = operations.concat(b);
314
+ }
315
+ }
318
316
 
319
- if (operations.length === 0) return;
317
+ if (operations.length === 0) return;
320
318
 
321
- // TODO(matsko): add documentation
322
- return function startAnimation(callback) {
323
- const runners = [];
324
- if (operations.length) {
325
- forEach(operations, (animateFn) => {
326
- runners.push(animateFn());
327
- });
328
- }
319
+ // TODO(matsko): add documentation
320
+ return function startAnimation(callback) {
321
+ const runners = [];
322
+ if (operations.length) {
323
+ forEach(operations, (animateFn) => {
324
+ runners.push(animateFn());
325
+ });
326
+ }
329
327
 
330
- if (runners.length) {
331
- $$AnimateRunner.all(runners, callback);
332
- } else {
333
- callback();
334
- }
328
+ if (runners.length) {
329
+ $$AnimateRunner.all(runners, callback);
330
+ } else {
331
+ callback();
332
+ }
335
333
 
336
- return function endFn(reject) {
337
- forEach(runners, (runner) => {
338
- if (reject) {
339
- runner.cancel();
340
- } else {
341
- runner.end();
342
- }
343
- });
344
- };
334
+ return function endFn(reject) {
335
+ forEach(runners, (runner) => {
336
+ if (reject) {
337
+ runner.cancel();
338
+ } else {
339
+ runner.end();
340
+ }
341
+ });
345
342
  };
343
+ };
344
+ }
345
+ };
346
+
347
+ function lookupAnimations(classes) {
348
+ classes = Array.isArray(classes) ? classes : classes.split(" ");
349
+ const matches = [];
350
+ const flagMap = {};
351
+ for (let i = 0; i < classes.length; i++) {
352
+ const klass = classes[i];
353
+ const animationFactory =
354
+ $animateProvider.$$registeredAnimations[klass];
355
+ if (animationFactory && !flagMap[klass]) {
356
+ matches.push($injector.get(animationFactory));
357
+ flagMap[klass] = true;
346
358
  }
347
- };
348
-
349
- function lookupAnimations(classes) {
350
- classes = Array.isArray(classes) ? classes : classes.split(" ");
351
- const matches = [];
352
- const flagMap = {};
353
- for (let i = 0; i < classes.length; i++) {
354
- const klass = classes[i];
355
- const animationFactory =
356
- $animateProvider.$$registeredAnimations[klass];
357
- if (animationFactory && !flagMap[klass]) {
358
- matches.push($injector.get(animationFactory));
359
- flagMap[klass] = true;
360
- }
361
- }
362
- return matches;
363
359
  }
364
- },
365
- ];
366
- },
367
- ];
360
+ return matches;
361
+ }
362
+ },
363
+ ];
364
+ }