@tensor_1/react 2.67.3 → 2.68.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.
@@ -1,11 +1,21 @@
1
1
  import * as react from 'react';
2
- import { HTMLAttributes, ReactNode } from 'react';
2
+ import { HTMLAttributes, ReactNode, PointerEvent } from 'react';
3
3
  import { DialogCloseEvent, DiscardPromptLabels } from './DiscardPrompt.js';
4
4
  import './Button.js';
5
5
  import '../link.js';
6
6
  import './Kbd.js';
7
7
  import './ButtonFeedback.js';
8
8
 
9
+ /** Internal (not in index.ts): the side Peek swipes closed the same way since 2.68 (HAR-4659). */
10
+ declare function useDrawerSwipe(side: 'end' | 'start' | 'bottom', canClose: boolean, dismiss: (event: PointerEvent<HTMLDialogElement>) => boolean): {
11
+ settle: (el: HTMLElement) => void;
12
+ handlers: {
13
+ onPointerDown: (e: PointerEvent<HTMLDialogElement>) => void;
14
+ onPointerMove: (e: PointerEvent<HTMLDialogElement>) => void;
15
+ onPointerUp: (e: PointerEvent<HTMLDialogElement>) => void;
16
+ onPointerCancel: (e: PointerEvent<HTMLDialogElement>) => void;
17
+ };
18
+ };
9
19
  interface DrawerProps extends Omit<HTMLAttributes<HTMLDialogElement>, 'title'> {
10
20
  /** TENSOR RX-125 (UIX-04): translatable; English default. */
11
21
  closeLabel?: string;
@@ -44,4 +54,4 @@ interface DrawerProps extends Omit<HTMLAttributes<HTMLDialogElement>, 'title'> {
44
54
  }
45
55
  declare function Drawer({ open, onClose, dirty, pending, discardLabels, dismissOnBackdrop, side, title, children, footer, closeLabel: closeLabelProp, className, onClick, onKeyDown, ...rest }: DrawerProps): react.JSX.Element;
46
56
 
47
- export { Drawer, type DrawerProps };
57
+ export { Drawer, type DrawerProps, useDrawerSwipe };
@@ -174,5 +174,6 @@ function Drawer({
174
174
  );
175
175
  }
176
176
  export {
177
- Drawer
177
+ Drawer,
178
+ useDrawerSwipe
178
179
  };
@@ -17,6 +17,11 @@ interface PeekProps extends Omit<HTMLAttributes<HTMLDialogElement>, 'title'> {
17
17
  onNavNext?: () => void;
18
18
  hint?: string;
19
19
  }
20
- declare function Peek({ open, onClose, title, children, footer, onNavPrev, onNavNext, hint, previousLabel: previousLabelProp, nextLabel: nextLabelProp, closeLabel: closeLabelProp, className, onClick, ...rest }: PeekProps): react.JSX.Element;
20
+ /**
21
+ * The record quick view beside a list. Since 2.68 (HAR-4659) it is the side Drawer's panel: the same
22
+ * floating frame, slide, blurred scrim and swipe-to-close on touch (drawer.css styles `.uix-peek`
23
+ * with `.uix-drawer`), plus what a peek adds: the ↑/↓ record arrows, the hint line and the footer.
24
+ */
25
+ declare function Peek({ open, onClose, title, children, footer, onNavPrev, onNavNext, hint, previousLabel: previousLabelProp, nextLabel: nextLabelProp, closeLabel: closeLabelProp, className, onClick, onPointerDown, onPointerMove, onPointerUp, onPointerCancel, ...rest }: PeekProps): react.JSX.Element;
21
26
 
22
27
  export { Peek, type PeekProps };
@@ -1,14 +1,15 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useId } from "react";
3
+ import { useEffect, useId } from "react";
4
4
  import { cx } from "../cx.js";
5
5
  import { useUixLabels } from "../labels-context.js";
6
6
  import { useDialog } from "../hooks/useDialog.js";
7
7
  import { backdropDismiss } from "../hooks/backdropDismiss.js";
8
+ import { useDrawerSwipe } from "./Drawer.js";
8
9
  const CloseIcon = () => /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M4 4l8 8M12 4l-8 8" }) });
9
10
  const ChevronUp = () => /* @__PURE__ */ jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M2 8l4-4 4 4" }) });
10
11
  const ChevronDown = () => /* @__PURE__ */ jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M2 4l4 4 4-4" }) });
11
- function Peek({ open, onClose, title, children, footer, onNavPrev, onNavNext, hint, previousLabel: previousLabelProp, nextLabel: nextLabelProp, closeLabel: closeLabelProp, className, onClick, ...rest }) {
12
+ function Peek({ open, onClose, title, children, footer, onNavPrev, onNavNext, hint, previousLabel: previousLabelProp, nextLabel: nextLabelProp, closeLabel: closeLabelProp, className, onClick, onPointerDown, onPointerMove, onPointerUp, onPointerCancel, ...rest }) {
12
13
  const uixLabels = useUixLabels();
13
14
  const previousLabel = previousLabelProp ?? uixLabels.peek?.previous ?? "Previous record";
14
15
  const nextLabel = nextLabelProp ?? uixLabels.peek?.next ?? "Next record";
@@ -16,19 +17,53 @@ function Peek({ open, onClose, title, children, footer, onNavPrev, onNavNext, hi
16
17
  const ref = useDialog(open, onClose);
17
18
  const hasNav = onNavPrev != null || onNavNext != null;
18
19
  const titleId = useId();
19
- return /* @__PURE__ */ jsxs("dialog", { ref, className: cx("uix-peek", className), "aria-labelledby": title ? titleId : void 0, ...rest, onClick: backdropDismiss(onClose, onClick), children: [
20
- /* @__PURE__ */ jsxs("div", { className: "uix-peek__header", children: [
21
- hasNav && /* @__PURE__ */ jsxs("div", { className: "uix-peek__nav", children: [
22
- /* @__PURE__ */ jsx("button", { type: "button", className: "uix-peek__navbtn", onClick: () => onNavPrev?.(), "aria-disabled": onNavPrev ? void 0 : true, "aria-label": previousLabel, children: /* @__PURE__ */ jsx(ChevronUp, {}) }),
23
- /* @__PURE__ */ jsx("button", { type: "button", className: "uix-peek__navbtn", onClick: () => onNavNext?.(), "aria-disabled": onNavNext ? void 0 : true, "aria-label": nextLabel, children: /* @__PURE__ */ jsx(ChevronDown, {}) })
24
- ] }),
25
- title && /* @__PURE__ */ jsx("h2", { className: "uix-peek__title", id: titleId, children: title }),
26
- hint && /* @__PURE__ */ jsx("span", { className: "uix-peek__hint", children: hint }),
27
- onClose && /* @__PURE__ */ jsx("button", { type: "button", className: "uix-peek__close", onClick: onClose, "aria-label": closeLabel, children: /* @__PURE__ */ jsx(CloseIcon, {}) })
28
- ] }),
29
- children != null && /* @__PURE__ */ jsx("div", { className: "uix-peek__body", children }),
30
- footer != null && /* @__PURE__ */ jsx("div", { className: "uix-peek__footer", children: footer })
31
- ] });
20
+ const swipe = useDrawerSwipe("end", !!onClose, () => {
21
+ onClose?.();
22
+ return true;
23
+ });
24
+ useEffect(() => {
25
+ const el = ref.current;
26
+ if (open && el) swipe.settle(el);
27
+ }, [open]);
28
+ return /* @__PURE__ */ jsxs(
29
+ "dialog",
30
+ {
31
+ ref,
32
+ className: cx("uix-peek", className),
33
+ "aria-labelledby": title ? titleId : void 0,
34
+ ...rest,
35
+ onClick: backdropDismiss(onClose, onClick),
36
+ onPointerDown: (event) => {
37
+ onPointerDown?.(event);
38
+ swipe.handlers.onPointerDown(event);
39
+ },
40
+ onPointerMove: (event) => {
41
+ onPointerMove?.(event);
42
+ swipe.handlers.onPointerMove(event);
43
+ },
44
+ onPointerUp: (event) => {
45
+ onPointerUp?.(event);
46
+ swipe.handlers.onPointerUp(event);
47
+ },
48
+ onPointerCancel: (event) => {
49
+ onPointerCancel?.(event);
50
+ swipe.handlers.onPointerCancel(event);
51
+ },
52
+ children: [
53
+ /* @__PURE__ */ jsxs("div", { className: "uix-peek__header", children: [
54
+ hasNav && /* @__PURE__ */ jsxs("div", { className: "uix-peek__nav", children: [
55
+ /* @__PURE__ */ jsx("button", { type: "button", className: "uix-peek__navbtn", onClick: () => onNavPrev?.(), "aria-disabled": onNavPrev ? void 0 : true, "aria-label": previousLabel, children: /* @__PURE__ */ jsx(ChevronUp, {}) }),
56
+ /* @__PURE__ */ jsx("button", { type: "button", className: "uix-peek__navbtn", onClick: () => onNavNext?.(), "aria-disabled": onNavNext ? void 0 : true, "aria-label": nextLabel, children: /* @__PURE__ */ jsx(ChevronDown, {}) })
57
+ ] }),
58
+ title && /* @__PURE__ */ jsx("h2", { className: "uix-peek__title", id: titleId, children: title }),
59
+ hint && /* @__PURE__ */ jsx("span", { className: "uix-peek__hint", children: hint }),
60
+ onClose && /* @__PURE__ */ jsx("button", { type: "button", className: "uix-peek__close", onClick: onClose, "aria-label": closeLabel, children: /* @__PURE__ */ jsx(CloseIcon, {}) })
61
+ ] }),
62
+ children != null && /* @__PURE__ */ jsx("div", { className: "uix-peek__body", children }),
63
+ footer != null && /* @__PURE__ */ jsx("div", { className: "uix-peek__footer", children: footer })
64
+ ]
65
+ }
66
+ );
32
67
  }
33
68
  export {
34
69
  Peek
package/dist/index.cjs CHANGED
@@ -7825,7 +7825,7 @@ var import_jsx_runtime36 = require("react/jsx-runtime");
7825
7825
  var CloseIcon3 = () => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("path", { d: "M4 4l8 8M12 4l-8 8" }) });
7826
7826
  var ChevronUp = () => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("path", { d: "M2 8l4-4 4 4" }) });
7827
7827
  var ChevronDown = () => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("path", { d: "M2 4l4 4 4-4" }) });
7828
- function Peek({ open, onClose, title, children, footer, onNavPrev, onNavNext, hint, previousLabel: previousLabelProp, nextLabel: nextLabelProp, closeLabel: closeLabelProp, className, onClick, ...rest }) {
7828
+ function Peek({ open, onClose, title, children, footer, onNavPrev, onNavNext, hint, previousLabel: previousLabelProp, nextLabel: nextLabelProp, closeLabel: closeLabelProp, className, onClick, onPointerDown, onPointerMove, onPointerUp, onPointerCancel, ...rest }) {
7829
7829
  const uixLabels = useUixLabels();
7830
7830
  const previousLabel = previousLabelProp ?? uixLabels.peek?.previous ?? "Previous record";
7831
7831
  const nextLabel = nextLabelProp ?? uixLabels.peek?.next ?? "Next record";
@@ -7833,19 +7833,53 @@ function Peek({ open, onClose, title, children, footer, onNavPrev, onNavNext, hi
7833
7833
  const ref = useDialog(open, onClose);
7834
7834
  const hasNav = onNavPrev != null || onNavNext != null;
7835
7835
  const titleId = (0, import_react47.useId)();
7836
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("dialog", { ref, className: cx("uix-peek", className), "aria-labelledby": title ? titleId : void 0, ...rest, onClick: backdropDismiss(onClose, onClick), children: [
7837
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "uix-peek__header", children: [
7838
- hasNav && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "uix-peek__nav", children: [
7839
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("button", { type: "button", className: "uix-peek__navbtn", onClick: () => onNavPrev?.(), "aria-disabled": onNavPrev ? void 0 : true, "aria-label": previousLabel, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ChevronUp, {}) }),
7840
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("button", { type: "button", className: "uix-peek__navbtn", onClick: () => onNavNext?.(), "aria-disabled": onNavNext ? void 0 : true, "aria-label": nextLabel, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ChevronDown, {}) })
7841
- ] }),
7842
- title && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("h2", { className: "uix-peek__title", id: titleId, children: title }),
7843
- hint && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "uix-peek__hint", children: hint }),
7844
- onClose && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("button", { type: "button", className: "uix-peek__close", onClick: onClose, "aria-label": closeLabel, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(CloseIcon3, {}) })
7845
- ] }),
7846
- children != null && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "uix-peek__body", children }),
7847
- footer != null && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "uix-peek__footer", children: footer })
7848
- ] });
7836
+ const swipe = useDrawerSwipe("end", !!onClose, () => {
7837
+ onClose?.();
7838
+ return true;
7839
+ });
7840
+ (0, import_react47.useEffect)(() => {
7841
+ const el = ref.current;
7842
+ if (open && el) swipe.settle(el);
7843
+ }, [open]);
7844
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
7845
+ "dialog",
7846
+ {
7847
+ ref,
7848
+ className: cx("uix-peek", className),
7849
+ "aria-labelledby": title ? titleId : void 0,
7850
+ ...rest,
7851
+ onClick: backdropDismiss(onClose, onClick),
7852
+ onPointerDown: (event) => {
7853
+ onPointerDown?.(event);
7854
+ swipe.handlers.onPointerDown(event);
7855
+ },
7856
+ onPointerMove: (event) => {
7857
+ onPointerMove?.(event);
7858
+ swipe.handlers.onPointerMove(event);
7859
+ },
7860
+ onPointerUp: (event) => {
7861
+ onPointerUp?.(event);
7862
+ swipe.handlers.onPointerUp(event);
7863
+ },
7864
+ onPointerCancel: (event) => {
7865
+ onPointerCancel?.(event);
7866
+ swipe.handlers.onPointerCancel(event);
7867
+ },
7868
+ children: [
7869
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "uix-peek__header", children: [
7870
+ hasNav && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "uix-peek__nav", children: [
7871
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("button", { type: "button", className: "uix-peek__navbtn", onClick: () => onNavPrev?.(), "aria-disabled": onNavPrev ? void 0 : true, "aria-label": previousLabel, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ChevronUp, {}) }),
7872
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("button", { type: "button", className: "uix-peek__navbtn", onClick: () => onNavNext?.(), "aria-disabled": onNavNext ? void 0 : true, "aria-label": nextLabel, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ChevronDown, {}) })
7873
+ ] }),
7874
+ title && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("h2", { className: "uix-peek__title", id: titleId, children: title }),
7875
+ hint && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "uix-peek__hint", children: hint }),
7876
+ onClose && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("button", { type: "button", className: "uix-peek__close", onClick: onClose, "aria-label": closeLabel, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(CloseIcon3, {}) })
7877
+ ] }),
7878
+ children != null && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "uix-peek__body", children }),
7879
+ footer != null && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "uix-peek__footer", children: footer })
7880
+ ]
7881
+ }
7882
+ );
7849
7883
  }
7850
7884
 
7851
7885
  // src/components/Lightbox.tsx
package/dist/index.d.cts CHANGED
@@ -6357,7 +6357,12 @@ interface PeekProps extends Omit<HTMLAttributes<HTMLDialogElement>, 'title'> {
6357
6357
  onNavNext?: () => void;
6358
6358
  hint?: string;
6359
6359
  }
6360
- declare function Peek({ open, onClose, title, children, footer, onNavPrev, onNavNext, hint, previousLabel: previousLabelProp, nextLabel: nextLabelProp, closeLabel: closeLabelProp, className, onClick, ...rest }: PeekProps): react.JSX.Element;
6360
+ /**
6361
+ * The record quick view beside a list. Since 2.68 (HAR-4659) it is the side Drawer's panel: the same
6362
+ * floating frame, slide, blurred scrim and swipe-to-close on touch (drawer.css styles `.uix-peek`
6363
+ * with `.uix-drawer`), plus what a peek adds: the ↑/↓ record arrows, the hint line and the footer.
6364
+ */
6365
+ declare function Peek({ open, onClose, title, children, footer, onNavPrev, onNavNext, hint, previousLabel: previousLabelProp, nextLabel: nextLabelProp, closeLabel: closeLabelProp, className, onClick, onPointerDown, onPointerMove, onPointerUp, onPointerCancel, ...rest }: PeekProps): react.JSX.Element;
6361
6366
 
6362
6367
  interface CardProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
6363
6368
  title?: ReactNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tensor_1/react",
3
- "version": "2.67.3",
3
+ "version": "2.68.0",
4
4
  "description": "Thin React wrappers over the UIx v2 CSS component library.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",