@ifto/mantine-kit 0.5.1 → 0.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.
@@ -29,11 +29,12 @@ export type NumbersMapFunction = (number1: number, number2: number) => number;
29
29
  export declare function arraysMap(array1: number[], array2: number[], operation: NumbersMapFunction, defaultItemValue?: number): number[];
30
30
  /**
31
31
  * Transposes a matrix, turning the rows into columns and vice versa.
32
- * @param matrix matrix to transpose, where each row is an array of values
32
+ * @param matrix matrix to transpose, where each row is an array of values of any type
33
33
  * @param defaultValForUndefinedCol value used when a row has no value for a column, which happens when the rows have
34
- * different sizes. Without it, the missing column is `undefined`. The parameter has no default value on purpose:
34
+ * different sizes. It also replaces an element that is already `undefined` or `null` in the matrix. Without it,
35
+ * the missing column is `undefined`. The parameter has no default value on purpose:
35
36
  * in JavaScript, passing `undefined` to a parameter with a default uses the default, so an `undefined`
36
37
  * explicitly asked by the caller would become another value.
37
38
  * @return the transposed matrix
38
39
  */
39
- export declare function transposeMatrix(matrix: number[][], defaultValForUndefinedCol?: number): number[][];
40
+ export declare function transposeMatrix<T>(matrix: T[][], defaultValForUndefinedCol?: T): (T | undefined)[][];
@@ -32,9 +32,10 @@ function arraysMap(array1, array2, operation, defaultItemValue = 0) {
32
32
  }
33
33
  /**
34
34
  * Transposes a matrix, turning the rows into columns and vice versa.
35
- * @param matrix matrix to transpose, where each row is an array of values
35
+ * @param matrix matrix to transpose, where each row is an array of values of any type
36
36
  * @param defaultValForUndefinedCol value used when a row has no value for a column, which happens when the rows have
37
- * different sizes. Without it, the missing column is `undefined`. The parameter has no default value on purpose:
37
+ * different sizes. It also replaces an element that is already `undefined` or `null` in the matrix. Without it,
38
+ * the missing column is `undefined`. The parameter has no default value on purpose:
38
39
  * in JavaScript, passing `undefined` to a parameter with a default uses the default, so an `undefined`
39
40
  * explicitly asked by the caller would become another value.
40
41
  * @return the transposed matrix
@@ -1 +1 @@
1
- {"version":3,"file":"ArrayUtil.js","names":[],"sources":["../../src/util/ArrayUtil.ts"],"sourcesContent":["/**\n * Creates an array of the given size, with the values from 0 to size - 1.\n * @param size size of the array\n */\nexport function createSequentialArray(size: number): number[] {\n return Array.from({ length: size }, (_, i) => i);\n}\n\n/**\n * Creates an array of any size, filled with the given value.\n * @param size size of the array\n * @param fillValue value of every element\n */\nexport function createFilledArray(size: number, fillValue: number = 0): number[] {\n return Array(size).fill(fillValue);\n}\n\n/**\n * Operation over two numbers that returns a new value from them.\n * @param number1 a number\n * @param number2 another number\n * @return a new value computed from the two numbers\n */\nexport type NumbersMapFunction = (number1: number, number2: number) => number;\n\n/**\n * Applies an operation to the elements at the same position of two arrays, mapping each pair of values to a new value.\n * @param array1 an array\n * @param array2 another array\n * @param operation operation applied to each pair of elements at the same position (see {@link NumbersMapFunction})\n * @param defaultItemValue value used when one array has no element at a position of the other one (when the arrays\n * have different sizes). A `NaN` (e.g. an empty year) is not replaced by the default: it propagates, so the\n * result for that position is empty too.\n * @return a new array with the result of the operation for each position\n */\nexport function arraysMap(\n array1: number[],\n array2: number[],\n operation: NumbersMapFunction,\n defaultItemValue: number = 0\n): number[] {\n if (array1.length === 0) return array2;\n\n if (array2.length === 0) return array1;\n\n const maxLen = Math.max(array1.length, array2.length);\n\n /* An array with just the indexes of the longest array, so that the result has the size of the longest one while\n keeping the order of the arguments (which may change the result of the operation). */\n const indexesArray = createSequentialArray(maxLen);\n return indexesArray.map(i => operation(array1[i] ?? defaultItemValue, array2[i] ?? defaultItemValue));\n}\n\n/**\n * Transposes a matrix, turning the rows into columns and vice versa.\n * @param matrix matrix to transpose, where each row is an array of values\n * @param defaultValForUndefinedCol value used when a row has no value for a column, which happens when the rows have\n * different sizes. Without it, the missing column is `undefined`. The parameter has no default value on purpose:\n * in JavaScript, passing `undefined` to a parameter with a default uses the default, so an `undefined`\n * explicitly asked by the caller would become another value.\n * @return the transposed matrix\n */\nexport function transposeMatrix(matrix: number[][], defaultValForUndefinedCol?: number): number[][] {\n const reducer = (acc: number, curr: number) => (curr > acc ? curr : acc);\n\n // Length of the longest row of the matrix\n const maxCols = matrix.map(line => line.length).reduce(reducer, 0);\n const colIndexes = createSequentialArray(maxCols);\n // `??`, not `||`: a 0 (a real value) and a NaN (an empty year) are kept, and only a missing column uses the default.\n return colIndexes.map(col => matrix.map(line => line[col] ?? defaultValForUndefinedCol));\n}\n"],"mappings":";;;;;;AAIA,SAAgB,sBAAsB,MAAwB;CAC1D,OAAO,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAI,GAAG,MAAM,CAAC;AACnD;;;;;;AAOA,SAAgB,kBAAkB,MAAc,YAAoB,GAAa;CAC7E,OAAO,MAAM,IAAI,CAAC,CAAC,KAAK,SAAS;AACrC;;;;;;;;;;;AAoBA,SAAgB,UACZ,QACA,QACA,WACA,mBAA2B,GACnB;CACR,IAAI,OAAO,WAAW,GAAG,OAAO;CAEhC,IAAI,OAAO,WAAW,GAAG,OAAO;CAOhC,OADqB,sBAJN,KAAK,IAAI,OAAO,QAAQ,OAAO,MAIH,CACpC,CAAA,CAAa,KAAI,MAAK,UAAU,OAAO,MAAM,kBAAkB,OAAO,MAAM,gBAAgB,CAAC;AACxG;;;;;;;;;;AAWA,SAAgB,gBAAgB,QAAoB,2BAAgD;CAChG,MAAM,WAAW,KAAa,SAAkB,OAAO,MAAM,OAAO;CAMpE,OAFmB,sBADH,OAAO,KAAI,SAAQ,KAAK,MAAM,CAAC,CAAC,OAAO,SAAS,CACvB,CAElC,CAAA,CAAW,KAAI,QAAO,OAAO,KAAI,SAAQ,KAAK,QAAQ,yBAAyB,CAAC;AAC3F"}
1
+ {"version":3,"file":"ArrayUtil.js","names":[],"sources":["../../src/util/ArrayUtil.ts"],"sourcesContent":["/**\n * Creates an array of the given size, with the values from 0 to size - 1.\n * @param size size of the array\n */\nexport function createSequentialArray(size: number): number[] {\n return Array.from({ length: size }, (_, i) => i);\n}\n\n/**\n * Creates an array of any size, filled with the given value.\n * @param size size of the array\n * @param fillValue value of every element\n */\nexport function createFilledArray(size: number, fillValue: number = 0): number[] {\n return Array(size).fill(fillValue);\n}\n\n/**\n * Operation over two numbers that returns a new value from them.\n * @param number1 a number\n * @param number2 another number\n * @return a new value computed from the two numbers\n */\nexport type NumbersMapFunction = (number1: number, number2: number) => number;\n\n/**\n * Applies an operation to the elements at the same position of two arrays, mapping each pair of values to a new value.\n * @param array1 an array\n * @param array2 another array\n * @param operation operation applied to each pair of elements at the same position (see {@link NumbersMapFunction})\n * @param defaultItemValue value used when one array has no element at a position of the other one (when the arrays\n * have different sizes). A `NaN` (e.g. an empty year) is not replaced by the default: it propagates, so the\n * result for that position is empty too.\n * @return a new array with the result of the operation for each position\n */\nexport function arraysMap(\n array1: number[],\n array2: number[],\n operation: NumbersMapFunction,\n defaultItemValue: number = 0\n): number[] {\n if (array1.length === 0) return array2;\n\n if (array2.length === 0) return array1;\n\n const maxLen = Math.max(array1.length, array2.length);\n\n /* An array with just the indexes of the longest array, so that the result has the size of the longest one while\n keeping the order of the arguments (which may change the result of the operation). */\n const indexesArray = createSequentialArray(maxLen);\n return indexesArray.map(i => operation(array1[i] ?? defaultItemValue, array2[i] ?? defaultItemValue));\n}\n\n/**\n * Transposes a matrix, turning the rows into columns and vice versa.\n * @param matrix matrix to transpose, where each row is an array of values of any type\n * @param defaultValForUndefinedCol value used when a row has no value for a column, which happens when the rows have\n * different sizes. It also replaces an element that is already `undefined` or `null` in the matrix. Without it,\n * the missing column is `undefined`. The parameter has no default value on purpose:\n * in JavaScript, passing `undefined` to a parameter with a default uses the default, so an `undefined`\n * explicitly asked by the caller would become another value.\n * @return the transposed matrix\n */\nexport function transposeMatrix<T>(matrix: T[][], defaultValForUndefinedCol?: T): (T | undefined)[][] {\n const reducer = (acc: number, curr: number) => (curr > acc ? curr : acc);\n\n // Length of the longest row of the matrix\n const maxCols = matrix.map(line => line.length).reduce(reducer, 0);\n const colIndexes = createSequentialArray(maxCols);\n // `??`, not `||`: a 0 (a real value) and a NaN (an empty year) are kept, and only a missing column uses the default.\n return colIndexes.map(col => matrix.map(line => line[col] ?? defaultValForUndefinedCol));\n}\n"],"mappings":";;;;;;AAIA,SAAgB,sBAAsB,MAAwB;CAC1D,OAAO,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAI,GAAG,MAAM,CAAC;AACnD;;;;;;AAOA,SAAgB,kBAAkB,MAAc,YAAoB,GAAa;CAC7E,OAAO,MAAM,IAAI,CAAC,CAAC,KAAK,SAAS;AACrC;;;;;;;;;;;AAoBA,SAAgB,UACZ,QACA,QACA,WACA,mBAA2B,GACnB;CACR,IAAI,OAAO,WAAW,GAAG,OAAO;CAEhC,IAAI,OAAO,WAAW,GAAG,OAAO;CAOhC,OADqB,sBAJN,KAAK,IAAI,OAAO,QAAQ,OAAO,MAIH,CACpC,CAAA,CAAa,KAAI,MAAK,UAAU,OAAO,MAAM,kBAAkB,OAAO,MAAM,gBAAgB,CAAC;AACxG;;;;;;;;;;;AAYA,SAAgB,gBAAmB,QAAe,2BAAoD;CAClG,MAAM,WAAW,KAAa,SAAkB,OAAO,MAAM,OAAO;CAMpE,OAFmB,sBADH,OAAO,KAAI,SAAQ,KAAK,MAAM,CAAC,CAAC,OAAO,SAAS,CACvB,CAElC,CAAA,CAAW,KAAI,QAAO,OAAO,KAAI,SAAQ,KAAK,QAAQ,yBAAyB,CAAC;AAC3F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ifto/mantine-kit",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "General purpose Mantine components for React apps: CRUD tables and forms, layout, ECharts charts, Excel/CSV export, print pages and a REST HTTP client, with i18n (en-US and pt-BR).",
5
5
  "license": "MIT",
6
6
  "author": "IFTO - Campus Palmas",