form-builder-pro 1.4.2 → 1.4.3

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.css CHANGED
@@ -1033,6 +1033,9 @@ body {
1033
1033
  .max-h-32 {
1034
1034
  max-height: 8rem;
1035
1035
  }
1036
+ .max-h-40 {
1037
+ max-height: 10rem;
1038
+ }
1036
1039
  .max-h-48 {
1037
1040
  max-height: 12rem;
1038
1041
  }
@@ -1197,6 +1200,15 @@ body {
1197
1200
  margin-top: calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));
1198
1201
  margin-bottom: calc(1.5rem * var(--tw-space-y-reverse));
1199
1202
  }
1203
+ .divide-y > :not([hidden]) ~ :not([hidden]) {
1204
+ --tw-divide-y-reverse: 0;
1205
+ border-top-width: calc(1px * calc(1 - var(--tw-divide-y-reverse)));
1206
+ border-bottom-width: calc(1px * var(--tw-divide-y-reverse));
1207
+ }
1208
+ .divide-gray-100 > :not([hidden]) ~ :not([hidden]) {
1209
+ --tw-divide-opacity: 1;
1210
+ border-color: rgb(243 244 246 / var(--tw-divide-opacity, 1));
1211
+ }
1200
1212
  .overflow-hidden {
1201
1213
  overflow: hidden;
1202
1214
  }
@@ -1597,6 +1609,9 @@ body {
1597
1609
  --tw-text-opacity: 1;
1598
1610
  color: rgb(202 138 4 / var(--tw-text-opacity, 1));
1599
1611
  }
1612
+ .accent-blue-600 {
1613
+ accent-color: #2563eb;
1614
+ }
1600
1615
  .opacity-100 {
1601
1616
  opacity: 1;
1602
1617
  }
@@ -2050,6 +2065,11 @@ input[type="radio"]:checked::after {
2050
2065
  opacity: 0.7;
2051
2066
  }
2052
2067
 
2068
+ .dark\:divide-gray-700:is(.dark *) > :not([hidden]) ~ :not([hidden]) {
2069
+ --tw-divide-opacity: 1;
2070
+ border-color: rgb(55 65 81 / var(--tw-divide-opacity, 1));
2071
+ }
2072
+
2053
2073
  .dark\:border-\[\#019FA2\]:is(.dark *) {
2054
2074
  --tw-border-opacity: 1;
2055
2075
  border-color: rgb(1 159 162 / var(--tw-border-opacity, 1));
package/dist/index.d.mts CHANGED
@@ -66,6 +66,23 @@ interface AsyncOptionSource {
66
66
  }
67
67
  /** Lookup (Entity Fields) — source category for optionSource LOOKUP */
68
68
  type LookupSourceType = 'MODULE' | 'MASTER_TYPE' | 'SETTINGS';
69
+ /**
70
+ * Configuration for the auto-populate fields feature on LOOKUP dropdowns.
71
+ * When `enabled` is true and a user selects a lookup record, the fields listed
72
+ * in `fields` are automatically populated from the corresponding lookup record data.
73
+ *
74
+ * `fields` contains the field keys (e.g. column/property names) that are present
75
+ * in both the Lookup Value Field and the Lookup Label Field response objects.
76
+ */
77
+ interface AutoPopulateFieldsConfig {
78
+ /** Whether auto-population is active for this dropdown */
79
+ enabled: boolean;
80
+ /**
81
+ * List of field keys from the lookup response that should be auto-populated
82
+ * into other form fields when the user selects a value.
83
+ */
84
+ fields: string[];
85
+ }
69
86
  interface FormField {
70
87
  id: string;
71
88
  type: FieldType;
@@ -136,6 +153,7 @@ interface FormField {
136
153
  nameGeneratorSuffix?: string;
137
154
  nameGeneratorIdPadding?: number;
138
155
  formulaConfig?: FormulaConfig;
156
+ autoPopulateFields?: AutoPopulateFieldsConfig;
139
157
  }
140
158
  /**
141
159
  * Conditional date constraint — evaluated at runtime against the current date or another field's value.
@@ -596,4 +614,4 @@ declare const initFormBuilder: (options: FormBuilderOptions & {
596
614
  containerId: string;
597
615
  }) => FormBuilder;
598
616
 
599
- export { type AsyncOptionSource, type DateConstraint, type FieldType, type FieldValidations, type FieldWidth, FormBuilder, type FormBuilderOptions, type FormField, FormRenderer, type FormSchema, FormSchemaValidation, type FormSection, type FormulaCondition, type FormulaConfig, type GroupPosition, type ISDConfig, LOOKUP_SOURCE_TYPE_OPTIONS, type LookupSourceType, type MasterType, type NameGeneratorFormat, type ValidationObject, type ValidationRule, builderToPlatform, cleanFormSchema, convertValidationObjectToArray, detectCircularDependency, detectFormulaFieldCircularDependency, evaluateFormula, evaluateFormulaConfig, evaluateFormulaExpression, extractBracketFields, formStore, generateName, getColSpanFromWidth, getFieldsForFormula, getNumericFieldsForFormula, getValidationConfigForAngular, initFormBuilder, parseFormulaDependencies, parseWidth, platformToBuilder, resetNameGeneratorCounter, validateFormula, validateFormulaExpression };
617
+ export { type AsyncOptionSource, type AutoPopulateFieldsConfig, type DateConstraint, type FieldType, type FieldValidations, type FieldWidth, FormBuilder, type FormBuilderOptions, type FormField, FormRenderer, type FormSchema, FormSchemaValidation, type FormSection, type FormulaCondition, type FormulaConfig, type GroupPosition, type ISDConfig, LOOKUP_SOURCE_TYPE_OPTIONS, type LookupSourceType, type MasterType, type NameGeneratorFormat, type ValidationObject, type ValidationRule, builderToPlatform, cleanFormSchema, convertValidationObjectToArray, detectCircularDependency, detectFormulaFieldCircularDependency, evaluateFormula, evaluateFormulaConfig, evaluateFormulaExpression, extractBracketFields, formStore, generateName, getColSpanFromWidth, getFieldsForFormula, getNumericFieldsForFormula, getValidationConfigForAngular, initFormBuilder, parseFormulaDependencies, parseWidth, platformToBuilder, resetNameGeneratorCounter, validateFormula, validateFormulaExpression };
package/dist/index.d.ts CHANGED
@@ -66,6 +66,23 @@ interface AsyncOptionSource {
66
66
  }
67
67
  /** Lookup (Entity Fields) — source category for optionSource LOOKUP */
68
68
  type LookupSourceType = 'MODULE' | 'MASTER_TYPE' | 'SETTINGS';
69
+ /**
70
+ * Configuration for the auto-populate fields feature on LOOKUP dropdowns.
71
+ * When `enabled` is true and a user selects a lookup record, the fields listed
72
+ * in `fields` are automatically populated from the corresponding lookup record data.
73
+ *
74
+ * `fields` contains the field keys (e.g. column/property names) that are present
75
+ * in both the Lookup Value Field and the Lookup Label Field response objects.
76
+ */
77
+ interface AutoPopulateFieldsConfig {
78
+ /** Whether auto-population is active for this dropdown */
79
+ enabled: boolean;
80
+ /**
81
+ * List of field keys from the lookup response that should be auto-populated
82
+ * into other form fields when the user selects a value.
83
+ */
84
+ fields: string[];
85
+ }
69
86
  interface FormField {
70
87
  id: string;
71
88
  type: FieldType;
@@ -136,6 +153,7 @@ interface FormField {
136
153
  nameGeneratorSuffix?: string;
137
154
  nameGeneratorIdPadding?: number;
138
155
  formulaConfig?: FormulaConfig;
156
+ autoPopulateFields?: AutoPopulateFieldsConfig;
139
157
  }
140
158
  /**
141
159
  * Conditional date constraint — evaluated at runtime against the current date or another field's value.
@@ -596,4 +614,4 @@ declare const initFormBuilder: (options: FormBuilderOptions & {
596
614
  containerId: string;
597
615
  }) => FormBuilder;
598
616
 
599
- export { type AsyncOptionSource, type DateConstraint, type FieldType, type FieldValidations, type FieldWidth, FormBuilder, type FormBuilderOptions, type FormField, FormRenderer, type FormSchema, FormSchemaValidation, type FormSection, type FormulaCondition, type FormulaConfig, type GroupPosition, type ISDConfig, LOOKUP_SOURCE_TYPE_OPTIONS, type LookupSourceType, type MasterType, type NameGeneratorFormat, type ValidationObject, type ValidationRule, builderToPlatform, cleanFormSchema, convertValidationObjectToArray, detectCircularDependency, detectFormulaFieldCircularDependency, evaluateFormula, evaluateFormulaConfig, evaluateFormulaExpression, extractBracketFields, formStore, generateName, getColSpanFromWidth, getFieldsForFormula, getNumericFieldsForFormula, getValidationConfigForAngular, initFormBuilder, parseFormulaDependencies, parseWidth, platformToBuilder, resetNameGeneratorCounter, validateFormula, validateFormulaExpression };
617
+ export { type AsyncOptionSource, type AutoPopulateFieldsConfig, type DateConstraint, type FieldType, type FieldValidations, type FieldWidth, FormBuilder, type FormBuilderOptions, type FormField, FormRenderer, type FormSchema, FormSchemaValidation, type FormSection, type FormulaCondition, type FormulaConfig, type GroupPosition, type ISDConfig, LOOKUP_SOURCE_TYPE_OPTIONS, type LookupSourceType, type MasterType, type NameGeneratorFormat, type ValidationObject, type ValidationRule, builderToPlatform, cleanFormSchema, convertValidationObjectToArray, detectCircularDependency, detectFormulaFieldCircularDependency, evaluateFormula, evaluateFormulaConfig, evaluateFormulaExpression, extractBracketFields, formStore, generateName, getColSpanFromWidth, getFieldsForFormula, getNumericFieldsForFormula, getValidationConfigForAngular, initFormBuilder, parseFormulaDependencies, parseWidth, platformToBuilder, resetNameGeneratorCounter, validateFormula, validateFormulaExpression };
package/dist/index.js CHANGED
@@ -4784,6 +4784,13 @@ function transformField(field) {
4784
4784
  transformed.nameGeneratorSuffix = field.nameGeneratorSuffix;
4785
4785
  if (field.nameGeneratorIdPadding !== void 0)
4786
4786
  transformed.nameGeneratorIdPadding = field.nameGeneratorIdPadding;
4787
+ if (field.autoPopulateFields !== void 0 && field.autoPopulateFields !== null) {
4788
+ const apf = field.autoPopulateFields;
4789
+ transformed.autoPopulateFields = {
4790
+ enabled: typeof apf.enabled === "boolean" ? apf.enabled : false,
4791
+ fields: Array.isArray(apf.fields) ? apf.fields : []
4792
+ };
4793
+ }
4787
4794
  if (field.css !== void 0)
4788
4795
  transformed.css = field.css;
4789
4796
  if (field.optionsSource !== void 0)
@@ -5042,6 +5049,12 @@ function fieldToPayload(field, opts) {
5042
5049
  parentFieldName: field.lookupParentFieldName ?? null
5043
5050
  };
5044
5051
  }
5052
+ if (field.optionSource === "LOOKUP" && field.autoPopulateFields !== void 0 && field.autoPopulateFields !== null) {
5053
+ payload.autoPopulateFields = {
5054
+ enabled: field.autoPopulateFields.enabled,
5055
+ fields: Array.isArray(field.autoPopulateFields.fields) ? field.autoPopulateFields.fields : []
5056
+ };
5057
+ }
5045
5058
  if (field.isd !== void 0)
5046
5059
  payload.isd = field.isd;
5047
5060
  if (field.imageUrl !== void 0)
@@ -13563,6 +13576,84 @@ var FormBuilder = class {
13563
13576
  });
13564
13577
  parentFieldGroup.appendChild(parentFieldSelect);
13565
13578
  body.appendChild(parentFieldGroup);
13579
+ const autoPopHeader = createElement("h3", {
13580
+ className: "text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3 mt-6",
13581
+ text: "Auto Populate Fields"
13582
+ });
13583
+ body.appendChild(autoPopHeader);
13584
+ const autoPopEnabled = selectedField.autoPopulateFields?.enabled === true;
13585
+ body.appendChild(this.createCheckboxField(
13586
+ "Enable automation for selected records",
13587
+ autoPopEnabled,
13588
+ (checked) => {
13589
+ const current = formStore.getState().schema.sections.flatMap((s) => s.fields).find((f) => f.id === selectedField.id);
13590
+ formStore.getState().updateField(selectedField.id, {
13591
+ autoPopulateFields: {
13592
+ enabled: checked,
13593
+ fields: current?.autoPopulateFields?.fields ?? []
13594
+ }
13595
+ });
13596
+ this.render();
13597
+ },
13598
+ `auto-populate-enabled-${selectedField.id}`
13599
+ ));
13600
+ {
13601
+ const autoPopFieldsGroup = createElement("div", { className: "mb-4 mt-2" });
13602
+ autoPopFieldsGroup.appendChild(createElement("label", {
13603
+ className: "block text-sm font-normal text-gray-700 dark:text-gray-300 mb-1",
13604
+ text: "Fields to auto-populate"
13605
+ }));
13606
+ const lookupFieldOptionsMapForAP = formStore.getState().lookupFieldOptionsMap;
13607
+ const availableAutoPopFields = selectedField.lookupSource ? lookupFieldOptionsMapForAP[selectedField.lookupSource] || [] : [];
13608
+ const selectedAutoPopFields = selectedField.autoPopulateFields?.fields ?? [];
13609
+ const isAutoPopDisabled = !autoPopEnabled || !selectedField.lookupSource;
13610
+ if (availableAutoPopFields.length === 0) {
13611
+ const emptyNote = createElement("p", {
13612
+ className: "text-xs text-gray-400 dark:text-gray-500 mt-1",
13613
+ text: selectedField.lookupSource ? "No fields available for this lookup source." : "Select a Lookup Source first."
13614
+ });
13615
+ autoPopFieldsGroup.appendChild(emptyNote);
13616
+ } else {
13617
+ const fieldList = createElement("div", {
13618
+ className: `border border-gray-200 dark:border-gray-700 rounded-md divide-y divide-gray-100 dark:divide-gray-700 overflow-y-auto max-h-40 ${isAutoPopDisabled ? "opacity-50 pointer-events-none" : ""}`
13619
+ });
13620
+ availableAutoPopFields.forEach((fieldKey) => {
13621
+ const isChecked = selectedAutoPopFields.includes(fieldKey);
13622
+ const row = createElement("label", {
13623
+ className: "flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 text-sm text-gray-700 dark:text-gray-300"
13624
+ });
13625
+ const cb = createElement("input", {
13626
+ type: "checkbox",
13627
+ className: "w-4 h-4 accent-blue-600",
13628
+ checked: isChecked,
13629
+ disabled: isAutoPopDisabled,
13630
+ onchange: (e) => {
13631
+ const target = e.target;
13632
+ const latestField = formStore.getState().schema.sections.flatMap((s) => s.fields).find((f) => f.id === selectedField.id);
13633
+ const latestSelected = latestField?.autoPopulateFields?.fields ?? [];
13634
+ const updatedFields = target.checked ? [.../* @__PURE__ */ new Set([...latestSelected, fieldKey])] : latestSelected.filter((k) => k !== fieldKey);
13635
+ formStore.getState().updateField(selectedField.id, {
13636
+ autoPopulateFields: {
13637
+ enabled: latestField?.autoPopulateFields?.enabled ?? true,
13638
+ fields: updatedFields
13639
+ }
13640
+ });
13641
+ }
13642
+ });
13643
+ row.appendChild(cb);
13644
+ row.appendChild(createElement("span", { text: fieldKey }));
13645
+ fieldList.appendChild(row);
13646
+ });
13647
+ autoPopFieldsGroup.appendChild(fieldList);
13648
+ if (selectedAutoPopFields.length > 0) {
13649
+ autoPopFieldsGroup.appendChild(createElement("p", {
13650
+ className: "text-xs text-gray-400 dark:text-gray-500 mt-1",
13651
+ text: `${selectedAutoPopFields.length} field(s) selected`
13652
+ }));
13653
+ }
13654
+ }
13655
+ body.appendChild(autoPopFieldsGroup);
13656
+ }
13566
13657
  body.appendChild(this.createCheckboxField(
13567
13658
  "Visibility",
13568
13659
  selectedField.visible !== false,