@spaced-out/ui-design-system 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/lib/components/Modal/Modal.js +39 -5
- package/lib/components/Modal/Modal.js.flow +45 -5
- package/lib/components/SearchInput/SearchInput.js +2 -1
- package/lib/components/SearchInput/SearchInput.js.flow +5 -1
- package/lib/components/SearchInput/SearchInput.module.css +8 -8
- package/lib/components/Table/Row.js +6 -2
- package/lib/components/Table/Row.js.flow +2 -0
- package/lib/components/Table/TableHeader.js +3 -1
- package/lib/components/Table/TableHeader.js.flow +1 -0
- package/lib/components/Text/Text.js +3 -2
- package/lib/components/Text/Text.js.flow +3 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.1.9](https://github.com/spaced-out/ui-design-system/compare/v0.1.8...v0.1.9) (2023-04-05)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* search input loader and typeahead fixes ([67db0fe](https://github.com/spaced-out/ui-design-system/commit/67db0fe3ad41f6d8a40a7fc77fef835ae96cc668))
|
|
11
|
+
|
|
12
|
+
### [0.1.8](https://github.com/spaced-out/ui-design-system/compare/v0.1.7...v0.1.8) (2023-04-05)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* modal scroll fix ([47a2349](https://github.com/spaced-out/ui-design-system/commit/47a23496c8b9328ab6cbe3f7736635776fb4f797))
|
|
18
|
+
* modal scroll fix ([c33b8bd](https://github.com/spaced-out/ui-design-system/commit/c33b8bd6b4a7cf4c4a51c2abe8a3211c829b054b))
|
|
19
|
+
|
|
5
20
|
### [0.1.7](https://github.com/spaced-out/ui-design-system/compare/v0.1.6...v0.1.7) (2023-04-05)
|
|
6
21
|
|
|
7
22
|
|
|
@@ -67,6 +67,34 @@ const createPortalRoot = id => {
|
|
|
67
67
|
return modalRoot;
|
|
68
68
|
};
|
|
69
69
|
const getModalRoot = id => document.getElementById(`modal-root-${id}`);
|
|
70
|
+
function hasChildNode(nodeList) {
|
|
71
|
+
for (let i = 0, len = nodeList.length; i < len; i++) {
|
|
72
|
+
if (nodeList[i].firstChild !== null) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
const fixBody = bodyEl => {
|
|
79
|
+
document.getElementsByTagName('body')[0].classList.add('fixed');
|
|
80
|
+
bodyEl.style.overflow = 'hidden';
|
|
81
|
+
};
|
|
82
|
+
const unfixBody = bodyEl => {
|
|
83
|
+
document.getElementsByTagName('body')[0].classList.remove('fixed');
|
|
84
|
+
bodyEl.style.overflow = '';
|
|
85
|
+
};
|
|
86
|
+
const checkAndAddBodyOverflow = bodyEl => {
|
|
87
|
+
const nodes = document.querySelectorAll('[id^="modal-root"]');
|
|
88
|
+
let isParentModalPresent = false;
|
|
89
|
+
if (nodes.length) {
|
|
90
|
+
isParentModalPresent = hasChildNode(nodes);
|
|
91
|
+
}
|
|
92
|
+
if (isParentModalPresent) {
|
|
93
|
+
fixBody(bodyEl);
|
|
94
|
+
} else {
|
|
95
|
+
unfixBody(bodyEl);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
70
98
|
const Modal = _ref4 => {
|
|
71
99
|
let {
|
|
72
100
|
classNames,
|
|
@@ -74,7 +102,6 @@ const Modal = _ref4 => {
|
|
|
74
102
|
isOpen = false,
|
|
75
103
|
onClose,
|
|
76
104
|
hideBackdrop = false,
|
|
77
|
-
removeWhenClosed = true,
|
|
78
105
|
tapOutsideToClose = true,
|
|
79
106
|
initialFocus = -1
|
|
80
107
|
} = _ref4;
|
|
@@ -97,7 +124,7 @@ const Modal = _ref4 => {
|
|
|
97
124
|
portal.remove();
|
|
98
125
|
// Ensure scroll overflow is removed
|
|
99
126
|
if (bodyEl) {
|
|
100
|
-
bodyEl
|
|
127
|
+
unfixBody(bodyEl);
|
|
101
128
|
}
|
|
102
129
|
};
|
|
103
130
|
}, []);
|
|
@@ -107,11 +134,11 @@ const Modal = _ref4 => {
|
|
|
107
134
|
const updatePageScroll = () => {
|
|
108
135
|
if (isOpen) {
|
|
109
136
|
if (bodyRef.current) {
|
|
110
|
-
bodyRef.current
|
|
137
|
+
fixBody(bodyRef.current);
|
|
111
138
|
}
|
|
112
139
|
} else {
|
|
113
140
|
if (bodyRef.current) {
|
|
114
|
-
bodyRef.current
|
|
141
|
+
unfixBody(bodyRef.current);
|
|
115
142
|
}
|
|
116
143
|
}
|
|
117
144
|
};
|
|
@@ -132,7 +159,14 @@ const Modal = _ref4 => {
|
|
|
132
159
|
window.removeEventListener('keyup', onKeyPress);
|
|
133
160
|
};
|
|
134
161
|
}, [isOpen, onClose]);
|
|
135
|
-
if (!isTransitioning &&
|
|
162
|
+
if (!isTransitioning && !isOpen) {
|
|
163
|
+
// Check overflow after resetting the DOM for modal. This should always happen after DOM reset
|
|
164
|
+
// TODO(Nishant): Better way to do this?
|
|
165
|
+
setTimeout(() => {
|
|
166
|
+
if (bodyRef && !!bodyRef.current) {
|
|
167
|
+
checkAndAddBodyOverflow(bodyRef.current);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
136
170
|
return null;
|
|
137
171
|
}
|
|
138
172
|
const onBackdropClick = e => {
|
|
@@ -37,6 +37,7 @@ export type ModalProps = {
|
|
|
37
37
|
isOpen?: boolean,
|
|
38
38
|
onClose?: ?(SyntheticEvent<HTMLElement>) => mixed,
|
|
39
39
|
hideBackdrop?: boolean,
|
|
40
|
+
// This prop is removed now
|
|
40
41
|
removeWhenClosed?: boolean,
|
|
41
42
|
tapOutsideToClose?: boolean,
|
|
42
43
|
initialFocus?: number,
|
|
@@ -116,13 +117,44 @@ const createPortalRoot = (id: string) => {
|
|
|
116
117
|
const getModalRoot = (id: string) =>
|
|
117
118
|
document.getElementById(`modal-root-${id}`);
|
|
118
119
|
|
|
120
|
+
function hasChildNode(nodeList) {
|
|
121
|
+
for (let i = 0, len = nodeList.length; i < len; i++) {
|
|
122
|
+
if (nodeList[i].firstChild !== null) {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const fixBody = (bodyEl: HTMLBodyElement) => {
|
|
130
|
+
document.getElementsByTagName('body')[0].classList.add('fixed');
|
|
131
|
+
bodyEl.style.overflow = 'hidden';
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const unfixBody = (bodyEl: HTMLBodyElement) => {
|
|
135
|
+
document.getElementsByTagName('body')[0].classList.remove('fixed');
|
|
136
|
+
bodyEl.style.overflow = '';
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const checkAndAddBodyOverflow = (bodyEl: HTMLBodyElement) => {
|
|
140
|
+
const nodes = document.querySelectorAll('[id^="modal-root"]');
|
|
141
|
+
let isParentModalPresent = false;
|
|
142
|
+
if (nodes.length) {
|
|
143
|
+
isParentModalPresent = hasChildNode(nodes);
|
|
144
|
+
}
|
|
145
|
+
if (isParentModalPresent) {
|
|
146
|
+
fixBody(bodyEl);
|
|
147
|
+
} else {
|
|
148
|
+
unfixBody(bodyEl);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
119
152
|
export const Modal = ({
|
|
120
153
|
classNames,
|
|
121
154
|
children,
|
|
122
155
|
isOpen = false,
|
|
123
156
|
onClose,
|
|
124
157
|
hideBackdrop = false,
|
|
125
|
-
removeWhenClosed = true,
|
|
126
158
|
tapOutsideToClose = true,
|
|
127
159
|
initialFocus = -1,
|
|
128
160
|
}: ModalProps): React.Node => {
|
|
@@ -150,7 +182,7 @@ export const Modal = ({
|
|
|
150
182
|
portal.remove();
|
|
151
183
|
// Ensure scroll overflow is removed
|
|
152
184
|
if (bodyEl) {
|
|
153
|
-
bodyEl
|
|
185
|
+
unfixBody(bodyEl);
|
|
154
186
|
}
|
|
155
187
|
};
|
|
156
188
|
}, []);
|
|
@@ -160,11 +192,11 @@ export const Modal = ({
|
|
|
160
192
|
const updatePageScroll = () => {
|
|
161
193
|
if (isOpen) {
|
|
162
194
|
if (bodyRef.current) {
|
|
163
|
-
bodyRef.current
|
|
195
|
+
fixBody(bodyRef.current);
|
|
164
196
|
}
|
|
165
197
|
} else {
|
|
166
198
|
if (bodyRef.current) {
|
|
167
|
-
bodyRef.current
|
|
199
|
+
unfixBody(bodyRef.current);
|
|
168
200
|
}
|
|
169
201
|
}
|
|
170
202
|
};
|
|
@@ -189,7 +221,15 @@ export const Modal = ({
|
|
|
189
221
|
};
|
|
190
222
|
}, [isOpen, onClose]);
|
|
191
223
|
|
|
192
|
-
if (!isTransitioning &&
|
|
224
|
+
if (!isTransitioning && !isOpen) {
|
|
225
|
+
// Check overflow after resetting the DOM for modal. This should always happen after DOM reset
|
|
226
|
+
// TODO(Nishant): Better way to do this?
|
|
227
|
+
setTimeout(() => {
|
|
228
|
+
if (bodyRef && !!bodyRef.current) {
|
|
229
|
+
checkAndAddBodyOverflow(bodyRef.current);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
|
|
193
233
|
return null;
|
|
194
234
|
}
|
|
195
235
|
|
|
@@ -53,7 +53,8 @@ const SearchInput = _ref => {
|
|
|
53
53
|
})
|
|
54
54
|
}, /*#__PURE__*/React.createElement(_CircularLoader.CircularLoader, {
|
|
55
55
|
colorToken: "colorFillPrimary",
|
|
56
|
-
|
|
56
|
+
className: _SearchInputModule.default.loader,
|
|
57
|
+
size: "small"
|
|
57
58
|
})));
|
|
58
59
|
};
|
|
59
60
|
exports.SearchInput = SearchInput;
|
|
@@ -64,7 +64,11 @@ export const SearchInput = ({
|
|
|
64
64
|
[css.small]: size === 'small',
|
|
65
65
|
})}
|
|
66
66
|
>
|
|
67
|
-
<CircularLoader
|
|
67
|
+
<CircularLoader
|
|
68
|
+
colorToken="colorFillPrimary"
|
|
69
|
+
className={css.loader}
|
|
70
|
+
size="small"
|
|
71
|
+
/>
|
|
68
72
|
</div>
|
|
69
73
|
)}
|
|
70
74
|
</div>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
@value (
|
|
2
|
-
colorTextPrimary
|
|
2
|
+
colorTextPrimary,
|
|
3
|
+
colorBackgroundTertiary
|
|
3
4
|
) from '../../styles/variables/_color.css';
|
|
4
5
|
|
|
5
6
|
@value (
|
|
@@ -7,15 +8,10 @@
|
|
|
7
8
|
size34
|
|
8
9
|
) from '../../styles/variables/_size.css';
|
|
9
10
|
|
|
10
|
-
@value (
|
|
11
|
-
spaceXXSmall
|
|
12
|
-
) from '../../styles/variables/_space.css';
|
|
13
|
-
|
|
14
11
|
.searchInputWrapper {
|
|
15
12
|
display: flex;
|
|
16
13
|
position: relative;
|
|
17
14
|
align-items: end;
|
|
18
|
-
gap: spaceXXSmall;
|
|
19
15
|
height: fit-content;
|
|
20
16
|
}
|
|
21
17
|
|
|
@@ -34,11 +30,15 @@
|
|
|
34
30
|
align-items: center;
|
|
35
31
|
justify-content: center;
|
|
36
32
|
align-items: center;
|
|
37
|
-
margin-
|
|
33
|
+
margin-left: calc(size42 * -1);
|
|
38
34
|
}
|
|
39
35
|
|
|
40
36
|
.loaderContainer.small {
|
|
41
37
|
height: size34;
|
|
42
38
|
width: size34;
|
|
43
|
-
margin-
|
|
39
|
+
margin-left: calc(size34 * -1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.loader {
|
|
43
|
+
background-color: colorBackgroundTertiary;
|
|
44
44
|
}
|
|
@@ -77,7 +77,9 @@ function DefaultRow(_ref2) {
|
|
|
77
77
|
sticky
|
|
78
78
|
} = item;
|
|
79
79
|
const value = data[key];
|
|
80
|
-
return Renderer ? /*#__PURE__*/React.createElement(Renderer
|
|
80
|
+
return Renderer ? /*#__PURE__*/React.createElement(Renderer
|
|
81
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
82
|
+
, {
|
|
81
83
|
key: index,
|
|
82
84
|
data: data,
|
|
83
85
|
extras: extras,
|
|
@@ -85,7 +87,9 @@ function DefaultRow(_ref2) {
|
|
|
85
87
|
className: (0, _classify.default)({
|
|
86
88
|
[_TableModule.default.stickyCell]: sticky
|
|
87
89
|
})
|
|
88
|
-
}) : /*#__PURE__*/React.createElement(_Cell.SingleCell
|
|
90
|
+
}) : /*#__PURE__*/React.createElement(_Cell.SingleCell
|
|
91
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
92
|
+
, {
|
|
89
93
|
key: index,
|
|
90
94
|
title: String(value),
|
|
91
95
|
className: (0, _classify.default)(cellClassName, {
|
|
@@ -126,6 +126,7 @@ export function DefaultRow<T: GenericObject, U: GenericObject>({
|
|
|
126
126
|
const value = data[key];
|
|
127
127
|
return Renderer ? (
|
|
128
128
|
<Renderer
|
|
129
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
129
130
|
key={index}
|
|
130
131
|
data={data}
|
|
131
132
|
extras={extras}
|
|
@@ -134,6 +135,7 @@ export function DefaultRow<T: GenericObject, U: GenericObject>({
|
|
|
134
135
|
/>
|
|
135
136
|
) : (
|
|
136
137
|
<SingleCell
|
|
138
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
137
139
|
key={index}
|
|
138
140
|
title={String(value)}
|
|
139
141
|
className={classify(cellClassName, {[css.stickyCell]: sticky})}
|
|
@@ -100,7 +100,9 @@ function DefaultTableHeader(props) {
|
|
|
100
100
|
return /*#__PURE__*/React.createElement(BasicHeadCell, {
|
|
101
101
|
className: (0, _classify.default)({
|
|
102
102
|
[_TableModule.default.selectedHeader]: sortKey === key && columnSortDirection !== 'original'
|
|
103
|
-
}, headerClassName)
|
|
103
|
+
}, headerClassName)
|
|
104
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
105
|
+
,
|
|
104
106
|
key: index,
|
|
105
107
|
scope: "col",
|
|
106
108
|
onClick: headCellClickHandler
|
|
@@ -29,8 +29,9 @@ const HighlightText = _ref => {
|
|
|
29
29
|
highlights = (0, _string.escapeRegExp)(highlight);
|
|
30
30
|
}
|
|
31
31
|
const parts = text.split(new RegExp(`(${highlights})`, caseSensitiveHighlighting ? '' : 'gi')).filter(part => part !== '');
|
|
32
|
-
return /*#__PURE__*/React.createElement("span", null, parts.map(part => highlights.toLowerCase().includes((0, _string.escapeRegExp)(part).toLowerCase()) ? /*#__PURE__*/React.createElement("span", {
|
|
33
|
-
key
|
|
32
|
+
return /*#__PURE__*/React.createElement("span", null, parts.map((part, idx) => highlights.toLowerCase().includes((0, _string.escapeRegExp)(part).toLowerCase()) ? /*#__PURE__*/React.createElement("span", {
|
|
33
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
34
|
+
key: idx,
|
|
34
35
|
className: (0, _classify.default)(_typographyModule.default.highlightText, {
|
|
35
36
|
[_typographyModule.default.bgHighlighting]: highlightWithBackground
|
|
36
37
|
}, highlightClassName)
|
|
@@ -50,10 +50,11 @@ const HighlightText = ({
|
|
|
50
50
|
|
|
51
51
|
return (
|
|
52
52
|
<span>
|
|
53
|
-
{parts.map((part) =>
|
|
53
|
+
{parts.map((part, idx) =>
|
|
54
54
|
highlights.toLowerCase().includes(escapeRegExp(part).toLowerCase()) ? (
|
|
55
55
|
<span
|
|
56
|
-
key
|
|
56
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
57
|
+
key={idx}
|
|
57
58
|
className={classify(
|
|
58
59
|
css.highlightText,
|
|
59
60
|
{
|