@kontur.candy/generator 5.122.0-test-9115.0 → 5.123.0-validation-choices.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.
Files changed (2) hide show
  1. package/dist/index.js +47 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -62511,6 +62511,7 @@ class FormSchemaRngElement {
62511
62511
  this.useServerFilters = void 0;
62512
62512
  this.attributes = new Map();
62513
62513
  this.parent = void 0;
62514
+ this.choices = [];
62514
62515
  this.optional = void 0;
62515
62516
  this.nillable = void 0;
62516
62517
  this.editorOnly = void 0;
@@ -62534,6 +62535,9 @@ class FormSchemaRngElement {
62534
62535
  addAttribute(attribute) {
62535
62536
  this.attributes.set(attribute.name, attribute);
62536
62537
  }
62538
+ setChoices(choices) {
62539
+ this.choices.push(choices);
62540
+ }
62537
62541
  setInnerTextType(type) {
62538
62542
  this.innerTextType = type;
62539
62543
  }
@@ -62601,9 +62605,17 @@ class FormSchemaRng {
62601
62605
  result.addElement(this.convertSchemaRngElement(childElement, result));
62602
62606
  }
62603
62607
  for (const childChoiceElement of schemaRngElement.choices) {
62608
+ const choiceChildren = new Map();
62609
+ const rngElements = [];
62604
62610
  for (const childElement of childChoiceElement.children) {
62605
- result.addElement(this.convertSchemaRngElement(childElement, result));
62611
+ const rngElement = this.convertSchemaRngElement(childElement, result);
62612
+ rngElements.push(rngElement);
62613
+ choiceChildren.set(childElement.name, rngElement);
62606
62614
  }
62615
+ rngElements.forEach(rngElement => {
62616
+ rngElement.setChoices(choiceChildren);
62617
+ result.addElement(rngElement);
62618
+ });
62607
62619
  }
62608
62620
  }
62609
62621
  return result;
@@ -62751,6 +62763,13 @@ class FormSchemaRng {
62751
62763
  optional: true
62752
62764
  };
62753
62765
  }
62766
+ if (currentElement instanceof FormSchemaRngElement && currentElement.choices.length > 0) {
62767
+ return {
62768
+ dependencies: [],
62769
+ hasOptionalParent: false,
62770
+ optional: false
62771
+ };
62772
+ }
62754
62773
  if (endOptionalElement == undefined || endOptionalElement instanceof FormSchemaRngElement && ((_endOptionalElement = endOptionalElement) === null || _endOptionalElement === void 0 ? void 0 : _endOptionalElement.multiple) === true) {
62755
62774
  return {
62756
62775
  dependencies: [],
@@ -105164,7 +105183,8 @@ class MarkupBuildingContext {
105164
105183
  __webpack_require__.r(__webpack_exports__);
105165
105184
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
105166
105185
  /* harmony export */ KCLangCalculationsBuildContext: () => (/* binding */ KCLangCalculationsBuildContext),
105167
- /* harmony export */ combineByAndKCLangExpr: () => (/* binding */ combineByAndKCLangExpr)
105186
+ /* harmony export */ combineByAndKCLangExpr: () => (/* binding */ combineByAndKCLangExpr),
105187
+ /* harmony export */ combineByOrKCLangExpr: () => (/* binding */ combineByOrKCLangExpr)
105168
105188
  /* harmony export */ });
105169
105189
  /* harmony import */ var _Common_AutoValidationUtils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../../Common/AutoValidationUtils */ "./Common/AutoValidationUtils.ts");
105170
105190
  /* harmony import */ var _Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../../Common/ModelPath/ModelPath */ "./Common/ModelPath/ModelPath.ts");
@@ -105287,9 +105307,26 @@ class KCLangCalculationsBuildContext {
105287
105307
  if (((_allChildrenPaths$len = (_allChildrenPaths = allChildrenPaths) === null || _allChildrenPaths === void 0 ? void 0 : _allChildrenPaths.length) !== null && _allChildrenPaths$len !== void 0 ? _allChildrenPaths$len : 0) > _validationGenerator_MaxOptionalChildrenLimit__WEBPACK_IMPORTED_MODULE_31__.maxOptionalChildrenLimit) {
105288
105308
  allChildrenPaths = undefined;
105289
105309
  }
105290
- const restChecks = (_allChildrenPaths2 = allChildrenPaths) === null || _allChildrenPaths2 === void 0 ? void 0 : _allChildrenPaths2.map(childPath => new _common_KCLang_CodeDom_AndExpression__WEBPACK_IMPORTED_MODULE_4__.AndExpression(new _common_KCLang_CodeDom_Functions_ExistsFunctionCall__WEBPACK_IMPORTED_MODULE_10__.ExistsFunctionCall(new _common_KCLang_CodeDom_ValueReferenceExpression__WEBPACK_IMPORTED_MODULE_26__.ValueReferenceExpression(_common_KCLang_CodeDom_KCLangPath__WEBPACK_IMPORTED_MODULE_17__.KCLangPath.fromModelPath(childPath, true))), new _common_KCLang_CodeDom_NotEqExpression__WEBPACK_IMPORTED_MODULE_20__.NotEqExpression(new _common_KCLang_CodeDom_CastExpression__WEBPACK_IMPORTED_MODULE_5__.CastExpression(new _common_KCLang_CodeDom_ValueReferenceExpression__WEBPACK_IMPORTED_MODULE_26__.ValueReferenceExpression(_common_KCLang_CodeDom_KCLangPath__WEBPACK_IMPORTED_MODULE_17__.KCLangPath.fromModelPath(childPath, true)), _common_KCLang_CodeDom_KCLangType__WEBPACK_IMPORTED_MODULE_18__.StringType.default), new _common_KCLang_CodeDom_StringConstExpression__WEBPACK_IMPORTED_MODULE_25__.StringConstExpression("")))).reduce(combineByAndKCLangExpr, undefined);
105310
+ const restChecks = (_allChildrenPaths2 = allChildrenPaths) === null || _allChildrenPaths2 === void 0 ? void 0 : _allChildrenPaths2.map(childPath => new _common_KCLang_CodeDom_AndExpression__WEBPACK_IMPORTED_MODULE_4__.AndExpression(new _common_KCLang_CodeDom_Functions_ExistsFunctionCall__WEBPACK_IMPORTED_MODULE_10__.ExistsFunctionCall(new _common_KCLang_CodeDom_ValueReferenceExpression__WEBPACK_IMPORTED_MODULE_26__.ValueReferenceExpression(_common_KCLang_CodeDom_KCLangPath__WEBPACK_IMPORTED_MODULE_17__.KCLangPath.fromModelPath(childPath, true))), new _common_KCLang_CodeDom_NotEqExpression__WEBPACK_IMPORTED_MODULE_20__.NotEqExpression(new _common_KCLang_CodeDom_CastExpression__WEBPACK_IMPORTED_MODULE_5__.CastExpression(new _common_KCLang_CodeDom_ValueReferenceExpression__WEBPACK_IMPORTED_MODULE_26__.ValueReferenceExpression(_common_KCLang_CodeDom_KCLangPath__WEBPACK_IMPORTED_MODULE_17__.KCLangPath.fromModelPath(childPath, true)), _common_KCLang_CodeDom_KCLangType__WEBPACK_IMPORTED_MODULE_18__.StringType.default), new _common_KCLang_CodeDom_StringConstExpression__WEBPACK_IMPORTED_MODULE_25__.StringConstExpression("")))).reduce(combineByOrKCLangExpr, undefined);
105311
+ let choiceChecks;
105312
+ const haveChoices = schemaNode instanceof _common_SchemaRng_FormSchemaRng__WEBPACK_IMPORTED_MODULE_28__.FormSchemaRngElement && schemaNode.choices.length > 0;
105313
+ if (haveChoices) {
105314
+ const choiceRules = [];
105315
+ for (const schemaNodeChoice of schemaNode.choices) {
105316
+ const allChoicesPaths = schemaNodeChoice === null || schemaNodeChoice === void 0 ? void 0 : schemaNodeChoice.values().map(x => this.schemaRng.getPath(x, _Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_1__.PathTokens.each)).filter(x => !(0,_Common_ModelPath_PathSplitHelper__WEBPACK_IMPORTED_MODULE_2__.getMatchedAndDifferentModelPaths)(targetFullPath, x).differentPath.isContainIteration());
105317
+ choiceChecks = allChoicesPaths === null || allChoicesPaths === void 0 ? void 0 : allChoicesPaths.map(childPath => new _common_KCLang_CodeDom_AndExpression__WEBPACK_IMPORTED_MODULE_4__.AndExpression(new _common_KCLang_CodeDom_Functions_ExistsFunctionCall__WEBPACK_IMPORTED_MODULE_10__.ExistsFunctionCall(new _common_KCLang_CodeDom_ValueReferenceExpression__WEBPACK_IMPORTED_MODULE_26__.ValueReferenceExpression(_common_KCLang_CodeDom_KCLangPath__WEBPACK_IMPORTED_MODULE_17__.KCLangPath.fromModelPath(childPath, true))), new _common_KCLang_CodeDom_NotEqExpression__WEBPACK_IMPORTED_MODULE_20__.NotEqExpression(new _common_KCLang_CodeDom_CastExpression__WEBPACK_IMPORTED_MODULE_5__.CastExpression(new _common_KCLang_CodeDom_ValueReferenceExpression__WEBPACK_IMPORTED_MODULE_26__.ValueReferenceExpression(_common_KCLang_CodeDom_KCLangPath__WEBPACK_IMPORTED_MODULE_17__.KCLangPath.fromModelPath(childPath, true)), _common_KCLang_CodeDom_KCLangType__WEBPACK_IMPORTED_MODULE_18__.StringType.default), new _common_KCLang_CodeDom_StringConstExpression__WEBPACK_IMPORTED_MODULE_25__.StringConstExpression("")))).reduce(combineByOrKCLangExpr, undefined);
105318
+ if (choiceChecks) {
105319
+ choiceRules.push(new _common_KCLang_CodeDom_NotExpression__WEBPACK_IMPORTED_MODULE_21__.NotExpression(choiceChecks));
105320
+ }
105321
+ }
105322
+ choiceChecks = choiceRules.reduce(combineByOrKCLangExpr, undefined);
105323
+ }
105291
105324
  const checkRequiredStatement = new _common_KCLang_CodeDom_CheckStatement__WEBPACK_IMPORTED_MODULE_6__.CheckStatement(new _common_KCLang_CodeDom_AndExpression__WEBPACK_IMPORTED_MODULE_4__.AndExpression(new _common_KCLang_CodeDom_Functions_ExistsFunctionCall__WEBPACK_IMPORTED_MODULE_10__.ExistsFunctionCall(new _common_KCLang_CodeDom_ValueReferenceExpression__WEBPACK_IMPORTED_MODULE_26__.ValueReferenceExpression(_common_KCLang_CodeDom_KCLangPath__WEBPACK_IMPORTED_MODULE_17__.KCLangPath.fromModelPath(targetPath, true))), new _common_KCLang_CodeDom_NotEqExpression__WEBPACK_IMPORTED_MODULE_20__.NotEqExpression(new _common_KCLang_CodeDom_CastExpression__WEBPACK_IMPORTED_MODULE_5__.CastExpression(new _common_KCLang_CodeDom_ValueReferenceExpression__WEBPACK_IMPORTED_MODULE_26__.ValueReferenceExpression(_common_KCLang_CodeDom_KCLangPath__WEBPACK_IMPORTED_MODULE_17__.KCLangPath.fromModelPath(targetPath, true)), _common_KCLang_CodeDom_KCLangType__WEBPACK_IMPORTED_MODULE_18__.StringType.default), new _common_KCLang_CodeDom_StringConstExpression__WEBPACK_IMPORTED_MODULE_25__.StringConstExpression(""))), [new _common_KCLang_CodeDom_WithBlock__WEBPACK_IMPORTED_MODULE_27__.WithBlock("description", new _common_KCLang_CodeDom_DescriptionText__WEBPACK_IMPORTED_MODULE_8__.DescriptionText((0,_Serializer_SugarSerializer__WEBPACK_IMPORTED_MODULE_38__.omitLocalization)(requiredDescription))), new _common_KCLang_CodeDom_WithBlock__WEBPACK_IMPORTED_MODULE_27__.WithBlock("target", new _common_KCLang_CodeDom_DescriptionText__WEBPACK_IMPORTED_MODULE_8__.DescriptionText((0,_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_1__.createRelativeFromTokens)(Iterator.from(targetPath.getPathParts()).filter(_Common_ModelPath_ModelPath__WEBPACK_IMPORTED_MODULE_1__.PathTokens.isSimpleToken).toArray()).toString()))]);
105292
- if (restChecks != undefined) {
105325
+ if (restChecks != undefined && choiceChecks != undefined) {
105326
+ yield new _common_KCLang_CodeDom_IfStatement__WEBPACK_IMPORTED_MODULE_16__.IfStatement(new _common_KCLang_CodeDom_AndExpression__WEBPACK_IMPORTED_MODULE_4__.AndExpression(restChecks, choiceChecks), [checkRequiredStatement]);
105327
+ } else if (choiceChecks != undefined) {
105328
+ yield new _common_KCLang_CodeDom_IfStatement__WEBPACK_IMPORTED_MODULE_16__.IfStatement(choiceChecks, [checkRequiredStatement]);
105329
+ } else if (restChecks != undefined) {
105293
105330
  yield new _common_KCLang_CodeDom_IfStatement__WEBPACK_IMPORTED_MODULE_16__.IfStatement(restChecks, [checkRequiredStatement]);
105294
105331
  } else {
105295
105332
  yield checkRequiredStatement;
@@ -105490,9 +105527,12 @@ class KCLangCalculationsBuildContext {
105490
105527
  }
105491
105528
  }
105492
105529
  }
105493
- function combineByAndKCLangExpr(acc, current) {
105530
+ function combineByOrKCLangExpr(acc, current) {
105494
105531
  return acc != undefined ? new _common_KCLang_CodeDom_OrExpression__WEBPACK_IMPORTED_MODULE_23__.OrExpression(acc, current) : current;
105495
105532
  }
105533
+ function combineByAndKCLangExpr(acc, current) {
105534
+ return acc != undefined ? new _common_KCLang_CodeDom_AndExpression__WEBPACK_IMPORTED_MODULE_4__.AndExpression(acc, current) : current;
105535
+ }
105496
105536
 
105497
105537
  /***/ }),
105498
105538
 
@@ -108223,7 +108263,8 @@ function getSettings(sugarRoot, gfv, additionalSettings, formJsonSettings) {
108223
108263
  ...additionalSettings,
108224
108264
  useServerSideFLangNormalization: formJsonSettings === null || formJsonSettings === void 0 ? void 0 : formJsonSettings.useServerSideFLangNormalization,
108225
108265
  useServerSideCalculations: formJsonSettings === null || formJsonSettings === void 0 ? void 0 : formJsonSettings.useServerSideCalculations,
108226
- disableFlangRulesForEnableAutoFieldFeature: formJsonSettings === null || formJsonSettings === void 0 ? void 0 : formJsonSettings.disableFlangRulesForEnableAutoFieldFeature
108266
+ disableFlangRulesForEnableAutoFieldFeature: formJsonSettings === null || formJsonSettings === void 0 ? void 0 : formJsonSettings.disableFlangRulesForEnableAutoFieldFeature,
108267
+ enableAutocalcsInReadOnly: formJsonSettings === null || formJsonSettings === void 0 ? void 0 : formJsonSettings.enableAutocalcsInReadOnly
108227
108268
  };
108228
108269
  return `module.exports = ${JSON.stringify(settings, undefined, 2)}`;
108229
108270
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kontur.candy/generator",
3
- "version": "5.122.0-test-9115.0",
3
+ "version": "5.123.0-validation-choices.0",
4
4
  "description": "Candy forms generator",
5
5
  "author": "SKBKontur Candy Team",
6
6
  "private": false,