@spaced-out/ui-design-system 0.0.66 → 0.0.67
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 +8 -0
- package/lib/components/Checkbox/Checkbox.module.css +3 -1
- package/lib/components/Input/Input.module.css +3 -1
- package/lib/components/Text/Text.js +5 -4
- package/lib/components/Text/Text.js.flow +9 -6
- package/lib/components/Textarea/Textarea.module.css +3 -1
- package/lib/utils/string.js +4 -2
- package/lib/utils/string.js.flow +3 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
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.0.67](https://github.com/spaced-out/ui-design-system/compare/v0.0.66...v0.0.67) (2023-03-30)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* input color fix ([daa9039](https://github.com/spaced-out/ui-design-system/commit/daa90393d504c6995f67b8a84f84a92a64ff3502))
|
|
11
|
+
* text highlight fix ([#90](https://github.com/spaced-out/ui-design-system/issues/90)) ([fc8d07c](https://github.com/spaced-out/ui-design-system/commit/fc8d07c23a2bf99b5d889c48d681d89f8957e8d5))
|
|
12
|
+
|
|
5
13
|
### [0.0.66](https://github.com/spaced-out/ui-design-system/compare/v0.0.65...v0.0.66) (2023-03-30)
|
|
6
14
|
|
|
7
15
|
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
colorBorderDanger,
|
|
12
12
|
colorDanger,
|
|
13
13
|
colorFocusPrimary,
|
|
14
|
-
colorFocusDanger
|
|
14
|
+
colorFocusDanger,
|
|
15
|
+
colorBackgroundTertiary
|
|
15
16
|
) from '../../styles/variables/_color.css';
|
|
16
17
|
|
|
17
18
|
@value (
|
|
@@ -85,6 +86,7 @@
|
|
|
85
86
|
align-items: center;
|
|
86
87
|
justify-content: center;
|
|
87
88
|
border-radius: borderRadiusXSmall;
|
|
89
|
+
background-color: colorBackgroundTertiary;
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
.enabled {
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
colorFocusDanger,
|
|
31
31
|
colorTextDisabled,
|
|
32
32
|
colorFillDisabled,
|
|
33
|
-
colorTextDanger
|
|
33
|
+
colorTextDanger,
|
|
34
|
+
colorBackgroundTertiary
|
|
34
35
|
) from '../../styles/variables/_color.css';
|
|
35
36
|
|
|
36
37
|
.container {
|
|
@@ -46,6 +47,7 @@
|
|
|
46
47
|
height: size42;
|
|
47
48
|
padding: spaceNone spaceSmall;
|
|
48
49
|
border: borderWidthSecondary solid colorBorderPrimary;
|
|
50
|
+
background-color: colorBackgroundTertiary;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
.locked {
|
|
@@ -7,6 +7,7 @@ exports.TitleMedium = exports.SubTitleSmall = exports.SubTitleMedium = exports.S
|
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _typography = require("../../types/typography");
|
|
9
9
|
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
10
|
+
var _string = require("../../utils/string");
|
|
10
11
|
var _typographyModule = _interopRequireDefault(require("../../styles/typography.module.css"));
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -23,12 +24,12 @@ const HighlightText = _ref => {
|
|
|
23
24
|
// Split text on highlight term, include term itself into parts, ignore case
|
|
24
25
|
let highlights = '';
|
|
25
26
|
if (Array.isArray(highlight)) {
|
|
26
|
-
highlights = highlight.join('|');
|
|
27
|
+
highlights = highlight.map(_string.escapeRegExp).join('|');
|
|
27
28
|
} else {
|
|
28
|
-
highlights = highlight;
|
|
29
|
+
highlights = (0, _string.escapeRegExp)(highlight);
|
|
29
30
|
}
|
|
30
|
-
const parts = text.split(new RegExp(`(${highlights})`, caseSensitiveHighlighting ? '' : 'gi'));
|
|
31
|
-
return /*#__PURE__*/React.createElement("span", null, parts.map(part => highlights.toLowerCase().includes(part.toLowerCase()) ? /*#__PURE__*/React.createElement("span", {
|
|
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", {
|
|
32
33
|
key: part,
|
|
33
34
|
className: (0, _classify.default)(_typographyModule.default.highlightText, {
|
|
34
35
|
[_typographyModule.default.bgHighlighting]: highlightWithBackground
|
|
@@ -5,6 +5,7 @@ import * as React from 'react';
|
|
|
5
5
|
import type {ColorTypes} from '../../types/typography';
|
|
6
6
|
import {TEXT_COLORS} from '../../types/typography';
|
|
7
7
|
import classify from '../../utils/classify';
|
|
8
|
+
import {escapeRegExp} from '../../utils/string';
|
|
8
9
|
|
|
9
10
|
import css from '../../styles/typography.module.css';
|
|
10
11
|
|
|
@@ -38,17 +39,19 @@ const HighlightText = ({
|
|
|
38
39
|
// Split text on highlight term, include term itself into parts, ignore case
|
|
39
40
|
let highlights = '';
|
|
40
41
|
if (Array.isArray(highlight)) {
|
|
41
|
-
highlights = highlight.join('|');
|
|
42
|
+
highlights = highlight.map(escapeRegExp).join('|');
|
|
42
43
|
} else {
|
|
43
|
-
highlights = highlight;
|
|
44
|
+
highlights = escapeRegExp(highlight);
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
|
|
47
|
+
const parts = text
|
|
48
|
+
.split(new RegExp(`(${highlights})`, caseSensitiveHighlighting ? '' : 'gi'))
|
|
49
|
+
.filter((part) => part !== '');
|
|
50
|
+
|
|
48
51
|
return (
|
|
49
52
|
<span>
|
|
50
53
|
{parts.map((part) =>
|
|
51
|
-
highlights.toLowerCase().includes(part.toLowerCase()) ? (
|
|
54
|
+
highlights.toLowerCase().includes(escapeRegExp(part).toLowerCase()) ? (
|
|
52
55
|
<span
|
|
53
56
|
key={part}
|
|
54
57
|
className={classify(
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
colorFocusDanger,
|
|
29
29
|
colorTextDisabled,
|
|
30
30
|
colorFillDisabled,
|
|
31
|
-
colorTextDanger
|
|
31
|
+
colorTextDanger,
|
|
32
|
+
colorBackgroundTertiary
|
|
32
33
|
) from '../../styles/variables/_color.css';
|
|
33
34
|
|
|
34
35
|
.container {
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
gap: spaceSmall;
|
|
44
45
|
height: size160;
|
|
45
46
|
border: borderWidthSecondary solid colorBorderPrimary;
|
|
47
|
+
background-color: colorBackgroundTertiary;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
.box textarea {
|
package/lib/utils/string.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.capitalize = void 0;
|
|
6
|
+
exports.escapeRegExp = exports.capitalize = void 0;
|
|
7
7
|
|
|
8
8
|
const capitalize = word => {
|
|
9
9
|
if (!word) {
|
|
@@ -11,4 +11,6 @@ const capitalize = word => {
|
|
|
11
11
|
}
|
|
12
12
|
return word.toLowerCase().replace(/\w/, firstLetter => firstLetter.toUpperCase());
|
|
13
13
|
};
|
|
14
|
-
exports.capitalize = capitalize;
|
|
14
|
+
exports.capitalize = capitalize;
|
|
15
|
+
const escapeRegExp = str => str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
16
|
+
exports.escapeRegExp = escapeRegExp;
|
package/lib/utils/string.js.flow
CHANGED