@tecsinapse/react-web-kit 1.7.8 → 1.8.0
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/CHANGELOG.md +11 -0
- package/dist/components/atoms/Accordion/Accordion.d.ts +1 -1
- package/dist/components/atoms/Accordion/Accordion.js +3 -2
- package/dist/components/atoms/Accordion/Accordion.js.map +1 -1
- package/dist/components/atoms/Modal/Modal.d.ts +2 -3
- package/dist/components/atoms/Modal/Modal.js +6 -3
- package/dist/components/atoms/Modal/Modal.js.map +1 -1
- package/dist/components/molecules/Breadcrumbs/Breadcrumbs.d.ts +2 -2
- package/dist/components/molecules/Breadcrumbs/Breadcrumbs.js +3 -2
- package/dist/components/molecules/Breadcrumbs/Breadcrumbs.js.map +1 -1
- package/dist/components/molecules/Drawer/Drawer.d.ts +4 -3
- package/dist/components/molecules/Drawer/Drawer.js +10 -4
- package/dist/components/molecules/Drawer/Drawer.js.map +1 -1
- package/dist/components/molecules/Drawer/animations.d.ts +3 -12
- package/dist/components/molecules/Drawer/animations.js +1 -1
- package/dist/components/molecules/Drawer/animations.js.map +1 -1
- package/dist/components/molecules/Menubar/Menubar.d.ts +1 -1
- package/dist/components/molecules/Menubar/Menubar.js +7 -3
- package/dist/components/molecules/Menubar/Menubar.js.map +1 -1
- package/dist/components/molecules/Select/Dropdown/Dropdown.d.ts +1 -3
- package/dist/components/molecules/Select/Dropdown/Dropdown.js +6 -4
- package/dist/components/molecules/Select/Dropdown/Dropdown.js.map +1 -1
- package/dist/components/molecules/Select/Dropdown/styled.d.ts +1 -1
- package/dist/components/molecules/Select/Dropdown/styled.js +26 -10
- package/dist/components/molecules/Select/Dropdown/styled.js.map +1 -1
- package/dist/components/molecules/Select/Select.d.ts +7 -2
- package/dist/components/molecules/Select/Select.js +15 -8
- package/dist/components/molecules/Select/Select.js.map +1 -1
- package/dist/components/molecules/Select/SelectItem/SelectItem.js +1 -1
- package/dist/components/molecules/Select/SelectItem/SelectItem.js.map +1 -1
- package/dist/components/molecules/Select/animations.d.ts +42 -18
- package/dist/components/molecules/Select/animations.js +42 -18
- package/dist/components/molecules/Select/animations.js.map +1 -1
- package/dist/components/organisms/DataGrid/DataGrid.d.ts +3 -4
- package/dist/components/organisms/DataGrid/DataGrid.js +3 -5
- package/dist/components/organisms/DataGrid/DataGrid.js.map +1 -1
- package/package.json +4 -3
- package/src/components/atoms/Accordion/Accordion.tsx +3 -2
- package/src/components/atoms/Modal/Modal.tsx +10 -4
- package/src/components/molecules/Breadcrumbs/Breadcrumbs.tsx +3 -3
- package/src/components/molecules/Drawer/Drawer.tsx +13 -5
- package/src/components/molecules/Drawer/animations.ts +9 -3
- package/src/components/molecules/Menubar/Menubar.tsx +5 -7
- package/src/components/molecules/Select/Dropdown/Dropdown.tsx +10 -6
- package/src/components/molecules/Select/Dropdown/styled.ts +32 -13
- package/src/components/molecules/Select/Select.tsx +22 -6
- package/src/components/molecules/Select/SelectItem/SelectItem.tsx +1 -1
- package/src/components/molecules/Select/animations.ts +31 -7
- package/src/components/organisms/DataGrid/DataGrid.tsx +5 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Checkbox,
|
|
4
4
|
Text,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
StyledContainerDropdown,
|
|
15
15
|
StyledContainerTextLabel,
|
|
16
16
|
StyledSpan,
|
|
17
|
-
|
|
17
|
+
OptionsContainer,
|
|
18
18
|
} from './styled';
|
|
19
19
|
|
|
20
20
|
const Dropdown = <Data, Type extends 'single' | 'multi'>({
|
|
@@ -28,9 +28,9 @@ const Dropdown = <Data, Type extends 'single' | 'multi'>({
|
|
|
28
28
|
labelExtractor,
|
|
29
29
|
setDropDownVisible,
|
|
30
30
|
style,
|
|
31
|
+
anchor,
|
|
31
32
|
}: SelectProps<Data, Type> & {
|
|
32
33
|
setDropDownVisible: (t: boolean) => void;
|
|
33
|
-
style: CSSProperties;
|
|
34
34
|
}): JSX.Element => {
|
|
35
35
|
const [searchArg, setSearchArg] = useDebouncedState<string>('', onSearch);
|
|
36
36
|
const lengthOptions = options.length;
|
|
@@ -49,7 +49,11 @@ const Dropdown = <Data, Type extends 'single' | 'multi'>({
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
return (
|
|
52
|
-
<StyledContainerDropdown
|
|
52
|
+
<StyledContainerDropdown
|
|
53
|
+
lengthOptions={lengthOptions}
|
|
54
|
+
style={style}
|
|
55
|
+
anchor={anchor}
|
|
56
|
+
>
|
|
53
57
|
{type === 'multi' && (
|
|
54
58
|
<StyledContainerCheckAll
|
|
55
59
|
onClick={hideSearchBar ? onClickCheckAll : undefined}
|
|
@@ -81,7 +85,7 @@ const Dropdown = <Data, Type extends 'single' | 'multi'>({
|
|
|
81
85
|
)}
|
|
82
86
|
</StyledContainerCheckAll>
|
|
83
87
|
)}
|
|
84
|
-
<
|
|
88
|
+
<OptionsContainer lengthOptions={options.length}>
|
|
85
89
|
{options.map((item, index) => (
|
|
86
90
|
<ItemSelect
|
|
87
91
|
type={type}
|
|
@@ -98,7 +102,7 @@ const Dropdown = <Data, Type extends 'single' | 'multi'>({
|
|
|
98
102
|
lenghtOptions={options.length}
|
|
99
103
|
/>
|
|
100
104
|
))}
|
|
101
|
-
</
|
|
105
|
+
</OptionsContainer>
|
|
102
106
|
</StyledContainerDropdown>
|
|
103
107
|
);
|
|
104
108
|
};
|
|
@@ -1,18 +1,39 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
2
|
import { hex2rgba, StyleProps } from '@tecsinapse/react-core';
|
|
3
3
|
import { SelectProps } from '../Select';
|
|
4
|
+
import { css } from '@emotion/react';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
type InjectedProps = Partial<
|
|
7
|
+
StyleProps & SelectProps<any, any> & { lengthOptions: number }
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
const anchorBottom = ({
|
|
11
|
+
theme,
|
|
12
|
+
anchor,
|
|
13
|
+
}: StyleProps & Omit<InjectedProps, 'theme'>) =>
|
|
14
|
+
anchor === 'bottom' &&
|
|
15
|
+
css`
|
|
16
|
+
margin-top: ${theme.spacing.centi};
|
|
17
|
+
top: 100%;
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
const anchorTop = ({
|
|
21
|
+
theme,
|
|
22
|
+
anchor,
|
|
23
|
+
}: StyleProps & Omit<InjectedProps, 'theme'>) =>
|
|
24
|
+
anchor === 'top' &&
|
|
25
|
+
css`
|
|
26
|
+
margin-bottom: ${theme.spacing.centi};
|
|
27
|
+
bottom: 100%;
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
export const StyledContainerDropdown = styled('div')<InjectedProps>`
|
|
8
31
|
width: 100%;
|
|
9
32
|
background-color: ${({ theme }: StyleProps) =>
|
|
10
33
|
theme.miscellaneous.surfaceColor};
|
|
11
34
|
border-radius: ${({ theme }: StyleProps) => theme.borderRadius.mili};
|
|
12
|
-
box-shadow:
|
|
35
|
+
box-shadow: 0 2px 8px
|
|
13
36
|
${({ theme }: StyleProps) => hex2rgba(theme.miscellaneous.shadow, 0.08)};
|
|
14
|
-
margin-top: ${({ theme }: StyleProps) => theme.spacing.centi};
|
|
15
|
-
top: 100%;
|
|
16
37
|
position: absolute;
|
|
17
38
|
padding-top: ${({
|
|
18
39
|
theme,
|
|
@@ -21,17 +42,15 @@ export const StyledContainerDropdown = styled('div')<
|
|
|
21
42
|
!hideSearchBar ? `${theme.spacing.deca}` : '0px'};
|
|
22
43
|
padding-bottom: ${({ theme }: StyleProps) => theme.spacing.mili};
|
|
23
44
|
z-index: ${({ theme }: StyleProps) => theme.zIndex.select};
|
|
45
|
+
${anchorTop}
|
|
46
|
+
${anchorBottom}
|
|
24
47
|
`;
|
|
25
48
|
|
|
26
|
-
export const
|
|
27
|
-
Partial<StyleProps & SelectProps<any, any> & { lenghtOptions: number }>
|
|
28
|
-
>`
|
|
49
|
+
export const OptionsContainer = styled('div')<InjectedProps>`
|
|
29
50
|
max-height: 250px;
|
|
30
51
|
top: 100%;
|
|
31
|
-
overflow-y: ${({
|
|
32
|
-
|
|
33
|
-
}: Partial<{ lenghtOptions: number } & StyleProps>) =>
|
|
34
|
-
lenghtOptions > 5 ? 'scroll' : 'hidden'};
|
|
52
|
+
overflow-y: ${({ lengthOptions = 0 }: InjectedProps) =>
|
|
53
|
+
lengthOptions > 5 ? 'scroll' : 'hidden'};
|
|
35
54
|
::-webkit-scrollbar {
|
|
36
55
|
width: 8px;
|
|
37
56
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Icon,
|
|
4
|
+
PressableInputContainer,
|
|
5
|
+
Text,
|
|
6
|
+
TextProps,
|
|
7
|
+
} from '@tecsinapse/react-core';
|
|
3
8
|
import { useClickAwayListener } from '../../../hooks';
|
|
4
9
|
import { StyledContainer, StyledInputContainer } from './styled';
|
|
5
10
|
import { Dropdown } from './Dropdown';
|
|
@@ -7,7 +12,8 @@ import { getDisplayValue } from './functions';
|
|
|
7
12
|
import { Transition } from 'react-transition-group';
|
|
8
13
|
import { defaultStyles, transition } from './animations';
|
|
9
14
|
|
|
10
|
-
export interface SelectProps<Data, Type extends 'single' | 'multi'>
|
|
15
|
+
export interface SelectProps<Data, Type extends 'single' | 'multi'>
|
|
16
|
+
extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> {
|
|
11
17
|
options: Data[];
|
|
12
18
|
onSelect: (
|
|
13
19
|
option: Type extends 'single' ? Data | undefined : Data[]
|
|
@@ -20,7 +26,10 @@ export interface SelectProps<Data, Type extends 'single' | 'multi'> {
|
|
|
20
26
|
onSearch?: (searchArg: string) => void | never;
|
|
21
27
|
searchBarPlaceholder?: string;
|
|
22
28
|
hideSearchBar?: boolean;
|
|
29
|
+
disabled?: boolean;
|
|
23
30
|
label?: string;
|
|
31
|
+
anchor?: 'top' | 'bottom';
|
|
32
|
+
displayTextProps?: TextProps;
|
|
24
33
|
}
|
|
25
34
|
|
|
26
35
|
export const Select = <Data, Type extends 'single' | 'multi'>({
|
|
@@ -32,8 +41,12 @@ export const Select = <Data, Type extends 'single' | 'multi'>({
|
|
|
32
41
|
labelExtractor,
|
|
33
42
|
placeholder,
|
|
34
43
|
onSearch,
|
|
44
|
+
searchBarPlaceholder,
|
|
35
45
|
hideSearchBar = true,
|
|
36
46
|
label,
|
|
47
|
+
disabled = false,
|
|
48
|
+
anchor = 'bottom',
|
|
49
|
+
displayTextProps,
|
|
37
50
|
...rest
|
|
38
51
|
}: SelectProps<Data, Type>): JSX.Element => {
|
|
39
52
|
const [dropDownVisible, setDropDownVisible] = React.useState<boolean>(false);
|
|
@@ -50,12 +63,12 @@ export const Select = <Data, Type extends 'single' | 'multi'>({
|
|
|
50
63
|
);
|
|
51
64
|
|
|
52
65
|
return (
|
|
53
|
-
<StyledContainer ref={refDropDown}>
|
|
66
|
+
<StyledContainer ref={refDropDown} {...rest}>
|
|
54
67
|
<StyledInputContainer>
|
|
55
68
|
<PressableInputContainer
|
|
56
69
|
label={label}
|
|
57
|
-
{...rest}
|
|
58
70
|
onPress={() => setDropDownVisible(!dropDownVisible)}
|
|
71
|
+
disabled={disabled}
|
|
59
72
|
rightComponent={
|
|
60
73
|
<Icon
|
|
61
74
|
name="chevron-down"
|
|
@@ -65,7 +78,7 @@ export const Select = <Data, Type extends 'single' | 'multi'>({
|
|
|
65
78
|
/>
|
|
66
79
|
}
|
|
67
80
|
>
|
|
68
|
-
<Text ellipsizeMode="tail" numberOfLines={1}>
|
|
81
|
+
<Text {...displayTextProps} ellipsizeMode="tail" numberOfLines={1}>
|
|
69
82
|
{displayValue}
|
|
70
83
|
</Text>
|
|
71
84
|
</PressableInputContainer>
|
|
@@ -80,8 +93,11 @@ export const Select = <Data, Type extends 'single' | 'multi'>({
|
|
|
80
93
|
keyExtractor={keyExtractor}
|
|
81
94
|
labelExtractor={labelExtractor}
|
|
82
95
|
hideSearchBar={hideSearchBar}
|
|
83
|
-
|
|
96
|
+
searchBarPlaceholder={searchBarPlaceholder}
|
|
97
|
+
onSearch={onSearch}
|
|
98
|
+
style={{ ...defaultStyles, ...transition[anchor][state] }}
|
|
84
99
|
setDropDownVisible={setDropDownVisible}
|
|
100
|
+
anchor={anchor}
|
|
85
101
|
/>
|
|
86
102
|
)}
|
|
87
103
|
</Transition>
|
|
@@ -57,7 +57,7 @@ const SelectItem = <Data, Type extends 'single' | 'multi'>({
|
|
|
57
57
|
onSelect([...value, key] as OnSelectArg);
|
|
58
58
|
[...value, key].length === lenghtOptions && setCheckedAll(true);
|
|
59
59
|
} else {
|
|
60
|
-
const auxArray: Data[] = value;
|
|
60
|
+
const auxArray: Data[] = [...value];
|
|
61
61
|
const indexToExclude = auxArray.indexOf(key);
|
|
62
62
|
auxArray.splice(indexToExclude, 1);
|
|
63
63
|
onSelect([...auxArray] as OnSelectArg);
|
|
@@ -7,12 +7,36 @@ export const defaultStyles = {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export const transition = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
bottom: {
|
|
11
|
+
entering: {
|
|
12
|
+
transform: 'translateY(-10%)',
|
|
13
|
+
opacity: 0,
|
|
14
|
+
visibility: 'hidden',
|
|
15
|
+
},
|
|
16
|
+
entered: {
|
|
17
|
+
transform: 'translateY(0%)',
|
|
18
|
+
opacity: 1,
|
|
19
|
+
visibility: 'visible',
|
|
20
|
+
},
|
|
21
|
+
exiting: {
|
|
22
|
+
transform: 'translateY(0%)',
|
|
23
|
+
opacity: 1,
|
|
24
|
+
visibility: 'visible',
|
|
25
|
+
},
|
|
26
|
+
exited: {
|
|
27
|
+
transform: 'translateY(-10%)',
|
|
28
|
+
opacity: 0,
|
|
29
|
+
visibility: 'hidden',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
top: {
|
|
33
|
+
entering: {
|
|
34
|
+
transform: 'translateY(10%)',
|
|
35
|
+
opacity: 0,
|
|
36
|
+
visibility: 'hidden',
|
|
37
|
+
},
|
|
38
|
+
entered: { transform: 'translateY(0%)', opacity: 1, visibility: 'visible' },
|
|
39
|
+
exiting: { transform: 'translateY(0%)', opacity: 1, visibility: 'visible' },
|
|
40
|
+
exited: { transform: 'translateY(10%)', opacity: 0, visibility: 'hidden' },
|
|
14
41
|
},
|
|
15
|
-
entered: { transform: 'translateY(0%)', opacity: 1, visibility: 'visible' },
|
|
16
|
-
exiting: { transform: 'translateY(0%)', opacity: 1, visibility: 'visible' },
|
|
17
|
-
exited: { transform: 'translateY(-10%)', opacity: 0, visibility: 'hidden' },
|
|
18
42
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Table,
|
|
4
4
|
TableToolbar,
|
|
@@ -14,7 +14,8 @@ import { Footer } from './Footer';
|
|
|
14
14
|
import { Skeleton } from '../../atoms/Skeleton';
|
|
15
15
|
import { getData, removeElement } from './utils';
|
|
16
16
|
|
|
17
|
-
export interface DataGridProps<Data>
|
|
17
|
+
export interface DataGridProps<Data>
|
|
18
|
+
extends React.HTMLAttributes<HTMLDivElement> {
|
|
18
19
|
headers: HeadersType<Data>[];
|
|
19
20
|
data: Data[];
|
|
20
21
|
/** Unique identifier for row data */
|
|
@@ -49,8 +50,6 @@ export interface DataGridProps<Data> {
|
|
|
49
50
|
loading?: boolean;
|
|
50
51
|
/** Custom skeleton component for better visual */
|
|
51
52
|
skeletonComponent?: React.ReactNode;
|
|
52
|
-
/** CSS style spread to TableContainer */
|
|
53
|
-
style?: CSSProperties;
|
|
54
53
|
/** Empty state placeholder */
|
|
55
54
|
emptyPlaceholder?: React.ReactNode;
|
|
56
55
|
}
|
|
@@ -78,8 +77,8 @@ const DataGrid = <Data extends unknown>({
|
|
|
78
77
|
onPageChange,
|
|
79
78
|
loading = false,
|
|
80
79
|
skeletonComponent,
|
|
81
|
-
style,
|
|
82
80
|
emptyPlaceholder,
|
|
81
|
+
...rest
|
|
83
82
|
}: DataGridProps<Data>): JSX.Element => {
|
|
84
83
|
if (selectable && (!selectedRows || !onSelectedRows)) {
|
|
85
84
|
throw new Error(
|
|
@@ -117,7 +116,7 @@ const DataGrid = <Data extends unknown>({
|
|
|
117
116
|
);
|
|
118
117
|
|
|
119
118
|
return (
|
|
120
|
-
<TableContainer
|
|
119
|
+
<TableContainer {...rest}>
|
|
121
120
|
<TableToolbar
|
|
122
121
|
title={toolbarTitle}
|
|
123
122
|
rightIcons={toolbarRightIcons}
|