@recursyve/nice-ui-kit.v2 14.0.0-beta.108 → 14.0.0-beta.110

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.
@@ -5,7 +5,7 @@ import * as i0 from '@angular/core';
5
5
  import { Injectable, NgModule, EventEmitter, Component, ViewEncapsulation, ChangeDetectionStrategy, Input, Output, HostBinding, InjectionToken, Directive, HostListener, forwardRef, TemplateRef, Optional, Inject, ViewChild, ContentChild, ViewChildren, Self, Pipe, ElementRef, PLATFORM_ID, ContentChildren, SimpleChange, SkipSelf } from '@angular/core';
6
6
  import { plainToInstance } from 'class-transformer';
7
7
  import { map, filter, takeUntil, tap, take, debounceTime as debounceTime$1, delay, switchMap } from 'rxjs/operators';
8
- import { catchError, ReplaySubject, Subject, BehaviorSubject, mergeMap, from, isObservable, firstValueFrom, debounceTime, distinctUntilChanged, startWith, tap as tap$1, Observable, combineLatest, of, fromEvent, merge as merge$1 } from 'rxjs';
8
+ import { catchError, ReplaySubject, Subject, BehaviorSubject, mergeMap, from, isObservable, firstValueFrom, debounceTime, distinctUntilChanged, startWith, tap as tap$1, Observable, combineLatest, of, fromEvent, merge as merge$1, pairwise } from 'rxjs';
9
9
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
10
10
  import * as i2 from '@angular/common';
11
11
  import { CommonModule, DatePipe, CurrencyPipe, DOCUMENT, isPlatformServer } from '@angular/common';
@@ -15,6 +15,7 @@ import * as i4 from '@angular/material/icon';
15
15
  import { MatIconModule } from '@angular/material/icon';
16
16
  import * as i1$2 from '@angular/forms';
17
17
  import { NG_VALUE_ACCESSOR, FormControl, Validators, ReactiveFormsModule, FormsModule, FormGroup } from '@angular/forms';
18
+ import { LexoRank } from 'lexorank';
18
19
  import * as i4$1 from '@angular/material/menu';
19
20
  import { MatMenuModule } from '@angular/material/menu';
20
21
  import * as i2$1 from '@angular/material/core';
@@ -65,6 +66,8 @@ import * as i1$e from '@angular/material/dialog';
65
66
  import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
66
67
  import * as i1$f from '@angular/material/snack-bar';
67
68
  import { MAT_SNACK_BAR_DATA, MatSnackBarModule } from '@angular/material/snack-bar';
69
+ import * as i2$4 from '@angular/cdk/drag-drop';
70
+ import { moveItemInArray, DragDropModule } from '@angular/cdk/drag-drop';
68
71
 
69
72
  class NiceAnimationCurves {
70
73
  }
@@ -1454,6 +1457,33 @@ var KeyboardCodes;
1454
1457
  KeyboardCodes["Comma"] = "Comma";
1455
1458
  })(KeyboardCodes || (KeyboardCodes = {}));
1456
1459
 
1460
+ class LexoRankUtils {
1461
+ static compareStringFn(previousRank, nextRank) {
1462
+ if (!previousRank || !nextRank) {
1463
+ return 0;
1464
+ }
1465
+ return LexoRank.parse(previousRank).compareTo(LexoRank.parse(nextRank));
1466
+ }
1467
+ static compareFn(previousRank, nextRank) {
1468
+ return previousRank.compareTo(nextRank);
1469
+ }
1470
+ static getNewRank(afterRank, beforeRank) {
1471
+ if (afterRank && beforeRank) {
1472
+ if (LexoRank.parse(beforeRank).equals(LexoRank.parse(afterRank))) {
1473
+ return LexoRank.parse(afterRank).genPrev().toString();
1474
+ }
1475
+ return LexoRank.parse(afterRank).between(LexoRank.parse(beforeRank)).toString();
1476
+ }
1477
+ if (afterRank) {
1478
+ return LexoRank.parse(afterRank).genPrev().toString();
1479
+ }
1480
+ if (beforeRank) {
1481
+ return LexoRank.parse(beforeRank).genNext().toString();
1482
+ }
1483
+ return LexoRank.middle().toString();
1484
+ }
1485
+ }
1486
+
1457
1487
  var ModalMode;
1458
1488
  (function (ModalMode) {
1459
1489
  ModalMode[ModalMode["Create"] = 0] = "Create";
@@ -10391,6 +10421,105 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImpor
10391
10421
  }]
10392
10422
  }] });
10393
10423
 
10424
+ class NiceDraggableListDirective {
10425
+ constructor(formArrayName, cdkDropList) {
10426
+ this.formArrayName = formArrayName;
10427
+ this.cdkDropList = cdkDropList;
10428
+ this.rankProperty = "rank";
10429
+ this.itemsUpdated = new EventEmitter();
10430
+ this.itemRankUpdated = new EventEmitter();
10431
+ this.sortedItems = [];
10432
+ this.unsubscribeAll$ = new Subject();
10433
+ }
10434
+ ngOnInit() {
10435
+ if (this.formArrayName) {
10436
+ this.formArray = this.formArrayName.control;
10437
+ this.formArray.valueChanges.pipe(takeUntil(this.unsubscribeAll$), startWith(this.formArray.getRawValue()), map(() => this.formArray.getRawValue()), pairwise()).subscribe(([previous, current]) => {
10438
+ if (previous.length !== current.length) {
10439
+ this.sortItems(current);
10440
+ }
10441
+ });
10442
+ this.sortItems(this.formArray.getRawValue());
10443
+ }
10444
+ this.cdkDropList.dropped.pipe(takeUntil(this.unsubscribeAll$)).subscribe((event) => this.drop(event));
10445
+ }
10446
+ ngOnDestroy() {
10447
+ this.unsubscribeAll$.next();
10448
+ this.unsubscribeAll$.complete();
10449
+ }
10450
+ ngOnChanges(changes) {
10451
+ if ("items" in changes && this.items) {
10452
+ this.sortItems(this.items);
10453
+ }
10454
+ }
10455
+ drop(event) {
10456
+ if (event.previousContainer === event.container) {
10457
+ if (event.previousIndex === event.currentIndex) {
10458
+ return;
10459
+ }
10460
+ event.item.data[this.rankProperty] = this.getNextRank(event);
10461
+ this.sortItems(this.sortedItems);
10462
+ this.itemsUpdated.next(this.sortedItems);
10463
+ this.itemRankUpdated.next(event.item.data);
10464
+ if (this.formArray) {
10465
+ this.formArray.get([event.previousIndex, this.rankProperty])?.patchValue(event.item.data[this.rankProperty]);
10466
+ moveItemInArray(this.formArray.controls, event.previousIndex, event.currentIndex);
10467
+ }
10468
+ }
10469
+ else {
10470
+ // TODO: Handle container change
10471
+ }
10472
+ }
10473
+ sortItems(items) {
10474
+ if (items.length && items.some((item) => !item[this.rankProperty])) {
10475
+ throw new Error(`All items must have a ${this.rankProperty}`);
10476
+ }
10477
+ this.sortedItems = [...items]
10478
+ .map(item => ({ ...item }))
10479
+ .sort((itemA, itemB) => LexoRankUtils.compareStringFn(itemA[this.rankProperty], itemB[this.rankProperty]));
10480
+ this.cdkDropList.data = this.sortedItems;
10481
+ }
10482
+ getNextRank(event) {
10483
+ const fromIndex = event.previousIndex;
10484
+ const toIndex = event.currentIndex;
10485
+ const itemAfter = this.sortedItems[fromIndex > toIndex ? toIndex : toIndex + 1];
10486
+ const itemBefore = this.sortedItems[fromIndex > toIndex ? toIndex - 1 : toIndex];
10487
+ return LexoRankUtils.getNewRank(itemAfter?.[this.rankProperty], itemBefore?.[this.rankProperty]);
10488
+ }
10489
+ }
10490
+ NiceDraggableListDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceDraggableListDirective, deps: [{ token: i1$2.FormArrayName, optional: true }, { token: i2$4.CdkDropList }], target: i0.ɵɵFactoryTarget.Directive });
10491
+ NiceDraggableListDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.3", type: NiceDraggableListDirective, selector: "[cdkDropList][niceDraggableList]", inputs: { items: "items", rankProperty: "rankProperty" }, outputs: { itemsUpdated: "itemsUpdated", itemRankUpdated: "itemRankUpdated" }, usesOnChanges: true, ngImport: i0 });
10492
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceDraggableListDirective, decorators: [{
10493
+ type: Directive,
10494
+ args: [{
10495
+ selector: "[cdkDropList][niceDraggableList]"
10496
+ }]
10497
+ }], ctorParameters: function () { return [{ type: i1$2.FormArrayName, decorators: [{
10498
+ type: Optional
10499
+ }] }, { type: i2$4.CdkDropList }]; }, propDecorators: { items: [{
10500
+ type: Input
10501
+ }], rankProperty: [{
10502
+ type: Input
10503
+ }], itemsUpdated: [{
10504
+ type: Output
10505
+ }], itemRankUpdated: [{
10506
+ type: Output
10507
+ }] } });
10508
+
10509
+ class NiceDraggableListModule {
10510
+ }
10511
+ NiceDraggableListModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceDraggableListModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
10512
+ NiceDraggableListModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.3", ngImport: i0, type: NiceDraggableListModule, declarations: [NiceDraggableListDirective], imports: [DragDropModule], exports: [NiceDraggableListDirective] });
10513
+ NiceDraggableListModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceDraggableListModule, imports: [DragDropModule] });
10514
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImport: i0, type: NiceDraggableListModule, decorators: [{
10515
+ type: NgModule,
10516
+ args: [{
10517
+ imports: [DragDropModule],
10518
+ declarations: [NiceDraggableListDirective],
10519
+ exports: [NiceDraggableListDirective],
10520
+ }]
10521
+ }] });
10522
+
10394
10523
  class NiceImageErrorPlaceholderDirective {
10395
10524
  constructor(elementRef, viewContainerRef) {
10396
10525
  this.elementRef = elementRef;
@@ -10716,5 +10845,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.3", ngImpor
10716
10845
  * Generated bundle index. Do not edit.
10717
10846
  */
10718
10847
 
10719
- export { ArrayUtils, BooleanPipe, CapitalizeFirstLetterPipe, CarouselComponent, CaseUtils, CeilPipe, ChipListItemLabelDirective, ColorsUtils, DateUtils, DefaultExportBottomSheetService, EntriesPipe, ExportBottomSheetComponent, ExportBottomSheetService, FileUtils, FindByKeyPipe, FirstLetterPipe, FloorPipe, FontAwesomeUtils, FormDataUtils, HttpStatusCodes, ImgCropperConfig, ImgCropperError, ImgResolution, JoinPipe, KeyboardCodes, LinkPipe, LocalizedBooleanPipe, LocalizedCurrencyPipe, LocalizedDateOnlyPipe, LocalizedDatePipe, MinutesToTimePipe, ModalMode, NavigationHideItemResolver, NavigationHintResolver, NiceAlertComponent, NiceAlertModule, NiceAlertService, NiceApiException, NiceAssetsCarouselActiveContentDirective, NiceAssetsCarouselComponent, NiceAssetsCarouselModule, NiceAsyncTypeaheadComponent, NiceAsyncTypeaheadModule, NiceAsyncTypeaheadProvider, NiceAutofocusDirective, NiceAutofocusDirectiveModule, NiceAutogrowDirective, NiceAutogrowModule, NiceBaseForm, NiceBaseFormComponent, NiceBaseFormModule, NiceCardComponent, NiceCardModule, NiceCarouselModule, NiceChipAsyncTypeaheadDirective, NiceChipListDirective, NiceChipListDirectiveModule, NiceChipListItemsComponent, NiceClickStopPropagationDirective, NiceCollapsableComponent, NiceCollapsableModule, NiceConfigModule, NiceConfigService, NiceControlStatusDirective, NiceCropperAreaComponent, NiceDateRangePickerComponent, NiceDateRangePickerModule, NiceDrawerComponent, NiceDrawerModule, NiceDrawerService, NiceDropzoneDirective, NiceDropzoneModule, NiceExportBottomSheetModule, NiceFormErrorComponent, NiceFormErrorModule, NiceFormSubmitDirective, NiceHorizontalNavigationBasicItemComponent, NiceHorizontalNavigationBranchItemComponent, NiceHorizontalNavigationComponent, NiceHorizontalNavigationDividerItemComponent, NiceHorizontalNavigationSpacerItemComponent, NiceHorizontalStepperComponent, NiceHorizontalStepperModule, NiceHttpExceptionFactory, NiceImageCropperComponent, NiceImageCropperModule, NiceImageErrorPlaceholderDirective, NiceImageErrorPlaceholderDirectiveModule, NiceLayoutComponent, NiceLayoutModule, NiceLoadingDirective, NiceLoadingSpinnerComponent, NiceLoadingSpinnerModule, NiceLottieComponent, NiceLottieModule, NiceMaterialModule, NiceMaterialStyleDirective, NiceMediaWatcherModule, NiceMediaWatcherService, NiceModalOnClickDirective, NiceModalOpenerDirective, NiceModule, NiceNavigationComponent, NiceNavigationModule, NiceNavigationService, NicePipesModule, NicePreventCloseWindowDirective, NiceRoundedStyleDirective, NiceScrollResetDirective, NiceScrollResetModule, NiceScrollbarDirective, NiceScrollbarModule, NiceSearchBarComponent, NiceSearchBarModule, NiceSplashScreenModule, NiceSplashScreenService, NiceStepComponent, NiceStopPropagationModule, NiceSweetAlertComponent, NiceSweetAlertDirective, NiceSweetAlertModule, NiceSweetAlertService, NiceToastComponent, NiceToastModule, NiceToastService, NiceToggleButtonGroupModule, NiceTransformResponseInterceptor, NiceTypeaheadComponent, NiceTypeaheadModule, NiceTypeaheadNewValue, NiceUtilsModule, NiceUtilsService, NiceVerticalNavigationAsideItemComponent, NiceVerticalNavigationBasicItemComponent, NiceVerticalNavigationCollapsableItemComponent, NiceVerticalNavigationComponent, NiceVerticalNavigationDividerItemComponent, NiceVerticalNavigationGroupItemComponent, NiceVerticalNavigationSpacerItemComponent, NiceWindowDirectiveModule, NumberToOrdinalIndicatorPipe, NumberUtils, ObjectUtils, OptionsScrollDirective, PadPipe, PhonePipe, PictureModalComponent, PictureModalService, PostalCodePipe, PromiseUtils, QueryParamsUtils, RangePipe, RegexUtils, RoundPipe, SanitizeBypassPipe, SecondsToTimePipe, TRANSFORM_TYPE, ToggleButtonComponent, ToggleButtonGroupComponent, TrackByPropPipe, TypeUtils, UrlUtils, _HintComponentBase, _normalizeDegrees, isNotNullOrUndefined, isNullOrUndefined, mergeDeep, mixinNiceApi, niceAnimations, round };
10848
+ export { ArrayUtils, BooleanPipe, CapitalizeFirstLetterPipe, CarouselComponent, CaseUtils, CeilPipe, ChipListItemLabelDirective, ColorsUtils, DateUtils, DefaultExportBottomSheetService, EntriesPipe, ExportBottomSheetComponent, ExportBottomSheetService, FileUtils, FindByKeyPipe, FirstLetterPipe, FloorPipe, FontAwesomeUtils, FormDataUtils, HttpStatusCodes, ImgCropperConfig, ImgCropperError, ImgResolution, JoinPipe, KeyboardCodes, LexoRankUtils, LinkPipe, LocalizedBooleanPipe, LocalizedCurrencyPipe, LocalizedDateOnlyPipe, LocalizedDatePipe, MinutesToTimePipe, ModalMode, NavigationHideItemResolver, NavigationHintResolver, NiceAlertComponent, NiceAlertModule, NiceAlertService, NiceApiException, NiceAssetsCarouselActiveContentDirective, NiceAssetsCarouselComponent, NiceAssetsCarouselModule, NiceAsyncTypeaheadComponent, NiceAsyncTypeaheadModule, NiceAsyncTypeaheadProvider, NiceAutofocusDirective, NiceAutofocusDirectiveModule, NiceAutogrowDirective, NiceAutogrowModule, NiceBaseForm, NiceBaseFormComponent, NiceBaseFormModule, NiceCardComponent, NiceCardModule, NiceCarouselModule, NiceChipAsyncTypeaheadDirective, NiceChipListDirective, NiceChipListDirectiveModule, NiceChipListItemsComponent, NiceClickStopPropagationDirective, NiceCollapsableComponent, NiceCollapsableModule, NiceConfigModule, NiceConfigService, NiceControlStatusDirective, NiceCropperAreaComponent, NiceDateRangePickerComponent, NiceDateRangePickerModule, NiceDraggableListDirective, NiceDraggableListModule, NiceDrawerComponent, NiceDrawerModule, NiceDrawerService, NiceDropzoneDirective, NiceDropzoneModule, NiceExportBottomSheetModule, NiceFormErrorComponent, NiceFormErrorModule, NiceFormSubmitDirective, NiceHorizontalNavigationBasicItemComponent, NiceHorizontalNavigationBranchItemComponent, NiceHorizontalNavigationComponent, NiceHorizontalNavigationDividerItemComponent, NiceHorizontalNavigationSpacerItemComponent, NiceHorizontalStepperComponent, NiceHorizontalStepperModule, NiceHttpExceptionFactory, NiceImageCropperComponent, NiceImageCropperModule, NiceImageErrorPlaceholderDirective, NiceImageErrorPlaceholderDirectiveModule, NiceLayoutComponent, NiceLayoutModule, NiceLoadingDirective, NiceLoadingSpinnerComponent, NiceLoadingSpinnerModule, NiceLottieComponent, NiceLottieModule, NiceMaterialModule, NiceMaterialStyleDirective, NiceMediaWatcherModule, NiceMediaWatcherService, NiceModalOnClickDirective, NiceModalOpenerDirective, NiceModule, NiceNavigationComponent, NiceNavigationModule, NiceNavigationService, NicePipesModule, NicePreventCloseWindowDirective, NiceRoundedStyleDirective, NiceScrollResetDirective, NiceScrollResetModule, NiceScrollbarDirective, NiceScrollbarModule, NiceSearchBarComponent, NiceSearchBarModule, NiceSplashScreenModule, NiceSplashScreenService, NiceStepComponent, NiceStopPropagationModule, NiceSweetAlertComponent, NiceSweetAlertDirective, NiceSweetAlertModule, NiceSweetAlertService, NiceToastComponent, NiceToastModule, NiceToastService, NiceToggleButtonGroupModule, NiceTransformResponseInterceptor, NiceTypeaheadComponent, NiceTypeaheadModule, NiceTypeaheadNewValue, NiceUtilsModule, NiceUtilsService, NiceVerticalNavigationAsideItemComponent, NiceVerticalNavigationBasicItemComponent, NiceVerticalNavigationCollapsableItemComponent, NiceVerticalNavigationComponent, NiceVerticalNavigationDividerItemComponent, NiceVerticalNavigationGroupItemComponent, NiceVerticalNavigationSpacerItemComponent, NiceWindowDirectiveModule, NumberToOrdinalIndicatorPipe, NumberUtils, ObjectUtils, OptionsScrollDirective, PadPipe, PhonePipe, PictureModalComponent, PictureModalService, PostalCodePipe, PromiseUtils, QueryParamsUtils, RangePipe, RegexUtils, RoundPipe, SanitizeBypassPipe, SecondsToTimePipe, TRANSFORM_TYPE, ToggleButtonComponent, ToggleButtonGroupComponent, TrackByPropPipe, TypeUtils, UrlUtils, _HintComponentBase, _normalizeDegrees, isNotNullOrUndefined, isNullOrUndefined, mergeDeep, mixinNiceApi, niceAnimations, round };
10720
10849
  //# sourceMappingURL=recursyve-nice-ui-kit.v2.mjs.map