@progress/kendo-spreadsheet-common 1.0.0-develop.11 → 1.0.0-develop.12

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/dist/index-esm.js CHANGED
@@ -3060,6 +3060,18 @@ function parseDate(str, format) {
3060
3060
  ]);
3061
3061
  }
3062
3062
 
3063
+ function defineAlias(alias, name) {
3064
+ var orig = FUNCS[name];
3065
+ if (!orig) {
3066
+ throw new Error("Function " + name + " is not yet defined");
3067
+ }
3068
+ if (!orig.kendoSpreadsheetAliases) {
3069
+ orig.kendoSpreadsheetAliases = [ name ];
3070
+ }
3071
+ orig.kendoSpreadsheetAliases.push(alias);
3072
+ FUNCS[alias] = orig;
3073
+ }
3074
+
3063
3075
  /* -----[ exports ]----- */
3064
3076
 
3065
3077
  calc.runtime.CalcError = CalcError;
@@ -3078,24 +3090,8 @@ calc.runtime.isLeapYear = isLeapYear;
3078
3090
  calc.runtime.daysInYear = daysInYear;
3079
3091
  calc.runtime.parseDate = parseDate;
3080
3092
  calc.runtime.limitPrecision = limitPrecision;
3081
-
3082
- // spreadsheet.dateToNumber = dateToSerial;
3083
- // spreadsheet.numberToDate = serialToDate;
3084
- // spreadsheet.defineFunction = defineFunction;
3085
- // spreadsheet.CalcError = CalcError;
3086
-
3087
3093
  calc.runtime.defineFunction = defineFunction;
3088
- calc.runtime.defineAlias = function(alias, name) {
3089
- var orig = FUNCS[name];
3090
- if (!orig) {
3091
- throw new Error("Function " + name + " is not yet defined");
3092
- }
3093
- if (!orig.kendoSpreadsheetAliases) {
3094
- orig.kendoSpreadsheetAliases = [ name ];
3095
- }
3096
- orig.kendoSpreadsheetAliases.push(alias);
3097
- FUNCS[alias] = orig;
3098
- };
3094
+ calc.runtime.defineAlias = defineAlias;
3099
3095
 
3100
3096
  /* -----[ Excel operators ]----- */
3101
3097
 
@@ -21933,7 +21929,7 @@ class FormulaInput extends Widget {
21933
21929
  return;
21934
21930
  }
21935
21931
 
21936
- const data = this.formulaSource.filter((item) => String(item.value).startsWith(value.toLowerCase()));
21932
+ const data = this.formulaSource.filter((item) => String(item.value).toLowerCase().startsWith(value.toLowerCase()));
21937
21933
 
21938
21934
  this.list.data(data);
21939
21935
 
@@ -28225,4 +28221,4 @@ class SpreadsheetWidget extends Widget {
28225
28221
  }
28226
28222
  }
28227
28223
 
28228
- export { Range$1 as Range, Sheet, SpreadsheetWidget, View, Workbook };
28224
+ export { CalcError, CellRef, Context, Matrix, NULLREF, NameRef, Range$1 as Range, RangeRef, Ref, Sheet, SpreadsheetWidget, UnionRef, View, Workbook, dateToSerial, defineAlias, defineFunction, packDate, packTime, serialToDate, unpackDate, unpackTime };
package/dist/index.js CHANGED
@@ -3061,6 +3061,18 @@
3061
3061
  ]);
3062
3062
  }
3063
3063
 
3064
+ function defineAlias(alias, name) {
3065
+ var orig = FUNCS[name];
3066
+ if (!orig) {
3067
+ throw new Error("Function " + name + " is not yet defined");
3068
+ }
3069
+ if (!orig.kendoSpreadsheetAliases) {
3070
+ orig.kendoSpreadsheetAliases = [ name ];
3071
+ }
3072
+ orig.kendoSpreadsheetAliases.push(alias);
3073
+ FUNCS[alias] = orig;
3074
+ }
3075
+
3064
3076
  /* -----[ exports ]----- */
3065
3077
 
3066
3078
  calc.runtime.CalcError = CalcError;
@@ -3079,24 +3091,8 @@
3079
3091
  calc.runtime.daysInYear = daysInYear;
3080
3092
  calc.runtime.parseDate = parseDate;
3081
3093
  calc.runtime.limitPrecision = limitPrecision;
3082
-
3083
- // spreadsheet.dateToNumber = dateToSerial;
3084
- // spreadsheet.numberToDate = serialToDate;
3085
- // spreadsheet.defineFunction = defineFunction;
3086
- // spreadsheet.CalcError = CalcError;
3087
-
3088
3094
  calc.runtime.defineFunction = defineFunction;
3089
- calc.runtime.defineAlias = function(alias, name) {
3090
- var orig = FUNCS[name];
3091
- if (!orig) {
3092
- throw new Error("Function " + name + " is not yet defined");
3093
- }
3094
- if (!orig.kendoSpreadsheetAliases) {
3095
- orig.kendoSpreadsheetAliases = [ name ];
3096
- }
3097
- orig.kendoSpreadsheetAliases.push(alias);
3098
- FUNCS[alias] = orig;
3099
- };
3095
+ calc.runtime.defineAlias = defineAlias;
3100
3096
 
3101
3097
  /* -----[ Excel operators ]----- */
3102
3098
 
@@ -21934,7 +21930,7 @@
21934
21930
  return;
21935
21931
  }
21936
21932
 
21937
- const data = this.formulaSource.filter((item) => String(item.value).startsWith(value.toLowerCase()));
21933
+ const data = this.formulaSource.filter((item) => String(item.value).toLowerCase().startsWith(value.toLowerCase()));
21938
21934
 
21939
21935
  this.list.data(data);
21940
21936
 
@@ -28226,10 +28222,27 @@
28226
28222
  }
28227
28223
  }
28228
28224
 
28225
+ exports.CalcError = CalcError;
28226
+ exports.CellRef = CellRef;
28227
+ exports.Context = Context;
28228
+ exports.Matrix = Matrix;
28229
+ exports.NULLREF = NULLREF;
28230
+ exports.NameRef = NameRef;
28229
28231
  exports.Range = Range$1;
28232
+ exports.RangeRef = RangeRef;
28233
+ exports.Ref = Ref;
28230
28234
  exports.Sheet = Sheet;
28231
28235
  exports.SpreadsheetWidget = SpreadsheetWidget;
28236
+ exports.UnionRef = UnionRef;
28232
28237
  exports.View = View;
28233
28238
  exports.Workbook = Workbook;
28239
+ exports.dateToSerial = dateToSerial;
28240
+ exports.defineAlias = defineAlias;
28241
+ exports.defineFunction = defineFunction;
28242
+ exports.packDate = packDate;
28243
+ exports.packTime = packTime;
28244
+ exports.serialToDate = serialToDate;
28245
+ exports.unpackDate = unpackDate;
28246
+ exports.unpackTime = unpackTime;
28234
28247
 
28235
28248
  }));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@progress/kendo-spreadsheet-common",
3
3
  "description": "Kendo UI platform-independent Spreadsheet library",
4
- "version": "1.0.0-develop.11",
4
+ "version": "1.0.0-develop.12",
5
5
  "keywords": [
6
6
  "Kendo UI"
7
7
  ],
package/src/index.d.ts CHANGED
@@ -754,3 +754,236 @@ export class SpreadsheetWidget {
754
754
  */
755
755
  destroy(): void;
756
756
  }
757
+
758
+ /**
759
+ * The context object of the custom JavaScript functions (primitives) in formulas.
760
+ */
761
+ export class Context {
762
+ /**
763
+ * Verifies that all references in the given array are resolved before invoking your callback—that is, executes any formula.
764
+ * If this array turns out to include the cell where the current formula lives, it returns a `#CIRCULAR!` error. Elements that are not references are ignored.
765
+ */
766
+ resolveCells(array: Ref[] | Ref[][], callback: () => any): any;
767
+
768
+ /**
769
+ * Returns as a flat array the values in any reference that exist in the given array. Elements that are not references are copied over.
770
+ */
771
+ cellValues(array: (Ref | Matrix)[] | Ref | Matrix): any;
772
+
773
+ /**
774
+ * Converts the given argument to a matrix, if possible.
775
+ * It accepts a `RangeRef` object or a plain JavaScript non-empty array.
776
+ * Additionally, if a `Matrix` object is provided, it is returned as is.
777
+ */
778
+ asMatrix(arg: RangeRef | RangeRef[] | Matrix): Matrix;
779
+
780
+ /**
781
+ * Returns the `Workbook` object where the current formula is evaluated.
782
+ */
783
+ workbook(): Workbook;
784
+
785
+ /**
786
+ * Returns the data that is the value in the given reference.
787
+ * If a `CellRef` is given, it returns a single value. For a `RangeRef` or `UnionRef`, it returns a flat array of values.
788
+ */
789
+ getRefData(ref: CellRef | RangeRef | UnionRef): any;
790
+ }
791
+
792
+ /**
793
+ * The "matrix" type which can be used in the custom JavaScript functions (primitives) in formulas.
794
+ */
795
+ export class Matrix {
796
+ constructor(context: Context);
797
+ /**
798
+ * Indicate the width of the matrix.
799
+ */
800
+ width: number;
801
+
802
+ /**
803
+ * Indicate the height of the matrix.
804
+ */
805
+ height: number;
806
+
807
+ /**
808
+ * Returns a new matrix with the same data.
809
+ */
810
+ clone(): Matrix;
811
+
812
+ /**
813
+ * Returns the element at a given location.
814
+ */
815
+ get(row: number, col: number): any;
816
+
817
+ /**
818
+ * Sets the element at a given location.
819
+ */
820
+ set(row: number, col: number, value: any): void;
821
+
822
+ /**
823
+ * Iterates through elements of the matrix and calling the `func` for each element (first columns, then rows).
824
+ *
825
+ * @param func The function which will be called for each element.
826
+ * @param includeEmpty If `true`, it will call the function for empty (`null`) elements as well. Otherwise, it only calls it where a value exists.
827
+ */
828
+ each(func: (value: any, row: number, column: number) => void, includeEmpty: boolean): void;
829
+
830
+ /**
831
+ * Similar to `each`, but produces a new matrix of the same shape as the original one with the values returned by the function.
832
+ *
833
+ * @param func The function which will be called for each element.
834
+ * @param includeEmpty If `true`, it will call the function for empty (`null`) elements as well. Otherwise, it only calls it where a value exists.
835
+ */
836
+ map(func: (value: any, row: number, column: number) => void, includeEmpty: boolean): Matrix;
837
+
838
+ /**
839
+ * Returns the transposed matrix. The rows of the original matrix become columns of the transposed one.
840
+ */
841
+ transpose(): Matrix;
842
+
843
+ /**
844
+ * Returns the unit square matrix of size `n`.
845
+ */
846
+ unit(n: number): Matrix;
847
+
848
+ /**
849
+ * Multiplies the current matrix by the given matrix, and returns a new matrix as the result.
850
+ */
851
+ multiply(m: Matrix): Matrix;
852
+
853
+ /**
854
+ * Returns the determinant of this matrix. The matrix should contain only numbers and be square. Note that there are no checks for this.
855
+ */
856
+ determinant(): number;
857
+
858
+ /**
859
+ * Returns the inverse of this matrix. The matrix should contain only numbers and be square.
860
+ * Note that there are no checks for this. If the inverse does not exist, the determinant is zero, then it returns `null`.
861
+ */
862
+ inverse(): Matrix | null;
863
+ }
864
+
865
+ /**
866
+ * A class from which formula calculation errors will be instantiated.
867
+ */
868
+ export class CalcError {
869
+ /**
870
+ * The error code.
871
+ */
872
+ code: string;
873
+ }
874
+
875
+ /**
876
+ * A base class only. All references inherit from it, but no direct instance of this object should ever be created.
877
+ * The class is exported just to make it easier to check whether something is a reference: `x instanceof Ref`.
878
+ */
879
+ export class Ref {
880
+ /**
881
+ * The name of the sheet that this cell points to.
882
+ */
883
+ sheet: string;
884
+ }
885
+
886
+ /**
887
+ * Represents a cell reference. Note that the references do not contain data.
888
+ * Instead they just point to where the data is.
889
+ */
890
+ export class CellRef extends Ref {
891
+ /**
892
+ * The row number, zero-based.
893
+ */
894
+ row: number;
895
+ /**
896
+ * The column number, zero-based.
897
+ */
898
+ col: number;
899
+ }
900
+
901
+ /**
902
+ * Represents a name cell reference.
903
+ */
904
+ export class NameRef extends Ref { }
905
+
906
+ /**
907
+ * A range reference.
908
+ */
909
+ export class RangeRef extends Ref {
910
+ /**
911
+ * The top-left CellRef of the range.
912
+ */
913
+ topLeft: CellRef;
914
+ /**
915
+ * The bottom-right CellRef of the range.
916
+ */
917
+ bottomRight: CellRef;
918
+ }
919
+
920
+ /**
921
+ * A union. It contains a refs property, which is an array of references (it can be empty).
922
+ * A UnionRef can be created by the union operator, which is the comma.
923
+ */
924
+ export class UnionRef extends Ref {
925
+ refs: (CellRef | RangeRef)[];
926
+ }
927
+ export class NULLREFClass {}
928
+
929
+ /**
930
+ * An object (a singleton) and not a class.
931
+ * It represents the NULL reference, and could occur, for example, when you intersect two disjoint ranges, or when a formula depends on a cell that has been deleted.
932
+ * For example, when you put in some cell `=test(B5)` and then right-click on column `B` and delete it.
933
+ * To test when something is the `NULL` reference, just do `x === NULLREF`.
934
+ */
935
+ export const NULLREF: NULLREFClass;
936
+
937
+ /**
938
+ * Converts date parameters to number.
939
+ */
940
+ export function packDate(year: number, month: number, date: number): number;
941
+
942
+ /**
943
+ * Converts number to date parameters.
944
+ */
945
+ export function unpackDate(serial: number): {
946
+ year: number;
947
+ month: number;
948
+ date: number;
949
+ day: number;
950
+ ord: number
951
+ };
952
+
953
+ /**
954
+ * Converts time parameters to number.
955
+ */
956
+ export function packTime(hh: number, mm: number, ss: number, ms: number): number;
957
+
958
+ /**
959
+ * Converts number to time parameters.
960
+ */
961
+ export function unpackTime(serial: number): {
962
+ hours: number;
963
+ minutes: number;
964
+ seconds: number;
965
+ milliseconds: number
966
+ };
967
+
968
+ /**
969
+ * Converts number to date.
970
+ */
971
+ export function serialToDate(serial: number): Date;
972
+
973
+ /**
974
+ * Converts date to number.
975
+ */
976
+ export function dateToSerial(date: Date): number;
977
+
978
+ /**
979
+ * Defines custom formula.
980
+ */
981
+ export function defineFunction(name: string, func: Function): {
982
+ args(args: any, log: any): any;
983
+ argsAsync(args: any, log: any): any;
984
+ };
985
+
986
+ /**
987
+ * Defines alias of a formula.
988
+ */
989
+ export function defineAlias(alias: string, name: string): void;