@manuscripts/style-guide 3.5.4 → 3.5.6
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/Button.js +9 -11
- package/dist/cjs/components/Checkbox.js +3 -1
- package/dist/cjs/components/DraggableModal.js +4 -0
- package/dist/cjs/components/Drawer.js +13 -10
- package/dist/cjs/components/Inspector.js +5 -0
- package/dist/cjs/components/List.js +195 -0
- package/dist/cjs/components/LoadingOverlay.js +16 -25
- package/dist/cjs/components/MultiValueInput.js +6 -1
- package/dist/cjs/components/SelectedItemsBox.js +5 -0
- package/dist/cjs/components/StyledModal.js +142 -81
- package/dist/cjs/hooks/use-focus-cycle.js +53 -0
- package/dist/cjs/index.js +2 -0
- package/dist/es/components/Button.js +8 -10
- package/dist/es/components/Checkbox.js +3 -1
- package/dist/es/components/DraggableModal.js +4 -0
- package/dist/es/components/Drawer.js +13 -10
- package/dist/es/components/Inspector.js +5 -0
- package/dist/es/components/List.js +187 -0
- package/dist/es/components/LoadingOverlay.js +17 -26
- package/dist/es/components/MultiValueInput.js +6 -1
- package/dist/es/components/SelectedItemsBox.js +5 -0
- package/dist/es/components/StyledModal.js +107 -77
- package/dist/es/hooks/use-focus-cycle.js +47 -0
- package/dist/es/index.js +2 -0
- package/dist/types/components/Button.d.ts +1 -0
- package/dist/types/components/Drawer.d.ts +20 -4
- package/dist/types/components/List.d.ts +4 -0
- package/dist/types/components/StyledModal.d.ts +12 -19
- package/dist/types/hooks/use-focus-cycle.d.ts +4 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +1 -3
|
@@ -48,7 +48,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
48
48
|
};
|
|
49
49
|
})();
|
|
50
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
-
exports.IconButtonGroup = exports.ButtonGroup = exports.SecondaryIconButton = exports.RoundIconButton = exports.IconButton = exports.ToggleButtonAlt = exports.ToggleButton = exports.IconTextButton = exports.TertiaryButton = exports.LoginButton = exports.PrimaryButton = exports.SecondaryButton = void 0;
|
|
51
|
+
exports.IconButtonGroup = exports.ButtonGroup = exports.SecondaryIconButton = exports.RoundIconButton = exports.IconButton = exports.ToggleButtonAlt = exports.ToggleButton = exports.IconTextButton = exports.TertiaryButton = exports.LoginButton = exports.PrimaryButton = exports.SecondaryButton = exports.outlineStyle = void 0;
|
|
52
52
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
53
53
|
const dangerBtnStyles = (0, styled_components_1.css) `
|
|
54
54
|
${(props) => btnColors(props.theme.colors.button.error.color.default, props.theme.colors.button.error.background.default, props.theme.colors.button.error.border.default, true)}
|
|
@@ -70,6 +70,12 @@ const miniBtnStyles = (0, styled_components_1.css) `
|
|
|
70
70
|
margin: 0 ${(props) => props.theme.grid.unit}px;
|
|
71
71
|
line-height: 1;
|
|
72
72
|
`;
|
|
73
|
+
exports.outlineStyle = (0, styled_components_1.css) `
|
|
74
|
+
&:not([disabled]):focus-visible {
|
|
75
|
+
outline: 3px solid ${(props) => props.theme.colors.outline.focus};
|
|
76
|
+
outline-offset: 4px;
|
|
77
|
+
}
|
|
78
|
+
`;
|
|
73
79
|
const btnStyles = (0, styled_components_1.css) `
|
|
74
80
|
align-items: center;
|
|
75
81
|
background: transparent;
|
|
@@ -104,6 +110,8 @@ const btnStyles = (0, styled_components_1.css) `
|
|
|
104
110
|
:disabled {
|
|
105
111
|
${disabledBtnStyles}
|
|
106
112
|
}
|
|
113
|
+
|
|
114
|
+
${exports.outlineStyle}
|
|
107
115
|
`;
|
|
108
116
|
const btnColors = (color, bg, border, important) => `
|
|
109
117
|
${color && 'color: ' + color}
|
|
@@ -128,11 +136,6 @@ exports.SecondaryButton = (0, styled_components_1.default)(ButtonTemplate) `
|
|
|
128
136
|
&:not([disabled]):active {
|
|
129
137
|
${(props) => btnColors(props.theme.colors.button.secondary.color.active, props.theme.colors.button.secondary.background.active, props.theme.colors.button.secondary.border.active, false)}
|
|
130
138
|
}
|
|
131
|
-
|
|
132
|
-
&:focus-visible {
|
|
133
|
-
outline: 3px solid ${(props) => props.theme.colors.outline.focus};
|
|
134
|
-
outline-offset: 4px;
|
|
135
|
-
}
|
|
136
139
|
`;
|
|
137
140
|
exports.PrimaryButton = (0, styled_components_1.default)(ButtonTemplate) `
|
|
138
141
|
${(props) => btnColors(props.theme.colors.button.primary.color.default, props.theme.colors.button.primary.background.default, props.theme.colors.button.primary.border.default, false)}
|
|
@@ -141,11 +144,6 @@ exports.PrimaryButton = (0, styled_components_1.default)(ButtonTemplate) `
|
|
|
141
144
|
${(props) => btnColors(props.theme.colors.button.primary.color.hover, props.theme.colors.button.primary.background.hover, props.theme.colors.button.primary.border.hover, false)}
|
|
142
145
|
}
|
|
143
146
|
|
|
144
|
-
&:focus-visible {
|
|
145
|
-
outline: 3px solid ${(props) => props.theme.colors.outline.focus} !important;
|
|
146
|
-
outline-offset: 4px;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
147
|
&:not([disabled]):active {
|
|
150
148
|
${(props) => btnColors(props.theme.colors.button.primary.color.active, props.theme.colors.button.primary.background.active, props.theme.colors.button.primary.border.active, false)}
|
|
151
149
|
}
|
|
@@ -58,6 +58,7 @@ exports.CheckboxLabel = styled_components_1.default.label `
|
|
|
58
58
|
border: 1.5px solid ${(props) => props.theme.colors.border.field.default};
|
|
59
59
|
border-radius: 3px;
|
|
60
60
|
margin-right: 10px;
|
|
61
|
+
margin-left: 4px;
|
|
61
62
|
text-align: center;
|
|
62
63
|
background: ${(props) => props.theme.colors.background.primary};
|
|
63
64
|
}
|
|
@@ -74,7 +75,8 @@ exports.CheckboxLabel = styled_components_1.default.label `
|
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
input:focus-visible + div::before {
|
|
77
|
-
outline:
|
|
78
|
+
outline: 2px solid ${(props) => props.theme.colors.outline.focus};
|
|
79
|
+
outline-offset: 2px;
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
input:disabled + div::before {
|
|
@@ -52,9 +52,13 @@ const DraggableModal = ({ children, isOpen, onRequestClose, hideOverlay }) => {
|
|
|
52
52
|
content: {
|
|
53
53
|
left: '0',
|
|
54
54
|
bottom: '0',
|
|
55
|
+
top: 'auto',
|
|
56
|
+
margin: '0',
|
|
55
57
|
transition: 'none',
|
|
56
58
|
position: 'fixed',
|
|
57
59
|
width: '100%',
|
|
60
|
+
maxWidth: '100%',
|
|
61
|
+
maxHeight: 'none',
|
|
58
62
|
},
|
|
59
63
|
}, children: (0, jsx_runtime_1.jsx)(DraggableModalContainer, { onMouseDown: mouseDown, onMouseMove: mouseMove, "data-cy": "find-replace-modal", children: children }) }));
|
|
60
64
|
};
|
|
@@ -36,6 +36,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.Drawer = exports.DrawerItemMeta = exports.DrawerItemLabel = exports.DrawerLabelContainer = exports.DrawerIcon = exports.DrawerListItem = exports.DrawerItemsList = void 0;
|
|
37
37
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
38
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
39
|
+
const Button_1 = require("./Button");
|
|
40
|
+
const List_1 = require("./List");
|
|
39
41
|
const slideIn = (0, styled_components_1.keyframes) `
|
|
40
42
|
from {
|
|
41
43
|
transform: translateX(100%);
|
|
@@ -44,7 +46,7 @@ const slideIn = (0, styled_components_1.keyframes) `
|
|
|
44
46
|
transform: translateX(0);
|
|
45
47
|
}
|
|
46
48
|
`;
|
|
47
|
-
const DrawerContainer = styled_components_1.default.div `
|
|
49
|
+
const DrawerContainer = (0, List_1.withFocusTrap)(styled_components_1.default.div `
|
|
48
50
|
width: ${(props) => props.width || '300px'};
|
|
49
51
|
background: ${(props) => props.theme.colors.background.primary};
|
|
50
52
|
height: 100%;
|
|
@@ -55,9 +57,10 @@ const DrawerContainer = styled_components_1.default.div `
|
|
|
55
57
|
right: 0;
|
|
56
58
|
top: 0;
|
|
57
59
|
z-index: 1;
|
|
58
|
-
|
|
59
|
-
const DrawerBackButton = styled_components_1.default.
|
|
60
|
-
|
|
60
|
+
`);
|
|
61
|
+
const DrawerBackButton = (0, styled_components_1.default)(Button_1.SecondaryButton) `
|
|
62
|
+
margin: 0 12px;
|
|
63
|
+
padding: 8px 4px;
|
|
61
64
|
border: none;
|
|
62
65
|
background: none;
|
|
63
66
|
font-weight: ${(props) => props.theme.font.weight.normal};
|
|
@@ -66,7 +69,7 @@ const DrawerBackButton = styled_components_1.default.button `
|
|
|
66
69
|
color: ${(props) => props.theme.colors.brand.default};
|
|
67
70
|
cursor: pointer;
|
|
68
71
|
display: flex;
|
|
69
|
-
|
|
72
|
+
justify-content: start;
|
|
70
73
|
gap: 4px;
|
|
71
74
|
|
|
72
75
|
&:hover {
|
|
@@ -74,13 +77,13 @@ const DrawerBackButton = styled_components_1.default.button `
|
|
|
74
77
|
opacity: 0.8;
|
|
75
78
|
}
|
|
76
79
|
`;
|
|
77
|
-
exports.DrawerItemsList = styled_components_1.default.ul `
|
|
80
|
+
exports.DrawerItemsList = (0, List_1.withListNavigation)(styled_components_1.default.ul `
|
|
78
81
|
list-style: none;
|
|
79
|
-
padding:
|
|
82
|
+
padding: 8px;
|
|
80
83
|
margin: 0;
|
|
81
84
|
overflow-y: auto;
|
|
82
|
-
|
|
83
|
-
exports.DrawerListItem = styled_components_1.default.li `
|
|
85
|
+
`);
|
|
86
|
+
exports.DrawerListItem = (0, List_1.withNavigableListItem)(styled_components_1.default.li `
|
|
84
87
|
padding: 8px 16px;
|
|
85
88
|
cursor: pointer;
|
|
86
89
|
display: flex;
|
|
@@ -95,7 +98,7 @@ exports.DrawerListItem = styled_components_1.default.li `
|
|
|
95
98
|
&:last-child {
|
|
96
99
|
border-bottom: none;
|
|
97
100
|
}
|
|
98
|
-
|
|
101
|
+
`);
|
|
99
102
|
exports.DrawerIcon = styled_components_1.default.span `
|
|
100
103
|
width: 20px;
|
|
101
104
|
height: 20px;
|
|
@@ -79,6 +79,11 @@ exports.InspectorTab = (0, styled_components_1.default)(react_1.Tab) `
|
|
|
79
79
|
border-color: ${(props) => props.theme.colors.brand.default};
|
|
80
80
|
color: ${(props) => props.theme.colors.brand.default};
|
|
81
81
|
}
|
|
82
|
+
|
|
83
|
+
&[data-headlessui-state~='selected'][data-headlessui-state~='focus'] {
|
|
84
|
+
outline: 2px solid ${(props) => props.theme.colors.outline.focus};
|
|
85
|
+
outline-offset: -2px;
|
|
86
|
+
}
|
|
82
87
|
}
|
|
83
88
|
`;
|
|
84
89
|
exports.InspectorTabPanelHeading = styled_components_1.default.div `
|
|
@@ -0,0 +1,195 @@
|
|
|
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.withListNavigation = withListNavigation;
|
|
7
|
+
exports.withNavigableListItem = withNavigableListItem;
|
|
8
|
+
exports.withFocusTrap = withFocusTrap;
|
|
9
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
12
|
+
const Button_1 = require("./Button");
|
|
13
|
+
const use_focus_cycle_1 = require("../hooks/use-focus-cycle");
|
|
14
|
+
function mergeRefs(...refs) {
|
|
15
|
+
return (value) => {
|
|
16
|
+
refs.forEach((ref) => {
|
|
17
|
+
if (typeof ref === 'function') {
|
|
18
|
+
ref(value);
|
|
19
|
+
}
|
|
20
|
+
else if (ref != null) {
|
|
21
|
+
;
|
|
22
|
+
ref.current = value;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function handleTabWithinListItem(e, items) {
|
|
28
|
+
if (e.key !== 'Tab') {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const activeElement = document.activeElement;
|
|
32
|
+
const currentItem = activeElement.closest('[data-list-item]');
|
|
33
|
+
const isOnInternalElement = currentItem &&
|
|
34
|
+
currentItem !== activeElement &&
|
|
35
|
+
currentItem.contains(activeElement);
|
|
36
|
+
if (currentItem && isOnInternalElement) {
|
|
37
|
+
const focusableElements = (0, use_focus_cycle_1.getFocusableElements)(currentItem);
|
|
38
|
+
const currentIndex = focusableElements.indexOf(activeElement);
|
|
39
|
+
const isFirstElement = currentIndex === 0;
|
|
40
|
+
const isLastElement = currentIndex === focusableElements.length - 1;
|
|
41
|
+
if (e.shiftKey && isFirstElement) {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
currentItem.focus();
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
else if (!e.shiftKey && isLastElement) {
|
|
47
|
+
const currentIndex = items.indexOf(currentItem);
|
|
48
|
+
const nextItem = items[currentIndex + 1];
|
|
49
|
+
if (nextItem) {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
nextItem.focus();
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
function withListNavigation(Component) {
|
|
59
|
+
return (0, styled_components_1.default)((0, react_1.forwardRef)((props, forwardedRef) => {
|
|
60
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
61
|
+
const tappingOutIndex = (0, react_1.useRef)(0);
|
|
62
|
+
const getListItems = (0, react_1.useCallback)(() => {
|
|
63
|
+
const element = containerRef.current;
|
|
64
|
+
if (!element) {
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
return Array.from(element.querySelectorAll('[data-list-item]'));
|
|
68
|
+
}, []);
|
|
69
|
+
const getColumnCount = (0, react_1.useCallback)(() => {
|
|
70
|
+
const element = containerRef.current;
|
|
71
|
+
if (!element) {
|
|
72
|
+
return 1;
|
|
73
|
+
}
|
|
74
|
+
const gridStyle = window.getComputedStyle(element);
|
|
75
|
+
return gridStyle
|
|
76
|
+
.getPropertyValue('grid-template-columns')
|
|
77
|
+
.split(' ')
|
|
78
|
+
.filter((val) => val !== '').length;
|
|
79
|
+
}, []);
|
|
80
|
+
const handleKeyDown = (0, react_1.useCallback)((e) => {
|
|
81
|
+
const items = getListItems();
|
|
82
|
+
const handled = handleTabWithinListItem(e, items);
|
|
83
|
+
if (handled) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const currentIndex = items.indexOf(document.activeElement);
|
|
87
|
+
const element = containerRef.current;
|
|
88
|
+
const columnCount = getColumnCount();
|
|
89
|
+
if (currentIndex === -1 || !element) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
let newIndex = currentIndex;
|
|
93
|
+
switch (e.key) {
|
|
94
|
+
case 'ArrowUp': {
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
newIndex =
|
|
97
|
+
(currentIndex - columnCount + items.length) % items.length;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
case 'ArrowDown': {
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
newIndex = (currentIndex + columnCount) % items.length;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
case 'ArrowLeft': {
|
|
106
|
+
if (columnCount > 1) {
|
|
107
|
+
e.preventDefault();
|
|
108
|
+
newIndex = (currentIndex - 1 + items.length) % items.length;
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
case 'ArrowRight': {
|
|
113
|
+
if (columnCount > 1) {
|
|
114
|
+
e.preventDefault();
|
|
115
|
+
newIndex = (currentIndex + 1) % items.length;
|
|
116
|
+
}
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
case 'Tab': {
|
|
120
|
+
tappingOutIndex.current = currentIndex;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (currentIndex !== newIndex) {
|
|
125
|
+
items[currentIndex].setAttribute('tabindex', '-1');
|
|
126
|
+
items[newIndex].setAttribute('tabindex', '0');
|
|
127
|
+
items[newIndex].focus();
|
|
128
|
+
}
|
|
129
|
+
}, [getListItems, getColumnCount, containerRef]);
|
|
130
|
+
const handelOnBlur = (0, react_1.useCallback)(() => {
|
|
131
|
+
if (tappingOutIndex.current) {
|
|
132
|
+
const items = getListItems();
|
|
133
|
+
items[tappingOutIndex.current].setAttribute('tabindex', '-1');
|
|
134
|
+
items[0].setAttribute('tabindex', '0');
|
|
135
|
+
tappingOutIndex.current = 0;
|
|
136
|
+
}
|
|
137
|
+
}, [getListItems]);
|
|
138
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
139
|
+
const element = containerRef.current;
|
|
140
|
+
if (!element) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const firstItem = element.querySelector('[data-list-item]');
|
|
144
|
+
if (!firstItem) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (firstItem.tabIndex === 0) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const tabbedElement = element.querySelector('[data-list-item][tabindex="0"]');
|
|
151
|
+
if (tabbedElement) {
|
|
152
|
+
tabbedElement.tabIndex = -1;
|
|
153
|
+
}
|
|
154
|
+
firstItem.tabIndex = 0;
|
|
155
|
+
});
|
|
156
|
+
return ((0, jsx_runtime_1.jsx)(Component, { ref: mergeRefs(containerRef, forwardedRef), ...props, onKeyDown: handleKeyDown, onBlur: handelOnBlur }));
|
|
157
|
+
})) `
|
|
158
|
+
outline: none;
|
|
159
|
+
`;
|
|
160
|
+
}
|
|
161
|
+
function withNavigableListItem(Component) {
|
|
162
|
+
return (0, styled_components_1.default)((0, react_1.forwardRef)((props, forwardedRef) => {
|
|
163
|
+
const listItemRef = (0, react_1.useRef)(null);
|
|
164
|
+
const handleKeyDown = (0, react_1.useCallback)((e) => {
|
|
165
|
+
const listItem = listItemRef.current;
|
|
166
|
+
const element = e.target;
|
|
167
|
+
if (element && listItem && element === listItem && e.key === 'Enter') {
|
|
168
|
+
const interactiveElements = [
|
|
169
|
+
'BUTTON',
|
|
170
|
+
'A',
|
|
171
|
+
'INPUT',
|
|
172
|
+
'TEXTAREA',
|
|
173
|
+
'SELECT',
|
|
174
|
+
];
|
|
175
|
+
if (!interactiveElements.includes(listItem.tagName)) {
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
listItem.click();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}, []);
|
|
181
|
+
return ((0, jsx_runtime_1.jsx)(Component, { tabIndex: -1, "data-list-item": true, ref: mergeRefs(listItemRef, forwardedRef), onKeyDown: handleKeyDown, ...props }));
|
|
182
|
+
})) `
|
|
183
|
+
&:not([disabled]):focus-visible {
|
|
184
|
+
background-color: ${(props) => props.theme.colors.background.fifth};
|
|
185
|
+
}
|
|
186
|
+
${Button_1.outlineStyle}
|
|
187
|
+
`;
|
|
188
|
+
}
|
|
189
|
+
function withFocusTrap(Component) {
|
|
190
|
+
return (0, react_1.forwardRef)((props, forwardedRef) => {
|
|
191
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
192
|
+
const handleKeyDown = (0, react_1.useCallback)((e) => (0, use_focus_cycle_1.trapFocus)(e, containerRef.current), []);
|
|
193
|
+
return ((0, jsx_runtime_1.jsx)(Component, { ref: mergeRefs(containerRef, forwardedRef), onKeyDown: handleKeyDown, ...props }));
|
|
194
|
+
});
|
|
195
|
+
}
|
|
@@ -5,29 +5,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.LoadingOverlay = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const
|
|
9
|
-
const LoadingOverlay = ({ children, }) => (
|
|
10
|
-
overlay: {
|
|
11
|
-
position: 'fixed',
|
|
12
|
-
top: 0,
|
|
13
|
-
left: 0,
|
|
14
|
-
right: 0,
|
|
15
|
-
bottom: 0,
|
|
16
|
-
backgroundColor: 'white',
|
|
17
|
-
zIndex: 20,
|
|
18
|
-
},
|
|
19
|
-
content: {
|
|
20
|
-
position: 'fixed',
|
|
21
|
-
top: 0,
|
|
22
|
-
left: 0,
|
|
23
|
-
right: 0,
|
|
24
|
-
bottom: 0,
|
|
25
|
-
background: 'white',
|
|
26
|
-
display: 'flex',
|
|
27
|
-
flexDirection: 'column',
|
|
28
|
-
padding: 0,
|
|
29
|
-
overflow: 'auto',
|
|
30
|
-
border: 'none',
|
|
31
|
-
},
|
|
32
|
-
}, children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }) }) }));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const LoadingOverlay = ({ children, }) => (0, jsx_runtime_1.jsx)(Overlay, { children: children });
|
|
33
10
|
exports.LoadingOverlay = LoadingOverlay;
|
|
11
|
+
const Overlay = styled_components_1.default.div `
|
|
12
|
+
position: fixed;
|
|
13
|
+
top: 0;
|
|
14
|
+
left: 0;
|
|
15
|
+
right: 0;
|
|
16
|
+
bottom: 0;
|
|
17
|
+
background: white;
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
padding: 0;
|
|
21
|
+
overflow: auto;
|
|
22
|
+
border: none;
|
|
23
|
+
z-index: 20;
|
|
24
|
+
`;
|
|
@@ -59,6 +59,11 @@ const RemoveButton = styled_components_1.default.button `
|
|
|
59
59
|
&:hover {
|
|
60
60
|
background: black;
|
|
61
61
|
}
|
|
62
|
+
|
|
63
|
+
&:not([disabled]):focus-visible {
|
|
64
|
+
outline: 1px solid ${(props) => props.theme.colors.outline.focus};
|
|
65
|
+
outline-offset: 2px;
|
|
66
|
+
}
|
|
62
67
|
`;
|
|
63
68
|
const Input = styled_components_1.default.input `
|
|
64
69
|
${TextField_1.commonStyles}
|
|
@@ -121,6 +126,6 @@ const MultiValueInput = ({ id, inputType, placeholder = '', initialValues = [],
|
|
|
121
126
|
: inputType === 'number'
|
|
122
127
|
? 'Enter number and press enter'
|
|
123
128
|
: 'Enter text and press enter';
|
|
124
|
-
return ((0, jsx_runtime_1.jsxs)(Container, { children: [values.map((value, index) => ((0, jsx_runtime_1.jsxs)(Chip, { children: [value, (0, jsx_runtime_1.jsx)(RemoveButton, {
|
|
129
|
+
return ((0, jsx_runtime_1.jsxs)(Container, { children: [values.map((value, index) => ((0, jsx_runtime_1.jsxs)(Chip, { children: [value, (0, jsx_runtime_1.jsx)(RemoveButton, { type: 'button', onClick: () => handleRemoveValue(index), children: "\u00D7" })] }, index))), (0, jsx_runtime_1.jsx)(Input, { id: id, type: inputType, value: currentValue, onChange: handleInputChange, onKeyDown: handleKeyDown, onBlur: handleBlur, placeholder: xplaceholder })] }));
|
|
125
130
|
};
|
|
126
131
|
exports.MultiValueInput = MultiValueInput;
|
|
@@ -58,6 +58,11 @@ const RemoveButton = styled_components_1.default.button `
|
|
|
58
58
|
padding: 0;
|
|
59
59
|
font-family: ${(props) => props.theme.font.family.sans};
|
|
60
60
|
font-weight: ${(props) => props.theme.font.weight.light};
|
|
61
|
+
|
|
62
|
+
&:not([disabled]):focus-visible {
|
|
63
|
+
outline: 1px solid ${(props) => props.theme.colors.outline.focus};
|
|
64
|
+
outline-offset: 2px;
|
|
65
|
+
}
|
|
61
66
|
`;
|
|
62
67
|
const SelectedItemsBox = ({ items, onRemove, placeholder = 'No items selected', ...props }) => {
|
|
63
68
|
return ((0, jsx_runtime_1.jsx)(BoxContainer, { ...props, children: items.length > 0 ? ((0, jsx_runtime_1.jsx)(ItemsList, { children: items.map((item) => ((0, jsx_runtime_1.jsxs)(Item, { "data-cy": "item", children: [item.label, (0, jsx_runtime_1.jsx)(RemoveButton, { onClick: () => onRemove(item.id), "aria-label": `Remove ${item.label}`, children: "x" })] }, item.id))) })) : ((0, jsx_runtime_1.jsx)(EmptyContainer, { children: (0, jsx_runtime_1.jsx)(Placeholder, { children: placeholder }) })) }));
|
|
@@ -1,27 +1,152 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
5
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
36
|
+
exports.ModalTitle = exports.ModalCardBody = exports.ScrollableModalContent = exports.ModelContent = exports.ModalSidebarTitle = exports.ModalSidebarHeader = exports.ModalSidebar = exports.ModalBody = exports.CloseButton = exports.ModalHeader = exports.ModalContainer = exports.StyledModal = void 0;
|
|
7
37
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
38
|
+
const react_1 = require("react");
|
|
39
|
+
const react_dom_1 = require("react-dom");
|
|
40
|
+
const styled_components_1 = __importStar(require("styled-components"));
|
|
10
41
|
const Button_1 = require("./Button");
|
|
11
42
|
const Sidebar_1 = require("./Sidebar");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
43
|
+
const StyledModal = ({ isOpen, onRequestClose, shouldCloseOnOverlayClick = true, hideOverlay = false, pointerEventsOnBackdrop, children, className, style, }) => {
|
|
44
|
+
const dialogRef = (0, react_1.useRef)(null);
|
|
45
|
+
const closedByCancelRef = (0, react_1.useRef)(false);
|
|
46
|
+
(0, react_1.useEffect)(() => {
|
|
47
|
+
const dialog = dialogRef.current;
|
|
48
|
+
if (!dialog) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (isOpen && !dialog.open) {
|
|
52
|
+
dialog.showModal();
|
|
53
|
+
}
|
|
54
|
+
else if (!isOpen && dialog.open) {
|
|
55
|
+
dialog.close();
|
|
56
|
+
}
|
|
57
|
+
}, [isOpen]);
|
|
58
|
+
(0, react_1.useEffect)(() => {
|
|
59
|
+
const dialog = dialogRef.current;
|
|
60
|
+
if (!dialog) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const handleNativeClose = (wasOpen) => {
|
|
64
|
+
if (wasOpen && !closedByCancelRef.current) {
|
|
65
|
+
onRequestClose?.();
|
|
66
|
+
}
|
|
67
|
+
closedByCancelRef.current = false;
|
|
21
68
|
};
|
|
22
|
-
|
|
23
|
-
|
|
69
|
+
const listener = () => handleNativeClose(isOpen);
|
|
70
|
+
dialog.addEventListener('close', listener);
|
|
71
|
+
return () => dialog.removeEventListener('close', listener);
|
|
72
|
+
}, [isOpen, onRequestClose]);
|
|
73
|
+
(0, react_1.useEffect)(() => {
|
|
74
|
+
const dialog = dialogRef.current;
|
|
75
|
+
if (!dialog) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const handleCancel = (e) => {
|
|
79
|
+
closedByCancelRef.current = true;
|
|
80
|
+
onRequestClose?.(e);
|
|
81
|
+
};
|
|
82
|
+
dialog.addEventListener('cancel', handleCancel);
|
|
83
|
+
return () => dialog.removeEventListener('cancel', handleCancel);
|
|
84
|
+
}, [onRequestClose]);
|
|
85
|
+
const handleBackdropClick = (e) => {
|
|
86
|
+
if (shouldCloseOnOverlayClick && e.target === dialogRef.current) {
|
|
87
|
+
onRequestClose?.();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(Dialog, { ref: dialogRef, onClick: handleBackdropClick, "$hideOverlay": hideOverlay, "$pointerEventsOnBackdrop": pointerEventsOnBackdrop, className: className, style: style?.content, children: children }), document.body);
|
|
24
91
|
};
|
|
92
|
+
exports.StyledModal = StyledModal;
|
|
93
|
+
const Dialog = styled_components_1.default.dialog `
|
|
94
|
+
background: transparent;
|
|
95
|
+
border: none;
|
|
96
|
+
position: relative;
|
|
97
|
+
outline: none;
|
|
98
|
+
padding: 0;
|
|
99
|
+
overflow: visible;
|
|
100
|
+
opacity: 1;
|
|
101
|
+
transition:
|
|
102
|
+
opacity 0.5s ease-in-out,
|
|
103
|
+
display 0.5s ease allow-discrete,
|
|
104
|
+
overlay 0.5s ease allow-discrete;
|
|
105
|
+
|
|
106
|
+
&:not([open]) {
|
|
107
|
+
opacity: 0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@starting-style {
|
|
111
|
+
&[open] {
|
|
112
|
+
opacity: 0;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
&::backdrop {
|
|
117
|
+
${(props) => {
|
|
118
|
+
if (props.$hideOverlay) {
|
|
119
|
+
return (0, styled_components_1.css) `
|
|
120
|
+
background: transparent;
|
|
121
|
+
`;
|
|
122
|
+
}
|
|
123
|
+
if (props.$pointerEventsOnBackdrop === 'none') {
|
|
124
|
+
return (0, styled_components_1.css) `
|
|
125
|
+
background: rgba(0, 0, 0, 0.1);
|
|
126
|
+
`;
|
|
127
|
+
}
|
|
128
|
+
return (0, styled_components_1.css) `
|
|
129
|
+
background: ${props.theme.colors.background.dark};
|
|
130
|
+
`;
|
|
131
|
+
}}
|
|
132
|
+
opacity: 1;
|
|
133
|
+
pointer-events: ${(props) => props.$pointerEventsOnBackdrop || 'auto'};
|
|
134
|
+
transition:
|
|
135
|
+
opacity 0.5s ease-in-out,
|
|
136
|
+
display 0.5s ease allow-discrete,
|
|
137
|
+
overlay 0.5s ease allow-discrete;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
&:not([open])::backdrop {
|
|
141
|
+
opacity: 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@starting-style {
|
|
145
|
+
&[open]::backdrop {
|
|
146
|
+
opacity: 0;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
`;
|
|
25
150
|
exports.ModalContainer = styled_components_1.default.div `
|
|
26
151
|
background: ${(props) => props.theme.colors.background.primary};
|
|
27
152
|
border-radius: ${(props) => props.theme.grid.radius.default};
|
|
@@ -119,67 +244,3 @@ exports.ModalTitle = styled_components_1.default.h2 `
|
|
|
119
244
|
color: ${(props) => props.theme.colors.text.primary};
|
|
120
245
|
margin: 0 0 20px 0;
|
|
121
246
|
`;
|
|
122
|
-
exports.StyledModal = (0, styled_components_1.default)(ReactModalAdapter).attrs({
|
|
123
|
-
closeTimeoutMS: totalTransitionTime,
|
|
124
|
-
overlayClassName: {
|
|
125
|
-
base: 'Overlay',
|
|
126
|
-
afterOpen: 'Overlay--after-open',
|
|
127
|
-
beforeClose: 'Overlay--before-close',
|
|
128
|
-
},
|
|
129
|
-
modalClassName: {
|
|
130
|
-
base: 'Modal',
|
|
131
|
-
afterOpen: 'Modal--after-open',
|
|
132
|
-
beforeClose: 'Modal--before-close',
|
|
133
|
-
},
|
|
134
|
-
}) `
|
|
135
|
-
.Overlay {
|
|
136
|
-
position: fixed;
|
|
137
|
-
top: 0;
|
|
138
|
-
left: 0;
|
|
139
|
-
right: 0;
|
|
140
|
-
bottom: 0;
|
|
141
|
-
background-color: ${(props) => props.hideOverlay
|
|
142
|
-
? 'transparent'
|
|
143
|
-
: props.pointerEventsOnBackdrop === 'none'
|
|
144
|
-
? 'rgba(0,0,0,0.1)'
|
|
145
|
-
: props.theme.colors.background.dark};
|
|
146
|
-
z-index: 1000;
|
|
147
|
-
display: flex;
|
|
148
|
-
justify-content: center;
|
|
149
|
-
align-items: center;
|
|
150
|
-
opacity: 0;
|
|
151
|
-
pointer-events: ${(props) => props.pointerEventsOnBackdrop || 'auto'};
|
|
152
|
-
|
|
153
|
-
&--after-open {
|
|
154
|
-
transition: opacity ${totalTransitionTime}ms ease-in-out;
|
|
155
|
-
opacity: 1;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
&--before-close {
|
|
159
|
-
transition: opacity ${delayedTransitionTime}ms ease-in-out;
|
|
160
|
-
transition-delay: ${transitionDelay}ms;
|
|
161
|
-
opacity: 0;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
.Modal {
|
|
166
|
-
background: transparent;
|
|
167
|
-
border: none;
|
|
168
|
-
position: relative;
|
|
169
|
-
outline: none;
|
|
170
|
-
opacity: 0;
|
|
171
|
-
transition:
|
|
172
|
-
opacity ${delayedTransitionTime}ms ease-in-out,
|
|
173
|
-
top ${delayedTransitionTime}ms ease-in-out;
|
|
174
|
-
transition-delay: ${transitionDelay}ms;
|
|
175
|
-
|
|
176
|
-
&--after-open {
|
|
177
|
-
opacity: 1;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
&--before-close {
|
|
181
|
-
transition-delay: 0ms;
|
|
182
|
-
opacity: 0;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
`;
|