@rjsf/utils 6.4.1 → 6.5.0

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.
Files changed (40) hide show
  1. package/dist/index.cjs +198 -84
  2. package/dist/index.cjs.map +4 -4
  3. package/dist/utils.esm.js +198 -84
  4. package/dist/utils.esm.js.map +4 -4
  5. package/dist/utils.umd.js +185 -80
  6. package/lib/enumOptionSelectedValue.d.ts +15 -0
  7. package/lib/enumOptionSelectedValue.js +28 -0
  8. package/lib/enumOptionSelectedValue.js.map +1 -0
  9. package/lib/enumOptionValueDecoder.d.ts +17 -0
  10. package/lib/enumOptionValueDecoder.js +53 -0
  11. package/lib/enumOptionValueDecoder.js.map +1 -0
  12. package/lib/enumOptionValueEncoder.d.ts +15 -0
  13. package/lib/enumOptionValueEncoder.js +27 -0
  14. package/lib/enumOptionValueEncoder.js.map +1 -0
  15. package/lib/getInputProps.js +9 -0
  16. package/lib/getInputProps.js.map +1 -1
  17. package/lib/getOptionValueFormat.d.ts +16 -0
  18. package/lib/getOptionValueFormat.js +17 -0
  19. package/lib/getOptionValueFormat.js.map +1 -0
  20. package/lib/index.d.ts +7 -2
  21. package/lib/index.js +7 -2
  22. package/lib/index.js.map +1 -1
  23. package/lib/removeOptionalEmptyObjects.d.ts +17 -0
  24. package/lib/removeOptionalEmptyObjects.js +108 -0
  25. package/lib/removeOptionalEmptyObjects.js.map +1 -0
  26. package/lib/resolveUiSchema.d.ts +5 -19
  27. package/lib/resolveUiSchema.js +49 -95
  28. package/lib/resolveUiSchema.js.map +1 -1
  29. package/lib/tsconfig.tsbuildinfo +1 -1
  30. package/lib/types.d.ts +27 -1
  31. package/package.json +4 -4
  32. package/src/enumOptionSelectedValue.ts +39 -0
  33. package/src/enumOptionValueDecoder.ts +64 -0
  34. package/src/enumOptionValueEncoder.ts +33 -0
  35. package/src/getInputProps.ts +10 -0
  36. package/src/getOptionValueFormat.ts +17 -0
  37. package/src/index.ts +11 -2
  38. package/src/removeOptionalEmptyObjects.ts +127 -0
  39. package/src/resolveUiSchema.ts +55 -122
  40. package/src/types.ts +28 -1
package/src/types.ts CHANGED
@@ -36,6 +36,14 @@ export type FormContextType = GenericObjectType;
36
36
  */
37
37
  export type TestIdShape = Record<string, string>;
38
38
 
39
+ /** Controls how enum-backed widgets encode option values in their DOM `value` attributes.
40
+ *
41
+ * - `'indexed'`: options are encoded as their array index (default, historical behavior).
42
+ * - `'realValue'`: primitive option values are stringified directly, enabling native form
43
+ * submission. Object/array values still fall back to their index.
44
+ */
45
+ export type OptionValueFormat = 'indexed' | 'realValue';
46
+
39
47
  /** Function to generate HTML name attributes from path segments */
40
48
  export type NameGeneratorFunction = (path: FieldPathList, idPrefix: string, isMultiValue?: boolean) => string;
41
49
 
@@ -151,11 +159,15 @@ export type RangeSpecType = {
151
159
  };
152
160
 
153
161
  /** Properties describing a Range specification in terms of attribute that can be added to the `HTML` `<input>` */
154
- export type InputPropsType = Omit<RangeSpecType, 'step'> & {
162
+ export type InputPropsType = {
155
163
  /** Specifies the type of the <input> element */
156
164
  type: string;
157
165
  /** Specifies the interval between legal numbers in an input field or "any" */
158
166
  step?: number | 'any';
167
+ /** Specifies a minimum value for an <input> element; accepts a number for numeric inputs or a string for date/time inputs */
168
+ min?: number | string;
169
+ /** Specifies the maximum value for an <input> element; accepts a number for numeric inputs or a string for date/time inputs */
170
+ max?: number | string;
159
171
  /** Specifies the `autoComplete` value for an <input> element */
160
172
  autoComplete?: HTMLInputElement['autocomplete'];
161
173
  /** Specifies a filter for what file types the user can upload. */
@@ -420,6 +432,21 @@ export type GlobalUISchemaOptions = GenericObjectType & {
420
432
  * both. To disable the Optional Data Field UI for a specific field, provide an empty array within the UI schema.
421
433
  */
422
434
  enableOptionalDataFieldForType?: ('object' | 'array')[];
435
+ /** Controls how enum-backed widgets (select, radio, checkboxes) encode option values
436
+ * in their DOM `value` attributes.
437
+ *
438
+ * - `'indexed'` (default): options are encoded as their array index. This is the
439
+ * historical behavior and keeps object/array enum values addressable without
440
+ * stringifying them.
441
+ * - `'realValue'`: primitive option values are stringified directly (e.g. `"foo"`,
442
+ * `"42"`, `"true"`). This enables native form submission and browser autocomplete
443
+ * since the submitted value matches the enum value. Object/array values still
444
+ * fall back to their index since `String(obj)` would produce `"[object Object]"`.
445
+ *
446
+ * The form data passed to `onChange` is always the typed enum value; this option
447
+ * only affects the DOM-level encoding.
448
+ */
449
+ optionValueFormat?: OptionValueFormat;
423
450
  };
424
451
 
425
452
  /** The set of options from the `Form` that will be available on the `Registry` for use in everywhere the `registry` is