@taiga-ui/addon-doc 2.51.1 → 2.52.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.
@@ -1084,6 +1084,10 @@
1084
1084
  return TuiDocDocumentationModule;
1085
1085
  }());
1086
1086
 
1087
+ var TUI_DOC_CODE_ACTIONS = new core.InjectionToken('Code actions for the opened tab with code example', {
1088
+ factory: function () { return ''; },
1089
+ });
1090
+
1087
1091
  var TUI_DOC_CODE_EDITOR = new core.InjectionToken('Contains service for opening online IDE e.g. Stackblitz');
1088
1092
 
1089
1093
  var TUI_DOC_EXAMPLE_CONTENT_PROCESSOR = new core.InjectionToken('Processes content in example', { factory: function () { return rxjs.identity; } });
@@ -1134,7 +1138,7 @@
1134
1138
  // Ambient type cannot be used without dynamic https://github.com/angular/angular/issues/23395
1135
1139
  // @dynamic
1136
1140
  var TuiDocExampleComponent = /** @class */ (function () {
1137
- function TuiDocExampleComponent(id, clipboard, notifications, location, copyTexts$, texts, codeEditor, processContent, isCypress) {
1141
+ function TuiDocExampleComponent(id, clipboard, notifications, location, copyTexts$, texts, codeEditor, processContent, isCypress, codeActions) {
1138
1142
  var _this = this;
1139
1143
  this.id = id;
1140
1144
  this.clipboard = clipboard;
@@ -1145,6 +1149,7 @@
1145
1149
  this.codeEditor = codeEditor;
1146
1150
  this.processContent = processContent;
1147
1151
  this.isCypress = isCypress;
1152
+ this.codeActions = codeActions;
1148
1153
  this.rawLoader$$ = new rxjs.BehaviorSubject({});
1149
1154
  this.heading = '';
1150
1155
  this.description = '';
@@ -1195,7 +1200,8 @@
1195
1200
  { type: Array, decorators: [{ type: core.Inject, args: [TUI_DOC_EXAMPLE_TEXTS,] }] },
1196
1201
  { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [TUI_DOC_CODE_EDITOR,] }] },
1197
1202
  { type: undefined, decorators: [{ type: core.Inject, args: [TUI_DOC_EXAMPLE_CONTENT_PROCESSOR,] }] },
1198
- { type: Boolean, decorators: [{ type: core.Inject, args: [cdk.TUI_IS_CYPRESS,] }] }
1203
+ { type: Boolean, decorators: [{ type: core.Inject, args: [cdk.TUI_IS_CYPRESS,] }] },
1204
+ { type: Array, decorators: [{ type: core.Inject, args: [TUI_DOC_CODE_ACTIONS,] }] }
1199
1205
  ]; };
1200
1206
  __decorate([
1201
1207
  core.Input()
@@ -1212,9 +1218,9 @@
1212
1218
  TuiDocExampleComponent = __decorate([
1213
1219
  core.Component({
1214
1220
  selector: 'tui-doc-example',
1215
- template: "<h3\n *ngIf=\"heading\"\n class=\"t-title\"\n>\n <span\n polymorpheus-outlet\n [content]=\"heading | tuiDocExampleCapitalize\"\n ></span>\n <button\n *ngIf=\"id\"\n tuiIconButton\n type=\"button\"\n size=\"xs\"\n icon=\"tuiIconLinkLarge\"\n appearance=\"icon\"\n class=\"t-link-icon\"\n [title]=\"copy$ | async\"\n (click)=\"copyExampleLink()\"\n ></button>\n</h3>\n<h4\n *ngIf=\"description\"\n polymorpheus-outlet\n class=\"t-description\"\n [content]=\"description | tuiDocExampleCapitalize\"\n></h4>\n\n<div\n *ngIf=\"processor$ | async as files\"\n class=\"t-example\"\n>\n <ng-container *ngIf=\"files | tuiDocExampleGetTabs: defaultTab as tabs\">\n <div class=\"t-tabs-wrapper\">\n <tui-tabs-with-more\n class=\"t-tabs\"\n [(activeItemIndex)]=\"activeItemIndex\"\n >\n <ng-container *ngFor=\"let tab of tabs\">\n <button\n *tuiTab\n tuiTab\n >\n {{tab}}\n </button>\n </ng-container>\n </tui-tabs-with-more>\n\n <button\n *ngIf=\"codeEditor\"\n tuiButton\n appearance=\"flat\"\n size=\"s\"\n [showLoader]=\"!!(loading$ | async)\"\n (click)=\"edit(files)\"\n >\n Edit on {{codeEditor.name}}\n </button>\n </div>\n\n <div\n *ngFor=\"let tab of tabs; let index = index\"\n class=\"t-content\"\n [class.t-content_animated]=\"!isCypress\"\n [class.t-content_visible]=\"activeItemIndex === index\"\n >\n <ng-container *ngIf=\"index === defaultTabIndex; else anotherTab\">\n <ng-container *ngTemplateOutlet=\"preview\"></ng-container>\n </ng-container>\n <ng-template #anotherTab>\n <ng-container\n *ngTemplateOutlet=\"codeSection; context: { $implicit: files[tabs[activeItemIndex]] || '' }\"\n ></ng-container>\n </ng-template>\n </div>\n </ng-container>\n</div>\n\n<ng-template #preview>\n <div\n automation-id=\"tui-doc-example\"\n class=\"t-demo\"\n >\n <ng-content></ng-content>\n </div>\n</ng-template>\n\n<ng-template\n #codeSection\n let-code\n>\n <tui-doc-copy\n class=\"t-copy-code\"\n [cdkCopyToClipboard]=\"code\"\n ></tui-doc-copy>\n <tui-doc-code [code]=\"code\"></tui-doc-code>\n</ng-template>\n",
1221
+ template: "<h3\n *ngIf=\"heading\"\n class=\"t-title\"\n>\n <span\n polymorpheus-outlet\n [content]=\"heading | tuiDocExampleCapitalize\"\n ></span>\n <button\n *ngIf=\"id\"\n tuiIconButton\n type=\"button\"\n size=\"xs\"\n icon=\"tuiIconLinkLarge\"\n appearance=\"icon\"\n class=\"t-link-icon\"\n [title]=\"copy$ | async\"\n (click)=\"copyExampleLink()\"\n ></button>\n</h3>\n<h4\n *ngIf=\"description\"\n polymorpheus-outlet\n class=\"t-description\"\n [content]=\"description | tuiDocExampleCapitalize\"\n></h4>\n\n<div\n *ngIf=\"processor$ | async as files\"\n class=\"t-example\"\n>\n <ng-container *ngIf=\"files | tuiDocExampleGetTabs: defaultTab as tabs\">\n <div class=\"t-tabs-wrapper\">\n <tui-tabs-with-more\n class=\"t-tabs\"\n [(activeItemIndex)]=\"activeItemIndex\"\n >\n <ng-container *ngFor=\"let tab of tabs\">\n <button\n *tuiTab\n tuiTab\n >\n {{tab}}\n </button>\n </ng-container>\n </tui-tabs-with-more>\n\n <button\n *ngIf=\"codeEditor\"\n tuiButton\n appearance=\"flat\"\n size=\"s\"\n [showLoader]=\"!!(loading$ | async)\"\n (click)=\"edit(files)\"\n >\n Edit on {{codeEditor.name}}\n </button>\n </div>\n\n <div\n *ngFor=\"let tab of tabs; let index = index\"\n class=\"t-content\"\n [class.t-content_animated]=\"!isCypress\"\n [class.t-content_visible]=\"activeItemIndex === index\"\n >\n <ng-container *ngIf=\"index === defaultTabIndex; else anotherTab\">\n <ng-container *ngTemplateOutlet=\"preview\"></ng-container>\n </ng-container>\n <ng-template #anotherTab>\n <ng-container\n *ngTemplateOutlet=\"codeSection; context: { $implicit: files[tabs[activeItemIndex]] || '' }\"\n ></ng-container>\n </ng-template>\n </div>\n </ng-container>\n</div>\n\n<ng-template #preview>\n <div\n automation-id=\"tui-doc-example\"\n class=\"t-demo\"\n >\n <ng-content></ng-content>\n </div>\n</ng-template>\n\n<ng-template\n #codeSection\n let-code\n>\n <section class=\"t-code-actions\">\n <ng-container *ngFor=\"let action of codeActions\">\n <div\n polymorpheus-outlet\n [content]=\"action\"\n [context]=\"{$implicit: code}\"\n ></div>\n </ng-container>\n <tui-doc-copy [cdkCopyToClipboard]=\"code\"></tui-doc-copy>\n </section>\n <tui-doc-code [code]=\"code\"></tui-doc-code>\n</ng-template>\n",
1216
1222
  changeDetection: core.ChangeDetectionStrategy.OnPush,
1217
- styles: [":host{position:relative;display:block;padding-top:3.5rem;clear:right}:host :host-context(tui-root._mobile){padding-top:2rem}.t-title{font:var(--tui-font-heading-5);margin:0 0 .5rem}:host-context(tui-root._mobile) .t-title{font:var(--tui-font-heading-6)}.t-description{font:var(--tui-font-text-m);font-weight:400;margin:0}.t-example{position:relative;margin-top:1.5rem;border:1px solid var(--tui-base-03);border-radius:var(--tui-radius-m);box-shadow:0 .125rem .1875rem rgba(0,0,0,.1)}:host-context(tui-root._mobile) .t-example{margin-top:.75rem}.t-tabs-wrapper{display:flex;padding:0 2rem;box-shadow:inset 0 -1px var(--tui-base-03);justify-content:space-between;align-items:center}:host-context(tui-root._mobile) .t-tabs-wrapper{padding:0 1rem}.t-tabs{flex-grow:1}.t-demo{padding:2rem;overflow-x:auto}@media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution:0.001dpcm){.t-demo::-webkit-scrollbar,.t-demo::-webkit-scrollbar-thumb{width:1rem;height:1rem;border-radius:6.25rem;background-clip:padding-box;border:2.667rem solid transparent}.t-demo::-webkit-scrollbar{background-color:transparent}.t-demo::-webkit-scrollbar-thumb{background-color:var(--tui-clear-hover)}.t-demo::-webkit-scrollbar-thumb:hover{background-color:var(--tui-clear-active)}.t-demo::-webkit-scrollbar-thumb:active{background-color:var(--tui-text-03)}}:host-context(tui-root._mobile) .t-demo{padding:1rem}.t-copy-code{position:absolute;top:4.375rem;right:1rem}.t-link-icon{margin-left:.3rem;vertical-align:baseline}.t-content{will-change:opacity;height:0;visibility:hidden;opacity:0}.t-content_animated{transition:opacity .3s ease-in-out}.t-content_visible{height:auto;visibility:visible;opacity:1}"]
1223
+ styles: [":host{position:relative;display:block;padding-top:3.5rem;clear:right}:host :host-context(tui-root._mobile){padding-top:2rem}.t-title{font:var(--tui-font-heading-5);margin:0 0 .5rem}:host-context(tui-root._mobile) .t-title{font:var(--tui-font-heading-6)}.t-description{font:var(--tui-font-text-m);font-weight:400;margin:0}.t-example{position:relative;margin-top:1.5rem;border:1px solid var(--tui-base-03);border-radius:var(--tui-radius-m);box-shadow:0 .125rem .1875rem rgba(0,0,0,.1)}:host-context(tui-root._mobile) .t-example{margin-top:.75rem}.t-tabs-wrapper{display:flex;padding:0 2rem;box-shadow:inset 0 -1px var(--tui-base-03);justify-content:space-between;align-items:center}:host-context(tui-root._mobile) .t-tabs-wrapper{padding:0 1rem}.t-tabs{flex-grow:1}.t-demo{padding:2rem;overflow-x:auto}@media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution:0.001dpcm){.t-demo::-webkit-scrollbar,.t-demo::-webkit-scrollbar-thumb{width:1rem;height:1rem;border-radius:6.25rem;background-clip:padding-box;border:2.667rem solid transparent}.t-demo::-webkit-scrollbar{background-color:transparent}.t-demo::-webkit-scrollbar-thumb{background-color:var(--tui-clear-hover)}.t-demo::-webkit-scrollbar-thumb:hover{background-color:var(--tui-clear-active)}.t-demo::-webkit-scrollbar-thumb:active{background-color:var(--tui-text-03)}}:host-context(tui-root._mobile) .t-demo{padding:1rem}.t-code-actions{position:absolute;top:4.375rem;right:1rem;display:flex;justify-content:flex-end;align-items:center}.t-code-actions>*{margin-left:.5rem}.t-link-icon{margin-left:.3rem;vertical-align:baseline}.t-content{will-change:opacity;height:0;visibility:hidden;opacity:0}.t-content_animated{transition:opacity .3s ease-in-out}.t-content_visible{height:auto;visibility:visible;opacity:1}"]
1218
1224
  }),
1219
1225
  __param(0, core.Attribute('id')),
1220
1226
  __param(1, core.Inject(clipboard.Clipboard)),
@@ -1225,7 +1231,8 @@
1225
1231
  __param(6, core.Optional()),
1226
1232
  __param(6, core.Inject(TUI_DOC_CODE_EDITOR)),
1227
1233
  __param(7, core.Inject(TUI_DOC_EXAMPLE_CONTENT_PROCESSOR)),
1228
- __param(8, core.Inject(cdk.TUI_IS_CYPRESS))
1234
+ __param(8, core.Inject(cdk.TUI_IS_CYPRESS)),
1235
+ __param(9, core.Inject(TUI_DOC_CODE_ACTIONS))
1229
1236
  ], TuiDocExampleComponent);
1230
1237
  return TuiDocExampleComponent;
1231
1238
  }());
@@ -1334,16 +1341,19 @@
1334
1341
  return TuiDocMainComponent;
1335
1342
  }());
1336
1343
 
1344
+ var TUI_DOC_PAGE_LOADED = new core.InjectionToken('[TUI_DOC_PAGE_LOADED] Stream that emits if loading of page is over (for example, to begin scrollIntoView)', { factory: function () { return rxjs.defer(function () { return rxjs.timer(200).pipe(operators.switchMapTo(rxjs.of(true))); }); } });
1345
+
1337
1346
  /**
1338
1347
  * @deprecated: use {@link TuiScrollIntoViewLinkDirective}
1339
1348
  * TODO: remove in v3.0
1340
1349
  */
1341
1350
  var ScrollIntoViewDirective = /** @class */ (function () {
1342
- function ScrollIntoViewDirective(destroy$, _a) {
1351
+ function ScrollIntoViewDirective(destroy$, _a, readyToScroll$) {
1343
1352
  var nativeElement = _a.nativeElement;
1344
- this.scroll$ = new rxjs.Subject();
1345
- this.scroll$
1346
- .pipe(operators.debounceTime(750), operators.filter(function (shallWe) { return shallWe && !!cdk.getElementObscurers(nativeElement); }), operators.takeUntil(destroy$))
1353
+ this.readyToScroll$ = readyToScroll$;
1354
+ this.scroll$ = new rxjs.ReplaySubject(1);
1355
+ this.readyToScroll$
1356
+ .pipe(operators.filter(Boolean), operators.switchMapTo(this.scroll$), operators.debounceTime(750), operators.filter(function (shallWe) { return shallWe && !!cdk.getElementObscurers(nativeElement); }), operators.takeUntil(destroy$))
1347
1357
  .subscribe(function () {
1348
1358
  nativeElement.scrollIntoView();
1349
1359
  });
@@ -1357,7 +1367,8 @@
1357
1367
  });
1358
1368
  ScrollIntoViewDirective.ctorParameters = function () { return [
1359
1369
  { type: cdk.TuiDestroyService, decorators: [{ type: core.Inject, args: [cdk.TuiDestroyService,] }] },
1360
- { type: core.ElementRef, decorators: [{ type: core.Inject, args: [core.ElementRef,] }] }
1370
+ { type: core.ElementRef, decorators: [{ type: core.Inject, args: [core.ElementRef,] }] },
1371
+ { type: rxjs.Observable, decorators: [{ type: core.Inject, args: [TUI_DOC_PAGE_LOADED,] }] }
1361
1372
  ]; };
1362
1373
  __decorate([
1363
1374
  core.Input()
@@ -1370,7 +1381,8 @@
1370
1381
  // eslint-disable-next-line @typescript-eslint/naming-convention
1371
1382
  ,
1372
1383
  __param(0, core.Inject(cdk.TuiDestroyService)),
1373
- __param(1, core.Inject(core.ElementRef))
1384
+ __param(1, core.Inject(core.ElementRef)),
1385
+ __param(2, core.Inject(TUI_DOC_PAGE_LOADED))
1374
1386
  ], ScrollIntoViewDirective);
1375
1387
  return ScrollIntoViewDirective;
1376
1388
  }());
@@ -1521,10 +1533,9 @@
1521
1533
  ]);
1522
1534
  }
1523
1535
 
1524
- var SCROLL_INTO_VIEW_DELAY = 200;
1525
1536
  // @dynamic
1526
1537
  var TuiDocNavigationComponent = /** @class */ (function () {
1527
- function TuiDocNavigationComponent(changeDetectorRef, titleService, title$, documentRef, mode, sidebar, labels, items, searchText, router, activatedRoute) {
1538
+ function TuiDocNavigationComponent(changeDetectorRef, titleService, title$, documentRef, mode, sidebar, labels, items, searchText, router, activatedRoute, destroy$, readyToScroll$) {
1528
1539
  var _this = this;
1529
1540
  this.documentRef = documentRef;
1530
1541
  this.mode = mode;
@@ -1534,6 +1545,8 @@
1534
1545
  this.searchText = searchText;
1535
1546
  this.router = router;
1536
1547
  this.activatedRoute = activatedRoute;
1548
+ this.destroy$ = destroy$;
1549
+ this.readyToScroll$ = readyToScroll$;
1537
1550
  this.menuOpen = false;
1538
1551
  this.search = '';
1539
1552
  this.open = false;
@@ -1618,9 +1631,9 @@
1618
1631
  };
1619
1632
  TuiDocNavigationComponent.prototype.handleAnchorLink = function (hash) {
1620
1633
  var _this = this;
1621
- setTimeout(function () {
1622
- _this.navigateToAnchorLink(hash);
1623
- }, SCROLL_INTO_VIEW_DELAY);
1634
+ this.readyToScroll$
1635
+ .pipe(operators.filter(Boolean), operators.take(1), operators.takeUntil(this.destroy$))
1636
+ .subscribe(function () { return _this.navigateToAnchorLink(hash); });
1624
1637
  };
1625
1638
  TuiDocNavigationComponent.prototype.openActivePageGroup = function () {
1626
1639
  var _this = this;
@@ -1665,7 +1678,9 @@
1665
1678
  { type: undefined, decorators: [{ type: core.Inject, args: [NAVIGATION_ITEMS,] }] },
1666
1679
  { type: String, decorators: [{ type: core.Inject, args: [TUI_DOC_SEARCH_TEXT,] }] },
1667
1680
  { type: router.Router, decorators: [{ type: core.Inject, args: [router.Router,] }] },
1668
- { type: router.ActivatedRoute, decorators: [{ type: core.Inject, args: [router.ActivatedRoute,] }] }
1681
+ { type: router.ActivatedRoute, decorators: [{ type: core.Inject, args: [router.ActivatedRoute,] }] },
1682
+ { type: rxjs.Observable, decorators: [{ type: core.Inject, args: [cdk.TuiDestroyService,] }] },
1683
+ { type: rxjs.Observable, decorators: [{ type: core.Inject, args: [TUI_DOC_PAGE_LOADED,] }] }
1669
1684
  ]; };
1670
1685
  __decorate([
1671
1686
  core.HostBinding('class._open')
@@ -1695,7 +1710,9 @@
1695
1710
  __param(7, core.Inject(NAVIGATION_ITEMS)),
1696
1711
  __param(8, core.Inject(TUI_DOC_SEARCH_TEXT)),
1697
1712
  __param(9, core.Inject(router.Router)),
1698
- __param(10, core.Inject(router.ActivatedRoute))
1713
+ __param(10, core.Inject(router.ActivatedRoute)),
1714
+ __param(11, core.Inject(cdk.TuiDestroyService)),
1715
+ __param(12, core.Inject(TUI_DOC_PAGE_LOADED))
1699
1716
  ], TuiDocNavigationComponent);
1700
1717
  return TuiDocNavigationComponent;
1701
1718
  }());
@@ -2158,6 +2175,7 @@
2158
2175
  exports.EXAMPLE_TEXTS = EXAMPLE_TEXTS;
2159
2176
  exports.ScrollIntoViewDirective = ScrollIntoViewDirective;
2160
2177
  exports.ScrollIntoViewModule = ScrollIntoViewModule;
2178
+ exports.TUI_DOC_CODE_ACTIONS = TUI_DOC_CODE_ACTIONS;
2161
2179
  exports.TUI_DOC_CODE_EDITOR = TUI_DOC_CODE_EDITOR;
2162
2180
  exports.TUI_DOC_DEFAULT_TABS = TUI_DOC_DEFAULT_TABS;
2163
2181
  exports.TUI_DOC_DEMO_TEXTS = TUI_DOC_DEMO_TEXTS;
@@ -2167,6 +2185,7 @@
2167
2185
  exports.TUI_DOC_LOGO = TUI_DOC_LOGO;
2168
2186
  exports.TUI_DOC_MENU_TEXT = TUI_DOC_MENU_TEXT;
2169
2187
  exports.TUI_DOC_PAGES = TUI_DOC_PAGES;
2188
+ exports.TUI_DOC_PAGE_LOADED = TUI_DOC_PAGE_LOADED;
2170
2189
  exports.TUI_DOC_RUSSIAN = TUI_DOC_RUSSIAN;
2171
2190
  exports.TUI_DOC_SEARCH_TEXT = TUI_DOC_SEARCH_TEXT;
2172
2191
  exports.TUI_DOC_SEE_ALSO = TUI_DOC_SEE_ALSO;