@datalayer/primer-addons 1.0.39 → 1.0.41

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 (58) hide show
  1. package/README.md +19 -8
  2. package/lib/components/box/boxCss.js +17 -1
  3. package/lib/components/box/boxTokens.d.ts +2 -1
  4. package/lib/components/box/boxTokens.js +2 -1
  5. package/lib/components/card/Card.d.ts +119 -5
  6. package/lib/components/card/Card.js +60 -46
  7. package/lib/components/card/Card.stories.d.ts +6 -0
  8. package/lib/components/card/Card.stories.js +26 -0
  9. package/lib/components/date-picker/TimeColumns.d.ts +5 -0
  10. package/lib/components/date-picker/TimeColumns.js +44 -3
  11. package/lib/components/entity-avatar/EntityAvatar.d.ts +73 -0
  12. package/lib/components/entity-avatar/EntityAvatar.js +63 -0
  13. package/lib/components/entity-avatar/index.d.ts +1 -0
  14. package/lib/components/entity-avatar/index.js +5 -0
  15. package/lib/components/hover-card/HoverCard.d.ts +63 -0
  16. package/lib/components/hover-card/HoverCard.js +55 -0
  17. package/lib/components/hover-card/HoverCardAnchor.d.ts +33 -0
  18. package/lib/components/hover-card/HoverCardAnchor.js +26 -0
  19. package/lib/components/hover-card/HoverCardDetails.d.ts +36 -0
  20. package/lib/components/hover-card/HoverCardDetails.js +65 -0
  21. package/lib/components/hover-card/HoverCardLayer.d.ts +34 -0
  22. package/lib/components/hover-card/HoverCardLayer.js +57 -0
  23. package/lib/components/hover-card/index.d.ts +12 -0
  24. package/lib/components/hover-card/index.js +16 -0
  25. package/lib/components/hover-card/useHoverCard.d.ts +57 -0
  26. package/lib/components/hover-card/useHoverCard.js +200 -0
  27. package/lib/components/hover-card/usePrefersReducedMotion.d.ts +10 -0
  28. package/lib/components/hover-card/usePrefersReducedMotion.js +28 -0
  29. package/lib/components/index.d.ts +2 -0
  30. package/lib/components/index.js +2 -0
  31. package/lib/components/logo/DatalayerLogo.js +18 -1
  32. package/lib/components/toolbar/ToolbarButton.d.ts +2 -2
  33. package/lib/components/toolbar/ToolbarButton.js +23 -21
  34. package/lib/components/toolbar/ToolbarDropdown.js +3 -1
  35. package/lib/theme/colors/index.d.ts +1 -0
  36. package/lib/theme/colors/index.js +3 -0
  37. package/lib/theme/colors/vscodeColors.d.ts +280 -0
  38. package/lib/theme/colors/vscodeColors.js +129 -0
  39. package/lib/theme/css/createThemeCSSVars.d.ts +18 -1
  40. package/lib/theme/css/createThemeCSSVars.js +17 -1
  41. package/lib/theme/css/primerBaseVars.js +59 -0
  42. package/lib/theme/css/primerComponentsCss.d.ts +47 -0
  43. package/lib/theme/css/primerComponentsCss.js +72 -0
  44. package/lib/theme/index.d.ts +2 -0
  45. package/lib/theme/index.js +2 -0
  46. package/lib/theme/palettes/ColorPalette.js +41 -1
  47. package/lib/theme/themeRegistry.js +2 -0
  48. package/lib/theme/themeTokens.d.ts +1 -1
  49. package/lib/theme/themeTokens.js +61 -1
  50. package/lib/theme/themes/loopThemeStyles.d.ts +4 -31
  51. package/lib/theme/themes/loopThemeStyles.js +17 -44
  52. package/lib/theme/themes/vscodeEditorsCss.d.ts +12 -0
  53. package/lib/theme/themes/vscodeEditorsCss.js +239 -0
  54. package/lib/theme/themes/vscodeTheme.d.ts +1085 -0
  55. package/lib/theme/themes/vscodeTheme.js +17 -0
  56. package/lib/theme/themes/vscodeThemeStyles.d.ts +7 -0
  57. package/lib/theme/themes/vscodeThemeStyles.js +246 -0
  58. package/package.json +3 -2
@@ -0,0 +1 @@
1
+ export * from './EntityAvatar';
@@ -0,0 +1,5 @@
1
+ /*
2
+ * Copyright (c) 2021-2026 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ export * from './EntityAvatar';
@@ -0,0 +1,63 @@
1
+ /**
2
+ * A card in three sizes, the way a shelf of films is read.
3
+ *
4
+ * A shelf is scanned at a glance, one thing catches the eye, and the reader
5
+ * wants a little more before committing — then, sometimes, a lot more:
6
+ *
7
+ * - the **small card** in the page is the caller's own, wrapped in a
8
+ * `HoverCardAnchor`;
9
+ * - **hovering** it grows this card out of it, covering it (`HoverCardLayer`
10
+ * places it, `useHoverCard` times it): the same picture larger, what to do
11
+ * with it, the whole title and description;
12
+ * - its **chevron** opens the large one, `HoverCardDetails`, over the page.
13
+ *
14
+ * Drawn by the theme: it is a `Card`, so its corner is the theme's card
15
+ * corner (rounder in `loop`, with nothing said here), its ground the
16
+ * overlay's, its hairline and shadow the theme's.
17
+ *
18
+ * @module components/hover-card/HoverCard
19
+ */
20
+ import type { JSX, ReactNode } from 'react';
21
+ /**
22
+ * How much bigger than its anchor the hover card is.
23
+ *
24
+ * Enough that the growth is visible and the artwork gets room; not so much
25
+ * that it stops reading as the same object enlarged.
26
+ */
27
+ export declare const HOVER_CARD_SCALE = 1.45;
28
+ export type HoverCardProps = {
29
+ /** The width of what this grew out of, so the card can be larger. */
30
+ anchorWidth: number;
31
+ /** How much larger; {@link HOVER_CARD_SCALE} by default. */
32
+ scale?: number;
33
+ /** Whether it is being taken away, so it plays the entrance backwards. */
34
+ closing?: boolean;
35
+ /**
36
+ * The picture at the top, drawn at the height given — half the card's
37
+ * width. A function, because only the card knows how wide it is.
38
+ */
39
+ picture?: (height: number) => ReactNode;
40
+ /** The picture is a way in: what pressing it does. */
41
+ onOpen?: () => void;
42
+ /** What pressing the picture is called, for assistive technology. */
43
+ openLabel?: string;
44
+ /** What to do with the thing: buttons, on the left of the chevron. */
45
+ actions?: ReactNode;
46
+ /**
47
+ * Open the large card. Without it there is no third size, and no chevron
48
+ * offering one.
49
+ */
50
+ onExpand?: () => void;
51
+ /** What the chevron is called, for assistive technology. */
52
+ expandLabel?: string;
53
+ /** Its name, on two lines at most. */
54
+ title: ReactNode;
55
+ /** What it is and whose: a line of labels. */
56
+ meta?: ReactNode;
57
+ /** The whole description, which the small card had to cut. */
58
+ description?: ReactNode;
59
+ /** Anything after it: tags, say. */
60
+ children?: ReactNode;
61
+ };
62
+ export declare function HoverCard({ anchorWidth, scale, closing, picture, onOpen, openLabel, actions, onExpand, expandLabel, title, meta, description, children, }: HoverCardProps): JSX.Element;
63
+ export default HoverCard;
@@ -0,0 +1,55 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { IconButton, Text } from '@primer/react';
3
+ import { ChevronDownIcon } from '@primer/octicons-react';
4
+ import { Box } from '../box/Box';
5
+ import { Card } from '../card/Card';
6
+ import { HOVER_CARD_MOTION_MS } from './useHoverCard';
7
+ import { usePrefersReducedMotion } from './usePrefersReducedMotion';
8
+ /**
9
+ * How much bigger than its anchor the hover card is.
10
+ *
11
+ * Enough that the growth is visible and the artwork gets room; not so much
12
+ * that it stops reading as the same object enlarged.
13
+ */
14
+ export const HOVER_CARD_SCALE = 1.45;
15
+ export function HoverCard({ anchorWidth, scale = HOVER_CARD_SCALE, closing = false, picture, onOpen, openLabel, actions, onExpand, expandLabel = 'More', title, meta, description, children, }) {
16
+ const reduced = usePrefersReducedMotion();
17
+ const width = Math.round(anchorWidth * scale);
18
+ const pictureHeight = Math.round(width * 0.5);
19
+ const from = (anchorWidth / width).toFixed(3);
20
+ return (_jsxs(Card, { border: true, shadow: "extraLarge", bg: "canvas.overlay", width: width, maxWidth: "92vw", overflow: "hidden", textAlign: "left",
21
+ /*
22
+ * Grown, not faded in. The card starts at the size of the one it
23
+ * covers and settles at its own, which is what makes it read as the
24
+ * same object rather than a second one arriving on top.
25
+ */
26
+ transformOrigin: "center", animation: reduced
27
+ ? undefined
28
+ : `${closing ? 'dlaHoverCardShrink' : 'dlaHoverCardGrow'} ${HOVER_CARD_MOTION_MS}ms ease-out both`, sx: {
29
+ '@keyframes dlaHoverCardGrow': {
30
+ from: { transform: `scale(${from})`, opacity: 0 },
31
+ to: { transform: 'scale(1)', opacity: 1 },
32
+ },
33
+ // The entrance backwards, at the same speed, ending on the card it
34
+ // grew from rather than simply disappearing.
35
+ '@keyframes dlaHoverCardShrink': {
36
+ from: { transform: 'scale(1)', opacity: 1 },
37
+ to: { transform: `scale(${from})`, opacity: 0 },
38
+ },
39
+ }, children: [picture ? (onOpen ? (_jsx(Box, { all: "unset", as: "button", type: "button", onClick: onOpen, "aria-label": openLabel, display: "block", width: "100%", cursor: "pointer", focusVisible: { outline: '2px solid', outlineColor: 'accent.emphasis', outlineOffset: -2 }, children: picture(pictureHeight) })) : (picture(pictureHeight))) : null, _jsxs(Box, { p: 3, display: "grid", gap: 2, children: [actions || onExpand ? (_jsxs(Box, { display: "flex", alignItems: "center", gap: 2, children: [actions, _jsx(Box, { flexGrow: 1 }), onExpand ? (_jsx(IconButton, { icon: ChevronDownIcon, "aria-label": expandLabel, size: "small", variant: "invisible", sx: {
40
+ borderRadius: '50%',
41
+ border: '1px solid',
42
+ borderColor: 'border.default',
43
+ color: 'fg.muted',
44
+ '&:hover': { borderColor: 'fg.default', color: 'fg.default' },
45
+ }, onClick: onExpand })) : null] })) : null, _jsx(Text, { sx: { fontWeight: 600, fontSize: 2, lineHeight: 1.25 },
46
+ // The two-line clamp as a plain style: Primer's sx type has no
47
+ // vendor-prefixed properties, so in sx it fails the type check.
48
+ style: {
49
+ overflow: 'hidden',
50
+ display: '-webkit-box',
51
+ WebkitLineClamp: 2,
52
+ WebkitBoxOrient: 'vertical',
53
+ }, children: title }), meta, description ? (_jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', lineHeight: 1.5 }, children: description })) : null, children] })] }));
54
+ }
55
+ export default HoverCard;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * One item of a grid or a list, as something a card can grow out of.
3
+ *
4
+ * All it does is report the pointer and, with it, where the item currently
5
+ * is on screen — measured at the moment of the hover rather than kept in
6
+ * state, because the page scrolls and a rectangle read at render time is
7
+ * wrong by the time it is used.
8
+ *
9
+ * `mouseover`/`mouseout` reach here as React's `onMouseEnter`/`onMouseLeave`,
10
+ * which are synthesised from them and so do not fire again as the pointer
11
+ * moves between the item's own children — the distinction that makes a card
12
+ * flicker if it is got wrong.
13
+ *
14
+ * @module components/hover-card/HoverCardAnchor
15
+ */
16
+ import type { JSX, ReactNode } from 'react';
17
+ import { type BoxProps } from '../box/Box';
18
+ import type { HoverCardRect, HoverCardState } from './useHoverCard';
19
+ export type HoverCardAnchorProps = BoxProps & {
20
+ /** The machine this item reports to. */
21
+ state: HoverCardState<HoverCardRect>;
22
+ /** What identifies this item to it. */
23
+ itemKey: string | number;
24
+ children: ReactNode;
25
+ };
26
+ /**
27
+ * A grid cell by default, which is the shape that makes the wrapper
28
+ * invisible: a lone child of a grid stretches to fill it, so wrapping a
29
+ * card changes nothing about how tall it is or where it sits. Any `Box`
30
+ * prop changes how it sits in its parent.
31
+ */
32
+ export declare function HoverCardAnchor({ state, itemKey, children, ...rest }: HoverCardAnchorProps): JSX.Element;
33
+ export default HoverCardAnchor;
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useRef } from 'react';
3
+ import { Box } from '../box/Box';
4
+ /**
5
+ * A grid cell by default, which is the shape that makes the wrapper
6
+ * invisible: a lone child of a grid stretches to fill it, so wrapping a
7
+ * card changes nothing about how tall it is or where it sits. Any `Box`
8
+ * prop changes how it sits in its parent.
9
+ */
10
+ export function HoverCardAnchor({ state, itemKey, children, ...rest }) {
11
+ const host = useRef(null);
12
+ return (_jsx(Box, { ref: host, onMouseEnter: () => {
13
+ const element = host.current;
14
+ if (!element) {
15
+ return;
16
+ }
17
+ const rect = element.getBoundingClientRect();
18
+ state.open(itemKey, {
19
+ left: rect.left,
20
+ top: rect.top,
21
+ width: rect.width,
22
+ height: rect.height,
23
+ });
24
+ }, onMouseLeave: state.scheduleClose, display: "grid", minWidth: 0, ...rest, children: children }));
25
+ }
26
+ export default HoverCardAnchor;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The large card: everything about one thing, over the page.
3
+ *
4
+ * Not a route: the reader asked for more about a card on a shelf, not to go
5
+ * somewhere. Closing it — the close button, a press on the veil, Escape —
6
+ * leaves them where they were, which is the difference between browsing and
7
+ * navigating.
8
+ *
9
+ * Its own element rather than Primer's `Dialog`, because a picture runs to
10
+ * the edges and under the close button, which a dialog with a header cannot
11
+ * do. Rendered into `document.body` through a portal: a `transform` on any
12
+ * ancestor (an entrance animation's `both` fill-mode is enough) makes
13
+ * `position: fixed` fix to that ancestor rather than to the viewport.
14
+ *
15
+ * It closes itself before it tells anybody: the exit plays, and only then
16
+ * does `onClose` run — unmounting on the click would be a disappearance, not
17
+ * a close. Drawn by the theme: a `Card` with the theme's corner (square to
18
+ * the screen on a narrow one, where it is the page), shadow and ground, on
19
+ * Primer's overlay backdrop.
20
+ *
21
+ * @module components/hover-card/HoverCardDetails
22
+ */
23
+ import type { JSX, ReactNode } from 'react';
24
+ export type HoverCardDetailsProps = {
25
+ /** What the dialog is called, for assistive technology. */
26
+ label: string;
27
+ /** Called once the exit has played. */
28
+ onClose: () => void;
29
+ /** Its width, in pixels; it never exceeds the screen's. 880 by default. */
30
+ width?: number;
31
+ /** What the close button is called. */
32
+ closeLabel?: string;
33
+ children: ReactNode;
34
+ };
35
+ export declare function HoverCardDetails({ label, onClose, width, closeLabel, children, }: HoverCardDetailsProps): JSX.Element | null;
36
+ export default HoverCardDetails;
@@ -0,0 +1,65 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { createPortal } from 'react-dom';
4
+ import { IconButton } from '@primer/react';
5
+ import { XIcon } from '@primer/octicons-react';
6
+ import { Box } from '../box/Box';
7
+ import { Card } from '../card/Card';
8
+ import { HOVER_CARD_MOTION_MS } from './useHoverCard';
9
+ import { usePrefersReducedMotion } from './usePrefersReducedMotion';
10
+ export function HoverCardDetails({ label, onClose, width = 880, closeLabel = 'Close', children, }) {
11
+ const reduced = usePrefersReducedMotion();
12
+ const [leaving, setLeaving] = useState(false);
13
+ const dismiss = () => {
14
+ if (leaving) {
15
+ return;
16
+ }
17
+ if (reduced) {
18
+ onClose();
19
+ return;
20
+ }
21
+ setLeaving(true);
22
+ window.setTimeout(onClose, HOVER_CARD_MOTION_MS);
23
+ };
24
+ // Escape closes it, as it would any overlay.
25
+ useEffect(() => {
26
+ const onKey = (event) => {
27
+ if (event.key === 'Escape') {
28
+ dismiss();
29
+ }
30
+ };
31
+ document.addEventListener('keydown', onKey);
32
+ return () => document.removeEventListener('keydown', onKey);
33
+ });
34
+ if (typeof document === 'undefined') {
35
+ return null;
36
+ }
37
+ return createPortal(_jsx(Box, { role: "presentation", onClick: dismiss, position: "fixed", inset: 0, zIndex: 1000, display: "flex", alignItems: "flex-start", justifyContent: "center", overflowY: "auto", p: [0, 3, 5], background: "var(--overlay-backdrop-bgColor)", animation: reduced
38
+ ? undefined
39
+ : `${leaving ? 'dlaHoverCardVeilOut' : 'dlaHoverCardVeilIn'} ${HOVER_CARD_MOTION_MS}ms ease-out both`, sx: {
40
+ '@keyframes dlaHoverCardVeilIn': { from: { opacity: 0 }, to: { opacity: 1 } },
41
+ '@keyframes dlaHoverCardVeilOut': { from: { opacity: 1 }, to: { opacity: 0 } },
42
+ }, children: _jsxs(Card, { role: "dialog", "aria-modal": "true", "aria-label": label, onClick: (event) => event.stopPropagation(), shadow: "extraLarge", width: width, maxWidth: "100%", borderRadius: [0, 'card'], overflow: "hidden", position: "relative", display: "block",
43
+ // Rises into place and sinks back out, at the hover card's speed: the
44
+ // third size arrives the way the second one did.
45
+ animation: reduced
46
+ ? undefined
47
+ : `${leaving ? 'dlaHoverCardPanelOut' : 'dlaHoverCardPanelIn'} ${HOVER_CARD_MOTION_MS}ms ease-out both`, sx: {
48
+ '@keyframes dlaHoverCardPanelIn': {
49
+ from: { transform: 'translateY(12px) scale(0.97)', opacity: 0 },
50
+ to: { transform: 'translateY(0) scale(1)', opacity: 1 },
51
+ },
52
+ '@keyframes dlaHoverCardPanelOut': {
53
+ from: { transform: 'translateY(0) scale(1)', opacity: 1 },
54
+ to: { transform: 'translateY(12px) scale(0.97)', opacity: 0 },
55
+ },
56
+ }, children: [_jsx(IconButton, { icon: XIcon, "aria-label": closeLabel, onClick: dismiss, sx: {
57
+ position: 'absolute',
58
+ top: 3,
59
+ right: 3,
60
+ zIndex: 2,
61
+ borderRadius: '50%',
62
+ bg: 'canvas.default',
63
+ } }), children] }) }), document.body);
64
+ }
65
+ export default HoverCardDetails;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Where a hover card goes when it is bigger than the thing it grew from.
3
+ *
4
+ * Two problems, both of which the obvious answer — an absolutely positioned
5
+ * element inside the card — gets wrong.
6
+ *
7
+ * The first is escape. A results grid clips, a marquee clips, a section
8
+ * animates; and `position: fixed` is fixed to the *viewport* only until some
9
+ * ancestor has a `transform`, at which point it fixes to that ancestor
10
+ * instead. An entrance animation with `both` fill-mode is enough to do it,
11
+ * for ever after it has played. A portal to `document.body` is immune to all
12
+ * of it, so that is where the card is put.
13
+ *
14
+ * The second is the edges. The card is wider and taller than the thing it
15
+ * covers, so one grown from the first column reaches past the left edge of
16
+ * the window and one at the bottom of the page reaches past the fold. It is
17
+ * measured once it is up and nudged back inside, which is why the position is
18
+ * state rather than a style computed on the way out: the layout has to exist
19
+ * before it can be corrected.
20
+ *
21
+ * @module components/hover-card/HoverCardLayer
22
+ */
23
+ import type { JSX, ReactNode } from 'react';
24
+ import type { HoverCardRect } from './useHoverCard';
25
+ export type HoverCardLayerProps = {
26
+ anchor: HoverCardRect;
27
+ children: ReactNode;
28
+ /** Kept high enough to clear page furniture; under the details dialog. */
29
+ zIndex?: number;
30
+ onMouseEnter?: () => void;
31
+ onMouseLeave?: () => void;
32
+ };
33
+ export declare function HoverCardLayer({ anchor, children, zIndex, onMouseEnter, onMouseLeave }: HoverCardLayerProps): JSX.Element | null;
34
+ export default HoverCardLayer;
@@ -0,0 +1,57 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useLayoutEffect, useRef, useState } from 'react';
3
+ import { createPortal } from 'react-dom';
4
+ /** How close to the window's edge the card may come. */
5
+ const MARGIN = 12;
6
+ export function HoverCardLayer({ anchor, children, zIndex = 900, onMouseEnter, onMouseLeave }) {
7
+ const box = useRef(null);
8
+ /** Centred on the anchor to start with, then corrected against the window. */
9
+ const [at, setAt] = useState(() => ({
10
+ left: anchor.left + anchor.width / 2,
11
+ top: anchor.top + anchor.height / 2
12
+ }));
13
+ useLayoutEffect(() => {
14
+ const element = box.current;
15
+ const centre = {
16
+ left: anchor.left + anchor.width / 2,
17
+ top: anchor.top + anchor.height / 2
18
+ };
19
+ if (!element) {
20
+ setAt(centre);
21
+ return;
22
+ }
23
+ /*
24
+ * The card's own size, not the anchor's.
25
+ *
26
+ * Read from the layout box rather than from the caller: the card decides
27
+ * how much bigger than its anchor it is, and a layer that had to be told
28
+ * would be one more thing to keep in step. `getBoundingClientRect` would
29
+ * report the *animated* size — the entrance starts at the anchor's scale
30
+ * — so the untransformed offsets are what is measured.
31
+ */
32
+ const half = { x: element.offsetWidth / 2, y: element.offsetHeight / 2 };
33
+ const clamp = (value, half_, limit) => {
34
+ // A card too big for the window at all: centre it, rather than pinning
35
+ // it to one edge and letting the other run off.
36
+ if (half_ * 2 + MARGIN * 2 > limit) {
37
+ return limit / 2;
38
+ }
39
+ return Math.min(Math.max(value, half_ + MARGIN), limit - half_ - MARGIN);
40
+ };
41
+ setAt({
42
+ left: clamp(centre.left, half.x, window.innerWidth),
43
+ top: clamp(centre.top, half.y, window.innerHeight)
44
+ });
45
+ }, [anchor.left, anchor.top, anchor.width, anchor.height]);
46
+ if (typeof document === 'undefined') {
47
+ return null;
48
+ }
49
+ return createPortal(_jsx("div", { ref: box, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, style: {
50
+ position: 'fixed',
51
+ left: at.left,
52
+ top: at.top,
53
+ transform: 'translate(-50%, -50%)',
54
+ zIndex
55
+ }, children: children }), document.body);
56
+ }
57
+ export default HoverCardLayer;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The hover card, in parts that compose: `useHoverCard` is the timing,
3
+ * `HoverCardAnchor` the pair of pointer handlers a grid item needs,
4
+ * `HoverCardLayer` the placement, `HoverCard` the card grown out of the
5
+ * small one and `HoverCardDetails` the large one its chevron opens.
6
+ */
7
+ export * from './useHoverCard';
8
+ export * from './usePrefersReducedMotion';
9
+ export * from './HoverCardLayer';
10
+ export * from './HoverCardAnchor';
11
+ export * from './HoverCard';
12
+ export * from './HoverCardDetails';
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Copyright (c) 2021-2026 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /**
6
+ * The hover card, in parts that compose: `useHoverCard` is the timing,
7
+ * `HoverCardAnchor` the pair of pointer handlers a grid item needs,
8
+ * `HoverCardLayer` the placement, `HoverCard` the card grown out of the
9
+ * small one and `HoverCardDetails` the large one its chevron opens.
10
+ */
11
+ export * from './useHoverCard';
12
+ export * from './usePrefersReducedMotion';
13
+ export * from './HoverCardLayer';
14
+ export * from './HoverCardAnchor';
15
+ export * from './HoverCard';
16
+ export * from './HoverCardDetails';
@@ -0,0 +1,57 @@
1
+ /** The thing a hover card grew out of, in viewport coordinates. */
2
+ export type HoverCardRect = {
3
+ left: number;
4
+ top: number;
5
+ width: number;
6
+ height: number;
7
+ };
8
+ /**
9
+ * How long the pointer must rest on something before its card opens.
10
+ *
11
+ * This is the wait that separates *reading a page* from *choosing something
12
+ * on it*: a card that opens while the eye is still travelling is an
13
+ * interruption, since the reader did not ask for it and has to wait for it
14
+ * to leave again. Set by feel, from the top of the range down — long enough
15
+ * that a pointer crossing the page is not chased by anything, short enough
16
+ * that stopping on something does not feel like waiting for it.
17
+ */
18
+ export declare const HOVER_CARD_OPEN_DELAY_MS = 320;
19
+ /** How long a card waits, after the pointer leaves, before it starts out. */
20
+ export declare const HOVER_CARD_CLOSE_DELAY_MS = 320;
21
+ /**
22
+ * How long a card takes to arrive, and to leave.
23
+ *
24
+ * The same number both ways: a card that leaves faster than it came reads as
25
+ * being dismissed rather than closed. Whatever draws the card has to animate
26
+ * for exactly this long, because the card is kept mounted for exactly this
27
+ * long after it is told it is leaving.
28
+ */
29
+ export declare const HOVER_CARD_MOTION_MS = 320;
30
+ export type HoverCardOptions = {
31
+ /**
32
+ * Whether the gesture is offered at all.
33
+ *
34
+ * A caller with nothing to preview passes `false` rather than skipping the
35
+ * hook, which it cannot do.
36
+ */
37
+ enabled?: boolean;
38
+ openDelayMs?: number;
39
+ closeDelayMs?: number;
40
+ motionMs?: number;
41
+ };
42
+ export type HoverCardState<Placement> = {
43
+ /** Where to put the open card, or `null` when there is none. */
44
+ active: Placement | null;
45
+ /** Which item it is open for. */
46
+ activeKey: string | number | null;
47
+ /** Whether it is playing its exit, and so is still on screen. */
48
+ closing: boolean;
49
+ /** The pointer reached this item. */
50
+ open: (key: string | number, at: Placement) => void;
51
+ /** The pointer left it, or left the card. */
52
+ scheduleClose: () => void;
53
+ /** The pointer came back before the card was gone. */
54
+ cancelClose: () => void;
55
+ };
56
+ export declare function useHoverCard<Placement = HoverCardRect>({ enabled, openDelayMs, closeDelayMs, motionMs }?: HoverCardOptions): HoverCardState<Placement>;
57
+ export default useHoverCard;