@trackunit/react-form-components 0.0.1
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/README.md +24 -0
- package/index.cjs +1274 -0
- package/index.css +259 -0
- package/index.js +1210 -0
- package/package.json +21 -0
- package/src/components/ActionButton/ActionButton.d.ts +26 -0
- package/src/components/ActionButton/index.d.ts +1 -0
- package/src/components/BaseInput/BaseInput.d.ts +62 -0
- package/src/components/BaseInput/index.d.ts +1 -0
- package/src/components/Checkbox/CheckIcon.d.ts +12 -0
- package/src/components/Checkbox/Checkbox.d.ts +48 -0
- package/src/components/Checkbox/IndeterminateIcon.d.ts +10 -0
- package/src/components/Checkbox/index.d.ts +1 -0
- package/src/components/DateField/DateField.d.ts +19 -0
- package/src/components/DateInput/DateInput.d.ts +28 -0
- package/src/components/DropZone/DropZone.d.ts +34 -0
- package/src/components/EmailField/EmailField.d.ts +17 -0
- package/src/components/EmailInput/EmailInput.d.ts +13 -0
- package/src/components/EmailInput/index.d.ts +1 -0
- package/src/components/FormGroup/FormGroup.d.ts +39 -0
- package/src/components/Label/Label.d.ts +34 -0
- package/src/components/Label/index.d.ts +1 -0
- package/src/components/NumberField/NumberField.d.ts +19 -0
- package/src/components/NumberInput/NumberInput.d.ts +12 -0
- package/src/components/PhoneField/PhoneField.d.ts +28 -0
- package/src/components/PhoneInput/CountryCodeSelect.d.ts +16 -0
- package/src/components/PhoneInput/CountryCodes.d.ts +5 -0
- package/src/components/PhoneInput/PhoneInput.d.ts +25 -0
- package/src/components/PhoneInput/index.d.ts +1 -0
- package/src/components/RadioGroup/RadioGroup.d.ts +57 -0
- package/src/components/RadioGroup/RadioGroupContext.d.ts +11 -0
- package/src/components/RadioGroup/RadioItem.d.ts +23 -0
- package/src/components/RadioGroup/index.d.ts +2 -0
- package/src/components/Search/Search.d.ts +62 -0
- package/src/components/Search/index.d.ts +1 -0
- package/src/components/Select/CreatableSelect.d.ts +38 -0
- package/src/components/Select/FieldContainer.d.ts +20 -0
- package/src/components/Select/Select.d.ts +18 -0
- package/src/components/Select/SelectMenuItem/SelectMenuItem.d.ts +49 -0
- package/src/components/Select/TagWithWidth.d.ts +17 -0
- package/src/components/Select/TagsContainer.d.ts +45 -0
- package/src/components/Select/index.d.ts +7 -0
- package/src/components/Select/shared.d.ts +15 -0
- package/src/components/Select/useCustomComponents.d.ts +19 -0
- package/src/components/Select/useCustomStyles.d.ts +14 -0
- package/src/components/Select/useSelect.d.ts +143 -0
- package/src/components/TextArea/TextArea.d.ts +30 -0
- package/src/components/TextArea/index.d.ts +1 -0
- package/src/components/TextAreaField/TextAreaField.d.ts +18 -0
- package/src/components/TextAreaField/index.d.ts +1 -0
- package/src/components/TextField/TextField.d.ts +24 -0
- package/src/components/TextField/TextLenghtIndicator.d.ts +19 -0
- package/src/components/TextField/index.d.ts +1 -0
- package/src/components/TextInput/TextInput.d.ts +12 -0
- package/src/components/Toggle/Toggle.d.ts +57 -0
- package/src/components/Toggle/index.d.ts +1 -0
- package/src/components/UploadField/UploadField.d.ts +15 -0
- package/src/components/UploadInput/UploadInput.d.ts +33 -0
- package/src/index.d.ts +24 -0
- package/src/test-utils/hooks.d.ts +4 -0
- package/src/test-utils/test-utils.d.ts +5 -0
- package/src/translation.d.ts +34 -0
- package/translation.cjs +7 -0
- package/translation.js +5 -0
- package/translation10.cjs +7 -0
- package/translation10.js +5 -0
- package/translation11.cjs +7 -0
- package/translation11.js +5 -0
- package/translation12.cjs +7 -0
- package/translation12.js +5 -0
- package/translation13.cjs +7 -0
- package/translation13.js +5 -0
- package/translation14.cjs +7 -0
- package/translation14.js +5 -0
- package/translation15.cjs +7 -0
- package/translation15.js +5 -0
- package/translation16.cjs +7 -0
- package/translation16.js +5 -0
- package/translation17.cjs +7 -0
- package/translation17.js +5 -0
- package/translation2.cjs +7 -0
- package/translation2.js +5 -0
- package/translation3.cjs +7 -0
- package/translation3.js +5 -0
- package/translation4.cjs +7 -0
- package/translation4.js +5 -0
- package/translation5.cjs +7 -0
- package/translation5.js +5 -0
- package/translation6.cjs +7 -0
- package/translation6.js +5 -0
- package/translation7.cjs +7 -0
- package/translation7.js +5 -0
- package/translation8.cjs +7 -0
- package/translation8.js +5 -0
- package/translation9.cjs +7 -0
- package/translation9.js +5 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { CommonProps } from "@trackunit/react-components";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { TextInputProps } from "../TextInput/TextInput";
|
|
4
|
+
export interface SearchProps extends CommonProps, TextInputProps {
|
|
5
|
+
/**
|
|
6
|
+
* The name for the HTML element.
|
|
7
|
+
*/
|
|
8
|
+
name?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Placeholder string to be shown in the search box.
|
|
11
|
+
*/
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the search box should widen to take up full width while in focus or not.
|
|
15
|
+
* If disabled, the search box takes up full width when not in focus.
|
|
16
|
+
*/
|
|
17
|
+
widenInputOnFocus?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the border for the search box should be displayed while the search box is not in focus.
|
|
20
|
+
*/
|
|
21
|
+
showBorderWhenNotInFocus?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Value rendered in the search box.
|
|
24
|
+
*/
|
|
25
|
+
value?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the search box is disabled or not.
|
|
28
|
+
*/
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Specify what if any permission the user agent has to provide automated assistance in filling out search values.
|
|
32
|
+
*/
|
|
33
|
+
autoComplete?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Event that occurs when the user releases a key.
|
|
36
|
+
*/
|
|
37
|
+
onKeyUp?: (evt: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Event that occurs when there is a change.
|
|
40
|
+
*/
|
|
41
|
+
onChange?: (evt: React.ChangeEvent<HTMLInputElement>) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Event that occurs when the search box is on focus.
|
|
44
|
+
*/
|
|
45
|
+
onFocus?: (evt: React.FocusEvent<HTMLInputElement>) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Event that occurs when search box is blurred.
|
|
48
|
+
*/
|
|
49
|
+
onBlur?: (evt: React.FocusEvent<HTMLInputElement>) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Event that search box is cleared.
|
|
52
|
+
*/
|
|
53
|
+
onClear?: () => void;
|
|
54
|
+
ref?: React.Ref<HTMLInputElement | undefined>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The Search component is used to render a search input field.
|
|
58
|
+
*
|
|
59
|
+
* @param {SearchProps} props - The props for the Search component
|
|
60
|
+
* @returns {JSX.Element} Search component
|
|
61
|
+
*/
|
|
62
|
+
export declare const Search: ({ className, placeholder, value, widenInputOnFocus, showBorderWhenNotInFocus, disabled, onKeyUp, onChange, onFocus, onBlur, name, onClear, dataTestId, autoComplete, ref, ...rest }: SearchProps) => JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Search";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { GroupBase } from "react-select";
|
|
3
|
+
import { SelectProps } from "./useSelect";
|
|
4
|
+
interface CreateableSelectProps<Option, IsAsync extends boolean = false, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>> extends SelectProps<Option, IsAsync, IsMulti, Group> {
|
|
5
|
+
/**
|
|
6
|
+
* To hide the label.
|
|
7
|
+
*/
|
|
8
|
+
hideLabel?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Description for the select component.
|
|
11
|
+
*/
|
|
12
|
+
description?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the component is invalid.
|
|
15
|
+
*/
|
|
16
|
+
isInvalid?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Info of the select component.
|
|
19
|
+
*/
|
|
20
|
+
info?: React.ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Error of the select component.
|
|
23
|
+
*/
|
|
24
|
+
error?: React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Size of the component.
|
|
27
|
+
*/
|
|
28
|
+
size?: SelectSize;
|
|
29
|
+
}
|
|
30
|
+
export type SelectSize = "small" | "default";
|
|
31
|
+
/**
|
|
32
|
+
* The CreatableSelect component.
|
|
33
|
+
*
|
|
34
|
+
* @param {CreateableSelectProps} props - The props for the CreatableSelect component
|
|
35
|
+
* @returns {JSX.Element} CreatableSelect component
|
|
36
|
+
*/
|
|
37
|
+
export declare const CreatableSelect: <Option, IsAsync extends boolean = false, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(props: CreateableSelectProps<Option, IsAsync, IsMulti, Group>) => JSX.Element;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface SelectContainerProps {
|
|
3
|
+
children: React.ReactElement;
|
|
4
|
+
label?: string;
|
|
5
|
+
hideLabel?: boolean;
|
|
6
|
+
hasError?: boolean;
|
|
7
|
+
id?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
error?: React.ReactNode;
|
|
10
|
+
info?: React.ReactNode;
|
|
11
|
+
dataTestId?: string;
|
|
12
|
+
isDisabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The SelectContainer component.
|
|
16
|
+
*
|
|
17
|
+
* @param {SelectContainerProps} props - The props for the SelectContainer component
|
|
18
|
+
* @returns {JSX.Element} SelectContainer component
|
|
19
|
+
*/
|
|
20
|
+
export declare const SelectContainer: ({ children, label, hideLabel, id, hasError, error, description, info, dataTestId, isDisabled, }: SelectContainerProps) => JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { GroupBase } from "react-select";
|
|
3
|
+
import { SelectProps } from "./useSelect";
|
|
4
|
+
export interface SelectOption<T extends string> {
|
|
5
|
+
label: string;
|
|
6
|
+
value: T;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Selects are input components used to choose a value from a set.
|
|
11
|
+
*
|
|
12
|
+
* @param {SelectProps} props - The props for the Select component
|
|
13
|
+
* @returns {JSX.Element} Select component
|
|
14
|
+
*/
|
|
15
|
+
export declare const Select: {
|
|
16
|
+
<Option, IsAsync extends boolean = false, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(props: SelectProps<Option, IsAsync, IsMulti, Group>): JSX.Element;
|
|
17
|
+
displayName: string;
|
|
18
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { CommonProps } from "@trackunit/react-components";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
interface SelectMenuItemProps extends CommonProps {
|
|
4
|
+
/**
|
|
5
|
+
* An string to render as a item label.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
label: string;
|
|
9
|
+
/**
|
|
10
|
+
* An handler for click on element
|
|
11
|
+
*/
|
|
12
|
+
onClick?: React.MouseEventHandler<HTMLDivElement>;
|
|
13
|
+
/**
|
|
14
|
+
* A boolean prop to set menu item to selected state
|
|
15
|
+
*/
|
|
16
|
+
selected?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* A boolean prop to set menu item to focused state
|
|
19
|
+
* used for keyboard navigation
|
|
20
|
+
*/
|
|
21
|
+
focused?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* A boolean prop to set menu item to disabled state
|
|
24
|
+
* used in disabled select options
|
|
25
|
+
*/
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface SingleSelectMenuItemProps extends SelectMenuItemProps {
|
|
29
|
+
/**
|
|
30
|
+
* An React element to render before the text in the select.
|
|
31
|
+
* This is typically used to render an icon.
|
|
32
|
+
*/
|
|
33
|
+
icon?: JSX.Element;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A single select menu item is a basic wrapper around Menu item designed to be used as a single value render in Select list
|
|
37
|
+
*
|
|
38
|
+
* @param {SelectMenuItemProps} props - The props for the SingleSelectMenuItem
|
|
39
|
+
* @returns {JSX.Element} SingleSelectMenuItem
|
|
40
|
+
*/
|
|
41
|
+
export declare const SingleSelectMenuItem: ({ label, icon, onClick, selected, dataTestId, focused, disabled, }: SingleSelectMenuItemProps) => JSX.Element;
|
|
42
|
+
/**
|
|
43
|
+
* A multi select menu item is a basic wrapper around Menu item designed to be used as a multi value render in Select list
|
|
44
|
+
*
|
|
45
|
+
* @param {SelectMenuItemProps} props - The props for the MultiSelectMenuItem
|
|
46
|
+
* @returns {JSX.Element} multi select menu item
|
|
47
|
+
*/
|
|
48
|
+
export declare const MultiSelectMenuItem: ({ label, onClick, selected, dataTestId, focused, disabled, }: SelectMenuItemProps) => JSX.Element;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TagProps } from "@trackunit/react-components";
|
|
3
|
+
type TagsPropsNoRef = Omit<TagProps, "ref">;
|
|
4
|
+
interface TagWithWidthProps extends TagsPropsNoRef {
|
|
5
|
+
onWidthKnown?: ({ width }: {
|
|
6
|
+
width: number;
|
|
7
|
+
}) => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Extended Tag component with information about its own width.
|
|
11
|
+
* Used in the select component.
|
|
12
|
+
*
|
|
13
|
+
* @param {TagProps} props - The props for the tag component
|
|
14
|
+
* @returns {JSX.Element} TagWithWidth component
|
|
15
|
+
*/
|
|
16
|
+
export declare const TagWithWidth: ({ onWidthKnown, children, ...rest }: TagWithWidthProps) => JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface TagsContainerItem {
|
|
3
|
+
/**
|
|
4
|
+
* A text value to be passed to tags inside container
|
|
5
|
+
*/
|
|
6
|
+
text: string;
|
|
7
|
+
/**
|
|
8
|
+
* OnClick handler for a tags
|
|
9
|
+
*/
|
|
10
|
+
onClick: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* A flag to set tags to readonly mode (without close button)
|
|
13
|
+
*/
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface TagsContainerProps {
|
|
17
|
+
/**
|
|
18
|
+
* An items to be rendered inside container if they fit available space. If they overlap then the counter will be displayed.
|
|
19
|
+
*/
|
|
20
|
+
items: TagsContainerItem[];
|
|
21
|
+
/**
|
|
22
|
+
* An css property to set a custom width for container
|
|
23
|
+
* Default behavior is to take 100% width of parent element
|
|
24
|
+
* You can provide a value with unit (pixels, percents, rem, etc)
|
|
25
|
+
*
|
|
26
|
+
* @memberof TagsContainerProps
|
|
27
|
+
*/
|
|
28
|
+
width?: string;
|
|
29
|
+
/**
|
|
30
|
+
* In case you have a gap between items then you can provide it to be used in calculation of available space,
|
|
31
|
+
* default value is 5, so if you don't need it then provide 0
|
|
32
|
+
*
|
|
33
|
+
* @memberof TagsContainerProps
|
|
34
|
+
*/
|
|
35
|
+
itemsGap?: number;
|
|
36
|
+
postFix: JSX.Element;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* TagsContainer component to display tags in limited space when children can't fit space it displays counter
|
|
40
|
+
*
|
|
41
|
+
* @param {TagsContainerProps} props - The props for the TagContainer
|
|
42
|
+
* @returns {JSX.Element} TagsContainer
|
|
43
|
+
*/
|
|
44
|
+
export declare const TagsContainer: ({ items, width, itemsGap, postFix }: TagsContainerProps) => JSX.Element;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GroupBase, MultiValue, OptionsOrGroups, PropsValue, SingleValue } from "react-select";
|
|
2
|
+
/**
|
|
3
|
+
* @param {MultiValue<Option> | SingleValue<Option>} arg option to check type
|
|
4
|
+
* @returns {arg is MultiValue<Option> } is Multivalue
|
|
5
|
+
*/
|
|
6
|
+
export declare function isMultiValue<Option>(arg: MultiValue<Option> | SingleValue<Option>): arg is MultiValue<Option>;
|
|
7
|
+
/**
|
|
8
|
+
* @template IsMulti
|
|
9
|
+
* @template Group
|
|
10
|
+
* @param {OptionsOrGroups<Option, Group> | undefined} options An array of options to select from
|
|
11
|
+
* @param {PropsValue<Option> | undefined} value Selected values
|
|
12
|
+
* @returns {OptionsOrGroups<Option, Group>} An array of ordered options with selected on top
|
|
13
|
+
*/
|
|
14
|
+
export declare const getOrderedOptions: <Option, Group extends GroupBase<Option>>(options: OptionsOrGroups<Option, Group> | undefined, value: PropsValue<Option> | undefined) => OptionsOrGroups<Option, Group>;
|
|
15
|
+
export declare const SelectPrefix: import("dist/libs/ui/tailwind-styled-components/src/lib/types").TailwindComponent<import("dist/libs/ui/tailwind-styled-components/src/lib/types").TailwindHtmlComponent<"div">, {}>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { GroupBase } from "react-select";
|
|
3
|
+
import { SelectComponents } from "react-select/dist/declarations/src/components";
|
|
4
|
+
/**
|
|
5
|
+
* A hook to retrieve components override object.
|
|
6
|
+
* This complex object includes all the compositional components that are used in react-select. If you wish to overwrite a component, pass in an object with the appropriate namespace.
|
|
7
|
+
*
|
|
8
|
+
* @template IsMulti
|
|
9
|
+
* @template Group
|
|
10
|
+
* @param {Partial<SelectComponents<Option, IsMulti, Group>> | undefined} componentsProps a custom component prop that you can to override defaults
|
|
11
|
+
* @param {boolean} disabled decide to override disabled variant
|
|
12
|
+
* @param {boolean} menuIsOpen menu is open state
|
|
13
|
+
* @param {React.MutableRefObject<boolean>} refMenuIsEnabled a flag to block menu from open
|
|
14
|
+
* @param {string} dataTestId a test id
|
|
15
|
+
* @param {number} maxSelectedDisplayCount a number of max display count
|
|
16
|
+
* @param {JSX.Element} dropdownIcon an custom dropdown icon
|
|
17
|
+
* @returns {Partial<SelectComponents<Option, boolean, GroupBase<Option>>> | undefined} components object to override react-select default components
|
|
18
|
+
*/
|
|
19
|
+
export declare const useCustomComponents: <Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(componentsProps: Partial<SelectComponents<Option, IsMulti, Group>> | undefined, disabled: boolean, menuIsOpen: boolean, refMenuIsEnabled: React.MutableRefObject<boolean>, dataTestId: string, maxSelectedDisplayCount: number | undefined, dropdownIcon?: JSX.Element) => Partial<SelectComponents<Option, IsMulti, Group>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { GroupBase, StylesConfig } from "react-select";
|
|
3
|
+
/**
|
|
4
|
+
* @template IsMulti
|
|
5
|
+
* @template Group
|
|
6
|
+
* @param {React.RefObject<HTMLDivElement>} refContainer react ref to container element
|
|
7
|
+
* @param {React.RefObject<HTMLDivElement>} refPrefix react ref to prefix element
|
|
8
|
+
* @param {number | undefined} maxSelectedDisplayCount a number of max display count
|
|
9
|
+
* @param {StylesConfig<Option, IsMulti, Group> | undefined} styles a optional object to override styles of react-select
|
|
10
|
+
* @returns {StylesConfig<Option, boolean>} styles to override in select
|
|
11
|
+
*/
|
|
12
|
+
export declare const useCustomStyles: <Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(refContainer: React.RefObject<HTMLDivElement>, refPrefix: React.RefObject<HTMLDivElement>, maxSelectedDisplayCount: number | undefined, styles: StylesConfig<Option, IsMulti, Group> | undefined) => {
|
|
13
|
+
customStyles: StylesConfig<Option, IsMulti, Group>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { CommonProps } from "@trackunit/react-components";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { GroupBase, MenuPlacement, OptionsOrGroups, Props, StylesConfig } from "react-select";
|
|
4
|
+
import { SelectComponents } from "react-select/dist/declarations/src/components";
|
|
5
|
+
export interface AsyncSelect<Option, Group extends GroupBase<Option> = GroupBase<Option>> {
|
|
6
|
+
loadOptions: (input: string) => void | Promise<OptionsOrGroups<Option, Group>>;
|
|
7
|
+
defaultOptions: OptionsOrGroups<Option, Group> | undefined;
|
|
8
|
+
cacheOptions: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface SelectProps<Option, IsAsync extends boolean, IsMulti extends boolean, GroupType extends GroupBase<Option>> extends CommonProps, Props<Option, IsMulti, GroupType> {
|
|
11
|
+
/**
|
|
12
|
+
* An React element to render before the text in the select.
|
|
13
|
+
* This is typically used to render an icon.
|
|
14
|
+
*
|
|
15
|
+
*
|
|
16
|
+
* @memberof SelectProps
|
|
17
|
+
*/
|
|
18
|
+
prefix?: JSX.Element;
|
|
19
|
+
/**
|
|
20
|
+
* An string to render in field when there is no value selected.
|
|
21
|
+
* Can be used as a description, example or a hint.
|
|
22
|
+
*
|
|
23
|
+
*
|
|
24
|
+
* @memberof SelectProps
|
|
25
|
+
*/
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
/**
|
|
28
|
+
* An boolean flag to disable field
|
|
29
|
+
*
|
|
30
|
+
*
|
|
31
|
+
* @memberof SelectProps
|
|
32
|
+
*/
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* An field id
|
|
36
|
+
*
|
|
37
|
+
*
|
|
38
|
+
* @memberof SelectProps
|
|
39
|
+
*/
|
|
40
|
+
id?: string;
|
|
41
|
+
/**
|
|
42
|
+
* An boolean flag to set select into async mode
|
|
43
|
+
* This is typically used when data is fetched after render
|
|
44
|
+
*
|
|
45
|
+
*
|
|
46
|
+
* @memberof SelectProps
|
|
47
|
+
*/
|
|
48
|
+
async?: AsyncSelect<Option, GroupType>;
|
|
49
|
+
/**
|
|
50
|
+
* A custom icon to be used as a dropdown indicator
|
|
51
|
+
* This is typically used during style customization
|
|
52
|
+
*
|
|
53
|
+
*
|
|
54
|
+
* @memberof SelectProps
|
|
55
|
+
*/
|
|
56
|
+
dropdownIcon?: JSX.Element;
|
|
57
|
+
/**
|
|
58
|
+
* A label to be used as a aria-label
|
|
59
|
+
* This is typically used for accessibility
|
|
60
|
+
*
|
|
61
|
+
*
|
|
62
|
+
* @memberof SelectProps
|
|
63
|
+
*/
|
|
64
|
+
label?: string;
|
|
65
|
+
/**
|
|
66
|
+
* A number of pixels to limit maximal length of the select menu list
|
|
67
|
+
*
|
|
68
|
+
*
|
|
69
|
+
* @memberof SelectProps
|
|
70
|
+
*/
|
|
71
|
+
maxMenuHeight?: number;
|
|
72
|
+
/**
|
|
73
|
+
* A boolean prop to set select into invalid mode
|
|
74
|
+
* typically used when selected value is not compliant with field requirement
|
|
75
|
+
* ex if it breaks validation rules
|
|
76
|
+
*
|
|
77
|
+
*
|
|
78
|
+
* @memberof SelectProps
|
|
79
|
+
*/
|
|
80
|
+
hasError?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* A boolean flag to display loading indicator
|
|
83
|
+
*
|
|
84
|
+
*
|
|
85
|
+
* @memberof SelectProps
|
|
86
|
+
*/
|
|
87
|
+
isLoading?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* A number value to limit amount of visible tags for selected options
|
|
90
|
+
*
|
|
91
|
+
*
|
|
92
|
+
* @memberof SelectProps
|
|
93
|
+
*/
|
|
94
|
+
maxSelectedDisplayCount?: number;
|
|
95
|
+
/**
|
|
96
|
+
* A custom handler for menu open event
|
|
97
|
+
* use if you want to trigger custom logic or fetch data
|
|
98
|
+
*
|
|
99
|
+
*
|
|
100
|
+
* @memberof SelectProps
|
|
101
|
+
*/
|
|
102
|
+
onMenuOpen?: () => void;
|
|
103
|
+
/**
|
|
104
|
+
* A flag to allow user to clear value once selected
|
|
105
|
+
* default value is true
|
|
106
|
+
*
|
|
107
|
+
*
|
|
108
|
+
* @memberof SelectProps
|
|
109
|
+
*/
|
|
110
|
+
isClearable?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* A flag to allow user to filter option list by key from the text input
|
|
113
|
+
*
|
|
114
|
+
*
|
|
115
|
+
* @memberof SelectProps
|
|
116
|
+
*/
|
|
117
|
+
isSearchable?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* A flag to set select into async mode
|
|
120
|
+
*
|
|
121
|
+
* @memberof SelectProps
|
|
122
|
+
*/
|
|
123
|
+
isAsync?: IsAsync;
|
|
124
|
+
}
|
|
125
|
+
interface IUseSelect<Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>> {
|
|
126
|
+
customStyles: StylesConfig<Option, IsMulti, Group>;
|
|
127
|
+
customComponents: Partial<SelectComponents<Option, IsMulti, Group>>;
|
|
128
|
+
refContainer: React.RefObject<HTMLDivElement>;
|
|
129
|
+
refPrefix: React.RefObject<HTMLDivElement>;
|
|
130
|
+
menuIsOpen: boolean;
|
|
131
|
+
menuPlacement: MenuPlacement;
|
|
132
|
+
openMenuHandler: () => Promise<void>;
|
|
133
|
+
closeMenuHandler: () => void;
|
|
134
|
+
orderedOptions: OptionsOrGroups<Option, Group>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* A hook used by selects to share the common code
|
|
138
|
+
*
|
|
139
|
+
* @param {SelectProps} props - The props for the Select component
|
|
140
|
+
* @returns {IUseSelect} Select component
|
|
141
|
+
*/
|
|
142
|
+
export declare const useSelect: <Option, IsAsync extends boolean = false, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>({ id, className, dataTestId, prefix, async, dropdownIcon, maxMenuHeight, label, hasError, disabled, isMulti, components, value, options, onChange, isLoading, classNamePrefix, onMenuOpen, onMenuClose, maxSelectedDisplayCount, isClearable, isSearchable, onMenuScrollToBottom, styles, filterOption, onInputChange, ...props }: SelectProps<Option, IsAsync, IsMulti, Group>) => IUseSelect<Option, IsMulti, Group>;
|
|
143
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CommonProps } from "@trackunit/react-components";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export type TextAreaResize = "none" | "vertical" | "horizontal" | "both";
|
|
4
|
+
type FilteredInputProps = Omit<React.InputHTMLAttributes<HTMLTextAreaElement>, "prefix" | "suffix">;
|
|
5
|
+
export interface TextAreaProps extends FilteredInputProps, CommonProps {
|
|
6
|
+
/**
|
|
7
|
+
* Number of rows in the text area.
|
|
8
|
+
*/
|
|
9
|
+
rows?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Resize of the text area.
|
|
12
|
+
*
|
|
13
|
+
* @default "vertical"
|
|
14
|
+
*/
|
|
15
|
+
resize?: TextAreaResize;
|
|
16
|
+
/**
|
|
17
|
+
* Default value of the textarea.
|
|
18
|
+
*/
|
|
19
|
+
defaultValue?: React.ReactText;
|
|
20
|
+
/**
|
|
21
|
+
* If true the field is rendered in its invalid state.
|
|
22
|
+
*/
|
|
23
|
+
isInvalid?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The TextArea is a base component, and should not be used very often.
|
|
27
|
+
* For most cases the TextAreaField is the correct component.
|
|
28
|
+
*/
|
|
29
|
+
export declare const TextArea: React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./TextArea";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CommonProps } from "@trackunit/react-components";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { FormGroupProps } from "../FormGroup/FormGroup";
|
|
4
|
+
import { TextAreaProps } from "../TextArea/TextArea";
|
|
5
|
+
type FormGroupExposedProps = Pick<FormGroupProps, "label" | "tip" | "helpText" | "helpAddon">;
|
|
6
|
+
export interface TextAreaFieldProps extends TextAreaProps, FormGroupExposedProps, CommonProps {
|
|
7
|
+
/**
|
|
8
|
+
* Set the Maximal length of the value for the input.
|
|
9
|
+
* Adds a TextLengthIndicator to the right of the helpText.
|
|
10
|
+
*/
|
|
11
|
+
maxLength?: number;
|
|
12
|
+
/**
|
|
13
|
+
* If a value is set, the field is rendered in its invalid state.
|
|
14
|
+
*/
|
|
15
|
+
errorMessage?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const TextAreaField: React.ForwardRefExoticComponent<TextAreaFieldProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./TextAreaField";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { FormGroupProps } from "../FormGroup/FormGroup";
|
|
3
|
+
import { TextInputProps } from "../TextInput/TextInput";
|
|
4
|
+
type FormGroupExposedProps = Pick<FormGroupProps, "label" | "tip" | "helpText" | "helpAddon">;
|
|
5
|
+
export interface TextFieldProps extends TextInputProps, FormGroupExposedProps {
|
|
6
|
+
/**
|
|
7
|
+
* Set the Maximal length of the value for the input.
|
|
8
|
+
* Adds a TextLengthIndicator to the right of the helpText.
|
|
9
|
+
*/
|
|
10
|
+
maxLength?: number;
|
|
11
|
+
/**
|
|
12
|
+
* If a value is set, the field is rendered in its invalid state.
|
|
13
|
+
*/
|
|
14
|
+
errorMessage?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Text fields enable the user to interact with and input content and data. This component can be used for long and short form entries. Allow the size of the text input box to reflect the length of the content you expect the user to enter.
|
|
18
|
+
*
|
|
19
|
+
* _**Do use** when the user has to input or edit simple text based information, such as metadata._
|
|
20
|
+
*
|
|
21
|
+
* _**Do not use** to confirm user actions, such as deleting. Use a checkbox for such flows._
|
|
22
|
+
*/
|
|
23
|
+
export declare const TextField: React.ForwardRefExoticComponent<TextFieldProps & React.RefAttributes<HTMLInputElement>>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface TextLengthIndicatorProps {
|
|
3
|
+
/**
|
|
4
|
+
* The current length of the content of the input
|
|
5
|
+
*/
|
|
6
|
+
length: number;
|
|
7
|
+
/**
|
|
8
|
+
* The max number of characters allowed in the input
|
|
9
|
+
*/
|
|
10
|
+
maxLength: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The TextLengthIndicator component shows a `{length}/{maxLength}` label.
|
|
14
|
+
* Used for TextFields to communicate a maximum allowed input length.
|
|
15
|
+
*
|
|
16
|
+
* @param {TextLengthIndicatorProps} props - The props for the TextLengthIndicator component
|
|
17
|
+
* @returns {JSX.Element} TextLengthIndicator component
|
|
18
|
+
*/
|
|
19
|
+
export declare const TextLengthIndicator: React.FC<TextLengthIndicatorProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./TextField";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BaseInputProps } from "../BaseInput/BaseInput";
|
|
3
|
+
type BaseInputExposedProps = Omit<BaseInputProps, "type">;
|
|
4
|
+
export interface TextInputProps extends BaseInputExposedProps {
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A thin wrapper around the `BaseInput` component for text input fields.
|
|
8
|
+
*
|
|
9
|
+
* NOTE: If shown with a label, please use the `TextField` component instead.
|
|
10
|
+
*/
|
|
11
|
+
export declare const TextInput: import("react").ForwardRefExoticComponent<TextInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CommonProps } from "@trackunit/react-components";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import "./Toggle.css";
|
|
4
|
+
export type ToggleSize = "small" | "medium";
|
|
5
|
+
export interface ToggleProps extends CommonProps {
|
|
6
|
+
/**
|
|
7
|
+
* ID of the toggle.
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* Whether the toggle is toggled(active) or not.
|
|
12
|
+
*/
|
|
13
|
+
toggled: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* onChange event handler.
|
|
16
|
+
*/
|
|
17
|
+
onChange: (toggled: boolean, event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the toggle is disabled or not.
|
|
20
|
+
*/
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Size of the toggle.
|
|
24
|
+
*/
|
|
25
|
+
size?: ToggleSize;
|
|
26
|
+
/**
|
|
27
|
+
* Tab index specifies the keyboard tab order of the toggle relative to the other controls on the page.
|
|
28
|
+
*/
|
|
29
|
+
tabIndex?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the toggle is required or not.
|
|
32
|
+
*/
|
|
33
|
+
required?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Name of the toggle.
|
|
36
|
+
*/
|
|
37
|
+
name?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The description of the toggle.
|
|
40
|
+
*/
|
|
41
|
+
description?: string;
|
|
42
|
+
/**
|
|
43
|
+
* onBlur event handler.
|
|
44
|
+
*/
|
|
45
|
+
onBlur?: React.FocusEventHandler<HTMLInputElement>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Use Toggle when you have to only enable/disable a feature.
|
|
49
|
+
*
|
|
50
|
+
* _**Do use** Toggle in forms or settings._
|
|
51
|
+
*
|
|
52
|
+
* _**Do not use** Toggle if a user can select many option from a list, use checkboxes instead of toggle._
|
|
53
|
+
*
|
|
54
|
+
* @param {ToggleProps} props - The props for the Toggle component
|
|
55
|
+
* @returns {JSX.Element} Toggle component
|
|
56
|
+
*/
|
|
57
|
+
export declare const Toggle: React.ForwardRefExoticComponent<ToggleProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Toggle";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormGroupProps } from "../FormGroup/FormGroup";
|
|
3
|
+
import { UploadInputProps } from "../UploadInput/UploadInput";
|
|
4
|
+
type FormGroupExposedProps = Pick<FormGroupProps, "label" | "tip" | "helpText" | "helpAddon">;
|
|
5
|
+
export interface UploadFieldProps extends UploadInputProps, FormGroupExposedProps {
|
|
6
|
+
/**
|
|
7
|
+
* If a value is set, the field is rendered in its invalid state.
|
|
8
|
+
*/
|
|
9
|
+
errorMessage?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Upload fields enable the user to upload Files.
|
|
13
|
+
*/
|
|
14
|
+
export declare const UploadField: import("react").ForwardRefExoticComponent<UploadFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
15
|
+
export {};
|