@trackunit/react-components 0.0.124 → 0.0.126
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/components/Menu/MenuItem.d.ts +2 -1
- package/components/Select/CreatableSelect.d.ts +32 -4
- package/components/Select/FieldContainer.d.ts +3 -3
- package/components/Select/Select.d.ts +132 -5
- package/components/Select/{Select/TagWithWidth.d.ts → TagWithWidth.d.ts} +1 -1
- package/components/Select/{Select/TagsContainer.d.ts → TagsContainer.d.ts} +0 -0
- package/components/Select/index.d.ts +4 -0
- package/components/Select/shared.d.ts +10 -67
- package/components/Select/useCustomComponents.d.ts +19 -0
- package/components/Select/useCustomStyles.d.ts +14 -0
- package/index.js +800 -174
- package/package.json +1 -1
- package/components/Select/Select/Select.d.ts +0 -122
- package/components/Select/Select/useCustomComponents.d.ts +0 -20
- package/components/Select/Select/useCustomStyles.d.ts +0 -10
- package/components/Select/Select/utils.d.ts +0 -10
|
@@ -1,10 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { GroupBase } from "react-select";
|
|
3
|
-
import {
|
|
3
|
+
import { SelectProps } from "./Select";
|
|
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 declare type SelectSize = "small" | "default";
|
|
4
31
|
/**
|
|
5
32
|
* The CreatableSelect component.
|
|
6
33
|
*
|
|
7
|
-
* @param {
|
|
34
|
+
* @param {CreateableSelectProps} props - The props for the CreatableSelect component
|
|
8
35
|
* @returns {JSX.Element} CreatableSelect component
|
|
9
36
|
*/
|
|
10
|
-
export declare const CreatableSelect: <Option, IsAsync extends boolean = false, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>({ dataTestId,
|
|
37
|
+
export declare const CreatableSelect: <Option, IsAsync extends boolean = false, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>({ dataTestId, id, label, hideLabel, description, error, info, isInvalid, maxMenuHeight, components, disabled, async, value, onChange, isMulti, classNamePrefix, isLoading, options, onMenuOpen, styles, ...props }: CreateableSelectProps<Option, IsAsync, IsMulti, Group>) => JSX.Element;
|
|
38
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
interface SelectContainerProps {
|
|
2
|
+
export interface SelectContainerProps {
|
|
3
3
|
children: React.ReactElement;
|
|
4
4
|
label?: string;
|
|
5
5
|
hideLabel?: boolean;
|
|
@@ -9,6 +9,7 @@ interface SelectContainerProps {
|
|
|
9
9
|
error?: React.ReactNode;
|
|
10
10
|
info?: React.ReactNode;
|
|
11
11
|
dataTestId?: string;
|
|
12
|
+
isDisabled?: boolean;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
15
|
* The SelectContainer component.
|
|
@@ -16,5 +17,4 @@ interface SelectContainerProps {
|
|
|
16
17
|
* @param {SelectContainerProps} props - The props for the SelectContainer component
|
|
17
18
|
* @returns {JSX.Element} SelectContainer component
|
|
18
19
|
*/
|
|
19
|
-
export declare const SelectContainer: ({ children, label, hideLabel, id, hasError, error, description, info, dataTestId, }: SelectContainerProps) => JSX.Element;
|
|
20
|
-
export {};
|
|
20
|
+
export declare const SelectContainer: ({ children, label, hideLabel, id, hasError, error, description, info, dataTestId, isDisabled, }: SelectContainerProps) => JSX.Element;
|
|
@@ -1,10 +1,137 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { GroupBase } from "react-select";
|
|
3
|
-
import {
|
|
2
|
+
import { GroupBase, OptionsOrGroups, Props } from "react-select";
|
|
3
|
+
import { CommonProps } from "../../common";
|
|
4
|
+
export interface SelectOption {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
export interface AsyncSelect<Option, Group extends GroupBase<Option> = GroupBase<Option>> {
|
|
9
|
+
loadOptions: (input: string) => void | Promise<OptionsOrGroups<Option, Group>>;
|
|
10
|
+
defaultOptions: OptionsOrGroups<Option, Group> | undefined;
|
|
11
|
+
cacheOptions: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface SelectProps<Option, IsAsync extends boolean, IsMulti extends boolean, GroupType extends GroupBase<Option>> extends CommonProps, Props<Option, IsMulti, GroupType> {
|
|
14
|
+
/**
|
|
15
|
+
* An React element to render before the text in the select.
|
|
16
|
+
* This is typically used to render an icon.
|
|
17
|
+
*
|
|
18
|
+
*
|
|
19
|
+
* @memberof SelectProps
|
|
20
|
+
*/
|
|
21
|
+
prefix?: JSX.Element;
|
|
22
|
+
/**
|
|
23
|
+
* An string to render in field when there is no value selected.
|
|
24
|
+
* Can be used as a description, example or a hint.
|
|
25
|
+
*
|
|
26
|
+
*
|
|
27
|
+
* @memberof SelectProps
|
|
28
|
+
*/
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
/**
|
|
31
|
+
* An boolean flag to disable field
|
|
32
|
+
*
|
|
33
|
+
*
|
|
34
|
+
* @memberof SelectProps
|
|
35
|
+
*/
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* An field id
|
|
39
|
+
*
|
|
40
|
+
*
|
|
41
|
+
* @memberof SelectProps
|
|
42
|
+
*/
|
|
43
|
+
id?: string;
|
|
44
|
+
/**
|
|
45
|
+
* An boolean flag to set select into async mode
|
|
46
|
+
* This is typically used when data is fetched after render
|
|
47
|
+
*
|
|
48
|
+
*
|
|
49
|
+
* @memberof SelectProps
|
|
50
|
+
*/
|
|
51
|
+
async?: AsyncSelect<Option, GroupType>;
|
|
52
|
+
/**
|
|
53
|
+
* A custom icon to be used as a dropdown indicator
|
|
54
|
+
* This is typically used during style customization
|
|
55
|
+
*
|
|
56
|
+
*
|
|
57
|
+
* @memberof SelectProps
|
|
58
|
+
*/
|
|
59
|
+
dropdownIcon?: JSX.Element;
|
|
60
|
+
/**
|
|
61
|
+
* A label to be used as a aria-label
|
|
62
|
+
* This is typically used for accessibility
|
|
63
|
+
*
|
|
64
|
+
*
|
|
65
|
+
* @memberof SelectProps
|
|
66
|
+
*/
|
|
67
|
+
label?: string;
|
|
68
|
+
/**
|
|
69
|
+
* A number of pixels to limit maximal length of the select menu list
|
|
70
|
+
*
|
|
71
|
+
*
|
|
72
|
+
* @memberof SelectProps
|
|
73
|
+
*/
|
|
74
|
+
maxMenuHeight?: number;
|
|
75
|
+
/**
|
|
76
|
+
* A boolean prop to set select into invalid mode
|
|
77
|
+
* typically used when selected value is not compliant with field requirement
|
|
78
|
+
* ex if it breaks validation rules
|
|
79
|
+
*
|
|
80
|
+
*
|
|
81
|
+
* @memberof SelectProps
|
|
82
|
+
*/
|
|
83
|
+
hasError?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* A boolean flag to display loading indicator
|
|
86
|
+
*
|
|
87
|
+
*
|
|
88
|
+
* @memberof SelectProps
|
|
89
|
+
*/
|
|
90
|
+
isLoading?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* A number value to limit amount of visible tags for selected options
|
|
93
|
+
*
|
|
94
|
+
*
|
|
95
|
+
* @memberof SelectProps
|
|
96
|
+
*/
|
|
97
|
+
maxSelectedDisplayCount?: number;
|
|
98
|
+
/**
|
|
99
|
+
* A custom handler for menu open event
|
|
100
|
+
* use if you want to trigger custom logic or fetch data
|
|
101
|
+
*
|
|
102
|
+
*
|
|
103
|
+
* @memberof SelectProps
|
|
104
|
+
*/
|
|
105
|
+
onMenuOpen?: () => void;
|
|
106
|
+
/**
|
|
107
|
+
* A flag to allow user to clear value once selected
|
|
108
|
+
* default value is true
|
|
109
|
+
*
|
|
110
|
+
*
|
|
111
|
+
* @memberof SelectProps
|
|
112
|
+
*/
|
|
113
|
+
isClearable?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* A flag to allow user to filter option list by key from the text input
|
|
116
|
+
*
|
|
117
|
+
*
|
|
118
|
+
* @memberof SelectProps
|
|
119
|
+
*/
|
|
120
|
+
isSearchable?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* A flag to set select into async mode
|
|
123
|
+
*
|
|
124
|
+
* @memberof SelectProps
|
|
125
|
+
*/
|
|
126
|
+
isAsync?: IsAsync;
|
|
127
|
+
}
|
|
4
128
|
/**
|
|
5
|
-
*
|
|
129
|
+
* Selects are input components used to choose a value from a set.
|
|
6
130
|
*
|
|
7
|
-
* @param {
|
|
131
|
+
* @param {SelectProps} props - The props for the Select component
|
|
8
132
|
* @returns {JSX.Element} Select component
|
|
9
133
|
*/
|
|
10
|
-
export declare const Select:
|
|
134
|
+
export declare const Select: {
|
|
135
|
+
<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>): JSX.Element;
|
|
136
|
+
displayName: string;
|
|
137
|
+
};
|
|
File without changes
|
|
@@ -1,71 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { GroupBase, Props, StylesConfig } from "react-select";
|
|
3
|
-
import { AsyncProps } from "react-select/async";
|
|
4
|
-
import { SelectComponents } from "react-select/dist/declarations/src/components";
|
|
5
|
-
import { CommonProps } from "../../common/CommonProps";
|
|
6
|
-
export interface SelectOption {
|
|
7
|
-
label: string;
|
|
8
|
-
value: string;
|
|
9
|
-
options?: SelectOption[];
|
|
10
|
-
}
|
|
11
|
-
export declare type SelectSize = "small" | "medium";
|
|
12
|
-
export interface ISelectProps<Option, IsAsync extends boolean, IsMulti extends boolean, GroupType extends GroupBase<Option>> extends CommonProps, Props<Option, IsMulti, GroupType> {
|
|
13
|
-
/**
|
|
14
|
-
* Label to be displayed.
|
|
15
|
-
*/
|
|
16
|
-
label?: string;
|
|
17
|
-
/**
|
|
18
|
-
* To hide the label.
|
|
19
|
-
*/
|
|
20
|
-
hideLabel?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Description for the select component.
|
|
23
|
-
*/
|
|
24
|
-
description?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Whether the component is invalid.
|
|
27
|
-
*/
|
|
28
|
-
isInvalid?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Whether the component is disabled.
|
|
31
|
-
*/
|
|
32
|
-
isDisabled?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Info of the select component.
|
|
35
|
-
*/
|
|
36
|
-
info?: React.ReactNode;
|
|
37
|
-
/**
|
|
38
|
-
* Error of the select component.
|
|
39
|
-
*/
|
|
40
|
-
error?: React.ReactNode;
|
|
41
|
-
/**
|
|
42
|
-
* Size of the component.
|
|
43
|
-
*/
|
|
44
|
-
size?: SelectSize;
|
|
45
|
-
/**
|
|
46
|
-
* Whether component is asynchronous or not.
|
|
47
|
-
*/
|
|
48
|
-
isAsync?: IsAsync;
|
|
49
|
-
}
|
|
50
|
-
export declare type SelectProps<Option, IsAsync extends boolean, IsMulti extends boolean, GroupType extends GroupBase<Option>> = IsAsync extends true ? AsyncProps<Option, IsMulti, GroupType> & SelectProps<Option, IsAsync, IsMulti, GroupType> : SelectProps<Option, IsAsync, IsMulti, GroupType>;
|
|
1
|
+
import { GroupBase, MultiValue, OptionsOrGroups, PropsValue, SingleValue } from "react-select";
|
|
51
2
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* @param {StylesConfig} styles -
|
|
55
|
-
* @param {boolean} hasError -
|
|
56
|
-
* @param {boolean} isInvalid -
|
|
57
|
-
* @param {SelectSize} size -
|
|
58
|
-
* @returns {{StylesConfig}} useCustomStyles hook return
|
|
3
|
+
* @param {MultiValue<Option> | SingleValue<Option>} arg option to check type
|
|
4
|
+
* @returns {arg is MultiValue<Option> } is Multivalue
|
|
59
5
|
*/
|
|
60
|
-
export declare
|
|
61
|
-
customStyles: StylesConfig<Option, IsMulti, Group>;
|
|
62
|
-
};
|
|
6
|
+
export declare function isMultiValue<Option>(arg: MultiValue<Option> | SingleValue<Option>): arg is MultiValue<Option>;
|
|
63
7
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* @param {
|
|
67
|
-
* @
|
|
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
|
|
68
13
|
*/
|
|
69
|
-
export declare const
|
|
70
|
-
customComponents: Partial<SelectComponents<Option, IsMulti, Group>>;
|
|
71
|
-
};
|
|
14
|
+
export declare const getOrderedOptions: <Option, Group extends GroupBase<Option>>(options: OptionsOrGroups<Option, Group> | undefined, value: PropsValue<Option> | undefined) => OptionsOrGroups<Option, Group>;
|
|
@@ -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} menuIsClosing a flag to trigger fade out animation for the menu
|
|
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, menuIsClosing: 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
|
+
};
|