@transferwise/components 46.71.5 → 46.71.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/build/typeahead/util/highlight.js +14 -2
- package/build/typeahead/util/highlight.js.map +1 -1
- package/build/typeahead/util/highlight.mjs +15 -3
- package/build/typeahead/util/highlight.mjs.map +1 -1
- package/build/types/typeahead/util/highlight.d.ts +1 -1
- package/build/types/typeahead/util/highlight.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/typeahead/typeaheadOption/TypeaheadOption.spec.js +7 -5
- package/src/typeahead/util/highlight.tsx +7 -2
|
@@ -6,13 +6,25 @@ function Highlight({
|
|
|
6
6
|
className,
|
|
7
7
|
value,
|
|
8
8
|
query
|
|
9
|
+
}) {
|
|
10
|
+
const content = /*#__PURE__*/jsxRuntime.jsx(HighlightContent, {
|
|
11
|
+
value: value,
|
|
12
|
+
query: query
|
|
13
|
+
});
|
|
14
|
+
return className ? /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
15
|
+
className: className,
|
|
16
|
+
children: content
|
|
17
|
+
}) : content;
|
|
18
|
+
}
|
|
19
|
+
function HighlightContent({
|
|
20
|
+
value,
|
|
21
|
+
query
|
|
9
22
|
}) {
|
|
10
23
|
if (value && query) {
|
|
11
24
|
const highlightStart = value.toUpperCase().indexOf(query.trim().toUpperCase());
|
|
12
25
|
const highlightEnd = highlightStart + query.trim().length;
|
|
13
26
|
if (highlightStart !== -1) {
|
|
14
|
-
return /*#__PURE__*/jsxRuntime.jsxs(
|
|
15
|
-
className: className,
|
|
27
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
16
28
|
children: [value.slice(0, Math.max(0, highlightStart)), /*#__PURE__*/jsxRuntime.jsx("strong", {
|
|
17
29
|
children: value.slice(highlightStart, highlightEnd)
|
|
18
30
|
}), value.slice(Math.max(0, highlightEnd))]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlight.js","sources":["../../../src/typeahead/util/highlight.tsx"],"sourcesContent":["export default function Highlight({\n className,\n value,\n query,\n}: {\n className?: string;\n value: string;\n query: string;\n}) {\n if (value && query) {\n const highlightStart = value.toUpperCase().indexOf(query.trim().toUpperCase());\n const highlightEnd = highlightStart + query.trim().length;\n if (highlightStart !== -1) {\n return (\n
|
|
1
|
+
{"version":3,"file":"highlight.js","sources":["../../../src/typeahead/util/highlight.tsx"],"sourcesContent":["export default function Highlight({\n className,\n value,\n query,\n}: {\n className?: string;\n value: string;\n query: string;\n}) {\n const content = <HighlightContent value={value} query={query} />;\n return className ? <span className={className}>{content}</span> : content;\n}\n\nfunction HighlightContent({ value, query }: { value: string; query: string }) {\n if (value && query) {\n const highlightStart = value.toUpperCase().indexOf(query.trim().toUpperCase());\n const highlightEnd = highlightStart + query.trim().length;\n if (highlightStart !== -1) {\n return (\n <>\n {value.slice(0, Math.max(0, highlightStart))}\n <strong>{value.slice(highlightStart, highlightEnd)}</strong>\n {value.slice(Math.max(0, highlightEnd))}\n </>\n );\n }\n }\n return value;\n}\n"],"names":["Highlight","className","value","query","content","_jsx","HighlightContent","children","highlightStart","toUpperCase","indexOf","trim","highlightEnd","length","_jsxs","_Fragment","slice","Math","max"],"mappings":";;;;AAAc,SAAUA,SAASA,CAAC;EAChCC,SAAS;EACTC,KAAK;AACLC,EAAAA,KAAAA;AAKD,CAAA,EAAA;AACC,EAAA,MAAMC,OAAO,gBAAGC,cAAA,CAACC,gBAAgB,EAAA;AAACJ,IAAAA,KAAK,EAAEA,KAAM;AAACC,IAAAA,KAAK,EAAEA,KAAAA;AAAM,IAAG,CAAA;EAChE,OAAOF,SAAS,gBAAGI,cAAA,CAAA,MAAA,EAAA;AAAMJ,IAAAA,SAAS,EAAEA,SAAU;AAAAM,IAAAA,QAAA,EAAEH,OAAAA;GAAc,CAAC,GAAGA,OAAO,CAAA;AAC3E,CAAA;AAEA,SAASE,gBAAgBA,CAAC;EAAEJ,KAAK;AAAEC,EAAAA,KAAAA;AAAyC,CAAA,EAAA;EAC1E,IAAID,KAAK,IAAIC,KAAK,EAAE;AAClB,IAAA,MAAMK,cAAc,GAAGN,KAAK,CAACO,WAAW,EAAE,CAACC,OAAO,CAACP,KAAK,CAACQ,IAAI,EAAE,CAACF,WAAW,EAAE,CAAC,CAAA;IAC9E,MAAMG,YAAY,GAAGJ,cAAc,GAAGL,KAAK,CAACQ,IAAI,EAAE,CAACE,MAAM,CAAA;AACzD,IAAA,IAAIL,cAAc,KAAK,CAAC,CAAC,EAAE;MACzB,oBACEM,eAAA,CAAAC,mBAAA,EAAA;AAAAR,QAAAA,QAAA,GACGL,KAAK,CAACc,KAAK,CAAC,CAAC,EAAEC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEV,cAAc,CAAC,CAAC,eAC5CH,cAAA,CAAA,QAAA,EAAA;AAAAE,UAAAA,QAAA,EAASL,KAAK,CAACc,KAAK,CAACR,cAAc,EAAEI,YAAY,CAAA;AAAC,SAAS,CAC3D,EAACV,KAAK,CAACc,KAAK,CAACC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEN,YAAY,CAAC,CAAC,CAAA;AAAA,OACzC,CAAG,CAAA;AAEP,KAAA;AACF,GAAA;AACA,EAAA,OAAOV,KAAK,CAAA;AACd;;;;"}
|
|
@@ -1,16 +1,28 @@
|
|
|
1
|
-
import { jsxs,
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
|
|
3
3
|
function Highlight({
|
|
4
4
|
className,
|
|
5
5
|
value,
|
|
6
6
|
query
|
|
7
|
+
}) {
|
|
8
|
+
const content = /*#__PURE__*/jsx(HighlightContent, {
|
|
9
|
+
value: value,
|
|
10
|
+
query: query
|
|
11
|
+
});
|
|
12
|
+
return className ? /*#__PURE__*/jsx("span", {
|
|
13
|
+
className: className,
|
|
14
|
+
children: content
|
|
15
|
+
}) : content;
|
|
16
|
+
}
|
|
17
|
+
function HighlightContent({
|
|
18
|
+
value,
|
|
19
|
+
query
|
|
7
20
|
}) {
|
|
8
21
|
if (value && query) {
|
|
9
22
|
const highlightStart = value.toUpperCase().indexOf(query.trim().toUpperCase());
|
|
10
23
|
const highlightEnd = highlightStart + query.trim().length;
|
|
11
24
|
if (highlightStart !== -1) {
|
|
12
|
-
return /*#__PURE__*/jsxs(
|
|
13
|
-
className: className,
|
|
25
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
14
26
|
children: [value.slice(0, Math.max(0, highlightStart)), /*#__PURE__*/jsx("strong", {
|
|
15
27
|
children: value.slice(highlightStart, highlightEnd)
|
|
16
28
|
}), value.slice(Math.max(0, highlightEnd))]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlight.mjs","sources":["../../../src/typeahead/util/highlight.tsx"],"sourcesContent":["export default function Highlight({\n className,\n value,\n query,\n}: {\n className?: string;\n value: string;\n query: string;\n}) {\n if (value && query) {\n const highlightStart = value.toUpperCase().indexOf(query.trim().toUpperCase());\n const highlightEnd = highlightStart + query.trim().length;\n if (highlightStart !== -1) {\n return (\n
|
|
1
|
+
{"version":3,"file":"highlight.mjs","sources":["../../../src/typeahead/util/highlight.tsx"],"sourcesContent":["export default function Highlight({\n className,\n value,\n query,\n}: {\n className?: string;\n value: string;\n query: string;\n}) {\n const content = <HighlightContent value={value} query={query} />;\n return className ? <span className={className}>{content}</span> : content;\n}\n\nfunction HighlightContent({ value, query }: { value: string; query: string }) {\n if (value && query) {\n const highlightStart = value.toUpperCase().indexOf(query.trim().toUpperCase());\n const highlightEnd = highlightStart + query.trim().length;\n if (highlightStart !== -1) {\n return (\n <>\n {value.slice(0, Math.max(0, highlightStart))}\n <strong>{value.slice(highlightStart, highlightEnd)}</strong>\n {value.slice(Math.max(0, highlightEnd))}\n </>\n );\n }\n }\n return value;\n}\n"],"names":["Highlight","className","value","query","content","_jsx","HighlightContent","children","highlightStart","toUpperCase","indexOf","trim","highlightEnd","length","_jsxs","_Fragment","slice","Math","max"],"mappings":";;AAAc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A;AACd;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../../../src/typeahead/util/highlight.tsx"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,SAAS,EACT,KAAK,EACL,KAAK,GACN,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf
|
|
1
|
+
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../../../src/typeahead/util/highlight.tsx"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,SAAS,EACT,KAAK,EACL,KAAK,GACN,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,+BAGA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "46.71.
|
|
3
|
+
"version": "46.71.6",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"rollup-preserve-directives": "^1.1.1",
|
|
93
93
|
"storybook": "^8.2.2",
|
|
94
94
|
"@transferwise/less-config": "3.1.0",
|
|
95
|
-
"@
|
|
96
|
-
"@
|
|
95
|
+
"@wise/components-theming": "1.6.1",
|
|
96
|
+
"@transferwise/neptune-css": "14.19.1"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"@transferwise/icons": "^3.13.1",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { shallow } from 'enzyme';
|
|
1
|
+
import { shallow, mount } from 'enzyme';
|
|
2
2
|
|
|
3
3
|
import { fakeEvent } from '../../common/fakeEvents';
|
|
4
4
|
|
|
@@ -11,7 +11,7 @@ describe('Typeahead Option', () => {
|
|
|
11
11
|
|
|
12
12
|
const labelHighlight = () => component.find(Highlight);
|
|
13
13
|
const noteSpan = () => component.find('.np-text-body-default.m-l-1');
|
|
14
|
-
const secondaryTextHighlight = () => component.find('.np-text-body-default.text-ellipsis');
|
|
14
|
+
const secondaryTextHighlight = () => component.find('.np-text-body-default.text-ellipsis > span');
|
|
15
15
|
const dropdownItem = () => component.find('.dropdown-item');
|
|
16
16
|
|
|
17
17
|
beforeEach(() => {
|
|
@@ -21,13 +21,13 @@ describe('Typeahead Option', () => {
|
|
|
21
21
|
},
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
component =
|
|
24
|
+
component = mount(<TypeaheadOption {...props} />);
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
it('renders a label', () => {
|
|
28
28
|
const label = 'test';
|
|
29
29
|
component.setProps({ option: { label } });
|
|
30
|
-
expect(labelHighlight().
|
|
30
|
+
expect(labelHighlight().text()).toStrictEqual(label);
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
it('renders a note', () => {
|
|
@@ -41,10 +41,11 @@ describe('Typeahead Option', () => {
|
|
|
41
41
|
const label = 'test';
|
|
42
42
|
const secondary = 'test note';
|
|
43
43
|
component.setProps({ option: { label, secondary } });
|
|
44
|
-
expect(secondaryTextHighlight().
|
|
44
|
+
expect(secondaryTextHighlight().text()).toStrictEqual(secondary);
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
it('highlights when selected', () => {
|
|
48
|
+
component = shallow(<TypeaheadOption {...props} />);
|
|
48
49
|
component.setProps({
|
|
49
50
|
selected: true,
|
|
50
51
|
});
|
|
@@ -53,6 +54,7 @@ describe('Typeahead Option', () => {
|
|
|
53
54
|
});
|
|
54
55
|
|
|
55
56
|
it('expect aria-selected to be true', () => {
|
|
57
|
+
component = shallow(<TypeaheadOption {...props} />);
|
|
56
58
|
component.setProps({
|
|
57
59
|
selected: true,
|
|
58
60
|
});
|
|
@@ -7,16 +7,21 @@ export default function Highlight({
|
|
|
7
7
|
value: string;
|
|
8
8
|
query: string;
|
|
9
9
|
}) {
|
|
10
|
+
const content = <HighlightContent value={value} query={query} />;
|
|
11
|
+
return className ? <span className={className}>{content}</span> : content;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function HighlightContent({ value, query }: { value: string; query: string }) {
|
|
10
15
|
if (value && query) {
|
|
11
16
|
const highlightStart = value.toUpperCase().indexOf(query.trim().toUpperCase());
|
|
12
17
|
const highlightEnd = highlightStart + query.trim().length;
|
|
13
18
|
if (highlightStart !== -1) {
|
|
14
19
|
return (
|
|
15
|
-
|
|
20
|
+
<>
|
|
16
21
|
{value.slice(0, Math.max(0, highlightStart))}
|
|
17
22
|
<strong>{value.slice(highlightStart, highlightEnd)}</strong>
|
|
18
23
|
{value.slice(Math.max(0, highlightEnd))}
|
|
19
|
-
|
|
24
|
+
</>
|
|
20
25
|
);
|
|
21
26
|
}
|
|
22
27
|
}
|