@guiexpert/demo-table-models 1.0.7 → 1.0.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.
package/index.js CHANGED
@@ -36,6 +36,15 @@ class fe {
36
36
  }
37
37
  }
38
38
  class T {
39
+ /**
40
+ * Represents a constructor for a class.
41
+ * @constructor
42
+ * @param {number} r1 - The value for r1.
43
+ * @param {number} c1 - The value for c1.
44
+ * @param {number} r2 - The value for r2.
45
+ * @param {number} c2 - The value for c2.
46
+ * @param {boolean} [gammaRange=false] - The value for gammaRange. Defaults to false. gammaRange will be used for AreaModelCellGroups, but it's not implemented yet!
47
+ */
39
48
  constructor(e, r, a, t, n = !1) {
40
49
  this.r1 = e, this.c1 = r, this.r2 = a, this.c2 = t, this.gammaRange = n;
41
50
  }
@@ -674,28 +683,80 @@ class _ {
674
683
  init() {
675
684
  this.recalcSize(this.parentSize), this.overridingColumnWidth === -1 && this.calcXPositions(), this.headerAreaModel && this.headerAreaModel.init(), this.bodyAreaModel && this.bodyAreaModel.init(), this.footerAreaModel && this.footerAreaModel.init();
676
685
  }
686
+ /**
687
+ * Retrieves the count of columns in the current instance.
688
+ *
689
+ * @return {number} The count of columns.
690
+ */
677
691
  getColumnCount() {
678
692
  return this.columnCount;
679
693
  }
694
+ /**
695
+ * Sets the width in pixel of a column (by columnIndex) in a table.
696
+ *
697
+ * @param {number} columnIndex - The index of the column.
698
+ * @param {number} width - The desired width of the column.
699
+ * @return {void}
700
+ */
680
701
  setColumnWidth(e, r) {
681
702
  var a;
682
703
  r = Math.max(0, r), this.overridingColumnWidth !== -1 && (this.overridingColumnWidth = r), e > -1 && e < ((a = this.columnSizes) == null ? void 0 : a.length) && (this.columnSizes[e] = r), this.recalcContentWidthInPx();
683
704
  }
705
+ /**
706
+ * Retrieves the width of a column specified by its index.
707
+ *
708
+ * @param {number} columnIndex - The index of the desired column.
709
+ * @return {number} - The width of the specified column.
710
+ */
684
711
  getColumnWidth(e) {
685
712
  var a;
686
713
  const r = this.getColumnDef(e);
687
714
  return r && r.isVisible && !r.isVisible() ? 0 : this.overridingColumnWidth !== -1 ? this.overridingColumnWidth : e > -1 && e < ((a = this.columnSizes) == null ? void 0 : a.length) ? this.columnSizes[e] : 0;
688
715
  }
716
+ /**
717
+ * Retrieves the x position for a given column index.
718
+ *
719
+ * @param {number} columnIndex - The index of the column.
720
+ * @return {number} - The x position of the column.
721
+ */
689
722
  getXPosByColumnIndex(e) {
690
723
  return e === 0 ? 0 : this.overridingColumnWidth > -1 ? this.overridingColumnWidth * e : this.xPositions[e];
691
724
  }
725
+ /**
726
+ * Recalculates the size (width, height, padding) of the elements based on the client width.
727
+ *
728
+ * @param {number} clientWidth - The width of the client area.
729
+ *
730
+ * @return {void} - This method does not return a value.
731
+ */
692
732
  recalcSize(e) {
693
733
  this.recalcColumnWidthes(e), this.recalcHeightAndPadding();
694
734
  }
735
+ /**
736
+ * Recalculates the height and padding for the body area.
737
+ *
738
+ * This method retrieves the area model for the "body" area,
739
+ * and updates the rowCount property with the row count of the model.
740
+ *
741
+ * The contentHeightInPx property is then updated with the height of the "body" area.
742
+ *
743
+ * The method calls the recalcContentWidthInPx() method to recalculate the content width.
744
+ *
745
+ * Finally, the method calls the recalcPadding() method to recalculate the padding.
746
+ *
747
+ * @return {void}
748
+ */
695
749
  recalcHeightAndPadding() {
696
750
  const e = this.getAreaModel("body");
697
751
  this.rowCount = e.getRowCount(), this.contentHeightInPx = this.getAreaHeight("body"), this.recalcContentWidthInPx(), this.recalcPadding();
698
752
  }
753
+ /**
754
+ * Recalculates the padding of an element based on the width and height of its surrounding areas.
755
+ *
756
+ * @method recalcPadding
757
+ *
758
+ * @returns {void}
759
+ */
699
760
  recalcPadding() {
700
761
  const e = this.getSideAreaWidth("west"), r = this.getSideAreaWidth("east"), a = this.getAreaHeight("header"), t = this.getAreaHeight("footer");
701
762
  this.padding = new re(
@@ -705,21 +766,55 @@ class _ {
705
766
  e
706
767
  );
707
768
  }
769
+ /**
770
+ * Retrieves the padding value.
771
+ *
772
+ * @returns {Padding} The padding value.
773
+ */
708
774
  getPadding() {
709
775
  return this.padding;
710
776
  }
777
+ /**
778
+ * Returns the height of the content in pixels.
779
+ *
780
+ * @returns {number} The height of the content in pixels.
781
+ */
711
782
  getContentHeightInPixel() {
712
783
  return this.contentHeightInPx;
713
784
  }
785
+ /**
786
+ * Returns the width of the content in pixels.
787
+ *
788
+ * @returns {number} The width of the content in pixels.
789
+ */
714
790
  getContentWidthInPixel() {
715
791
  return this.contentWidthInPx;
716
792
  }
793
+ /**
794
+ * Returns the height of the specified row in the given row area identifier.
795
+ *
796
+ * @param {AreaIdent} rowAreaIdent - The row area identifier.
797
+ * @param {number} rowIndex - The index of the row.
798
+ * @return {number} - The height of the specified row.
799
+ */
717
800
  getRowHeight(e, r) {
718
801
  return this.getAreaModel(e).getRowHeight(r);
719
802
  }
803
+ /**
804
+ * Retrieves the model for the given row area identifier.
805
+ *
806
+ * @param {AreaIdent} rowAreaIdent - The identifier of the row area.
807
+ * @return {AreaModelIf} - The model of the specified row area.
808
+ */
720
809
  getModel(e) {
721
810
  return this.getAreaModel(e);
722
811
  }
812
+ /**
813
+ * Calculates the height of the area identified by the given area identifier.
814
+ *
815
+ * @param {AreaIdent} areaIdent - The identifier of the area.
816
+ * @return {number} - The height of the area.
817
+ */
723
818
  getAreaHeight(e) {
724
819
  const r = this.getModel(e), a = r.getRowCount();
725
820
  if (this.defaultRowHeights[e])
@@ -729,6 +824,12 @@ class _ {
729
824
  t = t + r.getRowHeight(n);
730
825
  return t;
731
826
  }
827
+ /**
828
+ * Returns the total width of the side area identified by sideIdent.
829
+ *
830
+ * @param {SideIdent} sideIdent - The identifier of the side area ("west" | "center" | "east").
831
+ * @return {number} - The total width in pixels of the side area.
832
+ */
732
833
  getSideAreaWidth(e) {
733
834
  const [r, a] = this.getSideStartAndEndColumnIndex(e);
734
835
  let t = 0;
@@ -736,21 +837,50 @@ class _ {
736
837
  t = t + this.getColumnWidth(n);
737
838
  return t;
738
839
  }
840
+ /**
841
+ * Retrieves the start and end column indices based on the given side identifier.
842
+ *
843
+ * @param {SideIdent} sideIdent - The side identifier, which can be "west", "east", or "center".
844
+ * @return {[number, number]} - An array containing the start and end column indices.
845
+ */
739
846
  getSideStartAndEndColumnIndex(e) {
740
847
  const r = this.getFixedLeftColumnCount(), a = this.getFixedRightColumnCount();
741
848
  let t = 0, n = this.columnCount - 1;
742
849
  return e === "west" ? n = r - 1 : e === "east" ? t = this.columnCount - a : (t = r, n = this.columnCount - a - 1), [t, n];
743
850
  }
851
+ /**
852
+ * Returns the column definition at the specified index.
853
+ *
854
+ * @param {number} index - The index of the column definition to retrieve.
855
+ * @returns {ColumnDefIf | undefined} - The column definition at the specified index, or undefined if no ColumnDef is specified for the given column
856
+ */
744
857
  getColumnDef(e) {
745
858
  if (e < this.columnDefs.length)
746
859
  return this.columnDefs[e];
747
860
  }
861
+ /**
862
+ * Retrieves the count of fixed left columns.
863
+ *
864
+ * @returns {number} The count of fixed left columns.
865
+ */
748
866
  getFixedLeftColumnCount() {
749
867
  return this.fixedLeftColumnCount;
750
868
  }
869
+ /**
870
+ * Returns the number of fixed right columns.
871
+ *
872
+ * @returns {number} The number of fixed right columns.
873
+ */
751
874
  getFixedRightColumnCount() {
752
875
  return this.fixedRightColumnCount;
753
876
  }
877
+ /**
878
+ * Retrieves the area model (header, body or footer) based on the area identification.
879
+ *
880
+ * @param {AreaIdent} area - The identifier of the area.
881
+ * @return {AreaModelIf} The area model corresponding to the given area identification.
882
+ * @throws {Error} If the area identification is invalid.
883
+ */
754
884
  getAreaModel(e) {
755
885
  if (e === "header")
756
886
  return this.headerAreaModel;
@@ -760,38 +890,103 @@ class _ {
760
890
  return this.footerAreaModel;
761
891
  throw new Error("Wrong ident.");
762
892
  }
893
+ /**
894
+ * Returns the body area model.
895
+ *
896
+ * @returns {AreaModelIf} The body area model.
897
+ */
763
898
  getBodyModel() {
764
899
  return this.bodyAreaModel;
765
900
  }
901
+ /**
902
+ * Checks if the footer is visible.
903
+ *
904
+ * @returns {boolean} True if the footer is visible, false otherwise.
905
+ */
766
906
  isFooterVisibe() {
767
907
  var e;
768
908
  return (((e = this.footerAreaModel) == null ? void 0 : e.getRowCount()) ?? 0) > 0;
769
909
  }
910
+ /**
911
+ * Checks if the header area is visible.
912
+ * @return {boolean} Returns true if the header area is visible, otherwise false.
913
+ */
770
914
  isHeaderVisibe() {
771
915
  var e;
772
916
  return (((e = this.headerAreaModel) == null ? void 0 : e.getRowCount()) ?? 0) > 0;
773
917
  }
918
+ /**
919
+ * Checks whether the row checkbox is visible.
920
+ *
921
+ * @returns {boolean} True if the row checkbox is visible, otherwise false.
922
+ */
774
923
  isRowCheckboxVisible() {
775
924
  return this.rowCheckboxVisible;
776
925
  }
926
+ /**
927
+ * This method is called when an external filter is changed.
928
+ *
929
+ * @param {FilterFunction<T>} predictFn - The function used to predict whether an element should be filtered or not.
930
+ * @return {void}
931
+ */
777
932
  externalFilterChanged(e) {
778
933
  this.getAreaModel("body").externalFilterChanged(e);
779
934
  }
935
+ /**
936
+ * Sorts the items using the given sortItems array.
937
+ *
938
+ * @param {SortItem[]} sortItems - An array of sort items to sort the items.
939
+ * @return {boolean} - Returns true if the sorting is successful, otherwise false.
940
+ */
780
941
  doSort(e) {
781
942
  return this.getAreaModel("body").doSort(e);
782
943
  }
944
+ /**
945
+ * Returns an array of ColumnDefIf objects or undefined.
946
+ *
947
+ * @return {ColumnDefIf[] | undefined} An array of ColumnDefIf objects or undefined.
948
+ */
783
949
  getColumnDefs() {
784
950
  return this.columnDefs;
785
951
  }
952
+ /**
953
+ * Retrieves the property key of the table row business object associated with the specified column index.
954
+ * It's only available when columnDefs are specified.
955
+ *
956
+ * @param {number} columnIndex - The index of the column to retrieve the property from.
957
+ * @return {string} The property associated with the specified column index.
958
+ */
786
959
  getColumnProperty(e) {
787
- return this.columnDefs[e].property;
960
+ return this.columnDefs ? this.columnDefs[e].property : "";
788
961
  }
962
+ /**
963
+ * Retrieves the row object from the body model at the specified index.
964
+ *
965
+ * @param {number} rowIndex - The index of the row to retrieve.
966
+ *
967
+ * @return {any} The row object at the specified index.
968
+ */
789
969
  getBodyRowByIndex(e) {
790
970
  return this.getBodyModel().getRowByIndex(e);
791
971
  }
972
+ /**
973
+ * Checks if a column at the given index is sortable.
974
+ *
975
+ * @param {number} columnIndex - The index of the column to check.
976
+ *
977
+ * @returns {boolean} - `true` if the column is sortable, `false` otherwise.
978
+ */
792
979
  isSortable(e) {
793
980
  return this.columnDefs && e < this.columnDefs.length && this.columnDefs[e].sortable ? this.columnDefs[e].sortable() : !1;
794
981
  }
982
+ /**
983
+ * Moves a column in the column order.
984
+ *
985
+ * @param {number} sourceColumnIndex - The index of the column to be moved.
986
+ * @param {number} targetColumnIndex - The index where the column should be moved to.
987
+ *
988
+ * @returns {void}
989
+ */
795
990
  changeColumnOrder(e, r) {
796
991
  var a, t, n;
797
992
  this.arrayMove(this.columnDefs, e, r), this.arrayMove(this.columnSizes, e, r), (a = this.headerAreaModel) == null || a.changeColumnOrder(e, r), (t = this.bodyAreaModel) == null || t.changeColumnOrder(e, r), (n = this.footerAreaModel) == null || n.changeColumnOrder(e, r), this.calcXPositions();
@@ -219151,11 +219346,13 @@ const H = [
219151
219346
  children: [
219152
219347
  {
219153
219348
  data: "Gold A",
219154
- property: "GOLD_A"
219349
+ property: "GOLD_A",
219350
+ visibility: "inverted"
219155
219351
  },
219156
219352
  {
219157
219353
  data: "Gold B",
219158
- property: "GOLD_B"
219354
+ property: "GOLD_B",
219355
+ visibility: "inverted"
219159
219356
  }
219160
219357
  ]
219161
219358
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guiexpert/demo-table-models",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",