@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.
- package/.eslintignore +1 -0
- package/.eslintrc.cjs +29 -0
- package/.github/workflows/playwright.yml +27 -0
- package/CHANGELOG.md +17974 -0
- package/CODE_OF_CONDUCT.md +3 -0
- package/CONTRIBUTING.md +246 -0
- package/DEVELOPERS.md +488 -0
- package/LICENSE +22 -0
- package/Makefile +31 -0
- package/README.md +115 -0
- package/RELEASE.md +98 -0
- package/SECURITY.md +16 -0
- package/TRIAGING.md +135 -0
- package/css/angular.css +22 -0
- package/dist/angular-ts.cjs.js +36843 -0
- package/dist/angular-ts.esm.js +36841 -0
- package/dist/angular-ts.umd.js +36848 -0
- package/dist/build/angular-animate.js +4272 -0
- package/dist/build/angular-aria.js +426 -0
- package/dist/build/angular-message-format.js +1072 -0
- package/dist/build/angular-messages.js +829 -0
- package/dist/build/angular-mocks.js +3757 -0
- package/dist/build/angular-parse-ext.js +1275 -0
- package/dist/build/angular-resource.js +911 -0
- package/dist/build/angular-route.js +1266 -0
- package/dist/build/angular-sanitize.js +891 -0
- package/dist/build/angular-touch.js +368 -0
- package/dist/build/angular.js +36600 -0
- package/e2e/unit.spec.ts +15 -0
- package/images/android-chrome-192x192.png +0 -0
- package/images/android-chrome-512x512.png +0 -0
- package/images/apple-touch-icon.png +0 -0
- package/images/favicon-16x16.png +0 -0
- package/images/favicon-32x32.png +0 -0
- package/images/favicon.ico +0 -0
- package/images/site.webmanifest +1 -0
- package/index.html +104 -0
- package/package.json +47 -0
- package/playwright.config.ts +78 -0
- package/public/circle.html +1 -0
- package/public/my_child_directive.html +1 -0
- package/public/my_directive.html +1 -0
- package/public/my_other_directive.html +1 -0
- package/public/test.html +1 -0
- package/rollup.config.js +31 -0
- package/src/animations/animateCache.js +55 -0
- package/src/animations/animateChildrenDirective.js +105 -0
- package/src/animations/animateCss.js +1139 -0
- package/src/animations/animateCssDriver.js +291 -0
- package/src/animations/animateJs.js +367 -0
- package/src/animations/animateJsDriver.js +67 -0
- package/src/animations/animateQueue.js +851 -0
- package/src/animations/animation.js +506 -0
- package/src/animations/module.js +779 -0
- package/src/animations/ngAnimateSwap.js +119 -0
- package/src/animations/rafScheduler.js +50 -0
- package/src/animations/shared.js +378 -0
- package/src/constants.js +20 -0
- package/src/core/animate.js +845 -0
- package/src/core/animateCss.js +73 -0
- package/src/core/animateRunner.js +195 -0
- package/src/core/attributes.js +199 -0
- package/src/core/cache.js +45 -0
- package/src/core/compile.js +4727 -0
- package/src/core/controller.js +225 -0
- package/src/core/exceptionHandler.js +63 -0
- package/src/core/filter.js +146 -0
- package/src/core/interpolate.js +442 -0
- package/src/core/interval.js +188 -0
- package/src/core/intervalFactory.js +57 -0
- package/src/core/location.js +1086 -0
- package/src/core/parser/parse.js +2562 -0
- package/src/core/parser/parse.md +13 -0
- package/src/core/q.js +746 -0
- package/src/core/rootScope.js +1596 -0
- package/src/core/sanitizeUri.js +85 -0
- package/src/core/sce.js +1161 -0
- package/src/core/taskTrackerFactory.js +125 -0
- package/src/core/timeout.js +121 -0
- package/src/core/urlUtils.js +187 -0
- package/src/core/utils.js +1349 -0
- package/src/directive/a.js +37 -0
- package/src/directive/attrs.js +283 -0
- package/src/directive/bind.js +51 -0
- package/src/directive/bind.md +142 -0
- package/src/directive/change.js +12 -0
- package/src/directive/change.md +25 -0
- package/src/directive/cloak.js +12 -0
- package/src/directive/cloak.md +24 -0
- package/src/directive/events.js +75 -0
- package/src/directive/events.md +166 -0
- package/src/directive/form.js +725 -0
- package/src/directive/init.js +15 -0
- package/src/directive/init.md +41 -0
- package/src/directive/input.js +1783 -0
- package/src/directive/list.js +46 -0
- package/src/directive/list.md +22 -0
- package/src/directive/ngClass.js +249 -0
- package/src/directive/ngController.js +64 -0
- package/src/directive/ngCsp.js +82 -0
- package/src/directive/ngIf.js +134 -0
- package/src/directive/ngInclude.js +217 -0
- package/src/directive/ngModel.js +1356 -0
- package/src/directive/ngModelOptions.js +509 -0
- package/src/directive/ngOptions.js +670 -0
- package/src/directive/ngRef.js +90 -0
- package/src/directive/ngRepeat.js +650 -0
- package/src/directive/ngShowHide.js +255 -0
- package/src/directive/ngSwitch.js +178 -0
- package/src/directive/ngTransclude.js +98 -0
- package/src/directive/non-bindable.js +11 -0
- package/src/directive/non-bindable.md +17 -0
- package/src/directive/script.js +30 -0
- package/src/directive/select.js +624 -0
- package/src/directive/style.js +25 -0
- package/src/directive/style.md +23 -0
- package/src/directive/validators.js +329 -0
- package/src/exts/aria.js +544 -0
- package/src/exts/messages.js +852 -0
- package/src/filters/filter.js +207 -0
- package/src/filters/filter.md +69 -0
- package/src/filters/filters.js +239 -0
- package/src/filters/json.md +16 -0
- package/src/filters/limit-to.js +43 -0
- package/src/filters/limit-to.md +19 -0
- package/src/filters/order-by.js +183 -0
- package/src/filters/order-by.md +83 -0
- package/src/index.js +13 -0
- package/src/injector.js +1034 -0
- package/src/jqLite.js +1117 -0
- package/src/loader.js +1320 -0
- package/src/public.js +215 -0
- package/src/routeToRegExp.js +41 -0
- package/src/services/anchorScroll.js +135 -0
- package/src/services/browser.js +321 -0
- package/src/services/cacheFactory.js +398 -0
- package/src/services/cookieReader.js +72 -0
- package/src/services/document.js +64 -0
- package/src/services/http.js +1537 -0
- package/src/services/httpBackend.js +206 -0
- package/src/services/log.js +160 -0
- package/src/services/templateRequest.js +139 -0
- package/test/angular.spec.js +2153 -0
- package/test/aria/aria.spec.js +1245 -0
- package/test/binding.spec.js +504 -0
- package/test/build-test.html +14 -0
- package/test/injector.spec.js +2327 -0
- package/test/jasmine/jasmine-5.1.2/boot0.js +65 -0
- package/test/jasmine/jasmine-5.1.2/boot1.js +133 -0
- package/test/jasmine/jasmine-5.1.2/jasmine-html.js +963 -0
- package/test/jasmine/jasmine-5.1.2/jasmine.css +320 -0
- package/test/jasmine/jasmine-5.1.2/jasmine.js +10824 -0
- package/test/jasmine/jasmine-5.1.2/jasmine_favicon.png +0 -0
- package/test/jasmine/jasmine-browser.json +17 -0
- package/test/jasmine/jasmine.json +9 -0
- package/test/jqlite.spec.js +2133 -0
- package/test/loader.spec.js +219 -0
- package/test/messages/messages.spec.js +1146 -0
- package/test/min-err.spec.js +174 -0
- package/test/mock-test.html +13 -0
- package/test/module-test.html +15 -0
- package/test/ng/anomate.spec.js +606 -0
- package/test/ng/cache-factor.spec.js +334 -0
- package/test/ng/compile.spec.js +17956 -0
- package/test/ng/controller-provider.spec.js +227 -0
- package/test/ng/cookie-reader.spec.js +98 -0
- package/test/ng/directive/a.spec.js +192 -0
- package/test/ng/directive/bind.spec.js +334 -0
- package/test/ng/directive/boolean.spec.js +136 -0
- package/test/ng/directive/change.spec.js +71 -0
- package/test/ng/directive/class.spec.js +858 -0
- package/test/ng/directive/click.spec.js +38 -0
- package/test/ng/directive/cloak.spec.js +44 -0
- package/test/ng/directive/constoller.spec.js +194 -0
- package/test/ng/directive/element-style.spec.js +92 -0
- package/test/ng/directive/event.spec.js +282 -0
- package/test/ng/directive/form.spec.js +1518 -0
- package/test/ng/directive/href.spec.js +143 -0
- package/test/ng/directive/if.spec.js +402 -0
- package/test/ng/directive/include.spec.js +828 -0
- package/test/ng/directive/init.spec.js +68 -0
- package/test/ng/directive/input.spec.js +3810 -0
- package/test/ng/directive/list.spec.js +170 -0
- package/test/ng/directive/model-options.spec.js +1008 -0
- package/test/ng/directive/model.spec.js +1905 -0
- package/test/ng/directive/non-bindable.spec.js +55 -0
- package/test/ng/directive/options.spec.js +3583 -0
- package/test/ng/directive/ref.spec.js +575 -0
- package/test/ng/directive/repeat.spec.js +1675 -0
- package/test/ng/directive/script.spec.js +52 -0
- package/test/ng/directive/scrset.spec.js +67 -0
- package/test/ng/directive/select.spec.js +2541 -0
- package/test/ng/directive/show-hide.spec.js +253 -0
- package/test/ng/directive/src.spec.js +157 -0
- package/test/ng/directive/style.spec.js +178 -0
- package/test/ng/directive/switch.spec.js +647 -0
- package/test/ng/directive/validators.spec.js +717 -0
- package/test/ng/document.spec.js +52 -0
- package/test/ng/filter/filter.spec.js +714 -0
- package/test/ng/filter/filters.spec.js +35 -0
- package/test/ng/filter/limit-to.spec.js +251 -0
- package/test/ng/filter/order-by.spec.js +891 -0
- package/test/ng/filter.spec.js +149 -0
- package/test/ng/http-backend.spec.js +398 -0
- package/test/ng/http.spec.js +4071 -0
- package/test/ng/interpolate.spec.js +642 -0
- package/test/ng/interval.spec.js +343 -0
- package/test/ng/location.spec.js +3488 -0
- package/test/ng/on.spec.js +229 -0
- package/test/ng/parse.spec.js +4655 -0
- package/test/ng/prop.spec.js +805 -0
- package/test/ng/q.spec.js +2904 -0
- package/test/ng/root-element.spec.js +16 -0
- package/test/ng/sanitize-uri.spec.js +249 -0
- package/test/ng/sce.spec.js +660 -0
- package/test/ng/scope.spec.js +3442 -0
- package/test/ng/template-request.spec.js +236 -0
- package/test/ng/timeout.spec.js +351 -0
- package/test/ng/url-utils.spec.js +156 -0
- package/test/ng/utils.spec.js +144 -0
- package/test/original-test.html +21 -0
- package/test/public.spec.js +34 -0
- package/test/sanitize/bing-html.spec.js +36 -0
- package/test/server/express.js +158 -0
- package/test/test-utils.js +11 -0
- package/tsconfig.json +17 -0
- package/types/angular.d.ts +138 -0
- package/types/global.d.ts +9 -0
- package/types/index.d.ts +2357 -0
- package/types/jqlite.d.ts +558 -0
- package/vite.config.js +14 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ngdoc directive
|
|
3
|
+
* @name ngAnimateSwap
|
|
4
|
+
* @restrict A
|
|
5
|
+
* @scope
|
|
6
|
+
*
|
|
7
|
+
* @description
|
|
8
|
+
*
|
|
9
|
+
* ngAnimateSwap is a animation-oriented directive that allows for the container to
|
|
10
|
+
* be removed and entered in whenever the associated expression changes. A
|
|
11
|
+
* common usecase for this directive is a rotating banner or slider component which
|
|
12
|
+
* contains one image being present at a time. When the active image changes
|
|
13
|
+
* then the old image will perform a `leave` animation and the new element
|
|
14
|
+
* will be inserted via an `enter` animation.
|
|
15
|
+
*
|
|
16
|
+
* @animations
|
|
17
|
+
* | Animation | Occurs |
|
|
18
|
+
* |----------------------------------|--------------------------------------|
|
|
19
|
+
* | {@link ng.$animate#enter enter} | when the new element is inserted to the DOM |
|
|
20
|
+
* | {@link ng.$animate#leave leave} | when the old element is removed from the DOM |
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* <example name="ngAnimateSwap-directive" module="ngAnimateSwapExample"
|
|
24
|
+
* deps="angular-animate.js"
|
|
25
|
+
* animations="true" fixBase="true">
|
|
26
|
+
* <file name="index.html">
|
|
27
|
+
* <div class="container" ng-controller="AppCtrl">
|
|
28
|
+
* <div ng-animate-swap="number" class="cell swap-animation" ng-class="colorClass(number)">
|
|
29
|
+
* {{ number }}
|
|
30
|
+
* </div>
|
|
31
|
+
* </div>
|
|
32
|
+
* </file>
|
|
33
|
+
* <file name="script.js">
|
|
34
|
+
* angular.module('ngAnimateSwapExample', ['ngAnimate'])
|
|
35
|
+
* .controller('AppCtrl', ['$scope', '$interval', function($scope, $interval) {
|
|
36
|
+
* $scope.number = 0;
|
|
37
|
+
* $interval(function() {
|
|
38
|
+
* $scope.number++;
|
|
39
|
+
* }, 1000);
|
|
40
|
+
*
|
|
41
|
+
* let colors = ['red','blue','green','yellow','orange'];
|
|
42
|
+
* $scope.colorClass = function(number) {
|
|
43
|
+
* return colors[number % colors.length];
|
|
44
|
+
* };
|
|
45
|
+
* }]);
|
|
46
|
+
* </file>
|
|
47
|
+
* <file name="animations.css">
|
|
48
|
+
* .container {
|
|
49
|
+
* height:250px;
|
|
50
|
+
* width:250px;
|
|
51
|
+
* position:relative;
|
|
52
|
+
* overflow:hidden;
|
|
53
|
+
* border:2px solid black;
|
|
54
|
+
* }
|
|
55
|
+
* .container .cell {
|
|
56
|
+
* font-size:150px;
|
|
57
|
+
* text-align:center;
|
|
58
|
+
* line-height:250px;
|
|
59
|
+
* position:absolute;
|
|
60
|
+
* top:0;
|
|
61
|
+
* left:0;
|
|
62
|
+
* right:0;
|
|
63
|
+
* border-bottom:2px solid black;
|
|
64
|
+
* }
|
|
65
|
+
* .swap-animation.ng-enter, .swap-animation.ng-leave {
|
|
66
|
+
* transition:0.5s linear all;
|
|
67
|
+
* }
|
|
68
|
+
* .swap-animation.ng-enter {
|
|
69
|
+
* top:-250px;
|
|
70
|
+
* }
|
|
71
|
+
* .swap-animation.ng-enter-active {
|
|
72
|
+
* top:0px;
|
|
73
|
+
* }
|
|
74
|
+
* .swap-animation.ng-leave {
|
|
75
|
+
* top:0px;
|
|
76
|
+
* }
|
|
77
|
+
* .swap-animation.ng-leave-active {
|
|
78
|
+
* top:250px;
|
|
79
|
+
* }
|
|
80
|
+
* .red { background:red; }
|
|
81
|
+
* .green { background:green; }
|
|
82
|
+
* .blue { background:blue; }
|
|
83
|
+
* .yellow { background:yellow; }
|
|
84
|
+
* .orange { background:orange; }
|
|
85
|
+
* </file>
|
|
86
|
+
* </example>
|
|
87
|
+
*/
|
|
88
|
+
export const ngAnimateSwapDirective = [
|
|
89
|
+
"$animate",
|
|
90
|
+
function ($animate) {
|
|
91
|
+
return {
|
|
92
|
+
restrict: "A",
|
|
93
|
+
transclude: "element",
|
|
94
|
+
terminal: true,
|
|
95
|
+
priority: 550, // We use 550 here to ensure that the directive is caught before others,
|
|
96
|
+
// but after `ngIf` (at priority 600).
|
|
97
|
+
link(scope, $element, attrs, ctrl, $transclude) {
|
|
98
|
+
let previousElement;
|
|
99
|
+
let previousScope;
|
|
100
|
+
scope.$watchCollection(attrs.ngAnimateSwap || attrs.for, (value) => {
|
|
101
|
+
if (previousElement) {
|
|
102
|
+
$animate.leave(previousElement);
|
|
103
|
+
}
|
|
104
|
+
if (previousScope) {
|
|
105
|
+
previousScope.$destroy();
|
|
106
|
+
previousScope = null;
|
|
107
|
+
}
|
|
108
|
+
if (value || value === 0) {
|
|
109
|
+
$transclude((clone, childScope) => {
|
|
110
|
+
previousElement = clone;
|
|
111
|
+
previousScope = childScope;
|
|
112
|
+
$animate.enter(clone, null, $element);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export const $$rAFSchedulerFactory = [
|
|
2
|
+
() => {
|
|
3
|
+
let queue;
|
|
4
|
+
let cancelFn;
|
|
5
|
+
|
|
6
|
+
function nextTick() {
|
|
7
|
+
if (!queue.length) return;
|
|
8
|
+
|
|
9
|
+
const items = queue.shift();
|
|
10
|
+
items.forEach((i) => i());
|
|
11
|
+
|
|
12
|
+
if (!cancelFn) {
|
|
13
|
+
window.requestAnimationFrame(() => {
|
|
14
|
+
if (!cancelFn) nextTick();
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function scheduler(tasks) {
|
|
20
|
+
// we make a copy since RAFScheduler mutates the state
|
|
21
|
+
// of the passed in array variable and this would be difficult
|
|
22
|
+
// to track down on the outside code
|
|
23
|
+
queue = queue.concat(tasks);
|
|
24
|
+
nextTick();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// eslint-disable-next-line no-multi-assign
|
|
28
|
+
queue = scheduler.queue = [];
|
|
29
|
+
|
|
30
|
+
/* waitUntilQuiet does two things:
|
|
31
|
+
* 1. It will run the FINAL `fn` value only when an uncanceled RAF has passed through
|
|
32
|
+
* 2. It will delay the next wave of tasks from running until the quiet `fn` has run.
|
|
33
|
+
*
|
|
34
|
+
* The motivation here is that animation code can request more time from the scheduler
|
|
35
|
+
* before the next wave runs. This allows for certain DOM properties such as classes to
|
|
36
|
+
* be resolved in time for the next animation to run.
|
|
37
|
+
*/
|
|
38
|
+
scheduler.waitUntilQuiet = (fn) => {
|
|
39
|
+
if (cancelFn) cancelFn();
|
|
40
|
+
|
|
41
|
+
cancelFn = window.requestAnimationFrame(() => {
|
|
42
|
+
cancelFn = null;
|
|
43
|
+
fn();
|
|
44
|
+
nextTick();
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return scheduler;
|
|
49
|
+
},
|
|
50
|
+
];
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import { forEach, isArray, isString, minErr, extend } from "../core/utils";
|
|
2
|
+
import { jqLite } from "../jqLite";
|
|
3
|
+
|
|
4
|
+
export const ADD_CLASS_SUFFIX = "-add";
|
|
5
|
+
export const REMOVE_CLASS_SUFFIX = "-remove";
|
|
6
|
+
export const EVENT_CLASS_PREFIX = "ng-";
|
|
7
|
+
export const ACTIVE_CLASS_SUFFIX = "-active";
|
|
8
|
+
export const PREPARE_CLASS_SUFFIX = "-prepare";
|
|
9
|
+
|
|
10
|
+
export const NG_ANIMATE_CLASSNAME = "ng-animate";
|
|
11
|
+
export const NG_ANIMATE_CHILDREN_DATA = "$$ngAnimateChildren";
|
|
12
|
+
|
|
13
|
+
// Detect proper transitionend/animationend event names.
|
|
14
|
+
export let CSS_PREFIX = "";
|
|
15
|
+
export let TRANSITION_PROP;
|
|
16
|
+
export let TRANSITIONEND_EVENT;
|
|
17
|
+
export let ANIMATION_PROP;
|
|
18
|
+
export let ANIMATIONEND_EVENT;
|
|
19
|
+
|
|
20
|
+
// If unprefixed events are not supported but webkit-prefixed are, use the latter.
|
|
21
|
+
// Otherwise, just use W3C names, browsers not supporting them at all will just ignore them.
|
|
22
|
+
// Note: Chrome implements `window.onwebkitanimationend` and doesn't implement `window.onanimationend`
|
|
23
|
+
// but at the same time dispatches the `animationend` event and not `webkitAnimationEnd`.
|
|
24
|
+
// Register both events in case `window.onanimationend` is not supported because of that,
|
|
25
|
+
// do the same for `transitionend` as Safari is likely to exhibit similar behavior.
|
|
26
|
+
// Also, the only modern browser that uses vendor prefixes for transitions/keyframes is webkit
|
|
27
|
+
// therefore there is no reason to test anymore for other vendor prefixes:
|
|
28
|
+
// http://caniuse.com/#search=transition
|
|
29
|
+
if (
|
|
30
|
+
window.ontransitionend === undefined &&
|
|
31
|
+
window.onwebkittransitionend !== undefined
|
|
32
|
+
) {
|
|
33
|
+
CSS_PREFIX = "-webkit-";
|
|
34
|
+
TRANSITION_PROP = "WebkitTransition";
|
|
35
|
+
TRANSITIONEND_EVENT = "webkitTransitionEnd transitionend";
|
|
36
|
+
} else {
|
|
37
|
+
TRANSITION_PROP = "transition";
|
|
38
|
+
// eslint-disable-next-line no-unused-vars
|
|
39
|
+
TRANSITIONEND_EVENT = "transitionend";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (
|
|
43
|
+
window.onanimationend === undefined &&
|
|
44
|
+
window.onwebkitanimationend !== undefined
|
|
45
|
+
) {
|
|
46
|
+
// eslint-disable-next-line no-unused-vars
|
|
47
|
+
CSS_PREFIX = "-webkit-";
|
|
48
|
+
ANIMATION_PROP = "WebkitAnimation";
|
|
49
|
+
ANIMATIONEND_EVENT = "webkitAnimationEnd animationend";
|
|
50
|
+
} else {
|
|
51
|
+
ANIMATION_PROP = "animation";
|
|
52
|
+
// eslint-disable-next-line no-unused-vars
|
|
53
|
+
ANIMATIONEND_EVENT = "animationend";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const DURATION_KEY = "Duration";
|
|
57
|
+
export const PROPERTY_KEY = "Property";
|
|
58
|
+
export const DELAY_KEY = "Delay";
|
|
59
|
+
export const TIMING_KEY = "TimingFunction";
|
|
60
|
+
export const ANIMATION_ITERATION_COUNT_KEY = "IterationCount";
|
|
61
|
+
export const ANIMATION_PLAYSTATE_KEY = "PlayState";
|
|
62
|
+
export const SAFE_FAST_FORWARD_DURATION_VALUE = 9999;
|
|
63
|
+
|
|
64
|
+
export const ANIMATION_DELAY_PROP = ANIMATION_PROP + DELAY_KEY;
|
|
65
|
+
export const ANIMATION_DURATION_PROP = ANIMATION_PROP + DURATION_KEY;
|
|
66
|
+
export const TRANSITION_DELAY_PROP = TRANSITION_PROP + DELAY_KEY;
|
|
67
|
+
export const TRANSITION_DURATION_PROP = TRANSITION_PROP + DURATION_KEY;
|
|
68
|
+
|
|
69
|
+
export const ngMinErr = minErr("ng");
|
|
70
|
+
export function assertArg(arg, name, reason) {
|
|
71
|
+
if (!arg) {
|
|
72
|
+
throw ngMinErr(
|
|
73
|
+
"areq",
|
|
74
|
+
"Argument '{0}' is {1}",
|
|
75
|
+
name || "?",
|
|
76
|
+
reason || "required",
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
return arg;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function mergeClasses(a, b) {
|
|
83
|
+
if (!a && !b) return "";
|
|
84
|
+
if (!a) return b;
|
|
85
|
+
if (!b) return a;
|
|
86
|
+
if (isArray(a)) a = a.join(" ");
|
|
87
|
+
if (isArray(b)) b = b.join(" ");
|
|
88
|
+
return `${a} ${b}`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function packageStyles(options) {
|
|
92
|
+
const styles = {};
|
|
93
|
+
if (options && (options.to || options.from)) {
|
|
94
|
+
styles.to = options.to;
|
|
95
|
+
styles.from = options.from;
|
|
96
|
+
}
|
|
97
|
+
return styles;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function pendClasses(classes, fix, isPrefix) {
|
|
101
|
+
let className = "";
|
|
102
|
+
// eslint-disable-next-line no-nested-ternary
|
|
103
|
+
classes = isArray(classes)
|
|
104
|
+
? classes
|
|
105
|
+
: classes && isString(classes) && classes.length
|
|
106
|
+
? classes.split(/\s+/)
|
|
107
|
+
: [];
|
|
108
|
+
classes.forEach((klass, i) => {
|
|
109
|
+
if (klass && klass.length > 0) {
|
|
110
|
+
className += i > 0 ? " " : "";
|
|
111
|
+
className += isPrefix ? fix + klass : klass + fix;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return className;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function removeFromArray(arr, val) {
|
|
118
|
+
const index = arr.indexOf(val);
|
|
119
|
+
if (val >= 0) {
|
|
120
|
+
arr.splice(index, 1);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function stripCommentsFromElement(element) {
|
|
125
|
+
if (element instanceof jqLite) {
|
|
126
|
+
switch (element.length) {
|
|
127
|
+
case 0:
|
|
128
|
+
return element;
|
|
129
|
+
|
|
130
|
+
case 1:
|
|
131
|
+
// there is no point of stripping anything if the element
|
|
132
|
+
// is the only element within the jqLite wrapper.
|
|
133
|
+
// (it's important that we retain the element instance.)
|
|
134
|
+
if (element[0].nodeType === Node.ELEMENT_NODE) {
|
|
135
|
+
return element;
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
|
|
139
|
+
default:
|
|
140
|
+
return jqLite(extractElementNode(element));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (element.nodeType === Node.ELEMENT_NODE) {
|
|
145
|
+
return jqLite(element);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function extractElementNode(element) {
|
|
150
|
+
if (!element[0]) return element;
|
|
151
|
+
for (let i = 0; i < element.length; i++) {
|
|
152
|
+
const elm = element[i];
|
|
153
|
+
if (elm.nodeType === Node.ELEMENT_NODE) {
|
|
154
|
+
return elm;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function applyAnimationClassesFactory() {
|
|
160
|
+
return function (element, options) {
|
|
161
|
+
if (options.addClass) {
|
|
162
|
+
element[0].classList.add(options.addClass);
|
|
163
|
+
options.addClass = null;
|
|
164
|
+
}
|
|
165
|
+
if (options.removeClass) {
|
|
166
|
+
element[0].classList.remove(options.removeClass);
|
|
167
|
+
options.removeClass = null;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function prepareAnimationOptions(options) {
|
|
173
|
+
options = options || {};
|
|
174
|
+
if (!options.$$prepared) {
|
|
175
|
+
let domOperation = options.domOperation || (() => {});
|
|
176
|
+
options.domOperation = function () {
|
|
177
|
+
options.$$domOperationFired = true;
|
|
178
|
+
domOperation();
|
|
179
|
+
domOperation = () => {};
|
|
180
|
+
};
|
|
181
|
+
options.$$prepared = true;
|
|
182
|
+
}
|
|
183
|
+
return options;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function applyAnimationStyles(element, options) {
|
|
187
|
+
applyAnimationFromStyles(element, options);
|
|
188
|
+
applyAnimationToStyles(element, options);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function applyAnimationFromStyles(element, options) {
|
|
192
|
+
if (options.from) {
|
|
193
|
+
//element.css(options.from);
|
|
194
|
+
options.from = null;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function applyAnimationToStyles(element, options) {
|
|
199
|
+
if (options.to) {
|
|
200
|
+
//element.css(options.to);
|
|
201
|
+
options.to = null;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function mergeAnimationDetails(element, oldAnimation, newAnimation) {
|
|
206
|
+
const target = oldAnimation.options || {};
|
|
207
|
+
const newOptions = newAnimation.options || {};
|
|
208
|
+
|
|
209
|
+
const toAdd = `${target.addClass || ""} ${newOptions.addClass || ""}`;
|
|
210
|
+
const toRemove = `${target.removeClass || ""} ${newOptions.removeClass || ""}`;
|
|
211
|
+
const classes = resolveElementClasses(element.attr("class"), toAdd, toRemove);
|
|
212
|
+
|
|
213
|
+
if (newOptions.preparationClasses) {
|
|
214
|
+
target.preparationClasses = concatWithSpace(
|
|
215
|
+
newOptions.preparationClasses,
|
|
216
|
+
target.preparationClasses,
|
|
217
|
+
);
|
|
218
|
+
delete newOptions.preparationClasses;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// noop is basically when there is no callback; otherwise something has been set
|
|
222
|
+
const realDomOperation =
|
|
223
|
+
target.domOperation !== (() => {}) ? target.domOperation : null;
|
|
224
|
+
|
|
225
|
+
extend(target, newOptions);
|
|
226
|
+
|
|
227
|
+
// TODO(matsko or sreeramu): proper fix is to maintain all animation callback in array and call at last,but now only leave has the callback so no issue with this.
|
|
228
|
+
if (realDomOperation) {
|
|
229
|
+
target.domOperation = realDomOperation;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (classes.addClass) {
|
|
233
|
+
target.addClass = classes.addClass;
|
|
234
|
+
} else {
|
|
235
|
+
target.addClass = null;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (classes.removeClass) {
|
|
239
|
+
target.removeClass = classes.removeClass;
|
|
240
|
+
} else {
|
|
241
|
+
target.removeClass = null;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
oldAnimation.addClass = target.addClass;
|
|
245
|
+
oldAnimation.removeClass = target.removeClass;
|
|
246
|
+
|
|
247
|
+
return target;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export function resolveElementClasses(existing, toAdd, toRemove) {
|
|
251
|
+
const ADD_CLASS = 1;
|
|
252
|
+
const REMOVE_CLASS = -1;
|
|
253
|
+
|
|
254
|
+
const flags = {};
|
|
255
|
+
existing = splitClassesToLookup(existing);
|
|
256
|
+
|
|
257
|
+
toAdd = splitClassesToLookup(toAdd);
|
|
258
|
+
forEach(toAdd, (value, key) => {
|
|
259
|
+
flags[key] = ADD_CLASS;
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
toRemove = splitClassesToLookup(toRemove);
|
|
263
|
+
forEach(toRemove, (value, key) => {
|
|
264
|
+
flags[key] = flags[key] === ADD_CLASS ? null : REMOVE_CLASS;
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
const classes = {
|
|
268
|
+
addClass: "",
|
|
269
|
+
removeClass: "",
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
forEach(flags, function (val, klass) {
|
|
273
|
+
var prop, allow;
|
|
274
|
+
if (val === ADD_CLASS) {
|
|
275
|
+
prop = "addClass";
|
|
276
|
+
allow = !existing[klass] || existing[klass + REMOVE_CLASS_SUFFIX];
|
|
277
|
+
} else if (val === REMOVE_CLASS) {
|
|
278
|
+
prop = "removeClass";
|
|
279
|
+
allow = existing[klass] || existing[klass + ADD_CLASS_SUFFIX];
|
|
280
|
+
}
|
|
281
|
+
if (allow) {
|
|
282
|
+
if (classes[prop].length) {
|
|
283
|
+
classes[prop] += " ";
|
|
284
|
+
}
|
|
285
|
+
classes[prop] += klass;
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
function splitClassesToLookup(classes) {
|
|
290
|
+
if (isString(classes)) {
|
|
291
|
+
classes = classes.split(" ");
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const obj = {};
|
|
295
|
+
forEach(classes, (klass) => {
|
|
296
|
+
// sometimes the split leaves empty string values
|
|
297
|
+
// incase extra spaces were applied to the options
|
|
298
|
+
if (klass.length) {
|
|
299
|
+
obj[klass] = true;
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
return obj;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return classes;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export function getDomNode(element) {
|
|
309
|
+
return element instanceof jqLite ? element[0] : element;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export function applyGeneratedPreparationClasses(element, event, options) {
|
|
313
|
+
let classes = "";
|
|
314
|
+
if (event) {
|
|
315
|
+
classes = pendClasses(event, EVENT_CLASS_PREFIX, true);
|
|
316
|
+
}
|
|
317
|
+
if (options.addClass) {
|
|
318
|
+
classes = concatWithSpace(
|
|
319
|
+
classes,
|
|
320
|
+
pendClasses(options.addClass, ADD_CLASS_SUFFIX),
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
if (options.removeClass) {
|
|
324
|
+
classes = concatWithSpace(
|
|
325
|
+
classes,
|
|
326
|
+
pendClasses(options.removeClass, REMOVE_CLASS_SUFFIX),
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
if (classes.length) {
|
|
330
|
+
options.preparationClasses = classes;
|
|
331
|
+
element[0].className += ` ${classes}`;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export function clearGeneratedClasses(element, options) {
|
|
336
|
+
if (options.preparationClasses) {
|
|
337
|
+
options.preparationClasses
|
|
338
|
+
.split(" ")
|
|
339
|
+
.forEach((cls) => element[0].classList.remove(cls));
|
|
340
|
+
options.preparationClasses = null;
|
|
341
|
+
}
|
|
342
|
+
if (options.activeClasses) {
|
|
343
|
+
options.activeClasses
|
|
344
|
+
.split(" ")
|
|
345
|
+
.forEach((cls) => element[0].classList.remove(cls));
|
|
346
|
+
options.activeClasses = null;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export function blockKeyframeAnimations(node, applyBlock) {
|
|
351
|
+
const value = applyBlock ? "paused" : "";
|
|
352
|
+
const key = ANIMATION_PROP + ANIMATION_PLAYSTATE_KEY;
|
|
353
|
+
applyInlineStyle(node, [key, value]);
|
|
354
|
+
return [key, value];
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export function applyInlineStyle(node, styleTuple) {
|
|
358
|
+
const prop = styleTuple[0];
|
|
359
|
+
const value = styleTuple[1];
|
|
360
|
+
node.style[prop] = value;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export function concatWithSpace(a, b) {
|
|
364
|
+
if (!a) return b;
|
|
365
|
+
if (!b) return a;
|
|
366
|
+
return `${a} ${b}`;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
export const helpers = {
|
|
370
|
+
blockTransitions(node, duration) {
|
|
371
|
+
// we use a negative delay value since it performs blocking
|
|
372
|
+
// yet it doesn't kill any existing transitions running on the
|
|
373
|
+
// same element which makes this safe for class-based animations
|
|
374
|
+
const value = duration ? `-${duration}s` : "";
|
|
375
|
+
applyInlineStyle(node, [TRANSITION_DELAY_PROP, value]);
|
|
376
|
+
return [TRANSITION_DELAY_PROP, value];
|
|
377
|
+
},
|
|
378
|
+
};
|
package/src/constants.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const VALID_CLASS = "ng-valid";
|
|
2
|
+
export const INVALID_CLASS = "ng-invalid";
|
|
3
|
+
export const PRISTINE_CLASS = "ng-pristine";
|
|
4
|
+
export const DIRTY_CLASS = "ng-dirty";
|
|
5
|
+
export const UNTOUCHED_CLASS = "ng-untouched";
|
|
6
|
+
export const TOUCHED_CLASS = "ng-touched";
|
|
7
|
+
export const EMPTY_CLASS = "ng-empty";
|
|
8
|
+
export const NOT_EMPTY_CLASS = "ng-not-empty";
|
|
9
|
+
|
|
10
|
+
export const PREFIX_REGEXP = /^((?:x|data)[:\-_])/i;
|
|
11
|
+
export const SPECIAL_CHARS_REGEXP = /[:\-_]+(.)/g;
|
|
12
|
+
|
|
13
|
+
export const ALIASED_ATTR = {
|
|
14
|
+
ngMinlength: "minlength",
|
|
15
|
+
ngMaxlength: "maxlength",
|
|
16
|
+
ngMin: "min",
|
|
17
|
+
ngMax: "max",
|
|
18
|
+
ngPattern: "pattern",
|
|
19
|
+
ngStep: "step",
|
|
20
|
+
};
|