@manuscripts/style-guide 3.4.0 → 3.4.2
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/dist/cjs/components/Checkbox.js +34 -16
- package/dist/cjs/components/ContextMenu.js +1 -1
- package/dist/cjs/components/Form.js +94 -1
- package/dist/cjs/components/Menus/Menus.js +3 -3
- package/dist/cjs/components/Menus/Shortcut.js +1 -1
- package/dist/cjs/components/Menus/Submenu.js +11 -7
- package/dist/cjs/components/MultiValueInput.js +3 -3
- package/dist/cjs/components/RadioButton.js +62 -39
- package/dist/cjs/components/SelectField.js +90 -1
- package/dist/cjs/components/StyledModal.js +20 -1
- package/dist/cjs/components/TextField.js +57 -11
- package/dist/cjs/components/ToggleSwitch.js +69 -0
- package/dist/cjs/hooks/use-menus.js +5 -3
- package/dist/cjs/index.js +1 -0
- package/dist/es/components/Checkbox.js +34 -16
- package/dist/es/components/ContextMenu.js +1 -1
- package/dist/es/components/Form.js +93 -0
- package/dist/es/components/Menus/Menus.js +3 -3
- package/dist/es/components/Menus/Shortcut.js +1 -1
- package/dist/es/components/Menus/Submenu.js +11 -7
- package/dist/es/components/MultiValueInput.js +3 -3
- package/dist/es/components/RadioButton.js +62 -39
- package/dist/es/components/SelectField.js +90 -1
- package/dist/es/components/StyledModal.js +19 -0
- package/dist/es/components/TextField.js +56 -10
- package/dist/es/components/ToggleSwitch.js +62 -0
- package/dist/es/hooks/use-menus.js +5 -3
- package/dist/es/index.js +1 -0
- package/dist/types/components/Form.d.ts +15 -0
- package/dist/types/components/Menus/Menus.d.ts +1 -1
- package/dist/types/components/Menus/Submenu.d.ts +1 -1
- package/dist/types/components/SelectField.d.ts +4 -1
- package/dist/types/components/StyledModal.d.ts +4 -0
- package/dist/types/components/TextField.d.ts +16 -4
- package/dist/types/components/ToggleSwitch.d.ts +25 -0
- package/dist/types/hooks/use-menus.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lib/menus.d.ts +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ToggleSwitch = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const Track = styled_components_1.default.button `
|
|
10
|
+
position: relative;
|
|
11
|
+
width: 30px;
|
|
12
|
+
height: 16px;
|
|
13
|
+
border-radius: 999px;
|
|
14
|
+
border: 1px solid
|
|
15
|
+
${(props) => props.checked ? '#0d79d0' : props.theme.colors.text.secondary};
|
|
16
|
+
background: ${(props) => props.checked ? '#0d79d0' : props.theme.colors.text.secondary};
|
|
17
|
+
padding: 0;
|
|
18
|
+
cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};
|
|
19
|
+
transition:
|
|
20
|
+
background-color 120ms ease,
|
|
21
|
+
border-color 120ms ease,
|
|
22
|
+
box-shadow 120ms ease;
|
|
23
|
+
outline: none;
|
|
24
|
+
flex-shrink: 0;
|
|
25
|
+
|
|
26
|
+
&:focus-visible {
|
|
27
|
+
box-shadow: 0 0 0 2px #0d79d04d;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&:disabled {
|
|
31
|
+
background: #c9c9c9;
|
|
32
|
+
border-color: #c9c9c9;
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
const Thumb = styled_components_1.default.span `
|
|
36
|
+
position: absolute;
|
|
37
|
+
top: 0;
|
|
38
|
+
left: ${(props) => (props.checked ? '14px' : '0px')};
|
|
39
|
+
width: 14px;
|
|
40
|
+
height: 14px;
|
|
41
|
+
border-radius: 50%;
|
|
42
|
+
background: #fff;
|
|
43
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
|
44
|
+
transition: left 120ms ease;
|
|
45
|
+
|
|
46
|
+
${(props) => props.disabled &&
|
|
47
|
+
`
|
|
48
|
+
background: #fdfdfd;
|
|
49
|
+
box-shadow: none;
|
|
50
|
+
`}
|
|
51
|
+
`;
|
|
52
|
+
const LabelText = styled_components_1.default.span `
|
|
53
|
+
color: ${(props) => props.disabled ? '#b3b3b3' : props.theme.colors.text.primary};
|
|
54
|
+
font: ${(props) => props.theme.font.weight.normal}
|
|
55
|
+
${(props) => props.theme.font.size.medium} / 1
|
|
56
|
+
${(props) => props.theme.font.family.sans};
|
|
57
|
+
line-height: 20px;
|
|
58
|
+
`;
|
|
59
|
+
const Container = styled_components_1.default.label `
|
|
60
|
+
display: inline-flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
gap: 8px;
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
flex-direction: ${(props) => props.labelPosition === 'left' ? 'row' : 'row-reverse'};
|
|
65
|
+
`;
|
|
66
|
+
const ToggleSwitch = ({ checked, disabled, onChange, label, id, labelPosition = 'left', }) => {
|
|
67
|
+
return ((0, jsx_runtime_1.jsxs)(Container, { labelPosition: labelPosition, children: [label && (0, jsx_runtime_1.jsx)(LabelText, { disabled: disabled, children: label }), (0, jsx_runtime_1.jsx)(Track, { id: id, type: "button", role: "switch", "aria-checked": checked, "aria-label": label, checked: checked, disabled: disabled, onClick: () => !disabled && onChange(!checked), children: (0, jsx_runtime_1.jsx)(Thumb, { checked: checked, disabled: disabled }) })] }));
|
|
68
|
+
};
|
|
69
|
+
exports.ToggleSwitch = ToggleSwitch;
|
|
@@ -31,6 +31,7 @@ const getSubmenuState = (specs, pointer, position) => {
|
|
|
31
31
|
const current = [...position, index];
|
|
32
32
|
return {
|
|
33
33
|
...spec,
|
|
34
|
+
position: current,
|
|
34
35
|
submenu: spec.submenu && getSubmenuState(spec.submenu, pointer, current),
|
|
35
36
|
isOpen: isPart(pointer, current),
|
|
36
37
|
};
|
|
@@ -41,6 +42,7 @@ const getMenuState = (specs, pointer) => {
|
|
|
41
42
|
const position = [index];
|
|
42
43
|
return {
|
|
43
44
|
...spec,
|
|
45
|
+
position,
|
|
44
46
|
submenu: spec.submenu && getSubmenuState(spec.submenu, pointer, position),
|
|
45
47
|
isOpen: isPart(pointer, position),
|
|
46
48
|
};
|
|
@@ -89,13 +91,13 @@ const useMenus = (menus) => {
|
|
|
89
91
|
document.removeEventListener('click', handleClickOutside);
|
|
90
92
|
};
|
|
91
93
|
}, []);
|
|
92
|
-
const
|
|
93
|
-
setPointer(initialPointer);
|
|
94
|
+
const close = (0, react_1.useCallback)((depth) => {
|
|
95
|
+
setPointer(depth === undefined ? initialPointer : transformPointer(depth, -1));
|
|
94
96
|
}, []);
|
|
95
97
|
return {
|
|
96
98
|
menus: state,
|
|
97
99
|
handleClick,
|
|
98
|
-
|
|
100
|
+
close,
|
|
99
101
|
ref,
|
|
100
102
|
};
|
|
101
103
|
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -51,6 +51,7 @@ __exportStar(require("./components/TextField"), exports);
|
|
|
51
51
|
__exportStar(require("./components/TextFieldContainer"), exports);
|
|
52
52
|
__exportStar(require("./components/TextFieldError"), exports);
|
|
53
53
|
__exportStar(require("./components/TextFieldGroupContainer"), exports);
|
|
54
|
+
__exportStar(require("./components/ToggleSwitch"), exports);
|
|
54
55
|
var ToggleHeader_1 = require("./components/ToggleHeader");
|
|
55
56
|
Object.defineProperty(exports, "ToggleHeader", { enumerable: true, get: function () { return ToggleHeader_1.ToggleHeader; } });
|
|
56
57
|
Object.defineProperty(exports, "ToggleIcon", { enumerable: true, get: function () { return ToggleHeader_1.ToggleIcon; } });
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import styled from 'styled-components';
|
|
17
|
+
const CHECKED_ICON = 'data:image/svg+xml,%3Csvg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath fill-rule="evenodd" clip-rule="evenodd" d="M0 4C0 1.79086 1.79086 0 4 0H12C14.2091 0 16 1.79086 16 4V12C16 14.2091 14.2091 16 12 16H4C1.79086 16 0 14.2091 0 12V4Z" fill="%230D79D0"/%3E%3Cpath d="M6.48052 9.81367L11.5848 4.26912C11.7499 4.08971 11.9444 4 12.1685 4C12.3926 4 12.5872 4.08971 12.7523 4.26912C12.9174 4.44842 13 4.66099 13 4.90684C13 5.15269 12.9174 5.36531 12.7523 5.54473L7.06432 11.7309C6.89916 11.9103 6.70456 12 6.48052 12C6.25648 12 6.06187 11.9103 5.89671 11.7309L3.24437 8.84968C3.07921 8.67026 2.99777 8.45763 3.00005 8.21179C3.00232 7.96594 3.08604 7.75337 3.2512 7.57407C3.41626 7.39465 3.61195 7.30495 3.83827 7.30495C4.06458 7.30495 4.26032 7.39465 4.42548 7.57407L6.48052 9.81367Z" fill="white" stroke="white" stroke-width="0.5"/%3E%3C/svg%3E';
|
|
17
18
|
export const CheckboxLabel = styled.label `
|
|
18
19
|
input {
|
|
19
20
|
border: 0;
|
|
@@ -30,39 +31,56 @@ export const CheckboxLabel = styled.label `
|
|
|
30
31
|
|
|
31
32
|
div {
|
|
32
33
|
align-items: center;
|
|
33
|
-
|
|
34
|
+
font-family: ${(props) => props.theme.font.family.sans};
|
|
35
|
+
font-size: ${(props) => props.theme.font.size.normal};
|
|
36
|
+
font-weight: ${(props) => props.theme.font.weight.normal};
|
|
37
|
+
color: ${(props) => props.disabled
|
|
38
|
+
? props.theme.colors.text.muted
|
|
39
|
+
: props.theme.colors.text.primary};
|
|
34
40
|
display: flex;
|
|
35
41
|
flex-wrap: nowrap;
|
|
36
|
-
line-height:
|
|
37
|
-
margin:
|
|
42
|
+
line-height: 20px;
|
|
43
|
+
margin: 8px 0;
|
|
44
|
+
cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};
|
|
38
45
|
|
|
39
46
|
&::before {
|
|
40
|
-
content: '
|
|
47
|
+
content: '';
|
|
41
48
|
display: inline-block;
|
|
42
49
|
flex-shrink: 0;
|
|
43
50
|
width: 16px;
|
|
44
51
|
height: 16px;
|
|
45
|
-
border:
|
|
46
|
-
border-radius:
|
|
47
|
-
margin-right:
|
|
52
|
+
border: 1.5px solid ${(props) => props.theme.colors.border.field.default};
|
|
53
|
+
border-radius: 3px;
|
|
54
|
+
margin-right: 10px;
|
|
48
55
|
text-align: center;
|
|
56
|
+
background: ${(props) => props.theme.colors.background.primary};
|
|
49
57
|
}
|
|
50
58
|
}
|
|
51
59
|
|
|
60
|
+
|
|
52
61
|
input:checked + div::before {
|
|
53
|
-
background:
|
|
54
|
-
border-color:
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
background-color: transparent !important;
|
|
63
|
+
border-color: transparent !important;
|
|
64
|
+
background-image: url('${CHECKED_ICON}') !important;
|
|
65
|
+
background-repeat: no-repeat !important;
|
|
66
|
+
background-position: center !important;
|
|
67
|
+
background-size: cover !important;
|
|
57
68
|
}
|
|
58
69
|
|
|
59
|
-
input:focus + div::before {
|
|
60
|
-
|
|
70
|
+
input:focus-visible + div::before {
|
|
71
|
+
outline: none;
|
|
61
72
|
}
|
|
62
73
|
|
|
63
|
-
input:
|
|
64
|
-
|
|
65
|
-
|
|
74
|
+
input:disabled + div::before {
|
|
75
|
+
background: ${(props) => props.theme.colors.background.fifth};
|
|
76
|
+
border-color: ${(props) => props.theme.colors.border.field.default};
|
|
77
|
+
}
|
|
78
|
+
input:disabled + div {
|
|
79
|
+
color: ${(props) => props.theme.colors.text.secondary};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
input:checked:disabled + div::before {
|
|
83
|
+
filter: grayscale(1) opacity(0.4);
|
|
66
84
|
}
|
|
67
85
|
`;
|
|
68
86
|
export const CheckboxField = styled.input.attrs({
|
|
@@ -3,7 +3,7 @@ import styled from 'styled-components';
|
|
|
3
3
|
import { IconButton, IconButtonGroup } from './Button';
|
|
4
4
|
import * as Icons from './icons';
|
|
5
5
|
const ContextMenuIconButton = styled(IconButton) `
|
|
6
|
-
color:
|
|
6
|
+
color: ${(props) => props.theme.colors.text.secondary};
|
|
7
7
|
&:not([disabled]).selected {
|
|
8
8
|
background-color: #c9c9c9;
|
|
9
9
|
}
|
|
@@ -43,3 +43,96 @@ export const FormError = styled.div `
|
|
|
43
43
|
position: relative;
|
|
44
44
|
padding: 12px;
|
|
45
45
|
`;
|
|
46
|
+
export const FormContainer = styled.div `
|
|
47
|
+
margin: 0 auto;
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
gap: ${(props) => props.theme.grid.unit * 4}px;
|
|
51
|
+
padding: ${(props) => props.theme.grid.unit * 4}px;
|
|
52
|
+
box-sizing: border-box;
|
|
53
|
+
`;
|
|
54
|
+
export const FormField = styled.div `
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
gap: 4px;
|
|
58
|
+
`;
|
|
59
|
+
export const FormRow = styled.div `
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-direction: ${(props) => props.direction ?? 'column'};
|
|
62
|
+
gap: ${(props) => props.theme.grid.unit * 2}px;
|
|
63
|
+
margin-bottom: ${(props) => props.theme.grid.unit * 4}px;
|
|
64
|
+
justify-content: ${(props) => props.justify ?? 'flex-start'};
|
|
65
|
+
align-items: ${(props) => props.align ?? (props.direction === 'row' ? 'center' : 'stretch')};
|
|
66
|
+
flex-wrap: ${(props) => (props.direction === 'row' ? 'wrap' : 'nowrap')};
|
|
67
|
+
`;
|
|
68
|
+
export const FormLabel = styled.legend `
|
|
69
|
+
&:not(:first-child) {
|
|
70
|
+
margin-top: 15px;
|
|
71
|
+
}
|
|
72
|
+
margin-bottom: 15px;
|
|
73
|
+
font: ${(props) => props.theme.font.weight.normal}
|
|
74
|
+
${(props) => props.theme.font.size.xlarge} /
|
|
75
|
+
${(props) => props.theme.font.lineHeight.large}
|
|
76
|
+
${(props) => props.theme.font.family.sans};
|
|
77
|
+
letter-spacing: -0.4px;
|
|
78
|
+
color: ${(props) => props.theme.colors.text.secondary};
|
|
79
|
+
`;
|
|
80
|
+
export const FormActionsBar = styled.div `
|
|
81
|
+
display: flex;
|
|
82
|
+
flex-wrap: wrap;
|
|
83
|
+
justify-content: flex-end;
|
|
84
|
+
gap: ${(props) => props.theme.grid.unit * 2}px;
|
|
85
|
+
margin-top: ${(props) => props.theme.grid.unit * 3}px;
|
|
86
|
+
`;
|
|
87
|
+
export const FormTitle = styled.h2 `
|
|
88
|
+
margin: 0;
|
|
89
|
+
font: ${(props) => props.theme.font.weight.medium}
|
|
90
|
+
${(props) => props.theme.font.size.xlarge} /
|
|
91
|
+
${(props) => props.theme.font.lineHeight.normal}
|
|
92
|
+
${(props) => props.theme.font.family.sans};
|
|
93
|
+
color: ${(props) => props.theme.colors.text.primary};
|
|
94
|
+
`;
|
|
95
|
+
export const FormSubtitle = styled.p `
|
|
96
|
+
margin: 0;
|
|
97
|
+
color: ${(props) => props.theme.colors.text.secondary};
|
|
98
|
+
font: ${(props) => props.theme.font.weight.normal}
|
|
99
|
+
${(props) => props.theme.font.size.medium} /
|
|
100
|
+
${(props) => props.theme.font.lineHeight.large}
|
|
101
|
+
${(props) => props.theme.font.family.sans};
|
|
102
|
+
`;
|
|
103
|
+
export const Label = styled.label `
|
|
104
|
+
display: inline-flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
gap: ${(props) => props.theme.grid.unit}px;
|
|
107
|
+
color: ${(props) => props.theme.colors.text.secondary};
|
|
108
|
+
font: ${(props) => props.theme.font.weight.normal}
|
|
109
|
+
${(props) => props.theme.font.size.normal} /
|
|
110
|
+
${(props) => props.theme.font.lineHeight.normal}
|
|
111
|
+
${(props) => props.theme.font.family.sans};
|
|
112
|
+
`;
|
|
113
|
+
export const LabelText = styled.div `
|
|
114
|
+
font: ${(props) => props.theme.font.weight.normal}
|
|
115
|
+
${(props) => props.theme.font.size.normal} / 1
|
|
116
|
+
${(props) => props.theme.font.family.sans};
|
|
117
|
+
letter-spacing: -0.2px;
|
|
118
|
+
color: ${(props) => props.theme.colors.text.primary};
|
|
119
|
+
&::before {
|
|
120
|
+
margin-right: 8px !important;
|
|
121
|
+
}
|
|
122
|
+
`;
|
|
123
|
+
export const InputHelperText = styled.span `
|
|
124
|
+
color: ${(props) => props.theme.colors.text.muted};
|
|
125
|
+
font: ${(props) => props.theme.font.weight.normal}
|
|
126
|
+
${(props) => props.theme.font.size.small} /
|
|
127
|
+
${(props) => props.theme.font.lineHeight.normal}
|
|
128
|
+
${(props) => props.theme.font.family.sans};
|
|
129
|
+
`;
|
|
130
|
+
export const InputErrorText = styled.span `
|
|
131
|
+
color: ${(props) => props.theme.colors.text.error};
|
|
132
|
+
font: ${(props) => props.theme.font.weight.normal}
|
|
133
|
+
${(props) => props.theme.font.size.small} /
|
|
134
|
+
${(props) => props.theme.font.lineHeight.normal}
|
|
135
|
+
${(props) => props.theme.font.family.sans};
|
|
136
|
+
display: block;
|
|
137
|
+
margin-top: 4px;
|
|
138
|
+
`;
|
|
@@ -28,7 +28,7 @@ const MenuContainer = styled.div `
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
`;
|
|
31
|
-
export const Menus = ({ menus, innerRef, handleClick,
|
|
31
|
+
export const Menus = ({ menus, innerRef, handleClick, close, }) => {
|
|
32
32
|
const menuHeadingsRef = useRef([]);
|
|
33
33
|
useEffect(() => {
|
|
34
34
|
menuHeadingsRef.current.forEach((heading, index) => {
|
|
@@ -65,7 +65,7 @@ export const Menus = ({ menus, innerRef, handleClick, closeAll, }) => {
|
|
|
65
65
|
case 'Escape': {
|
|
66
66
|
event.preventDefault();
|
|
67
67
|
event.stopPropagation();
|
|
68
|
-
|
|
68
|
+
close();
|
|
69
69
|
break;
|
|
70
70
|
}
|
|
71
71
|
case 'ArrowDown': {
|
|
@@ -90,7 +90,7 @@ export const Menus = ({ menus, innerRef, handleClick, closeAll, }) => {
|
|
|
90
90
|
e.preventDefault();
|
|
91
91
|
handleClick([index]);
|
|
92
92
|
}, isOpen: menu.isOpen, children: _jsx(Text, { children: menu.label }) }), menu.isEnabled && menu.isOpen && menu.submenu && (_jsx(SubmenusContainerWrapper, { children: _jsx(SubmenusContainer, { "data-submenu-container": true, tabIndex: -1, children: menu.submenu.map((submenu, sindex) => {
|
|
93
|
-
return (_jsx(Submenu, { menu: submenu, handleClick: (i) => handleClick([index, sindex, ...i]),
|
|
93
|
+
return (_jsx(Submenu, { menu: submenu, handleClick: (i) => handleClick([index, sindex, ...i]), close: close }, `${index}-${sindex}`));
|
|
94
94
|
}) }) }))] }, `menu-${index}`));
|
|
95
95
|
}) }));
|
|
96
96
|
};
|
|
@@ -3,7 +3,7 @@ import styled from 'styled-components';
|
|
|
3
3
|
const isMac = /Mac/.test(window.navigator.platform);
|
|
4
4
|
export const ShortcutContainer = styled.div `
|
|
5
5
|
display: inline-flex;
|
|
6
|
-
color:
|
|
6
|
+
color: ${(props) => props.theme.colors.text.secondary};
|
|
7
7
|
margin-left: 16px;
|
|
8
8
|
flex-shrink: 0;
|
|
9
9
|
justify-content: flex-end;
|
|
@@ -77,7 +77,7 @@ const Container = styled.div `
|
|
|
77
77
|
}
|
|
78
78
|
`;
|
|
79
79
|
const activeContent = (menu) => (menu.isActive ? '✓' : '');
|
|
80
|
-
export const SubmenuLabel = ({ menu, handleClick,
|
|
80
|
+
export const SubmenuLabel = ({ menu, handleClick, close, }) => {
|
|
81
81
|
if (isMenuSeparator(menu)) {
|
|
82
82
|
return null;
|
|
83
83
|
}
|
|
@@ -126,17 +126,21 @@ export const SubmenuLabel = ({ menu, handleClick, closeAll, }) => {
|
|
|
126
126
|
case 'ArrowLeft': {
|
|
127
127
|
const parentContainer = submenuContainer?.parentElement?.closest('[data-submenu-container]');
|
|
128
128
|
if (parentContainer) {
|
|
129
|
+
if (menu.position) {
|
|
130
|
+
const currentDepth = menu.position.length - 2;
|
|
131
|
+
close(currentDepth);
|
|
132
|
+
}
|
|
129
133
|
const parentLabel = parentContainer.querySelector(':scope > [data-submenu-item]');
|
|
130
134
|
parentLabel?.focus();
|
|
131
135
|
}
|
|
132
136
|
else {
|
|
133
137
|
focusMenuHeading();
|
|
134
|
-
|
|
138
|
+
close();
|
|
135
139
|
}
|
|
136
140
|
break;
|
|
137
141
|
}
|
|
138
142
|
case 'Escape': {
|
|
139
|
-
|
|
143
|
+
close();
|
|
140
144
|
focusMenuHeading();
|
|
141
145
|
break;
|
|
142
146
|
}
|
|
@@ -153,15 +157,15 @@ export const SubmenuLabel = ({ menu, handleClick, closeAll, }) => {
|
|
|
153
157
|
handleClick([]);
|
|
154
158
|
}, onKeyDown: handleKeyDown, children: [_jsx(Active, { children: activeContent(menu) }), _jsx(Text, { children: menu.label }), menu.submenu && _jsx(Arrow, {}), menu.shortcut && _jsx(Shortcut, { shortcut: menu.shortcut })] }));
|
|
155
159
|
};
|
|
156
|
-
export const Submenu = ({ menu, handleClick,
|
|
160
|
+
export const Submenu = ({ menu, handleClick, close, }) => {
|
|
157
161
|
if (isMenuSeparator(menu)) {
|
|
158
162
|
return _jsx(Separator, {});
|
|
159
163
|
}
|
|
160
164
|
if (menu.component) {
|
|
161
|
-
return _jsx(menu.component, { menu: menu, handleClick: handleClick,
|
|
165
|
+
return (_jsx(menu.component, { menu: menu, handleClick: handleClick, close: close }));
|
|
162
166
|
}
|
|
163
167
|
if (!menu.submenu) {
|
|
164
|
-
return
|
|
168
|
+
return _jsx(SubmenuLabel, { menu: menu, handleClick: handleClick, close: close });
|
|
165
169
|
}
|
|
166
|
-
return (_jsxs(SubmenuContainer, { "data-cy": 'submenu', children: [_jsx(SubmenuLabel, { menu: menu, handleClick: handleClick,
|
|
170
|
+
return (_jsxs(SubmenuContainer, { "data-cy": 'submenu', children: [_jsx(SubmenuLabel, { menu: menu, handleClick: handleClick, close: close }), menu.submenu && menu.isOpen && (_jsx(NestedSubmenusContainer, { "data-submenu-container": true, children: menu.submenu.map((submenu, index) => (_jsx(Submenu, { menu: submenu, handleClick: (i) => handleClick([index, ...i]), close: close }, `menu-${index}`))) }))] }));
|
|
167
171
|
};
|
|
@@ -9,8 +9,8 @@ const Container = styled.div `
|
|
|
9
9
|
flex-wrap: wrap;
|
|
10
10
|
gap: 4px;
|
|
11
11
|
align-items: center;
|
|
12
|
-
padding:
|
|
13
|
-
background:
|
|
12
|
+
padding: 4px 8px;
|
|
13
|
+
background: ${(props) => props.theme.colors.background.primary};
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
&:hover Input {
|
|
@@ -43,7 +43,7 @@ const RemoveButton = styled.button `
|
|
|
43
43
|
width: 10px;
|
|
44
44
|
height: 10px;
|
|
45
45
|
color: white;
|
|
46
|
-
background:
|
|
46
|
+
background: ${(props) => props.theme.colors.text.secondary};
|
|
47
47
|
margin-left: 4px;
|
|
48
48
|
border: none;
|
|
49
49
|
border-radius: 100%;
|
|
@@ -1,49 +1,72 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
const Input = styled.input `
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
border: 0;
|
|
5
|
+
clip: rect(0 0 0 0);
|
|
6
|
+
clip-path: inset(50%);
|
|
7
|
+
height: 1px;
|
|
8
|
+
margin: -1px;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
padding: 0;
|
|
11
|
+
position: absolute;
|
|
12
|
+
white-space: nowrap;
|
|
13
|
+
width: 1px;
|
|
7
14
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
+ label {
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
margin: 0;
|
|
18
|
+
display: inline-flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
font-family: ${(props) => props.theme.font.family.sans};
|
|
21
|
+
font-size: ${(props) => props.theme.font.size.normal};
|
|
22
|
+
font-weight: ${(props) => props.theme.font.weight.normal};
|
|
23
|
+
color: ${(props) => props.theme.colors.text.primary};
|
|
24
|
+
line-height: 20px;
|
|
25
|
+
margin-bottom: ${(props) => props.theme.grid.unit}px;
|
|
26
|
+
position: relative;
|
|
27
|
+
padding-left: 24px;
|
|
28
|
+
text-align: left;
|
|
29
|
+
user-select: none;
|
|
19
30
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
z-index: 0;
|
|
34
|
-
}
|
|
31
|
+
&::before {
|
|
32
|
+
border: 1.5px solid ${(props) => props.theme.colors.border.field.default};
|
|
33
|
+
border-radius: 50%;
|
|
34
|
+
box-sizing: border-box;
|
|
35
|
+
content: ' ';
|
|
36
|
+
display: block;
|
|
37
|
+
height: 16px;
|
|
38
|
+
width: 16px;
|
|
39
|
+
position: absolute;
|
|
40
|
+
left: 0;
|
|
41
|
+
top: 50%;
|
|
42
|
+
transform: translateY(-50%);
|
|
43
|
+
background: ${(props) => props.theme.colors.background.primary};
|
|
35
44
|
}
|
|
45
|
+
}
|
|
36
46
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
&:checked + label::before {
|
|
48
|
+
background: ${(props) => props.theme.colors.background.primary};
|
|
49
|
+
box-shadow: inset 0 0 0 4px #0d79d0;
|
|
50
|
+
border-color: #0d79d0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&:hover:not(:disabled) + label::before {
|
|
54
|
+
border-color: ${(props) => props.theme.colors.text.secondary};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&:focus-visible + label::before {
|
|
58
|
+
border-color: #0d79d0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&:disabled + label {
|
|
62
|
+
color: ${(props) => props.theme.colors.text.secondary};
|
|
63
|
+
cursor: not-allowed;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&:disabled + label::before {
|
|
67
|
+
background: #c9c9c9;
|
|
68
|
+
filter: grayscale(1) opacity(0.4);
|
|
69
|
+
border-color: #e4e4e4;
|
|
47
70
|
}
|
|
48
71
|
`;
|
|
49
72
|
export const RadioButton = ({ checked, id, label, name, ...rest }) => (_jsxs(_Fragment, { children: [_jsx(Input, { checked: checked, type: "radio", name: name, id: id, ...rest }), _jsx("label", { htmlFor: id, children: label })] }));
|
|
@@ -1,3 +1,92 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import Select from 'react-select';
|
|
3
|
-
|
|
3
|
+
import { useTheme } from 'styled-components';
|
|
4
|
+
const selectStyles = (theme, error, variant) => ({
|
|
5
|
+
control: (base, state) => ({
|
|
6
|
+
...base,
|
|
7
|
+
minHeight: variant === 'large' ? 40 : 32,
|
|
8
|
+
borderRadius: 3,
|
|
9
|
+
fontFamily: theme.font.family.sans,
|
|
10
|
+
fontSize: theme.font.size.medium,
|
|
11
|
+
borderColor: error
|
|
12
|
+
? theme.colors.border.error
|
|
13
|
+
: state.isFocused
|
|
14
|
+
? theme.colors.brand.default
|
|
15
|
+
: theme.colors.border.field.default,
|
|
16
|
+
boxShadow: 'none',
|
|
17
|
+
'&:hover': {
|
|
18
|
+
borderColor: error
|
|
19
|
+
? theme.colors.border.error
|
|
20
|
+
: state.isFocused
|
|
21
|
+
? theme.colors.brand.default
|
|
22
|
+
: theme.colors.text.secondary,
|
|
23
|
+
backgroundColor: !state.isDisabled ? '#F2FBFC' : 'transparent',
|
|
24
|
+
},
|
|
25
|
+
backgroundColor: state.isDisabled
|
|
26
|
+
? '#F5F5F5'
|
|
27
|
+
: state.isFocused
|
|
28
|
+
? '#F2FBFC'
|
|
29
|
+
: theme.colors.background.primary,
|
|
30
|
+
transition: 'border-color 120ms ease, box-shadow 120ms ease',
|
|
31
|
+
cursor: state.isDisabled ? 'not-allowed' : 'pointer',
|
|
32
|
+
}),
|
|
33
|
+
valueContainer: (base) => ({
|
|
34
|
+
...base,
|
|
35
|
+
padding: '0 8px',
|
|
36
|
+
}),
|
|
37
|
+
singleValue: (base, state) => ({
|
|
38
|
+
...base,
|
|
39
|
+
color: state.isDisabled ? '#B3B3B3' : theme.colors.text.primary,
|
|
40
|
+
fontFamily: theme.font.family.sans,
|
|
41
|
+
fontSize: theme.font.size.medium,
|
|
42
|
+
}),
|
|
43
|
+
option: (base, state) => ({
|
|
44
|
+
...base,
|
|
45
|
+
fontFamily: theme.font.family.sans,
|
|
46
|
+
fontSize: theme.font.size.medium,
|
|
47
|
+
backgroundColor: state.isSelected
|
|
48
|
+
? theme.colors.brand.default
|
|
49
|
+
: state.isFocused
|
|
50
|
+
? '#F2FBFC'
|
|
51
|
+
: theme.colors.background.primary,
|
|
52
|
+
color: state.isSelected ? '#FFF' : theme.colors.text.primary,
|
|
53
|
+
'&:active': {
|
|
54
|
+
backgroundColor: theme.colors.brand.default,
|
|
55
|
+
color: '#FFF',
|
|
56
|
+
},
|
|
57
|
+
}),
|
|
58
|
+
menu: (base) => ({
|
|
59
|
+
...base,
|
|
60
|
+
borderRadius: 3,
|
|
61
|
+
overflow: 'hidden',
|
|
62
|
+
boxShadow: '0 4px 6px rgba(0, 0, 0, 0.1)',
|
|
63
|
+
}),
|
|
64
|
+
placeholder: (base) => ({
|
|
65
|
+
...base,
|
|
66
|
+
color: theme.colors.text.secondary,
|
|
67
|
+
fontStyle: 'italic',
|
|
68
|
+
fontFamily: theme.font.family.sans,
|
|
69
|
+
fontSize: theme.font.size.medium,
|
|
70
|
+
fontWeight: theme.font.weight.normal,
|
|
71
|
+
lineHeight: theme.font.lineHeight.large,
|
|
72
|
+
}),
|
|
73
|
+
dropdownIndicator: (base, state) => ({
|
|
74
|
+
...base,
|
|
75
|
+
color: state.isDisabled ? '#B3B3B3' : theme.colors.text.secondary,
|
|
76
|
+
'&:hover': {
|
|
77
|
+
color: state.isDisabled ? '#B3B3B3' : theme.colors.text.primary,
|
|
78
|
+
},
|
|
79
|
+
}),
|
|
80
|
+
});
|
|
81
|
+
export const SelectField = ({ id, options, field, form, error, variant, isDisabled, ...rest }) => {
|
|
82
|
+
const theme = useTheme();
|
|
83
|
+
const name = field?.name || '';
|
|
84
|
+
const value = field?.value;
|
|
85
|
+
return (_jsx(Select, { inputId: id, options: options, name: name, classNamePrefix: name, value: options?.find((option) => option.value === value), onChange: (option) => form?.setFieldValue(name, option?.value), onBlur: field?.onBlur, styles: selectStyles(theme, error, variant), isDisabled: form?.isSubmitting || isDisabled, ...rest, theme: (base) => ({
|
|
86
|
+
...base,
|
|
87
|
+
colors: {
|
|
88
|
+
...base.colors,
|
|
89
|
+
primary: theme.colors.brand.default || base.colors.primary,
|
|
90
|
+
},
|
|
91
|
+
}) }));
|
|
92
|
+
};
|
|
@@ -94,6 +94,25 @@ export const ScrollableModalContent = styled(ModelContent) `
|
|
|
94
94
|
overflow-y: auto;
|
|
95
95
|
max-height: 100%;
|
|
96
96
|
`;
|
|
97
|
+
export const ModalCardBody = styled.div `
|
|
98
|
+
box-sizing: border-box;
|
|
99
|
+
padding: ${(props) => 6 * props.theme.grid.unit}px;
|
|
100
|
+
background-color: ${(props) => props.theme.colors.background.primary};
|
|
101
|
+
width: ${(props) => props.width
|
|
102
|
+
? typeof props.width === 'number'
|
|
103
|
+
? `${props.width}px`
|
|
104
|
+
: props.width
|
|
105
|
+
: '640px'};
|
|
106
|
+
max-width: 60vw;
|
|
107
|
+
max-height: 80vh;
|
|
108
|
+
`;
|
|
109
|
+
export const ModalTitle = styled.h2 `
|
|
110
|
+
font-family: ${(props) => props.theme.font.family.sans};
|
|
111
|
+
font-size: ${(props) => props.theme.font.size.medium};
|
|
112
|
+
font-weight: ${(props) => props.theme.font.weight.bold};
|
|
113
|
+
color: ${(props) => props.theme.colors.text.primary};
|
|
114
|
+
margin: 0 0 20px 0;
|
|
115
|
+
`;
|
|
97
116
|
export const StyledModal = styled(ReactModalAdapter).attrs({
|
|
98
117
|
closeTimeoutMS: totalTransitionTime,
|
|
99
118
|
overlayClassName: {
|