@trackunit/react-form-components 0.0.288 → 0.0.289
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/index.cjs.js +924 -871
- package/index.esm.js +927 -875
- package/package.json +1 -1
- package/src/SelectField/SelectField.d.ts +50 -0
- package/src/index.d.ts +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CommonProps } from "@trackunit/react-components";
|
|
3
|
+
import { GroupBase } from "react-select";
|
|
4
|
+
import { FormGroupProps } from "../components/FormGroup/FormGroup";
|
|
5
|
+
import { SelectProps } from "../components/Select/useSelect";
|
|
6
|
+
export type BaseOptionType = {
|
|
7
|
+
label: string;
|
|
8
|
+
value: string | number;
|
|
9
|
+
};
|
|
10
|
+
type SelectExposedProps<TOptionType extends BaseOptionType> = Omit<SelectProps<TOptionType, false, false, GroupBase<TOptionType>>, "value" | "label" | "onChange" | "defaultValue" | "onBlur">;
|
|
11
|
+
type FormGroupExposedProps = Pick<FormGroupProps, "label" | "tip" | "helpText" | "helpAddon" | "isInvalid">;
|
|
12
|
+
export interface SelectFieldProps<TOptionType extends BaseOptionType> extends CommonProps, FormGroupExposedProps, SelectExposedProps<TOptionType> {
|
|
13
|
+
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
14
|
+
/**
|
|
15
|
+
* The options available for the SelectField.
|
|
16
|
+
*/
|
|
17
|
+
options: TOptionType[];
|
|
18
|
+
/**
|
|
19
|
+
* The selected value of the SelectField.
|
|
20
|
+
*/
|
|
21
|
+
value?: TOptionType["value"];
|
|
22
|
+
/**
|
|
23
|
+
* The default selected value of the SelectField.
|
|
24
|
+
*/
|
|
25
|
+
defaultValue?: TOptionType["value"];
|
|
26
|
+
/**
|
|
27
|
+
* The onChange handler for the SelectField.
|
|
28
|
+
*/
|
|
29
|
+
onChange?: (event: {
|
|
30
|
+
target: {
|
|
31
|
+
value?: TOptionType["value"];
|
|
32
|
+
};
|
|
33
|
+
}) => void;
|
|
34
|
+
/**
|
|
35
|
+
* If a value is set, the field is rendered in its invalid state.
|
|
36
|
+
*/
|
|
37
|
+
errorMessage?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The SelectField component is a Select component wrapped in the FromGroup component.
|
|
41
|
+
*
|
|
42
|
+
* This means that it can easily be added to any form alongside other Field components.
|
|
43
|
+
*
|
|
44
|
+
* This is done to make the field compatible with the React-hook-form library.
|
|
45
|
+
*
|
|
46
|
+
* @param {SelectFieldProps} props - The props for the SelectField component
|
|
47
|
+
* @returns {JSX.Element} SelectField component
|
|
48
|
+
*/
|
|
49
|
+
export declare const SelectField: import("react").ForwardRefExoticComponent<SelectFieldProps<BaseOptionType> & import("react").RefAttributes<HTMLSelectElement>>;
|
|
50
|
+
export {};
|
package/src/index.d.ts
CHANGED