mimir-ui-kit 1.43.3 → 1.43.4

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.
@@ -28,7 +28,7 @@ export type TProps = {
28
28
  /**
29
29
  * Значение, которое раздвигает отрицательными и положительным отступами.
30
30
  */
31
- padding?: number;
31
+ padding?: number | string;
32
32
  /**
33
33
  * Флаг, определяющий, нужны ли кнопки для перелистывания.
34
34
  */
@@ -1,66 +1,67 @@
1
- import { jsxs as S, jsx as u } from "react/jsx-runtime";
2
- import { c as n } from "../../index-DIxK0V-G.js";
3
- import { forwardRef as q, useRef as f, useState as _, useEffect as P, Children as X } from "react";
4
- import { DEFAULT_SPACE_BETWEEN as Y, DEFAULT_SCROLL_STEP as G, DEFAULT_DIVIDED as J, DEFAULT_CARD_INDEX as K } from "./constants.js";
5
- import { hasHorizontalScroll as g, isScrollAtEdge as T } from "./utils.js";
6
- import { useMergeRefs as Q } from "../../hooks/useMergeRefs/useMergeRefs.js";
7
- import { useThrottledCallback as Z } from "../../hooks/useThrottledCallback/index.js";
8
- import { MergedButton as rr } from "../MergedButton/MergedButton.js";
9
- import '../../assets/CardTrail.css';const tr = "_pointer_1wzbr_50", i = {
1
+ import { jsxs as w, jsx as d } from "react/jsx-runtime";
2
+ import { c as l } from "../../index-DIxK0V-G.js";
3
+ import { forwardRef as Y, useRef as f, useState as _, useEffect as G, Children as J } from "react";
4
+ import { DEFAULT_SPACE_BETWEEN as K, DEFAULT_SCROLL_STEP as Q, DEFAULT_DIVIDED as Z, DEFAULT_CARD_INDEX as rr } from "./constants.js";
5
+ import { hasHorizontalScroll as g, getCSSVariableNumericValue as D, isScrollAtEdge as L } from "./utils.js";
6
+ import { useMergeRefs as tr } from "../../hooks/useMergeRefs/useMergeRefs.js";
7
+ import { useThrottledCallback as er } from "../../hooks/useThrottledCallback/index.js";
8
+ import { MergedButton as ar } from "../MergedButton/MergedButton.js";
9
+ import '../../assets/CardTrail.css';const ir = "_pointer_1wzbr_50", i = {
10
10
  "card-trail": "_card-trail_1wzbr_3",
11
11
  "card-trail-header": "_card-trail-header_1wzbr_7",
12
12
  "card-trail-header-title": "_card-trail-header-title_1wzbr_15",
13
13
  "card-trail-header-merged-button": "_card-trail-header-merged-button_1wzbr_29",
14
14
  "card-trail-list": "_card-trail-list_1wzbr_32",
15
15
  "card-trail-list-item": "_card-trail-list-item_1wzbr_46",
16
- pointer: tr
16
+ pointer: ir
17
17
  };
18
- let v = {};
19
- const dr = q((w, D) => {
18
+ let z = {};
19
+ const mr = Y((W, A) => {
20
20
  const {
21
- cardClassName: L,
22
- cardTrailClassName: z,
23
- cardTrailHeaderClassName: W,
24
- cardTrailListClassName: A,
25
- cardTrailMergedButtonClassName: R,
26
- children: b,
27
- title: p,
28
- spaceBetween: o = Y,
29
- scrollStep: C = G,
30
- dividedCardWidth: k = J,
31
- currentCardIndex: h = K,
21
+ cardClassName: R,
22
+ cardTrailClassName: k,
23
+ cardTrailHeaderClassName: I,
24
+ cardTrailListClassName: y,
25
+ cardTrailMergedButtonClassName: M,
26
+ children: p,
27
+ title: u,
28
+ spaceBetween: n = K,
29
+ scrollStep: b = Q,
30
+ dividedCardWidth: V = Z,
31
+ currentCardIndex: h = rr,
32
32
  mergedButtonProps: c,
33
- scrollToCard: B = !1,
34
- needButtons: I = !0,
35
- padding: l = 0
36
- } = w, r = f(null), N = f(!0), s = f(null), [d, y] = _({
33
+ scrollToCard: C = !1,
34
+ needButtons: B = !0,
35
+ padding: N = 0
36
+ } = W, r = f(null), S = f(!0), o = f(null), [s, x] = _({
37
37
  leftButton: !0,
38
38
  rightButton: !1
39
- }), [M, x] = _(0), [U, E] = _(
39
+ }), [U, F] = _(0), [E, T] = _(
40
40
  () => g(r == null ? void 0 : r.current)
41
- ), F = Q(r, D), H = Z(() => {
42
- var a;
43
- if (N.current) {
44
- N.current = !1;
45
- const m = r.current, V = ((a = m == null ? void 0 : m.children[h]) == null ? void 0 : a.clientWidth) ?? 0;
46
- x(
47
- V / k + l + o
41
+ ), H = tr(r, A), O = er(() => {
42
+ var v;
43
+ if (S.current) {
44
+ S.current = !1;
45
+ const m = r.current, P = ((v = m == null ? void 0 : m.children[h]) == null ? void 0 : v.clientWidth) ?? 0, X = D(N);
46
+ F(
47
+ P / V + X + n
48
48
  );
49
49
  }
50
- v = {
51
- paddingLeft: l,
52
- paddingRight: l,
53
- marginLeft: -l,
54
- marginRight: -l
50
+ const t = D(N);
51
+ z = {
52
+ paddingLeft: t,
53
+ paddingRight: t,
54
+ marginLeft: -t,
55
+ marginRight: -t
55
56
  };
56
- const t = !T(r.current, "left"), e = !T(r.current, "right");
57
- y({
58
- leftButton: !t,
59
- rightButton: !e
57
+ const e = !L(r.current, "left"), a = !L(r.current, "right");
58
+ x({
59
+ leftButton: !e,
60
+ rightButton: !a
60
61
  });
61
- }, 300), O = (t) => () => {
62
+ }, 300), $ = (t) => () => {
62
63
  var a;
63
- if (!B)
64
+ if (!C)
64
65
  return;
65
66
  const e = (a = r == null ? void 0 : r.current) == null ? void 0 : a.querySelector(
66
67
  `[data-active-card='${t}']`
@@ -70,55 +71,55 @@ const dr = q((w, D) => {
70
71
  block: "nearest",
71
72
  inline: "center"
72
73
  }));
73
- }, $ = () => {
74
+ }, j = () => {
74
75
  var a;
75
- if (!r.current || d.leftButton) return;
76
+ if (!r.current || s.leftButton) return;
76
77
  const t = r.current, e = ((a = t.children[h]) == null ? void 0 : a.clientWidth) ?? 0;
77
78
  t.scrollBy({
78
- left: -(e + o) * C,
79
+ left: -(e + n) * b,
79
80
  behavior: "smooth"
80
81
  });
81
- }, j = () => {
82
+ }, q = () => {
82
83
  var a;
83
- if (!r.current || d.rightButton) return;
84
+ if (!r.current || s.rightButton) return;
84
85
  const t = r.current, e = ((a = t.children[h]) == null ? void 0 : a.clientWidth) ?? 0;
85
86
  t.scrollBy({
86
- left: (e + o) * C,
87
+ left: (e + n) * b,
87
88
  behavior: "smooth"
88
89
  });
89
90
  };
90
- return P(() => {
91
+ return G(() => {
91
92
  const t = r.current;
92
93
  if (t)
93
- return s.current = new ResizeObserver(() => {
94
- E(g(r == null ? void 0 : r.current));
95
- }), s.current.observe(t), E(g(r == null ? void 0 : r.current)), () => {
96
- s.current && s.current.disconnect();
94
+ return o.current = new ResizeObserver(() => {
95
+ T(g(r == null ? void 0 : r.current));
96
+ }), o.current.observe(t), T(g(r == null ? void 0 : r.current)), () => {
97
+ o.current && o.current.disconnect();
97
98
  };
98
- }, [b]), /* @__PURE__ */ S("section", { className: n(i["card-trail"], z), children: [
99
- /* @__PURE__ */ S(
99
+ }, [p]), /* @__PURE__ */ w("section", { className: l(i["card-trail"], k), children: [
100
+ (u || E && B) && /* @__PURE__ */ w(
100
101
  "header",
101
102
  {
102
- className: n(
103
+ className: l(
103
104
  i["card-trail-header"],
104
- W
105
+ I
105
106
  ),
106
107
  children: [
107
- p && /* @__PURE__ */ u("h3", { className: i["card-trail-header-title"], children: p }),
108
- U && I && /* @__PURE__ */ u(
109
- rr,
108
+ u && /* @__PURE__ */ d("h3", { className: i["card-trail-header-title"], children: u }),
109
+ E && B && /* @__PURE__ */ d(
110
+ ar,
110
111
  {
111
- buttonsWrapperClassName: n(
112
+ buttonsWrapperClassName: l(
112
113
  i["card-trail-header-merged-button"],
113
- R
114
+ M
114
115
  ),
115
116
  buttons: [
116
117
  {
117
118
  isIconButton: !0,
118
119
  iconName: "ArrowLeft16px",
119
120
  variant: "gray",
120
- onClick: $,
121
- disabled: d.leftButton,
121
+ onClick: j,
122
+ disabled: s.leftButton,
122
123
  size: "s",
123
124
  ...c == null ? void 0 : c.leftButton
124
125
  },
@@ -126,9 +127,9 @@ const dr = q((w, D) => {
126
127
  isIconButton: !0,
127
128
  iconName: "ArrowRight16px",
128
129
  variant: "gray",
129
- onClick: j,
130
+ onClick: q,
130
131
  size: "s",
131
- disabled: d.rightButton,
132
+ disabled: s.rightButton,
132
133
  ...c == null ? void 0 : c.rightButton
133
134
  }
134
135
  ]
@@ -137,27 +138,27 @@ const dr = q((w, D) => {
137
138
  ]
138
139
  }
139
140
  ),
140
- /* @__PURE__ */ u(
141
+ /* @__PURE__ */ d(
141
142
  "ul",
142
143
  {
143
- onScroll: H,
144
+ onScroll: O,
144
145
  style: {
145
- gap: o,
146
- scrollPadding: `0 ${M}px`,
147
- ...v
146
+ gap: n,
147
+ scrollPadding: `0 ${U}px`,
148
+ ...z
148
149
  },
149
- className: n(i["card-trail-list"], A),
150
- ref: F,
151
- children: X.map(b, (t, e) => /* @__PURE__ */ u(
150
+ className: l(i["card-trail-list"], y),
151
+ ref: H,
152
+ children: J.map(p, (t, e) => /* @__PURE__ */ d(
152
153
  "li",
153
154
  {
154
- onClick: O(e),
155
+ onClick: $(e),
155
156
  "data-active-card": e,
156
157
  "data-testid": `card-trail-item-${e}`,
157
- className: n(
158
+ className: l(
158
159
  i["card-trail-list-item"],
159
- { [i.pointer]: B },
160
- L
160
+ { [i.pointer]: C },
161
+ R
161
162
  ),
162
163
  children: t
163
164
  }
@@ -167,5 +168,5 @@ const dr = q((w, D) => {
167
168
  ] });
168
169
  });
169
170
  export {
170
- dr as CardTrail
171
+ mr as CardTrail
171
172
  };
@@ -7,3 +7,4 @@
7
7
  */
8
8
  export declare const isScrollAtEdge: (container: HTMLElement | null, direction: "left" | "right", tolerance?: number) => boolean;
9
9
  export declare const hasHorizontalScroll: (element: HTMLElement | null) => boolean;
10
+ export declare const getCSSVariableNumericValue: (value: string | number) => number;
@@ -1,9 +1,18 @@
1
- const c = (r, i, t = 1) => {
2
- if (!r) return !0;
3
- const { scrollLeft: l, scrollWidth: s, clientWidth: o } = r;
4
- return i === "left" ? l <= t : l >= s - o - t;
5
- }, e = (r) => r ? r.scrollWidth > r.clientWidth : !1;
1
+ const i = (t, r, e = 1) => {
2
+ if (!t) return !0;
3
+ const { scrollLeft: o, scrollWidth: s, clientWidth: l } = t;
4
+ return r === "left" ? o <= e : o >= s - l - e;
5
+ }, n = (t) => t ? t.scrollWidth > t.clientWidth : !1, c = (t) => {
6
+ if (typeof t == "number")
7
+ return t;
8
+ if (t.startsWith("--")) {
9
+ const r = getComputedStyle(document.documentElement).getPropertyValue(t).trim();
10
+ return parseFloat(r) || 0;
11
+ }
12
+ return parseFloat(t) || 0;
13
+ };
6
14
  export {
7
- e as hasHorizontalScroll,
8
- c as isScrollAtEdge
15
+ c as getCSSVariableNumericValue,
16
+ n as hasHorizontalScroll,
17
+ i as isScrollAtEdge
9
18
  };