@procore/core-react
Version:
React library of Procore Design Guidelines
73 lines (71 loc) • 1.76 kB
TypeScript
import type React from 'react';
/**
* @deprecatedSince 9
* @deprecated Never officially documented/supported
*/
export declare type ChangeEvent = React.ChangeEvent<HTMLInputElement>;
/**
* @deprecatedSince 9
* @deprecated Never officially documented/supported
*/
export interface TextEntryConfig {
initialValue?: string;
onChange: (event: ChangeEvent) => void;
}
/**
* @deprecatedSince 9
* @deprecated Never officially documented/supported
*/
export interface TextEntryApi {
clear: () => void;
empty: boolean;
onChange: (event: ChangeEvent) => void;
reset: () => void;
value: string;
}
interface RenderProps extends TextEntryConfig {
children: (props: TextEntryApi) => {};
}
/**
* @deprecatedSince 9.7.0
* @deprecated A wrapper around useBuffer (deprecated) that would also call onChange. A trivial hook for storing a string. Write your own or use a hook utility lib.
*
* **Source:**
* ```
export function useTextEntry({
initialValue = '',
onChange = () => {},
}) {
const { value, update, clear, reset } = useBuffer({ initialValue })
return {
clear: () => {
onChange({ target: { value: '' } })
clear()
},
empty: Ramda.isEmpty(value),
onChange: (event) => {
onChange(event)
update(event.target.value)
},
reset: () => {
onChange({ target: { value } })
reset()
},
value,
}
}
```
*/
export declare function useTextEntry({ initialValue, onChange, }: TextEntryConfig): {
clear: () => void;
empty: boolean;
onChange: (event: ChangeEvent) => void;
reset: () => void;
value: string;
};
/**
* @deprecatedSince 9.7.0
* @deprecated
*/
export declare function TextEntry({ children, ...props }: RenderProps): {};
export {};