@formique/semantq 1.1.0 → 1.1.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.
- package/LowCodeParser.js +327 -150
- package/astToFormique.js +15 -32
- package/formique-semantq.js +274 -428
- package/package.json +1 -1
package/astToFormique.js
CHANGED
|
@@ -642,7 +642,6 @@ getOptionValuesByKey(attributes, targetKey) {
|
|
|
642
642
|
|
|
643
643
|
|
|
644
644
|
buildDynamicSingleSelect(node, rawFieldName) {
|
|
645
|
-
|
|
646
645
|
const cleanString = this.cleanFieldName(rawFieldName);
|
|
647
646
|
const fieldName = cleanString.input_name;
|
|
648
647
|
|
|
@@ -661,7 +660,6 @@ buildDynamicSingleSelect(node, rawFieldName) {
|
|
|
661
660
|
inputParams = { validations: {}, attributes: {} }
|
|
662
661
|
}
|
|
663
662
|
|
|
664
|
-
|
|
665
663
|
validations = inputParams.validations;
|
|
666
664
|
attributes = inputParams.attributes;
|
|
667
665
|
|
|
@@ -669,47 +667,37 @@ buildDynamicSingleSelect(node, rawFieldName) {
|
|
|
669
667
|
validations['required'] = true;
|
|
670
668
|
}
|
|
671
669
|
|
|
672
|
-
//
|
|
670
|
+
// Extract 'options' (main dropdown values)
|
|
673
671
|
if (attributes.options) {
|
|
674
672
|
mainSelectOptions = attributes.options;
|
|
675
673
|
delete attributes.options;
|
|
676
674
|
}
|
|
677
675
|
|
|
678
|
-
// Since the AST is now clean, we assume the only remaining attributes are standard HTML attributes (or empty {}).
|
|
679
|
-
// The previous workaround for fragmented 'South' and 'Africa' keys is now removed.
|
|
680
|
-
|
|
681
|
-
// Push Schema Elements (Index 3 and 4)
|
|
682
676
|
fieldSchema.push(validations); // Index 3
|
|
683
|
-
fieldSchema.push(attributes); // Index 4
|
|
684
|
-
|
|
677
|
+
fieldSchema.push(attributes); // Index 4
|
|
685
678
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
// optionValues retrieves all unique keys that are NOT 'options'
|
|
679
|
+
// Build scenario blocks (Index 6)
|
|
689
680
|
const optionValues = this.extractOptionValues(node.attributes);
|
|
690
681
|
let scenarioBlocks = [];
|
|
691
682
|
|
|
692
|
-
|
|
693
683
|
if (optionValues.length > 0) {
|
|
694
684
|
optionValues.forEach(option => {
|
|
695
|
-
|
|
696
685
|
let schema = {};
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
schema['id'] = option; //lowerCaseOption;
|
|
686
|
+
|
|
687
|
+
// Use the original option string as the ID
|
|
688
|
+
schema['id'] = option;
|
|
701
689
|
schema['label'] = option;
|
|
702
690
|
|
|
703
|
-
//
|
|
704
|
-
const
|
|
705
|
-
|
|
706
|
-
/// Add sub-options now
|
|
707
|
-
const keyOptions = this.getOptionValuesByKey(node.attributes, attributeKey);
|
|
691
|
+
// Get sub-options for this category
|
|
692
|
+
const keyOptions = this.getOptionValuesByKey(node.attributes, option);
|
|
708
693
|
let options = [];
|
|
709
694
|
|
|
710
695
|
if (keyOptions.length > 0) {
|
|
711
696
|
keyOptions.forEach(subOption => {
|
|
712
|
-
options.push({
|
|
697
|
+
options.push({
|
|
698
|
+
value: subOption.toLowerCase(),
|
|
699
|
+
label: this.toTitleCase(subOption)
|
|
700
|
+
});
|
|
713
701
|
});
|
|
714
702
|
schema['options'] = options;
|
|
715
703
|
scenarioBlocks.push(schema);
|
|
@@ -717,15 +705,9 @@ buildDynamicSingleSelect(node, rawFieldName) {
|
|
|
717
705
|
});
|
|
718
706
|
}
|
|
719
707
|
|
|
708
|
+
fieldSchema.push(mainSelectOptions); // Index 5
|
|
709
|
+
fieldSchema.push(scenarioBlocks); // Index 6
|
|
720
710
|
|
|
721
|
-
// 3. PUSH MAIN OPTIONS: Add the main select options list (Index 5)
|
|
722
|
-
fieldSchema.push(mainSelectOptions);
|
|
723
|
-
|
|
724
|
-
// 4. PUSH SCENARIO BLOCKS: Add the list of scenario blocks (Index 6)
|
|
725
|
-
fieldSchema.push(scenarioBlocks);
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
// 5. Final push to the form schema
|
|
729
711
|
this.formSchema.push(fieldSchema);
|
|
730
712
|
}
|
|
731
713
|
|
|
@@ -958,6 +940,7 @@ buildField(node) {
|
|
|
958
940
|
|
|
959
941
|
// 5. Finalize Schema
|
|
960
942
|
this.formSchema.push(fieldSchema);
|
|
943
|
+
console.log("formSchema", JSON.stringify(this.formSchema,null,2));
|
|
961
944
|
}
|
|
962
945
|
|
|
963
946
|
|