@angular-wave/angular.ts 0.0.69 → 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.
package/src/public.js CHANGED
@@ -97,8 +97,21 @@ import {
97
97
  ngMessagesDirective,
98
98
  ngMessagesIncludeDirective,
99
99
  } from "./directive/messages/messages";
100
- import { initAriaModule } from "./exts/aria/aria";
101
100
  import { initRouter } from "./router/index";
101
+ import {
102
+ AriaProvider,
103
+ ngCheckedAriaDirective,
104
+ ngClickAriaDirective,
105
+ ngDblclickAriaDirective,
106
+ ngDisabledAriaDirective,
107
+ ngHideAriaDirective,
108
+ ngMessagesAriaDirective,
109
+ ngModelAriaDirective,
110
+ ngReadonlyAriaDirective,
111
+ ngRequiredAriaDirective,
112
+ ngShowAriaDirective,
113
+ ngValueAriaDirective,
114
+ } from "./directive/aria/aria";
102
115
 
103
116
  /**
104
117
  * @type {string} `version` from `package.json`, injected by Rollup plugin
@@ -140,6 +153,7 @@ export function publishExternalAPI(angular) {
140
153
  ngClassOdd: ngClassOddDirective,
141
154
  ngCloak: ngCloakDirective,
142
155
  ngController: ngControllerDirective,
156
+ ngDisabled: ngDisabledAriaDirective,
143
157
  ngForm: ngFormDirective,
144
158
  ngHide: ngHideDirective,
145
159
  ngIf: ngIfDirective,
@@ -175,12 +189,23 @@ export function publishExternalAPI(angular) {
175
189
  ngModelOptions: ngModelOptionsDirective,
176
190
  })
177
191
  .directive({
178
- ngInclude: ngIncludeFillContentDirective,
179
192
  input: hiddenInputBrowserCacheDirective,
193
+ ngChecked: ngCheckedAriaDirective,
194
+ ngClick: ngClickAriaDirective,
195
+ ngDblclick: ngDblclickAriaDirective,
196
+ ngInclude: ngIncludeFillContentDirective,
197
+ ngHide: ngHideAriaDirective,
198
+ ngShow: ngShowAriaDirective,
199
+ ngMessages: ngMessagesAriaDirective,
200
+ ngModel: ngModelAriaDirective,
201
+ ngReadonly: ngReadonlyAriaDirective,
202
+ ngRequired: ngRequiredAriaDirective,
203
+ ngValue: ngValueAriaDirective,
180
204
  })
181
205
  .directive(ngAttributeAliasDirectives)
182
206
  .directive(ngEventDirectives);
183
207
  $provide.provider({
208
+ $aria: AriaProvider,
184
209
  $anchorScroll: AnchorScrollProvider,
185
210
  $animate: AnimateProvider,
186
211
  $animateCss: CoreAnimateCssProvider,
@@ -218,7 +243,6 @@ export function publishExternalAPI(angular) {
218
243
  .info({ version: VERSION });
219
244
 
220
245
  initAnimateModule(angular);
221
- initAriaModule(angular);
222
246
  initRouter(angular);
223
247
  return ng;
224
248
  }
@@ -185,7 +185,6 @@ export function isFunction(value) {
185
185
  /**
186
186
  * Determines if a value is a regular expression object.
187
187
  *
188
- * @private
189
188
  * @param {*} value Reference to check.
190
189
  * @returns {boolean} True if `value` is a `RegExp`.
191
190
  */
@@ -196,7 +195,6 @@ export function isRegExp(value) {
196
195
  /**
197
196
  * Checks if `obj` is a window object.
198
197
  *
199
- * @private
200
198
  * @param {*} obj Object to check
201
199
  * @returns {boolean} True if `obj` is a window obj.
202
200
  */
@@ -404,10 +404,9 @@ export class Scope {
404
404
  */
405
405
  $digest(): void;
406
406
  /**
407
- * @private
408
407
  * @param {ScopePhase} phase
409
408
  */
410
- private beginPhase;
409
+ beginPhase(phase: ScopePhase): void;
411
410
  /**
412
411
  * @ngdoc method
413
412
  * @name $rootScope.Scope#$suspend
@@ -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
+ }
@@ -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
- }
@@ -1 +0,0 @@
1
- export function initAriaModule(angular: any): void;
File without changes