@datalayer/primer-addons 1.0.60 → 1.0.62

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.
package/README.md CHANGED
@@ -34,6 +34,7 @@ This project has been [shared in a discussion](https://github.com/primer/react/d
34
34
  - [x] Hover Card
35
35
  - [x] Datalayer logos and text marks
36
36
  - [x] Progress Ring, Timer and Spinner Bar
37
+ - [x] Scrollbar: Scroll Area, `scrollbarSx`, `SCROLLBAR_CLASS` and `ScrollbarStyles`
37
38
  - [x] Sheet
38
39
  - [x] Side Overlay
39
40
  - [x] Slider
@@ -205,6 +206,22 @@ import { Box } from '@datalayer/primer-addons';
205
206
 
206
207
  The sources: `src/components/box/Box.tsx` (the design), `boxCss.ts` (the props and their scales, the stylesheet), `boxTokens.ts` (the tokens, generated from Primer's theme), `src/theme/css/primerBaseVars.ts` (Primer's variables no theme sets).
207
208
 
209
+ ## Scrollbars
210
+
211
+ One discreet scrollbar, the same in Chromium, Safari and Firefox: narrow (8px, the rounded thumb inset to 4px) on a clear track, the thumb in the theme's `--borderColor-default`, `--fgColor-muted` on hover, so it follows light, dark and every theme. Chromium and Safari draw it from `::-webkit-scrollbar` (with `scrollbar-width` and `scrollbar-color` set back to `auto`, which would otherwise disable it, and which an ancestor's `scrollbar-color` would pass down); Firefox from `scrollbar-width: thin` and `scrollbar-color`. Nothing here changes an element's overflow, only its scrollbar's look.
212
+
213
+ ```tsx
214
+ import { ScrollArea, scrollbarSx, SCROLLBAR_CLASS, ScrollbarStyles } from '@datalayer/primer-addons';
215
+
216
+ <ScrollArea maxHeight={320}>…</ScrollArea> // a Box scrolling vertically, its scroll kept to itself
217
+ <Box sx={{ overflowX: 'auto', ...scrollbarSx }}>…</Box> // a Box of your own
218
+ <ScrollbarStyles /> <pre className={SCROLLBAR_CLASS}>…</pre> // any element, by class
219
+ <ScrollbarStyles global /> // every scrollbar of the application, <html>'s included
220
+ <ScrollbarStyles selector=".jp-Notebook *" /> // the elements a selector matches
221
+ ```
222
+
223
+ `scrollbarCss(selector)` is the same stylesheet as text. An element may colour its own scrollbar with `--dla-scrollbar-thumb`, `--dla-scrollbar-thumb-hover` and `--dla-scrollbar-track` (a grid painting its track as its headers). The sources: `src/components/scroll-area/`.
224
+
208
225
  ## Theme accents
209
226
 
210
227
  Six soft accents, and an application takes one — **over any theme**: `datalayer`, `spatial`, `lovely`, `matrix`, `earth`, `sand`, `ivory`, `sun` and `agent` alike (decided 2026-10-07; they coloured `agent` alone before). The [gallery](examples/gallery)'s *Theme Accents* page shows the six in whatever theme and colour mode the gallery wears, beside the theme's own, with its tokens read back. Each is five values — the accent, the text that sits on it, the **stage** (the tint behind a hosted application), a **quiet** tint (the agent's bubble, a draft) and the accent **as text** (a link, a suggested question) — the last three each with a light and a dark value.
@@ -7,7 +7,7 @@ import { useEffect, useLayoutEffect, useRef, useState } from 'react';
7
7
  import { IconButton, Tooltip } from '@primer/react';
8
8
  import { MoonIcon, SunIcon, DeviceDesktopIcon } from '@primer/octicons-react';
9
9
  import { Box } from '../box/Box';
10
- import { thinScrollbarSx } from '../scroll-area/ScrollArea';
10
+ import { scrollbarSx } from '../scroll-area/scrollbar';
11
11
  import { themeConfigs } from '../../theme';
12
12
  /** Order in which a click cycles through the color modes. */
13
13
  const COLOR_MODE_CYCLE = {
@@ -150,7 +150,7 @@ export function ColorModeCircle({ colorMode, onColorModeChange, size = 28, hover
150
150
  overflowY: 'auto',
151
151
  overscrollBehavior: 'contain',
152
152
  // The tiny scrollbar, as the left sidebar's (13 November 2026).
153
- ...thinScrollbarSx,
153
+ ...scrollbarSx,
154
154
  bg: 'canvas.overlay',
155
155
  border: '1px solid',
156
156
  borderColor: 'border.default',
@@ -20,7 +20,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
20
  * @module components/date-picker/TimeColumns
21
21
  */
22
22
  import { useEffect, useRef, useState } from "react";
23
- import { ActionList, Box, Text, TextInput } from "@primer/react";
23
+ import { ActionList, Text, TextInput } from "@primer/react";
24
+ import { Box } from "../box/Box";
25
+ import { scrollbarSx } from "../scroll-area/scrollbar";
24
26
  /** `7` → `07`. Two digits, always, because a column of ragged numbers reads badly. */
25
27
  export const pad = (value) => `${value}`.padStart(2, "0");
26
28
  /** Read a freely typed 24-hour time without letting `Date` roll it over. */
@@ -69,7 +71,7 @@ function Column({ label, ariaLabel, values, selected, onPick, disabled, }) {
69
71
  bg: "canvas.default",
70
72
  // The scrollbar is the only hint that there is more below, so it
71
73
  // stays: a hidden one turns the column into a list of six hours.
72
- scrollbarWidth: "thin",
74
+ ...scrollbarSx,
73
75
  }, children: _jsx(ActionList, { selectionVariant: "single", "aria-label": ariaLabel, sx: { p: 1 }, children: values.map((value) => (_jsx(ActionList.Item, { ref: value === selected ? chosen : undefined, selected: value === selected, disabled: disabled, onSelect: () => onPick(value), sx: { justifyContent: "center", fontVariantNumeric: "tabular-nums" }, children: pad(value) }, value))) }) })] }));
74
76
  }
75
77
  /**
@@ -1,31 +1,10 @@
1
1
  import { type ComponentProps } from 'react';
2
2
  import { Box } from '../box/Box';
3
- /**
4
- * A tiny scrollbar: thin, its thumb in the theme's border colour on a clear
5
- * track, darker on hover. Spread it into any scrolling element's `sx`.
6
- */
7
- export declare const thinScrollbarSx: {
8
- readonly scrollbarWidth: "thin";
9
- readonly scrollbarColor: "var(--borderColor-default, rgba(127, 127, 127, 0.4)) transparent";
10
- readonly '&::-webkit-scrollbar': {
11
- readonly width: "6px";
12
- readonly height: "6px";
13
- };
14
- readonly '&::-webkit-scrollbar-track': {
15
- readonly background: "transparent";
16
- };
17
- readonly '&::-webkit-scrollbar-thumb': {
18
- readonly background: "var(--borderColor-default, rgba(127, 127, 127, 0.4))";
19
- readonly borderRadius: "999px";
20
- };
21
- readonly '&::-webkit-scrollbar-thumb:hover': {
22
- readonly background: "var(--fgColor-muted, rgba(127, 127, 127, 0.7))";
23
- };
24
- };
25
3
  export type ScrollAreaProps = ComponentProps<typeof Box>;
26
4
  /**
27
- * A Box that scrolls (vertically by default) with the tiny scrollbar, its
28
- * scroll kept to itself. Any `sx` given is applied over it.
5
+ * A Box that scrolls (vertically by default) with the discreet scrollbar
6
+ * (`scrollbarSx`), its scroll kept to itself. Any `sx` given is applied
7
+ * over it, a `scrollbarWidth` or `scrollbarColor` included (`withScrollbarSx`).
29
8
  */
30
9
  export declare const ScrollArea: import("react").ForwardRefExoticComponent<Omit<import("..").BoxStyleProps & {
31
10
  hover?: import("..").BoxStyleProps | undefined;
@@ -5,28 +5,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
5
5
  */
6
6
  import { forwardRef } from 'react';
7
7
  import { Box } from '../box/Box';
8
+ import { withScrollbarSx } from './scrollbar';
8
9
  /**
9
- * A tiny scrollbar: thin, its thumb in the theme's border colour on a clear
10
- * track, darker on hover. Spread it into any scrolling element's `sx`.
11
- */
12
- export const thinScrollbarSx = {
13
- scrollbarWidth: 'thin',
14
- scrollbarColor: 'var(--borderColor-default, rgba(127, 127, 127, 0.4)) transparent',
15
- '&::-webkit-scrollbar': { width: '6px', height: '6px' },
16
- '&::-webkit-scrollbar-track': { background: 'transparent' },
17
- '&::-webkit-scrollbar-thumb': {
18
- background: 'var(--borderColor-default, rgba(127, 127, 127, 0.4))',
19
- borderRadius: '999px'
20
- },
21
- '&::-webkit-scrollbar-thumb:hover': {
22
- background: 'var(--fgColor-muted, rgba(127, 127, 127, 0.7))'
23
- }
24
- };
25
- /**
26
- * A Box that scrolls (vertically by default) with the tiny scrollbar, its
27
- * scroll kept to itself. Any `sx` given is applied over it.
10
+ * A Box that scrolls (vertically by default) with the discreet scrollbar
11
+ * (`scrollbarSx`), its scroll kept to itself. Any `sx` given is applied
12
+ * over it, a `scrollbarWidth` or `scrollbarColor` included (`withScrollbarSx`).
28
13
  */
29
14
  export const ScrollArea = forwardRef(function ScrollArea({ sx, ...props }, ref) {
30
- return (_jsx(Box, { ref: ref, ...props, sx: { overflowY: 'auto', overscrollBehavior: 'contain', ...thinScrollbarSx, ...sx } }));
15
+ return (_jsx(Box, { ref: ref, ...props, sx: { overflowY: 'auto', overscrollBehavior: 'contain', ...withScrollbarSx(sx) } }));
31
16
  });
32
17
  export default ScrollArea;
@@ -0,0 +1,29 @@
1
+ import type { StoryObj } from "@storybook/react";
2
+ declare const meta: {
3
+ title: string;
4
+ component: import("react").ForwardRefExoticComponent<Omit<import("..").BoxStyleProps & {
5
+ hover?: import("..").BoxStyleProps | undefined;
6
+ focus?: import("..").BoxStyleProps | undefined;
7
+ focusVisible?: import("..").BoxStyleProps | undefined;
8
+ focusWithin?: import("..").BoxStyleProps | undefined;
9
+ active?: import("..").BoxStyleProps | undefined;
10
+ } & {
11
+ reducedMotion?: import("..").BoxStyleProps;
12
+ } & Omit<import("react").HTMLAttributes<HTMLElement>, "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "animationDelay" | "appearance" | "aspectRatio" | "backdropFilter" | "backgroundColor" | "backgroundImage" | "backgroundRepeat" | "backgroundSize" | "borderBottomColor" | "borderBottomLeftRadius" | "borderBottomRightRadius" | "borderBottomStyle" | "borderBottomWidth" | "borderCollapse" | "borderLeftColor" | "borderLeftStyle" | "borderLeftWidth" | "borderRightColor" | "borderRightStyle" | "borderRightWidth" | "borderSpacing" | "borderTopColor" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderTopStyle" | "borderTopWidth" | "bottom" | "boxSizing" | "clipPath" | "color" | "columnGap" | "cursor" | "display" | "fill" | "filter" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "float" | "fontFamily" | "fontSize" | "fontStyle" | "fontVariantNumeric" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridColumnEnd" | "gridColumnStart" | "gridRowEnd" | "gridRowStart" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "isolation" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "listStylePosition" | "listStyleType" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "mixBlendMode" | "objectFit" | "objectPosition" | "opacity" | "order" | "outlineColor" | "outlineOffset" | "overflowWrap" | "overflowX" | "overflowY" | "overscrollBehaviorY" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "pointerEvents" | "position" | "resize" | "right" | "rowGap" | "scrollMarginTop" | "scrollbarGutter" | "scrollbarWidth" | "stroke" | "tableLayout" | "textAlign" | "textOverflow" | "textShadow" | "textTransform" | "textUnderlineOffset" | "top" | "touchAction" | "transform" | "transformOrigin" | "userSelect" | "verticalAlign" | "visibility" | "whiteSpace" | "width" | "willChange" | "wordBreak" | "wordWrap" | "all" | "animation" | "background" | "backgroundPosition" | "border" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderStyle" | "borderTop" | "borderWidth" | "flex" | "flexFlow" | "font" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "gridTemplate" | "inset" | "listStyle" | "margin" | "outline" | "overflow" | "overscrollBehavior" | "padding" | "paddingBlock" | "paddingInline" | "placeContent" | "placeItems" | "placeSelf" | "textDecoration" | "textWrap" | "transition" | "clip" | "WebkitLineClamp" | "bg" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "size" | "gridColumnGap" | "gridGap" | "gridRowGap" | "WebkitBoxOrient" | "borderX" | "borderY" | "as"> & {
13
+ [prop: string]: unknown;
14
+ as?: import("react").ElementType;
15
+ sx?: import("../box/sx").BetterSystemStyleObject;
16
+ className?: string;
17
+ style?: import("react").CSSProperties;
18
+ children?: import("react").ReactNode;
19
+ } & import("react").RefAttributes<any>, "ref"> & import("react").RefAttributes<HTMLElement>>;
20
+ tags: string[];
21
+ };
22
+ export default meta;
23
+ type Story = StoryObj<typeof meta>;
24
+ /** A `ScrollArea`: a Box that scrolls vertically, with the scrollbar. */
25
+ export declare const Default: Story;
26
+ /** `scrollbarSx` on an element that scrolls both ways. */
27
+ export declare const Sx: Story;
28
+ /** `SCROLLBAR_CLASS` on any element, with `ScrollbarStyles` rendered once. */
29
+ export declare const ClassName: Story;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Box, SCROLLBAR_CLASS, ScrollArea, ScrollbarStyles, scrollbarSx } from "../..";
3
+ const lines = Array.from({ length: 40 }, (_, i) => `Line ${i + 1}: the discreet scrollbar, in the theme's colours.`);
4
+ const meta = {
5
+ title: "Components/ScrollArea",
6
+ component: ScrollArea,
7
+ tags: ["autodocs"],
8
+ };
9
+ export default meta;
10
+ /** A `ScrollArea`: a Box that scrolls vertically, with the scrollbar. */
11
+ export const Default = {
12
+ render: () => (_jsx(ScrollArea, { height: 200, width: 360, p: 2, border: "1px solid", borderColor: "border.default", borderRadius: 2, children: lines.map(line => (_jsx(Box, { py: 1, children: line }, line))) })),
13
+ };
14
+ /** `scrollbarSx` on an element that scrolls both ways. */
15
+ export const Sx = {
16
+ render: () => (_jsx(Box, { height: 200, width: 360, p: 2, border: "1px solid", borderColor: "border.default", borderRadius: 2, sx: { overflow: "auto", whiteSpace: "nowrap", ...scrollbarSx }, children: lines.map(line => (_jsxs(Box, { py: 1, children: [line, " ", line] }, line))) })),
17
+ };
18
+ /** `SCROLLBAR_CLASS` on any element, with `ScrollbarStyles` rendered once. */
19
+ export const ClassName = {
20
+ render: () => (_jsxs(_Fragment, { children: [_jsx(ScrollbarStyles, {}), _jsx("pre", { className: SCROLLBAR_CLASS, style: { height: 160, width: 360, overflow: "auto", margin: 0 }, children: lines.map(line => `${line} ${line}`).join("\n") })] })),
21
+ };
@@ -0,0 +1,17 @@
1
+ export type ScrollbarStylesProps = {
2
+ /**
3
+ * Every scrolling element of the page, `<html>` included: an application's
4
+ * scrollbars, all of them. Without it, the elements with `SCROLLBAR_CLASS`.
5
+ */
6
+ global?: boolean;
7
+ /** The elements to give the scrollbar instead (a selector list). */
8
+ selector?: string;
9
+ };
10
+ /**
11
+ * The discreet scrollbar as a `<style>` element, rendered where it stands
12
+ * (a shadow root keeps it to itself): for the elements with
13
+ * `SCROLLBAR_CLASS` by default, every element with `global`, or those a
14
+ * `selector` matches. Rendering it twice is harmless.
15
+ */
16
+ export declare function ScrollbarStyles({ global, selector }: ScrollbarStylesProps): import("react").JSX.Element;
17
+ export default ScrollbarStyles;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } 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 { SCROLLBAR_CLASS, scrollbarCss } from './scrollbar';
7
+ /**
8
+ * The discreet scrollbar as a `<style>` element, rendered where it stands
9
+ * (a shadow root keeps it to itself): for the elements with
10
+ * `SCROLLBAR_CLASS` by default, every element with `global`, or those a
11
+ * `selector` matches. Rendering it twice is harmless.
12
+ */
13
+ export function ScrollbarStyles({ global = false, selector }) {
14
+ const target = selector ?? (global ? '*' : `.${SCROLLBAR_CLASS}`);
15
+ return _jsx("style", { "data-primer-addons-scrollbar": target, children: scrollbarCss(target) });
16
+ }
17
+ export default ScrollbarStyles;
@@ -1 +1,3 @@
1
+ export * from './scrollbar';
1
2
  export * from './ScrollArea';
3
+ export * from './ScrollbarStyles';
@@ -2,4 +2,6 @@
2
2
  * Copyright (c) 2021-2026 Datalayer, Inc.
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
+ export * from './scrollbar';
5
6
  export * from './ScrollArea';
7
+ export * from './ScrollbarStyles';
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The discreet scrollbar: narrow, a rounded thumb on a clear track, the
3
+ * thumb plainer on hover. One look in every browser:
4
+ *
5
+ * - Chromium and Safari draw it from `::-webkit-scrollbar` (8px, the thumb
6
+ * inset 2px, so 4px seen). `scrollbar-width` and `scrollbar-color` are
7
+ * set back to `auto` there: Chromium 121 and later ignores
8
+ * `::-webkit-scrollbar` on an element where either is set, and
9
+ * `scrollbar-color` is inherited, from any ancestor (JupyterLab's theme).
10
+ * - Firefox, which has no `::-webkit-scrollbar`, draws it from
11
+ * `scrollbar-width: thin` and `scrollbar-color`.
12
+ *
13
+ * The colours are the theme's, so they follow light and dark and every
14
+ * theme: the thumb is `--borderColor-default`, `--fgColor-muted` on hover.
15
+ * The fallbacks are for an element no theme provider covers (the page's
16
+ * own scrollbar, on `<html>`). An element may set its own colours with
17
+ * `--dla-scrollbar-thumb`, `--dla-scrollbar-thumb-hover` and
18
+ * `--dla-scrollbar-track` (a grid painting its track as its headers).
19
+ */
20
+ /** The class giving an element the scrollbar, once `ScrollbarStyles` is rendered. */
21
+ export declare const SCROLLBAR_CLASS = "dla-scrollbar";
22
+ /** The scrollbar's thickness in Chromium and Safari, the thumb inset in it. */
23
+ export declare const SCROLLBAR_SIZE = "8px";
24
+ /**
25
+ * The scrollbar as an `sx` fragment, for an element that scrolls: spread it
26
+ * into the element's `sx` (a primer-addons `Box`). It sets no overflow.
27
+ */
28
+ export declare const scrollbarSx: {
29
+ readonly "@supports selector(::-webkit-scrollbar)": {
30
+ readonly scrollbarWidth: "auto";
31
+ readonly scrollbarColor: "auto";
32
+ };
33
+ readonly "@supports not selector(::-webkit-scrollbar)": {
34
+ readonly scrollbarWidth: "thin";
35
+ readonly scrollbarColor: "var(--dla-scrollbar-thumb, var(--borderColor-default, rgba(127, 127, 127, 0.4))) var(--dla-scrollbar-track, transparent)";
36
+ };
37
+ readonly '&::-webkit-scrollbar': {
38
+ readonly width: "8px";
39
+ readonly height: "8px";
40
+ readonly background: "transparent";
41
+ };
42
+ readonly '&::-webkit-scrollbar-track': {
43
+ readonly background: "var(--dla-scrollbar-track, transparent)";
44
+ };
45
+ readonly '&::-webkit-scrollbar-corner': {
46
+ readonly background: "var(--dla-scrollbar-track, transparent)";
47
+ };
48
+ readonly '&::-webkit-scrollbar-thumb': {
49
+ readonly backgroundColor: "var(--dla-scrollbar-thumb, var(--borderColor-default, rgba(127, 127, 127, 0.4)))";
50
+ readonly border: "2px solid transparent";
51
+ readonly backgroundClip: "padding-box";
52
+ readonly borderRadius: "999px";
53
+ };
54
+ readonly '&::-webkit-scrollbar-thumb:hover': {
55
+ readonly backgroundColor: "var(--dla-scrollbar-thumb-hover, var(--fgColor-muted, rgba(127, 127, 127, 0.7)))";
56
+ };
57
+ };
58
+ /**
59
+ * `scrollbarSx` with an element's own `sx` over it. A `scrollbarWidth` or
60
+ * `scrollbarColor` given in `sx` goes into both of the scrollbar's
61
+ * `@supports` branches too: set at the element's top level only, the
62
+ * branches, which come after it, would put the scrollbar's values back.
63
+ * The element's own `@supports` blocks of the same conditions come last,
64
+ * whole.
65
+ */
66
+ export declare function withScrollbarSx<T extends object>(sx?: T): typeof scrollbarSx & T;
67
+ /**
68
+ * The scrollbar as a stylesheet, for the elements a selector matches (a
69
+ * selector list too: each part gets it). `'*'` is every element of the page.
70
+ */
71
+ export declare function scrollbarCss(selector?: string): string;
@@ -0,0 +1,156 @@
1
+ /*
2
+ * Copyright (c) 2021-2026 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /**
6
+ * The discreet scrollbar: narrow, a rounded thumb on a clear track, the
7
+ * thumb plainer on hover. One look in every browser:
8
+ *
9
+ * - Chromium and Safari draw it from `::-webkit-scrollbar` (8px, the thumb
10
+ * inset 2px, so 4px seen). `scrollbar-width` and `scrollbar-color` are
11
+ * set back to `auto` there: Chromium 121 and later ignores
12
+ * `::-webkit-scrollbar` on an element where either is set, and
13
+ * `scrollbar-color` is inherited, from any ancestor (JupyterLab's theme).
14
+ * - Firefox, which has no `::-webkit-scrollbar`, draws it from
15
+ * `scrollbar-width: thin` and `scrollbar-color`.
16
+ *
17
+ * The colours are the theme's, so they follow light and dark and every
18
+ * theme: the thumb is `--borderColor-default`, `--fgColor-muted` on hover.
19
+ * The fallbacks are for an element no theme provider covers (the page's
20
+ * own scrollbar, on `<html>`). An element may set its own colours with
21
+ * `--dla-scrollbar-thumb`, `--dla-scrollbar-thumb-hover` and
22
+ * `--dla-scrollbar-track` (a grid painting its track as its headers).
23
+ */
24
+ /** The class giving an element the scrollbar, once `ScrollbarStyles` is rendered. */
25
+ export const SCROLLBAR_CLASS = 'dla-scrollbar';
26
+ /** The scrollbar's thickness in Chromium and Safari, the thumb inset in it. */
27
+ export const SCROLLBAR_SIZE = '8px';
28
+ const THUMB_INSET = '2px';
29
+ const THUMB = 'var(--dla-scrollbar-thumb, var(--borderColor-default, rgba(127, 127, 127, 0.4)))';
30
+ const THUMB_HOVER = 'var(--dla-scrollbar-thumb-hover, var(--fgColor-muted, rgba(127, 127, 127, 0.7)))';
31
+ const TRACK = 'var(--dla-scrollbar-track, transparent)';
32
+ /** Matched by the browsers that draw `::-webkit-scrollbar` (Chromium, Safari). */
33
+ const WEBKIT = '@supports selector(::-webkit-scrollbar)';
34
+ /** Matched by the others (Firefox). */
35
+ const STANDARD = '@supports not selector(::-webkit-scrollbar)';
36
+ /**
37
+ * The scrollbar as an `sx` fragment, for an element that scrolls: spread it
38
+ * into the element's `sx` (a primer-addons `Box`). It sets no overflow.
39
+ */
40
+ export const scrollbarSx = {
41
+ [WEBKIT]: { scrollbarWidth: 'auto', scrollbarColor: 'auto' },
42
+ [STANDARD]: { scrollbarWidth: 'thin', scrollbarColor: `${THUMB} ${TRACK}` },
43
+ '&::-webkit-scrollbar': { width: SCROLLBAR_SIZE, height: SCROLLBAR_SIZE, background: 'transparent' },
44
+ '&::-webkit-scrollbar-track': { background: TRACK },
45
+ '&::-webkit-scrollbar-corner': { background: TRACK },
46
+ '&::-webkit-scrollbar-thumb': {
47
+ backgroundColor: THUMB,
48
+ border: `${THUMB_INSET} solid transparent`,
49
+ backgroundClip: 'padding-box',
50
+ borderRadius: '999px',
51
+ },
52
+ '&::-webkit-scrollbar-thumb:hover': { backgroundColor: THUMB_HOVER },
53
+ };
54
+ /** Unset as `Box` reads it: no declaration (`null`, `undefined`, `false`, `''`). */
55
+ const isSet = (value) => value !== null && value !== undefined && value !== false && value !== '';
56
+ /**
57
+ * A `scrollbarWidth` or `scrollbarColor` of the element's own over a
58
+ * branch's default: an unset value keeps the default, and so does an
59
+ * unset base of a responsive array (its later values still apply).
60
+ */
61
+ function over(own, fallback) {
62
+ if (Array.isArray(own)) {
63
+ return isSet(own[0]) ? own : [fallback, ...own.slice(1)];
64
+ }
65
+ return isSet(own) ? own : fallback;
66
+ }
67
+ /**
68
+ * `scrollbarSx` with an element's own `sx` over it. A `scrollbarWidth` or
69
+ * `scrollbarColor` given in `sx` goes into both of the scrollbar's
70
+ * `@supports` branches too: set at the element's top level only, the
71
+ * branches, which come after it, would put the scrollbar's values back.
72
+ * The element's own `@supports` blocks of the same conditions come last,
73
+ * whole.
74
+ */
75
+ export function withScrollbarSx(sx) {
76
+ const own = (sx ?? {});
77
+ const branch = (condition) => {
78
+ const defaults = scrollbarSx[condition];
79
+ return {
80
+ ...defaults,
81
+ scrollbarWidth: over(own.scrollbarWidth, defaults.scrollbarWidth),
82
+ scrollbarColor: over(own.scrollbarColor, defaults.scrollbarColor),
83
+ ...(own[condition] ?? {}),
84
+ };
85
+ };
86
+ return {
87
+ ...scrollbarSx,
88
+ ...sx,
89
+ [WEBKIT]: branch(WEBKIT),
90
+ [STANDARD]: branch(STANDARD),
91
+ };
92
+ }
93
+ /**
94
+ * A selector list split at its top-level commas: not those in `:is(a, b)`
95
+ * or `[a="b"]`, in quotes, escaped (`\,`) or in a comment (which is dropped).
96
+ */
97
+ function selectorsOf(selector) {
98
+ const parts = [];
99
+ let depth = 0;
100
+ let quote = '';
101
+ let part = '';
102
+ for (let i = 0; i < selector.length; i++) {
103
+ const c = selector[i];
104
+ if (c === '\\') {
105
+ part += c + (selector[i + 1] ?? '');
106
+ i++;
107
+ }
108
+ else if (quote) {
109
+ part += c;
110
+ if (c === quote)
111
+ quote = '';
112
+ }
113
+ else if (c === '/' && selector[i + 1] === '*') {
114
+ const end = selector.indexOf('*/', i + 2);
115
+ i = end === -1 ? selector.length : end + 1;
116
+ // A hex escape the comment ended (`\31/**/ .b`) is ended by a space
117
+ // in its place, which CSS consumes: the whitespace after it stays.
118
+ if (/(^|[^\\])(\\\\)*\\[0-9a-fA-F]{1,6}$/.test(part))
119
+ part += ' ';
120
+ }
121
+ else if (c === '"' || c === "'") {
122
+ quote = c;
123
+ part += c;
124
+ }
125
+ else if (c === ',' && depth === 0) {
126
+ parts.push(part);
127
+ part = '';
128
+ }
129
+ else {
130
+ if (c === '(' || c === '[')
131
+ depth++;
132
+ else if ((c === ')' || c === ']') && depth > 0)
133
+ depth--;
134
+ part += c;
135
+ }
136
+ }
137
+ parts.push(part);
138
+ return parts.map(p => p.trim()).filter(Boolean);
139
+ }
140
+ /**
141
+ * The scrollbar as a stylesheet, for the elements a selector matches (a
142
+ * selector list too: each part gets it). `'*'` is every element of the page.
143
+ */
144
+ export function scrollbarCss(selector = `.${SCROLLBAR_CLASS}`) {
145
+ const parts = selectorsOf(selector);
146
+ const each = (pseudo) => parts.map(part => `${part}${pseudo}`).join(',');
147
+ return [
148
+ `${WEBKIT}{${each('')}{scrollbar-width:auto;scrollbar-color:auto}}`,
149
+ `${STANDARD}{${each('')}{scrollbar-width:thin;scrollbar-color:${THUMB} ${TRACK}}}`,
150
+ `${each('::-webkit-scrollbar')}{width:${SCROLLBAR_SIZE};height:${SCROLLBAR_SIZE};background:transparent}`,
151
+ `${each('::-webkit-scrollbar-track')}{background:${TRACK}}`,
152
+ `${each('::-webkit-scrollbar-corner')}{background:${TRACK}}`,
153
+ `${each('::-webkit-scrollbar-thumb')}{background-color:${THUMB};border:${THUMB_INSET} solid transparent;background-clip:padding-box;border-radius:999px}`,
154
+ `${each('::-webkit-scrollbar-thumb:hover')}{background-color:${THUMB_HOVER}}`,
155
+ ].join('\n');
156
+ }
@@ -20,6 +20,7 @@ export declare const primerComponentSelectors: {
20
20
  readonly button: "[class*=\"prc-Button-ButtonBase\"]";
21
21
  readonly textInput: "[class*=\"prc-components-TextInputBaseWrapper\"]";
22
22
  readonly textArea: "[class*=\"prc-Textarea-TextArea\"]";
23
+ readonly select: "[class*=\"prc-Select-Select-\"]";
23
24
  readonly segmentedControl: "[class*=\"prc-SegmentedControl-SegmentedControl\"]";
24
25
  readonly buttonGroup: "[class*=\"prc-ButtonGroup-ButtonGroup\"]";
25
26
  readonly underlineTab: "[class*=\"prc-components-UnderlineItem\"]";
@@ -40,6 +41,13 @@ export declare const primerComponentSelectors: {
40
41
  * lines is a lozenge. Where a control draws more than one element from the
41
42
  * token — a segmented control's track and segments, a button group's ends
42
43
  * — the token itself is set on the control, and Primer's rules draw it.
44
+ * A select's list of options, where the browser lets a page draw it
45
+ * (`appearance: base-select`), is drawn as the theme's overlay: its
46
+ * corner, its ground and its hairline (no shadow: a theme draws one, the
47
+ * frame's), each option a
48
+ * rounded row, the chosen one in the accent; elsewhere the browser's own.
49
+ * The select itself keeps Primer's box there: its label on one line,
50
+ * centred, with room at its end for Primer's arrow.
43
51
  * - `radiusTable` — a data table's outer corners (`--table-border-radius`).
44
52
  * - `tableHeaderBg`, `tableHeaderFg` — its header band and header text.
45
53
  * - `tableBorder` — the hairline between and around its cells.
@@ -6,6 +6,7 @@ export const primerComponentSelectors = {
6
6
  button: '[class*="prc-Button-ButtonBase"]',
7
7
  textInput: '[class*="prc-components-TextInputBaseWrapper"]',
8
8
  textArea: '[class*="prc-Textarea-TextArea"]',
9
+ select: '[class*="prc-Select-Select-"]',
9
10
  segmentedControl: '[class*="prc-SegmentedControl-SegmentedControl"]',
10
11
  buttonGroup: '[class*="prc-ButtonGroup-ButtonGroup"]',
11
12
  underlineTab: '[class*="prc-components-UnderlineItem"]',
@@ -27,6 +28,13 @@ const sel = primerComponentSelectors;
27
28
  * lines is a lozenge. Where a control draws more than one element from the
28
29
  * token — a segmented control's track and segments, a button group's ends
29
30
  * — the token itself is set on the control, and Primer's rules draw it.
31
+ * A select's list of options, where the browser lets a page draw it
32
+ * (`appearance: base-select`), is drawn as the theme's overlay: its
33
+ * corner, its ground and its hairline (no shadow: a theme draws one, the
34
+ * frame's), each option a
35
+ * rounded row, the chosen one in the accent; elsewhere the browser's own.
36
+ * The select itself keeps Primer's box there: its label on one line,
37
+ * centred, with room at its end for Primer's arrow.
30
38
  * - `radiusTable` — a data table's outer corners (`--table-border-radius`).
31
39
  * - `tableHeaderBg`, `tableHeaderFg` — its header band and header text.
32
40
  * - `tableBorder` — the hairline between and around its cells.
@@ -45,6 +53,57 @@ export function primerComponentsCss(shape = {}) {
45
53
  }
46
54
  :scope ${sel.buttonGroup} {
47
55
  --borderRadius-medium: var(--theme-radius-control);
56
+ }`);
57
+ rules.push(`@supports (appearance: base-select) {
58
+ :scope ${sel.select},
59
+ :scope ${sel.select}::picker(select) {
60
+ appearance: base-select;
61
+ }
62
+ :scope ${sel.select} {
63
+ align-items: center;
64
+ padding-block: 0;
65
+ min-block-size: 0;
66
+ white-space: nowrap;
67
+ padding-inline-end: var(--base-size-24, 1.5rem);
68
+ }
69
+ :scope ${sel.select}::picker-icon {
70
+ display: none;
71
+ }
72
+ :scope ${sel.select}::picker(select) {
73
+ margin-top: 4px;
74
+ padding: 4px;
75
+ border: 1px solid var(--borderColor-default);
76
+ border-radius: var(--theme-radius-overlay, 12px);
77
+ background-color: var(--overlay-bgColor, var(--bgColor-default));
78
+ color: var(--fgColor-default);
79
+ }
80
+ :scope ${sel.select} option {
81
+ padding: 6px 12px;
82
+ border-radius: var(--borderRadius-medium);
83
+ background-color: transparent;
84
+ color: var(--fgColor-default);
85
+ cursor: pointer;
86
+ }
87
+ :scope ${sel.select} option::checkmark {
88
+ display: none;
89
+ }
90
+ :scope ${sel.select} option:hover,
91
+ :scope ${sel.select} option:focus-visible {
92
+ background-color: var(--control-transparent-bgColor-hover, var(--bgColor-neutral-muted));
93
+ outline: none;
94
+ }
95
+ :scope ${sel.select} option:checked {
96
+ background-color: var(--bgColor-accent-muted);
97
+ color: var(--fgColor-accent);
98
+ font-weight: 600;
99
+ }
100
+ :scope ${sel.select} option:disabled,
101
+ :scope ${sel.select} optgroup:disabled option {
102
+ background-color: transparent;
103
+ color: var(--fgColor-disabled);
104
+ font-weight: normal;
105
+ cursor: not-allowed;
106
+ }
48
107
  }`);
49
108
  }
50
109
  if (shape.radiusTable !== undefined) {
@@ -232,4 +232,20 @@ const matrixDark = {
232
232
  */
233
233
  const matrixFontFamily = '"SF Mono", "Cascadia Code", "Fira Code", Menlo, Consolas, "Liberation Mono", "Courier New", monospace';
234
234
  /** Comprehensive Primer CSS-variable overrides for light & dark mode. */
235
- export const matrixThemeStyles = buildThemeStyles(matrixLight, matrixDark, { fontFamily: matrixFontFamily });
235
+ export const matrixThemeStyles = buildThemeStyles(matrixLight, matrixDark, {
236
+ fontFamily: matrixFontFamily,
237
+ // A terminal's corners: 2px everywhere, a bubble 3px, in place of
238
+ // Primer's 6px and 12px (the user, 5 December 2026).
239
+ shape: {
240
+ radiusControl: '2px',
241
+ radiusTable: '2px',
242
+ radiusOverlay: '2px',
243
+ radiusCard: '2px',
244
+ radiusBubble: '3px',
245
+ radiusFrame: '2px',
246
+ },
247
+ variables: {
248
+ light: { '--borderRadius-small': '2px', '--borderRadius-medium': '2px', '--borderRadius-large': '2px' },
249
+ dark: { '--borderRadius-small': '2px', '--borderRadius-medium': '2px', '--borderRadius-large': '2px' },
250
+ },
251
+ });
@@ -185,10 +185,10 @@ function vscodeVariables(mode) {
185
185
  '--control-borderColor-rest': v('inputBorder'),
186
186
  '--control-borderColor-emphasis': v('focusBorder'),
187
187
  '--control-fgColor-placeholder': v('inputPlaceholderForeground'),
188
- // The editor's corners: square-ish everywhere.
188
+ // The editor's corners: 2px everywhere (lowered from 4px for the large, the user, 5 December 2026).
189
189
  '--borderRadius-small': '2px',
190
190
  '--borderRadius-medium': '2px',
191
- '--borderRadius-large': '4px',
191
+ '--borderRadius-large': '2px',
192
192
  // The editor's controls: 26px tall, tight.
193
193
  '--control-medium-size': '26px',
194
194
  '--control-medium-paddingBlock': '4px',
@@ -228,12 +228,13 @@ export const vscodePortableThemeStyles = buildThemeStyles(vscodeLight, vscodeDar
228
228
  css: vscodeOwnCss,
229
229
  // The editor's shape: tight corners, flat surfaces, no motion.
230
230
  shape: {
231
+ // 2px everywhere, a bubble 3px (lowered, the user, 5 December 2026).
231
232
  radiusControl: '2px',
232
233
  radiusTable: '2px',
233
- radiusOverlay: '4px',
234
- radiusCard: '4px',
235
- radiusBubble: '6px',
236
- radiusFrame: '4px',
234
+ radiusOverlay: '2px',
235
+ radiusCard: '2px',
236
+ radiusBubble: '3px',
237
+ radiusFrame: '2px',
237
238
  shadow: 'none',
238
239
  motionStatus: '0ms',
239
240
  motionMessage: '0ms',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/primer-addons",
3
- "version": "1.0.60",
3
+ "version": "1.0.62",
4
4
  "license": "BSD-3-Clause",
5
5
  "scripts": {
6
6
  "build": "npm run build:lib",