mimir-ui-kit 1.44.3 → 1.45.0

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.
@@ -104,4 +104,9 @@ export type TSelectSearchProps = Pick<TInputProps, 'withClearButton' | 'variant'
104
104
  * @default 'all'
105
105
  */
106
106
  borderRadius?: ESelectSearchBorderRadius | `${ESelectSearchBorderRadius}`;
107
+ /**
108
+ * Включить подсветку найденных значений в выпадающем списке
109
+ * @default false
110
+ */
111
+ highlightMatches?: boolean;
107
112
  };
@@ -6,3 +6,19 @@ export declare const mapSizeToInputSize: (size: ESelectSearchSize) => EInputSize
6
6
  export declare const getDropdownArrowIcon: (isOpen: boolean, size: ESelectSearchSize) => "DropdownArrowBottom16px" | "DropdownArrowUp16px" | "DropdownArrowUp24px" | "DropdownArrowDown24px";
7
7
  export declare const prepareGroupedItems: (items: TSelectOption[], groupBy: string, getGroupTitle: (value: string) => string) => TSelectOption[];
8
8
  export declare const shouldShowMenuOnTop: (selectRef: React.RefObject<HTMLDivElement>, size: ESelectSearchSize) => boolean;
9
+ /**
10
+ * Подсвечивает совпадения поискового запроса в тексте.
11
+ * @param text - Исходный текст для подсветки.
12
+ * @param searchQuery - Поисковый запрос.
13
+ * @param highlightClassName - CSS класс для подсвеченного текста.
14
+ * @returns Массив частей текста, где совпадения обернуты в span с классом.
15
+ */
16
+ export declare const highlightText: (text: string, searchQuery: string, highlightClassName: string) => (string | React.ReactElement)[];
17
+ /**
18
+ * Рекурсивно подсвечивает совпадения поискового запроса в ReactNode (включая JSX элементы).
19
+ * @param node - ReactNode для обработки.
20
+ * @param searchQuery - Поисковый запрос.
21
+ * @param highlightClassName - CSS класс для подсвеченного текста.
22
+ * @returns ReactNode с подсвеченными совпадениями.
23
+ */
24
+ export declare const highlightReactNode: (node: React.ReactNode, searchQuery: string, highlightClassName: string) => React.ReactNode;
@@ -1,38 +1,85 @@
1
- import { ESelectSearchSize as t, MOBILE_MENU_HEIGHT as i, DESKTOP_MENU_HEIGHT as a } from "./constants.js";
1
+ import { createElement as u, Fragment as l, isValidElement as g, cloneElement as m } from "react";
2
+ import { ESelectSearchSize as s, MOBILE_MENU_HEIGHT as w, DESKTOP_MENU_HEIGHT as f } from "./constants.js";
2
3
  import "../../Input-IzZ6B9kw.js";
3
- import { EInputSize as s } from "../Input/constants.js";
4
- const h = (r) => {
4
+ import { EInputSize as c } from "../Input/constants.js";
5
+ const A = (r) => {
5
6
  switch (r) {
6
- case t.S:
7
- return s.S;
8
- case t.M:
9
- return s.M;
10
- case t.L:
11
- return s.L;
7
+ case s.S:
8
+ return c.S;
9
+ case s.M:
10
+ return c.M;
11
+ case s.L:
12
+ return c.L;
12
13
  default:
13
- return s.M;
14
+ return c.M;
14
15
  }
15
- }, l = (r, o) => r ? o === t.L ? "DropdownArrowUp24px" : "DropdownArrowUp16px" : o === t.L ? "DropdownArrowDown24px" : "DropdownArrowBottom16px", f = (r, o, u) => {
16
- if (!r.length || !o) return r;
17
- const n = [], c = /* @__PURE__ */ new Set();
18
- for (const p of r) {
19
- const e = String(p[o] || "Без группы");
20
- c.has(e) || (c.add(e), n.push({
21
- id: `group-header-${e}`,
22
- name: u(e),
16
+ }, H = (r, t) => r ? t === s.L ? "DropdownArrowUp24px" : "DropdownArrowUp16px" : t === s.L ? "DropdownArrowDown24px" : "DropdownArrowBottom16px", M = (r, t, n) => {
17
+ if (!r.length || !t) return r;
18
+ const e = [], i = /* @__PURE__ */ new Set();
19
+ for (const o of r) {
20
+ const p = String(o[t] || "Без группы");
21
+ i.has(p) || (i.add(p), e.push({
22
+ id: `group-header-${p}`,
23
+ name: n(p),
23
24
  isGroupHeader: !0,
24
- originalValue: e
25
- })), n.push(p);
25
+ originalValue: p
26
+ })), e.push(o);
26
27
  }
27
- return n;
28
- }, g = (r, o) => {
28
+ return e;
29
+ }, D = (r, t) => {
29
30
  if (!r.current) return !1;
30
- const u = r.current.getBoundingClientRect(), n = window.innerHeight, c = o === t.M || o === t.S ? i : a, p = n - u.bottom, e = u.top;
31
- return p >= c ? !1 : e > p;
31
+ const n = r.current.getBoundingClientRect(), e = window.innerHeight, i = t === s.M || t === s.S ? w : f, o = e - n.bottom, p = n.top;
32
+ return o >= i ? !1 : p > o;
33
+ }, h = (r, t, n) => {
34
+ if (!t.trim())
35
+ return [r];
36
+ const e = new RegExp(
37
+ `(${t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`,
38
+ "gi"
39
+ );
40
+ return r.split(e).map((o, p) => e.test(o) ? u(
41
+ "span",
42
+ {
43
+ key: p,
44
+ className: n
45
+ },
46
+ o
47
+ ) : o);
48
+ }, a = (r, t, n) => {
49
+ if (!t.trim())
50
+ return r;
51
+ if (typeof r == "string") {
52
+ const e = h(
53
+ r,
54
+ t,
55
+ n
56
+ );
57
+ return u(
58
+ "span",
59
+ { className: "highlighted-text-wrapper" },
60
+ e
61
+ );
62
+ }
63
+ return Array.isArray(r) ? r.map(
64
+ (e, i) => u(
65
+ l,
66
+ { key: i },
67
+ a(e, t, n)
68
+ )
69
+ ) : g(r) ? m(r, {
70
+ ...r.props,
71
+ children: a(
72
+ r.props.children,
73
+ t,
74
+ n
75
+ )
76
+ }) : r;
32
77
  };
33
78
  export {
34
- l as getDropdownArrowIcon,
35
- h as mapSizeToInputSize,
36
- f as prepareGroupedItems,
37
- g as shouldShowMenuOnTop
79
+ H as getDropdownArrowIcon,
80
+ a as highlightReactNode,
81
+ h as highlightText,
82
+ A as mapSizeToInputSize,
83
+ M as prepareGroupedItems,
84
+ D as shouldShowMenuOnTop
38
85
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mimir-ui-kit",
3
3
  "private": false,
4
- "version": "1.44.3",
4
+ "version": "1.45.0",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {