@angular-wave/angular.ts 0.0.1

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 (231) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.cjs +29 -0
  3. package/.github/workflows/playwright.yml +27 -0
  4. package/CHANGELOG.md +17974 -0
  5. package/CODE_OF_CONDUCT.md +3 -0
  6. package/CONTRIBUTING.md +246 -0
  7. package/DEVELOPERS.md +488 -0
  8. package/LICENSE +22 -0
  9. package/Makefile +31 -0
  10. package/README.md +115 -0
  11. package/RELEASE.md +98 -0
  12. package/SECURITY.md +16 -0
  13. package/TRIAGING.md +135 -0
  14. package/css/angular.css +22 -0
  15. package/dist/angular-ts.cjs.js +36843 -0
  16. package/dist/angular-ts.esm.js +36841 -0
  17. package/dist/angular-ts.umd.js +36848 -0
  18. package/dist/build/angular-animate.js +4272 -0
  19. package/dist/build/angular-aria.js +426 -0
  20. package/dist/build/angular-message-format.js +1072 -0
  21. package/dist/build/angular-messages.js +829 -0
  22. package/dist/build/angular-mocks.js +3757 -0
  23. package/dist/build/angular-parse-ext.js +1275 -0
  24. package/dist/build/angular-resource.js +911 -0
  25. package/dist/build/angular-route.js +1266 -0
  26. package/dist/build/angular-sanitize.js +891 -0
  27. package/dist/build/angular-touch.js +368 -0
  28. package/dist/build/angular.js +36600 -0
  29. package/e2e/unit.spec.ts +15 -0
  30. package/images/android-chrome-192x192.png +0 -0
  31. package/images/android-chrome-512x512.png +0 -0
  32. package/images/apple-touch-icon.png +0 -0
  33. package/images/favicon-16x16.png +0 -0
  34. package/images/favicon-32x32.png +0 -0
  35. package/images/favicon.ico +0 -0
  36. package/images/site.webmanifest +1 -0
  37. package/index.html +104 -0
  38. package/package.json +47 -0
  39. package/playwright.config.ts +78 -0
  40. package/public/circle.html +1 -0
  41. package/public/my_child_directive.html +1 -0
  42. package/public/my_directive.html +1 -0
  43. package/public/my_other_directive.html +1 -0
  44. package/public/test.html +1 -0
  45. package/rollup.config.js +31 -0
  46. package/src/animations/animateCache.js +55 -0
  47. package/src/animations/animateChildrenDirective.js +105 -0
  48. package/src/animations/animateCss.js +1139 -0
  49. package/src/animations/animateCssDriver.js +291 -0
  50. package/src/animations/animateJs.js +367 -0
  51. package/src/animations/animateJsDriver.js +67 -0
  52. package/src/animations/animateQueue.js +851 -0
  53. package/src/animations/animation.js +506 -0
  54. package/src/animations/module.js +779 -0
  55. package/src/animations/ngAnimateSwap.js +119 -0
  56. package/src/animations/rafScheduler.js +50 -0
  57. package/src/animations/shared.js +378 -0
  58. package/src/constants.js +20 -0
  59. package/src/core/animate.js +845 -0
  60. package/src/core/animateCss.js +73 -0
  61. package/src/core/animateRunner.js +195 -0
  62. package/src/core/attributes.js +199 -0
  63. package/src/core/cache.js +45 -0
  64. package/src/core/compile.js +4727 -0
  65. package/src/core/controller.js +225 -0
  66. package/src/core/exceptionHandler.js +63 -0
  67. package/src/core/filter.js +146 -0
  68. package/src/core/interpolate.js +442 -0
  69. package/src/core/interval.js +188 -0
  70. package/src/core/intervalFactory.js +57 -0
  71. package/src/core/location.js +1086 -0
  72. package/src/core/parser/parse.js +2562 -0
  73. package/src/core/parser/parse.md +13 -0
  74. package/src/core/q.js +746 -0
  75. package/src/core/rootScope.js +1596 -0
  76. package/src/core/sanitizeUri.js +85 -0
  77. package/src/core/sce.js +1161 -0
  78. package/src/core/taskTrackerFactory.js +125 -0
  79. package/src/core/timeout.js +121 -0
  80. package/src/core/urlUtils.js +187 -0
  81. package/src/core/utils.js +1349 -0
  82. package/src/directive/a.js +37 -0
  83. package/src/directive/attrs.js +283 -0
  84. package/src/directive/bind.js +51 -0
  85. package/src/directive/bind.md +142 -0
  86. package/src/directive/change.js +12 -0
  87. package/src/directive/change.md +25 -0
  88. package/src/directive/cloak.js +12 -0
  89. package/src/directive/cloak.md +24 -0
  90. package/src/directive/events.js +75 -0
  91. package/src/directive/events.md +166 -0
  92. package/src/directive/form.js +725 -0
  93. package/src/directive/init.js +15 -0
  94. package/src/directive/init.md +41 -0
  95. package/src/directive/input.js +1783 -0
  96. package/src/directive/list.js +46 -0
  97. package/src/directive/list.md +22 -0
  98. package/src/directive/ngClass.js +249 -0
  99. package/src/directive/ngController.js +64 -0
  100. package/src/directive/ngCsp.js +82 -0
  101. package/src/directive/ngIf.js +134 -0
  102. package/src/directive/ngInclude.js +217 -0
  103. package/src/directive/ngModel.js +1356 -0
  104. package/src/directive/ngModelOptions.js +509 -0
  105. package/src/directive/ngOptions.js +670 -0
  106. package/src/directive/ngRef.js +90 -0
  107. package/src/directive/ngRepeat.js +650 -0
  108. package/src/directive/ngShowHide.js +255 -0
  109. package/src/directive/ngSwitch.js +178 -0
  110. package/src/directive/ngTransclude.js +98 -0
  111. package/src/directive/non-bindable.js +11 -0
  112. package/src/directive/non-bindable.md +17 -0
  113. package/src/directive/script.js +30 -0
  114. package/src/directive/select.js +624 -0
  115. package/src/directive/style.js +25 -0
  116. package/src/directive/style.md +23 -0
  117. package/src/directive/validators.js +329 -0
  118. package/src/exts/aria.js +544 -0
  119. package/src/exts/messages.js +852 -0
  120. package/src/filters/filter.js +207 -0
  121. package/src/filters/filter.md +69 -0
  122. package/src/filters/filters.js +239 -0
  123. package/src/filters/json.md +16 -0
  124. package/src/filters/limit-to.js +43 -0
  125. package/src/filters/limit-to.md +19 -0
  126. package/src/filters/order-by.js +183 -0
  127. package/src/filters/order-by.md +83 -0
  128. package/src/index.js +13 -0
  129. package/src/injector.js +1034 -0
  130. package/src/jqLite.js +1117 -0
  131. package/src/loader.js +1320 -0
  132. package/src/public.js +215 -0
  133. package/src/routeToRegExp.js +41 -0
  134. package/src/services/anchorScroll.js +135 -0
  135. package/src/services/browser.js +321 -0
  136. package/src/services/cacheFactory.js +398 -0
  137. package/src/services/cookieReader.js +72 -0
  138. package/src/services/document.js +64 -0
  139. package/src/services/http.js +1537 -0
  140. package/src/services/httpBackend.js +206 -0
  141. package/src/services/log.js +160 -0
  142. package/src/services/templateRequest.js +139 -0
  143. package/test/angular.spec.js +2153 -0
  144. package/test/aria/aria.spec.js +1245 -0
  145. package/test/binding.spec.js +504 -0
  146. package/test/build-test.html +14 -0
  147. package/test/injector.spec.js +2327 -0
  148. package/test/jasmine/jasmine-5.1.2/boot0.js +65 -0
  149. package/test/jasmine/jasmine-5.1.2/boot1.js +133 -0
  150. package/test/jasmine/jasmine-5.1.2/jasmine-html.js +963 -0
  151. package/test/jasmine/jasmine-5.1.2/jasmine.css +320 -0
  152. package/test/jasmine/jasmine-5.1.2/jasmine.js +10824 -0
  153. package/test/jasmine/jasmine-5.1.2/jasmine_favicon.png +0 -0
  154. package/test/jasmine/jasmine-browser.json +17 -0
  155. package/test/jasmine/jasmine.json +9 -0
  156. package/test/jqlite.spec.js +2133 -0
  157. package/test/loader.spec.js +219 -0
  158. package/test/messages/messages.spec.js +1146 -0
  159. package/test/min-err.spec.js +174 -0
  160. package/test/mock-test.html +13 -0
  161. package/test/module-test.html +15 -0
  162. package/test/ng/anomate.spec.js +606 -0
  163. package/test/ng/cache-factor.spec.js +334 -0
  164. package/test/ng/compile.spec.js +17956 -0
  165. package/test/ng/controller-provider.spec.js +227 -0
  166. package/test/ng/cookie-reader.spec.js +98 -0
  167. package/test/ng/directive/a.spec.js +192 -0
  168. package/test/ng/directive/bind.spec.js +334 -0
  169. package/test/ng/directive/boolean.spec.js +136 -0
  170. package/test/ng/directive/change.spec.js +71 -0
  171. package/test/ng/directive/class.spec.js +858 -0
  172. package/test/ng/directive/click.spec.js +38 -0
  173. package/test/ng/directive/cloak.spec.js +44 -0
  174. package/test/ng/directive/constoller.spec.js +194 -0
  175. package/test/ng/directive/element-style.spec.js +92 -0
  176. package/test/ng/directive/event.spec.js +282 -0
  177. package/test/ng/directive/form.spec.js +1518 -0
  178. package/test/ng/directive/href.spec.js +143 -0
  179. package/test/ng/directive/if.spec.js +402 -0
  180. package/test/ng/directive/include.spec.js +828 -0
  181. package/test/ng/directive/init.spec.js +68 -0
  182. package/test/ng/directive/input.spec.js +3810 -0
  183. package/test/ng/directive/list.spec.js +170 -0
  184. package/test/ng/directive/model-options.spec.js +1008 -0
  185. package/test/ng/directive/model.spec.js +1905 -0
  186. package/test/ng/directive/non-bindable.spec.js +55 -0
  187. package/test/ng/directive/options.spec.js +3583 -0
  188. package/test/ng/directive/ref.spec.js +575 -0
  189. package/test/ng/directive/repeat.spec.js +1675 -0
  190. package/test/ng/directive/script.spec.js +52 -0
  191. package/test/ng/directive/scrset.spec.js +67 -0
  192. package/test/ng/directive/select.spec.js +2541 -0
  193. package/test/ng/directive/show-hide.spec.js +253 -0
  194. package/test/ng/directive/src.spec.js +157 -0
  195. package/test/ng/directive/style.spec.js +178 -0
  196. package/test/ng/directive/switch.spec.js +647 -0
  197. package/test/ng/directive/validators.spec.js +717 -0
  198. package/test/ng/document.spec.js +52 -0
  199. package/test/ng/filter/filter.spec.js +714 -0
  200. package/test/ng/filter/filters.spec.js +35 -0
  201. package/test/ng/filter/limit-to.spec.js +251 -0
  202. package/test/ng/filter/order-by.spec.js +891 -0
  203. package/test/ng/filter.spec.js +149 -0
  204. package/test/ng/http-backend.spec.js +398 -0
  205. package/test/ng/http.spec.js +4071 -0
  206. package/test/ng/interpolate.spec.js +642 -0
  207. package/test/ng/interval.spec.js +343 -0
  208. package/test/ng/location.spec.js +3488 -0
  209. package/test/ng/on.spec.js +229 -0
  210. package/test/ng/parse.spec.js +4655 -0
  211. package/test/ng/prop.spec.js +805 -0
  212. package/test/ng/q.spec.js +2904 -0
  213. package/test/ng/root-element.spec.js +16 -0
  214. package/test/ng/sanitize-uri.spec.js +249 -0
  215. package/test/ng/sce.spec.js +660 -0
  216. package/test/ng/scope.spec.js +3442 -0
  217. package/test/ng/template-request.spec.js +236 -0
  218. package/test/ng/timeout.spec.js +351 -0
  219. package/test/ng/url-utils.spec.js +156 -0
  220. package/test/ng/utils.spec.js +144 -0
  221. package/test/original-test.html +21 -0
  222. package/test/public.spec.js +34 -0
  223. package/test/sanitize/bing-html.spec.js +36 -0
  224. package/test/server/express.js +158 -0
  225. package/test/test-utils.js +11 -0
  226. package/tsconfig.json +17 -0
  227. package/types/angular.d.ts +138 -0
  228. package/types/global.d.ts +9 -0
  229. package/types/index.d.ts +2357 -0
  230. package/types/jqlite.d.ts +558 -0
  231. package/vite.config.js +14 -0
@@ -0,0 +1,255 @@
1
+ const NG_HIDE_CLASS = "ng-hide";
2
+ const NG_HIDE_IN_PROGRESS_CLASS = "ng-hide-animate";
3
+ /**
4
+ * @ngdoc directive
5
+ * @name ngShow
6
+ * @multiElement
7
+ *
8
+ * @description
9
+ * The `ngShow` directive shows or hides the given HTML element based on the expression provided to
10
+ * the `ngShow` attribute.
11
+ *
12
+ * The element is shown or hidden by removing or adding the `.ng-hide` CSS class onto the element.
13
+ * The `.ng-hide` CSS class is predefined in AngularJS and sets the display style to none (using an
14
+ * `!important` flag). For CSP mode please add `angular-csp.css` to your HTML file (see
15
+ * {@link ng.directive:ngCsp ngCsp}).
16
+ *
17
+ * ```html
18
+ * <!-- when $scope.myValue is truthy (element is visible) -->
19
+ * <div ng-show="myValue"></div>
20
+ *
21
+ * <!-- when $scope.myValue is falsy (element is hidden) -->
22
+ * <div ng-show="myValue" class="ng-hide"></div>
23
+ * ```
24
+ *
25
+ * When the `ngShow` expression evaluates to a falsy value then the `.ng-hide` CSS class is added
26
+ * to the class attribute on the element causing it to become hidden. When truthy, the `.ng-hide`
27
+ * CSS class is removed from the element causing the element not to appear hidden.
28
+ *
29
+ * ## Why is `!important` used?
30
+ *
31
+ * You may be wondering why `!important` is used for the `.ng-hide` CSS class. This is because the
32
+ * `.ng-hide` selector can be easily overridden by heavier selectors. For example, something as
33
+ * simple as changing the display style on a HTML list item would make hidden elements appear
34
+ * visible. This also becomes a bigger issue when dealing with CSS frameworks.
35
+ *
36
+ * By using `!important`, the show and hide behavior will work as expected despite any clash between
37
+ * CSS selector specificity (when `!important` isn't used with any conflicting styles). If a
38
+ * developer chooses to override the styling to change how to hide an element then it is just a
39
+ * matter of using `!important` in their own CSS code.
40
+ *
41
+ * ### Overriding `.ng-hide`
42
+ *
43
+ * By default, the `.ng-hide` class will style the element with `display: none !important`. If you
44
+ * wish to change the hide behavior with `ngShow`/`ngHide`, you can simply overwrite the styles for
45
+ * the `.ng-hide` CSS class. Note that the selector that needs to be used is actually
46
+ * `.ng-hide:not(.ng-hide-animate)` to cope with extra animation classes that can be added.
47
+ *
48
+ * ```css
49
+ * .ng-hide:not(.ng-hide-animate) {
50
+ * /&#42; These are just alternative ways of hiding an element &#42;/
51
+ * display: block!important;
52
+ * position: absolute;
53
+ * top: -9999px;
54
+ * left: -9999px;
55
+ * }
56
+ * ```
57
+ *
58
+ * By default you don't need to override anything in CSS and the animations will work around the
59
+ * display style.
60
+ *
61
+ * @animations
62
+ * | Animation | Occurs |
63
+ * |-----------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
64
+ * | {@link $animate#addClass addClass} `.ng-hide` | After the `ngShow` expression evaluates to a non truthy value and just before the contents are set to hidden. |
65
+ * | {@link $animate#removeClass removeClass} `.ng-hide` | After the `ngShow` expression evaluates to a truthy value and just before contents are set to visible. |
66
+ *
67
+ * Animations in `ngShow`/`ngHide` work with the show and hide events that are triggered when the
68
+ * directive expression is true and false. This system works like the animation system present with
69
+ * `ngClass` except that you must also include the `!important` flag to override the display
70
+ * property so that the elements are not actually hidden during the animation.
71
+ *
72
+ * ```css
73
+ * /&#42; A working example can be found at the bottom of this page. &#42;/
74
+ * .my-element.ng-hide-add, .my-element.ng-hide-remove {
75
+ * transition: all 0.5s linear;
76
+ * }
77
+ *
78
+ * .my-element.ng-hide-add { ... }
79
+ * .my-element.ng-hide-add.ng-hide-add-active { ... }
80
+ * .my-element.ng-hide-remove { ... }
81
+ * .my-element.ng-hide-remove.ng-hide-remove-active { ... }
82
+ * ```
83
+ *
84
+ * Keep in mind that, as of AngularJS version 1.3, there is no need to change the display property
85
+ * to block during animation states - ngAnimate will automatically handle the style toggling for you.
86
+ *
87
+ * @element ANY
88
+ * @param {string} ngShow If the {@link guide/expression expression} is truthy/falsy then the
89
+ * element is shown/hidden respectively.
90
+ *
91
+ * @example
92
+ * A simple example, animating the element's opacity:
93
+
94
+ * <hr />
95
+ *
96
+ * @knownIssue
97
+ *
98
+ * ### Flickering when using ngShow to toggle between elements
99
+ *
100
+ * When using {@link ngShow} and / or {@link ngHide} to toggle between elements, it can
101
+ * happen that both the element to show and the element to hide are visible for a very short time.
102
+ *
103
+ * This usually happens when the {@link ngAnimate ngAnimate module} is included, but no actual animations
104
+ * are defined for {@link ngShow} / {@link ngHide}.
105
+ *
106
+ * There are several way to mitigate this problem:
107
+ *
108
+ * - {@link guide/animations#how-to-selectively-enable-disable-and-skip-animations Disable animations on the affected elements}.
109
+ * - Use {@link ngIf} or {@link ngSwitch} instead of {@link ngShow} / {@link ngHide}.
110
+ * - Use the special CSS selector `ng-hide.ng-hide-animate` to set `{display: none}` or similar on the affected elements.
111
+ * - Use `ng-class="{'ng-hide': expression}` instead of instead of {@link ngShow} / {@link ngHide}.
112
+ * - Define an animation on the affected elements.
113
+ */
114
+ export const ngShowDirective = [
115
+ "$animate",
116
+ ($animate) => ({
117
+ restrict: "A",
118
+ multiElement: true,
119
+ link(scope, element, attr) {
120
+ scope.$watch(attr.ngShow, (value) => {
121
+ // we're adding a temporary, animation-specific class for ng-hide since this way
122
+ // we can control when the element is actually displayed on screen without having
123
+ // to have a global/greedy CSS selector that breaks when other animations are run.
124
+ // Read: https://github.com/angular/angular.js/issues/9103#issuecomment-58335845
125
+ $animate[value ? "removeClass" : "addClass"](element, NG_HIDE_CLASS, {
126
+ tempClasses: NG_HIDE_IN_PROGRESS_CLASS,
127
+ });
128
+ });
129
+ },
130
+ }),
131
+ ];
132
+
133
+ /**
134
+ * @ngdoc directive
135
+ * @name ngHide
136
+ * @multiElement
137
+ *
138
+ * @description
139
+ * The `ngHide` directive shows or hides the given HTML element based on the expression provided to
140
+ * the `ngHide` attribute.
141
+ *
142
+ * The element is shown or hidden by removing or adding the `.ng-hide` CSS class onto the element.
143
+ * The `.ng-hide` CSS class is predefined in AngularJS and sets the display style to none (using an
144
+ * `!important` flag). For CSP mode please add `angular-csp.css` to your HTML file (see
145
+ * {@link ng.directive:ngCsp ngCsp}).
146
+ *
147
+ * ```html
148
+ * <!-- when $scope.myValue is truthy (element is hidden) -->
149
+ * <div ng-hide="myValue" class="ng-hide"></div>
150
+ *
151
+ * <!-- when $scope.myValue is falsy (element is visible) -->
152
+ * <div ng-hide="myValue"></div>
153
+ * ```
154
+ *
155
+ * When the `ngHide` expression evaluates to a truthy value then the `.ng-hide` CSS class is added
156
+ * to the class attribute on the element causing it to become hidden. When falsy, the `.ng-hide`
157
+ * CSS class is removed from the element causing the element not to appear hidden.
158
+ *
159
+ * ## Why is `!important` used?
160
+ *
161
+ * You may be wondering why `!important` is used for the `.ng-hide` CSS class. This is because the
162
+ * `.ng-hide` selector can be easily overridden by heavier selectors. For example, something as
163
+ * simple as changing the display style on a HTML list item would make hidden elements appear
164
+ * visible. This also becomes a bigger issue when dealing with CSS frameworks.
165
+ *
166
+ * By using `!important`, the show and hide behavior will work as expected despite any clash between
167
+ * CSS selector specificity (when `!important` isn't used with any conflicting styles). If a
168
+ * developer chooses to override the styling to change how to hide an element then it is just a
169
+ * matter of using `!important` in their own CSS code.
170
+ *
171
+ * ### Overriding `.ng-hide`
172
+ *
173
+ * By default, the `.ng-hide` class will style the element with `display: none !important`. If you
174
+ * wish to change the hide behavior with `ngShow`/`ngHide`, you can simply overwrite the styles for
175
+ * the `.ng-hide` CSS class. Note that the selector that needs to be used is actually
176
+ * `.ng-hide:not(.ng-hide-animate)` to cope with extra animation classes that can be added.
177
+ *
178
+ * ```css
179
+ * .ng-hide:not(.ng-hide-animate) {
180
+ * /&#42; These are just alternative ways of hiding an element &#42;/
181
+ * display: block!important;
182
+ * position: absolute;
183
+ * top: -9999px;
184
+ * left: -9999px;
185
+ * }
186
+ * ```
187
+ *
188
+ * By default you don't need to override in CSS anything and the animations will work around the
189
+ * display style.
190
+ *
191
+ * @animations
192
+ * | Animation | Occurs |
193
+ * |-----------------------------------------------------|------------------------------------------------------------------------------------------------------------|
194
+ * | {@link $animate#addClass addClass} `.ng-hide` | After the `ngHide` expression evaluates to a truthy value and just before the contents are set to hidden. |
195
+ * | {@link $animate#removeClass removeClass} `.ng-hide` | After the `ngHide` expression evaluates to a non truthy value and just before contents are set to visible. |
196
+ *
197
+ * Animations in `ngShow`/`ngHide` work with the show and hide events that are triggered when the
198
+ * directive expression is true and false. This system works like the animation system present with
199
+ * `ngClass` except that you must also include the `!important` flag to override the display
200
+ * property so that the elements are not actually hidden during the animation.
201
+ *
202
+ * ```css
203
+ * /&#42; A working example can be found at the bottom of this page. &#42;/
204
+ * .my-element.ng-hide-add, .my-element.ng-hide-remove {
205
+ * transition: all 0.5s linear;
206
+ * }
207
+ *
208
+ * .my-element.ng-hide-add { ... }
209
+ * .my-element.ng-hide-add.ng-hide-add-active { ... }
210
+ * .my-element.ng-hide-remove { ... }
211
+ * .my-element.ng-hide-remove.ng-hide-remove-active { ... }
212
+ * ```
213
+ *
214
+ * Keep in mind that, as of AngularJS version 1.3, there is no need to change the display property
215
+ * to block during animation states - ngAnimate will automatically handle the style toggling for you.
216
+ *
217
+ * @element ANY
218
+ * @param {string} ngHide If the {@link guide/expression expression} is truthy/falsy then the
219
+ * element is hidden/shown respectively.
220
+ *
221
+ * @knownIssue
222
+ *
223
+ * ### Flickering when using ngHide to toggle between elements
224
+ *
225
+ * When using {@link ngShow} and / or {@link ngHide} to toggle between elements, it can
226
+ * happen that both the element to show and the element to hide are visible for a very short time.
227
+ *
228
+ * This usually happens when the {@link ngAnimate ngAnimate module} is included, but no actual animations
229
+ * are defined for {@link ngShow} / {@link ngHide}. Internet Explorer is affected more often than
230
+ * other browsers.
231
+ *
232
+ * There are several way to mitigate this problem:
233
+ *
234
+ * - {@link guide/animations#how-to-selectively-enable-disable-and-skip-animations Disable animations on the affected elements}.
235
+ * - Use {@link ngIf} or {@link ngSwitch} instead of {@link ngShow} / {@link ngHide}.
236
+ * - Use the special CSS selector `ng-hide.ng-hide-animate` to set `{display: none}` or similar on the affected elements.
237
+ * - Use `ng-class="{'ng-hide': expression}` instead of instead of {@link ngShow} / {@link ngHide}.
238
+ * - Define an animation on the affected elements.
239
+ */
240
+ export const ngHideDirective = [
241
+ "$animate",
242
+ ($animate) => ({
243
+ restrict: "A",
244
+ multiElement: true,
245
+ link(scope, element, attr) {
246
+ scope.$watch(attr.ngHide, (value) => {
247
+ // The comment inside of the ngShowDirective explains why we add and
248
+ // remove a temporary class for the show/hide animation
249
+ $animate[value ? "addClass" : "removeClass"](element, NG_HIDE_CLASS, {
250
+ tempClasses: NG_HIDE_IN_PROGRESS_CLASS,
251
+ });
252
+ });
253
+ },
254
+ }),
255
+ ];
@@ -0,0 +1,178 @@
1
+ import { forEach } from "../core/utils";
2
+ import { getBlockNodes } from "../jqLite";
3
+
4
+ /**
5
+ * @ngdoc directive
6
+ * @name ngSwitch
7
+ * @restrict EA
8
+ *
9
+ * @description
10
+ * The `ngSwitch` directive is used to conditionally swap DOM structure on your template based on a scope expression.
11
+ * Elements within `ngSwitch` but without `ngSwitchWhen` or `ngSwitchDefault` directives will be preserved at the location
12
+ * as specified in the template.
13
+ *
14
+ * The directive itself works similar to ngInclude, however, instead of downloading template code (or loading it
15
+ * from the template cache), `ngSwitch` simply chooses one of the nested elements and makes it visible based on which element
16
+ * matches the value obtained from the evaluated expression. In other words, you define a container element
17
+ * (where you place the directive), place an expression on the **`on="..."` attribute**
18
+ * (or the **`ng-switch="..."` attribute**), define any inner elements inside of the directive and place
19
+ * a when attribute per element. The when attribute is used to inform ngSwitch which element to display when the on
20
+ * expression is evaluated. If a matching expression is not found via a when attribute then an element with the default
21
+ * attribute is displayed.
22
+ *
23
+ * <div class="alert alert-info">
24
+ * Be aware that the attribute values to match against cannot be expressions. They are interpreted
25
+ * as literal string values to match against.
26
+ * For example, **`ng-switch-when="someVal"`** will match against the string `"someVal"` not against the
27
+ * value of the expression `$scope.someVal`.
28
+ * </div>
29
+
30
+ * @animations
31
+ * | Animation | Occurs |
32
+ * |----------------------------------|-------------------------------------|
33
+ * | {@link ng.$animate#enter enter} | after the ngSwitch contents change and the matched child element is placed inside the container |
34
+ * | {@link ng.$animate#leave leave} | after the ngSwitch contents change and just before the former contents are removed from the DOM |
35
+ *
36
+ * @usage
37
+ *
38
+ * ```
39
+ * <ANY ng-switch="expression">
40
+ * <ANY ng-switch-when="matchValue1">...</ANY>
41
+ * <ANY ng-switch-when="matchValue2">...</ANY>
42
+ * <ANY ng-switch-default>...</ANY>
43
+ * </ANY>
44
+ * ```
45
+ *
46
+ *
47
+ * @scope
48
+ * @priority 1200
49
+ * @param {*} ngSwitch|on expression to match against <code>ng-switch-when</code>.
50
+ * On child elements add:
51
+ *
52
+ * * `ngSwitchWhen`: the case statement to match against. If match then this
53
+ * case will be displayed. If the same match appears multiple times, all the
54
+ * elements will be displayed. It is possible to associate multiple values to
55
+ * the same `ngSwitchWhen` by defining the optional attribute
56
+ * `ngSwitchWhenSeparator`. The separator will be used to split the value of
57
+ * the `ngSwitchWhen` attribute into multiple tokens, and the element will show
58
+ * if any of the `ngSwitch` evaluates to any of these tokens.
59
+ * * `ngSwitchDefault`: the default case when no other case match. If there
60
+ * are multiple default cases, all of them will be displayed when no other
61
+ * case match.
62
+ *
63
+ */
64
+ export const ngSwitchDirective = [
65
+ "$animate",
66
+ "$compile",
67
+ ($animate, $compile) => ({
68
+ require: "ngSwitch",
69
+
70
+ // asks for $scope to fool the BC controller module
71
+ controller: [
72
+ "$scope",
73
+ function NgSwitchController() {
74
+ this.cases = {};
75
+ },
76
+ ],
77
+ link(scope, element, attr, ngSwitchController) {
78
+ const watchExpr = attr.ngSwitch || attr.on;
79
+ let selectedTranscludes = [];
80
+ const selectedElements = [];
81
+ const previousLeaveAnimations = [];
82
+ const selectedScopes = [];
83
+
84
+ const spliceFactory = function (array, index) {
85
+ return function (response) {
86
+ if (response !== false) array.splice(index, 1);
87
+ };
88
+ };
89
+
90
+ scope.$watch(watchExpr, (value) => {
91
+ let i;
92
+ let ii;
93
+
94
+ // Start with the last, in case the array is modified during the loop
95
+ while (previousLeaveAnimations.length) {
96
+ $animate.cancel(previousLeaveAnimations.pop());
97
+ }
98
+
99
+ for (i = 0, ii = selectedScopes.length; i < ii; ++i) {
100
+ const selected = getBlockNodes(selectedElements[i].clone);
101
+ selectedScopes[i].$destroy();
102
+ const runner = (previousLeaveAnimations[i] =
103
+ $animate.leave(selected));
104
+ runner.done(spliceFactory(previousLeaveAnimations, i));
105
+ }
106
+
107
+ selectedElements.length = 0;
108
+ selectedScopes.length = 0;
109
+
110
+ if (
111
+ (selectedTranscludes =
112
+ ngSwitchController.cases[`!${value}`] ||
113
+ ngSwitchController.cases["?"])
114
+ ) {
115
+ forEach(selectedTranscludes, (selectedTransclude) => {
116
+ selectedTransclude.transclude((caseElement, selectedScope) => {
117
+ selectedScopes.push(selectedScope);
118
+ const anchor = selectedTransclude.element;
119
+ caseElement[caseElement.length++] =
120
+ $compile.$$createComment("end ngSwitchWhen");
121
+ const block = { clone: caseElement };
122
+
123
+ selectedElements.push(block);
124
+ $animate.enter(caseElement, anchor.parent(), anchor);
125
+ });
126
+ });
127
+ }
128
+ });
129
+ },
130
+ }),
131
+ ];
132
+
133
+ /**
134
+ * @returns {angular.IDirective}
135
+ */
136
+ export function ngSwitchWhenDirective() {
137
+ return {
138
+ transclude: "element",
139
+ priority: 1200,
140
+ restrict: "EA",
141
+ require: "^ngSwitch",
142
+ multiElement: true,
143
+ link(scope, element, attrs, ctrl, $transclude) {
144
+ const cases = attrs.ngSwitchWhen
145
+ .split(attrs.ngSwitchWhenSeparator)
146
+ .sort()
147
+ .filter(
148
+ // Filter duplicate cases
149
+ (element, index, array) => array[index - 1] !== element,
150
+ );
151
+
152
+ cases.forEach((whenCase) => {
153
+ ctrl.cases[`!${whenCase}`] = ctrl.cases[`!${whenCase}`] || [];
154
+ ctrl.cases[`!${whenCase}`].push({
155
+ transclude: $transclude,
156
+ element,
157
+ });
158
+ });
159
+ },
160
+ };
161
+ }
162
+
163
+ /**
164
+ * @returns {angular.IDirective}
165
+ */
166
+ export function ngSwitchDefaultDirective() {
167
+ return {
168
+ restrict: "EA",
169
+ transclude: "element",
170
+ priority: 1200,
171
+ require: "^ngSwitch",
172
+ multiElement: true,
173
+ link(_scope, element, _attr, ctrl, $transclude) {
174
+ ctrl.cases["?"] = ctrl.cases["?"] || [];
175
+ ctrl.cases["?"].push({ transclude: $transclude, element });
176
+ },
177
+ };
178
+ }
@@ -0,0 +1,98 @@
1
+ import { minErr } from "../core/utils";
2
+ import { startingTag } from "../jqLite";
3
+
4
+ /**
5
+ * @ngdoc directive
6
+ * @name ngTransclude
7
+ * @restrict EAC
8
+ *
9
+ * @description
10
+ * Directive that marks the insertion point for the transcluded DOM of the nearest parent directive that uses transclusion.
11
+ *
12
+ * You can specify that you want to insert a named transclusion slot, instead of the default slot, by providing the slot name
13
+ * as the value of the `ng-transclude` or `ng-transclude-slot` attribute.
14
+ *
15
+ * If the transcluded content is not empty (i.e. contains one or more DOM nodes, including whitespace text nodes), any existing
16
+ * content of this element will be removed before the transcluded content is inserted.
17
+ * If the transcluded content is empty (or only whitespace), the existing content is left intact. This lets you provide fallback
18
+ * content in the case that no transcluded content is provided.
19
+ *
20
+ * @element ANY
21
+ *
22
+ * @param {string} ngTransclude|ngTranscludeSlot the name of the slot to insert at this point. If this is not provided, is empty
23
+ * or its value is the same as the name of the attribute then the default slot is used.
24
+ */
25
+ const ngTranscludeMinErr = minErr("ngTransclude");
26
+ export const ngTranscludeDirective = [
27
+ "$compile",
28
+ function ($compile) {
29
+ return {
30
+ restrict: "EAC",
31
+ compile: function ngTranscludeCompile(tElement) {
32
+ // Remove and cache any original content to act as a fallback
33
+ const fallbackLinkFn = $compile(tElement[0].childNodes);
34
+ tElement.empty();
35
+
36
+ return function ngTranscludePostLink(
37
+ $scope,
38
+ $element,
39
+ $attrs,
40
+ controller,
41
+ $transclude,
42
+ ) {
43
+ if (!$transclude) {
44
+ throw ngTranscludeMinErr(
45
+ "orphan",
46
+ "Illegal use of ngTransclude directive in the template! " +
47
+ "No parent directive that requires a transclusion found. " +
48
+ "Element: {0}",
49
+ startingTag($element),
50
+ );
51
+ }
52
+
53
+ // If the attribute is of the form: `ng-transclude="ng-transclude"` then treat it like the default
54
+ if ($attrs.ngTransclude === $attrs.$attr.ngTransclude) {
55
+ $attrs.ngTransclude = "";
56
+ }
57
+ const slotName = $attrs.ngTransclude || $attrs.ngTranscludeSlot;
58
+
59
+ // If the slot is required and no transclusion content is provided then this call will throw an error
60
+ $transclude(ngTranscludeCloneAttachFn, null, slotName);
61
+
62
+ // If the slot is optional and no transclusion content is provided then use the fallback content
63
+ if (slotName && !$transclude.isSlotFilled(slotName)) {
64
+ useFallbackContent();
65
+ }
66
+
67
+ function ngTranscludeCloneAttachFn(clone, transcludedScope) {
68
+ if (clone.length && notWhitespace(clone)) {
69
+ $element.append(clone);
70
+ } else {
71
+ useFallbackContent();
72
+ // There is nothing linked against the transcluded scope since no content was available,
73
+ // so it should be safe to clean up the generated scope.
74
+ transcludedScope.$destroy();
75
+ }
76
+ }
77
+
78
+ function useFallbackContent() {
79
+ // Since this is the fallback content rather than the transcluded content,
80
+ // we link against the scope of this directive rather than the transcluded scope
81
+ fallbackLinkFn($scope, (clone) => {
82
+ $element.append(clone);
83
+ });
84
+ }
85
+
86
+ function notWhitespace(nodes) {
87
+ for (let i = 0, ii = nodes.length; i < ii; i++) {
88
+ const node = nodes[i];
89
+ if (node.nodeType !== Node.TEXT_NODE || node.nodeValue.trim()) {
90
+ return true;
91
+ }
92
+ }
93
+ }
94
+ };
95
+ },
96
+ };
97
+ },
98
+ ];
@@ -0,0 +1,11 @@
1
+ /**
2
+ *
3
+ * @returns {angular.IDirective}
4
+ */
5
+ export function ngNonBindableDirective() {
6
+ return {
7
+ restrict: "EA",
8
+ terminal: true,
9
+ priority: 1000,
10
+ };
11
+ }
@@ -0,0 +1,17 @@
1
+ ## `ngNonBindable` Directive
2
+
3
+ ### Restrict
4
+
5
+ `AC`
6
+
7
+ ### Priority
8
+
9
+ 1000
10
+
11
+ ### Element
12
+
13
+ `ANY`
14
+
15
+ ### Description
16
+
17
+ The `ngNonBindable` directive tells AngularJS not to compile or bind the contents of the current DOM element, including directives on the element itself that have a lower priority than `ngNonBindable`. This is useful if the element contains what appears to be AngularJS directives and bindings but which should be ignored by AngularJS. This could be the case if you have a site that displays snippets of code, for instance.
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @ngdoc directive
3
+ * @name script
4
+ * @restrict E
5
+ *
6
+ * @description
7
+ * Load the content of a `<script>` element into {@link ng.$templateCache `$templateCache`}, so that the
8
+ * template can be used by {@link ng.directive:ngInclude `ngInclude`},
9
+ * {@link ngRoute.directive:ngView `ngView`}, or {@link guide/directive directives}. The type of the
10
+ * `<script>` element must be specified as `text/ng-template`, and a cache name for the template must be
11
+ * assigned through the element's `id`, which can then be used as a directive's `templateUrl`.
12
+ *
13
+ * @param {string} type Must be set to `'text/ng-template'`.
14
+ * @param {string} id Cache name of the template.
15
+ */
16
+ export const scriptDirective = [
17
+ "$templateCache",
18
+ ($templateCache) => ({
19
+ restrict: "E",
20
+ terminal: true,
21
+ compile(element, attr) {
22
+ if (attr.type === "text/ng-template") {
23
+ const templateUrl = attr.id;
24
+ const { text } = element[0];
25
+
26
+ $templateCache.put(templateUrl, text);
27
+ }
28
+ },
29
+ }),
30
+ ];