@dss-kit/ui-kit 1.0.0 → 1.0.2
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 +169 -165
- package/dist/components/builders/Table/Table.types.d.ts +5 -1
- package/dist/components/builders/Table/TableBodyRow/TableBodyRow.d.ts +5 -0
- package/dist/components/builders/Table/TableBodyRow/TableBodyRow.js +23 -9
- package/dist/components/builders/Table/TablePlaceholder/TablePlaceholder.js +22 -22
- package/dist/components/controls/Switch/Switch.d.ts +3 -3
- package/dist/components/controls/Switch/styles.d.ts +1 -0
- package/dist/components/controls/Switch/styles.js +44 -34
- package/dist/components/controls/Tabs/TabItem/TabItem.d.ts +5 -0
- package/dist/components/controls/Tabs/TabItem/TabItem.js +68 -49
- package/dist/components/controls/Tabs/Tabs.d.ts +6 -1
- package/dist/components/controls/Tabs/Tabs.js +31 -28
- package/dist/components/shared/Counter/Counter.const.d.ts +6 -0
- package/dist/components/shared/Counter/Counter.const.js +16 -0
- package/dist/components/shared/Counter/Counter.d.ts +11 -0
- package/dist/components/shared/Counter/Counter.js +58 -0
- package/dist/components/shared/Counter/Counter.types.d.ts +29 -0
- package/dist/components/shared/Counter/Counter.utils.d.ts +2 -0
- package/dist/components/shared/Counter/Counter.utils.js +6 -0
- package/dist/components/shared/Counter/index.d.ts +2 -0
- package/dist/components/shared/Counter/styles.d.ts +2 -0
- package/dist/components/shared/Counter/styles.js +11 -0
- package/dist/components/shared/Dot/Dot.const.d.ts +5 -0
- package/dist/components/shared/Dot/Dot.const.js +15 -0
- package/dist/components/shared/Dot/Dot.d.ts +10 -0
- package/dist/components/shared/Dot/Dot.js +32 -0
- package/dist/components/shared/Dot/Dot.types.d.ts +17 -0
- package/dist/components/shared/Dot/index.d.ts +2 -0
- package/dist/components/shared/Dot/styles.d.ts +1 -0
- package/dist/components/shared/Dot/styles.js +7 -0
- package/dist/components/shared/index.d.ts +2 -0
- package/dist/index.js +52 -48
- package/dist/ui-kit.cjs +8 -8
- package/package.json +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { css as
|
|
2
|
-
import { theme as
|
|
3
|
-
const { color:
|
|
4
|
-
container:
|
|
1
|
+
import { css as i } from "@emotion/css";
|
|
2
|
+
import { theme as c } from "../../../utils/theme/index.js";
|
|
3
|
+
const { color: t, cornerRadius: r, height: h, spacing: s, transition: e } = c, l = {
|
|
4
|
+
container: i({
|
|
5
5
|
width: "100%",
|
|
6
6
|
cursor: "pointer",
|
|
7
7
|
outline: "none",
|
|
8
8
|
userSelect: "none",
|
|
9
9
|
display: "flex",
|
|
10
10
|
justifyContent: "space-between",
|
|
11
|
-
gap:
|
|
11
|
+
gap: s.md,
|
|
12
12
|
"&.disabled": {
|
|
13
13
|
cursor: "not-allowed",
|
|
14
14
|
opacity: 0.5
|
|
@@ -17,14 +17,14 @@ const { color: i, cornerRadius: e, height: h, spacing: c, transition: r } = s, l
|
|
|
17
17
|
flexDirection: "row-reverse"
|
|
18
18
|
}
|
|
19
19
|
}),
|
|
20
|
-
disabled:
|
|
20
|
+
disabled: i({
|
|
21
21
|
cursor: "not-allowed",
|
|
22
22
|
opacity: 0.5
|
|
23
23
|
}),
|
|
24
|
-
reverse:
|
|
24
|
+
reverse: i({
|
|
25
25
|
flexDirection: "row-reverse"
|
|
26
26
|
}),
|
|
27
|
-
switchContainer:
|
|
27
|
+
switchContainer: i({
|
|
28
28
|
"--width-switch-sm": "34px",
|
|
29
29
|
"--width-switch-md": "40px",
|
|
30
30
|
"--width-switch-lg": "52px",
|
|
@@ -37,82 +37,92 @@ const { color: i, cornerRadius: e, height: h, spacing: c, transition: r } = s, l
|
|
|
37
37
|
}
|
|
38
38
|
}),
|
|
39
39
|
// Variant classes — each handles both checked and unchecked states
|
|
40
|
-
variant_accent:
|
|
40
|
+
variant_accent: i({
|
|
41
41
|
"&:has(input:not(:checked))": {
|
|
42
|
-
"--switch-bg-color":
|
|
43
|
-
"--thumb-bg-color":
|
|
42
|
+
"--switch-bg-color": t.fill.bg_tertiary,
|
|
43
|
+
"--thumb-bg-color": t.fill.bg_primary
|
|
44
44
|
},
|
|
45
45
|
"&:has(input:checked)": {
|
|
46
|
-
"--switch-bg-color":
|
|
47
|
-
"--thumb-bg-color":
|
|
46
|
+
"--switch-bg-color": t.fill.accent_primary,
|
|
47
|
+
"--thumb-bg-color": t.fill.bg_primary
|
|
48
48
|
}
|
|
49
49
|
}),
|
|
50
|
-
variant_secondary:
|
|
50
|
+
variant_secondary: i({
|
|
51
51
|
"&:has(input:not(:checked))": {
|
|
52
|
-
"--switch-bg-color":
|
|
53
|
-
"--thumb-bg-color":
|
|
52
|
+
"--switch-bg-color": t.fill.bg_tertiary,
|
|
53
|
+
"--thumb-bg-color": t.fill.bg_primary
|
|
54
54
|
},
|
|
55
55
|
"&:has(input:checked)": {
|
|
56
|
-
"--switch-bg-color":
|
|
57
|
-
"--thumb-bg-color":
|
|
56
|
+
"--switch-bg-color": t.fill.accent_secondary,
|
|
57
|
+
"--thumb-bg-color": t.fill.accent_primary
|
|
58
58
|
}
|
|
59
59
|
}),
|
|
60
|
-
|
|
60
|
+
variant_positive: i({
|
|
61
61
|
"&:has(input:not(:checked))": {
|
|
62
|
-
"--switch-bg-color":
|
|
63
|
-
"--thumb-bg-color":
|
|
62
|
+
"--switch-bg-color": t.fill.bg_tertiary,
|
|
63
|
+
"--thumb-bg-color": t.fill.bg_primary
|
|
64
64
|
},
|
|
65
65
|
"&:has(input:checked)": {
|
|
66
|
-
"--switch-bg-color":
|
|
67
|
-
"--thumb-bg-color":
|
|
66
|
+
"--switch-bg-color": t.fill.positive_primary,
|
|
67
|
+
"--thumb-bg-color": t.fill.bg_primary
|
|
68
|
+
}
|
|
69
|
+
}),
|
|
70
|
+
variant_theme: i({
|
|
71
|
+
"&:has(input:not(:checked))": {
|
|
72
|
+
"--switch-bg-color": t.fill.bg_tertiary,
|
|
73
|
+
"--thumb-bg-color": t.fill.bg_primary
|
|
74
|
+
},
|
|
75
|
+
"&:has(input:checked)": {
|
|
76
|
+
"--switch-bg-color": t.fill.bg_secondary,
|
|
77
|
+
"--thumb-bg-color": t.fill.bg_tertiary
|
|
68
78
|
}
|
|
69
79
|
}),
|
|
70
80
|
// Size classes
|
|
71
|
-
size_sm:
|
|
81
|
+
size_sm: i({
|
|
72
82
|
"--switch-width": "var(--width-switch-sm)",
|
|
73
83
|
"--switch-height": h.switch.sm,
|
|
74
84
|
"--thumb-width": "var(--size-thumb-sm)",
|
|
75
85
|
"--thumb-height": "var(--size-thumb-sm)"
|
|
76
86
|
}),
|
|
77
|
-
size_md:
|
|
87
|
+
size_md: i({
|
|
78
88
|
"--switch-width": "var(--width-switch-md)",
|
|
79
89
|
"--switch-height": h.switch.md,
|
|
80
90
|
"--thumb-width": "var(--size-thumb-md)",
|
|
81
91
|
"--thumb-height": "var(--size-thumb-md)"
|
|
82
92
|
}),
|
|
83
|
-
size_lg:
|
|
93
|
+
size_lg: i({
|
|
84
94
|
"--switch-width": "var(--width-switch-lg)",
|
|
85
95
|
"--switch-height": h.switch.lg,
|
|
86
96
|
"--thumb-width": "var(--size-thumb-lg)",
|
|
87
97
|
"--thumb-height": "var(--size-thumb-lg)"
|
|
88
98
|
}),
|
|
89
|
-
switch:
|
|
99
|
+
switch: i({
|
|
90
100
|
width: "var(--switch-width)",
|
|
91
101
|
height: "var(--switch-height)",
|
|
92
|
-
transition:
|
|
102
|
+
transition: e.general,
|
|
93
103
|
display: "flex",
|
|
94
104
|
alignItems: "center",
|
|
95
105
|
padding: 2,
|
|
96
106
|
backgroundColor: "var(--switch-bg-color)",
|
|
97
|
-
borderRadius:
|
|
107
|
+
borderRadius: r.xl
|
|
98
108
|
}),
|
|
99
|
-
thumb:
|
|
109
|
+
thumb: i({
|
|
100
110
|
display: "flex",
|
|
101
111
|
alignItems: "center",
|
|
102
112
|
justifyContent: "center",
|
|
103
113
|
padding: 4,
|
|
104
|
-
transition:
|
|
114
|
+
transition: e.general,
|
|
105
115
|
transform: "translateX(var(--thumb-translate, 0))",
|
|
106
116
|
width: "var(--thumb-width)",
|
|
107
117
|
height: "var(--thumb-height)",
|
|
108
118
|
backgroundColor: "var(--thumb-bg-color)",
|
|
109
|
-
borderRadius:
|
|
119
|
+
borderRadius: r.fullRound
|
|
110
120
|
}),
|
|
111
|
-
moon:
|
|
121
|
+
moon: i({
|
|
112
122
|
width: "100%",
|
|
113
123
|
height: "100%"
|
|
114
124
|
}),
|
|
115
|
-
fire:
|
|
125
|
+
fire: i({
|
|
116
126
|
width: "100%",
|
|
117
127
|
height: "100%"
|
|
118
128
|
})
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
interface TabItemProps {
|
|
2
3
|
label: string;
|
|
3
4
|
selected: boolean;
|
|
@@ -10,6 +11,10 @@ interface TabItemProps {
|
|
|
10
11
|
activeClassName?: string;
|
|
11
12
|
/** Класс для текста внутри таба (`Text`). */
|
|
12
13
|
textClassName?: string;
|
|
14
|
+
/** Элемент справа от подписи, например `Counter`. */
|
|
15
|
+
endSlot?: ReactNode;
|
|
16
|
+
/** Класс для обёртки `endSlot`. */
|
|
17
|
+
endSlotClassName?: string;
|
|
13
18
|
}
|
|
14
19
|
export declare const TabItem: import('react').ForwardRefExoticComponent<TabItemProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
15
20
|
export {};
|
|
@@ -1,58 +1,77 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { cx as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { Box as
|
|
5
|
-
import { theme as
|
|
6
|
-
import { Text as
|
|
7
|
-
const { spacing:
|
|
1
|
+
import { jsxs as h, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { cx as i, css as o } from "@emotion/css";
|
|
3
|
+
import { forwardRef as g } from "react";
|
|
4
|
+
import { Box as m } from "../../../builders/Box/Box.js";
|
|
5
|
+
import { theme as w } from "../../../../utils/theme/index.js";
|
|
6
|
+
import { Text as S } from "../../../builders/Text/Text.js";
|
|
7
|
+
const { spacing: t } = w, N = o({
|
|
8
8
|
cursor: "pointer",
|
|
9
9
|
userSelect: "none"
|
|
10
|
-
}),
|
|
10
|
+
}), b = o({
|
|
11
11
|
cursor: "not-allowed",
|
|
12
12
|
opacity: 0.5
|
|
13
|
-
}),
|
|
13
|
+
}), j = o({
|
|
14
14
|
transition: "color 0.2s ease"
|
|
15
|
-
}),
|
|
15
|
+
}), E = g(
|
|
16
16
|
({
|
|
17
|
-
label:
|
|
18
|
-
selected:
|
|
19
|
-
disabled:
|
|
20
|
-
fullWidth:
|
|
21
|
-
onClick:
|
|
22
|
-
className:
|
|
23
|
-
activeClassName:
|
|
24
|
-
textClassName:
|
|
25
|
-
|
|
26
|
-
y
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
17
|
+
label: a,
|
|
18
|
+
selected: r,
|
|
19
|
+
disabled: c,
|
|
20
|
+
fullWidth: l,
|
|
21
|
+
onClick: p,
|
|
22
|
+
className: f,
|
|
23
|
+
activeClassName: x,
|
|
24
|
+
textClassName: d,
|
|
25
|
+
endSlot: e,
|
|
26
|
+
endSlotClassName: y
|
|
27
|
+
}, u) => {
|
|
28
|
+
const s = !!e;
|
|
29
|
+
return /* @__PURE__ */ h(
|
|
30
|
+
m,
|
|
31
|
+
{
|
|
32
|
+
row: s,
|
|
33
|
+
gap: t.xs,
|
|
34
|
+
w: l ? "full" : void 0,
|
|
35
|
+
justifyContent: "center",
|
|
36
|
+
alignItems: "center",
|
|
37
|
+
ref: u,
|
|
38
|
+
py: t.md,
|
|
39
|
+
px: t.xl,
|
|
40
|
+
onClick: p,
|
|
41
|
+
className: i(
|
|
42
|
+
N,
|
|
43
|
+
{
|
|
44
|
+
[b]: c
|
|
45
|
+
},
|
|
46
|
+
f,
|
|
47
|
+
r && x
|
|
48
|
+
),
|
|
49
|
+
children: [
|
|
50
|
+
/* @__PURE__ */ n(
|
|
51
|
+
S,
|
|
52
|
+
{
|
|
53
|
+
className: i(j, d),
|
|
54
|
+
colorName: r ? "primary" : "tertiary",
|
|
55
|
+
fontWeight: "medium",
|
|
56
|
+
variant: "body-2",
|
|
57
|
+
children: a
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
s && /* @__PURE__ */ n(
|
|
61
|
+
m,
|
|
62
|
+
{
|
|
63
|
+
row: !0,
|
|
64
|
+
alignItems: "center",
|
|
65
|
+
flexShrink: 0,
|
|
66
|
+
className: y,
|
|
67
|
+
children: e
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
55
74
|
);
|
|
56
75
|
export {
|
|
57
|
-
|
|
76
|
+
E as TabItem
|
|
58
77
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
export interface TabOption<T extends string | number> {
|
|
2
3
|
/** Текстовая метка опции */
|
|
3
4
|
label: string;
|
|
@@ -5,6 +6,8 @@ export interface TabOption<T extends string | number> {
|
|
|
5
6
|
value: T;
|
|
6
7
|
/** Флаг отключения опции */
|
|
7
8
|
disabled?: boolean;
|
|
9
|
+
/** Элемент справа от подписи, например `Counter` */
|
|
10
|
+
endSlot?: ReactNode;
|
|
8
11
|
}
|
|
9
12
|
export interface TabsProps<T extends string | number> {
|
|
10
13
|
/** Текущее выбранное значение */
|
|
@@ -25,6 +28,8 @@ export interface TabsProps<T extends string | number> {
|
|
|
25
28
|
activeTabClassName?: string;
|
|
26
29
|
/** Класс для текста внутри табов. */
|
|
27
30
|
tabTextClassName?: string;
|
|
31
|
+
/** Класс для обёртки `endSlot` внутри табов. */
|
|
32
|
+
endSlotClassName?: string;
|
|
28
33
|
/** Класс для индикатора выбранного таба. */
|
|
29
34
|
indicatorClassName?: string;
|
|
30
35
|
}
|
|
@@ -41,7 +46,7 @@ export interface TabsProps<T extends string | number> {
|
|
|
41
46
|
* ```
|
|
42
47
|
*/
|
|
43
48
|
declare const Tabs: {
|
|
44
|
-
<T extends string | number>({ value, onChange, options, fullWidth, className, tabClassName, activeTabClassName, tabTextClassName, indicatorClassName, }: TabsProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
<T extends string | number>({ value, onChange, options, fullWidth, className, tabClassName, activeTabClassName, tabTextClassName, endSlotClassName, indicatorClassName, }: TabsProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
45
50
|
displayName: string;
|
|
46
51
|
};
|
|
47
52
|
export { Tabs };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { cx as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { TabItem as
|
|
5
|
-
import { Box as
|
|
6
|
-
import { theme as
|
|
7
|
-
const { color:
|
|
8
|
-
borderBottom: `1px solid ${
|
|
9
|
-
}),
|
|
1
|
+
import { jsxs as C, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { cx as d, css as m } from "@emotion/css";
|
|
3
|
+
import { useState as p, useRef as I, useEffect as k } from "react";
|
|
4
|
+
import { TabItem as R } from "./TabItem/TabItem.js";
|
|
5
|
+
import { Box as f } from "../../builders/Box/Box.js";
|
|
6
|
+
import { theme as _ } from "../../../utils/theme/index.js";
|
|
7
|
+
const { color: i } = _, g = m({
|
|
8
|
+
borderBottom: `1px solid ${i.border.neutral_alpha_basic}`
|
|
9
|
+
}), j = ({
|
|
10
10
|
value: a,
|
|
11
11
|
onChange: n,
|
|
12
12
|
options: s,
|
|
@@ -15,59 +15,62 @@ const { color: m } = R, _ = i({
|
|
|
15
15
|
tabClassName: u,
|
|
16
16
|
activeTabClassName: h,
|
|
17
17
|
tabTextClassName: x,
|
|
18
|
-
|
|
18
|
+
endSlotClassName: w,
|
|
19
|
+
indicatorClassName: v
|
|
19
20
|
}) => {
|
|
20
|
-
const [l,
|
|
21
|
+
const [l, N] = p({
|
|
21
22
|
left: 0,
|
|
22
23
|
width: 0
|
|
23
|
-
}), o = I([]),
|
|
24
|
+
}), o = I([]), S = (e) => (t) => {
|
|
24
25
|
o.current[e] = t;
|
|
25
26
|
};
|
|
26
|
-
|
|
27
|
-
const e = s.findIndex((
|
|
28
|
-
t &&
|
|
27
|
+
k(() => {
|
|
28
|
+
const e = s.findIndex((y) => y.value === a), t = o.current[e];
|
|
29
|
+
t && N({
|
|
29
30
|
left: t.offsetLeft,
|
|
30
31
|
width: t.offsetWidth
|
|
31
32
|
});
|
|
32
33
|
}, [a, s]);
|
|
33
34
|
const T = (e, t = !1) => () => !t && n(e);
|
|
34
|
-
return /* @__PURE__ */
|
|
35
|
-
|
|
35
|
+
return /* @__PURE__ */ C(
|
|
36
|
+
f,
|
|
36
37
|
{
|
|
37
38
|
row: !0,
|
|
38
39
|
w: r ? "full" : "auto",
|
|
39
40
|
relative: !0,
|
|
40
|
-
className:
|
|
41
|
+
className: d(g, b),
|
|
41
42
|
children: [
|
|
42
43
|
s.map((e, t) => /* @__PURE__ */ c(
|
|
43
|
-
|
|
44
|
+
R,
|
|
44
45
|
{
|
|
45
46
|
selected: a === e.value,
|
|
46
47
|
onClick: T(e.value, e.disabled),
|
|
47
|
-
ref:
|
|
48
|
+
ref: S(t),
|
|
48
49
|
label: e.label,
|
|
49
50
|
disabled: e.disabled,
|
|
50
51
|
fullWidth: r,
|
|
51
52
|
className: u,
|
|
52
53
|
activeClassName: h,
|
|
53
|
-
textClassName: x
|
|
54
|
+
textClassName: x,
|
|
55
|
+
endSlot: e.endSlot,
|
|
56
|
+
endSlotClassName: w
|
|
54
57
|
},
|
|
55
58
|
e.value
|
|
56
59
|
)),
|
|
57
60
|
/* @__PURE__ */ c(
|
|
58
|
-
|
|
61
|
+
f,
|
|
59
62
|
{
|
|
60
63
|
h: 2,
|
|
61
64
|
w: l.width,
|
|
62
65
|
absolute: !0,
|
|
63
66
|
bottom: -1,
|
|
64
67
|
left: l.left,
|
|
65
|
-
backgroundColor:
|
|
66
|
-
className:
|
|
67
|
-
|
|
68
|
+
backgroundColor: i.border.accent_primary,
|
|
69
|
+
className: d(
|
|
70
|
+
m({
|
|
68
71
|
transition: "left 0.2s ease, width 0.2s ease"
|
|
69
72
|
}),
|
|
70
|
-
|
|
73
|
+
v
|
|
71
74
|
)
|
|
72
75
|
}
|
|
73
76
|
)
|
|
@@ -75,7 +78,7 @@ const { color: m } = R, _ = i({
|
|
|
75
78
|
}
|
|
76
79
|
);
|
|
77
80
|
};
|
|
78
|
-
|
|
81
|
+
j.displayName = "Tabs";
|
|
79
82
|
export {
|
|
80
|
-
|
|
83
|
+
j as Tabs
|
|
81
84
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CounterColorName, CounterSize } from './Counter.types';
|
|
2
|
+
export declare const DEFAULT_MAX_NUMBER = 99;
|
|
3
|
+
export declare const COUNTER_CUTOUT_WIDTH = 1;
|
|
4
|
+
export declare const COUNTER_CUTOUT_COLOR: "var(--fill-bg-primary)";
|
|
5
|
+
export declare const COUNTER_BACKGROUND: Record<CounterColorName, string>;
|
|
6
|
+
export declare const COUNTER_HEIGHT: Record<CounterSize, number>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { theme as o } from "../../../utils/theme/index.js";
|
|
2
|
+
const { color: t } = o, n = 99, c = 1, e = t.fill.bg_primary, T = {
|
|
3
|
+
negative: t.status.negative,
|
|
4
|
+
accent: t.status.accent,
|
|
5
|
+
neutral: t.status.neutral
|
|
6
|
+
}, U = {
|
|
7
|
+
sm: 16,
|
|
8
|
+
md: 20
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
T as COUNTER_BACKGROUND,
|
|
12
|
+
e as COUNTER_CUTOUT_COLOR,
|
|
13
|
+
c as COUNTER_CUTOUT_WIDTH,
|
|
14
|
+
U as COUNTER_HEIGHT,
|
|
15
|
+
n as DEFAULT_MAX_NUMBER
|
|
16
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CounterProps } from './Counter.types';
|
|
2
|
+
/**
|
|
3
|
+
* Счётчик: число или короткий текст в цветной капсуле.
|
|
4
|
+
* @example
|
|
5
|
+
* ```tsx
|
|
6
|
+
* <Counter value={5} />
|
|
7
|
+
* <Counter value={120} maxNumber={99} colorName="accent" size="sm" />
|
|
8
|
+
* <Counter value="New" />
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function Counter({ value, maxNumber, colorName, size, withBorder, className, }: CounterProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { cx as s } from "@emotion/css";
|
|
3
|
+
import { useMemo as c } from "react";
|
|
4
|
+
import { DEFAULT_MAX_NUMBER as p, COUNTER_BACKGROUND as d, COUNTER_CUTOUT_COLOR as f, COUNTER_CUTOUT_WIDTH as u, COUNTER_HEIGHT as n } from "./Counter.const.js";
|
|
5
|
+
import { getCounterLabel as C } from "./Counter.utils.js";
|
|
6
|
+
import { counterLabelStyles as T, counterStyles as U } from "./styles.js";
|
|
7
|
+
import { Box as R } from "../../builders/Box/Box.js";
|
|
8
|
+
import { theme as h } from "../../../utils/theme/index.js";
|
|
9
|
+
import { Text as O } from "../../builders/Text/Text.js";
|
|
10
|
+
const { cornerRadius: b, spacing: x } = h;
|
|
11
|
+
function A({
|
|
12
|
+
value: r,
|
|
13
|
+
maxNumber: e = p,
|
|
14
|
+
colorName: i = "negative",
|
|
15
|
+
size: o = "md",
|
|
16
|
+
withBorder: m = !0,
|
|
17
|
+
className: a
|
|
18
|
+
}) {
|
|
19
|
+
const l = c(
|
|
20
|
+
() => C({ value: r, maxNumber: e }),
|
|
21
|
+
[r, e]
|
|
22
|
+
);
|
|
23
|
+
return /* @__PURE__ */ t(
|
|
24
|
+
R,
|
|
25
|
+
{
|
|
26
|
+
row: !0,
|
|
27
|
+
display: "inline-flex",
|
|
28
|
+
alignItems: "center",
|
|
29
|
+
justifyContent: "center",
|
|
30
|
+
flexShrink: 0,
|
|
31
|
+
h: n[o],
|
|
32
|
+
minWidth: n[o],
|
|
33
|
+
px: x.xs,
|
|
34
|
+
borderRadius: b.fullRound,
|
|
35
|
+
borderWidth: u,
|
|
36
|
+
borderStyle: "solid",
|
|
37
|
+
borderColor: m ? f : "transparent",
|
|
38
|
+
backgroundColor: d[i],
|
|
39
|
+
className: s(U, a),
|
|
40
|
+
children: /* @__PURE__ */ t(
|
|
41
|
+
O,
|
|
42
|
+
{
|
|
43
|
+
tag: "span",
|
|
44
|
+
variant: "caption-2",
|
|
45
|
+
fontWeight: "semibold",
|
|
46
|
+
colorName: "inverse",
|
|
47
|
+
whiteSpace: "nowrap",
|
|
48
|
+
center: !0,
|
|
49
|
+
className: T,
|
|
50
|
+
children: l
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
A as Counter
|
|
58
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AccentType, NegativeType, NeutralType, Size } from '../../../types/tokens.types';
|
|
2
|
+
export type CounterColorName = NegativeType | AccentType | NeutralType;
|
|
3
|
+
export type CounterSize = Extract<Size, "sm" | "md">;
|
|
4
|
+
export interface CounterProps {
|
|
5
|
+
/** Значение счётчика. Строка выводится как есть, число ограничивается через `maxNumber`. */
|
|
6
|
+
value: number | string;
|
|
7
|
+
/**
|
|
8
|
+
* Верхняя граница для числового `value`: при превышении выводится `${maxNumber}+`.
|
|
9
|
+
* `null` снимает ограничение. На строки не действует.
|
|
10
|
+
* @default 99
|
|
11
|
+
*/
|
|
12
|
+
maxNumber?: number | null;
|
|
13
|
+
/** Цветовая схема счётчика. @default "negative" */
|
|
14
|
+
colorName?: CounterColorName;
|
|
15
|
+
/** Размер счётчика: "sm" (16px) или "md" (20px). @default "md" */
|
|
16
|
+
size?: CounterSize;
|
|
17
|
+
/**
|
|
18
|
+
* Обводка цветом фона страницы. Отделяет счётчик от элемента, на который он наложен.
|
|
19
|
+
* При `false` рамка становится прозрачной, место под неё и размеры счётчика сохраняются.
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
withBorder?: boolean;
|
|
23
|
+
/** Класс для корневого элемента. Добавляется к внутренним классам, например для позиционирования снаружи. */
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface GetCounterLabelParams {
|
|
27
|
+
value: number | string;
|
|
28
|
+
maxNumber: number | null;
|
|
29
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DotColorName, DotSize } from './Dot.types';
|
|
2
|
+
export declare const DOT_CUTOUT_WIDTH = 1;
|
|
3
|
+
export declare const DOT_CUTOUT_COLOR: "var(--fill-bg-primary)";
|
|
4
|
+
export declare const DOT_BACKGROUND: Record<DotColorName, string>;
|
|
5
|
+
export declare const DOT_SIZE: Record<DotSize, number>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { theme as o } from "../../../utils/theme/index.js";
|
|
2
|
+
const { color: t } = o, e = 1, n = t.fill.bg_primary, c = {
|
|
3
|
+
negative: t.status.negative,
|
|
4
|
+
accent: t.status.accent,
|
|
5
|
+
neutral: t.status.neutral
|
|
6
|
+
}, a = {
|
|
7
|
+
sm: 6,
|
|
8
|
+
md: 8
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
c as DOT_BACKGROUND,
|
|
12
|
+
n as DOT_CUTOUT_COLOR,
|
|
13
|
+
e as DOT_CUTOUT_WIDTH,
|
|
14
|
+
a as DOT_SIZE
|
|
15
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DotProps } from './Dot.types';
|
|
2
|
+
/**
|
|
3
|
+
* Точка-индикатор без текста, например отметка непрочитанного.
|
|
4
|
+
* @example
|
|
5
|
+
* ```tsx
|
|
6
|
+
* <Dot />
|
|
7
|
+
* <Dot colorName="accent" size="sm" />
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export declare function Dot({ colorName, size, withBorder, className, }: DotProps): import("react/jsx-runtime").JSX.Element;
|