@datalayer/primer-addons 1.0.19 → 1.0.20
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/lib/components/logo/DatalayerTextAI.d.ts +4 -4
- package/lib/components/logo/DatalayerTextAI.js +6 -6
- package/lib/components/logo/index.d.ts +5 -7
- package/lib/components/logo/index.js +5 -7
- package/lib/components/toolbar/Toolbar.js +18 -1
- package/lib/components/toolbar/ToolbarButton.js +12 -7
- package/lib/components/toolbar/ToolbarRenderer.js +3 -0
- package/lib/components/toolbar/types.d.ts +11 -2
- package/package.json +1 -1
- package/lib/components/logo/AI.d.ts +0 -17
- package/lib/components/logo/AI.js +0 -18
- package/lib/components/logo/AI2.d.ts +0 -20
- package/lib/components/logo/AI2.js +0 -23
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type SVGProps } from
|
|
2
|
-
import { type ThemeVariant } from
|
|
3
|
-
export interface DatalayerTextAIProps extends Omit<SVGProps<SVGSVGElement>,
|
|
1
|
+
import { type SVGProps } from "react";
|
|
2
|
+
import { type ThemeVariant } from "../../theme";
|
|
3
|
+
export interface DatalayerTextAIProps extends Omit<SVGProps<SVGSVGElement>, "ref"> {
|
|
4
4
|
size?: number;
|
|
5
5
|
scale?: number;
|
|
6
|
-
colorMode?:
|
|
6
|
+
colorMode?: "light" | "dark" | "auto";
|
|
7
7
|
variant?: ThemeVariant;
|
|
8
8
|
/** Colour for the "LAYER" part of the wordmark. */
|
|
9
9
|
primaryColor?: string;
|
|
@@ -3,10 +3,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
* Copyright (c) 2023-2026 Datalayer, Inc.
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
|
-
import { forwardRef } from
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { getLogoColors } from './DatalayerLogo';
|
|
6
|
+
import { forwardRef } from "react";
|
|
7
|
+
import { DatalayerText } from "./DatalayerText";
|
|
8
|
+
import { getLogoColors } from "./DatalayerLogo";
|
|
10
9
|
const TEXT_LEFT_TRIM = 12;
|
|
11
10
|
const TEXT_END_X = 136.672 - TEXT_LEFT_TRIM;
|
|
12
11
|
const AI_SIZE = 24;
|
|
@@ -15,13 +14,14 @@ const AI_VISIBLE_LEFT = 0.25;
|
|
|
15
14
|
const AI_VISIBLE_HEIGHT = 16.136075;
|
|
16
15
|
const AI_SCALE_TO_TEXT_HEIGHT = 25 / AI_VISIBLE_HEIGHT;
|
|
17
16
|
const AI_RENDER_SIZE = AI_SIZE * AI_SCALE_TO_TEXT_HEIGHT;
|
|
17
|
+
const AI_RENDER_SCALE = AI_RENDER_SIZE / AI_SIZE;
|
|
18
18
|
const AI_X_TRIM = AI_VISIBLE_LEFT * AI_SCALE_TO_TEXT_HEIGHT;
|
|
19
19
|
const AI_Y_TRIM = AI_VISIBLE_TOP * AI_SCALE_TO_TEXT_HEIGHT;
|
|
20
20
|
/**
|
|
21
21
|
* Datalayer wordmark followed by AI glyph on one line.
|
|
22
22
|
* Both elements are aligned to the same 25-unit cap height.
|
|
23
23
|
*/
|
|
24
|
-
export const DatalayerTextAI = forwardRef(function DatalayerTextAI({ size = 25, scale = 1, colorMode =
|
|
24
|
+
export const DatalayerTextAI = forwardRef(function DatalayerTextAI({ size = 25, scale = 1, colorMode = "light", variant = "datalayer", primaryColor, secondaryColor, textColor,
|
|
25
25
|
// 2.380655 ~= 25 / (0.7 * 15.00187)
|
|
26
26
|
textSizeMultiplier = 2.380655, aiPrimaryColor, aiSecondaryColor, aiGap = 6, ...svgProps }, ref) {
|
|
27
27
|
const themed = getLogoColors(variant, colorMode);
|
|
@@ -35,6 +35,6 @@ textSizeMultiplier = 2.380655, aiPrimaryColor, aiSecondaryColor, aiGap = 6, ...s
|
|
|
35
35
|
const baseWidth = (viewBoxWidth / 25) * size;
|
|
36
36
|
const height = baseHeight * scale;
|
|
37
37
|
const width = baseWidth * scale;
|
|
38
|
-
return (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: `0 0 ${viewBoxWidth} 25`, width: width, height: height, role: "img", "aria-label": "Datalayer AI", ref: ref, ...svgProps, children: [_jsx(DatalayerText, { primaryColor: layerColor, secondaryColor: dataTextColor, sizeMultiplier: textSizeMultiplier, x: -TEXT_LEFT_TRIM }),
|
|
38
|
+
return (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: `0 0 ${viewBoxWidth} 25`, width: width, height: height, role: "img", "aria-label": "Datalayer AI", ref: ref, ...svgProps, children: [_jsx(DatalayerText, { primaryColor: layerColor, secondaryColor: dataTextColor, sizeMultiplier: textSizeMultiplier, x: -TEXT_LEFT_TRIM }), _jsxs("g", { transform: `translate(${TEXT_END_X + aiGap - AI_X_TRIM} ${-AI_Y_TRIM}) scale(${AI_RENDER_SCALE})`, children: [_jsx("path", { d: "m13.788825 3.932 6.43325 16.136075h3.5279L17.316725 3.932H13.788825Z", fill: resolvedAiPrimary, strokeWidth: 0.25 }), _jsx("path", { d: "m6.325375 13.682775 2.20125 -5.67065 2.201275 5.67065H6.325375ZM6.68225 3.932 0.25 20.068075h3.596525l1.3155 -3.3886h6.729425l1.315275 3.3886h3.59655L10.371 3.932H6.68225Z", fill: resolvedAiSecondary, fillRule: "evenodd", clipRule: "evenodd", strokeWidth: 0.25 })] })] }));
|
|
39
39
|
});
|
|
40
40
|
export default DatalayerTextAI;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from './DatalayerText';
|
|
7
|
-
export * from './DatalayerTextAI';
|
|
1
|
+
export * from "./DI";
|
|
2
|
+
export * from "./DatalayerLogo";
|
|
3
|
+
export * from "./DatalayerLogoText";
|
|
4
|
+
export * from "./DatalayerText";
|
|
5
|
+
export * from "./DatalayerTextAI";
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from './DatalayerText';
|
|
7
|
-
export * from './DatalayerTextAI';
|
|
1
|
+
export * from "./DI";
|
|
2
|
+
export * from "./DatalayerLogo";
|
|
3
|
+
export * from "./DatalayerLogoText";
|
|
4
|
+
export * from "./DatalayerText";
|
|
5
|
+
export * from "./DatalayerTextAI";
|
|
@@ -30,7 +30,24 @@ export function Toolbar({ items, extraItems, className, disabled, ariaLabel = 'E
|
|
|
30
30
|
const allItems = useMemo(() => {
|
|
31
31
|
if (!extraItems?.length)
|
|
32
32
|
return items;
|
|
33
|
-
|
|
33
|
+
/*
|
|
34
|
+
* An extra item takes the place of the item it shares its key with.
|
|
35
|
+
*
|
|
36
|
+
* A host that knows better what one of the items should do — how this
|
|
37
|
+
* document is saved, where it is run — says so with the key of that item
|
|
38
|
+
* rather than adding a second button next to it. What it leaves out, its
|
|
39
|
+
* order and its icon among them, stays as the toolbar had it.
|
|
40
|
+
*/
|
|
41
|
+
const overrides = new Map(extraItems.map(item => [item.key, item]));
|
|
42
|
+
const merged = items.map(item => {
|
|
43
|
+
const override = overrides.get(item.key);
|
|
44
|
+
if (!override) {
|
|
45
|
+
return item;
|
|
46
|
+
}
|
|
47
|
+
overrides.delete(item.key);
|
|
48
|
+
return { ...item, ...override };
|
|
49
|
+
});
|
|
50
|
+
return [...merged, ...extraItems.filter(item => overrides.has(item.key))];
|
|
34
51
|
}, [items, extraItems]);
|
|
35
52
|
return (_jsx(Box, { className: className, role: "toolbar", "aria-label": ariaLabel, sx: {
|
|
36
53
|
display: 'flex',
|
|
@@ -6,16 +6,19 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
6
6
|
/**
|
|
7
7
|
* ToolbarButton - A single button in a Toolbar.
|
|
8
8
|
*
|
|
9
|
-
* Renders a native <button> with a direct Octicon icon
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* Renders a native <button> with a direct Octicon icon, wrapped in Primer's
|
|
10
|
+
* Tooltip when the item carries a title. The v37 Tooltip demands a native
|
|
11
|
+
* interactive child — the reason IconButton is avoided — and a plain
|
|
12
|
+
* <button> is exactly that. A disabled item therefore wears `aria-disabled`
|
|
13
|
+
* rather than the `disabled` attribute: a truly disabled button is not
|
|
14
|
+
* interactive, which both silences its tooltip and breaks the invariant —
|
|
15
|
+
* and the tooltip of a disabled action is precisely where the why-disabled
|
|
16
|
+
* explanation lives.
|
|
15
17
|
*
|
|
16
18
|
* @module components/toolbar/ToolbarButton
|
|
17
19
|
*/
|
|
18
20
|
import { isValidElement } from 'react';
|
|
21
|
+
import { Tooltip } from '@primer/react';
|
|
19
22
|
export function ToolbarButton({ item, size = 'medium' }) {
|
|
20
23
|
const { ariaLabel, title, icon, label, isActive, onClick, disabled } = item;
|
|
21
24
|
// Resolve icon → React element.
|
|
@@ -38,7 +41,7 @@ export function ToolbarButton({ item, size = 'medium' }) {
|
|
|
38
41
|
iconElement = _jsx("span", { style: { fontSize: 12, fontWeight: 600, lineHeight: 1 }, children: label });
|
|
39
42
|
}
|
|
40
43
|
const btnSize = size === 'small' ? 28 : 32;
|
|
41
|
-
|
|
44
|
+
const button = (_jsx("button", { type: "button", "aria-label": ariaLabel, "aria-disabled": disabled || undefined, onMouseDown: (e) => e.preventDefault(), onClick: disabled ? undefined : onClick, style: {
|
|
42
45
|
display: 'inline-flex',
|
|
43
46
|
alignItems: 'center',
|
|
44
47
|
justifyContent: 'center',
|
|
@@ -66,5 +69,7 @@ export function ToolbarButton({ item, size = 'medium' }) {
|
|
|
66
69
|
? 'var(--fgColor-accent, #0969da)'
|
|
67
70
|
: 'var(--fgColor-muted, #656d76)';
|
|
68
71
|
}, children: iconElement }));
|
|
72
|
+
// No title: nothing to say, no wrapper to say it with.
|
|
73
|
+
return title ? (_jsx(Tooltip, { text: title, direction: "s", children: button })) : (button);
|
|
69
74
|
}
|
|
70
75
|
export default ToolbarButton;
|
|
@@ -11,6 +11,7 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
11
11
|
* @module components/toolbar/ToolbarRenderer
|
|
12
12
|
*/
|
|
13
13
|
import { Fragment } from 'react';
|
|
14
|
+
import { Box } from '../box/Box';
|
|
14
15
|
import { ToolbarButton } from './ToolbarButton';
|
|
15
16
|
import { ToolbarDropdown } from './ToolbarDropdown';
|
|
16
17
|
import { ToolbarDivider } from './ToolbarDivider';
|
|
@@ -30,6 +31,8 @@ export function ToolbarRenderer({ items, disabled, size = 'medium' }) {
|
|
|
30
31
|
return (_jsx(Fragment, { children: _jsx(ToolbarDropdown, { item: { ...item, disabled: itemDisabled }, size: size }) }, item.key));
|
|
31
32
|
case 'divider':
|
|
32
33
|
return (_jsx(Fragment, { children: _jsx(ToolbarDivider, {}) }, item.key));
|
|
34
|
+
case 'spacer':
|
|
35
|
+
return (_jsx(Box, { sx: { flex: '1 1 auto', minWidth: 8 } }, item.key));
|
|
33
36
|
case 'custom':
|
|
34
37
|
return _jsx(Fragment, { children: item.render() }, item.key);
|
|
35
38
|
default:
|
|
@@ -3,7 +3,7 @@ import type { IconProps } from '@primer/octicons-react';
|
|
|
3
3
|
/**
|
|
4
4
|
* Toolbar item types that can be registered in a toolbar.
|
|
5
5
|
*/
|
|
6
|
-
export type ToolbarItemType = 'button' | 'dropdown' | 'divider' | 'custom';
|
|
6
|
+
export type ToolbarItemType = 'button' | 'dropdown' | 'divider' | 'spacer' | 'custom';
|
|
7
7
|
/**
|
|
8
8
|
* Base toolbar item definition.
|
|
9
9
|
*/
|
|
@@ -88,6 +88,15 @@ export interface ToolbarDropdownItem extends ToolbarItemBase {
|
|
|
88
88
|
export interface ToolbarDividerItem extends ToolbarItemBase {
|
|
89
89
|
type: 'divider';
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Toolbar spacer item definition.
|
|
93
|
+
*
|
|
94
|
+
* Takes the free space of the toolbar, so the items ordered after it sit on
|
|
95
|
+
* the trailing edge — e.g. a status indicator kept away from the actions.
|
|
96
|
+
*/
|
|
97
|
+
export interface ToolbarSpacerItem extends ToolbarItemBase {
|
|
98
|
+
type: 'spacer';
|
|
99
|
+
}
|
|
91
100
|
/**
|
|
92
101
|
* Toolbar custom item definition.
|
|
93
102
|
*/
|
|
@@ -99,7 +108,7 @@ export interface ToolbarCustomItem extends ToolbarItemBase {
|
|
|
99
108
|
/**
|
|
100
109
|
* Union of all toolbar item types.
|
|
101
110
|
*/
|
|
102
|
-
export type ToolbarItem = ToolbarButtonItem | ToolbarDropdownItem | ToolbarDividerItem | ToolbarCustomItem;
|
|
111
|
+
export type ToolbarItem = ToolbarButtonItem | ToolbarDropdownItem | ToolbarDividerItem | ToolbarSpacerItem | ToolbarCustomItem;
|
|
103
112
|
/**
|
|
104
113
|
* Props for the extensible Toolbar component.
|
|
105
114
|
*/
|
package/package.json
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type SVGProps } from 'react';
|
|
2
|
-
import { type ThemeVariant } from '../../theme';
|
|
3
|
-
export interface AIProps extends Omit<SVGProps<SVGSVGElement>, 'ref'> {
|
|
4
|
-
size?: number;
|
|
5
|
-
variant?: ThemeVariant;
|
|
6
|
-
colorMode?: 'light' | 'dark' | 'auto';
|
|
7
|
-
/** Colour of the "I" glyph. */
|
|
8
|
-
primaryColor?: string;
|
|
9
|
-
/** Colour of the "A" glyph. */
|
|
10
|
-
secondaryColor?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* AI glyph mark from the official brand source SVG.
|
|
14
|
-
* Defaults to themed logo colors and supports explicit overrides.
|
|
15
|
-
*/
|
|
16
|
-
export declare const AI: import("react").ForwardRefExoticComponent<AIProps & import("react").RefAttributes<SVGSVGElement>>;
|
|
17
|
-
export default AI;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2023-2026 Datalayer, Inc.
|
|
4
|
-
* Distributed under the terms of the Modified BSD License.
|
|
5
|
-
*/
|
|
6
|
-
import { forwardRef } from 'react';
|
|
7
|
-
import { getLogoColors } from './DatalayerLogo';
|
|
8
|
-
/**
|
|
9
|
-
* AI glyph mark from the official brand source SVG.
|
|
10
|
-
* Defaults to themed logo colors and supports explicit overrides.
|
|
11
|
-
*/
|
|
12
|
-
export const AI = forwardRef(function AI({ size = 24, variant = 'datalayer', colorMode = 'light', primaryColor, secondaryColor, ...svgProps }, ref) {
|
|
13
|
-
const themed = getLogoColors(variant, colorMode);
|
|
14
|
-
const resolvedPrimary = primaryColor ?? themed.primary;
|
|
15
|
-
const resolvedSecondary = secondaryColor ?? themed.textColor;
|
|
16
|
-
return (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", width: size, height: size, role: "img", "aria-label": "AI", ref: ref, ...svgProps, children: [_jsx("path", { d: "m13.788825 3.932 6.43325 16.136075h3.5279L17.316725 3.932H13.788825Z", fill: resolvedPrimary, strokeWidth: 0.25 }), _jsx("path", { d: "m6.325375 13.682775 2.20125 -5.67065 2.201275 5.67065H6.325375ZM6.68225 3.932 0.25 20.068075h3.596525l1.3155 -3.3886h6.729425l1.315275 3.3886h3.59655L10.371 3.932H6.68225Z", fill: resolvedSecondary, fillRule: "evenodd", clipRule: "evenodd", strokeWidth: 0.25 })] }));
|
|
17
|
-
});
|
|
18
|
-
export default AI;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type SVGProps } from 'react';
|
|
2
|
-
import { type ThemeVariant } from '../../theme';
|
|
3
|
-
export interface AI2Props extends Omit<SVGProps<SVGSVGElement>, 'ref'> {
|
|
4
|
-
size?: number;
|
|
5
|
-
variant?: ThemeVariant;
|
|
6
|
-
colorMode?: 'light' | 'dark' | 'auto';
|
|
7
|
-
/** Colour of the "I" glyph. */
|
|
8
|
-
primaryColor?: string;
|
|
9
|
-
/** Colour of the "A" glyph. */
|
|
10
|
-
secondaryColor?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Alternate AI glyph mark.
|
|
14
|
-
*
|
|
15
|
-
* A is rendered with an oblique left bar, a right vertical bar,
|
|
16
|
-
* and a horizontal crossbar.
|
|
17
|
-
* I is rendered as a simple vertical bar.
|
|
18
|
-
*/
|
|
19
|
-
export declare const AI2: import("react").ForwardRefExoticComponent<AI2Props & import("react").RefAttributes<SVGSVGElement>>;
|
|
20
|
-
export default AI2;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 2023-2026 Datalayer, Inc.
|
|
4
|
-
* Distributed under the terms of the Modified BSD License.
|
|
5
|
-
*/
|
|
6
|
-
import { forwardRef } from 'react';
|
|
7
|
-
import { getLogoColors } from './DatalayerLogo';
|
|
8
|
-
/**
|
|
9
|
-
* Alternate AI glyph mark.
|
|
10
|
-
*
|
|
11
|
-
* A is rendered with an oblique left bar, a right vertical bar,
|
|
12
|
-
* and a horizontal crossbar.
|
|
13
|
-
* I is rendered as a simple vertical bar.
|
|
14
|
-
*/
|
|
15
|
-
export const AI2 = forwardRef(function AI2({ size = 24, variant = 'datalayer', colorMode = 'light', primaryColor, secondaryColor, ...svgProps }, ref) {
|
|
16
|
-
const themed = getLogoColors(variant, colorMode);
|
|
17
|
-
const resolvedPrimary = primaryColor ?? themed.primary;
|
|
18
|
-
const resolvedSecondary = secondaryColor ?? themed.textColor;
|
|
19
|
-
const barWidth = 3.1;
|
|
20
|
-
const leftBarBottomInnerX = -2.2 + barWidth;
|
|
21
|
-
return (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "-2.2 0 26.2 24", width: size, height: size, role: "img", "aria-label": "AI2", ref: ref, ...svgProps, children: [_jsx("path", { d: `M15.35 3.5h${barWidth}V20h-${barWidth}z`, fill: resolvedPrimary }), _jsx("path", { d: `M-2.2 20 9.8 3.5h${barWidth}L${leftBarBottomInnerX} 20H-2.2z`, fill: resolvedSecondary }), _jsx("path", { d: `M10.35 3.5h${barWidth}V20h-${barWidth}z`, fill: resolvedSecondary }), _jsx("path", { d: "M3.5 12.95h9.6v2.75H3.5z", fill: resolvedSecondary })] }));
|
|
22
|
-
});
|
|
23
|
-
export default AI2;
|