@form-eng/core 1.1.1 → 1.2.1

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
@@ -121,6 +121,29 @@ interface IRule {
121
121
  priority?: number;
122
122
  }
123
123
 
124
+ /** Generic dictionary type */
125
+ type Dictionary<T> = Record<string, T>;
126
+ /** Entity data type */
127
+ type IEntityData = Record<string, unknown>;
128
+ /** Sub-entity value type */
129
+ type SubEntityType = string | number | boolean | Date | object | null | undefined;
130
+ declare function isEmpty(value: unknown): boolean;
131
+ declare function isNull(value: unknown): value is null | undefined;
132
+ declare function isStringEmpty(value: string | null | undefined): boolean;
133
+ declare function deepCopy<T>(obj: T): T;
134
+ declare function convertBooleanToYesOrNoText(value: boolean | null | undefined): string;
135
+ /** Sort options alphabetically by label */
136
+ declare function sortDropdownOptions(a: {
137
+ label?: string;
138
+ }, b: {
139
+ label?: string;
140
+ }): number;
141
+ /** Create an option from a value string (value and label are the same) */
142
+ declare function createOption(value: string): {
143
+ value: string;
144
+ label: string;
145
+ };
146
+
124
147
  /**
125
148
  * Static configuration for a single form field (v2 schema).
126
149
  *
@@ -173,6 +196,20 @@ interface IFieldConfig {
173
196
  skipLayoutReadOnly?: boolean;
174
197
  /** Whether the field is disabled at the layout level. */
175
198
  disabled?: boolean;
199
+ /**
200
+ * Async function that loads options dynamically for select/radio/checkbox fields.
201
+ * When present, overrides the static `options` array with the resolved result.
202
+ * Results are cached per unique combination of `optionsDependsOn` field values.
203
+ */
204
+ loadOptions?: (context: {
205
+ fieldId: string;
206
+ values: IEntityData;
207
+ }) => Promise<IOption[]>;
208
+ /**
209
+ * Field IDs whose values trigger a re-run of `loadOptions` when they change.
210
+ * If omitted, `loadOptions` is only called once on mount.
211
+ */
212
+ optionsDependsOn?: string[];
176
213
  }
177
214
 
178
215
  /** Configuration for a single wizard step */
@@ -299,6 +336,8 @@ interface IFieldProps<T = Record<string, unknown>> {
299
336
  config?: T;
300
337
  /** Dropdown/select options (was `dropdownOptions` in v1) */
301
338
  options?: IOption[];
339
+ /** True while async loadOptions is in-flight for this field */
340
+ optionsLoading?: boolean;
302
341
  /** Field label */
303
342
  label?: string;
304
343
  /** Component type string */
@@ -334,6 +373,8 @@ interface IRuntimeFieldState {
334
373
  confirmInput?: boolean;
335
374
  /** Available options for dropdown-type fields (may be filtered by rules). */
336
375
  options?: IOption[];
376
+ /** True while async loadOptions is in-flight. Passed through to field adapters via IFieldProps. */
377
+ optionsLoading?: boolean;
337
378
  /** Override field label (may be set by rules). */
338
379
  label?: string;
339
380
  /** Default value to set when the field value is null and the field is visible. */
@@ -534,29 +575,6 @@ interface IFieldToRender {
534
575
  softHidden?: boolean;
535
576
  }
536
577
 
537
- /** Generic dictionary type */
538
- type Dictionary<T> = Record<string, T>;
539
- /** Entity data type */
540
- type IEntityData = Record<string, unknown>;
541
- /** Sub-entity value type */
542
- type SubEntityType = string | number | boolean | Date | object | null | undefined;
543
- declare function isEmpty(value: unknown): boolean;
544
- declare function isNull(value: unknown): value is null | undefined;
545
- declare function isStringEmpty(value: string | null | undefined): boolean;
546
- declare function deepCopy<T>(obj: T): T;
547
- declare function convertBooleanToYesOrNoText(value: boolean | null | undefined): string;
548
- /** Sort options alphabetically by label */
549
- declare function sortDropdownOptions(a: {
550
- label?: string;
551
- }, b: {
552
- label?: string;
553
- }): number;
554
- /** Create an option from a value string (value and label are the same) */
555
- declare function createOption(value: string): {
556
- value: string;
557
- label: string;
558
- };
559
-
560
578
  interface IFormEngineSharedProps {
561
579
  entityId?: string;
562
580
  entityType?: string;
@@ -580,6 +598,41 @@ interface IFormEngineSharedProps {
580
598
  parentEntity?: IEntityData;
581
599
  }
582
600
 
601
+ /**
602
+ * Shared field config interfaces used by adapter packages.
603
+ * These define the shape of the `config` prop (IFieldProps.config) for specific field types.
604
+ */
605
+ /** Config for Rating field */
606
+ interface IRatingConfig {
607
+ max?: number;
608
+ allowHalf?: boolean;
609
+ }
610
+ /** Config for DateRange field */
611
+ interface IDateRangeConfig {
612
+ minDate?: string;
613
+ maxDate?: string;
614
+ }
615
+ /** Value shape for DateRange field */
616
+ interface IDateRangeValue {
617
+ start: string;
618
+ end: string;
619
+ }
620
+ /** Config for DateTime field */
621
+ interface IDateTimeConfig {
622
+ minDateTime?: string;
623
+ maxDateTime?: string;
624
+ }
625
+ /** Config for FileUpload field */
626
+ interface IFileUploadConfig {
627
+ multiple?: boolean;
628
+ accept?: string;
629
+ maxSizeMb?: number;
630
+ }
631
+ /** Config for PhoneInput field */
632
+ interface IPhoneInputConfig {
633
+ format?: "us" | "international" | "raw";
634
+ }
635
+
583
636
  declare const FIELD_PARENT_PREFIX = "Parent.";
584
637
  /** Component type constants */
585
638
  declare const ComponentTypes: {
@@ -990,6 +1043,8 @@ interface IFormEngineProps extends IFormEngineSharedProps {
990
1043
  isSubmitting: boolean;
991
1044
  }) => React.ReactNode;
992
1045
  formErrors?: string[];
1046
+ /** Per-field server-side errors to inject (e.g. from a failed API save). Keys are field names, values are error messages. */
1047
+ fieldErrors?: Record<string, string>;
993
1048
  renderLabel?: (props: {
994
1049
  id: string;
995
1050
  labelId: string;
@@ -1008,6 +1063,17 @@ interface IFormEngineProps extends IFormEngineSharedProps {
1008
1063
  errorCount?: number;
1009
1064
  isManualSave?: boolean;
1010
1065
  }) => React.ReactNode;
1066
+ /** Called with validated form values when the user submits. Works alongside auto-save. */
1067
+ onSubmit?: (values: IEntityData) => void | Promise<void>;
1068
+ /** Called with RHF FieldErrors when submit validation fails. */
1069
+ onSubmitError?: (errors: react_hook_form.FieldErrors) => void;
1070
+ /** Render prop for a custom submit button. If onSubmit is provided and this is omitted, a default submit button is rendered. */
1071
+ renderSubmitButton?: (props: {
1072
+ onSubmit: () => void;
1073
+ isDirty: boolean;
1074
+ isValid: boolean;
1075
+ isSubmitting: boolean;
1076
+ }) => React.ReactNode;
1011
1077
  }
1012
1078
  declare const FormEngine: React.FC<IFormEngineProps>;
1013
1079
 
@@ -1127,6 +1193,7 @@ interface IRenderFieldProps {
1127
1193
  readOnly?: boolean;
1128
1194
  disabled?: boolean;
1129
1195
  options?: IOption[];
1196
+ optionsLoading?: boolean;
1130
1197
  validate?: IValidationRule[];
1131
1198
  parentEntityId?: string;
1132
1199
  parentEntityType?: string;
@@ -1384,25 +1451,73 @@ declare function serializeFormState(data: IEntityData): string;
1384
1451
  declare function deserializeFormState(json: string): IEntityData;
1385
1452
 
1386
1453
  /**
1387
- * Evaluates an expression string against form values.
1388
- *
1389
- * Supports:
1390
- * - $values.fieldName for field references (including nested paths)
1391
- * - $fn.name() for value function calls
1392
- * - $parent.fieldName for parent entity references
1393
- * - $root.fieldName alias for $values.fieldName
1394
- * - Math functions: Math.round, Math.floor, Math.ceil, Math.abs, Math.min, Math.max
1395
- * - Arithmetic: +, -, *, /
1396
- * - Comparison: >, <, >=, <=, ===, !==
1397
- * - Logical: &&, ||
1398
- * - String concatenation via +
1399
- *
1400
- * @example
1401
- * "$values.quantity * $values.unitPrice"
1402
- * "$fn.setDate()"
1403
- * "$parent.category"
1404
- * "Math.round($values.total * 100) / 100"
1454
+ * Generates a consistent data-testid for field components.
1455
+ * Used by all adapter packages for test attribute generation.
1456
+ */
1457
+ declare const GetFieldDataTestId: (fieldName: string, programName?: string, entityType?: string, entityId?: string) => string;
1458
+ /**
1459
+ * Appends "error" to a className when a field has a validation error.
1460
+ * Used by Fluent and MUI adapters for error styling.
1461
+ */
1462
+ declare const FieldClassName: (className: string, error?: FieldError) => string;
1463
+ /**
1464
+ * Returns a field state string based on the current field props.
1465
+ * Used by headless adapter for data-state attributes.
1466
+ */
1467
+ declare function getFieldState(props: {
1468
+ error?: FieldError;
1469
+ required?: boolean;
1470
+ readOnly?: boolean;
1471
+ disabled?: boolean;
1472
+ }): string | undefined;
1473
+ /**
1474
+ * Formats an ISO date string for display.
1475
+ * Returns short date (e.g. "Jan 15, 2024") or date+time (e.g. "Jan 15, 2024, 02:30 PM").
1476
+ */
1477
+ declare function formatDateTime(dateStr: string, options?: {
1478
+ hideTimestamp?: boolean;
1479
+ }): string;
1480
+ /**
1481
+ * Safely formats a value as a date+time string, falling back to String() on error.
1405
1482
  */
1483
+ declare function formatDateTimeValue(value: unknown): string;
1484
+ /**
1485
+ * Formats a date range value for read-only display.
1486
+ * Returns "start – end", or just the one that exists.
1487
+ */
1488
+ declare function formatDateRange(value: unknown): string;
1489
+ /**
1490
+ * Extracts display names from File or File[] values.
1491
+ */
1492
+ declare function getFileNames(value: unknown): string;
1493
+ /**
1494
+ * Strips all non-digit characters from a string.
1495
+ */
1496
+ declare function extractDigits(value: string): string;
1497
+ /**
1498
+ * Formats a digit string as a phone number.
1499
+ * Supports US "(XXX) XXX-XXXX", international "+X XXX XXX XXXX", and raw digits.
1500
+ */
1501
+ declare function formatPhone(digits: string, format: "us" | "international" | "raw"): string;
1502
+ /**
1503
+ * Truncates text with "..." if it exceeds maxChars.
1504
+ */
1505
+ declare function ellipsifyText(value: string, maxChars: number): string;
1506
+ /** Default max file size in MB for FileUpload fields */
1507
+ declare const MAX_FILE_SIZE_MB_DEFAULT = 10;
1508
+ /** Shared strings for DocumentLinks component */
1509
+ declare const DocumentLinksStrings: {
1510
+ link: string;
1511
+ addLink: string;
1512
+ addAnotherLink: string;
1513
+ deleteLink: string;
1514
+ confirmDeleteLink: string;
1515
+ delete: string;
1516
+ cancel: string;
1517
+ saveChanges: string;
1518
+ save: string;
1519
+ };
1520
+
1406
1521
  declare function evaluateExpression(expression: string, values: IEntityData, fieldName?: string, parentEntity?: IEntityData, currentUserId?: string): unknown;
1407
1522
  /**
1408
1523
  * Extracts field names referenced in an expression via $values.fieldName or $root.fieldName.
@@ -1485,4 +1600,4 @@ declare function getTimeline(): ITimelineEvent[];
1485
1600
  */
1486
1601
  declare function clearTimeline(): void;
1487
1602
 
1488
- export { CheckAsyncFieldValidationRules, CheckDefaultValues, CheckFieldValidationRules, CheckValidDropdownOptions, ComponentTypes, ConfirmInputsModal, type Dictionary, ExecuteComputedValue, FIELD_PARENT_PREFIX, FieldArray, FieldWrapper, FormConstants, FormDevTools, FormEngine, FormErrorBoundary, FormFields, FormStrings, GetChildEntity, GetComputedValuesOnCreate, GetComputedValuesOnDirtyFields, GetConfirmInputModalProps, GetFieldsToRender, type IAnalyticsCallbacks, type IClearRulesAction, type ICondition, type IConfigValidationError, type IConfirmInputModalProps, type ICoreLocaleStrings, type ICycleError, type IDraftPersistenceOptions, type IDraftState, type IEntityData, type IFieldArrayProps, type IFieldCondition, type IFieldConfig, type IFieldEffect, type IFieldProps, type IFieldToRender, type IFormAnalytics, type IFormConfig, type IFormDevToolsProps, type IFormEngineSharedProps, type IFormSettings, type IInjectedFieldProvider, type IJsonSchemaNode, type ILogicalCondition, type IOption, type IRjsfConvertOptions, type IRjsfUiSchema, type IRule, type IRuleTraceEvent, type IRulesEngineProvider, type IRulesEngineState, type IRuntimeFieldState, type IRuntimeFormState, type ISetRulesAction, type ITimelineEvent, type IUpdateRulesAction, type IUseDraftPersistenceResult, type IValidationContext, type IValidationRule, type IValidatorMetadata, type IValueFunctionContext, type IWizardConfig, type IWizardFormProps, type IWizardNavigationProps, type IWizardStep, type IWizardStepHeaderProps, InitOnCreateFormState, InitOnEditFormState, InjectedFieldProvider, IsExpandVisible, _default as RenderField, type RulesEngineAction, RulesEngineActionType, RulesEngineProvider, ShowField, SortOptions as SortDropdownOptions, SortOptions$1 as SortOptions, type SubEntityType, type TimelineEventType, type TypedFieldConfig, UseInjectedFieldContext, UseRulesEngineContext, type ValidatorFn, type ValueFunction, WizardForm, buildDefaultFieldStates, buildDependencyGraph, clearRuleTraceLog, clearTimeline, convertBooleanToYesOrNoText, createLazyFieldRegistry, createMaxLengthRule, createMinLengthRule, createNumericRangeRule, createOption, createPatternRule, createRequiredIfRule, deepCopy, defineFormConfig, deserializeFormState, detectDependencyCycles, detectSelfDependencies, disableRuleTracing, enableRuleTracing, evaluateAffectedFields, evaluateAllRules, evaluateCondition, evaluateExpression, executeValueFunction, extractConditionDependencies, extractExpressionDependencies, extractFunctionDependencies, flushRenderCycle, fromRjsfSchema, getAllValidatorMetadata, getCurrentLocale, getLastRenderedFields, getLocaleString, getRenderCounts, getRuleTraceLog, getStepFieldOrder, getStepFields, getStepIndex, getTimeline, getTotalFormRenders, getValidator, getValidatorMetadata, getValidatorRegistry, getValueFunction, getVisibleSteps, isEmpty, isFieldCondition, isLogicalCondition, isNull, isRuleTracingEnabled, isStepValid, isStringEmpty, logEvent, registerLocale, registerValidatorMetadata, registerValidators, registerValueFunctions, resetLocale, resetRenderTracker, resetValidatorMetadataRegistry, resetValidatorRegistry, resetValueFunctionRegistry, runSyncValidations, runValidations, serializeFormState, sortDropdownOptions, toRjsfSchema, topologicalSort, traceRuleEvent, trackRender, useBeforeUnload, useDraftPersistence, useFormAnalytics, validateDependencyGraph, validateFieldConfigs, validateStepFields, zodSchemaToFieldConfig };
1603
+ export { CheckAsyncFieldValidationRules, CheckDefaultValues, CheckFieldValidationRules, CheckValidDropdownOptions, ComponentTypes, ConfirmInputsModal, type Dictionary, DocumentLinksStrings, ExecuteComputedValue, FIELD_PARENT_PREFIX, FieldArray, FieldClassName, FieldWrapper, FormConstants, FormDevTools, FormEngine, FormErrorBoundary, FormFields, FormStrings, GetChildEntity, GetComputedValuesOnCreate, GetComputedValuesOnDirtyFields, GetConfirmInputModalProps, GetFieldDataTestId, GetFieldsToRender, type IAnalyticsCallbacks, type IClearRulesAction, type ICondition, type IConfigValidationError, type IConfirmInputModalProps, type ICoreLocaleStrings, type ICycleError, type IDateRangeConfig, type IDateRangeValue, type IDateTimeConfig, type IDraftPersistenceOptions, type IDraftState, type IEntityData, type IFieldArrayProps, type IFieldCondition, type IFieldConfig, type IFieldEffect, type IFieldProps, type IFieldToRender, type IFileUploadConfig, type IFormAnalytics, type IFormConfig, type IFormDevToolsProps, type IFormEngineSharedProps, type IFormSettings, type IInjectedFieldProvider, type IJsonSchemaNode, type ILogicalCondition, type IOption, type IPhoneInputConfig, type IRatingConfig, type IRjsfConvertOptions, type IRjsfUiSchema, type IRule, type IRuleTraceEvent, type IRulesEngineProvider, type IRulesEngineState, type IRuntimeFieldState, type IRuntimeFormState, type ISetRulesAction, type ITimelineEvent, type IUpdateRulesAction, type IUseDraftPersistenceResult, type IValidationContext, type IValidationRule, type IValidatorMetadata, type IValueFunctionContext, type IWizardConfig, type IWizardFormProps, type IWizardNavigationProps, type IWizardStep, type IWizardStepHeaderProps, InitOnCreateFormState, InitOnEditFormState, InjectedFieldProvider, IsExpandVisible, MAX_FILE_SIZE_MB_DEFAULT, _default as RenderField, type RulesEngineAction, RulesEngineActionType, RulesEngineProvider, ShowField, SortOptions as SortDropdownOptions, SortOptions$1 as SortOptions, type SubEntityType, type TimelineEventType, type TypedFieldConfig, UseInjectedFieldContext, UseRulesEngineContext, type ValidatorFn, type ValueFunction, WizardForm, buildDefaultFieldStates, buildDependencyGraph, clearRuleTraceLog, clearTimeline, convertBooleanToYesOrNoText, createLazyFieldRegistry, createMaxLengthRule, createMinLengthRule, createNumericRangeRule, createOption, createPatternRule, createRequiredIfRule, deepCopy, defineFormConfig, deserializeFormState, detectDependencyCycles, detectSelfDependencies, disableRuleTracing, ellipsifyText, enableRuleTracing, evaluateAffectedFields, evaluateAllRules, evaluateCondition, evaluateExpression, executeValueFunction, extractConditionDependencies, extractDigits, extractExpressionDependencies, extractFunctionDependencies, flushRenderCycle, formatDateRange, formatDateTime, formatDateTimeValue, formatPhone, fromRjsfSchema, getAllValidatorMetadata, getCurrentLocale, getFieldState, getFileNames, getLastRenderedFields, getLocaleString, getRenderCounts, getRuleTraceLog, getStepFieldOrder, getStepFields, getStepIndex, getTimeline, getTotalFormRenders, getValidator, getValidatorMetadata, getValidatorRegistry, getValueFunction, getVisibleSteps, isEmpty, isFieldCondition, isLogicalCondition, isNull, isRuleTracingEnabled, isStepValid, isStringEmpty, logEvent, registerLocale, registerValidatorMetadata, registerValidators, registerValueFunctions, resetLocale, resetRenderTracker, resetValidatorMetadataRegistry, resetValidatorRegistry, resetValueFunctionRegistry, runSyncValidations, runValidations, serializeFormState, sortDropdownOptions, toRjsfSchema, topologicalSort, traceRuleEvent, trackRender, useBeforeUnload, useDraftPersistence, useFormAnalytics, validateDependencyGraph, validateFieldConfigs, validateStepFields, zodSchemaToFieldConfig };
package/dist/index.d.ts CHANGED
@@ -121,6 +121,29 @@ interface IRule {
121
121
  priority?: number;
122
122
  }
123
123
 
124
+ /** Generic dictionary type */
125
+ type Dictionary<T> = Record<string, T>;
126
+ /** Entity data type */
127
+ type IEntityData = Record<string, unknown>;
128
+ /** Sub-entity value type */
129
+ type SubEntityType = string | number | boolean | Date | object | null | undefined;
130
+ declare function isEmpty(value: unknown): boolean;
131
+ declare function isNull(value: unknown): value is null | undefined;
132
+ declare function isStringEmpty(value: string | null | undefined): boolean;
133
+ declare function deepCopy<T>(obj: T): T;
134
+ declare function convertBooleanToYesOrNoText(value: boolean | null | undefined): string;
135
+ /** Sort options alphabetically by label */
136
+ declare function sortDropdownOptions(a: {
137
+ label?: string;
138
+ }, b: {
139
+ label?: string;
140
+ }): number;
141
+ /** Create an option from a value string (value and label are the same) */
142
+ declare function createOption(value: string): {
143
+ value: string;
144
+ label: string;
145
+ };
146
+
124
147
  /**
125
148
  * Static configuration for a single form field (v2 schema).
126
149
  *
@@ -173,6 +196,20 @@ interface IFieldConfig {
173
196
  skipLayoutReadOnly?: boolean;
174
197
  /** Whether the field is disabled at the layout level. */
175
198
  disabled?: boolean;
199
+ /**
200
+ * Async function that loads options dynamically for select/radio/checkbox fields.
201
+ * When present, overrides the static `options` array with the resolved result.
202
+ * Results are cached per unique combination of `optionsDependsOn` field values.
203
+ */
204
+ loadOptions?: (context: {
205
+ fieldId: string;
206
+ values: IEntityData;
207
+ }) => Promise<IOption[]>;
208
+ /**
209
+ * Field IDs whose values trigger a re-run of `loadOptions` when they change.
210
+ * If omitted, `loadOptions` is only called once on mount.
211
+ */
212
+ optionsDependsOn?: string[];
176
213
  }
177
214
 
178
215
  /** Configuration for a single wizard step */
@@ -299,6 +336,8 @@ interface IFieldProps<T = Record<string, unknown>> {
299
336
  config?: T;
300
337
  /** Dropdown/select options (was `dropdownOptions` in v1) */
301
338
  options?: IOption[];
339
+ /** True while async loadOptions is in-flight for this field */
340
+ optionsLoading?: boolean;
302
341
  /** Field label */
303
342
  label?: string;
304
343
  /** Component type string */
@@ -334,6 +373,8 @@ interface IRuntimeFieldState {
334
373
  confirmInput?: boolean;
335
374
  /** Available options for dropdown-type fields (may be filtered by rules). */
336
375
  options?: IOption[];
376
+ /** True while async loadOptions is in-flight. Passed through to field adapters via IFieldProps. */
377
+ optionsLoading?: boolean;
337
378
  /** Override field label (may be set by rules). */
338
379
  label?: string;
339
380
  /** Default value to set when the field value is null and the field is visible. */
@@ -534,29 +575,6 @@ interface IFieldToRender {
534
575
  softHidden?: boolean;
535
576
  }
536
577
 
537
- /** Generic dictionary type */
538
- type Dictionary<T> = Record<string, T>;
539
- /** Entity data type */
540
- type IEntityData = Record<string, unknown>;
541
- /** Sub-entity value type */
542
- type SubEntityType = string | number | boolean | Date | object | null | undefined;
543
- declare function isEmpty(value: unknown): boolean;
544
- declare function isNull(value: unknown): value is null | undefined;
545
- declare function isStringEmpty(value: string | null | undefined): boolean;
546
- declare function deepCopy<T>(obj: T): T;
547
- declare function convertBooleanToYesOrNoText(value: boolean | null | undefined): string;
548
- /** Sort options alphabetically by label */
549
- declare function sortDropdownOptions(a: {
550
- label?: string;
551
- }, b: {
552
- label?: string;
553
- }): number;
554
- /** Create an option from a value string (value and label are the same) */
555
- declare function createOption(value: string): {
556
- value: string;
557
- label: string;
558
- };
559
-
560
578
  interface IFormEngineSharedProps {
561
579
  entityId?: string;
562
580
  entityType?: string;
@@ -580,6 +598,41 @@ interface IFormEngineSharedProps {
580
598
  parentEntity?: IEntityData;
581
599
  }
582
600
 
601
+ /**
602
+ * Shared field config interfaces used by adapter packages.
603
+ * These define the shape of the `config` prop (IFieldProps.config) for specific field types.
604
+ */
605
+ /** Config for Rating field */
606
+ interface IRatingConfig {
607
+ max?: number;
608
+ allowHalf?: boolean;
609
+ }
610
+ /** Config for DateRange field */
611
+ interface IDateRangeConfig {
612
+ minDate?: string;
613
+ maxDate?: string;
614
+ }
615
+ /** Value shape for DateRange field */
616
+ interface IDateRangeValue {
617
+ start: string;
618
+ end: string;
619
+ }
620
+ /** Config for DateTime field */
621
+ interface IDateTimeConfig {
622
+ minDateTime?: string;
623
+ maxDateTime?: string;
624
+ }
625
+ /** Config for FileUpload field */
626
+ interface IFileUploadConfig {
627
+ multiple?: boolean;
628
+ accept?: string;
629
+ maxSizeMb?: number;
630
+ }
631
+ /** Config for PhoneInput field */
632
+ interface IPhoneInputConfig {
633
+ format?: "us" | "international" | "raw";
634
+ }
635
+
583
636
  declare const FIELD_PARENT_PREFIX = "Parent.";
584
637
  /** Component type constants */
585
638
  declare const ComponentTypes: {
@@ -990,6 +1043,8 @@ interface IFormEngineProps extends IFormEngineSharedProps {
990
1043
  isSubmitting: boolean;
991
1044
  }) => React.ReactNode;
992
1045
  formErrors?: string[];
1046
+ /** Per-field server-side errors to inject (e.g. from a failed API save). Keys are field names, values are error messages. */
1047
+ fieldErrors?: Record<string, string>;
993
1048
  renderLabel?: (props: {
994
1049
  id: string;
995
1050
  labelId: string;
@@ -1008,6 +1063,17 @@ interface IFormEngineProps extends IFormEngineSharedProps {
1008
1063
  errorCount?: number;
1009
1064
  isManualSave?: boolean;
1010
1065
  }) => React.ReactNode;
1066
+ /** Called with validated form values when the user submits. Works alongside auto-save. */
1067
+ onSubmit?: (values: IEntityData) => void | Promise<void>;
1068
+ /** Called with RHF FieldErrors when submit validation fails. */
1069
+ onSubmitError?: (errors: react_hook_form.FieldErrors) => void;
1070
+ /** Render prop for a custom submit button. If onSubmit is provided and this is omitted, a default submit button is rendered. */
1071
+ renderSubmitButton?: (props: {
1072
+ onSubmit: () => void;
1073
+ isDirty: boolean;
1074
+ isValid: boolean;
1075
+ isSubmitting: boolean;
1076
+ }) => React.ReactNode;
1011
1077
  }
1012
1078
  declare const FormEngine: React.FC<IFormEngineProps>;
1013
1079
 
@@ -1127,6 +1193,7 @@ interface IRenderFieldProps {
1127
1193
  readOnly?: boolean;
1128
1194
  disabled?: boolean;
1129
1195
  options?: IOption[];
1196
+ optionsLoading?: boolean;
1130
1197
  validate?: IValidationRule[];
1131
1198
  parentEntityId?: string;
1132
1199
  parentEntityType?: string;
@@ -1384,25 +1451,73 @@ declare function serializeFormState(data: IEntityData): string;
1384
1451
  declare function deserializeFormState(json: string): IEntityData;
1385
1452
 
1386
1453
  /**
1387
- * Evaluates an expression string against form values.
1388
- *
1389
- * Supports:
1390
- * - $values.fieldName for field references (including nested paths)
1391
- * - $fn.name() for value function calls
1392
- * - $parent.fieldName for parent entity references
1393
- * - $root.fieldName alias for $values.fieldName
1394
- * - Math functions: Math.round, Math.floor, Math.ceil, Math.abs, Math.min, Math.max
1395
- * - Arithmetic: +, -, *, /
1396
- * - Comparison: >, <, >=, <=, ===, !==
1397
- * - Logical: &&, ||
1398
- * - String concatenation via +
1399
- *
1400
- * @example
1401
- * "$values.quantity * $values.unitPrice"
1402
- * "$fn.setDate()"
1403
- * "$parent.category"
1404
- * "Math.round($values.total * 100) / 100"
1454
+ * Generates a consistent data-testid for field components.
1455
+ * Used by all adapter packages for test attribute generation.
1456
+ */
1457
+ declare const GetFieldDataTestId: (fieldName: string, programName?: string, entityType?: string, entityId?: string) => string;
1458
+ /**
1459
+ * Appends "error" to a className when a field has a validation error.
1460
+ * Used by Fluent and MUI adapters for error styling.
1461
+ */
1462
+ declare const FieldClassName: (className: string, error?: FieldError) => string;
1463
+ /**
1464
+ * Returns a field state string based on the current field props.
1465
+ * Used by headless adapter for data-state attributes.
1466
+ */
1467
+ declare function getFieldState(props: {
1468
+ error?: FieldError;
1469
+ required?: boolean;
1470
+ readOnly?: boolean;
1471
+ disabled?: boolean;
1472
+ }): string | undefined;
1473
+ /**
1474
+ * Formats an ISO date string for display.
1475
+ * Returns short date (e.g. "Jan 15, 2024") or date+time (e.g. "Jan 15, 2024, 02:30 PM").
1476
+ */
1477
+ declare function formatDateTime(dateStr: string, options?: {
1478
+ hideTimestamp?: boolean;
1479
+ }): string;
1480
+ /**
1481
+ * Safely formats a value as a date+time string, falling back to String() on error.
1405
1482
  */
1483
+ declare function formatDateTimeValue(value: unknown): string;
1484
+ /**
1485
+ * Formats a date range value for read-only display.
1486
+ * Returns "start – end", or just the one that exists.
1487
+ */
1488
+ declare function formatDateRange(value: unknown): string;
1489
+ /**
1490
+ * Extracts display names from File or File[] values.
1491
+ */
1492
+ declare function getFileNames(value: unknown): string;
1493
+ /**
1494
+ * Strips all non-digit characters from a string.
1495
+ */
1496
+ declare function extractDigits(value: string): string;
1497
+ /**
1498
+ * Formats a digit string as a phone number.
1499
+ * Supports US "(XXX) XXX-XXXX", international "+X XXX XXX XXXX", and raw digits.
1500
+ */
1501
+ declare function formatPhone(digits: string, format: "us" | "international" | "raw"): string;
1502
+ /**
1503
+ * Truncates text with "..." if it exceeds maxChars.
1504
+ */
1505
+ declare function ellipsifyText(value: string, maxChars: number): string;
1506
+ /** Default max file size in MB for FileUpload fields */
1507
+ declare const MAX_FILE_SIZE_MB_DEFAULT = 10;
1508
+ /** Shared strings for DocumentLinks component */
1509
+ declare const DocumentLinksStrings: {
1510
+ link: string;
1511
+ addLink: string;
1512
+ addAnotherLink: string;
1513
+ deleteLink: string;
1514
+ confirmDeleteLink: string;
1515
+ delete: string;
1516
+ cancel: string;
1517
+ saveChanges: string;
1518
+ save: string;
1519
+ };
1520
+
1406
1521
  declare function evaluateExpression(expression: string, values: IEntityData, fieldName?: string, parentEntity?: IEntityData, currentUserId?: string): unknown;
1407
1522
  /**
1408
1523
  * Extracts field names referenced in an expression via $values.fieldName or $root.fieldName.
@@ -1485,4 +1600,4 @@ declare function getTimeline(): ITimelineEvent[];
1485
1600
  */
1486
1601
  declare function clearTimeline(): void;
1487
1602
 
1488
- export { CheckAsyncFieldValidationRules, CheckDefaultValues, CheckFieldValidationRules, CheckValidDropdownOptions, ComponentTypes, ConfirmInputsModal, type Dictionary, ExecuteComputedValue, FIELD_PARENT_PREFIX, FieldArray, FieldWrapper, FormConstants, FormDevTools, FormEngine, FormErrorBoundary, FormFields, FormStrings, GetChildEntity, GetComputedValuesOnCreate, GetComputedValuesOnDirtyFields, GetConfirmInputModalProps, GetFieldsToRender, type IAnalyticsCallbacks, type IClearRulesAction, type ICondition, type IConfigValidationError, type IConfirmInputModalProps, type ICoreLocaleStrings, type ICycleError, type IDraftPersistenceOptions, type IDraftState, type IEntityData, type IFieldArrayProps, type IFieldCondition, type IFieldConfig, type IFieldEffect, type IFieldProps, type IFieldToRender, type IFormAnalytics, type IFormConfig, type IFormDevToolsProps, type IFormEngineSharedProps, type IFormSettings, type IInjectedFieldProvider, type IJsonSchemaNode, type ILogicalCondition, type IOption, type IRjsfConvertOptions, type IRjsfUiSchema, type IRule, type IRuleTraceEvent, type IRulesEngineProvider, type IRulesEngineState, type IRuntimeFieldState, type IRuntimeFormState, type ISetRulesAction, type ITimelineEvent, type IUpdateRulesAction, type IUseDraftPersistenceResult, type IValidationContext, type IValidationRule, type IValidatorMetadata, type IValueFunctionContext, type IWizardConfig, type IWizardFormProps, type IWizardNavigationProps, type IWizardStep, type IWizardStepHeaderProps, InitOnCreateFormState, InitOnEditFormState, InjectedFieldProvider, IsExpandVisible, _default as RenderField, type RulesEngineAction, RulesEngineActionType, RulesEngineProvider, ShowField, SortOptions as SortDropdownOptions, SortOptions$1 as SortOptions, type SubEntityType, type TimelineEventType, type TypedFieldConfig, UseInjectedFieldContext, UseRulesEngineContext, type ValidatorFn, type ValueFunction, WizardForm, buildDefaultFieldStates, buildDependencyGraph, clearRuleTraceLog, clearTimeline, convertBooleanToYesOrNoText, createLazyFieldRegistry, createMaxLengthRule, createMinLengthRule, createNumericRangeRule, createOption, createPatternRule, createRequiredIfRule, deepCopy, defineFormConfig, deserializeFormState, detectDependencyCycles, detectSelfDependencies, disableRuleTracing, enableRuleTracing, evaluateAffectedFields, evaluateAllRules, evaluateCondition, evaluateExpression, executeValueFunction, extractConditionDependencies, extractExpressionDependencies, extractFunctionDependencies, flushRenderCycle, fromRjsfSchema, getAllValidatorMetadata, getCurrentLocale, getLastRenderedFields, getLocaleString, getRenderCounts, getRuleTraceLog, getStepFieldOrder, getStepFields, getStepIndex, getTimeline, getTotalFormRenders, getValidator, getValidatorMetadata, getValidatorRegistry, getValueFunction, getVisibleSteps, isEmpty, isFieldCondition, isLogicalCondition, isNull, isRuleTracingEnabled, isStepValid, isStringEmpty, logEvent, registerLocale, registerValidatorMetadata, registerValidators, registerValueFunctions, resetLocale, resetRenderTracker, resetValidatorMetadataRegistry, resetValidatorRegistry, resetValueFunctionRegistry, runSyncValidations, runValidations, serializeFormState, sortDropdownOptions, toRjsfSchema, topologicalSort, traceRuleEvent, trackRender, useBeforeUnload, useDraftPersistence, useFormAnalytics, validateDependencyGraph, validateFieldConfigs, validateStepFields, zodSchemaToFieldConfig };
1603
+ export { CheckAsyncFieldValidationRules, CheckDefaultValues, CheckFieldValidationRules, CheckValidDropdownOptions, ComponentTypes, ConfirmInputsModal, type Dictionary, DocumentLinksStrings, ExecuteComputedValue, FIELD_PARENT_PREFIX, FieldArray, FieldClassName, FieldWrapper, FormConstants, FormDevTools, FormEngine, FormErrorBoundary, FormFields, FormStrings, GetChildEntity, GetComputedValuesOnCreate, GetComputedValuesOnDirtyFields, GetConfirmInputModalProps, GetFieldDataTestId, GetFieldsToRender, type IAnalyticsCallbacks, type IClearRulesAction, type ICondition, type IConfigValidationError, type IConfirmInputModalProps, type ICoreLocaleStrings, type ICycleError, type IDateRangeConfig, type IDateRangeValue, type IDateTimeConfig, type IDraftPersistenceOptions, type IDraftState, type IEntityData, type IFieldArrayProps, type IFieldCondition, type IFieldConfig, type IFieldEffect, type IFieldProps, type IFieldToRender, type IFileUploadConfig, type IFormAnalytics, type IFormConfig, type IFormDevToolsProps, type IFormEngineSharedProps, type IFormSettings, type IInjectedFieldProvider, type IJsonSchemaNode, type ILogicalCondition, type IOption, type IPhoneInputConfig, type IRatingConfig, type IRjsfConvertOptions, type IRjsfUiSchema, type IRule, type IRuleTraceEvent, type IRulesEngineProvider, type IRulesEngineState, type IRuntimeFieldState, type IRuntimeFormState, type ISetRulesAction, type ITimelineEvent, type IUpdateRulesAction, type IUseDraftPersistenceResult, type IValidationContext, type IValidationRule, type IValidatorMetadata, type IValueFunctionContext, type IWizardConfig, type IWizardFormProps, type IWizardNavigationProps, type IWizardStep, type IWizardStepHeaderProps, InitOnCreateFormState, InitOnEditFormState, InjectedFieldProvider, IsExpandVisible, MAX_FILE_SIZE_MB_DEFAULT, _default as RenderField, type RulesEngineAction, RulesEngineActionType, RulesEngineProvider, ShowField, SortOptions as SortDropdownOptions, SortOptions$1 as SortOptions, type SubEntityType, type TimelineEventType, type TypedFieldConfig, UseInjectedFieldContext, UseRulesEngineContext, type ValidatorFn, type ValueFunction, WizardForm, buildDefaultFieldStates, buildDependencyGraph, clearRuleTraceLog, clearTimeline, convertBooleanToYesOrNoText, createLazyFieldRegistry, createMaxLengthRule, createMinLengthRule, createNumericRangeRule, createOption, createPatternRule, createRequiredIfRule, deepCopy, defineFormConfig, deserializeFormState, detectDependencyCycles, detectSelfDependencies, disableRuleTracing, ellipsifyText, enableRuleTracing, evaluateAffectedFields, evaluateAllRules, evaluateCondition, evaluateExpression, executeValueFunction, extractConditionDependencies, extractDigits, extractExpressionDependencies, extractFunctionDependencies, flushRenderCycle, formatDateRange, formatDateTime, formatDateTimeValue, formatPhone, fromRjsfSchema, getAllValidatorMetadata, getCurrentLocale, getFieldState, getFileNames, getLastRenderedFields, getLocaleString, getRenderCounts, getRuleTraceLog, getStepFieldOrder, getStepFields, getStepIndex, getTimeline, getTotalFormRenders, getValidator, getValidatorMetadata, getValidatorRegistry, getValueFunction, getVisibleSteps, isEmpty, isFieldCondition, isLogicalCondition, isNull, isRuleTracingEnabled, isStepValid, isStringEmpty, logEvent, registerLocale, registerValidatorMetadata, registerValidators, registerValueFunctions, resetLocale, resetRenderTracker, resetValidatorMetadataRegistry, resetValidatorRegistry, resetValueFunctionRegistry, runSyncValidations, runValidations, serializeFormState, sortDropdownOptions, toRjsfSchema, topologicalSort, traceRuleEvent, trackRender, useBeforeUnload, useDraftPersistence, useFormAnalytics, validateDependencyGraph, validateFieldConfigs, validateStepFields, zodSchemaToFieldConfig };