@formality-ui/core 0.2.5 → 0.3.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.cts CHANGED
@@ -672,8 +672,22 @@ interface EvaluateConditionsInput {
672
672
  * - visible: AND logic (any false = false)
673
673
  * - setValue: last matching condition wins
674
674
  *
675
- * @param input - Evaluation input with conditions and state
676
- * @returns Result with resolved disabled, visible, and setValue states
675
+ * **Signature object-arg form.** Takes a single {@link EvaluateConditionsInput}
676
+ * object (`{ conditions, fieldValues, fieldStates?, record?, props? }`) rather
677
+ * than positional `(conditions, state)` arguments.
678
+ *
679
+ * **PRD deviation note (accepted, gap_analysis G4).** PRD §1.3.2's *table*
680
+ * summarizes this export as `evaluateConditions(conditions, state)`, but PRD
681
+ * §1.3.2's own *example code* defines and uses the identical
682
+ * {@link EvaluateConditionsInput} object-arg form implemented here. The table
683
+ * text is a simplified representation; the object-arg form is the actual, stable
684
+ * contract and is the shape every framework adapter passes (see e.g.
685
+ * `@formality-ui/react`'s `useConditions`). No code change is planned.
686
+ *
687
+ * @param input - {@link EvaluateConditionsInput} - Evaluation input with
688
+ * conditions and state
689
+ * @returns {@link ConditionResult} - Result with resolved disabled, visible,
690
+ * and setValue states
677
691
  *
678
692
  * @example
679
693
  * const result = evaluateConditions({
@@ -730,6 +744,35 @@ declare function mergeConditionResults(results: ConditionResult[]): ConditionRes
730
744
  */
731
745
  declare function inferFieldsFromConditions(conditions: ConditionDescriptor[]): string[];
732
746
 
747
+ /**
748
+ * Validate a value against a rule specification.
749
+ *
750
+ * PRD §1.3.2 headline export for the `validation/validate` module. This is a
751
+ * THIN WRAPPER over {@link runValidator}: it reorders the arguments into the
752
+ * ergonomic `(value, rules, validators, formValues)` shape documented in the
753
+ * PRD, defaults `formValues` to `{}`, and delegates every semantic (named
754
+ * lookup, factory detection, array short-circuit, async, throw-as-failure) to
755
+ * `runValidator` — see that function for details.
756
+ *
757
+ * This covers the RULES layer only (PRD §9.1). The field-validator and
758
+ * type-validator layers are wired by the adapter's `Field` Controller
759
+ * `rules.validate`; this function does not compose them.
760
+ *
761
+ * Returns the raw {@link ValidationResult}. Resolve a user-facing message
762
+ * with {@link resolveErrorMessage}.
763
+ *
764
+ * @param value - The value to validate.
765
+ * @param rules - ValidatorSpec: a named validator (string), an inline
766
+ * ValidatorFunction, or an array of either (run in sequence, short-circuiting
767
+ * on first failure).
768
+ * @param validators - Optional named-validators registry (ValidatorsConfig)
769
+ * for resolving string `rules`. When omitted, a string rule warns and passes.
770
+ * @param formValues - Optional full form values for cross-field validation.
771
+ * Defaults to `{}`.
772
+ * @returns The ValidationResult (`true`/`undefined` = valid; `false`/string/
773
+ * `{type,message?}` = invalid).
774
+ */
775
+ declare function validate(value: unknown, rules: ValidatorSpec, validators?: ValidatorsConfig, formValues?: Record<string, unknown>): Promise<ValidationResult | undefined>;
733
776
  /**
734
777
  * Run a validator specification against a value
735
778
  *
@@ -1110,6 +1153,43 @@ declare function createConfigContext(providerConfig: FormalityProviderConfig, fo
1110
1153
  defaultFieldProps: Record<string, unknown>;
1111
1154
  selectDefaultFieldProps: unknown;
1112
1155
  };
1156
+ /**
1157
+ * Merge provider + form + (optional) field configs into a resolved pair.
1158
+ *
1159
+ * PRD §1.3.2 headline export for the `config/merge` module. This is a
1160
+ * CONVENIENCE WRAPPER for the common 3-source static merge; it composes the
1161
+ * granular functions and delegates all semantics to them:
1162
+ *
1163
+ * - `inputConfig` = `resolveInputConfig(resolveFieldType(undefined, field),
1164
+ * mergeInputConfigs(provider.inputs, form?.inputs))`.
1165
+ * The field's type is derived from `field?.type` (default "textField").
1166
+ * - `fieldConfig.props` = `mergeStaticProps(provider.defaultFieldProps,
1167
+ * form?.defaultFieldProps, field?.props)` (provider → form →
1168
+ * field; later wins). The field's own config (type, label,
1169
+ * disabled, …) is preserved via spread.
1170
+ *
1171
+ * STATIC ONLY. This function does NOT evaluate `selectProps` or
1172
+ * `selectDefaultFieldProps` — those dynamic layers require a `FormState`
1173
+ * (expression evaluation) that a pure merge function cannot supply. For the
1174
+ * full evaluated 8-layer pipeline (PRD §5.3.2 / §6.1), use {@link mergeFieldProps}
1175
+ * from within an adapter that has form state.
1176
+ *
1177
+ * The granular functions ({@link mergeInputConfigs}, {@link resolveInputConfig},
1178
+ * {@link mergeStaticProps}, {@link mergeFieldProps}) remain exported for
1179
+ * advanced use.
1180
+ *
1181
+ * @param provider - Provider config (inputs REQUIRED).
1182
+ * @param form - Optional form config. When omitted, only provider inputs/
1183
+ * defaultFieldProps apply (matches {@link createConfigContext}).
1184
+ * @param field - Optional field config. Its `type` selects the inputConfig;
1185
+ * its `props` are the highest-priority static prop layer.
1186
+ * @returns `{ inputConfig, fieldConfig }`. `inputConfig` is `undefined` when the
1187
+ * resolved type is not registered and no "textField" default exists.
1188
+ */
1189
+ declare function mergeConfigs(provider: FormalityProviderConfig, form?: FormConfig, field?: FieldConfig): {
1190
+ inputConfig: InputConfig | undefined;
1191
+ fieldConfig: FieldConfig;
1192
+ };
1113
1193
 
1114
1194
  /**
1115
1195
  * Resolve the initial value for a field
@@ -1119,6 +1199,16 @@ declare function createConfigContext(providerConfig: FormalityProviderConfig, fo
1119
1199
  * 2. record[recordKey] (using recordKey if specified, else fieldName)
1120
1200
  * 3. inputConfig.defaultValue (from input type definition)
1121
1201
  *
1202
+ * **PRD deviation note (accepted, gap_analysis G5).** PRD §1.3.2's table
1203
+ * summarizes this export as `resolveInitialValue(record, config, inputConfig)`.
1204
+ * The implemented signature is a richer superset —
1205
+ * `(fieldName, fieldConfig?, inputConfig?, record?, defaultValues?)` — because
1206
+ * it drives the full priority chain above (defaultValues → record[recordKey] →
1207
+ * inputConfig.defaultValue) from a single call. This is an internal API
1208
+ * consumed by the framework adapters and by {@link resolveAllInitialValues},
1209
+ * not a simplified end-user entry point; the PRD literal form is a condensed
1210
+ * representation. No code change is planned.
1211
+ *
1122
1212
  * @param fieldName - Field name
1123
1213
  * @param fieldConfig - Field configuration
1124
1214
  * @param inputConfig - Input type configuration
@@ -1186,6 +1276,38 @@ declare function getInputDefaultValue(inputConfig?: InputConfig, typeName?: stri
1186
1276
  */
1187
1277
  declare function mergeRecordWithDefaults(record?: Record<string, unknown>, defaults?: Record<string, unknown>): Record<string, unknown>;
1188
1278
 
1279
+ /**
1280
+ * Sort fields by their order property
1281
+ *
1282
+ * Canonical location: `config/ordering.ts` (PRD §1.3.1/§1.3.2).
1283
+ *
1284
+ * @param fieldNames - Array of field names
1285
+ * @param fieldConfigs - Map of field configs
1286
+ * @returns Sorted array of field names
1287
+ */
1288
+ declare function sortFieldsByOrder(fieldNames: string[], fieldConfigs: Record<string, FieldConfig>): string[];
1289
+ /**
1290
+ * Get fields that are not in the declared set
1291
+ *
1292
+ * Canonical location: `config/ordering.ts` (PRD §1.3.1/§1.3.2).
1293
+ *
1294
+ * @param allFields - All field names from config
1295
+ * @param declaredFields - Set of explicitly declared field names
1296
+ * @returns Array of unused field names
1297
+ */
1298
+ declare function getUnusedFields(allFields: string[], declaredFields: Set<string>): string[];
1299
+ /**
1300
+ * Get ordered unused fields
1301
+ *
1302
+ * Canonical location: `config/ordering.ts` (PRD §1.3.1/§1.3.2).
1303
+ *
1304
+ * @param allFields - All field names from config
1305
+ * @param declaredFields - Set of explicitly declared field names
1306
+ * @param fieldConfigs - Map of field configs
1307
+ * @returns Sorted array of unused field names
1308
+ */
1309
+ declare function getOrderedUnusedFields(allFields: string[], declaredFields: Set<string>, fieldConfigs: Record<string, FieldConfig>): string[];
1310
+
1189
1311
  /**
1190
1312
  * Convert a camelCase or PascalCase field name to a human-readable label
1191
1313
  *
@@ -1212,6 +1334,18 @@ declare function humanizeLabel(fieldName: string): string;
1212
1334
  * 5. Field config title (legacy alias)
1213
1335
  * 6. Auto-generated from field name
1214
1336
  *
1337
+ * **PRD deviation note (accepted, gap_analysis G5).** PRD §1.3.2's table
1338
+ * summarizes this export as `resolveLabel(config, fieldName)`. The implemented
1339
+ * signature is a richer superset —
1340
+ * `(fieldName, fieldConfig?, evaluatedSelectProps?, componentProps?)` — because
1341
+ * it resolves the full 6-source priority chain above in one call, which
1342
+ * requires the pre-evaluated `selectProps` and the JSX `componentProps`. This
1343
+ * is an internal API consumed by the framework adapters (e.g.
1344
+ * `@formality-ui/react`'s `Field` calls
1345
+ * `resolveLabel(name, fieldConfig, fieldSelectProps, restProps)`), not a
1346
+ * simplified end-user entry point; the PRD literal form is a condensed
1347
+ * representation. No code change is planned.
1348
+ *
1215
1349
  * @param fieldName - Field name
1216
1350
  * @param fieldConfig - Field configuration
1217
1351
  * @param evaluatedSelectProps - Pre-evaluated selectProps
@@ -1261,30 +1395,5 @@ declare function parseLabelWithUnit(label: string): {
1261
1395
  base: string;
1262
1396
  unit?: string;
1263
1397
  };
1264
- /**
1265
- * Sort fields by their order property
1266
- *
1267
- * @param fieldNames - Array of field names
1268
- * @param fieldConfigs - Map of field configs
1269
- * @returns Sorted array of field names
1270
- */
1271
- declare function sortFieldsByOrder(fieldNames: string[], fieldConfigs: Record<string, FieldConfig>): string[];
1272
- /**
1273
- * Get fields that are not in the declared set
1274
- *
1275
- * @param allFields - All field names from config
1276
- * @param declaredFields - Set of explicitly declared field names
1277
- * @returns Array of unused field names
1278
- */
1279
- declare function getUnusedFields(allFields: string[], declaredFields: Set<string>): string[];
1280
- /**
1281
- * Get ordered unused fields
1282
- *
1283
- * @param allFields - All field names from config
1284
- * @param declaredFields - Set of explicitly declared field names
1285
- * @param fieldConfigs - Map of field configs
1286
- * @returns Sorted array of unused field names
1287
- */
1288
- declare function getOrderedUnusedFields(allFields: string[], declaredFields: Set<string>, fieldConfigs: Record<string, FieldConfig>): string[];
1289
1398
 
1290
- export { type ConditionDescriptor, type ConditionResult, type ErrorMessagesConfig, type EvaluateConditionsInput, type EvaluationContext, FIELD_PROXY_MARKER, FIELD_PROXY_VALUE, type FieldConfig, type FieldError, type FieldState, type FieldStateInput, type FormConfig, type FormFieldsConfig, type FormState, type FormalityProviderConfig, type FormatterFunction, type FormatterSpec, type FormattersConfig, type GroupConfig, type InputConfig, type InputTemplateProps, KEYWORDS, type ParserFunction, type ParserSpec, type ParsersConfig, QUALIFIED_PREFIXES, type SelectFunction, type SelectValue, type ValidationResult, type ValidatorEntry, type ValidatorFactory, type ValidatorFunction, type ValidatorSpec, type ValidatorsConfig, buildEvaluationContext, buildFieldContext, buildFormContext, clearExpressionCache, composeValidators, conditionMatches, createConfigContext, createDefaultFormatters, createDefaultParsers, createErrorMessages, createFieldStateProxy, createFloatFormatter, createFloatParser, createIntParser, createLabelWithUnit, createTrimParser, createValidationError, deepMerge, evaluate, evaluateConditions, evaluateDescriptor, extractValueField, format, formatTypeAsMessage, getErrorType, getInputDefaultValue, getOrderedUnusedFields, getUnusedFields, humanizeLabel, inferFieldsFromConditions, inferFieldsFromDescriptor, inferFieldsFromExpression, isAutoGeneratedLabel, isEmptyValue, isFieldProxy, isValid, maxLength, mergeConditionResults, mergeFieldProps, mergeInputConfigs, mergeRecordWithDefaults, mergeStaticProps, minLength, parse, parseLabelWithUnit, pattern, required, resolveAllInitialValues, resolveErrorMessage, resolveFieldType, resolveFormTitle, resolveInitialValue, resolveInputConfig, resolveLabel, runValidator, runValidatorSync, sortFieldsByOrder, transformFieldName, unwrapFieldProxy };
1399
+ export { type ConditionDescriptor, type ConditionResult, type ErrorMessagesConfig, type EvaluateConditionsInput, type EvaluationContext, FIELD_PROXY_MARKER, FIELD_PROXY_VALUE, type FieldConfig, type FieldError, type FieldState, type FieldStateInput, type FormConfig, type FormFieldsConfig, type FormState, type FormalityProviderConfig, type FormatterFunction, type FormatterSpec, type FormattersConfig, type GroupConfig, type InputConfig, type InputTemplateProps, KEYWORDS, type ParserFunction, type ParserSpec, type ParsersConfig, QUALIFIED_PREFIXES, type SelectFunction, type SelectValue, type ValidationResult, type ValidatorEntry, type ValidatorFactory, type ValidatorFunction, type ValidatorSpec, type ValidatorsConfig, buildEvaluationContext, buildFieldContext, buildFormContext, clearExpressionCache, composeValidators, conditionMatches, createConfigContext, createDefaultFormatters, createDefaultParsers, createErrorMessages, createFieldStateProxy, createFloatFormatter, createFloatParser, createIntParser, createLabelWithUnit, createTrimParser, createValidationError, deepMerge, evaluate, evaluateConditions, evaluateDescriptor, extractValueField, format, formatTypeAsMessage, getErrorType, getInputDefaultValue, getOrderedUnusedFields, getUnusedFields, humanizeLabel, inferFieldsFromConditions, inferFieldsFromDescriptor, inferFieldsFromExpression, isAutoGeneratedLabel, isEmptyValue, isFieldProxy, isValid, maxLength, mergeConditionResults, mergeConfigs, mergeFieldProps, mergeInputConfigs, mergeRecordWithDefaults, mergeStaticProps, minLength, parse, parseLabelWithUnit, pattern, required, resolveAllInitialValues, resolveErrorMessage, resolveFieldType, resolveFormTitle, resolveInitialValue, resolveInputConfig, resolveLabel, runValidator, runValidatorSync, sortFieldsByOrder, transformFieldName, unwrapFieldProxy, validate };
package/dist/index.d.ts CHANGED
@@ -672,8 +672,22 @@ interface EvaluateConditionsInput {
672
672
  * - visible: AND logic (any false = false)
673
673
  * - setValue: last matching condition wins
674
674
  *
675
- * @param input - Evaluation input with conditions and state
676
- * @returns Result with resolved disabled, visible, and setValue states
675
+ * **Signature object-arg form.** Takes a single {@link EvaluateConditionsInput}
676
+ * object (`{ conditions, fieldValues, fieldStates?, record?, props? }`) rather
677
+ * than positional `(conditions, state)` arguments.
678
+ *
679
+ * **PRD deviation note (accepted, gap_analysis G4).** PRD §1.3.2's *table*
680
+ * summarizes this export as `evaluateConditions(conditions, state)`, but PRD
681
+ * §1.3.2's own *example code* defines and uses the identical
682
+ * {@link EvaluateConditionsInput} object-arg form implemented here. The table
683
+ * text is a simplified representation; the object-arg form is the actual, stable
684
+ * contract and is the shape every framework adapter passes (see e.g.
685
+ * `@formality-ui/react`'s `useConditions`). No code change is planned.
686
+ *
687
+ * @param input - {@link EvaluateConditionsInput} - Evaluation input with
688
+ * conditions and state
689
+ * @returns {@link ConditionResult} - Result with resolved disabled, visible,
690
+ * and setValue states
677
691
  *
678
692
  * @example
679
693
  * const result = evaluateConditions({
@@ -730,6 +744,35 @@ declare function mergeConditionResults(results: ConditionResult[]): ConditionRes
730
744
  */
731
745
  declare function inferFieldsFromConditions(conditions: ConditionDescriptor[]): string[];
732
746
 
747
+ /**
748
+ * Validate a value against a rule specification.
749
+ *
750
+ * PRD §1.3.2 headline export for the `validation/validate` module. This is a
751
+ * THIN WRAPPER over {@link runValidator}: it reorders the arguments into the
752
+ * ergonomic `(value, rules, validators, formValues)` shape documented in the
753
+ * PRD, defaults `formValues` to `{}`, and delegates every semantic (named
754
+ * lookup, factory detection, array short-circuit, async, throw-as-failure) to
755
+ * `runValidator` — see that function for details.
756
+ *
757
+ * This covers the RULES layer only (PRD §9.1). The field-validator and
758
+ * type-validator layers are wired by the adapter's `Field` Controller
759
+ * `rules.validate`; this function does not compose them.
760
+ *
761
+ * Returns the raw {@link ValidationResult}. Resolve a user-facing message
762
+ * with {@link resolveErrorMessage}.
763
+ *
764
+ * @param value - The value to validate.
765
+ * @param rules - ValidatorSpec: a named validator (string), an inline
766
+ * ValidatorFunction, or an array of either (run in sequence, short-circuiting
767
+ * on first failure).
768
+ * @param validators - Optional named-validators registry (ValidatorsConfig)
769
+ * for resolving string `rules`. When omitted, a string rule warns and passes.
770
+ * @param formValues - Optional full form values for cross-field validation.
771
+ * Defaults to `{}`.
772
+ * @returns The ValidationResult (`true`/`undefined` = valid; `false`/string/
773
+ * `{type,message?}` = invalid).
774
+ */
775
+ declare function validate(value: unknown, rules: ValidatorSpec, validators?: ValidatorsConfig, formValues?: Record<string, unknown>): Promise<ValidationResult | undefined>;
733
776
  /**
734
777
  * Run a validator specification against a value
735
778
  *
@@ -1110,6 +1153,43 @@ declare function createConfigContext(providerConfig: FormalityProviderConfig, fo
1110
1153
  defaultFieldProps: Record<string, unknown>;
1111
1154
  selectDefaultFieldProps: unknown;
1112
1155
  };
1156
+ /**
1157
+ * Merge provider + form + (optional) field configs into a resolved pair.
1158
+ *
1159
+ * PRD §1.3.2 headline export for the `config/merge` module. This is a
1160
+ * CONVENIENCE WRAPPER for the common 3-source static merge; it composes the
1161
+ * granular functions and delegates all semantics to them:
1162
+ *
1163
+ * - `inputConfig` = `resolveInputConfig(resolveFieldType(undefined, field),
1164
+ * mergeInputConfigs(provider.inputs, form?.inputs))`.
1165
+ * The field's type is derived from `field?.type` (default "textField").
1166
+ * - `fieldConfig.props` = `mergeStaticProps(provider.defaultFieldProps,
1167
+ * form?.defaultFieldProps, field?.props)` (provider → form →
1168
+ * field; later wins). The field's own config (type, label,
1169
+ * disabled, …) is preserved via spread.
1170
+ *
1171
+ * STATIC ONLY. This function does NOT evaluate `selectProps` or
1172
+ * `selectDefaultFieldProps` — those dynamic layers require a `FormState`
1173
+ * (expression evaluation) that a pure merge function cannot supply. For the
1174
+ * full evaluated 8-layer pipeline (PRD §5.3.2 / §6.1), use {@link mergeFieldProps}
1175
+ * from within an adapter that has form state.
1176
+ *
1177
+ * The granular functions ({@link mergeInputConfigs}, {@link resolveInputConfig},
1178
+ * {@link mergeStaticProps}, {@link mergeFieldProps}) remain exported for
1179
+ * advanced use.
1180
+ *
1181
+ * @param provider - Provider config (inputs REQUIRED).
1182
+ * @param form - Optional form config. When omitted, only provider inputs/
1183
+ * defaultFieldProps apply (matches {@link createConfigContext}).
1184
+ * @param field - Optional field config. Its `type` selects the inputConfig;
1185
+ * its `props` are the highest-priority static prop layer.
1186
+ * @returns `{ inputConfig, fieldConfig }`. `inputConfig` is `undefined` when the
1187
+ * resolved type is not registered and no "textField" default exists.
1188
+ */
1189
+ declare function mergeConfigs(provider: FormalityProviderConfig, form?: FormConfig, field?: FieldConfig): {
1190
+ inputConfig: InputConfig | undefined;
1191
+ fieldConfig: FieldConfig;
1192
+ };
1113
1193
 
1114
1194
  /**
1115
1195
  * Resolve the initial value for a field
@@ -1119,6 +1199,16 @@ declare function createConfigContext(providerConfig: FormalityProviderConfig, fo
1119
1199
  * 2. record[recordKey] (using recordKey if specified, else fieldName)
1120
1200
  * 3. inputConfig.defaultValue (from input type definition)
1121
1201
  *
1202
+ * **PRD deviation note (accepted, gap_analysis G5).** PRD §1.3.2's table
1203
+ * summarizes this export as `resolveInitialValue(record, config, inputConfig)`.
1204
+ * The implemented signature is a richer superset —
1205
+ * `(fieldName, fieldConfig?, inputConfig?, record?, defaultValues?)` — because
1206
+ * it drives the full priority chain above (defaultValues → record[recordKey] →
1207
+ * inputConfig.defaultValue) from a single call. This is an internal API
1208
+ * consumed by the framework adapters and by {@link resolveAllInitialValues},
1209
+ * not a simplified end-user entry point; the PRD literal form is a condensed
1210
+ * representation. No code change is planned.
1211
+ *
1122
1212
  * @param fieldName - Field name
1123
1213
  * @param fieldConfig - Field configuration
1124
1214
  * @param inputConfig - Input type configuration
@@ -1186,6 +1276,38 @@ declare function getInputDefaultValue(inputConfig?: InputConfig, typeName?: stri
1186
1276
  */
1187
1277
  declare function mergeRecordWithDefaults(record?: Record<string, unknown>, defaults?: Record<string, unknown>): Record<string, unknown>;
1188
1278
 
1279
+ /**
1280
+ * Sort fields by their order property
1281
+ *
1282
+ * Canonical location: `config/ordering.ts` (PRD §1.3.1/§1.3.2).
1283
+ *
1284
+ * @param fieldNames - Array of field names
1285
+ * @param fieldConfigs - Map of field configs
1286
+ * @returns Sorted array of field names
1287
+ */
1288
+ declare function sortFieldsByOrder(fieldNames: string[], fieldConfigs: Record<string, FieldConfig>): string[];
1289
+ /**
1290
+ * Get fields that are not in the declared set
1291
+ *
1292
+ * Canonical location: `config/ordering.ts` (PRD §1.3.1/§1.3.2).
1293
+ *
1294
+ * @param allFields - All field names from config
1295
+ * @param declaredFields - Set of explicitly declared field names
1296
+ * @returns Array of unused field names
1297
+ */
1298
+ declare function getUnusedFields(allFields: string[], declaredFields: Set<string>): string[];
1299
+ /**
1300
+ * Get ordered unused fields
1301
+ *
1302
+ * Canonical location: `config/ordering.ts` (PRD §1.3.1/§1.3.2).
1303
+ *
1304
+ * @param allFields - All field names from config
1305
+ * @param declaredFields - Set of explicitly declared field names
1306
+ * @param fieldConfigs - Map of field configs
1307
+ * @returns Sorted array of unused field names
1308
+ */
1309
+ declare function getOrderedUnusedFields(allFields: string[], declaredFields: Set<string>, fieldConfigs: Record<string, FieldConfig>): string[];
1310
+
1189
1311
  /**
1190
1312
  * Convert a camelCase or PascalCase field name to a human-readable label
1191
1313
  *
@@ -1212,6 +1334,18 @@ declare function humanizeLabel(fieldName: string): string;
1212
1334
  * 5. Field config title (legacy alias)
1213
1335
  * 6. Auto-generated from field name
1214
1336
  *
1337
+ * **PRD deviation note (accepted, gap_analysis G5).** PRD §1.3.2's table
1338
+ * summarizes this export as `resolveLabel(config, fieldName)`. The implemented
1339
+ * signature is a richer superset —
1340
+ * `(fieldName, fieldConfig?, evaluatedSelectProps?, componentProps?)` — because
1341
+ * it resolves the full 6-source priority chain above in one call, which
1342
+ * requires the pre-evaluated `selectProps` and the JSX `componentProps`. This
1343
+ * is an internal API consumed by the framework adapters (e.g.
1344
+ * `@formality-ui/react`'s `Field` calls
1345
+ * `resolveLabel(name, fieldConfig, fieldSelectProps, restProps)`), not a
1346
+ * simplified end-user entry point; the PRD literal form is a condensed
1347
+ * representation. No code change is planned.
1348
+ *
1215
1349
  * @param fieldName - Field name
1216
1350
  * @param fieldConfig - Field configuration
1217
1351
  * @param evaluatedSelectProps - Pre-evaluated selectProps
@@ -1261,30 +1395,5 @@ declare function parseLabelWithUnit(label: string): {
1261
1395
  base: string;
1262
1396
  unit?: string;
1263
1397
  };
1264
- /**
1265
- * Sort fields by their order property
1266
- *
1267
- * @param fieldNames - Array of field names
1268
- * @param fieldConfigs - Map of field configs
1269
- * @returns Sorted array of field names
1270
- */
1271
- declare function sortFieldsByOrder(fieldNames: string[], fieldConfigs: Record<string, FieldConfig>): string[];
1272
- /**
1273
- * Get fields that are not in the declared set
1274
- *
1275
- * @param allFields - All field names from config
1276
- * @param declaredFields - Set of explicitly declared field names
1277
- * @returns Array of unused field names
1278
- */
1279
- declare function getUnusedFields(allFields: string[], declaredFields: Set<string>): string[];
1280
- /**
1281
- * Get ordered unused fields
1282
- *
1283
- * @param allFields - All field names from config
1284
- * @param declaredFields - Set of explicitly declared field names
1285
- * @param fieldConfigs - Map of field configs
1286
- * @returns Sorted array of unused field names
1287
- */
1288
- declare function getOrderedUnusedFields(allFields: string[], declaredFields: Set<string>, fieldConfigs: Record<string, FieldConfig>): string[];
1289
1398
 
1290
- export { type ConditionDescriptor, type ConditionResult, type ErrorMessagesConfig, type EvaluateConditionsInput, type EvaluationContext, FIELD_PROXY_MARKER, FIELD_PROXY_VALUE, type FieldConfig, type FieldError, type FieldState, type FieldStateInput, type FormConfig, type FormFieldsConfig, type FormState, type FormalityProviderConfig, type FormatterFunction, type FormatterSpec, type FormattersConfig, type GroupConfig, type InputConfig, type InputTemplateProps, KEYWORDS, type ParserFunction, type ParserSpec, type ParsersConfig, QUALIFIED_PREFIXES, type SelectFunction, type SelectValue, type ValidationResult, type ValidatorEntry, type ValidatorFactory, type ValidatorFunction, type ValidatorSpec, type ValidatorsConfig, buildEvaluationContext, buildFieldContext, buildFormContext, clearExpressionCache, composeValidators, conditionMatches, createConfigContext, createDefaultFormatters, createDefaultParsers, createErrorMessages, createFieldStateProxy, createFloatFormatter, createFloatParser, createIntParser, createLabelWithUnit, createTrimParser, createValidationError, deepMerge, evaluate, evaluateConditions, evaluateDescriptor, extractValueField, format, formatTypeAsMessage, getErrorType, getInputDefaultValue, getOrderedUnusedFields, getUnusedFields, humanizeLabel, inferFieldsFromConditions, inferFieldsFromDescriptor, inferFieldsFromExpression, isAutoGeneratedLabel, isEmptyValue, isFieldProxy, isValid, maxLength, mergeConditionResults, mergeFieldProps, mergeInputConfigs, mergeRecordWithDefaults, mergeStaticProps, minLength, parse, parseLabelWithUnit, pattern, required, resolveAllInitialValues, resolveErrorMessage, resolveFieldType, resolveFormTitle, resolveInitialValue, resolveInputConfig, resolveLabel, runValidator, runValidatorSync, sortFieldsByOrder, transformFieldName, unwrapFieldProxy };
1399
+ export { type ConditionDescriptor, type ConditionResult, type ErrorMessagesConfig, type EvaluateConditionsInput, type EvaluationContext, FIELD_PROXY_MARKER, FIELD_PROXY_VALUE, type FieldConfig, type FieldError, type FieldState, type FieldStateInput, type FormConfig, type FormFieldsConfig, type FormState, type FormalityProviderConfig, type FormatterFunction, type FormatterSpec, type FormattersConfig, type GroupConfig, type InputConfig, type InputTemplateProps, KEYWORDS, type ParserFunction, type ParserSpec, type ParsersConfig, QUALIFIED_PREFIXES, type SelectFunction, type SelectValue, type ValidationResult, type ValidatorEntry, type ValidatorFactory, type ValidatorFunction, type ValidatorSpec, type ValidatorsConfig, buildEvaluationContext, buildFieldContext, buildFormContext, clearExpressionCache, composeValidators, conditionMatches, createConfigContext, createDefaultFormatters, createDefaultParsers, createErrorMessages, createFieldStateProxy, createFloatFormatter, createFloatParser, createIntParser, createLabelWithUnit, createTrimParser, createValidationError, deepMerge, evaluate, evaluateConditions, evaluateDescriptor, extractValueField, format, formatTypeAsMessage, getErrorType, getInputDefaultValue, getOrderedUnusedFields, getUnusedFields, humanizeLabel, inferFieldsFromConditions, inferFieldsFromDescriptor, inferFieldsFromExpression, isAutoGeneratedLabel, isEmptyValue, isFieldProxy, isValid, maxLength, mergeConditionResults, mergeConfigs, mergeFieldProps, mergeInputConfigs, mergeRecordWithDefaults, mergeStaticProps, minLength, parse, parseLabelWithUnit, pattern, required, resolveAllInitialValues, resolveErrorMessage, resolveFieldType, resolveFormTitle, resolveInitialValue, resolveInputConfig, resolveLabel, runValidator, runValidatorSync, sortFieldsByOrder, transformFieldName, unwrapFieldProxy, validate };
package/dist/index.js CHANGED
@@ -717,6 +717,9 @@ function inferFieldsFromConditions(conditions) {
717
717
  }
718
718
 
719
719
  // src/validation/validate.ts
720
+ async function validate(value, rules, validators, formValues) {
721
+ return runValidator(rules, value, formValues ?? {}, validators);
722
+ }
720
723
  function runSingleValidator(validator, value, formValues) {
721
724
  try {
722
725
  return validator(value, formValues);
@@ -1201,6 +1204,20 @@ function createConfigContext(providerConfig, formConfig) {
1201
1204
  selectDefaultFieldProps: formConfig?.selectDefaultFieldProps ?? providerConfig.selectDefaultFieldProps
1202
1205
  };
1203
1206
  }
1207
+ function mergeConfigs(provider, form, field) {
1208
+ const mergedInputs = mergeInputConfigs(provider.inputs, form?.inputs);
1209
+ const type = resolveFieldType(void 0, field, "textField");
1210
+ const inputConfig = resolveInputConfig(type, mergedInputs);
1211
+ const fieldConfig = {
1212
+ ...field,
1213
+ props: mergeStaticProps(
1214
+ provider.defaultFieldProps,
1215
+ form?.defaultFieldProps,
1216
+ field?.props
1217
+ )
1218
+ };
1219
+ return { inputConfig, fieldConfig };
1220
+ }
1204
1221
 
1205
1222
  // src/config/defaults.ts
1206
1223
  function resolveInitialValue(fieldName, fieldConfig, inputConfig, record, defaultValues) {
@@ -1296,6 +1313,22 @@ function mergeRecordWithDefaults(record, defaults) {
1296
1313
  return result;
1297
1314
  }
1298
1315
 
1316
+ // src/config/ordering.ts
1317
+ function sortFieldsByOrder(fieldNames, fieldConfigs) {
1318
+ return [...fieldNames].sort((a, b) => {
1319
+ const orderA = fieldConfigs[a]?.order ?? Infinity;
1320
+ const orderB = fieldConfigs[b]?.order ?? Infinity;
1321
+ return orderA - orderB;
1322
+ });
1323
+ }
1324
+ function getUnusedFields(allFields, declaredFields) {
1325
+ return allFields.filter((name) => !declaredFields.has(name));
1326
+ }
1327
+ function getOrderedUnusedFields(allFields, declaredFields, fieldConfigs) {
1328
+ const unused = getUnusedFields(allFields, declaredFields);
1329
+ return sortFieldsByOrder(unused, fieldConfigs);
1330
+ }
1331
+
1299
1332
  // src/labels/resolve.ts
1300
1333
  function humanizeLabel(fieldName) {
1301
1334
  if (!fieldName) {
@@ -1347,21 +1380,7 @@ function parseLabelWithUnit(label) {
1347
1380
  }
1348
1381
  return { base: label };
1349
1382
  }
1350
- function sortFieldsByOrder(fieldNames, fieldConfigs) {
1351
- return [...fieldNames].sort((a, b) => {
1352
- const orderA = fieldConfigs[a]?.order ?? Infinity;
1353
- const orderB = fieldConfigs[b]?.order ?? Infinity;
1354
- return orderA - orderB;
1355
- });
1356
- }
1357
- function getUnusedFields(allFields, declaredFields) {
1358
- return allFields.filter((name) => !declaredFields.has(name));
1359
- }
1360
- function getOrderedUnusedFields(allFields, declaredFields, fieldConfigs) {
1361
- const unused = getUnusedFields(allFields, declaredFields);
1362
- return sortFieldsByOrder(unused, fieldConfigs);
1363
- }
1364
1383
 
1365
- export { FIELD_PROXY_MARKER, FIELD_PROXY_VALUE, KEYWORDS, QUALIFIED_PREFIXES, buildEvaluationContext, buildFieldContext, buildFormContext, clearExpressionCache, composeValidators, conditionMatches, createConfigContext, createDefaultFormatters, createDefaultParsers, createErrorMessages, createFieldStateProxy, createFloatFormatter, createFloatParser, createIntParser, createLabelWithUnit, createTrimParser, createValidationError, deepMerge, evaluate, evaluateConditions, evaluateDescriptor, extractValueField, format, formatTypeAsMessage, getErrorType, getInputDefaultValue, getOrderedUnusedFields, getUnusedFields, humanizeLabel, inferFieldsFromConditions, inferFieldsFromDescriptor, inferFieldsFromExpression, isAutoGeneratedLabel, isEmptyValue, isFieldProxy, isValid, maxLength, mergeConditionResults, mergeFieldProps, mergeInputConfigs, mergeRecordWithDefaults, mergeStaticProps, minLength, parse, parseLabelWithUnit, pattern, required, resolveAllInitialValues, resolveErrorMessage, resolveFieldType, resolveFormTitle, resolveInitialValue, resolveInputConfig, resolveLabel, runValidator, runValidatorSync, sortFieldsByOrder, transformFieldName, unwrapFieldProxy };
1384
+ export { FIELD_PROXY_MARKER, FIELD_PROXY_VALUE, KEYWORDS, QUALIFIED_PREFIXES, buildEvaluationContext, buildFieldContext, buildFormContext, clearExpressionCache, composeValidators, conditionMatches, createConfigContext, createDefaultFormatters, createDefaultParsers, createErrorMessages, createFieldStateProxy, createFloatFormatter, createFloatParser, createIntParser, createLabelWithUnit, createTrimParser, createValidationError, deepMerge, evaluate, evaluateConditions, evaluateDescriptor, extractValueField, format, formatTypeAsMessage, getErrorType, getInputDefaultValue, getOrderedUnusedFields, getUnusedFields, humanizeLabel, inferFieldsFromConditions, inferFieldsFromDescriptor, inferFieldsFromExpression, isAutoGeneratedLabel, isEmptyValue, isFieldProxy, isValid, maxLength, mergeConditionResults, mergeConfigs, mergeFieldProps, mergeInputConfigs, mergeRecordWithDefaults, mergeStaticProps, minLength, parse, parseLabelWithUnit, pattern, required, resolveAllInitialValues, resolveErrorMessage, resolveFieldType, resolveFormTitle, resolveInitialValue, resolveInputConfig, resolveLabel, runValidator, runValidatorSync, sortFieldsByOrder, transformFieldName, unwrapFieldProxy, validate };
1366
1385
  //# sourceMappingURL=index.js.map
1367
1386
  //# sourceMappingURL=index.js.map