@trackunit/react-components 0.0.138 → 0.0.142
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/Alert/Alert.d.ts +4 -4
- package/components/DayPicker/DayPickerPopover.d.ts +3 -3
- 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/components/buttons/Button/Button.d.ts +2 -2
- package/components/buttons/shared/ButtonProps.d.ts +3 -2
- package/components/buttons/shared/helpers.d.ts +3 -3
- package/constants/colors.d.ts +2 -0
- package/index.css +13 -13
- package/index.js +268 -278
- package/package.json +13 -14
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';
|
|
@@ -164,7 +164,7 @@ const Container$9 = tw.div`
|
|
|
164
164
|
*/
|
|
165
165
|
|
|
166
166
|
const getStyles = () => ({
|
|
167
|
-
$
|
|
167
|
+
$color,
|
|
168
168
|
$variant
|
|
169
169
|
}) => {
|
|
170
170
|
const styles = {
|
|
@@ -183,7 +183,7 @@ const getStyles = () => ({
|
|
|
183
183
|
warning: tws`tu-button--transparent tu-button--transparent-warning`
|
|
184
184
|
}
|
|
185
185
|
};
|
|
186
|
-
return styles[$variant][$
|
|
186
|
+
return styles[$variant][$color];
|
|
187
187
|
};
|
|
188
188
|
/**
|
|
189
189
|
* Helper to get the needed classname for padding.
|
|
@@ -223,7 +223,7 @@ const Button = React.forwardRef((_a, ref) => {
|
|
|
223
223
|
fullWidth = false,
|
|
224
224
|
prefix,
|
|
225
225
|
suffix,
|
|
226
|
-
|
|
226
|
+
color = "primary",
|
|
227
227
|
variant = "filled",
|
|
228
228
|
type = "button",
|
|
229
229
|
size = "medium",
|
|
@@ -234,7 +234,7 @@ const Button = React.forwardRef((_a, ref) => {
|
|
|
234
234
|
tabIndex,
|
|
235
235
|
renderAs = "button"
|
|
236
236
|
} = _a,
|
|
237
|
-
rest = __rest(_a, ["onClick", "children", "loading", "disabled", "className", "fullWidth", "prefix", "suffix", "
|
|
237
|
+
rest = __rest(_a, ["onClick", "children", "loading", "disabled", "className", "fullWidth", "prefix", "suffix", "color", "variant", "type", "size", "square", "dataTestId", "title", "role", "tabIndex", "renderAs"]);
|
|
238
238
|
|
|
239
239
|
return jsxs(StyledButton$1, Object.assign({
|
|
240
240
|
"$as": renderAs,
|
|
@@ -242,7 +242,7 @@ const Button = React.forwardRef((_a, ref) => {
|
|
|
242
242
|
disabled: disabled || loading,
|
|
243
243
|
type: type,
|
|
244
244
|
className: className,
|
|
245
|
-
"$
|
|
245
|
+
"$color": color,
|
|
246
246
|
"$fullWidth": fullWidth,
|
|
247
247
|
"$variant": variant,
|
|
248
248
|
"$size": size,
|
|
@@ -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`
|
|
@@ -313,6 +313,7 @@ const IconContainer$2 = tw.div`
|
|
|
313
313
|
*/
|
|
314
314
|
const generalColors = {
|
|
315
315
|
PRIMARY: "primary",
|
|
316
|
+
SECONDARY: "secondary",
|
|
316
317
|
ACCENT: "accent",
|
|
317
318
|
NEUTRAL: "neutral"
|
|
318
319
|
};
|
|
@@ -443,6 +444,9 @@ const Root$4 = tw.span`
|
|
|
443
444
|
case colors.PRIMARY:
|
|
444
445
|
return tws`tu-icon--primary`;
|
|
445
446
|
|
|
447
|
+
case colors.SECONDARY:
|
|
448
|
+
return tws`tu-icon--secondary`;
|
|
449
|
+
|
|
446
450
|
case colors.ACCENT:
|
|
447
451
|
return tws`tu-icon--accent`;
|
|
448
452
|
|
|
@@ -535,7 +539,7 @@ const ActionButton = ({
|
|
|
535
539
|
children: jsx(StyledIconButton, {
|
|
536
540
|
dataTestId: "testIconButtonId",
|
|
537
541
|
size: "small",
|
|
538
|
-
|
|
542
|
+
color: "tertiary",
|
|
539
543
|
icon: jsx(Icon$1, {
|
|
540
544
|
size: "small",
|
|
541
545
|
name: getIconName()
|
|
@@ -547,7 +551,7 @@ const ActionButton = ({
|
|
|
547
551
|
const ActionContainer = tw.div`
|
|
548
552
|
tu-action-container
|
|
549
553
|
`;
|
|
550
|
-
const StyledIconButton =
|
|
554
|
+
const StyledIconButton = twx(IconButton)`
|
|
551
555
|
tu-action-button
|
|
552
556
|
`;
|
|
553
557
|
|
|
@@ -576,7 +580,7 @@ const Flex$2 = tw.div`
|
|
|
576
580
|
flex
|
|
577
581
|
items-center
|
|
578
582
|
`;
|
|
579
|
-
const CustomIcon =
|
|
583
|
+
const CustomIcon = twx(Icon$1)`
|
|
580
584
|
cursor-pointer
|
|
581
585
|
w-5
|
|
582
586
|
h-5
|
|
@@ -688,7 +692,7 @@ const StyledText$4 = tw.text`
|
|
|
688
692
|
*/
|
|
689
693
|
|
|
690
694
|
const Alert = ({
|
|
691
|
-
|
|
695
|
+
color = "info",
|
|
692
696
|
title,
|
|
693
697
|
className,
|
|
694
698
|
children,
|
|
@@ -701,8 +705,8 @@ const Alert = ({
|
|
|
701
705
|
}) => {
|
|
702
706
|
const ref = React.useRef();
|
|
703
707
|
|
|
704
|
-
const
|
|
705
|
-
switch (
|
|
708
|
+
const getIconFromColor = () => {
|
|
709
|
+
switch (color) {
|
|
706
710
|
case "danger":
|
|
707
711
|
return jsx(Icon$1, {
|
|
708
712
|
name: "ExclamationIcon",
|
|
@@ -728,8 +732,8 @@ const Alert = ({
|
|
|
728
732
|
}
|
|
729
733
|
};
|
|
730
734
|
|
|
731
|
-
const
|
|
732
|
-
switch (
|
|
735
|
+
const getButtonColor = () => {
|
|
736
|
+
switch (color) {
|
|
733
737
|
case "danger":
|
|
734
738
|
return "danger";
|
|
735
739
|
|
|
@@ -770,7 +774,7 @@ const Alert = ({
|
|
|
770
774
|
}
|
|
771
775
|
}, [ref, autoScroll]);
|
|
772
776
|
return jsxs(Container$8, Object.assign({
|
|
773
|
-
"$
|
|
777
|
+
"$color": color,
|
|
774
778
|
className: className,
|
|
775
779
|
"data-testid": dataTestId,
|
|
776
780
|
"$inline": inline,
|
|
@@ -780,7 +784,7 @@ const Alert = ({
|
|
|
780
784
|
children: [jsx(IconContainer$1, Object.assign({
|
|
781
785
|
"$inline": inline
|
|
782
786
|
}, {
|
|
783
|
-
children:
|
|
787
|
+
children: getIconFromColor()
|
|
784
788
|
})), jsxs(Content$1, Object.assign({
|
|
785
789
|
"$inline": inline
|
|
786
790
|
}, {
|
|
@@ -793,7 +797,7 @@ const Alert = ({
|
|
|
793
797
|
children: jsx(IconButton, {
|
|
794
798
|
size: "small",
|
|
795
799
|
variant: "transparent",
|
|
796
|
-
|
|
800
|
+
color: "secondary",
|
|
797
801
|
onClick: onClose,
|
|
798
802
|
icon: jsx(Icon$1, {
|
|
799
803
|
name: "XIcon",
|
|
@@ -809,14 +813,14 @@ const Alert = ({
|
|
|
809
813
|
children: [secondaryAction && jsx(Button, Object.assign({
|
|
810
814
|
size: "small",
|
|
811
815
|
variant: "transparent",
|
|
812
|
-
|
|
816
|
+
color: getButtonColor(),
|
|
813
817
|
onClick: secondaryAction.onClick,
|
|
814
818
|
loading: secondaryAction === null || secondaryAction === void 0 ? void 0 : secondaryAction.loading
|
|
815
819
|
}, {
|
|
816
820
|
children: secondaryAction.label
|
|
817
821
|
})), primaryAction && jsx(Button, Object.assign({
|
|
818
822
|
size: "small",
|
|
819
|
-
|
|
823
|
+
color: getButtonColor(),
|
|
820
824
|
onClick: primaryAction.onClick,
|
|
821
825
|
loading: primaryAction === null || primaryAction === void 0 ? void 0 : primaryAction.loading
|
|
822
826
|
}, {
|
|
@@ -827,7 +831,7 @@ const Alert = ({
|
|
|
827
831
|
children: jsx(IconButton, {
|
|
828
832
|
size: "small",
|
|
829
833
|
variant: "transparent",
|
|
830
|
-
|
|
834
|
+
color: "secondary",
|
|
831
835
|
onClick: onClose,
|
|
832
836
|
icon: jsx(Icon$1, {
|
|
833
837
|
name: "XIcon",
|
|
@@ -846,7 +850,7 @@ const CloseButtonContainer = tw.div`
|
|
|
846
850
|
`;
|
|
847
851
|
|
|
848
852
|
const getBackgroundColor = () => ({
|
|
849
|
-
$
|
|
853
|
+
$color
|
|
850
854
|
}) => {
|
|
851
855
|
const colors = {
|
|
852
856
|
danger: tws`tu-alert--danger`,
|
|
@@ -854,7 +858,7 @@ const getBackgroundColor = () => ({
|
|
|
854
858
|
success: tws`tu-alert--success`,
|
|
855
859
|
info: tws`tu-alert--info`
|
|
856
860
|
};
|
|
857
|
-
return colors[$
|
|
861
|
+
return colors[$color];
|
|
858
862
|
};
|
|
859
863
|
|
|
860
864
|
const Container$8 = tw.div`
|
|
@@ -871,7 +875,7 @@ const ContentDetails = tw.div`
|
|
|
871
875
|
const ContentBody = tw.div`
|
|
872
876
|
tu-alert__content-body
|
|
873
877
|
`;
|
|
874
|
-
const Description$2 =
|
|
878
|
+
const Description$2 = twx(Text$1)`
|
|
875
879
|
${p => p.$hasTitle ? tws`tu-alert__description` : null}
|
|
876
880
|
`;
|
|
877
881
|
const RightAligned = tw.div`
|
|
@@ -937,6 +941,7 @@ const getBadgeModifierClass = () => ({
|
|
|
937
941
|
}) => {
|
|
938
942
|
const colorClasses = {
|
|
939
943
|
primary: $subtle ? tws`tu-badge--primary-subtle` : tws`tu-badge--primary`,
|
|
944
|
+
secondary: $subtle ? tws`tu-badge--secondary-subtle` : tws`tu-badge--secondary`,
|
|
940
945
|
accent: $subtle ? tws`tu-badge--accent-subtle` : tws`tu-badge--accent`,
|
|
941
946
|
success: $subtle ? tws`tu-badge--success-subtle` : tws`tu-badge--success`,
|
|
942
947
|
danger: $subtle ? tws`tu-badge--danger-subtle` : tws`tu-badge--danger`,
|
|
@@ -1228,7 +1233,7 @@ const getOverflow = () => ({
|
|
|
1228
1233
|
return overflows[$overflow];
|
|
1229
1234
|
};
|
|
1230
1235
|
|
|
1231
|
-
const StyledDensityContainer =
|
|
1236
|
+
const StyledDensityContainer = twx(DensityContainer)`
|
|
1232
1237
|
${getOverflow()}
|
|
1233
1238
|
tu-card__body
|
|
1234
1239
|
`;
|
|
@@ -1258,7 +1263,7 @@ const CardFooter = ({
|
|
|
1258
1263
|
})
|
|
1259
1264
|
}));
|
|
1260
1265
|
};
|
|
1261
|
-
const TopBorderedDensityContainer =
|
|
1266
|
+
const TopBorderedDensityContainer = twx(DensityContainer)`
|
|
1262
1267
|
tu-card__footer-density-container
|
|
1263
1268
|
`;
|
|
1264
1269
|
const Body = tw.div`
|
|
@@ -1365,7 +1370,7 @@ const CardHeader = ({
|
|
|
1365
1370
|
}), onClose && jsx(IconButton, {
|
|
1366
1371
|
dataTestId: "card-header-close-button",
|
|
1367
1372
|
variant: "transparent",
|
|
1368
|
-
|
|
1373
|
+
color: "secondary",
|
|
1369
1374
|
onClick: onClose,
|
|
1370
1375
|
icon: jsx(Icon$1, {
|
|
1371
1376
|
name: "XIcon",
|
|
@@ -1375,7 +1380,7 @@ const CardHeader = ({
|
|
|
1375
1380
|
})
|
|
1376
1381
|
}));
|
|
1377
1382
|
};
|
|
1378
|
-
const BottomBorderedDensityContainer =
|
|
1383
|
+
const BottomBorderedDensityContainer = twx(DensityContainer)`
|
|
1379
1384
|
tu-card__header-density-container
|
|
1380
1385
|
`;
|
|
1381
1386
|
const Container$7 = tw.div`
|
|
@@ -1665,8 +1670,8 @@ const Checkbox = React.forwardRef((_a, ref) => {
|
|
|
1665
1670
|
})), children]
|
|
1666
1671
|
}));
|
|
1667
1672
|
});
|
|
1668
|
-
const StyledCheckIcon =
|
|
1669
|
-
const StyledIndeterminateIcon =
|
|
1673
|
+
const StyledCheckIcon = twx(CheckIcon)`tu-checkbox--icon`;
|
|
1674
|
+
const StyledIndeterminateIcon = twx(IndeterminateIcon)`tu-checkbox--icon`;
|
|
1670
1675
|
const CheckboxContainer = tw.label`tu-checkbox--container group`;
|
|
1671
1676
|
const HiddenInput$1 = tw.input`tu-checkbox--input`;
|
|
1672
1677
|
const CheckboxWrapper = tw.span`
|
|
@@ -1735,7 +1740,7 @@ const Collapse = ({
|
|
|
1735
1740
|
}),
|
|
1736
1741
|
size: "medium",
|
|
1737
1742
|
variant: "transparent",
|
|
1738
|
-
|
|
1743
|
+
color: "secondary"
|
|
1739
1744
|
})]
|
|
1740
1745
|
})
|
|
1741
1746
|
})), jsx(Collapsible, Object.assign({
|
|
@@ -1746,7 +1751,7 @@ const Collapse = ({
|
|
|
1746
1751
|
}))]
|
|
1747
1752
|
}));
|
|
1748
1753
|
};
|
|
1749
|
-
const Rotate =
|
|
1754
|
+
const Rotate = twx(Icon$1)`
|
|
1750
1755
|
${p => p.$expanded ? tws`tu-icon--animated-rotate-expanded` : null}
|
|
1751
1756
|
tu-icon--animated-rotate
|
|
1752
1757
|
`;
|
|
@@ -1768,25 +1773,11 @@ const Collapsible = ({
|
|
|
1768
1773
|
const [ref, {
|
|
1769
1774
|
height
|
|
1770
1775
|
}] = useMeasure();
|
|
1771
|
-
const props = useSpring({
|
|
1772
|
-
config: {
|
|
1773
|
-
tension: expanded ? 2000 : 1500,
|
|
1774
|
-
friction: 100,
|
|
1775
|
-
precision: 0.01
|
|
1776
|
-
},
|
|
1777
|
-
from: {
|
|
1778
|
-
height: 0
|
|
1779
|
-
},
|
|
1780
|
-
to: expanded ? {
|
|
1781
|
-
// We add 8 pixels to the bottom to prevent overflow issues.
|
|
1782
|
-
height: height + 8
|
|
1783
|
-
} : {
|
|
1784
|
-
height: 0
|
|
1785
|
-
}
|
|
1786
|
-
});
|
|
1787
1776
|
return jsx(AnimatedCollapsible, Object.assign({
|
|
1788
1777
|
id: id,
|
|
1789
|
-
style:
|
|
1778
|
+
style: {
|
|
1779
|
+
height: expanded ? height : "0"
|
|
1780
|
+
}
|
|
1790
1781
|
}, {
|
|
1791
1782
|
children: jsx(StyledCollapsible, Object.assign({
|
|
1792
1783
|
ref: ref
|
|
@@ -1796,7 +1787,7 @@ const Collapsible = ({
|
|
|
1796
1787
|
}));
|
|
1797
1788
|
};
|
|
1798
1789
|
|
|
1799
|
-
const AnimatedCollapsible = tw
|
|
1790
|
+
const AnimatedCollapsible = tw.div`
|
|
1800
1791
|
tu-collapsible--animated
|
|
1801
1792
|
`;
|
|
1802
1793
|
const StyledCollapsible = tw.div`
|
|
@@ -2101,7 +2092,7 @@ const PopoverList = ({
|
|
|
2101
2092
|
const List = tw.ul`
|
|
2102
2093
|
tu-popover-list
|
|
2103
2094
|
`;
|
|
2104
|
-
const StyledCardBody =
|
|
2095
|
+
const StyledCardBody = twx(CardBody)`
|
|
2105
2096
|
tu-popover-list-body
|
|
2106
2097
|
`;
|
|
2107
2098
|
|
|
@@ -2161,7 +2152,7 @@ const DateInput = forwardRef((_a, ref) => {
|
|
|
2161
2152
|
}),
|
|
2162
2153
|
actions: selectedDay && jsx(RemoveValueContainer, {
|
|
2163
2154
|
children: jsx(Button, Object.assign({
|
|
2164
|
-
|
|
2155
|
+
color: "tertiary",
|
|
2165
2156
|
onClick: e => {
|
|
2166
2157
|
e.preventDefault();
|
|
2167
2158
|
setSelectedDay(undefined);
|
|
@@ -2249,7 +2240,7 @@ const PopoverListItem = ({
|
|
|
2249
2240
|
})) : content
|
|
2250
2241
|
}));
|
|
2251
2242
|
};
|
|
2252
|
-
const StyledText$2 =
|
|
2243
|
+
const StyledText$2 = twx(Text$1)`
|
|
2253
2244
|
tu-popover-list-item__text
|
|
2254
2245
|
${p => p.$selected && tws`tu-popover-list-item__text--selected`}
|
|
2255
2246
|
`;
|
|
@@ -2296,7 +2287,7 @@ const Container$6 = tw.div`
|
|
|
2296
2287
|
tu-popover-title-container
|
|
2297
2288
|
${p => p.$divider && `tu-popover-title-container--divider`}
|
|
2298
2289
|
`;
|
|
2299
|
-
const StyledText$1 =
|
|
2290
|
+
const StyledText$1 = twx(Text$1)`
|
|
2300
2291
|
tu-popover-title-text
|
|
2301
2292
|
`;
|
|
2302
2293
|
|
|
@@ -2365,7 +2356,7 @@ const Tooltip = ({
|
|
|
2365
2356
|
const Flex$1 = tw.div`
|
|
2366
2357
|
inline-flex
|
|
2367
2358
|
`;
|
|
2368
|
-
const Container$5 =
|
|
2359
|
+
const Container$5 = twx(AnimatedPopover)`
|
|
2369
2360
|
tu-tooltip__container
|
|
2370
2361
|
`;
|
|
2371
2362
|
const Content = tw.div`
|
|
@@ -2537,7 +2528,7 @@ const DayPickerPopover = ({
|
|
|
2537
2528
|
className,
|
|
2538
2529
|
selectedDay,
|
|
2539
2530
|
onDaySelect,
|
|
2540
|
-
|
|
2531
|
+
color = "secondary",
|
|
2541
2532
|
placement = "bottom",
|
|
2542
2533
|
size = "small",
|
|
2543
2534
|
buttonContent,
|
|
@@ -2558,7 +2549,7 @@ const DayPickerPopover = ({
|
|
|
2558
2549
|
});
|
|
2559
2550
|
return jsxs(Fragment$1, {
|
|
2560
2551
|
children: [jsx(Button, Object.assign({
|
|
2561
|
-
|
|
2552
|
+
color: color,
|
|
2562
2553
|
size: size,
|
|
2563
2554
|
className: className,
|
|
2564
2555
|
prefix: jsx(Icon$1, {
|
|
@@ -2690,6 +2681,9 @@ const Container$4 = tw.div`
|
|
|
2690
2681
|
case colors.PRIMARY:
|
|
2691
2682
|
return tws`tu-indicator--primary`;
|
|
2692
2683
|
|
|
2684
|
+
case colors.SECONDARY:
|
|
2685
|
+
return tws`tu-indicator--secondary`;
|
|
2686
|
+
|
|
2693
2687
|
case colors.ACCENT:
|
|
2694
2688
|
return tws`tu-indicator--accent`;
|
|
2695
2689
|
|
|
@@ -2946,44 +2940,31 @@ const ModalBackdrop = ({
|
|
|
2946
2940
|
isVisible,
|
|
2947
2941
|
onClick
|
|
2948
2942
|
}) => {
|
|
2949
|
-
const transitions = useTransition(isVisible, {
|
|
2950
|
-
from: {
|
|
2951
|
-
opacity: 0
|
|
2952
|
-
},
|
|
2953
|
-
enter: {
|
|
2954
|
-
opacity: 1
|
|
2955
|
-
},
|
|
2956
|
-
leave: {
|
|
2957
|
-
opacity: 0
|
|
2958
|
-
},
|
|
2959
|
-
config: {
|
|
2960
|
-
tension: 300,
|
|
2961
|
-
friction: 30,
|
|
2962
|
-
precision: 0.1
|
|
2963
|
-
}
|
|
2964
|
-
});
|
|
2965
2943
|
const ref = React.useRef(null);
|
|
2966
|
-
return jsx(
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
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
|
|
2971
2949
|
|
|
2972
2950
|
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
}
|
|
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();
|
|
2977
2954
|
}
|
|
2978
|
-
}
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
});
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
}, {
|
|
2958
|
+
children: children
|
|
2959
|
+
}));
|
|
2984
2960
|
};
|
|
2985
|
-
const Backdrop = tw
|
|
2961
|
+
const Backdrop = tw.div`
|
|
2986
2962
|
tu-modal-backdrop
|
|
2963
|
+
${({
|
|
2964
|
+
$isVisible
|
|
2965
|
+
}) => {
|
|
2966
|
+
return $isVisible && tws`tu-modal-backdrop--show`;
|
|
2967
|
+
}}
|
|
2987
2968
|
`;
|
|
2988
2969
|
|
|
2989
2970
|
/**
|
|
@@ -3002,32 +2983,12 @@ const Modal = React.forwardRef(({
|
|
|
3002
2983
|
return;
|
|
3003
2984
|
}
|
|
3004
2985
|
}, ref) => {
|
|
3005
|
-
const transitions = useTransition(isOpen, {
|
|
3006
|
-
from: {
|
|
3007
|
-
opacity: 0,
|
|
3008
|
-
transform: "scale(0.9)"
|
|
3009
|
-
},
|
|
3010
|
-
enter: {
|
|
3011
|
-
opacity: 1,
|
|
3012
|
-
transform: "scale(1)"
|
|
3013
|
-
},
|
|
3014
|
-
leave: {
|
|
3015
|
-
opacity: 0,
|
|
3016
|
-
transform: "scale(0.9)"
|
|
3017
|
-
},
|
|
3018
|
-
config: {
|
|
3019
|
-
tension: 300,
|
|
3020
|
-
friction: 30,
|
|
3021
|
-
precision: 0.1
|
|
3022
|
-
}
|
|
3023
|
-
});
|
|
3024
2986
|
return jsx(ModalBackdrop, Object.assign({
|
|
3025
2987
|
isVisible: isOpen,
|
|
3026
2988
|
onClick: onDismissClick
|
|
3027
2989
|
}, {
|
|
3028
|
-
children:
|
|
3029
|
-
ref: ref
|
|
3030
|
-
style: props
|
|
2990
|
+
children: isOpen && jsx(StyledDiv, Object.assign({
|
|
2991
|
+
ref: ref
|
|
3031
2992
|
}, {
|
|
3032
2993
|
children: jsx(StyledCard, Object.assign({
|
|
3033
2994
|
dataTestId: dataTestId,
|
|
@@ -3036,7 +2997,7 @@ const Modal = React.forwardRef(({
|
|
|
3036
2997
|
}, {
|
|
3037
2998
|
children: children
|
|
3038
2999
|
}))
|
|
3039
|
-
}))
|
|
3000
|
+
}))
|
|
3040
3001
|
}));
|
|
3041
3002
|
});
|
|
3042
3003
|
|
|
@@ -3054,14 +3015,13 @@ const getCardMaxWidth = () => ({
|
|
|
3054
3015
|
return widths[maxWidth];
|
|
3055
3016
|
};
|
|
3056
3017
|
|
|
3057
|
-
const StyledCard =
|
|
3018
|
+
const StyledCard = twx(Card)`
|
|
3058
3019
|
tu-modal__card
|
|
3059
3020
|
${getCardMaxWidth()}
|
|
3060
3021
|
`;
|
|
3061
3022
|
const StyledDiv = tw.div`
|
|
3062
3023
|
tu-modal__container
|
|
3063
3024
|
`;
|
|
3064
|
-
const AnimatedDiv = animated(StyledDiv);
|
|
3065
3025
|
|
|
3066
3026
|
/**
|
|
3067
3027
|
* The useModal component should be used to inform the user of important information.
|
|
@@ -3275,6 +3235,7 @@ const getColorModifierClass = () => ({
|
|
|
3275
3235
|
}) => {
|
|
3276
3236
|
const colorClasses = {
|
|
3277
3237
|
primary: tws`tu-tag--primary`,
|
|
3238
|
+
secondary: tws`tu-tag--secondary`,
|
|
3278
3239
|
accent: tws`tu-tag--accent`,
|
|
3279
3240
|
success: tws`tu-tag--success`,
|
|
3280
3241
|
danger: tws`tu-tag--danger`,
|
|
@@ -3292,7 +3253,7 @@ const getColorModifierClass = () => ({
|
|
|
3292
3253
|
return colorClasses[$color];
|
|
3293
3254
|
};
|
|
3294
3255
|
|
|
3295
|
-
const StyledText = tw.
|
|
3256
|
+
const StyledText = tw.span`
|
|
3296
3257
|
tu-tag
|
|
3297
3258
|
${getSizeModifierClass()}
|
|
3298
3259
|
${getColorModifierClass()}
|
|
@@ -3347,40 +3308,29 @@ const StyledFlex = tw.div`
|
|
|
3347
3308
|
gap-2
|
|
3348
3309
|
`;
|
|
3349
3310
|
|
|
3350
|
-
function
|
|
3351
|
-
return useContext(UNSAFE_LocationContext) !== null;
|
|
3352
|
-
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
function invariant(cond, message) {
|
|
3356
|
-
if (!cond) {
|
|
3357
|
-
throw new Error(message);
|
|
3358
|
-
}
|
|
3359
|
-
}
|
|
3360
|
-
|
|
3361
|
-
function useBlocker(blocker, when = true) {
|
|
3362
|
-
invariant(useInRouterContext(), `useBlocker() may be used only in the context of a <Router> component.`);
|
|
3311
|
+
function useConfirmExit(confirmExit, when = true) {
|
|
3363
3312
|
const {
|
|
3364
3313
|
navigator
|
|
3365
3314
|
} = useContext(UNSAFE_NavigationContext);
|
|
3366
3315
|
useEffect(() => {
|
|
3367
3316
|
if (!when) {
|
|
3368
3317
|
return;
|
|
3369
|
-
}
|
|
3318
|
+
}
|
|
3370
3319
|
|
|
3320
|
+
const push = navigator.push;
|
|
3371
3321
|
|
|
3372
|
-
|
|
3373
|
-
const
|
|
3374
|
-
retry() {
|
|
3375
|
-
unblock();
|
|
3376
|
-
tx.retry();
|
|
3377
|
-
}
|
|
3322
|
+
navigator.push = (...args) => {
|
|
3323
|
+
const result = confirmExit();
|
|
3378
3324
|
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3325
|
+
if (result !== false) {
|
|
3326
|
+
push(...args);
|
|
3327
|
+
}
|
|
3328
|
+
};
|
|
3329
|
+
|
|
3330
|
+
return () => {
|
|
3331
|
+
navigator.push = push;
|
|
3332
|
+
};
|
|
3333
|
+
}, [navigator, confirmExit, when]);
|
|
3384
3334
|
}
|
|
3385
3335
|
/**
|
|
3386
3336
|
* The usePrompt hook.
|
|
@@ -3391,14 +3341,24 @@ function useBlocker(blocker, when = true) {
|
|
|
3391
3341
|
*/
|
|
3392
3342
|
|
|
3393
3343
|
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
if (
|
|
3397
|
-
|
|
3344
|
+
const usePrompt = (message, when = true) => {
|
|
3345
|
+
useEffect(() => {
|
|
3346
|
+
if (when) {
|
|
3347
|
+
window.onbeforeunload = function () {
|
|
3348
|
+
return message;
|
|
3349
|
+
};
|
|
3398
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;
|
|
3399
3359
|
}, [message]);
|
|
3400
|
-
|
|
3401
|
-
}
|
|
3360
|
+
useConfirmExit(confirmExit, when);
|
|
3361
|
+
};
|
|
3402
3362
|
/**
|
|
3403
3363
|
* The Prompt function.
|
|
3404
3364
|
*
|
|
@@ -3590,7 +3550,7 @@ const Container$1 = tw.label`
|
|
|
3590
3550
|
$isDisabled
|
|
3591
3551
|
}) => $isDisabled ? tws`tu-select--disabled` : null}
|
|
3592
3552
|
`;
|
|
3593
|
-
const InformativeText =
|
|
3553
|
+
const InformativeText = twx(Text$1)`
|
|
3594
3554
|
tu-informative-text
|
|
3595
3555
|
${p => p.$hasError ? `tu-informative-text--error` : null}
|
|
3596
3556
|
`;
|
|
@@ -3599,6 +3559,7 @@ const InformativeText = tw(Text$1)`
|
|
|
3599
3559
|
* @param {MultiValue<Option> | SingleValue<Option>} arg option to check type
|
|
3600
3560
|
* @returns {arg is MultiValue<Option> } is Multivalue
|
|
3601
3561
|
*/
|
|
3562
|
+
|
|
3602
3563
|
function isMultiValue(arg) {
|
|
3603
3564
|
return Array.isArray(arg);
|
|
3604
3565
|
}
|
|
@@ -3646,6 +3607,9 @@ const getOrderedOptions = (options, value) => {
|
|
|
3646
3607
|
|
|
3647
3608
|
return options || [];
|
|
3648
3609
|
};
|
|
3610
|
+
const SelectPrefix = tw.div`
|
|
3611
|
+
tu-select__prefix
|
|
3612
|
+
`;
|
|
3649
3613
|
|
|
3650
3614
|
/**
|
|
3651
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
|
|
@@ -4128,48 +4092,55 @@ const useCustomStyles = (refContainer, refPrefix, maxSelectedDisplayCount, style
|
|
|
4128
4092
|
};
|
|
4129
4093
|
|
|
4130
4094
|
/**
|
|
4131
|
-
*
|
|
4095
|
+
* A hook used by selects to share the common code
|
|
4132
4096
|
*
|
|
4133
|
-
* @param {
|
|
4134
|
-
* @returns {
|
|
4097
|
+
* @param {SelectProps} props - The props for the Select component
|
|
4098
|
+
* @returns {IUseSelect} Select component
|
|
4135
4099
|
*/
|
|
4136
4100
|
|
|
4137
|
-
const
|
|
4101
|
+
const useSelect = _a => {
|
|
4102
|
+
var _b;
|
|
4103
|
+
|
|
4138
4104
|
var {
|
|
4139
|
-
dataTestId = "createableSelect",
|
|
4140
4105
|
id,
|
|
4106
|
+
className,
|
|
4107
|
+
dataTestId = "select",
|
|
4108
|
+
prefix,
|
|
4109
|
+
async,
|
|
4110
|
+
dropdownIcon,
|
|
4111
|
+
maxMenuHeight = 200,
|
|
4141
4112
|
label,
|
|
4142
|
-
|
|
4143
|
-
description,
|
|
4144
|
-
error,
|
|
4145
|
-
info,
|
|
4146
|
-
isInvalid,
|
|
4147
|
-
maxMenuHeight = 308,
|
|
4148
|
-
components,
|
|
4113
|
+
hasError,
|
|
4149
4114
|
disabled,
|
|
4150
|
-
|
|
4115
|
+
isMulti,
|
|
4116
|
+
components,
|
|
4151
4117
|
value,
|
|
4118
|
+
options,
|
|
4152
4119
|
onChange,
|
|
4153
|
-
isMulti,
|
|
4154
|
-
classNamePrefix,
|
|
4155
4120
|
isLoading,
|
|
4156
|
-
|
|
4121
|
+
classNamePrefix = "",
|
|
4157
4122
|
onMenuOpen,
|
|
4158
|
-
|
|
4123
|
+
onMenuClose,
|
|
4124
|
+
maxSelectedDisplayCount = undefined,
|
|
4125
|
+
isClearable = false,
|
|
4126
|
+
isSearchable = true,
|
|
4127
|
+
onMenuScrollToBottom,
|
|
4128
|
+
styles,
|
|
4129
|
+
filterOption,
|
|
4130
|
+
onInputChange
|
|
4159
4131
|
} = _a,
|
|
4160
|
-
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"]);
|
|
4161
4133
|
|
|
4162
|
-
const hasError = !!error;
|
|
4163
4134
|
const refContainer = React__default.useRef(null);
|
|
4164
4135
|
const refPrefix = React__default.useRef(null);
|
|
4165
|
-
const [menuIsOpen, setMenuIsOpen] = React__default.useState(false);
|
|
4166
|
-
const [menuIsClosing, setMenuIsClosing] = React__default.useState(false);
|
|
4167
|
-
const refMenuIsEnabled = React__default.useRef(true);
|
|
4168
4136
|
const {
|
|
4169
4137
|
customStyles
|
|
4170
|
-
} = 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);
|
|
4171
4143
|
const menuPlacement = "auto";
|
|
4172
|
-
const customComponents = useCustomComponents(components, disabled || false, menuIsClosing, refMenuIsEnabled, dataTestId, undefined);
|
|
4173
4144
|
|
|
4174
4145
|
const openMenuHandler = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
4175
4146
|
onMenuOpen && onMenuOpen();
|
|
@@ -4185,12 +4156,78 @@ const CreatableSelect = _a => {
|
|
|
4185
4156
|
const closeMenuHandler = () => {
|
|
4186
4157
|
if (refMenuIsEnabled.current) {
|
|
4187
4158
|
setMenuIsClosing(true);
|
|
4188
|
-
setTimeout(() => {
|
|
4189
|
-
setMenuIsOpen(false);
|
|
4190
|
-
}, 250);
|
|
4191
4159
|
}
|
|
4160
|
+
|
|
4161
|
+
onMenuClose && onMenuClose();
|
|
4162
|
+
};
|
|
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
|
|
4192
4189
|
};
|
|
4190
|
+
};
|
|
4193
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);
|
|
4194
4231
|
const selectProps = {
|
|
4195
4232
|
value,
|
|
4196
4233
|
menuPlacement,
|
|
@@ -4226,32 +4263,35 @@ const CreatableSelect = _a => {
|
|
|
4226
4263
|
dataTestId: dataTestId,
|
|
4227
4264
|
isDisabled: disabled
|
|
4228
4265
|
}, {
|
|
4229
|
-
children:
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
}
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
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
|
+
})
|
|
4255
4295
|
}));
|
|
4256
4296
|
};
|
|
4257
4297
|
|
|
@@ -4262,72 +4302,40 @@ const CreatableSelect = _a => {
|
|
|
4262
4302
|
* @returns {JSX.Element} Select component
|
|
4263
4303
|
*/
|
|
4264
4304
|
|
|
4265
|
-
const Select =
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
var {
|
|
4305
|
+
const Select = props => {
|
|
4306
|
+
const {
|
|
4269
4307
|
id,
|
|
4270
4308
|
className,
|
|
4271
4309
|
dataTestId = "select",
|
|
4272
4310
|
prefix,
|
|
4273
4311
|
async,
|
|
4274
|
-
dropdownIcon,
|
|
4275
4312
|
maxMenuHeight = 200,
|
|
4276
4313
|
label,
|
|
4277
4314
|
hasError,
|
|
4278
4315
|
disabled,
|
|
4279
4316
|
isMulti,
|
|
4280
|
-
components,
|
|
4281
4317
|
value,
|
|
4282
4318
|
options,
|
|
4283
4319
|
onChange,
|
|
4284
4320
|
isLoading,
|
|
4285
4321
|
classNamePrefix = "",
|
|
4286
|
-
onMenuOpen,
|
|
4287
|
-
onMenuClose,
|
|
4288
|
-
maxSelectedDisplayCount = undefined,
|
|
4289
|
-
isClearable = false,
|
|
4290
|
-
isSearchable = true,
|
|
4291
4322
|
onMenuScrollToBottom,
|
|
4292
|
-
styles,
|
|
4293
4323
|
filterOption,
|
|
4294
|
-
onInputChange
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
const refContainer = React.useRef(null);
|
|
4299
|
-
const refPrefix = React.useRef(null);
|
|
4324
|
+
onInputChange,
|
|
4325
|
+
isSearchable,
|
|
4326
|
+
isClearable
|
|
4327
|
+
} = props;
|
|
4300
4328
|
const {
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
if (refMenuIsEnabled.current) {
|
|
4313
|
-
setMenuIsClosing(false);
|
|
4314
|
-
yield setMenuIsOpen(true);
|
|
4315
|
-
} else {
|
|
4316
|
-
refMenuIsEnabled.current = true;
|
|
4317
|
-
}
|
|
4318
|
-
});
|
|
4319
|
-
|
|
4320
|
-
const closeMenuHandler = () => {
|
|
4321
|
-
if (refMenuIsEnabled.current) {
|
|
4322
|
-
setMenuIsClosing(true);
|
|
4323
|
-
setTimeout(() => {
|
|
4324
|
-
setMenuIsOpen(false);
|
|
4325
|
-
}, 250);
|
|
4326
|
-
}
|
|
4327
|
-
|
|
4328
|
-
onMenuClose && onMenuClose();
|
|
4329
|
-
};
|
|
4330
|
-
|
|
4329
|
+
refContainer,
|
|
4330
|
+
refPrefix,
|
|
4331
|
+
customStyles,
|
|
4332
|
+
menuIsOpen,
|
|
4333
|
+
customComponents,
|
|
4334
|
+
menuPlacement,
|
|
4335
|
+
openMenuHandler,
|
|
4336
|
+
closeMenuHandler,
|
|
4337
|
+
orderedOptions
|
|
4338
|
+
} = useSelect(props);
|
|
4331
4339
|
const selectProps = {
|
|
4332
4340
|
value,
|
|
4333
4341
|
menuPlacement,
|
|
@@ -4339,7 +4347,7 @@ const Select = _a => {
|
|
|
4339
4347
|
styles: customStyles,
|
|
4340
4348
|
tabSelectsValue: false,
|
|
4341
4349
|
blurInputOnSelect: !isMulti,
|
|
4342
|
-
menuPortalTarget: document.body,
|
|
4350
|
+
menuPortalTarget: props.menuPortalTarget || document.body,
|
|
4343
4351
|
isSearchable: disabled ? false : isSearchable,
|
|
4344
4352
|
menuShouldBlockScroll: true,
|
|
4345
4353
|
menuShouldScrollIntoView: true,
|
|
@@ -4355,13 +4363,6 @@ const Select = _a => {
|
|
|
4355
4363
|
onMenuScrollToBottom,
|
|
4356
4364
|
onInputChange
|
|
4357
4365
|
};
|
|
4358
|
-
const orderedOptions = React.useMemo(() => {
|
|
4359
|
-
return disabled ? getOrderedOptions(options, value).map(option => {
|
|
4360
|
-
return Object.assign(Object.assign({}, option), {
|
|
4361
|
-
disabled: true
|
|
4362
|
-
});
|
|
4363
|
-
}) : getOrderedOptions(options, value);
|
|
4364
|
-
}, [options, value, disabled]);
|
|
4365
4366
|
return jsxs(SelectContainer, Object.assign({
|
|
4366
4367
|
ref: refContainer,
|
|
4367
4368
|
className: className,
|
|
@@ -4374,29 +4375,18 @@ const Select = _a => {
|
|
|
4374
4375
|
ref: refPrefix
|
|
4375
4376
|
}, {
|
|
4376
4377
|
children: prefix
|
|
4377
|
-
})), async ? jsx(ReactAsyncSelect, Object.assign({}, selectProps, async, {
|
|
4378
|
-
onMenuOpen:
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
onMenuClose: () => {
|
|
4382
|
-
closeMenuHandler();
|
|
4383
|
-
}
|
|
4384
|
-
})) : 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, {
|
|
4385
4382
|
options: filterOption ? orderedOptions : options,
|
|
4386
4383
|
hideSelectedOptions: false,
|
|
4387
4384
|
isMulti: isMulti,
|
|
4388
|
-
onMenuOpen:
|
|
4389
|
-
|
|
4390
|
-
},
|
|
4391
|
-
onMenuClose: () => {
|
|
4392
|
-
closeMenuHandler();
|
|
4393
|
-
}
|
|
4385
|
+
onMenuOpen: openMenuHandler,
|
|
4386
|
+
onMenuClose: closeMenuHandler
|
|
4394
4387
|
}))]
|
|
4395
4388
|
}));
|
|
4396
4389
|
};
|
|
4397
|
-
const SelectPrefix = tw.div`
|
|
4398
|
-
tu-select__prefix
|
|
4399
|
-
`;
|
|
4400
4390
|
const SelectContainer = tw.div`
|
|
4401
4391
|
tu-select
|
|
4402
4392
|
${({
|
|
@@ -5373,4 +5363,4 @@ const Layout = tw.div`
|
|
|
5373
5363
|
tu-layout-TwoColumnLayout
|
|
5374
5364
|
`;
|
|
5375
5365
|
|
|
5376
|
-
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 };
|