@robert-stackflow/oneui 0.6.54 → 0.6.56

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
@@ -1,3 +1,11 @@
1
+ ## 0.6.56
2
+
3
+ - 窄屏和触屏灯箱隐藏前后箭头;宽屏箭头以整个视窗为定位基准,切换不同高度的图注时保持位置。
4
+
5
+ ## 0.6.55
6
+
7
+ - ContributionCalendar 新增 `labels`,应用可传入日历名称、空状态、图例与贡献计数格式。月份、星期和日期继续按 `locale` 格式化。
8
+
1
9
  ## 0.6.54
2
10
 
3
11
  - 触屏按主题密度显示控件,24px 点击尺寸作为下限。可编辑字段继续使用至少 16px 的字号,搜索清除按钮保留紧凑图标并提供 24px 点击区域。
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 打开期间会接管滚轮:长菜单仍可在内部滚动,短菜单及边界滚动不会传递到正文或嵌套工作区;关闭后恢复。
@@ -336,7 +338,7 @@ Menu 支持 iconOnly:`<Menu iconOnly label="更多操作" items={items} />`
336
338
 
337
339
  `Lightbox` is a controlled image viewer: pass `open`, `items`, `index`, `onIndexChange` and `onClose`. Each item has a stable `id`, `src`, `alt` and optional `caption`, `thumbnailSrc`, `width` and `height`. The optional `sourceElement(item)` resolves the original image for Hero motion; `onLocate(item)` runs after exit and scroll unlocking. Supply `labels` for localization. Provide valid `width` and `height` for an aspect-correct loading skeleton fitted to the canvas; images without known dimensions use a compact loading indicator.
338
340
 
339
- The viewer uses an opaque black canvas with light controls in both color modes. Opening focuses the header so keyboard navigation starts inside the dialog. Mouse users have previous and next buttons. On touch, the image follows horizontal swipes and the thumbnail strip provides direct navigation. Arrow keys, Escape, zoom, pinch, pan, captions and image retry work across layouts. A single image hides navigation. Only adjacent full images are preloaded. Native modal isolation and the shared focus lifecycle restore focus to the opener. Keep the component mounted through exit and retain the selected index.
341
+ The viewer uses an opaque black canvas with light controls in both color modes. Opening focuses the header so keyboard navigation starts inside the dialog. Wide mouse layouts offer previous and next buttons anchored to the viewer, independent of caption height. Narrow and touch layouts use the thumbnail strip for direct navigation. On touch, the image follows horizontal swipes. Arrow keys, Escape, zoom, pinch, pan, captions and image retry work across layouts. A single image hides navigation. Only adjacent full images are preloaded. Native modal isolation and the shared focus lifecycle restore focus to the opener. Keep the component mounted through exit and retain the selected index.
340
342
 
341
343
  Image changes retain the existing outgoing image for a directional fade/slide, without remounting it for the animation. Thumbnail selection uses a moving outline and a separate keyboard focus ring. Shared modal scroll locking preserves classic scrollbar space, nested lock ownership and original document styles.
342
344
 
@@ -1,6 +1,33 @@
1
1
  import { type ReactNode } from "react";
2
2
  import { type ContributionDay } from "./contribution";
3
- export declare function ContributionCalendar({ data, year, startDate, endDate, weekStartsOn, value, onChange, label, unit, locale, color, emptyMode, allowFuture, today, thresholds, footer, source, fill, }: {
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) return /* @__PURE__ */ jsx("p", { role: "alert", lang: locale, children: copy.invalidRange });
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(new Date(Date.UTC(month.year, month.month - 1, 1))) }, month.key))
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 text = formatter.format(parseCalendarDay(day.date)) + copy.separator + (day.future ? copy.future : emptyMode === "missing" && day.missing ? copy.missing : numbers.format(day.count) + " " + calendarUnit);
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
  {
@@ -55,7 +55,6 @@
55
55
  }
56
56
  .canvas {
57
57
  flex: 1;
58
- position: relative;
59
58
  min-height: 0;
60
59
  display: flex;
61
60
  justify-content: center;
@@ -96,16 +95,17 @@
96
95
  .previous,
97
96
  .next {
98
97
  position: absolute;
99
- top: calc(50% - 20px);
98
+ top: 50%;
99
+ translate: 0 -50%;
100
100
  z-index: 1;
101
101
  border-radius: 50%;
102
102
  background: color-mix(in srgb, var(--surface) 90%, transparent);
103
103
  }
104
104
  .previous {
105
- left: 0;
105
+ left: max(16px, env(safe-area-inset-left));
106
106
  }
107
107
  .next {
108
- right: 0;
108
+ right: max(16px, env(safe-area-inset-right));
109
109
  }
110
110
  .feedback {
111
111
  position: absolute;
@@ -203,7 +203,7 @@
203
203
  clip-path: inset(50%);
204
204
  white-space: nowrap;
205
205
  }
206
- @media (min-width: 640px) and (pointer: fine) {
206
+ @media (width > 760px) and (pointer: fine) {
207
207
  .canvas:has(.next) .stage {
208
208
  margin-inline: 48px;
209
209
  }
@@ -231,6 +231,8 @@
231
231
  width: 44px;
232
232
  height: 44px;
233
233
  }
234
+ }
235
+ @media (width <= 760px), (pointer: coarse) {
234
236
  .canvas :is(.previous, .next) {
235
237
  display: none;
236
238
  }
@@ -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";
@@ -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 { ContributionCalendar } from "./ContributionCalendar.js";
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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robert-stackflow/oneui",
3
- "version": "0.6.54",
3
+ "version": "0.6.56",
4
4
  "description": "OneUI React components, application shell and portable visual themes",
5
5
  "type": "module",
6
6
  "sideEffects": [