md-components-mdigial-azamat 0.0.348 → 0.0.349
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/dist/Segments/Segments.js +116 -111
- package/dist/Segments/SegmentsSliderTabs.js +72 -29
- package/package.json +1 -1
|
@@ -1,166 +1,171 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useState as
|
|
3
|
-
import { b as
|
|
4
|
-
import { r as
|
|
5
|
-
import { C as
|
|
6
|
-
import { F as
|
|
7
|
-
import { c as
|
|
8
|
-
import { SegmentsSliderTabs as
|
|
9
|
-
import { propsToEdit as
|
|
10
|
-
import { SegmentsVariant as
|
|
11
|
-
function
|
|
12
|
-
var
|
|
13
|
-
return typeof window > "u" || !((
|
|
1
|
+
import { jsx as i, jsxs as S } from "react/jsx-runtime";
|
|
2
|
+
import { useState as A, useEffect as k, useCallback as N, lazy as D, Suspense as T } from "react";
|
|
3
|
+
import { b as H } from "../LayoutContext-60bf5495.js";
|
|
4
|
+
import { r as j } from "../tokens-29849cf7.js";
|
|
5
|
+
import { C as R } from "../ComponentContainer-aefde3e0.js";
|
|
6
|
+
import { F as y } from "../Flex-86aee720.js";
|
|
7
|
+
import { c as C } from "../cn-6a4bf187.js";
|
|
8
|
+
import { SegmentsSliderTabs as K } from "./SegmentsSliderTabs.js";
|
|
9
|
+
import { propsToEdit as O } from "./schema.js";
|
|
10
|
+
import { SegmentsVariant as a } from "./types.js";
|
|
11
|
+
function Y(e) {
|
|
12
|
+
var t;
|
|
13
|
+
return typeof window > "u" || !((t = window.location) != null && t.search) ? null : new URLSearchParams(window.location.search).get(e);
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function M(e, t) {
|
|
16
16
|
if (typeof window > "u")
|
|
17
17
|
return;
|
|
18
18
|
const n = new URL(window.location.href);
|
|
19
|
-
n.searchParams.set(
|
|
19
|
+
n.searchParams.set(e, t), window.history.replaceState(window.history.state, "", n.toString());
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
const [
|
|
23
|
-
|
|
24
|
-
const o = () => n(
|
|
21
|
+
function Q(e) {
|
|
22
|
+
const [t, n] = A(() => null);
|
|
23
|
+
k(() => {
|
|
24
|
+
const o = () => n(Y(e));
|
|
25
25
|
return o(), window.addEventListener("popstate", o), () => window.removeEventListener("popstate", o);
|
|
26
|
-
}, [
|
|
27
|
-
const r =
|
|
26
|
+
}, [e]);
|
|
27
|
+
const r = N(
|
|
28
28
|
(o) => {
|
|
29
|
-
|
|
29
|
+
M(e, o), n(o);
|
|
30
30
|
},
|
|
31
|
-
[
|
|
31
|
+
[e]
|
|
32
32
|
);
|
|
33
|
-
return [
|
|
33
|
+
return [t, r];
|
|
34
34
|
}
|
|
35
|
-
const
|
|
36
|
-
() => import("./SegmentsContent.js").then((
|
|
37
|
-
),
|
|
38
|
-
[
|
|
35
|
+
const U = D(
|
|
36
|
+
() => import("./SegmentsContent.js").then((e) => ({ default: e.SegmentsContent }))
|
|
37
|
+
), P = {
|
|
38
|
+
[a.PRIMARY]: {
|
|
39
39
|
container: "rounded-[20px] bg-[#E3E4E8] p-1",
|
|
40
40
|
item: "rounded-[19px] text-gray-800 font-semibold max-tablet:text-[16px] max-tablet:leading-[27px] max-tablet:px-4 max-tablet:py-2 text-[20px] leading-[30px] px-8 py-4 w-[275px]",
|
|
41
41
|
activeItem: "bg-white"
|
|
42
42
|
},
|
|
43
|
-
[
|
|
43
|
+
[a.SECONDARY]: {
|
|
44
44
|
container: "rounded-xl bg-white/15 border border-white/15 backdrop-blur-[15px]",
|
|
45
45
|
item: "text-white rounded-[13px] text-sm leading-5 py-[14px] w-[180px] max-tablet:pr-5 max-tablet:pl-4",
|
|
46
46
|
activeItem: "bg-white text-black font-medium"
|
|
47
47
|
},
|
|
48
|
-
[
|
|
48
|
+
[a.SLIDER]: {
|
|
49
49
|
container: "",
|
|
50
50
|
item: "",
|
|
51
51
|
activeItem: ""
|
|
52
52
|
},
|
|
53
|
-
[
|
|
53
|
+
[a.HEADER]: {
|
|
54
54
|
container: "rounded-[10px] bg-white p-1 gap-1",
|
|
55
55
|
item: "rounded-[8px] text-[#40474f] font-medium text-[14px] leading-5 px-4 py-2",
|
|
56
56
|
// Фон задаётся цветом из пропса, поэтому в классах его нет
|
|
57
57
|
activeItem: ""
|
|
58
58
|
}
|
|
59
|
-
},
|
|
60
|
-
if (!
|
|
59
|
+
}, F = "green", _ = (e) => {
|
|
60
|
+
if (!e)
|
|
61
61
|
return;
|
|
62
|
-
const
|
|
62
|
+
const t = e.trim().replace("#", ""), n = t.length === 3 ? t.split("").map((s) => s + s).join("") : t, r = n.length === 8 ? n.slice(0, 6) : n;
|
|
63
63
|
if (r.length !== 6 || /[^0-9a-f]/i.test(r))
|
|
64
64
|
return;
|
|
65
|
-
const [o, c, u] = [0, 2, 4].map((
|
|
65
|
+
const [o, c, u] = [0, 2, 4].map((s) => parseInt(r.slice(s, s + 2), 16));
|
|
66
66
|
return (0.299 * o + 0.587 * c + 0.114 * u) / 255 > 0.6 ? "#0e0f11" : "#ffffff";
|
|
67
67
|
};
|
|
68
|
-
function
|
|
68
|
+
function z(e, t) {
|
|
69
69
|
var r;
|
|
70
|
-
const n = (r =
|
|
71
|
-
return n || String(
|
|
70
|
+
const n = (r = e == null ? void 0 : e.tabKey) == null ? void 0 : r.trim();
|
|
71
|
+
return n || String(t);
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
if (!(
|
|
73
|
+
function B(e, t) {
|
|
74
|
+
if (!(e != null && e.length) || t == null || t === "")
|
|
75
75
|
return 0;
|
|
76
|
-
const n =
|
|
76
|
+
const n = e.findIndex(
|
|
77
77
|
(o) => {
|
|
78
78
|
var c;
|
|
79
|
-
return ((c = o.tabKey) == null ? void 0 : c.trim()) ===
|
|
79
|
+
return ((c = o.tabKey) == null ? void 0 : c.trim()) === t;
|
|
80
80
|
}
|
|
81
81
|
);
|
|
82
82
|
if (n >= 0)
|
|
83
83
|
return n;
|
|
84
|
-
const r = parseInt(
|
|
85
|
-
return Number.isNaN(r) || r < 0 || r >=
|
|
84
|
+
const r = parseInt(t, 10);
|
|
85
|
+
return Number.isNaN(r) || r < 0 || r >= e.length ? 0 : r;
|
|
86
86
|
}
|
|
87
|
-
const
|
|
88
|
-
data:
|
|
89
|
-
variant:
|
|
87
|
+
const q = ({
|
|
88
|
+
data: e = [],
|
|
89
|
+
variant: t = a.PRIMARY,
|
|
90
90
|
queryParamKey: n = "tab",
|
|
91
91
|
title: r,
|
|
92
92
|
active_color: o
|
|
93
93
|
}) => {
|
|
94
|
-
var
|
|
95
|
-
const [c, u] =
|
|
94
|
+
var E;
|
|
95
|
+
const [c, u] = Q(n), p = B(e, c), s = N(
|
|
96
96
|
(l, x) => {
|
|
97
|
-
u(
|
|
97
|
+
u(z(l, x));
|
|
98
98
|
},
|
|
99
99
|
[u]
|
|
100
|
-
), b =
|
|
101
|
-
o || (g ?
|
|
102
|
-
),
|
|
103
|
-
backgroundColor:
|
|
104
|
-
color:
|
|
105
|
-
} : void 0
|
|
106
|
-
|
|
107
|
-
h,
|
|
100
|
+
), b = P[t] || P[a.PRIMARY], d = e[p], g = t === a.HEADER, w = H().kind === "root", h = j(
|
|
101
|
+
o || (g ? F : void 0)
|
|
102
|
+
), L = h ? {
|
|
103
|
+
backgroundColor: h,
|
|
104
|
+
color: _(h)
|
|
105
|
+
} : void 0, v = t === a.SLIDER ? /* @__PURE__ */ i(
|
|
106
|
+
K,
|
|
108
107
|
{
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
j,
|
|
114
|
-
{
|
|
115
|
-
data: t,
|
|
116
|
-
activeIndex: p,
|
|
117
|
-
onChange: (l) => i(t[l], l)
|
|
118
|
-
}
|
|
119
|
-
) : (() => {
|
|
120
|
-
const l = /* @__PURE__ */ a(
|
|
121
|
-
h,
|
|
122
|
-
{
|
|
123
|
-
className: S(
|
|
124
|
-
"w-fit mx-auto max-tablet:w-full overflow-x-auto no-scrollbar cursor-grab active:cursor-grabbing",
|
|
125
|
-
// В шапке ряд прижат вправо. Без этого `mx-auto` съедает всё
|
|
126
|
-
// свободное место раньше, чем сработает justify-between, и
|
|
127
|
-
// переключатель повисает посреди строки.
|
|
128
|
-
g && "mx-0",
|
|
129
|
-
b.container
|
|
130
|
-
),
|
|
131
|
-
children: t.map((m, f) => {
|
|
132
|
-
var y;
|
|
133
|
-
return /* @__PURE__ */ a(
|
|
134
|
-
"button",
|
|
135
|
-
{
|
|
136
|
-
onClick: () => i(m, f),
|
|
137
|
-
style: f === p ? P : void 0,
|
|
138
|
-
className: S(
|
|
139
|
-
"bg-transparent cursor-pointer text-center whitespace-nowrap transition-colors duration-200 max-tablet:min-w-min max-tablet:flex-1",
|
|
140
|
-
b.item,
|
|
141
|
-
f === p && b.activeItem
|
|
142
|
-
),
|
|
143
|
-
children: m == null ? void 0 : m.title
|
|
144
|
-
},
|
|
145
|
-
((y = m.tabKey) == null ? void 0 : y.trim()) || m.title || f
|
|
146
|
-
);
|
|
147
|
-
})
|
|
148
|
-
}
|
|
149
|
-
);
|
|
150
|
-
if (!g)
|
|
151
|
-
return l;
|
|
152
|
-
const x = /* @__PURE__ */ E(h, { className: "w-full items-center justify-between gap-4 max-tablet:flex-col max-tablet:items-start", children: [
|
|
153
|
-
r ? /* @__PURE__ */ a("h2", { className: "text-[#0e0f11] font-bold text-[32px] leading-[40px] max-tablet:text-[24px] max-tablet:leading-[32px]", children: r }) : null,
|
|
154
|
-
l
|
|
155
|
-
] });
|
|
156
|
-
return C ? /* @__PURE__ */ a(T, { children: x }) : x;
|
|
157
|
-
})(),
|
|
158
|
-
(v = d == null ? void 0 : d.components) != null && v.length ? /* @__PURE__ */ a("div", { className: "segments-content w-full", children: /* @__PURE__ */ a(k, { fallback: null, children: /* @__PURE__ */ a(Q, { components: d.components }) }) }) : null
|
|
159
|
-
]
|
|
108
|
+
data: e,
|
|
109
|
+
activeIndex: p,
|
|
110
|
+
onChange: (l) => s(e[l], l),
|
|
111
|
+
edgeInset: w
|
|
160
112
|
}
|
|
113
|
+
) : null;
|
|
114
|
+
return (
|
|
115
|
+
// min-w-0: во flex-родителе блок иначе раздвигается по ширине ряда
|
|
116
|
+
// табов, и прокрутка внутри ряда не включается
|
|
117
|
+
/* @__PURE__ */ S(
|
|
118
|
+
y,
|
|
119
|
+
{
|
|
120
|
+
vertical: !0,
|
|
121
|
+
className: "min-w-0 gap-6",
|
|
122
|
+
children: [
|
|
123
|
+
t === a.SLIDER ? w ? /* @__PURE__ */ i(R, { className: "max-tablet:px-0", children: v }) : v : (() => {
|
|
124
|
+
const l = /* @__PURE__ */ i(
|
|
125
|
+
y,
|
|
126
|
+
{
|
|
127
|
+
className: C(
|
|
128
|
+
"w-fit mx-auto max-tablet:w-full overflow-x-auto no-scrollbar cursor-grab active:cursor-grabbing",
|
|
129
|
+
// В шапке ряд прижат вправо. Без этого `mx-auto` съедает всё
|
|
130
|
+
// свободное место раньше, чем сработает justify-between, и
|
|
131
|
+
// переключатель повисает посреди строки.
|
|
132
|
+
g && "mx-0",
|
|
133
|
+
b.container
|
|
134
|
+
),
|
|
135
|
+
children: e.map((m, f) => {
|
|
136
|
+
var I;
|
|
137
|
+
return /* @__PURE__ */ i(
|
|
138
|
+
"button",
|
|
139
|
+
{
|
|
140
|
+
onClick: () => s(m, f),
|
|
141
|
+
style: f === p ? L : void 0,
|
|
142
|
+
className: C(
|
|
143
|
+
"bg-transparent cursor-pointer text-center whitespace-nowrap transition-colors duration-200 max-tablet:min-w-min max-tablet:flex-1",
|
|
144
|
+
b.item,
|
|
145
|
+
f === p && b.activeItem
|
|
146
|
+
),
|
|
147
|
+
children: m == null ? void 0 : m.title
|
|
148
|
+
},
|
|
149
|
+
((I = m.tabKey) == null ? void 0 : I.trim()) || m.title || f
|
|
150
|
+
);
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
if (!g)
|
|
155
|
+
return l;
|
|
156
|
+
const x = /* @__PURE__ */ S(y, { className: "w-full items-center justify-between gap-4 max-tablet:flex-col max-tablet:items-start", children: [
|
|
157
|
+
r ? /* @__PURE__ */ i("h2", { className: "text-[#0e0f11] font-bold text-[32px] leading-[40px] max-tablet:text-[24px] max-tablet:leading-[32px]", children: r }) : null,
|
|
158
|
+
l
|
|
159
|
+
] });
|
|
160
|
+
return w ? /* @__PURE__ */ i(R, { children: x }) : x;
|
|
161
|
+
})(),
|
|
162
|
+
(E = d == null ? void 0 : d.components) != null && E.length ? /* @__PURE__ */ i("div", { className: "segments-content w-full", children: /* @__PURE__ */ i(T, { fallback: null, children: /* @__PURE__ */ i(U, { components: d.components }) }) }) : null
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
)
|
|
161
166
|
);
|
|
162
167
|
};
|
|
163
|
-
|
|
168
|
+
q.propsToEdit = O;
|
|
164
169
|
export {
|
|
165
|
-
|
|
170
|
+
q as Segments
|
|
166
171
|
};
|
|
@@ -1,56 +1,99 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { u as
|
|
4
|
-
import { c as
|
|
5
|
-
const
|
|
6
|
-
data:
|
|
7
|
-
activeIndex:
|
|
8
|
-
onChange:
|
|
1
|
+
import { jsx as c, jsxs as w } from "react/jsx-runtime";
|
|
2
|
+
import { useState as L, useRef as v, useEffect as a } from "react";
|
|
3
|
+
import { u as E } from "../useDraggableScroll-440da9b7.js";
|
|
4
|
+
import { c as m } from "../cn-6a4bf187.js";
|
|
5
|
+
const S = 5, y = ({
|
|
6
|
+
data: f,
|
|
7
|
+
activeIndex: s,
|
|
8
|
+
onChange: h,
|
|
9
|
+
edgeInset: p = !0
|
|
9
10
|
}) => {
|
|
10
|
-
const { ref: o, events:
|
|
11
|
-
return
|
|
11
|
+
const { ref: o, events: x } = E(), [u, b] = L({ left: 0, width: 0 }), i = v([]);
|
|
12
|
+
return a(() => {
|
|
12
13
|
const t = () => {
|
|
13
|
-
const e =
|
|
14
|
-
e &&
|
|
14
|
+
const e = i.current[s];
|
|
15
|
+
e && b({
|
|
15
16
|
left: e.offsetLeft,
|
|
16
17
|
width: e.offsetWidth
|
|
17
18
|
});
|
|
18
19
|
};
|
|
19
20
|
return t(), window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
|
|
20
|
-
}, [
|
|
21
|
-
const t = o.current, e =
|
|
21
|
+
}, [s, f]), a(() => {
|
|
22
|
+
const t = o.current, e = i.current[s];
|
|
22
23
|
if (!t || !e)
|
|
23
24
|
return;
|
|
24
|
-
const
|
|
25
|
+
const r = e.offsetLeft - (t.clientWidth - e.offsetWidth) / 2, n = Math.max(
|
|
26
|
+
t.scrollWidth - t.clientWidth,
|
|
27
|
+
0
|
|
28
|
+
), l = Math.min(
|
|
29
|
+
Math.max(r, 0),
|
|
30
|
+
n
|
|
31
|
+
);
|
|
25
32
|
t.scrollTo({
|
|
26
|
-
left:
|
|
33
|
+
left: l,
|
|
27
34
|
behavior: "smooth"
|
|
28
35
|
});
|
|
29
|
-
}, [
|
|
36
|
+
}, [s, o]), a(() => {
|
|
37
|
+
const t = o.current;
|
|
38
|
+
if (!t)
|
|
39
|
+
return;
|
|
40
|
+
const e = (r) => {
|
|
41
|
+
if (r.ctrlKey || Math.abs(r.deltaY) <= Math.abs(r.deltaX))
|
|
42
|
+
return;
|
|
43
|
+
const n = t.scrollWidth - t.clientWidth;
|
|
44
|
+
if (n <= 0)
|
|
45
|
+
return;
|
|
46
|
+
const l = r.deltaMode === 1 ? r.deltaY * 16 : r.deltaMode === 2 ? r.deltaY * t.clientWidth : r.deltaY;
|
|
47
|
+
l < 0 && t.scrollLeft <= 1 || l > 0 && t.scrollLeft >= n - 1 || (r.preventDefault(), t.scrollLeft += l);
|
|
48
|
+
};
|
|
49
|
+
return t.addEventListener("wheel", e, { passive: !1 }), () => t.removeEventListener("wheel", e);
|
|
50
|
+
}, [o]), a(() => {
|
|
51
|
+
const t = o.current;
|
|
52
|
+
if (!t)
|
|
53
|
+
return;
|
|
54
|
+
let e = null;
|
|
55
|
+
const r = (l) => {
|
|
56
|
+
e = l.clientX;
|
|
57
|
+
}, n = (l) => {
|
|
58
|
+
const d = e;
|
|
59
|
+
e = null, d !== null && Math.abs(l.clientX - d) > S && (l.preventDefault(), l.stopPropagation());
|
|
60
|
+
};
|
|
61
|
+
return t.addEventListener("mousedown", r, !0), t.addEventListener("click", n, !0), () => {
|
|
62
|
+
t.removeEventListener("mousedown", r, !0), t.removeEventListener("click", n, !0);
|
|
63
|
+
};
|
|
64
|
+
}, [o]), // Ряд шире контейнера прокручивается внутри него. Центрирует ряд
|
|
65
|
+
// `mx-auto` у внутреннего блока, а не justify-center: при нехватке места
|
|
66
|
+
// justify-center сдвигал ряд влево за край, и первые табы было уже не
|
|
67
|
+
// достать прокруткой. Автоотступы в такой ситуации обнуляются, и ряд
|
|
68
|
+
// встаёт от левого края, а лишнее уходит под правый — как в макете.
|
|
69
|
+
/* @__PURE__ */ c(
|
|
30
70
|
"div",
|
|
31
71
|
{
|
|
32
72
|
ref: o,
|
|
33
|
-
...
|
|
34
|
-
className:
|
|
35
|
-
|
|
36
|
-
|
|
73
|
+
...x,
|
|
74
|
+
className: m(
|
|
75
|
+
"mb-6 flex w-full max-w-full overflow-x-auto no-scrollbar cursor-grab active:cursor-grabbing",
|
|
76
|
+
p && "max-tablet:px-4"
|
|
77
|
+
),
|
|
78
|
+
children: /* @__PURE__ */ w("div", { className: "relative mx-auto inline-flex gap-1 rounded-[20px] max-tablet:rounded-2xl bg-[#edeef0] h-[48px] min-w-max", children: [
|
|
79
|
+
/* @__PURE__ */ c(
|
|
37
80
|
"div",
|
|
38
81
|
{
|
|
39
82
|
className: "absolute top-0 bottom-0 rounded-[20px] max-tablet:rounded-2xl bg-white shadow-sm transition-all duration-300 ease-in-out",
|
|
40
83
|
style: {
|
|
41
|
-
left:
|
|
42
|
-
width:
|
|
84
|
+
left: u.left,
|
|
85
|
+
width: u.width
|
|
43
86
|
}
|
|
44
87
|
}
|
|
45
88
|
),
|
|
46
|
-
|
|
89
|
+
f.map((t, e) => /* @__PURE__ */ c(
|
|
47
90
|
"button",
|
|
48
91
|
{
|
|
49
|
-
ref: (
|
|
50
|
-
onClick: () =>
|
|
51
|
-
className:
|
|
92
|
+
ref: (r) => i.current[e] = r,
|
|
93
|
+
onClick: () => h(e),
|
|
94
|
+
className: m(
|
|
52
95
|
"relative z-10 rounded-[20px] max-tablet:rounded-2xl px-4 py-2 text-[14px] font-medium whitespace-nowrap transition-colors min-w-[180px] max-tablet:min-w-[112px]",
|
|
53
|
-
|
|
96
|
+
s === e ? "text-blackBG" : "text-[#6b7280]"
|
|
54
97
|
),
|
|
55
98
|
children: t.title
|
|
56
99
|
},
|
|
@@ -61,5 +104,5 @@ const E = ({
|
|
|
61
104
|
);
|
|
62
105
|
};
|
|
63
106
|
export {
|
|
64
|
-
|
|
107
|
+
y as SegmentsSliderTabs
|
|
65
108
|
};
|