@octohirono/stitch-design-system 0.1.0 → 0.2.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/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/Icon/Icon.d.ts +16 -0
- package/dist/components/Icon/Icon.js +26 -1
- 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/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/_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 +12 -0
- package/dist/index.js +28 -21
- package/dist/style.css +441 -46
- package/dist/themes/seline.css +39 -0
- package/dist/themes/steep.css +37 -0
- package/package.json +9 -4
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** 单条系列:从每行数据里取哪个字段、显示成什么名。 */
|
|
3
|
+
export interface BarChartSeries {
|
|
4
|
+
/** 该系列在数据项里取值的字段名 */
|
|
5
|
+
dataKey: string;
|
|
6
|
+
/** 系列显示名(tooltip / 图例);缺省用 `dataKey` */
|
|
7
|
+
name?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 柱状图。系列色只从契约分类色槽 `var(--stitch-cat-*)` 取、按序号循环,随站换肤整图跟随;
|
|
11
|
+
* 组件内零硬编码主题值、零手写内联 svg(svg 全由 recharts 出),无 emoji。多系列默认分组并排,
|
|
12
|
+
* `stack` 开启则堆叠成一柱;多系列另出图例(`Legend`)把系列名列出,不只靠颜色区分(守 a11y)。
|
|
13
|
+
* 整图作一张图对外——`role="img"` + `aria-label`(缺省兜底非空名)。
|
|
14
|
+
*/
|
|
15
|
+
export interface BarChartProps {
|
|
16
|
+
/** 数据源,每项一行记录(Ant charts `data` 语义) */
|
|
17
|
+
data: Record<string, unknown>[];
|
|
18
|
+
/** x 轴取值字段名(Ant charts `xField` 语义) */
|
|
19
|
+
xField: string;
|
|
20
|
+
/** 一条或多条系列(各取一个 y 字段) */
|
|
21
|
+
series: BarChartSeries[];
|
|
22
|
+
/**
|
|
23
|
+
* 多系列堆叠成一柱(Ant charts `isStack` 语义);关闭时多系列分组并排
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
stack?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 图表高度(px);宽度恒铺满容器
|
|
29
|
+
* @default 300
|
|
30
|
+
*/
|
|
31
|
+
height?: number;
|
|
32
|
+
/** y 值格式化(如货币);作用于坐标轴刻度与 tooltip 值 */
|
|
33
|
+
valueFormatter?: (value: number) => string;
|
|
34
|
+
/** 图表整体可访问名(`role="img"` 的文本替代);缺省兜底非空名 */
|
|
35
|
+
ariaLabel?: string;
|
|
36
|
+
/** 透传外层容器类名 */
|
|
37
|
+
className?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 把数据画成柱状(单 / 多系列,可堆叠),系列色走契约分类色槽、随站换肤。
|
|
41
|
+
*/
|
|
42
|
+
export declare const BarChart: React.FC<BarChartProps>;
|
|
@@ -0,0 +1,71 @@
|
|
|
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 "./bar-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 { Bar as s, BarChart as c, CartesianGrid as l, Legend as u, Tooltip as d, XAxis as f, YAxis as p } from "recharts";
|
|
9
|
+
//#region packages/react/src/components/BarChart/BarChart.tsx
|
|
10
|
+
var m = ({ data: m, xField: h, series: g, stack: _ = !1, height: v = 300, valueFormatter: y, ariaLabel: b, className: x }) => {
|
|
11
|
+
let S = { fill: "var(--stitch-text-secondary)" }, C = y ? (e) => y(e) : void 0, w = (e) => {
|
|
12
|
+
let { active: t, label: r, payload: i } = e, o = i?.map((e) => ({
|
|
13
|
+
name: e.name,
|
|
14
|
+
value: y && typeof e.value == "number" ? y(e.value) : e.value,
|
|
15
|
+
color: e.color
|
|
16
|
+
}));
|
|
17
|
+
return /* @__PURE__ */ a(n, {
|
|
18
|
+
active: t,
|
|
19
|
+
label: r,
|
|
20
|
+
payload: o
|
|
21
|
+
});
|
|
22
|
+
}, T = _ ? "stack" : void 0, E = g.length > 1;
|
|
23
|
+
return /* @__PURE__ */ a(t, {
|
|
24
|
+
ariaLabel: b,
|
|
25
|
+
height: v,
|
|
26
|
+
className: i(r.chart, x),
|
|
27
|
+
children: /* @__PURE__ */ o(c, {
|
|
28
|
+
data: m,
|
|
29
|
+
margin: {
|
|
30
|
+
top: 8,
|
|
31
|
+
right: 8,
|
|
32
|
+
bottom: 4,
|
|
33
|
+
left: 4
|
|
34
|
+
},
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ a(l, {
|
|
37
|
+
stroke: "var(--stitch-border)",
|
|
38
|
+
vertical: !1
|
|
39
|
+
}),
|
|
40
|
+
/* @__PURE__ */ a(f, {
|
|
41
|
+
dataKey: h,
|
|
42
|
+
stroke: "var(--stitch-border)",
|
|
43
|
+
tick: S,
|
|
44
|
+
tickLine: !1
|
|
45
|
+
}),
|
|
46
|
+
/* @__PURE__ */ a(p, {
|
|
47
|
+
stroke: "var(--stitch-border)",
|
|
48
|
+
tick: S,
|
|
49
|
+
tickLine: !1,
|
|
50
|
+
tickFormatter: C
|
|
51
|
+
}),
|
|
52
|
+
/* @__PURE__ */ a(d, {
|
|
53
|
+
content: w,
|
|
54
|
+
cursor: { fill: "color-mix(in srgb, var(--stitch-text-primary), transparent 92%)" }
|
|
55
|
+
}),
|
|
56
|
+
E && /* @__PURE__ */ a(u, { wrapperStyle: { color: "var(--stitch-text-primary)" } }),
|
|
57
|
+
g.map((t, n) => /* @__PURE__ */ a(s, {
|
|
58
|
+
dataKey: t.dataKey,
|
|
59
|
+
name: t.name ?? t.dataKey,
|
|
60
|
+
fill: e(n),
|
|
61
|
+
stackId: T,
|
|
62
|
+
radius: 0,
|
|
63
|
+
isAnimationActive: !1
|
|
64
|
+
}, t.dataKey))
|
|
65
|
+
]
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
m.displayName = "BarChart";
|
|
70
|
+
//#endregion
|
|
71
|
+
export { m as BarChart };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type CalendarMode = 'single' | 'range';
|
|
3
|
+
/** 顶部年月区形态:`'label'` 静态标题;`'dropdown'` 月/年可点下拉(快速跳月跳年) */
|
|
4
|
+
export type CalendarCaptionLayout = 'label' | 'dropdown';
|
|
5
|
+
/** 日期范围:`from` 起点、`to` 终点(range 模式的取值形态) */
|
|
6
|
+
export interface DateRange {
|
|
7
|
+
from?: Date;
|
|
8
|
+
to?: Date;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 内联日历网格(react-day-picker 引擎):一次支持 `mode="single"`(单选)与 `mode="range"`
|
|
12
|
+
* (范围);月份网格、方向键导航、ARIA grid(`role="grid"`、日按钮可及名、翻月按钮可及名)
|
|
13
|
+
* 全由引擎兜底,上皮只读角色变量随换肤变化。
|
|
14
|
+
*
|
|
15
|
+
* 跨-prop 注意事项:
|
|
16
|
+
* - **取值随 `mode` 变形**:`single` 下 `value`/`defaultValue` 是 `Date`、`onChange` 收
|
|
17
|
+
* `Date | undefined`;`range` 下它们是 {@link DateRange}(`{from,to}`)、`onChange` 收
|
|
18
|
+
* `DateRange | undefined`。切 mode 时同步换掉取值形态。
|
|
19
|
+
* - **受控/非受控双模式**:给 `value` 由父管(配 `onChange` 回写),只给 `defaultValue`
|
|
20
|
+
* 组件自管;两者互斥优先取 `value`。
|
|
21
|
+
* - **禁用某些日期**用 `disabledDate(date) => boolean`(Ant 语义),命中的日按钮 `disabled`、
|
|
22
|
+
* 键盘与点击都跳过;整块只读用 `disabled`(把所有日期禁掉)。
|
|
23
|
+
* - **面 = 角色变量**:选中日 `--stitch-accent` + `--stitch-accent-text`,范围中段
|
|
24
|
+
* `--stitch-bg-accent`(日按钮铺满整格,底色与端点框边到边对齐、不出头),今天描
|
|
25
|
+
* `--stitch-border-strong`、hover 落 `--stitch-bg-card`、禁用走 `--stitch-text-disabled`;
|
|
26
|
+
* 翻月箭头一律经 `<Icon>`(`chevron-left`/`chevron-right`),无裸 svg / Unicode 符号。
|
|
27
|
+
* - **`captionLayout="dropdown"`(默认)** 顶部月/年为可点下拉,快速跳月跳年(原生 `<select>`
|
|
28
|
+
* 兜键盘与可及名);传 `'label'` 退回静态标题。年份范围默认「今年往前 100 年」,用
|
|
29
|
+
* `startMonth`/`endMonth` 收窄。
|
|
30
|
+
*/
|
|
31
|
+
export interface CalendarProps {
|
|
32
|
+
/** 选择模式:单日或范围 @default 'single' */
|
|
33
|
+
mode?: CalendarMode;
|
|
34
|
+
/** 受控选中值(`single`→`Date`,`range`→`DateRange`) */
|
|
35
|
+
value?: Date | DateRange;
|
|
36
|
+
/** 非受控初始选中值(`single`→`Date`,`range`→`DateRange`) */
|
|
37
|
+
defaultValue?: Date | DateRange;
|
|
38
|
+
/** 选中变化回调(`single`→`Date | undefined`,`range`→`DateRange | undefined`) */
|
|
39
|
+
onChange?: (value: Date | DateRange | undefined) => void;
|
|
40
|
+
/** 逐日禁用判定:返回 `true` 的日期不可选 */
|
|
41
|
+
disabledDate?: (date: Date) => boolean;
|
|
42
|
+
/** 整块禁用(所有日期不可选) @default false */
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
/** 首屏展示的月份(不给则据选中值 / 当月) */
|
|
45
|
+
defaultMonth?: Date;
|
|
46
|
+
/** 顶部年月区形态:`'dropdown'` 可点选月 / 年,`'label'` 静态标题 @default 'dropdown' */
|
|
47
|
+
captionLayout?: CalendarCaptionLayout;
|
|
48
|
+
/** dropdown 年份下限(不给默认今年往前 100 年) */
|
|
49
|
+
startMonth?: Date;
|
|
50
|
+
/** dropdown 年份上限(不给默认今年年底) */
|
|
51
|
+
endMonth?: Date;
|
|
52
|
+
/** 日历网格的可访问名 */
|
|
53
|
+
'aria-label'?: string;
|
|
54
|
+
/** 自定义类名(挂到日历根节点) */
|
|
55
|
+
className?: string;
|
|
56
|
+
}
|
|
57
|
+
export declare const Calendar: React.FC<CalendarProps>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Icon as e } from "../Icon/Icon.js";
|
|
2
|
+
import { Select as t } from "../Select/Select.js";
|
|
3
|
+
import n from "./calendar.module.js";
|
|
4
|
+
import { useCallback as r, useState as i } from "react";
|
|
5
|
+
import a from "clsx";
|
|
6
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
7
|
+
import { DayPicker as s } from "react-day-picker";
|
|
8
|
+
//#region packages/react/src/components/Calendar/Calendar.tsx
|
|
9
|
+
var c = ({ orientation: t }) => /* @__PURE__ */ o(e, {
|
|
10
|
+
name: t === "left" ? "chevron-left" : t === "right" ? "chevron-right" : "chevron-down",
|
|
11
|
+
size: 18
|
|
12
|
+
}), l = ({ options: e, value: r, onChange: i, disabled: s, "aria-label": c }) => {
|
|
13
|
+
let l = typeof c == "string" && /year/i.test(c);
|
|
14
|
+
return /* @__PURE__ */ o(t, {
|
|
15
|
+
size: "small",
|
|
16
|
+
className: a(n.captionSelect, l && n.captionYear),
|
|
17
|
+
options: (e ?? []).map((e) => ({
|
|
18
|
+
label: e.label,
|
|
19
|
+
value: e.value,
|
|
20
|
+
disabled: e.disabled
|
|
21
|
+
})),
|
|
22
|
+
value: r == null ? void 0 : Number(r),
|
|
23
|
+
onChange: (e) => i?.({ target: { value: String(e) } }),
|
|
24
|
+
disabled: s,
|
|
25
|
+
"aria-label": typeof c == "string" ? c : void 0
|
|
26
|
+
});
|
|
27
|
+
}, u = {
|
|
28
|
+
root: n.root,
|
|
29
|
+
months: n.months,
|
|
30
|
+
month: n.month,
|
|
31
|
+
month_caption: n.caption,
|
|
32
|
+
caption_label: n.captionLabel,
|
|
33
|
+
nav: n.nav,
|
|
34
|
+
button_previous: n.navButton,
|
|
35
|
+
button_next: n.navButton,
|
|
36
|
+
dropdowns: n.dropdowns,
|
|
37
|
+
month_grid: n.grid,
|
|
38
|
+
weekdays: n.weekdays,
|
|
39
|
+
weekday: n.weekday,
|
|
40
|
+
week: n.week,
|
|
41
|
+
day: n.day,
|
|
42
|
+
day_button: n.dayButton,
|
|
43
|
+
today: n.today,
|
|
44
|
+
selected: n.selected,
|
|
45
|
+
range_start: n.rangeStart,
|
|
46
|
+
range_middle: n.rangeMiddle,
|
|
47
|
+
range_end: n.rangeEnd,
|
|
48
|
+
outside: n.outside,
|
|
49
|
+
disabled: n.disabled,
|
|
50
|
+
hidden: n.hidden,
|
|
51
|
+
focused: n.focused
|
|
52
|
+
}, d = ({ mode: e = "single", value: t, defaultValue: n, onChange: d, disabledDate: f, disabled: p = !1, defaultMonth: m, captionLayout: h = "dropdown", startMonth: g, endMonth: _, className: v, "aria-label": y }) => {
|
|
53
|
+
let b = t !== void 0, [x, S] = i(n), C = b ? t : x, w = r((e) => {
|
|
54
|
+
b || S(e), d?.(e);
|
|
55
|
+
}, [b, d]), T = (/* @__PURE__ */ new Date()).getFullYear(), E = h === "dropdown" ? g ?? new Date(T - 100, 0, 1) : g, D = h === "dropdown" ? _ ?? new Date(T + 10, 11, 31) : _, O = {
|
|
56
|
+
classNames: u,
|
|
57
|
+
components: {
|
|
58
|
+
Chevron: c,
|
|
59
|
+
Dropdown: l
|
|
60
|
+
},
|
|
61
|
+
disabled: p ? !0 : f,
|
|
62
|
+
defaultMonth: m,
|
|
63
|
+
captionLayout: h,
|
|
64
|
+
startMonth: E,
|
|
65
|
+
endMonth: D,
|
|
66
|
+
"aria-label": y,
|
|
67
|
+
className: a(v)
|
|
68
|
+
};
|
|
69
|
+
return e === "range" ? /* @__PURE__ */ o(s, {
|
|
70
|
+
mode: "range",
|
|
71
|
+
selected: C,
|
|
72
|
+
onSelect: (e) => w(e ?? void 0),
|
|
73
|
+
...O
|
|
74
|
+
}) : /* @__PURE__ */ o(s, {
|
|
75
|
+
mode: "single",
|
|
76
|
+
selected: C,
|
|
77
|
+
onSelect: (e) => w(e ?? void 0),
|
|
78
|
+
...O
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
d.displayName = "Calendar";
|
|
82
|
+
//#endregion
|
|
83
|
+
export { d as Calendar };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region packages/react/src/components/Calendar/calendar.module.less
|
|
2
|
+
var e = "_root_de6fy_1", t = "_months_de6fy_11", n = "_caption_de6fy_14", r = "_captionLabel_de6fy_21", i = "_nav_de6fy_25", a = "_navButton_de6fy_34", o = "_dropdowns_de6fy_60", s = "_captionSelect_de6fy_66", c = "_captionYear_de6fy_69", l = "_grid_de6fy_72", u = "_weekday_de6fy_75", d = "_day_de6fy_83", f = "_dayButton_de6fy_90", p = "_today_de6fy_116", m = "_selected_de6fy_116", h = "_rangeStart_de6fy_116", g = "_rangeEnd_de6fy_116", _ = "_outside_de6fy_120", v = "_disabled_de6fy_123", y = "_hidden_de6fy_130", b = "_rangeMiddle_de6fy_140", x = {
|
|
3
|
+
root: e,
|
|
4
|
+
months: t,
|
|
5
|
+
caption: n,
|
|
6
|
+
captionLabel: r,
|
|
7
|
+
nav: i,
|
|
8
|
+
navButton: a,
|
|
9
|
+
dropdowns: o,
|
|
10
|
+
captionSelect: s,
|
|
11
|
+
captionYear: c,
|
|
12
|
+
grid: l,
|
|
13
|
+
weekday: u,
|
|
14
|
+
day: d,
|
|
15
|
+
dayButton: f,
|
|
16
|
+
today: p,
|
|
17
|
+
selected: m,
|
|
18
|
+
rangeStart: h,
|
|
19
|
+
rangeEnd: g,
|
|
20
|
+
outside: _,
|
|
21
|
+
disabled: v,
|
|
22
|
+
hidden: y,
|
|
23
|
+
rangeMiddle: b
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { n as caption, r as captionLabel, s as captionSelect, c as captionYear, d as day, f as dayButton, x as default, v as disabled, o as dropdowns, l as grid, y as hidden, t as months, i as nav, a as navButton, _ as outside, g as rangeEnd, b as rangeMiddle, h as rangeStart, e as root, m as selected, p as today, u as weekday };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type CalendarMode, type CalendarCaptionLayout, type DateRange } from '../Calendar';
|
|
3
|
+
export type DatePickerSize = 'small' | 'middle' | 'large';
|
|
4
|
+
/**
|
|
5
|
+
* 日期选择器(Ant `DatePicker` / `RangePicker` 语义):字段触发器 + 复用现有
|
|
6
|
+
* {@link Popover} 弹出内联 {@link Calendar}(不另造浮层)。`mode="single"` 单日、
|
|
7
|
+
* `mode="range"` 范围(`Jul 28 – Aug 26` 的范围触发器)。
|
|
8
|
+
*
|
|
9
|
+
* 跨-prop 注意事项:
|
|
10
|
+
* - **取值随 `mode` 变形**(同 Calendar):`single`→`Date`;`range`→{@link DateRange}
|
|
11
|
+
* (`{from,to}`)。`onChange` 同步收对应形态或 `undefined`(清除时)。
|
|
12
|
+
* - **受控/非受控双开关**:取值 `value`/`defaultValue`/`onChange`(Ant v5 取值约定)与浮层
|
|
13
|
+
* `open`/`onOpenChange`(Ant v5 气泡约定)各自独立支持受控与非受控。
|
|
14
|
+
* - **`allowClear`(默认开)** 有值且未禁用时在字段尾部显示清除按钮(走 `<Icon name="close">`、
|
|
15
|
+
* 原生 `<button>`、`clearAriaLabel` 定可及名);点击清空且不冒泡打开浮层。
|
|
16
|
+
* - **`disabledDate(date)`** 透传给内层 Calendar 逐日禁用;`disabled` 禁用整个触发器。
|
|
17
|
+
* - **面 = 角色变量**:字段结构靠 `--stitch-border` + `--stitch-radius-input`,选中态与范围底色
|
|
18
|
+
* 由 Calendar 上皮(accent / bg-accent)承载;日历图标与翻月箭头一律经 `<Icon>`,无裸 svg。
|
|
19
|
+
*/
|
|
20
|
+
export interface DatePickerProps {
|
|
21
|
+
/** 选择模式:单日或范围 @default 'single' */
|
|
22
|
+
mode?: CalendarMode;
|
|
23
|
+
/** 受控选中值(`single`→`Date`,`range`→`DateRange`) */
|
|
24
|
+
value?: Date | DateRange;
|
|
25
|
+
/** 非受控初始选中值(`single`→`Date`,`range`→`DateRange`) */
|
|
26
|
+
defaultValue?: Date | DateRange;
|
|
27
|
+
/** 选中变化回调(含清除时的 `undefined`) */
|
|
28
|
+
onChange?: (value: Date | DateRange | undefined) => void;
|
|
29
|
+
/** 逐日禁用判定:返回 `true` 的日期不可选 */
|
|
30
|
+
disabledDate?: (date: Date) => boolean;
|
|
31
|
+
/** 首屏展示的月份(Ant `defaultPickerValue`);不给则据选中值 / 当月 */
|
|
32
|
+
defaultPickerValue?: Date;
|
|
33
|
+
/** 弹出日历顶部年月区形态:`'dropdown'` 可点选月 / 年,`'label'` 静态标题 @default 'dropdown' */
|
|
34
|
+
captionLayout?: CalendarCaptionLayout;
|
|
35
|
+
/** 禁用整个触发器 @default false */
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
/** 允许一键清除 @default true */
|
|
38
|
+
allowClear?: boolean;
|
|
39
|
+
/** 清除按钮的无障碍标签 @default '清除' */
|
|
40
|
+
clearAriaLabel?: string;
|
|
41
|
+
/** 占位符(`range` 可传 `[起, 止]` 两段) */
|
|
42
|
+
placeholder?: string | [string, string];
|
|
43
|
+
/** 日期展示格式(date-fns 格式串) @default 'yyyy-MM-dd' */
|
|
44
|
+
format?: string;
|
|
45
|
+
/** 触发器尺寸 @default 'middle' */
|
|
46
|
+
size?: DatePickerSize;
|
|
47
|
+
/** 校验态(error 同时置 `aria-invalid`) */
|
|
48
|
+
status?: 'error' | 'warning';
|
|
49
|
+
/** 受控浮层显隐(Ant v5 `open`) */
|
|
50
|
+
open?: boolean;
|
|
51
|
+
/** 非受控初始显隐 @default false */
|
|
52
|
+
defaultOpen?: boolean;
|
|
53
|
+
/** 显隐变化回调(Ant v5 `onOpenChange`) */
|
|
54
|
+
onOpenChange?: (open: boolean) => void;
|
|
55
|
+
/** 触发器的可访问名 */
|
|
56
|
+
'aria-label'?: string;
|
|
57
|
+
/** 自定义类名(挂到字段包裹上) */
|
|
58
|
+
className?: string;
|
|
59
|
+
}
|
|
60
|
+
export declare const DatePicker: React.FC<DatePickerProps>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Icon as e } from "../Icon/Icon.js";
|
|
2
|
+
import { Calendar as t } from "../Calendar/Calendar.js";
|
|
3
|
+
import { Popover as n } from "../Popover/Popover.js";
|
|
4
|
+
import r from "./datepicker.module.js";
|
|
5
|
+
import { useCallback as i, useEffect as a, useRef as o, useState as s } from "react";
|
|
6
|
+
import c from "clsx";
|
|
7
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
8
|
+
import { format as d } from "date-fns";
|
|
9
|
+
//#region packages/react/src/components/DatePicker/DatePicker.tsx
|
|
10
|
+
var f = (e) => typeof e == "object" && !!e && !(e instanceof Date), p = ({ mode: p = "single", value: m, defaultValue: h, onChange: g, disabledDate: _, defaultPickerValue: v, captionLayout: y, disabled: b = !1, allowClear: x = !0, clearAriaLabel: S = "清除", placeholder: C, format: w = "yyyy-MM-dd", size: T = "middle", status: E, open: D, defaultOpen: O, onOpenChange: k, className: A, "aria-label": j }) => {
|
|
11
|
+
let M = m !== void 0, [N, P] = s(h), F = M ? m : N, I = D !== void 0, [L, R] = s(O ?? !1), z = I ? D : L, B = i((e) => {
|
|
12
|
+
I || R(e), k?.(e);
|
|
13
|
+
}, [I, k]), V = o(0);
|
|
14
|
+
a(() => {
|
|
15
|
+
z && (V.current = 0);
|
|
16
|
+
}, [z]);
|
|
17
|
+
let H = i((e) => {
|
|
18
|
+
M || P(e), g?.(e);
|
|
19
|
+
}, [M, g]), U = i((e) => {
|
|
20
|
+
H(e), p === "range" ? (V.current += 1, V.current >= 2 && f(e) && e.from && e.to && B(!1)) : e && B(!1);
|
|
21
|
+
}, [
|
|
22
|
+
H,
|
|
23
|
+
p,
|
|
24
|
+
B
|
|
25
|
+
]), W = i((e) => {
|
|
26
|
+
e.stopPropagation(), H(void 0);
|
|
27
|
+
}, [H]), G = (e) => e ? d(e, w) : "", K = "", q = !1;
|
|
28
|
+
p === "range" && f(F) ? (q = !!(F.from || F.to), q && (K = `${G(F.from)} – ${G(F.to)}`)) : p === "single" && F instanceof Date && (q = !0, K = G(F));
|
|
29
|
+
let [J, Y] = Array.isArray(C) ? C : [C, C], X = p === "range" ? `${J ?? "开始日期"} – ${Y ?? "结束日期"}` : J ?? "请选择日期", Z = x && q && !b, Q = c(r.field, r[T], E && r[`status-${E}`], b && r.disabled, A), $ = /* @__PURE__ */ u("button", {
|
|
30
|
+
type: "button",
|
|
31
|
+
className: r.trigger,
|
|
32
|
+
disabled: b,
|
|
33
|
+
"aria-label": j,
|
|
34
|
+
"aria-invalid": E === "error" ? "true" : void 0,
|
|
35
|
+
"aria-haspopup": "dialog",
|
|
36
|
+
children: [/* @__PURE__ */ l(e, {
|
|
37
|
+
name: "calendar",
|
|
38
|
+
size: 16,
|
|
39
|
+
className: r.calendarIcon
|
|
40
|
+
}), /* @__PURE__ */ l("span", {
|
|
41
|
+
className: c(r.text, !q && r.placeholder),
|
|
42
|
+
children: q ? K : X
|
|
43
|
+
})]
|
|
44
|
+
});
|
|
45
|
+
return /* @__PURE__ */ u("span", {
|
|
46
|
+
className: Q,
|
|
47
|
+
children: [/* @__PURE__ */ l(n, {
|
|
48
|
+
open: z,
|
|
49
|
+
onOpenChange: B,
|
|
50
|
+
"aria-label": j ?? X,
|
|
51
|
+
trigger: $,
|
|
52
|
+
className: r.panel,
|
|
53
|
+
children: /* @__PURE__ */ l(t, {
|
|
54
|
+
mode: p,
|
|
55
|
+
value: F,
|
|
56
|
+
onChange: U,
|
|
57
|
+
disabledDate: _,
|
|
58
|
+
defaultMonth: v,
|
|
59
|
+
captionLayout: y
|
|
60
|
+
})
|
|
61
|
+
}), Z && /* @__PURE__ */ l("button", {
|
|
62
|
+
type: "button",
|
|
63
|
+
className: r.clear,
|
|
64
|
+
"aria-label": S,
|
|
65
|
+
onClick: W,
|
|
66
|
+
children: /* @__PURE__ */ l(e, {
|
|
67
|
+
name: "close",
|
|
68
|
+
size: 14
|
|
69
|
+
})
|
|
70
|
+
})]
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
p.displayName = "DatePicker";
|
|
74
|
+
//#endregion
|
|
75
|
+
export { p as DatePicker };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region packages/react/src/components/DatePicker/datepicker.module.less
|
|
2
|
+
var e = "_field_qa4ee_1", t = "_trigger_qa4ee_7", n = "_calendarIcon_qa4ee_37", r = "_text_qa4ee_41", i = "_placeholder_qa4ee_47", a = "_small_qa4ee_50", o = "_middle_qa4ee_54", s = "_large_qa4ee_57", c = "_clear_qa4ee_73", l = "_panel_qa4ee_94", u = {
|
|
3
|
+
field: e,
|
|
4
|
+
trigger: t,
|
|
5
|
+
calendarIcon: n,
|
|
6
|
+
text: r,
|
|
7
|
+
placeholder: i,
|
|
8
|
+
small: a,
|
|
9
|
+
middle: o,
|
|
10
|
+
large: s,
|
|
11
|
+
"status-error": "_status-error_qa4ee_61",
|
|
12
|
+
"status-warning": "_status-warning_qa4ee_67",
|
|
13
|
+
clear: c,
|
|
14
|
+
panel: l
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { n as calendarIcon, c as clear, u as default, e as field, s as large, o as middle, l as panel, i as placeholder, a as small, r as text, t as trigger };
|
|
@@ -4,6 +4,8 @@ declare const ICON_PATHS: {
|
|
|
4
4
|
readonly close: readonly ["M6 6l12 12", "M18 6L6 18"];
|
|
5
5
|
readonly 'chevron-down': readonly ["M5 9l7 7 7-7"];
|
|
6
6
|
readonly 'chevron-right': readonly ["M9 5l7 7-7 7"];
|
|
7
|
+
readonly 'chevron-left': readonly ["M15 5l-7 7 7 7"];
|
|
8
|
+
readonly calendar: readonly ["M4 6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z", "M8 3v4", "M16 3v4", "M4 10h16"];
|
|
7
9
|
readonly search: readonly ["M4 11a7 7 0 1 0 14 0a7 7 0 1 0 -14 0z", "M16.5 16.5L21 21"];
|
|
8
10
|
readonly menu: readonly ["M4 7h16", "M4 12h16", "M4 17h16"];
|
|
9
11
|
readonly info: readonly ["M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0z", "M12 11v5", "M12 7.5h0.01"];
|
|
@@ -19,6 +21,8 @@ declare const ICON_PATHS: {
|
|
|
19
21
|
readonly 'align-left': readonly ["M4 6h16", "M4 12h10", "M4 18h13"];
|
|
20
22
|
readonly 'align-center': readonly ["M4 6h16", "M7 12h10", "M6 18h12"];
|
|
21
23
|
readonly 'align-right': readonly ["M4 6h16", "M10 12h10", "M7 18h13"];
|
|
24
|
+
readonly 'arrow-up-right': readonly ["M7 17L17 7", "M8 7h9v9"];
|
|
25
|
+
readonly 'arrow-down-right': readonly ["M7 7L17 17", "M17 8v9H8"];
|
|
22
26
|
};
|
|
23
27
|
export type IconName = keyof typeof ICON_PATHS;
|
|
24
28
|
/**
|
|
@@ -69,6 +73,12 @@ export declare const ICON_LIST: readonly [{
|
|
|
69
73
|
}, {
|
|
70
74
|
readonly name: 'chevron-right';
|
|
71
75
|
readonly label: 'Chevron right';
|
|
76
|
+
}, {
|
|
77
|
+
readonly name: 'chevron-left';
|
|
78
|
+
readonly label: 'Chevron left';
|
|
79
|
+
}, {
|
|
80
|
+
readonly name: 'calendar';
|
|
81
|
+
readonly label: 'Calendar';
|
|
72
82
|
}, {
|
|
73
83
|
readonly name: 'search';
|
|
74
84
|
readonly label: 'Search';
|
|
@@ -96,5 +106,11 @@ export declare const ICON_LIST: readonly [{
|
|
|
96
106
|
}, {
|
|
97
107
|
readonly name: 'eye-off';
|
|
98
108
|
readonly label: 'Eye off';
|
|
109
|
+
}, {
|
|
110
|
+
readonly name: 'arrow-up-right';
|
|
111
|
+
readonly label: 'Trend up';
|
|
112
|
+
}, {
|
|
113
|
+
readonly name: 'arrow-down-right';
|
|
114
|
+
readonly label: 'Trend down';
|
|
99
115
|
}];
|
|
100
116
|
export {};
|
|
@@ -8,6 +8,13 @@ var r = {
|
|
|
8
8
|
close: ["M6 6l12 12", "M18 6L6 18"],
|
|
9
9
|
"chevron-down": ["M5 9l7 7 7-7"],
|
|
10
10
|
"chevron-right": ["M9 5l7 7-7 7"],
|
|
11
|
+
"chevron-left": ["M15 5l-7 7 7 7"],
|
|
12
|
+
calendar: [
|
|
13
|
+
"M4 6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z",
|
|
14
|
+
"M8 3v4",
|
|
15
|
+
"M16 3v4",
|
|
16
|
+
"M4 10h16"
|
|
17
|
+
],
|
|
11
18
|
search: ["M4 11a7 7 0 1 0 14 0a7 7 0 1 0 -14 0z", "M16.5 16.5L21 21"],
|
|
12
19
|
menu: [
|
|
13
20
|
"M4 7h16",
|
|
@@ -59,7 +66,9 @@ var r = {
|
|
|
59
66
|
"M4 6h16",
|
|
60
67
|
"M10 12h10",
|
|
61
68
|
"M7 18h13"
|
|
62
|
-
]
|
|
69
|
+
],
|
|
70
|
+
"arrow-up-right": ["M7 17L17 7", "M8 7h9v9"],
|
|
71
|
+
"arrow-down-right": ["M7 7L17 17", "M17 8v9H8"]
|
|
63
72
|
}, i = /* @__PURE__ */ new Set(["dot"]), a = ({ name: a, src: o, size: s = 24, label: c, strokeWidth: l, className: u, style: d, ...f }) => {
|
|
64
73
|
let p = t(e.icon, u), m = c == null ? { "aria-hidden": !0 } : {
|
|
65
74
|
role: "img",
|
|
@@ -109,6 +118,14 @@ var o = [
|
|
|
109
118
|
name: "chevron-right",
|
|
110
119
|
label: "Chevron right"
|
|
111
120
|
},
|
|
121
|
+
{
|
|
122
|
+
name: "chevron-left",
|
|
123
|
+
label: "Chevron left"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "calendar",
|
|
127
|
+
label: "Calendar"
|
|
128
|
+
},
|
|
112
129
|
{
|
|
113
130
|
name: "search",
|
|
114
131
|
label: "Search"
|
|
@@ -144,6 +161,14 @@ var o = [
|
|
|
144
161
|
{
|
|
145
162
|
name: "eye-off",
|
|
146
163
|
label: "Eye off"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: "arrow-up-right",
|
|
167
|
+
label: "Trend up"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: "arrow-down-right",
|
|
171
|
+
label: "Trend down"
|
|
147
172
|
}
|
|
148
173
|
];
|
|
149
174
|
//#endregion
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** 单条系列:从每行数据里取哪个字段、显示成什么名。 */
|
|
3
|
+
export interface LineChartSeries {
|
|
4
|
+
/** 该系列在数据项里取值的字段名 */
|
|
5
|
+
dataKey: string;
|
|
6
|
+
/** 系列显示名(tooltip / 图例);缺省用 `dataKey` */
|
|
7
|
+
name?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 折线 / 面积图。系列色只从契约分类色槽 `var(--stitch-cat-*)` 取、按序号循环,随站换肤整图跟随;
|
|
11
|
+
* `area` 开启时线下软填充由同一系列色经 `color-mix()` 派生。多系列不只靠颜色区分——每系列按序
|
|
12
|
+
* 循环线型(`strokeDasharray`),并在末点旁直接标出系列名(文字走 `var(--stitch-text-primary)`),
|
|
13
|
+
* 故主题线色偏淡时也能分辨(不依赖颜色,守 a11y)。svg 全由 recharts 出、源码零手写 svg,无 emoji。
|
|
14
|
+
* 整图作一张图对外——`role="img"` + `aria-label`(缺省兜底非空名)。
|
|
15
|
+
*/
|
|
16
|
+
export interface LineChartProps {
|
|
17
|
+
/** 数据源,每项一行记录(Ant charts `data` 语义) */
|
|
18
|
+
data: Record<string, unknown>[];
|
|
19
|
+
/** x 轴取值字段名(Ant charts `xField` 语义) */
|
|
20
|
+
xField: string;
|
|
21
|
+
/** 一条或多条系列(各取一个 y 字段) */
|
|
22
|
+
series: LineChartSeries[];
|
|
23
|
+
/**
|
|
24
|
+
* 平滑曲线(Ant charts `smooth` 语义)
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
smooth?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* 折线下渲染派生软填充面积(Ant charts `area` 语义)
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
area?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* 图表高度(px);宽度恒铺满容器
|
|
35
|
+
* @default 300
|
|
36
|
+
*/
|
|
37
|
+
height?: number;
|
|
38
|
+
/** y 值格式化(如货币);作用于坐标轴刻度与 tooltip 值 */
|
|
39
|
+
valueFormatter?: (value: number) => string;
|
|
40
|
+
/** 图表整体可访问名(`role="img"` 的文本替代);缺省兜底非空名 */
|
|
41
|
+
ariaLabel?: string;
|
|
42
|
+
/** 透传外层容器类名 */
|
|
43
|
+
className?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 把数据画成折线(可选面积),系列色走契约分类色槽、随站换肤。
|
|
47
|
+
*/
|
|
48
|
+
export declare const LineChart: React.FC<LineChartProps>;
|