ngx-bootstrap 8.0.0-RC.3 → 8.0.0-RC.9

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 (65) hide show
  1. package/accordion/package.json +3 -3
  2. package/alert/package.json +2 -2
  3. package/buttons/package.json +1 -1
  4. package/carousel/package.json +2 -2
  5. package/chronos/package.json +1 -1
  6. package/collapse/package.json +1 -1
  7. package/component-loader/esm2020/component-loader.class.mjs +4 -8
  8. package/component-loader/fesm2015/ngx-bootstrap-component-loader.mjs +5 -9
  9. package/component-loader/fesm2015/ngx-bootstrap-component-loader.mjs.map +1 -1
  10. package/component-loader/fesm2020/ngx-bootstrap-component-loader.mjs +3 -7
  11. package/component-loader/fesm2020/ngx-bootstrap-component-loader.mjs.map +1 -1
  12. package/component-loader/package.json +3 -3
  13. package/datepicker/bs-datepicker-inline.component.d.ts +2 -0
  14. package/datepicker/bs-datepicker.component.d.ts +2 -0
  15. package/datepicker/bs-datepicker.config.d.ts +4 -0
  16. package/datepicker/bs-daterangepicker-inline.component.d.ts +2 -0
  17. package/datepicker/bs-daterangepicker.component.d.ts +2 -0
  18. package/datepicker/esm2020/bs-datepicker-inline.component.mjs +13 -3
  19. package/datepicker/esm2020/bs-datepicker.component.mjs +24 -14
  20. package/datepicker/esm2020/bs-datepicker.config.mjs +5 -1
  21. package/datepicker/esm2020/bs-datepicker.module.mjs +2 -3
  22. package/datepicker/esm2020/bs-daterangepicker-inline.component.mjs +27 -15
  23. package/datepicker/esm2020/bs-daterangepicker.component.mjs +11 -1
  24. package/datepicker/esm2020/engine/flag-months-calendar.mjs +2 -2
  25. package/datepicker/esm2020/reducer/bs-datepicker.reducer.mjs +2 -2
  26. package/datepicker/esm2020/themes/bs/bs-datepicker-container.component.mjs +10 -3
  27. package/datepicker/esm2020/themes/bs/bs-daterangepicker-container.component.mjs +10 -3
  28. package/datepicker/esm2020/utils/bs-calendar-utils.mjs +3 -6
  29. package/datepicker/esm2020/utils/copy-time-utils.mjs +4 -1
  30. package/datepicker/fesm2015/ngx-bootstrap-datepicker.mjs +105 -40
  31. package/datepicker/fesm2015/ngx-bootstrap-datepicker.mjs.map +1 -1
  32. package/datepicker/fesm2020/ngx-bootstrap-datepicker.mjs +100 -40
  33. package/datepicker/fesm2020/ngx-bootstrap-datepicker.mjs.map +1 -1
  34. package/datepicker/package.json +8 -8
  35. package/datepicker/utils/bs-calendar-utils.d.ts +2 -2
  36. package/dropdown/package.json +4 -4
  37. package/focus-trap/package.json +1 -1
  38. package/locale/package.json +2 -2
  39. package/mini-ngrx/package.json +1 -1
  40. package/modal/package.json +5 -5
  41. package/package.json +209 -16
  42. package/pagination/package.json +1 -1
  43. package/popover/package.json +4 -4
  44. package/positioning/package.json +2 -2
  45. package/progressbar/esm2020/bar.component.mjs +2 -2
  46. package/progressbar/fesm2015/ngx-bootstrap-progressbar.mjs +3 -3
  47. package/progressbar/fesm2015/ngx-bootstrap-progressbar.mjs.map +1 -1
  48. package/progressbar/fesm2020/ngx-bootstrap-progressbar.mjs +1 -1
  49. package/progressbar/fesm2020/ngx-bootstrap-progressbar.mjs.map +1 -1
  50. package/progressbar/package.json +2 -2
  51. package/rating/package.json +1 -1
  52. package/schematics/ng-add/index.js +1 -1
  53. package/schematics/package.json +1 -1
  54. package/schematics/utils/current_dependency_versions.json +2 -2
  55. package/sortable/package.json +1 -1
  56. package/tabs/package.json +1 -1
  57. package/timepicker/package.json +2 -2
  58. package/tooltip/package.json +4 -4
  59. package/typeahead/package.json +4 -4
  60. package/utils/esm2020/theme-provider.mjs +9 -7
  61. package/utils/fesm2015/ngx-bootstrap-utils.mjs +8 -6
  62. package/utils/fesm2015/ngx-bootstrap-utils.mjs.map +1 -1
  63. package/utils/fesm2020/ngx-bootstrap-utils.mjs +8 -6
  64. package/utils/fesm2020/ngx-bootstrap-utils.mjs.map +1 -1
  65. package/utils/package.json +1 -1
@@ -93,6 +93,10 @@ class BsDatepickerConfig {
93
93
  * Shows timepicker under datepicker
94
94
  */
95
95
  this.withTimepicker = false;
96
+ /**
97
+ * Set allowed positions of container.
98
+ */
99
+ this.allowedPositions = ['top', 'bottom'];
96
100
  }
97
101
  }
98
102
  BsDatepickerConfig.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BsDatepickerConfig, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
@@ -593,7 +597,7 @@ function isDisabledDate(date, datesDisabled, unit) {
593
597
  if (!datesDisabled || !isArray(datesDisabled) || !datesDisabled.length) {
594
598
  return false;
595
599
  }
596
- if (unit && unit === 'year') {
600
+ if (unit && unit === 'year' && !datesDisabled[0].getDate()) {
597
601
  return datesDisabled.some((dateDisabled) => isSame(date, dateDisabled, 'year'));
598
602
  }
599
603
  return datesDisabled.some((dateDisabled) => isSame(date, dateDisabled, 'date'));
@@ -602,10 +606,7 @@ function isEnabledDate(date, datesEnabled, unit) {
602
606
  if (!datesEnabled || !isArray(datesEnabled) || !datesEnabled.length) {
603
607
  return false;
604
608
  }
605
- if (unit && unit === 'year') {
606
- return !datesEnabled.some((dateDisabled) => isSame(date, dateDisabled, 'year'));
607
- }
608
- return !datesEnabled.some((enabledDate) => isSame(date, enabledDate, 'date'));
609
+ return !datesEnabled.some((enabledDate) => isSame(date, enabledDate, unit || 'date'));
609
610
  }
610
611
  function getYearsCalendarInitialDate(state, calendarIndex = 0) {
611
612
  const model = state && state.yearsCalendarModel && state.yearsCalendarModel[calendarIndex];
@@ -865,7 +866,7 @@ function flagMonthsCalendar(monthCalendar, options) {
865
866
  const isHovered = isSameMonth(month.date, options.hoveredMonth);
866
867
  const isDisabled = options.isDisabled ||
867
868
  isDisabledDate(month.date, options.datesDisabled) ||
868
- isEnabledDate(month.date, options.datesEnabled) ||
869
+ isEnabledDate(month.date, options.datesEnabled, 'month') ||
869
870
  isMonthDisabled(month.date, options.minDate, options.maxDate);
870
871
  if (!options.selectedDate && options.selectedRange) {
871
872
  isSelected = isSameMonth(month.date, options.selectedRange[0]);
@@ -979,6 +980,9 @@ function flagYearsCalendar(yearsCalendar, options) {
979
980
  }
980
981
 
981
982
  function copyTime(sourceDate, time) {
983
+ if (!sourceDate || !isNaN(sourceDate.getTime())) {
984
+ return;
985
+ }
982
986
  sourceDate.setHours(time.getHours());
983
987
  sourceDate.setMinutes(time.getMinutes());
984
988
  sourceDate.setSeconds(time.getSeconds());
@@ -1093,7 +1097,7 @@ function bsDatepickerReducer(state = initialDatepickerState, action) {
1093
1097
  selectedRange: action.payload,
1094
1098
  view: state.view
1095
1099
  };
1096
- newState.selectedRange.forEach((dte, index) => {
1100
+ newState.selectedRange?.forEach((dte, index) => {
1097
1101
  if (Array.isArray(state.selectedTime)) {
1098
1102
  const _time = state.selectedTime[index];
1099
1103
  if (_time) {
@@ -2085,8 +2089,15 @@ class BsDatepickerContainerComponent extends BsDatepickerAbstractComponent {
2085
2089
  }
2086
2090
  ngOnInit() {
2087
2091
  this._positionService.setOptions({
2088
- modifiers: { flip: { enabled: this._config.adaptivePosition } },
2089
- allowedPositions: ['top', 'bottom']
2092
+ modifiers: {
2093
+ flip: {
2094
+ enabled: this._config.adaptivePosition
2095
+ },
2096
+ preventOverflow: {
2097
+ enabled: this._config.adaptivePosition
2098
+ }
2099
+ },
2100
+ allowedPositions: this._config.allowedPositions
2090
2101
  });
2091
2102
  this._positionService.event$?.pipe(take(1))
2092
2103
  .subscribe(() => {
@@ -2320,6 +2331,21 @@ class BsDatepickerDirective {
2320
2331
  this._datepickerRef.instance.dateTooltipTexts = this.dateTooltipTexts;
2321
2332
  }
2322
2333
  }
2334
+ initSubscribes() {
2335
+ // if date changes from external source (model -> view)
2336
+ this._subs.push(this.bsValueChange.subscribe((value) => {
2337
+ if (this._datepickerRef) {
2338
+ this._datepickerRef.instance.value = value;
2339
+ }
2340
+ }));
2341
+ // if date changes from picker (view -> model)
2342
+ if (this._datepickerRef) {
2343
+ this._subs.push(this._datepickerRef.instance.valueChange.subscribe((value) => {
2344
+ this.bsValue = value;
2345
+ this.hide();
2346
+ }));
2347
+ }
2348
+ }
2323
2349
  ngAfterViewInit() {
2324
2350
  this.isOpen$.pipe(filter(isOpen => isOpen !== this.isOpen), takeUntil(this.isDestroy$))
2325
2351
  .subscribe(() => this.toggle());
@@ -2339,19 +2365,7 @@ class BsDatepickerDirective {
2339
2365
  .to(this.container)
2340
2366
  .position({ attachment: this.placement })
2341
2367
  .show({ placement: this.placement });
2342
- // if date changes from external source (model -> view)
2343
- this._subs.push(this.bsValueChange.subscribe((value) => {
2344
- if (this._datepickerRef) {
2345
- this._datepickerRef.instance.value = value;
2346
- }
2347
- }));
2348
- // if date changes from picker (view -> model)
2349
- if (this._datepickerRef) {
2350
- this._subs.push(this._datepickerRef.instance.valueChange.subscribe((value) => {
2351
- this.bsValue = value;
2352
- this.hide();
2353
- }));
2354
- }
2368
+ this.initSubscribes();
2355
2369
  }
2356
2370
  /**
2357
2371
  * Closes an element’s datepicker. This is considered a “manual” triggering of
@@ -2396,6 +2410,12 @@ class BsDatepickerDirective {
2396
2410
  initCurrentTime: this.bsConfig?.initCurrentTime
2397
2411
  });
2398
2412
  }
2413
+ unsubscribeSubscriptions() {
2414
+ if (this._subs?.length) {
2415
+ this._subs.map(sub => sub.unsubscribe());
2416
+ this._subs.length = 0;
2417
+ }
2418
+ }
2399
2419
  ngOnDestroy() {
2400
2420
  this._datepicker.dispose();
2401
2421
  this.isOpen$.next(false);
@@ -2403,6 +2423,7 @@ class BsDatepickerDirective {
2403
2423
  this.isDestroy$.next(null);
2404
2424
  this.isDestroy$.complete();
2405
2425
  }
2426
+ this.unsubscribeSubscriptions();
2406
2427
  }
2407
2428
  }
2408
2429
  BsDatepickerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BsDatepickerDirective, deps: [{ token: BsDatepickerConfig }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ViewContainerRef }, { token: i2.ComponentLoaderFactory }], target: i0.ɵɵFactoryTarget.Directive });
@@ -2518,19 +2539,27 @@ class BsDatepickerInlineDirective {
2518
2539
  }
2519
2540
  ngOnInit() {
2520
2541
  this.setConfig();
2521
- // if date changes from external source (model -> view)
2542
+ this.initSubscribes();
2543
+ }
2544
+ initSubscribes() {
2545
+ this.unsubscribeSubscriptions();
2522
2546
  this._subs.push(this.bsValueChange.subscribe((value) => {
2523
2547
  if (this._datepickerRef) {
2524
2548
  this._datepickerRef.instance.value = value;
2525
2549
  }
2526
2550
  }));
2527
- // if date changes from picker (view -> model)
2528
2551
  if (this._datepickerRef) {
2529
2552
  this._subs.push(this._datepickerRef.instance.valueChange.subscribe((value) => {
2530
2553
  this.bsValue = value;
2531
2554
  }));
2532
2555
  }
2533
2556
  }
2557
+ unsubscribeSubscriptions() {
2558
+ if (this._subs?.length) {
2559
+ this._subs.map(sub => sub.unsubscribe());
2560
+ this._subs.length = 0;
2561
+ }
2562
+ }
2534
2563
  ngOnChanges(changes) {
2535
2564
  if (changes["bsConfig"]) {
2536
2565
  if (changes["bsConfig"].currentValue?.initCurrentTime && changes["bsConfig"].currentValue?.initCurrentTime !== changes["bsConfig"].previousValue?.initCurrentTime && this._bsValue) {
@@ -2588,9 +2617,11 @@ class BsDatepickerInlineDirective {
2588
2617
  .attach(BsDatepickerInlineContainerComponent)
2589
2618
  .to(this._elementRef)
2590
2619
  .show();
2620
+ this.initSubscribes();
2591
2621
  }
2592
2622
  ngOnDestroy() {
2593
2623
  this._datepicker.dispose();
2624
+ this.unsubscribeSubscriptions();
2594
2625
  }
2595
2626
  }
2596
2627
  BsDatepickerInlineDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BsDatepickerInlineDirective, deps: [{ token: BsDatepickerInlineConfig }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ViewContainerRef }, { token: i2.ComponentLoaderFactory }], target: i0.ɵɵFactoryTarget.Directive });
@@ -2666,8 +2697,15 @@ class BsDaterangepickerContainerComponent extends BsDatepickerAbstractComponent
2666
2697
  }
2667
2698
  ngOnInit() {
2668
2699
  this._positionService.setOptions({
2669
- modifiers: { flip: { enabled: this._config.adaptivePosition } },
2670
- allowedPositions: ['top', 'bottom']
2700
+ modifiers: {
2701
+ flip: {
2702
+ enabled: this._config.adaptivePosition
2703
+ },
2704
+ preventOverflow: {
2705
+ enabled: this._config.adaptivePosition
2706
+ }
2707
+ },
2708
+ allowedPositions: this._config.allowedPositions
2671
2709
  });
2672
2710
  this._positionService.event$?.pipe(take(1))
2673
2711
  .subscribe(() => {
@@ -2891,20 +2929,7 @@ class BsDaterangepickerInlineDirective {
2891
2929
  }
2892
2930
  ngOnInit() {
2893
2931
  this.setConfig();
2894
- // if date changes from external source (model -> view)
2895
- this._subs.push(this.bsValueChange.subscribe((value) => {
2896
- if (this._datepickerRef) {
2897
- this._datepickerRef.instance.value = value;
2898
- }
2899
- }));
2900
- // if date changes from picker (view -> model)
2901
- if (this._datepickerRef) {
2902
- this._subs.push(this._datepickerRef.instance.valueChange
2903
- .pipe(filter((range) => range && range[0] && !!range[1]))
2904
- .subscribe((value) => {
2905
- this.bsValue = value;
2906
- }));
2907
- }
2932
+ this.initSubscribes();
2908
2933
  }
2909
2934
  ngOnChanges(changes) {
2910
2935
  if (changes["bsConfig"]) {
@@ -2965,9 +2990,34 @@ class BsDaterangepickerInlineDirective {
2965
2990
  .attach(BsDaterangepickerInlineContainerComponent)
2966
2991
  .to(this._elementRef)
2967
2992
  .show();
2993
+ this.initSubscribes();
2994
+ }
2995
+ initSubscribes() {
2996
+ this.unsubscribeSubscriptions();
2997
+ // if date changes from external source (model -> view)
2998
+ this._subs.push(this.bsValueChange.subscribe((value) => {
2999
+ if (this._datepickerRef) {
3000
+ this._datepickerRef.instance.value = value;
3001
+ }
3002
+ }));
3003
+ // if date changes from picker (view -> model)
3004
+ if (this._datepickerRef) {
3005
+ this._subs.push(this._datepickerRef.instance.valueChange
3006
+ .pipe(filter((range) => range && range[0] && !!range[1]))
3007
+ .subscribe((value) => {
3008
+ this.bsValue = value;
3009
+ }));
3010
+ }
3011
+ }
3012
+ unsubscribeSubscriptions() {
3013
+ if (this._subs?.length) {
3014
+ this._subs.map(sub => sub.unsubscribe());
3015
+ this._subs.length = 0;
3016
+ }
2968
3017
  }
2969
3018
  ngOnDestroy() {
2970
3019
  this._datepicker.dispose();
3020
+ this.unsubscribeSubscriptions();
2971
3021
  }
2972
3022
  }
2973
3023
  BsDaterangepickerInlineDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BsDaterangepickerInlineDirective, deps: [{ token: BsDaterangepickerInlineConfig }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ViewContainerRef }, { token: i2.ComponentLoaderFactory }], target: i0.ɵɵFactoryTarget.Directive });
@@ -3300,6 +3350,9 @@ class BsDaterangepickerDirective {
3300
3350
  .to(this.container)
3301
3351
  .position({ attachment: this.placement })
3302
3352
  .show({ placement: this.placement });
3353
+ this.initSubscribes();
3354
+ }
3355
+ initSubscribes() {
3303
3356
  // if date changes from external source (model -> view)
3304
3357
  this._subs.push(this.bsValueChange.subscribe((value) => {
3305
3358
  if (this._datepickerRef) {
@@ -3359,6 +3412,12 @@ class BsDaterangepickerDirective {
3359
3412
  }
3360
3413
  this.show();
3361
3414
  }
3415
+ unsubscribeSubscriptions() {
3416
+ if (this._subs?.length) {
3417
+ this._subs.map(sub => sub.unsubscribe());
3418
+ this._subs.length = 0;
3419
+ }
3420
+ }
3362
3421
  ngOnDestroy() {
3363
3422
  this._datepicker.dispose();
3364
3423
  this.isOpen$.next(false);
@@ -3366,6 +3425,7 @@ class BsDaterangepickerDirective {
3366
3425
  this.isDestroy$.next(null);
3367
3426
  this.isDestroy$.complete();
3368
3427
  }
3428
+ this.unsubscribeSubscriptions();
3369
3429
  }
3370
3430
  }
3371
3431
  BsDaterangepickerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BsDaterangepickerDirective, deps: [{ token: BsDaterangepickerConfig }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ViewContainerRef }, { token: i2.ComponentLoaderFactory }], target: i0.ɵɵFactoryTarget.Directive });