@redsift/design-system-legacy 8.0.1 → 8.0.3
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/package.json +3 -2
- package/dist/package.json +0 -65
- package/rollup.config.js +0 -70
- package/src/components/Alert/Alert.jsx +0 -94
- package/src/components/Alert/index.ts +0 -1
- package/src/components/Alert/readme.md +0 -114
- package/src/components/Button/Button.jsx +0 -161
- package/src/components/Button/index.ts +0 -1
- package/src/components/Button/readme.md +0 -173
- package/src/components/Card/Card.jsx +0 -34
- package/src/components/Card/index.ts +0 -1
- package/src/components/Card/readme.md +0 -54
- package/src/components/CardHeader/CardHeader.jsx +0 -40
- package/src/components/CardHeader/index.ts +0 -1
- package/src/components/Checkbox/Checkbox.jsx +0 -123
- package/src/components/Checkbox/index.ts +0 -1
- package/src/components/Checkbox/readme.md +0 -54
- package/src/components/CheckboxTree/CheckboxTree.jsx +0 -167
- package/src/components/CheckboxTree/CheckboxTree.styles.ts +0 -49
- package/src/components/CheckboxTree/index.ts +0 -1
- package/src/components/CheckboxTree/readme.md +0 -60
- package/src/components/IconContainer/IconContainer.jsx +0 -51
- package/src/components/IconContainer/index.ts +0 -1
- package/src/components/Input/Input.jsx +0 -27
- package/src/components/Input/OutlineInput/OutlineInput.jsx +0 -188
- package/src/components/Input/RegularInput/RegularInput.jsx +0 -55
- package/src/components/Input/RegularInput/RegularInput.styles.ts +0 -98
- package/src/components/Input/index.ts +0 -1
- package/src/components/Input/readme.md +0 -82
- package/src/components/Pagination/Pagination.jsx +0 -111
- package/src/components/Pagination/index.ts +0 -1
- package/src/components/Pagination/readme.md +0 -34
- package/src/components/Radio/Radio.jsx +0 -121
- package/src/components/Radio/index.ts +0 -1
- package/src/components/Radio/readme.md +0 -90
- package/src/components/Select/Select.jsx +0 -360
- package/src/components/Select/SelectComponents.jsx +0 -342
- package/src/components/Select/index.ts +0 -1
- package/src/components/Select/readme.md +0 -2507
- package/src/components/Switch/Switch.jsx +0 -130
- package/src/components/Switch/index.ts +0 -1
- package/src/components/Switch/readme.md +0 -55
- package/src/components/Table/ExportCSVButton.jsx +0 -34
- package/src/components/Table/Table.jsx +0 -872
- package/src/components/Table/TableComponents.jsx +0 -239
- package/src/components/Table/TableFilters.jsx +0 -23
- package/src/components/Table/TableStyles.jsx +0 -514
- package/src/components/Table/index.ts +0 -1
- package/src/components/Table/readme.md +0 -2190
- package/src/components/Tabs/Tabs.jsx +0 -116
- package/src/components/Tabs/TabsComponents.jsx +0 -124
- package/src/components/Tabs/index.ts +0 -1
- package/src/components/Tabs/readme.md +0 -171
- package/src/components/Typography/Typography.jsx +0 -77
- package/src/components/Typography/index.ts +0 -1
- package/src/components/Typography/readme.md +0 -88
- package/src/components/icons/ActionsIcon.jsx +0 -24
- package/src/components/icons/AddIcon.jsx +0 -8
- package/src/components/icons/Arrow.jsx +0 -39
- package/src/components/icons/ArrowDown.jsx +0 -8
- package/src/components/icons/ArrowIcon.jsx +0 -25
- package/src/components/icons/ArrowUp.jsx +0 -8
- package/src/components/icons/BarchartHorizontal.jsx +0 -18
- package/src/components/icons/BellIcon.jsx +0 -19
- package/src/components/icons/BimiSetupIcon.jsx +0 -25
- package/src/components/icons/Chevron.jsx +0 -42
- package/src/components/icons/ChevronLeft.jsx +0 -8
- package/src/components/icons/ChevronRight.jsx +0 -8
- package/src/components/icons/ClearIcon.jsx +0 -8
- package/src/components/icons/Cloud.jsx +0 -34
- package/src/components/icons/Cross.jsx +0 -25
- package/src/components/icons/DeleteIcon.jsx +0 -19
- package/src/components/icons/DynamicDmarcIcon.jsx +0 -43
- package/src/components/icons/EditOutline.jsx +0 -8
- package/src/components/icons/Email.jsx +0 -68
- package/src/components/icons/EmailSourcesIcon.jsx +0 -36
- package/src/components/icons/ExpandLayoutIcon.jsx +0 -38
- package/src/components/icons/ExportIcon.jsx +0 -7
- package/src/components/icons/Eye.jsx +0 -28
- package/src/components/icons/Facebook.jsx +0 -31
- package/src/components/icons/FilterList.jsx +0 -8
- package/src/components/icons/FindOutHowIcon.jsx +0 -49
- package/src/components/icons/FlatArrow.jsx +0 -33
- package/src/components/icons/ForwardArrowIcon.jsx +0 -54
- package/src/components/icons/Github.jsx +0 -41
- package/src/components/icons/Globe.jsx +0 -29
- package/src/components/icons/Hand.jsx +0 -21
- package/src/components/icons/InfinityLoop.jsx +0 -22
- package/src/components/icons/InfinityLoopBreak.jsx +0 -35
- package/src/components/icons/IngrainIcon.jsx +0 -33
- package/src/components/icons/LanguageIcon.jsx +0 -44
- package/src/components/icons/Linkedin.jsx +0 -37
- package/src/components/icons/LocationPin.jsx +0 -34
- package/src/components/icons/MicrosoftShield.jsx +0 -44
- package/src/components/icons/News.jsx +0 -65
- package/src/components/icons/Nodes.jsx +0 -17
- package/src/components/icons/OnDmarcIcon.jsx +0 -29
- package/src/components/icons/OnDmarcLogo.jsx +0 -74
- package/src/components/icons/OnDomainIcon.jsx +0 -27
- package/src/components/icons/OnInboxIcon.jsx +0 -42
- package/src/components/icons/OnInboxLogo.jsx +0 -97
- package/src/components/icons/OnInboxManagerIcon.jsx +0 -46
- package/src/components/icons/OpenInNewTabIcon.jsx +0 -28
- package/src/components/icons/Padlock.jsx +0 -37
- package/src/components/icons/PlusIcon.jsx +0 -16
- package/src/components/icons/Question.jsx +0 -19
- package/src/components/icons/Recruiting.jsx +0 -34
- package/src/components/icons/ReportsIcon.jsx +0 -25
- package/src/components/icons/SearchIcon.jsx +0 -7
- package/src/components/icons/Shield.jsx +0 -17
- package/src/components/icons/ShieldPassIcon.jsx +0 -23
- package/src/components/icons/ShieldSolid.jsx +0 -33
- package/src/components/icons/ShieldWarningIcon.jsx +0 -40
- package/src/components/icons/ShieldWarningInvertedIcon.jsx +0 -36
- package/src/components/icons/Spinner.jsx +0 -100
- package/src/components/icons/Team.jsx +0 -164
- package/src/components/icons/ThreeDotsIcon.jsx +0 -18
- package/src/components/icons/Thumb.jsx +0 -17
- package/src/components/icons/Traffic.jsx +0 -22
- package/src/components/icons/Twitter.jsx +0 -47
- package/src/components/icons/Upload.jsx +0 -12
- package/src/components/icons/VerticalDots.jsx +0 -28
- package/src/components/icons/Warning.jsx +0 -36
- package/src/components/icons/WarningTriangle.jsx +0 -44
- package/src/components/icons/Youtube.jsx +0 -28
- package/src/components/icons/index.ts +0 -69
- package/src/hooks/useDebouncedValue.jsx +0 -19
- package/src/hooks/useFetch.jsx +0 -26
- package/src/hooks/useIsMobile.jsx +0 -25
- package/src/hooks/useOnClickOutside.jsx +0 -14
- package/src/hooks/useToggle.jsx +0 -8
- package/src/index.ts +0 -23
- package/tsconfig.json +0 -3
- /package/{dist/CONTRIBUTING.md → CONTRIBUTING.md} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/index.js.map → index.js.map} +0 -0
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
|
|
5
|
-
const StyledCard = styled.section`
|
|
6
|
-
background-color: #fff;
|
|
7
|
-
border-radius: 10px;
|
|
8
|
-
box-shadow: 0 2px 1px -1px rgba(0, 0, 0, 0.2), 0 1px 1px 0 rgba(0, 0, 0, 0.14),
|
|
9
|
-
0 1px 3px 0 rgba(0, 0, 0, 0.12);
|
|
10
|
-
box-sizing: border-box;
|
|
11
|
-
margin-bottom: 20px;
|
|
12
|
-
padding: ${(props) => (props.noPadding ? "" : "1.875rem")};
|
|
13
|
-
width: 100%;
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
export const Card = ({ children, className, component, noPadding, ...otherProps }) => {
|
|
17
|
-
return (
|
|
18
|
-
<StyledCard
|
|
19
|
-
{...otherProps}
|
|
20
|
-
noPadding={noPadding}
|
|
21
|
-
as={component}
|
|
22
|
-
className={className}
|
|
23
|
-
>
|
|
24
|
-
{children}
|
|
25
|
-
</StyledCard>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
Card.propTypes = {
|
|
30
|
-
children: PropTypes.node,
|
|
31
|
-
className: PropTypes.string,
|
|
32
|
-
component: PropTypes.string,
|
|
33
|
-
noPadding: PropTypes.bool,
|
|
34
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Card';
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
### Accessibility
|
|
2
|
-
|
|
3
|
-
### Props
|
|
4
|
-
|
|
5
|
-
| Prop | Default | Options |
|
|
6
|
-
| :-------: | :-------: | --------------------------------: |
|
|
7
|
-
| component | 'section' | any html element including: `div` |
|
|
8
|
-
| noPadding | | Removes padding |
|
|
9
|
-
| children | | Card contents |
|
|
10
|
-
| ...rest | | Props passed to the Wrapper |
|
|
11
|
-
|
|
12
|
-
### Examples
|
|
13
|
-
|
|
14
|
-
Common case
|
|
15
|
-
|
|
16
|
-
```js
|
|
17
|
-
<div style={{ padding: "10px", backgroundColor: "rgba(0,0,0,.05)" }}>
|
|
18
|
-
<Card>Default Card</Card>
|
|
19
|
-
</div>
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### Subcomponents
|
|
23
|
-
|
|
24
|
-
To facilitate the composition of Cards, the following components are defined:
|
|
25
|
-
|
|
26
|
-
- CardHeader
|
|
27
|
-
|
|
28
|
-
| Prop | Default | Options |
|
|
29
|
-
| :-------: | :-----: | --------------: |
|
|
30
|
-
| children | | Card contents |
|
|
31
|
-
| className | | Container class |
|
|
32
|
-
| title | | Card title |
|
|
33
|
-
|
|
34
|
-
#### NOTE
|
|
35
|
-
|
|
36
|
-
This component is for the most common situation:
|
|
37
|
-
|
|
38
|
-
- Title with h2
|
|
39
|
-
- Optional elements in the top right of the card
|
|
40
|
-
|
|
41
|
-
Using CardHeader
|
|
42
|
-
|
|
43
|
-
```js
|
|
44
|
-
import CardHeader from "../CardHeader/CardHeader";
|
|
45
|
-
|
|
46
|
-
<div style={{ padding: "10px", backgroundColor: "rgba(0,0,0,.05)" }}>
|
|
47
|
-
<Card>
|
|
48
|
-
<CardHeader title="Card Header">
|
|
49
|
-
<div>Some icons here</div>
|
|
50
|
-
</CardHeader>
|
|
51
|
-
<div>Some content</div>
|
|
52
|
-
</Card>
|
|
53
|
-
</div>;
|
|
54
|
-
```
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
import { Typography } from '../Typography';
|
|
5
|
-
|
|
6
|
-
const StyledContainer = styled.section`
|
|
7
|
-
display: flex;
|
|
8
|
-
justify-content: space-between;
|
|
9
|
-
margin-bottom: 0.5rem;
|
|
10
|
-
`;
|
|
11
|
-
|
|
12
|
-
const StyledTitle = styled(Typography)`
|
|
13
|
-
margin: 0;
|
|
14
|
-
padding: 0;
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
const StyledContent = styled.div`
|
|
18
|
-
align-items: flex-end;
|
|
19
|
-
display: flex;
|
|
20
|
-
gap: 10px;
|
|
21
|
-
`;
|
|
22
|
-
|
|
23
|
-
export const CardHeader = ({ children, className, title, ...otherProps }) => {
|
|
24
|
-
return (
|
|
25
|
-
<StyledContainer className={className} {...otherProps}>
|
|
26
|
-
{title && (
|
|
27
|
-
<StyledTitle as="h2" size="h2">
|
|
28
|
-
{title}
|
|
29
|
-
</StyledTitle>
|
|
30
|
-
)}
|
|
31
|
-
<StyledContent>{children}</StyledContent>
|
|
32
|
-
</StyledContainer>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
CardHeader.propTypes = {
|
|
37
|
-
children: PropTypes.node,
|
|
38
|
-
className: PropTypes.string,
|
|
39
|
-
title: PropTypes.string,
|
|
40
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './CardHeader';
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
import { Typography } from '../Typography';
|
|
4
|
-
|
|
5
|
-
const Wrapper = styled.label`
|
|
6
|
-
position: relative;
|
|
7
|
-
display: flex;
|
|
8
|
-
align-items: center;
|
|
9
|
-
cursor: ${props => (props.disabled ? "default" : "pointer")};
|
|
10
|
-
`;
|
|
11
|
-
|
|
12
|
-
const Input = styled.input`
|
|
13
|
-
position: absolute;
|
|
14
|
-
opacity: 0;
|
|
15
|
-
z-index: -1;
|
|
16
|
-
transition: border-color 0.2s, background-color 0.2s, transform 0.2s;
|
|
17
|
-
/* Create the background for checked status */
|
|
18
|
-
:checked + span {
|
|
19
|
-
background-color: ${props => props.checkedColor || "#000"};
|
|
20
|
-
border-color: ${props => props.checkedColor || "#000"};
|
|
21
|
-
}
|
|
22
|
-
/* Show the checkmark when checked */
|
|
23
|
-
:checked + span:after {
|
|
24
|
-
display: block;
|
|
25
|
-
}
|
|
26
|
-
/* Create the background for disabled status */
|
|
27
|
-
:disabled + span {
|
|
28
|
-
cursor: initial;
|
|
29
|
-
border-color: #ccc;
|
|
30
|
-
}
|
|
31
|
-
:checked:disabled + span {
|
|
32
|
-
cursor: initial;
|
|
33
|
-
background-color: #ccc;
|
|
34
|
-
border-color: #ccc;
|
|
35
|
-
}
|
|
36
|
-
`;
|
|
37
|
-
|
|
38
|
-
const CheckIndicator = styled.span`
|
|
39
|
-
/* Create the box */
|
|
40
|
-
position: relative;
|
|
41
|
-
-webkit-user-select: none;
|
|
42
|
-
-moz-user-select: none;
|
|
43
|
-
-ms-user-select: none;
|
|
44
|
-
user-select: none;
|
|
45
|
-
background-color: #fff;
|
|
46
|
-
content: "";
|
|
47
|
-
display: inline-block;
|
|
48
|
-
box-sizing: border-box;
|
|
49
|
-
border: solid 2px;
|
|
50
|
-
border-color: ${props => props.borderColor || "rgba(0, 0, 0 , .54)"};
|
|
51
|
-
border-radius: 2px;
|
|
52
|
-
width: 18px;
|
|
53
|
-
height: 18px;
|
|
54
|
-
vertical-align: top;
|
|
55
|
-
transition: border-color 0.2s, background-color 0.2s;
|
|
56
|
-
|
|
57
|
-
/* Create the checkmark */
|
|
58
|
-
:after {
|
|
59
|
-
content: "";
|
|
60
|
-
position: absolute;
|
|
61
|
-
display: none;
|
|
62
|
-
top: ${props => (props.dashed ? "6px" : "0px")};
|
|
63
|
-
left: ${props => (props.dashed ? "2px" : "4px")};
|
|
64
|
-
width: ${props => (props.dashed ? "10px" : "5px")};
|
|
65
|
-
height: 10px;
|
|
66
|
-
border: solid white;
|
|
67
|
-
border-width: ${props =>
|
|
68
|
-
props.dashed ? "2px 0px 0px 0px" : "0 2px 2px 0"};
|
|
69
|
-
-webkit-transform: ${props => (props.dashed ? "" : "rotate(45deg)")};
|
|
70
|
-
-ms-transform: ${props => (props.dashed ? "" : "rotate(45deg)")};
|
|
71
|
-
transform: ${props => (props.dashed ? "" : "rotate(45deg)")};
|
|
72
|
-
}
|
|
73
|
-
`;
|
|
74
|
-
|
|
75
|
-
const Text = styled(Typography)`
|
|
76
|
-
margin-left: ${props => (props.hideLabel ? "0px" : "10px")};
|
|
77
|
-
`;
|
|
78
|
-
|
|
79
|
-
export const Checkbox = props => {
|
|
80
|
-
const {
|
|
81
|
-
color,
|
|
82
|
-
inputProps,
|
|
83
|
-
labelProps,
|
|
84
|
-
checked,
|
|
85
|
-
defaultChecked,
|
|
86
|
-
disabled,
|
|
87
|
-
onChange,
|
|
88
|
-
label,
|
|
89
|
-
checkProps,
|
|
90
|
-
borderColor,
|
|
91
|
-
hideLabel,
|
|
92
|
-
dashed,
|
|
93
|
-
...rest
|
|
94
|
-
} = props;
|
|
95
|
-
return (
|
|
96
|
-
<Wrapper {...rest} disabled={disabled}>
|
|
97
|
-
<Input
|
|
98
|
-
checkedColor={color}
|
|
99
|
-
checked={checked}
|
|
100
|
-
defaultChecked={defaultChecked}
|
|
101
|
-
disabled={disabled}
|
|
102
|
-
onChange={onChange}
|
|
103
|
-
aria-label={label}
|
|
104
|
-
{...inputProps}
|
|
105
|
-
type="checkbox"
|
|
106
|
-
/>
|
|
107
|
-
<CheckIndicator
|
|
108
|
-
dashed={dashed}
|
|
109
|
-
borderColor={borderColor}
|
|
110
|
-
checkedColor={color}
|
|
111
|
-
{...checkProps}
|
|
112
|
-
/>
|
|
113
|
-
<Text
|
|
114
|
-
hideLabel={hideLabel}
|
|
115
|
-
component="span"
|
|
116
|
-
color={disabled ? "#ccc" : "#333"}
|
|
117
|
-
{...labelProps}
|
|
118
|
-
>
|
|
119
|
-
{!hideLabel && label}
|
|
120
|
-
</Text>
|
|
121
|
-
</Wrapper>
|
|
122
|
-
);
|
|
123
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Checkbox';
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
### Accessibility
|
|
2
|
-
|
|
3
|
-
- Ensure label is provided
|
|
4
|
-
|
|
5
|
-
### Props
|
|
6
|
-
|
|
7
|
-
| Prop | Default | Options |
|
|
8
|
-
| :------------: | :-----------------: | ---------------------------------------------------: |
|
|
9
|
-
| color | #000 | Color |
|
|
10
|
-
| borderColor | rgba(0, 0, 0 , .54) | Color |
|
|
11
|
-
| label | | string **Required** |
|
|
12
|
-
| checked | false | Boolean |
|
|
13
|
-
| dashed | false | Shows a dash instead of a check when checked is true |
|
|
14
|
-
| defaultChecked | false | Boolean |
|
|
15
|
-
| disabled | false | Boolean |
|
|
16
|
-
| onChange | | Function |
|
|
17
|
-
| checkProps | | Passes props to the Check Indicator |
|
|
18
|
-
| inputProps | | Passes props to the Input |
|
|
19
|
-
| ...rest | | Passes props to the Wrapper |
|
|
20
|
-
|
|
21
|
-
### Examples
|
|
22
|
-
|
|
23
|
-
```js
|
|
24
|
-
<div
|
|
25
|
-
style={{
|
|
26
|
-
display: "flex",
|
|
27
|
-
flexWrap: "wrap",
|
|
28
|
-
flexDirection: "row",
|
|
29
|
-
alignItems: "center",
|
|
30
|
-
justifyContent: "space-evenly"
|
|
31
|
-
}}
|
|
32
|
-
>
|
|
33
|
-
<Checkbox label="Default" />
|
|
34
|
-
<Checkbox color="#02ac61" borderColor="#02ac61" label="OnDMARC" />
|
|
35
|
-
<Checkbox color="#33b222" borderColor="#33b222" label="OnINBOX" />
|
|
36
|
-
|
|
37
|
-
<Checkbox color="#53C3EB" borderColor="#53C3EB" label="InGRAIN" />
|
|
38
|
-
<Checkbox color="#02ac61" borderColor="#02ac61" disabled label="Disabled" />
|
|
39
|
-
<Checkbox
|
|
40
|
-
color="#02ac61"
|
|
41
|
-
borderColor="#02ac61"
|
|
42
|
-
checked
|
|
43
|
-
disabled
|
|
44
|
-
label="Disabled"
|
|
45
|
-
/>
|
|
46
|
-
<Checkbox
|
|
47
|
-
color="#33b222"
|
|
48
|
-
borderColor="#33b222"
|
|
49
|
-
label="Dashed"
|
|
50
|
-
dashed
|
|
51
|
-
defaultChecked={true}
|
|
52
|
-
/>
|
|
53
|
-
</div>
|
|
54
|
-
```
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import React, { useMemo, useState, useEffect } from 'react';
|
|
2
|
-
import { Checkbox } from '../Checkbox';
|
|
3
|
-
import * as Styled from "./CheckboxTree.styles";
|
|
4
|
-
|
|
5
|
-
// Types
|
|
6
|
-
//
|
|
7
|
-
// export type CheckboxTreeNode = {
|
|
8
|
-
// name: string;
|
|
9
|
-
// branches?: CheckboxTreeNode[];
|
|
10
|
-
// key?: string;
|
|
11
|
-
// };
|
|
12
|
-
//
|
|
13
|
-
// type CheckedNodes = Record<string, string>;
|
|
14
|
-
//
|
|
15
|
-
// type TreeNodeProps = {
|
|
16
|
-
// node: CheckboxTreeNode;
|
|
17
|
-
// onSelectNode: (node: CheckboxTreeNode) => void;
|
|
18
|
-
// checkedNodes: CheckedNodes;
|
|
19
|
-
// isDisabled?: boolean;
|
|
20
|
-
// };
|
|
21
|
-
//
|
|
22
|
-
// type CheckboxTreeProps = {
|
|
23
|
-
// data: CheckboxTreeNode[];
|
|
24
|
-
// onChange: (checkedNodesList: string[]) => void;
|
|
25
|
-
// initialChecked?: Boolean;
|
|
26
|
-
// };
|
|
27
|
-
|
|
28
|
-
/*
|
|
29
|
-
type TAddKeysToNodeParams = {
|
|
30
|
-
node: CheckboxTreeNode;
|
|
31
|
-
nodeIndex: number;
|
|
32
|
-
rootKey?: string;
|
|
33
|
-
};
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
export const addKeysToNode = ({ node, nodeIndex, rootKey }) => {
|
|
37
|
-
const key = rootKey ? `${rootKey}.${nodeIndex}` : String(nodeIndex);
|
|
38
|
-
return {
|
|
39
|
-
...node,
|
|
40
|
-
key,
|
|
41
|
-
branches: (node.branches || []).map((branchNode, branchNodeIndex) =>
|
|
42
|
-
addKeysToNode({
|
|
43
|
-
node: branchNode,
|
|
44
|
-
nodeIndex: branchNodeIndex,
|
|
45
|
-
rootKey: key,
|
|
46
|
-
})
|
|
47
|
-
),
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/*
|
|
52
|
-
type TUpdateNodesParams = {
|
|
53
|
-
nodes: CheckboxTreeNode[];
|
|
54
|
-
checkedNds: CheckedNodes;
|
|
55
|
-
addChildren: boolean;
|
|
56
|
-
}
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
export const updateNodes = ({ nodes, checkedNds, addChildren }) => {
|
|
60
|
-
let newCheckedNodes = { ...checkedNds };
|
|
61
|
-
nodes.forEach((node) => {
|
|
62
|
-
if (addChildren) {
|
|
63
|
-
newCheckedNodes[node.key] = node.name;
|
|
64
|
-
} else {
|
|
65
|
-
delete newCheckedNodes[node.key];
|
|
66
|
-
}
|
|
67
|
-
if (node.branches && node.branches.length > 0) {
|
|
68
|
-
newCheckedNodes = updateNodes({
|
|
69
|
-
nodes: node.branches,
|
|
70
|
-
checkedNds: newCheckedNodes,
|
|
71
|
-
addChildren,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
return newCheckedNodes;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
// TreeNode Component
|
|
79
|
-
const TreeNode = ({ node, onSelectNode, checkedNodes, isDisabled }) => {
|
|
80
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
81
|
-
const toggleIsOpen = () => setIsOpen(!isOpen);
|
|
82
|
-
const isChecked = Boolean(checkedNodes[node.key]);
|
|
83
|
-
const hasBranches = Boolean(node.branches && node.branches.length > 0);
|
|
84
|
-
const renderCheckboxRow = () => (
|
|
85
|
-
<Styled.ListRow>
|
|
86
|
-
<Checkbox
|
|
87
|
-
checked={isChecked}
|
|
88
|
-
onChange={() => onSelectNode(node)}
|
|
89
|
-
disabled={isDisabled}
|
|
90
|
-
/>
|
|
91
|
-
<span>{node.name}</span>
|
|
92
|
-
</Styled.ListRow>
|
|
93
|
-
);
|
|
94
|
-
const renderNodeRow = () => (
|
|
95
|
-
<>
|
|
96
|
-
<Styled.ListRow onClick={toggleIsOpen}>
|
|
97
|
-
{node.branches && <Styled.Arrow data-open={isOpen} />}
|
|
98
|
-
<Checkbox
|
|
99
|
-
checked={isChecked}
|
|
100
|
-
onChange={() => onSelectNode(node)}
|
|
101
|
-
disabled={isDisabled}
|
|
102
|
-
/>
|
|
103
|
-
<span>{node.name}</span>
|
|
104
|
-
</Styled.ListRow>
|
|
105
|
-
<Styled.ListDropdown data-open={isOpen}>
|
|
106
|
-
{(node.branches || []).map((branchNode) => (
|
|
107
|
-
<TreeNode
|
|
108
|
-
key={`nodeTree.${branchNode.key}.${branchNode.name}`}
|
|
109
|
-
node={branchNode}
|
|
110
|
-
onSelectNode={onSelectNode}
|
|
111
|
-
checkedNodes={checkedNodes}
|
|
112
|
-
isDisabled={isDisabled || isChecked}
|
|
113
|
-
/>
|
|
114
|
-
))}
|
|
115
|
-
</Styled.ListDropdown>
|
|
116
|
-
</>
|
|
117
|
-
);
|
|
118
|
-
return <div>{hasBranches ? renderNodeRow() : renderCheckboxRow()}</div>;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
// CheckboxTree Component
|
|
122
|
-
export const CheckboxTree = ({ data, onChange, initialChecked }) => {
|
|
123
|
-
const [checkedNodes, setCheckedNodes] = useState({});
|
|
124
|
-
|
|
125
|
-
const parsedNodes = useMemo(() => {
|
|
126
|
-
return data.map((node, nodeIndex) => addKeysToNode({ node, nodeIndex }));
|
|
127
|
-
}, [data]);
|
|
128
|
-
|
|
129
|
-
useEffect(() => {
|
|
130
|
-
if (initialChecked) {
|
|
131
|
-
const newCheckedNodes = updateNodes({
|
|
132
|
-
nodes: parsedNodes,
|
|
133
|
-
checkedNds: {},
|
|
134
|
-
addChildren: true,
|
|
135
|
-
});
|
|
136
|
-
setCheckedNodes(newCheckedNodes);
|
|
137
|
-
if (onChange) {
|
|
138
|
-
onChange(Object.values(newCheckedNodes));
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}, [initialChecked, parsedNodes]);
|
|
142
|
-
|
|
143
|
-
const onSelectNode = (node) => {
|
|
144
|
-
const newCheckedNodes = updateNodes({
|
|
145
|
-
nodes: [node],
|
|
146
|
-
checkedNds: checkedNodes,
|
|
147
|
-
addChildren: Boolean(!checkedNodes[node.key]),
|
|
148
|
-
});
|
|
149
|
-
setCheckedNodes(newCheckedNodes);
|
|
150
|
-
if (onChange) {
|
|
151
|
-
onChange(Object.values(newCheckedNodes));
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
return (
|
|
156
|
-
<Styled.Container>
|
|
157
|
-
{parsedNodes.map((node) => (
|
|
158
|
-
<TreeNode
|
|
159
|
-
key={`nodeTree.${node.key}.${node.name}`}
|
|
160
|
-
node={node}
|
|
161
|
-
onSelectNode={onSelectNode}
|
|
162
|
-
checkedNodes={checkedNodes}
|
|
163
|
-
/>
|
|
164
|
-
))}
|
|
165
|
-
</Styled.Container>
|
|
166
|
-
);
|
|
167
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import styled from "styled-components";
|
|
2
|
-
|
|
3
|
-
export const Container = styled.div``;
|
|
4
|
-
|
|
5
|
-
export const ListRow = styled.div`
|
|
6
|
-
display: flex;
|
|
7
|
-
flex-direction: row;
|
|
8
|
-
align-items: center;
|
|
9
|
-
justify-content: flex-start;
|
|
10
|
-
margin-bottom: 16px;
|
|
11
|
-
`;
|
|
12
|
-
|
|
13
|
-
export const ListDropdown = styled.div`
|
|
14
|
-
height: 0;
|
|
15
|
-
opacity: 0;
|
|
16
|
-
overflow: hidden;
|
|
17
|
-
transition: all 0.3s;
|
|
18
|
-
|
|
19
|
-
padding: 0;
|
|
20
|
-
|
|
21
|
-
&[data-open="true"] {
|
|
22
|
-
opacity: 1;
|
|
23
|
-
height: auto;
|
|
24
|
-
padding-left: 16px;
|
|
25
|
-
}
|
|
26
|
-
`;
|
|
27
|
-
|
|
28
|
-
export const Arrow = styled.div`
|
|
29
|
-
width: 0;
|
|
30
|
-
height: 0;
|
|
31
|
-
border-top: 6px solid transparent;
|
|
32
|
-
border-bottom: 6px solid transparent;
|
|
33
|
-
|
|
34
|
-
border-left: 6px solid #000;
|
|
35
|
-
|
|
36
|
-
transform: rotate(0deg);
|
|
37
|
-
transition: all 0.2s;
|
|
38
|
-
|
|
39
|
-
margin-right: 12px;
|
|
40
|
-
|
|
41
|
-
&[data-open="true"] {
|
|
42
|
-
transform: rotate(90deg);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
&,
|
|
46
|
-
& ~ span {
|
|
47
|
-
cursor: pointer;
|
|
48
|
-
}
|
|
49
|
-
`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './CheckboxTree';
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
### General
|
|
2
|
-
|
|
3
|
-
- When a node is selected, all its children are selected.
|
|
4
|
-
- Can be used as a checkbox list.
|
|
5
|
-
|
|
6
|
-
### Props
|
|
7
|
-
|
|
8
|
-
| Prop | Default | Options |
|
|
9
|
-
| :------------: | :-----: | -----------------------------------------------------: |
|
|
10
|
-
| data | | CheckboxTreeNode[]. Required |
|
|
11
|
-
| onChange | | Function, triggered on pressing any checkbox. Required |
|
|
12
|
-
| initialChecked | | All boxes start checked |
|
|
13
|
-
|
|
14
|
-
### Types
|
|
15
|
-
|
|
16
|
-
```md
|
|
17
|
-
type TCheckboxTreeNode = { name: string; branches?: TCheckboxTreeNode[]; key?: string; };
|
|
18
|
-
|
|
19
|
-
type TCheckedNodes = Record<string, string>;
|
|
20
|
-
|
|
21
|
-
type TTreeNodeProps = { node: CheckboxTreeNode; onSelectNode: (node: CheckboxTreeNode) => void; checkedNodes:
|
|
22
|
-
CheckedNodes; isDisabled?: boolean; };
|
|
23
|
-
|
|
24
|
-
type TCheckboxTreeProps = { data: CheckboxTreeNode[]; onChange: (checkedNodesList: string[]) => void; initialChecked?:
|
|
25
|
-
Boolean; };
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### Examples
|
|
29
|
-
|
|
30
|
-
```js
|
|
31
|
-
const data = [
|
|
32
|
-
{
|
|
33
|
-
name: "domain.com",
|
|
34
|
-
branches: [
|
|
35
|
-
{ name: "subdomain.domain.com" },
|
|
36
|
-
{
|
|
37
|
-
name: "otherSubdomain.domain.com",
|
|
38
|
-
branches: [{ name: "otherSubdomain.domain.com/about" }],
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
},
|
|
42
|
-
{ name: "fakeDomain.com" },
|
|
43
|
-
{ name: "error.com" },
|
|
44
|
-
];
|
|
45
|
-
const onChange = (checkedNodesList) =>
|
|
46
|
-
console.log("CheckboxTree =>", checkedNodesList);
|
|
47
|
-
|
|
48
|
-
<div
|
|
49
|
-
style={{
|
|
50
|
-
display: "flex",
|
|
51
|
-
flexWrap: "wrap",
|
|
52
|
-
flexDirection: "row",
|
|
53
|
-
alignItems: "center",
|
|
54
|
-
justifyContent: "space-evenly",
|
|
55
|
-
}}
|
|
56
|
-
>
|
|
57
|
-
<CheckboxTree data={data} onChange={onChange} />
|
|
58
|
-
<CheckboxTree data={data} onChange={onChange} initialChecked />
|
|
59
|
-
</div>;
|
|
60
|
-
```
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import styled, { css } from 'styled-components';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
|
|
5
|
-
const StyledIconContainer = styled.div`
|
|
6
|
-
${({ fill = "#000000", size = '24px' }) => {
|
|
7
|
-
return css`
|
|
8
|
-
display: flex;
|
|
9
|
-
fill: ${fill };
|
|
10
|
-
height: ${size};
|
|
11
|
-
width: ${size};
|
|
12
|
-
align-items: center;
|
|
13
|
-
justify-content: center;
|
|
14
|
-
|
|
15
|
-
svg,
|
|
16
|
-
img {
|
|
17
|
-
width: 100%;
|
|
18
|
-
height: 100%;
|
|
19
|
-
margin: 0 !important;
|
|
20
|
-
padding: 0;
|
|
21
|
-
}
|
|
22
|
-
svg {
|
|
23
|
-
.stroke {
|
|
24
|
-
stroke: ${fill };
|
|
25
|
-
}
|
|
26
|
-
.fill {
|
|
27
|
-
fill: ${fill };
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
`;
|
|
31
|
-
}}
|
|
32
|
-
`;
|
|
33
|
-
|
|
34
|
-
export const IconContainer = ({ children, className, size, fill }) => {
|
|
35
|
-
return (
|
|
36
|
-
<StyledIconContainer className={className} fill={fill} size={size}>
|
|
37
|
-
{children}
|
|
38
|
-
</StyledIconContainer>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const IconContainerPropTypes = {
|
|
43
|
-
className: PropTypes.string,
|
|
44
|
-
fill: PropTypes.string,
|
|
45
|
-
size: PropTypes.string,
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
IconContainer.propTypes = {
|
|
49
|
-
...IconContainerPropTypes,
|
|
50
|
-
children: PropTypes.node.isRequired,
|
|
51
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './IconContainer';
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { OutlineInput } from "./OutlineInput/OutlineInput";
|
|
3
|
-
import { RegularInput } from "./RegularInput/RegularInput";
|
|
4
|
-
|
|
5
|
-
export const Input = ({ color, label, errorText, placeholder, outlined, ...rest }) =>
|
|
6
|
-
outlined ? (
|
|
7
|
-
<OutlineInput
|
|
8
|
-
placeholder={placeholder}
|
|
9
|
-
label={label}
|
|
10
|
-
errorText={errorText}
|
|
11
|
-
color={color}
|
|
12
|
-
{...rest}
|
|
13
|
-
/>
|
|
14
|
-
) : (
|
|
15
|
-
<RegularInput
|
|
16
|
-
placeholder={placeholder}
|
|
17
|
-
label={label}
|
|
18
|
-
errorText={errorText}
|
|
19
|
-
color={color}
|
|
20
|
-
hideUnderline={rest.hideUnderline}
|
|
21
|
-
helperText={rest.helperText}
|
|
22
|
-
leftIcon={rest.leftIcon}
|
|
23
|
-
rightIcon={rest.rightIcon}
|
|
24
|
-
showClear={rest.showClear}
|
|
25
|
-
{...rest}
|
|
26
|
-
/>
|
|
27
|
-
);
|