@angular-wave/angular.ts 0.7.5 → 0.7.7

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 (33) hide show
  1. package/@types/core/scope/scope.d.ts +0 -2
  2. package/@types/directive/setter/setter.d.ts +2 -2
  3. package/@types/shared/utils.d.ts +8 -0
  4. package/dist/angular-ts.esm.js +208 -176
  5. package/dist/angular-ts.umd.js +208 -176
  6. package/dist/angular-ts.umd.min.js +1 -1
  7. package/docs/assets/scss/index.scss +12 -0
  8. package/docs/content/_index.md +15 -4
  9. package/docs/content/docs/directive/bind.md +70 -0
  10. package/docs/content/docs/directive/click.md +3 -0
  11. package/docs/content/docs/directive/dblclick.md +3 -0
  12. package/docs/content/docs/directive/keydown.md +38 -0
  13. package/docs/content/docs/directive/keyup.md +38 -0
  14. package/docs/content/docs/directive/load.md +43 -0
  15. package/docs/static/examples/ng-bind/ng-bind.html +9 -0
  16. package/docs/static/examples/ng-keydown/ng-keydown.html +9 -0
  17. package/docs/static/examples/ng-keyup/ng-keyup.html +9 -0
  18. package/docs/static/examples/ng-load/ng-load.html +8 -0
  19. package/legacy.d.ts +0 -4
  20. package/package.json +1 -1
  21. package/src/core/location/location.js +1 -1
  22. package/src/core/scope/scope.js +0 -5
  23. package/src/directive/bind/bind.js +16 -4
  24. package/src/directive/bind/bind.spec.js +13 -0
  25. package/src/directive/events/events.js +1 -1
  26. package/src/directive/events/events.md +0 -41
  27. package/src/directive/messages/messages.js +1 -1
  28. package/src/directive/repeat/repeat.js +175 -153
  29. package/src/directive/setter/setter.js +1 -1
  30. package/src/directive/switch/switch.spec.js +1 -1
  31. package/src/router/directives/state-directives.js +4 -6
  32. package/src/services/anchor-scroll.js +1 -1
  33. package/src/shared/utils.js +19 -1
@@ -10,4 +10,16 @@
10
10
  &::after {
11
11
  background-color: white !important; // override dark overlay
12
12
  }
13
+
14
+ #download {
15
+ display: flex;
16
+ flex-direction: row;
17
+ justify-content: center;
18
+ align-items: baseline;
19
+
20
+ #version {
21
+ font-weight: 600;
22
+ margin-right: 2rem;
23
+ }
24
+ }
13
25
  }
@@ -4,13 +4,24 @@ title: AngularTS
4
4
 
5
5
  {{< blocks/cover color="white" height="full" >}}
6
6
 
7
- <div class="text-center">
7
+ <div class="text-center" ng-app>
8
8
  <h1 class="display-1 mt-0 mt-md-5 pb-4">Angular<span>TS</span></h1>
9
9
  </div>
10
10
 
11
11
  <p class="lead mb-5">A modern, reactive and typesafe evolution of the classic JS framework from Google&copy;</p>
12
- <a class="btn btn-lg btn-secondary me-3 mb-4" href="https://github.com/Angular-Wave/angular.ts">
13
- Download <i class="fab fa-github ms-2 "></i>
14
- </a>
12
+
13
+ <div id="download">
14
+ <span id="version"></span>
15
+ <a class="btn btn-lg btn-secondary me-3 mb-4" href="https://github.com/Angular-Wave/angular.ts">
16
+ Download <i class="fab fa-github ms-2 "></i>
17
+ </a>
18
+ <script defer>
19
+ window.addEventListener("DOMContentLoaded", () => {
20
+ const versionSpan = document.getElementById("version");
21
+ const version = window.angular.version;
22
+ versionSpan.textContent = `Latest release: ${version}`;
23
+ });
24
+ </script>
25
+ </div>
15
26
 
16
27
  {{< /blocks/cover >}}
@@ -0,0 +1,70 @@
1
+ ---
2
+ title: ng-bind
3
+ description: >
4
+ Sync or hydrate textContent of element with an expression
5
+ ---
6
+
7
+ ### Description
8
+
9
+ The `ng-bind` attribute places the text content of the specified HTML element
10
+ with the value of a given expression, and to update the text content when the
11
+ value of that expression changes.
12
+
13
+ Typically, you don't use `ng-bind` directly, but instead you use the double
14
+ curly markup like `{{ expression }}` which is similar but less verbose.
15
+
16
+ It is preferable to use `ng-bind` instead of `{{ expression }}` if a template is
17
+ momentarily displayed by the browser in its raw state before it is compiled.
18
+ Since `ng-bind` is an element attribute, it makes the bindings invisible to the
19
+ user while the page is loading.
20
+
21
+ An alternative solution to this problem would be using the `ng-cloak` directive.
22
+
23
+ `ng-bind` can be modified with a `data-lazy` data attribute, which will delay
24
+ update of element content until model is changed. This is useful for rendering
25
+ server-generated content, while keeping the UI dynamic. In other frameworks,
26
+ this technieque is known as
27
+ [hydration](<https://en.wikipedia.org/wiki/Hydration_(web_development)>).
28
+
29
+ ### Directive parameters
30
+
31
+ ---
32
+
33
+ #### `ng-bind`
34
+
35
+ - **Type:** [Expression](../../../typedoc/types/Expression.html)
36
+ - **Restrict:** `A`
37
+ - **Element:** ANY
38
+ - **Priority:** `0`
39
+ - **Description:** Expression to evaluate and modify
40
+ [textContent](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent)
41
+ property.
42
+ - **Example:**
43
+
44
+ ```html
45
+ <div ng-bind="name"></div>
46
+ ```
47
+
48
+ ---
49
+
50
+ ### Directive modifiers
51
+
52
+ #### `data-lazy`
53
+
54
+ - **Type:** `boolean`
55
+ - **Description:** Apply expression once the bound model changes.
56
+ - **Example:**
57
+
58
+ ```html
59
+ <div ng-bind="name" data-lazy="true"></div>
60
+ ```
61
+
62
+ ---
63
+
64
+ #### Demo
65
+
66
+ {{< showhtml src="examples/ng-bind/ng-bind.html" >}}
67
+
68
+ {{< showraw src="examples/ng-bind/ng-bind.html" >}}
69
+
70
+ ---
@@ -16,6 +16,9 @@ is clicked.
16
16
  #### `ng-click`
17
17
 
18
18
  - **Type:** [Expression](../../../typedoc/types/Expression.html)
19
+ - **Restrict:** `A`
20
+ - **Element:** ANY
21
+ - **Priority:** `0`
19
22
  - **Description:** Expression to evaluate upon
20
23
  [click](https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event)
21
24
  event.
@@ -16,6 +16,9 @@ element is double clicked.
16
16
  #### `ng-dblclick`
17
17
 
18
18
  - **Type:** [Expression](../../../typedoc/types/Expression.html)
19
+ - **Restrict:** `A`
20
+ - **Element:** ANY
21
+ - **Priority:** `0`
19
22
  - **Description:** Expression to evaluate upon
20
23
  [dblclick](https://developer.mozilla.org/en-US/docs/Web/API/Element/dblclick_event)
21
24
  event.
@@ -0,0 +1,38 @@
1
+ ---
2
+ title: ng-keydown
3
+ description: >
4
+ Handler for keydown event
5
+ ---
6
+
7
+ ### Description
8
+
9
+ The `ng-keydown` directive allows you to specify custom behavior when pressing
10
+ keys, regardless of whether they produce a character value.
11
+
12
+ ### Directive parameters
13
+
14
+ ---
15
+
16
+ #### `ng-keydown`
17
+
18
+ - **Type:** [Expression](../../../typedoc/types/Expression.html)
19
+ - **Description:** Expression to evaluate upon
20
+ [keydown](https://developer.mozilla.org/en-US/docs/Web/API/Element/keydown_event)
21
+ event.
22
+ [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent)
23
+ object is available as `$event`.
24
+ - **Example:**
25
+
26
+ ```html
27
+ <div ng-keydown="$ctrl.greet($event)"></div>
28
+ ```
29
+
30
+ ---
31
+
32
+ #### Demo
33
+
34
+ {{< showhtml src="examples/ng-keydown/ng-keydown.html" >}}
35
+
36
+ {{< showraw src="examples/ng-keydown/ng-keydown.html" >}}
37
+
38
+ ---
@@ -0,0 +1,38 @@
1
+ ---
2
+ title: ng-keyup
3
+ description: >
4
+ Handler for keyup event
5
+ ---
6
+
7
+ ### Description
8
+
9
+ The `ng-keyup` directive allows you to specify custom behavior when releasing
10
+ keys, regardless of whether they produce a character value.
11
+
12
+ ### Directive parameters
13
+
14
+ ---
15
+
16
+ #### `ng-keyup`
17
+
18
+ - **Type:** [Expression](../../../typedoc/types/Expression.html)
19
+ - **Description:** Expression to evaluate upon
20
+ [keyup](https://developer.mozilla.org/en-US/docs/Web/API/Element/keyup_event)
21
+ event.
22
+ [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent)
23
+ object is available as `$event`.
24
+ - **Example:**
25
+
26
+ ```html
27
+ <div ng-keyup="$ctrl.greet($event)"></div>
28
+ ```
29
+
30
+ ---
31
+
32
+ #### Demo
33
+
34
+ {{< showhtml src="examples/ng-keyup/ng-keyup.html" >}}
35
+
36
+ {{< showraw src="examples/ng-keyup/ng-keyup.html" >}}
37
+
38
+ ---
@@ -0,0 +1,43 @@
1
+ ---
2
+ title: ng-load
3
+ description: >
4
+ Handler for load event
5
+ ---
6
+
7
+ ### Description
8
+
9
+ The `ng-load` directive allows you to specify custom behavior for elements that
10
+ trigger
11
+ [load](https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event)
12
+ event.
13
+
14
+ **Note**: there is no guarantee that the browser will bind `ng-load` directive
15
+ before loading its resource. Demo below is using a large image to showcase
16
+ itself.
17
+
18
+ ### Directive parameters
19
+
20
+ ---
21
+
22
+ #### `ng-load`
23
+
24
+ - **Type:** [Expression](../../../typedoc/types/Expression.html)
25
+ - **Description:** Expression to evaluate upon
26
+ [load](https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event)
27
+ event. [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event) object
28
+ is available as `$event`.
29
+ - **Example:**
30
+
31
+ ```html
32
+ <img src="url" ng-load="$ctrl.load($event)"></div>
33
+ ```
34
+
35
+ ---
36
+
37
+ #### Demo
38
+
39
+ {{< showhtml src="examples/ng-load/ng-load.html" >}}
40
+
41
+ {{< showraw src="examples/ng-load/ng-load.html" >}}
42
+
43
+ ---
@@ -0,0 +1,9 @@
1
+ <section ng-app>
2
+ <!-- Eager bind -->
3
+ <label>Enter name: <input type="text" ng-model="name" /></label><br />
4
+ Hello <span ng-bind="name">I am never displayed</span>!
5
+
6
+ <!-- Lazy bind -->
7
+ <button ng-click="name1 = name">Sync</button>
8
+ <span ng-bind="name1" data-lazy="true">I am server content</span>!
9
+ </section>
@@ -0,0 +1,9 @@
1
+ <section ng-app>
2
+ <input
3
+ type="text"
4
+ ng-keydown="count = count + 1"
5
+ ng-init="count = 0"
6
+ placeholder="Click here, then press down a key."
7
+ />
8
+ Keydown {{ count }} times
9
+ </section>
@@ -0,0 +1,9 @@
1
+ <section ng-app>
2
+ <input
3
+ type="text"
4
+ ng-keyup="count = count + 1"
5
+ ng-init="count = 0"
6
+ placeholder="Click here, then press down a key."
7
+ />
8
+ Keyup {{ count }} times
9
+ </section>
@@ -0,0 +1,8 @@
1
+ <section ng-app>
2
+ <img
3
+ ng-load="res = 'Large image loaded'"
4
+ width="150px"
5
+ src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/93/Centroamerica_prehispanica_siglo_XVI.svg/1920px-Centroamerica_prehispanica_siglo_XVI.svg.png"
6
+ />
7
+ {{ res }}
8
+ </section>
package/legacy.d.ts CHANGED
@@ -662,10 +662,6 @@ declare namespace angular {
662
662
  $eval(expression: string, locals?: Object): any;
663
663
  $eval(expression: (scope: IScope) => any, locals?: Object): any;
664
664
 
665
- $evalAsync(): void;
666
- $evalAsync(expression: string, locals?: Object): void;
667
- $evalAsync(expression: (scope: IScope) => void, locals?: Object): void;
668
-
669
665
  // Defaults to false by the implementation checking strategy
670
666
  $new(isolate?: boolean, parent?: IScope): IScope;
671
667
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@angular-wave/angular.ts",
3
3
  "description": "A modern, optimized and type-safe version of AngularJS",
4
4
  "license": "MIT",
5
- "version": "0.7.5",
5
+ "version": "0.7.7",
6
6
  "type": "module",
7
7
  "main": "dist/angular-ts.esm.js",
8
8
  "module": "dist/angular-ts.esm.js",
@@ -775,7 +775,7 @@ export class LocationProvider {
775
775
  return;
776
776
  }
777
777
 
778
- $rootScope.$evalAsync(() => {
778
+ Promise.resolve().then(() => {
779
779
  const oldUrl = $location.absUrl();
780
780
  const oldState = $location.$$state;
781
781
  let defaultPrevented;
@@ -467,7 +467,6 @@ export class Scope {
467
467
  $destroy: this.$destroy.bind(this),
468
468
  $eval: this.$eval.bind(this),
469
469
  $apply: this.$apply.bind(this),
470
- $evalAsync: this.$evalAsync.bind(this),
471
470
  $postUpdate: this.$postUpdate.bind(this),
472
471
  $isRoot: this.#isRoot.bind(this),
473
472
  $target: target,
@@ -977,10 +976,6 @@ export class Scope {
977
976
  return res;
978
977
  }
979
978
 
980
- async $evalAsync(expr, locals) {
981
- return await this.$eval(expr, locals);
982
- }
983
-
984
979
  /**
985
980
  * @param {Object} newTarget
986
981
  */
@@ -1,4 +1,10 @@
1
- import { isUndefined, stringify, isNull, isProxy } from "../../shared/utils.js";
1
+ import {
2
+ isUndefined,
3
+ stringify,
4
+ isNull,
5
+ isProxy,
6
+ isDefined,
7
+ } from "../../shared/utils.js";
2
8
  import { $injectTokens } from "../../injection-tokens.js";
3
9
 
4
10
  /**
@@ -12,9 +18,15 @@ export function ngBindDirective() {
12
18
  * @param {import('../../core/compile/attributes.js').Attributes} attr
13
19
  */
14
20
  link(scope, element, attr) {
15
- scope.$watch(attr["ngBind"], (value) => {
16
- element.textContent = stringify(isProxy(value) ? value.$target : value);
17
- });
21
+ scope.$watch(
22
+ attr["ngBind"],
23
+ (value) => {
24
+ element.textContent = stringify(
25
+ isProxy(value) ? value.$target : value,
26
+ );
27
+ },
28
+ isDefined(attr["lazy"]),
29
+ );
18
30
  },
19
31
  };
20
32
  }
@@ -106,6 +106,19 @@ describe("ng-bind", () => {
106
106
  $rootScope.value.$target.toString(),
107
107
  );
108
108
  });
109
+
110
+ it("should support `data-lazy` attribute", async () => {
111
+ $rootScope.value = 0;
112
+ await wait();
113
+ element = $compile('<div ng-bind="value" data-lazy="true">Content</div>')(
114
+ $rootScope,
115
+ );
116
+ expect(element.textContent).toEqual("Content");
117
+
118
+ $rootScope.value = 2;
119
+ await wait();
120
+ expect(element.textContent).toEqual("2");
121
+ });
109
122
  });
110
123
 
111
124
  describe("ngBindTemplate", () => {
@@ -6,7 +6,7 @@ import { directiveNormalize } from "../../shared/utils.js";
6
6
  */
7
7
  export const ngEventDirectives = {};
8
8
 
9
- "click copy cut dblclick focus blur keydown keyup keypress load mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup paste submit touchstart touchend touchmove"
9
+ "click copy cut dblclick focus blur keydown keyup load mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup paste submit touchstart touchend touchmove"
10
10
  .split(" ")
11
11
  .forEach((eventName) => {
12
12
  const directiveName = directiveNormalize(`ng-${eventName}`);
@@ -1,44 +1,3 @@
1
- ## ngClick
2
-
3
- **Directive:** `ngClick`
4
- **Restrict:** `A`
5
- **Element:** `ANY`
6
- **Priority:** `0`
7
-
8
- **Description:**
9
- The ngClick directive allows you to specify custom behavior when an element is clicked.
10
-
11
- **Param:**
12
-
13
- - `{String} ngClick` [Expression](guide/expression) to evaluate upon click. ([Event object](guide/expression#-event-) is available as `$event`).
14
-
15
- ## ngDblclick
16
-
17
- **Directive:** `ngDblclick`
18
- **Restrict:** `A`
19
- **Element:** `ANY`
20
- **Priority:** `0`
21
-
22
- **Description:**
23
- The `ngDblclick` directive allows you to specify custom behavior on a dblclick event.
24
-
25
- **Param:**
26
-
27
- - `{string} ngDblclick` [Expression](guide/expression) to evaluate upon a dblclick. (The Event object is available as `$event`).
28
-
29
- **Example:**
30
-
31
- ```html
32
- <example name="ng-dblclick">
33
- <file name="index.html">
34
- <button ng-dblclick="count = count + 1" ng-init="count=0">
35
- Increment (on double click)
36
- </button>
37
- count: {{count}}
38
- </file>
39
- </example>
40
- ```
41
-
42
1
  ## ngSubmit
43
2
 
44
3
  **Directive:** `ngSubmit`
@@ -103,7 +103,7 @@ class NgMessageCtrl {
103
103
  reRender() {
104
104
  if (!this.renderLater) {
105
105
  this.renderLater = true;
106
- this.$scope.$evalAsync(() => {
106
+ Promise.resolve().then(() => {
107
107
  if (this.renderLater && this.cachedCollection) {
108
108
  this.render(this.cachedCollection);
109
109
  }