@angular-wave/angular.ts 0.0.68 → 0.0.70

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 (78) 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-swap.js +1 -1
  5. package/src/core/animate/animate.js +5 -5
  6. package/src/core/compile/compile.js +0 -1
  7. package/src/core/compile/compile.spec.js +4 -4
  8. package/src/core/controller/controller.js +5 -1
  9. package/src/core/cookie-reader.spec.js +1 -1
  10. package/src/core/di/injector.js +1 -1
  11. package/src/core/di/injector.spec.js +35 -35
  12. package/src/core/di/internal-injector.js +1 -1
  13. package/src/core/filter/filter.spec.js +15 -15
  14. package/src/core/interpolate/interpolate.spec.js +29 -29
  15. package/src/core/interval/interval.spec.js +1 -1
  16. package/src/core/location/location.spec.js +1 -1
  17. package/src/core/parser/lexer.spec.js +1 -1
  18. package/src/core/parser/parse.spec.js +1 -1
  19. package/src/core/q/q.js +1 -0
  20. package/src/core/q/q.spec.js +1 -1
  21. package/src/core/scope/scope.js +1 -2
  22. package/src/core/timeout/timeout.js +5 -21
  23. package/src/{exts → directive}/aria/aria.html +1 -1
  24. package/src/directive/aria/aria.js +382 -0
  25. package/src/{exts → directive}/aria/aria.spec.js +13 -13
  26. package/src/{exts → directive}/aria/aria.test.js +1 -1
  27. package/src/directive/attrs/boolean.spec.js +1 -1
  28. package/src/directive/bind/bind.js +2 -2
  29. package/src/directive/class/class.js +1 -1
  30. package/src/directive/form/form.js +1 -18
  31. package/src/directive/form/form.spec.js +2 -2
  32. package/src/directive/include/include.js +7 -0
  33. package/src/directive/input/input.js +1 -1
  34. package/src/{exts → directive}/messages/messages.html +4 -1
  35. package/src/directive/messages/messages.js +339 -0
  36. package/src/{exts → directive}/messages/messages.spec.js +7 -11
  37. package/src/{exts → directive}/messages/messages.test.js +1 -1
  38. package/src/directive/model-options/model-options.spec.js +1 -1
  39. package/src/directive/switch/switch.spec.js +1 -1
  40. package/src/filters/filter.js +2 -6
  41. package/src/filters/filter.spec.js +1 -1
  42. package/src/filters/filters.spec.js +1 -1
  43. package/src/filters/limit-to.js +0 -1
  44. package/src/filters/limit-to.spec.js +2 -2
  45. package/src/loader.js +1 -1
  46. package/src/loader.spec.js +1 -1
  47. package/src/public.js +39 -5
  48. package/src/router/common/glob.spec.js +1 -1
  49. package/src/router/params/param-factory.js +1 -1
  50. package/src/router/state/state-builder.spec.js +1 -1
  51. package/src/router/template-factory.js +6 -4
  52. package/src/router/view/view.spec.js +8 -11
  53. package/src/router/view-scroll.js +6 -1
  54. package/src/services/anchor-scroll.html +83 -0
  55. package/src/services/anchor-scroll.js +23 -6
  56. package/src/services/browser.js +1 -1
  57. package/src/services/http/http.spec.js +40 -40
  58. package/src/shared/jqlite/jqlite.js +3 -3
  59. package/src/shared/jqlite/jqlite.spec.js +4 -4
  60. package/src/shared/utils.js +1 -3
  61. package/types/core/q/q.d.ts +5 -0
  62. package/types/core/scope/scope.d.ts +2 -3
  63. package/types/core/timeout/timeout.d.ts +3 -7
  64. package/types/directive/aria/aria.d.ts +94 -0
  65. package/types/directive/form/form.d.ts +3 -20
  66. package/types/directive/include/include.d.ts +1 -1
  67. package/types/router/params/param-factory.d.ts +1 -1
  68. package/types/router/template-factory.d.ts +4 -4
  69. package/types/router/view-scroll.d.ts +1 -1
  70. package/types/services/anchor-scroll.d.ts +16 -1
  71. package/types/services/browser.d.ts +2 -2
  72. package/types/shared/utils.d.ts +0 -2
  73. package/src/exts/aria/aria.js +0 -415
  74. package/src/exts/messages/messages.js +0 -361
  75. package/types/exts/aria/aria.d.ts +0 -1
  76. package/types/exts/messages/messages.d.ts +0 -1
  77. /package/src/{exts → directive}/aria/aria.md +0 -0
  78. /package/src/{exts → directive}/messages/messages.md +0 -0
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @ngdoc provider
3
+ * @name $ariaProvider
4
+ *
5
+ *
6
+ * @description
7
+ *
8
+ * Used for configuring the ARIA attributes injected and managed by ngAria.
9
+ *
10
+ * ```js
11
+ * angular.module('myApp', ['ngAria'], function config($ariaProvider) {
12
+ * $ariaProvider.config({
13
+ * ariaValue: true,
14
+ * tabindex: false
15
+ * });
16
+ * });
17
+ *```
18
+ *
19
+ * ## Dependencies
20
+ * Requires the {@link ngAria} module to be installed.
21
+ *
22
+ */
23
+ export function AriaProvider(): void;
24
+ export class AriaProvider {
25
+ config: (newConfig: any) => void;
26
+ $get: () => {
27
+ config(key: any): any;
28
+ $$watchExpr: (attrName: any, ariaAttr: any, nativeAriaNodeNames: any, negate: any) => (scope: any, elem: any, attr: any) => void;
29
+ };
30
+ }
31
+ export function ngDisabledAriaDirective($aria: any): any;
32
+ export namespace ngDisabledAriaDirective {
33
+ let $inject: string[];
34
+ }
35
+ export function ngShowAriaDirective($aria: any): any;
36
+ export namespace ngShowAriaDirective {
37
+ let $inject_1: string[];
38
+ export { $inject_1 as $inject };
39
+ }
40
+ export function ngMessagesAriaDirective(): {
41
+ restrict: string;
42
+ require: string;
43
+ link(_scope: any, elem: any, attr: any): void;
44
+ };
45
+ export function ngClickAriaDirective($aria: any, $parse: any): {
46
+ restrict: string;
47
+ compile(elem: any, attr: any): (scope: any, elem: any, attr: any) => void;
48
+ };
49
+ export namespace ngClickAriaDirective {
50
+ let $inject_2: string[];
51
+ export { $inject_2 as $inject };
52
+ }
53
+ export function ngRequiredAriaDirective($aria: any): any;
54
+ export namespace ngRequiredAriaDirective {
55
+ let $inject_3: string[];
56
+ export { $inject_3 as $inject };
57
+ }
58
+ export function ngCheckedAriaDirective($aria: any): any;
59
+ export namespace ngCheckedAriaDirective {
60
+ let $inject_4: string[];
61
+ export { $inject_4 as $inject };
62
+ }
63
+ export function ngValueAriaDirective($aria: any): any;
64
+ export namespace ngValueAriaDirective {
65
+ let $inject_5: string[];
66
+ export { $inject_5 as $inject };
67
+ }
68
+ export function ngHideAriaDirective($aria: any): any;
69
+ export namespace ngHideAriaDirective {
70
+ let $inject_6: string[];
71
+ export { $inject_6 as $inject };
72
+ }
73
+ export function ngReadonlyAriaDirective($aria: any): any;
74
+ export namespace ngReadonlyAriaDirective {
75
+ let $inject_7: string[];
76
+ export { $inject_7 as $inject };
77
+ }
78
+ export function ngModelAriaDirective($aria: any): {
79
+ restrict: string;
80
+ require: string;
81
+ priority: number;
82
+ compile(elem: any, attr: any): {
83
+ post(scope: any, elem: any, attr: any, ngModel: any): void;
84
+ };
85
+ };
86
+ export namespace ngModelAriaDirective {
87
+ let $inject_8: string[];
88
+ export { $inject_8 as $inject };
89
+ }
90
+ export function ngDblclickAriaDirective($aria: any): (scope: any, elem: any, attr: any) => void;
91
+ export namespace ngDblclickAriaDirective {
92
+ let $inject_9: string[];
93
+ export { $inject_9 as $inject };
94
+ }
@@ -49,12 +49,6 @@ export class FormController {
49
49
  */
50
50
  $commitViewValue(): void;
51
51
  /**
52
- * @ngdoc method
53
- * @name form.FormController#$addControl
54
- * @param {object} control control object, either a {@link form.FormController} or an
55
- * {@link ngModel.NgModelController}
56
- *
57
- * @description
58
52
  * Register a control with the form. Input elements using ngModelController do this automatically
59
53
  * when they are linked.
60
54
  *
@@ -69,13 +63,8 @@ export class FormController {
69
63
  * For example, if an input control is added that is already `$dirty` and has `$error` properties,
70
64
  * calling `$setDirty()` and `$validate()` afterwards will propagate the state to the parent form.
71
65
  */
72
- $addControl(control: object): void;
66
+ $addControl(control: any): void;
73
67
  /**
74
- * @ngdoc method
75
- * @name form.FormController#$getControls
76
- * @returns {Array} the controls that are currently part of this form
77
- *
78
- * @description
79
68
  * This method returns a **shallow copy** of the controls that are currently part of this form.
80
69
  * The controls can be instances of {@link form.FormController `FormController`}
81
70
  * ({@link ngForm "child-forms"}) and of {@link ngModel.NgModelController `NgModelController`}.
@@ -90,15 +79,9 @@ export class FormController {
90
79
  * in the shallow copy. That means you should get a fresh copy from `$getControls()` every time
91
80
  * you need access to the controls.
92
81
  */
93
- $getControls(): any[];
82
+ $getControls(): any;
94
83
  $$renameControl(control: any, newName: any): void;
95
84
  /**
96
- * @ngdoc method
97
- * @name form.FormController#$removeControl
98
- * @param {object} control control object, either a {@link form.FormController} or an
99
- * {@link ngModel.NgModelController}
100
- *
101
- * @description
102
85
  * Deregister a control from the form.
103
86
  *
104
87
  * Input elements using ngModelController do this automatically when they are destroyed.
@@ -108,7 +91,7 @@ export class FormController {
108
91
  * different from case to case. For example, removing the only `$dirty` control from a form may or
109
92
  * may not mean that the form is still `$dirty`.
110
93
  */
111
- $removeControl(control: object): void;
94
+ $removeControl(control: any): void;
112
95
  /**
113
96
  * @ngdoc method
114
97
  * @name form.FormController#$setDirty
@@ -1,4 +1,4 @@
1
- export const ngIncludeDirective: (string | (($templateRequest: any, $anchorScroll: any, $animate: any) => {
1
+ export const ngIncludeDirective: (string | (($templateRequest: any, $anchorScroll: import("../../services/anchor-scroll").AnchorScrollFunction, $animate: any) => {
2
2
  restrict: string;
3
3
  priority: number;
4
4
  terminal: boolean;
@@ -5,4 +5,4 @@ export class ParamFactory {
5
5
  fromPath(id: any, type: any, state: any): Param;
6
6
  fromSearch(id: any, type: any, state: any): Param;
7
7
  }
8
- import { Param } from "../params/param";
8
+ import { Param } from "./param";
@@ -59,20 +59,20 @@ export class TemplateFactory {
59
59
  * Creates a template by invoking an injectable provider function.
60
60
  *
61
61
  * @param {import('../types').Injectable<any>} provider Function to invoke via `locals`
62
- * @param {Function} injectFn a function used to invoke the template provider
62
+ * @param {Function} params a function used to invoke the template provider
63
63
  * @param {import("./resolve/resolve-context").ResolveContext} context
64
64
  * @return {string|Promise.<string>} The template html as a string, or a promise
65
65
  * for that string.
66
66
  */
67
- fromProvider(provider: import("../types").Injectable<any>, params: any, context: import("./resolve/resolve-context").ResolveContext): string | Promise<string>;
67
+ fromProvider(provider: import("../types").Injectable<any>, params: Function, context: import("./resolve/resolve-context").ResolveContext): string | Promise<string>;
68
68
  /**
69
69
  * Creates a component's template by invoking an injectable provider function.
70
70
  *
71
71
  * @param {import('../types').Injectable<any>} provider Function to invoke via `locals`
72
- * @param {Function} injectFn a function used to invoke the template provider
72
+ * @param {Function} params a function used to invoke the template provider
73
73
  * @return {string} The template html as a string: "<component-name input1='::$resolve.foo'></component-name>".
74
74
  */
75
- fromComponentProvider(provider: import("../types").Injectable<any>, params: any, context: any): string;
75
+ fromComponentProvider(provider: import("../types").Injectable<any>, params: Function, context: any): string;
76
76
  /**
77
77
  * Creates a template from a component's name
78
78
  *
@@ -1,5 +1,5 @@
1
1
  export function $ViewScrollProvider(): void;
2
2
  export class $ViewScrollProvider {
3
3
  useAnchorScroll: () => void;
4
- $get: (string | (($anchorScroll: any, $timeout: any) => any))[];
4
+ $get: (string | (($anchorScroll: import("../services/anchor-scroll").AnchorScrollObject, $timeout: any) => import("../services/anchor-scroll").AnchorScrollObject | Function))[];
5
5
  }
@@ -1,5 +1,20 @@
1
+ /**
2
+ * @typedef {Object} AnchorScrollObject
3
+ * @property {number|function|import("../shared/jqlite/jqlite").JQLite} yOffset
4
+ */
5
+ /**
6
+ * @typedef {(string) => void} AnchorScrollFunction
7
+ */
8
+ /**
9
+ * @typedef {AnchorScrollFunction | AnchorScrollObject} AnchorScrollService
10
+ */
1
11
  export function AnchorScrollProvider(): void;
2
12
  export class AnchorScrollProvider {
3
13
  disableAutoScrolling: () => void;
4
- $get: (string | (($location: import("../core/location/location").Location, $rootScope: import("../core/scope/scope").Scope) => (hash: any) => void))[];
14
+ $get: (string | (($location: import("../core/location/location").Location, $rootScope: import("../core/scope/scope").Scope) => AnchorScrollFunction))[];
5
15
  }
16
+ export type AnchorScrollObject = {
17
+ yOffset: number | Function | import("../shared/jqlite/jqlite").JQLite;
18
+ };
19
+ export type AnchorScrollFunction = (string: any) => void;
20
+ export type AnchorScrollService = AnchorScrollFunction | AnchorScrollObject;
@@ -125,7 +125,7 @@ export class Browser {
125
125
  * @param {function():any} fn A function, who's execution should be deferred.
126
126
  * @param {number=} [delay=0] Number of milliseconds to defer the function execution.
127
127
  * @param {string=} [taskType=DEFAULT_TASK_TYPE] The type of task that is deferred.
128
- * @returns {*} DeferId that can be used to cancel the task via `$browser.cancel()`.
128
+ * @returns {number} DeferId that can be used to cancel the task via `$browser.cancel()`.
129
129
  *
130
130
  * @description
131
131
  * Executes a fn asynchronously via `setTimeout(fn, delay)`.
@@ -135,7 +135,7 @@ export class Browser {
135
135
  * via `$browser.defer.flush()`.
136
136
  *
137
137
  */
138
- defer: (fn: () => any, delay?: number | undefined, taskType?: string | undefined) => any;
138
+ defer: (fn: () => any, delay?: number | undefined, taskType?: string | undefined) => number;
139
139
  /**
140
140
  * @name $browser#cancel
141
141
  *
@@ -106,7 +106,6 @@ export function isFunction(value: any): boolean;
106
106
  /**
107
107
  * Determines if a value is a regular expression object.
108
108
  *
109
- * @private
110
109
  * @param {*} value Reference to check.
111
110
  * @returns {boolean} True if `value` is a `RegExp`.
112
111
  */
@@ -114,7 +113,6 @@ export function isRegExp(value: any): boolean;
114
113
  /**
115
114
  * Checks if `obj` is a window object.
116
115
  *
117
- * @private
118
116
  * @param {*} obj Object to check
119
117
  * @returns {boolean} True if `obj` is a window obj.
120
118
  */
@@ -1,415 +0,0 @@
1
- import { extend } from "../../shared/utils";
2
-
3
- const ARIA_DISABLE_ATTR = "ngAriaDisable";
4
-
5
- export function initAriaModule(angular) {
6
- angular
7
- .module("ngAria", ["ng"])
8
- .provider("$aria", $AriaProvider)
9
- .directive("ngShow", [
10
- "$aria",
11
- function ($aria) {
12
- return $aria.$$watchExpr("ngShow", "aria-hidden", [], true);
13
- },
14
- ])
15
- .directive("ngHide", [
16
- "$aria",
17
- function ($aria) {
18
- return $aria.$$watchExpr("ngHide", "aria-hidden", [], false);
19
- },
20
- ])
21
- .directive("ngValue", [
22
- "$aria",
23
- function ($aria) {
24
- return $aria.$$watchExpr(
25
- "ngValue",
26
- "aria-checked",
27
- nativeAriaNodeNames,
28
- false,
29
- );
30
- },
31
- ])
32
- .directive("ngChecked", [
33
- "$aria",
34
- function ($aria) {
35
- return $aria.$$watchExpr(
36
- "ngChecked",
37
- "aria-checked",
38
- nativeAriaNodeNames,
39
- false,
40
- );
41
- },
42
- ])
43
- .directive("ngReadonly", [
44
- "$aria",
45
- function ($aria) {
46
- return $aria.$$watchExpr(
47
- "ngReadonly",
48
- "aria-readonly",
49
- nativeAriaNodeNames,
50
- false,
51
- );
52
- },
53
- ])
54
- .directive("ngRequired", [
55
- "$aria",
56
- function ($aria) {
57
- return $aria.$$watchExpr(
58
- "ngRequired",
59
- "aria-required",
60
- nativeAriaNodeNames,
61
- false,
62
- );
63
- },
64
- ])
65
- .directive("ngModel", [
66
- "$aria",
67
- function ($aria) {
68
- function shouldAttachAttr(
69
- attr,
70
- normalizedAttr,
71
- elem,
72
- allowNonAriaNodes,
73
- ) {
74
- return (
75
- $aria.config(normalizedAttr) &&
76
- !elem.attr(attr) &&
77
- (allowNonAriaNodes || !isNodeOneOf(elem, nativeAriaNodeNames)) &&
78
- (elem.attr("type") !== "hidden" || elem[0].nodeName !== "INPUT")
79
- );
80
- }
81
-
82
- function shouldAttachRole(role, elem) {
83
- // if element does not have role attribute
84
- // AND element type is equal to role (if custom element has a type equaling shape) <-- remove?
85
- // AND element is not in nativeAriaNodeNames
86
- return (
87
- !elem.attr("role") &&
88
- elem.attr("type") === role &&
89
- !isNodeOneOf(elem, nativeAriaNodeNames)
90
- );
91
- }
92
-
93
- function getShape(attr) {
94
- const { type } = attr;
95
- const { role } = attr;
96
-
97
- return (type || role) === "checkbox" || role === "menuitemcheckbox"
98
- ? "checkbox"
99
- : (type || role) === "radio" || role === "menuitemradio"
100
- ? "radio"
101
- : type === "range" || role === "progressbar" || role === "slider"
102
- ? "range"
103
- : "";
104
- }
105
-
106
- return {
107
- restrict: "A",
108
- require: "ngModel",
109
- priority: 200, // Make sure watches are fired after any other directives that affect the ngModel value
110
- compile(elem, attr) {
111
- if (Object.prototype.hasOwnProperty.call(attr, ARIA_DISABLE_ATTR))
112
- return;
113
-
114
- const shape = getShape(attr);
115
-
116
- return {
117
- post(scope, elem, attr, ngModel) {
118
- const needsTabIndex = shouldAttachAttr(
119
- "tabindex",
120
- "tabindex",
121
- elem,
122
- false,
123
- );
124
-
125
- function ngAriaWatchModelValue() {
126
- return ngModel.$modelValue;
127
- }
128
-
129
- function getRadioReaction() {
130
- // Strict comparison would cause a BC
131
- elem[0].setAttribute(
132
- "aria-checked",
133
- (attr.value == ngModel.$viewValue).toString(),
134
- );
135
- }
136
-
137
- function getCheckboxReaction() {
138
- elem.attr(
139
- "aria-checked",
140
- (!ngModel.$isEmpty(ngModel.$viewValue)).toString(),
141
- );
142
- }
143
-
144
- switch (shape) {
145
- case "radio":
146
- case "checkbox":
147
- if (shouldAttachRole(shape, elem)) {
148
- elem.attr("role", shape);
149
- }
150
- if (
151
- shouldAttachAttr(
152
- "aria-checked",
153
- "ariaChecked",
154
- elem,
155
- false,
156
- )
157
- ) {
158
- scope.$watch(
159
- ngAriaWatchModelValue,
160
- shape === "radio"
161
- ? getRadioReaction
162
- : getCheckboxReaction,
163
- );
164
- }
165
- if (needsTabIndex) {
166
- elem.attr("tabindex", 0);
167
- }
168
- break;
169
- case "range":
170
- if (shouldAttachRole(shape, elem)) {
171
- elem.attr("role", "slider");
172
- }
173
- if ($aria.config("ariaValue")) {
174
- const needsAriaValuemin =
175
- !elem.attr("aria-valuemin") &&
176
- (Object.prototype.hasOwnProperty.call(attr, "min") ||
177
- Object.prototype.hasOwnProperty.call(attr, "ngMin"));
178
- const needsAriaValuemax =
179
- !elem.attr("aria-valuemax") &&
180
- (Object.prototype.hasOwnProperty.call(attr, "max") ||
181
- Object.prototype.hasOwnProperty.call(attr, "ngMax"));
182
- const needsAriaValuenow = !elem.attr("aria-valuenow");
183
-
184
- if (needsAriaValuemin) {
185
- attr.$observe("min", (newVal) => {
186
- elem.attr("aria-valuemin", newVal);
187
- });
188
- }
189
- if (needsAriaValuemax) {
190
- attr.$observe("max", (newVal) => {
191
- elem.attr("aria-valuemax", newVal);
192
- });
193
- }
194
- if (needsAriaValuenow) {
195
- scope.$watch(ngAriaWatchModelValue, (newVal) => {
196
- elem.attr("aria-valuenow", newVal);
197
- });
198
- }
199
- }
200
- if (needsTabIndex) {
201
- elem.attr("tabindex", 0);
202
- }
203
- break;
204
- }
205
-
206
- if (
207
- !Object.prototype.hasOwnProperty.call(attr, "ngRequired") &&
208
- ngModel.$validators.required &&
209
- shouldAttachAttr("aria-required", "ariaRequired", elem, false)
210
- ) {
211
- // ngModel.$error.required is undefined on custom controls
212
- attr.$observe("required", () => {
213
- elem.attr("aria-required", (!!attr.required).toString());
214
- });
215
- }
216
-
217
- if (
218
- shouldAttachAttr("aria-invalid", "ariaInvalid", elem, true)
219
- ) {
220
- scope.$watch(
221
- () => ngModel.$invalid,
222
- (newVal) => {
223
- elem.attr("aria-invalid", (!!newVal).toString());
224
- },
225
- );
226
- }
227
- },
228
- };
229
- },
230
- };
231
- },
232
- ])
233
- .directive("ngDisabled", [
234
- "$aria",
235
- function ($aria) {
236
- return $aria.$$watchExpr(
237
- "ngDisabled",
238
- "aria-disabled",
239
- nativeAriaNodeNames,
240
- false,
241
- );
242
- },
243
- ])
244
- .directive("ngMessages", () => ({
245
- restrict: "A",
246
- require: "?ngMessages",
247
- link(_scope, elem, attr) {
248
- if (Object.prototype.hasOwnProperty.call(attr, ARIA_DISABLE_ATTR))
249
- return;
250
-
251
- if (!elem.attr("aria-live")) {
252
- elem.attr("aria-live", "assertive");
253
- }
254
- },
255
- }))
256
- .directive("ngClick", [
257
- "$aria",
258
- "$parse",
259
- function ($aria, $parse) {
260
- return {
261
- restrict: "A",
262
- compile(elem, attr) {
263
- if (Object.prototype.hasOwnProperty.call(attr, ARIA_DISABLE_ATTR))
264
- return;
265
-
266
- const fn = $parse(attr.ngClick);
267
- return function (scope, elem, attr) {
268
- if (!isNodeOneOf(elem, nativeAriaNodeNames)) {
269
- if ($aria.config("bindRoleForClick") && !elem.attr("role")) {
270
- elem.attr("role", "button");
271
- }
272
-
273
- if ($aria.config("tabindex") && !elem.attr("tabindex")) {
274
- elem.attr("tabindex", 0);
275
- }
276
-
277
- if (
278
- $aria.config("bindKeydown") &&
279
- !attr.ngKeydown &&
280
- !attr.ngKeypress &&
281
- !attr.ngKeyup
282
- ) {
283
- elem.on("keydown", (event) => {
284
- const keyCode = event.which || event.keyCode;
285
-
286
- if (keyCode === 13 || keyCode === 32) {
287
- // If the event is triggered on a non-interactive element ...
288
- if (
289
- nativeAriaNodeNames.indexOf(event.target.nodeName) ===
290
- -1 &&
291
- !event.target.isContentEditable
292
- ) {
293
- // ... prevent the default browser behavior (e.g. scrolling when pressing spacebar)
294
- // See https://github.com/angular/angular.js/issues/16664
295
- event.preventDefault();
296
- }
297
- scope.$apply(callback);
298
- }
299
-
300
- function callback() {
301
- fn(scope, { $event: event });
302
- }
303
- });
304
- }
305
- }
306
- };
307
- },
308
- };
309
- },
310
- ])
311
- .directive("ngDblclick", [
312
- "$aria",
313
- function ($aria) {
314
- return function (scope, elem, attr) {
315
- if (Object.prototype.hasOwnProperty.call(attr, ARIA_DISABLE_ATTR))
316
- return;
317
-
318
- if (
319
- $aria.config("tabindex") &&
320
- !elem.attr("tabindex") &&
321
- !isNodeOneOf(elem, nativeAriaNodeNames)
322
- ) {
323
- elem.attr("tabindex", 0);
324
- }
325
- };
326
- },
327
- ]);
328
- }
329
-
330
- /**
331
- * Internal Utilities
332
- */
333
- const nativeAriaNodeNames = [
334
- "BUTTON",
335
- "A",
336
- "INPUT",
337
- "TEXTAREA",
338
- "SELECT",
339
- "DETAILS",
340
- "SUMMARY",
341
- ];
342
-
343
- const isNodeOneOf = function (elem, nodeTypeArray) {
344
- if (nodeTypeArray.indexOf(elem[0].nodeName) !== -1) {
345
- return true;
346
- }
347
- };
348
- /**
349
- * @ngdoc provider
350
- * @name $ariaProvider
351
- *
352
- *
353
- * @description
354
- *
355
- * Used for configuring the ARIA attributes injected and managed by ngAria.
356
- *
357
- * ```js
358
- * angular.module('myApp', ['ngAria'], function config($ariaProvider) {
359
- * $ariaProvider.config({
360
- * ariaValue: true,
361
- * tabindex: false
362
- * });
363
- * });
364
- *```
365
- *
366
- * ## Dependencies
367
- * Requires the {@link ngAria} module to be installed.
368
- *
369
- */
370
- function $AriaProvider() {
371
- let config = {
372
- ariaHidden: true,
373
- ariaChecked: true,
374
- ariaReadonly: true,
375
- ariaDisabled: true,
376
- ariaRequired: true,
377
- ariaInvalid: true,
378
- ariaValue: true,
379
- tabindex: true,
380
- bindKeydown: true,
381
- bindRoleForClick: true,
382
- };
383
-
384
- this.config = function (newConfig) {
385
- config = extend(config, newConfig);
386
- };
387
-
388
- function watchExpr(attrName, ariaAttr, nativeAriaNodeNames, negate) {
389
- return function (scope, elem, attr) {
390
- if (Object.prototype.hasOwnProperty.call(attr, ARIA_DISABLE_ATTR)) return;
391
-
392
- const ariaCamelName = attr.$normalize(ariaAttr);
393
- if (
394
- config[ariaCamelName] &&
395
- !isNodeOneOf(elem, nativeAriaNodeNames) &&
396
- !attr[ariaCamelName]
397
- ) {
398
- scope.$watch(attr[attrName], (boolVal) => {
399
- // ensure boolean value
400
- boolVal = negate ? !boolVal : !!boolVal;
401
- elem.attr(ariaAttr, boolVal);
402
- });
403
- }
404
- };
405
- }
406
-
407
- this.$get = function () {
408
- return {
409
- config(key) {
410
- return config[key];
411
- },
412
- $$watchExpr: watchExpr,
413
- };
414
- };
415
- }