@cosmotech/core 1.8.0 → 1.9.0

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/CHANGELOG.md CHANGED
@@ -1,8 +1,18 @@
1
+ ## **1.9.0** <sub><sup>2022-07-22 (aedf63f...3ee8718)</sup></sub>
2
+
3
+ ### Features
4
+
5
+ - implement scenarioIsValid function ([06d23d8](https://github.com/Cosmo-Tech/webapp-component-core/commit/06d23d8))
6
+
7
+ ### Bug Fixes
8
+
9
+ - fix error during parsing of CSV strings when columns list is undefined ([a72b5b5](https://github.com/Cosmo-Tech/webapp-component-core/commit/a72b5b5))
10
+
1
11
  ## **1.8.0** <sub><sup>2022-05-09 (5d61a0e...5317d94)</sup></sub>
2
12
 
3
13
  ### Features
4
- * support empty fields in table component ([5d61a0e](https://github.com/Cosmo-Tech/webapp-component-core/commit/5d61a0e))
5
14
 
15
+ - support empty fields in table component ([5d61a0e](https://github.com/Cosmo-Tech/webapp-component-core/commit/5d61a0e))
6
16
 
7
17
  ## **1.7.2** <sub><sup>2022-04-29</sup></sub>
8
18
 
package/dist/index.cjs.js CHANGED
@@ -32151,6 +32151,10 @@ var _buildCols = header => header.map(col => ({
32151
32151
  }));
32152
32152
 
32153
32153
  var _calculateEmptyCols = cols => {
32154
+ if (cols === undefined) {
32155
+ return [];
32156
+ }
32157
+
32154
32158
  return cols.map((_, index) => index).filter(colIndex => {
32155
32159
  var _cols$colIndex$cellEd;
32156
32160
 
@@ -32715,6 +32719,10 @@ var DatasetUtils = {
32715
32719
 
32716
32720
  // Copyright (c) Cosmo Tech.
32717
32721
  // Licensed under the MIT license.
32722
+ var NAME_VALIDATOR = /^[a-zA-Z0-9][\w\s.-]*$/;
32723
+
32724
+ // Copyright (c) Cosmo Tech.
32725
+
32718
32726
  var scenarioExistsInList = (scenarioName, scenarioList) => {
32719
32727
  scenarioName = scenarioName.trim();
32720
32728
  return scenarioList.find(scenario => scenario.name.trim() === scenarioName) !== undefined;
@@ -32734,6 +32742,22 @@ var scenarioExistsInTree = (scenarioName, scenarioTree) => {
32734
32742
  return treeSearch(scenarioTree);
32735
32743
  };
32736
32744
 
32745
+ var scenarioNameIsValid = (scenarioName, scenarioList) => {
32746
+ scenarioName = scenarioName.trimEnd();
32747
+
32748
+ if (scenarioName.length === 0) {
32749
+ return 'emptyScenarioName';
32750
+ } else {
32751
+ if (scenarioName.match(NAME_VALIDATOR) === null) {
32752
+ return 'forbiddenCharsInScenarioName';
32753
+ } else if (scenarioExistsInList(scenarioName, scenarioList)) {
32754
+ return 'existingScenarioName';
32755
+ }
32756
+ }
32757
+
32758
+ return null;
32759
+ };
32760
+
32737
32761
  var getScenarioTree = (scenarioList, compareFn) => {
32738
32762
  var scenarioTree = []; // Sort scenario list based on optional user-defined function
32739
32763
 
@@ -32777,6 +32801,7 @@ function countScenariosInTree(treeData) {
32777
32801
  var ScenarioUtils = {
32778
32802
  scenarioExistsInList,
32779
32803
  scenarioExistsInTree,
32804
+ scenarioNameIsValid,
32780
32805
  getScenarioTree,
32781
32806
  countScenariosInTree
32782
32807
  };
package/dist/index.esm.js CHANGED
@@ -32143,6 +32143,10 @@ var _buildCols = header => header.map(col => ({
32143
32143
  }));
32144
32144
 
32145
32145
  var _calculateEmptyCols = cols => {
32146
+ if (cols === undefined) {
32147
+ return [];
32148
+ }
32149
+
32146
32150
  return cols.map((_, index) => index).filter(colIndex => {
32147
32151
  var _cols$colIndex$cellEd;
32148
32152
 
@@ -32707,6 +32711,10 @@ var DatasetUtils = {
32707
32711
 
32708
32712
  // Copyright (c) Cosmo Tech.
32709
32713
  // Licensed under the MIT license.
32714
+ var NAME_VALIDATOR = /^[a-zA-Z0-9][\w\s.-]*$/;
32715
+
32716
+ // Copyright (c) Cosmo Tech.
32717
+
32710
32718
  var scenarioExistsInList = (scenarioName, scenarioList) => {
32711
32719
  scenarioName = scenarioName.trim();
32712
32720
  return scenarioList.find(scenario => scenario.name.trim() === scenarioName) !== undefined;
@@ -32726,6 +32734,22 @@ var scenarioExistsInTree = (scenarioName, scenarioTree) => {
32726
32734
  return treeSearch(scenarioTree);
32727
32735
  };
32728
32736
 
32737
+ var scenarioNameIsValid = (scenarioName, scenarioList) => {
32738
+ scenarioName = scenarioName.trimEnd();
32739
+
32740
+ if (scenarioName.length === 0) {
32741
+ return 'emptyScenarioName';
32742
+ } else {
32743
+ if (scenarioName.match(NAME_VALIDATOR) === null) {
32744
+ return 'forbiddenCharsInScenarioName';
32745
+ } else if (scenarioExistsInList(scenarioName, scenarioList)) {
32746
+ return 'existingScenarioName';
32747
+ }
32748
+ }
32749
+
32750
+ return null;
32751
+ };
32752
+
32729
32753
  var getScenarioTree = (scenarioList, compareFn) => {
32730
32754
  var scenarioTree = []; // Sort scenario list based on optional user-defined function
32731
32755
 
@@ -32769,6 +32793,7 @@ function countScenariosInTree(treeData) {
32769
32793
  var ScenarioUtils = {
32770
32794
  scenarioExistsInList,
32771
32795
  scenarioExistsInTree,
32796
+ scenarioNameIsValid,
32772
32797
  getScenarioTree,
32773
32798
  countScenariosInTree
32774
32799
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cosmotech/core",
3
3
  "private": false,
4
- "version": "1.8.0",
4
+ "version": "1.9.0",
5
5
  "description": "",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.esm.js",