@jetbrains/ring-ui 5.0.53 → 5.0.55

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.
@@ -124,7 +124,7 @@
124
124
  &.withIcon,
125
125
  &.withIcon:active,
126
126
  &.withIcon.active {
127
- color: var(--ring-main-color);
127
+ color: var(--ring-action-link-color);
128
128
  }
129
129
 
130
130
  &:global(.focus-visible),
@@ -233,7 +233,7 @@
233
233
  }
234
234
 
235
235
  .text {
236
- color: var(--ring-main-color);
236
+ color: var(--ring-action-link-color);
237
237
  }
238
238
 
239
239
  .inline {
@@ -259,7 +259,7 @@
259
259
  .withIcon {
260
260
  &:active,
261
261
  &.active {
262
- color: var(--ring-main-color);
262
+ color: var(--ring-action-link-color);
263
263
  }
264
264
  }
265
265
 
@@ -1,5 +1,11 @@
1
1
  /** https://github.com/bevacqua/fuzzysearch + highlighting with Markdown */
2
+ declare type Match = {
3
+ from: number;
4
+ to: number;
5
+ };
2
6
  export default function fuzzyHighlight(needle: string, haystack: string, caseSensitive?: boolean): {
3
7
  matched: boolean;
8
+ matches: Match[];
4
9
  highlight: string;
5
10
  };
11
+ export {};
@@ -1,9 +1,20 @@
1
1
  /** https://github.com/bevacqua/fuzzysearch + highlighting with Markdown */
2
- const marker = '**';
3
2
  export default function fuzzyHighlight(needle, haystack, caseSensitive = false) {
4
3
  const ndl = caseSensitive ? needle : needle.toLowerCase();
5
4
  const hstck = caseSensitive ? haystack : haystack.toLowerCase();
6
- const result = (matched, highlight = haystack) => ({ matched, highlight });
5
+ const result = (matched, matches = []) => {
6
+ let highlight = haystack;
7
+ if (matches.length > 0) {
8
+ highlight = '';
9
+ let prevMatch = { to: 0 };
10
+ for (const match of matches) {
11
+ highlight += `${haystack.slice(prevMatch.to, match.from)}**${haystack.slice(match.from, match.to)}**`;
12
+ prevMatch = match;
13
+ }
14
+ highlight += haystack.slice(prevMatch.to);
15
+ }
16
+ return ({ matched, matches, highlight });
17
+ };
7
18
  const hlen = hstck.length;
8
19
  const nlen = ndl.length;
9
20
  if (nlen > hlen) {
@@ -11,11 +22,12 @@ export default function fuzzyHighlight(needle, haystack, caseSensitive = false)
11
22
  }
12
23
  if (nlen === hlen) {
13
24
  const matched = ndl === hstck;
14
- return result(matched, matched ? `${marker}${haystack}${marker}` : haystack);
25
+ return result(matched, matched ? [{ from: 0, to: haystack.length }] : []);
15
26
  }
16
- let highlight = '';
17
27
  let on = false;
18
28
  let j = 0;
29
+ const matches = [];
30
+ let from = 0;
19
31
  /* eslint-disable no-labels */
20
32
  outer: for (let i = 0; i < nlen; i++) {
21
33
  const nch = ndl[i];
@@ -24,10 +36,13 @@ export default function fuzzyHighlight(needle, haystack, caseSensitive = false)
24
36
  const match = hch === nch;
25
37
  // Don't turn highlight on for space characters
26
38
  const nextOn = match && /\S/.test(hch);
27
- if (nextOn !== on) {
28
- highlight += marker;
39
+ if (nextOn && !on) {
40
+ from = j;
41
+ }
42
+ else if (!nextOn && on) {
43
+ matches.push({ from, to: j });
29
44
  }
30
- highlight += haystack[j++];
45
+ j++;
31
46
  on = nextOn;
32
47
  if (match) {
33
48
  continue outer;
@@ -37,8 +52,7 @@ export default function fuzzyHighlight(needle, haystack, caseSensitive = false)
37
52
  }
38
53
  /* eslint-enable */
39
54
  if (on) {
40
- highlight += marker;
55
+ matches.push({ from, to: j });
41
56
  }
42
- highlight += haystack.slice(j);
43
- return result(true, highlight);
57
+ return result(true, matches);
44
58
  }
@@ -25,6 +25,8 @@
25
25
  --ring-icon-hover-color: var(--ring-link-hover-color);
26
26
  --ring-main-components: 0, 128, 229;
27
27
  --ring-main-color: rgb(var(--ring-main-components)); /* #0080e5 */
28
+ --ring-action-link-components: var(--ring-main-components);
29
+ --ring-action-link-color: rgb(var(--ring-main-components)); /* #0080e5 */
28
30
  --ring-main-hover-components: 0, 112, 204;
29
31
  --ring-main-hover-color: rgb(var(--ring-main-hover-components)); /* #0070cc */
30
32
  --ring-icon-error-components: 219, 88, 96;
@@ -21,6 +21,8 @@
21
21
  --ring-border-hover-color: rgb(var(--ring-border-hover-components)); /* #70b1e6 */
22
22
  --ring-main-components: 0, 142, 255;
23
23
  --ring-main-color: rgb(var(--ring-main-components)); /* #008eff */
24
+ --ring-action-link-components: var(--ring-main-components);
25
+ --ring-action-link-color: rgb(var(--ring-main-components)); /* #008eff */
24
26
  --ring-main-hover-components: 0, 126, 229;
25
27
  --ring-main-hover-color: rgb(var(--ring-main-hover-components)); /* #007ee5 */
26
28
  --ring-icon-error-components: 219, 88, 96;
@@ -1,5 +1,11 @@
1
1
  /** https://github.com/bevacqua/fuzzysearch + highlighting with Markdown */
2
+ declare type Match = {
3
+ from: number;
4
+ to: number;
5
+ };
2
6
  export default function fuzzyHighlight(needle: string, haystack: string, caseSensitive?: boolean): {
3
7
  matched: boolean;
8
+ matches: Match[];
4
9
  highlight: string;
5
10
  };
11
+ export {};
@@ -1,13 +1,25 @@
1
1
  /** https://github.com/bevacqua/fuzzysearch + highlighting with Markdown */
2
- const marker = '**';
3
2
  function fuzzyHighlight(needle, haystack) {
4
3
  let caseSensitive = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
5
4
  const ndl = caseSensitive ? needle : needle.toLowerCase();
6
5
  const hstck = caseSensitive ? haystack : haystack.toLowerCase();
7
6
  const result = function (matched) {
8
- let highlight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : haystack;
7
+ let matches = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
8
+ let highlight = haystack;
9
+ if (matches.length > 0) {
10
+ highlight = '';
11
+ let prevMatch = {
12
+ to: 0
13
+ };
14
+ for (const match of matches) {
15
+ highlight += `${haystack.slice(prevMatch.to, match.from)}**${haystack.slice(match.from, match.to)}**`;
16
+ prevMatch = match;
17
+ }
18
+ highlight += haystack.slice(prevMatch.to);
19
+ }
9
20
  return {
10
21
  matched,
22
+ matches,
11
23
  highlight
12
24
  };
13
25
  };
@@ -18,11 +30,15 @@ function fuzzyHighlight(needle, haystack) {
18
30
  }
19
31
  if (nlen === hlen) {
20
32
  const matched = ndl === hstck;
21
- return result(matched, matched ? `${marker}${haystack}${marker}` : haystack);
33
+ return result(matched, matched ? [{
34
+ from: 0,
35
+ to: haystack.length
36
+ }] : []);
22
37
  }
23
- let highlight = '';
24
38
  let on = false;
25
39
  let j = 0;
40
+ const matches = [];
41
+ let from = 0;
26
42
  /* eslint-disable no-labels */
27
43
  outer: for (let i = 0; i < nlen; i++) {
28
44
  const nch = ndl[i];
@@ -31,10 +47,15 @@ function fuzzyHighlight(needle, haystack) {
31
47
  const match = hch === nch;
32
48
  // Don't turn highlight on for space characters
33
49
  const nextOn = match && /\S/.test(hch);
34
- if (nextOn !== on) {
35
- highlight += marker;
50
+ if (nextOn && !on) {
51
+ from = j;
52
+ } else if (!nextOn && on) {
53
+ matches.push({
54
+ from,
55
+ to: j
56
+ });
36
57
  }
37
- highlight += haystack[j++];
58
+ j++;
38
59
  on = nextOn;
39
60
  if (match) {
40
61
  continue outer;
@@ -44,10 +65,12 @@ function fuzzyHighlight(needle, haystack) {
44
65
  }
45
66
  /* eslint-enable */
46
67
  if (on) {
47
- highlight += marker;
68
+ matches.push({
69
+ from,
70
+ to: j
71
+ });
48
72
  }
49
- highlight += haystack.slice(j);
50
- return result(true, highlight);
73
+ return result(true, matches);
51
74
  }
52
75
 
53
76
  export { fuzzyHighlight as default };