@taiga-ui/addon-mobile 3.28.0 → 3.29.0

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 (36) hide show
  1. package/bundles/taiga-ui-addon-mobile-components-pull-to-refresh.umd.js +228 -114
  2. package/bundles/taiga-ui-addon-mobile-components-pull-to-refresh.umd.js.map +1 -1
  3. package/bundles/taiga-ui-addon-mobile.umd.js +4 -10
  4. package/bundles/taiga-ui-addon-mobile.umd.js.map +1 -1
  5. package/components/pull-to-refresh/index.d.ts +1 -0
  6. package/components/pull-to-refresh/loader-android/loader-android.component.d.ts +11 -3
  7. package/components/pull-to-refresh/loader-ios/loader-ios.component.d.ts +8 -2
  8. package/components/pull-to-refresh/pull-to-refresh.component.d.ts +8 -6
  9. package/components/pull-to-refresh/pull-to-refresh.module.d.ts +2 -1
  10. package/components/pull-to-refresh/pull-to-refresh.providers.d.ts +17 -6
  11. package/components/pull-to-refresh/pull-to-refresh.service.d.ts +15 -0
  12. package/esm2015/components/pull-to-refresh/index.js +2 -1
  13. package/esm2015/components/pull-to-refresh/loader-android/loader-android.component.js +38 -14
  14. package/esm2015/components/pull-to-refresh/loader-ios/loader-ios.component.js +23 -13
  15. package/esm2015/components/pull-to-refresh/pull-to-refresh.component.js +29 -32
  16. package/esm2015/components/pull-to-refresh/pull-to-refresh.module.js +21 -4
  17. package/esm2015/components/pull-to-refresh/pull-to-refresh.providers.js +26 -29
  18. package/esm2015/components/pull-to-refresh/pull-to-refresh.service.js +51 -0
  19. package/esm2015/index.js +1 -2
  20. package/fesm2015/taiga-ui-addon-mobile-components-pull-to-refresh.js +184 -100
  21. package/fesm2015/taiga-ui-addon-mobile-components-pull-to-refresh.js.map +1 -1
  22. package/fesm2015/taiga-ui-addon-mobile.js +0 -1
  23. package/fesm2015/taiga-ui-addon-mobile.js.map +1 -1
  24. package/index.d.ts +0 -1
  25. package/package.json +4 -4
  26. package/bundles/taiga-ui-addon-mobile-tokens.umd.js +0 -23
  27. package/bundles/taiga-ui-addon-mobile-tokens.umd.js.map +0 -1
  28. package/esm2015/tokens/index.js +0 -2
  29. package/esm2015/tokens/loaded.js +0 -9
  30. package/esm2015/tokens/taiga-ui-addon-mobile-tokens.js +0 -5
  31. package/fesm2015/taiga-ui-addon-mobile-tokens.js +0 -16
  32. package/fesm2015/taiga-ui-addon-mobile-tokens.js.map +0 -1
  33. package/tokens/index.d.ts +0 -1
  34. package/tokens/loaded.d.ts +0 -6
  35. package/tokens/package.json +0 -10
  36. package/tokens/taiga-ui-addon-mobile-tokens.d.ts +0 -5
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@taiga-ui/cdk'), require('rxjs'), require('rxjs/operators'), require('@taiga-ui/addon-mobile/tokens'), require('@taiga-ui/core')) :
3
- typeof define === 'function' && define.amd ? define('@taiga-ui/addon-mobile/components/pull-to-refresh', ['exports', '@angular/core', '@angular/common', '@taiga-ui/cdk', 'rxjs', 'rxjs/operators', '@taiga-ui/addon-mobile/tokens', '@taiga-ui/core'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["taiga-ui"] = global["taiga-ui"] || {}, global["taiga-ui"]["addon-mobile"] = global["taiga-ui"]["addon-mobile"] || {}, global["taiga-ui"]["addon-mobile"].components = global["taiga-ui"]["addon-mobile"].components || {}, global["taiga-ui"]["addon-mobile"].components["pull-to-refresh"] = {}), global.ng.core, global.ng.common, global.i1, global.rxjs, global.rxjs.operators, global["taiga-ui"]["addon-mobile"].tokens, global.core));
5
- })(this, (function (exports, i0, i4, i1, i5, operators, tokens, core) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@tinkoff/ng-polymorpheus'), require('@taiga-ui/cdk'), require('rxjs'), require('@angular/common'), require('rxjs/operators'), require('@taiga-ui/core')) :
3
+ typeof define === 'function' && define.amd ? define('@taiga-ui/addon-mobile/components/pull-to-refresh', ['exports', '@angular/core', '@tinkoff/ng-polymorpheus', '@taiga-ui/cdk', 'rxjs', '@angular/common', 'rxjs/operators', '@taiga-ui/core'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["taiga-ui"] = global["taiga-ui"] || {}, global["taiga-ui"]["addon-mobile"] = global["taiga-ui"]["addon-mobile"] || {}, global["taiga-ui"]["addon-mobile"].components = global["taiga-ui"]["addon-mobile"].components || {}, global["taiga-ui"]["addon-mobile"].components["pull-to-refresh"] = {}), global.ng.core, global.i2, global.i1, global.rxjs, global.ng.common, global.rxjs.operators, global.core));
5
+ })(this, (function (exports, i0, i2, i1, i1$1, i2$1, operators, core) { 'use strict';
6
6
 
7
7
  function _interopNamespace(e) {
8
8
  if (e && e.__esModule) return e;
@@ -23,68 +23,35 @@
23
23
  }
24
24
 
25
25
  var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
26
- var i4__namespace = /*#__PURE__*/_interopNamespace(i4);
26
+ var i2__namespace$1 = /*#__PURE__*/_interopNamespace(i2);
27
27
  var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
28
- var i5__namespace = /*#__PURE__*/_interopNamespace(i5);
29
-
30
- var HIDDEN_DISTANCE = 2;
31
- var ROTATE_X_DEFAULT = 180;
32
- var ROTATE_X_MAX = 500;
33
- var ROTATE_X_MULTIPLIER = 2.3;
34
- var TuiMobileLoaderAndroidComponent = /** @class */ (function () {
35
- function TuiMobileLoaderAndroidComponent() {
36
- this.pulled = 0;
37
- }
38
- Object.defineProperty(TuiMobileLoaderAndroidComponent.prototype, "transform", {
39
- get: function () {
40
- var rotateX = Math.min(ROTATE_X_DEFAULT + this.pulled * ROTATE_X_MULTIPLIER, ROTATE_X_MAX);
41
- return "rotate(" + rotateX + " 0 0)";
42
- },
43
- enumerable: false,
44
- configurable: true
45
- });
46
- Object.defineProperty(TuiMobileLoaderAndroidComponent.prototype, "hidden", {
47
- get: function () {
48
- return this.pulled < HIDDEN_DISTANCE;
49
- },
50
- enumerable: false,
51
- configurable: true
52
- });
53
- return TuiMobileLoaderAndroidComponent;
54
- }());
55
- TuiMobileLoaderAndroidComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TuiMobileLoaderAndroidComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
56
- TuiMobileLoaderAndroidComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: TuiMobileLoaderAndroidComponent, selector: "tui-mobile-android-loader", inputs: { pulled: "pulled" }, host: { properties: { "class._hidden": "this.hidden" } }, ngImport: i0__namespace, template: "<svg\n *ngIf=\"pulled !== 100; else loading\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n [attr.transform]=\"transform\"\n>\n <defs>\n <mask id=\"mask-1\">\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M21 12C21 7.03 16.97 3 12 3C7.03 3 3 7.03 3 12C3 16.97 7.03 21 12 21C14.06 21 15.96 20.3 17.48 19.14L16.06 17.7C14.91 18.51 13.51 19 12 19C8.13 19 5 15.87 5 12C5 8.13 8.13 5 12 5C15.87 5 19 8.13 19 12H16L20 16L24 12H21Z\"\n fill=\"white\"\n />\n </mask>\n </defs>\n <g mask=\"url(#mask-1)\">\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M21 12C21 7.03 16.97 3 12 3C7.03 3 3 7.03 3 12C3 16.97 7.03 21 12 21C14.06 21 15.96 20.3 17.48 19.14L16.06 17.7C14.91 18.51 13.51 19 12 19C8.13 19 5 15.87 5 12C5 8.13 8.13 5 12 5C15.87 5 19 8.13 19 12H16L20 16L24 12H21Z\"\n fill=\"black\"\n />\n </g>\n</svg>\n<ng-template #loading>\n <svg\n viewBox=\"0 0 100 100\"\n xmlns=\"http://www.w3.org/2000/svg\"\n class=\"t-loading\"\n >\n <circle\n cx=\"50\"\n cy=\"50\"\n r=\"50\"\n stroke-dasharray=\"314\"\n class=\"t-circle\"\n ></circle>\n </svg>\n</ng-template>\n", styles: [":host{box-shadow:0 1.5rem 1rem #00000008,0 .75rem .75rem #0000000a,0 .25rem .375rem #0000000d;display:flex;height:2.25rem;width:2.25rem;background-color:#fff;border-radius:6.25rem;align-items:center;justify-content:center}:host._hidden{visibility:hidden;transition:0s}.t-loading{display:block;width:1rem;border-radius:100%;animation:tuiLoaderRotate 3s linear infinite}.t-circle{fill:none;stroke:var(--tui-text-01);stroke-width:1.5rem;animation:tuiLoaderDashOffset 3s linear infinite}\n"], directives: [{ type: i4__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
57
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TuiMobileLoaderAndroidComponent, decorators: [{
58
- type: i0.Component,
59
- args: [{
60
- selector: 'tui-mobile-android-loader',
61
- templateUrl: './loader-android.template.html',
62
- styleUrls: ['./loader-android.style.less'],
63
- changeDetection: i0.ChangeDetectionStrategy.OnPush,
64
- }]
65
- }], propDecorators: { pulled: [{
66
- type: i0.Input
67
- }], hidden: [{
68
- type: i0.HostBinding,
69
- args: ['class._hidden']
70
- }] } });
28
+ var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1$1);
29
+ var i2__namespace = /*#__PURE__*/_interopNamespace(i2$1);
71
30
 
72
31
  var LOADED_STEP = 8;
73
32
  var ROTATE_X_STEP = 30;
74
33
  var TuiMobileLoaderIOSComponent = /** @class */ (function () {
75
- function TuiMobileLoaderIOSComponent() {
76
- this.pulled = 0;
34
+ function TuiMobileLoaderIOSComponent(context, threshold) {
35
+ this.context = context;
36
+ this.threshold = threshold;
77
37
  this.steps = 12;
78
38
  }
79
39
  Object.defineProperty(TuiMobileLoaderIOSComponent.prototype, "finished", {
80
40
  get: function () {
81
- return this.pulled >= 100;
41
+ return this.percent >= 100;
42
+ },
43
+ enumerable: false,
44
+ configurable: true
45
+ });
46
+ Object.defineProperty(TuiMobileLoaderIOSComponent.prototype, "percent", {
47
+ get: function () {
48
+ return (this.context.$implicit * 100) / this.threshold;
82
49
  },
83
50
  enumerable: false,
84
51
  configurable: true
85
52
  });
86
53
  TuiMobileLoaderIOSComponent.prototype.isShown = function (index) {
87
- return this.pulled > (index + 1) * LOADED_STEP;
54
+ return this.percent > (index + 1) * LOADED_STEP;
88
55
  };
89
56
  TuiMobileLoaderIOSComponent.prototype.calculateTransform = function (index) {
90
57
  return "rotate(" + index * ROTATE_X_STEP + " 50 50)";
@@ -94,19 +61,49 @@
94
61
  };
95
62
  return TuiMobileLoaderIOSComponent;
96
63
  }());
97
- TuiMobileLoaderIOSComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TuiMobileLoaderIOSComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
98
- TuiMobileLoaderIOSComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: TuiMobileLoaderIOSComponent, selector: "tui-mobile-ios-loader", inputs: { pulled: "pulled" }, providers: [i1.TuiDestroyService], ngImport: i0__namespace, template: "<svg\n width=\"36\"\n height=\"36\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n viewBox=\"0 0 100 100\"\n preserveAspectRatio=\"xMidYMid\"\n>\n <ng-container *tuiRepeatTimes=\"let index of steps\">\n <g\n *ngIf=\"isShown(index)\"\n [attr.transform]=\"calculateTransform(index)\"\n >\n <rect\n x=\"47\"\n y=\"22\"\n rx=\"7.05\"\n ry=\"3.3\"\n width=\"6\"\n height=\"16\"\n fill=\"#c7c9cc\"\n >\n <animate\n *ngIf=\"finished\"\n attributeName=\"opacity\"\n values=\"1;0\"\n keyTimes=\"0;1\"\n dur=\"1s\"\n repeatCount=\"indefinite\"\n [attr.begin]=\"calculateAnimationBegin(index)\"\n ></animate>\n </rect>\n </g>\n </ng-container>\n</svg>\n", directives: [{ type: i1__namespace.TuiRepeatTimesDirective, selector: "[tuiRepeatTimes][tuiRepeatTimesOf]", inputs: ["tuiRepeatTimesOf"] }, { type: i4__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
64
+ TuiMobileLoaderIOSComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TuiMobileLoaderIOSComponent, deps: [{ token: i2.POLYMORPHEUS_CONTEXT }, { token: TUI_PULL_TO_REFRESH_THRESHOLD }], target: i0__namespace.ɵɵFactoryTarget.Component });
65
+ TuiMobileLoaderIOSComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: TuiMobileLoaderIOSComponent, selector: "tui-mobile-ios-loader", ngImport: i0__namespace, template: "<svg\n width=\"36\"\n height=\"36\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n viewBox=\"0 0 100 100\"\n preserveAspectRatio=\"xMidYMid\"\n>\n <ng-container *tuiRepeatTimes=\"let index of steps\">\n <g\n *ngIf=\"isShown(index)\"\n [attr.transform]=\"calculateTransform(index)\"\n >\n <rect\n x=\"47\"\n y=\"22\"\n rx=\"7.05\"\n ry=\"3.3\"\n width=\"6\"\n height=\"16\"\n fill=\"#c7c9cc\"\n >\n <animate\n *ngIf=\"finished\"\n attributeName=\"opacity\"\n values=\"1;0\"\n keyTimes=\"0;1\"\n dur=\"1s\"\n repeatCount=\"indefinite\"\n [attr.begin]=\"calculateAnimationBegin(index)\"\n ></animate>\n </rect>\n </g>\n </ng-container>\n</svg>\n", styles: [":host{position:absolute;top:-.5rem;left:50%;margin-left:-1.125rem}\n"], directives: [{ type: i1__namespace.TuiRepeatTimesDirective, selector: "[tuiRepeatTimes][tuiRepeatTimesOf]", inputs: ["tuiRepeatTimesOf"] }, { type: i2__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
99
66
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TuiMobileLoaderIOSComponent, decorators: [{
100
67
  type: i0.Component,
101
68
  args: [{
102
69
  selector: 'tui-mobile-ios-loader',
103
70
  templateUrl: './loader-ios.template.html',
71
+ styleUrls: ['./loader-ios.style.less'],
104
72
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
105
- providers: [i1.TuiDestroyService],
106
73
  }]
107
- }], propDecorators: { pulled: [{
108
- type: i0.Input
109
- }] } });
74
+ }], ctorParameters: function () {
75
+ return [{ type: undefined, decorators: [{
76
+ type: i0.Inject,
77
+ args: [i2.POLYMORPHEUS_CONTEXT]
78
+ }] }, { type: undefined, decorators: [{
79
+ type: i0.Inject,
80
+ args: [TUI_PULL_TO_REFRESH_THRESHOLD]
81
+ }] }];
82
+ } });
83
+ var TUI_IOS_LOADER = new i2.PolymorpheusComponent(TuiMobileLoaderIOSComponent);
84
+
85
+ /**
86
+ * Stream that emits when loading is over
87
+ */
88
+ var TUI_PULL_TO_REFRESH_LOADED = new i0.InjectionToken("[TUI_PULL_TO_REFRESH_LOADED]", {
89
+ factory: function () { return i1$1.EMPTY; },
90
+ });
91
+ /**
92
+ * Pull threshold in pixels until loading starts
93
+ */
94
+ var TUI_PULL_TO_REFRESH_THRESHOLD = new i0.InjectionToken("[TUI_PULL_TO_REFRESH_THRESHOLD]", {
95
+ factory: function () { return 50; },
96
+ });
97
+ /**
98
+ * Loading indicator component that gets current pull distance in pixels as context
99
+ */
100
+ var TUI_PULL_TO_REFRESH_COMPONENT = new i0.InjectionToken("[TUI_PULL_TO_REFRESH_COMPONENT]", {
101
+ factory: function () { return (i0.inject(i1.TUI_IS_IOS) ? TUI_IOS_LOADER : TUI_ANDROID_LOADER); },
102
+ });
103
+ /**
104
+ * @deprecated renamed to {@link TUI_PULL_TO_REFRESH_LOADED}
105
+ */
106
+ var TUI_LOADED = TUI_PULL_TO_REFRESH_LOADED;
110
107
 
111
108
  /*! *****************************************************************************
112
109
  Copyright (c) Microsoft Corporation.
@@ -427,62 +424,153 @@
427
424
  }
428
425
 
429
426
  var MICRO_OFFSET = Math.pow(10, -6);
430
- var PULLED_DISTANCE = 50;
431
- /**
432
- * Stream that emits content pulling
433
- */
434
- var TUI_PULLING = new i0.InjectionToken("[TUI_PULLING]");
435
- var TUI_PULL_TO_REFRESH_PROVIDERS = [
436
- {
437
- provide: TUI_PULLING,
438
- deps: [i1.TUI_IS_IOS, tokens.TUI_LOADED, i0.ElementRef],
439
- useFactory: function (isIOS, loaded$, _a) {
440
- var nativeElement = _a.nativeElement;
441
- return i5.merge(i1.tuiTypedFromEvent(nativeElement, "touchstart", { passive: true }).pipe(operators.filter(function () { return nativeElement.scrollTop === 0; }), operators.switchMap(function (touchStart) { return i1.tuiTypedFromEvent(nativeElement, "touchmove").pipe(operators.map(function (touchMove) { return touchMove.touches[0].clientY -
442
- touchStart.touches[0].clientY; }), operators.takeUntil(i1.tuiTypedFromEvent(nativeElement, "touchend")), operators.endWith(0)); })), loaded$.pipe(operators.map(function () { return NaN; }))).pipe(operators.scan(function (max, current) {
443
- if (Number.isNaN(current)) {
444
- return 0;
445
- }
446
- var androidLoading = !isIOS && max === PULLED_DISTANCE;
447
- var dropped = current === 0 && max > PULLED_DISTANCE;
448
- return androidLoading || dropped
449
- ? PULLED_DISTANCE
450
- : current + MICRO_OFFSET;
451
- }, 0));
427
+ var TuiPullToRefreshService = /** @class */ (function (_super) {
428
+ __extends(TuiPullToRefreshService, _super);
429
+ function TuiPullToRefreshService(el, isIos, loaded$, threshold, component) {
430
+ var _this = _super.call(this, function (subscriber) { return (component ? _this.pulling$ : i1$1.EMPTY).subscribe(subscriber); }) || this;
431
+ _this.el = el;
432
+ _this.isIos = isIos;
433
+ _this.loaded$ = loaded$;
434
+ _this.threshold = threshold;
435
+ _this.pulling$ = i1$1.merge(i1.tuiTypedFromEvent(_this.element, "touchstart", { passive: true }).pipe(operators.filter(function () { return _this.element.scrollTop === 0; }), operators.switchMap(function (touchStart) { return i1.tuiTypedFromEvent(_this.element, "touchmove").pipe(operators.map(function (touchMove) { return touchMove.touches[0].clientY - touchStart.touches[0].clientY; }), operators.takeUntil(i1.tuiTypedFromEvent(_this.element, "touchend")), operators.endWith(0)); })), _this.loaded$.pipe(operators.map(function () { return NaN; }))).pipe(operators.scan(function (max, current) {
436
+ if (Number.isNaN(current)) {
437
+ return 0;
438
+ }
439
+ var androidLoading = !_this.isIos && max === _this.threshold;
440
+ var dropped = current === 0 && max > _this.threshold;
441
+ return androidLoading || dropped
442
+ ? _this.threshold
443
+ : current + current * MICRO_OFFSET;
444
+ }, 0));
445
+ return _this;
446
+ }
447
+ Object.defineProperty(TuiPullToRefreshService.prototype, "element", {
448
+ get: function () {
449
+ return this.el.nativeElement;
452
450
  },
453
- },
454
- ];
451
+ enumerable: false,
452
+ configurable: true
453
+ });
454
+ return TuiPullToRefreshService;
455
+ }(i1$1.Observable));
456
+ TuiPullToRefreshService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TuiPullToRefreshService, deps: [{ token: i0.ElementRef }, { token: i1.TUI_IS_IOS }, { token: TUI_PULL_TO_REFRESH_LOADED }, { token: TUI_PULL_TO_REFRESH_THRESHOLD }, { token: TUI_PULL_TO_REFRESH_COMPONENT }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
457
+ TuiPullToRefreshService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TuiPullToRefreshService });
458
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TuiPullToRefreshService, decorators: [{
459
+ type: i0.Injectable
460
+ }], ctorParameters: function () {
461
+ return [{ type: i0__namespace.ElementRef, decorators: [{
462
+ type: i0.Inject,
463
+ args: [i0.ElementRef]
464
+ }] }, { type: undefined, decorators: [{
465
+ type: i0.Inject,
466
+ args: [i1.TUI_IS_IOS]
467
+ }] }, { type: i1__namespace$1.Observable, decorators: [{
468
+ type: i0.Inject,
469
+ args: [TUI_PULL_TO_REFRESH_LOADED]
470
+ }] }, { type: undefined, decorators: [{
471
+ type: i0.Inject,
472
+ args: [TUI_PULL_TO_REFRESH_THRESHOLD]
473
+ }] }, { type: undefined, decorators: [{
474
+ type: i0.Inject,
475
+ args: [TUI_PULL_TO_REFRESH_COMPONENT]
476
+ }] }];
477
+ } });
455
478
 
456
- var IOS_LOADING_DISTANCE = PULLED_DISTANCE / 2;
457
- var ANDROID_MAX_DISTANCE = PULLED_DISTANCE * 1.5;
458
- function translateY(distance) {
459
- return "translateY(" + distance + "px)";
460
- }
461
- var TuiPullToRefreshComponent = /** @class */ (function () {
462
- function TuiPullToRefreshComponent(isIOS, pulling$) {
463
- this.isIOS = isIOS;
464
- this.pulling$ = pulling$;
465
- this.pulled = this.pulling$.pipe(operators.distinctUntilChanged(), operators.filter(function (distance) { return distance === PULLED_DISTANCE; }), operators.map(function () { return undefined; }));
466
- this.pulledInPercent$ = this.pulling$.pipe(operators.map(function (distance) { return (distance * 100) / PULLED_DISTANCE; }));
467
- this.dropped$ = this.pulling$.pipe(operators.map(function (distance) { return distance <= MICRO_OFFSET || distance === PULLED_DISTANCE; }), operators.distinctUntilChanged());
468
- this.contentTransform$ = this.isIOS
469
- ? this.pulling$.pipe(operators.map(function (distance) { return distance === PULLED_DISTANCE ? IOS_LOADING_DISTANCE : distance; }), operators.map(translateY))
470
- : i5.of(null);
479
+ var ROTATE_X_DEFAULT = 180;
480
+ var ROTATE_X_MAX = 500;
481
+ var ROTATE_X_MULTIPLIER = 2.3;
482
+ var TuiMobileLoaderAndroidComponent = /** @class */ (function () {
483
+ function TuiMobileLoaderAndroidComponent(context, threshold) {
484
+ this.context = context;
485
+ this.threshold = threshold;
471
486
  }
472
- Object.defineProperty(TuiPullToRefreshComponent.prototype, "loaderTransform$", {
487
+ Object.defineProperty(TuiMobileLoaderAndroidComponent.prototype, "transform", {
488
+ get: function () {
489
+ var rotateX = Math.min(ROTATE_X_DEFAULT + this.percent * ROTATE_X_MULTIPLIER, ROTATE_X_MAX);
490
+ return "rotate(" + rotateX + " 0 0)";
491
+ },
492
+ enumerable: false,
493
+ configurable: true
494
+ });
495
+ Object.defineProperty(TuiMobileLoaderAndroidComponent.prototype, "percent", {
496
+ get: function () {
497
+ return (this.context.$implicit * 100) / this.threshold;
498
+ },
499
+ enumerable: false,
500
+ configurable: true
501
+ });
502
+ Object.defineProperty(TuiMobileLoaderAndroidComponent.prototype, "opacity", {
503
+ get: function () {
504
+ return this.context.$implicit / (this.threshold * 1.5);
505
+ },
506
+ enumerable: false,
507
+ configurable: true
508
+ });
509
+ Object.defineProperty(TuiMobileLoaderAndroidComponent.prototype, "dropped", {
510
+ get: function () {
511
+ return (this.context.$implicit <= MICRO_OFFSET ||
512
+ this.context.$implicit === this.threshold);
513
+ },
514
+ enumerable: false,
515
+ configurable: true
516
+ });
517
+ Object.defineProperty(TuiMobileLoaderAndroidComponent.prototype, "hostTransform", {
473
518
  get: function () {
474
- return this.pulling$.pipe(operators.map(function (distance) { return translateY(Math.min(distance, ANDROID_MAX_DISTANCE)); }));
519
+ return "translateY(" + Math.min(this.context.$implicit, this.threshold * 1.5) + "px)";
475
520
  },
476
521
  enumerable: false,
477
522
  configurable: true
478
523
  });
524
+ return TuiMobileLoaderAndroidComponent;
525
+ }());
526
+ TuiMobileLoaderAndroidComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TuiMobileLoaderAndroidComponent, deps: [{ token: i2.POLYMORPHEUS_CONTEXT }, { token: TUI_PULL_TO_REFRESH_THRESHOLD }], target: i0__namespace.ɵɵFactoryTarget.Component });
527
+ TuiMobileLoaderAndroidComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: TuiMobileLoaderAndroidComponent, selector: "tui-mobile-android-loader", host: { properties: { "class._visible": "this.percent", "class._dropped": "this.dropped", "style.transform": "this.hostTransform" } }, ngImport: i0__namespace, template: "<svg\n *ngIf=\"percent !== 100; else loading\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n [attr.transform]=\"transform\"\n [style.opacity]=\"opacity\"\n>\n <defs>\n <mask id=\"mask-1\">\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M21 12C21 7.03 16.97 3 12 3C7.03 3 3 7.03 3 12C3 16.97 7.03 21 12 21C14.06 21 15.96 20.3 17.48 19.14L16.06 17.7C14.91 18.51 13.51 19 12 19C8.13 19 5 15.87 5 12C5 8.13 8.13 5 12 5C15.87 5 19 8.13 19 12H16L20 16L24 12H21Z\"\n fill=\"white\"\n />\n </mask>\n </defs>\n <g mask=\"url(#mask-1)\">\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M21 12C21 7.03 16.97 3 12 3C7.03 3 3 7.03 3 12C3 16.97 7.03 21 12 21C14.06 21 15.96 20.3 17.48 19.14L16.06 17.7C14.91 18.51 13.51 19 12 19C8.13 19 5 15.87 5 12C5 8.13 8.13 5 12 5C15.87 5 19 8.13 19 12H16L20 16L24 12H21Z\"\n fill=\"black\"\n />\n </g>\n</svg>\n<ng-template #loading>\n <svg\n viewBox=\"0 0 100 100\"\n xmlns=\"http://www.w3.org/2000/svg\"\n class=\"t-loading\"\n >\n <circle\n cx=\"50\"\n cy=\"50\"\n r=\"50\"\n stroke-dasharray=\"314\"\n class=\"t-circle\"\n ></circle>\n </svg>\n</ng-template>\n", styles: [":host{box-shadow:0 1.5rem 1rem #00000008,0 .75rem .75rem #0000000a,0 .25rem .375rem #0000000d;transition-property:opacity;transition-duration:var(--tui-duration, .3s);transition-timing-function:ease-in-out;position:absolute;top:-1.5rem;left:50%;display:flex;height:2.25rem;width:2.25rem;background-color:var(--tui-secondary);border-radius:6.25rem;align-items:center;justify-content:center;margin-left:-1.125rem;opacity:0}:host._visible{opacity:1}:host._dropped{transition:transform var(--tui-duration) cubic-bezier(.4,0,.2,1),opacity var(--tui-duration) var(--tui-duration)}.t-loading{display:block;width:1rem;border-radius:100%;animation:tuiLoaderRotate 3s linear infinite}.t-circle{fill:none;stroke:var(--tui-text-01);stroke-width:1.5rem;animation:tuiLoaderDashOffset 3s linear infinite}\n"], directives: [{ type: i2__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
528
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TuiMobileLoaderAndroidComponent, decorators: [{
529
+ type: i0.Component,
530
+ args: [{
531
+ selector: 'tui-mobile-android-loader',
532
+ templateUrl: './loader-android.template.html',
533
+ styleUrls: ['./loader-android.style.less'],
534
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
535
+ }]
536
+ }], ctorParameters: function () {
537
+ return [{ type: undefined, decorators: [{
538
+ type: i0.Inject,
539
+ args: [i2.POLYMORPHEUS_CONTEXT]
540
+ }] }, { type: undefined, decorators: [{
541
+ type: i0.Inject,
542
+ args: [TUI_PULL_TO_REFRESH_THRESHOLD]
543
+ }] }];
544
+ }, propDecorators: { percent: [{
545
+ type: i0.HostBinding,
546
+ args: ['class._visible']
547
+ }], dropped: [{
548
+ type: i0.HostBinding,
549
+ args: ['class._dropped']
550
+ }], hostTransform: [{
551
+ type: i0.HostBinding,
552
+ args: ['style.transform']
553
+ }] } });
554
+ var TUI_ANDROID_LOADER = new i2.PolymorpheusComponent(TuiMobileLoaderAndroidComponent);
555
+
556
+ var TuiPullToRefreshComponent = /** @class */ (function () {
557
+ function TuiPullToRefreshComponent(isIOS, threshold, component, pulling$) {
558
+ var _this = this;
559
+ this.isIOS = isIOS;
560
+ this.threshold = threshold;
561
+ this.component = component;
562
+ this.pulling$ = pulling$;
563
+ this.pulled = this.pulling$.pipe(operators.distinctUntilChanged(), operators.filter(function (distance) { return distance === _this.threshold; }));
564
+ // TODO: Move to iOS loader somehow, like contentTransform$ below
565
+ this.dropped$ = this.pulling$.pipe(operators.map(function (distance) { return distance <= MICRO_OFFSET || distance === _this.threshold; }), operators.distinctUntilChanged());
566
+ this.contentTransform$ = this.isIOS && this.component === TUI_IOS_LOADER
567
+ ? this.pulling$.pipe(operators.map(function (distance) { return "translateY(" + distance / 2 + "px)"; }))
568
+ : i1$1.of(null);
569
+ }
479
570
  return TuiPullToRefreshComponent;
480
571
  }());
481
- TuiPullToRefreshComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TuiPullToRefreshComponent, deps: [{ token: i1.TUI_IS_IOS }, { token: TUI_PULLING }], target: i0__namespace.ɵɵFactoryTarget.Component });
482
- TuiPullToRefreshComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: TuiPullToRefreshComponent, selector: "tui-pull-to-refresh", outputs: { pulled: "pulled" }, providers: TUI_PULL_TO_REFRESH_PROVIDERS, ngImport: i0__namespace, template: "<div\n tuiOverscroll\n [class.t-drop-animation]=\"dropped$ | async\"\n [style.transform]=\"contentTransform$ | async\"\n>\n <ng-content></ng-content>\n</div>\n\n<tui-mobile-ios-loader\n *ngIf=\"isIOS; else androidLoader\"\n class=\"t-ios-spinner\"\n [pulled]=\"(pulledInPercent$ | async) || 0\"\n></tui-mobile-ios-loader>\n\n<ng-template #androidLoader>\n <tui-mobile-android-loader\n class=\"t-android-loader\"\n [class.t-drop-animation]=\"dropped$ | async\"\n [style.transform]=\"loaderTransform$ | async\"\n [pulled]=\"(pulledInPercent$ | async) || 0\"\n ></tui-mobile-android-loader>\n</ng-template>\n", styles: [":host{position:relative;display:block;overflow:hidden}.t-ios-spinner{position:absolute;top:-.5rem;left:50%;margin-left:-1.125rem}.t-android-loader{position:absolute;top:-1.5rem;left:50%;margin-left:-1.125rem}.t-drop-animation{transition:all var(--tui-duration) cubic-bezier(.4,0,.2,1)}\n"], components: [{ type: TuiMobileLoaderIOSComponent, selector: "tui-mobile-ios-loader", inputs: ["pulled"] }, { type: TuiMobileLoaderAndroidComponent, selector: "tui-mobile-android-loader", inputs: ["pulled"] }], directives: [{ type: i1__namespace.TuiOverscrollDirective, selector: "[tuiOverscroll]", inputs: ["tuiOverscroll"] }, { type: i4__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i4__namespace.AsyncPipe }, changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
483
- __decorate([
484
- i1.tuiPure
485
- ], TuiPullToRefreshComponent.prototype, "loaderTransform$", null);
572
+ TuiPullToRefreshComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TuiPullToRefreshComponent, deps: [{ token: i1.TUI_IS_IOS }, { token: TUI_PULL_TO_REFRESH_THRESHOLD }, { token: TUI_PULL_TO_REFRESH_COMPONENT }, { token: TuiPullToRefreshService }], target: i0__namespace.ɵɵFactoryTarget.Component });
573
+ TuiPullToRefreshComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: TuiPullToRefreshComponent, selector: "tui-pull-to-refresh", outputs: { pulled: "pulled" }, providers: [TuiPullToRefreshService], ngImport: i0__namespace, template: "<div\n tuiOverscroll\n [class.t-drop-animation]=\"dropped$ | async\"\n [style.transform]=\"contentTransform$ | async\"\n>\n <ng-content></ng-content>\n</div>\n\n<ng-container *polymorpheusOutlet=\"component; context: {$implicit: (pulling$ | async) || 0}\"></ng-container>\n", styles: [":host{position:relative;display:block;overflow:hidden}.t-drop-animation{transition:all var(--tui-duration) cubic-bezier(.4,0,.2,1)}\n"], directives: [{ type: i1__namespace.TuiOverscrollDirective, selector: "[tuiOverscroll]", inputs: ["tuiOverscroll"] }, { type: i2__namespace$1.PolymorpheusOutletDirective, selector: "[polymorpheusOutlet]", inputs: ["polymorpheusOutlet", "polymorpheusOutletContext"] }], pipes: { "async": i2__namespace.AsyncPipe }, changeDetection: i0__namespace.ChangeDetectionStrategy.OnPush });
486
574
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TuiPullToRefreshComponent, decorators: [{
487
575
  type: i0.Component,
488
576
  args: [{
@@ -490,19 +578,25 @@
490
578
  templateUrl: './pull-to-refresh.template.html',
491
579
  styleUrls: ['./pull-to-refresh.style.less'],
492
580
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
493
- providers: TUI_PULL_TO_REFRESH_PROVIDERS,
581
+ providers: [TuiPullToRefreshService],
494
582
  }]
495
583
  }], ctorParameters: function () {
496
584
  return [{ type: undefined, decorators: [{
497
585
  type: i0.Inject,
498
586
  args: [i1.TUI_IS_IOS]
499
- }] }, { type: i5__namespace.Observable, decorators: [{
587
+ }] }, { type: undefined, decorators: [{
500
588
  type: i0.Inject,
501
- args: [TUI_PULLING]
589
+ args: [TUI_PULL_TO_REFRESH_THRESHOLD]
590
+ }] }, { type: undefined, decorators: [{
591
+ type: i0.Inject,
592
+ args: [TUI_PULL_TO_REFRESH_COMPONENT]
593
+ }] }, { type: i1__namespace$1.Observable, decorators: [{
594
+ type: i0.Inject,
595
+ args: [TuiPullToRefreshService]
502
596
  }] }];
503
597
  }, propDecorators: { pulled: [{
504
598
  type: i0.Output
505
- }], loaderTransform$: [] } });
599
+ }] } });
506
600
 
507
601
  var TuiPullToRefreshModule = /** @class */ (function () {
508
602
  function TuiPullToRefreshModule() {
@@ -512,12 +606,28 @@
512
606
  TuiPullToRefreshModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TuiPullToRefreshModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
513
607
  TuiPullToRefreshModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TuiPullToRefreshModule, declarations: [TuiPullToRefreshComponent,
514
608
  TuiMobileLoaderAndroidComponent,
515
- TuiMobileLoaderIOSComponent], imports: [i4.CommonModule, core.TuiSvgModule, i1.TuiOverscrollModule, i1.TuiRepeatTimesModule], exports: [TuiPullToRefreshComponent] });
516
- TuiPullToRefreshModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TuiPullToRefreshModule, imports: [[i4.CommonModule, core.TuiSvgModule, i1.TuiOverscrollModule, i1.TuiRepeatTimesModule]] });
609
+ TuiMobileLoaderIOSComponent], imports: [i2$1.CommonModule,
610
+ core.TuiSvgModule,
611
+ i1.TuiOverscrollModule,
612
+ i1.TuiRepeatTimesModule,
613
+ i2.PolymorpheusModule], exports: [TuiPullToRefreshComponent] });
614
+ TuiPullToRefreshModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TuiPullToRefreshModule, imports: [[
615
+ i2$1.CommonModule,
616
+ core.TuiSvgModule,
617
+ i1.TuiOverscrollModule,
618
+ i1.TuiRepeatTimesModule,
619
+ i2.PolymorpheusModule,
620
+ ]] });
517
621
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: TuiPullToRefreshModule, decorators: [{
518
622
  type: i0.NgModule,
519
623
  args: [{
520
- imports: [i4.CommonModule, core.TuiSvgModule, i1.TuiOverscrollModule, i1.TuiRepeatTimesModule],
624
+ imports: [
625
+ i2$1.CommonModule,
626
+ core.TuiSvgModule,
627
+ i1.TuiOverscrollModule,
628
+ i1.TuiRepeatTimesModule,
629
+ i2.PolymorpheusModule,
630
+ ],
521
631
  declarations: [
522
632
  TuiPullToRefreshComponent,
523
633
  TuiMobileLoaderAndroidComponent,
@@ -532,13 +642,17 @@
532
642
  */
533
643
 
534
644
  exports.MICRO_OFFSET = MICRO_OFFSET;
535
- exports.PULLED_DISTANCE = PULLED_DISTANCE;
536
- exports.TUI_PULLING = TUI_PULLING;
537
- exports.TUI_PULL_TO_REFRESH_PROVIDERS = TUI_PULL_TO_REFRESH_PROVIDERS;
645
+ exports.TUI_ANDROID_LOADER = TUI_ANDROID_LOADER;
646
+ exports.TUI_IOS_LOADER = TUI_IOS_LOADER;
647
+ exports.TUI_LOADED = TUI_LOADED;
648
+ exports.TUI_PULL_TO_REFRESH_COMPONENT = TUI_PULL_TO_REFRESH_COMPONENT;
649
+ exports.TUI_PULL_TO_REFRESH_LOADED = TUI_PULL_TO_REFRESH_LOADED;
650
+ exports.TUI_PULL_TO_REFRESH_THRESHOLD = TUI_PULL_TO_REFRESH_THRESHOLD;
538
651
  exports.TuiMobileLoaderAndroidComponent = TuiMobileLoaderAndroidComponent;
539
652
  exports.TuiMobileLoaderIOSComponent = TuiMobileLoaderIOSComponent;
540
653
  exports.TuiPullToRefreshComponent = TuiPullToRefreshComponent;
541
654
  exports.TuiPullToRefreshModule = TuiPullToRefreshModule;
655
+ exports.TuiPullToRefreshService = TuiPullToRefreshService;
542
656
 
543
657
  Object.defineProperty(exports, '__esModule', { value: true });
544
658