@taiga-ui/addon-mobile 2.88.0 → 2.90.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 (87) hide show
  1. package/bundles/taiga-ui-addon-mobile-components-pull-to-refresh.umd.js +229 -110
  2. package/bundles/taiga-ui-addon-mobile-components-pull-to-refresh.umd.js.map +1 -1
  3. package/bundles/taiga-ui-addon-mobile-components-pull-to-refresh.umd.min.js +1 -1
  4. package/bundles/taiga-ui-addon-mobile-components-pull-to-refresh.umd.min.js.map +1 -1
  5. package/bundles/taiga-ui-addon-mobile-components-sheet.umd.js +11 -3
  6. package/bundles/taiga-ui-addon-mobile-components-sheet.umd.js.map +1 -1
  7. package/bundles/taiga-ui-addon-mobile-components-sheet.umd.min.js +1 -1
  8. package/bundles/taiga-ui-addon-mobile-components-sheet.umd.min.js.map +1 -1
  9. package/bundles/taiga-ui-addon-mobile-directives-elastic-sticky.umd.js +14 -27
  10. package/bundles/taiga-ui-addon-mobile-directives-elastic-sticky.umd.js.map +1 -1
  11. package/bundles/taiga-ui-addon-mobile-directives-elastic-sticky.umd.min.js +1 -1
  12. package/bundles/taiga-ui-addon-mobile-directives-elastic-sticky.umd.min.js.map +1 -1
  13. package/bundles/taiga-ui-addon-mobile.umd.js +4 -12
  14. package/bundles/taiga-ui-addon-mobile.umd.js.map +1 -1
  15. package/bundles/taiga-ui-addon-mobile.umd.min.js +1 -1
  16. package/components/pull-to-refresh/index.d.ts +2 -0
  17. package/components/pull-to-refresh/loader-android/loader-android.component.d.ts +10 -2
  18. package/components/pull-to-refresh/loader-ios/loader-ios.component.d.ts +7 -1
  19. package/components/pull-to-refresh/pull-to-refresh.component.d.ts +10 -7
  20. package/components/pull-to-refresh/pull-to-refresh.providers.d.ts +15 -6
  21. package/components/pull-to-refresh/pull-to-refresh.service.d.ts +14 -0
  22. package/components/pull-to-refresh/pull-to-refresh.tokens.d.ts +5 -0
  23. package/components/pull-to-refresh/taiga-ui-addon-mobile-components-pull-to-refresh.metadata.json +1 -1
  24. package/components/sheet/sheet.service.d.ts +2 -1
  25. package/components/sheet/taiga-ui-addon-mobile-components-sheet.metadata.json +1 -1
  26. package/directives/elastic-sticky/elastic-sticky.service.d.ts +1 -2
  27. package/directives/elastic-sticky/taiga-ui-addon-mobile-directives-elastic-sticky.metadata.json +1 -1
  28. package/esm2015/components/pull-to-refresh/index.js +3 -1
  29. package/esm2015/components/pull-to-refresh/loader-android/loader-android.component.js +39 -16
  30. package/esm2015/components/pull-to-refresh/loader-ios/loader-ios.component.js +22 -13
  31. package/esm2015/components/pull-to-refresh/pull-to-refresh.component.js +46 -30
  32. package/esm2015/components/pull-to-refresh/pull-to-refresh.module.js +4 -3
  33. package/esm2015/components/pull-to-refresh/pull-to-refresh.providers.js +22 -27
  34. package/esm2015/components/pull-to-refresh/pull-to-refresh.service.js +52 -0
  35. package/esm2015/components/pull-to-refresh/pull-to-refresh.tokens.js +8 -0
  36. package/esm2015/components/sheet/sheet.service.js +16 -5
  37. package/esm2015/directives/elastic-sticky/elastic-sticky.service.js +12 -25
  38. package/esm2015/index.js +1 -2
  39. package/esm5/components/pull-to-refresh/index.js +3 -1
  40. package/esm5/components/pull-to-refresh/loader-android/loader-android.component.js +51 -16
  41. package/esm5/components/pull-to-refresh/loader-ios/loader-ios.component.js +26 -13
  42. package/esm5/components/pull-to-refresh/pull-to-refresh.component.js +48 -36
  43. package/esm5/components/pull-to-refresh/pull-to-refresh.module.js +4 -3
  44. package/esm5/components/pull-to-refresh/pull-to-refresh.providers.js +22 -32
  45. package/esm5/components/pull-to-refresh/pull-to-refresh.service.js +75 -0
  46. package/esm5/components/pull-to-refresh/pull-to-refresh.tokens.js +8 -0
  47. package/esm5/components/sheet/sheet.service.js +16 -5
  48. package/esm5/directives/elastic-sticky/elastic-sticky.service.js +13 -27
  49. package/esm5/index.js +1 -2
  50. package/fesm2015/taiga-ui-addon-mobile-components-pull-to-refresh.js +176 -90
  51. package/fesm2015/taiga-ui-addon-mobile-components-pull-to-refresh.js.map +1 -1
  52. package/fesm2015/taiga-ui-addon-mobile-components-sheet.js +12 -4
  53. package/fesm2015/taiga-ui-addon-mobile-components-sheet.js.map +1 -1
  54. package/fesm2015/taiga-ui-addon-mobile-directives-elastic-sticky.js +11 -24
  55. package/fesm2015/taiga-ui-addon-mobile-directives-elastic-sticky.js.map +1 -1
  56. package/fesm2015/taiga-ui-addon-mobile.js +0 -1
  57. package/fesm2015/taiga-ui-addon-mobile.js.map +1 -1
  58. package/fesm5/taiga-ui-addon-mobile-components-pull-to-refresh.js +226 -110
  59. package/fesm5/taiga-ui-addon-mobile-components-pull-to-refresh.js.map +1 -1
  60. package/fesm5/taiga-ui-addon-mobile-components-sheet.js +12 -4
  61. package/fesm5/taiga-ui-addon-mobile-components-sheet.js.map +1 -1
  62. package/fesm5/taiga-ui-addon-mobile-directives-elastic-sticky.js +12 -26
  63. package/fesm5/taiga-ui-addon-mobile-directives-elastic-sticky.js.map +1 -1
  64. package/fesm5/taiga-ui-addon-mobile.js +0 -1
  65. package/fesm5/taiga-ui-addon-mobile.js.map +1 -1
  66. package/index.d.ts +0 -1
  67. package/package.json +4 -4
  68. package/taiga-ui-addon-mobile.metadata.json +1 -1
  69. package/bundles/taiga-ui-addon-mobile-tokens.umd.js +0 -16
  70. package/bundles/taiga-ui-addon-mobile-tokens.umd.js.map +0 -1
  71. package/bundles/taiga-ui-addon-mobile-tokens.umd.min.js +0 -2
  72. package/bundles/taiga-ui-addon-mobile-tokens.umd.min.js.map +0 -1
  73. package/esm2015/tokens/index.js +0 -2
  74. package/esm2015/tokens/loaded.js +0 -6
  75. package/esm2015/tokens/taiga-ui-addon-mobile-tokens.js +0 -5
  76. package/esm5/tokens/index.js +0 -2
  77. package/esm5/tokens/loaded.js +0 -6
  78. package/esm5/tokens/taiga-ui-addon-mobile-tokens.js +0 -5
  79. package/fesm2015/taiga-ui-addon-mobile-tokens.js +0 -13
  80. package/fesm2015/taiga-ui-addon-mobile-tokens.js.map +0 -1
  81. package/fesm5/taiga-ui-addon-mobile-tokens.js +0 -13
  82. package/fesm5/taiga-ui-addon-mobile-tokens.js.map +0 -1
  83. package/tokens/index.d.ts +0 -1
  84. package/tokens/loaded.d.ts +0 -3
  85. package/tokens/package.json +0 -13
  86. package/tokens/taiga-ui-addon-mobile-tokens.d.ts +0 -4
  87. package/tokens/taiga-ui-addon-mobile-tokens.metadata.json +0 -1
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@taiga-ui/cdk'), require('rxjs'), require('rxjs/operators'), require('@taiga-ui/addon-mobile/tokens'), require('@angular/common'), require('@taiga-ui/core')) :
3
- typeof define === 'function' && define.amd ? define('@taiga-ui/addon-mobile/components/pull-to-refresh', ['exports', '@angular/core', '@taiga-ui/cdk', 'rxjs', 'rxjs/operators', '@taiga-ui/addon-mobile/tokens', '@angular/common', '@taiga-ui/core'], factory) :
4
- (global = 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.cdk, global.rxjs, global.rxjs.operators, global['taiga-ui']['addon-mobile'].tokens, global.ng.common, global.core$1));
5
- }(this, (function (exports, core, cdk, rxjs, operators, tokens, common, core$1) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@tinkoff/ng-polymorpheus'), require('@taiga-ui/cdk'), require('@taiga-ui/core'), require('rxjs'), require('rxjs/operators'), require('@angular/common')) :
3
+ typeof define === 'function' && define.amd ? define('@taiga-ui/addon-mobile/components/pull-to-refresh', ['exports', '@angular/core', '@tinkoff/ng-polymorpheus', '@taiga-ui/cdk', '@taiga-ui/core', 'rxjs', 'rxjs/operators', '@angular/common'], factory) :
4
+ (global = 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.ngPolymorpheus, global.cdk, global.core$1, global.rxjs, global.rxjs.operators, global.ng.common));
5
+ }(this, (function (exports, core, ngPolymorpheus, cdk, core$1, rxjs, operators, common) { 'use strict';
6
6
 
7
7
  /******************************************************************************
8
8
  Copyright (c) Microsoft Corporation.
@@ -298,62 +298,37 @@
298
298
  return typeof state === "function" ? receiver === state : state.has(receiver);
299
299
  }
300
300
 
301
- var HIDDEN_DISTANCE = 2;
302
- var ROTATE_X_DEFAULT = 180;
303
- var ROTATE_X_MAX = 500;
304
- var ROTATE_X_MULTIPLIER = 2.3;
305
- var TuiMobileLoaderAndroidComponent = /** @class */ (function () {
306
- function TuiMobileLoaderAndroidComponent() {
307
- this.pulled = 0;
308
- }
309
- Object.defineProperty(TuiMobileLoaderAndroidComponent.prototype, "transform", {
310
- get: function () {
311
- var rotateX = Math.min(ROTATE_X_DEFAULT + this.pulled * ROTATE_X_MULTIPLIER, ROTATE_X_MAX);
312
- return "rotate(" + rotateX + " 0 0)";
313
- },
314
- enumerable: true,
315
- configurable: true
316
- });
317
- Object.defineProperty(TuiMobileLoaderAndroidComponent.prototype, "hidden", {
318
- get: function () {
319
- return this.pulled < HIDDEN_DISTANCE;
320
- },
321
- enumerable: true,
322
- configurable: true
323
- });
324
- __decorate([
325
- core.Input()
326
- ], TuiMobileLoaderAndroidComponent.prototype, "pulled", void 0);
327
- __decorate([
328
- core.HostBinding('class._hidden')
329
- ], TuiMobileLoaderAndroidComponent.prototype, "hidden", null);
330
- TuiMobileLoaderAndroidComponent = __decorate([
331
- core.Component({
332
- selector: 'tui-mobile-android-loader',
333
- 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",
334
- changeDetection: core.ChangeDetectionStrategy.OnPush,
335
- styles: [":host{box-shadow:0 .5rem 1rem rgba(0,0,0,.16);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:none}.t-loading{display:block;width:1rem;border-radius:100%;animation:3s linear infinite tuiLoaderRotate}.t-circle{fill:none;stroke:var(--tui-text-01);stroke-width:1.5rem;animation:3s linear infinite tuiLoaderDashOffset}"]
336
- })
337
- ], TuiMobileLoaderAndroidComponent);
338
- return TuiMobileLoaderAndroidComponent;
339
- }());
301
+ /**
302
+ * Pull threshold in pixels until loading starts
303
+ */
304
+ var TUI_PULL_TO_REFRESH_THRESHOLD = new core.InjectionToken("[TUI_PULL_TO_REFRESH_THRESHOLD]", {
305
+ factory: function () { return 50; },
306
+ });
340
307
 
341
308
  var LOADED_STEP = 8;
342
309
  var ROTATE_X_STEP = 30;
343
310
  var TuiMobileLoaderIOSComponent = /** @class */ (function () {
344
- function TuiMobileLoaderIOSComponent() {
345
- this.pulled = 0;
311
+ function TuiMobileLoaderIOSComponent(context, threshold) {
312
+ this.context = context;
313
+ this.threshold = threshold;
346
314
  this.steps = 12;
347
315
  }
348
316
  Object.defineProperty(TuiMobileLoaderIOSComponent.prototype, "finished", {
349
317
  get: function () {
350
- return this.pulled >= 100;
318
+ return this.percent >= 100;
319
+ },
320
+ enumerable: true,
321
+ configurable: true
322
+ });
323
+ Object.defineProperty(TuiMobileLoaderIOSComponent.prototype, "percent", {
324
+ get: function () {
325
+ return (this.context.$implicit * 100) / this.threshold;
351
326
  },
352
327
  enumerable: true,
353
328
  configurable: true
354
329
  });
355
330
  TuiMobileLoaderIOSComponent.prototype.isShown = function (index) {
356
- return this.pulled > (index + 1) * LOADED_STEP;
331
+ return this.percent > (index + 1) * LOADED_STEP;
357
332
  };
358
333
  TuiMobileLoaderIOSComponent.prototype.calculateTransform = function (index) {
359
334
  return "rotate(" + index * ROTATE_X_STEP + " 50 50)";
@@ -361,92 +336,233 @@
361
336
  TuiMobileLoaderIOSComponent.prototype.calculateAnimationBegin = function (index) {
362
337
  return (index * LOADED_STEP) / 100 + "s";
363
338
  };
364
- __decorate([
365
- core.Input()
366
- ], TuiMobileLoaderIOSComponent.prototype, "pulled", void 0);
339
+ TuiMobileLoaderIOSComponent.ctorParameters = function () { return [
340
+ { type: undefined, decorators: [{ type: core.Inject, args: [ngPolymorpheus.POLYMORPHEUS_CONTEXT,] }] },
341
+ { type: Number, decorators: [{ type: core.Inject, args: [TUI_PULL_TO_REFRESH_THRESHOLD,] }] }
342
+ ]; };
367
343
  TuiMobileLoaderIOSComponent = __decorate([
368
344
  core.Component({
369
345
  selector: 'tui-mobile-ios-loader',
370
346
  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",
371
347
  changeDetection: core.ChangeDetectionStrategy.OnPush,
372
- providers: [cdk.TuiDestroyService]
373
- })
348
+ styles: [":host{position:absolute;top:-.5rem;left:50%;margin-left:-1.125rem}"]
349
+ }),
350
+ __param(0, core.Inject(ngPolymorpheus.POLYMORPHEUS_CONTEXT)),
351
+ __param(1, core.Inject(TUI_PULL_TO_REFRESH_THRESHOLD))
374
352
  ], TuiMobileLoaderIOSComponent);
375
353
  return TuiMobileLoaderIOSComponent;
376
354
  }());
355
+ var TUI_IOS_LOADER = new ngPolymorpheus.PolymorpheusComponent(TuiMobileLoaderIOSComponent);
356
+
357
+ /**
358
+ * Stream that emits when loading is over
359
+ */
360
+ var TUI_PULL_TO_REFRESH_LOADED = new core.InjectionToken("[TUI_PULL_TO_REFRESH_LOADED]", {
361
+ factory: function () { return rxjs.EMPTY; },
362
+ });
363
+ /**
364
+ * Loading indicator component that gets current pull distance in pixels as context
365
+ */
366
+ var TUI_PULL_TO_REFRESH_COMPONENT = new core.InjectionToken("[TUI_PULL_TO_REFRESH_COMPONENT]", {
367
+ factory: function () { return (core.inject(cdk.TUI_IS_IOS) ? TUI_IOS_LOADER : TUI_ANDROID_LOADER); },
368
+ });
369
+ /**
370
+ * @deprecated renamed to {@link TUI_PULL_TO_REFRESH_LOADED}
371
+ */
372
+ var TUI_LOADED = TUI_PULL_TO_REFRESH_LOADED;
377
373
 
378
374
  var MICRO_OFFSET = Math.pow(10, -6);
379
- var PULLED_DISTANCE = 50;
380
- var TUI_PULLING = new core.InjectionToken("Stream that emits content pulling");
381
- var TUI_PULL_TO_REFRESH_PROVIDERS = [
382
- {
383
- provide: TUI_PULLING,
384
- deps: [cdk.TUI_IS_IOS, tokens.TUI_LOADED, core.ElementRef],
385
- useFactory: pullingFactory,
386
- },
387
- ];
388
- // eslint-disable-next-line @typescript-eslint/naming-convention
389
- function pullingFactory(isIOS, loaded$, _a) {
390
- var nativeElement = _a.nativeElement;
391
- return rxjs.merge(cdk.typedFromEvent(nativeElement, "touchstart", { passive: true }).pipe(operators.filter(function () { return nativeElement.scrollTop === 0; }), operators.switchMap(function (touchStart) {
392
- return cdk.typedFromEvent(nativeElement, "touchmove").pipe(operators.map(function (touchMove) {
393
- return touchMove.touches[0].clientY - touchStart.touches[0].clientY;
394
- }), operators.takeUntil(cdk.typedFromEvent(nativeElement, "touchend")), operators.endWith(0));
395
- })), loaded$.pipe(operators.mapTo(NaN))).pipe(operators.scan(function (max, current) {
396
- if (Number.isNaN(current)) {
397
- return 0;
398
- }
399
- var androidLoading = !isIOS && max === PULLED_DISTANCE;
400
- var dropped = current === 0 && max > PULLED_DISTANCE;
401
- return androidLoading || dropped ? PULLED_DISTANCE : current + MICRO_OFFSET;
402
- }, 0));
403
- }
375
+ // @dynamic
376
+ var TuiPullToRefreshService = /** @class */ (function (_super) {
377
+ __extends(TuiPullToRefreshService, _super);
378
+ function TuiPullToRefreshService(el, scrollRef, loaded$, threshold, component) {
379
+ var _this = _super.call(this, function (subscriber) { return (component ? _this.pulling$ : rxjs.EMPTY).subscribe(subscriber); }) || this;
380
+ _this.el = el;
381
+ _this.scrollRef = scrollRef;
382
+ _this.loaded$ = loaded$;
383
+ _this.threshold = threshold;
384
+ // Hack for iOS to determine if pulling stopped due to scroll
385
+ // because Safari does not support `touch-action: pan-down`
386
+ _this.touched = false;
387
+ _this.pulling$ = _this.loaded$.pipe(operators.startWith(null), operators.switchMap(function () {
388
+ return cdk.tuiTypedFromEvent(_this.element, "touchstart", { passive: true }).pipe(operators.filter(function () { return !_this.scrollTop; }), operators.map(function (_a) {
389
+ var touches = _a.touches;
390
+ return touches[0].clientY;
391
+ }), operators.switchMap(function (start) {
392
+ return cdk.tuiTypedFromEvent(_this.element, "touchmove").pipe(operators.tap(function () {
393
+ _this.touched = true;
394
+ }), operators.map(function (_a) {
395
+ var touches = _a.touches;
396
+ return touches[0].clientY - start;
397
+ }), operators.filter(function (distance) { return distance > 0; }), operators.takeUntil(cdk.tuiTypedFromEvent(_this.element, "touchend").pipe(operators.tap(function () {
398
+ _this.touched = false;
399
+ }))), operators.takeUntil(cdk.tuiScrollFrom(_this.scrollRef.nativeElement)), operators.endWith(0));
400
+ }), operators.scan(function (prev, current) {
401
+ return !current && !_this.touched && prev > _this.threshold
402
+ ? _this.threshold
403
+ : current + current * MICRO_OFFSET;
404
+ }, 0), operators.takeWhile(function (distance) { return distance !== _this.threshold; }, true), operators.startWith(0));
405
+ }), operators.distinctUntilChanged(), operators.share());
406
+ return _this;
407
+ }
408
+ Object.defineProperty(TuiPullToRefreshService.prototype, "element", {
409
+ get: function () {
410
+ return this.el.nativeElement;
411
+ },
412
+ enumerable: true,
413
+ configurable: true
414
+ });
415
+ Object.defineProperty(TuiPullToRefreshService.prototype, "scrollTop", {
416
+ get: function () {
417
+ return this.scrollRef.nativeElement.scrollTop;
418
+ },
419
+ enumerable: true,
420
+ configurable: true
421
+ });
422
+ TuiPullToRefreshService.ctorParameters = function () { return [
423
+ { type: core.ElementRef, decorators: [{ type: core.Inject, args: [core.ElementRef,] }] },
424
+ { type: core.ElementRef, decorators: [{ type: core.Inject, args: [core$1.TUI_SCROLL_REF,] }] },
425
+ { type: rxjs.Observable, decorators: [{ type: core.Inject, args: [TUI_PULL_TO_REFRESH_LOADED,] }] },
426
+ { type: Number, decorators: [{ type: core.Inject, args: [TUI_PULL_TO_REFRESH_THRESHOLD,] }] },
427
+ { type: undefined, decorators: [{ type: core.Inject, args: [TUI_PULL_TO_REFRESH_COMPONENT,] }] }
428
+ ]; };
429
+ TuiPullToRefreshService = __decorate([
430
+ core.Injectable(),
431
+ __param(0, core.Inject(core.ElementRef)),
432
+ __param(1, core.Inject(core$1.TUI_SCROLL_REF)),
433
+ __param(2, core.Inject(TUI_PULL_TO_REFRESH_LOADED)),
434
+ __param(3, core.Inject(TUI_PULL_TO_REFRESH_THRESHOLD)),
435
+ __param(4, core.Inject(TUI_PULL_TO_REFRESH_COMPONENT))
436
+ ], TuiPullToRefreshService);
437
+ return TuiPullToRefreshService;
438
+ }(rxjs.Observable));
404
439
 
405
- var IOS_LOADING_DISTANCE = PULLED_DISTANCE / 2;
406
- var ANDROID_MAX_DISTANCE = PULLED_DISTANCE * 1.5;
407
- function translateY(distance) {
408
- return "translateY(" + distance + "px)";
409
- }
410
- var TuiPullToRefreshComponent = /** @class */ (function () {
411
- function TuiPullToRefreshComponent(isIOS, pulling$) {
412
- this.isIOS = isIOS;
413
- this.pulling$ = pulling$;
414
- this.pulled = this.pulling$.pipe(operators.distinctUntilChanged(), operators.filter(function (distance) { return distance === PULLED_DISTANCE; }), operators.mapTo(undefined));
415
- this.pulledInPercent$ = this.pulling$.pipe(operators.map(function (distance) { return (distance * 100) / PULLED_DISTANCE; }));
416
- this.dropped$ = this.pulling$.pipe(operators.map(function (distance) { return distance <= MICRO_OFFSET || distance === PULLED_DISTANCE; }), operators.distinctUntilChanged());
417
- this.contentTransform$ = this.isIOS
418
- ? this.pulling$.pipe(operators.map(function (distance) {
419
- return distance === PULLED_DISTANCE ? IOS_LOADING_DISTANCE : distance;
420
- }), operators.map(translateY))
421
- : rxjs.of(null);
440
+ var ROTATE_X_DEFAULT = 180;
441
+ var ROTATE_X_MAX = 500;
442
+ var ROTATE_X_MULTIPLIER = 2.3;
443
+ var TuiMobileLoaderAndroidComponent = /** @class */ (function () {
444
+ function TuiMobileLoaderAndroidComponent(context, threshold) {
445
+ this.context = context;
446
+ this.threshold = threshold;
422
447
  }
423
- Object.defineProperty(TuiPullToRefreshComponent.prototype, "loaderTransform$", {
448
+ Object.defineProperty(TuiMobileLoaderAndroidComponent.prototype, "transform", {
449
+ get: function () {
450
+ var rotateX = Math.min(ROTATE_X_DEFAULT + this.percent * ROTATE_X_MULTIPLIER, ROTATE_X_MAX);
451
+ return "rotate(" + rotateX + " 0 0)";
452
+ },
453
+ enumerable: true,
454
+ configurable: true
455
+ });
456
+ Object.defineProperty(TuiMobileLoaderAndroidComponent.prototype, "percent", {
457
+ get: function () {
458
+ return (this.context.$implicit * 100) / this.threshold;
459
+ },
460
+ enumerable: true,
461
+ configurable: true
462
+ });
463
+ Object.defineProperty(TuiMobileLoaderAndroidComponent.prototype, "opacity", {
464
+ get: function () {
465
+ return this.context.$implicit / (this.threshold * 1.5);
466
+ },
467
+ enumerable: true,
468
+ configurable: true
469
+ });
470
+ Object.defineProperty(TuiMobileLoaderAndroidComponent.prototype, "dropped", {
424
471
  get: function () {
425
- return this.pulling$.pipe(operators.map(function (distance) { return translateY(Math.min(distance, ANDROID_MAX_DISTANCE)); }));
472
+ return (this.context.$implicit <= MICRO_OFFSET ||
473
+ this.context.$implicit === this.threshold);
426
474
  },
427
475
  enumerable: true,
428
476
  configurable: true
429
477
  });
478
+ Object.defineProperty(TuiMobileLoaderAndroidComponent.prototype, "hostTransform", {
479
+ get: function () {
480
+ return "translateY(" + Math.min(this.context.$implicit, this.threshold * 1.5) + "px)";
481
+ },
482
+ enumerable: true,
483
+ configurable: true
484
+ });
485
+ TuiMobileLoaderAndroidComponent.ctorParameters = function () { return [
486
+ { type: undefined, decorators: [{ type: core.Inject, args: [ngPolymorpheus.POLYMORPHEUS_CONTEXT,] }] },
487
+ { type: Number, decorators: [{ type: core.Inject, args: [TUI_PULL_TO_REFRESH_THRESHOLD,] }] }
488
+ ]; };
489
+ __decorate([
490
+ core.HostBinding('class._visible')
491
+ ], TuiMobileLoaderAndroidComponent.prototype, "percent", null);
492
+ __decorate([
493
+ core.HostBinding('class._dropped')
494
+ ], TuiMobileLoaderAndroidComponent.prototype, "dropped", null);
495
+ __decorate([
496
+ core.HostBinding('style.transform')
497
+ ], TuiMobileLoaderAndroidComponent.prototype, "hostTransform", null);
498
+ TuiMobileLoaderAndroidComponent = __decorate([
499
+ core.Component({
500
+ selector: 'tui-mobile-android-loader',
501
+ template: "<div class=\"t-wrapper\">\n <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</div>\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",
502
+ changeDetection: core.ChangeDetectionStrategy.OnPush,
503
+ styles: [":host{transition-property:opacity;transition-duration:var(--tui-duration,300ms);transition-timing-function:ease-in-out;position:-webkit-sticky;position:sticky;top:0;z-index:1;display:block;height:0;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-wrapper{box-shadow:0 .5rem 1rem rgba(0,0,0,.16);position:absolute;top:-2.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}.t-loading{display:block;width:1rem;border-radius:100%;animation:3s linear infinite tuiLoaderRotate}.t-circle{fill:none;stroke:var(--tui-text-01);stroke-width:1.5rem;animation:3s linear infinite tuiLoaderDashOffset}@keyframes tuiLoaderDashOffset{0%,100%{stroke-dashoffset:-66}50%{stroke-dashoffset:-314}}@keyframes tuiLoaderRotate{0%{transform:rotate(0)}50%{transform:rotate(1turn)}100%{transform:rotate(3turn)}}"]
504
+ }),
505
+ __param(0, core.Inject(ngPolymorpheus.POLYMORPHEUS_CONTEXT)),
506
+ __param(1, core.Inject(TUI_PULL_TO_REFRESH_THRESHOLD))
507
+ ], TuiMobileLoaderAndroidComponent);
508
+ return TuiMobileLoaderAndroidComponent;
509
+ }());
510
+ var TUI_ANDROID_LOADER = new ngPolymorpheus.PolymorpheusComponent(TuiMobileLoaderAndroidComponent);
511
+
512
+ var TuiPullToRefreshComponent = /** @class */ (function () {
513
+ function TuiPullToRefreshComponent(destroy$, _a, isIOS, threshold, component, pulling$) {
514
+ var _this = this;
515
+ var nativeElement = _a.nativeElement;
516
+ this.isIOS = isIOS;
517
+ this.threshold = threshold;
518
+ this.component = component;
519
+ this.pulling$ = pulling$;
520
+ this.styleHandler = this.isIOS
521
+ ? function (distance) { return ({ transform: "translateY(" + distance / 2 + "px)" }); }
522
+ : function () { return null; };
523
+ this.pulled = this.pulling$.pipe(operators.filter(function (distance) { return distance === _this.threshold; }));
524
+ this.dropped$ = this.pulling$.pipe(operators.map(function (distance) { return distance <= MICRO_OFFSET || distance === _this.threshold; }), operators.distinctUntilChanged());
525
+ // Ensure scrolling down is impossible while pulling
526
+ cdk.tuiScrollFrom(nativeElement)
527
+ .pipe(operators.startWith(null), operators.takeUntil(destroy$))
528
+ .subscribe(function () {
529
+ if (nativeElement.scrollTop) {
530
+ nativeElement.style.touchAction = '';
531
+ }
532
+ else {
533
+ nativeElement.style.touchAction = 'pan-down';
534
+ }
535
+ });
536
+ }
430
537
  TuiPullToRefreshComponent.ctorParameters = function () { return [
538
+ { type: rxjs.Observable, decorators: [{ type: core.Inject, args: [cdk.TuiDestroyService,] }, { type: core.Self }] },
539
+ { type: core.ElementRef, decorators: [{ type: core.Inject, args: [core$1.TUI_SCROLL_REF,] }] },
431
540
  { type: Boolean, decorators: [{ type: core.Inject, args: [cdk.TUI_IS_IOS,] }] },
432
- { type: rxjs.Observable, decorators: [{ type: core.Inject, args: [TUI_PULLING,] }] }
541
+ { type: Number, decorators: [{ type: core.Inject, args: [TUI_PULL_TO_REFRESH_THRESHOLD,] }] },
542
+ { type: undefined, decorators: [{ type: core.Inject, args: [TUI_PULL_TO_REFRESH_COMPONENT,] }] },
543
+ { type: rxjs.Observable, decorators: [{ type: core.Inject, args: [TuiPullToRefreshService,] }] }
433
544
  ]; };
545
+ __decorate([
546
+ core.Input(),
547
+ cdk.tuiDefaultProp()
548
+ ], TuiPullToRefreshComponent.prototype, "styleHandler", void 0);
434
549
  __decorate([
435
550
  core.Output()
436
551
  ], TuiPullToRefreshComponent.prototype, "pulled", void 0);
437
- __decorate([
438
- cdk.tuiPure
439
- ], TuiPullToRefreshComponent.prototype, "loaderTransform$", null);
440
552
  TuiPullToRefreshComponent = __decorate([
441
553
  core.Component({
442
554
  selector: 'tui-pull-to-refresh',
443
- 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",
555
+ template: "<div\n polymorpheus-outlet\n [content]=\"component\"\n [context]=\"{$implicit: (pulling$ | async) || 0}\"\n></div>\n\n<div\n [class.t-drop]=\"dropped$ | async\"\n [ngStyle]=\"styleHandler((pulling$ | async) || 0)\"\n>\n <ng-content></ng-content>\n</div>\n",
444
556
  changeDetection: core.ChangeDetectionStrategy.OnPush,
445
- providers: [TUI_PULL_TO_REFRESH_PROVIDERS],
446
- 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)}"]
557
+ providers: [TuiPullToRefreshService, cdk.TuiDestroyService],
558
+ styles: [".t-drop{transition:all var(--tui-duration) cubic-bezier(.4,0,.2,1)}"]
447
559
  }),
448
- __param(0, core.Inject(cdk.TUI_IS_IOS)),
449
- __param(1, core.Inject(TUI_PULLING))
560
+ __param(0, core.Inject(cdk.TuiDestroyService)), __param(0, core.Self()),
561
+ __param(1, core.Inject(core$1.TUI_SCROLL_REF)),
562
+ __param(2, core.Inject(cdk.TUI_IS_IOS)),
563
+ __param(3, core.Inject(TUI_PULL_TO_REFRESH_THRESHOLD)),
564
+ __param(4, core.Inject(TUI_PULL_TO_REFRESH_COMPONENT)),
565
+ __param(5, core.Inject(TuiPullToRefreshService))
450
566
  ], TuiPullToRefreshComponent);
451
567
  return TuiPullToRefreshComponent;
452
568
  }());
@@ -456,7 +572,7 @@
456
572
  }
457
573
  TuiPullToRefreshModule = __decorate([
458
574
  core.NgModule({
459
- imports: [common.CommonModule, core$1.TuiSvgModule, cdk.TuiOverscrollModule, cdk.TuiRepeatTimesModule],
575
+ imports: [common.CommonModule, core$1.TuiSvgModule, cdk.TuiRepeatTimesModule, ngPolymorpheus.PolymorpheusModule],
460
576
  declarations: [
461
577
  TuiPullToRefreshComponent,
462
578
  TuiMobileLoaderAndroidComponent,
@@ -469,14 +585,17 @@
469
585
  }());
470
586
 
471
587
  exports.MICRO_OFFSET = MICRO_OFFSET;
472
- exports.PULLED_DISTANCE = PULLED_DISTANCE;
473
- exports.TUI_PULLING = TUI_PULLING;
474
- exports.TUI_PULL_TO_REFRESH_PROVIDERS = TUI_PULL_TO_REFRESH_PROVIDERS;
588
+ exports.TUI_ANDROID_LOADER = TUI_ANDROID_LOADER;
589
+ exports.TUI_IOS_LOADER = TUI_IOS_LOADER;
590
+ exports.TUI_LOADED = TUI_LOADED;
591
+ exports.TUI_PULL_TO_REFRESH_COMPONENT = TUI_PULL_TO_REFRESH_COMPONENT;
592
+ exports.TUI_PULL_TO_REFRESH_LOADED = TUI_PULL_TO_REFRESH_LOADED;
593
+ exports.TUI_PULL_TO_REFRESH_THRESHOLD = TUI_PULL_TO_REFRESH_THRESHOLD;
475
594
  exports.TuiMobileLoaderAndroidComponent = TuiMobileLoaderAndroidComponent;
476
595
  exports.TuiMobileLoaderIOSComponent = TuiMobileLoaderIOSComponent;
477
596
  exports.TuiPullToRefreshComponent = TuiPullToRefreshComponent;
478
597
  exports.TuiPullToRefreshModule = TuiPullToRefreshModule;
479
- exports.pullingFactory = pullingFactory;
598
+ exports.TuiPullToRefreshService = TuiPullToRefreshService;
480
599
 
481
600
  Object.defineProperty(exports, '__esModule', { value: true });
482
601