@octohirono/stitch-design-system 0.1.0 → 0.3.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.
- package/dist/components/BarChart/BarChart.d.ts +42 -0
- package/dist/components/BarChart/BarChart.js +71 -0
- package/dist/components/BarChart/bar-chart.module.js +4 -0
- package/dist/components/BarChart/index.d.ts +2 -0
- package/dist/components/Calendar/Calendar.d.ts +57 -0
- package/dist/components/Calendar/Calendar.js +83 -0
- package/dist/components/Calendar/calendar.module.js +26 -0
- package/dist/components/Calendar/index.d.ts +2 -0
- package/dist/components/ChatFile/ChatFile.d.ts +34 -0
- package/dist/components/ChatFile/ChatFile.js +71 -0
- package/dist/components/ChatFile/chat-file.module.js +12 -0
- package/dist/components/ChatFile/index.d.ts +2 -0
- package/dist/components/ChatImage/ChatImage.d.ts +31 -0
- package/dist/components/ChatImage/ChatImage.js +88 -0
- package/dist/components/ChatImage/chat-image.module.js +12 -0
- package/dist/components/ChatImage/index.d.ts +2 -0
- package/dist/components/ChatInput/ChatInput.d.ts +77 -0
- package/dist/components/ChatInput/ChatInput.js +88 -0
- package/dist/components/ChatInput/chat-input.module.js +11 -0
- package/dist/components/ChatInput/index.d.ts +2 -0
- package/dist/components/ChatList/ChatList.d.ts +58 -0
- package/dist/components/ChatList/ChatList.js +49 -0
- package/dist/components/ChatList/chat-list.module.js +7 -0
- package/dist/components/ChatList/index.d.ts +2 -0
- package/dist/components/ChatMessage/ChatMessage.d.ts +52 -0
- package/dist/components/ChatMessage/ChatMessage.js +71 -0
- package/dist/components/ChatMessage/chat-message.module.js +21 -0
- package/dist/components/ChatMessage/index.d.ts +2 -0
- package/dist/components/ChatMessageActions/ChatMessageActions.d.ts +40 -0
- package/dist/components/ChatMessageActions/ChatMessageActions.js +34 -0
- package/dist/components/ChatMessageActions/chat-message-actions.module.js +7 -0
- package/dist/components/ChatMessageActions/index.d.ts +2 -0
- package/dist/components/ChatVoice/ChatVoice.d.ts +39 -0
- package/dist/components/ChatVoice/ChatVoice.js +44 -0
- package/dist/components/ChatVoice/chat-voice.module.js +12 -0
- package/dist/components/ChatVoice/index.d.ts +2 -0
- package/dist/components/ContextMenu/ContextMenu.js +41 -34
- package/dist/components/ContextMenu/context-menu.module.js +10 -9
- package/dist/components/DatePicker/DatePicker.d.ts +60 -0
- package/dist/components/DatePicker/DatePicker.js +75 -0
- package/dist/components/DatePicker/datepicker.module.js +17 -0
- package/dist/components/DatePicker/index.d.ts +2 -0
- package/dist/components/DropdownMenu/DropdownMenu.js +45 -38
- package/dist/components/DropdownMenu/dropdown-menu.module.js +10 -9
- package/dist/components/Icon/Icon.d.ts +36 -0
- package/dist/components/Icon/Icon.js +59 -1
- package/dist/components/Image/Image.js +1 -1
- package/dist/components/Image/image.module.js +14 -14
- package/dist/components/LineChart/LineChart.d.ts +48 -0
- package/dist/components/LineChart/LineChart.js +110 -0
- package/dist/components/LineChart/index.d.ts +2 -0
- package/dist/components/LineChart/line-chart.module.js +7 -0
- package/dist/components/PieChart/PieChart.d.ts +43 -0
- package/dist/components/PieChart/PieChart.js +56 -0
- package/dist/components/PieChart/index.d.ts +2 -0
- package/dist/components/PieChart/pie-chart.module.js +7 -0
- package/dist/components/Select/Select.js +87 -83
- package/dist/components/Select/select.module.js +10 -9
- package/dist/components/Stat/Stat.d.ts +71 -0
- package/dist/components/Stat/Stat.js +66 -0
- package/dist/components/Stat/StatGroup.d.ts +14 -0
- package/dist/components/Stat/StatGroup.js +16 -0
- package/dist/components/Stat/index.d.ts +4 -0
- package/dist/components/Stat/stat.module.js +23 -0
- package/dist/components/TypingIndicator/TypingIndicator.d.ts +24 -0
- package/dist/components/TypingIndicator/TypingIndicator.js +29 -0
- package/dist/components/TypingIndicator/index.d.ts +2 -0
- package/dist/components/TypingIndicator/typing-indicator.module.js +8 -0
- package/dist/components/_internal/dataviz/ChartFrame.d.ts +20 -0
- package/dist/components/_internal/dataviz/ChartFrame.js +18 -0
- package/dist/components/_internal/dataviz/ChartTooltip.d.ts +23 -0
- package/dist/components/_internal/dataviz/ChartTooltip.js +33 -0
- package/dist/components/_internal/dataviz/chart-frame.module.js +4 -0
- package/dist/components/_internal/dataviz/chart-tooltip.module.js +11 -0
- package/dist/components/_internal/dataviz/chartColors.d.ts +12 -0
- package/dist/components/_internal/dataviz/chartColors.js +3 -0
- package/dist/components/_internal/dataviz/index.d.ts +5 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +37 -22
- package/dist/style.css +1305 -448
- package/dist/themes/seline.css +39 -0
- package/dist/themes/steep.css +37 -0
- package/package.json +9 -4
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { catColor as e } from "../_internal/dataviz/chartColors.js";
|
|
2
|
+
import { ChartFrame as t } from "../_internal/dataviz/ChartFrame.js";
|
|
3
|
+
import { ChartTooltip as n } from "../_internal/dataviz/ChartTooltip.js";
|
|
4
|
+
import r from "./line-chart.module.js";
|
|
5
|
+
import "react";
|
|
6
|
+
import i from "clsx";
|
|
7
|
+
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
8
|
+
import { Area as c, AreaChart as l, CartesianGrid as u, LabelList as d, Line as f, LineChart as p, Tooltip as m, XAxis as h, YAxis as g } from "recharts";
|
|
9
|
+
//#region packages/react/src/components/LineChart/LineChart.tsx
|
|
10
|
+
var _ = [
|
|
11
|
+
"0",
|
|
12
|
+
"6 4",
|
|
13
|
+
"2 4",
|
|
14
|
+
"10 4 2 4"
|
|
15
|
+
], v = (e) => _[(e % _.length + _.length) % _.length], y = ({ data: _, xField: y, series: b, smooth: x = !1, area: S = !1, height: C = 300, valueFormatter: w, ariaLabel: T, className: E }) => {
|
|
16
|
+
let D = x ? "monotone" : "linear", O = { fill: "var(--stitch-text-secondary)" }, k = w ? (e) => w(e) : void 0, A = (e) => {
|
|
17
|
+
let { active: t, label: r, payload: i } = e, a = i?.map((e) => ({
|
|
18
|
+
name: e.name,
|
|
19
|
+
value: w && typeof e.value == "number" ? w(e.value) : e.value,
|
|
20
|
+
color: e.color
|
|
21
|
+
}));
|
|
22
|
+
return /* @__PURE__ */ o(n, {
|
|
23
|
+
active: t,
|
|
24
|
+
label: r,
|
|
25
|
+
payload: a
|
|
26
|
+
});
|
|
27
|
+
}, j = _.length - 1, M = (e) => ({ x: t, y: n, index: i }) => i === j ? /* @__PURE__ */ o("text", {
|
|
28
|
+
x: Number(t) + 8,
|
|
29
|
+
y: Number(n),
|
|
30
|
+
dy: 4,
|
|
31
|
+
className: r.endLabel,
|
|
32
|
+
children: e
|
|
33
|
+
}) : null, N = {
|
|
34
|
+
top: 8,
|
|
35
|
+
right: 56,
|
|
36
|
+
bottom: 4,
|
|
37
|
+
left: 4
|
|
38
|
+
}, P = /* @__PURE__ */ s(a, { children: [
|
|
39
|
+
/* @__PURE__ */ o(u, {
|
|
40
|
+
stroke: "var(--stitch-border)",
|
|
41
|
+
vertical: !1
|
|
42
|
+
}),
|
|
43
|
+
/* @__PURE__ */ o(h, {
|
|
44
|
+
dataKey: y,
|
|
45
|
+
stroke: "var(--stitch-border)",
|
|
46
|
+
tick: O,
|
|
47
|
+
tickLine: !1
|
|
48
|
+
}),
|
|
49
|
+
/* @__PURE__ */ o(g, {
|
|
50
|
+
stroke: "var(--stitch-border)",
|
|
51
|
+
tick: O,
|
|
52
|
+
tickLine: !1,
|
|
53
|
+
tickFormatter: k
|
|
54
|
+
}),
|
|
55
|
+
/* @__PURE__ */ o(m, { content: A })
|
|
56
|
+
] }), F = S ? /* @__PURE__ */ s(l, {
|
|
57
|
+
data: _,
|
|
58
|
+
margin: N,
|
|
59
|
+
children: [P, b.map((t, n) => {
|
|
60
|
+
let r = e(n), i = t.name ?? t.dataKey;
|
|
61
|
+
return /* @__PURE__ */ o(c, {
|
|
62
|
+
type: D,
|
|
63
|
+
dataKey: t.dataKey,
|
|
64
|
+
name: i,
|
|
65
|
+
stroke: r,
|
|
66
|
+
strokeWidth: 2,
|
|
67
|
+
strokeDasharray: v(n),
|
|
68
|
+
fill: `color-mix(in srgb, ${r}, transparent 88%)`,
|
|
69
|
+
fillOpacity: 1,
|
|
70
|
+
dot: !1,
|
|
71
|
+
activeDot: { r: 4 },
|
|
72
|
+
isAnimationActive: !1,
|
|
73
|
+
children: /* @__PURE__ */ o(d, {
|
|
74
|
+
dataKey: t.dataKey,
|
|
75
|
+
content: M(i)
|
|
76
|
+
})
|
|
77
|
+
}, t.dataKey);
|
|
78
|
+
})]
|
|
79
|
+
}) : /* @__PURE__ */ s(p, {
|
|
80
|
+
data: _,
|
|
81
|
+
margin: N,
|
|
82
|
+
children: [P, b.map((t, n) => {
|
|
83
|
+
let r = t.name ?? t.dataKey;
|
|
84
|
+
return /* @__PURE__ */ o(f, {
|
|
85
|
+
type: D,
|
|
86
|
+
dataKey: t.dataKey,
|
|
87
|
+
name: r,
|
|
88
|
+
stroke: e(n),
|
|
89
|
+
strokeWidth: 2,
|
|
90
|
+
strokeDasharray: v(n),
|
|
91
|
+
dot: !1,
|
|
92
|
+
activeDot: { r: 4 },
|
|
93
|
+
isAnimationActive: !1,
|
|
94
|
+
children: /* @__PURE__ */ o(d, {
|
|
95
|
+
dataKey: t.dataKey,
|
|
96
|
+
content: M(r)
|
|
97
|
+
})
|
|
98
|
+
}, t.dataKey);
|
|
99
|
+
})]
|
|
100
|
+
});
|
|
101
|
+
return /* @__PURE__ */ o(t, {
|
|
102
|
+
ariaLabel: T,
|
|
103
|
+
height: C,
|
|
104
|
+
className: i(r.chart, E),
|
|
105
|
+
children: F
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
y.displayName = "LineChart";
|
|
109
|
+
//#endregion
|
|
110
|
+
export { y as LineChart };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* 饼 / 环图。扇区色只从契约分类色槽 `var(--stitch-cat-*)` 取、按序号循环,随站换肤整图跟随;
|
|
4
|
+
* 组件内零硬编码主题值、零手写内联 svg(svg 全由 recharts 出),无 emoji。`innerRadius` 挖空
|
|
5
|
+
* 中心即成环形(donut),此时可用 `centerLabel` 在中心放一个值;默认出图例(`Legend`)把
|
|
6
|
+
* 分类名列出,不只靠颜色区分(守 a11y)。整图作一张图对外——`role="img"` + `aria-label`
|
|
7
|
+
* (缺省兜底非空名)。
|
|
8
|
+
*/
|
|
9
|
+
export interface PieChartProps {
|
|
10
|
+
/** 数据源,每项一扇区(Ant charts `data` 语义) */
|
|
11
|
+
data: Record<string, unknown>[];
|
|
12
|
+
/** 扇区数值字段——决定扇区角度大小(Ant charts `angleField` 语义) */
|
|
13
|
+
angleField: string;
|
|
14
|
+
/** 扇区分类字段——作图例名与 tooltip 名(Ant charts `colorField` 语义) */
|
|
15
|
+
colorField: string;
|
|
16
|
+
/**
|
|
17
|
+
* 环形内半径占比 0–1(Ant charts `innerRadius` 语义);0 = 实心饼,>0 = 环形 donut
|
|
18
|
+
* @default 0
|
|
19
|
+
*/
|
|
20
|
+
innerRadius?: number;
|
|
21
|
+
/** 环形中心值(仅 `innerRadius` > 0 挖空后有空间显示;扇区数值的汇总等) */
|
|
22
|
+
centerLabel?: string | number;
|
|
23
|
+
/**
|
|
24
|
+
* 是否显示图例(把分类名 → 色块显式列出,作不依赖颜色的区分通道)
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
legend?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* 图表高度(px);宽度恒铺满容器
|
|
30
|
+
* @default 300
|
|
31
|
+
*/
|
|
32
|
+
height?: number;
|
|
33
|
+
/** 扇区值格式化(如货币 / 百分比);作用于 tooltip 值 */
|
|
34
|
+
valueFormatter?: (value: number) => string;
|
|
35
|
+
/** 图表整体可访问名(`role="img"` 的文本替代);缺省兜底非空名 */
|
|
36
|
+
ariaLabel?: string;
|
|
37
|
+
/** 透传外层容器类名 */
|
|
38
|
+
className?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 把数据画成饼 / 环图,扇区色走契约分类色槽、随站换肤;可挖空成环形并在中心放一个值。
|
|
42
|
+
*/
|
|
43
|
+
export declare const PieChart: React.FC<PieChartProps>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { catColor as e } from "../_internal/dataviz/chartColors.js";
|
|
2
|
+
import { ChartFrame as t } from "../_internal/dataviz/ChartFrame.js";
|
|
3
|
+
import { ChartTooltip as n } from "../_internal/dataviz/ChartTooltip.js";
|
|
4
|
+
import r from "./pie-chart.module.js";
|
|
5
|
+
import "react";
|
|
6
|
+
import i from "clsx";
|
|
7
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
8
|
+
import { Cell as s, Label as c, Legend as l, Pie as u, PieChart as d, Tooltip as f } from "recharts";
|
|
9
|
+
//#region packages/react/src/components/PieChart/PieChart.tsx
|
|
10
|
+
var p = ({ data: p, angleField: m, colorField: h, innerRadius: g = 0, centerLabel: _, legend: v = !0, height: y = 300, valueFormatter: b, ariaLabel: x, className: S }) => {
|
|
11
|
+
let C = (e) => {
|
|
12
|
+
let { active: t, payload: r } = e, i = r?.map((e) => ({
|
|
13
|
+
name: e.name,
|
|
14
|
+
value: b && typeof e.value == "number" ? b(e.value) : e.value,
|
|
15
|
+
color: e.color
|
|
16
|
+
}));
|
|
17
|
+
return /* @__PURE__ */ a(n, {
|
|
18
|
+
active: t,
|
|
19
|
+
payload: i
|
|
20
|
+
});
|
|
21
|
+
}, w = `${Math.max(0, Math.min(1, g)) * 100}%`, T = g > 0 && _ != null && _ !== "";
|
|
22
|
+
return /* @__PURE__ */ a(t, {
|
|
23
|
+
ariaLabel: x,
|
|
24
|
+
height: y,
|
|
25
|
+
className: i(r.chart, S),
|
|
26
|
+
children: /* @__PURE__ */ o(d, {
|
|
27
|
+
margin: {
|
|
28
|
+
top: 8,
|
|
29
|
+
right: 8,
|
|
30
|
+
bottom: 4,
|
|
31
|
+
left: 4
|
|
32
|
+
},
|
|
33
|
+
children: [
|
|
34
|
+
/* @__PURE__ */ a(f, { content: C }),
|
|
35
|
+
v && /* @__PURE__ */ a(l, { wrapperStyle: { color: "var(--stitch-text-primary)" } }),
|
|
36
|
+
/* @__PURE__ */ o(u, {
|
|
37
|
+
data: p,
|
|
38
|
+
dataKey: m,
|
|
39
|
+
nameKey: h,
|
|
40
|
+
innerRadius: w,
|
|
41
|
+
outerRadius: "80%",
|
|
42
|
+
stroke: "var(--stitch-bg-elevated)",
|
|
43
|
+
isAnimationActive: !1,
|
|
44
|
+
children: [p.map((t, n) => /* @__PURE__ */ a(s, { fill: e(n) }, n)), T && /* @__PURE__ */ a(c, {
|
|
45
|
+
position: "center",
|
|
46
|
+
value: _,
|
|
47
|
+
className: r.center
|
|
48
|
+
})]
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
p.displayName = "PieChart";
|
|
55
|
+
//#endregion
|
|
56
|
+
export { p as PieChart };
|
|
@@ -1,118 +1,122 @@
|
|
|
1
1
|
import { Icon as e } from "../Icon/Icon.js";
|
|
2
|
-
import t from "
|
|
3
|
-
import
|
|
4
|
-
import c from "
|
|
5
|
-
import
|
|
2
|
+
import { ScrollArea as t } from "../ScrollArea/ScrollArea.js";
|
|
3
|
+
import n from "./select.module.js";
|
|
4
|
+
import { useCallback as r, useEffect as i, useId as a, useMemo as o, useRef as s, useState as c } from "react";
|
|
5
|
+
import l from "clsx";
|
|
6
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
6
7
|
//#region packages/react/src/components/Select/Select.tsx
|
|
7
|
-
var
|
|
8
|
-
let [
|
|
9
|
-
|
|
10
|
-
if (!
|
|
8
|
+
var f = ({ options: f, value: p, defaultValue: m, onChange: h, placeholder: g = "请选择", size: _ = "middle", disabled: v = !1, className: y, style: b, "aria-label": x, "aria-labelledby": S }) => {
|
|
9
|
+
let [C, w] = c(m), T = p !== void 0, E = T ? p : C, [D, O] = c(!1), [k, A] = c(null), j = s(null), M = s(null), N = `stitch-select-${a().replace(/:/g, "")}`, P = `${N}-listbox`, F = (e) => `${N}-option-${e}`, I = f.find((e) => e.value === E), L = I ? I.label : g, R = I !== void 0, z = o(() => f.filter((e) => !e.disabled).map((e) => e.value), [f]);
|
|
10
|
+
i(() => {
|
|
11
|
+
if (!D) return;
|
|
11
12
|
let e = (e) => {
|
|
12
|
-
|
|
13
|
+
j.current && !j.current.contains(e.target) && O(!1);
|
|
13
14
|
};
|
|
14
15
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
15
|
-
}, [
|
|
16
|
-
if (
|
|
17
|
-
let e =
|
|
18
|
-
|
|
19
|
-
} else
|
|
20
|
-
}, [
|
|
21
|
-
let
|
|
22
|
-
|
|
23
|
-
}, [
|
|
24
|
-
if (!
|
|
25
|
-
let t =
|
|
26
|
-
|
|
16
|
+
}, [D]), i(() => {
|
|
17
|
+
if (D) {
|
|
18
|
+
let e = z[0] ?? null;
|
|
19
|
+
A(E != null && z.includes(E) ? E : e);
|
|
20
|
+
} else A(null);
|
|
21
|
+
}, [D]);
|
|
22
|
+
let B = r((e) => {
|
|
23
|
+
T || w(e), h?.(e), O(!1), M.current?.focus();
|
|
24
|
+
}, [T, h]), V = (e) => {
|
|
25
|
+
if (!z.length) return;
|
|
26
|
+
let t = k == null ? -1 : z.indexOf(k), n = t < 0 ? e === 1 ? 0 : z.length - 1 : (t + e + z.length) % z.length;
|
|
27
|
+
A(z[n]);
|
|
27
28
|
};
|
|
28
|
-
return /* @__PURE__ */
|
|
29
|
-
ref:
|
|
30
|
-
className:
|
|
31
|
-
style:
|
|
29
|
+
return /* @__PURE__ */ d("div", {
|
|
30
|
+
ref: j,
|
|
31
|
+
className: l(n.wrapper, v && n.disabled, y),
|
|
32
|
+
style: b,
|
|
32
33
|
onKeyDown: (e) => {
|
|
33
|
-
if (
|
|
34
|
+
if (v) return;
|
|
34
35
|
let { key: t } = e;
|
|
35
|
-
if (!
|
|
36
|
-
(t === "Enter" || t === " " || t === "ArrowDown" || t === "ArrowUp") && (e.preventDefault(),
|
|
36
|
+
if (!D) {
|
|
37
|
+
(t === "Enter" || t === " " || t === "ArrowDown" || t === "ArrowUp") && (e.preventDefault(), O(!0));
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
40
|
switch (t) {
|
|
40
41
|
case "Escape":
|
|
41
|
-
e.preventDefault(),
|
|
42
|
+
e.preventDefault(), O(!1), M.current?.focus();
|
|
42
43
|
break;
|
|
43
44
|
case "ArrowDown":
|
|
44
|
-
e.preventDefault(),
|
|
45
|
+
e.preventDefault(), V(1);
|
|
45
46
|
break;
|
|
46
47
|
case "ArrowUp":
|
|
47
|
-
e.preventDefault(),
|
|
48
|
+
e.preventDefault(), V(-1);
|
|
48
49
|
break;
|
|
49
50
|
case "Home":
|
|
50
|
-
e.preventDefault(),
|
|
51
|
+
e.preventDefault(), z.length && A(z[0]);
|
|
51
52
|
break;
|
|
52
53
|
case "End":
|
|
53
|
-
e.preventDefault(),
|
|
54
|
+
e.preventDefault(), z.length && A(z[z.length - 1]);
|
|
54
55
|
break;
|
|
55
56
|
case "Enter":
|
|
56
|
-
case " ": e.preventDefault(),
|
|
57
|
+
case " ": e.preventDefault(), k != null && B(k);
|
|
57
58
|
}
|
|
58
59
|
},
|
|
59
|
-
children: [/* @__PURE__ */
|
|
60
|
-
ref:
|
|
61
|
-
className:
|
|
62
|
-
onClick: () => !
|
|
60
|
+
children: [/* @__PURE__ */ d("div", {
|
|
61
|
+
ref: M,
|
|
62
|
+
className: l(n.trigger, n[_], D && n.open),
|
|
63
|
+
onClick: () => !v && O((e) => !e),
|
|
63
64
|
role: "combobox",
|
|
64
65
|
"aria-haspopup": "listbox",
|
|
65
|
-
"aria-expanded":
|
|
66
|
-
"aria-controls":
|
|
67
|
-
"aria-activedescendant":
|
|
68
|
-
"aria-disabled":
|
|
69
|
-
"aria-label":
|
|
70
|
-
"aria-labelledby":
|
|
71
|
-
tabIndex:
|
|
72
|
-
children: [/* @__PURE__ */
|
|
73
|
-
className:
|
|
74
|
-
children:
|
|
75
|
-
}), /* @__PURE__ */
|
|
66
|
+
"aria-expanded": D,
|
|
67
|
+
"aria-controls": D ? P : void 0,
|
|
68
|
+
"aria-activedescendant": D && k != null ? F(k) : void 0,
|
|
69
|
+
"aria-disabled": v || void 0,
|
|
70
|
+
"aria-label": x,
|
|
71
|
+
"aria-labelledby": S,
|
|
72
|
+
tabIndex: v ? -1 : 0,
|
|
73
|
+
children: [/* @__PURE__ */ u("span", {
|
|
74
|
+
className: R ? n.value : n.placeholder,
|
|
75
|
+
children: L
|
|
76
|
+
}), /* @__PURE__ */ u(e, {
|
|
76
77
|
name: "chevron-down",
|
|
77
78
|
size: "1em",
|
|
78
|
-
className:
|
|
79
|
+
className: l(n.arrow, D && n.arrowOpen)
|
|
79
80
|
})]
|
|
80
|
-
}),
|
|
81
|
-
className:
|
|
81
|
+
}), D && /* @__PURE__ */ u("div", {
|
|
82
|
+
className: n.dropdown,
|
|
82
83
|
role: "listbox",
|
|
83
|
-
id:
|
|
84
|
-
"aria-label":
|
|
85
|
-
"aria-labelledby":
|
|
86
|
-
"aria-activedescendant":
|
|
87
|
-
children:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
children:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
84
|
+
id: P,
|
|
85
|
+
"aria-label": x,
|
|
86
|
+
"aria-labelledby": S,
|
|
87
|
+
"aria-activedescendant": k == null ? void 0 : F(k),
|
|
88
|
+
children: /* @__PURE__ */ u(t, {
|
|
89
|
+
className: n.dropdownScroll,
|
|
90
|
+
children: f.map((t) => {
|
|
91
|
+
let r = E === t.value, i = k === t.value;
|
|
92
|
+
return /* @__PURE__ */ d("div", {
|
|
93
|
+
id: F(t.value),
|
|
94
|
+
role: "option",
|
|
95
|
+
"aria-selected": r,
|
|
96
|
+
"aria-disabled": t.disabled || void 0,
|
|
97
|
+
className: l(n.option, {
|
|
98
|
+
[n.optionActive]: i,
|
|
99
|
+
[n.optionSelected]: r,
|
|
100
|
+
[n.optionDisabled]: t.disabled
|
|
101
|
+
}),
|
|
102
|
+
onClick: () => !t.disabled && B(t.value),
|
|
103
|
+
onMouseEnter: () => {
|
|
104
|
+
t.disabled || A(t.value);
|
|
105
|
+
},
|
|
106
|
+
children: [/* @__PURE__ */ u("span", {
|
|
107
|
+
className: n.optionLabel,
|
|
108
|
+
children: t.label
|
|
109
|
+
}), r && /* @__PURE__ */ u(e, {
|
|
110
|
+
name: "check",
|
|
111
|
+
size: "1em",
|
|
112
|
+
className: n.checkMark
|
|
113
|
+
})]
|
|
114
|
+
}, String(t.value));
|
|
115
|
+
})
|
|
112
116
|
})
|
|
113
117
|
})]
|
|
114
118
|
});
|
|
115
119
|
};
|
|
116
|
-
|
|
120
|
+
f.displayName = "Select";
|
|
117
121
|
//#endregion
|
|
118
|
-
export {
|
|
122
|
+
export { f as Select };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region packages/react/src/components/Select/select.module.less
|
|
2
|
-
var e = "
|
|
2
|
+
var e = "_wrapper_i7k60_1", t = "_trigger_i7k60_8", n = "_open_i7k60_30", r = "_small_i7k60_33", i = "_middle_i7k60_38", a = "_large_i7k60_43", o = "_value_i7k60_48", s = "_placeholder_i7k60_55", c = "_arrow_i7k60_62", l = "_arrowOpen_i7k60_67", u = "_dropdown_i7k60_71", d = "_dropdownFadeIn_i7k60_1", f = "_dropdownScroll_i7k60_86", p = "_option_i7k60_102", m = "_optionLabel_i7k60_115", h = "_optionActive_i7k60_119", g = "_optionSelected_i7k60_122", _ = "_checkMark_i7k60_126", v = "_optionDisabled_i7k60_130", y = "_disabled_i7k60_137", b = {
|
|
3
3
|
wrapper: e,
|
|
4
4
|
trigger: t,
|
|
5
5
|
open: n,
|
|
@@ -12,13 +12,14 @@ var e = "_wrapper_13o0n_1", t = "_trigger_13o0n_8", n = "_open_13o0n_30", r = "_
|
|
|
12
12
|
arrowOpen: l,
|
|
13
13
|
dropdown: u,
|
|
14
14
|
dropdownFadeIn: d,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
dropdownScroll: f,
|
|
16
|
+
option: p,
|
|
17
|
+
optionLabel: m,
|
|
18
|
+
optionActive: h,
|
|
19
|
+
optionSelected: g,
|
|
20
|
+
checkMark: _,
|
|
21
|
+
optionDisabled: v,
|
|
22
|
+
disabled: y
|
|
22
23
|
};
|
|
23
24
|
//#endregion
|
|
24
|
-
export { c as arrow, l as arrowOpen,
|
|
25
|
+
export { c as arrow, l as arrowOpen, _ as checkMark, b as default, y as disabled, u as dropdown, d as dropdownFadeIn, f as dropdownScroll, a as large, i as middle, n as open, p as option, h as optionActive, v as optionDisabled, m as optionLabel, g as optionSelected, s as placeholder, r as small, t as trigger, o as value, e as wrapper };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** 趋势方向:值往哪走(好/坏由 direction + trendReversed 共同决定,不等于方向本身)。 */
|
|
3
|
+
export type StatTrendDirection = 'up' | 'down';
|
|
4
|
+
/** 趋势描述:一个变化量 + 方向。方向缺省时按 value 正负推断(≥0 视为 up)。 */
|
|
5
|
+
export interface StatTrend {
|
|
6
|
+
/** 变化量(展示为绝对值,方向由箭头/配色承载) */
|
|
7
|
+
value: number;
|
|
8
|
+
/** 方向;缺省按 value 正负推断 */
|
|
9
|
+
direction?: StatTrendDirection;
|
|
10
|
+
}
|
|
11
|
+
/** 状态点语义色调(点色走对应角色变量,缺省 neutral = 弱化中性)。 */
|
|
12
|
+
export type StatStatusTone = 'neutral' | 'success' | 'danger' | 'warning' | 'info';
|
|
13
|
+
/** 状态点:一枚 <Icon name="dot"> + 文案(如 ○ 0 online)。 */
|
|
14
|
+
export interface StatStatus {
|
|
15
|
+
/** 状态文案 */
|
|
16
|
+
text: React.ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* 点的语义色调(走角色变量)
|
|
19
|
+
* @default 'neutral'
|
|
20
|
+
*/
|
|
21
|
+
tone?: StatStatusTone;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 单个指标块:标签 + 大值(可带 prefix/suffix/精度/千分位/自定义 formatter)+ 可选趋势 /
|
|
25
|
+
* 副说明 / 状态点。展示 props 借 Ant `Statistic` 语义。
|
|
26
|
+
*
|
|
27
|
+
* 跨-prop 注意事项:
|
|
28
|
+
* - **只读角色变量**:趋势好/坏色只走 `var(--stitch-success)` / `var(--stitch-danger)`,
|
|
29
|
+
* 状态点色 / 分隔线走 `var(--stitch-*)`——组件内零硬编码绿红、零主题值。
|
|
30
|
+
* - **趋势方向经 `<Icon>`**(内置 `arrow-up-right` / `arrow-down-right`),**禁**内联 svg /
|
|
31
|
+
* emoji / Unicode 箭头。方向(箭头形状)是不依赖颜色的区分通道,配色只叠加好/坏语义。
|
|
32
|
+
* - **`trendReversed`**:给「跌是好事」的指标(Bounce Rate 等)翻转好/坏配色——方向不变、
|
|
33
|
+
* 语义色对调。
|
|
34
|
+
* - **`formatter` 优先**:给出时接管全部数值格式化,`precision` / `groupSeparator` 不再生效。
|
|
35
|
+
* - **Accessibility**:有 `title` 时整块为 `role="group"` + `aria-labelledby`(可访问名 =
|
|
36
|
+
* 标签文案);趋势箭头为装饰(`aria-hidden`),语义由数值文案与箭头形状承载。
|
|
37
|
+
*/
|
|
38
|
+
export interface StatProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title' | 'prefix'> {
|
|
39
|
+
/** 指标标签(如 Unique Visitors) */
|
|
40
|
+
title?: React.ReactNode;
|
|
41
|
+
/** 指标值。number 走内置格式化;string 原样展示 */
|
|
42
|
+
value: string | number;
|
|
43
|
+
/** 小数精度(仅 number 值、未给 formatter 时生效) */
|
|
44
|
+
precision?: number;
|
|
45
|
+
/** 值前缀(如 `$`) */
|
|
46
|
+
prefix?: React.ReactNode;
|
|
47
|
+
/** 值后缀(如 `%`) */
|
|
48
|
+
suffix?: React.ReactNode;
|
|
49
|
+
/** 自定义格式化;给出时接管数值格式化,precision / groupSeparator 失效 */
|
|
50
|
+
formatter?: (value: string | number) => React.ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* 千分位分隔符(仅 number 值、未给 formatter 时生效)
|
|
53
|
+
* @default ','
|
|
54
|
+
*/
|
|
55
|
+
groupSeparator?: string;
|
|
56
|
+
/** 趋势涨/跌 */
|
|
57
|
+
trend?: StatTrend;
|
|
58
|
+
/**
|
|
59
|
+
* 反转趋势好坏(「跌是好事」的指标,如 Bounce Rate)
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
trendReversed?: boolean;
|
|
63
|
+
/** 副说明(如 vs previous 30 days) */
|
|
64
|
+
caption?: React.ReactNode;
|
|
65
|
+
/** 状态点 + 文案 */
|
|
66
|
+
status?: StatStatus;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 把一个指标画成「标签 + 大值 + 趋势 + 副说明 + 状态点」,趋势色走语义角色变量、方向经 <Icon>。
|
|
70
|
+
*/
|
|
71
|
+
export declare const Stat: React.FC<StatProps>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Icon as e } from "../Icon/Icon.js";
|
|
2
|
+
import t from "./stat.module.js";
|
|
3
|
+
import { useId as n } from "react";
|
|
4
|
+
import r from "clsx";
|
|
5
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
|
+
//#region packages/react/src/components/Stat/Stat.tsx
|
|
7
|
+
function o(e, t, n) {
|
|
8
|
+
let [r, i] = (t == null ? String(e) : e.toFixed(t)).split("."), a = r.startsWith("-") ? "-" : "", o = (a ? r.slice(1) : r).replace(/\B(?=(\d{3})+(?!\d))/g, n);
|
|
9
|
+
return i == null ? `${a}${o}` : `${a}${o}.${i}`;
|
|
10
|
+
}
|
|
11
|
+
var s = ({ title: s, value: c, precision: l, prefix: u, suffix: d, formatter: f, groupSeparator: p = ",", trend: m, trendReversed: h = !1, caption: g, status: _, className: v, ...y }) => {
|
|
12
|
+
let b = n(), x = f ? f(c) : typeof c == "number" ? o(c, l, p) : c, S = m?.direction ?? ((m?.value ?? 0) >= 0 ? "up" : "down"), C = h ? S === "down" : S === "up";
|
|
13
|
+
return /* @__PURE__ */ a("div", {
|
|
14
|
+
className: r(t.stat, v),
|
|
15
|
+
...s == null ? null : {
|
|
16
|
+
role: "group",
|
|
17
|
+
"aria-labelledby": b
|
|
18
|
+
},
|
|
19
|
+
...y,
|
|
20
|
+
children: [
|
|
21
|
+
s != null && /* @__PURE__ */ i("div", {
|
|
22
|
+
id: b,
|
|
23
|
+
className: t["stat-title"],
|
|
24
|
+
children: s
|
|
25
|
+
}),
|
|
26
|
+
/* @__PURE__ */ a("div", {
|
|
27
|
+
className: t["stat-value-row"],
|
|
28
|
+
children: [/* @__PURE__ */ a("div", {
|
|
29
|
+
className: t["stat-value"],
|
|
30
|
+
children: [
|
|
31
|
+
u != null && /* @__PURE__ */ i("span", {
|
|
32
|
+
className: t["stat-prefix"],
|
|
33
|
+
children: u
|
|
34
|
+
}),
|
|
35
|
+
/* @__PURE__ */ i("span", { children: x }),
|
|
36
|
+
d != null && /* @__PURE__ */ i("span", {
|
|
37
|
+
className: t["stat-suffix"],
|
|
38
|
+
children: d
|
|
39
|
+
})
|
|
40
|
+
]
|
|
41
|
+
}), m != null && /* @__PURE__ */ a("span", {
|
|
42
|
+
className: r(t["stat-trend"], C ? t["stat-trend-positive"] : t["stat-trend-negative"]),
|
|
43
|
+
children: [/* @__PURE__ */ i(e, {
|
|
44
|
+
name: S === "up" ? "arrow-up-right" : "arrow-down-right",
|
|
45
|
+
size: "1em"
|
|
46
|
+
}), Math.abs(m.value)]
|
|
47
|
+
})]
|
|
48
|
+
}),
|
|
49
|
+
g != null && /* @__PURE__ */ i("div", {
|
|
50
|
+
className: t["stat-caption"],
|
|
51
|
+
children: g
|
|
52
|
+
}),
|
|
53
|
+
_ != null && /* @__PURE__ */ a("div", {
|
|
54
|
+
className: t["stat-status"],
|
|
55
|
+
children: [/* @__PURE__ */ i(e, {
|
|
56
|
+
name: "dot",
|
|
57
|
+
size: "0.6em",
|
|
58
|
+
className: t[`stat-dot-${_.tone ?? "neutral"}`]
|
|
59
|
+
}), _.text]
|
|
60
|
+
})
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
s.displayName = "Stat";
|
|
65
|
+
//#endregion
|
|
66
|
+
export { s as Stat };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* 一排指标:把每个子项裹进一格,相邻格之间用发丝线 `var(--stitch-border)` 竖线分隔(首项不带)。
|
|
4
|
+
*
|
|
5
|
+
* 跨-prop 注意事项:
|
|
6
|
+
* - **分隔线只走角色变量** `var(--stitch-border)` + `var(--stitch-border-width)`——零硬编码。
|
|
7
|
+
* - 子项各自成格、等高对齐;换行时靠 flex-wrap,格内间距走 `var(--stitch-spacing-*)`。
|
|
8
|
+
*/
|
|
9
|
+
export interface StatGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
10
|
+
/** 一排指标子项(通常是 `<Stat>`) */
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/** 把一排指标横排,相邻项之间以发丝线分隔。 */
|
|
14
|
+
export declare const StatGroup: React.FC<StatGroupProps>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import e from "./stat.module.js";
|
|
2
|
+
import t from "react";
|
|
3
|
+
import n from "clsx";
|
|
4
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
5
|
+
//#region packages/react/src/components/Stat/StatGroup.tsx
|
|
6
|
+
var i = ({ children: i, className: a, ...o }) => /* @__PURE__ */ r("div", {
|
|
7
|
+
className: n(e.group, a),
|
|
8
|
+
...o,
|
|
9
|
+
children: t.Children.map(i, (t) => t == null || t === !1 ? t : /* @__PURE__ */ r("div", {
|
|
10
|
+
className: e["group-item"],
|
|
11
|
+
children: t
|
|
12
|
+
}))
|
|
13
|
+
});
|
|
14
|
+
i.displayName = "StatGroup";
|
|
15
|
+
//#endregion
|
|
16
|
+
export { i as StatGroup };
|