@trackunit/react-components 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import EChart from 'echarts-for-react';
|
|
|
7
7
|
import { v4 } from 'uuid';
|
|
8
8
|
import { useMeasure, useCopyToClipboard } from 'react-use';
|
|
9
9
|
import { format, formatDistance } from 'date-fns';
|
|
10
|
-
import { useFloating, offset, shift, flip, autoUpdate, useInteractions, useClick, useHover, useRole, useDismiss, FloatingPortal, FloatingFocusManager } from '@floating-ui/react
|
|
10
|
+
import { useFloating, offset, shift, flip, autoUpdate, useInteractions, useClick, useHover, useRole, useDismiss, FloatingPortal, FloatingFocusManager } from '@floating-ui/react';
|
|
11
11
|
import { Link, UNSAFE_NavigationContext } from 'react-router-dom';
|
|
12
12
|
import { DayPicker as DayPicker$1 } from 'react-day-picker';
|
|
13
13
|
import { enGB, enUS, da, de, cs, nl, fr, fi, hu, it, nb, pl, pt, ru, ro, es, sv, ja, th } from 'date-fns/locale';
|
|
@@ -4053,14 +4053,14 @@ tu-select__counter
|
|
|
4053
4053
|
* @template Group
|
|
4054
4054
|
* @param {Partial<SelectComponents<Option, IsMulti, Group>> | undefined} componentsProps a custom component prop that you can to override defaults
|
|
4055
4055
|
* @param {boolean} disabled decide to override disabled variant
|
|
4056
|
-
* @param {boolean}
|
|
4056
|
+
* @param {boolean} menuIsOpen menu is open state
|
|
4057
4057
|
* @param {React.MutableRefObject<boolean>} refMenuIsEnabled a flag to block menu from open
|
|
4058
4058
|
* @param {string} dataTestId a test id
|
|
4059
4059
|
* @param {number} maxSelectedDisplayCount a number of max display count
|
|
4060
4060
|
* @param {JSX.Element} dropdownIcon an custom dropdown icon
|
|
4061
4061
|
* @returns {Partial<SelectComponents<Option, boolean, GroupBase<Option>>> | undefined} components object to override react-select default components
|
|
4062
4062
|
*/
|
|
4063
|
-
const useCustomComponents = (componentsProps, disabled,
|
|
4063
|
+
const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon) => {
|
|
4064
4064
|
const customComponents = React.useMemo(() => {
|
|
4065
4065
|
return Object.assign({
|
|
4066
4066
|
ValueContainer: props => {
|
|
@@ -4131,11 +4131,11 @@ const useCustomComponents = (componentsProps, disabled, menuIsClosing, refMenuIs
|
|
|
4131
4131
|
DropdownIndicator: props => {
|
|
4132
4132
|
return props.selectProps.isLoading ? null : jsx(components.DropdownIndicator, Object.assign({}, props, {
|
|
4133
4133
|
children: jsx(StyledIcon, {
|
|
4134
|
-
children: dropdownIcon ? dropdownIcon :
|
|
4135
|
-
name: "
|
|
4134
|
+
children: dropdownIcon ? dropdownIcon : menuIsOpen ? jsx(Icon$1, {
|
|
4135
|
+
name: "ChevronUpIcon",
|
|
4136
4136
|
size: "medium"
|
|
4137
4137
|
}) : jsx(Icon$1, {
|
|
4138
|
-
name: "
|
|
4138
|
+
name: "ChevronDownIcon",
|
|
4139
4139
|
size: "medium"
|
|
4140
4140
|
})
|
|
4141
4141
|
})
|
|
@@ -4179,7 +4179,7 @@ const useCustomComponents = (componentsProps, disabled, menuIsClosing, refMenuIs
|
|
|
4179
4179
|
},
|
|
4180
4180
|
Menu: props => {
|
|
4181
4181
|
return jsx(components.Menu, Object.assign({}, props, {
|
|
4182
|
-
className:
|
|
4182
|
+
className: menuIsOpen ? tws`tu-select__menu-list animate-fade-in-fast` : tws`tu-select__menu-list animate-fade-out-fast`
|
|
4183
4183
|
}));
|
|
4184
4184
|
},
|
|
4185
4185
|
Option: props => {
|
|
@@ -4206,7 +4206,7 @@ const useCustomComponents = (componentsProps, disabled, menuIsClosing, refMenuIs
|
|
|
4206
4206
|
}
|
|
4207
4207
|
}, componentsProps);
|
|
4208
4208
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4209
|
-
}, [componentsProps, disabled,
|
|
4209
|
+
}, [componentsProps, disabled, menuIsOpen, refMenuIsEnabled, maxSelectedDisplayCount]); // do not add dropdownIcon (it will cause issue with opening/closing list for selects with custom icon)
|
|
4210
4210
|
return customComponents;
|
|
4211
4211
|
};
|
|
4212
4212
|
const StyledIcon = tw.div`
|
|
@@ -4351,33 +4351,21 @@ const useSelect = _a => {
|
|
|
4351
4351
|
customStyles
|
|
4352
4352
|
} = useCustomStyles(refContainer, refPrefix, maxSelectedDisplayCount, styles);
|
|
4353
4353
|
const [menuIsOpen, setMenuIsOpen] = React__default.useState((_b = props.menuIsOpen) !== null && _b !== void 0 ? _b : false);
|
|
4354
|
-
const [menuIsClosing, setMenuIsClosing] = React__default.useState(true);
|
|
4355
4354
|
const refMenuIsEnabled = React__default.useRef(true);
|
|
4356
|
-
const customComponents = useCustomComponents(components, disabled || false,
|
|
4355
|
+
const customComponents = useCustomComponents(components, disabled || false, menuIsOpen, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon);
|
|
4357
4356
|
const menuPlacement = "auto";
|
|
4358
4357
|
const openMenuHandler = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
4359
4358
|
onMenuOpen && onMenuOpen();
|
|
4360
4359
|
if (refMenuIsEnabled.current) {
|
|
4361
|
-
|
|
4362
|
-
yield setMenuIsOpen(true);
|
|
4360
|
+
setMenuIsOpen(true);
|
|
4363
4361
|
} else {
|
|
4364
4362
|
refMenuIsEnabled.current = true;
|
|
4365
4363
|
}
|
|
4366
4364
|
});
|
|
4367
4365
|
const closeMenuHandler = () => {
|
|
4368
|
-
|
|
4369
|
-
setMenuIsClosing(true);
|
|
4370
|
-
}
|
|
4366
|
+
setMenuIsOpen(false);
|
|
4371
4367
|
onMenuClose && onMenuClose();
|
|
4372
4368
|
};
|
|
4373
|
-
React__default.useEffect(() => {
|
|
4374
|
-
const timeout = menuIsClosing && setTimeout(() => {
|
|
4375
|
-
setMenuIsOpen(false);
|
|
4376
|
-
}, 250);
|
|
4377
|
-
return () => {
|
|
4378
|
-
timeout && clearTimeout(timeout);
|
|
4379
|
-
};
|
|
4380
|
-
}, [menuIsClosing]);
|
|
4381
4369
|
const orderedOptions = React__default.useMemo(() => {
|
|
4382
4370
|
return disabled ? getOrderedOptions(options, value).map(option => {
|
|
4383
4371
|
return Object.assign(Object.assign({}, option), {
|
|
@@ -5411,6 +5399,7 @@ const Layout$2 = tw.span`
|
|
|
5411
5399
|
|
|
5412
5400
|
/**
|
|
5413
5401
|
* The TitleNavContentLayout.
|
|
5402
|
+
* Use the `TitleGridArea`, `NavGridArea` and `ContentGridArea` components to define the layout elements.
|
|
5414
5403
|
*
|
|
5415
5404
|
* @param {TitleNavContentLayoutProps} props - The props for the TitleNavContentLayout component
|
|
5416
5405
|
* @returns {JSX.Element} TitleNavContentLayout component
|
|
@@ -5425,6 +5414,27 @@ const TitleNavContentLayout = ({
|
|
|
5425
5414
|
}));
|
|
5426
5415
|
const Layout$1 = tw.div`
|
|
5427
5416
|
tu-layout-TitleNavContentLayout
|
|
5417
|
+
lg:tu-layout-TitleNavContentLayout-lg
|
|
5418
|
+
`;
|
|
5419
|
+
/**
|
|
5420
|
+
* A component to define the title area of the TitleNavContentLayout.
|
|
5421
|
+
*/
|
|
5422
|
+
const TitleGridArea = tw.header`
|
|
5423
|
+
tu-layout-area-title
|
|
5424
|
+
`;
|
|
5425
|
+
/**
|
|
5426
|
+
* A component to define the navigation area of the TitleNavContentLayout.
|
|
5427
|
+
* Adds the needed left padding on large screens.
|
|
5428
|
+
*/
|
|
5429
|
+
const NavGridArea = tw.aside`
|
|
5430
|
+
tu-layout-area-nav
|
|
5431
|
+
`;
|
|
5432
|
+
/**
|
|
5433
|
+
* A component to define the content area of the TitleNavContentLayout.
|
|
5434
|
+
* Adds the needed right padding on large screens.
|
|
5435
|
+
*/
|
|
5436
|
+
const ContentGridArea = tw.article`
|
|
5437
|
+
tu-layout-area-content
|
|
5428
5438
|
`;
|
|
5429
5439
|
|
|
5430
5440
|
/**
|
|
@@ -5442,4 +5452,4 @@ const Layout = tw.div`
|
|
|
5442
5452
|
tu-layout-TwoColumnLayout
|
|
5443
5453
|
`;
|
|
5444
5454
|
|
|
5445
|
-
export { ActionButton, Alert, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Chart, Checkbox, Collapse, CopyableText, CreatableSelect, DateField, DateInput, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, Drawer, ExternalLink, FilterListMapLayout, FormGroup, FullWidthRepeatingLayout, GridArea, Heading$1 as Heading, Icon$1 as Icon, IconButton, Indicator$1 as Indicator, IntrinsicallyResponsiveGrid, Label$2 as Label, LegendItem, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, MoreMenu, MultiSelectMenuItem, NumberField, NumberInput, PageHeader, Pagination, PieChart, Popover, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, Search, SectionHeader, Select, SelectPrefix, SingleSelectMenuItem, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text$1 as Text, TextArea, TextAreaField, TextField, TextInput, Timeline, TimelineElement, Tip, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, ValueBar, docs, getOrderedOptions, getValueBarColorByValue, isMultiValue, useContainerProps, useCustomComponents, useDebounce, useLocalStorage, useModal, usePrompt, useTimeout };
|
|
5455
|
+
export { ActionButton, Alert, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Chart, Checkbox, Collapse, ContentGridArea, CopyableText, CreatableSelect, DateField, DateInput, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, Drawer, ExternalLink, FilterListMapLayout, FormGroup, FullWidthRepeatingLayout, GridArea, Heading$1 as Heading, Icon$1 as Icon, IconButton, Indicator$1 as Indicator, IntrinsicallyResponsiveGrid, Label$2 as Label, LegendItem, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, MoreMenu, MultiSelectMenuItem, NavGridArea, NumberField, NumberInput, PageHeader, Pagination, PieChart, Popover, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, Search, SectionHeader, Select, SelectPrefix, SingleSelectMenuItem, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text$1 as Text, TextArea, TextAreaField, TextField, TextInput, Timeline, TimelineElement, Tip, TitleGridArea, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, ValueBar, docs, getOrderedOptions, getValueBarColorByValue, isMultiValue, useContainerProps, useCustomComponents, useDebounce, useLocalStorage, useModal, usePrompt, useTimeout };
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
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.
|
|
7
|
+
"@trackunit/css-core": "0.0.65",
|
|
8
8
|
"@storybook/addon-docs": "6.5.14",
|
|
9
9
|
"@trackunit/tailwind-styled-components": "0.0.50",
|
|
10
10
|
"react": "18.2.0",
|
|
11
|
-
"@trackunit/ui-design-tokens": "0.0.
|
|
11
|
+
"@trackunit/ui-design-tokens": "0.0.52",
|
|
12
12
|
"@trackunit/react-core-contexts-test": "0.1.13",
|
|
13
13
|
"echarts-for-react": "3.0.2",
|
|
14
14
|
"echarts": "5.4.0",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"react-use": "17.4.0",
|
|
17
17
|
"date-fns": "2.29.3",
|
|
18
18
|
"react-day-picker": "8.3.7",
|
|
19
|
-
"@floating-ui/react
|
|
19
|
+
"@floating-ui/react": "0.15.1",
|
|
20
20
|
"@trackunit/ui-icons": "0.0.54",
|
|
21
21
|
"react-browser-hooks": "2.2.4",
|
|
22
22
|
"react-useportal": "1.0.17",
|
|
@@ -9,11 +9,11 @@ import { SelectComponents } from "react-select/dist/declarations/src/components"
|
|
|
9
9
|
* @template Group
|
|
10
10
|
* @param {Partial<SelectComponents<Option, IsMulti, Group>> | undefined} componentsProps a custom component prop that you can to override defaults
|
|
11
11
|
* @param {boolean} disabled decide to override disabled variant
|
|
12
|
-
* @param {boolean}
|
|
12
|
+
* @param {boolean} menuIsOpen menu is open state
|
|
13
13
|
* @param {React.MutableRefObject<boolean>} refMenuIsEnabled a flag to block menu from open
|
|
14
14
|
* @param {string} dataTestId a test id
|
|
15
15
|
* @param {number} maxSelectedDisplayCount a number of max display count
|
|
16
16
|
* @param {JSX.Element} dropdownIcon an custom dropdown icon
|
|
17
17
|
* @returns {Partial<SelectComponents<Option, boolean, GroupBase<Option>>> | undefined} components object to override react-select default components
|
|
18
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,
|
|
19
|
+
export declare const useCustomComponents: <Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(componentsProps: Partial<SelectComponents<Option, IsMulti, Group>> | undefined, disabled: boolean, menuIsOpen: boolean, refMenuIsEnabled: React.MutableRefObject<boolean>, dataTestId: string, maxSelectedDisplayCount: number | undefined, dropdownIcon?: JSX.Element) => Partial<SelectComponents<Option, IsMulti, Group>>;
|
|
@@ -5,9 +5,24 @@ interface TitleNavContentLayoutProps extends CommonProps {
|
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* The TitleNavContentLayout.
|
|
8
|
+
* Use the `TitleGridArea`, `NavGridArea` and `ContentGridArea` components to define the layout elements.
|
|
8
9
|
*
|
|
9
10
|
* @param {TitleNavContentLayoutProps} props - The props for the TitleNavContentLayout component
|
|
10
11
|
* @returns {JSX.Element} TitleNavContentLayout component
|
|
11
12
|
*/
|
|
12
13
|
export declare const TitleNavContentLayout: ({ children, className }: TitleNavContentLayoutProps) => JSX.Element;
|
|
14
|
+
/**
|
|
15
|
+
* A component to define the title area of the TitleNavContentLayout.
|
|
16
|
+
*/
|
|
17
|
+
export declare const TitleGridArea: import("dist/libs/ui/tailwind-styled-components/src/lib/types").TailwindComponent<import("dist/libs/ui/tailwind-styled-components/src/lib/types").TailwindHtmlComponent<"header">, {}>;
|
|
18
|
+
/**
|
|
19
|
+
* A component to define the navigation area of the TitleNavContentLayout.
|
|
20
|
+
* Adds the needed left padding on large screens.
|
|
21
|
+
*/
|
|
22
|
+
export declare const NavGridArea: import("dist/libs/ui/tailwind-styled-components/src/lib/types").TailwindComponent<import("dist/libs/ui/tailwind-styled-components/src/lib/types").TailwindHtmlComponent<"aside">, {}>;
|
|
23
|
+
/**
|
|
24
|
+
* A component to define the content area of the TitleNavContentLayout.
|
|
25
|
+
* Adds the needed right padding on large screens.
|
|
26
|
+
*/
|
|
27
|
+
export declare const ContentGridArea: import("dist/libs/ui/tailwind-styled-components/src/lib/types").TailwindComponent<import("dist/libs/ui/tailwind-styled-components/src/lib/types").TailwindHtmlComponent<"article">, {}>;
|
|
13
28
|
export {};
|