form-builder-pro 1.3.7 → 1.3.8

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.d.mts CHANGED
@@ -64,6 +64,8 @@ interface AsyncOptionSource {
64
64
  labelKey: string;
65
65
  valueKey: string;
66
66
  }
67
+ /** Lookup (Entity Fields) — source category for optionSource LOOKUP */
68
+ type LookupSourceType = 'MODULE' | 'MASTER_TYPE' | 'SETTINGS';
67
69
  interface FormField {
68
70
  id: string;
69
71
  type: FieldType;
@@ -98,6 +100,8 @@ interface FormField {
98
100
  masterTypeName?: string;
99
101
  enabled?: boolean;
100
102
  visible?: boolean;
103
+ /** When true, host/backend may enforce uniqueness for this field’s value */
104
+ isUnique?: boolean;
101
105
  order?: number;
102
106
  css?: {
103
107
  class?: string;
@@ -107,7 +111,7 @@ interface FormField {
107
111
  multiselect?: boolean;
108
112
  multiSelect?: boolean;
109
113
  optionSource?: 'STATIC' | 'MASTER' | 'LOOKUP';
110
- lookupSourceType?: 'MODULE' | 'MASTER_TYPE';
114
+ lookupSourceType?: LookupSourceType;
111
115
  lookupSource?: string;
112
116
  lookupValueField?: string;
113
117
  lookupLabelField?: string;
@@ -217,6 +221,12 @@ declare const FormSchemaValidation: z.ZodObject<{
217
221
  }[];
218
222
  }>;
219
223
 
224
+ /** Labels for Lookup Source Type (Entity Fields) — values are the API `sourceType` strings */
225
+ declare const LOOKUP_SOURCE_TYPE_OPTIONS: {
226
+ value: LookupSourceType;
227
+ label: string;
228
+ }[];
229
+
220
230
  interface MasterType {
221
231
  id: string;
222
232
  name: string;
@@ -304,6 +314,11 @@ interface FormBuilderOptions {
304
314
  }[];
305
315
  };
306
316
  moduleList?: string[];
317
+ /** Settings entity registry (sourceKey + display label) — same list the host uses for Legal Entities, Operating Units, User Groups, etc. */
318
+ settingsEntities?: {
319
+ label: string;
320
+ value: string;
321
+ }[];
307
322
  lookupFieldOptionsMap?: {
308
323
  [lookupSource: string]: string[];
309
324
  };
@@ -317,7 +332,7 @@ interface FormBuilderOptions {
317
332
  }) => void;
318
333
  onLookupSourceChange?: (event: {
319
334
  fieldId: string;
320
- lookupSourceType: 'MODULE' | 'MASTER_TYPE';
335
+ lookupSourceType: LookupSourceType;
321
336
  lookupSource: string;
322
337
  }) => void;
323
338
  onProfileClick?: () => void;
@@ -475,4 +490,4 @@ declare const initFormBuilder: (options: FormBuilderOptions & {
475
490
  containerId: string;
476
491
  }) => FormBuilder;
477
492
 
478
- export { type AsyncOptionSource, type DateConstraint, type FieldType, type FieldValidations, type FieldWidth, FormBuilder, type FormBuilderOptions, type FormField, FormRenderer, type FormSchema, FormSchemaValidation, type FormSection, type ISDConfig, type MasterType, type NameGeneratorFormat, type ValidationObject, type ValidationRule, builderToPlatform, cleanFormSchema, convertValidationObjectToArray, detectCircularDependency, evaluateFormula, formStore, generateName, getColSpanFromWidth, getNumericFieldsForFormula, getValidationConfigForAngular, initFormBuilder, parseFormulaDependencies, parseWidth, platformToBuilder, resetNameGeneratorCounter, validateFormula };
493
+ export { type AsyncOptionSource, type DateConstraint, type FieldType, type FieldValidations, type FieldWidth, FormBuilder, type FormBuilderOptions, type FormField, FormRenderer, type FormSchema, FormSchemaValidation, type FormSection, type ISDConfig, LOOKUP_SOURCE_TYPE_OPTIONS, type LookupSourceType, type MasterType, type NameGeneratorFormat, type ValidationObject, type ValidationRule, builderToPlatform, cleanFormSchema, convertValidationObjectToArray, detectCircularDependency, evaluateFormula, formStore, generateName, getColSpanFromWidth, getNumericFieldsForFormula, getValidationConfigForAngular, initFormBuilder, parseFormulaDependencies, parseWidth, platformToBuilder, resetNameGeneratorCounter, validateFormula };
package/dist/index.d.ts CHANGED
@@ -64,6 +64,8 @@ interface AsyncOptionSource {
64
64
  labelKey: string;
65
65
  valueKey: string;
66
66
  }
67
+ /** Lookup (Entity Fields) — source category for optionSource LOOKUP */
68
+ type LookupSourceType = 'MODULE' | 'MASTER_TYPE' | 'SETTINGS';
67
69
  interface FormField {
68
70
  id: string;
69
71
  type: FieldType;
@@ -98,6 +100,8 @@ interface FormField {
98
100
  masterTypeName?: string;
99
101
  enabled?: boolean;
100
102
  visible?: boolean;
103
+ /** When true, host/backend may enforce uniqueness for this field’s value */
104
+ isUnique?: boolean;
101
105
  order?: number;
102
106
  css?: {
103
107
  class?: string;
@@ -107,7 +111,7 @@ interface FormField {
107
111
  multiselect?: boolean;
108
112
  multiSelect?: boolean;
109
113
  optionSource?: 'STATIC' | 'MASTER' | 'LOOKUP';
110
- lookupSourceType?: 'MODULE' | 'MASTER_TYPE';
114
+ lookupSourceType?: LookupSourceType;
111
115
  lookupSource?: string;
112
116
  lookupValueField?: string;
113
117
  lookupLabelField?: string;
@@ -217,6 +221,12 @@ declare const FormSchemaValidation: z.ZodObject<{
217
221
  }[];
218
222
  }>;
219
223
 
224
+ /** Labels for Lookup Source Type (Entity Fields) — values are the API `sourceType` strings */
225
+ declare const LOOKUP_SOURCE_TYPE_OPTIONS: {
226
+ value: LookupSourceType;
227
+ label: string;
228
+ }[];
229
+
220
230
  interface MasterType {
221
231
  id: string;
222
232
  name: string;
@@ -304,6 +314,11 @@ interface FormBuilderOptions {
304
314
  }[];
305
315
  };
306
316
  moduleList?: string[];
317
+ /** Settings entity registry (sourceKey + display label) — same list the host uses for Legal Entities, Operating Units, User Groups, etc. */
318
+ settingsEntities?: {
319
+ label: string;
320
+ value: string;
321
+ }[];
307
322
  lookupFieldOptionsMap?: {
308
323
  [lookupSource: string]: string[];
309
324
  };
@@ -317,7 +332,7 @@ interface FormBuilderOptions {
317
332
  }) => void;
318
333
  onLookupSourceChange?: (event: {
319
334
  fieldId: string;
320
- lookupSourceType: 'MODULE' | 'MASTER_TYPE';
335
+ lookupSourceType: LookupSourceType;
321
336
  lookupSource: string;
322
337
  }) => void;
323
338
  onProfileClick?: () => void;
@@ -475,4 +490,4 @@ declare const initFormBuilder: (options: FormBuilderOptions & {
475
490
  containerId: string;
476
491
  }) => FormBuilder;
477
492
 
478
- export { type AsyncOptionSource, type DateConstraint, type FieldType, type FieldValidations, type FieldWidth, FormBuilder, type FormBuilderOptions, type FormField, FormRenderer, type FormSchema, FormSchemaValidation, type FormSection, type ISDConfig, type MasterType, type NameGeneratorFormat, type ValidationObject, type ValidationRule, builderToPlatform, cleanFormSchema, convertValidationObjectToArray, detectCircularDependency, evaluateFormula, formStore, generateName, getColSpanFromWidth, getNumericFieldsForFormula, getValidationConfigForAngular, initFormBuilder, parseFormulaDependencies, parseWidth, platformToBuilder, resetNameGeneratorCounter, validateFormula };
493
+ export { type AsyncOptionSource, type DateConstraint, type FieldType, type FieldValidations, type FieldWidth, FormBuilder, type FormBuilderOptions, type FormField, FormRenderer, type FormSchema, FormSchemaValidation, type FormSection, type ISDConfig, LOOKUP_SOURCE_TYPE_OPTIONS, type LookupSourceType, type MasterType, type NameGeneratorFormat, type ValidationObject, type ValidationRule, builderToPlatform, cleanFormSchema, convertValidationObjectToArray, detectCircularDependency, evaluateFormula, formStore, generateName, getColSpanFromWidth, getNumericFieldsForFormula, getValidationConfigForAngular, initFormBuilder, parseFormulaDependencies, parseWidth, platformToBuilder, resetNameGeneratorCounter, validateFormula };
package/dist/index.js CHANGED
@@ -4076,39 +4076,12 @@ var FormSchemaValidation = external_exports.object({
4076
4076
  }))
4077
4077
  });
4078
4078
 
4079
- // node_modules/.pnpm/zustand@4.5.7_react@19.2.4/node_modules/zustand/esm/vanilla.mjs
4080
- var createStoreImpl = (createState) => {
4081
- let state;
4082
- const listeners = /* @__PURE__ */ new Set();
4083
- const setState = (partial, replace) => {
4084
- const nextState = typeof partial === "function" ? partial(state) : partial;
4085
- if (!Object.is(nextState, state)) {
4086
- const previousState = state;
4087
- state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
4088
- listeners.forEach((listener) => listener(state, previousState));
4089
- }
4090
- };
4091
- const getState = () => state;
4092
- const getInitialState = () => initialState;
4093
- const subscribe = (listener) => {
4094
- listeners.add(listener);
4095
- return () => listeners.delete(listener);
4096
- };
4097
- const destroy2 = () => {
4098
- if ((undefined ? undefined.MODE : void 0) !== "production") {
4099
- console.warn(
4100
- "[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."
4101
- );
4102
- }
4103
- listeners.clear();
4104
- };
4105
- const api = { setState, getState, getInitialState, subscribe, destroy: destroy2 };
4106
- const initialState = state = createState(setState, getState, api);
4107
- return api;
4108
- };
4109
- var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
4110
-
4111
4079
  // src/core/constants.ts
4080
+ var LOOKUP_SOURCE_TYPE_OPTIONS = [
4081
+ { value: "MODULE", label: "Module" },
4082
+ { value: "MASTER_TYPE", label: "Master Type" },
4083
+ { value: "SETTINGS", label: "Settings Entity" }
4084
+ ];
4112
4085
  var generateId = () => Math.random().toString(36).substring(2, 9);
4113
4086
  var FIELD_TYPES = [
4114
4087
  { type: "text", label: "Text Input", icon: "Type" },
@@ -4317,6 +4290,38 @@ var REGEX_PRESETS = [
4317
4290
  }
4318
4291
  ];
4319
4292
 
4293
+ // node_modules/.pnpm/zustand@4.5.7_react@19.2.4/node_modules/zustand/esm/vanilla.mjs
4294
+ var createStoreImpl = (createState) => {
4295
+ let state;
4296
+ const listeners = /* @__PURE__ */ new Set();
4297
+ const setState = (partial, replace) => {
4298
+ const nextState = typeof partial === "function" ? partial(state) : partial;
4299
+ if (!Object.is(nextState, state)) {
4300
+ const previousState = state;
4301
+ state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
4302
+ listeners.forEach((listener) => listener(state, previousState));
4303
+ }
4304
+ };
4305
+ const getState = () => state;
4306
+ const getInitialState = () => initialState;
4307
+ const subscribe = (listener) => {
4308
+ listeners.add(listener);
4309
+ return () => listeners.delete(listener);
4310
+ };
4311
+ const destroy2 = () => {
4312
+ if ((undefined ? undefined.MODE : void 0) !== "production") {
4313
+ console.warn(
4314
+ "[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."
4315
+ );
4316
+ }
4317
+ listeners.clear();
4318
+ };
4319
+ const api = { setState, getState, getInitialState, subscribe, destroy: destroy2 };
4320
+ const initialState = state = createState(setState, getState, api);
4321
+ return api;
4322
+ };
4323
+ var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
4324
+
4320
4325
  // src/utils/clone.ts
4321
4326
  var cloneForm = (schema) => {
4322
4327
  return {
@@ -4696,6 +4701,8 @@ function transformField(field) {
4696
4701
  transformed.enabled = field.enabled;
4697
4702
  if (field.visible !== void 0)
4698
4703
  transformed.visible = field.visible;
4704
+ if (field.isUnique !== void 0)
4705
+ transformed.isUnique = field.isUnique;
4699
4706
  if (field.isd !== void 0)
4700
4707
  transformed.isd = field.isd;
4701
4708
  if (field.imageUrl !== void 0)
@@ -4931,6 +4938,8 @@ function fieldToPayload(field) {
4931
4938
  payload.enabled = field.enabled;
4932
4939
  if (field.visible !== void 0)
4933
4940
  payload.visible = field.visible;
4941
+ if (field.isUnique !== void 0)
4942
+ payload.isUnique = field.isUnique;
4934
4943
  if (field.css !== void 0)
4935
4944
  payload.css = field.css;
4936
4945
  if (field.optionSource !== void 0)
@@ -10736,6 +10745,12 @@ var FormBuilder = class {
10736
10745
  (checked) => formStore.getState().updateField(selectedField.id, { visible: checked }),
10737
10746
  `visible-${selectedField.id}`
10738
10747
  ));
10748
+ body.appendChild(this.createCheckboxField(
10749
+ "Unique",
10750
+ selectedField.isUnique === true,
10751
+ (checked) => formStore.getState().updateField(selectedField.id, { isUnique: checked }),
10752
+ `unique-${selectedField.id}`
10753
+ ));
10739
10754
  if (selectedField.type === "name_generator") {
10740
10755
  const ngHeader = createElement("h3", { className: "text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3 mt-6", text: "Name Generator Settings" });
10741
10756
  body.appendChild(ngHeader);
@@ -11107,8 +11122,14 @@ var FormBuilder = class {
11107
11122
  this.render();
11108
11123
  }
11109
11124
  });
11110
- lookupSourceTypeSelect.appendChild(createElement("option", { value: "MODULE", text: "Module", selected: (selectedField.lookupSourceType || "MODULE") === "MODULE" }));
11111
- lookupSourceTypeSelect.appendChild(createElement("option", { value: "MASTER_TYPE", text: "Master Type", selected: selectedField.lookupSourceType === "MASTER_TYPE" }));
11125
+ const currentLookupSourceType = selectedField.lookupSourceType || "MODULE";
11126
+ LOOKUP_SOURCE_TYPE_OPTIONS.forEach((opt) => {
11127
+ lookupSourceTypeSelect.appendChild(createElement("option", {
11128
+ value: opt.value,
11129
+ text: opt.label,
11130
+ selected: currentLookupSourceType === opt.value
11131
+ }));
11132
+ });
11112
11133
  lookupSourceTypeGroup.appendChild(lookupSourceTypeSelect);
11113
11134
  body.appendChild(lookupSourceTypeGroup);
11114
11135
  if (selectedField.lookupSourceType === "MODULE") {
@@ -11147,6 +11168,42 @@ var FormBuilder = class {
11147
11168
  });
11148
11169
  lookupSourceGroup.appendChild(lookupSourceSelect);
11149
11170
  body.appendChild(lookupSourceGroup);
11171
+ } else if (selectedField.lookupSourceType === "SETTINGS") {
11172
+ const settingsEntities = this.options.settingsEntities || [];
11173
+ const lookupSourceGroup = createElement("div", { className: "mb-4" });
11174
+ lookupSourceGroup.appendChild(createElement("label", { className: "block text-sm font-normal text-gray-700 dark:text-gray-300 mb-1", text: "Source Key" }));
11175
+ const lookupSourceSelect = createElement("select", {
11176
+ className: "w-full px-3 py-2 border border-gray-200 dark:border-gray-700 rounded-md bg-transparent",
11177
+ value: selectedField.lookupSource || "",
11178
+ onchange: (e) => {
11179
+ const lookupSource = e.target.value;
11180
+ formStore.getState().updateField(selectedField.id, { lookupSource: lookupSource || void 0 });
11181
+ if (lookupSource) {
11182
+ formStore.getState().updateField(selectedField.id, {
11183
+ lookupValueField: void 0,
11184
+ lookupLabelField: void 0
11185
+ });
11186
+ }
11187
+ if (this.options.onLookupSourceChange && lookupSource) {
11188
+ this.options.onLookupSourceChange({
11189
+ fieldId: selectedField.id,
11190
+ lookupSourceType: "SETTINGS",
11191
+ lookupSource
11192
+ });
11193
+ }
11194
+ this.render();
11195
+ }
11196
+ });
11197
+ lookupSourceSelect.appendChild(createElement("option", { value: "", text: "Select Settings Entity", selected: !selectedField.lookupSource }));
11198
+ settingsEntities.forEach((ent) => {
11199
+ lookupSourceSelect.appendChild(createElement("option", {
11200
+ value: ent.value,
11201
+ text: ent.label,
11202
+ selected: selectedField.lookupSource === ent.value
11203
+ }));
11204
+ });
11205
+ lookupSourceGroup.appendChild(lookupSourceSelect);
11206
+ body.appendChild(lookupSourceGroup);
11150
11207
  } else if (selectedField.lookupSourceType === "MASTER_TYPE") {
11151
11208
  const masterTypes = formStore.getState().masterTypes;
11152
11209
  const activeMasterTypes = masterTypes.filter((mt) => mt.active === true);
@@ -12273,6 +12330,7 @@ sortablejs/modular/sortable.esm.js:
12273
12330
  exports.FormBuilder = FormBuilder;
12274
12331
  exports.FormRenderer = FormRenderer;
12275
12332
  exports.FormSchemaValidation = FormSchemaValidation;
12333
+ exports.LOOKUP_SOURCE_TYPE_OPTIONS = LOOKUP_SOURCE_TYPE_OPTIONS;
12276
12334
  exports.builderToPlatform = builderToPlatform;
12277
12335
  exports.cleanFormSchema = cleanFormSchema;
12278
12336
  exports.convertValidationObjectToArray = convertValidationObjectToArray;