@dss-kit/ui-kit 0.3.8 → 0.3.10
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/components/builders/Table/Table.js +58 -57
- package/dist/components/builders/Table/TableBodyRow/TableBodyRow.d.ts +0 -5
- package/dist/components/builders/Table/TableBodyRow/TableBodyRow.js +15 -11
- package/dist/components/builders/Table/TableWrapper/TableWrapper.js +38 -39
- package/dist/components/controls/Button/Button.js +66 -63
- package/dist/components/controls/Button/types.d.ts +2 -1
- package/dist/components/controls/MarkdownTextEditor/MarkdownTextEditor.js +6 -6
- package/dist/components/controls/RadioGroup/Radio.d.ts +10 -1
- package/dist/components/controls/RadioGroup/Radio.js +68 -63
- package/dist/components/shared/Badge/Badge.d.ts +1 -1
- package/dist/components/shared/Badge/Badge.js +51 -42
- package/dist/components/shared/MarkdownText/MarkdownText.js +10 -10
- package/dist/ui-kit.cjs +8 -8
- package/package.json +1 -1
- package/dist/components/builders/Table/styles.d.ts +0 -3
- package/dist/components/builders/Table/styles.js +0 -11
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as o, jsxs as v } from "react/jsx-runtime";
|
|
2
2
|
import { cx as p, css as b } from "@emotion/css";
|
|
3
|
-
import { useReactTable as He, getPaginationRowModel as Me, getSortedRowModel as Ne, getCoreRowModel as ke, flexRender as H, createColumnHelper as
|
|
4
|
-
import { useMemo as
|
|
3
|
+
import { useReactTable as He, getPaginationRowModel as Me, getSortedRowModel as Ne, getCoreRowModel as ke, flexRender as H, createColumnHelper as ze } from "@tanstack/react-table";
|
|
4
|
+
import { useMemo as Ie, useImperativeHandle as Ve } from "react";
|
|
5
5
|
import Le from "../../../assets/svg/table/search.svg.js";
|
|
6
|
-
import {
|
|
7
|
-
import { useControllableState as
|
|
6
|
+
import { typography as We } from "../../../styles/utils/typography.js";
|
|
7
|
+
import { useControllableState as m } from "./Table.hooks.js";
|
|
8
8
|
import { getColumnPinningStyles as f } from "./Table.utils.js";
|
|
9
|
-
import { TablePlaceholder as
|
|
10
|
-
import { TableWrapper as
|
|
9
|
+
import { TablePlaceholder as Ee } from "./TablePlaceholder/TablePlaceholder.js";
|
|
10
|
+
import { TableWrapper as Fe } from "./TableWrapper/TableWrapper.js";
|
|
11
11
|
import { TableHeadRow as je } from "./TableHeadRow/TableHeadRow.js";
|
|
12
12
|
import { TablePagination as Be } from "./TablePagination/TablePagination.js";
|
|
13
13
|
import { TableHeadCell as De } from "./TableHeadCell/TableHeadCell.js";
|
|
@@ -19,32 +19,34 @@ import { TableHeadCellContent as Oe } from "./TableHeadCellContent/TableHeadCell
|
|
|
19
19
|
import { TableHeadCellContentSortable as $e } from "./TableHeadCellContentSortable/TableHeadCellContentSortable.js";
|
|
20
20
|
import { theme as qe } from "../../../utils/theme/index.js";
|
|
21
21
|
import { Box as Ge } from "../Box/Box.js";
|
|
22
|
-
const { spacing: M, color:
|
|
22
|
+
const { spacing: M, color: l } = qe, Je = b({
|
|
23
|
+
...We.body2,
|
|
24
|
+
fontWeight: 500,
|
|
23
25
|
width: "100%",
|
|
24
26
|
maxWidth: "100%",
|
|
25
27
|
minWidth: "max-content",
|
|
26
28
|
borderCollapse: "collapse",
|
|
27
29
|
borderSpacing: 0,
|
|
28
|
-
backgroundColor:
|
|
30
|
+
backgroundColor: l.fill.bgPrimary
|
|
29
31
|
}), Qe = b({
|
|
30
|
-
backgroundColor:
|
|
31
|
-
color:
|
|
32
|
+
backgroundColor: l.fill.bgSecondary,
|
|
33
|
+
color: l.text.tertiary
|
|
32
34
|
}), Ue = b({
|
|
33
35
|
pointerEvents: "none",
|
|
34
36
|
userSelect: "none"
|
|
35
37
|
}), N = ["70%", "55%", "80%", "60%"], c = ({
|
|
36
|
-
ref:
|
|
38
|
+
ref: z,
|
|
37
39
|
data: h,
|
|
38
40
|
columns: u,
|
|
39
41
|
showBorders: g = !0,
|
|
40
|
-
enableSorting:
|
|
42
|
+
enableSorting: I = !1,
|
|
41
43
|
enablePagination: S = !1,
|
|
42
44
|
enableRowSelection: V = !1,
|
|
43
45
|
enableMultiRowSelection: L = !1,
|
|
44
46
|
enableColumnPinning: d = !1,
|
|
45
|
-
columnPinning:
|
|
46
|
-
onColumnPinningChange:
|
|
47
|
-
sorting:
|
|
47
|
+
columnPinning: W,
|
|
48
|
+
onColumnPinningChange: E,
|
|
49
|
+
sorting: F,
|
|
48
50
|
onSortingChange: j,
|
|
49
51
|
manualSorting: B,
|
|
50
52
|
columnFilters: D,
|
|
@@ -55,7 +57,7 @@ const { spacing: M, color: t } = qe, Je = b({
|
|
|
55
57
|
onPaginationChange: $,
|
|
56
58
|
rowSelection: q,
|
|
57
59
|
onRowSelectionChange: G,
|
|
58
|
-
totalCount:
|
|
60
|
+
totalCount: s,
|
|
59
61
|
loading: i = !1,
|
|
60
62
|
loadingRowCount: J = 10,
|
|
61
63
|
emptyLabels: Q = {
|
|
@@ -70,47 +72,47 @@ const { spacing: M, color: t } = qe, Je = b({
|
|
|
70
72
|
emptyStateClassName: Z,
|
|
71
73
|
emptyStateTitleClassName: ee,
|
|
72
74
|
emptyStateDescriptionClassName: oe,
|
|
73
|
-
paginationClassName:
|
|
74
|
-
tableOptions:
|
|
75
|
+
paginationClassName: ne,
|
|
76
|
+
tableOptions: te = {},
|
|
75
77
|
onRowClick: w,
|
|
76
|
-
getRowId:
|
|
78
|
+
getRowId: le,
|
|
77
79
|
headCellComponent: ie = De,
|
|
78
80
|
bodyCellComponent: x = _e,
|
|
79
81
|
headRowComponent: ae = je,
|
|
80
82
|
bodyRowComponent: R = Ae,
|
|
81
83
|
onReset: re,
|
|
82
|
-
paginationVariant:
|
|
83
|
-
paginationLabels:
|
|
84
|
+
paginationVariant: me,
|
|
85
|
+
paginationLabels: se,
|
|
84
86
|
renderPageSizeSelectorDropdownItem: ce,
|
|
85
87
|
renderPageSizeSelectorInputItem: ge
|
|
86
88
|
}) => {
|
|
87
|
-
const [de, pe] =
|
|
88
|
-
|
|
89
|
+
const [de, pe] = m(
|
|
90
|
+
F,
|
|
89
91
|
j,
|
|
90
92
|
[]
|
|
91
|
-
), [he, Ce] =
|
|
93
|
+
), [he, Ce] = m(
|
|
92
94
|
D,
|
|
93
95
|
_,
|
|
94
96
|
[]
|
|
95
|
-
), [fe, be] =
|
|
97
|
+
), [fe, be] = m(
|
|
96
98
|
A,
|
|
97
99
|
K,
|
|
98
100
|
{}
|
|
99
|
-
), [a, C] =
|
|
101
|
+
), [a, C] = m(
|
|
100
102
|
O,
|
|
101
103
|
$,
|
|
102
104
|
{ pageIndex: 0, pageSize: 10 }
|
|
103
|
-
), [ue, Se] =
|
|
105
|
+
), [ue, Se] = m(q, G, {}), [ye, we] = m(
|
|
106
|
+
W,
|
|
104
107
|
E,
|
|
105
|
-
F,
|
|
106
108
|
{ left: [], right: [] }
|
|
107
|
-
), T = B ?? !!
|
|
109
|
+
), T = B ?? !!s, xe = Ie(
|
|
108
110
|
() => u.map((e) => ({
|
|
109
111
|
enableSorting: !1,
|
|
110
112
|
...e
|
|
111
113
|
})),
|
|
112
114
|
[u]
|
|
113
|
-
),
|
|
115
|
+
), t = He({
|
|
114
116
|
data: h,
|
|
115
117
|
columns: xe,
|
|
116
118
|
state: {
|
|
@@ -128,41 +130,40 @@ const { spacing: M, color: t } = qe, Je = b({
|
|
|
128
130
|
onRowSelectionChange: Se,
|
|
129
131
|
onColumnPinningChange: we,
|
|
130
132
|
getCoreRowModel: ke(),
|
|
131
|
-
getSortedRowModel:
|
|
133
|
+
getSortedRowModel: I && !T ? Ne() : void 0,
|
|
132
134
|
getPaginationRowModel: S ? Me() : void 0,
|
|
133
135
|
enableRowSelection: V,
|
|
134
136
|
enableMultiRowSelection: L,
|
|
135
137
|
enableColumnPinning: d,
|
|
136
|
-
getRowId:
|
|
138
|
+
getRowId: le,
|
|
137
139
|
manualSorting: T,
|
|
138
|
-
manualPagination: !!
|
|
139
|
-
pageCount:
|
|
140
|
-
...
|
|
140
|
+
manualPagination: !!s,
|
|
141
|
+
pageCount: s ? Math.ceil(s / a.pageSize) : void 0,
|
|
142
|
+
...te
|
|
141
143
|
});
|
|
142
|
-
Ve(
|
|
143
|
-
const { rows: P } =
|
|
144
|
-
w && w(e.original,
|
|
144
|
+
Ve(z, () => t);
|
|
145
|
+
const { rows: P } = t.getRowModel(), Re = (e, n) => {
|
|
146
|
+
w && w(e.original, n);
|
|
145
147
|
}, Te = (e) => /* @__PURE__ */ o(
|
|
146
148
|
ie,
|
|
147
149
|
{
|
|
148
150
|
style: {
|
|
149
151
|
width: e.getSize(),
|
|
150
|
-
...d && f(
|
|
152
|
+
...d && f(t, e.column, l.fill.bgSecondary)
|
|
151
153
|
},
|
|
152
154
|
onClick: i ? void 0 : e.column.getToggleSortingHandler(),
|
|
153
155
|
children: e.isPlaceholder ? null : H(e.column.columnDef.header, e.getContext())
|
|
154
156
|
},
|
|
155
157
|
e.id
|
|
156
|
-
), Pe = (e,
|
|
158
|
+
), Pe = (e, n) => /* @__PURE__ */ o(
|
|
157
159
|
R,
|
|
158
160
|
{
|
|
159
161
|
showBorders: g,
|
|
160
|
-
|
|
161
|
-
onClick: () => Re(e, l),
|
|
162
|
+
onClick: () => Re(e, n),
|
|
162
163
|
children: e.getVisibleCells().map((r) => /* @__PURE__ */ o(
|
|
163
164
|
x,
|
|
164
165
|
{
|
|
165
|
-
style: d ? f(
|
|
166
|
+
style: d ? f(t, r.column, l.fill.bgPrimary) : void 0,
|
|
166
167
|
children: H(r.column.columnDef.cell, r.getContext())
|
|
167
168
|
},
|
|
168
169
|
r.id
|
|
@@ -173,10 +174,10 @@ const { spacing: M, color: t } = qe, Je = b({
|
|
|
173
174
|
R,
|
|
174
175
|
{
|
|
175
176
|
showBorders: g,
|
|
176
|
-
children:
|
|
177
|
+
children: t.getVisibleLeafColumns().map((n, r) => /* @__PURE__ */ o(
|
|
177
178
|
x,
|
|
178
179
|
{
|
|
179
|
-
style: d ? f(n, l
|
|
180
|
+
style: d ? f(t, n, l.fill.bgPrimary) : void 0,
|
|
180
181
|
children: /* @__PURE__ */ o(k, { children: /* @__PURE__ */ o(
|
|
181
182
|
Ke,
|
|
182
183
|
{
|
|
@@ -186,20 +187,20 @@ const { spacing: M, color: t } = qe, Je = b({
|
|
|
186
187
|
}
|
|
187
188
|
) })
|
|
188
189
|
},
|
|
189
|
-
|
|
190
|
+
n.id
|
|
190
191
|
))
|
|
191
192
|
},
|
|
192
193
|
`skeleton-row-${e}`
|
|
193
194
|
);
|
|
194
195
|
return !i && !P.length ? /* @__PURE__ */ o(
|
|
195
|
-
|
|
196
|
+
Ee,
|
|
196
197
|
{
|
|
197
198
|
icon: /* @__PURE__ */ o(
|
|
198
199
|
Le,
|
|
199
200
|
{
|
|
200
201
|
width: 24,
|
|
201
202
|
height: 24,
|
|
202
|
-
style: { color:
|
|
203
|
+
style: { color: l.icon.tertiary, marginBottom: M.sm }
|
|
203
204
|
}
|
|
204
205
|
),
|
|
205
206
|
labels: Q,
|
|
@@ -209,7 +210,7 @@ const { spacing: M, color: t } = qe, Je = b({
|
|
|
209
210
|
descriptionClassName: oe
|
|
210
211
|
}
|
|
211
212
|
) : /* @__PURE__ */ v(Ge, { w: "full", gap: M.xl, className: p(y), children: [
|
|
212
|
-
/* @__PURE__ */ o(
|
|
213
|
+
/* @__PURE__ */ o(Fe, { data: h, showBorders: g, children: /* @__PURE__ */ v("table", { className: p(Je, U), children: [
|
|
213
214
|
/* @__PURE__ */ o(
|
|
214
215
|
"thead",
|
|
215
216
|
{
|
|
@@ -219,27 +220,27 @@ const { spacing: M, color: t } = qe, Je = b({
|
|
|
219
220
|
X
|
|
220
221
|
),
|
|
221
222
|
"aria-busy": i,
|
|
222
|
-
children:
|
|
223
|
+
children: t.getHeaderGroups().map((e) => /* @__PURE__ */ o(ae, { showBorders: g, children: e.headers.map(Te) }, e.id))
|
|
223
224
|
}
|
|
224
225
|
),
|
|
225
226
|
/* @__PURE__ */ o("tbody", { className: Y, children: i ? Array.from(
|
|
226
227
|
{ length: J },
|
|
227
|
-
(e,
|
|
228
|
-
) : P.map((e,
|
|
228
|
+
(e, n) => ve(n)
|
|
229
|
+
) : P.map((e, n) => Pe(e, n)) })
|
|
229
230
|
] }) }),
|
|
230
231
|
S && !i && /* @__PURE__ */ o(
|
|
231
232
|
Be,
|
|
232
233
|
{
|
|
233
234
|
pageIndex: a.pageIndex,
|
|
234
235
|
pageSize: a.pageSize,
|
|
235
|
-
totalCount:
|
|
236
|
-
variant:
|
|
237
|
-
labels:
|
|
236
|
+
totalCount: s || h.length,
|
|
237
|
+
variant: me,
|
|
238
|
+
labels: se,
|
|
238
239
|
renderPageSizeSelectorDropdownItem: ce,
|
|
239
240
|
renderPageSizeSelectorInputItem: ge,
|
|
240
241
|
onPageChange: (e) => C({ ...a, pageIndex: e }),
|
|
241
242
|
onPageSizeChange: (e) => C({ ...a, pageSize: e, pageIndex: 0 }),
|
|
242
|
-
className:
|
|
243
|
+
className: ne
|
|
243
244
|
}
|
|
244
245
|
)
|
|
245
246
|
] });
|
|
@@ -248,7 +249,7 @@ c.displayName = "Table";
|
|
|
248
249
|
c.HeadCellContent = Oe;
|
|
249
250
|
c.BodyCellContent = k;
|
|
250
251
|
c.HeadCellContentSortable = $e;
|
|
251
|
-
c.createColumnHelper =
|
|
252
|
+
c.createColumnHelper = ze;
|
|
252
253
|
export {
|
|
253
254
|
c as Table
|
|
254
255
|
};
|
|
@@ -4,10 +4,5 @@ export interface TableBodyRowProps extends React.HTMLAttributes<HTMLTableRowElem
|
|
|
4
4
|
* @default false
|
|
5
5
|
*/
|
|
6
6
|
showBorders?: boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Выбрана ли строка
|
|
9
|
-
* @default false
|
|
10
|
-
*/
|
|
11
|
-
isSelected?: boolean;
|
|
12
7
|
}
|
|
13
8
|
export declare const TableBodyRow: import('react').ForwardRefExoticComponent<TableBodyRowProps & import('react').RefAttributes<HTMLTableRowElement>>;
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { css as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { theme as
|
|
5
|
-
const { color:
|
|
6
|
-
({ children:
|
|
7
|
-
const
|
|
8
|
-
borderBottom:
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { css as m, cx as c } from "@emotion/css";
|
|
3
|
+
import { forwardRef as i } from "react";
|
|
4
|
+
import { theme as d } from "../../../../utils/theme/index.js";
|
|
5
|
+
const { color: o } = d, f = i(
|
|
6
|
+
({ children: r, className: e, showBorders: t = !1, ...a }, l) => {
|
|
7
|
+
const s = m({
|
|
8
|
+
borderBottom: t ? `1px solid ${o.border.neutralAlphaLow}` : "none",
|
|
9
|
+
transition: "background-color 0.15s ease-in-out",
|
|
10
|
+
"&:hover": {
|
|
11
|
+
backgroundColor: o.fill.neutralPrimaryHover
|
|
12
|
+
}
|
|
9
13
|
});
|
|
10
|
-
return /* @__PURE__ */
|
|
14
|
+
return /* @__PURE__ */ n("tr", { ref: l, className: c(s, e), ...a, children: r });
|
|
11
15
|
}
|
|
12
16
|
);
|
|
13
|
-
|
|
17
|
+
f.displayName = "TableBodyRow";
|
|
14
18
|
export {
|
|
15
|
-
|
|
19
|
+
f as TableBodyRow
|
|
16
20
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { css as n, cx as
|
|
3
|
-
import { memo as
|
|
4
|
-
import { theme as
|
|
5
|
-
import { Box as
|
|
6
|
-
const { color:
|
|
1
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { css as n, cx as f } from "@emotion/css";
|
|
3
|
+
import { memo as k, useState as d, useRef as x, useCallback as E, useEffect as W } from "react";
|
|
4
|
+
import { theme as $ } from "../../../../utils/theme/index.js";
|
|
5
|
+
import { Box as m } from "../../Box/Box.js";
|
|
6
|
+
const { color: o, cornerRadius: C } = $, P = n({
|
|
7
7
|
position: "relative",
|
|
8
8
|
borderRadius: C.md,
|
|
9
9
|
overflow: "hidden",
|
|
@@ -14,66 +14,65 @@ const { color: s, cornerRadius: C } = W, z = n({
|
|
|
14
14
|
bottom: 14,
|
|
15
15
|
width: 96,
|
|
16
16
|
pointerEvents: "none",
|
|
17
|
-
zIndex: 1,
|
|
18
17
|
transition: "opacity 0.2s ease"
|
|
19
18
|
},
|
|
20
19
|
"&::before": {
|
|
21
20
|
left: 0,
|
|
22
|
-
background:
|
|
21
|
+
background: `linear-gradient(to left, transparent 0%, ${o.fill.bgPrimary} 100%)`
|
|
23
22
|
},
|
|
24
23
|
"&::after": {
|
|
25
24
|
right: 0,
|
|
26
|
-
background:
|
|
25
|
+
background: `linear-gradient(to right, transparent 0%, ${o.fill.bgPrimary} 100%)`
|
|
27
26
|
}
|
|
28
27
|
}), N = n({
|
|
29
28
|
overflowX: "auto",
|
|
30
29
|
scrollbarWidth: "thin",
|
|
31
|
-
scrollbarColor: `${
|
|
32
|
-
}), T =
|
|
30
|
+
scrollbarColor: `${o.scrollbar.thumbPrimary} ${o.scrollbar.trackPrimary}`
|
|
31
|
+
}), T = k(
|
|
33
32
|
({
|
|
34
|
-
data:
|
|
33
|
+
data: b,
|
|
35
34
|
children: h,
|
|
36
35
|
className: p,
|
|
37
36
|
scrollContainerClassName: u,
|
|
38
37
|
showBorders: w = !1,
|
|
39
|
-
...
|
|
38
|
+
...y
|
|
40
39
|
}) => {
|
|
41
|
-
const [
|
|
42
|
-
const
|
|
43
|
-
if (!
|
|
44
|
-
const { scrollLeft:
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
const [S, g] = d(!1), [v, R] = d(!1), s = x(null), e = E(() => {
|
|
41
|
+
const r = s.current;
|
|
42
|
+
if (!r) return;
|
|
43
|
+
const { scrollLeft: t, scrollWidth: a, clientWidth: l } = r, i = a > l;
|
|
44
|
+
g(i && t > 0), R(
|
|
45
|
+
i && t < a - l - 1
|
|
47
46
|
);
|
|
48
47
|
}, []);
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
if (!
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
return
|
|
55
|
-
|
|
48
|
+
W(() => {
|
|
49
|
+
const r = s.current;
|
|
50
|
+
if (!r) return;
|
|
51
|
+
e();
|
|
52
|
+
const t = new ResizeObserver(e);
|
|
53
|
+
return t.observe(r), r.addEventListener("scroll", e), () => {
|
|
54
|
+
t.disconnect(), r.removeEventListener("scroll", e);
|
|
56
55
|
};
|
|
57
|
-
}, [
|
|
58
|
-
const
|
|
59
|
-
border: w ? `1px solid ${
|
|
56
|
+
}, [e, b]);
|
|
57
|
+
const L = n({
|
|
58
|
+
border: w ? `1px solid ${o.border.neutralAlphaLow}` : "transparent",
|
|
60
59
|
"&::before": {
|
|
61
|
-
opacity:
|
|
60
|
+
opacity: S ? 1 : 0
|
|
62
61
|
},
|
|
63
62
|
"&::after": {
|
|
64
|
-
opacity:
|
|
63
|
+
opacity: v ? 1 : 0
|
|
65
64
|
}
|
|
66
65
|
});
|
|
67
|
-
return /* @__PURE__ */
|
|
68
|
-
|
|
66
|
+
return /* @__PURE__ */ c(
|
|
67
|
+
m,
|
|
69
68
|
{
|
|
70
|
-
className:
|
|
71
|
-
...
|
|
72
|
-
children: /* @__PURE__ */
|
|
73
|
-
|
|
69
|
+
className: f(P, L, p),
|
|
70
|
+
...y,
|
|
71
|
+
children: /* @__PURE__ */ c(
|
|
72
|
+
m,
|
|
74
73
|
{
|
|
75
|
-
ref:
|
|
76
|
-
className:
|
|
74
|
+
ref: s,
|
|
75
|
+
className: f(N, u),
|
|
77
76
|
children: h
|
|
78
77
|
}
|
|
79
78
|
)
|
|
@@ -1,88 +1,91 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { cx as
|
|
3
|
-
import { motion as
|
|
4
|
-
import { useMemo as
|
|
5
|
-
import { cornerRadiusValues as
|
|
6
|
-
import { Loader as
|
|
7
|
-
import { AnimatedText as
|
|
8
|
-
import { theme as
|
|
9
|
-
import { Box as
|
|
1
|
+
import { jsx as o, jsxs as b, Fragment as O } from "react/jsx-runtime";
|
|
2
|
+
import { cx as w, css as P } from "@emotion/css";
|
|
3
|
+
import { motion as k } from "framer-motion";
|
|
4
|
+
import { useMemo as n } from "react";
|
|
5
|
+
import { cornerRadiusValues as m, baseButton as q, getVariantStyles as D, typeStyles as E, sizeValues as G } from "./styles.js";
|
|
6
|
+
import { Loader as H } from "../../builders/Loader/Loader.js";
|
|
7
|
+
import { AnimatedText as I } from "../../builders/Text/Text.js";
|
|
8
|
+
import { theme as J } from "../../../utils/theme/index.js";
|
|
9
|
+
import { Box as K } from "../../builders/Box/Box.js";
|
|
10
10
|
import { Ripple as Q } from "../../builders/Ripple/Ripple.js";
|
|
11
|
-
const { color:
|
|
12
|
-
disabled:
|
|
11
|
+
const { color: u } = J, sr = ({
|
|
12
|
+
disabled: a,
|
|
13
13
|
loading: l,
|
|
14
14
|
className: g,
|
|
15
15
|
wrapperClassName: S,
|
|
16
16
|
buttonClassName: _,
|
|
17
17
|
buttonDisabledClassName: $,
|
|
18
18
|
textClassName: N,
|
|
19
|
-
children:
|
|
20
|
-
variant:
|
|
19
|
+
children: B,
|
|
20
|
+
variant: e = "filled",
|
|
21
21
|
backgroundColor: f,
|
|
22
22
|
textColor: d,
|
|
23
23
|
textFontWeight: U,
|
|
24
|
-
borderColor:
|
|
25
|
-
color:
|
|
24
|
+
borderColor: i,
|
|
25
|
+
color: r = "accent",
|
|
26
26
|
opacity: p,
|
|
27
27
|
borderRadius: x,
|
|
28
|
-
width:
|
|
28
|
+
width: c = "auto",
|
|
29
29
|
size: s = "md",
|
|
30
|
-
iconLeft:
|
|
30
|
+
iconLeft: v,
|
|
31
31
|
iconRight: R,
|
|
32
32
|
intensity: t = "primary",
|
|
33
33
|
flex: T,
|
|
34
34
|
type: V = "button",
|
|
35
35
|
...j
|
|
36
36
|
}) => {
|
|
37
|
-
const h =
|
|
38
|
-
switch (
|
|
37
|
+
const h = n(() => {
|
|
38
|
+
switch (c) {
|
|
39
39
|
case "full":
|
|
40
40
|
return "100%";
|
|
41
41
|
case "auto":
|
|
42
42
|
return "fit-content";
|
|
43
43
|
default:
|
|
44
|
-
return
|
|
44
|
+
return c;
|
|
45
45
|
}
|
|
46
|
-
}, [
|
|
46
|
+
}, [c]), A = n(() => f || (e === "filled" ? r === "neutral" ? u.fill.neutralSecondary : r === "neutral-primary" ? u.fill.neutralPrimary : `var(--fill-${r}-${t})` : "transparent"), [e, f, r, t]), F = n(() => {
|
|
47
47
|
if (t === "primary") {
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return
|
|
52
|
-
|
|
48
|
+
if (r === "neutral" || r === "neutral-primary")
|
|
49
|
+
return u.text.secondary;
|
|
50
|
+
if (e === "filled") return u.text.inverse;
|
|
51
|
+
} else if (r === "neutral") return u.text.secondary;
|
|
52
|
+
return `var(--text-${r})`;
|
|
53
|
+
}, [t, r, e]), y = n(() => {
|
|
53
54
|
if (t === "primary") {
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
if (r === "neutral" || r === "neutral-primary")
|
|
56
|
+
return "secondary";
|
|
57
|
+
if (e === "filled") return "inverse";
|
|
58
|
+
} else if (r === "neutral" || r === "neutral-primary")
|
|
59
|
+
return "secondary";
|
|
60
|
+
return r;
|
|
61
|
+
}, [e, r, t]), W = n(() => i || (e === "outline" ? r === "neutral-primary" ? u.border.neutralAlphaBasic : `var(--border-${r}-${t})` : "transparent"), [e, i, r, t]), C = n(() => {
|
|
59
62
|
switch (s) {
|
|
60
63
|
case "lg":
|
|
61
|
-
return
|
|
64
|
+
return m.lg;
|
|
62
65
|
case "md":
|
|
63
66
|
case "sm":
|
|
64
|
-
return
|
|
67
|
+
return m.md;
|
|
65
68
|
case "xs":
|
|
66
|
-
return
|
|
69
|
+
return m.sm;
|
|
67
70
|
default:
|
|
68
|
-
return
|
|
71
|
+
return m.md;
|
|
69
72
|
}
|
|
70
|
-
}, [s]), L =
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
borderRadius: x ?
|
|
77
|
-
backgroundColor:
|
|
78
|
-
borderColor:
|
|
79
|
-
color: d ?? `var(--text-${
|
|
73
|
+
}, [s]), L = w(
|
|
74
|
+
q,
|
|
75
|
+
D(e, r, t, a),
|
|
76
|
+
E[e],
|
|
77
|
+
a ? $ : void 0,
|
|
78
|
+
P({
|
|
79
|
+
borderRadius: x ? m[x] : C,
|
|
80
|
+
backgroundColor: A,
|
|
81
|
+
borderColor: W,
|
|
82
|
+
color: d ?? `var(--text-${y})`,
|
|
80
83
|
width: h,
|
|
81
|
-
height:
|
|
82
|
-
opacity: p || (
|
|
84
|
+
height: G[s],
|
|
85
|
+
opacity: p || (a ? 0.7 : 1)
|
|
83
86
|
}),
|
|
84
87
|
_
|
|
85
|
-
), M =
|
|
88
|
+
), M = n(() => {
|
|
86
89
|
switch (s) {
|
|
87
90
|
case "lg":
|
|
88
91
|
case "md":
|
|
@@ -94,44 +97,44 @@ const { color: m } = K, ue = ({
|
|
|
94
97
|
return "body-1";
|
|
95
98
|
}
|
|
96
99
|
}, [s]);
|
|
97
|
-
return /* @__PURE__ */
|
|
98
|
-
|
|
100
|
+
return /* @__PURE__ */ o(
|
|
101
|
+
K,
|
|
99
102
|
{
|
|
100
|
-
className:
|
|
103
|
+
className: w(S, g),
|
|
101
104
|
w: h,
|
|
102
105
|
flex: T,
|
|
103
106
|
relative: !0,
|
|
104
107
|
overflow: "hidden",
|
|
105
|
-
children: /* @__PURE__ */
|
|
106
|
-
|
|
108
|
+
children: /* @__PURE__ */ b(
|
|
109
|
+
k.button,
|
|
107
110
|
{
|
|
108
111
|
...j,
|
|
109
|
-
whileTap: !
|
|
112
|
+
whileTap: !a && !l ? {
|
|
110
113
|
scale: 0.99,
|
|
111
114
|
boxShadow: "inset 0 0 0 10000px rgba(0,0,0,0.1)",
|
|
112
115
|
transition: { duration: 0 }
|
|
113
116
|
} : {},
|
|
114
|
-
disabled:
|
|
117
|
+
disabled: a || l,
|
|
115
118
|
className: L,
|
|
116
119
|
type: V,
|
|
117
120
|
children: [
|
|
118
|
-
l ? /* @__PURE__ */
|
|
119
|
-
|
|
120
|
-
/* @__PURE__ */
|
|
121
|
-
|
|
121
|
+
l ? /* @__PURE__ */ o(H, { color: F }) : /* @__PURE__ */ b(O, { children: [
|
|
122
|
+
v,
|
|
123
|
+
/* @__PURE__ */ o(
|
|
124
|
+
I,
|
|
122
125
|
{
|
|
123
126
|
style: { color: d },
|
|
124
|
-
colorName:
|
|
127
|
+
colorName: y,
|
|
125
128
|
variant: M,
|
|
126
129
|
className: N,
|
|
127
130
|
textOverflow: "ellipsis",
|
|
128
131
|
overflow: "hidden",
|
|
129
|
-
children:
|
|
132
|
+
children: B
|
|
130
133
|
}
|
|
131
134
|
),
|
|
132
135
|
R
|
|
133
136
|
] }),
|
|
134
|
-
/* @__PURE__ */
|
|
137
|
+
/* @__PURE__ */ o(Q, {})
|
|
135
138
|
]
|
|
136
139
|
}
|
|
137
140
|
)
|
|
@@ -139,5 +142,5 @@ const { color: m } = K, ue = ({
|
|
|
139
142
|
);
|
|
140
143
|
};
|
|
141
144
|
export {
|
|
142
|
-
|
|
145
|
+
sr as Button
|
|
143
146
|
};
|
|
@@ -11,8 +11,9 @@ export type ButtonType = "clear" | "filled" | "outline";
|
|
|
11
11
|
* Использует системные токены:
|
|
12
12
|
* - `accent` — акцентный цвет
|
|
13
13
|
* - `neutral` — нейтральный
|
|
14
|
+
* - `neutral-primary` — нейтральный основной
|
|
14
15
|
* - `negative` — негативный (ошибки/отмена)
|
|
15
16
|
* - `positive` — позитивный (успех)
|
|
16
17
|
* - `warning` — предупреждение
|
|
17
18
|
*/
|
|
18
|
-
export type ButtonColor = AccentType | NeutralType | NegativeType | PositiveType | WarningType | TransferType;
|
|
19
|
+
export type ButtonColor = AccentType | NeutralType | "neutral-primary" | NegativeType | PositiveType | WarningType | TransferType;
|