@datorama/core 22.5.1 → 22.5.2

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.
@@ -6633,6 +6633,108 @@ const defaultClientSearchStrategy = (searchIn, searchValue, labelKey) => {
6633
6633
  return false;
6634
6634
  };
6635
6635
 
6636
+ /**
6637
+ * @license
6638
+ * Copyright Datorama. All Rights Reserved.
6639
+ *
6640
+ * Use of this source code is governed by an Apache License 2.0 license that can be
6641
+ * found in the LICENSE file at https://github.com/datorama/client-core/blob/master/LICENSE
6642
+ */
6643
+ let DatoSortableComponent = class DatoSortableComponent {
6644
+ constructor() {
6645
+ this.list = [];
6646
+ this.noop = noop;
6647
+ /**
6648
+ * Sortablejs options
6649
+ */
6650
+ this.datoOptions = {};
6651
+ /**
6652
+ * Fired once items order has changed
6653
+ */
6654
+ this.orderUpdated = new EventEmitter();
6655
+ this.defaultOptions = {
6656
+ handle: '.dato-sortable-handler',
6657
+ ghostClass: 'dato-sortable-ghost',
6658
+ chosenClass: 'dato-sortable-chosen',
6659
+ dragClass: 'dato-sortable-drag'
6660
+ };
6661
+ }
6662
+ set datoList(list) {
6663
+ const isArr = Array.isArray(list);
6664
+ const validInput = isArr || (list instanceof FormControl && Array.isArray(list.value));
6665
+ if (!validInput) {
6666
+ throw new Error(`DatoSortable - datoList expected array or form control but got ${typeof list}`);
6667
+ }
6668
+ if (!isArr) {
6669
+ this.formControl = list;
6670
+ this.list = [...this.formControl.value];
6671
+ }
6672
+ else {
6673
+ this.list = list;
6674
+ }
6675
+ }
6676
+ ngOnInit() {
6677
+ const _a = this.datoOptions, { dynamicGhostHeight, hasStaticItems } = _a, sortableOptions = __rest(_a, ["dynamicGhostHeight", "hasStaticItems"]);
6678
+ const mergedOptions = Object.assign(Object.assign(Object.assign({}, this.defaultOptions), sortableOptions), { onUpdate: event => (sortableOptions.onUpdate ? sortableOptions.onUpdate(event) : this.emitUpdate(event)) });
6679
+ if (dynamicGhostHeight) {
6680
+ mergedOptions.onStart = event => this.setGhostHeight(event);
6681
+ }
6682
+ if (hasStaticItems) {
6683
+ mergedOptions.onMove = event => {
6684
+ if (event.related.classList.contains('dato-sortable-static-item')) {
6685
+ return false;
6686
+ }
6687
+ return sortableOptions.onMove ? sortableOptions.onMove(event) : true;
6688
+ };
6689
+ }
6690
+ this.mergedOptions = mergedOptions;
6691
+ }
6692
+ emitUpdate(event) {
6693
+ if (this.formControl) {
6694
+ this.formControl.setValue(this.list);
6695
+ }
6696
+ this.orderUpdated.emit(event);
6697
+ }
6698
+ setGhostHeight(event) {
6699
+ const originalEl = event.from.children[event.oldIndex];
6700
+ setStyle(originalEl, 'display', 'block');
6701
+ const { height } = originalEl.getBoundingClientRect();
6702
+ setStyle(originalEl, 'display', 'none');
6703
+ const ghostEl = query('.dato-sortable-ghost');
6704
+ setStyle(ghostEl, 'height', `${height}px`);
6705
+ }
6706
+ };
6707
+ __decorate([
6708
+ ContentChildren(DatoAccordionGroupComponent),
6709
+ __metadata("design:type", QueryList)
6710
+ ], DatoSortableComponent.prototype, "accordionGroups", void 0);
6711
+ __decorate([
6712
+ Input(),
6713
+ __metadata("design:type", Object),
6714
+ __metadata("design:paramtypes", [Object])
6715
+ ], DatoSortableComponent.prototype, "datoList", null);
6716
+ __decorate([
6717
+ Input(),
6718
+ __metadata("design:type", Object)
6719
+ ], DatoSortableComponent.prototype, "datoOptions", void 0);
6720
+ __decorate([
6721
+ Input(),
6722
+ __metadata("design:type", String)
6723
+ ], DatoSortableComponent.prototype, "containerClass", void 0);
6724
+ __decorate([
6725
+ Output(),
6726
+ __metadata("design:type", Object)
6727
+ ], DatoSortableComponent.prototype, "orderUpdated", void 0);
6728
+ DatoSortableComponent = __decorate([
6729
+ Component({
6730
+ selector: 'dato-sortable',
6731
+ template: "<section [sortablejs]=\"list\" [sortablejsOptions]=\"mergedOptions\" [ngClass]=\"containerClass\"\n (update.stop)=\"noop()\" (add.stop)=\"noop()\" (sort.stop)=\"noop()\" (remove.stop)=\"noop()\"\n (filter.stop)=\"noop()\" (change.stop)=\"noop()\" (drag.stop)=\"noop()\">\n <ng-content></ng-content>\n</section>",
6732
+ changeDetection: ChangeDetectionStrategy.OnPush,
6733
+ encapsulation: ViewEncapsulation.None,
6734
+ styles: ["dato-sortable{display:inline-block}dato-sortable .dato-sortable-handler{cursor:move;cursor:-webkit-grabbing}.dato-sortable-ghost>*{display:none!important}.dato-sortable-drag{box-shadow:0 2px 14px 0 rgba(0,0,0,.2)}"]
6735
+ })
6736
+ ], DatoSortableComponent);
6737
+
6636
6738
  /**
6637
6739
  * @license
6638
6740
  * Copyright Datorama. All Rights Reserved.
@@ -6674,6 +6776,9 @@ let DatoAccordionComponent = DatoAccordionComponent_1 = class DatoAccordionCompo
6674
6776
  }
6675
6777
  }
6676
6778
  }
6779
+ get groups() {
6780
+ return this.sortable && this.sortable.accordionGroups.length > 0 ? this.sortable.accordionGroups : this.childGroups;
6781
+ }
6677
6782
  ngOnChanges(changes) {
6678
6783
  if (changes.expandAll && !changes.expandAll.firstChange) {
6679
6784
  this.setExpandAll();
@@ -6845,11 +6950,15 @@ DatoAccordionComponent.ctorParameters = () => [
6845
6950
  __decorate([
6846
6951
  ContentChildren(DatoAccordionGroupComponent),
6847
6952
  __metadata("design:type", QueryList)
6848
- ], DatoAccordionComponent.prototype, "groups", void 0);
6953
+ ], DatoAccordionComponent.prototype, "childGroups", void 0);
6849
6954
  __decorate([
6850
6955
  ContentChildren(DatoAccordionComponent_1, { descendants: true }),
6851
6956
  __metadata("design:type", QueryList)
6852
6957
  ], DatoAccordionComponent.prototype, "childAccordion", void 0);
6958
+ __decorate([
6959
+ ContentChild(DatoSortableComponent, { static: true }),
6960
+ __metadata("design:type", DatoSortableComponent)
6961
+ ], DatoAccordionComponent.prototype, "sortable", void 0);
6853
6962
  __decorate([
6854
6963
  Input(),
6855
6964
  __metadata("design:type", Object)
@@ -8855,104 +8964,6 @@ DatoOptionsModule = __decorate([
8855
8964
  })
8856
8965
  ], DatoOptionsModule);
8857
8966
 
8858
- /**
8859
- * @license
8860
- * Copyright Datorama. All Rights Reserved.
8861
- *
8862
- * Use of this source code is governed by an Apache License 2.0 license that can be
8863
- * found in the LICENSE file at https://github.com/datorama/client-core/blob/master/LICENSE
8864
- */
8865
- let DatoSortableComponent = class DatoSortableComponent {
8866
- constructor() {
8867
- this.list = [];
8868
- this.noop = noop;
8869
- /**
8870
- * Sortablejs options
8871
- */
8872
- this.datoOptions = {};
8873
- /**
8874
- * Fired once items order has changed
8875
- */
8876
- this.orderUpdated = new EventEmitter();
8877
- this.defaultOptions = {
8878
- handle: '.dato-sortable-handler',
8879
- ghostClass: 'dato-sortable-ghost',
8880
- chosenClass: 'dato-sortable-chosen',
8881
- dragClass: 'dato-sortable-drag'
8882
- };
8883
- }
8884
- set datoList(list) {
8885
- const isArr = Array.isArray(list);
8886
- const validInput = isArr || (list instanceof FormControl && Array.isArray(list.value));
8887
- if (!validInput) {
8888
- throw new Error(`DatoSortable - datoList expected array or form control but got ${typeof list}`);
8889
- }
8890
- if (!isArr) {
8891
- this.formControl = list;
8892
- this.list = [...this.formControl.value];
8893
- }
8894
- else {
8895
- this.list = list;
8896
- }
8897
- }
8898
- ngOnInit() {
8899
- const _a = this.datoOptions, { dynamicGhostHeight, hasStaticItems } = _a, sortableOptions = __rest(_a, ["dynamicGhostHeight", "hasStaticItems"]);
8900
- const mergedOptions = Object.assign(Object.assign(Object.assign({}, this.defaultOptions), sortableOptions), { onUpdate: event => (sortableOptions.onUpdate ? sortableOptions.onUpdate(event) : this.emitUpdate(event)) });
8901
- if (dynamicGhostHeight) {
8902
- mergedOptions.onStart = event => this.setGhostHeight(event);
8903
- }
8904
- if (hasStaticItems) {
8905
- mergedOptions.onMove = event => {
8906
- if (event.related.classList.contains('dato-sortable-static-item')) {
8907
- return false;
8908
- }
8909
- return sortableOptions.onMove ? sortableOptions.onMove(event) : true;
8910
- };
8911
- }
8912
- this.mergedOptions = mergedOptions;
8913
- }
8914
- emitUpdate(event) {
8915
- if (this.formControl) {
8916
- this.formControl.setValue(this.list);
8917
- }
8918
- this.orderUpdated.emit(event);
8919
- }
8920
- setGhostHeight(event) {
8921
- const originalEl = event.from.children[event.oldIndex];
8922
- setStyle(originalEl, 'display', 'block');
8923
- const { height } = originalEl.getBoundingClientRect();
8924
- setStyle(originalEl, 'display', 'none');
8925
- const ghostEl = query('.dato-sortable-ghost');
8926
- setStyle(ghostEl, 'height', `${height}px`);
8927
- }
8928
- };
8929
- __decorate([
8930
- Input(),
8931
- __metadata("design:type", Object),
8932
- __metadata("design:paramtypes", [Object])
8933
- ], DatoSortableComponent.prototype, "datoList", null);
8934
- __decorate([
8935
- Input(),
8936
- __metadata("design:type", Object)
8937
- ], DatoSortableComponent.prototype, "datoOptions", void 0);
8938
- __decorate([
8939
- Input(),
8940
- __metadata("design:type", String)
8941
- ], DatoSortableComponent.prototype, "containerClass", void 0);
8942
- __decorate([
8943
- Output(),
8944
- __metadata("design:type", Object)
8945
- ], DatoSortableComponent.prototype, "orderUpdated", void 0);
8946
- DatoSortableComponent = __decorate([
8947
- Component({
8948
- selector: 'dato-sortable',
8949
- template: "<section [sortablejs]=\"list\" [sortablejsOptions]=\"mergedOptions\" [ngClass]=\"containerClass\"\n (update.stop)=\"noop()\" (add.stop)=\"noop()\" (sort.stop)=\"noop()\" (remove.stop)=\"noop()\"\n (filter.stop)=\"noop()\" (change.stop)=\"noop()\" (drag.stop)=\"noop()\">\n <ng-content></ng-content>\n</section>",
8950
- changeDetection: ChangeDetectionStrategy.OnPush,
8951
- encapsulation: ViewEncapsulation.None,
8952
- styles: ["dato-sortable{display:inline-block}dato-sortable .dato-sortable-handler{cursor:move;cursor:-webkit-grabbing}.dato-sortable-ghost>*{display:none!important}.dato-sortable-drag{box-shadow:0 2px 14px 0 rgba(0,0,0,.2)}"]
8953
- })
8954
- ], DatoSortableComponent);
8955
-
8956
8967
  /**
8957
8968
  * @license
8958
8969
  * Copyright Datorama. All Rights Reserved.
@@ -22655,7 +22666,7 @@ function fixNgLeaks() {
22655
22666
  };
22656
22667
  }
22657
22668
 
22658
- window.coreVersion = '22.5.1';
22669
+ window.coreVersion = '22.5.2';
22659
22670
 
22660
22671
  /**
22661
22672
  * @license