@trackunit/react-form-components 1.0.29 → 1.0.31
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 +222 -135
- package/index.esm.js +224 -136
- package/package.json +2 -2
- package/src/components/ActionButton/ActionButton.d.ts +1 -7
- package/src/components/ActionButton/ActionButton.variants.d.ts +4 -2
- package/src/components/BaseInput/BaseInput.d.ts +26 -30
- package/src/components/BaseInput/BaseInput.variants.d.ts +9 -7
- package/src/components/BaseInput/InputLockReasonTooltip.d.ts +15 -0
- package/src/components/BaseInput/components/AddonAfterRenderer.d.ts +7 -0
- package/src/components/BaseInput/components/AddonBeforeRenderer.d.ts +7 -0
- package/src/components/BaseInput/components/GenericActionsRenderer.d.ts +8 -0
- package/src/components/BaseInput/components/LockReasonRenderer.d.ts +5 -0
- package/src/components/BaseInput/components/PrefixRenderer.d.ts +8 -0
- package/src/components/BaseInput/components/SuffixRenderer.d.ts +10 -0
- package/src/components/BaseInput/components/index.d.ts +6 -0
- package/src/components/EmailInput/EmailInput.d.ts +1 -2
- package/src/components/FormGroup/FormGroup.d.ts +6 -1
- package/src/components/FormGroup/FormGroup.variants.d.ts +1 -0
- package/src/components/PhoneInput/PhoneInput.d.ts +3 -3
- package/src/components/Search/Search.d.ts +4 -0
- package/src/components/Select/Select.variants.d.ts +1 -0
- package/src/components/Select/SelectMenuItem/SelectMenuItem.d.ts +7 -2
- package/src/components/Select/useCustomComponents.d.ts +3 -1
- package/src/components/Select/useCustomStyles.d.ts +3 -1
- package/src/components/Select/useSelect.d.ts +10 -3
- package/src/components/TextField/TextField.d.ts +0 -4
- package/src/components/UploadInput/UploadInput.variants.d.ts +0 -1
- package/src/translation.d.ts +2 -2
- package/src/types.d.ts +1 -0
- package/src/components/BaseInput/DisabledForReasonsTip.d.ts +0 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-form-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.31",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"react-hook-form": "7.53.1",
|
|
19
19
|
"tailwind-merge": "^2.0.0",
|
|
20
20
|
"@trackunit/css-class-variance-utilities": "1.0.8",
|
|
21
|
-
"@trackunit/react-components": "1.1.
|
|
21
|
+
"@trackunit/react-components": "1.1.13",
|
|
22
22
|
"@trackunit/ui-icons": "1.0.11",
|
|
23
23
|
"@trackunit/shared-utils": "1.2.5",
|
|
24
24
|
"@trackunit/i18n-library-translation": "1.0.17"
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { VariantProps } from "@trackunit/css-class-variance-utilities";
|
|
2
1
|
import { ButtonCommonProps, CommonProps } from "@trackunit/react-components";
|
|
3
|
-
import { cvaActionButton } from "./ActionButton.variants";
|
|
4
2
|
type ActionType = "PHONE_NUMBER" | "WEB_ADDRESS" | "EMAIL" | "COPY";
|
|
5
3
|
interface AbstractActionButtonProps extends ButtonCommonProps, CommonProps {
|
|
6
4
|
/**
|
|
@@ -11,10 +9,6 @@ interface AbstractActionButtonProps extends ButtonCommonProps, CommonProps {
|
|
|
11
9
|
* The value to be passed into the button.
|
|
12
10
|
*/
|
|
13
11
|
value?: string | React.RefObject<HTMLInputElement> | null;
|
|
14
|
-
/**
|
|
15
|
-
* The size of the icon.
|
|
16
|
-
*/
|
|
17
|
-
iconSize?: VariantProps<typeof cvaActionButton>["size"];
|
|
18
12
|
}
|
|
19
13
|
interface GenericActionButtonProps extends AbstractActionButtonProps {
|
|
20
14
|
/**
|
|
@@ -43,5 +37,5 @@ type ActionButtonProps = CopyActionButtonProps | GenericActionButtonProps;
|
|
|
43
37
|
* @param {ActionButtonProps} props - The props for the ActionButton component
|
|
44
38
|
* @returns {JSX.Element} ActionButton component
|
|
45
39
|
*/
|
|
46
|
-
export declare const ActionButton: ({ type, value, dataTestId,
|
|
40
|
+
export declare const ActionButton: ({ type, value, dataTestId, size, disabled, className }: ActionButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
47
41
|
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare const cvaActionButton: (props?: ({
|
|
2
|
-
size?: "small" | "medium" | null | undefined;
|
|
2
|
+
size?: "small" | "medium" | "large" | null | undefined;
|
|
3
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
4
|
+
export declare const cvaActionContainer: (props?: ({
|
|
5
|
+
size?: "small" | "medium" | "large" | null | undefined;
|
|
3
6
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
4
|
-
export declare const cvaActionContainer: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
@@ -1,45 +1,35 @@
|
|
|
1
|
-
import { VariantProps } from "@trackunit/css-class-variance-utilities";
|
|
2
1
|
import { CommonProps } from "@trackunit/react-components";
|
|
3
2
|
import { MappedOmit } from "@trackunit/shared-utils";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
3
|
+
import { InputHTMLAttributes, ReactNode } from "react";
|
|
4
|
+
import { FormComponentSizes } from "../../types";
|
|
5
|
+
import { LockedForReasons } from "./InputLockReasonTooltip";
|
|
6
|
+
import { BaseInputActionTypes } from "./components";
|
|
7
|
+
type FilteredInputProps = MappedOmit<InputHTMLAttributes<HTMLInputElement>, "prefix" | "disabled" | "readOnly">;
|
|
8
8
|
export interface BaseInputProps extends FilteredInputProps, CommonProps {
|
|
9
9
|
/**
|
|
10
10
|
* A React element to render before the text in the input.
|
|
11
|
-
* This is typically used to render an icon.
|
|
12
|
-
* For elements other than icons, please consider using the addonBefore prop.
|
|
13
11
|
*/
|
|
14
|
-
prefix?:
|
|
12
|
+
prefix?: ReactNode;
|
|
15
13
|
/**
|
|
16
14
|
* A React element to render after the text in the input.
|
|
17
|
-
* This is typically used to render an icon.
|
|
18
|
-
* For other elements than icons, please consider using the addonAfter prop.
|
|
19
15
|
*/
|
|
20
|
-
suffix?:
|
|
16
|
+
suffix?: ReactNode;
|
|
21
17
|
/**
|
|
22
18
|
* A React element to render in a separate container before the text in the input.
|
|
23
|
-
* This is typically used to render text.
|
|
24
|
-
* For icons, please consider using the prefix prop.
|
|
25
19
|
*/
|
|
26
|
-
addonBefore?:
|
|
20
|
+
addonBefore?: ReactNode;
|
|
27
21
|
/**
|
|
28
22
|
* A React element to render in a separate container after the text in the input.
|
|
29
|
-
* This is typically used to render text.
|
|
30
|
-
* For icons, please consider using the suffix prop.
|
|
31
23
|
*/
|
|
32
|
-
addonAfter?:
|
|
24
|
+
addonAfter?: ReactNode;
|
|
33
25
|
/**
|
|
34
26
|
* A ReactNode to render at the end of the input field before the addonAfter.
|
|
35
|
-
* Mainly meant for the icon button actions for special input types.
|
|
36
27
|
*/
|
|
37
|
-
actions?:
|
|
28
|
+
actions?: ReactNode;
|
|
38
29
|
/**
|
|
39
|
-
*
|
|
40
|
-
* Default == 40px, Small == 32px.
|
|
30
|
+
* The size of the input field.
|
|
41
31
|
*/
|
|
42
|
-
fieldSize?:
|
|
32
|
+
fieldSize?: FormComponentSizes;
|
|
43
33
|
/**
|
|
44
34
|
* If true the field is rendered in its invalid state.
|
|
45
35
|
*/
|
|
@@ -49,7 +39,7 @@ export interface BaseInputProps extends FilteredInputProps, CommonProps {
|
|
|
49
39
|
*/
|
|
50
40
|
placeholder?: string;
|
|
51
41
|
/**
|
|
52
|
-
*
|
|
42
|
+
* Flag to disable direct interaction with the input.
|
|
53
43
|
*/
|
|
54
44
|
nonInteractive?: boolean;
|
|
55
45
|
/**
|
|
@@ -61,15 +51,21 @@ export interface BaseInputProps extends FilteredInputProps, CommonProps {
|
|
|
61
51
|
*/
|
|
62
52
|
addonBeforeClassName?: string;
|
|
63
53
|
/**
|
|
64
|
-
*
|
|
54
|
+
* If true, shows the input in warning state.
|
|
65
55
|
*/
|
|
66
|
-
|
|
56
|
+
isWarning?: boolean;
|
|
67
57
|
/**
|
|
68
|
-
*
|
|
58
|
+
* Render a generic action, like "copy".
|
|
69
59
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
60
|
+
genericAction?: BaseInputActionTypes;
|
|
61
|
+
/**
|
|
62
|
+
* Flag or object to disable the input. If an object, shows a tooltip with the reason.
|
|
63
|
+
*/
|
|
64
|
+
disabled?: boolean | LockedForReasons;
|
|
65
|
+
/**
|
|
66
|
+
* Flag or object to set the input as readOnly. If an object, shows a tooltip with the reason.
|
|
67
|
+
*/
|
|
68
|
+
readOnly?: boolean | LockedForReasons;
|
|
73
69
|
}
|
|
74
70
|
/**
|
|
75
71
|
* A base input component that can be used for text inputs, password inputs, etc.
|
|
@@ -79,5 +75,5 @@ export interface BaseInputProps extends FilteredInputProps, CommonProps {
|
|
|
79
75
|
* For specific input types make sure to use the corresponding input component.
|
|
80
76
|
* This is a base used by our other input components such as TextInput, NumberInput, PasswordInput, etc.
|
|
81
77
|
*/
|
|
82
|
-
export declare const BaseInput:
|
|
78
|
+
export declare const BaseInput: import("react").ForwardRefExoticComponent<BaseInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
83
79
|
export {};
|
|
@@ -2,19 +2,23 @@ export declare const cvaInputBase: (props?: import("class-variance-authority/dis
|
|
|
2
2
|
export declare const cvaInputBaseDisabled: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
3
3
|
export declare const cvaInputBaseInvalid: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
4
4
|
export declare const cvaInput: (props?: ({
|
|
5
|
-
size?: "small" | "medium" | null | undefined;
|
|
5
|
+
size?: "small" | "medium" | "large" | null | undefined;
|
|
6
6
|
disabled?: boolean | null | undefined;
|
|
7
7
|
invalid?: boolean | null | undefined;
|
|
8
|
+
isWarning?: boolean | null | undefined;
|
|
8
9
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
9
10
|
export declare const cvaInputField: (props?: ({
|
|
10
|
-
size?: "small" | "medium" | null | undefined;
|
|
11
|
+
size?: "small" | "medium" | "large" | null | undefined;
|
|
11
12
|
disabled?: boolean | null | undefined;
|
|
13
|
+
readOnly?: boolean | null | undefined;
|
|
12
14
|
autoFocus?: boolean | null | undefined;
|
|
13
15
|
addonBefore?: boolean | null | undefined;
|
|
14
16
|
prefix?: boolean | null | undefined;
|
|
15
17
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
16
18
|
export declare const cvaInputAddon: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
17
|
-
export declare const cvaInputAddonBefore: (props?:
|
|
19
|
+
export declare const cvaInputAddonBefore: (props?: ({
|
|
20
|
+
size?: "small" | "medium" | "large" | null | undefined;
|
|
21
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
18
22
|
export declare const cvaInputPrefix: (props?: ({
|
|
19
23
|
disabled?: boolean | null | undefined;
|
|
20
24
|
addonBefore?: boolean | null | undefined;
|
|
@@ -24,8 +28,6 @@ export declare const cvaInputSuffix: (props?: ({
|
|
|
24
28
|
addonAfter?: boolean | null | undefined;
|
|
25
29
|
actions?: boolean | null | undefined;
|
|
26
30
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
27
|
-
export declare const cvaInputAddonAfter: (props?:
|
|
28
|
-
|
|
29
|
-
addonAfter?: boolean | null | undefined;
|
|
30
|
-
suffix?: boolean | null | undefined;
|
|
31
|
+
export declare const cvaInputAddonAfter: (props?: ({
|
|
32
|
+
size?: "small" | "medium" | "large" | null | undefined;
|
|
31
33
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type LockedKind = "locked" | "disabled";
|
|
2
|
+
export type LockedForReasons = {
|
|
3
|
+
kind: LockedKind;
|
|
4
|
+
reasons?: string | string[];
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Icon with explanation tooltip for why an input is locked or disabled.
|
|
8
|
+
* If locked, a permission lacks but the input **can** sometimes be edited.
|
|
9
|
+
* If disabled, the input **cannot** be edited and is only ever for displaying information.
|
|
10
|
+
*
|
|
11
|
+
* @param {LockedForReasons} props - The reasons for the disabled state.
|
|
12
|
+
* @param {LockedKind} kind - The kind of disabled state. If locked, the input can sometimes be edited. If disabled, the input cannot be edited.
|
|
13
|
+
*/
|
|
14
|
+
export declare const InputLockReasonTooltip: ({ reasons, kind }: LockedForReasons) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { FormComponentSizes } from "../../../types";
|
|
3
|
+
export declare const AddonAfterRenderer: ({ addonAfter, dataTestId, fieldSize, }: {
|
|
4
|
+
addonAfter?: ReactNode;
|
|
5
|
+
dataTestId?: string;
|
|
6
|
+
fieldSize: FormComponentSizes;
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FormComponentSizes } from "../../../types";
|
|
2
|
+
export declare const AddonBeforeRenderer: ({ addonBefore, addonBeforeClassName, dataTestId, fieldSize, }: {
|
|
3
|
+
addonBefore?: React.ReactNode;
|
|
4
|
+
addonBeforeClassName?: string;
|
|
5
|
+
dataTestId?: string;
|
|
6
|
+
fieldSize: FormComponentSizes;
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
import { FormComponentSizes } from "../../../types";
|
|
3
|
+
export type BaseInputActionTypes = "copy";
|
|
4
|
+
export declare const GenericActionsRenderer: ({ genericAction, fieldSize, innerRef, }: {
|
|
5
|
+
genericAction?: BaseInputActionTypes;
|
|
6
|
+
fieldSize?: FormComponentSizes;
|
|
7
|
+
innerRef: RefObject<HTMLInputElement>;
|
|
8
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HTMLInputTypeAttribute, ReactNode } from "react";
|
|
2
|
+
export declare const PrefixRenderer: ({ prefix, type, addonBefore, dataTestId, disabled, }: {
|
|
3
|
+
prefix?: ReactNode;
|
|
4
|
+
type?: HTMLInputTypeAttribute;
|
|
5
|
+
addonBefore?: ReactNode;
|
|
6
|
+
dataTestId?: string;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
export declare const SuffixRenderer: ({ suffix, addonAfter, actions, isInvalid, isWarning, dataTestId, disabled, }: {
|
|
3
|
+
suffix?: ReactNode;
|
|
4
|
+
addonAfter?: ReactNode;
|
|
5
|
+
actions?: ReactNode;
|
|
6
|
+
isInvalid?: boolean;
|
|
7
|
+
isWarning?: boolean;
|
|
8
|
+
dataTestId?: string;
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import { BaseInputProps } from "../BaseInput";
|
|
3
2
|
type BaseInputExposedProps = Omit<BaseInputProps, "type">;
|
|
4
3
|
export interface EmailInputProps extends BaseInputExposedProps {
|
|
@@ -22,5 +21,5 @@ export interface EmailInputProps extends BaseInputExposedProps {
|
|
|
22
21
|
* A reference to the input element is provided as the `ref` prop.
|
|
23
22
|
* For specific input types make sure to use the corresponding input component.
|
|
24
23
|
*/
|
|
25
|
-
export declare const EmailInput:
|
|
24
|
+
export declare const EmailInput: import("react").ForwardRefExoticComponent<EmailInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
26
25
|
export {};
|
|
@@ -29,6 +29,11 @@ export interface FormGroupProps extends CommonProps {
|
|
|
29
29
|
* If true the input is required with an asterisk prepended to the label.
|
|
30
30
|
*/
|
|
31
31
|
required?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* If true the input is rendered in its warning state.
|
|
34
|
+
* This is used for when the input is valid but the user should be aware of something.
|
|
35
|
+
*/
|
|
36
|
+
isWarning?: boolean;
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
34
39
|
* The FormGroup component should be used to wrap any Input element that needs a label.
|
|
@@ -37,4 +42,4 @@ export interface FormGroupProps extends CommonProps {
|
|
|
37
42
|
* @param {FormGroupProps} props - The props for the FormGroup component
|
|
38
43
|
* @returns {JSX.Element} FormGroup component
|
|
39
44
|
*/
|
|
40
|
-
export declare const FormGroup: ({ isInvalid, helpText, helpAddon, tip, className, dataTestId, label, htmlFor, children, required, }: FormGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
export declare const FormGroup: ({ isInvalid, isWarning, helpText, helpAddon, tip, className, dataTestId, label, htmlFor, children, required, }: FormGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,5 +2,6 @@ export declare const cvaFormGroup: (props?: import("class-variance-authority/dis
|
|
|
2
2
|
export declare const cvaFormGroupContainerBefore: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
3
3
|
export declare const cvaFormGroupContainerAfter: (props?: ({
|
|
4
4
|
invalid?: boolean | null | undefined;
|
|
5
|
+
isWarning?: boolean | null | undefined;
|
|
5
6
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
6
7
|
export declare const cvaHelpAddon: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
2
|
import { BaseInputProps } from "../BaseInput";
|
|
3
3
|
type BaseInputExposedProps = Omit<BaseInputProps, "actions">;
|
|
4
4
|
export interface PhoneInputProps extends BaseInputExposedProps {
|
|
@@ -15,7 +15,7 @@ export interface PhoneInputProps extends BaseInputExposedProps {
|
|
|
15
15
|
* A ReactNode to render at the end of the input field before the addonAfter.
|
|
16
16
|
* Mainly meant for the icon button actions for special input types.
|
|
17
17
|
*/
|
|
18
|
-
actions?:
|
|
18
|
+
actions?: ReactNode;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* A component for inputting phone numbers with an optional action button for initiating a phone call.
|
|
@@ -27,5 +27,5 @@ export interface PhoneInputProps extends BaseInputExposedProps {
|
|
|
27
27
|
* @param {boolean} [disableAction=false] - Whether the action button is disabled or not.
|
|
28
28
|
* @returns {JSX.Element} - The PhoneInput component.
|
|
29
29
|
*/
|
|
30
|
-
export declare const PhoneInput:
|
|
30
|
+
export declare const PhoneInput: import("react").ForwardRefExoticComponent<PhoneInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
31
31
|
export {};
|
|
@@ -65,6 +65,10 @@ export interface SearchProps extends CommonProps, TextInputProps {
|
|
|
65
65
|
*/
|
|
66
66
|
iconName?: IconName;
|
|
67
67
|
style?: React.CSSProperties;
|
|
68
|
+
/**
|
|
69
|
+
* Ref object for the "Clear" button (with the XMark icon), allowing external control of the button.
|
|
70
|
+
*/
|
|
71
|
+
xMarkRef?: React.RefObject<HTMLButtonElement>;
|
|
68
72
|
}
|
|
69
73
|
/**
|
|
70
74
|
* The Search component is used to render a search input field.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const cvaSelect: (props?: ({
|
|
2
|
+
fieldSize?: "small" | "medium" | "large" | null | undefined;
|
|
2
3
|
invalid?: boolean | null | undefined;
|
|
3
4
|
disabled?: boolean | null | undefined;
|
|
4
5
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CommonProps } from "@trackunit/react-components";
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
import { FormComponentSizes } from "../../../types";
|
|
3
4
|
interface SelectMenuItemProps extends CommonProps {
|
|
4
5
|
/**
|
|
5
6
|
* An string to render as a item label.
|
|
@@ -24,6 +25,10 @@ interface SelectMenuItemProps extends CommonProps {
|
|
|
24
25
|
* Such as a description or a hint for the option
|
|
25
26
|
*/
|
|
26
27
|
optionLabelDescription?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The size of the selected item
|
|
30
|
+
*/
|
|
31
|
+
fieldSize?: FormComponentSizes;
|
|
27
32
|
}
|
|
28
33
|
export interface SingleSelectMenuItemProps extends SelectMenuItemProps {
|
|
29
34
|
/**
|
|
@@ -38,12 +43,12 @@ export interface SingleSelectMenuItemProps extends SelectMenuItemProps {
|
|
|
38
43
|
* @param {SelectMenuItemProps} props - The props for the SingleSelectMenuItem
|
|
39
44
|
* @returns {JSX.Element} SingleSelectMenuItem
|
|
40
45
|
*/
|
|
41
|
-
export declare const SingleSelectMenuItem: ({ label, icon, onClick, selected, dataTestId, disabled, optionLabelDescription, }: SingleSelectMenuItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
export declare const SingleSelectMenuItem: ({ label, icon, onClick, selected, dataTestId, disabled, optionLabelDescription, fieldSize, }: SingleSelectMenuItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
42
47
|
/**
|
|
43
48
|
* 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
49
|
*
|
|
45
50
|
* @param {SelectMenuItemProps} props - The props for the MultiSelectMenuItem
|
|
46
51
|
* @returns {JSX.Element} multi select menu item
|
|
47
52
|
*/
|
|
48
|
-
export declare const MultiSelectMenuItem: ({ label, onClick, selected, dataTestId, disabled, optionLabelDescription, }: SelectMenuItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
53
|
+
export declare const MultiSelectMenuItem: ({ label, onClick, selected, dataTestId, disabled, optionLabelDescription, fieldSize, }: SelectMenuItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
49
54
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MutableRefObject } from "react";
|
|
2
2
|
import { GroupBase } from "react-select";
|
|
3
3
|
import { SelectComponents } from "react-select/dist/declarations/src/components";
|
|
4
|
+
import { FormComponentSizes } from "../../types";
|
|
4
5
|
/**
|
|
5
6
|
* A hook to retrieve components override object.
|
|
6
7
|
* 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.
|
|
@@ -18,7 +19,7 @@ import { SelectComponents } from "react-select/dist/declarations/src/components"
|
|
|
18
19
|
* @param {JSX.Element} prefix a prefix element
|
|
19
20
|
* @returns {Partial<SelectComponents<Option, boolean, GroupBase<Option>>> | undefined} components object to override react-select default components
|
|
20
21
|
*/
|
|
21
|
-
export declare const useCustomComponents: <Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>({ componentsProps, disabled, readOnly, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon, prefix, hasError, getOptionLabelDescription, }: {
|
|
22
|
+
export declare const useCustomComponents: <Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>({ componentsProps, disabled, readOnly, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon, prefix, hasError, fieldSize, getOptionLabelDescription, }: {
|
|
22
23
|
componentsProps: Partial<SelectComponents<Option, IsMulti, Group>> | undefined;
|
|
23
24
|
disabled: boolean;
|
|
24
25
|
readOnly: boolean;
|
|
@@ -28,5 +29,6 @@ export declare const useCustomComponents: <Option, IsMulti extends boolean = fal
|
|
|
28
29
|
dropdownIcon?: JSX.Element;
|
|
29
30
|
prefix?: JSX.Element;
|
|
30
31
|
hasError?: boolean;
|
|
32
|
+
fieldSize?: FormComponentSizes;
|
|
31
33
|
getOptionLabelDescription?: (option: Option) => string | undefined;
|
|
32
34
|
}) => Partial<SelectComponents<Option, IsMulti, Group>>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { GroupBase, StylesConfig } from "react-select";
|
|
3
|
+
import { FormComponentSizes } from "../../types";
|
|
3
4
|
/**
|
|
4
5
|
* @template IsMulti
|
|
5
6
|
* @template Group
|
|
@@ -9,12 +10,13 @@ import { GroupBase, StylesConfig } from "react-select";
|
|
|
9
10
|
* @param {StylesConfig<Option, IsMulti, Group> | undefined} styles a optional object to override styles of react-select
|
|
10
11
|
* @returns {StylesConfig<Option, boolean>} styles to override in select
|
|
11
12
|
*/
|
|
12
|
-
export declare const useCustomStyles: <Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>({ refContainer, refPrefix, maxSelectedDisplayCount, styles, disabled, }: {
|
|
13
|
+
export declare const useCustomStyles: <Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>({ refContainer, refPrefix, maxSelectedDisplayCount, styles, disabled, fieldSize, }: {
|
|
13
14
|
refContainer: React.RefObject<HTMLDivElement>;
|
|
14
15
|
refPrefix: React.RefObject<HTMLDivElement>;
|
|
15
16
|
maxSelectedDisplayCount: number | undefined;
|
|
16
17
|
styles: StylesConfig<Option, IsMulti, Group> | undefined;
|
|
17
18
|
disabled: boolean | undefined;
|
|
19
|
+
fieldSize: FormComponentSizes;
|
|
18
20
|
}) => {
|
|
19
21
|
customStyles: StylesConfig<Option, IsMulti, Group>;
|
|
20
22
|
};
|
|
@@ -3,7 +3,8 @@ import { MappedOmit } from "@trackunit/shared-utils";
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { GroupBase, MenuPlacement, OptionsOrGroups, Props, StylesConfig } from "react-select";
|
|
5
5
|
import { SelectComponents } from "react-select/dist/declarations/src/components";
|
|
6
|
-
import {
|
|
6
|
+
import { FormComponentSizes } from "../../types";
|
|
7
|
+
import { LockedForReasons } from "../BaseInput/InputLockReasonTooltip";
|
|
7
8
|
export interface AsyncSelect<Option, Group extends GroupBase<Option> = GroupBase<Option>> {
|
|
8
9
|
loadOptions: (input: string) => void | Promise<OptionsOrGroups<Option, Group>>;
|
|
9
10
|
defaultOptions?: OptionsOrGroups<Option, Group>;
|
|
@@ -29,7 +30,7 @@ export type SelectProps<Option, IsAsync extends boolean, IsMulti extends boolean
|
|
|
29
30
|
*
|
|
30
31
|
* @memberof SelectProps
|
|
31
32
|
*/
|
|
32
|
-
disabled?: boolean |
|
|
33
|
+
disabled?: boolean | LockedForReasons;
|
|
33
34
|
/**
|
|
34
35
|
* An boolean flag to make the field readonly
|
|
35
36
|
*
|
|
@@ -128,6 +129,12 @@ export type SelectProps<Option, IsAsync extends boolean, IsMulti extends boolean
|
|
|
128
129
|
* @memberof SelectProps
|
|
129
130
|
*/
|
|
130
131
|
getOptionLabelDescription?: (option: Option) => string | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* The size of the select component.
|
|
134
|
+
* Large = 40px, Medium = 32px, Small = 28px.
|
|
135
|
+
* Default is Medium.
|
|
136
|
+
*/
|
|
137
|
+
fieldSize?: FormComponentSizes;
|
|
131
138
|
};
|
|
132
139
|
interface UseSelectProps<Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>> {
|
|
133
140
|
customStyles: StylesConfig<Option, IsMulti, Group>;
|
|
@@ -145,5 +152,5 @@ interface UseSelectProps<Option, IsMulti extends boolean = false, Group extends
|
|
|
145
152
|
* @param {SelectProps} props - The props for the Select component
|
|
146
153
|
* @returns {UseSelectProps} Select component
|
|
147
154
|
*/
|
|
148
|
-
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, getOptionLabelDescription, ...props }: SelectProps<Option, IsAsync, IsMulti, Group>) => UseSelectProps<Option, IsMulti, Group>;
|
|
155
|
+
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, getOptionLabelDescription, fieldSize, ...props }: SelectProps<Option, IsAsync, IsMulti, Group>) => UseSelectProps<Option, IsMulti, Group>;
|
|
149
156
|
export {};
|
|
@@ -15,10 +15,6 @@ export interface TextFieldProps extends TextInputProps, FormGroupExposedProps {
|
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
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
18
|
*/
|
|
23
19
|
export declare const TextField: React.ForwardRefExoticComponent<TextFieldProps & React.RefAttributes<HTMLInputElement>>;
|
|
24
20
|
export {};
|
package/src/translation.d.ts
CHANGED
|
@@ -14,8 +14,8 @@ export declare const translations: TranslationResource<TranslationKeys>;
|
|
|
14
14
|
/**
|
|
15
15
|
* Local useTranslation for this specific library
|
|
16
16
|
*/
|
|
17
|
-
export declare const useTranslation: () => [TransForLibs<"clearIndicator.icon.tooltip.clearAll" | "colorField.error.INVALID_HEX_CODE" | "colorField.error.REQUIRED" | "dropzone.input.title" | "dropzone.label.default" | "emailField.error.INVALID_EMAIL" | "emailField.error.REQUIRED" | "field.notEditable.tooltip" | "field.required.asterisk.tooltip" | "numberField.error.GREATER_THAN" | "numberField.error.INVALID_NUMBER" | "numberField.error.LESS_THAN" | "numberField.error.NOT_IN_BETWEEN" | "numberField.error.REQUIRED" | "phoneField.error.INVALID_COUNTRY" | "phoneField.error.INVALID_LENGTH" | "phoneField.error.INVALID_NUMBER" | "phoneField.error.NOT_A_NUMBER" | "phoneField.error.REQUIRED" | "phoneField.error.REQUIRED_COUNTRY" | "phoneField.error.TOO_LONG" | "phoneField.error.TOO_SHORT" | "phoneField.error.undefined" | "schedule.label.active" | "schedule.label.allDay" | "schedule.label.day" | "urlField.error.INVALID_URL" | "urlField.error.REQUIRED">, import("i18next").i18n, boolean] & {
|
|
18
|
-
t: TransForLibs<"clearIndicator.icon.tooltip.clearAll" | "colorField.error.INVALID_HEX_CODE" | "colorField.error.REQUIRED" | "dropzone.input.title" | "dropzone.label.default" | "emailField.error.INVALID_EMAIL" | "emailField.error.REQUIRED" | "field.notEditable.tooltip" | "field.required.asterisk.tooltip" | "numberField.error.GREATER_THAN" | "numberField.error.INVALID_NUMBER" | "numberField.error.LESS_THAN" | "numberField.error.NOT_IN_BETWEEN" | "numberField.error.REQUIRED" | "phoneField.error.INVALID_COUNTRY" | "phoneField.error.INVALID_LENGTH" | "phoneField.error.INVALID_NUMBER" | "phoneField.error.NOT_A_NUMBER" | "phoneField.error.REQUIRED" | "phoneField.error.REQUIRED_COUNTRY" | "phoneField.error.TOO_LONG" | "phoneField.error.TOO_SHORT" | "phoneField.error.undefined" | "schedule.label.active" | "schedule.label.allDay" | "schedule.label.day" | "urlField.error.INVALID_URL" | "urlField.error.REQUIRED">;
|
|
17
|
+
export declare const useTranslation: () => [TransForLibs<"baseInput.copyAction.toolTip" | "clearIndicator.icon.tooltip.clearAll" | "colorField.error.INVALID_HEX_CODE" | "colorField.error.REQUIRED" | "dropzone.input.title" | "dropzone.label.default" | "emailField.error.INVALID_EMAIL" | "emailField.error.REQUIRED" | "field.notEditable.tooltip" | "field.required.asterisk.tooltip" | "numberField.error.GREATER_THAN" | "numberField.error.INVALID_NUMBER" | "numberField.error.LESS_THAN" | "numberField.error.NOT_IN_BETWEEN" | "numberField.error.REQUIRED" | "phoneField.error.INVALID_COUNTRY" | "phoneField.error.INVALID_LENGTH" | "phoneField.error.INVALID_NUMBER" | "phoneField.error.NOT_A_NUMBER" | "phoneField.error.REQUIRED" | "phoneField.error.REQUIRED_COUNTRY" | "phoneField.error.TOO_LONG" | "phoneField.error.TOO_SHORT" | "phoneField.error.undefined" | "schedule.label.active" | "schedule.label.allDay" | "schedule.label.day" | "urlField.error.INVALID_URL" | "urlField.error.REQUIRED">, import("i18next").i18n, boolean] & {
|
|
18
|
+
t: TransForLibs<"baseInput.copyAction.toolTip" | "clearIndicator.icon.tooltip.clearAll" | "colorField.error.INVALID_HEX_CODE" | "colorField.error.REQUIRED" | "dropzone.input.title" | "dropzone.label.default" | "emailField.error.INVALID_EMAIL" | "emailField.error.REQUIRED" | "field.notEditable.tooltip" | "field.required.asterisk.tooltip" | "numberField.error.GREATER_THAN" | "numberField.error.INVALID_NUMBER" | "numberField.error.LESS_THAN" | "numberField.error.NOT_IN_BETWEEN" | "numberField.error.REQUIRED" | "phoneField.error.INVALID_COUNTRY" | "phoneField.error.INVALID_LENGTH" | "phoneField.error.INVALID_NUMBER" | "phoneField.error.NOT_A_NUMBER" | "phoneField.error.REQUIRED" | "phoneField.error.REQUIRED_COUNTRY" | "phoneField.error.TOO_LONG" | "phoneField.error.TOO_SHORT" | "phoneField.error.undefined" | "schedule.label.active" | "schedule.label.allDay" | "schedule.label.day" | "urlField.error.INVALID_URL" | "urlField.error.REQUIRED">;
|
|
19
19
|
i18n: import("i18next").i18n;
|
|
20
20
|
ready: boolean;
|
|
21
21
|
};
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type FormComponentSizes = "small" | "medium" | "large" | undefined | null;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type DisabledKind = "locked" | "disabled";
|
|
2
|
-
export type DisabledForReasons = {
|
|
3
|
-
kind: DisabledKind;
|
|
4
|
-
reasons?: string | string[];
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Icon with explanation tooltip for why an input is locked or disabled.
|
|
8
|
-
* If locked, a permission lacks but the input **can** sometimes be edited.
|
|
9
|
-
* If disabled, the input **cannot** be edited and is only ever for displaying information.
|
|
10
|
-
*
|
|
11
|
-
* @param {DisabledForReasons} props - The reasons for the disabled state.
|
|
12
|
-
* @param {DisabledKind} kind - The kind of disabled state. If locked, the input can sometimes be edited. If disabled, the input cannot be edited.
|
|
13
|
-
*/
|
|
14
|
-
export declare const DisabledForReasonsTip: ({ reasons, kind }: DisabledForReasons) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
export {};
|