@producteca/producteca-ui-kit 1.7.0 → 1.8.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.
@@ -1,4 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ import { ReduxFormInput } from '../../../hooks/useReduxFormField';
2
3
 
3
4
  export interface CheckboxItem {
4
5
  id?: string;
@@ -15,12 +16,7 @@ export interface CheckboxInputProps {
15
16
  title?: string;
16
17
  type?: 'checkbox' | 'radio';
17
18
  size?: 'sm' | 'md' | 'lg';
18
- input?: {
19
- value: any;
20
- onChange: (value: any) => void;
21
- onBlur: () => void;
22
- name: string;
23
- };
19
+ input?: ReduxFormInput;
24
20
  }
25
21
  export declare const CheckboxInput: React.FC<CheckboxInputProps>;
26
22
  export default CheckboxInput;
@@ -1,5 +1,6 @@
1
1
  import { default as React, ChangeEvent } from 'react';
2
2
  import { Meta, InputValue } from '../../../validators';
3
+ import { ReduxFormInput } from '../../../hooks/useReduxFormField';
3
4
 
4
5
  export interface TextInputProps {
5
6
  meta?: Meta;
@@ -18,11 +19,6 @@ export interface TextInputProps {
18
19
  isValid?: (value: InputValue) => boolean;
19
20
  type?: 'text' | 'number' | 'password' | undefined;
20
21
  onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
21
- input?: {
22
- value: any;
23
- onChange: (value: any) => void;
24
- onBlur: () => void;
25
- name: string;
26
- };
22
+ input?: ReduxFormInput;
27
23
  }
28
24
  export declare const TextInput: React.FC<TextInputProps>;
@@ -1,5 +1,6 @@
1
1
  import { default as React } from 'react';
2
2
  import { OptionProps, SingleValueProps } from 'react-select';
3
+ import { ReduxFormInput } from '../../../hooks/useReduxFormField';
3
4
 
4
5
  export interface SelectOption {
5
6
  label: string;
@@ -27,12 +28,7 @@ export interface SelectFieldProps {
27
28
  value?: (string | number)[] | null | undefined;
28
29
  defaultValue?: (string | number) | (string | number)[] | null | undefined;
29
30
  onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
30
- input?: {
31
- value: any;
32
- onChange: (value: any) => void;
33
- onBlur: () => void;
34
- name: string;
35
- };
31
+ input?: ReduxFormInput;
36
32
  }
37
33
  export declare const Option: (props: OptionProps<SelectOption>) => import("react/jsx-runtime").JSX.Element;
38
34
  export declare const SingleValue: (props: SingleValueProps<SelectOption>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,26 @@
1
+ import { ChangeEvent } from 'react';
2
+
3
+ export type ReduxFormInput = {
4
+ value: any;
5
+ onChange: (value: any) => void;
6
+ onBlur: () => void;
7
+ name: string;
8
+ };
9
+ interface UseReduxFormFieldParams<T, E = ChangeEvent<any>> {
10
+ input?: ReduxFormInput;
11
+ onChange?: (event: E) => void;
12
+ onBlur?: () => void;
13
+ transformValue?: (value: any, event: E) => T;
14
+ }
15
+ interface UseReduxFormFieldResult<E> {
16
+ handleChange: (event: E) => void;
17
+ handleBlur: () => void;
18
+ }
19
+ /**
20
+ * Hook to unify Redux Form and regular form field handling
21
+ *
22
+ * @param params Configuration object containing input, onChange, and transformValue
23
+ * @returns Object with handleChange and handleBlur functions
24
+ */
25
+ export declare function useReduxFormField<T, E = ChangeEvent<any>>({ input, onChange, onBlur, transformValue, }: UseReduxFormFieldParams<T, E>): UseReduxFormFieldResult<E>;
26
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './components';
2
2
  export * from './styles/colors';
3
+ export * from './hooks/useReduxFormField';
@@ -26,6 +26,9 @@ declare const _default: {
26
26
  onChangeCheckboxInput: string;
27
27
  onChangeInput: string;
28
28
  isOptionDisabled: string;
29
+ reduxForm: {
30
+ input: string;
31
+ };
29
32
  selectField: {
30
33
  example: string;
31
34
  defaultValue: string;