@datalayer/primer-addons 1.0.56 → 1.0.58
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 +42 -1
- package/lib/components/appearance/AppearanceControls.d.ts +3 -3
- package/lib/components/appearance/AppearanceControls.js +8 -4
- package/lib/components/appearance/AppearanceControls.stories.d.ts +1 -1
- package/lib/components/appearance/AppearanceControls.stories.js +1 -1
- package/lib/components/appearance/AppearanceMenu.d.ts +1 -1
- package/lib/components/buttons/Buttons.stories.d.ts +1 -0
- package/lib/components/buttons/Buttons.stories.js +10 -1
- package/lib/components/buttons/SplitButton.d.ts +82 -0
- package/lib/components/buttons/SplitButton.js +63 -0
- package/lib/components/buttons/index.d.ts +1 -0
- package/lib/components/buttons/index.js +1 -0
- package/lib/components/dialog/Dialog.d.ts +62 -0
- package/lib/components/dialog/Dialog.js +117 -0
- package/lib/components/dialog/index.d.ts +1 -0
- package/lib/components/dialog/index.js +5 -0
- package/lib/components/emoji/faceEmojis.js +14 -0
- package/lib/components/emoji/fluent/loaders.js +13 -0
- package/lib/components/emoji/fluent/svg/1f39e.d.ts +2 -0
- package/lib/components/emoji/fluent/svg/1f39e.js +9 -0
- package/lib/components/emoji/fluent/svg/1f3c3.d.ts +2 -0
- package/lib/components/emoji/fluent/svg/1f3c3.js +9 -0
- package/lib/components/emoji/fluent/svg/1f3d3.d.ts +2 -0
- package/lib/components/emoji/fluent/svg/1f3d3.js +9 -0
- package/lib/components/emoji/fluent/svg/1f3e8.d.ts +2 -0
- package/lib/components/emoji/fluent/svg/1f3e8.js +9 -0
- package/lib/components/emoji/fluent/svg/1f3ea.d.ts +2 -0
- package/lib/components/emoji/fluent/svg/1f3ea.js +9 -0
- package/lib/components/emoji/fluent/svg/1f50f.d.ts +2 -0
- package/lib/components/emoji/fluent/svg/1f50f.js +9 -0
- package/lib/components/emoji/fluent/svg/1f510.d.ts +2 -0
- package/lib/components/emoji/fluent/svg/1f510.js +9 -0
- package/lib/components/emoji/fluent/svg/1f516.d.ts +2 -0
- package/lib/components/emoji/fluent/svg/1f516.js +9 -0
- package/lib/components/emoji/fluent/svg/1f526.d.ts +2 -0
- package/lib/components/emoji/fluent/svg/1f526.js +9 -0
- package/lib/components/emoji/fluent/svg/1f6ce.d.ts +2 -0
- package/lib/components/emoji/fluent/svg/1f6ce.js +9 -0
- package/lib/components/emoji/fluent/svg/1f9fa.d.ts +2 -0
- package/lib/components/emoji/fluent/svg/1f9fa.js +9 -0
- package/lib/components/emoji/fluent/svg/21a9.d.ts +2 -0
- package/lib/components/emoji/fluent/svg/21a9.js +9 -0
- package/lib/components/emoji/fluent/svg/2708.d.ts +2 -0
- package/lib/components/emoji/fluent/svg/2708.js +9 -0
- package/lib/components/hover-card/HoverCardDetails.d.ts +7 -4
- package/lib/components/hover-card/HoverCardDetails.js +65 -41
- package/lib/components/hover-card/HoverCardLayer.d.ts +6 -5
- package/lib/components/hover-card/HoverCardLayer.js +21 -16
- package/lib/components/hover-card/useThemedPortalTarget.d.ts +20 -0
- package/lib/components/hover-card/useThemedPortalTarget.js +13 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +1 -0
- package/lib/components/sliding-panel/SlidingPanel.js +7 -2
- package/lib/components/tabs/RouteTabs.d.ts +38 -0
- package/lib/components/tabs/RouteTabs.js +8 -0
- package/lib/components/tabs/RouteTabs.stories.d.ts +12 -0
- package/lib/components/tabs/RouteTabs.stories.js +31 -0
- package/lib/components/tabs/ViewTabs.d.ts +2 -1
- package/lib/components/tabs/ViewTabs.stories.d.ts +1 -0
- package/lib/components/tabs/ViewTabs.stories.js +13 -1
- package/lib/components/tabs/index.d.ts +2 -0
- package/lib/components/tabs/index.js +2 -0
- package/lib/components/tabs/useTabParam.d.ts +18 -0
- package/lib/components/tabs/useTabParam.js +37 -0
- package/lib/theme/themes/metalThemeStyles.js +3 -0
- package/package.json +1 -1
package/lib/components/index.js
CHANGED
|
@@ -20,6 +20,7 @@ export * from "./color";
|
|
|
20
20
|
export * from "./color-picker";
|
|
21
21
|
export * from "./content-loader/ContentLoader";
|
|
22
22
|
export * from "./date-picker";
|
|
23
|
+
export * from "./dialog";
|
|
23
24
|
export * from "./closeable-flash/CloseableFlash";
|
|
24
25
|
export * from "./icons/CircleIcon";
|
|
25
26
|
export * from "./side-overlay/SideOverlay";
|
|
@@ -4,9 +4,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
6
|
import { useEffect, useMemo, useState } from 'react';
|
|
7
|
-
import { IconButton } from '@primer/react';
|
|
7
|
+
import { IconButton, useTheme } from '@primer/react';
|
|
8
8
|
import { XIcon } from '@primer/octicons-react';
|
|
9
9
|
import { Box } from '../box/Box';
|
|
10
|
+
import { panelBackground } from '../hover-card/HoverCardDetails';
|
|
10
11
|
const variantStyles = {
|
|
11
12
|
default: {
|
|
12
13
|
bg: 'var(--bgColor-default, #ffffff)',
|
|
@@ -164,6 +165,7 @@ export const SlidingPanel = ({ isOpen, message, details, onDismiss, position = '
|
|
|
164
165
|
return null;
|
|
165
166
|
}
|
|
166
167
|
const style = variantStyles[variant];
|
|
168
|
+
const { theme } = useTheme();
|
|
167
169
|
const alerting = variant === 'error' || variant === 'danger';
|
|
168
170
|
// Over the viewport, or over its own region of the page.
|
|
169
171
|
const across = contained ? '100%' : '100vw';
|
|
@@ -216,7 +218,10 @@ export const SlidingPanel = ({ isOpen, message, details, onDismiss, position = '
|
|
|
216
218
|
borderRight: edgeBorder.borderRight,
|
|
217
219
|
borderBottom: edgeBorder.borderBottom,
|
|
218
220
|
borderLeft: edgeBorder.borderLeft,
|
|
219
|
-
|
|
221
|
+
// Opaque in every theme: the variant's tint over the panel background the hover card uses
|
|
222
|
+
// (the canvas over its overlay colour), since a theme's muted tints and even its default
|
|
223
|
+
// canvas (metal's, in dark mode) are translucent.
|
|
224
|
+
background: `linear-gradient(${style.bg}, ${style.bg}), ${panelBackground(theme)}`,
|
|
220
225
|
color: style.fg,
|
|
221
226
|
textAlign: 'left',
|
|
222
227
|
px: 4,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A row of tabs that are routes: the selected one is in the address, so a
|
|
3
|
+
* link opens a page on its tab and the back button returns to the last one.
|
|
4
|
+
* Underlined, the open tab in the accent; a row too long for its width
|
|
5
|
+
* scrolls rather than wrapping.
|
|
6
|
+
*
|
|
7
|
+
* The component has no router of its own: `navigate` is the host's, called
|
|
8
|
+
* with the chosen tab's `to`.
|
|
9
|
+
*
|
|
10
|
+
* @module components/tabs/RouteTabs
|
|
11
|
+
*/
|
|
12
|
+
import type { JSX } from 'react';
|
|
13
|
+
import type { Icon } from '@primer/octicons-react';
|
|
14
|
+
export type RouteTab = {
|
|
15
|
+
key: string;
|
|
16
|
+
label: string;
|
|
17
|
+
/** Where the tab lives. */
|
|
18
|
+
to: string;
|
|
19
|
+
/** A count shown after the label, when there is one. */
|
|
20
|
+
count?: number | null;
|
|
21
|
+
/**
|
|
22
|
+
* A mark before the label, when the tab has one. It is the same mark the
|
|
23
|
+
* destination wears elsewhere in the application, so a row of tabs and the
|
|
24
|
+
* sidebar name the same thing the same way.
|
|
25
|
+
*/
|
|
26
|
+
icon?: Icon;
|
|
27
|
+
};
|
|
28
|
+
export type RouteTabsProps = {
|
|
29
|
+
/** What the tabs are of, said to assistive technology. */
|
|
30
|
+
label: string;
|
|
31
|
+
items: ReadonlyArray<RouteTab>;
|
|
32
|
+
/** The key of the open tab. */
|
|
33
|
+
current: string;
|
|
34
|
+
/** The host's navigation, called with the chosen tab's `to`. */
|
|
35
|
+
navigate: (to: string) => void;
|
|
36
|
+
};
|
|
37
|
+
export declare const RouteTabs: ({ label, items, current, navigate, }: RouteTabsProps) => JSX.Element;
|
|
38
|
+
export default RouteTabs;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CounterLabel } from '@primer/react';
|
|
3
|
+
import { Box } from '../box/Box';
|
|
4
|
+
export const RouteTabs = ({ label, items, current, navigate, }) => (_jsx(Box, { role: "tablist", "aria-label": label, display: "flex", gap: 1, borderBottom: "1px solid", borderColor: "border.default", mb: 3, overflowX: "auto", children: items.map(item => {
|
|
5
|
+
const selected = item.key === current;
|
|
6
|
+
return (_jsxs(Box, { as: "button", type: "button", role: "tab", "aria-selected": selected, "data-tab": item.key, onClick: () => navigate(item.to), appearance: "none", background: "none", border: "none", borderBottom: "2px solid", borderBottomColor: selected ? 'accent.fg' : 'transparent', color: selected ? 'fg.default' : 'fg.muted', fontWeight: selected ? 'semibold' : 'normal', fontSize: 1, px: 2, py: 2, cursor: "pointer", whiteSpace: "nowrap", display: "inline-flex", alignItems: "center", gap: 2, hover: { color: 'fg.default' }, children: [item.icon ? (_jsx(Box, { as: "span", "aria-hidden": "true", display: "inline-flex", color: selected ? 'accent.fg' : 'fg.muted', children: _jsx(item.icon, { size: 16 }) })) : null, item.label, typeof item.count === 'number' ? (_jsx(CounterLabel, { children: item.count })) : null] }, item.key));
|
|
7
|
+
}) }));
|
|
8
|
+
export default RouteTabs;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: ({ label, items, current, navigate, }: import("./RouteTabs").RouteTabsProps) => import("react").JSX.Element;
|
|
5
|
+
tags: string[];
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<typeof meta>;
|
|
12
|
+
export declare const Default: Story;
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { GearIcon, GraphIcon, PlayIcon } from '@primer/octicons-react';
|
|
8
|
+
import { Box } from '../box/Box';
|
|
9
|
+
import { RouteTabs } from './RouteTabs';
|
|
10
|
+
const meta = {
|
|
11
|
+
title: 'Components/RouteTabs',
|
|
12
|
+
component: RouteTabs,
|
|
13
|
+
tags: ['autodocs'],
|
|
14
|
+
parameters: { layout: 'fullscreen' },
|
|
15
|
+
};
|
|
16
|
+
export default meta;
|
|
17
|
+
const ITEMS = [
|
|
18
|
+
{ key: 'overview', label: 'Overview', to: '/benchmarks/swe' },
|
|
19
|
+
{ key: 'runs', label: 'Runs', to: '/benchmarks/swe/runs', count: 12, icon: PlayIcon },
|
|
20
|
+
{ key: 'reports', label: 'Reports', to: '/benchmarks/swe/reports', count: 0, icon: GraphIcon },
|
|
21
|
+
{ key: 'settings', label: 'Settings', to: '/benchmarks/swe/settings', icon: GearIcon },
|
|
22
|
+
];
|
|
23
|
+
const Routed = (props) => {
|
|
24
|
+
const [path, setPath] = useState(props.items[0].to);
|
|
25
|
+
const current = props.items.find(item => item.to === path)?.key ?? props.items[0].key;
|
|
26
|
+
return (_jsxs(Box, { p: 3, bg: "canvas.default", children: [_jsx(RouteTabs, { label: "Benchmark", items: props.items, current: current, navigate: setPath }), _jsx(Box, { as: "code", color: "fg.muted", fontSize: 1, children: path })] }));
|
|
27
|
+
};
|
|
28
|
+
export const Default = {
|
|
29
|
+
args: { label: 'Benchmark', items: ITEMS, current: 'overview', navigate: () => undefined },
|
|
30
|
+
render: args => _jsx(Routed, { items: args.items }),
|
|
31
|
+
};
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
* - A tab may be `disabled`, its `title` saying why; it may carry a `count`.
|
|
10
10
|
* - A tab may carry a `leadingVisual`, an icon before its label (the user,
|
|
11
11
|
* 21 November 2026: the application page's Build, Try, Validate and Ship).
|
|
12
|
-
* - `useTabParam` (./useTabParam) keeps the open tab in the address (`?tab=`)
|
|
12
|
+
* - `useTabParam` (./useTabParam) keeps the open tab in the address (`?tab=`),
|
|
13
|
+
* given the host's search pair (React Router's `useSearchParams()`).
|
|
13
14
|
*
|
|
14
15
|
* @module components/tabs/ViewTabs
|
|
15
16
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/*
|
|
3
3
|
* Copyright (c) 2021-2026 Datalayer, Inc.
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
@@ -7,6 +7,7 @@ import { useState } from 'react';
|
|
|
7
7
|
import { PlayIcon, ToolsIcon } from '@primer/octicons-react';
|
|
8
8
|
import { Box } from '../box/Box';
|
|
9
9
|
import { ViewTabs } from './ViewTabs';
|
|
10
|
+
import { useTabParam } from './useTabParam';
|
|
10
11
|
const meta = {
|
|
11
12
|
title: 'Components/ViewTabs',
|
|
12
13
|
component: ViewTabs,
|
|
@@ -28,3 +29,14 @@ export const Default = {
|
|
|
28
29
|
args: { label: 'Sections', tabs: TABS, value: 'all', onChange: () => undefined },
|
|
29
30
|
render: args => _jsx(Stateful, { tabs: args.tabs }),
|
|
30
31
|
};
|
|
32
|
+
/** The open tab in the address: the search pair held in state, as a router would hand it. */
|
|
33
|
+
const InTheAddressStory = (props) => {
|
|
34
|
+
const [search, setSearch] = useState(() => new URLSearchParams());
|
|
35
|
+
const pair = [search, next => setSearch(next)];
|
|
36
|
+
const [open, setOpen] = useTabParam(props.tabs.map(tab => tab.id), pair);
|
|
37
|
+
return (_jsxs(Box, { p: 3, bg: "canvas.default", children: [_jsx(ViewTabs, { label: "Sections", tabs: props.tabs, value: open, onChange: setOpen }), _jsxs(Box, { as: "code", color: "fg.muted", fontSize: 1, children: ["?", search.toString()] })] }));
|
|
38
|
+
};
|
|
39
|
+
export const InTheAddress = {
|
|
40
|
+
args: { label: 'Sections', tabs: TABS, value: 'all', onChange: () => undefined },
|
|
41
|
+
render: args => _jsx(InTheAddressStory, { tabs: args.tabs }),
|
|
42
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The address's search parameters and how to replace them: the pair React
|
|
3
|
+
* Router's `useSearchParams()` returns, or any state shaped the same way.
|
|
4
|
+
*/
|
|
5
|
+
export type TabSearch = readonly [
|
|
6
|
+
URLSearchParams,
|
|
7
|
+
(next: URLSearchParams, options: {
|
|
8
|
+
replace: boolean;
|
|
9
|
+
}) => void
|
|
10
|
+
];
|
|
11
|
+
/**
|
|
12
|
+
* The open tab kept in the address under `param` (`tab` by default): the
|
|
13
|
+
* first of `ids` when absent or unknown, and dropped from the address when it
|
|
14
|
+
* is the first, so the view's own address opens it. Choosing a tab replaces
|
|
15
|
+
* the address rather than pushing one, and keeps its other parameters.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useTabParam<T extends string>(ids: ReadonlyArray<T>, [search, setSearch]: TabSearch, param?: string): [T, (id: T) => void];
|
|
18
|
+
export default useTabParam;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2026 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The open tab kept in the address, with no router of its own: the host hands
|
|
7
|
+
* in its search parameters and their setter, as React Router's
|
|
8
|
+
* `useSearchParams()` returns them, so `useTabParam(ids, useSearchParams())`
|
|
9
|
+
* is the whole binding.
|
|
10
|
+
*
|
|
11
|
+
* @module components/tabs/useTabParam
|
|
12
|
+
*/
|
|
13
|
+
import { useCallback } from 'react';
|
|
14
|
+
/**
|
|
15
|
+
* The open tab kept in the address under `param` (`tab` by default): the
|
|
16
|
+
* first of `ids` when absent or unknown, and dropped from the address when it
|
|
17
|
+
* is the first, so the view's own address opens it. Choosing a tab replaces
|
|
18
|
+
* the address rather than pushing one, and keeps its other parameters.
|
|
19
|
+
*/
|
|
20
|
+
export function useTabParam(ids, [search, setSearch], param = 'tab') {
|
|
21
|
+
const asked = search.get(param);
|
|
22
|
+
const open = ids.includes(asked ?? '')
|
|
23
|
+
? asked
|
|
24
|
+
: ids[0];
|
|
25
|
+
const choose = useCallback((id) => {
|
|
26
|
+
const next = new URLSearchParams(search);
|
|
27
|
+
if (id === ids[0]) {
|
|
28
|
+
next.delete(param);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
next.set(param, id);
|
|
32
|
+
}
|
|
33
|
+
setSearch(next, { replace: true });
|
|
34
|
+
}, [search, setSearch, ids, param]);
|
|
35
|
+
return [open, choose];
|
|
36
|
+
}
|
|
37
|
+
export default useTabParam;
|
|
@@ -225,6 +225,9 @@ const metalPainted = {
|
|
|
225
225
|
'--bgColor-accent-muted': 'rgba(255, 255, 255, 0.09)',
|
|
226
226
|
'--borderColor-accent-muted': 'rgba(255, 255, 255, 0.22)',
|
|
227
227
|
'--overlay-bgColor': '#25343F',
|
|
228
|
+
// A field's border reads on the glass: the hairline (18% white) all but vanished around a prompt.
|
|
229
|
+
'--control-borderColor-rest': 'rgba(255, 255, 255, 0.34)',
|
|
230
|
+
'--control-borderColor-emphasis': 'rgba(255, 255, 255, 0.5)',
|
|
228
231
|
'--metal-primary-image': 'none',
|
|
229
232
|
'--metal-primary-shadow': 'none',
|
|
230
233
|
'--fgColor-default': '#FFFFFF',
|