@plexui/ui 0.41.0 → 0.43.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.
Files changed (79) hide show
  1. package/dist/es/components/Alert/Alert.js +12 -2
  2. package/dist/es/components/Alert/Alert.js.map +1 -1
  3. package/dist/es/components/ColorPicker/ColorPicker.js +12 -10
  4. package/dist/es/components/ColorPicker/ColorPicker.js.map +1 -1
  5. package/dist/es/components/ColorPicker/ColorWell.js +1 -1
  6. package/dist/es/components/ColorPicker/ColorWell.js.map +1 -1
  7. package/dist/es/components/ColorPicker/shared.js +5 -4
  8. package/dist/es/components/ColorPicker/shared.js.map +1 -1
  9. package/dist/es/components/ContextMenu/ContextMenu.js +9 -9
  10. package/dist/es/components/ContextMenu/ContextMenu.js.map +1 -1
  11. package/dist/es/components/ContextMenu/shared.js +25 -5
  12. package/dist/es/components/ContextMenu/shared.js.map +1 -1
  13. package/dist/es/components/DataTable/columnHelpers.js +85 -4
  14. package/dist/es/components/DataTable/columnHelpers.js.map +1 -1
  15. package/dist/es/components/DatePicker/DatePicker.js +3 -3
  16. package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
  17. package/dist/es/components/DatePicker/useCalendarCollisionPadding.js +25 -0
  18. package/dist/es/components/DatePicker/useCalendarCollisionPadding.js.map +1 -0
  19. package/dist/es/components/DateRangePicker/DateRangePicker.js +3 -3
  20. package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
  21. package/dist/es/components/Dialog/Dialog.js +1 -1
  22. package/dist/es/components/Dialog/Dialog.js.map +1 -1
  23. package/dist/es/components/Input/Input.js +1 -1
  24. package/dist/es/components/Input/Input.js.map +1 -1
  25. package/dist/es/components/Menu/Menu.js +15 -2
  26. package/dist/es/components/Menu/Menu.js.map +1 -1
  27. package/dist/es/components/PhoneLayout/PhoneLayout.js +6 -1
  28. package/dist/es/components/PhoneLayout/PhoneLayout.js.map +1 -1
  29. package/dist/es/components/Popover/Popover.js.map +1 -1
  30. package/dist/es/components/ProgressSteps/ProgressSteps.js +1 -1
  31. package/dist/es/components/ProgressSteps/ProgressSteps.js.map +1 -1
  32. package/dist/es/components/ProgressSteps/index.js.map +1 -1
  33. package/dist/es/components/Select/Select.js +155 -25
  34. package/dist/es/components/Select/Select.js.map +1 -1
  35. package/dist/es/components/SelectControl/SelectControl.js +1 -1
  36. package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
  37. package/dist/es/components/Slider/Slider.js +19 -12
  38. package/dist/es/components/Slider/Slider.js.map +1 -1
  39. package/dist/es/components/Sortable/Sortable.js +1 -1
  40. package/dist/es/components/Sortable/Sortable.js.map +1 -1
  41. package/dist/es/components/StatCard/index.js +5 -1
  42. package/dist/es/components/StatCard/index.js.map +1 -1
  43. package/dist/es/components/StatsCard/StatsCard.js +48 -0
  44. package/dist/es/components/StatsCard/StatsCard.js.map +1 -0
  45. package/dist/es/components/StatsCard/index.js +2 -0
  46. package/dist/es/components/StatsCard/index.js.map +1 -0
  47. package/dist/es/components/SwipeActions/SwipeActions.js +30 -8
  48. package/dist/es/components/SwipeActions/SwipeActions.js.map +1 -1
  49. package/dist/es/components/TabBar/TabBar.js +11 -4
  50. package/dist/es/components/TabBar/TabBar.js.map +1 -1
  51. package/dist/es/components/Tabs/Tabs.js +200 -7
  52. package/dist/es/components/Tabs/Tabs.js.map +1 -1
  53. package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
  54. package/dist/es/lib/menuTriggerCover.js +40 -3
  55. package/dist/es/lib/menuTriggerCover.js.map +1 -1
  56. package/dist/types/components/ColorPicker/ColorPicker.d.ts +3 -2
  57. package/dist/types/components/ColorPicker/shared.d.ts +5 -4
  58. package/dist/types/components/ContextMenu/shared.d.ts +28 -6
  59. package/dist/types/components/DatePicker/useCalendarCollisionPadding.d.ts +8 -0
  60. package/dist/types/components/Dialog/Dialog.d.ts +1 -1
  61. package/dist/types/components/PhoneLayout/PhoneLayout.d.ts +5 -0
  62. package/dist/types/components/Popover/Popover.d.ts +2 -2
  63. package/dist/types/components/ProgressSteps/ProgressSteps.d.ts +11 -4
  64. package/dist/types/components/ProgressSteps/index.d.ts +1 -1
  65. package/dist/types/components/Select/Select.d.ts +11 -3
  66. package/dist/types/components/StatCard/index.d.ts +5 -1
  67. package/dist/types/components/{StatCard/StatCard.d.ts → StatsCard/StatsCard.d.ts} +7 -7
  68. package/dist/types/components/StatsCard/index.d.ts +1 -0
  69. package/dist/types/components/SwipeActions/SwipeActions.d.ts +1 -1
  70. package/dist/types/components/TabBar/TabBar.d.ts +12 -2
  71. package/dist/types/components/Tabs/Tabs.d.ts +12 -0
  72. package/dist/types/components/Toolbar/Toolbar.d.ts +1 -1
  73. package/dist/types/lib/menuTriggerCover.d.ts +16 -2
  74. package/package.json +2 -2
  75. package/dist/es/components/DatePicker/useCalendarGutter.js +0 -8
  76. package/dist/es/components/DatePicker/useCalendarGutter.js.map +0 -1
  77. package/dist/es/components/StatCard/StatCard.js +0 -39
  78. package/dist/es/components/StatCard/StatCard.js.map +0 -1
  79. package/dist/types/components/DatePicker/useCalendarGutter.d.ts +0 -1
@@ -10,7 +10,7 @@ import { Menu, useMenuContext, useMenuPhoneLayout } from "../Menu/Menu.js";
10
10
  import { PhoneLayoutContext } from "../PhoneLayout/PhoneLayout.js";
11
11
  import { TransitionGroup } from "../Transition/index.js";
12
12
  import { overlayTiming } from "../Transition/shared.js";
13
- import { CONTEXT_MENU_LONG_PRESS, CONTEXT_MENU_LONG_PRESS_SLOP, contextMenuClipTop, contextMenuFrame, contextMenuHoleMask, contextMenuInFrame, contextMenuName, contextMenuNaturalHeight, contextMenuPlacement, contextMenuPreview, contextMenuPreviewShift, liftContextMenuPreview, } from "./shared.js";
13
+ import { CONTEXT_MENU_LONG_PRESS, CONTEXT_MENU_LONG_PRESS_SLOP, contextMenuClipTop, contextMenuFrame, contextMenuHoleMask, contextMenuInFrame, contextMenuName, contextMenuNaturalHeight, contextMenuPlacement, contextMenuPreview, contextMenuPreviewLayout, liftContextMenuPreview, } from "./shared.js";
14
14
  const ContextMenuContext = createContext(null);
15
15
  function useContextMenuContext(part) {
16
16
  const context = useContext(ContextMenuContext);
@@ -43,7 +43,7 @@ function ContextMenuRoot({ children, forceOpen, onOpen, onClose }) {
43
43
  const preview = current.presentation;
44
44
  if (preview?.kind !== "preview" || preview.shift === undefined)
45
45
  return current;
46
- return { ...current, presentation: { ...preview, rect: { ...preview.rect, y: preview.rect.y + preview.shift }, shift: undefined } };
46
+ return { ...current, presentation: { ...preview, rect: { ...preview.rect, y: preview.rect.y + preview.shift }, side: undefined, shift: undefined } };
47
47
  });
48
48
  }, [drop]);
49
49
  const present = useCallback((element, measure, still = false) => {
@@ -52,7 +52,7 @@ function ContextMenuRoot({ children, forceOpen, onOpen, onClose }) {
52
52
  regionRef.current = element;
53
53
  setShown({ presentation: measure(), frame: contextMenuFrame(container), name: contextMenuName(element) });
54
54
  }, [container, drop]);
55
- const lift = useCallback((shift) => {
55
+ const lift = useCallback((shift, side = "bottom") => {
56
56
  const element = regionRef.current;
57
57
  drop(false);
58
58
  if (element && shift > 0)
@@ -61,7 +61,7 @@ function ContextMenuRoot({ children, forceOpen, onOpen, onClose }) {
61
61
  const preview = current.presentation;
62
62
  if (preview?.kind !== "preview")
63
63
  return current;
64
- return { ...current, presentation: { ...preview, rect: { ...preview.rect, y: preview.rect.y - shift }, shift } };
64
+ return { ...current, presentation: { ...preview, rect: { ...preview.rect, y: preview.rect.y - shift }, side, shift } };
65
65
  });
66
66
  }, [drop]);
67
67
  useEffect(() => () => drop(false), [drop]);
@@ -99,8 +99,7 @@ const suppressNextClick = (doc) => {
99
99
  const forcedPresentation = (element) => {
100
100
  if (!isPhoneLayout(element))
101
101
  return { kind: "keyboard", rect: element.getBoundingClientRect() };
102
- const box = element.getBoundingClientRect();
103
- return contextMenuPreview(element, box.left + box.width / 2);
102
+ return contextMenuPreview(element);
104
103
  };
105
104
  function ContextMenuTrigger({ children, disabled = false }) {
106
105
  const menu = useMenuContext();
@@ -144,7 +143,7 @@ function ContextMenuTrigger({ children, disabled = false }) {
144
143
  present(element, measure);
145
144
  menu.setOpen(true);
146
145
  };
147
- const openPreview = (element, x) => open(element, () => contextMenuPreview(element, x));
146
+ const openPreview = (element) => open(element, () => contextMenuPreview(element));
148
147
  // A touch and hold opens the preview once, by the timer or by the browser's own context menu (Android)
149
148
  const openHeld = (element, current) => {
150
149
  // A Sortable list around the element already turned this hold into a drag
@@ -152,7 +151,7 @@ function ContextMenuTrigger({ children, disabled = false }) {
152
151
  return cancel();
153
152
  window.clearTimeout(current.timer);
154
153
  current.opened = true;
155
- openPreview(element, current.x);
154
+ openPreview(element);
156
155
  // The same hold drags the element where it is a Sortable item: moving on, the finger closes the menu
157
156
  sendContextMenuHold(element, {
158
157
  pointerId: current.id,
@@ -256,7 +255,8 @@ function ContextMenuContent({ "aria-label": ariaLabel, ...props }) {
256
255
  const height = Math.min(contextMenuNaturalHeight(content), limit ?? Infinity) * (box?.scaleY ?? 1);
257
256
  // A room not known yet (no layout) moves nothing
258
257
  const known = bounds && bounds.bottom > bounds.top;
259
- lift(known ? contextMenuPreviewShift(current.rect, height, bounds, contextMenuClipTop(element), box?.scaleY ?? 1) : 0);
258
+ const layout = known ? contextMenuPreviewLayout(current.rect, height, bounds, contextMenuClipTop(element), box?.scaleY ?? 1) : null;
259
+ lift(layout?.shift ?? 0, layout?.side);
260
260
  };
261
261
  measure();
262
262
  return () => cancelAnimationFrame(frame);
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenu.js","sourceRoot":"","sources":["../../../../src/components/ContextMenu/ContextMenu.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GAOT,MAAM,OAAO,CAAA;AACd,OAAO,CAAC,MAAM,8DA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U;wBAAE,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;gBAC1F,CAAC,GACD,IACD,CACJ,CAAA;AACH,CAAC;AACD,kBAAkB,CAAC,WAAW,GAAG,qBAAqB,CAAA;AAEtD,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE;IACxD,OAAO,EAAE,kBAAkB;IAC3B,OAAO,EAAE,kBAAkB;IAC3B,IAAI,EAAE,IAAI,CAAC,IAAI;IACf,IAAI,EAAE,IAAI,CAAC,IAAI;IACf,SAAS,EAAE,IAAI,CAAC,SAAS;IACzB,KAAK,EAAE,IAAI,CAAC,KAAK;IACjB,KAAK,EAAE,IAAI,CAAC,KAAK;IACjB,GAAG,EAAE,IAAI,CAAC,GAAG;IACb,UAAU,EAAE,IAAI,CAAC,UAAU;IAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;IAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;IAC/B,UAAU,EAAE,IAAI,CAAC,UAAU;IAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;CAC1B,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport { Portal, Slot } from \"radix-ui\"\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type MouseEvent as ReactMouseEvent,\n type PointerEvent as ReactPointerEvent,\n type ReactElement,\n type ReactNode,\n type RefObject,\n} from \"react\"\nimport s from \"@plexui/styles/components/ContextMenu/ContextMenu.module.css\"\nimport { CONTEXT_MENU_TRIGGER, SORTABLE_HANDLE, SORTABLE_SOURCE, sendContextMenuHold } from \"../../lib/contextMenuHold\"\nimport { readMenuBoundaryRect } from \"../../lib/menuSubmenuPlacement\"\nimport { isPhoneLayout } from \"../../lib/phoneLayout\"\nimport { Menu, useMenuContext, useMenuPhoneLayout, type MenuContentProps } from \"../Menu/Menu\"\nimport { PhoneLayoutContext } from \"../PhoneLayout/PhoneLayout\"\nimport { TransitionGroup } from \"../Transition\"\nimport { overlayTiming } from \"../Transition/shared\"\nimport {\n CONTEXT_MENU_LONG_PRESS,\n CONTEXT_MENU_LONG_PRESS_SLOP,\n contextMenuClipTop,\n contextMenuFrame,\n contextMenuHoleMask,\n contextMenuInFrame,\n contextMenuName,\n contextMenuNaturalHeight,\n contextMenuPlacement,\n contextMenuPreview,\n contextMenuPreviewShift,\n liftContextMenuPreview,\n type ContextMenuFrame,\n type ContextMenuPresentation,\n} from \"./shared\"\n\ntype Shown = { presentation: ContextMenuPresentation | null; frame: ContextMenuFrame | null; name: string }\n\ntype ContextMenuContextValue = Shown & {\n /**\n * Shows the menu for the element as `measure` places it, once a raised preview is back in its place. A menu held\n * open is placed again as the page moves, and its preview moves up without gliding.\n */\n present: (element: HTMLElement, measure: () => ContextMenuPresentation, held?: boolean) => void\n /** Moves the preview up by `shift`, so that the menu stands whole below it */\n lift: (shift: number) => void\n /** Puts a raised preview back in its place, gliding or at once */\n drop: (glide: boolean) => void\n /** Puts a raised preview back at once and forgets its move, for content that goes away while the element stays */\n release: () => void\n regionRef: RefObject<HTMLElement | null>\n container: HTMLElement | null\n forced: boolean\n}\n\nconst ContextMenuContext = createContext<ContextMenuContextValue | null>(null)\n\nfunction useContextMenuContext(part: string) {\n const context = useContext(ContextMenuContext)\n if (!context) throw new Error(`${part} must be used within ContextMenu`)\n return context\n}\n\nexport type ContextMenuProps = {\n /** `ContextMenu.Trigger` and `ContextMenu.Content`. */\n children: ReactNode\n /**\n * Holds the menu open (`true`) or closed (`false`). Held open without a press, it stands at the element: as the\n * touch-and-hold preview on a phone, under the element elsewhere, and it follows the element as the page scrolls.\n */\n forceOpen?: boolean\n /** Called when the menu opens. */\n onOpen?: () => void\n /** Called when the menu closes. */\n onClose?: () => void\n}\n\n/**\n * A menu of actions for an element, after the iOS 26 kit Context Menu (507:25994): a secondary click opens it at\n * the pointer, a touch and hold opens it beside the element, which stays clear above a dimmed, blurred page, as\n * iOS lifts the preview. The items are the ones of `Menu`.\n */\nfunction ContextMenuRoot({ children, forceOpen, onOpen, onClose }: ContextMenuProps) {\n const [shown, setShown] = useState<Shown>({ presentation: null, frame: null, name: \"\" })\n const regionRef = useRef<HTMLElement | null>(null)\n // Inside a PhoneLayout the anchor and the dimming lie in its box, as the menu does\n const container = useContext(PhoneLayoutContext)?.container ?? null\n const restore = useRef<((glide: boolean) => void) | null>(null)\n const held = useRef(false)\n\n // Puts the element back; after a glide back the restore stays, so that a press or a close that follows stops it\n const drop = useCallback((glide: boolean) => {\n const current = restore.current\n current?.(glide)\n restore.current = glide ? current : null\n }, [])\n // The content going away while the element stays: the element back in place, and measured anew when it returns\n const release = useCallback(() => {\n drop(false)\n setShown((current) => {\n const preview = current.presentation\n if (preview?.kind !== \"preview\" || preview.shift === undefined) return current\n return { ...current, presentation: { ...preview, rect: { ...preview.rect, y: preview.rect.y + preview.shift }, shift: undefined } }\n })\n }, [drop])\n const present = useCallback((element: HTMLElement, measure: () => ContextMenuPresentation, still = false) => {\n drop(false)\n held.current = still\n regionRef.current = element\n setShown({ presentation: measure(), frame: contextMenuFrame(container), name: contextMenuName(element) })\n }, [container, drop])\n const lift = useCallback((shift: number) => {\n const element = regionRef.current\n drop(false)\n if (element && shift > 0) restore.current = liftContextMenuPreview(element, shift, !held.current)\n setShown((current) => {\n const preview = current.presentation\n if (preview?.kind !== \"preview\") return current\n return { ...current, presentation: { ...preview, rect: { ...preview.rect, y: preview.rect.y - shift }, shift } }\n })\n }, [drop])\n useEffect(() => () => drop(false), [drop])\n\n const value = useMemo(\n () => ({ ...shown, present, lift, drop, release, regionRef, container, forced: forceOpen === true }),\n [shown, present, lift, drop, release, container, forceOpen],\n )\n return (\n <ContextMenuContext.Provider value={value}>\n <Menu forceOpen={forceOpen} onOpen={onOpen} onClose={onClose}>{children}</Menu>\n </ContextMenuContext.Provider>\n )\n}\nContextMenuRoot.displayName = \"ContextMenu\"\n\nexport type ContextMenuTriggerProps = {\n /** The element the menu is for; it receives the handlers, so it keeps its own role and focus. */\n children: ReactElement\n /** When `true`, the element keeps the browser's own context menu. */\n disabled?: boolean\n}\n\ntype Press = { id: number; x: number; y: number; timer: number; opened: boolean }\n\n/**\n * Swallows the mouse events a browser sends after the touch and hold that opened the menu: the compatibility mousedown\n * would focus the element under the finger, and focus leaving the menu closes it (inside a Dialog or a Sheet, whose\n * content takes the press), and the click would activate the element.\n */\nconst suppressNextClick = (doc: Document) => {\n const hold = (event: Event) => {\n event.preventDefault()\n event.stopPropagation()\n }\n const swallow = (event: Event) => {\n hold(event)\n stop()\n }\n const stop = () => {\n doc.removeEventListener(\"mousedown\", hold, true)\n doc.removeEventListener(\"click\", swallow, true)\n doc.removeEventListener(\"pointerdown\", stop, true)\n window.clearTimeout(timer)\n }\n // A browser that sends no click after the hold must not swallow the next tap: a new press ends the wait too.\n const timer = window.setTimeout(stop, 600)\n doc.addEventListener(\"mousedown\", hold, true)\n doc.addEventListener(\"click\", swallow, true)\n doc.addEventListener(\"pointerdown\", stop, true)\n}\n\n/** A menu held open without a press: the touch-and-hold preview on a phone, under the element elsewhere. */\nconst forcedPresentation = (element: HTMLElement): ContextMenuPresentation => {\n if (!isPhoneLayout(element)) return { kind: \"keyboard\", rect: element.getBoundingClientRect() }\n const box = element.getBoundingClientRect()\n return contextMenuPreview(element, box.left + box.width / 2)\n}\n\nfunction ContextMenuTrigger({ children, disabled = false }: ContextMenuTriggerProps) {\n const menu = useMenuContext()\n const { present, drop, forced } = useContextMenuContext(\"ContextMenu.Trigger\")\n const press = useRef<Press | null>(null)\n // The element, as state: a menu held open follows the element the trigger has now\n const [element, setElement] = useState<HTMLElement | null>(null)\n\n const cancel = () => {\n if (press.current) window.clearTimeout(press.current.timer)\n press.current = null\n }\n useEffect(() => () => {\n if (press.current) window.clearTimeout(press.current.timer)\n }, [])\n\n // A menu held open stands at the element, and follows it as the page around it scrolls or the window changes\n useLayoutEffect(() => {\n if (!forced || !element) return\n const doc = element.ownerDocument\n const view = doc.defaultView\n const place = () => present(element, () => forcedPresentation(element), true)\n place()\n let frame = 0\n const follow = (event: Event) => {\n if (event.target instanceof Node && event.target !== doc && !event.target.contains(element)) return\n view?.cancelAnimationFrame(frame)\n frame = view?.requestAnimationFrame(place) ?? 0\n }\n view?.addEventListener(\"resize\", follow)\n doc.addEventListener(\"scroll\", follow, { capture: true, passive: true })\n return () => {\n view?.cancelAnimationFrame(frame)\n view?.removeEventListener(\"resize\", follow)\n doc.removeEventListener(\"scroll\", follow, { capture: true })\n }\n }, [forced, present, element])\n\n const open = (element: HTMLElement, measure: () => ContextMenuPresentation) => {\n present(element, measure)\n menu.setOpen(true)\n }\n const openPreview = (element: HTMLElement, x: number) => open(element, () => contextMenuPreview(element, x))\n // A touch and hold opens the preview once, by the timer or by the browser's own context menu (Android)\n const openHeld = (element: HTMLElement, current: Press) => {\n // A Sortable list around the element already turned this hold into a drag\n if (element.ownerDocument.querySelector(SORTABLE_SOURCE)) return cancel()\n window.clearTimeout(current.timer)\n current.opened = true\n openPreview(element, current.x)\n // The same hold drags the element where it is a Sortable item: moving on, the finger closes the menu\n sendContextMenuHold(element, {\n pointerId: current.id,\n close: () => {\n drop(false)\n menu.setOpen(false)\n },\n })\n }\n\n const handlers = {\n [CONTEXT_MENU_TRIGGER]: disabled ? undefined : \"\",\n onPointerDown: (event: ReactPointerEvent<HTMLElement>) => {\n if (event.defaultPrevented || disabled || event.pointerType !== \"touch\" || !event.isPrimary) return\n // The grip of a Sortable item drags at once\n if (event.target instanceof Element && event.target.closest(SORTABLE_HANDLE)) return\n cancel()\n const element = event.currentTarget\n const x = event.clientX\n const timer = window.setTimeout(() => {\n const current = press.current\n if (current && current.timer === timer) openHeld(element, current)\n }, CONTEXT_MENU_LONG_PRESS)\n press.current = { id: event.pointerId, x, y: event.clientY, timer, opened: false }\n },\n onPointerMove: (event: ReactPointerEvent<HTMLElement>) => {\n const current = press.current\n if (!current || current.id !== event.pointerId || current.opened) return\n if (Math.hypot(event.clientX - current.x, event.clientY - current.y) > CONTEXT_MENU_LONG_PRESS_SLOP) cancel()\n },\n onPointerUp: (event: ReactPointerEvent<HTMLElement>) => {\n const current = press.current\n if (!current || current.id !== event.pointerId) return\n if (current.opened) suppressNextClick(event.currentTarget.ownerDocument)\n cancel()\n },\n onPointerCancel: (event: ReactPointerEvent<HTMLElement>) => {\n if (press.current?.id === event.pointerId) cancel()\n },\n onContextMenu: (event: ReactMouseEvent<HTMLElement>) => {\n if (event.defaultPrevented || disabled) return\n event.preventDefault()\n const element = event.currentTarget\n // A touch and hold that the browser reports as a context menu (Android) opens the preview once.\n const current = press.current\n if (current) {\n if (!current.opened) openHeld(element, current)\n return\n }\n if (menu.isUsingKeyboard.current) return open(element, () => ({ kind: \"keyboard\", rect: element.getBoundingClientRect() }))\n const { clientX, clientY } = event\n open(element, () => ({ kind: \"pointer\", rect: { x: clientX, y: clientY, width: 0, height: 0 } }))\n },\n }\n\n return <Slot.Root ref={setElement} className={s.Trigger} {...handlers}>{children}</Slot.Root>\n}\nContextMenuTrigger.displayName = \"ContextMenu.Trigger\"\n\n/** The props of `Menu.Content` but its placement, which follows how the menu opened. */\nexport type ContextMenuContentProps = Omit<MenuContentProps, \"side\" | \"sideOffset\" | \"align\" | \"alignOffset\" | \"onCloseAutoFocus\" | \"layout\" | \"size\"> & {\n /** Names the menu for assistive technology. Without it the menu takes the name of its element. */\n \"aria-label\"?: string\n}\n\nfunction ContextMenuContent({ \"aria-label\": ariaLabel, ...props }: ContextMenuContentProps) {\n const { open } = useMenuContext()\n const { presentation, frame, name, regionRef, container, lift, drop, release } = useContextMenuContext(\"ContextMenu.Content\")\n const anchorRef = useRef<HTMLSpanElement>(null)\n const { boundary } = useMenuPhoneLayout(open)\n const rect = presentation?.rect\n const placement = contextMenuPlacement(presentation)\n const preview = presentation?.kind === \"preview\" ? presentation : null\n const dimmed = open && preview !== null\n const pending = open && preview !== null && preview.shift === undefined\n const maxHeight = props.maxHeight\n\n // The preview moves up so that the menu stands whole below it, measured as the menu first lays out, before it shows\n const latest = useRef({ preview, boundary, maxHeight, frame })\n latest.current = { preview, boundary, maxHeight, frame }\n useLayoutEffect(() => {\n if (!pending) return\n let frame = 0\n const measure = () => {\n const { preview: current, boundary: room, maxHeight: limit, frame: box } = latest.current\n const element = regionRef.current\n const anchor = anchorRef.current\n if (!current || current.shift !== undefined || !element) return\n const content = anchor?.ownerDocument.getElementById(anchor.getAttribute(\"aria-controls\") ?? \"\")\n // The menu of a PhoneLayout mounts a frame later, with the box it portals into, and content mounted again while\n // the menu is open finds its anchor (in a portal) a frame later too\n if (!content) {\n frame = requestAnimationFrame(measure)\n return\n }\n const bounds = readMenuBoundaryRect(element.ownerDocument, room)\n // On the screen, as the room is: a PhoneLayout drawn smaller draws the menu smaller too\n const height = Math.min(contextMenuNaturalHeight(content), limit ?? Infinity) * (box?.scaleY ?? 1)\n // A room not known yet (no layout) moves nothing\n const known = bounds && bounds.bottom > bounds.top\n lift(known ? contextMenuPreviewShift(current.rect, height, bounds, contextMenuClipTop(element), box?.scaleY ?? 1) : 0)\n }\n measure()\n return () => cancelAnimationFrame(frame)\n }, [pending, lift, regionRef])\n useLayoutEffect(() => {\n if (!open) drop(true)\n }, [open, drop])\n // The content going away while the element stays puts the element back\n useLayoutEffect(() => release, [release])\n\n const local = (box: NonNullable<typeof rect>) => contextMenuInFrame(box, frame)\n const anchor = rect ? local(rect) : undefined\n const hole = preview && { ...preview, rect: local(preview.rect), radius: preview.radius / (frame?.scaleX ?? 1) }\n const viewport = frame ? { width: frame.width, height: frame.height } : undefined\n const label = ariaLabel ?? name\n\n return (\n <>\n {/* The menu is placed against this invisible box: the pointer, or the element. It names the menu. */}\n <Portal.Root asChild container={container}>\n <Menu.Trigger>\n <span\n ref={anchorRef}\n aria-hidden=\"true\"\n aria-label={label || undefined}\n tabIndex={-1}\n className={s.Anchor}\n style={anchor ? { left: anchor.x, top: anchor.y, width: anchor.width, height: anchor.height } : undefined}\n />\n </Menu.Trigger>\n </Portal.Root>\n <Portal.Root asChild container={container}>\n <TransitionGroup className={s.Dimming} {...overlayTiming}>\n {dimmed && hole && (\n <div key=\"dimming\" data-context-menu-dimming=\"\" className={s.Overlay} style={contextMenuHoleMask(hole, viewport) as CSSProperties}>\n <div\n className={s.Preview}\n style={{ left: hole.rect.x, top: hole.rect.y, width: hole.rect.width, height: hole.rect.height, borderRadius: hole.radius }}\n />\n </div>\n )}\n </TransitionGroup>\n </Portal.Root>\n <Menu.Content\n {...props}\n {...placement}\n onCloseAutoFocus={(event) => {\n // Focus goes back to the element only when the keyboard opened the menu; a pointer leaves it where it was.\n event.preventDefault()\n if (presentation?.kind === \"keyboard\") regionRef.current?.focus({ preventScroll: true })\n }}\n />\n </>\n )\n}\nContextMenuContent.displayName = \"ContextMenu.Content\"\n\nexport const ContextMenu = Object.assign(ContextMenuRoot, {\n Trigger: ContextMenuTrigger,\n Content: ContextMenuContent,\n Item: Menu.Item,\n Link: Menu.Link,\n Separator: Menu.Separator,\n Label: Menu.Label,\n Group: Menu.Group,\n Sub: Menu.Sub,\n SubTrigger: Menu.SubTrigger,\n SubContent: Menu.SubContent,\n CheckboxItem: Menu.CheckboxItem,\n RadioGroup: Menu.RadioGroup,\n RadioItem: Menu.RadioItem,\n})\n"]}
1
+ {"version":3,"file":"ContextMenu.js","sourceRoot":"","sources":["../../../../src/components/ContextMenu/ContextMenu.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GAOT,MAAM,OAAO,CAAA;AACd,OAAO,CAAC,MAAM,8DAA8D,CAAA;AAC5E,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AACv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C;AACD,kBAAkB,CAAC,WAAW,GAAG,qBAAqB,CAAA;AAEtD,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE;IACxD,OAAO,EAAE,kBAAkB;IAC3B,OAAO,EAAE,kBAAkB;IAC3B,IAAI,EAAE,IAAI,CAAC,IAAI;IACf,IAAI,EAAE,IAAI,CAAC,IAAI;IACf,SAAS,EAAE,IAAI,CAAC,SAAS;IACzB,KAAK,EAAE,IAAI,CAAC,KAAK;IACjB,KAAK,EAAE,IAAI,CAAC,KAAK;IACjB,GAAG,EAAE,IAAI,CAAC,GAAG;IACb,UAAU,EAAE,IAAI,CAAC,UAAU;IAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;IAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;IAC/B,UAAU,EAAE,IAAI,CAAC,UAAU;IAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;CAC1B,CAAC,CAAA","sourcesContent":["\"use client\"\n\nimport { Portal, Slot } from \"radix-ui\"\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type MouseEvent as ReactMouseEvent,\n type PointerEvent as ReactPointerEvent,\n type ReactElement,\n type ReactNode,\n type RefObject,\n} from \"react\"\nimport s from \"@plexui/styles/components/ContextMenu/ContextMenu.module.css\"\nimport { CONTEXT_MENU_TRIGGER, SORTABLE_HANDLE, SORTABLE_SOURCE, sendContextMenuHold } from \"../../lib/contextMenuHold\"\nimport { readMenuBoundaryRect } from \"../../lib/menuSubmenuPlacement\"\nimport { isPhoneLayout } from \"../../lib/phoneLayout\"\nimport { Menu, useMenuContext, useMenuPhoneLayout, type MenuContentProps } from \"../Menu/Menu\"\nimport { PhoneLayoutContext } from \"../PhoneLayout/PhoneLayout\"\nimport { TransitionGroup } from \"../Transition\"\nimport { overlayTiming } from \"../Transition/shared\"\nimport {\n CONTEXT_MENU_LONG_PRESS,\n CONTEXT_MENU_LONG_PRESS_SLOP,\n contextMenuClipTop,\n contextMenuFrame,\n contextMenuHoleMask,\n contextMenuInFrame,\n contextMenuName,\n contextMenuNaturalHeight,\n contextMenuPlacement,\n contextMenuPreview,\n contextMenuPreviewLayout,\n liftContextMenuPreview,\n type ContextMenuFrame,\n type ContextMenuPresentation,\n} from \"./shared\"\n\ntype Shown = { presentation: ContextMenuPresentation | null; frame: ContextMenuFrame | null; name: string }\n\ntype ContextMenuContextValue = Shown & {\n /**\n * Shows the menu for the element as `measure` places it, once a raised preview is back in its place. A menu held\n * open is placed again as the page moves, and its preview moves up without gliding.\n */\n present: (element: HTMLElement, measure: () => ContextMenuPresentation, held?: boolean) => void\n /** Moves the preview up by `shift`, so that the menu stands whole below it */\n lift: (shift: number, side?: \"top\" | \"bottom\") => void\n /** Puts a raised preview back in its place, gliding or at once */\n drop: (glide: boolean) => void\n /** Puts a raised preview back at once and forgets its move, for content that goes away while the element stays */\n release: () => void\n regionRef: RefObject<HTMLElement | null>\n container: HTMLElement | null\n forced: boolean\n}\n\nconst ContextMenuContext = createContext<ContextMenuContextValue | null>(null)\n\nfunction useContextMenuContext(part: string) {\n const context = useContext(ContextMenuContext)\n if (!context) throw new Error(`${part} must be used within ContextMenu`)\n return context\n}\n\nexport type ContextMenuProps = {\n /** `ContextMenu.Trigger` and `ContextMenu.Content`. */\n children: ReactNode\n /**\n * Holds the menu open (`true`) or closed (`false`). Held open without a press, it stands at the element: as the\n * touch-and-hold preview on a phone, under the element elsewhere, and it follows the element as the page scrolls.\n */\n forceOpen?: boolean\n /** Called when the menu opens. */\n onOpen?: () => void\n /** Called when the menu closes. */\n onClose?: () => void\n}\n\n/**\n * A menu of actions for an element, after the iOS 26 kit Context Menu (507:25994): a secondary click opens it at\n * the pointer, a touch and hold opens it beside the element, which stays clear above a dimmed, blurred page, as\n * iOS lifts the preview. The items are the ones of `Menu`.\n */\nfunction ContextMenuRoot({ children, forceOpen, onOpen, onClose }: ContextMenuProps) {\n const [shown, setShown] = useState<Shown>({ presentation: null, frame: null, name: \"\" })\n const regionRef = useRef<HTMLElement | null>(null)\n // Inside a PhoneLayout the anchor and the dimming lie in its box, as the menu does\n const container = useContext(PhoneLayoutContext)?.container ?? null\n const restore = useRef<((glide: boolean) => void) | null>(null)\n const held = useRef(false)\n\n // Puts the element back; after a glide back the restore stays, so that a press or a close that follows stops it\n const drop = useCallback((glide: boolean) => {\n const current = restore.current\n current?.(glide)\n restore.current = glide ? current : null\n }, [])\n // The content going away while the element stays: the element back in place, and measured anew when it returns\n const release = useCallback(() => {\n drop(false)\n setShown((current) => {\n const preview = current.presentation\n if (preview?.kind !== \"preview\" || preview.shift === undefined) return current\n return { ...current, presentation: { ...preview, rect: { ...preview.rect, y: preview.rect.y + preview.shift }, side: undefined, shift: undefined } }\n })\n }, [drop])\n const present = useCallback((element: HTMLElement, measure: () => ContextMenuPresentation, still = false) => {\n drop(false)\n held.current = still\n regionRef.current = element\n setShown({ presentation: measure(), frame: contextMenuFrame(container), name: contextMenuName(element) })\n }, [container, drop])\n const lift = useCallback((shift: number, side: \"top\" | \"bottom\" = \"bottom\") => {\n const element = regionRef.current\n drop(false)\n if (element && shift > 0) restore.current = liftContextMenuPreview(element, shift, !held.current)\n setShown((current) => {\n const preview = current.presentation\n if (preview?.kind !== \"preview\") return current\n return { ...current, presentation: { ...preview, rect: { ...preview.rect, y: preview.rect.y - shift }, side, shift } }\n })\n }, [drop])\n useEffect(() => () => drop(false), [drop])\n\n const value = useMemo(\n () => ({ ...shown, present, lift, drop, release, regionRef, container, forced: forceOpen === true }),\n [shown, present, lift, drop, release, container, forceOpen],\n )\n return (\n <ContextMenuContext.Provider value={value}>\n <Menu forceOpen={forceOpen} onOpen={onOpen} onClose={onClose}>{children}</Menu>\n </ContextMenuContext.Provider>\n )\n}\nContextMenuRoot.displayName = \"ContextMenu\"\n\nexport type ContextMenuTriggerProps = {\n /** The element the menu is for; it receives the handlers, so it keeps its own role and focus. */\n children: ReactElement\n /** When `true`, the element keeps the browser's own context menu. */\n disabled?: boolean\n}\n\ntype Press = { id: number; x: number; y: number; timer: number; opened: boolean }\n\n/**\n * Swallows the mouse events a browser sends after the touch and hold that opened the menu: the compatibility mousedown\n * would focus the element under the finger, and focus leaving the menu closes it (inside a Dialog or a Sheet, whose\n * content takes the press), and the click would activate the element.\n */\nconst suppressNextClick = (doc: Document) => {\n const hold = (event: Event) => {\n event.preventDefault()\n event.stopPropagation()\n }\n const swallow = (event: Event) => {\n hold(event)\n stop()\n }\n const stop = () => {\n doc.removeEventListener(\"mousedown\", hold, true)\n doc.removeEventListener(\"click\", swallow, true)\n doc.removeEventListener(\"pointerdown\", stop, true)\n window.clearTimeout(timer)\n }\n // A browser that sends no click after the hold must not swallow the next tap: a new press ends the wait too.\n const timer = window.setTimeout(stop, 600)\n doc.addEventListener(\"mousedown\", hold, true)\n doc.addEventListener(\"click\", swallow, true)\n doc.addEventListener(\"pointerdown\", stop, true)\n}\n\n/** A menu held open without a press: the touch-and-hold preview on a phone, under the element elsewhere. */\nconst forcedPresentation = (element: HTMLElement): ContextMenuPresentation => {\n if (!isPhoneLayout(element)) return { kind: \"keyboard\", rect: element.getBoundingClientRect() }\n return contextMenuPreview(element)\n}\n\nfunction ContextMenuTrigger({ children, disabled = false }: ContextMenuTriggerProps) {\n const menu = useMenuContext()\n const { present, drop, forced } = useContextMenuContext(\"ContextMenu.Trigger\")\n const press = useRef<Press | null>(null)\n // The element, as state: a menu held open follows the element the trigger has now\n const [element, setElement] = useState<HTMLElement | null>(null)\n\n const cancel = () => {\n if (press.current) window.clearTimeout(press.current.timer)\n press.current = null\n }\n useEffect(() => () => {\n if (press.current) window.clearTimeout(press.current.timer)\n }, [])\n\n // A menu held open stands at the element, and follows it as the page around it scrolls or the window changes\n useLayoutEffect(() => {\n if (!forced || !element) return\n const doc = element.ownerDocument\n const view = doc.defaultView\n const place = () => present(element, () => forcedPresentation(element), true)\n place()\n let frame = 0\n const follow = (event: Event) => {\n if (event.target instanceof Node && event.target !== doc && !event.target.contains(element)) return\n view?.cancelAnimationFrame(frame)\n frame = view?.requestAnimationFrame(place) ?? 0\n }\n view?.addEventListener(\"resize\", follow)\n doc.addEventListener(\"scroll\", follow, { capture: true, passive: true })\n return () => {\n view?.cancelAnimationFrame(frame)\n view?.removeEventListener(\"resize\", follow)\n doc.removeEventListener(\"scroll\", follow, { capture: true })\n }\n }, [forced, present, element])\n\n const open = (element: HTMLElement, measure: () => ContextMenuPresentation) => {\n present(element, measure)\n menu.setOpen(true)\n }\n const openPreview = (element: HTMLElement) => open(element, () => contextMenuPreview(element))\n // A touch and hold opens the preview once, by the timer or by the browser's own context menu (Android)\n const openHeld = (element: HTMLElement, current: Press) => {\n // A Sortable list around the element already turned this hold into a drag\n if (element.ownerDocument.querySelector(SORTABLE_SOURCE)) return cancel()\n window.clearTimeout(current.timer)\n current.opened = true\n openPreview(element)\n // The same hold drags the element where it is a Sortable item: moving on, the finger closes the menu\n sendContextMenuHold(element, {\n pointerId: current.id,\n close: () => {\n drop(false)\n menu.setOpen(false)\n },\n })\n }\n\n const handlers = {\n [CONTEXT_MENU_TRIGGER]: disabled ? undefined : \"\",\n onPointerDown: (event: ReactPointerEvent<HTMLElement>) => {\n if (event.defaultPrevented || disabled || event.pointerType !== \"touch\" || !event.isPrimary) return\n // The grip of a Sortable item drags at once\n if (event.target instanceof Element && event.target.closest(SORTABLE_HANDLE)) return\n cancel()\n const element = event.currentTarget\n const x = event.clientX\n const timer = window.setTimeout(() => {\n const current = press.current\n if (current && current.timer === timer) openHeld(element, current)\n }, CONTEXT_MENU_LONG_PRESS)\n press.current = { id: event.pointerId, x, y: event.clientY, timer, opened: false }\n },\n onPointerMove: (event: ReactPointerEvent<HTMLElement>) => {\n const current = press.current\n if (!current || current.id !== event.pointerId || current.opened) return\n if (Math.hypot(event.clientX - current.x, event.clientY - current.y) > CONTEXT_MENU_LONG_PRESS_SLOP) cancel()\n },\n onPointerUp: (event: ReactPointerEvent<HTMLElement>) => {\n const current = press.current\n if (!current || current.id !== event.pointerId) return\n if (current.opened) suppressNextClick(event.currentTarget.ownerDocument)\n cancel()\n },\n onPointerCancel: (event: ReactPointerEvent<HTMLElement>) => {\n if (press.current?.id === event.pointerId) cancel()\n },\n onContextMenu: (event: ReactMouseEvent<HTMLElement>) => {\n if (event.defaultPrevented || disabled) return\n event.preventDefault()\n const element = event.currentTarget\n // A touch and hold that the browser reports as a context menu (Android) opens the preview once.\n const current = press.current\n if (current) {\n if (!current.opened) openHeld(element, current)\n return\n }\n if (menu.isUsingKeyboard.current) return open(element, () => ({ kind: \"keyboard\", rect: element.getBoundingClientRect() }))\n const { clientX, clientY } = event\n open(element, () => ({ kind: \"pointer\", rect: { x: clientX, y: clientY, width: 0, height: 0 } }))\n },\n }\n\n return <Slot.Root ref={setElement} className={s.Trigger} {...handlers}>{children}</Slot.Root>\n}\nContextMenuTrigger.displayName = \"ContextMenu.Trigger\"\n\n/** The props of `Menu.Content` but its placement, which follows how the menu opened. */\nexport type ContextMenuContentProps = Omit<MenuContentProps, \"side\" | \"sideOffset\" | \"align\" | \"alignOffset\" | \"onCloseAutoFocus\" | \"layout\" | \"size\"> & {\n /** Names the menu for assistive technology. Without it the menu takes the name of its element. */\n \"aria-label\"?: string\n}\n\nfunction ContextMenuContent({ \"aria-label\": ariaLabel, ...props }: ContextMenuContentProps) {\n const { open } = useMenuContext()\n const { presentation, frame, name, regionRef, container, lift, drop, release } = useContextMenuContext(\"ContextMenu.Content\")\n const anchorRef = useRef<HTMLSpanElement>(null)\n const { boundary } = useMenuPhoneLayout(open)\n const rect = presentation?.rect\n const placement = contextMenuPlacement(presentation)\n const preview = presentation?.kind === \"preview\" ? presentation : null\n const dimmed = open && preview !== null\n const pending = open && preview !== null && preview.shift === undefined\n const maxHeight = props.maxHeight\n\n // The preview moves up so that the menu stands whole below it, measured as the menu first lays out, before it shows\n const latest = useRef({ preview, boundary, maxHeight, frame })\n latest.current = { preview, boundary, maxHeight, frame }\n useLayoutEffect(() => {\n if (!pending) return\n let frame = 0\n const measure = () => {\n const { preview: current, boundary: room, maxHeight: limit, frame: box } = latest.current\n const element = regionRef.current\n const anchor = anchorRef.current\n if (!current || current.shift !== undefined || !element) return\n const content = anchor?.ownerDocument.getElementById(anchor.getAttribute(\"aria-controls\") ?? \"\")\n // The menu of a PhoneLayout mounts a frame later, with the box it portals into, and content mounted again while\n // the menu is open finds its anchor (in a portal) a frame later too\n if (!content) {\n frame = requestAnimationFrame(measure)\n return\n }\n const bounds = readMenuBoundaryRect(element.ownerDocument, room)\n // On the screen, as the room is: a PhoneLayout drawn smaller draws the menu smaller too\n const height = Math.min(contextMenuNaturalHeight(content), limit ?? Infinity) * (box?.scaleY ?? 1)\n // A room not known yet (no layout) moves nothing\n const known = bounds && bounds.bottom > bounds.top\n const layout = known ? contextMenuPreviewLayout(current.rect, height, bounds, contextMenuClipTop(element), box?.scaleY ?? 1) : null\n lift(layout?.shift ?? 0, layout?.side)\n }\n measure()\n return () => cancelAnimationFrame(frame)\n }, [pending, lift, regionRef])\n useLayoutEffect(() => {\n if (!open) drop(true)\n }, [open, drop])\n // The content going away while the element stays puts the element back\n useLayoutEffect(() => release, [release])\n\n const local = (box: NonNullable<typeof rect>) => contextMenuInFrame(box, frame)\n const anchor = rect ? local(rect) : undefined\n const hole = preview && { ...preview, rect: local(preview.rect), radius: preview.radius / (frame?.scaleX ?? 1) }\n const viewport = frame ? { width: frame.width, height: frame.height } : undefined\n const label = ariaLabel ?? name\n\n return (\n <>\n {/* The menu is placed against this invisible box: the pointer, or the element. It names the menu. */}\n <Portal.Root asChild container={container}>\n <Menu.Trigger>\n <span\n ref={anchorRef}\n aria-hidden=\"true\"\n aria-label={label || undefined}\n tabIndex={-1}\n className={s.Anchor}\n style={anchor ? { left: anchor.x, top: anchor.y, width: anchor.width, height: anchor.height } : undefined}\n />\n </Menu.Trigger>\n </Portal.Root>\n <Portal.Root asChild container={container}>\n <TransitionGroup className={s.Dimming} {...overlayTiming}>\n {dimmed && hole && (\n <div key=\"dimming\" data-context-menu-dimming=\"\" className={s.Overlay} style={contextMenuHoleMask(hole, viewport) as CSSProperties}>\n <div\n className={s.Preview}\n style={{ left: hole.rect.x, top: hole.rect.y, width: hole.rect.width, height: hole.rect.height, borderRadius: hole.radius }}\n />\n </div>\n )}\n </TransitionGroup>\n </Portal.Root>\n <Menu.Content\n {...props}\n {...placement}\n onCloseAutoFocus={(event) => {\n // Focus goes back to the element only when the keyboard opened the menu; a pointer leaves it where it was.\n event.preventDefault()\n if (presentation?.kind === \"keyboard\") regionRef.current?.focus({ preventScroll: true })\n }}\n />\n </>\n )\n}\nContextMenuContent.displayName = \"ContextMenu.Content\"\n\nexport const ContextMenu = Object.assign(ContextMenuRoot, {\n Trigger: ContextMenuTrigger,\n Content: ContextMenuContent,\n Item: Menu.Item,\n Link: Menu.Link,\n Separator: Menu.Separator,\n Label: Menu.Label,\n Group: Menu.Group,\n Sub: Menu.Sub,\n SubTrigger: Menu.SubTrigger,\n SubContent: Menu.SubContent,\n CheckboxItem: Menu.CheckboxItem,\n RadioGroup: Menu.RadioGroup,\n RadioItem: Menu.RadioItem,\n})\n"]}
@@ -1,3 +1,4 @@
1
+ import { PHONE_LAYOUT_SCOPE } from "../../lib/phoneLayout.js";
1
2
  export { CONTEXT_MENU_LONG_PRESS, CONTEXT_MENU_LONG_PRESS_SLOP } from "../../lib/contextMenuHold.js";
2
3
  /** The kit's gap between the preview and the menu: iOS 27 Context Menu 125:58750, Alignment=Vertical, the menu at
3
4
  * 176.5 under a content area that ends at 160.5 (the iOS 26 kit had 18). */
@@ -12,9 +13,13 @@ const px = (value, base) => {
12
13
  };
13
14
  /**
14
15
  * The preview of a touch and hold: the element's box and corner (its own, or `--context-menu-preview-radius`), and
15
- * the edge the menu keeps to, the one on the side of the touch, as the kit's Side=Leading and Side=Trailing.
16
+ * where the menu keeps to across it, as iOS 27.2 places it by where the element stands on the screen, wherever the
17
+ * touch (ref-app menus-context, block 8): in the leading third its leading edge, in the trailing third its trailing
18
+ * edge, else its centre (a full-width row, a tile in the middle). The kit draws only Side=Leading and Side=Trailing.
19
+ * The screen is a PhoneLayout's box when the element is in one (a phone Dialog's scope has no box: the window is its
20
+ * screen), as for a menu that covers its trigger (menuTriggerCover.ts).
16
21
  */
17
- export function contextMenuPreview(element, touchX) {
22
+ export function contextMenuPreview(element) {
18
23
  const box = element.getBoundingClientRect();
19
24
  const rect = { x: box.left, y: box.top, width: box.width, height: box.height };
20
25
  const style = getComputedStyle(element);
@@ -22,13 +27,16 @@ export function contextMenuPreview(element, touchX) {
22
27
  const own = px(style.borderTopLeftRadius, short);
23
28
  const fallback = px(style.getPropertyValue("--context-menu-preview-radius"), short) || PREVIEW_RADIUS;
24
29
  const radius = Math.min(own > 0 ? own : fallback, short / 2);
25
- const width = element.ownerDocument.defaultView?.innerWidth ?? rect.x + rect.width;
26
- return { kind: "preview", rect, radius, align: touchX < width / 2 ? "start" : "end" };
30
+ const frame = element.closest(PHONE_LAYOUT_SCOPE)?.getBoundingClientRect();
31
+ const start = frame && frame.width > 0 ? frame.left : 0;
32
+ const width = frame && frame.width > 0 ? frame.width : element.ownerDocument.defaultView?.innerWidth ?? rect.x + rect.width;
33
+ const centre = rect.x + rect.width / 2 - start;
34
+ return { kind: "preview", rect, radius, align: centre < width / 3 ? "start" : centre > (width * 2) / 3 ? "end" : "center" };
27
35
  }
28
36
  /** The menu's side, alignment and offsets for a presentation. */
29
37
  export function contextMenuPlacement(presentation) {
30
38
  if (presentation?.kind === "preview")
31
- return { side: "bottom", align: presentation.align, sideOffset: CONTEXT_MENU_PREVIEW_GAP, alignOffset: 0 };
39
+ return { side: presentation.side ?? "bottom", align: presentation.align, sideOffset: CONTEXT_MENU_PREVIEW_GAP, alignOffset: 0 };
32
40
  if (presentation?.kind === "keyboard")
33
41
  return { side: "bottom", align: "start", sideOffset: 5, alignOffset: 0 };
34
42
  // As a desktop context menu, its corner at the pointer.
@@ -74,6 +82,18 @@ export function contextMenuPreviewShift(rect, height, room, ceiling = -Infinity,
74
82
  return round(missing);
75
83
  return rect.y - gap - height >= room.top ? 0 : round(allowed);
76
84
  }
85
+ /**
86
+ * The side a preview's menu opens on, and how far the preview moves up for it: above, unmoved, when the preview stands
87
+ * in the lower half of the room and the menu stands whole above it, as iOS 27.2 opens a menu toward the larger room
88
+ * (ref-app menus-context-small, block 8: a tile low on the screen opens its menu above, with room below too); else
89
+ * below, the preview moved up as `contextMenuPreviewShift` says.
90
+ */
91
+ export function contextMenuPreviewLayout(rect, height, room, ceiling = -Infinity, scale = 1) {
92
+ const gap = CONTEXT_MENU_PREVIEW_GAP * scale;
93
+ if (rect.y + rect.height / 2 > (room.top + room.bottom) / 2 && rect.y - gap - height >= room.top)
94
+ return { side: "top", shift: 0 };
95
+ return { side: "bottom", shift: contextMenuPreviewShift(rect, height, room, ceiling, scale) };
96
+ }
77
97
  /** The top of the nearest box that clips the element: moved above it, the element would not be seen. */
78
98
  export function contextMenuClipTop(element) {
79
99
  const view = element.ownerDocument.defaultView;
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/components/ContextMenu/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAA;AAEjG;4EAC4E;AAC5E,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA;AAC1C,qGAAqG;AACrG,MAAM,cAAc,GAAG,EAAE,CAAA;AAazB,MAAM,EAAE,GAAG,CAAC,KAAa,EAAE,IAAY,EAAE,EAAE;IACzC,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IACvC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,CAAC,CAAA;IACtC,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,GA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\n\n/** The kit's gap between the preview and the menu: iOS 27 Context Menu 125:58750, Alignment=Vertical, the menu at\n * 176.5 under a content area that ends at 160.5 (the iOS 26 kit had 18). */\nexport const CONTEXT_MENU_PREVIEW_GAP = 16\n/** The kit's preview corner (Content Area, radius 30), for an element without corners of its own. */\nconst PREVIEW_RADIUS = 30\n\ntype Rect = { x: number; y: number; width: number; height: number }\n\n/**\n * Where the menu opens: at the pointer, under the element for the keyboard, or beside a touch-and-hold preview. A\n * preview's `rect` is where it stands, `shift` how far it moved up so that the menu stands whole below it, once known.\n */\nexport type ContextMenuPresentation =\n | { kind: \"pointer\"; rect: Rect }\n | { kind: \"keyboard\"; rect: Rect }\n | { kind: \"preview\"; rect: Rect; radius: number; align: \"start\" | \"end\"; shift?: number }\n\nconst px = (value: string, base: number) => {\n const number = Number.parseFloat(value)\n if (!Number.isFinite(number)) return 0\n return value.trim().endsWith(\"%\") ? (number / 100) * base : number\n}\n\n/**\n * The preview of a touch and hold: the element's box and corner (its own, or `--context-menu-preview-radius`), and\n * the edge the menu keeps to, the one on the side of the touch, as the kit's Side=Leading and Side=Trailing.\n */\nexport function contextMenuPreview(element: HTMLElement, touchX: number): ContextMenuPresentation {\n const box = element.getBoundingClientRect()\n const rect = { x: box.left, y: box.top, width: box.width, height: box.height }\n const style = getComputedStyle(element)\n const short = Math.min(rect.width, rect.height)\n const own = px(style.borderTopLeftRadius, short)\n const fallback = px(style.getPropertyValue(\"--context-menu-preview-radius\"), short) || PREVIEW_RADIUS\n const radius = Math.min(own > 0 ? own : fallback, short / 2)\n const width = element.ownerDocument.defaultView?.innerWidth ?? rect.x + rect.width\n return { kind: \"preview\", rect, radius, align: touchX < width / 2 ? \"start\" : \"end\" }\n}\n\n/** The menu's side, alignment and offsets for a presentation. */\nexport function contextMenuPlacement(presentation: ContextMenuPresentation | null) {\n if (presentation?.kind === \"preview\")\n return { side: \"bottom\" as const, align: presentation.align, sideOffset: CONTEXT_MENU_PREVIEW_GAP, alignOffset: 0 }\n if (presentation?.kind === \"keyboard\") return { side: \"bottom\" as const, align: \"start\" as const, sideOffset: 5, alignOffset: 0 }\n // As a desktop context menu, its corner at the pointer.\n return { side: \"bottom\" as const, align: \"start\" as const, sideOffset: 2, alignOffset: 0 }\n}\n\nconst round = (value: number) => Math.round(value * 100) / 100\n\n/**\n * The dimming covers the page but the element: the element's rounded box is cut out of it, so the element stays\n * clear above the dimmed, blurred page. `--context-menu-hole` draws the cut (an SVG mask), and\n * `--context-menu-hole-clip` the same shape as a clip path, through which a press reaches the element: a mask leaves\n * the dimming pressable, a clip path does not.\n */\nexport function contextMenuHoleMask(preview: Extract<ContextMenuPresentation, { kind: \"preview\" }>, viewport?: { width: number; height: number }) {\n const width = round(viewport?.width ?? window.innerWidth)\n const height = round(viewport?.height ?? window.innerHeight)\n const x = round(preview.rect.x)\n const y = round(preview.rect.y)\n const w = round(preview.rect.width)\n const h = round(preview.rect.height)\n const r = round(preview.radius)\n const hole = `M${x + r} ${y}H${round(x + w - r)}A${r} ${r} 0 0 1 ${x + w} ${round(y + r)}V${round(y + h - r)}A${r} ${r} 0 0 1 ${round(x + w - r)} ${round(y + h)}H${round(x + r)}A${r} ${r} 0 0 1 ${x} ${round(y + h - r)}V${round(y + r)}A${r} ${r} 0 0 1 ${round(x + r)} ${y}Z`\n const path = `M0 0H${width}V${height}H0Z${hole}`\n const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='${width}' height='${height}' viewBox='0 0 ${width} ${height}'><path fill-rule='evenodd' d='${path}'/></svg>`\n return {\n \"--context-menu-hole\": `url(\"data:image/svg+xml,${encodeURIComponent(svg)}\")`,\n \"--context-menu-hole-clip\": `path(evenodd, \"${path}\")`,\n }\n}\n\n/**\n * How far the preview moves up so that a menu `height` tall stands whole below it, as iOS moves a lifted preview:\n * within `room` (the top and bottom the menu keeps to), and no higher than `ceiling`, the top of a box that clips\n * the element. Nothing when the menu fits. When no move lets it stand whole below, nothing either if it stands whole\n * above the element, where it then opens; else as far as the room above lets it, and the menu scrolls. All on the\n * screen: `scale` is the one a PhoneLayout is drawn at, which the gap takes too.\n */\nexport function contextMenuPreviewShift(rect: Rect, height: number, room: { top: number; bottom: number }, ceiling = -Infinity, scale = 1) {\n const gap = CONTEXT_MENU_PREVIEW_GAP * scale\n const missing = rect.y + rect.height + gap + height - room.bottom\n if (missing <= 0) return 0\n const allowed = Math.max(0, rect.y - Math.max(room.top, ceiling))\n if (missing <= allowed) return round(missing)\n return rect.y - gap - height >= room.top ? 0 : round(allowed)\n}\n\n/** The top of the nearest box that clips the element: moved above it, the element would not be seen. */\nexport function contextMenuClipTop(element: HTMLElement) {\n const view = element.ownerDocument.defaultView\n let top = -Infinity\n for (let node = element.parentElement; node && node !== element.ownerDocument.documentElement; node = node.parentElement) {\n const style = view?.getComputedStyle(node)\n if (style && (style.overflowX !== \"visible\" || style.overflowY !== \"visible\"))\n top = Math.max(top, node.getBoundingClientRect().top + node.clientTop)\n }\n return top\n}\n\n/** A menu's height without the limit of the room it is given: the panel, and what its items scroll out of sight. */\nexport function contextMenuNaturalHeight(content: HTMLElement) {\n const hidden = (element: Element) => (element instanceof HTMLElement ? Math.max(0, element.scrollHeight - element.clientHeight) : 0)\n return [...content.children].reduce((height, child) => height + hidden(child), content.offsetHeight + hidden(content))\n}\n\n/**\n * The name of the element a menu is for, which names the menu, in the order of accessible names: the text it is\n * labelled by, its own label, its text, or the text of a picture it is or shows.\n */\nexport function contextMenuName(element: HTMLElement) {\n const text = (value: string | null | undefined) => (value ?? \"\").replace(/\\s+/g, \" \").trim()\n const doc = element.ownerDocument\n const ids = text(element.getAttribute(\"aria-labelledby\")).split(\" \").filter(Boolean)\n const labelled = text(ids.map((id) => doc.getElementById(id)?.textContent ?? \"\").join(\" \"))\n if (labelled) return labelled\n const label = text(element.getAttribute(\"aria-label\"))\n if (label) return label\n const picture = element.matches(\"img[alt]\") ? element : element.querySelector(\"img[alt]\")\n return text(element.textContent) || text(picture?.getAttribute(\"alt\"))\n}\n\n/**\n * The box the anchor and the dimming lie in when they portal into a PhoneLayout, which is their containing block:\n * its padding box on the screen, and its scale when the frame is drawn smaller or larger. Null for the window.\n */\nexport type ContextMenuFrame = { left: number; top: number; scaleX: number; scaleY: number; width: number; height: number }\n\nexport function contextMenuFrame(box: HTMLElement | null | undefined): ContextMenuFrame | null {\n if (!box) return null\n const rect = box.getBoundingClientRect()\n const scaleX = box.offsetWidth > 0 ? rect.width / box.offsetWidth : 1\n const scaleY = box.offsetHeight > 0 ? rect.height / box.offsetHeight : 1\n return {\n left: rect.left + box.clientLeft * scaleX,\n top: rect.top + box.clientTop * scaleY,\n scaleX,\n scaleY,\n width: box.clientWidth,\n height: box.clientHeight,\n }\n}\n\n/** A rectangle on the screen in the coordinates of the frame, or as it is for the window. */\nexport const contextMenuInFrame = (rect: Rect, frame: ContextMenuFrame | null): Rect =>\n frame\n ? {\n x: round((rect.x - frame.left) / frame.scaleX),\n y: round((rect.y - frame.top) / frame.scaleY),\n width: round(rect.width / frame.scaleX),\n height: round(rect.height / frame.scaleY),\n }\n : rect\n\n/** The duration and easing of a motion token (`--motion-enter` with `--cubic-enter`), 0 where motion is reduced. */\nconst motion = (element: HTMLElement, name: \"enter\" | \"exit\") => {\n const style = getComputedStyle(element)\n const value = style.getPropertyValue(`--motion-${name}`).trim()\n const number = Number.parseFloat(value)\n const duration = !Number.isFinite(number) ? 0 : value.endsWith(\"ms\") ? number : value.endsWith(\"s\") ? number * 1000 : 0\n return { duration, easing: style.getPropertyValue(`--cubic-${name}`).trim() || \"ease\" }\n}\n\n/** The parts of a computed `translate` (`none`, or x, y and z lengths, a `calc()` among them). */\nconst translateParts = (value: string) => {\n const parts: string[] = []\n let depth = 0\n let part = \"\"\n for (const char of value.trim()) {\n if (char === \"(\") depth += 1\n if (char === \")\") depth -= 1\n if (char === \" \" && depth === 0) {\n if (part) parts.push(part)\n part = \"\"\n } else part += char\n }\n if (part) parts.push(part)\n return parts\n}\n\n/**\n * How large the element's pixels are drawn on the screen: the scale of the nearest box around it with a height, such\n * as a PhoneLayout drawn smaller. Read from its parents, which a transition or animation of the element's own does not\n * move.\n */\nconst screenScale = (element: HTMLElement) => {\n for (let node = element.parentElement; node; node = node.parentElement) {\n if (node.offsetHeight > 0) {\n const scale = node.getBoundingClientRect().height / node.offsetHeight\n return scale > 0 && Number.isFinite(scale) ? scale : 1\n }\n }\n return 1\n}\n\n/**\n * Changes the element's `translate` without a transition of its own (`transition: all` or one on `translate`): the\n * move has its own glide, and a drag measures the element right after it is put back. The transition the change\n * starts is cancelled, which shows the new value at once and leaves the element's own style as it was.\n */\nconst withoutTransition = (element: HTMLElement, change: () => void) => {\n change()\n // Reading the style starts the element's transition, if it has one\n void getComputedStyle(element).getPropertyValue(\"translate\")\n for (const animation of element.getAnimations?.() ?? []) {\n if (\"transitionProperty\" in animation && animation.transitionProperty === \"translate\") animation.cancel()\n }\n}\n\n/**\n * Moves the element up by `shift` pixels of the screen while its preview stands, gliding there as the dimming comes in\n * (or at once, for a menu held open that is placed again), and returns how to put it back: gliding as the dimming\n * goes, or at once for a drag that measures where the element stands; called again at once, it stops that glide. An\n * animation, not a transition, so the element's own styles stay; the move adds to a `translate` the element has.\n */\nexport function liftContextMenuPreview(element: HTMLElement, shift: number, smooth = true): (glide: boolean) => void {\n const previous = element.style.getPropertyValue(\"translate\")\n const computed = getComputedStyle(element).getPropertyValue(\"translate\").trim()\n const own = computed && computed !== \"none\" ? translateParts(computed) : []\n const rest = own.length > 0 ? computed : \"none\"\n const by = round(shift / screenScale(element))\n const raised = own.length > 0 ? [own[0], `calc(${own[1] ?? \"0px\"} - ${by}px)`, ...own.slice(2)].join(\" \") : `0 ${-by}px`\n withoutTransition(element, () => element.style.setProperty(\"translate\", raised))\n const glide = (from: string, to: string, name: \"enter\" | \"exit\") => {\n const { duration, easing } = motion(element, name)\n return duration > 0 && typeof element.animate === \"function\"\n ? element.animate([{ translate: from }, { translate: to }], { duration, easing })\n : undefined\n }\n let animation = smooth ? glide(rest, raised, \"enter\") : undefined\n let lifted = true\n return (back) => {\n if (!lifted) {\n if (!back) animation?.cancel()\n return\n }\n lifted = false\n animation?.cancel()\n withoutTransition(element, () => {\n if (previous) element.style.setProperty(\"translate\", previous)\n else element.style.removeProperty(\"translate\")\n })\n animation = back ? glide(raised, rest, \"exit\") : undefined\n }\n}\n"]}
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/components/ContextMenu/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAA;AAEjG;4EAC4E;AAC5E,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA;AAC1C,qGAAqG;AACrG,MAAM,cAAc,GAAG,EAAE,CAAA;AAczB,MAAM,EAAE,GAAG,CAAC,KAAa,EAAE,IAAY,EAAE,EAAE;IACzC,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IACvC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,CAAC,CAAA;IACtC,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAA;AACpE,CAAC,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAoB;IACrD,MAAM,GAAG,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAA;IAC3C,MAAM,IAAI,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAA;IAC9E,MAAM,KAAK,GAAG,gBAAgB,C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AAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IACjE,IAAI,MAAM,GAAG,IAAI,CAAA;IACjB,OAAO,CAAC,IAAI,EAAE,EAAE;QACd,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,IAAI,CAAC,IAAI;gBAAE,SAAS,EAAE,MAAM,EAAE,CAAA;YAC9B,OAAM;QACR,CAAC;QACD,MAAM,GAAG,KAAK,CAAA;QACd,SAAS,EAAE,MAAM,EAAE,CAAA;QACnB,iBAAiB,CAAC,OAAO,EAAE,GAAG,EAAE;YAC9B,IAAI,QAAQ;gBAAE,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;;gBACzD,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;QAChD,CAAC,CAAC,CAAA;QACF,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAC5D,CAAC,CAAA;AACH,CAAC","sourcesContent":["import { PHONE_LAYOUT_SCOPE } from \"../../lib/phoneLayout\"\nexport { CONTEXT_MENU_LONG_PRESS, CONTEXT_MENU_LONG_PRESS_SLOP } from \"../../lib/contextMenuHold\"\n\n/** The kit's gap between the preview and the menu: iOS 27 Context Menu 125:58750, Alignment=Vertical, the menu at\n * 176.5 under a content area that ends at 160.5 (the iOS 26 kit had 18). */\nexport const CONTEXT_MENU_PREVIEW_GAP = 16\n/** The kit's preview corner (Content Area, radius 30), for an element without corners of its own. */\nconst PREVIEW_RADIUS = 30\n\ntype Rect = { x: number; y: number; width: number; height: number }\n\n/**\n * Where the menu opens: at the pointer, under the element for the keyboard, or beside a touch-and-hold preview. A\n * preview's `rect` is where it stands; once the menu is measured, `side` is the side of the preview it opens on and\n * `shift` how far the preview moved up so that the menu stands whole below it.\n */\nexport type ContextMenuPresentation =\n | { kind: \"pointer\"; rect: Rect }\n | { kind: \"keyboard\"; rect: Rect }\n | { kind: \"preview\"; rect: Rect; radius: number; align: \"start\" | \"center\" | \"end\"; side?: \"top\" | \"bottom\"; shift?: number }\n\nconst px = (value: string, base: number) => {\n const number = Number.parseFloat(value)\n if (!Number.isFinite(number)) return 0\n return value.trim().endsWith(\"%\") ? (number / 100) * base : number\n}\n\n/**\n * The preview of a touch and hold: the element's box and corner (its own, or `--context-menu-preview-radius`), and\n * where the menu keeps to across it, as iOS 27.2 places it by where the element stands on the screen, wherever the\n * touch (ref-app menus-context, block 8): in the leading third its leading edge, in the trailing third its trailing\n * edge, else its centre (a full-width row, a tile in the middle). The kit draws only Side=Leading and Side=Trailing.\n * The screen is a PhoneLayout's box when the element is in one (a phone Dialog's scope has no box: the window is its\n * screen), as for a menu that covers its trigger (menuTriggerCover.ts).\n */\nexport function contextMenuPreview(element: HTMLElement): ContextMenuPresentation {\n const box = element.getBoundingClientRect()\n const rect = { x: box.left, y: box.top, width: box.width, height: box.height }\n const style = getComputedStyle(element)\n const short = Math.min(rect.width, rect.height)\n const own = px(style.borderTopLeftRadius, short)\n const fallback = px(style.getPropertyValue(\"--context-menu-preview-radius\"), short) || PREVIEW_RADIUS\n const radius = Math.min(own > 0 ? own : fallback, short / 2)\n const frame = element.closest(PHONE_LAYOUT_SCOPE)?.getBoundingClientRect()\n const start = frame && frame.width > 0 ? frame.left : 0\n const width = frame && frame.width > 0 ? frame.width : element.ownerDocument.defaultView?.innerWidth ?? rect.x + rect.width\n const centre = rect.x + rect.width / 2 - start\n return { kind: \"preview\", rect, radius, align: centre < width / 3 ? \"start\" : centre > (width * 2) / 3 ? \"end\" : \"center\" }\n}\n\n/** The menu's side, alignment and offsets for a presentation. */\nexport function contextMenuPlacement(presentation: ContextMenuPresentation | null) {\n if (presentation?.kind === \"preview\")\n return { side: presentation.side ?? (\"bottom\" as const), align: presentation.align, sideOffset: CONTEXT_MENU_PREVIEW_GAP, alignOffset: 0 }\n if (presentation?.kind === \"keyboard\") return { side: \"bottom\" as const, align: \"start\" as const, sideOffset: 5, alignOffset: 0 }\n // As a desktop context menu, its corner at the pointer.\n return { side: \"bottom\" as const, align: \"start\" as const, sideOffset: 2, alignOffset: 0 }\n}\n\nconst round = (value: number) => Math.round(value * 100) / 100\n\n/**\n * The dimming covers the page but the element: the element's rounded box is cut out of it, so the element stays\n * clear above the dimmed, blurred page. `--context-menu-hole` draws the cut (an SVG mask), and\n * `--context-menu-hole-clip` the same shape as a clip path, through which a press reaches the element: a mask leaves\n * the dimming pressable, a clip path does not.\n */\nexport function contextMenuHoleMask(preview: Extract<ContextMenuPresentation, { kind: \"preview\" }>, viewport?: { width: number; height: number }) {\n const width = round(viewport?.width ?? window.innerWidth)\n const height = round(viewport?.height ?? window.innerHeight)\n const x = round(preview.rect.x)\n const y = round(preview.rect.y)\n const w = round(preview.rect.width)\n const h = round(preview.rect.height)\n const r = round(preview.radius)\n const hole = `M${x + r} ${y}H${round(x + w - r)}A${r} ${r} 0 0 1 ${x + w} ${round(y + r)}V${round(y + h - r)}A${r} ${r} 0 0 1 ${round(x + w - r)} ${round(y + h)}H${round(x + r)}A${r} ${r} 0 0 1 ${x} ${round(y + h - r)}V${round(y + r)}A${r} ${r} 0 0 1 ${round(x + r)} ${y}Z`\n const path = `M0 0H${width}V${height}H0Z${hole}`\n const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='${width}' height='${height}' viewBox='0 0 ${width} ${height}'><path fill-rule='evenodd' d='${path}'/></svg>`\n return {\n \"--context-menu-hole\": `url(\"data:image/svg+xml,${encodeURIComponent(svg)}\")`,\n \"--context-menu-hole-clip\": `path(evenodd, \"${path}\")`,\n }\n}\n\n/**\n * How far the preview moves up so that a menu `height` tall stands whole below it, as iOS moves a lifted preview:\n * within `room` (the top and bottom the menu keeps to), and no higher than `ceiling`, the top of a box that clips\n * the element. Nothing when the menu fits. When no move lets it stand whole below, nothing either if it stands whole\n * above the element, where it then opens; else as far as the room above lets it, and the menu scrolls. All on the\n * screen: `scale` is the one a PhoneLayout is drawn at, which the gap takes too.\n */\nexport function contextMenuPreviewShift(rect: Rect, height: number, room: { top: number; bottom: number }, ceiling = -Infinity, scale = 1) {\n const gap = CONTEXT_MENU_PREVIEW_GAP * scale\n const missing = rect.y + rect.height + gap + height - room.bottom\n if (missing <= 0) return 0\n const allowed = Math.max(0, rect.y - Math.max(room.top, ceiling))\n if (missing <= allowed) return round(missing)\n return rect.y - gap - height >= room.top ? 0 : round(allowed)\n}\n\n/**\n * The side a preview's menu opens on, and how far the preview moves up for it: above, unmoved, when the preview stands\n * in the lower half of the room and the menu stands whole above it, as iOS 27.2 opens a menu toward the larger room\n * (ref-app menus-context-small, block 8: a tile low on the screen opens its menu above, with room below too); else\n * below, the preview moved up as `contextMenuPreviewShift` says.\n */\nexport function contextMenuPreviewLayout(rect: Rect, height: number, room: { top: number; bottom: number }, ceiling = -Infinity, scale = 1) {\n const gap = CONTEXT_MENU_PREVIEW_GAP * scale\n if (rect.y + rect.height / 2 > (room.top + room.bottom) / 2 && rect.y - gap - height >= room.top)\n return { side: \"top\" as const, shift: 0 }\n return { side: \"bottom\" as const, shift: contextMenuPreviewShift(rect, height, room, ceiling, scale) }\n}\n\n/** The top of the nearest box that clips the element: moved above it, the element would not be seen. */\nexport function contextMenuClipTop(element: HTMLElement) {\n const view = element.ownerDocument.defaultView\n let top = -Infinity\n for (let node = element.parentElement; node && node !== element.ownerDocument.documentElement; node = node.parentElement) {\n const style = view?.getComputedStyle(node)\n if (style && (style.overflowX !== \"visible\" || style.overflowY !== \"visible\"))\n top = Math.max(top, node.getBoundingClientRect().top + node.clientTop)\n }\n return top\n}\n\n/** A menu's height without the limit of the room it is given: the panel, and what its items scroll out of sight. */\nexport function contextMenuNaturalHeight(content: HTMLElement) {\n const hidden = (element: Element) => (element instanceof HTMLElement ? Math.max(0, element.scrollHeight - element.clientHeight) : 0)\n return [...content.children].reduce((height, child) => height + hidden(child), content.offsetHeight + hidden(content))\n}\n\n/**\n * The name of the element a menu is for, which names the menu, in the order of accessible names: the text it is\n * labelled by, its own label, its text, or the text of a picture it is or shows.\n */\nexport function contextMenuName(element: HTMLElement) {\n const text = (value: string | null | undefined) => (value ?? \"\").replace(/\\s+/g, \" \").trim()\n const doc = element.ownerDocument\n const ids = text(element.getAttribute(\"aria-labelledby\")).split(\" \").filter(Boolean)\n const labelled = text(ids.map((id) => doc.getElementById(id)?.textContent ?? \"\").join(\" \"))\n if (labelled) return labelled\n const label = text(element.getAttribute(\"aria-label\"))\n if (label) return label\n const picture = element.matches(\"img[alt]\") ? element : element.querySelector(\"img[alt]\")\n return text(element.textContent) || text(picture?.getAttribute(\"alt\"))\n}\n\n/**\n * The box the anchor and the dimming lie in when they portal into a PhoneLayout, which is their containing block:\n * its padding box on the screen, and its scale when the frame is drawn smaller or larger. Null for the window.\n */\nexport type ContextMenuFrame = { left: number; top: number; scaleX: number; scaleY: number; width: number; height: number }\n\nexport function contextMenuFrame(box: HTMLElement | null | undefined): ContextMenuFrame | null {\n if (!box) return null\n const rect = box.getBoundingClientRect()\n const scaleX = box.offsetWidth > 0 ? rect.width / box.offsetWidth : 1\n const scaleY = box.offsetHeight > 0 ? rect.height / box.offsetHeight : 1\n return {\n left: rect.left + box.clientLeft * scaleX,\n top: rect.top + box.clientTop * scaleY,\n scaleX,\n scaleY,\n width: box.clientWidth,\n height: box.clientHeight,\n }\n}\n\n/** A rectangle on the screen in the coordinates of the frame, or as it is for the window. */\nexport const contextMenuInFrame = (rect: Rect, frame: ContextMenuFrame | null): Rect =>\n frame\n ? {\n x: round((rect.x - frame.left) / frame.scaleX),\n y: round((rect.y - frame.top) / frame.scaleY),\n width: round(rect.width / frame.scaleX),\n height: round(rect.height / frame.scaleY),\n }\n : rect\n\n/** The duration and easing of a motion token (`--motion-enter` with `--cubic-enter`), 0 where motion is reduced. */\nconst motion = (element: HTMLElement, name: \"enter\" | \"exit\") => {\n const style = getComputedStyle(element)\n const value = style.getPropertyValue(`--motion-${name}`).trim()\n const number = Number.parseFloat(value)\n const duration = !Number.isFinite(number) ? 0 : value.endsWith(\"ms\") ? number : value.endsWith(\"s\") ? number * 1000 : 0\n return { duration, easing: style.getPropertyValue(`--cubic-${name}`).trim() || \"ease\" }\n}\n\n/** The parts of a computed `translate` (`none`, or x, y and z lengths, a `calc()` among them). */\nconst translateParts = (value: string) => {\n const parts: string[] = []\n let depth = 0\n let part = \"\"\n for (const char of value.trim()) {\n if (char === \"(\") depth += 1\n if (char === \")\") depth -= 1\n if (char === \" \" && depth === 0) {\n if (part) parts.push(part)\n part = \"\"\n } else part += char\n }\n if (part) parts.push(part)\n return parts\n}\n\n/**\n * How large the element's pixels are drawn on the screen: the scale of the nearest box around it with a height, such\n * as a PhoneLayout drawn smaller. Read from its parents, which a transition or animation of the element's own does not\n * move.\n */\nconst screenScale = (element: HTMLElement) => {\n for (let node = element.parentElement; node; node = node.parentElement) {\n if (node.offsetHeight > 0) {\n const scale = node.getBoundingClientRect().height / node.offsetHeight\n return scale > 0 && Number.isFinite(scale) ? scale : 1\n }\n }\n return 1\n}\n\n/**\n * Changes the element's `translate` without a transition of its own (`transition: all` or one on `translate`): the\n * move has its own glide, and a drag measures the element right after it is put back. The transition the change\n * starts is cancelled, which shows the new value at once and leaves the element's own style as it was.\n */\nconst withoutTransition = (element: HTMLElement, change: () => void) => {\n change()\n // Reading the style starts the element's transition, if it has one\n void getComputedStyle(element).getPropertyValue(\"translate\")\n for (const animation of element.getAnimations?.() ?? []) {\n if (\"transitionProperty\" in animation && animation.transitionProperty === \"translate\") animation.cancel()\n }\n}\n\n/**\n * Moves the element up by `shift` pixels of the screen while its preview stands, gliding there as the dimming comes in\n * (or at once, for a menu held open that is placed again), and returns how to put it back: gliding as the dimming\n * goes, or at once for a drag that measures where the element stands; called again at once, it stops that glide. An\n * animation, not a transition, so the element's own styles stay; the move adds to a `translate` the element has.\n */\nexport function liftContextMenuPreview(element: HTMLElement, shift: number, smooth = true): (glide: boolean) => void {\n const previous = element.style.getPropertyValue(\"translate\")\n const computed = getComputedStyle(element).getPropertyValue(\"translate\").trim()\n const own = computed && computed !== \"none\" ? translateParts(computed) : []\n const rest = own.length > 0 ? computed : \"none\"\n const by = round(shift / screenScale(element))\n const raised = own.length > 0 ? [own[0], `calc(${own[1] ?? \"0px\"} - ${by}px)`, ...own.slice(2)].join(\" \") : `0 ${-by}px`\n withoutTransition(element, () => element.style.setProperty(\"translate\", raised))\n const glide = (from: string, to: string, name: \"enter\" | \"exit\") => {\n const { duration, easing } = motion(element, name)\n return duration > 0 && typeof element.animate === \"function\"\n ? element.animate([{ translate: from }, { translate: to }], { duration, easing })\n : undefined\n }\n let animation = smooth ? glide(rest, raised, \"enter\") : undefined\n let lifted = true\n return (back) => {\n if (!lifted) {\n if (!back) animation?.cancel()\n return\n }\n lifted = false\n animation?.cancel()\n withoutTransition(element, () => {\n if (previous) element.style.setProperty(\"translate\", previous)\n else element.style.removeProperty(\"translate\")\n })\n animation = back ? glide(raised, rest, \"exit\") : undefined\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useLayoutEffect, useRef, useSyncExternalStore } from "react";
3
4
  import { Badge } from "../Badge/index.js";
4
5
  import { CopyTooltip } from "../Tooltip/index.js";
5
6
  import { Tooltip } from "../Tooltip/index.js";
@@ -15,18 +16,98 @@ export function idCell(accessor) {
15
16
  IdCell.displayName = "IdCell";
16
17
  return IdCell;
17
18
  }
18
- export function dateTimeCell(accessor, options) {
19
- const defaultOptions = {
19
+ const subscribeNever = () => () => { };
20
+ const isClient = () => true;
21
+ const isServer = () => false;
22
+ // ISO 8601: a date, a time, and a zone (Z or an offset) when the value names an instant.
23
+ const ISO_DATE = /^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}(?::?\d{2})?)?)?$/;
24
+ /**
25
+ * An ISO date read field by field, the same in every runtime (engines read the edges of the format each their own
26
+ * way), null when it is no date (the 30th of February, an hour of 25; 24:00 is the next midnight). A date, or a
27
+ * date and time, written without a zone ("2023-01-15", "2023-01-15T09:00") names no instant, and a runtime would
28
+ * read it in its own zone, the server's in one and the reader's in another: it is `written`, shown as written in
29
+ * every zone.
30
+ */
31
+ function readIsoDate(value) {
32
+ const match = ISO_DATE.exec(value);
33
+ if (!match)
34
+ return undefined;
35
+ const [, yearText, monthText, dayText, hourText = "0", minuteText = "0", secondText = "0", fraction = "0", zone] = match;
36
+ const [year, month, day, hour, minute, second] = [yearText, monthText, dayText, hourText, minuteText, secondText].map(Number);
37
+ const leap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
38
+ const monthDays = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1];
39
+ const endOfDay = hour === 24 && minute + second + Number(fraction) === 0;
40
+ const offsetHours = zone && zone !== "Z" ? Number(zone.slice(1, 3)) : 0;
41
+ const offsetMinutes = zone && zone.length > 3 ? Number(zone.slice(-2)) : 0;
42
+ const inRange = monthDays !== undefined && day >= 1 && day <= monthDays && (hour <= 23 || endOfDay) && minute <= 59 && second <= 59 &&
43
+ offsetHours <= 23 && offsetMinutes <= 59;
44
+ if (!inRange)
45
+ return null;
46
+ // Counted, not built from a Date: a value at the edge of the range a Date holds would leave it on the way.
47
+ // An offset east of UTC is that much earlier in UTC.
48
+ const offset = (zone?.[0] === "-" ? -1 : 1) * (offsetHours * 60 + offsetMinutes);
49
+ const time = daysFromCivil(year, month, day) * 86_400_000 + ((hour * 60 + minute - offset) * 60 + second) * 1000 +
50
+ Number(fraction.slice(0, 3).padEnd(3, "0"));
51
+ const date = new Date(time);
52
+ return Number.isNaN(date.getTime()) ? null : { date, written: !zone };
53
+ }
54
+ /** Days from 1970-01-01 to a date of the proleptic Gregorian calendar (H. Hinnant's days_from_civil). */
55
+ function daysFromCivil(year, month, day) {
56
+ const y = month <= 2 ? year - 1 : year;
57
+ const era = Math.floor(y / 400);
58
+ const yearOfEra = y - era * 400;
59
+ const dayOfYear = Math.floor((153 * (month + (month > 2 ? -3 : 9)) + 2) / 5) + day - 1;
60
+ const dayOfEra = yearOfEra * 365 + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100) + dayOfYear;
61
+ return era * 146_097 + dayOfEra - 719_468;
62
+ }
63
+ /**
64
+ * Formats a cell's value: in the reader's zone once mounted, and on the server and while hydrating in a zone that
65
+ * does not depend on where they run. The text can still differ between engines (Node joins a date and a time with
66
+ * ", ", WebKit with " at "), so the cell lets hydration differ in its text and writes the reader's text once mounted.
67
+ */
68
+ function dateTimeFormatter(options) {
69
+ const formatOptions = options ?? {
20
70
  year: "numeric",
21
71
  month: "short",
22
72
  day: "numeric",
23
73
  hour: "2-digit",
24
74
  minute: "2-digit",
25
75
  };
26
- const fmt = new Intl.DateTimeFormat("en-US", options ?? defaultOptions);
76
+ const reader = new Intl.DateTimeFormat("en-US", formatOptions);
77
+ // The server knows no reader's time zone: without a timeZone in the options it writes an instant in UTC, and
78
+ // so does the render that takes over the server's markup; the reader's own zone follows right after it.
79
+ const server = formatOptions.timeZone ? reader : new Intl.DateTimeFormat("en-US", { ...formatOptions, timeZone: "UTC" });
80
+ // A written date names no zone, so none is printed: a long or full time would add one, a medium one does not.
81
+ const zoneless = formatOptions.timeStyle === "long" || formatOptions.timeStyle === "full" ? "medium" : formatOptions.timeStyle;
82
+ const written = new Intl.DateTimeFormat("en-US", { ...formatOptions, timeZone: "UTC", timeZoneName: undefined, timeStyle: zoneless });
83
+ return (value, mounted) => {
84
+ const iso = readIsoDate(value);
85
+ if (iso === null)
86
+ return value;
87
+ if (iso)
88
+ return (iso.written ? written : mounted ? reader : server).format(iso.date);
89
+ // Any other way of writing a date each runtime reads its own way, and one that is no date at all none can
90
+ // format: the server and the render that takes over its markup show it as written, the reader's runtime
91
+ // reads it once mounted.
92
+ const date = new Date(value);
93
+ return mounted && !Number.isNaN(date.getTime()) ? reader.format(date) : value;
94
+ };
95
+ }
96
+ export function dateTimeCell(accessor, options) {
97
+ const format = dateTimeFormatter(options);
27
98
  function DateTimeCell({ row }) {
28
99
  const val = accessor(row.original);
29
- return _jsx("span", { style: { color: "var(--color-text-secondary)" }, children: val ? fmt.format(new Date(val)) : "—" });
100
+ const client = useSyncExternalStore(subscribeNever, isClient, isServer);
101
+ const text = val ? format(val, client) : "—";
102
+ const span = useRef(null);
103
+ // React keeps the server's words through hydration (it does not patch text it was told may differ) and later
104
+ // writes only what changed since its own first render: where the server's words still stand, the reader's
105
+ // are written once, and a text that already reads the same is left alone, selection and all.
106
+ useLayoutEffect(() => {
107
+ if (span.current && span.current.textContent !== text)
108
+ span.current.textContent = text;
109
+ }, [text]);
110
+ return (_jsx("span", { ref: span, suppressHydrationWarning: true, style: { color: "var(--color-text-secondary)" }, children: text }));
30
111
  }
31
112
  DateTimeCell.displayName = "DateTimeCell";
32
113
  return DateTimeCell;
@@ -1 +1 @@
1
- {"version":3,"file":"columnHelpers.js","sourceRoot":"","sources":["../../../../src/components/DataTable/columnHelpers.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAGZ,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,MAAM,UAAU,MAAM,CAAI,QAA4B;IACpD,SAAS,MAAM,CAAC,EAAE,GAAG,EAA2B;QAC9C,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACpC,OAAO,CACL,KAAC,WAAW,IAAC,SAAS,EAAE,KAAK,YAC3B,eACE,KAAK,EAAE;oBACL,UAAU,EAAE,2CAA2C;oBACvD,KAAK,EAAE,6BAA6B;oBACpC,MAAM,EAAE,SAAS;iBAClB,YAEA,KAAK,GACD,GACK,CACf,CAAA;IACH,CAAC;IACD,MAAM,CAAC,WAAW,G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AAG,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,IAAI,WAAW,CAAA;QACtD,OAAO,CACL,KAAC,KAAK,IAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAC,MAAM,YAChC,MAAM,GACD,CACT,CAAA;IACH,CAAC;IACD,UAAU,CAAC,WAAW,GAAG,YAAY,CAAA;IACrC,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,WAAmB;IAC9D,SAAS,aAAa;QACpB,OAAO,CACL,KAAC,OAAO,IAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,GAAG,YACxD,eAAM,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,yBAAyB,EAAE,YAAG,KAAK,GAAQ,GAChF,CACX,CAAA;IACH,CAAC;IACD,aAAa,CAAC,WAAW,GAAG,eAAe,CAAA;IAC3C,OAAO,aAAa,CAAA;AACtB,CAAC","sourcesContent":["\"use client\"\n\nimport type { CellContext } from \"@tanstack/react-table\"\nimport { Badge } from \"../Badge\"\nimport { CopyTooltip } from \"../Tooltip\"\nimport { Tooltip } from \"../Tooltip\"\n\nexport function idCell<T>(accessor: (row: T) => string) {\n function IdCell({ row }: CellContext<T, unknown>) {\n const value = accessor(row.original)\n return (\n <CopyTooltip copyValue={value}>\n <span\n style={{\n fontFamily: \"var(--font-mono, ui-monospace, monospace)\",\n color: \"var(--color-text-secondary)\",\n cursor: \"pointer\",\n }}\n >\n {value}\n </span>\n </CopyTooltip>\n )\n }\n IdCell.displayName = \"IdCell\"\n return IdCell\n}\n\nexport function dateTimeCell<T>(\n accessor: (row: T) => string | null | undefined,\n options?: Intl.DateTimeFormatOptions,\n) {\n const defaultOptions: Intl.DateTimeFormatOptions = {\n year: \"numeric\",\n month: \"short\",\n day: \"numeric\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n }\n const fmt = new Intl.DateTimeFormat(\"en-US\", options ?? defaultOptions)\n\n function DateTimeCell({ row }: CellContext<T, unknown>) {\n const val = accessor(row.original)\n return <span style={{ color: \"var(--color-text-secondary)\" }}>{val ? fmt.format(new Date(val)) : \"—\"}</span>\n }\n DateTimeCell.displayName = \"DateTimeCell\"\n return DateTimeCell\n}\n\nexport function statusCell<T>(\n accessor: (row: T) => string,\n colorMap?: Record<\n string,\n \"secondary\" | \"success\" | \"danger\" | \"warning\" | \"info\" | \"discovery\" | \"caution\"\n >,\n) {\n const defaultColorMap: Record<\n string,\n \"secondary\" | \"success\" | \"danger\" | \"warning\" | \"info\" | \"discovery\" | \"caution\"\n > = {\n active: \"success\",\n completed: \"success\",\n paid: \"success\",\n pending: \"warning\",\n processing: \"info\",\n inactive: \"secondary\",\n cancelled: \"danger\",\n failed: \"danger\",\n unpaid: \"danger\",\n }\n\n function StatusCell({ row }: CellContext<T, unknown>) {\n const status = accessor(row.original)\n const map = colorMap ?? defaultColorMap\n const color = map[status.toLowerCase()] ?? \"secondary\"\n return (\n <Badge color={color} variant=\"soft\">\n {status}\n </Badge>\n )\n }\n StatusCell.displayName = \"StatusCell\"\n return StatusCell\n}\n\nexport function tooltipHeader(label: string, description: string) {\n function TooltipHeader() {\n return (\n <Tooltip content={description} side=\"bottom\" maxWidth={260}>\n <span style={{ cursor: \"help\", borderBottom: \"1px dashed currentColor\" }}>{label}</span>\n </Tooltip>\n )\n }\n TooltipHeader.displayName = \"TooltipHeader\"\n return TooltipHeader\n}\n"]}
1
+ {"version":3,"file":"columnHelpers.js","sourceRoot":"","sources":["../../../../src/components/DataTable/columnHelpers.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAGZ,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,OAAO,EA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AG,YACxD,eAAM,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,yBAAyB,EAAE,YAAG,KAAK,GAAQ,GAChF,CACX,CAAA;IACH,CAAC;IACD,aAAa,CAAC,WAAW,GAAG,eAAe,CAAA;IAC3C,OAAO,aAAa,CAAA;AACtB,CAAC","sourcesContent":["\"use client\"\n\nimport type { CellContext } from \"@tanstack/react-table\"\nimport { useLayoutEffect, useRef, useSyncExternalStore } from \"react\"\nimport { Badge } from \"../Badge\"\nimport { CopyTooltip } from \"../Tooltip\"\nimport { Tooltip } from \"../Tooltip\"\n\nexport function idCell<T>(accessor: (row: T) => string) {\n function IdCell({ row }: CellContext<T, unknown>) {\n const value = accessor(row.original)\n return (\n <CopyTooltip copyValue={value}>\n <span\n style={{\n fontFamily: \"var(--font-mono, ui-monospace, monospace)\",\n color: \"var(--color-text-secondary)\",\n cursor: \"pointer\",\n }}\n >\n {value}\n </span>\n </CopyTooltip>\n )\n }\n IdCell.displayName = \"IdCell\"\n return IdCell\n}\n\nconst subscribeNever = () => () => {}\nconst isClient = () => true\nconst isServer = () => false\n\n// ISO 8601: a date, a time, and a zone (Z or an offset) when the value names an instant.\nconst ISO_DATE = /^([+-]\\d{6}|\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d+))?)?(Z|[+-]\\d{2}(?::?\\d{2})?)?)?$/\n\n/**\n * An ISO date read field by field, the same in every runtime (engines read the edges of the format each their own\n * way), null when it is no date (the 30th of February, an hour of 25; 24:00 is the next midnight). A date, or a\n * date and time, written without a zone (\"2023-01-15\", \"2023-01-15T09:00\") names no instant, and a runtime would\n * read it in its own zone, the server's in one and the reader's in another: it is `written`, shown as written in\n * every zone.\n */\nfunction readIsoDate(value: string): { date: Date; written: boolean } | null | undefined {\n const match = ISO_DATE.exec(value)\n if (!match) return undefined\n const [, yearText, monthText, dayText, hourText = \"0\", minuteText = \"0\", secondText = \"0\", fraction = \"0\", zone] = match\n const [year, month, day, hour, minute, second] = [yearText, monthText, dayText, hourText, minuteText, secondText].map(Number)\n const leap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0\n const monthDays = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1]\n const endOfDay = hour === 24 && minute + second + Number(fraction) === 0\n const offsetHours = zone && zone !== \"Z\" ? Number(zone.slice(1, 3)) : 0\n const offsetMinutes = zone && zone.length > 3 ? Number(zone.slice(-2)) : 0\n const inRange =\n monthDays !== undefined && day >= 1 && day <= monthDays && (hour <= 23 || endOfDay) && minute <= 59 && second <= 59 &&\n offsetHours <= 23 && offsetMinutes <= 59\n if (!inRange) return null\n // Counted, not built from a Date: a value at the edge of the range a Date holds would leave it on the way.\n // An offset east of UTC is that much earlier in UTC.\n const offset = (zone?.[0] === \"-\" ? -1 : 1) * (offsetHours * 60 + offsetMinutes)\n const time =\n daysFromCivil(year, month, day) * 86_400_000 + ((hour * 60 + minute - offset) * 60 + second) * 1000 +\n Number(fraction.slice(0, 3).padEnd(3, \"0\"))\n const date = new Date(time)\n return Number.isNaN(date.getTime()) ? null : { date, written: !zone }\n}\n\n/** Days from 1970-01-01 to a date of the proleptic Gregorian calendar (H. Hinnant's days_from_civil). */\nfunction daysFromCivil(year: number, month: number, day: number) {\n const y = month <= 2 ? year - 1 : year\n const era = Math.floor(y / 400)\n const yearOfEra = y - era * 400\n const dayOfYear = Math.floor((153 * (month + (month > 2 ? -3 : 9)) + 2) / 5) + day - 1\n const dayOfEra = yearOfEra * 365 + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100) + dayOfYear\n return era * 146_097 + dayOfEra - 719_468\n}\n\n/**\n * Formats a cell's value: in the reader's zone once mounted, and on the server and while hydrating in a zone that\n * does not depend on where they run. The text can still differ between engines (Node joins a date and a time with\n * \", \", WebKit with \" at \"), so the cell lets hydration differ in its text and writes the reader's text once mounted.\n */\nfunction dateTimeFormatter(options?: Intl.DateTimeFormatOptions) {\n const formatOptions: Intl.DateTimeFormatOptions = options ?? {\n year: \"numeric\",\n month: \"short\",\n day: \"numeric\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n }\n const reader = new Intl.DateTimeFormat(\"en-US\", formatOptions)\n // The server knows no reader's time zone: without a timeZone in the options it writes an instant in UTC, and\n // so does the render that takes over the server's markup; the reader's own zone follows right after it.\n const server = formatOptions.timeZone ? reader : new Intl.DateTimeFormat(\"en-US\", { ...formatOptions, timeZone: \"UTC\" })\n // A written date names no zone, so none is printed: a long or full time would add one, a medium one does not.\n const zoneless = formatOptions.timeStyle === \"long\" || formatOptions.timeStyle === \"full\" ? \"medium\" : formatOptions.timeStyle\n const written = new Intl.DateTimeFormat(\"en-US\", { ...formatOptions, timeZone: \"UTC\", timeZoneName: undefined, timeStyle: zoneless })\n return (value: string, mounted: boolean) => {\n const iso = readIsoDate(value)\n if (iso === null) return value\n if (iso) return (iso.written ? written : mounted ? reader : server).format(iso.date)\n // Any other way of writing a date each runtime reads its own way, and one that is no date at all none can\n // format: the server and the render that takes over its markup show it as written, the reader's runtime\n // reads it once mounted.\n const date = new Date(value)\n return mounted && !Number.isNaN(date.getTime()) ? reader.format(date) : value\n }\n}\n\nexport function dateTimeCell<T>(\n accessor: (row: T) => string | null | undefined,\n options?: Intl.DateTimeFormatOptions,\n) {\n const format = dateTimeFormatter(options)\n\n function DateTimeCell({ row }: CellContext<T, unknown>) {\n const val = accessor(row.original)\n const client = useSyncExternalStore(subscribeNever, isClient, isServer)\n const text = val ? format(val, client) : \"—\"\n const span = useRef<HTMLSpanElement>(null)\n // React keeps the server's words through hydration (it does not patch text it was told may differ) and later\n // writes only what changed since its own first render: where the server's words still stand, the reader's\n // are written once, and a text that already reads the same is left alone, selection and all.\n useLayoutEffect(() => {\n if (span.current && span.current.textContent !== text) span.current.textContent = text\n }, [text])\n return (\n <span ref={span} suppressHydrationWarning style={{ color: \"var(--color-text-secondary)\" }}>\n {text}\n </span>\n )\n }\n DateTimeCell.displayName = \"DateTimeCell\"\n return DateTimeCell\n}\n\nexport function statusCell<T>(\n accessor: (row: T) => string,\n colorMap?: Record<\n string,\n \"secondary\" | \"success\" | \"danger\" | \"warning\" | \"info\" | \"discovery\" | \"caution\"\n >,\n) {\n const defaultColorMap: Record<\n string,\n \"secondary\" | \"success\" | \"danger\" | \"warning\" | \"info\" | \"discovery\" | \"caution\"\n > = {\n active: \"success\",\n completed: \"success\",\n paid: \"success\",\n pending: \"warning\",\n processing: \"info\",\n inactive: \"secondary\",\n cancelled: \"danger\",\n failed: \"danger\",\n unpaid: \"danger\",\n }\n\n function StatusCell({ row }: CellContext<T, unknown>) {\n const status = accessor(row.original)\n const map = colorMap ?? defaultColorMap\n const color = map[status.toLowerCase()] ?? \"secondary\"\n return (\n <Badge color={color} variant=\"soft\">\n {status}\n </Badge>\n )\n }\n StatusCell.displayName = \"StatusCell\"\n return StatusCell\n}\n\nexport function tooltipHeader(label: string, description: string) {\n function TooltipHeader() {\n return (\n <Tooltip content={description} side=\"bottom\" maxWidth={260}>\n <span style={{ cursor: \"help\", borderBottom: \"1px dashed currentColor\" }}>{label}</span>\n </Tooltip>\n )\n }\n TooltipHeader.displayName = \"TooltipHeader\"\n return TooltipHeader\n}\n"]}