@availity/mui-controlled-form 1.2.9 → 1.3.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.
package/src/lib/Types.tsx CHANGED
@@ -33,9 +33,22 @@ export type ControllerProps = {
33
33
  shouldUnregister?: MuiControllerProps['shouldUnregister'];
34
34
  };
35
35
 
36
+ export type TransformProp<Input = string, Output = string> = {
37
+ /** Object containing functions to parse the input value and format the output value. Useful for converting values from API responses to display values and back.
38
+ * - `input`: Function to transform the value from the underlying data to the input value.
39
+ * - `output`: Function to transform the value from the input to the underlying data.
40
+ *
41
+ * Example: The input always expects a dayjs object, but your endpoint expects and returns a string:
42
+ * `{ input: (value) => value ? dayjs(value) : null, output: (value) => value.format('YYYY-MM-DD') }`
43
+ */
44
+ transform?: { input?: (value: Output) => Input; output?: (value: Input) => Output };
45
+ };
46
+
36
47
  // Storybook Categories
37
48
 
38
- type AllControllerProps = ControllerProps & Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'>;
49
+ type AllControllerProps = ControllerProps &
50
+ Pick<RegisterOptions<FieldValues, string>, 'onBlur' | 'onChange' | 'value'> &
51
+ TransformProp;
39
52
 
40
53
  type CategorizedControllerPropsObject = Record<keyof AllControllerProps, { table: { category: 'Controller Props' } }>;
41
54
 
@@ -185,6 +198,7 @@ export const AllControllerPropertiesCategorized: CategorizedControllerPropsObjec
185
198
  value: { table: { category: 'Controller Props' } },
186
199
  rules: { table: { category: 'Controller Props' } },
187
200
  shouldUnregister: { table: { category: 'Controller Props' } },
201
+ transform: { table: { category: 'Controller Props' } },
188
202
  };
189
203
 
190
204
  export const TextFieldPropsCategorized: TextFieldPropsObject = {