@datalayer/primer-addons 1.0.41 → 1.0.43

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 (43) hide show
  1. package/README.md +6 -2
  2. package/lib/components/appearance/AppearanceControls.stories.d.ts +45 -0
  3. package/lib/components/appearance/AppearanceControls.stories.js +91 -0
  4. package/lib/components/appearance/AppearanceMenu.stories.d.ts +49 -0
  5. package/lib/components/appearance/AppearanceMenu.stories.js +80 -0
  6. package/lib/components/appearance/CollaboratorPalette.stories.d.ts +34 -0
  7. package/lib/components/appearance/CollaboratorPalette.stories.js +59 -0
  8. package/lib/components/appearance/ColorModeCircle.stories.d.ts +47 -0
  9. package/lib/components/appearance/ColorModeCircle.stories.js +80 -0
  10. package/lib/components/appearance/ThemeCircle.stories.d.ts +31 -0
  11. package/lib/components/appearance/ThemeCircle.stories.js +54 -0
  12. package/lib/components/appearance/ThemePreviewCard.stories.d.ts +38 -0
  13. package/lib/components/appearance/ThemePreviewCard.stories.js +72 -0
  14. package/lib/components/box/Box.stories.d.ts +61 -0
  15. package/lib/components/box/Box.stories.js +103 -0
  16. package/lib/components/calendar-picker/CalendarPicker.stories.d.ts +53 -0
  17. package/lib/components/calendar-picker/CalendarPicker.stories.js +89 -0
  18. package/lib/components/card/Card.d.ts +40 -0
  19. package/lib/components/card/Card.js +59 -3
  20. package/lib/components/card/Card.stories.d.ts +8 -0
  21. package/lib/components/card/Card.stories.js +17 -1
  22. package/lib/components/color/ColorSwatch.stories.d.ts +26 -0
  23. package/lib/components/color/ColorSwatch.stories.js +54 -0
  24. package/lib/components/color-picker/ColorPicker.stories.d.ts +36 -0
  25. package/lib/components/color-picker/ColorPicker.stories.js +85 -0
  26. package/lib/components/date-picker/DatePicker.stories.d.ts +65 -0
  27. package/lib/components/date-picker/DatePicker.stories.js +110 -0
  28. package/lib/components/entity-avatar/EntityAvatar.stories.d.ts +47 -0
  29. package/lib/components/entity-avatar/EntityAvatar.stories.js +81 -0
  30. package/lib/components/hover-card/HoverCard.js +4 -1
  31. package/lib/components/hover-card/HoverCard.stories.d.ts +48 -0
  32. package/lib/components/hover-card/HoverCard.stories.js +98 -0
  33. package/lib/components/logo/DatalayerLogo.stories.d.ts +37 -0
  34. package/lib/components/logo/DatalayerLogo.stories.js +58 -0
  35. package/lib/components/sheet/Sheet.stories.d.ts +25 -0
  36. package/lib/components/sheet/Sheet.stories.js +32 -0
  37. package/lib/components/toolbar/Toolbar.stories.d.ts +36 -0
  38. package/lib/components/toolbar/Toolbar.stories.js +209 -0
  39. package/lib/story-helpers.d.ts +11 -0
  40. package/lib/story-helpers.js +19 -1
  41. package/lib/utils/Portals.d.ts +0 -13
  42. package/lib/utils/Portals.js +22 -0
  43. package/package.json +1 -1
@@ -0,0 +1,54 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box } from "@primer/react";
3
+ import { ColorSwatch } from "../..";
4
+ const meta = {
5
+ title: "Components/ColorSwatch",
6
+ component: ColorSwatch,
7
+ tags: ["autodocs"],
8
+ parameters: {
9
+ layout: "fullscreen",
10
+ },
11
+ args: {
12
+ color: "var(--bgColor-accent-emphasis)",
13
+ label: "Accent",
14
+ showValue: true,
15
+ height: 54,
16
+ },
17
+ };
18
+ export default meta;
19
+ const ThemedColorSwatch = (props) => (_jsx(Box, { p: 3, bg: "canvas.default", children: _jsx(Box, { maxWidth: 200, children: _jsx(ColorSwatch, { ...props }) }) }));
20
+ /** A theme variable: the value under it is read from the page, so it follows the theme. */
21
+ export const ThemeToken = {
22
+ render: (args) => _jsx(ThemedColorSwatch, { ...args }),
23
+ };
24
+ /** A fixed colour, shorter. */
25
+ export const FixedColour = {
26
+ args: {
27
+ color: "#7ad7b1",
28
+ label: "A fixed colour",
29
+ height: 32,
30
+ },
31
+ render: (args) => _jsx(ThemedColorSwatch, { ...args }),
32
+ };
33
+ /** Without its value. */
34
+ export const WithoutValue = {
35
+ args: {
36
+ color: "var(--fgColor-default)",
37
+ label: "Foreground",
38
+ showValue: false,
39
+ },
40
+ render: (args) => _jsx(ThemedColorSwatch, { ...args }),
41
+ };
42
+ /** The theme's emphasis colours in a row. */
43
+ export const Palette = {
44
+ render: (args) => (_jsx(Box, { p: 3, bg: "canvas.default", sx: {
45
+ display: "grid",
46
+ gridTemplateColumns: ["repeat(2, 1fr)", "repeat(4, 1fr)"],
47
+ gap: 2,
48
+ }, children: [
49
+ ["var(--bgColor-accent-emphasis)", "Accent"],
50
+ ["var(--bgColor-success-emphasis)", "Success"],
51
+ ["var(--bgColor-attention-emphasis)", "Attention"],
52
+ ["var(--bgColor-danger-emphasis)", "Danger"],
53
+ ].map(([color, label]) => (_jsx(ColorSwatch, { color: color, label: label, showValue: args.showValue, height: args.height }, label))) })),
54
+ };
@@ -0,0 +1,36 @@
1
+ import type { StoryObj } from "@storybook/react";
2
+ import { ColorPicker } from "../..";
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof ColorPicker;
6
+ tags: string[];
7
+ parameters: {
8
+ layout: string;
9
+ };
10
+ argTypes: {
11
+ presets: {
12
+ control: false;
13
+ };
14
+ presetGroups: {
15
+ control: false;
16
+ };
17
+ };
18
+ args: {
19
+ color: string;
20
+ showPresets: true;
21
+ showThemeColors: true;
22
+ showCollaboratorColors: false;
23
+ showInput: true;
24
+ "aria-label": string;
25
+ };
26
+ };
27
+ export default meta;
28
+ type Story = StoryObj<typeof meta>;
29
+ /** The field, the hue rail, the hex input, the neutral presets and the theme's own colours. */
30
+ export declare const Default: Story;
31
+ /** With the colours a room gives its collaborators as a further row. */
32
+ export declare const WithCollaboratorColors: Story;
33
+ /** Rows of your own, each with a heading. */
34
+ export declare const CustomPresetGroups: Story;
35
+ /** The field and the rail only, narrower. */
36
+ export declare const Minimal: Story;
@@ -0,0 +1,85 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2021-2026 Datalayer, Inc.
4
+ * Distributed under the terms of the Modified BSD License.
5
+ */
6
+ import { useEffect, useState } from "react";
7
+ import { Box, Text } from "@primer/react";
8
+ import { ColorPicker } from "../..";
9
+ const meta = {
10
+ title: "Components/ColorPicker",
11
+ component: ColorPicker,
12
+ tags: ["autodocs"],
13
+ parameters: {
14
+ layout: "fullscreen",
15
+ },
16
+ argTypes: {
17
+ presets: { control: false },
18
+ presetGroups: { control: false },
19
+ },
20
+ args: {
21
+ color: "#0969da",
22
+ showPresets: true,
23
+ showThemeColors: true,
24
+ showCollaboratorColors: false,
25
+ showInput: true,
26
+ "aria-label": "Colour",
27
+ },
28
+ };
29
+ export default meta;
30
+ /** Holds the colour and shows it beside the picker. */
31
+ const ThemedColorPicker = (props) => {
32
+ const [color, setColor] = useState(props.color);
33
+ useEffect(() => setColor(props.color), [props.color]);
34
+ return (_jsxs(Box, { p: 3, bg: "canvas.default", sx: {
35
+ display: "flex",
36
+ gap: 4,
37
+ flexWrap: "wrap",
38
+ alignItems: "flex-start",
39
+ }, children: [_jsx(ColorPicker, { ...props, color: color, onChange: (next) => {
40
+ setColor(next);
41
+ props.onChange?.(next);
42
+ } }), _jsxs(Box, { sx: { display: "grid", gap: 2, minWidth: 160 }, children: [_jsx(Box, { sx: {
43
+ height: 72,
44
+ borderRadius: "var(--theme-radius-card)",
45
+ border: "1px solid",
46
+ borderColor: "border.default",
47
+ }, style: { backgroundColor: color } }), _jsx(Text, { sx: { fontFamily: "mono", fontSize: 1 }, children: color })] })] }));
48
+ };
49
+ /** The field, the hue rail, the hex input, the neutral presets and the theme's own colours. */
50
+ export const Default = {
51
+ render: (args) => _jsx(ThemedColorPicker, { ...args }),
52
+ };
53
+ /** With the colours a room gives its collaborators as a further row. */
54
+ export const WithCollaboratorColors = {
55
+ args: {
56
+ showCollaboratorColors: true,
57
+ },
58
+ render: (args) => _jsx(ThemedColorPicker, { ...args }),
59
+ };
60
+ /** Rows of your own, each with a heading. */
61
+ export const CustomPresetGroups = {
62
+ args: {
63
+ color: "#16a085",
64
+ showThemeColors: false,
65
+ presetGroups: [
66
+ { label: "Brand", colors: ["#16a085", "#1abc9c", "#2c3e50", "#f1c40f"] },
67
+ {
68
+ label: "Charts",
69
+ colors: ["#4c78a8", "#f58518", "#e45756", "#72b7b2", "#54a24b"],
70
+ },
71
+ ],
72
+ },
73
+ render: (args) => _jsx(ThemedColorPicker, { ...args }),
74
+ };
75
+ /** The field and the rail only, narrower. */
76
+ export const Minimal = {
77
+ args: {
78
+ color: "#bf3989",
79
+ showPresets: false,
80
+ showThemeColors: false,
81
+ showInput: false,
82
+ width: 200,
83
+ },
84
+ render: (args) => _jsx(ThemedColorPicker, { ...args }),
85
+ };
@@ -0,0 +1,65 @@
1
+ import type { StoryObj } from "@storybook/react";
2
+ import { DatePicker } from "../..";
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof DatePicker;
6
+ tags: string[];
7
+ parameters: {
8
+ layout: string;
9
+ };
10
+ argTypes: {
11
+ value: {
12
+ control: false;
13
+ };
14
+ min: {
15
+ control: false;
16
+ };
17
+ max: {
18
+ control: false;
19
+ };
20
+ isDisabled: {
21
+ control: false;
22
+ };
23
+ format: {
24
+ control: false;
25
+ };
26
+ size: {
27
+ options: string[];
28
+ control: "radio";
29
+ };
30
+ validationStatus: {
31
+ options: (string | undefined)[];
32
+ control: "radio";
33
+ };
34
+ timePosition: {
35
+ options: string[];
36
+ control: "radio";
37
+ };
38
+ weekStartsOn: {
39
+ options: number[];
40
+ control: "radio";
41
+ };
42
+ };
43
+ args: {
44
+ value: Date;
45
+ placeholder: string;
46
+ disabled: false;
47
+ size: "medium";
48
+ withTime: false;
49
+ "aria-label": string;
50
+ };
51
+ };
52
+ export default meta;
53
+ type Story = StoryObj<typeof meta>;
54
+ /** A day, typed or picked from the calendar the field opens. */
55
+ export declare const Default: Story;
56
+ /** A day and a time: the hour and minute columns to the right of the calendar. */
57
+ export declare const WithTime: Story;
58
+ /** The time under the calendar, five-minute steps. */
59
+ export declare const TimeSouth: Story;
60
+ /** Nothing before today, nothing past three months out; weeks open on Monday. */
61
+ export declare const Bounded: Story;
62
+ /** Marked as holding something invalid. */
63
+ export declare const Invalid: Story;
64
+ /** Nothing can be picked or typed. */
65
+ export declare const Disabled: Story;
@@ -0,0 +1,110 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2021-2026 Datalayer, Inc.
4
+ * Distributed under the terms of the Modified BSD License.
5
+ */
6
+ import { useEffect, useState } from "react";
7
+ import { Box, Text } from "@primer/react";
8
+ import { DatePicker, formatISODateTime } from "../..";
9
+ const today = new Date();
10
+ const meta = {
11
+ title: "Components/DatePicker",
12
+ component: DatePicker,
13
+ tags: ["autodocs"],
14
+ parameters: {
15
+ layout: "fullscreen",
16
+ },
17
+ argTypes: {
18
+ value: { control: false },
19
+ min: { control: false },
20
+ max: { control: false },
21
+ isDisabled: { control: false },
22
+ format: { control: false },
23
+ size: {
24
+ options: ["small", "medium", "large"],
25
+ control: "radio",
26
+ },
27
+ validationStatus: {
28
+ options: ["error", "success", undefined],
29
+ control: "radio",
30
+ },
31
+ timePosition: {
32
+ options: ["east", "south", "west", "north"],
33
+ control: "radio",
34
+ },
35
+ weekStartsOn: {
36
+ options: [0, 1],
37
+ control: "radio",
38
+ },
39
+ },
40
+ args: {
41
+ value: today,
42
+ placeholder: "YYYY-MM-DD",
43
+ disabled: false,
44
+ size: "medium",
45
+ withTime: false,
46
+ "aria-label": "Start date",
47
+ },
48
+ };
49
+ export default meta;
50
+ /** Holds the date and says it under the field. */
51
+ const ThemedDatePicker = (props) => {
52
+ const [date, setDate] = useState(props.value ?? null);
53
+ useEffect(() => setDate(props.value ?? null), [props.value]);
54
+ return (_jsx(Box, { p: 3, bg: "canvas.default", minHeight: 420, children: _jsxs(Box, { sx: { display: "grid", gap: 2, maxWidth: 420 }, children: [_jsx(DatePicker, { ...props, value: date, onChange: (next) => {
55
+ setDate(next);
56
+ props.onChange?.(next);
57
+ } }), _jsxs(Text, { sx: { fontSize: 0, color: "fg.muted" }, children: [date ? `Chosen: ${formatISODateTime(date)}.` : "Nothing chosen.", " A date can be typed as well as picked; what is typed is read on blur or on Enter."] })] }) }));
58
+ };
59
+ /** A day, typed or picked from the calendar the field opens. */
60
+ export const Default = {
61
+ render: (args) => _jsx(ThemedDatePicker, { ...args }),
62
+ };
63
+ /** A day and a time: the hour and minute columns to the right of the calendar. */
64
+ export const WithTime = {
65
+ args: {
66
+ value: null,
67
+ withTime: true,
68
+ timePosition: "east",
69
+ timeStep: 15,
70
+ defaultTime: "09:00",
71
+ placeholder: "YYYY-MM-DD HH:mm",
72
+ "aria-label": "Meeting date and time",
73
+ },
74
+ render: (args) => _jsx(ThemedDatePicker, { ...args }),
75
+ };
76
+ /** The time under the calendar, five-minute steps. */
77
+ export const TimeSouth = {
78
+ args: {
79
+ withTime: true,
80
+ timePosition: "south",
81
+ timeStep: 5,
82
+ "aria-label": "Reminder date and time",
83
+ },
84
+ render: (args) => _jsx(ThemedDatePicker, { ...args }),
85
+ };
86
+ /** Nothing before today, nothing past three months out; weeks open on Monday. */
87
+ export const Bounded = {
88
+ args: {
89
+ value: null,
90
+ min: today,
91
+ max: new Date(today.getFullYear(), today.getMonth() + 3, 0),
92
+ weekStartsOn: 1,
93
+ "aria-label": "Due date",
94
+ },
95
+ render: (args) => _jsx(ThemedDatePicker, { ...args }),
96
+ };
97
+ /** Marked as holding something invalid. */
98
+ export const Invalid = {
99
+ args: {
100
+ validationStatus: "error",
101
+ },
102
+ render: (args) => _jsx(ThemedDatePicker, { ...args }),
103
+ };
104
+ /** Nothing can be picked or typed. */
105
+ export const Disabled = {
106
+ args: {
107
+ disabled: true,
108
+ },
109
+ render: (args) => _jsx(ThemedDatePicker, { ...args }),
110
+ };
@@ -0,0 +1,47 @@
1
+ import type { StoryObj } from "@storybook/react";
2
+ import { EntityAvatar, type EntityAvatarTone } from "../..";
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof EntityAvatar;
6
+ tags: string[];
7
+ parameters: {
8
+ layout: string;
9
+ };
10
+ argTypes: {
11
+ shape: {
12
+ options: string[];
13
+ control: "radio";
14
+ };
15
+ tone: {
16
+ options: EntityAvatarTone[];
17
+ control: "select";
18
+ };
19
+ ground: {
20
+ options: string[];
21
+ control: "radio";
22
+ };
23
+ children: {
24
+ control: false;
25
+ };
26
+ };
27
+ args: {
28
+ name: string;
29
+ size: number;
30
+ shape: "circle";
31
+ tone: "accent";
32
+ ground: "subtle";
33
+ ring: false;
34
+ };
35
+ };
36
+ export default meta;
37
+ type Story = StoryObj<typeof meta>;
38
+ /** Initials, when there is neither image nor glyph. */
39
+ export declare const Initials: Story;
40
+ /** An image covers the avatar. */
41
+ export declare const Image: Story;
42
+ /** A glyph — an icon, an emoji — on the theme's corner, for what is not a person. */
43
+ export declare const Glyphs: Story;
44
+ /** Its sizes, as a person and as a space. */
45
+ export declare const Sizes: Story;
46
+ /** The tones, on their wash and solid; the page's ground, a ring, an entity's own colour. */
47
+ export declare const Tones: Story;
@@ -0,0 +1,81 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CopilotIcon } from "@primer/octicons-react";
3
+ import { Box, Text } from "@primer/react";
4
+ import { EntityAvatar } from "../..";
5
+ /** A portrait drawn inline, so the story needs no network. */
6
+ const PORTRAIT = "data:image/svg+xml;utf8," +
7
+ encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" fill="#ddf4ff"/><circle cx="32" cy="26" r="12" fill="#0969da"/><rect x="12" y="42" width="40" height="26" rx="13" fill="#0969da"/></svg>');
8
+ const TONES = [
9
+ "accent",
10
+ "success",
11
+ "attention",
12
+ "severe",
13
+ "danger",
14
+ "done",
15
+ "sponsors",
16
+ "neutral",
17
+ ];
18
+ const meta = {
19
+ title: "Components/EntityAvatar",
20
+ component: EntityAvatar,
21
+ tags: ["autodocs"],
22
+ parameters: {
23
+ layout: "fullscreen",
24
+ },
25
+ argTypes: {
26
+ shape: {
27
+ options: ["circle", "rounded"],
28
+ control: "radio",
29
+ },
30
+ tone: {
31
+ options: TONES,
32
+ control: "select",
33
+ },
34
+ ground: {
35
+ options: ["subtle", "emphasis", "canvas"],
36
+ control: "radio",
37
+ },
38
+ children: { control: false },
39
+ },
40
+ args: {
41
+ name: "Eric Charles",
42
+ size: 48,
43
+ shape: "circle",
44
+ tone: "accent",
45
+ ground: "subtle",
46
+ ring: false,
47
+ },
48
+ };
49
+ export default meta;
50
+ const Row = ({ title, children }) => (_jsxs(Box, { sx: { display: "grid", gap: 2 }, children: [_jsx(Text, { sx: { fontSize: 1, fontWeight: "semibold" }, children: title }), _jsx(Box, { sx: { display: "flex", flexWrap: "wrap", alignItems: "center", gap: 3 }, children: children })] }));
51
+ /** Initials, when there is neither image nor glyph. */
52
+ export const Initials = {
53
+ render: (args) => (_jsx(Box, { p: 3, bg: "canvas.default", children: _jsx(EntityAvatar, { ...args }) })),
54
+ };
55
+ /** An image covers the avatar. */
56
+ export const Image = {
57
+ args: {
58
+ src: PORTRAIT,
59
+ name: "A person",
60
+ },
61
+ render: (args) => (_jsx(Box, { p: 3, bg: "canvas.default", children: _jsx(EntityAvatar, { ...args }) })),
62
+ };
63
+ /** A glyph — an icon, an emoji — on the theme's corner, for what is not a person. */
64
+ export const Glyphs = {
65
+ args: {
66
+ shape: "rounded",
67
+ },
68
+ render: (args) => (_jsxs(Box, { p: 3, bg: "canvas.default", sx: { display: "flex", gap: 3 }, children: [_jsx(EntityAvatar, { ...args, name: "Copilot", children: _jsx(CopilotIcon, { size: 24 }) }), _jsx(EntityAvatar, { ...args, name: "Compactor", children: _jsx("span", { style: { fontSize: 26 }, children: "\uD83D\uDDDC\uFE0F" }) }), _jsx(EntityAvatar, { ...args, name: "Data Analysis" })] })),
69
+ };
70
+ /** Its sizes, as a person and as a space. */
71
+ export const Sizes = {
72
+ render: (args) => (_jsxs(Box, { p: 3, bg: "canvas.default", sx: { display: "grid", gap: 3 }, children: [_jsx(Row, { title: "circle", children: [16, 20, 24, 32, 40, 48, 72].map((size) => (_jsx(EntityAvatar, { ...args, size: size, shape: "circle" }, size))) }), _jsx(Row, { title: "rounded", children: [16, 20, 24, 32, 40, 48, 72].map((size) => (_jsx(EntityAvatar, { ...args, name: "Space", size: size, shape: "rounded" }, size))) })] })),
73
+ };
74
+ /** The tones, on their wash and solid; the page's ground, a ring, an entity's own colour. */
75
+ export const Tones = {
76
+ args: {
77
+ shape: "rounded",
78
+ size: 40,
79
+ },
80
+ render: (args) => (_jsxs(Box, { p: 3, bg: "canvas.default", sx: { display: "grid", gap: 3 }, children: [_jsx(Row, { title: "On their wash", children: TONES.map((tone) => (_jsx(EntityAvatar, { ...args, name: tone, tone: tone, ground: "subtle" }, tone))) }), _jsx(Row, { title: "Solid", children: TONES.map((tone) => (_jsx(EntityAvatar, { ...args, name: tone, tone: tone, ground: "emphasis" }, tone))) }), _jsxs(Row, { title: "The page's ground, a ring, an entity's own colour", children: [_jsx(EntityAvatar, { ...args, name: "Canvas", ground: "canvas" }), _jsx(EntityAvatar, { ...args, name: "Ring", ring: true }), _jsx(EntityAvatar, { ...args, name: "Own Colour", color: "var(--bgColor-done-emphasis)" })] })] })),
81
+ };
@@ -50,6 +50,9 @@ export function HoverCard({ anchorWidth, scale = HOVER_CARD_SCALE, closing = fal
50
50
  display: '-webkit-box',
51
51
  WebkitLineClamp: 2,
52
52
  WebkitBoxOrient: 'vertical',
53
- }, children: title }), meta, description ? (_jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', lineHeight: 1.5 }, children: description })) : null, children] })] }));
53
+ }, children: title }), meta ? (
54
+ // A row of its own, so a label or a token in it hugs its text
55
+ // rather than stretching across the grid's column.
56
+ _jsx(Box, { display: "flex", flexWrap: "wrap", alignItems: "center", gap: 1, children: meta })) : null, description ? (_jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', lineHeight: 1.5 }, children: description })) : null, children] })] }));
54
57
  }
55
58
  export default HoverCard;
@@ -0,0 +1,48 @@
1
+ import type { StoryObj } from "@storybook/react";
2
+ import { HoverCard } from "../..";
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof HoverCard;
6
+ tags: string[];
7
+ parameters: {
8
+ layout: string;
9
+ };
10
+ argTypes: {
11
+ picture: {
12
+ control: false;
13
+ };
14
+ actions: {
15
+ control: false;
16
+ };
17
+ meta: {
18
+ control: false;
19
+ };
20
+ children: {
21
+ control: false;
22
+ };
23
+ };
24
+ args: {
25
+ anchorWidth: number;
26
+ title: string;
27
+ description: string;
28
+ openLabel: string;
29
+ expandLabel: string;
30
+ closing: false;
31
+ };
32
+ };
33
+ export default meta;
34
+ type Story = StoryObj<typeof meta>;
35
+ /**
36
+ * The grown card on its own: the picture as a way in, actions, the
37
+ * focusable chevron, the whole title and description.
38
+ */
39
+ export declare const Grown: Story;
40
+ /** Without a chevron: no `onExpand`, so no third size is offered. */
41
+ export declare const WithoutExpand: Story;
42
+ /**
43
+ * A shelf of small cards: rest the pointer on one and after a moment it grows
44
+ * into the hover card, whose chevron opens the large one. Escape closes either.
45
+ */
46
+ export declare const Shelf: Story;
47
+ /** The large card over the page, on the overlay backdrop: closed by its button, the veil or Escape. */
48
+ export declare const Details: Story;
@@ -0,0 +1,98 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2021-2026 Datalayer, Inc.
4
+ * Distributed under the terms of the Modified BSD License.
5
+ */
6
+ import { useState } from "react";
7
+ import { Box, Button, Label, Text } from "@primer/react";
8
+ import { Card, HoverCard, HoverCardAnchor, HoverCardDetails, HoverCardLayer, useHoverCard, } from "../..";
9
+ const ITEMS = [
10
+ {
11
+ id: "titanic",
12
+ name: "Titanic survival",
13
+ kind: "notebook",
14
+ description: "Who survived, and why: a classic dataset read again with an agent.",
15
+ color: "accent.emphasis",
16
+ },
17
+ {
18
+ id: "quarterly",
19
+ name: "Quarterly report",
20
+ kind: "document",
21
+ description: "Revenue, churn and the pipeline, written from the warehouse every quarter.",
22
+ color: "success.emphasis",
23
+ },
24
+ {
25
+ id: "deck",
26
+ name: "Launch deck",
27
+ kind: "deck",
28
+ description: "Twelve slides from a specification, presented in the browser.",
29
+ color: "done.emphasis",
30
+ },
31
+ ];
32
+ /** A picture drawn by the theme, so the story needs no network. */
33
+ const Picture = ({ item, height }) => (_jsx(Box, { height: height, bg: item.color, color: "fg.onEmphasis", display: "flex", alignItems: "center", justifyContent: "center", fontSize: 3, fontWeight: "semibold", children: item.kind }));
34
+ const meta = {
35
+ title: "Components/HoverCard",
36
+ component: HoverCard,
37
+ tags: ["autodocs"],
38
+ parameters: {
39
+ layout: "fullscreen",
40
+ },
41
+ argTypes: {
42
+ picture: { control: false },
43
+ actions: { control: false },
44
+ meta: { control: false },
45
+ children: { control: false },
46
+ },
47
+ args: {
48
+ anchorWidth: 240,
49
+ title: ITEMS[0].name,
50
+ description: ITEMS[0].description,
51
+ openLabel: `Open ${ITEMS[0].name}`,
52
+ expandLabel: `More about ${ITEMS[0].name}`,
53
+ closing: false,
54
+ },
55
+ };
56
+ export default meta;
57
+ /**
58
+ * The grown card on its own: the picture as a way in, actions, the
59
+ * focusable chevron, the whole title and description.
60
+ */
61
+ export const Grown = {
62
+ render: function GrownStory(args) {
63
+ const [details, setDetails] = useState(false);
64
+ return (_jsxs(Box, { p: 3, bg: "canvas.default", children: [_jsx(HoverCard, { ...args, picture: (height) => _jsx(Picture, { item: ITEMS[0], height: height }), onOpen: () => console.log("Open", ITEMS[0].name), actions: _jsx(Button, { size: "small", variant: "primary", children: "Open" }), onExpand: () => setDetails(true), meta: _jsx(Label, { size: "small", children: ITEMS[0].kind }) }), details ? (_jsxs(HoverCardDetails, { label: ITEMS[0].name, onClose: () => setDetails(false), children: [_jsx(Picture, { item: ITEMS[0], height: 280 }), _jsx(Box, { p: 4, children: _jsx(Text, { sx: { fontSize: 4, fontWeight: 600 }, children: ITEMS[0].name }) })] })) : null] }));
65
+ },
66
+ };
67
+ /** Without a chevron: no `onExpand`, so no third size is offered. */
68
+ export const WithoutExpand = {
69
+ args: {
70
+ title: ITEMS[2].name,
71
+ description: ITEMS[2].description,
72
+ },
73
+ render: (args) => (_jsx(Box, { p: 3, bg: "canvas.default", children: _jsx(HoverCard, { ...args, picture: (height) => _jsx(Picture, { item: ITEMS[2], height: height }), meta: _jsx(Label, { size: "small", children: ITEMS[2].kind }) }) })),
74
+ };
75
+ /**
76
+ * A shelf of small cards: rest the pointer on one and after a moment it grows
77
+ * into the hover card, whose chevron opens the large one. Escape closes either.
78
+ */
79
+ export const Shelf = {
80
+ render: function ShelfStory() {
81
+ const state = useHoverCard();
82
+ const [details, setDetails] = useState(null);
83
+ const previewed = ITEMS.find((item) => item.id === state.activeKey);
84
+ return (_jsxs(Box, { p: 3, bg: "canvas.default", minHeight: 420, children: [_jsx(Box, { sx: {
85
+ display: "grid",
86
+ gridTemplateColumns: "repeat(auto-fill, minmax(200px, 1fr))",
87
+ gap: 3,
88
+ }, children: ITEMS.map((item) => (_jsx(HoverCardAnchor, { state: state, itemKey: item.id, children: _jsxs(Card, { border: true, shadow: "none", interactive: true, overflow: "hidden", children: [_jsx(Picture, { item: item, height: 100 }), _jsx(Card.Content, { children: _jsx(Text, { sx: { fontWeight: "bold" }, children: item.name }) })] }) }, item.id))) }), state.active && previewed ? (_jsx(HoverCardLayer, { anchor: state.active, onMouseEnter: state.cancelClose, onMouseLeave: state.scheduleClose, children: _jsx(HoverCard, { anchorWidth: state.active.width, closing: state.closing, picture: (height) => _jsx(Picture, { item: previewed, height: height }), onOpen: () => console.log("Open", previewed.name), openLabel: `Open ${previewed.name}`, actions: _jsx(Button, { size: "small", variant: "primary", children: "Open" }), onExpand: () => setDetails(previewed), expandLabel: `More about ${previewed.name}`, title: previewed.name, meta: _jsx(Label, { size: "small", children: previewed.kind }), description: previewed.description }) })) : null, details ? (_jsxs(HoverCardDetails, { label: details.name, onClose: () => setDetails(null), children: [_jsx(Picture, { item: details, height: 280 }), _jsxs(Box, { p: 4, sx: { display: "grid", gap: 3 }, children: [_jsx(Text, { sx: { fontSize: 4, fontWeight: 600 }, children: details.name }), _jsx(Label, { sx: { justifySelf: "start" }, children: details.kind }), _jsx(Text, { sx: { color: "fg.muted" }, children: details.description })] })] })) : null] }));
89
+ },
90
+ };
91
+ /** The large card over the page, on the overlay backdrop: closed by its button, the veil or Escape. */
92
+ export const Details = {
93
+ render: function DetailsStory() {
94
+ const [open, setOpen] = useState(false);
95
+ const item = ITEMS[1];
96
+ return (_jsxs(Box, { p: 3, bg: "canvas.default", children: [_jsx(Button, { onClick: () => setOpen(true), children: "Open the large card" }), open ? (_jsxs(HoverCardDetails, { label: item.name, onClose: () => setOpen(false), width: 720, children: [_jsx(Picture, { item: item, height: 240 }), _jsxs(Box, { p: 4, sx: { display: "grid", gap: 3 }, children: [_jsx(Text, { sx: { fontSize: 4, fontWeight: 600 }, children: item.name }), _jsx(Label, { sx: { justifySelf: "start" }, children: item.kind }), _jsx(Text, { sx: { color: "fg.muted" }, children: item.description })] })] })) : null] }));
97
+ },
98
+ };
@@ -0,0 +1,37 @@
1
+ import type { StoryObj } from "@storybook/react";
2
+ declare const meta: {
3
+ title: string;
4
+ component: import("react").ForwardRefExoticComponent<import("./DatalayerLogo").DatalayerLogoProps & import("react").RefAttributes<SVGSVGElement>>;
5
+ tags: string[];
6
+ parameters: {
7
+ layout: string;
8
+ };
9
+ argTypes: {
10
+ variant: {
11
+ options: import("../..").ThemeVariant[];
12
+ control: "select";
13
+ };
14
+ colorMode: {
15
+ options: string[];
16
+ control: "radio";
17
+ };
18
+ };
19
+ args: {
20
+ size: number;
21
+ variant: "datalayer";
22
+ colorMode: "light";
23
+ gradient: false;
24
+ };
25
+ };
26
+ export default meta;
27
+ type Story = StoryObj<typeof meta>;
28
+ /** The square mark, in a theme's colours. */
29
+ export declare const Logo: Story;
30
+ /** The mark with gradients. */
31
+ export declare const Gradient: Story;
32
+ /** The mark beside the wordmark, and the wordmark with the AI glyph. */
33
+ export declare const LogoTextAndTextAI: Story;
34
+ /** The bare wordmark: an SVG group, placed in an SVG of the host's own. */
35
+ export declare const Wordmark: Story;
36
+ /** The mark in every theme. */
37
+ export declare const AllThemes: Story;