@robert-stackflow/oneui 0.6.52 → 0.6.54

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,12 @@
1
+ ## 0.6.54
2
+
3
+ - 触屏按主题密度显示控件,24px 点击尺寸作为下限。可编辑字段继续使用至少 16px 的字号,搜索清除按钮保留紧凑图标并提供 24px 点击区域。
4
+ - 图片查看器打开时将焦点置于标题区。触屏支持跟手滑动和缩略图换图,横屏缩减周边空间,桌面保留前后箭头与键盘操作。
5
+
6
+ ## 0.6.53
7
+
8
+ - ContributionCalendar 的月份、星期、提示与图例随 locale 显示,保留中文默认文案并支持英文日历。
9
+
1
10
  ## 0.6.48
2
11
 
3
12
  - TableOfContents 新增 railAlign="start",支持左侧目录的短线左对齐及从左侧展开长度变化;默认 end 保持原行为。
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  React 组件、应用外壳和两套可互换的主题。无 Electron、React Router、账户 API 或持久化存储依赖。
4
4
 
5
- ## 触屏尺寸与分页链接(0.6.51)
5
+ ## 触屏密度(0.6.54)
6
6
 
7
- 粗指针设备的按钮、图标按钮、分段控件、标签页、菜单、输入及分页使用至少 44px 的操作高度;可编辑字段至少 16px,避免 iOS 聚焦时自动缩放。鼠标设备保留现有密度。公开 CSS 变量 `--touch-target-min`、`--touch-field-font-size` 可按宿主输入策略配置,组件无需私有 DOM 覆盖。
7
+ 控件沿用主题和密度定义的尺寸。粗指针设备下,共用控件的最小点击尺寸为 24 CSS px。按钮、分段控件、标签页、选择器、菜单和分页各自保留主题高度。仅可编辑字段在触屏下保持至少 16px 字号,避免 iOS 聚焦时缩放。空间充足的独立操作可用公开变量 `--touch-target-min: 44px` 提供更大的目标。字号可通过 `--touch-field-font-size` 配置。
8
8
 
9
9
  `Pagination getPageHref(page)` 为可用的页码和翻页控件输出真实链接,普通点击仍调用 `onPageChange`,修饰键/中键交给浏览器。禁用翻页按钮不生成链接。后台不传该属性时保留原有按钮行为。
10
10
 
@@ -336,7 +336,7 @@ Menu 支持 iconOnly:`<Menu iconOnly label="更多操作" items={items} />`
336
336
 
337
337
  `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
338
 
339
- The viewer uses an opaque black canvas with light controls independently of the document color mode. It supports captions, thumbnail navigation, non-wrapping previous/next, arrow keys, Escape, original-size zoom, bounded dragging, touch pinch/swipe and manual retry of the original URL. A single image hides navigation. Only adjacent full images are preloaded. It uses native modal isolation and shared OneUI focus, scroll lock and motion; reduced motion and missing/offscreen source elements use a quiet fallback. Keep the component mounted through exit and retain the selected index. Resolve resource permissions and document anchors in the host, not inside OneUI.
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.
340
340
 
341
341
  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
342
 
@@ -356,4 +356,4 @@ Closing returns a visible source image with Hero motion. Missing/offscreen sourc
356
356
 
357
357
  ### 窄屏分页(0.6.52)
358
358
 
359
- 650px 及以下保留上一页、下一页、首页页码、末页页码和当前页;省略相邻页码与重复的首尾双箭头,用省略号标明页码间隔。44px 触屏目标保持不变,320px 视口中分页无需折到第二行。全部页码仍使用同一套按钮/原生链接和回调逻辑。
359
+ 650px 及以下保留上一页、下一页、首页页码、末页页码和当前页,使用省略号标明页码间隔。分页使用主题的控件尺寸,320px 下保持一行。页码可使用按钮或原生链接。
@@ -12,6 +12,30 @@ import {
12
12
  parseCalendarDay
13
13
  } from "./contribution.js";
14
14
  import s from "./ContributionCalendar.module.css";
15
+ const calendarCopy = {
16
+ zh: {
17
+ label: "\u6D3B\u52A8\u8BB0\u5F55",
18
+ unit: "\u6B21\u6D3B\u52A8",
19
+ invalidRange: "\u65E5\u671F\u8303\u56F4\u65E0\u6548\u3002",
20
+ future: "\u672A\u6765\u65E5\u671F",
21
+ missing: "\u6682\u65E0\u6570\u636E",
22
+ legend: "\u6D3B\u52A8\u6B21\u6570\u7531\u5C11\u5230\u591A",
23
+ less: "\u5C11",
24
+ more: "\u591A",
25
+ separator: "\uFF0C"
26
+ },
27
+ en: {
28
+ label: "Activity",
29
+ unit: "activities",
30
+ invalidRange: "Invalid date range.",
31
+ future: "Future date",
32
+ missing: "No data",
33
+ legend: "Activity from less to more",
34
+ less: "Less",
35
+ more: "More",
36
+ separator: ", "
37
+ }
38
+ };
15
39
  function ContributionCalendar({
16
40
  data,
17
41
  year = (/* @__PURE__ */ new Date()).getFullYear(),
@@ -20,8 +44,8 @@ function ContributionCalendar({
20
44
  weekStartsOn = 1,
21
45
  value,
22
46
  onChange,
23
- label = "\u6D3B\u52A8\u8BB0\u5F55",
24
- unit = "\u6B21\u6D3B\u52A8",
47
+ label,
48
+ unit,
25
49
  locale = "zh-CN",
26
50
  color = "var(--success)",
27
51
  emptyMode = "zero",
@@ -32,6 +56,10 @@ function ContributionCalendar({
32
56
  source,
33
57
  fill = false
34
58
  }) {
59
+ const chinese = new Intl.Locale(locale).language === "zh";
60
+ const copy = calendarCopy[chinese ? "zh" : "en"];
61
+ const calendarLabel = label ?? copy.label;
62
+ const calendarUnit = unit ?? copy.unit;
35
63
  const current = /* @__PURE__ */ new Date(), todayKey = today || [
36
64
  current.getFullYear(),
37
65
  String(current.getMonth() + 1).padStart(2, "0"),
@@ -69,6 +97,20 @@ function ContributionCalendar({
69
97
  }),
70
98
  [locale]
71
99
  ), numbers = useMemo(() => new Intl.NumberFormat(locale), [locale]);
100
+ const months = useMemo(
101
+ () => new Intl.DateTimeFormat(locale, { month: "short", timeZone: "UTC" }),
102
+ [locale]
103
+ );
104
+ const weekdays = useMemo(() => {
105
+ const format = new Intl.DateTimeFormat(locale, {
106
+ weekday: chinese ? "narrow" : "short",
107
+ timeZone: "UTC"
108
+ });
109
+ return Array.from(
110
+ { length: 7 },
111
+ (_, day) => format.format(new Date(Date.UTC(2024, 0, 7 + day)))
112
+ );
113
+ }, [locale, chinese]);
72
114
  const choose = useCallback((date) => onChange?.(date), [onChange]);
73
115
  const move = useCallback(
74
116
  (event, day) => {
@@ -105,11 +147,12 @@ function ContributionCalendar({
105
147
  },
106
148
  [model]
107
149
  );
108
- if (!model.valid) return /* @__PURE__ */ jsx("p", { role: "alert", children: "\u65E5\u671F\u8303\u56F4\u65E0\u6548\u3002" });
150
+ if (!model.valid) return /* @__PURE__ */ jsx("p", { role: "alert", lang: locale, children: copy.invalidRange });
109
151
  return /* @__PURE__ */ jsxs(
110
152
  "div",
111
153
  {
112
154
  className: s.calendar,
155
+ lang: locale,
113
156
  style: {
114
157
  "--calendar-color": color,
115
158
  "--calendar-cell-max": fill ? "24px" : "13px",
@@ -117,11 +160,11 @@ function ContributionCalendar({
117
160
  },
118
161
  children: [
119
162
  /* @__PURE__ */ jsxs("header", { className: s.header, children: [
120
- /* @__PURE__ */ jsx("h3", { children: label }),
163
+ /* @__PURE__ */ jsx("h3", { children: calendarLabel }),
121
164
  /* @__PURE__ */ jsxs("span", { children: [
122
165
  numbers.format(model.total),
123
166
  " ",
124
- unit
167
+ calendarUnit
125
168
  ] })
126
169
  ] }),
127
170
  /* @__PURE__ */ jsxs("div", { className: s.scroll, ref: root, children: [
@@ -136,11 +179,8 @@ function ContributionCalendar({
136
179
  children: [
137
180
  /* @__PURE__ */ jsx("span", {}),
138
181
  model.months.filter(
139
- (month, index, months) => !months[index + 1] || months[index + 1].column - month.column >= 2
140
- ).map((month) => /* @__PURE__ */ jsxs("span", { style: { gridColumn: month.column + 2 }, children: [
141
- month.month,
142
- "\u6708"
143
- ] }, month.key))
182
+ (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))
144
184
  ]
145
185
  }
146
186
  ),
@@ -148,7 +188,7 @@ function ContributionCalendar({
148
188
  "div",
149
189
  {
150
190
  role: "grid",
151
- "aria-label": label,
191
+ "aria-label": calendarLabel,
152
192
  "aria-rowcount": 7,
153
193
  "aria-colcount": model.weeks,
154
194
  children: Array.from({ length: 7 }, (_, row) => /* @__PURE__ */ jsxs(
@@ -160,10 +200,10 @@ function ContributionCalendar({
160
200
  gridTemplateColumns: "28px repeat(" + model.weeks + ",var(--calendar-cell))"
161
201
  },
162
202
  children: [
163
- /* @__PURE__ */ jsx("span", { className: s.weekday, role: "rowheader", children: ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"][(row + weekStartsOn) % 7] }),
203
+ /* @__PURE__ */ jsx("span", { className: s.weekday, role: "rowheader", children: weekdays[(row + weekStartsOn) % 7] }),
164
204
  Array.from({ length: model.weeks }, (_2, column) => {
165
205
  const day = model.cells[column * 7 + row];
166
- const text = formatter.format(parseCalendarDay(day.date)) + (day.future ? "\uFF0C\u672A\u6765\u65E5\u671F" : emptyMode === "missing" && day.missing ? "\uFF0C\u6682\u65E0\u6570\u636E" : "\uFF0C" + numbers.format(day.count) + " " + unit);
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);
167
207
  return /* @__PURE__ */ jsx(
168
208
  ContributionCell,
169
209
  {
@@ -188,8 +228,8 @@ function ContributionCalendar({
188
228
  ] }),
189
229
  /* @__PURE__ */ jsxs("footer", { className: s.footer, children: [
190
230
  source ?? (value && /* @__PURE__ */ jsx("span", { children: value })),
191
- /* @__PURE__ */ jsxs("div", { className: s.legend, "aria-label": "\u6D3B\u52A8\u6B21\u6570\u7531\u5C11\u5230\u591A", children: [
192
- /* @__PURE__ */ jsx("span", { children: "\u5C11" }),
231
+ /* @__PURE__ */ jsxs("div", { className: s.legend, "aria-label": copy.legend, children: [
232
+ /* @__PURE__ */ jsx("span", { children: copy.less }),
193
233
  [0, 1, 2, 3, 4].map((level) => /* @__PURE__ */ jsx(
194
234
  "i",
195
235
  {
@@ -199,7 +239,7 @@ function ContributionCalendar({
199
239
  },
200
240
  level
201
241
  )),
202
- /* @__PURE__ */ jsx("span", { children: "\u591A" })
242
+ /* @__PURE__ */ jsx("span", { children: copy.more })
203
243
  ] })
204
244
  ] }),
205
245
  footer && /* @__PURE__ */ jsx("div", { className: s.extraFooter, children: footer })
@@ -5,7 +5,7 @@
5
5
  border-radius: var(--field-radius);
6
6
  background: var(--field);
7
7
  color: var(--fg);
8
- font-size: max(var(--field-font-size), var(--touch-field-font-size, 0px));
8
+ font-size: var(--field-font-size);
9
9
  line-height: var(--field-line-height);
10
10
  outline: none;
11
11
  transition:
@@ -82,9 +82,11 @@
82
82
  .surface:has(input[readonly]) {
83
83
  background: var(--field-readonly);
84
84
  }
85
+ .surface:where(input, textarea, :has(input:not([type="hidden"]))) {
86
+ font-size: max(var(--field-font-size), var(--touch-field-font-size, 0px));
87
+ }
85
88
  @media (max-width: 600px) {
86
- .surface:has(input),
87
- .surface:is(input, textarea) {
88
- font-size: 16px;
89
+ .surface:where(input, textarea, :has(input:not([type="hidden"]))) {
90
+ font-size: max(var(--field-font-size), var(--touch-field-font-size, 16px));
89
91
  }
90
92
  }
@@ -56,7 +56,8 @@ function Lightbox(props) {
56
56
  const outgoingRef = useRef(null), thumbnailsRef = useRef(null);
57
57
  const [indicator, setIndicator] = useState(null);
58
58
  const slideAnimations = useRef([]);
59
- const imageRef = useRef(null), stageRef = useRef(null), closeRef = useRef(null);
59
+ const imageRef = useRef(null), stageRef = useRef(null), headerRef = useRef(null);
60
+ const swipeOffset = useRef(0), swipeSettle = useRef(null);
60
61
  const titleId = useId(), captionId = useId();
61
62
  const live = useRef(props);
62
63
  live.current = props;
@@ -111,6 +112,7 @@ function Lightbox(props) {
111
112
  const slideState = useRef(slide);
112
113
  slideState.current = slide;
113
114
  const blankGesture = useRef(null);
115
+ const touchButton = useRef(null);
114
116
  const isBlank = (target) => target === ref.current || target === stageRef.current || target instanceof HTMLElement && target.hasAttribute("data-lightbox-blank");
115
117
  const pointers = useRef(/* @__PURE__ */ new Map());
116
118
  const gesture = useRef({
@@ -267,6 +269,9 @@ function Lightbox(props) {
267
269
  setZoom(1);
268
270
  setPan({ x: 0, y: 0 });
269
271
  pointers.current.clear();
272
+ swipeSettle.current?.cancel();
273
+ swipeOffset.current = 0;
274
+ stageRef.current?.style.removeProperty("--lightbox-swipe-x");
270
275
  const img = imageRef.current;
271
276
  if (img?.complete && img.naturalWidth) onLoaded();
272
277
  }, [open, item?.id, item?.src]);
@@ -293,6 +298,10 @@ function Lightbox(props) {
293
298
  useEffect(() => {
294
299
  const element = ref.current;
295
300
  const resize = () => {
301
+ pointers.current.clear();
302
+ swipeSettle.current?.cancel();
303
+ swipeOffset.current = 0;
304
+ stageRef.current?.style.removeProperty("--lightbox-swipe-x");
296
305
  setZoom(1);
297
306
  setPan({ x: 0, y: 0 });
298
307
  };
@@ -301,6 +310,7 @@ function Lightbox(props) {
301
310
  window.removeEventListener("resize", resize);
302
311
  if (element) cancelMotion(element);
303
312
  hero.current?.cancel();
313
+ swipeSettle.current?.cancel();
304
314
  slideAnimations.current.forEach((animation) => animation.cancel());
305
315
  };
306
316
  }, [portal]);
@@ -314,7 +324,7 @@ function Lightbox(props) {
314
324
  if (!dialog.open) {
315
325
  rememberFocus();
316
326
  dialog.showModal();
317
- closeRef.current?.focus({ preventScroll: true });
327
+ headerRef.current?.focus({ preventScroll: true });
318
328
  heroPending.current = true;
319
329
  if (imageRef.current?.complete && imageRef.current.naturalWidth) {
320
330
  heroPending.current = false;
@@ -357,7 +367,11 @@ function Lightbox(props) {
357
367
  setPan({ x: 0, y: 0 });
358
368
  };
359
369
  const pointerDown = (event) => {
360
- if (event.button !== 0 || status !== "loaded") return;
370
+ if (event.button !== 0 || event.target instanceof Element && event.target.closest("button"))
371
+ return;
372
+ swipeSettle.current?.cancel();
373
+ swipeOffset.current = 0;
374
+ event.currentTarget.style.removeProperty("--lightbox-swipe-x");
361
375
  event.currentTarget.setPointerCapture(event.pointerId);
362
376
  pointers.current.set(event.pointerId, {
363
377
  x: event.clientX,
@@ -381,7 +395,7 @@ function Lightbox(props) {
381
395
  y: event.clientY
382
396
  });
383
397
  const points = [...pointers.current.values()], start = gesture.current;
384
- if (points.length === 2 && start.distance) {
398
+ if (points.length === 2 && start.distance && status === "loaded") {
385
399
  const scale = clamp(
386
400
  start.scale * Math.hypot(points[0].x - points[1].x, points[0].y - points[1].y) / start.distance,
387
401
  1,
@@ -389,7 +403,7 @@ function Lightbox(props) {
389
403
  );
390
404
  setZoom(scale);
391
405
  setPan(bounds(pan.x, pan.y, scale));
392
- } else if (zoom > 1 && !start.multi)
406
+ } else if (zoom > 1 && points.length === 1) {
393
407
  setPan(
394
408
  bounds(
395
409
  start.panX + event.clientX - start.x,
@@ -397,13 +411,47 @@ function Lightbox(props) {
397
411
  zoom
398
412
  )
399
413
  );
414
+ } else if (event.pointerType === "touch" && !start.multi && items.length > 1) {
415
+ const dx = event.clientX - start.x;
416
+ const dy = event.clientY - start.y;
417
+ const atEnd = dx > 0 ? index === 0 : index === items.length - 1;
418
+ const offset = Math.abs(dx) > Math.abs(dy) * 1.2 ? dx * (atEnd ? 0.16 : 0.65) : 0;
419
+ swipeOffset.current = offset;
420
+ event.currentTarget.style.setProperty(
421
+ "--lightbox-swipe-x",
422
+ `${offset}px`
423
+ );
424
+ }
400
425
  };
401
426
  const pointerEnd = (event) => {
402
427
  if (!pointers.current.has(event.pointerId)) return;
403
428
  const start = gesture.current, dx = event.clientX - start.x, dy = event.clientY - start.y;
404
429
  pointers.current.delete(event.pointerId);
405
- if (event.type !== "pointercancel" && !start.multi && zoom === 1 && Math.abs(dx) > 64 && Math.abs(dx) > Math.abs(dy) * 1.2)
406
- move(index + (dx < 0 ? 1 : -1));
430
+ const remaining = [...pointers.current.values()];
431
+ if (remaining.length === 1 && start.multi)
432
+ gesture.current = {
433
+ ...start,
434
+ ...remaining[0],
435
+ panX: pan.x,
436
+ panY: pan.y,
437
+ distance: 0
438
+ };
439
+ const offset = swipeOffset.current;
440
+ swipeOffset.current = 0;
441
+ event.currentTarget.style.removeProperty("--lightbox-swipe-x");
442
+ const threshold = event.pointerType === "touch" ? clamp(event.currentTarget.clientWidth * 0.16, 36, 64) : 64;
443
+ const next = index + (dx < 0 ? 1 : -1);
444
+ if (event.type !== "pointercancel" && !start.multi && zoom === 1 && Math.abs(dx) > threshold && Math.abs(dx) > Math.abs(dy) * 1.2 && next >= 0 && next < items.length) {
445
+ move(next);
446
+ } else if (offset && !reducedMotion()) {
447
+ swipeSettle.current = imageRef.current?.animate(
448
+ [{ translate: `${offset}px` }, { translate: "0px" }],
449
+ {
450
+ duration: motionDuration("--motion-hover", 140),
451
+ easing: "ease-out"
452
+ }
453
+ ) ?? null;
454
+ }
407
455
  };
408
456
  return createPortal(
409
457
  /* @__PURE__ */ jsx(SurfacePortalContext, { value: { host, active: open }, children: /* @__PURE__ */ jsxs(
@@ -415,12 +463,14 @@ function Lightbox(props) {
415
463
  "aria-describedby": item.caption ? captionId : void 0,
416
464
  "aria-modal": "true",
417
465
  onPointerDownCapture: (event) => {
466
+ touchButton.current = null;
418
467
  blankGesture.current = event.isPrimary && event.button === 0 ? {
419
468
  id: event.pointerId,
420
469
  x: event.clientX,
421
470
  y: event.clientY,
422
471
  moved: false,
423
- blank: isBlank(event.target)
472
+ blank: isBlank(event.target),
473
+ button: event.pointerType === "touch" && event.target instanceof Element ? event.target.closest("button") : null
424
474
  } : null;
425
475
  },
426
476
  onPointerMoveCapture: (event) => {
@@ -431,11 +481,21 @@ function Lightbox(props) {
431
481
  onPointerUpCapture: (event) => {
432
482
  const start = blankGesture.current;
433
483
  blankGesture.current = null;
434
- if (start?.id === event.pointerId && start.blank && !start.moved && isBlank(event.target))
435
- props.onClose();
484
+ if (start?.id !== event.pointerId || start.moved) return;
485
+ if (start.blank && isBlank(event.target)) props.onClose();
486
+ if (start.button && event.target instanceof Node && start.button.contains(event.target))
487
+ touchButton.current = start.button;
488
+ },
489
+ onTouchEnd: (event) => {
490
+ const button = touchButton.current;
491
+ touchButton.current = null;
492
+ if (!button || event.touches.length || !event.cancelable) return;
493
+ event.preventDefault();
494
+ button.click();
436
495
  },
437
496
  onPointerCancelCapture: () => {
438
497
  blankGesture.current = null;
498
+ touchButton.current = null;
439
499
  },
440
500
  onCancel: (event) => {
441
501
  event.preventDefault();
@@ -449,36 +509,45 @@ function Lightbox(props) {
449
509
  },
450
510
  children: [
451
511
  /* @__PURE__ */ jsx("h2", { id: titleId, className: s.srOnly, children: t.title }),
452
- /* @__PURE__ */ jsxs("header", { className: s.header, "data-lightbox-blank": "", children: [
453
- /* @__PURE__ */ jsxs("span", { className: s.counter, role: "status", "aria-live": "polite", children: [
454
- index + 1,
455
- " / ",
456
- items.length
457
- ] }),
458
- /* @__PURE__ */ jsxs("div", { className: s.actions, children: [
459
- /* @__PURE__ */ jsx(
460
- IconButton,
461
- {
462
- label: zoom > 1 ? t.zoomOut : t.zoomIn,
463
- disabled: status !== "loaded",
464
- onClick: toggleZoom,
465
- children: zoom > 1 ? /* @__PURE__ */ jsx(ZoomOut, { size: 19 }) : /* @__PURE__ */ jsx(ZoomIn, { size: 19 })
466
- }
467
- ),
468
- props.onLocate && /* @__PURE__ */ jsx(
469
- IconButton,
470
- {
471
- label: t.locate,
472
- onClick: () => {
473
- locate.current = item;
474
- props.onClose();
475
- },
476
- children: /* @__PURE__ */ jsx(LocateFixed, { size: 19 })
477
- }
478
- ),
479
- /* @__PURE__ */ jsx(IconButton, { ref: closeRef, label: t.close, onClick: props.onClose, children: /* @__PURE__ */ jsx(X, { size: 20 }) })
480
- ] })
481
- ] }),
512
+ /* @__PURE__ */ jsxs(
513
+ "header",
514
+ {
515
+ ref: headerRef,
516
+ tabIndex: -1,
517
+ className: s.header,
518
+ "data-lightbox-blank": "",
519
+ children: [
520
+ /* @__PURE__ */ jsxs("span", { className: s.counter, role: "status", "aria-live": "polite", children: [
521
+ index + 1,
522
+ " / ",
523
+ items.length
524
+ ] }),
525
+ /* @__PURE__ */ jsxs("div", { className: s.actions, children: [
526
+ /* @__PURE__ */ jsx(
527
+ IconButton,
528
+ {
529
+ label: zoom > 1 ? t.zoomOut : t.zoomIn,
530
+ disabled: status !== "loaded",
531
+ onClick: toggleZoom,
532
+ children: zoom > 1 ? /* @__PURE__ */ jsx(ZoomOut, { size: 19 }) : /* @__PURE__ */ jsx(ZoomIn, { size: 19 })
533
+ }
534
+ ),
535
+ props.onLocate && /* @__PURE__ */ jsx(
536
+ IconButton,
537
+ {
538
+ label: t.locate,
539
+ onClick: () => {
540
+ locate.current = item;
541
+ props.onClose();
542
+ },
543
+ children: /* @__PURE__ */ jsx(LocateFixed, { size: 19 })
544
+ }
545
+ ),
546
+ /* @__PURE__ */ jsx(IconButton, { label: t.close, onClick: props.onClose, children: /* @__PURE__ */ jsx(X, { size: 20 }) })
547
+ ] })
548
+ ]
549
+ }
550
+ ),
482
551
  /* @__PURE__ */ jsxs("div", { className: s.canvas, "data-lightbox-blank": "", children: [
483
552
  items.length > 1 && /* @__PURE__ */ jsx(
484
553
  IconButton,
@@ -549,7 +618,7 @@ function Lightbox(props) {
549
618
  {
550
619
  label: t.retry,
551
620
  onClick: () => {
552
- closeRef.current?.focus({ preventScroll: true });
621
+ headerRef.current?.focus({ preventScroll: true });
553
622
  setStatus("loading");
554
623
  const img = imageRef.current;
555
624
  if (img) {
@@ -25,19 +25,23 @@
25
25
  overflow: hidden;
26
26
  }
27
27
  .lightbox[open] {
28
- display: grid;
29
- grid-template-rows: auto minmax(0, 1fr) auto auto;
28
+ display: flex;
29
+ flex-direction: column;
30
30
  gap: 12px;
31
31
  }
32
32
  .lightbox::backdrop {
33
33
  background: transparent;
34
34
  }
35
35
  .header {
36
+ flex-shrink: 0;
36
37
  display: flex;
37
38
  align-items: center;
38
39
  justify-content: space-between;
39
40
  min-height: 40px;
40
41
  }
42
+ .header:focus {
43
+ outline: none;
44
+ }
41
45
  .counter {
42
46
  color: var(--muted);
43
47
  font-size: 13px;
@@ -50,6 +54,7 @@
50
54
  align-items: center;
51
55
  }
52
56
  .canvas {
57
+ flex: 1;
53
58
  position: relative;
54
59
  min-height: 0;
55
60
  display: flex;
@@ -85,6 +90,9 @@
85
90
  border-radius: 2px;
86
91
  flex-shrink: 0;
87
92
  }
93
+ .image[data-image-phase="current"] {
94
+ translate: var(--lightbox-swipe-x, 0px);
95
+ }
88
96
  .previous,
89
97
  .next {
90
98
  position: absolute;
@@ -110,7 +118,7 @@
110
118
  font-size: 13px;
111
119
  }
112
120
  .caption {
113
- justify-self: center;
121
+ align-self: center;
114
122
  max-width: min(760px, 90vw);
115
123
  max-height: 15dvh;
116
124
  overflow: auto;
@@ -125,12 +133,15 @@
125
133
  max-height: 100%;
126
134
  }
127
135
  .thumbnails {
136
+ align-self: center;
137
+ flex-shrink: 0;
128
138
  position: relative;
129
139
  display: flex;
130
140
  gap: 8px;
131
141
  max-width: 100%;
132
142
  margin-inline: auto;
133
143
  overflow-x: auto;
144
+ overscroll-behavior-x: contain;
134
145
  padding: 4px;
135
146
  }
136
147
  .thumbnails button {
@@ -192,8 +203,8 @@
192
203
  clip-path: inset(50%);
193
204
  white-space: nowrap;
194
205
  }
195
- @media (min-width: 800px) {
196
- .stage {
206
+ @media (min-width: 640px) and (pointer: fine) {
207
+ .canvas:has(.next) .stage {
197
208
  margin-inline: 48px;
198
209
  }
199
210
  }
@@ -204,16 +215,38 @@
204
215
  }
205
216
 
206
217
  .actions button,
207
- .canvas > button {
218
+ .canvas :is(.previous, .next) {
208
219
  width: 40px;
209
220
  height: 40px;
210
221
  }
211
222
  @media (pointer: coarse) {
212
- .actions button,
213
- .canvas > button {
223
+ .lightbox {
224
+ padding-inline: max(10px, env(safe-area-inset-left))
225
+ max(10px, env(safe-area-inset-right));
226
+ }
227
+ .lightbox[open] {
228
+ gap: 8px;
229
+ }
230
+ .actions button {
214
231
  width: 44px;
215
232
  height: 44px;
216
233
  }
234
+ .canvas :is(.previous, .next) {
235
+ display: none;
236
+ }
237
+ }
238
+ @media (max-height: 440px) {
239
+ .lightbox[open] {
240
+ gap: 6px;
241
+ }
242
+ .caption {
243
+ max-height: 12dvh;
244
+ }
245
+ .thumbnails button {
246
+ flex-basis: 48px;
247
+ width: 48px;
248
+ height: 34px;
249
+ }
217
250
  }
218
251
 
219
252
  .outgoing {
@@ -29,11 +29,6 @@
29
29
  .item + .item {
30
30
  margin-top: var(--menu-item-spacing);
31
31
  }
32
- @media (pointer: coarse) {
33
- .item {
34
- min-height: 44px;
35
- }
36
- }
37
32
  .item[data-selected="true"] {
38
33
  background: var(--selected);
39
34
  }
@@ -13,6 +13,7 @@
13
13
  height: 15px;
14
14
  }
15
15
  .search input {
16
+ align-self: stretch;
16
17
  width: 100%;
17
18
  min-width: 0;
18
19
  background: transparent;
@@ -24,6 +25,9 @@
24
25
  display: none;
25
26
  }
26
27
  .search button {
28
+ flex: none;
29
+ min-inline-size: 24px;
30
+ min-block-size: 24px;
27
31
  border: 0;
28
32
  background: transparent;
29
33
  color: var(--muted);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robert-stackflow/oneui",
3
- "version": "0.6.52",
3
+ "version": "0.6.54",
4
4
  "description": "OneUI React components, application shell and portable visual themes",
5
5
  "type": "module",
6
6
  "sideEffects": [
package/styles/base.css CHANGED
@@ -214,10 +214,10 @@
214
214
  --on-danger: #141414;
215
215
  }
216
216
 
217
- /* Public input-mode tokens: compact mouse layouts retain their theme dimensions. */
217
+ /* Touch increases the hit-target floor and editable type, not control density. */
218
218
  @media (pointer: coarse) {
219
219
  :root[data-ui-theme] {
220
- --touch-target-min: 44px;
220
+ --touch-target-min: 24px;
221
221
  --touch-field-font-size: 16px;
222
222
  }
223
223
  }