@trackunit/react-components 0.1.7 → 0.1.10
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';
|
|
@@ -1187,7 +1187,8 @@ const CardHeader = ({
|
|
|
1187
1187
|
className,
|
|
1188
1188
|
children,
|
|
1189
1189
|
accessories,
|
|
1190
|
-
density
|
|
1190
|
+
density,
|
|
1191
|
+
extraClassName
|
|
1191
1192
|
}) => {
|
|
1192
1193
|
return jsx(BottomBorderedDensityContainer, Object.assign({
|
|
1193
1194
|
dataTestId: dataTestId,
|
|
@@ -1195,7 +1196,9 @@ const CardHeader = ({
|
|
|
1195
1196
|
"$density": density
|
|
1196
1197
|
}, {
|
|
1197
1198
|
children: jsxs(Container$6, {
|
|
1198
|
-
children: [jsxs("div", {
|
|
1199
|
+
children: [jsxs("div", Object.assign({
|
|
1200
|
+
className: extraClassName
|
|
1201
|
+
}, {
|
|
1199
1202
|
children: [jsxs(HeadingContainer$1, {
|
|
1200
1203
|
children: [jsx(Heading$1, Object.assign({
|
|
1201
1204
|
variant: headingVariant
|
|
@@ -1208,7 +1211,7 @@ const CardHeader = ({
|
|
|
1208
1211
|
}, {
|
|
1209
1212
|
children: subHeading
|
|
1210
1213
|
})), children]
|
|
1211
|
-
}), onClose && jsx(IconButton, {
|
|
1214
|
+
})), onClose && jsx(IconButton, {
|
|
1212
1215
|
dataTestId: "card-header-close-button",
|
|
1213
1216
|
variant: "transparent",
|
|
1214
1217
|
color: "secondary",
|
|
@@ -4053,14 +4056,14 @@ tu-select__counter
|
|
|
4053
4056
|
* @template Group
|
|
4054
4057
|
* @param {Partial<SelectComponents<Option, IsMulti, Group>> | undefined} componentsProps a custom component prop that you can to override defaults
|
|
4055
4058
|
* @param {boolean} disabled decide to override disabled variant
|
|
4056
|
-
* @param {boolean}
|
|
4059
|
+
* @param {boolean} menuIsOpen menu is open state
|
|
4057
4060
|
* @param {React.MutableRefObject<boolean>} refMenuIsEnabled a flag to block menu from open
|
|
4058
4061
|
* @param {string} dataTestId a test id
|
|
4059
4062
|
* @param {number} maxSelectedDisplayCount a number of max display count
|
|
4060
4063
|
* @param {JSX.Element} dropdownIcon an custom dropdown icon
|
|
4061
4064
|
* @returns {Partial<SelectComponents<Option, boolean, GroupBase<Option>>> | undefined} components object to override react-select default components
|
|
4062
4065
|
*/
|
|
4063
|
-
const useCustomComponents = (componentsProps, disabled,
|
|
4066
|
+
const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon) => {
|
|
4064
4067
|
const customComponents = React.useMemo(() => {
|
|
4065
4068
|
return Object.assign({
|
|
4066
4069
|
ValueContainer: props => {
|
|
@@ -4131,11 +4134,11 @@ const useCustomComponents = (componentsProps, disabled, menuIsClosing, refMenuIs
|
|
|
4131
4134
|
DropdownIndicator: props => {
|
|
4132
4135
|
return props.selectProps.isLoading ? null : jsx(components.DropdownIndicator, Object.assign({}, props, {
|
|
4133
4136
|
children: jsx(StyledIcon, {
|
|
4134
|
-
children: dropdownIcon ? dropdownIcon :
|
|
4135
|
-
name: "
|
|
4137
|
+
children: dropdownIcon ? dropdownIcon : menuIsOpen ? jsx(Icon$1, {
|
|
4138
|
+
name: "ChevronUpIcon",
|
|
4136
4139
|
size: "medium"
|
|
4137
4140
|
}) : jsx(Icon$1, {
|
|
4138
|
-
name: "
|
|
4141
|
+
name: "ChevronDownIcon",
|
|
4139
4142
|
size: "medium"
|
|
4140
4143
|
})
|
|
4141
4144
|
})
|
|
@@ -4179,7 +4182,7 @@ const useCustomComponents = (componentsProps, disabled, menuIsClosing, refMenuIs
|
|
|
4179
4182
|
},
|
|
4180
4183
|
Menu: props => {
|
|
4181
4184
|
return jsx(components.Menu, Object.assign({}, props, {
|
|
4182
|
-
className:
|
|
4185
|
+
className: menuIsOpen ? tws`tu-select__menu-list animate-fade-in-fast` : tws`tu-select__menu-list animate-fade-out-fast`
|
|
4183
4186
|
}));
|
|
4184
4187
|
},
|
|
4185
4188
|
Option: props => {
|
|
@@ -4206,7 +4209,7 @@ const useCustomComponents = (componentsProps, disabled, menuIsClosing, refMenuIs
|
|
|
4206
4209
|
}
|
|
4207
4210
|
}, componentsProps);
|
|
4208
4211
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4209
|
-
}, [componentsProps, disabled,
|
|
4212
|
+
}, [componentsProps, disabled, menuIsOpen, refMenuIsEnabled, maxSelectedDisplayCount]); // do not add dropdownIcon (it will cause issue with opening/closing list for selects with custom icon)
|
|
4210
4213
|
return customComponents;
|
|
4211
4214
|
};
|
|
4212
4215
|
const StyledIcon = tw.div`
|
|
@@ -4351,33 +4354,21 @@ const useSelect = _a => {
|
|
|
4351
4354
|
customStyles
|
|
4352
4355
|
} = useCustomStyles(refContainer, refPrefix, maxSelectedDisplayCount, styles);
|
|
4353
4356
|
const [menuIsOpen, setMenuIsOpen] = React__default.useState((_b = props.menuIsOpen) !== null && _b !== void 0 ? _b : false);
|
|
4354
|
-
const [menuIsClosing, setMenuIsClosing] = React__default.useState(true);
|
|
4355
4357
|
const refMenuIsEnabled = React__default.useRef(true);
|
|
4356
|
-
const customComponents = useCustomComponents(components, disabled || false,
|
|
4358
|
+
const customComponents = useCustomComponents(components, disabled || false, menuIsOpen, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon);
|
|
4357
4359
|
const menuPlacement = "auto";
|
|
4358
4360
|
const openMenuHandler = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
4359
4361
|
onMenuOpen && onMenuOpen();
|
|
4360
4362
|
if (refMenuIsEnabled.current) {
|
|
4361
|
-
|
|
4362
|
-
yield setMenuIsOpen(true);
|
|
4363
|
+
setMenuIsOpen(true);
|
|
4363
4364
|
} else {
|
|
4364
4365
|
refMenuIsEnabled.current = true;
|
|
4365
4366
|
}
|
|
4366
4367
|
});
|
|
4367
4368
|
const closeMenuHandler = () => {
|
|
4368
|
-
|
|
4369
|
-
setMenuIsClosing(true);
|
|
4370
|
-
}
|
|
4369
|
+
setMenuIsOpen(false);
|
|
4371
4370
|
onMenuClose && onMenuClose();
|
|
4372
4371
|
};
|
|
4373
|
-
React__default.useEffect(() => {
|
|
4374
|
-
const timeout = menuIsClosing && setTimeout(() => {
|
|
4375
|
-
setMenuIsOpen(false);
|
|
4376
|
-
}, 250);
|
|
4377
|
-
return () => {
|
|
4378
|
-
timeout && clearTimeout(timeout);
|
|
4379
|
-
};
|
|
4380
|
-
}, [menuIsClosing]);
|
|
4381
4372
|
const orderedOptions = React__default.useMemo(() => {
|
|
4382
4373
|
return disabled ? getOrderedOptions(options, value).map(option => {
|
|
4383
4374
|
return Object.assign(Object.assign({}, option), {
|
|
@@ -5411,6 +5402,7 @@ const Layout$2 = tw.span`
|
|
|
5411
5402
|
|
|
5412
5403
|
/**
|
|
5413
5404
|
* The TitleNavContentLayout.
|
|
5405
|
+
* Use the `TitleGridArea`, `NavGridArea` and `ContentGridArea` components to define the layout elements.
|
|
5414
5406
|
*
|
|
5415
5407
|
* @param {TitleNavContentLayoutProps} props - The props for the TitleNavContentLayout component
|
|
5416
5408
|
* @returns {JSX.Element} TitleNavContentLayout component
|
|
@@ -5425,6 +5417,27 @@ const TitleNavContentLayout = ({
|
|
|
5425
5417
|
}));
|
|
5426
5418
|
const Layout$1 = tw.div`
|
|
5427
5419
|
tu-layout-TitleNavContentLayout
|
|
5420
|
+
lg:tu-layout-TitleNavContentLayout-lg
|
|
5421
|
+
`;
|
|
5422
|
+
/**
|
|
5423
|
+
* A component to define the title area of the TitleNavContentLayout.
|
|
5424
|
+
*/
|
|
5425
|
+
const TitleGridArea = tw.header`
|
|
5426
|
+
tu-layout-area-title
|
|
5427
|
+
`;
|
|
5428
|
+
/**
|
|
5429
|
+
* A component to define the navigation area of the TitleNavContentLayout.
|
|
5430
|
+
* Adds the needed left padding on large screens.
|
|
5431
|
+
*/
|
|
5432
|
+
const NavGridArea = tw.aside`
|
|
5433
|
+
tu-layout-area-nav
|
|
5434
|
+
`;
|
|
5435
|
+
/**
|
|
5436
|
+
* A component to define the content area of the TitleNavContentLayout.
|
|
5437
|
+
* Adds the needed right padding on large screens.
|
|
5438
|
+
*/
|
|
5439
|
+
const ContentGridArea = tw.article`
|
|
5440
|
+
tu-layout-area-content
|
|
5428
5441
|
`;
|
|
5429
5442
|
|
|
5430
5443
|
/**
|
|
@@ -5442,4 +5455,4 @@ const Layout = tw.div`
|
|
|
5442
5455
|
tu-layout-TwoColumnLayout
|
|
5443
5456
|
`;
|
|
5444
5457
|
|
|
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 };
|
|
5458
|
+
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.10",
|
|
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",
|
|
@@ -33,6 +33,10 @@ export interface CardHeaderProps extends CommonProps {
|
|
|
33
33
|
* Children to render in the header
|
|
34
34
|
*/
|
|
35
35
|
children?: React.ReactNode | null;
|
|
36
|
+
/**
|
|
37
|
+
* Extra className for div container
|
|
38
|
+
*/
|
|
39
|
+
extraClassName?: string | undefined;
|
|
36
40
|
}
|
|
37
41
|
/**
|
|
38
42
|
* Header for Cards and Modals.
|
|
@@ -40,4 +44,4 @@ export interface CardHeaderProps extends CommonProps {
|
|
|
40
44
|
* @param {CardHeaderProps} props - The props for the CardHeader component
|
|
41
45
|
* @returns {JSX.Element} CardHeader component
|
|
42
46
|
*/
|
|
43
|
-
export declare const CardHeader: ({ heading, headingVariant, subHeading, onClose, dataTestId, className, children, accessories, density, }: CardHeaderProps) => JSX.Element;
|
|
47
|
+
export declare const CardHeader: ({ heading, headingVariant, subHeading, onClose, dataTestId, className, children, accessories, density, extraClassName, }: CardHeaderProps) => JSX.Element;
|
|
@@ -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 {};
|