@trackunit/react-components 0.0.139 → 0.0.143
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/FormGroup/FormGroup.d.ts +1 -1
- package/components/Prompt/Prompt.d.ts +1 -1
- package/components/Select/CreatableSelect.d.ts +2 -2
- package/components/Select/Select.d.ts +3 -123
- package/components/Select/shared.d.ts +1 -0
- package/components/Select/useSelect.d.ts +143 -0
- package/components/ValueBar/ValueBar.d.ts +2 -2
- package/index.js +239 -258
- package/package.json +13 -14
|
@@ -12,7 +12,7 @@ export interface FormGroupProps extends CommonProps {
|
|
|
12
12
|
/**
|
|
13
13
|
* A string to display under the input element to help the user understand the input.
|
|
14
14
|
*/
|
|
15
|
-
helpText?: string;
|
|
15
|
+
helpText?: string | null;
|
|
16
16
|
/**
|
|
17
17
|
* An addon element to render to the right under the input element.
|
|
18
18
|
* Used for displaying maxLength etc.
|
|
@@ -9,7 +9,7 @@ interface PromptProps {
|
|
|
9
9
|
* @param {boolean} when -
|
|
10
10
|
* @returns {void} void
|
|
11
11
|
*/
|
|
12
|
-
export declare
|
|
12
|
+
export declare const usePrompt: (message: string, when?: boolean) => void;
|
|
13
13
|
/**
|
|
14
14
|
* The Prompt function.
|
|
15
15
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { GroupBase } from "react-select";
|
|
3
|
-
import { SelectProps } from "./
|
|
3
|
+
import { SelectProps } from "./useSelect";
|
|
4
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
5
|
/**
|
|
6
6
|
* To hide the label.
|
|
@@ -34,5 +34,5 @@ export declare type SelectSize = "small" | "default";
|
|
|
34
34
|
* @param {CreateableSelectProps} props - The props for the CreatableSelect component
|
|
35
35
|
* @returns {JSX.Element} CreatableSelect component
|
|
36
36
|
*/
|
|
37
|
-
export declare const CreatableSelect: <Option, IsAsync extends boolean = false, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(
|
|
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
38
|
export {};
|
|
@@ -1,130 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { GroupBase
|
|
3
|
-
import {
|
|
2
|
+
import { GroupBase } from "react-select";
|
|
3
|
+
import { SelectProps } from "./useSelect";
|
|
4
4
|
export interface SelectOption {
|
|
5
5
|
label: string;
|
|
6
6
|
value: string;
|
|
7
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
|
-
}
|
|
128
8
|
/**
|
|
129
9
|
* Selects are input components used to choose a value from a set.
|
|
130
10
|
*
|
|
@@ -132,6 +12,6 @@ export interface SelectProps<Option, IsAsync extends boolean, IsMulti extends bo
|
|
|
132
12
|
* @returns {JSX.Element} Select component
|
|
133
13
|
*/
|
|
134
14
|
export declare const Select: {
|
|
135
|
-
<Option, IsAsync extends boolean = false, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(
|
|
15
|
+
<Option, IsAsync extends boolean = false, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(props: SelectProps<Option, IsAsync, IsMulti, Group>): JSX.Element;
|
|
136
16
|
displayName: string;
|
|
137
17
|
};
|
|
@@ -12,3 +12,4 @@ export declare function isMultiValue<Option>(arg: MultiValue<Option> | SingleVal
|
|
|
12
12
|
* @returns {OptionsOrGroups<Option, Group>} An array of ordered options with selected on top
|
|
13
13
|
*/
|
|
14
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("tailwind-styled-components/dist/tailwind").TailwindComponent<"div", {}>;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { GroupBase, MenuPlacement, OptionsOrGroups, Props, StylesConfig } from "react-select";
|
|
3
|
+
import { SelectComponents } from "react-select/dist/declarations/src/components";
|
|
4
|
+
import { CommonProps } from "../../common/CommonProps";
|
|
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 {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { LevelColors } from "./ValueBarTypes";
|
|
3
2
|
import { CommonProps } from "../../common";
|
|
3
|
+
import { LevelColors } from "./ValueBarTypes";
|
|
4
4
|
export interface ValueBarProps extends CommonProps {
|
|
5
5
|
/**
|
|
6
6
|
* Value to display.
|
|
@@ -41,4 +41,4 @@ export interface ValueBarProps extends CommonProps {
|
|
|
41
41
|
* @param {ValueBarProps} props - The props for the ValueBar component
|
|
42
42
|
* @returns {JSX.Element} ValueBar component
|
|
43
43
|
*/
|
|
44
|
-
export declare const ValueBar: ({ value, min, max, unit, size, levelColors, valueColor, showValue, className, dataTestId }: ValueBarProps) => JSX.Element;
|
|
44
|
+
export declare const ValueBar: ({ value, min, max, unit, size, levelColors, valueColor, showValue, className, dataTestId, }: ValueBarProps) => JSX.Element;
|
package/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { tw, tws } from '@trackunit/tailwind-styled-components';
|
|
2
|
+
import { tw, tws, twx } from '@trackunit/tailwind-styled-components';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import React__default, { useState, forwardRef, useCallback, useRef, Fragment as Fragment$1, createElement,
|
|
4
|
+
import React__default, { useState, forwardRef, useCallback, useRef, Fragment as Fragment$1, createElement, useEffect, useContext, memo } from 'react';
|
|
5
5
|
import { HeroIconsArray, heroIconLookup, TrackunitSolidIconsArray, TrackunitOutlineIconsArray, trackunitIconLookup } from '@trackunit/ui-icons';
|
|
6
6
|
import EChart from 'echarts-for-react';
|
|
7
7
|
import { v4 } from 'uuid';
|
|
8
|
-
import { animated, useSpring, useTransition } from '@react-spring/web';
|
|
9
8
|
import { useMeasure, useCopyToClipboard, useKeyPressEvent } from 'react-use';
|
|
10
9
|
import { DayPicker as DayPicker$1 } from 'react-day-picker';
|
|
11
10
|
import { enGB, enUS, da, de, cs, nl, fr, fi, hu, it, nb, pl, pt, ru, ro, es, sv, ja, th } from 'date-fns/locale';
|
|
11
|
+
import { useSpring, animated } from '@react-spring/web';
|
|
12
12
|
import usePortal from 'react-useportal';
|
|
13
13
|
import { createPopper } from '@popperjs/core';
|
|
14
14
|
import { Helmet } from 'react-helmet';
|
|
15
|
-
import {
|
|
15
|
+
import { UNSAFE_NavigationContext } from 'react-router-dom';
|
|
16
16
|
import ReactSelect, { components } from 'react-select';
|
|
17
17
|
export { default as ValueType } from 'react-select';
|
|
18
18
|
import ReactAsyncCreatableSelect from 'react-select/async-creatable';
|
|
@@ -266,7 +266,7 @@ const StyledButton$1 = tw.button`
|
|
|
266
266
|
${getStyles()}
|
|
267
267
|
${getPadding()}
|
|
268
268
|
`;
|
|
269
|
-
const StyledSpinner =
|
|
269
|
+
const StyledSpinner = twx(Spinner)`
|
|
270
270
|
tu-button__spinner
|
|
271
271
|
`;
|
|
272
272
|
|
|
@@ -295,7 +295,7 @@ const IconButton = React.forwardRef((_a, ref) => {
|
|
|
295
295
|
})
|
|
296
296
|
}));
|
|
297
297
|
});
|
|
298
|
-
const StyledButton =
|
|
298
|
+
const StyledButton = twx(Button)`
|
|
299
299
|
${p => p.$circular ? tws`tu-button--rounded` : null}
|
|
300
300
|
`;
|
|
301
301
|
const IconContainer$2 = tw.div`
|
|
@@ -551,7 +551,7 @@ const ActionButton = ({
|
|
|
551
551
|
const ActionContainer = tw.div`
|
|
552
552
|
tu-action-container
|
|
553
553
|
`;
|
|
554
|
-
const StyledIconButton =
|
|
554
|
+
const StyledIconButton = twx(IconButton)`
|
|
555
555
|
tu-action-button
|
|
556
556
|
`;
|
|
557
557
|
|
|
@@ -580,7 +580,7 @@ const Flex$2 = tw.div`
|
|
|
580
580
|
flex
|
|
581
581
|
items-center
|
|
582
582
|
`;
|
|
583
|
-
const CustomIcon =
|
|
583
|
+
const CustomIcon = twx(Icon$1)`
|
|
584
584
|
cursor-pointer
|
|
585
585
|
w-5
|
|
586
586
|
h-5
|
|
@@ -875,7 +875,7 @@ const ContentDetails = tw.div`
|
|
|
875
875
|
const ContentBody = tw.div`
|
|
876
876
|
tu-alert__content-body
|
|
877
877
|
`;
|
|
878
|
-
const Description$2 =
|
|
878
|
+
const Description$2 = twx(Text$1)`
|
|
879
879
|
${p => p.$hasTitle ? tws`tu-alert__description` : null}
|
|
880
880
|
`;
|
|
881
881
|
const RightAligned = tw.div`
|
|
@@ -1233,7 +1233,7 @@ const getOverflow = () => ({
|
|
|
1233
1233
|
return overflows[$overflow];
|
|
1234
1234
|
};
|
|
1235
1235
|
|
|
1236
|
-
const StyledDensityContainer =
|
|
1236
|
+
const StyledDensityContainer = twx(DensityContainer)`
|
|
1237
1237
|
${getOverflow()}
|
|
1238
1238
|
tu-card__body
|
|
1239
1239
|
`;
|
|
@@ -1263,7 +1263,7 @@ const CardFooter = ({
|
|
|
1263
1263
|
})
|
|
1264
1264
|
}));
|
|
1265
1265
|
};
|
|
1266
|
-
const TopBorderedDensityContainer =
|
|
1266
|
+
const TopBorderedDensityContainer = twx(DensityContainer)`
|
|
1267
1267
|
tu-card__footer-density-container
|
|
1268
1268
|
`;
|
|
1269
1269
|
const Body = tw.div`
|
|
@@ -1380,7 +1380,7 @@ const CardHeader = ({
|
|
|
1380
1380
|
})
|
|
1381
1381
|
}));
|
|
1382
1382
|
};
|
|
1383
|
-
const BottomBorderedDensityContainer =
|
|
1383
|
+
const BottomBorderedDensityContainer = twx(DensityContainer)`
|
|
1384
1384
|
tu-card__header-density-container
|
|
1385
1385
|
`;
|
|
1386
1386
|
const Container$7 = tw.div`
|
|
@@ -1670,8 +1670,8 @@ const Checkbox = React.forwardRef((_a, ref) => {
|
|
|
1670
1670
|
})), children]
|
|
1671
1671
|
}));
|
|
1672
1672
|
});
|
|
1673
|
-
const StyledCheckIcon =
|
|
1674
|
-
const StyledIndeterminateIcon =
|
|
1673
|
+
const StyledCheckIcon = twx(CheckIcon)`tu-checkbox--icon`;
|
|
1674
|
+
const StyledIndeterminateIcon = twx(IndeterminateIcon)`tu-checkbox--icon`;
|
|
1675
1675
|
const CheckboxContainer = tw.label`tu-checkbox--container group`;
|
|
1676
1676
|
const HiddenInput$1 = tw.input`tu-checkbox--input`;
|
|
1677
1677
|
const CheckboxWrapper = tw.span`
|
|
@@ -1751,7 +1751,7 @@ const Collapse = ({
|
|
|
1751
1751
|
}))]
|
|
1752
1752
|
}));
|
|
1753
1753
|
};
|
|
1754
|
-
const Rotate =
|
|
1754
|
+
const Rotate = twx(Icon$1)`
|
|
1755
1755
|
${p => p.$expanded ? tws`tu-icon--animated-rotate-expanded` : null}
|
|
1756
1756
|
tu-icon--animated-rotate
|
|
1757
1757
|
`;
|
|
@@ -1773,25 +1773,11 @@ const Collapsible = ({
|
|
|
1773
1773
|
const [ref, {
|
|
1774
1774
|
height
|
|
1775
1775
|
}] = useMeasure();
|
|
1776
|
-
const props = useSpring({
|
|
1777
|
-
config: {
|
|
1778
|
-
tension: expanded ? 2000 : 1500,
|
|
1779
|
-
friction: 100,
|
|
1780
|
-
precision: 0.01
|
|
1781
|
-
},
|
|
1782
|
-
from: {
|
|
1783
|
-
height: 0
|
|
1784
|
-
},
|
|
1785
|
-
to: expanded ? {
|
|
1786
|
-
// We add 8 pixels to the bottom to prevent overflow issues.
|
|
1787
|
-
height: height + 8
|
|
1788
|
-
} : {
|
|
1789
|
-
height: 0
|
|
1790
|
-
}
|
|
1791
|
-
});
|
|
1792
1776
|
return jsx(AnimatedCollapsible, Object.assign({
|
|
1793
1777
|
id: id,
|
|
1794
|
-
style:
|
|
1778
|
+
style: {
|
|
1779
|
+
height: expanded ? height : "0"
|
|
1780
|
+
}
|
|
1795
1781
|
}, {
|
|
1796
1782
|
children: jsx(StyledCollapsible, Object.assign({
|
|
1797
1783
|
ref: ref
|
|
@@ -1801,7 +1787,7 @@ const Collapsible = ({
|
|
|
1801
1787
|
}));
|
|
1802
1788
|
};
|
|
1803
1789
|
|
|
1804
|
-
const AnimatedCollapsible = tw
|
|
1790
|
+
const AnimatedCollapsible = tw.div`
|
|
1805
1791
|
tu-collapsible--animated
|
|
1806
1792
|
`;
|
|
1807
1793
|
const StyledCollapsible = tw.div`
|
|
@@ -2106,7 +2092,7 @@ const PopoverList = ({
|
|
|
2106
2092
|
const List = tw.ul`
|
|
2107
2093
|
tu-popover-list
|
|
2108
2094
|
`;
|
|
2109
|
-
const StyledCardBody =
|
|
2095
|
+
const StyledCardBody = twx(CardBody)`
|
|
2110
2096
|
tu-popover-list-body
|
|
2111
2097
|
`;
|
|
2112
2098
|
|
|
@@ -2254,7 +2240,7 @@ const PopoverListItem = ({
|
|
|
2254
2240
|
})) : content
|
|
2255
2241
|
}));
|
|
2256
2242
|
};
|
|
2257
|
-
const StyledText$2 =
|
|
2243
|
+
const StyledText$2 = twx(Text$1)`
|
|
2258
2244
|
tu-popover-list-item__text
|
|
2259
2245
|
${p => p.$selected && tws`tu-popover-list-item__text--selected`}
|
|
2260
2246
|
`;
|
|
@@ -2301,7 +2287,7 @@ const Container$6 = tw.div`
|
|
|
2301
2287
|
tu-popover-title-container
|
|
2302
2288
|
${p => p.$divider && `tu-popover-title-container--divider`}
|
|
2303
2289
|
`;
|
|
2304
|
-
const StyledText$1 =
|
|
2290
|
+
const StyledText$1 = twx(Text$1)`
|
|
2305
2291
|
tu-popover-title-text
|
|
2306
2292
|
`;
|
|
2307
2293
|
|
|
@@ -2370,7 +2356,7 @@ const Tooltip = ({
|
|
|
2370
2356
|
const Flex$1 = tw.div`
|
|
2371
2357
|
inline-flex
|
|
2372
2358
|
`;
|
|
2373
|
-
const Container$5 =
|
|
2359
|
+
const Container$5 = twx(AnimatedPopover)`
|
|
2374
2360
|
tu-tooltip__container
|
|
2375
2361
|
`;
|
|
2376
2362
|
const Content = tw.div`
|
|
@@ -2954,44 +2940,31 @@ const ModalBackdrop = ({
|
|
|
2954
2940
|
isVisible,
|
|
2955
2941
|
onClick
|
|
2956
2942
|
}) => {
|
|
2957
|
-
const transitions = useTransition(isVisible, {
|
|
2958
|
-
from: {
|
|
2959
|
-
opacity: 0
|
|
2960
|
-
},
|
|
2961
|
-
enter: {
|
|
2962
|
-
opacity: 1
|
|
2963
|
-
},
|
|
2964
|
-
leave: {
|
|
2965
|
-
opacity: 0
|
|
2966
|
-
},
|
|
2967
|
-
config: {
|
|
2968
|
-
tension: 300,
|
|
2969
|
-
friction: 30,
|
|
2970
|
-
precision: 0.1
|
|
2971
|
-
}
|
|
2972
|
-
});
|
|
2973
2943
|
const ref = React.useRef(null);
|
|
2974
|
-
return jsx(
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2944
|
+
return jsx(Backdrop, Object.assign({
|
|
2945
|
+
ref: ref,
|
|
2946
|
+
"$isVisible": isVisible,
|
|
2947
|
+
onMouseDown: e => {
|
|
2948
|
+
var _a, _b; // only react on click on backdrop - accessing first child to get around styled element element
|
|
2979
2949
|
|
|
2980
2950
|
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
}
|
|
2951
|
+
if (ref.current !== null) {
|
|
2952
|
+
if ((e === null || e === void 0 ? void 0 : e.target) === ((_b = (_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b[0])) {
|
|
2953
|
+
onClick();
|
|
2985
2954
|
}
|
|
2986
|
-
}
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
});
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
}, {
|
|
2958
|
+
children: children
|
|
2959
|
+
}));
|
|
2992
2960
|
};
|
|
2993
|
-
const Backdrop = tw
|
|
2961
|
+
const Backdrop = tw.div`
|
|
2994
2962
|
tu-modal-backdrop
|
|
2963
|
+
${({
|
|
2964
|
+
$isVisible
|
|
2965
|
+
}) => {
|
|
2966
|
+
return $isVisible && tws`tu-modal-backdrop--show`;
|
|
2967
|
+
}}
|
|
2995
2968
|
`;
|
|
2996
2969
|
|
|
2997
2970
|
/**
|
|
@@ -3010,32 +2983,12 @@ const Modal = React.forwardRef(({
|
|
|
3010
2983
|
return;
|
|
3011
2984
|
}
|
|
3012
2985
|
}, ref) => {
|
|
3013
|
-
const transitions = useTransition(isOpen, {
|
|
3014
|
-
from: {
|
|
3015
|
-
opacity: 0,
|
|
3016
|
-
transform: "scale(0.9)"
|
|
3017
|
-
},
|
|
3018
|
-
enter: {
|
|
3019
|
-
opacity: 1,
|
|
3020
|
-
transform: "scale(1)"
|
|
3021
|
-
},
|
|
3022
|
-
leave: {
|
|
3023
|
-
opacity: 0,
|
|
3024
|
-
transform: "scale(0.9)"
|
|
3025
|
-
},
|
|
3026
|
-
config: {
|
|
3027
|
-
tension: 300,
|
|
3028
|
-
friction: 30,
|
|
3029
|
-
precision: 0.1
|
|
3030
|
-
}
|
|
3031
|
-
});
|
|
3032
2986
|
return jsx(ModalBackdrop, Object.assign({
|
|
3033
2987
|
isVisible: isOpen,
|
|
3034
2988
|
onClick: onDismissClick
|
|
3035
2989
|
}, {
|
|
3036
|
-
children:
|
|
3037
|
-
ref: ref
|
|
3038
|
-
style: props
|
|
2990
|
+
children: isOpen && jsx(StyledDiv, Object.assign({
|
|
2991
|
+
ref: ref
|
|
3039
2992
|
}, {
|
|
3040
2993
|
children: jsx(StyledCard, Object.assign({
|
|
3041
2994
|
dataTestId: dataTestId,
|
|
@@ -3044,7 +2997,7 @@ const Modal = React.forwardRef(({
|
|
|
3044
2997
|
}, {
|
|
3045
2998
|
children: children
|
|
3046
2999
|
}))
|
|
3047
|
-
}))
|
|
3000
|
+
}))
|
|
3048
3001
|
}));
|
|
3049
3002
|
});
|
|
3050
3003
|
|
|
@@ -3062,14 +3015,13 @@ const getCardMaxWidth = () => ({
|
|
|
3062
3015
|
return widths[maxWidth];
|
|
3063
3016
|
};
|
|
3064
3017
|
|
|
3065
|
-
const StyledCard =
|
|
3018
|
+
const StyledCard = twx(Card)`
|
|
3066
3019
|
tu-modal__card
|
|
3067
3020
|
${getCardMaxWidth()}
|
|
3068
3021
|
`;
|
|
3069
3022
|
const StyledDiv = tw.div`
|
|
3070
3023
|
tu-modal__container
|
|
3071
3024
|
`;
|
|
3072
|
-
const AnimatedDiv = animated(StyledDiv);
|
|
3073
3025
|
|
|
3074
3026
|
/**
|
|
3075
3027
|
* The useModal component should be used to inform the user of important information.
|
|
@@ -3301,7 +3253,7 @@ const getColorModifierClass = () => ({
|
|
|
3301
3253
|
return colorClasses[$color];
|
|
3302
3254
|
};
|
|
3303
3255
|
|
|
3304
|
-
const StyledText = tw.
|
|
3256
|
+
const StyledText = tw.span`
|
|
3305
3257
|
tu-tag
|
|
3306
3258
|
${getSizeModifierClass()}
|
|
3307
3259
|
${getColorModifierClass()}
|
|
@@ -3356,40 +3308,29 @@ const StyledFlex = tw.div`
|
|
|
3356
3308
|
gap-2
|
|
3357
3309
|
`;
|
|
3358
3310
|
|
|
3359
|
-
function
|
|
3360
|
-
return useContext(UNSAFE_LocationContext) !== null;
|
|
3361
|
-
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
function invariant(cond, message) {
|
|
3365
|
-
if (!cond) {
|
|
3366
|
-
throw new Error(message);
|
|
3367
|
-
}
|
|
3368
|
-
}
|
|
3369
|
-
|
|
3370
|
-
function useBlocker(blocker, when = true) {
|
|
3371
|
-
invariant(useInRouterContext(), `useBlocker() may be used only in the context of a <Router> component.`);
|
|
3311
|
+
function useConfirmExit(confirmExit, when = true) {
|
|
3372
3312
|
const {
|
|
3373
3313
|
navigator
|
|
3374
3314
|
} = useContext(UNSAFE_NavigationContext);
|
|
3375
3315
|
useEffect(() => {
|
|
3376
3316
|
if (!when) {
|
|
3377
3317
|
return;
|
|
3378
|
-
}
|
|
3318
|
+
}
|
|
3379
3319
|
|
|
3320
|
+
const push = navigator.push;
|
|
3380
3321
|
|
|
3381
|
-
|
|
3382
|
-
const
|
|
3383
|
-
retry() {
|
|
3384
|
-
unblock();
|
|
3385
|
-
tx.retry();
|
|
3386
|
-
}
|
|
3322
|
+
navigator.push = (...args) => {
|
|
3323
|
+
const result = confirmExit();
|
|
3387
3324
|
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3325
|
+
if (result !== false) {
|
|
3326
|
+
push(...args);
|
|
3327
|
+
}
|
|
3328
|
+
};
|
|
3329
|
+
|
|
3330
|
+
return () => {
|
|
3331
|
+
navigator.push = push;
|
|
3332
|
+
};
|
|
3333
|
+
}, [navigator, confirmExit, when]);
|
|
3393
3334
|
}
|
|
3394
3335
|
/**
|
|
3395
3336
|
* The usePrompt hook.
|
|
@@ -3400,14 +3341,24 @@ function useBlocker(blocker, when = true) {
|
|
|
3400
3341
|
*/
|
|
3401
3342
|
|
|
3402
3343
|
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
if (
|
|
3406
|
-
|
|
3344
|
+
const usePrompt = (message, when = true) => {
|
|
3345
|
+
useEffect(() => {
|
|
3346
|
+
if (when) {
|
|
3347
|
+
window.onbeforeunload = function () {
|
|
3348
|
+
return message;
|
|
3349
|
+
};
|
|
3407
3350
|
}
|
|
3351
|
+
|
|
3352
|
+
return () => {
|
|
3353
|
+
window.onbeforeunload = null;
|
|
3354
|
+
};
|
|
3355
|
+
}, [message, when]);
|
|
3356
|
+
const confirmExit = useCallback(() => {
|
|
3357
|
+
const confirm = window.confirm(message);
|
|
3358
|
+
return confirm;
|
|
3408
3359
|
}, [message]);
|
|
3409
|
-
|
|
3410
|
-
}
|
|
3360
|
+
useConfirmExit(confirmExit, when);
|
|
3361
|
+
};
|
|
3411
3362
|
/**
|
|
3412
3363
|
* The Prompt function.
|
|
3413
3364
|
*
|
|
@@ -3599,7 +3550,7 @@ const Container$1 = tw.label`
|
|
|
3599
3550
|
$isDisabled
|
|
3600
3551
|
}) => $isDisabled ? tws`tu-select--disabled` : null}
|
|
3601
3552
|
`;
|
|
3602
|
-
const InformativeText =
|
|
3553
|
+
const InformativeText = twx(Text$1)`
|
|
3603
3554
|
tu-informative-text
|
|
3604
3555
|
${p => p.$hasError ? `tu-informative-text--error` : null}
|
|
3605
3556
|
`;
|
|
@@ -3608,6 +3559,7 @@ const InformativeText = tw(Text$1)`
|
|
|
3608
3559
|
* @param {MultiValue<Option> | SingleValue<Option>} arg option to check type
|
|
3609
3560
|
* @returns {arg is MultiValue<Option> } is Multivalue
|
|
3610
3561
|
*/
|
|
3562
|
+
|
|
3611
3563
|
function isMultiValue(arg) {
|
|
3612
3564
|
return Array.isArray(arg);
|
|
3613
3565
|
}
|
|
@@ -3655,6 +3607,9 @@ const getOrderedOptions = (options, value) => {
|
|
|
3655
3607
|
|
|
3656
3608
|
return options || [];
|
|
3657
3609
|
};
|
|
3610
|
+
const SelectPrefix = tw.div`
|
|
3611
|
+
tu-select__prefix
|
|
3612
|
+
`;
|
|
3658
3613
|
|
|
3659
3614
|
/**
|
|
3660
3615
|
* A single select menu item is a basic wrapper around Menu item designed to be used as a single value render in Select list
|
|
@@ -4008,7 +3963,7 @@ const useCustomComponents = (componentsProps, disabled, menuIsClosing, refMenuIs
|
|
|
4008
3963
|
},
|
|
4009
3964
|
Menu: props => {
|
|
4010
3965
|
return jsx(components.Menu, Object.assign({}, props, {
|
|
4011
|
-
className: menuIsClosing ? tws`tu-
|
|
3966
|
+
className: menuIsClosing ? tws`tu-select__menu-list animate-fade-out-fast` : tws`tu-select__menu-list animate-fade-in-fast`
|
|
4012
3967
|
}));
|
|
4013
3968
|
},
|
|
4014
3969
|
Option: props => {
|
|
@@ -4076,13 +4031,13 @@ const useCustomStyles = (refContainer, refPrefix, maxSelectedDisplayCount, style
|
|
|
4076
4031
|
indicatorSeparator: () => ({
|
|
4077
4032
|
width: "0px"
|
|
4078
4033
|
}),
|
|
4079
|
-
menu:
|
|
4080
|
-
return {
|
|
4034
|
+
menu: base => {
|
|
4035
|
+
return Object.assign(Object.assign({}, base), {
|
|
4081
4036
|
width: "100%",
|
|
4082
4037
|
marginTop: "4px",
|
|
4083
4038
|
marginBottom: "18px",
|
|
4084
4039
|
transition: "all 1s ease-in-out"
|
|
4085
|
-
};
|
|
4040
|
+
});
|
|
4086
4041
|
},
|
|
4087
4042
|
input: base => Object.assign(Object.assign({}, base), {
|
|
4088
4043
|
marginLeft: "0px"
|
|
@@ -4137,48 +4092,55 @@ const useCustomStyles = (refContainer, refPrefix, maxSelectedDisplayCount, style
|
|
|
4137
4092
|
};
|
|
4138
4093
|
|
|
4139
4094
|
/**
|
|
4140
|
-
*
|
|
4095
|
+
* A hook used by selects to share the common code
|
|
4141
4096
|
*
|
|
4142
|
-
* @param {
|
|
4143
|
-
* @returns {
|
|
4097
|
+
* @param {SelectProps} props - The props for the Select component
|
|
4098
|
+
* @returns {IUseSelect} Select component
|
|
4144
4099
|
*/
|
|
4145
4100
|
|
|
4146
|
-
const
|
|
4101
|
+
const useSelect = _a => {
|
|
4102
|
+
var _b;
|
|
4103
|
+
|
|
4147
4104
|
var {
|
|
4148
|
-
dataTestId = "createableSelect",
|
|
4149
4105
|
id,
|
|
4106
|
+
className,
|
|
4107
|
+
dataTestId = "select",
|
|
4108
|
+
prefix,
|
|
4109
|
+
async,
|
|
4110
|
+
dropdownIcon,
|
|
4111
|
+
maxMenuHeight = 200,
|
|
4150
4112
|
label,
|
|
4151
|
-
|
|
4152
|
-
description,
|
|
4153
|
-
error,
|
|
4154
|
-
info,
|
|
4155
|
-
isInvalid,
|
|
4156
|
-
maxMenuHeight = 308,
|
|
4157
|
-
components,
|
|
4113
|
+
hasError,
|
|
4158
4114
|
disabled,
|
|
4159
|
-
|
|
4115
|
+
isMulti,
|
|
4116
|
+
components,
|
|
4160
4117
|
value,
|
|
4118
|
+
options,
|
|
4161
4119
|
onChange,
|
|
4162
|
-
isMulti,
|
|
4163
|
-
classNamePrefix,
|
|
4164
4120
|
isLoading,
|
|
4165
|
-
|
|
4121
|
+
classNamePrefix = "",
|
|
4166
4122
|
onMenuOpen,
|
|
4167
|
-
|
|
4123
|
+
onMenuClose,
|
|
4124
|
+
maxSelectedDisplayCount = undefined,
|
|
4125
|
+
isClearable = false,
|
|
4126
|
+
isSearchable = true,
|
|
4127
|
+
onMenuScrollToBottom,
|
|
4128
|
+
styles,
|
|
4129
|
+
filterOption,
|
|
4130
|
+
onInputChange
|
|
4168
4131
|
} = _a,
|
|
4169
|
-
props = __rest(_a, ["
|
|
4132
|
+
props = __rest(_a, ["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"]);
|
|
4170
4133
|
|
|
4171
|
-
const hasError = !!error;
|
|
4172
4134
|
const refContainer = React__default.useRef(null);
|
|
4173
4135
|
const refPrefix = React__default.useRef(null);
|
|
4174
|
-
const [menuIsOpen, setMenuIsOpen] = React__default.useState(false);
|
|
4175
|
-
const [menuIsClosing, setMenuIsClosing] = React__default.useState(false);
|
|
4176
|
-
const refMenuIsEnabled = React__default.useRef(true);
|
|
4177
4136
|
const {
|
|
4178
4137
|
customStyles
|
|
4179
|
-
} = useCustomStyles(refContainer, refPrefix,
|
|
4138
|
+
} = useCustomStyles(refContainer, refPrefix, maxSelectedDisplayCount, styles);
|
|
4139
|
+
const [menuIsOpen, setMenuIsOpen] = React__default.useState((_b = props.menuIsOpen) !== null && _b !== void 0 ? _b : false);
|
|
4140
|
+
const [menuIsClosing, setMenuIsClosing] = React__default.useState(true);
|
|
4141
|
+
const refMenuIsEnabled = React__default.useRef(true);
|
|
4142
|
+
const customComponents = useCustomComponents(components, disabled || false, menuIsClosing, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon);
|
|
4180
4143
|
const menuPlacement = "auto";
|
|
4181
|
-
const customComponents = useCustomComponents(components, disabled || false, menuIsClosing, refMenuIsEnabled, dataTestId, undefined);
|
|
4182
4144
|
|
|
4183
4145
|
const openMenuHandler = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
4184
4146
|
onMenuOpen && onMenuOpen();
|
|
@@ -4194,12 +4156,78 @@ const CreatableSelect = _a => {
|
|
|
4194
4156
|
const closeMenuHandler = () => {
|
|
4195
4157
|
if (refMenuIsEnabled.current) {
|
|
4196
4158
|
setMenuIsClosing(true);
|
|
4197
|
-
setTimeout(() => {
|
|
4198
|
-
setMenuIsOpen(false);
|
|
4199
|
-
}, 250);
|
|
4200
4159
|
}
|
|
4160
|
+
|
|
4161
|
+
onMenuClose && onMenuClose();
|
|
4201
4162
|
};
|
|
4202
4163
|
|
|
4164
|
+
React__default.useEffect(() => {
|
|
4165
|
+
const timeout = menuIsClosing && setTimeout(() => {
|
|
4166
|
+
setMenuIsOpen(false);
|
|
4167
|
+
}, 250);
|
|
4168
|
+
return () => {
|
|
4169
|
+
timeout && clearTimeout(timeout);
|
|
4170
|
+
};
|
|
4171
|
+
}, [menuIsClosing]);
|
|
4172
|
+
const orderedOptions = React__default.useMemo(() => {
|
|
4173
|
+
return disabled ? getOrderedOptions(options, value).map(option => {
|
|
4174
|
+
return Object.assign(Object.assign({}, option), {
|
|
4175
|
+
disabled: true
|
|
4176
|
+
});
|
|
4177
|
+
}) : getOrderedOptions(options, value);
|
|
4178
|
+
}, [options, value, disabled]);
|
|
4179
|
+
return {
|
|
4180
|
+
refContainer,
|
|
4181
|
+
refPrefix,
|
|
4182
|
+
customStyles,
|
|
4183
|
+
menuIsOpen,
|
|
4184
|
+
customComponents,
|
|
4185
|
+
menuPlacement,
|
|
4186
|
+
openMenuHandler,
|
|
4187
|
+
closeMenuHandler,
|
|
4188
|
+
orderedOptions
|
|
4189
|
+
};
|
|
4190
|
+
};
|
|
4191
|
+
|
|
4192
|
+
/**
|
|
4193
|
+
* The CreatableSelect component.
|
|
4194
|
+
*
|
|
4195
|
+
* @param {CreateableSelectProps} props - The props for the CreatableSelect component
|
|
4196
|
+
* @returns {JSX.Element} CreatableSelect component
|
|
4197
|
+
*/
|
|
4198
|
+
|
|
4199
|
+
const CreatableSelect = props => {
|
|
4200
|
+
const {
|
|
4201
|
+
id,
|
|
4202
|
+
dataTestId = "select",
|
|
4203
|
+
async,
|
|
4204
|
+
maxMenuHeight = 200,
|
|
4205
|
+
label,
|
|
4206
|
+
error,
|
|
4207
|
+
disabled,
|
|
4208
|
+
isMulti,
|
|
4209
|
+
value,
|
|
4210
|
+
hideLabel,
|
|
4211
|
+
description,
|
|
4212
|
+
info,
|
|
4213
|
+
options,
|
|
4214
|
+
onChange,
|
|
4215
|
+
isLoading,
|
|
4216
|
+
classNamePrefix = "",
|
|
4217
|
+
filterOption,
|
|
4218
|
+
prefix
|
|
4219
|
+
} = props;
|
|
4220
|
+
const hasError = !!error;
|
|
4221
|
+
const {
|
|
4222
|
+
refPrefix,
|
|
4223
|
+
customStyles,
|
|
4224
|
+
menuIsOpen,
|
|
4225
|
+
customComponents,
|
|
4226
|
+
menuPlacement,
|
|
4227
|
+
openMenuHandler,
|
|
4228
|
+
closeMenuHandler,
|
|
4229
|
+
orderedOptions
|
|
4230
|
+
} = useSelect(props);
|
|
4203
4231
|
const selectProps = {
|
|
4204
4232
|
value,
|
|
4205
4233
|
menuPlacement,
|
|
@@ -4235,32 +4263,35 @@ const CreatableSelect = _a => {
|
|
|
4235
4263
|
dataTestId: dataTestId,
|
|
4236
4264
|
isDisabled: disabled
|
|
4237
4265
|
}, {
|
|
4238
|
-
children:
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
}
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4266
|
+
children: jsxs(Fragment, {
|
|
4267
|
+
children: [prefix !== undefined && jsx(SelectPrefix, Object.assign({
|
|
4268
|
+
"data-testid": `${dataTestId}-prefix`,
|
|
4269
|
+
ref: refPrefix
|
|
4270
|
+
}, {
|
|
4271
|
+
children: prefix
|
|
4272
|
+
})), async ? jsx(ReactAsyncCreatableSelect, Object.assign({
|
|
4273
|
+
"aria-label": label,
|
|
4274
|
+
maxMenuHeight: maxMenuHeight,
|
|
4275
|
+
"data-testid": dataTestId,
|
|
4276
|
+
components: customComponents
|
|
4277
|
+
}, props, {
|
|
4278
|
+
onMenuOpen: () => {
|
|
4279
|
+
!disabled && openMenuHandler();
|
|
4280
|
+
},
|
|
4281
|
+
onMenuClose: () => {
|
|
4282
|
+
closeMenuHandler();
|
|
4283
|
+
}
|
|
4284
|
+
})) : jsx(ReactCreatableSelect, Object.assign({}, selectProps, {
|
|
4285
|
+
options: filterOption ? orderedOptions : options,
|
|
4286
|
+
isMulti: isMulti,
|
|
4287
|
+
onMenuOpen: () => {
|
|
4288
|
+
!disabled && openMenuHandler();
|
|
4289
|
+
},
|
|
4290
|
+
onMenuClose: () => {
|
|
4291
|
+
closeMenuHandler();
|
|
4292
|
+
}
|
|
4293
|
+
}))]
|
|
4294
|
+
})
|
|
4264
4295
|
}));
|
|
4265
4296
|
};
|
|
4266
4297
|
|
|
@@ -4271,72 +4302,40 @@ const CreatableSelect = _a => {
|
|
|
4271
4302
|
* @returns {JSX.Element} Select component
|
|
4272
4303
|
*/
|
|
4273
4304
|
|
|
4274
|
-
const Select =
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
var {
|
|
4305
|
+
const Select = props => {
|
|
4306
|
+
const {
|
|
4278
4307
|
id,
|
|
4279
4308
|
className,
|
|
4280
4309
|
dataTestId = "select",
|
|
4281
4310
|
prefix,
|
|
4282
4311
|
async,
|
|
4283
|
-
dropdownIcon,
|
|
4284
4312
|
maxMenuHeight = 200,
|
|
4285
4313
|
label,
|
|
4286
4314
|
hasError,
|
|
4287
4315
|
disabled,
|
|
4288
4316
|
isMulti,
|
|
4289
|
-
components,
|
|
4290
4317
|
value,
|
|
4291
4318
|
options,
|
|
4292
4319
|
onChange,
|
|
4293
4320
|
isLoading,
|
|
4294
4321
|
classNamePrefix = "",
|
|
4295
|
-
onMenuOpen,
|
|
4296
|
-
onMenuClose,
|
|
4297
|
-
maxSelectedDisplayCount = undefined,
|
|
4298
|
-
isClearable = false,
|
|
4299
|
-
isSearchable = true,
|
|
4300
4322
|
onMenuScrollToBottom,
|
|
4301
|
-
styles,
|
|
4302
4323
|
filterOption,
|
|
4303
|
-
onInputChange
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
const refContainer = React.useRef(null);
|
|
4308
|
-
const refPrefix = React.useRef(null);
|
|
4324
|
+
onInputChange,
|
|
4325
|
+
isSearchable,
|
|
4326
|
+
isClearable
|
|
4327
|
+
} = props;
|
|
4309
4328
|
const {
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
if (refMenuIsEnabled.current) {
|
|
4322
|
-
setMenuIsClosing(false);
|
|
4323
|
-
yield setMenuIsOpen(true);
|
|
4324
|
-
} else {
|
|
4325
|
-
refMenuIsEnabled.current = true;
|
|
4326
|
-
}
|
|
4327
|
-
});
|
|
4328
|
-
|
|
4329
|
-
const closeMenuHandler = () => {
|
|
4330
|
-
if (refMenuIsEnabled.current) {
|
|
4331
|
-
setMenuIsClosing(true);
|
|
4332
|
-
setTimeout(() => {
|
|
4333
|
-
setMenuIsOpen(false);
|
|
4334
|
-
}, 250);
|
|
4335
|
-
}
|
|
4336
|
-
|
|
4337
|
-
onMenuClose && onMenuClose();
|
|
4338
|
-
};
|
|
4339
|
-
|
|
4329
|
+
refContainer,
|
|
4330
|
+
refPrefix,
|
|
4331
|
+
customStyles,
|
|
4332
|
+
menuIsOpen,
|
|
4333
|
+
customComponents,
|
|
4334
|
+
menuPlacement,
|
|
4335
|
+
openMenuHandler,
|
|
4336
|
+
closeMenuHandler,
|
|
4337
|
+
orderedOptions
|
|
4338
|
+
} = useSelect(props);
|
|
4340
4339
|
const selectProps = {
|
|
4341
4340
|
value,
|
|
4342
4341
|
menuPlacement,
|
|
@@ -4348,7 +4347,7 @@ const Select = _a => {
|
|
|
4348
4347
|
styles: customStyles,
|
|
4349
4348
|
tabSelectsValue: false,
|
|
4350
4349
|
blurInputOnSelect: !isMulti,
|
|
4351
|
-
menuPortalTarget: document.body,
|
|
4350
|
+
menuPortalTarget: props.menuPortalTarget || document.body,
|
|
4352
4351
|
isSearchable: disabled ? false : isSearchable,
|
|
4353
4352
|
menuShouldBlockScroll: true,
|
|
4354
4353
|
menuShouldScrollIntoView: true,
|
|
@@ -4364,13 +4363,6 @@ const Select = _a => {
|
|
|
4364
4363
|
onMenuScrollToBottom,
|
|
4365
4364
|
onInputChange
|
|
4366
4365
|
};
|
|
4367
|
-
const orderedOptions = React.useMemo(() => {
|
|
4368
|
-
return disabled ? getOrderedOptions(options, value).map(option => {
|
|
4369
|
-
return Object.assign(Object.assign({}, option), {
|
|
4370
|
-
disabled: true
|
|
4371
|
-
});
|
|
4372
|
-
}) : getOrderedOptions(options, value);
|
|
4373
|
-
}, [options, value, disabled]);
|
|
4374
4366
|
return jsxs(SelectContainer, Object.assign({
|
|
4375
4367
|
ref: refContainer,
|
|
4376
4368
|
className: className,
|
|
@@ -4383,29 +4375,18 @@ const Select = _a => {
|
|
|
4383
4375
|
ref: refPrefix
|
|
4384
4376
|
}, {
|
|
4385
4377
|
children: prefix
|
|
4386
|
-
})), async ? jsx(ReactAsyncSelect, Object.assign({}, selectProps, async, {
|
|
4387
|
-
onMenuOpen:
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
onMenuClose: () => {
|
|
4391
|
-
closeMenuHandler();
|
|
4392
|
-
}
|
|
4393
|
-
})) : jsx(ReactSelect, Object.assign({}, selectProps, {
|
|
4378
|
+
})), async ? jsx(ReactAsyncSelect, Object.assign({}, props, selectProps, async, {
|
|
4379
|
+
onMenuOpen: openMenuHandler,
|
|
4380
|
+
onMenuClose: closeMenuHandler
|
|
4381
|
+
})) : jsx(ReactSelect, Object.assign({}, props, selectProps, {
|
|
4394
4382
|
options: filterOption ? orderedOptions : options,
|
|
4395
4383
|
hideSelectedOptions: false,
|
|
4396
4384
|
isMulti: isMulti,
|
|
4397
|
-
onMenuOpen:
|
|
4398
|
-
|
|
4399
|
-
},
|
|
4400
|
-
onMenuClose: () => {
|
|
4401
|
-
closeMenuHandler();
|
|
4402
|
-
}
|
|
4385
|
+
onMenuOpen: openMenuHandler,
|
|
4386
|
+
onMenuClose: closeMenuHandler
|
|
4403
4387
|
}))]
|
|
4404
4388
|
}));
|
|
4405
4389
|
};
|
|
4406
|
-
const SelectPrefix = tw.div`
|
|
4407
|
-
tu-select__prefix
|
|
4408
|
-
`;
|
|
4409
4390
|
const SelectContainer = tw.div`
|
|
4410
4391
|
tu-select
|
|
4411
4392
|
${({
|
|
@@ -5382,4 +5363,4 @@ const Layout = tw.div`
|
|
|
5382
5363
|
tu-layout-TwoColumnLayout
|
|
5383
5364
|
`;
|
|
5384
5365
|
|
|
5385
|
-
export { ActionButton, Alert, AnimatedPopover, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Chart, Checkbox, Collapse, CopyableText, CreatableSelect, DateField, DateInput, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, FilterListMapLayout, FormGroup, FullWidthRepeatingLayout, GridArea, Heading, Icon$1 as Icon, IconButton, Indicator$1 as Indicator, IntrinsicallyResponsiveGrid, Label$3 as Label, LegendItem, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, MultiSelectMenuItem, NumberField, NumberInput, PageHeading, PopoverLifecycle, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, Select, SingleSelectMenuItem, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text$1 as Text, TextArea, TextAreaField, TextField, TextInput, Timeline, TimelineElement, Tip, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, ValueBar, activityColors, colors, criticalityColors, docs, generalColors, getOrderedOptions, getValueBarColorByValue, intentColors, isMultiValue, rentalStatusColors, useContainerProps, useCustomComponents, useDebounce, useLocalStorage, useModal, usePopover, usePrompt, useTimeout };
|
|
5366
|
+
export { ActionButton, Alert, AnimatedPopover, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Chart, Checkbox, Collapse, CopyableText, CreatableSelect, DateField, DateInput, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, FilterListMapLayout, FormGroup, FullWidthRepeatingLayout, GridArea, Heading, Icon$1 as Icon, IconButton, Indicator$1 as Indicator, IntrinsicallyResponsiveGrid, Label$3 as Label, LegendItem, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, MultiSelectMenuItem, NumberField, NumberInput, PageHeading, PopoverLifecycle, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, Select, SelectPrefix, SingleSelectMenuItem, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text$1 as Text, TextArea, TextAreaField, TextField, TextInput, Timeline, TimelineElement, Tip, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, ValueBar, activityColors, colors, criticalityColors, docs, generalColors, getOrderedOptions, getValueBarColorByValue, intentColors, isMultiValue, rentalStatusColors, useContainerProps, useCustomComponents, useDebounce, useLocalStorage, useModal, usePopover, usePrompt, useTimeout };
|
package/package.json
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.143",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@trackunit/css-core": "0.0.
|
|
8
|
-
"@trackunit/tailwind-styled-components": "0.0.
|
|
9
|
-
"react": "17.0.
|
|
10
|
-
"@trackunit/ui-design-tokens": "0.0.
|
|
7
|
+
"@trackunit/css-core": "0.0.51",
|
|
8
|
+
"@trackunit/tailwind-styled-components": "0.0.44",
|
|
9
|
+
"react": "17.0.2",
|
|
10
|
+
"@trackunit/ui-design-tokens": "0.0.43",
|
|
11
11
|
"echarts-for-react": "^3.0.2",
|
|
12
12
|
"uuid": "^8.3.2",
|
|
13
|
-
"
|
|
14
|
-
"react-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"react-useportal": "^1.0.16",
|
|
13
|
+
"react-use": "^17.4.0",
|
|
14
|
+
"react-day-picker": "^8.3.0",
|
|
15
|
+
"date-fns": "^2.29.3",
|
|
16
|
+
"@trackunit/ui-icons": "0.0.46",
|
|
17
|
+
"react-useportal": "1.0.16",
|
|
19
18
|
"react-helmet": "^6.1.0",
|
|
20
|
-
"@
|
|
21
|
-
"
|
|
22
|
-
"react-router-dom": "
|
|
19
|
+
"@react-spring/web": "9.5.2",
|
|
20
|
+
"@popperjs/core": "^2.11.6",
|
|
21
|
+
"react-router-dom": "6.4.1",
|
|
23
22
|
"react-select": "^5.4.0",
|
|
24
23
|
"jest-canvas-mock": "^2.4.0"
|
|
25
24
|
},
|