@datalayer/primer-addons 1.0.51 → 1.0.52

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.
@@ -30,13 +30,20 @@ export interface AppearanceControlsProps {
30
30
  themeVariant?: ThemeVariant;
31
31
  /** Called on a new colour mode; required without the store, called after it with the store. */
32
32
  onColorModeChange?: (mode: ColorMode) => void;
33
- /** Called on a new theme; required without the store, called after it with the store. */
33
+ /**
34
+ * Called on a new theme; required without the store when the theme chooser
35
+ * shows, called after it with the store.
36
+ */
34
37
  onThemeChange?: (theme: ThemeVariant) => void;
35
38
  /** `stacked` by default; see {@link AppearanceControlsLayout}. */
36
39
  layout?: AppearanceControlsLayout;
37
40
  /** Show the light / dark / auto switch. Default: shown. */
38
41
  showColorMode?: boolean;
39
- /** Show the theme chooser. Default: shown. */
42
+ /**
43
+ * Show the theme chooser (the swatches, and with `showThemePreviews` the
44
+ * chosen theme's preview). Default: shown; `false` for a site that wears
45
+ * one theme, where the controls are the light / dark / auto switch alone.
46
+ */
40
47
  showThemeChooser?: boolean;
41
48
  /** Stacked, with the chooser: the chosen theme's name, description and preview under its swatches. Default: swatches only. */
42
49
  showThemePreviews?: boolean;
@@ -35,13 +35,14 @@ export function AppearanceControls({ withStore = true, useStore = useThemeStore,
35
35
  if (givenColorMode === undefined ||
36
36
  givenThemeVariant === undefined ||
37
37
  !givenOnColorModeChange ||
38
- !givenOnThemeChange) {
39
- throw new Error("AppearanceControls without the store needs colorMode, themeVariant, onColorModeChange and onThemeChange.");
38
+ (showThemeChooser && !givenOnThemeChange)) {
39
+ throw new Error("AppearanceControls without the store needs colorMode, themeVariant, onColorModeChange, and onThemeChange when the theme chooser shows.");
40
40
  }
41
41
  colorMode = givenColorMode;
42
42
  themeVariant = givenThemeVariant;
43
43
  onColorModeChange = givenOnColorModeChange;
44
- onThemeChange = givenOnThemeChange;
44
+ // Never called without the chooser: nothing in the controls picks a theme then.
45
+ onThemeChange = givenOnThemeChange ?? (() => undefined);
45
46
  }
46
47
  // At most `themesPerLine` swatches on a line when given, each line centred,
47
48
  // so a shorter last line sits in the middle under the full ones; one line
@@ -8,14 +8,21 @@ export interface AppearanceMenuProps {
8
8
  themeVariant: ThemeVariant;
9
9
  /** Called with the next color mode. */
10
10
  onColorModeChange: (mode: ColorMode) => void;
11
- /** Called with the next theme variant. */
12
- onThemeChange: (theme: ThemeVariant) => void;
11
+ /** Called with the next theme variant; required when the theme chooser shows. */
12
+ onThemeChange?: (theme: ThemeVariant) => void;
13
13
  /** Diameter of the trigger circle in pixels. */
14
14
  size?: number;
15
15
  /** Visual shape of the trigger control. */
16
16
  shape?: 'square' | 'circle';
17
17
  /** Overlay placement relative to the circle. */
18
18
  hoverOverlayPlacement?: HoverOverlayPlacement;
19
+ /**
20
+ * Whether the overlay offers the themes (their swatches, and with
21
+ * `showThemePreviews` the chosen one's preview). Default: shown; `false`
22
+ * for a site that wears one theme — the overlay is the light / dark / auto
23
+ * switch alone.
24
+ */
25
+ showThemeChooser?: boolean;
19
26
  /** Whether the overlay shows the live theme previews. */
20
27
  showThemePreviews?: boolean;
21
28
  /** The most theme swatches on one line in the overlay; undefined, they wrap freely. */
@@ -23,11 +30,12 @@ export interface AppearanceMenuProps {
23
30
  }
24
31
  /**
25
32
  * A single color-mode circle that reveals, on hover, an appearance overlay
26
- * with color-mode controls, theme circles and live theme previews.
33
+ * with color-mode controls, theme circles and live theme previews — or the
34
+ * color-mode controls alone, with `showThemeChooser={false}`.
27
35
  *
28
36
  * This bundles the {@link ColorModeCircle} trigger together with the
29
37
  * {@link AppearanceControls} overlay so the whole appearance menu can be
30
38
  * dropped into any header with a single component.
31
39
  */
32
- export declare function AppearanceMenu({ colorMode, themeVariant, onColorModeChange, onThemeChange, size, shape, hoverOverlayPlacement, showThemePreviews, themesPerLine, }: AppearanceMenuProps): ReactElement;
40
+ export declare function AppearanceMenu({ colorMode, themeVariant, onColorModeChange, onThemeChange, size, shape, hoverOverlayPlacement, showThemeChooser, showThemePreviews, themesPerLine, }: AppearanceMenuProps): ReactElement;
33
41
  export default AppearanceMenu;
@@ -3,13 +3,16 @@ import { ColorModeCircle } from './ColorModeCircle';
3
3
  import { AppearanceControls } from './AppearanceControls';
4
4
  /**
5
5
  * A single color-mode circle that reveals, on hover, an appearance overlay
6
- * with color-mode controls, theme circles and live theme previews.
6
+ * with color-mode controls, theme circles and live theme previews — or the
7
+ * color-mode controls alone, with `showThemeChooser={false}`.
7
8
  *
8
9
  * This bundles the {@link ColorModeCircle} trigger together with the
9
10
  * {@link AppearanceControls} overlay so the whole appearance menu can be
10
11
  * dropped into any header with a single component.
11
12
  */
12
- export function AppearanceMenu({ colorMode, themeVariant, onColorModeChange, onThemeChange, size = 26, shape = 'square', hoverOverlayPlacement = 'bottom-end', showThemePreviews = true, themesPerLine, }) {
13
- return (_jsx(ColorModeCircle, { colorMode: colorMode, onColorModeChange: onColorModeChange, cycleOnClick: false, themeVariant: themeVariant, hoverOverlayPlacement: hoverOverlayPlacement, shape: shape, size: size, hoverOverlay: _jsx(AppearanceControls, { withStore: false, colorMode: colorMode, themeVariant: themeVariant, onColorModeChange: onColorModeChange, onThemeChange: onThemeChange, showThemePreviews: showThemePreviews, themesPerLine: themesPerLine }) }));
13
+ export function AppearanceMenu({ colorMode, themeVariant, onColorModeChange, onThemeChange, size = 26, shape = 'square', hoverOverlayPlacement = 'bottom-end', showThemeChooser = true, showThemePreviews = true, themesPerLine, }) {
14
+ return (_jsx(ColorModeCircle, { colorMode: colorMode, onColorModeChange: onColorModeChange, cycleOnClick: false, themeVariant: themeVariant, hoverOverlayPlacement: hoverOverlayPlacement,
15
+ // The switch alone needs no room for the swatches.
16
+ hoverOverlayMinWidth: showThemeChooser ? 340 : 'auto', shape: shape, size: size, hoverOverlay: _jsx(AppearanceControls, { withStore: false, colorMode: colorMode, themeVariant: themeVariant, onColorModeChange: onColorModeChange, onThemeChange: onThemeChange, showThemeChooser: showThemeChooser, showThemePreviews: showThemePreviews, themesPerLine: themesPerLine }) }));
14
17
  }
15
18
  export default AppearanceMenu;
@@ -40,6 +40,7 @@ declare const meta: {
40
40
  size: number;
41
41
  shape: "square";
42
42
  hoverOverlayPlacement: "bottom-start";
43
+ showThemeChooser: true;
43
44
  showThemePreviews: true;
44
45
  };
45
46
  };
@@ -49,6 +50,11 @@ type Story = StoryObj<typeof meta>;
49
50
  export declare const Default: Story;
50
51
  /** A round trigger, larger, without the theme previews in its overlay. */
51
52
  export declare const CircleWithoutPreviews: Story;
53
+ /**
54
+ * The colour mode alone: light, dark and auto, no theme swatches — the menu
55
+ * of a site that wears one theme (the Datalayer landing, on loop).
56
+ */
57
+ export declare const ColorModeOnly: Story;
52
58
  /**
53
59
  * `AppearanceMenuWithStore`: the menu wired to a theme store, as the
54
60
  * appearance plugin puts it in a header.
@@ -42,6 +42,7 @@ const meta = {
42
42
  size: 26,
43
43
  shape: "square",
44
44
  hoverOverlayPlacement: "bottom-start",
45
+ showThemeChooser: true,
45
46
  showThemePreviews: true,
46
47
  },
47
48
  };
@@ -58,7 +59,7 @@ const ThemedAppearanceMenu = (props) => {
58
59
  props.onColorModeChange(mode);
59
60
  }, onThemeChange: (variant) => {
60
61
  setThemeVariant(variant);
61
- props.onThemeChange(variant);
62
+ props.onThemeChange?.(variant);
62
63
  } }), _jsx(Text, { sx: { color: "fg.muted", fontSize: 1 }, children: "Hover the control: colour mode, theme, the theme's description and a preview." })] }) }) }));
63
64
  };
64
65
  /** The square a header wears. */
@@ -74,10 +75,22 @@ export const CircleWithoutPreviews = {
74
75
  },
75
76
  render: (args) => _jsx(ThemedAppearanceMenu, { ...args }),
76
77
  };
78
+ /**
79
+ * The colour mode alone: light, dark and auto, no theme swatches — the menu
80
+ * of a site that wears one theme (the Datalayer landing, on loop).
81
+ */
82
+ export const ColorModeOnly = {
83
+ args: {
84
+ themeVariant: "loop",
85
+ colorMode: "dark",
86
+ showThemeChooser: false,
87
+ },
88
+ render: (args) => _jsx(ThemedAppearanceMenu, { ...args }),
89
+ };
77
90
  /**
78
91
  * `AppearanceMenuWithStore`: the menu wired to a theme store, as the
79
92
  * appearance plugin puts it in a header.
80
93
  */
81
94
  export const WithStore = {
82
- render: (args) => (_jsx(ThemedProvider, { useStore: useThemeStore, children: _jsx(Box, { p: 3, bg: "canvas.default", minHeight: 520, children: _jsx(AppearanceMenuWithStore, { useStore: useThemeStore, size: args.size, shape: args.shape, hoverOverlayPlacement: args.hoverOverlayPlacement, showThemePreviews: args.showThemePreviews }) }) })),
95
+ render: (args) => (_jsx(ThemedProvider, { useStore: useThemeStore, children: _jsx(Box, { p: 3, bg: "canvas.default", minHeight: 520, children: _jsx(AppearanceMenuWithStore, { useStore: useThemeStore, size: args.size, shape: args.shape, hoverOverlayPlacement: args.hoverOverlayPlacement, showThemeChooser: args.showThemeChooser, showThemePreviews: args.showThemePreviews }) }) })),
83
96
  };
@@ -15,6 +15,11 @@ export interface ColorModeCircleProps {
15
15
  cycleOnClick?: boolean;
16
16
  /** Overlay placement relative to the circle. */
17
17
  hoverOverlayPlacement?: HoverOverlayPlacement;
18
+ /**
19
+ * The overlay's least width: 340 by default, room for the theme swatches;
20
+ * `auto` sizes it to what it holds (the colour-mode switch alone).
21
+ */
22
+ hoverOverlayMinWidth?: number | 'auto';
18
23
  /** Optional theme used to tint the circle border. */
19
24
  themeVariant?: ThemeVariant;
20
25
  /** Visual shape of the control. */
@@ -24,5 +29,5 @@ export interface ColorModeCircleProps {
24
29
  * A single clickable circle that cycles the color mode through
25
30
  * light → dark → system (auto). The icon reflects the current mode.
26
31
  */
27
- export declare function ColorModeCircle({ colorMode, onColorModeChange, size, hoverOverlay, cycleOnClick, hoverOverlayPlacement, themeVariant, shape, }: ColorModeCircleProps): ReactElement;
32
+ export declare function ColorModeCircle({ colorMode, onColorModeChange, size, hoverOverlay, cycleOnClick, hoverOverlayPlacement, hoverOverlayMinWidth, themeVariant, shape, }: ColorModeCircleProps): ReactElement;
28
33
  export default ColorModeCircle;
@@ -34,7 +34,7 @@ const OVERLAY_MARGIN = 12;
34
34
  * A single clickable circle that cycles the color mode through
35
35
  * light → dark → system (auto). The icon reflects the current mode.
36
36
  */
37
- export function ColorModeCircle({ colorMode, onColorModeChange, size = 28, hoverOverlay, cycleOnClick = true, hoverOverlayPlacement = 'bottom-end', themeVariant, shape = 'square', }) {
37
+ export function ColorModeCircle({ colorMode, onColorModeChange, size = 28, hoverOverlay, cycleOnClick = true, hoverOverlayPlacement = 'bottom-end', hoverOverlayMinWidth = 340, themeVariant, shape = 'square', }) {
38
38
  const meta = COLOR_MODE_META[colorMode] ?? COLOR_MODE_META.light;
39
39
  const next = COLOR_MODE_CYCLE[colorMode] ?? 'light';
40
40
  const nextMeta = COLOR_MODE_META[next];
@@ -145,7 +145,7 @@ export function ColorModeCircle({ colorMode, onColorModeChange, size = 28, hover
145
145
  left: isRight ? `calc(100% + 8px)` : isBottomStart ? 0 : 'auto',
146
146
  right: isRight || isBottomStart ? 'auto' : 0,
147
147
  zIndex: 220,
148
- minWidth: 340,
148
+ minWidth: hoverOverlayMinWidth,
149
149
  maxHeight: overlayMaxHeight ?? `calc(100vh - ${OVERLAY_MARGIN * 2}px)`,
150
150
  overflowY: 'auto',
151
151
  overscrollBehavior: 'contain',
@@ -68,10 +68,14 @@ type CardBoxProps = Omit<BoxStyleProps, 'border'> & BoxPseudoProps & Omit<React.
68
68
  * - `subtle` — a quieter ground, `canvas.subtle`, for a card among cards
69
69
  * or one inside a panel;
70
70
  * - `inset` — sunk into the page, `canvas.inset`, for code, logs, a prompt;
71
+ * - `overlay` — a panel floating over the page (a menu, a popover, a
72
+ * picker), `canvas.overlay`: opaque in every theme, where `canvas.default`
73
+ * may be glass (Metal's dark panels) and let the page read through it.
74
+ * The default of a card with `rounded="overlay"`;
71
75
  * - `accent`, `success`, `attention`, `danger` — a note in that tone: the
72
76
  * tone's wash with the tone's muted hairline.
73
77
  */
74
- export type CardVariant = 'default' | 'subtle' | 'inset' | 'accent' | 'success' | 'attention' | 'danger';
78
+ export type CardVariant = 'default' | 'subtle' | 'inset' | 'overlay' | 'accent' | 'success' | 'attention' | 'danger';
75
79
  /** The gradient a card is made of; see {@link CardProps.surface}. */
76
80
  export type CardSurface = 'sage' | 'steel' | 'mauve' | 'clay';
77
81
  export type CardProps = CardBoxProps & {
@@ -82,7 +86,10 @@ export type CardProps = CardBoxProps & {
82
86
  * or an index of Primer's radii. The theme's `card` corner by default.
83
87
  */
84
88
  rounded?: BoxRadiusToken | number;
85
- /** The card's flavour, `default` by default; see {@link CardVariant}. */
89
+ /**
90
+ * The card's flavour: `overlay` with `rounded="overlay"`, `default`
91
+ * otherwise; see {@link CardVariant}.
92
+ */
86
93
  variant?: CardVariant;
87
94
  /**
88
95
  * The card as a gradient, with white text on it and no hairline; it lies
@@ -3,6 +3,7 @@ import { IconButton, Text } from "@primer/react";
3
3
  import { Box, } from "../box/Box";
4
4
  const VARIANTS = {
5
5
  default: { bg: 'canvas.default', borderColor: 'border.default' },
6
+ overlay: { bg: 'canvas.overlay', borderColor: 'border.default' },
6
7
  subtle: { bg: 'canvas.subtle', borderColor: 'border.default' },
7
8
  inset: { bg: 'canvas.inset', borderColor: 'border.default' },
8
9
  accent: { bg: 'accent.subtle', borderColor: 'accent.muted' },
@@ -107,10 +108,11 @@ const DISABLED = {
107
108
  hover: {},
108
109
  };
109
110
  export const Card = (props) => {
110
- const { rounded, border, shadow, variant = 'default', surface, interactive, selected, dashed, disabled, accent, hoverEffect, sx, style, children, ...otherProps } = props;
111
+ const { rounded, border, shadow, variant, surface, interactive, selected, dashed, disabled, accent, hoverEffect, sx, style, children, ...otherProps } = props;
111
112
  const lift = hoverEffect === 'lift' && !disabled;
112
113
  const outlined = border || interactive || selected || dashed || lift;
113
- const flavour = VARIANTS[variant];
114
+ // A floating panel's ground is the overlay's, opaque whatever the theme.
115
+ const flavour = VARIANTS[variant ?? (rounded === 'overlay' ? 'overlay' : 'default')];
114
116
  // An interactive card's hover hairline is the accent, lifted or not.
115
117
  const effectSx = lift ? liftSx(interactive ? 'accent.emphasis' : 'border.muted') : undefined;
116
118
  const mergedSx = effectSx ? { ...effectSx, ...sx } : sx;
@@ -14,6 +14,31 @@ export interface SlidingPanelProps {
14
14
  offset?: number;
15
15
  panelSize?: number | string;
16
16
  fullWidth?: boolean;
17
+ /**
18
+ * Slide within the nearest positioned ancestor rather than over the
19
+ * viewport: the panel is `position: absolute` and takes that box's width
20
+ * (north, south) or height (east, west). For a panel that belongs to one
21
+ * region of a page — a chat embedded in a section — and must not cover
22
+ * the rest of it. Off by default: over the viewport, as before.
23
+ */
24
+ contained?: boolean;
25
+ /**
26
+ * Whether a click on the panel's background dismisses it, as it always
27
+ * did. Off for a panel whose content is read and used (a table, a card):
28
+ * its Close button and Escape still dismiss it.
29
+ */
30
+ dismissOnPanelClick?: boolean;
31
+ /** The Close button's name, said to a screen reader. */
32
+ closeLabel?: string;
33
+ /**
34
+ * Whether the panel is a live region that a screen reader reads out when
35
+ * it opens (`status`, or `alert` for an error), as it always was. Off for
36
+ * a panel with content to read at one's pace: it is then a named region
37
+ * (`ariaLabel`), reached like any other part of the page.
38
+ */
39
+ live?: boolean;
40
+ /** The panel's name, for a region that is not live. */
41
+ ariaLabel?: string;
17
42
  }
18
- export declare const SlidingPanel: ({ isOpen, message, details, onDismiss, position, variant, durationMs, transitionMs, zIndex, offset, panelSize, fullWidth, }: SlidingPanelProps) => import("react").JSX.Element | null;
43
+ export declare const SlidingPanel: ({ isOpen, message, details, onDismiss, position, variant, durationMs, transitionMs, zIndex, offset, panelSize, fullWidth, contained, dismissOnPanelClick, closeLabel, live, ariaLabel, }: SlidingPanelProps) => import("react").JSX.Element | null;
19
44
  export default SlidingPanel;
@@ -97,7 +97,7 @@ const edgeBorderStyles = {
97
97
  borderLeft: '1px solid',
98
98
  },
99
99
  };
100
- export const SlidingPanel = ({ isOpen, message, details, onDismiss, position = 'north', variant = 'default', durationMs, transitionMs = 260, zIndex = 200, offset = 0, panelSize = 360, fullWidth = true, }) => {
100
+ export const SlidingPanel = ({ isOpen, message, details, onDismiss, position = 'north', variant = 'default', durationMs, transitionMs = 260, zIndex = 200, offset = 0, panelSize = 360, fullWidth = true, contained = false, dismissOnPanelClick = true, closeLabel = 'Close panel', live = true, ariaLabel, }) => {
101
101
  const [isMounted, setIsMounted] = useState(isOpen);
102
102
  const [isVisible, setIsVisible] = useState(isOpen);
103
103
  useEffect(() => {
@@ -164,16 +164,27 @@ export const SlidingPanel = ({ isOpen, message, details, onDismiss, position = '
164
164
  return null;
165
165
  }
166
166
  const style = variantStyles[variant];
167
+ const alerting = variant === 'error' || variant === 'danger';
168
+ // Over the viewport, or over its own region of the page.
169
+ const across = contained ? '100%' : '100vw';
170
+ const along = contained ? '100%' : '100vh';
167
171
  const closeStyle = closeButtonStyles[variant];
168
172
  const horizontal = position === 'north' || position === 'south';
169
173
  const edgeBorder = edgeBorderStyles[position];
170
174
  return (_jsx(Box, { sx: {
171
- position: 'fixed',
175
+ position: contained ? 'absolute' : 'fixed',
172
176
  zIndex,
173
177
  display: 'flex',
174
178
  pointerEvents: 'none',
175
179
  ...anchorStyles,
176
- }, children: _jsxs(Box, { role: variant === 'error' || variant === 'danger' ? 'alert' : 'status', "aria-live": variant === 'error' || variant === 'danger' ? 'assertive' : 'polite', onClick: onDismiss
180
+ }, children: _jsxs(Box, { role: live ? (alerting ? 'alert' : 'status') : 'region', "aria-live": live ? (alerting ? 'assertive' : 'polite') : undefined, "aria-label": live ? undefined : ariaLabel, "data-sliding-panel": position, onKeyDown: onDismiss
181
+ ? (event) => {
182
+ if (event.key === 'Escape') {
183
+ event.stopPropagation();
184
+ onDismiss();
185
+ }
186
+ }
187
+ : undefined, onClick: onDismiss && dismissOnPanelClick
177
188
  ? (event) => {
178
189
  // A tap on the panel dismisses it — but not a click on a
179
190
  // link, button or field in its content, nor the end of a
@@ -191,15 +202,15 @@ export const SlidingPanel = ({ isOpen, message, details, onDismiss, position = '
191
202
  display: 'flex',
192
203
  alignItems: 'center',
193
204
  justifyContent: 'flex-start',
194
- cursor: onDismiss ? 'pointer' : 'default',
205
+ cursor: onDismiss && dismissOnPanelClick ? 'pointer' : 'default',
195
206
  width: horizontal
196
207
  ? fullWidth
197
- ? '100vw'
198
- : 'min(960px, 96vw)'
208
+ ? across
209
+ : `min(960px, ${contained ? '100%' : '96vw'})`
199
210
  : panelSize,
200
- maxWidth: horizontal ? '100vw' : undefined,
201
- height: horizontal ? undefined : '100vh',
202
- maxHeight: horizontal ? undefined : '100vh',
211
+ maxWidth: horizontal ? across : '100%',
212
+ height: horizontal ? undefined : along,
213
+ maxHeight: horizontal ? undefined : along,
203
214
  borderColor: style.border,
204
215
  borderTop: edgeBorder.borderTop,
205
216
  borderRight: edgeBorder.borderRight,
@@ -219,7 +230,7 @@ export const SlidingPanel = ({ isOpen, message, details, onDismiss, position = '
219
230
  position: 'absolute',
220
231
  top: 2,
221
232
  right: 3,
222
- }, children: _jsx(IconButton, { variant: "invisible", icon: XIcon, "aria-label": "Close panel", onClick: event => {
233
+ }, children: _jsx(IconButton, { variant: "invisible", icon: XIcon, "aria-label": closeLabel, onClick: event => {
223
234
  event.stopPropagation();
224
235
  onDismiss();
225
236
  }, sx: {
@@ -2,7 +2,7 @@ import type { StoryObj } from '@storybook/react';
2
2
  import { type SlidingPanelProps } from './SlidingPanel';
3
3
  declare const meta: {
4
4
  title: string;
5
- component: ({ isOpen, message, details, onDismiss, position, variant, durationMs, transitionMs, zIndex, offset, panelSize, fullWidth, }: SlidingPanelProps) => import("react").JSX.Element | null;
5
+ component: ({ isOpen, message, details, onDismiss, position, variant, durationMs, transitionMs, zIndex, offset, panelSize, fullWidth, contained, dismissOnPanelClick, closeLabel, live, ariaLabel, }: SlidingPanelProps) => import("react").JSX.Element | null;
6
6
  tags: string[];
7
7
  parameters: {
8
8
  layout: string;
@@ -14,3 +14,4 @@ export declare const NorthInfo: Story;
14
14
  export declare const SouthWarning: Story;
15
15
  export declare const EastSuccess: Story;
16
16
  export declare const WestError: Story;
17
+ export declare const ContainedEast: Story;
@@ -70,3 +70,34 @@ export const WestError = {
70
70
  },
71
71
  render: args => _jsx(Demo, { ...args }),
72
72
  };
73
+ /**
74
+ * Contained: the panel slides within its region of the page (here a box
75
+ * standing for a chat embedded in a section), never over the rest of it.
76
+ */
77
+ const ContainedDemo = (props) => {
78
+ const [isOpen, setIsOpen] = useState(false);
79
+ return (_jsxs(Box, { sx: { p: 4, minHeight: '100vh', bg: 'canvas.default' }, children: [_jsx(Heading, { as: "h2", sx: { fontSize: 3, mb: 3 }, children: "A panel inside its region" }), _jsx(Button, { onClick: () => setIsOpen(true), children: "Open panel" }), _jsxs(Box, { sx: {
80
+ position: 'relative',
81
+ overflow: 'hidden',
82
+ mt: 3,
83
+ height: 360,
84
+ maxWidth: 720,
85
+ border: '1px solid',
86
+ borderColor: 'border.default',
87
+ borderRadius: 2,
88
+ }, children: [_jsx(Box, { sx: { p: 3, color: 'fg.muted' }, children: "The region the panel belongs to." }), _jsx(SlidingPanel, { ...props, isOpen: isOpen, onDismiss: () => setIsOpen(false) })] })] }));
89
+ };
90
+ export const ContainedEast = {
91
+ args: {
92
+ isOpen: false,
93
+ message: 'Deck ready',
94
+ details: 'Six slides on the roast-day launch.',
95
+ position: 'east',
96
+ variant: 'success',
97
+ contained: true,
98
+ panelSize: 320,
99
+ dismissOnPanelClick: false,
100
+ closeLabel: 'Close the notice',
101
+ },
102
+ render: args => _jsx(ContainedDemo, { ...args }),
103
+ };
@@ -16,6 +16,11 @@ export type AppearancePluginConfig = {
16
16
  shape: "square" | "circle";
17
17
  /** Which way the overlay opens from the trigger. */
18
18
  placement: "bottom-start" | "bottom-end";
19
+ /**
20
+ * Whether the overlay offers the themes, or only light, dark and auto: a
21
+ * host that wears one theme turns it off.
22
+ */
23
+ showThemeChooser: boolean;
19
24
  /**
20
25
  * Whether the overlay carries the chosen theme's description and its
21
26
  * preview, or only the circles.
@@ -40,6 +40,7 @@ export const AppearancePlugin = definePlugin({
40
40
  size: 26,
41
41
  shape: "square",
42
42
  placement: "bottom-end",
43
+ showThemeChooser: true,
43
44
  showThemePreviews: true,
44
45
  applyThemeColorMode: false,
45
46
  themesPerLine: 6,
@@ -54,6 +55,7 @@ export const AppearancePlugin = definePlugin({
54
55
  size: config.size,
55
56
  shape: config.shape,
56
57
  hoverOverlayPlacement: config.placement,
58
+ showThemeChooser: config.showThemeChooser,
57
59
  showThemePreviews: config.showThemePreviews,
58
60
  applyThemeColorMode: config.applyThemeColorMode,
59
61
  themesPerLine: config.themesPerLine,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/primer-addons",
3
- "version": "1.0.51",
3
+ "version": "1.0.52",
4
4
  "license": "BSD-3-Clause",
5
5
  "scripts": {
6
6
  "build": "npm run build:lib",