@trackunit/react-components 0.1.4 → 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.css
CHANGED
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';
|
|
@@ -3631,9 +3631,11 @@ const Search = ({
|
|
|
3631
3631
|
name,
|
|
3632
3632
|
onClear,
|
|
3633
3633
|
dataTestId,
|
|
3634
|
-
autoComplete = "on"
|
|
3634
|
+
autoComplete = "on",
|
|
3635
|
+
ref
|
|
3635
3636
|
}) => {
|
|
3636
3637
|
return jsx(StyledTextInput, {
|
|
3638
|
+
ref: ref,
|
|
3637
3639
|
dataTestId: dataTestId,
|
|
3638
3640
|
name: name,
|
|
3639
3641
|
className: className,
|
|
@@ -4051,14 +4053,14 @@ tu-select__counter
|
|
|
4051
4053
|
* @template Group
|
|
4052
4054
|
* @param {Partial<SelectComponents<Option, IsMulti, Group>> | undefined} componentsProps a custom component prop that you can to override defaults
|
|
4053
4055
|
* @param {boolean} disabled decide to override disabled variant
|
|
4054
|
-
* @param {boolean}
|
|
4056
|
+
* @param {boolean} menuIsOpen menu is open state
|
|
4055
4057
|
* @param {React.MutableRefObject<boolean>} refMenuIsEnabled a flag to block menu from open
|
|
4056
4058
|
* @param {string} dataTestId a test id
|
|
4057
4059
|
* @param {number} maxSelectedDisplayCount a number of max display count
|
|
4058
4060
|
* @param {JSX.Element} dropdownIcon an custom dropdown icon
|
|
4059
4061
|
* @returns {Partial<SelectComponents<Option, boolean, GroupBase<Option>>> | undefined} components object to override react-select default components
|
|
4060
4062
|
*/
|
|
4061
|
-
const useCustomComponents = (componentsProps, disabled,
|
|
4063
|
+
const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon) => {
|
|
4062
4064
|
const customComponents = React.useMemo(() => {
|
|
4063
4065
|
return Object.assign({
|
|
4064
4066
|
ValueContainer: props => {
|
|
@@ -4129,11 +4131,11 @@ const useCustomComponents = (componentsProps, disabled, menuIsClosing, refMenuIs
|
|
|
4129
4131
|
DropdownIndicator: props => {
|
|
4130
4132
|
return props.selectProps.isLoading ? null : jsx(components.DropdownIndicator, Object.assign({}, props, {
|
|
4131
4133
|
children: jsx(StyledIcon, {
|
|
4132
|
-
children: dropdownIcon ? dropdownIcon :
|
|
4133
|
-
name: "
|
|
4134
|
+
children: dropdownIcon ? dropdownIcon : menuIsOpen ? jsx(Icon$1, {
|
|
4135
|
+
name: "ChevronUpIcon",
|
|
4134
4136
|
size: "medium"
|
|
4135
4137
|
}) : jsx(Icon$1, {
|
|
4136
|
-
name: "
|
|
4138
|
+
name: "ChevronDownIcon",
|
|
4137
4139
|
size: "medium"
|
|
4138
4140
|
})
|
|
4139
4141
|
})
|
|
@@ -4177,7 +4179,7 @@ const useCustomComponents = (componentsProps, disabled, menuIsClosing, refMenuIs
|
|
|
4177
4179
|
},
|
|
4178
4180
|
Menu: props => {
|
|
4179
4181
|
return jsx(components.Menu, Object.assign({}, props, {
|
|
4180
|
-
className:
|
|
4182
|
+
className: menuIsOpen ? tws`tu-select__menu-list animate-fade-in-fast` : tws`tu-select__menu-list animate-fade-out-fast`
|
|
4181
4183
|
}));
|
|
4182
4184
|
},
|
|
4183
4185
|
Option: props => {
|
|
@@ -4204,7 +4206,7 @@ const useCustomComponents = (componentsProps, disabled, menuIsClosing, refMenuIs
|
|
|
4204
4206
|
}
|
|
4205
4207
|
}, componentsProps);
|
|
4206
4208
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4207
|
-
}, [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)
|
|
4208
4210
|
return customComponents;
|
|
4209
4211
|
};
|
|
4210
4212
|
const StyledIcon = tw.div`
|
|
@@ -4349,33 +4351,21 @@ const useSelect = _a => {
|
|
|
4349
4351
|
customStyles
|
|
4350
4352
|
} = useCustomStyles(refContainer, refPrefix, maxSelectedDisplayCount, styles);
|
|
4351
4353
|
const [menuIsOpen, setMenuIsOpen] = React__default.useState((_b = props.menuIsOpen) !== null && _b !== void 0 ? _b : false);
|
|
4352
|
-
const [menuIsClosing, setMenuIsClosing] = React__default.useState(true);
|
|
4353
4354
|
const refMenuIsEnabled = React__default.useRef(true);
|
|
4354
|
-
const customComponents = useCustomComponents(components, disabled || false,
|
|
4355
|
+
const customComponents = useCustomComponents(components, disabled || false, menuIsOpen, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon);
|
|
4355
4356
|
const menuPlacement = "auto";
|
|
4356
4357
|
const openMenuHandler = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
4357
4358
|
onMenuOpen && onMenuOpen();
|
|
4358
4359
|
if (refMenuIsEnabled.current) {
|
|
4359
|
-
|
|
4360
|
-
yield setMenuIsOpen(true);
|
|
4360
|
+
setMenuIsOpen(true);
|
|
4361
4361
|
} else {
|
|
4362
4362
|
refMenuIsEnabled.current = true;
|
|
4363
4363
|
}
|
|
4364
4364
|
});
|
|
4365
4365
|
const closeMenuHandler = () => {
|
|
4366
|
-
|
|
4367
|
-
setMenuIsClosing(true);
|
|
4368
|
-
}
|
|
4366
|
+
setMenuIsOpen(false);
|
|
4369
4367
|
onMenuClose && onMenuClose();
|
|
4370
4368
|
};
|
|
4371
|
-
React__default.useEffect(() => {
|
|
4372
|
-
const timeout = menuIsClosing && setTimeout(() => {
|
|
4373
|
-
setMenuIsOpen(false);
|
|
4374
|
-
}, 250);
|
|
4375
|
-
return () => {
|
|
4376
|
-
timeout && clearTimeout(timeout);
|
|
4377
|
-
};
|
|
4378
|
-
}, [menuIsClosing]);
|
|
4379
4369
|
const orderedOptions = React__default.useMemo(() => {
|
|
4380
4370
|
return disabled ? getOrderedOptions(options, value).map(option => {
|
|
4381
4371
|
return Object.assign(Object.assign({}, option), {
|
|
@@ -4508,9 +4498,12 @@ const CreatableSelect = props => {
|
|
|
4508
4498
|
* @returns {JSX.Element} Select component
|
|
4509
4499
|
*/
|
|
4510
4500
|
const Select = props => {
|
|
4501
|
+
const {
|
|
4502
|
+
className
|
|
4503
|
+
} = props,
|
|
4504
|
+
propsNoClassName = __rest(props, ["className"]);
|
|
4511
4505
|
const {
|
|
4512
4506
|
id,
|
|
4513
|
-
className,
|
|
4514
4507
|
dataTestId = "select",
|
|
4515
4508
|
prefix,
|
|
4516
4509
|
async,
|
|
@@ -4580,10 +4573,10 @@ const Select = props => {
|
|
|
4580
4573
|
ref: refPrefix
|
|
4581
4574
|
}, {
|
|
4582
4575
|
children: prefix
|
|
4583
|
-
})), async ? jsx(ReactAsyncSelect, Object.assign({},
|
|
4576
|
+
})), async ? jsx(ReactAsyncSelect, Object.assign({}, propsNoClassName, selectProps, async, {
|
|
4584
4577
|
onMenuOpen: openMenuHandler,
|
|
4585
4578
|
onMenuClose: closeMenuHandler
|
|
4586
|
-
})) : jsx(ReactSelect, Object.assign({},
|
|
4579
|
+
})) : jsx(ReactSelect, Object.assign({}, propsNoClassName, selectProps, {
|
|
4587
4580
|
options: filterOption ? orderedOptions : options,
|
|
4588
4581
|
hideSelectedOptions: false,
|
|
4589
4582
|
isMulti: isMulti,
|
|
@@ -5406,17 +5399,42 @@ const Layout$2 = tw.span`
|
|
|
5406
5399
|
|
|
5407
5400
|
/**
|
|
5408
5401
|
* The TitleNavContentLayout.
|
|
5402
|
+
* Use the `TitleGridArea`, `NavGridArea` and `ContentGridArea` components to define the layout elements.
|
|
5409
5403
|
*
|
|
5410
5404
|
* @param {TitleNavContentLayoutProps} props - The props for the TitleNavContentLayout component
|
|
5411
5405
|
* @returns {JSX.Element} TitleNavContentLayout component
|
|
5412
5406
|
*/
|
|
5413
5407
|
const TitleNavContentLayout = ({
|
|
5414
|
-
children
|
|
5415
|
-
|
|
5408
|
+
children,
|
|
5409
|
+
className
|
|
5410
|
+
}) => jsx(Layout$1, Object.assign({
|
|
5411
|
+
className: className
|
|
5412
|
+
}, {
|
|
5416
5413
|
children: children
|
|
5417
|
-
});
|
|
5414
|
+
}));
|
|
5418
5415
|
const Layout$1 = tw.div`
|
|
5419
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
|
|
5420
5438
|
`;
|
|
5421
5439
|
|
|
5422
5440
|
/**
|
|
@@ -5434,4 +5452,4 @@ const Layout = tw.div`
|
|
|
5434
5452
|
tu-layout-TwoColumnLayout
|
|
5435
5453
|
`;
|
|
5436
5454
|
|
|
5437
|
-
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",
|
|
@@ -50,6 +50,7 @@ export interface SearchProps extends CommonProps {
|
|
|
50
50
|
* Event that search box is cleared.
|
|
51
51
|
*/
|
|
52
52
|
onClear?: () => void;
|
|
53
|
+
ref?: React.Ref<HTMLInputElement | undefined>;
|
|
53
54
|
}
|
|
54
55
|
/**
|
|
55
56
|
* The Search component is used to render a search input field.
|
|
@@ -57,4 +58,4 @@ export interface SearchProps extends CommonProps {
|
|
|
57
58
|
* @param {SearchProps} props - The props for the Search component
|
|
58
59
|
* @returns {JSX.Element} Search component
|
|
59
60
|
*/
|
|
60
|
-
export declare const Search: ({ className, placeholder, value, widenInputOnFocus, showBorderWhenNotInFocus, disabled, onKeyUp, onChange, onFocus, onBlur, name, onClear, dataTestId, autoComplete, }: SearchProps) => JSX.Element;
|
|
61
|
+
export declare const Search: ({ className, placeholder, value, widenInputOnFocus, showBorderWhenNotInFocus, disabled, onKeyUp, onChange, onFocus, onBlur, name, onClear, dataTestId, autoComplete, ref, }: SearchProps) => 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>>;
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
import { CommonProps } from "../../common";
|
|
3
|
+
interface TitleNavContentLayoutProps extends CommonProps {
|
|
3
4
|
children: React.ReactNode;
|
|
4
5
|
}
|
|
5
6
|
/**
|
|
6
7
|
* The TitleNavContentLayout.
|
|
8
|
+
* Use the `TitleGridArea`, `NavGridArea` and `ContentGridArea` components to define the layout elements.
|
|
7
9
|
*
|
|
8
10
|
* @param {TitleNavContentLayoutProps} props - The props for the TitleNavContentLayout component
|
|
9
11
|
* @returns {JSX.Element} TitleNavContentLayout component
|
|
10
12
|
*/
|
|
11
|
-
export declare const TitleNavContentLayout: ({ children }: TitleNavContentLayoutProps) => JSX.Element;
|
|
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">, {}>;
|
|
12
28
|
export {};
|