@angular-wave/angular.ts 0.0.13 → 0.0.14

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@angular-wave/angular.ts",
3
3
  "license": "MIT",
4
- "version": "0.0.13",
4
+ "version": "0.0.14",
5
5
  "type": "module",
6
6
  "main": "dist/angular-ts.esm.js",
7
7
  "browser": "dist/angular-ts.umd.js",
@@ -518,33 +518,33 @@ _ {@link module:ngMessages Click here} to learn more about`ngMessages`and`ngMess
518
518
  _ @param {string} ngMessageExp|whenExp an expression value corresponding to the message key.
519
519
  _/
520
520
 
521
- /**
522
- * @ngdoc directive
523
- * @name ngMessageDefault
524
- * @restrict AE
525
- * @scope
526
- *
527
- * @description
528
- * `ngMessageDefault` is a directive with the purpose to show and hide a default message for
529
- * {@link directive:ngMessages}, when none of provided messages matches.
530
- *
531
- * More information about using `ngMessageDefault` can be found in the
532
- * {@link module:ngMessages `ngMessages` module documentation}.
533
- *
534
- * @usage
535
- * ```html
536
- * <!-- using attribute directives -->
537
- * <ANY ng-messages="expression" role="alert">
538
- * <ANY ng-message="stringValue">...</ANY>
539
- * <ANY ng-message="stringValue1, stringValue2, ...">...</ANY>
540
- * <ANY ng-message-default>...</ANY>
541
- * </ANY>
542
- *
543
- * <!-- or by using element directives -->
544
- * <ng-messages for="expression" role="alert">
545
- * <ng-message when="stringValue">...</ng-message>
546
- * <ng-message when="stringValue1, stringValue2, ...">...</ng-message>
547
- * <ng-message-default>...</ng-message-default>
548
- * </ng-messages>
549
- *
550
- */
521
+ /**
522
+ * @ngdoc directive
523
+ * @name ngMessageDefault
524
+ * @restrict AE
525
+ * @scope
526
+ *
527
+ * @description
528
+ * `ngMessageDefault` is a directive with the purpose to show and hide a default message for
529
+ * {@link directive:ngMessages}, when none of provided messages matches.
530
+ *
531
+ * More information about using `ngMessageDefault` can be found in the
532
+ * {@link module:ngMessages `ngMessages` module documentation}.
533
+ *
534
+ * @usage
535
+ * ```html
536
+ * <!-- using attribute directives -->
537
+ * <ANY ng-messages="expression" role="alert">
538
+ * <ANY ng-message="stringValue">...</ANY>
539
+ * <ANY ng-message="stringValue1, stringValue2, ...">...</ANY>
540
+ * <ANY ng-message-default>...</ANY>
541
+ * </ANY>
542
+ *
543
+ * <!-- or by using element directives -->
544
+ * <ng-messages for="expression" role="alert">
545
+ * <ng-message when="stringValue">...</ng-message>
546
+ * <ng-message when="stringValue1, stringValue2, ...">...</ng-message>
547
+ * <ng-message-default>...</ng-message-default>
548
+ * </ng-messages>
549
+ *
550
+ */
package/src/index.js CHANGED
@@ -5,7 +5,6 @@ import { publishExternalAPI } from "./public";
5
5
  * @type {angular.IAngularStatic}
6
6
  */
7
7
  window.angular = new Angular();
8
- console.log(window.angular);
9
8
 
10
9
  publishExternalAPI();
11
10
 
@@ -4,23 +4,21 @@
4
4
  * These are the directives included in UI-Router for Angular 1.
5
5
  * These directives are used in templates to create viewports and link/navigate to states.
6
6
  *
7
- * @preferred @publicapi @module directives
8
- */ /** */
7
+ */
9
8
  import {
10
9
  extend,
11
10
  forEach,
12
11
  tail,
13
- isString,
14
- isObject,
15
- isArray,
16
- parse,
17
12
  noop,
18
13
  unnestR,
19
14
  identity,
20
15
  uniqR,
21
16
  inArray,
22
17
  removeFrom,
23
- } from "../../core/index";
18
+ } from "../../core/common/common";
19
+ import { isString, isObject, isArray } from "../../core/common/predicates";
20
+
21
+ import { parse } from "../../core/common/hof";
24
22
  /** @hidden */
25
23
  function parseStateRef(ref) {
26
24
  const paramsOnly = ref.match(/^\s*({[^}]*})\s*$/);
@@ -52,12 +50,12 @@ function processedDef($state, $element, def) {
52
50
  function getTypeInfo(el) {
53
51
  // SVGAElement does not use the href attribute, but rather the 'xlinkHref' attribute.
54
52
  const isSvg =
55
- Object.prototype.toString.call(el.prop("href")) ===
53
+ Object.prototype.toString.call(el[0].getAttribute("href")) ===
56
54
  "[object SVGAnimatedString]";
57
55
  const isForm = el[0].nodeName === "FORM";
58
56
  return {
59
57
  attr: isForm ? "action" : isSvg ? "xlink:href" : "href",
60
- isAnchor: el.prop("tagName").toUpperCase() === "A",
58
+ isAnchor: el[0].nodeName === "A",
61
59
  clickable: !isForm,
62
60
  };
63
61
  }
@@ -252,8 +250,7 @@ function bindEvents(element, scope, hookFn, uiStateOpts) {
252
250
  * - Unlike the parameter values expression, the state name is not `$watch`ed (for performance reasons).
253
251
  * If you need to dynamically update the state being linked to, use the fully dynamic [[uiState]] directive.
254
252
  */
255
- let uiSrefDirective;
256
- uiSrefDirective = [
253
+ export let uiSrefDirective = [
257
254
  "$uiRouter",
258
255
  "$timeout",
259
256
  function $StateRefDirective($uiRouter, $timeout) {
@@ -390,8 +387,7 @@ uiSrefDirective = [
390
387
  * - A middle-click, right-click, or ctrl-click is handled (natively) by the browser to open the href in a new window, for example.
391
388
  * ```
392
389
  */
393
- let uiStateDirective;
394
- uiStateDirective = [
390
+ export let uiStateDirective = [
395
391
  "$uiRouter",
396
392
  "$timeout",
397
393
  function $StateRefDynamicDirective($uiRouter, $timeout) {
@@ -540,8 +536,7 @@ uiStateDirective = [
540
536
  *
541
537
  * - Multiple classes may be specified in a space-separated format: `ui-sref-active='class1 class2 class3'`
542
538
  */
543
- let uiSrefActiveDirective;
544
- uiSrefActiveDirective = [
539
+ export let uiSrefActiveDirective = [
545
540
  "$state",
546
541
  "$stateParams",
547
542
  "$interpolate",
@@ -675,9 +670,11 @@ uiSrefActiveDirective = [
675
670
  (cls) => !inArray(addClasses, cls),
676
671
  );
677
672
  $scope.$evalAsync(() => {
678
- addClasses.forEach((className) => $element.addClass(className));
673
+ addClasses.forEach((className) =>
674
+ $element[0].classList.add(className),
675
+ );
679
676
  removeClasses.forEach((className) =>
680
- $element.removeClass(className),
677
+ $element[0].classList.remove(className),
681
678
  );
682
679
  });
683
680
  }
@@ -687,9 +684,3 @@ uiSrefActiveDirective = [
687
684
  };
688
685
  },
689
686
  ];
690
- window.angular
691
- .module("ui.router.state")
692
- .directive("uiSref", uiSrefDirective)
693
- .directive("uiSrefActive", uiSrefActiveDirective)
694
- .directive("uiSrefActiveEq", uiSrefActiveDirective)
695
- .directive("uiState", uiStateDirective);
@@ -1,21 +1,13 @@
1
- /** @publicapi @module directives */ /** */
2
- import {
3
- extend,
4
- filter,
5
- isDefined,
6
- isFunction,
7
- isString,
8
- kebobString,
9
- noop,
10
- parse,
11
- ResolveContext,
12
- tail,
13
- trace,
14
- unnestR,
15
- } from "../../core/index";
16
-
1
+ import { extend, filter, tail, unnestR } from "../../core/common/common";
2
+ import { isDefined, isFunction, isString } from "../../core/common/predicates";
3
+ import { kebobString } from "../../core/common/strings";
4
+ import { noop } from "../../core/common/common";
5
+ import { parse } from "../../core/common/hof";
6
+ import { ResolveContext } from "../../core/resolve/resolveContext";
7
+ import { trace } from "../../core/common/trace";
17
8
  import { getLocals } from "../services";
18
9
  import { Ng1ViewConfig } from "../statebuilders/views";
10
+ import { jqLite } from "../../../jqLite";
19
11
  /**
20
12
  * `ui-view`: A viewport directive which is filled in by a view from the active state.
21
13
  *
@@ -141,9 +133,7 @@ import { Ng1ViewConfig } from "../statebuilders/views";
141
133
  * });
142
134
  * ```
143
135
  */
144
- export let uiView;
145
- // eslint-disable-next-line prefer-const
146
- uiView = [
136
+ export let uiView = [
147
137
  "$view",
148
138
  "$animate",
149
139
  "$uiViewScroll",
@@ -153,18 +143,18 @@ uiView = [
153
143
  function getRenderer() {
154
144
  return {
155
145
  enter: function (element, target, cb) {
156
- if (angular.version.minor > 2) {
157
- $animate.enter(element, null, target).then(cb);
158
- } else {
159
- $animate.enter(element, null, target, cb);
160
- }
146
+ // if (angular.version.minor > 2) {
147
+ //$animate.enter(element, null, target).then(cb);
148
+ // } else {
149
+ $animate.enter(element, null, target, cb);
150
+ // }
161
151
  },
162
152
  leave: function (element, cb) {
163
- if (angular.version.minor > 2) {
164
- $animate.leave(element).then(cb);
165
- } else {
166
- $animate.leave(element, cb);
167
- }
153
+ // if (angular.version.minor > 2) {
154
+ //$animate.leave(element).then(cb);
155
+ // } else {
156
+ $animate.leave(element, cb);
157
+ // }
168
158
  },
169
159
  };
170
160
  }
@@ -324,8 +314,13 @@ $ViewDirectiveFill.$inject = [
324
314
  "$view",
325
315
  "$q",
326
316
  ];
327
- /** @hidden */
328
- function $ViewDirectiveFill($compile, $controller, $transitions, $view, $q) {
317
+ export function $ViewDirectiveFill(
318
+ $compile,
319
+ $controller,
320
+ $transitions,
321
+ $view,
322
+ $q,
323
+ ) {
329
324
  const getControllerAs = parse("viewDecl.controllerAs");
330
325
  const getResolveAs = parse("viewDecl.resolveAs");
331
326
  return {
@@ -338,14 +333,18 @@ function $ViewDirectiveFill($compile, $controller, $transitions, $view, $q) {
338
333
  const data = $element.data("$uiView");
339
334
  if (!data) {
340
335
  $element.html(initial);
341
- $compile($element.contents())(scope);
336
+ $compile($element[0].contentDocument || $element[0].childNodes)(
337
+ scope,
338
+ );
342
339
  return;
343
340
  }
344
341
  const cfg = data.$cfg || { viewDecl: {}, getTemplate: noop };
345
342
  const resolveCtx = cfg.path && new ResolveContext(cfg.path);
346
343
  $element.html(cfg.getTemplate($element, resolveCtx) || initial);
347
344
  trace.traceUIViewFill(data.$uiView, $element.html());
348
- const link = $compile($element.contents());
345
+ const link = $compile(
346
+ $element[0].contentDocument || $element[0].childNodes,
347
+ );
349
348
  const controller = cfg.controller;
350
349
  const controllerAs = getControllerAs(cfg);
351
350
  const resolveAs = getResolveAs(cfg);
@@ -386,7 +385,7 @@ function $ViewDirectiveFill($compile, $controller, $transitions, $view, $q) {
386
385
  .filter((el) => el && el.tagName && tagRegexp.exec(el.tagName));
387
386
  return (
388
387
  directiveEl &&
389
- angular.element(directiveEl).data(`$${cfg.component}Controller`)
388
+ jqLite(directiveEl).data(`$${cfg.component}Controller`)
390
389
  );
391
390
  };
392
391
  const deregisterWatch = scope.$watch(
@@ -410,8 +409,6 @@ function $ViewDirectiveFill($compile, $controller, $transitions, $view, $q) {
410
409
  };
411
410
  }
412
411
  /** @hidden */
413
- const hasComponentImpl =
414
- typeof angular.module("ui.router")["component"] === "function";
415
412
  /** @hidden incrementing id */
416
413
  let _uiCanExitId = 0;
417
414
  /** @hidden TODO: move these callbacks to $view and/or `/hooks/components.ts` or something */
@@ -425,10 +422,7 @@ function registerControllerCallbacks(
425
422
  // Call $onInit() ASAP
426
423
  if (
427
424
  isFunction(controllerInstance.$onInit) &&
428
- !(
429
- (cfg.viewDecl.component || cfg.viewDecl.componentProvider) &&
430
- hasComponentImpl
431
- )
425
+ !(cfg.viewDecl.component || cfg.viewDecl.componentProvider)
432
426
  ) {
433
427
  controllerInstance.$onInit();
434
428
  }
@@ -508,7 +502,3 @@ function registerControllerCallbacks(
508
502
  );
509
503
  }
510
504
  }
511
- window.angular
512
- .module("ui.router.state")
513
- .directive("uiView", uiView)
514
- .directive("uiView", $ViewDirectiveFill);
@@ -100,7 +100,6 @@ export function runBlock($injector, $q, $uiRouter) {
100
100
  // $state service and $stateProvider
101
101
  // $urlRouter service and $urlRouterProvider
102
102
  export function getStateProvider() {
103
- debugger;
104
103
  return extend(router.stateProvider, { $get: () => router.stateService });
105
104
  }
106
105
 
@@ -11,7 +11,7 @@
11
11
  * ```
12
12
  */
13
13
  $IsStateFilter.$inject = ["$state"];
14
- function $IsStateFilter($state) {
14
+ export function $IsStateFilter($state) {
15
15
  const isFilter = function (state, params, options) {
16
16
  return $state.is(state, params, options);
17
17
  };
@@ -29,15 +29,10 @@ function $IsStateFilter($state) {
29
29
  * ```
30
30
  */
31
31
  $IncludedByStateFilter.$inject = ["$state"];
32
- function $IncludedByStateFilter($state) {
32
+ export function $IncludedByStateFilter($state) {
33
33
  const includesFilter = function (state, params, options) {
34
34
  return $state.includes(state, params, options);
35
35
  };
36
36
  includesFilter.$stateful = true;
37
37
  return includesFilter;
38
38
  }
39
- window.angular
40
- .module("ui.router.state")
41
- .filter("isState", $IsStateFilter)
42
- .filter("includedByState", $IncludedByStateFilter);
43
- export { $IsStateFilter, $IncludedByStateFilter };
@@ -154,7 +154,7 @@ export class TemplateFactory {
154
154
  makeComponentTemplate(uiView, context, component, bindings) {
155
155
  bindings = bindings || {};
156
156
  // Bind once prefix
157
- const prefix = angular.version.minor >= 3 ? "::" : "";
157
+ const prefix = "::"; //angular.version.minor >= 3 ? "::" : "";
158
158
  // Convert to kebob name. Add x- prefix if the string starts with `x-` or `data-`
159
159
  const kebob = (camelCase) => {
160
160
  const kebobed = kebobString(camelCase);
@@ -1,7 +1,4 @@
1
- /** @publicapi @module ng1 */ /** */
2
-
3
- /** @hidden */
4
- function $ViewScrollProvider() {
1
+ export function $ViewScrollProvider() {
5
2
  let useAnchorScroll = false;
6
3
  this.useAnchorScroll = function () {
7
4
  useAnchorScroll = true;
@@ -25,7 +22,3 @@ function $ViewScrollProvider() {
25
22
  },
26
23
  ];
27
24
  }
28
-
29
- window.angular
30
- .module("ui.router.state")
31
- .provider("$uiViewScroll", $ViewScrollProvider);
@@ -1,4 +1,4 @@
1
- import { defaults, find, inherit } from "../common/common";
1
+ import { defaults, find } from "../common/common";
2
2
  import { propEq } from "../common/hof";
3
3
  import { Glob } from "../common/glob";
4
4
  import { isObject, isFunction } from "../common/predicates";
@@ -25,7 +25,7 @@ export class StateObject {
25
25
  stateDecl = StateObject.isStateClass(stateDecl)
26
26
  ? new stateDecl()
27
27
  : stateDecl;
28
- const state = inherit(inherit(stateDecl, StateObject.prototype));
28
+ const state = Object.setPrototypeOf(stateDecl, StateObject.prototype);
29
29
  stateDecl.$$state = () => state;
30
30
  state.self = stateDecl;
31
31
  state.__stateObjectCache = {
@@ -33,7 +33,7 @@ export class StateObject {
33
33
  };
34
34
  return state;
35
35
  }
36
- /** @deprecated use State.create() */
36
+ // /** @deprecated use State.create() */
37
37
  constructor(config) {
38
38
  return StateObject.create(config || {});
39
39
  }
@@ -8,6 +8,14 @@ import {
8
8
  } from "./adapter/services";
9
9
  import { TemplateFactory } from "./adapter/templateFactory";
10
10
  import { trace } from "./core/common/trace";
11
+ import { $ViewScrollProvider } from "./adapter/viewScroll";
12
+ import { $IsStateFilter, $IncludedByStateFilter } from "./adapter/stateFilters";
13
+ import {
14
+ uiSrefActiveDirective,
15
+ uiStateDirective,
16
+ uiSrefDirective,
17
+ } from "./adapter/directives/stateDirectives";
18
+ import { uiView, $ViewDirectiveFill } from "./adapter/directives/viewDirective";
11
19
 
12
20
  export function initRouter() {
13
21
  window.angular.module("ui.router.angular1", []);
@@ -35,16 +43,26 @@ export function initRouter() {
35
43
  mod_util.provider("$templateFactory", function () {
36
44
  return new TemplateFactory();
37
45
  });
38
- mod_state.provider("$stateRegistry", getProviderFor("stateRegistry"));
39
- mod_state.provider("$uiRouterGlobals", getProviderFor("globals"));
40
- mod_state.provider("$transitions", getProviderFor("transitionService"));
41
- mod_state.provider("$state", ["$uiRouterProvider", getStateProvider]);
42
- mod_state.factory("$stateParams", [
43
- "$uiRouter",
44
- function StateParamse($uiRouter) {
45
- return $uiRouter.globals.params;
46
- },
47
- ]);
46
+ mod_state
47
+ .provider("$stateRegistry", getProviderFor("stateRegistry"))
48
+ .provider("$uiRouterGlobals", getProviderFor("globals"))
49
+ .provider("$transitions", getProviderFor("transitionService"))
50
+ .provider("$state", ["$uiRouterProvider", getStateProvider])
51
+ .provider("$uiViewScroll", $ViewScrollProvider)
52
+ .factory("$stateParams", [
53
+ "$uiRouter",
54
+ function StateParamse($uiRouter) {
55
+ return $uiRouter.globals.params;
56
+ },
57
+ ])
58
+ .filter("isState", $IsStateFilter)
59
+ .filter("includedByState", $IncludedByStateFilter)
60
+ .directive("uiSref", uiSrefDirective)
61
+ .directive("uiSrefActive", uiSrefActiveDirective)
62
+ .directive("uiSrefActiveEq", uiSrefActiveDirective)
63
+ .directive("uiState", uiStateDirective)
64
+ .directive("uiView", uiView)
65
+ .directive("uiView", $ViewDirectiveFill);
48
66
  mod_main.factory("$view", function View() {
49
67
  return router.viewService;
50
68
  });
@@ -1,23 +1,26 @@
1
1
  <!doctype html>
2
2
  <html>
3
3
  <head>
4
+ <script></script>
5
+ <script type="module" src="../src/index.js"></script>
4
6
  <script>
5
7
  document.addEventListener("DOMContentLoaded", () => {
6
- window.angular.module("test", ["ui.router"]);
8
+ var myApp = window.angular.module("test", ["ui.router"]);
9
+ myApp.config(function ($stateProvider) {
10
+ var helloState = {
11
+ name: "hello",
12
+ url: "/",
13
+ template: "<h3>hello world!</h3>",
14
+ };
15
+
16
+ $stateProvider.state(helloState);
17
+ });
7
18
  });
8
19
  </script>
9
- <script type="module" src="../src/index.js"></script>
10
20
  </head>
11
21
  <body ng-app="test">
12
- <div ng-init='list = [{ name: "x" }, { name: "y" }, { name: "z" }]'>
13
- <label>Name:</label>
14
- <input type="text" ng-model="yourName" placeholder="Enter a name here" />
15
- <hr />
16
- <h1>Hello {{yourName}}!</h1>
17
-
18
- <ul ng-repeat="i in list">
19
- <li>{{ i.name }}</li>
20
- </ul>
21
- </div>
22
+ {{ 2 + 2 }}
23
+ <a ui-sref="hello" ui-sref-active="active">Hello</a>
24
+ <ui-view></ui-view>
22
25
  </body>
23
26
  </html>
@@ -103,7 +103,6 @@ describe("ngIf", () => {
103
103
 
104
104
  it("should destroy the child scope every time the expression evaluates to false", () => {
105
105
  $scope.value = true;
106
- debugger;
107
106
  element.append($compile('<div ng-if="value"></div>')($scope));
108
107
  $scope.$apply();
109
108
 
@@ -1,21 +1,33 @@
1
1
  <!doctype html>
2
2
  <html>
3
3
  <head>
4
- <script src="../legacy/build/angular.js"></script>
5
- </head>
6
- <body>
7
- Test:
8
- <my-component></my-component>
9
- {{ 2 + 2 }}
10
- </body>
4
+ <script src="../legacy/angular.js"></script>
5
+ <script src="//unpkg.com/@uirouter/angularjs/release/angular-ui-router.min.js"></script>
6
+ <script>
7
+ var myApp = angular.module("helloworld", ["ui.router"]);
8
+
9
+ myApp.config(function ($stateProvider) {
10
+ var helloState = {
11
+ name: "hello",
12
+ url: "/",
13
+ template: "<h3>hello world!</h3>",
14
+ };
11
15
 
12
- <script>
13
- document.addEventListener("DOMContentLoaded", () => {
14
- window.angular.module("myModule", []).component("myComponent", {
15
- template: "<div>ME</div>",
16
+ var aboutState = {
17
+ name: "about",
18
+ url: "/about",
19
+ template: "<h3>Its the UI-Router hello world app!</h3>",
20
+ };
21
+
22
+ $stateProvider.state(helloState);
23
+ $stateProvider.state(aboutState);
16
24
  });
17
- window.angular.bootstrap(document, ["myModule"]);
18
- //angularInit(document, window.angular.bootstrap);
19
- });
20
- </script>
25
+ </script>
26
+ </head>
27
+ <body ng-app="helloworld">
28
+ <a ui-sref="hello" ui-sref-active="active">Hello</a>
29
+ {{ 2 + 2}}
30
+ <ui-view></ui-view>
31
+ {{ 2 + 2}}
32
+ </body>
21
33
  </html>