@robert-stackflow/oneui 0.6.54 → 0.6.55
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/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -20,6 +20,8 @@ ghost 图标按钮及分栏按钮的展开 / 选中态使用主题轻背景;
|
|
|
20
20
|
|
|
21
21
|
`ContributionCalendar fill` 在可用版心中放大网格;`source` 替换左下角默认日期范围,`footer` 在分隔线下提供统计等组合内容。调用方复用原生日历的主题、边框、提示和交互,不在外层再套 Card。
|
|
22
22
|
|
|
23
|
+
应用通过 `locale` 指定月份、星期和日期格式,并通过 `labels` 传入日历名称、无数据和未来日期提示、图例、分隔符与 `formatCount(count, formattedCount)`。未传入的文案使用组件默认值,已有的 `label` 和 `unit` 属性继续可用。
|
|
24
|
+
|
|
23
25
|
## 菜单滚动边界(0.6.37)
|
|
24
26
|
|
|
25
27
|
ContextMenu 打开期间会接管滚轮:长菜单仍可在内部滚动,短菜单及边界滚动不会传递到正文或嵌套工作区;关闭后恢复。
|
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import { type ContributionDay } from "./contribution";
|
|
3
|
-
|
|
3
|
+
declare const calendarCopy: {
|
|
4
|
+
zh: {
|
|
5
|
+
label: string;
|
|
6
|
+
unit: string;
|
|
7
|
+
invalidRange: string;
|
|
8
|
+
future: string;
|
|
9
|
+
missing: string;
|
|
10
|
+
legend: string;
|
|
11
|
+
less: string;
|
|
12
|
+
more: string;
|
|
13
|
+
separator: string;
|
|
14
|
+
};
|
|
15
|
+
en: {
|
|
16
|
+
label: string;
|
|
17
|
+
unit: string;
|
|
18
|
+
invalidRange: string;
|
|
19
|
+
future: string;
|
|
20
|
+
missing: string;
|
|
21
|
+
legend: string;
|
|
22
|
+
less: string;
|
|
23
|
+
more: string;
|
|
24
|
+
separator: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type ContributionCalendarLabels = typeof calendarCopy.en & {
|
|
28
|
+
formatCount?: (count: number, formattedCount: string) => string;
|
|
29
|
+
};
|
|
30
|
+
export declare function ContributionCalendar({ data, year, startDate, endDate, weekStartsOn, value, onChange, label, unit, labels, locale, color, emptyMode, allowFuture, today, thresholds, footer, source, fill, }: {
|
|
4
31
|
data: ContributionDay[];
|
|
5
32
|
year?: number;
|
|
6
33
|
startDate?: string;
|
|
@@ -10,6 +37,7 @@ export declare function ContributionCalendar({ data, year, startDate, endDate, w
|
|
|
10
37
|
onChange?(date: string): void;
|
|
11
38
|
label?: string;
|
|
12
39
|
unit?: string;
|
|
40
|
+
labels?: Partial<ContributionCalendarLabels>;
|
|
13
41
|
locale?: string;
|
|
14
42
|
color?: string;
|
|
15
43
|
emptyMode?: "zero" | "missing";
|
|
@@ -20,3 +48,4 @@ export declare function ContributionCalendar({ data, year, startDate, endDate, w
|
|
|
20
48
|
source?: ReactNode;
|
|
21
49
|
fill?: boolean;
|
|
22
50
|
}): import("react").JSX.Element;
|
|
51
|
+
export {};
|
|
@@ -46,6 +46,7 @@ function ContributionCalendar({
|
|
|
46
46
|
onChange,
|
|
47
47
|
label,
|
|
48
48
|
unit,
|
|
49
|
+
labels,
|
|
49
50
|
locale = "zh-CN",
|
|
50
51
|
color = "var(--success)",
|
|
51
52
|
emptyMode = "zero",
|
|
@@ -57,7 +58,7 @@ function ContributionCalendar({
|
|
|
57
58
|
fill = false
|
|
58
59
|
}) {
|
|
59
60
|
const chinese = new Intl.Locale(locale).language === "zh";
|
|
60
|
-
const copy = calendarCopy[chinese ? "zh" : "en"];
|
|
61
|
+
const copy = { ...calendarCopy[chinese ? "zh" : "en"], ...labels };
|
|
61
62
|
const calendarLabel = label ?? copy.label;
|
|
62
63
|
const calendarUnit = unit ?? copy.unit;
|
|
63
64
|
const current = /* @__PURE__ */ new Date(), todayKey = today || [
|
|
@@ -147,7 +148,8 @@ function ContributionCalendar({
|
|
|
147
148
|
},
|
|
148
149
|
[model]
|
|
149
150
|
);
|
|
150
|
-
if (!model.valid)
|
|
151
|
+
if (!model.valid)
|
|
152
|
+
return /* @__PURE__ */ jsx("p", { role: "alert", lang: locale, children: copy.invalidRange });
|
|
151
153
|
return /* @__PURE__ */ jsxs(
|
|
152
154
|
"div",
|
|
153
155
|
{
|
|
@@ -180,7 +182,9 @@ function ContributionCalendar({
|
|
|
180
182
|
/* @__PURE__ */ jsx("span", {}),
|
|
181
183
|
model.months.filter(
|
|
182
184
|
(month, index, headings) => !headings[index + 1] || headings[index + 1].column - month.column >= 2
|
|
183
|
-
).map((month) => /* @__PURE__ */ jsx("span", { style: { gridColumn: month.column + 2 }, children: months.format(
|
|
185
|
+
).map((month) => /* @__PURE__ */ jsx("span", { style: { gridColumn: month.column + 2 }, children: months.format(
|
|
186
|
+
new Date(Date.UTC(month.year, month.month - 1, 1))
|
|
187
|
+
) }, month.key))
|
|
184
188
|
]
|
|
185
189
|
}
|
|
186
190
|
),
|
|
@@ -203,7 +207,8 @@ function ContributionCalendar({
|
|
|
203
207
|
/* @__PURE__ */ jsx("span", { className: s.weekday, role: "rowheader", children: weekdays[(row + weekStartsOn) % 7] }),
|
|
204
208
|
Array.from({ length: model.weeks }, (_2, column) => {
|
|
205
209
|
const day = model.cells[column * 7 + row];
|
|
206
|
-
const
|
|
210
|
+
const count = numbers.format(day.count);
|
|
211
|
+
const text = formatter.format(parseCalendarDay(day.date)) + copy.separator + (day.future ? copy.future : emptyMode === "missing" && day.missing ? copy.missing : copy.formatCount?.(day.count, count) ?? count + " " + calendarUnit);
|
|
207
212
|
return /* @__PURE__ */ jsx(
|
|
208
213
|
ContributionCell,
|
|
209
214
|
{
|
package/components/index.d.ts
CHANGED
|
@@ -98,7 +98,7 @@ export { FormErrorSummary } from "./FormErrorSummary";
|
|
|
98
98
|
export { useFormState } from "./useFormState";
|
|
99
99
|
export type { FormController, FormRules, FieldRule } from "./useFormState";
|
|
100
100
|
export { PinInput } from "./PinInput";
|
|
101
|
-
export { ContributionCalendar } from "./ContributionCalendar";
|
|
101
|
+
export { ContributionCalendar, type ContributionCalendarLabels, } from "./ContributionCalendar";
|
|
102
102
|
export type { ContributionDay } from "./contribution";
|
|
103
103
|
export { Combobox, type ComboboxProps } from "./Combobox";
|
|
104
104
|
export { TagInput } from "./TagInput";
|
package/components/index.js
CHANGED
|
@@ -89,7 +89,9 @@ import { FormGroup } from "./FormGroup.js";
|
|
|
89
89
|
import { FormErrorSummary } from "./FormErrorSummary.js";
|
|
90
90
|
import { useFormState } from "./useFormState.js";
|
|
91
91
|
import { PinInput } from "./PinInput.js";
|
|
92
|
-
import {
|
|
92
|
+
import {
|
|
93
|
+
ContributionCalendar
|
|
94
|
+
} from "./ContributionCalendar.js";
|
|
93
95
|
import { Combobox } from "./Combobox.js";
|
|
94
96
|
import { TagInput } from "./TagInput.js";
|
|
95
97
|
import { PasswordField } from "./PasswordField.js";
|