@atlaskit/editor-toolbar 0.2.3 → 0.3.1
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/CHANGELOG.md +23 -0
- package/dist/cjs/index.js +15 -7
- package/dist/cjs/ui/ColorPalette/Color.compiled.css +25 -0
- package/dist/cjs/ui/ColorPalette/Color.js +76 -0
- package/dist/cjs/ui/ColorPalette/getColorMessage.js +20 -0
- package/dist/cjs/ui/ColorPalette/index.compiled.css +1 -0
- package/dist/cjs/ui/ColorPalette/index.js +118 -0
- package/dist/cjs/ui/ColorPalette/types.js +5 -0
- package/dist/cjs/ui/ColorPalette/utils.js +94 -0
- package/dist/cjs/ui/ToolbarButton.compiled.css +1 -13
- package/dist/cjs/ui/ToolbarButton.js +2 -6
- package/dist/cjs/ui/ToolbarButtonGroup.compiled.css +7 -1
- package/dist/cjs/ui/ToolbarButtonGroup.js +17 -5
- package/dist/cjs/ui/ToolbarDropdownItem.compiled.css +4 -2
- package/dist/cjs/ui/ToolbarDropdownItem.js +1 -1
- package/dist/cjs/ui/ToolbarDropdownItemSection.js +7 -10
- package/dist/cjs/ui/ToolbarDropdownMenu.compiled.css +1 -0
- package/dist/cjs/ui/ToolbarDropdownMenu.js +51 -6
- package/dist/cjs/ui/ToolbarDropdownMenuContext.js +40 -0
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/ui/ColorPalette/Color.compiled.css +25 -0
- package/dist/es2019/ui/ColorPalette/Color.js +65 -0
- package/dist/es2019/ui/ColorPalette/getColorMessage.js +18 -0
- package/dist/es2019/ui/ColorPalette/index.compiled.css +1 -0
- package/dist/es2019/ui/ColorPalette/index.js +110 -0
- package/dist/es2019/ui/ColorPalette/types.js +1 -0
- package/dist/es2019/ui/ColorPalette/utils.js +83 -0
- package/dist/es2019/ui/ToolbarButton.compiled.css +1 -13
- package/dist/es2019/ui/ToolbarButton.js +2 -6
- package/dist/es2019/ui/ToolbarButtonGroup.compiled.css +7 -1
- package/dist/es2019/ui/ToolbarButtonGroup.js +14 -3
- package/dist/es2019/ui/ToolbarDropdownItem.compiled.css +4 -2
- package/dist/es2019/ui/ToolbarDropdownItem.js +1 -1
- package/dist/es2019/ui/ToolbarDropdownItemSection.js +7 -10
- package/dist/es2019/ui/ToolbarDropdownMenu.compiled.css +1 -0
- package/dist/es2019/ui/ToolbarDropdownMenu.js +50 -6
- package/dist/es2019/ui/ToolbarDropdownMenuContext.js +26 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/ui/ColorPalette/Color.compiled.css +25 -0
- package/dist/esm/ui/ColorPalette/Color.js +67 -0
- package/dist/esm/ui/ColorPalette/getColorMessage.js +14 -0
- package/dist/esm/ui/ColorPalette/index.compiled.css +1 -0
- package/dist/esm/ui/ColorPalette/index.js +109 -0
- package/dist/esm/ui/ColorPalette/types.js +1 -0
- package/dist/esm/ui/ColorPalette/utils.js +84 -0
- package/dist/esm/ui/ToolbarButton.compiled.css +1 -13
- package/dist/esm/ui/ToolbarButton.js +2 -6
- package/dist/esm/ui/ToolbarButtonGroup.compiled.css +7 -1
- package/dist/esm/ui/ToolbarButtonGroup.js +14 -3
- package/dist/esm/ui/ToolbarDropdownItem.compiled.css +4 -2
- package/dist/esm/ui/ToolbarDropdownItem.js +1 -1
- package/dist/esm/ui/ToolbarDropdownItemSection.js +7 -10
- package/dist/esm/ui/ToolbarDropdownMenu.compiled.css +1 -0
- package/dist/esm/ui/ToolbarDropdownMenu.js +49 -6
- package/dist/esm/ui/ToolbarDropdownMenuContext.js +31 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/types.d.ts +0 -1
- package/dist/types/ui/ColorPalette/Color.d.ts +11 -0
- package/dist/types/ui/ColorPalette/getColorMessage.d.ts +8 -0
- package/dist/types/ui/ColorPalette/index.d.ts +15 -0
- package/dist/types/ui/ColorPalette/types.d.ts +89 -0
- package/dist/types/ui/ColorPalette/utils.d.ts +40 -0
- package/dist/types/ui/ToolbarButton.d.ts +0 -2
- package/dist/types/ui/ToolbarButtonGroup.d.ts +6 -2
- package/dist/types/ui/ToolbarDropdownItemSection.d.ts +3 -1
- package/dist/types/ui/ToolbarDropdownMenu.d.ts +9 -3
- package/dist/types/ui/ToolbarDropdownMenuContext.d.ts +12 -0
- package/dist/types/ui/ToolbarTooltip.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +3 -2
- package/dist/types-ts4.5/types.d.ts +0 -1
- package/dist/types-ts4.5/ui/ColorPalette/Color.d.ts +11 -0
- package/dist/types-ts4.5/ui/ColorPalette/getColorMessage.d.ts +8 -0
- package/dist/types-ts4.5/ui/ColorPalette/index.d.ts +15 -0
- package/dist/types-ts4.5/ui/ColorPalette/types.d.ts +89 -0
- package/dist/types-ts4.5/ui/ColorPalette/utils.d.ts +40 -0
- package/dist/types-ts4.5/ui/ToolbarButton.d.ts +0 -2
- package/dist/types-ts4.5/ui/ToolbarButtonGroup.d.ts +6 -2
- package/dist/types-ts4.5/ui/ToolbarDropdownItemSection.d.ts +3 -1
- package/dist/types-ts4.5/ui/ToolbarDropdownMenu.d.ts +9 -3
- package/dist/types-ts4.5/ui/ToolbarDropdownMenuContext.d.ts +12 -0
- package/dist/types-ts4.5/ui/ToolbarTooltip.d.ts +1 -1
- package/examples/toolbar/examples/ExampleManuallyComposedToolbar.tsx +2 -12
- package/package.json +5 -3
- package/src/index.ts +4 -2
- package/src/types.ts +0 -1
- package/src/ui/ColorPalette/Color.tsx +118 -0
- package/src/ui/ColorPalette/getColorMessage.ts +27 -0
- package/src/ui/ColorPalette/index.tsx +125 -0
- package/src/ui/ColorPalette/types.ts +96 -0
- package/src/ui/ColorPalette/utils.ts +102 -0
- package/src/ui/ToolbarButton.tsx +0 -28
- package/src/ui/ToolbarButtonGroup.tsx +42 -3
- package/src/ui/ToolbarDropdownItem.tsx +4 -2
- package/src/ui/ToolbarDropdownItemSection.tsx +13 -11
- package/src/ui/ToolbarDropdownMenu.tsx +68 -9
- package/src/ui/ToolbarDropdownMenuContext.tsx +44 -0
- package/src/ui/ToolbarTooltip.tsx +1 -1
- package/dist/cjs/ui/ToolbarDropdownDivider.compiled.css +0 -3
- package/dist/cjs/ui/ToolbarDropdownDivider.js +0 -20
- package/dist/cjs/ui/ToolbarDropdownItemSection.compiled.css +0 -2
- package/dist/es2019/ui/ToolbarDropdownDivider.compiled.css +0 -3
- package/dist/es2019/ui/ToolbarDropdownDivider.js +0 -12
- package/dist/es2019/ui/ToolbarDropdownItemSection.compiled.css +0 -2
- package/dist/esm/ui/ToolbarDropdownDivider.compiled.css +0 -3
- package/dist/esm/ui/ToolbarDropdownDivider.js +0 -12
- package/dist/esm/ui/ToolbarDropdownItemSection.compiled.css +0 -2
- package/dist/types/ui/ToolbarDropdownDivider.d.ts +0 -1
- package/dist/types-ts4.5/ui/ToolbarDropdownDivider.d.ts +0 -1
- package/src/ui/ToolbarDropdownDivider.tsx +0 -20
|
@@ -1,16 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
/* ToolbarDropdownMenu.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import "./ToolbarDropdownMenu.compiled.css";
|
|
3
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
+
import React, { useCallback } from 'react';
|
|
2
5
|
import DropdownMenu from '@atlaskit/dropdown-menu';
|
|
3
6
|
import { useToolbarUI } from '../hooks/ui-context';
|
|
4
7
|
import { ToolbarButton } from './ToolbarButton';
|
|
5
|
-
|
|
8
|
+
import { ToolbarDropdownMenuProvider, useToolbarDropdownMenu } from './ToolbarDropdownMenuContext';
|
|
9
|
+
var styles = {
|
|
10
|
+
sectionMargin: "_1mou1b66"
|
|
11
|
+
};
|
|
12
|
+
var ToolbarDropdownMenuContent = function ToolbarDropdownMenuContent(_ref) {
|
|
6
13
|
var iconBefore = _ref.iconBefore,
|
|
7
|
-
groupLocation = _ref.groupLocation,
|
|
8
14
|
children = _ref.children,
|
|
9
15
|
isDisabled = _ref.isDisabled,
|
|
10
16
|
testId = _ref.testId,
|
|
11
17
|
label = _ref.label;
|
|
12
18
|
var _useToolbarUI = useToolbarUI(),
|
|
13
19
|
onDropdownOpenChanged = _useToolbarUI.onDropdownOpenChanged;
|
|
20
|
+
var _useToolbarDropdownMe = useToolbarDropdownMenu(),
|
|
21
|
+
closeMenu = _useToolbarDropdownMe.closeMenu,
|
|
22
|
+
isOpen = _useToolbarDropdownMe.isOpen,
|
|
23
|
+
openMenu = _useToolbarDropdownMe.openMenu;
|
|
24
|
+
var handleOpenChange = useCallback(function (args) {
|
|
25
|
+
onDropdownOpenChanged(args);
|
|
26
|
+
if (!args.isOpen) {
|
|
27
|
+
closeMenu();
|
|
28
|
+
}
|
|
29
|
+
}, [closeMenu, onDropdownOpenChanged]);
|
|
30
|
+
var handleClick = useCallback(function () {
|
|
31
|
+
if (!isOpen) {
|
|
32
|
+
openMenu();
|
|
33
|
+
} else {
|
|
34
|
+
closeMenu();
|
|
35
|
+
}
|
|
36
|
+
}, [closeMenu, openMenu, isOpen]);
|
|
14
37
|
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
15
38
|
trigger: function trigger(triggerProps) {
|
|
16
39
|
return /*#__PURE__*/React.createElement(ToolbarButton, {
|
|
@@ -20,15 +43,35 @@ export var ToolbarDropdownMenu = function ToolbarDropdownMenu(_ref) {
|
|
|
20
43
|
"aria-haspopup": triggerProps['aria-haspopup'],
|
|
21
44
|
"aria-controls": triggerProps['aria-controls'],
|
|
22
45
|
onBlur: triggerProps.onBlur,
|
|
23
|
-
onClick:
|
|
46
|
+
onClick: function onClick(e) {
|
|
47
|
+
handleClick();
|
|
48
|
+
triggerProps.onClick && triggerProps.onClick(e);
|
|
49
|
+
},
|
|
24
50
|
onFocus: triggerProps.onFocus,
|
|
25
51
|
testId: testId,
|
|
26
52
|
iconBefore: iconBefore,
|
|
27
|
-
groupLocation: groupLocation,
|
|
28
53
|
isDisabled: isDisabled,
|
|
29
54
|
label: label
|
|
30
55
|
});
|
|
31
56
|
},
|
|
32
|
-
onOpenChange:
|
|
57
|
+
onOpenChange: handleOpenChange,
|
|
58
|
+
isOpen: isOpen
|
|
33
59
|
}, children);
|
|
60
|
+
};
|
|
61
|
+
export var ToolbarDropdownMenu = function ToolbarDropdownMenu(_ref2) {
|
|
62
|
+
var iconBefore = _ref2.iconBefore,
|
|
63
|
+
children = _ref2.children,
|
|
64
|
+
isDisabled = _ref2.isDisabled,
|
|
65
|
+
testId = _ref2.testId,
|
|
66
|
+
label = _ref2.label,
|
|
67
|
+
_ref2$hasSectionMargi = _ref2.hasSectionMargin,
|
|
68
|
+
hasSectionMargin = _ref2$hasSectionMargi === void 0 ? true : _ref2$hasSectionMargi;
|
|
69
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownMenuProvider, null, /*#__PURE__*/React.createElement(ToolbarDropdownMenuContent, {
|
|
70
|
+
iconBefore: iconBefore,
|
|
71
|
+
isDisabled: isDisabled,
|
|
72
|
+
testId: testId,
|
|
73
|
+
label: label
|
|
74
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
75
|
+
className: ax([hasSectionMargin && styles.sectionMargin])
|
|
76
|
+
}, children)));
|
|
34
77
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { createContext, useContext, useState } from 'react';
|
|
3
|
+
var ToolbarDropdownMenuContext = /*#__PURE__*/createContext(undefined);
|
|
4
|
+
export var useToolbarDropdownMenu = function useToolbarDropdownMenu() {
|
|
5
|
+
var context = useContext(ToolbarDropdownMenuContext);
|
|
6
|
+
if (!context) {
|
|
7
|
+
throw new Error('useToolbarDropdownMenu must be used within ToolbarDropdownMenuProvider');
|
|
8
|
+
}
|
|
9
|
+
return context;
|
|
10
|
+
};
|
|
11
|
+
export var ToolbarDropdownMenuProvider = function ToolbarDropdownMenuProvider(_ref) {
|
|
12
|
+
var children = _ref.children;
|
|
13
|
+
var _useState = useState(false),
|
|
14
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
15
|
+
isOpen = _useState2[0],
|
|
16
|
+
setIsOpen = _useState2[1];
|
|
17
|
+
var openMenu = function openMenu() {
|
|
18
|
+
return setIsOpen(true);
|
|
19
|
+
};
|
|
20
|
+
var closeMenu = function closeMenu() {
|
|
21
|
+
setIsOpen(false);
|
|
22
|
+
};
|
|
23
|
+
var contextValue = {
|
|
24
|
+
openMenu: openMenu,
|
|
25
|
+
closeMenu: closeMenu,
|
|
26
|
+
isOpen: isOpen
|
|
27
|
+
};
|
|
28
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownMenuContext.Provider, {
|
|
29
|
+
value: contextValue
|
|
30
|
+
}, children);
|
|
31
|
+
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export { ToolbarNestedDropdownMenu } from './ui/ToolbarNestedDropdownMenu';
|
|
|
8
8
|
export { ToolbarKeyboardShortcutHint } from './ui/ToolbarKeyboardShortcutHint';
|
|
9
9
|
export { ToolbarSection } from './ui/ToolbarSection';
|
|
10
10
|
export { ToolbarTooltip } from './ui/ToolbarTooltip';
|
|
11
|
-
export { ToolbarDropdownDivider } from './ui/ToolbarDropdownDivider';
|
|
12
11
|
export { ToolbarColorSwatch } from './ui/ToolbarColorSwatch';
|
|
12
|
+
export { useToolbarDropdownMenu } from './ui/ToolbarDropdownMenuContext';
|
|
13
13
|
export { AIAdjustLengthIcon } from './ui/icons/AIAdjustLengthIcon';
|
|
14
14
|
export { AIChatIcon } from './ui/icons/AIChatIcon';
|
|
15
15
|
export { AIBriefcaseIcon } from './ui/icons/AIProfessionalIcon';
|
|
@@ -55,5 +55,6 @@ export { AlignTextCenterIcon } from './ui/icons/AlignTextCenterIcon';
|
|
|
55
55
|
export { AlignTextRightIcon } from './ui/icons/AlignTextRightIcon';
|
|
56
56
|
export { IndentIcon } from './ui/icons/IndentIcon';
|
|
57
57
|
export { OutdentIcon } from './ui/icons/OutdentIcon';
|
|
58
|
-
export
|
|
58
|
+
export { default as ColorPalette } from './ui/ColorPalette';
|
|
59
|
+
export type { IconComponent } from './types';
|
|
59
60
|
export { useToolbarUI, ToolbarUIProvider } from './hooks/ui-context';
|
package/dist/types/types.d.ts
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import type { ColorProps } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Individual color palette item component
|
|
9
|
+
* Displays a single color swatch with tooltip and selection state
|
|
10
|
+
*/
|
|
11
|
+
export declare const Color: React.NamedExoticComponent<ColorProps>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type MessageDescriptor } from 'react-intl-next';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the appropriate internationalization message for a given color
|
|
4
|
+
* @param messages - Record of color values to message descriptors
|
|
5
|
+
* @param color - The color value to look up
|
|
6
|
+
* @returns The message descriptor or undefined if not found
|
|
7
|
+
*/
|
|
8
|
+
export default function getColorMessage(messages: Record<string | number, MessageDescriptor>, color: string): MessageDescriptor | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ColorPaletteProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* ColorPalette component for displaying a grid of selectable colors
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - Responsive grid layout
|
|
8
|
+
* - Keyboard navigation support
|
|
9
|
+
* - Accessibility compliance (ARIA attributes)
|
|
10
|
+
* - Theme-aware tooltips
|
|
11
|
+
* - Design token integration
|
|
12
|
+
* - Customizable color mapping
|
|
13
|
+
*/
|
|
14
|
+
declare const ColorPalette: ({ cols, onClick, onKeyDown, selectedColor, paletteOptions, }: ColorPaletteProps) => React.JSX.Element;
|
|
15
|
+
export default ColorPalette;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import { type MessageDescriptor } from 'react-intl-next';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a single color in the palette
|
|
5
|
+
*/
|
|
6
|
+
export interface PaletteColor {
|
|
7
|
+
/** The color value (hex, token, etc.) */
|
|
8
|
+
value: string;
|
|
9
|
+
/** Display label for the color */
|
|
10
|
+
label: string;
|
|
11
|
+
/** Border color for the color swatch */
|
|
12
|
+
border: string;
|
|
13
|
+
/** Optional internationalization message */
|
|
14
|
+
message?: MessageDescriptor;
|
|
15
|
+
/** Optional decorator element to display instead of checkmark */
|
|
16
|
+
decorator?: ReactElement;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Array of palette colors
|
|
20
|
+
*/
|
|
21
|
+
export type Palette = Array<PaletteColor>;
|
|
22
|
+
/**
|
|
23
|
+
* Tooltip messages for different themes
|
|
24
|
+
*/
|
|
25
|
+
export type PaletteTooltipMessages = {
|
|
26
|
+
dark: Record<string, MessageDescriptor>;
|
|
27
|
+
light: Record<string, MessageDescriptor>;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Configuration options for the color palette
|
|
31
|
+
*/
|
|
32
|
+
export interface PaletteOptions {
|
|
33
|
+
/** Array of colors to display */
|
|
34
|
+
palette: PaletteColor[];
|
|
35
|
+
/**
|
|
36
|
+
* Function to convert hex codes to design system tokens
|
|
37
|
+
* Different color palettes may use different mapping functions
|
|
38
|
+
*/
|
|
39
|
+
hexToPaletteColor?: (hexColor: string) => string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Tooltip messages for different color themes
|
|
42
|
+
* Consumer determines which tooltip messages to use
|
|
43
|
+
*/
|
|
44
|
+
paletteColorTooltipMessages?: PaletteTooltipMessages;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Props for the main ColorPalette component
|
|
48
|
+
*/
|
|
49
|
+
export interface ColorPaletteProps {
|
|
50
|
+
/** Currently selected color value */
|
|
51
|
+
selectedColor: string | null;
|
|
52
|
+
/** Callback when a color is clicked */
|
|
53
|
+
onClick: (value: string, label: string) => void;
|
|
54
|
+
/** Optional callback for keyboard navigation */
|
|
55
|
+
onKeyDown?: (value: string, label: string, event: React.KeyboardEvent) => void;
|
|
56
|
+
/** Number of columns in the palette grid */
|
|
57
|
+
cols?: number;
|
|
58
|
+
/** Optional CSS class name */
|
|
59
|
+
className?: string;
|
|
60
|
+
/** Palette configuration options */
|
|
61
|
+
paletteOptions: PaletteOptions;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Props for individual color palette items
|
|
65
|
+
*/
|
|
66
|
+
export interface ColorProps {
|
|
67
|
+
/** The color value */
|
|
68
|
+
value: string;
|
|
69
|
+
/** Display label for accessibility */
|
|
70
|
+
label: string;
|
|
71
|
+
/** Tab index for keyboard navigation */
|
|
72
|
+
tabIndex?: number;
|
|
73
|
+
/** Whether this color is currently selected */
|
|
74
|
+
isSelected?: boolean;
|
|
75
|
+
/** Click handler */
|
|
76
|
+
onClick: (value: string, label: string) => void;
|
|
77
|
+
/** Keyboard event handler */
|
|
78
|
+
onKeyDown?: (value: string, label: string, event: React.KeyboardEvent) => void;
|
|
79
|
+
/** Border color for the swatch */
|
|
80
|
+
borderColor: string;
|
|
81
|
+
/** Color for the checkmark icon */
|
|
82
|
+
checkMarkColor?: string;
|
|
83
|
+
/** Whether to auto-focus this item */
|
|
84
|
+
autoFocus?: boolean;
|
|
85
|
+
/** Function to convert hex to palette color */
|
|
86
|
+
hexToPaletteColor?: (hexColor: string) => string | undefined;
|
|
87
|
+
/** Optional decorator element */
|
|
88
|
+
decorator?: ReactElement;
|
|
89
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { PaletteColor } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Default number of columns in the color picker
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_COLOR_PICKER_COLUMNS = 7;
|
|
6
|
+
/**
|
|
7
|
+
* Splits a palette array into rows based on the specified number of columns
|
|
8
|
+
* @param palette - Array of palette colors
|
|
9
|
+
* @param cols - Number of columns per row
|
|
10
|
+
* @returns Array of color rows
|
|
11
|
+
*/
|
|
12
|
+
export declare function getColorsPerRowFromPalette(palette: PaletteColor[], cols?: number): PaletteColor[][];
|
|
13
|
+
/**
|
|
14
|
+
* Finds the row and column indices of a selected color in the palette grid
|
|
15
|
+
* @param colorsPerRow - 2D array of colors organized by rows
|
|
16
|
+
* @param selectedColor - The currently selected color value
|
|
17
|
+
* @returns Object containing row and column indices
|
|
18
|
+
*/
|
|
19
|
+
export declare function getSelectedRowAndColumn(colorsPerRow: PaletteColor[][], selectedColor: string | null): {
|
|
20
|
+
selectedRowIndex: number;
|
|
21
|
+
selectedColumnIndex: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Finds the row and column indices of a selected color in a flat palette array
|
|
25
|
+
* @param palette - Flat array of palette colors
|
|
26
|
+
* @param selectedColor - The currently selected color value
|
|
27
|
+
* @param cols - Number of columns per row
|
|
28
|
+
* @returns Object containing row and column indices
|
|
29
|
+
*/
|
|
30
|
+
export declare function getSelectedRowAndColumnFromPalette(palette: PaletteColor[], selectedColor: string | null, cols?: number): {
|
|
31
|
+
selectedRowIndex: number;
|
|
32
|
+
selectedColumnIndex: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Extracts the actual color value from a CSS variable expression
|
|
36
|
+
* Handles both token variables and fallback values
|
|
37
|
+
* @param variableExpression - CSS variable expression (e.g., "var(--ds-background-accent-blue-subtle, #0052CC)")
|
|
38
|
+
* @returns The resolved color value or empty string if not found
|
|
39
|
+
*/
|
|
40
|
+
export declare const getTokenCSSVariableValue: (variableExpression: string) => string;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { type ReactNode } from 'react';
|
|
2
2
|
import { type TriggerProps } from '@atlaskit/popup';
|
|
3
|
-
import { type ToolbarButtonGroupLocation } from '../types';
|
|
4
3
|
type ToolbarButtonProps = Partial<TriggerProps> & {
|
|
5
4
|
children?: ReactNode;
|
|
6
5
|
isSelected?: boolean;
|
|
@@ -9,7 +8,6 @@ type ToolbarButtonProps = Partial<TriggerProps> & {
|
|
|
9
8
|
onFocus?: (event: React.FocusEvent<HTMLButtonElement>) => void;
|
|
10
9
|
testId?: string;
|
|
11
10
|
iconBefore: React.ReactNode;
|
|
12
|
-
groupLocation?: ToolbarButtonGroupLocation;
|
|
13
11
|
isDisabled?: boolean;
|
|
14
12
|
ariaKeyshortcuts?: string;
|
|
15
13
|
label?: string;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import { type ReactNode } from 'react';
|
|
2
6
|
type ToolbarButtonGroupProps = {
|
|
3
7
|
children?: ReactNode;
|
|
4
8
|
};
|
|
5
|
-
export declare const ToolbarButtonGroup: ({ children }: ToolbarButtonGroupProps) =>
|
|
9
|
+
export declare const ToolbarButtonGroup: ({ children }: ToolbarButtonGroupProps) => JSX.Element;
|
|
6
10
|
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React, { type ReactNode } from 'react';
|
|
2
2
|
type ToolbarDropdownItemSectionProps = {
|
|
3
3
|
children?: ReactNode;
|
|
4
|
+
hasSeparator?: boolean;
|
|
5
|
+
title?: string;
|
|
4
6
|
};
|
|
5
|
-
export declare const ToolbarDropdownItemSection: ({ children }: ToolbarDropdownItemSectionProps) => React.JSX.Element;
|
|
7
|
+
export declare const ToolbarDropdownItemSection: ({ children, hasSeparator, title, }: ToolbarDropdownItemSectionProps) => React.JSX.Element;
|
|
6
8
|
export {};
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
1
5
|
import React, { type ReactNode } from 'react';
|
|
2
|
-
import { type ToolbarButtonGroupLocation } from '../types';
|
|
3
6
|
type ToolbarDropdownMenuProps = {
|
|
4
7
|
iconBefore: React.ReactNode;
|
|
5
8
|
children?: ReactNode;
|
|
6
|
-
groupLocation?: ToolbarButtonGroupLocation;
|
|
7
9
|
isDisabled?: boolean;
|
|
8
10
|
testId?: string;
|
|
9
11
|
label?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Whether to add margin around sections to align with 4px block padding existing in current editor dropdown
|
|
14
|
+
*/
|
|
15
|
+
hasSectionMargin?: boolean;
|
|
10
16
|
};
|
|
11
|
-
export declare const ToolbarDropdownMenu: ({ iconBefore,
|
|
17
|
+
export declare const ToolbarDropdownMenu: ({ iconBefore, children, isDisabled, testId, label, hasSectionMargin, }: ToolbarDropdownMenuProps) => JSX.Element;
|
|
12
18
|
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ToolbarDropdownMenuContextValue {
|
|
3
|
+
openMenu: () => void;
|
|
4
|
+
closeMenu: () => void;
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const useToolbarDropdownMenu: () => ToolbarDropdownMenuContextValue;
|
|
8
|
+
interface ToolbarDropdownMenuProviderProps {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export declare const ToolbarDropdownMenuProvider: ({ children }: ToolbarDropdownMenuProviderProps) => React.JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -8,8 +8,8 @@ export { ToolbarNestedDropdownMenu } from './ui/ToolbarNestedDropdownMenu';
|
|
|
8
8
|
export { ToolbarKeyboardShortcutHint } from './ui/ToolbarKeyboardShortcutHint';
|
|
9
9
|
export { ToolbarSection } from './ui/ToolbarSection';
|
|
10
10
|
export { ToolbarTooltip } from './ui/ToolbarTooltip';
|
|
11
|
-
export { ToolbarDropdownDivider } from './ui/ToolbarDropdownDivider';
|
|
12
11
|
export { ToolbarColorSwatch } from './ui/ToolbarColorSwatch';
|
|
12
|
+
export { useToolbarDropdownMenu } from './ui/ToolbarDropdownMenuContext';
|
|
13
13
|
export { AIAdjustLengthIcon } from './ui/icons/AIAdjustLengthIcon';
|
|
14
14
|
export { AIChatIcon } from './ui/icons/AIChatIcon';
|
|
15
15
|
export { AIBriefcaseIcon } from './ui/icons/AIProfessionalIcon';
|
|
@@ -55,5 +55,6 @@ export { AlignTextCenterIcon } from './ui/icons/AlignTextCenterIcon';
|
|
|
55
55
|
export { AlignTextRightIcon } from './ui/icons/AlignTextRightIcon';
|
|
56
56
|
export { IndentIcon } from './ui/icons/IndentIcon';
|
|
57
57
|
export { OutdentIcon } from './ui/icons/OutdentIcon';
|
|
58
|
-
export
|
|
58
|
+
export { default as ColorPalette } from './ui/ColorPalette';
|
|
59
|
+
export type { IconComponent } from './types';
|
|
59
60
|
export { useToolbarUI, ToolbarUIProvider } from './hooks/ui-context';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import type { ColorProps } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Individual color palette item component
|
|
9
|
+
* Displays a single color swatch with tooltip and selection state
|
|
10
|
+
*/
|
|
11
|
+
export declare const Color: React.NamedExoticComponent<ColorProps>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type MessageDescriptor } from 'react-intl-next';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the appropriate internationalization message for a given color
|
|
4
|
+
* @param messages - Record of color values to message descriptors
|
|
5
|
+
* @param color - The color value to look up
|
|
6
|
+
* @returns The message descriptor or undefined if not found
|
|
7
|
+
*/
|
|
8
|
+
export default function getColorMessage(messages: Record<string | number, MessageDescriptor>, color: string): MessageDescriptor | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ColorPaletteProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* ColorPalette component for displaying a grid of selectable colors
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - Responsive grid layout
|
|
8
|
+
* - Keyboard navigation support
|
|
9
|
+
* - Accessibility compliance (ARIA attributes)
|
|
10
|
+
* - Theme-aware tooltips
|
|
11
|
+
* - Design token integration
|
|
12
|
+
* - Customizable color mapping
|
|
13
|
+
*/
|
|
14
|
+
declare const ColorPalette: ({ cols, onClick, onKeyDown, selectedColor, paletteOptions, }: ColorPaletteProps) => React.JSX.Element;
|
|
15
|
+
export default ColorPalette;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import { type MessageDescriptor } from 'react-intl-next';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a single color in the palette
|
|
5
|
+
*/
|
|
6
|
+
export interface PaletteColor {
|
|
7
|
+
/** The color value (hex, token, etc.) */
|
|
8
|
+
value: string;
|
|
9
|
+
/** Display label for the color */
|
|
10
|
+
label: string;
|
|
11
|
+
/** Border color for the color swatch */
|
|
12
|
+
border: string;
|
|
13
|
+
/** Optional internationalization message */
|
|
14
|
+
message?: MessageDescriptor;
|
|
15
|
+
/** Optional decorator element to display instead of checkmark */
|
|
16
|
+
decorator?: ReactElement;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Array of palette colors
|
|
20
|
+
*/
|
|
21
|
+
export type Palette = Array<PaletteColor>;
|
|
22
|
+
/**
|
|
23
|
+
* Tooltip messages for different themes
|
|
24
|
+
*/
|
|
25
|
+
export type PaletteTooltipMessages = {
|
|
26
|
+
dark: Record<string, MessageDescriptor>;
|
|
27
|
+
light: Record<string, MessageDescriptor>;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Configuration options for the color palette
|
|
31
|
+
*/
|
|
32
|
+
export interface PaletteOptions {
|
|
33
|
+
/** Array of colors to display */
|
|
34
|
+
palette: PaletteColor[];
|
|
35
|
+
/**
|
|
36
|
+
* Function to convert hex codes to design system tokens
|
|
37
|
+
* Different color palettes may use different mapping functions
|
|
38
|
+
*/
|
|
39
|
+
hexToPaletteColor?: (hexColor: string) => string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Tooltip messages for different color themes
|
|
42
|
+
* Consumer determines which tooltip messages to use
|
|
43
|
+
*/
|
|
44
|
+
paletteColorTooltipMessages?: PaletteTooltipMessages;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Props for the main ColorPalette component
|
|
48
|
+
*/
|
|
49
|
+
export interface ColorPaletteProps {
|
|
50
|
+
/** Currently selected color value */
|
|
51
|
+
selectedColor: string | null;
|
|
52
|
+
/** Callback when a color is clicked */
|
|
53
|
+
onClick: (value: string, label: string) => void;
|
|
54
|
+
/** Optional callback for keyboard navigation */
|
|
55
|
+
onKeyDown?: (value: string, label: string, event: React.KeyboardEvent) => void;
|
|
56
|
+
/** Number of columns in the palette grid */
|
|
57
|
+
cols?: number;
|
|
58
|
+
/** Optional CSS class name */
|
|
59
|
+
className?: string;
|
|
60
|
+
/** Palette configuration options */
|
|
61
|
+
paletteOptions: PaletteOptions;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Props for individual color palette items
|
|
65
|
+
*/
|
|
66
|
+
export interface ColorProps {
|
|
67
|
+
/** The color value */
|
|
68
|
+
value: string;
|
|
69
|
+
/** Display label for accessibility */
|
|
70
|
+
label: string;
|
|
71
|
+
/** Tab index for keyboard navigation */
|
|
72
|
+
tabIndex?: number;
|
|
73
|
+
/** Whether this color is currently selected */
|
|
74
|
+
isSelected?: boolean;
|
|
75
|
+
/** Click handler */
|
|
76
|
+
onClick: (value: string, label: string) => void;
|
|
77
|
+
/** Keyboard event handler */
|
|
78
|
+
onKeyDown?: (value: string, label: string, event: React.KeyboardEvent) => void;
|
|
79
|
+
/** Border color for the swatch */
|
|
80
|
+
borderColor: string;
|
|
81
|
+
/** Color for the checkmark icon */
|
|
82
|
+
checkMarkColor?: string;
|
|
83
|
+
/** Whether to auto-focus this item */
|
|
84
|
+
autoFocus?: boolean;
|
|
85
|
+
/** Function to convert hex to palette color */
|
|
86
|
+
hexToPaletteColor?: (hexColor: string) => string | undefined;
|
|
87
|
+
/** Optional decorator element */
|
|
88
|
+
decorator?: ReactElement;
|
|
89
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { PaletteColor } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Default number of columns in the color picker
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_COLOR_PICKER_COLUMNS = 7;
|
|
6
|
+
/**
|
|
7
|
+
* Splits a palette array into rows based on the specified number of columns
|
|
8
|
+
* @param palette - Array of palette colors
|
|
9
|
+
* @param cols - Number of columns per row
|
|
10
|
+
* @returns Array of color rows
|
|
11
|
+
*/
|
|
12
|
+
export declare function getColorsPerRowFromPalette(palette: PaletteColor[], cols?: number): PaletteColor[][];
|
|
13
|
+
/**
|
|
14
|
+
* Finds the row and column indices of a selected color in the palette grid
|
|
15
|
+
* @param colorsPerRow - 2D array of colors organized by rows
|
|
16
|
+
* @param selectedColor - The currently selected color value
|
|
17
|
+
* @returns Object containing row and column indices
|
|
18
|
+
*/
|
|
19
|
+
export declare function getSelectedRowAndColumn(colorsPerRow: PaletteColor[][], selectedColor: string | null): {
|
|
20
|
+
selectedRowIndex: number;
|
|
21
|
+
selectedColumnIndex: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Finds the row and column indices of a selected color in a flat palette array
|
|
25
|
+
* @param palette - Flat array of palette colors
|
|
26
|
+
* @param selectedColor - The currently selected color value
|
|
27
|
+
* @param cols - Number of columns per row
|
|
28
|
+
* @returns Object containing row and column indices
|
|
29
|
+
*/
|
|
30
|
+
export declare function getSelectedRowAndColumnFromPalette(palette: PaletteColor[], selectedColor: string | null, cols?: number): {
|
|
31
|
+
selectedRowIndex: number;
|
|
32
|
+
selectedColumnIndex: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Extracts the actual color value from a CSS variable expression
|
|
36
|
+
* Handles both token variables and fallback values
|
|
37
|
+
* @param variableExpression - CSS variable expression (e.g., "var(--ds-background-accent-blue-subtle, #0052CC)")
|
|
38
|
+
* @returns The resolved color value or empty string if not found
|
|
39
|
+
*/
|
|
40
|
+
export declare const getTokenCSSVariableValue: (variableExpression: string) => string;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { type ReactNode } from 'react';
|
|
2
2
|
import { type TriggerProps } from '@atlaskit/popup';
|
|
3
|
-
import { type ToolbarButtonGroupLocation } from '../types';
|
|
4
3
|
type ToolbarButtonProps = Partial<TriggerProps> & {
|
|
5
4
|
children?: ReactNode;
|
|
6
5
|
isSelected?: boolean;
|
|
@@ -9,7 +8,6 @@ type ToolbarButtonProps = Partial<TriggerProps> & {
|
|
|
9
8
|
onFocus?: (event: React.FocusEvent<HTMLButtonElement>) => void;
|
|
10
9
|
testId?: string;
|
|
11
10
|
iconBefore: React.ReactNode;
|
|
12
|
-
groupLocation?: ToolbarButtonGroupLocation;
|
|
13
11
|
isDisabled?: boolean;
|
|
14
12
|
ariaKeyshortcuts?: string;
|
|
15
13
|
label?: string;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import { type ReactNode } from 'react';
|
|
2
6
|
type ToolbarButtonGroupProps = {
|
|
3
7
|
children?: ReactNode;
|
|
4
8
|
};
|
|
5
|
-
export declare const ToolbarButtonGroup: ({ children }: ToolbarButtonGroupProps) =>
|
|
9
|
+
export declare const ToolbarButtonGroup: ({ children }: ToolbarButtonGroupProps) => JSX.Element;
|
|
6
10
|
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React, { type ReactNode } from 'react';
|
|
2
2
|
type ToolbarDropdownItemSectionProps = {
|
|
3
3
|
children?: ReactNode;
|
|
4
|
+
hasSeparator?: boolean;
|
|
5
|
+
title?: string;
|
|
4
6
|
};
|
|
5
|
-
export declare const ToolbarDropdownItemSection: ({ children }: ToolbarDropdownItemSectionProps) => React.JSX.Element;
|
|
7
|
+
export declare const ToolbarDropdownItemSection: ({ children, hasSeparator, title, }: ToolbarDropdownItemSectionProps) => React.JSX.Element;
|
|
6
8
|
export {};
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
1
5
|
import React, { type ReactNode } from 'react';
|
|
2
|
-
import { type ToolbarButtonGroupLocation } from '../types';
|
|
3
6
|
type ToolbarDropdownMenuProps = {
|
|
4
7
|
iconBefore: React.ReactNode;
|
|
5
8
|
children?: ReactNode;
|
|
6
|
-
groupLocation?: ToolbarButtonGroupLocation;
|
|
7
9
|
isDisabled?: boolean;
|
|
8
10
|
testId?: string;
|
|
9
11
|
label?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Whether to add margin around sections to align with 4px block padding existing in current editor dropdown
|
|
14
|
+
*/
|
|
15
|
+
hasSectionMargin?: boolean;
|
|
10
16
|
};
|
|
11
|
-
export declare const ToolbarDropdownMenu: ({ iconBefore,
|
|
17
|
+
export declare const ToolbarDropdownMenu: ({ iconBefore, children, isDisabled, testId, label, hasSectionMargin, }: ToolbarDropdownMenuProps) => JSX.Element;
|
|
12
18
|
export {};
|