@atlaskit/editor-toolbar 0.2.2 → 0.3.0

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/index.js +15 -0
  3. package/dist/cjs/ui/ColorPalette/Color.compiled.css +25 -0
  4. package/dist/cjs/ui/ColorPalette/Color.js +76 -0
  5. package/dist/cjs/ui/ColorPalette/getColorMessage.js +20 -0
  6. package/dist/cjs/ui/ColorPalette/index.compiled.css +1 -0
  7. package/dist/cjs/ui/ColorPalette/index.js +118 -0
  8. package/dist/cjs/ui/ColorPalette/types.js +5 -0
  9. package/dist/cjs/ui/ColorPalette/utils.js +94 -0
  10. package/dist/cjs/ui/ToolbarDropdownMenu.js +43 -4
  11. package/dist/cjs/ui/ToolbarDropdownMenuContext.js +40 -0
  12. package/dist/cjs/ui/icons/AIChatIcon.js +24 -12
  13. package/dist/es2019/index.js +2 -0
  14. package/dist/es2019/ui/ColorPalette/Color.compiled.css +25 -0
  15. package/dist/es2019/ui/ColorPalette/Color.js +65 -0
  16. package/dist/es2019/ui/ColorPalette/getColorMessage.js +18 -0
  17. package/dist/es2019/ui/ColorPalette/index.compiled.css +1 -0
  18. package/dist/es2019/ui/ColorPalette/index.js +110 -0
  19. package/dist/es2019/ui/ColorPalette/types.js +1 -0
  20. package/dist/es2019/ui/ColorPalette/utils.js +83 -0
  21. package/dist/es2019/ui/ToolbarDropdownMenu.js +43 -4
  22. package/dist/es2019/ui/ToolbarDropdownMenuContext.js +26 -0
  23. package/dist/es2019/ui/icons/AIChatIcon.js +32 -10
  24. package/dist/esm/index.js +2 -0
  25. package/dist/esm/ui/ColorPalette/Color.compiled.css +25 -0
  26. package/dist/esm/ui/ColorPalette/Color.js +67 -0
  27. package/dist/esm/ui/ColorPalette/getColorMessage.js +14 -0
  28. package/dist/esm/ui/ColorPalette/index.compiled.css +1 -0
  29. package/dist/esm/ui/ColorPalette/index.js +109 -0
  30. package/dist/esm/ui/ColorPalette/types.js +1 -0
  31. package/dist/esm/ui/ColorPalette/utils.js +84 -0
  32. package/dist/esm/ui/ToolbarDropdownMenu.js +41 -4
  33. package/dist/esm/ui/ToolbarDropdownMenuContext.js +31 -0
  34. package/dist/esm/ui/icons/AIChatIcon.js +22 -11
  35. package/dist/types/index.d.ts +2 -0
  36. package/dist/types/ui/ColorPalette/Color.d.ts +11 -0
  37. package/dist/types/ui/ColorPalette/getColorMessage.d.ts +8 -0
  38. package/dist/types/ui/ColorPalette/index.d.ts +15 -0
  39. package/dist/types/ui/ColorPalette/types.d.ts +89 -0
  40. package/dist/types/ui/ColorPalette/utils.d.ts +40 -0
  41. package/dist/types/ui/ToolbarDropdownMenu.d.ts +3 -0
  42. package/dist/types/ui/ToolbarDropdownMenuContext.d.ts +12 -0
  43. package/dist/types/ui/icons/AIChatIcon.d.ts +7 -4
  44. package/dist/types-ts4.5/index.d.ts +2 -0
  45. package/dist/types-ts4.5/ui/ColorPalette/Color.d.ts +11 -0
  46. package/dist/types-ts4.5/ui/ColorPalette/getColorMessage.d.ts +8 -0
  47. package/dist/types-ts4.5/ui/ColorPalette/index.d.ts +15 -0
  48. package/dist/types-ts4.5/ui/ColorPalette/types.d.ts +89 -0
  49. package/dist/types-ts4.5/ui/ColorPalette/utils.d.ts +40 -0
  50. package/dist/types-ts4.5/ui/ToolbarDropdownMenu.d.ts +3 -0
  51. package/dist/types-ts4.5/ui/ToolbarDropdownMenuContext.d.ts +12 -0
  52. package/dist/types-ts4.5/ui/icons/AIChatIcon.d.ts +7 -4
  53. package/package.json +7 -5
  54. package/src/index.ts +3 -0
  55. package/src/ui/ColorPalette/Color.tsx +110 -0
  56. package/src/ui/ColorPalette/getColorMessage.ts +27 -0
  57. package/src/ui/ColorPalette/index.tsx +125 -0
  58. package/src/ui/ColorPalette/types.ts +96 -0
  59. package/src/ui/ColorPalette/utils.ts +102 -0
  60. package/src/ui/ToolbarDropdownMenu.tsx +51 -5
  61. package/src/ui/ToolbarDropdownMenuContext.tsx +44 -0
  62. package/src/ui/icons/AIChatIcon.tsx +34 -10
  63. package/tsconfig.app.json +0 -3
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Default number of columns in the color picker
3
+ */
4
+ export var DEFAULT_COLOR_PICKER_COLUMNS = 7;
5
+
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 function getColorsPerRowFromPalette(palette) {
13
+ var cols = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_COLOR_PICKER_COLUMNS;
14
+ return palette.reduce(function (resultArray, item, index) {
15
+ var chunkIndex = Math.floor(index / cols);
16
+ resultArray[chunkIndex] = resultArray[chunkIndex] || []; // start a new chunk
17
+ resultArray[chunkIndex].push(item);
18
+ return resultArray;
19
+ }, []);
20
+ }
21
+
22
+ /**
23
+ * Finds the row and column indices of a selected color in the palette grid
24
+ * @param colorsPerRow - 2D array of colors organized by rows
25
+ * @param selectedColor - The currently selected color value
26
+ * @returns Object containing row and column indices
27
+ */
28
+ export function getSelectedRowAndColumn(colorsPerRow, selectedColor) {
29
+ var selectedRowIndex = -1;
30
+ var selectedColumnIndex = -1;
31
+ colorsPerRow.forEach(function (row, rowIndex) {
32
+ row.forEach(function (_ref, columnIndex) {
33
+ var value = _ref.value;
34
+ if (value === selectedColor) {
35
+ selectedRowIndex = rowIndex;
36
+ selectedColumnIndex = columnIndex;
37
+ }
38
+ });
39
+ });
40
+ return {
41
+ selectedRowIndex: selectedRowIndex,
42
+ selectedColumnIndex: selectedColumnIndex
43
+ };
44
+ }
45
+
46
+ /**
47
+ * Finds the row and column indices of a selected color in a flat palette array
48
+ * @param palette - Flat array of palette colors
49
+ * @param selectedColor - The currently selected color value
50
+ * @param cols - Number of columns per row
51
+ * @returns Object containing row and column indices
52
+ */
53
+ export function getSelectedRowAndColumnFromPalette(palette, selectedColor) {
54
+ var cols = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_COLOR_PICKER_COLUMNS;
55
+ var colorsPerRow = getColorsPerRowFromPalette(palette, cols);
56
+ return getSelectedRowAndColumn(colorsPerRow, selectedColor);
57
+ }
58
+
59
+ /**
60
+ * Extracts the actual color value from a CSS variable expression
61
+ * Handles both token variables and fallback values
62
+ * @param variableExpression - CSS variable expression (e.g., "var(--ds-background-accent-blue-subtle, #0052CC)")
63
+ * @returns The resolved color value or empty string if not found
64
+ */
65
+ export var getTokenCSSVariableValue = function getTokenCSSVariableValue(variableExpression) {
66
+ // Match CSS variable pattern: var(--variable-name, fallback)
67
+ // Ignored via go/ees005
68
+ // eslint-disable-next-line require-unicode-regexp
69
+ var matcher = variableExpression.match(/var\(([^,\)]+)(,.*)?/);
70
+ if (matcher) {
71
+ var variable = matcher[1].trim();
72
+ var fallback = matcher[2] ? matcher[2].replace(',', '').trim() : '';
73
+
74
+ // Return fallback if we're in a server environment
75
+ if (typeof document === 'undefined') {
76
+ return fallback;
77
+ }
78
+
79
+ // Get the computed value from the document
80
+ var value = window.getComputedStyle(document.documentElement).getPropertyValue(variable).trim();
81
+ return value || fallback;
82
+ }
83
+ return '';
84
+ };
@@ -1,8 +1,9 @@
1
- import React from 'react';
1
+ import React, { useCallback } from 'react';
2
2
  import DropdownMenu from '@atlaskit/dropdown-menu';
3
3
  import { useToolbarUI } from '../hooks/ui-context';
4
4
  import { ToolbarButton } from './ToolbarButton';
5
- export var ToolbarDropdownMenu = function ToolbarDropdownMenu(_ref) {
5
+ import { ToolbarDropdownMenuProvider, useToolbarDropdownMenu } from './ToolbarDropdownMenuContext';
6
+ var ToolbarDropdownMenuContent = function ToolbarDropdownMenuContent(_ref) {
6
7
  var iconBefore = _ref.iconBefore,
7
8
  groupLocation = _ref.groupLocation,
8
9
  children = _ref.children,
@@ -11,6 +12,23 @@ export var ToolbarDropdownMenu = function ToolbarDropdownMenu(_ref) {
11
12
  label = _ref.label;
12
13
  var _useToolbarUI = useToolbarUI(),
13
14
  onDropdownOpenChanged = _useToolbarUI.onDropdownOpenChanged;
15
+ var _useToolbarDropdownMe = useToolbarDropdownMenu(),
16
+ closeMenu = _useToolbarDropdownMe.closeMenu,
17
+ isOpen = _useToolbarDropdownMe.isOpen,
18
+ openMenu = _useToolbarDropdownMe.openMenu;
19
+ var handleOpenChange = useCallback(function (args) {
20
+ onDropdownOpenChanged(args);
21
+ if (!args.isOpen) {
22
+ closeMenu();
23
+ }
24
+ }, [closeMenu, onDropdownOpenChanged]);
25
+ var handleClick = useCallback(function () {
26
+ if (!isOpen) {
27
+ openMenu();
28
+ } else {
29
+ closeMenu();
30
+ }
31
+ }, [closeMenu, openMenu, isOpen]);
14
32
  return /*#__PURE__*/React.createElement(DropdownMenu, {
15
33
  trigger: function trigger(triggerProps) {
16
34
  return /*#__PURE__*/React.createElement(ToolbarButton, {
@@ -20,7 +38,10 @@ export var ToolbarDropdownMenu = function ToolbarDropdownMenu(_ref) {
20
38
  "aria-haspopup": triggerProps['aria-haspopup'],
21
39
  "aria-controls": triggerProps['aria-controls'],
22
40
  onBlur: triggerProps.onBlur,
23
- onClick: triggerProps.onClick,
41
+ onClick: function onClick(e) {
42
+ handleClick();
43
+ triggerProps.onClick && triggerProps.onClick(e);
44
+ },
24
45
  onFocus: triggerProps.onFocus,
25
46
  testId: testId,
26
47
  iconBefore: iconBefore,
@@ -29,6 +50,22 @@ export var ToolbarDropdownMenu = function ToolbarDropdownMenu(_ref) {
29
50
  label: label
30
51
  });
31
52
  },
32
- onOpenChange: onDropdownOpenChanged
53
+ onOpenChange: handleOpenChange,
54
+ isOpen: isOpen
33
55
  }, children);
56
+ };
57
+ export var ToolbarDropdownMenu = function ToolbarDropdownMenu(_ref2) {
58
+ var iconBefore = _ref2.iconBefore,
59
+ groupLocation = _ref2.groupLocation,
60
+ children = _ref2.children,
61
+ isDisabled = _ref2.isDisabled,
62
+ testId = _ref2.testId,
63
+ label = _ref2.label;
64
+ return /*#__PURE__*/React.createElement(ToolbarDropdownMenuProvider, null, /*#__PURE__*/React.createElement(ToolbarDropdownMenuContent, {
65
+ iconBefore: iconBefore,
66
+ groupLocation: groupLocation,
67
+ isDisabled: isDisabled,
68
+ testId: testId,
69
+ label: label
70
+ }, children));
34
71
  };
@@ -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
+ };
@@ -1,20 +1,31 @@
1
1
  /* AIChatIcon.tsx generated by @compiled/babel-plugin v0.36.1 */
2
2
  import "./AIChatIcon.compiled.css";
3
+ import * as React from 'react';
3
4
  import { ax, ix } from "@compiled/react/runtime";
4
- import React from 'react';
5
- import { RovoIcon as RovoLogoIcon } from '@atlaskit/logo';
6
- import { Box } from '@atlaskit/primitives/compiled';
7
5
  var styles = {
8
- small: "_1e0c1txw _4cvr1h6o _1bah1h6o _4t3i1crf _1bsb1crf"
6
+ container: "_1e0c1txw _4cvr1h6o _1bah1h6o _4t3i1crf _1bsb1crf"
9
7
  };
10
- export var AIChatIcon = function AIChatIcon(_ref) {
8
+ var ROVO_SVG_PATH = "<svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t<path d=\"M5.4905 0.135176C5.80591 -0.0450587 6.19311 -0.0450584 6.50852 0.135176L10.8688 2.62676C11.1885 2.80943 11.3857 3.14937 11.3857 3.51754V8.48246C11.3857 8.85063 11.1885 9.19057 10.8688 9.37324L6.50852 11.8648C6.19311 12.0451 5.80591 12.0451 5.4905 11.8648L1.13022 9.37324C0.810557 9.19057 0.613281 8.85063 0.613281 8.48246V3.51754C0.613281 3.14937 0.810557 2.80943 1.13022 2.62676L5.4905 0.135176Z\" fill=\"#BF63F3\"/>\n\t\t<mask id=\"mask0_7293_80230\" style=\"mask-type:alpha\" maskUnits=\"userSpaceOnUse\" x=\"0\" y=\"0\" width=\"12\" height=\"12\">\n\t\t\t<path d=\"M5.49147 0.135176C5.80688 -0.0450587 6.19409 -0.0450584 6.5095 0.135176L10.8698 2.62676C11.1894 2.80943 11.3867 3.14937 11.3867 3.51754V8.48246C11.3867 8.85063 11.1894 9.19057 10.8698 9.37324L6.5095 11.8648C6.19409 12.0451 5.80688 12.0451 5.49147 11.8648L1.13119 9.37324C0.811533 9.19057 0.614258 8.85063 0.614258 8.48246V3.51754C0.614258 3.14937 0.811533 2.80943 1.13119 2.62676L5.49147 0.135176Z\" fill=\"#BF63F3\"/>\n\t\t</mask>\n\t\t<g mask=\"url(#mask0_7293_80230)\">\n\t\t\t<path d=\"M1.16288 17.7949C1.88804 16.4071 2.9469 15.3192 4.34131 14.5785C5.73572 13.8378 7.35499 13.5206 8.99441 13.7092L0.174767 -2.55519C-1.28774 -2.29055 -2.70974 -1.80225 -4.07832 -1.07526C-5.44691 -0.348264 -6.62375 0.522036 -7.64571 1.5465L1.16656 17.7973L1.16288 17.7949Z\" fill=\"#82B536\"/>\n\t\t\t<path d=\"M6.2482 7.95377C3.81481 8.96062 1.95638 10.6236 1.88069 12.9253C1.88069 12.9253 1.88199 12.9371 1.88076 12.9428C1.87578 13.1139 1.87896 13.2868 1.89469 13.4633C1.89533 13.4648 1.89596 13.4663 1.89659 13.4678C1.91139 13.6465 1.93718 13.8294 1.97333 14.0151C1.98259 14.0588 1.99625 14.1041 2.00551 14.1478C2.03868 14.296 2.07186 14.4442 2.11979 14.5968C2.18327 14.7994 2.25711 15.0047 2.3457 15.2144C2.50959 15.6024 2.70185 15.9488 2.90932 16.2571C3.18552 16.6673 3.48842 17.0101 3.79015 17.2936C3.86597 17.3643 3.94053 17.432 4.01695 17.4954C4.37212 17.7357 4.89091 18.0543 5.7602 18.4584C6.328 18.7233 7.04924 19.025 7.97282 19.3662C8.7114 18.2422 10.0629 17.368 11.3277 16.3888C12.3263 15.6149 13.2681 14.7764 13.805 13.6971C14.2974 12.7085 14.3102 11.4765 13.7704 10.1986C12.4194 7.00012 9.42898 6.63591 6.2507 7.95097L6.2482 7.95377Z\" fill=\"#FCA700\"/>\n\t\t\t<path d=\"M11.6634 -7.61136L-2.81461 -5.02797C-2.81461 -5.02797 -1.3238 1.52224 -4.55981 7.48526C-4.11672 7.5189 -3.66847 7.5392 -3.21522 7.53288C5.12023 7.41664 11.7808 0.635945 11.6634 -7.61401L11.6634 -7.61136Z\" fill=\"#1868DB\"/>\n\t\t</g>\n\t\t<path d=\"M5.67239 2.71364C5.90711 2.58408 6.19359 2.58646 6.42641 2.72078L8.69144 4.02848C8.92849 4.16524 9.07522 4.41898 9.07522 4.69232V7.30776C9.07522 7.58218 8.92938 7.83479 8.69162 7.97148L6.98899 8.95449C6.99272 8.94401 6.99627 8.93347 6.99965 8.92286C7.03126 8.82487 7.04801 8.72132 7.04801 8.61548V6.00004C7.04801 5.64073 6.8569 5.3094 6.54519 5.13016L5.27598 4.39771V3.3846C5.27598 3.30477 5.28833 3.22678 5.31168 3.15296C5.3691 2.97429 5.49122 2.81962 5.65828 2.72306L5.65879 2.72277C5.66358 2.72001 5.66814 2.71694 5.67239 2.71364Z\" fill=\"white\"/>\n\t\t<path d=\"M5.09599 3.04811L3.39336 4.03112C3.1556 4.1678 3.00977 4.42042 3.00977 4.69484V7.31028C3.00977 7.58362 3.15646 7.83734 3.39352 7.9741L5.65857 9.28182C5.89139 9.41612 6.17789 9.41851 6.4126 9.28896C6.41685 9.28566 6.42137 9.28261 6.42616 9.27985C6.59341 9.18336 6.71572 9.02863 6.77323 8.84989C6.79663 8.77599 6.809 8.69792 6.809 8.618V7.60489L5.53987 6.87249C5.22822 6.69323 5.03697 6.36183 5.03697 6.00256V3.38712C5.03697 3.28142 5.05368 3.17802 5.0852 3.08015C5.08862 3.0694 5.09222 3.05872 5.09599 3.04811Z\" fill=\"white\"/>\n\t</svg>";
9
+ var RovoLogoSVG = function RovoLogoSVG(_ref) {
11
10
  var label = _ref.label,
12
11
  testId = _ref.testId;
13
- return /*#__PURE__*/React.createElement(Box, {
14
- xcss: styles.small
15
- }, /*#__PURE__*/React.createElement(RovoLogoIcon, {
12
+ return /*#__PURE__*/React.createElement("span", {
13
+ role: "img",
14
+ "aria-label": label,
15
+ "data-testid": testId
16
+ // eslint-disable-next-line react/no-danger
17
+ ,
18
+ dangerouslySetInnerHTML: {
19
+ __html: ROVO_SVG_PATH
20
+ },
21
+ className: ax([styles.container])
22
+ });
23
+ };
24
+ export var AIChatIcon = function AIChatIcon(_ref2) {
25
+ var label = _ref2.label,
26
+ testId = _ref2.testId;
27
+ return /*#__PURE__*/React.createElement(RovoLogoSVG, {
16
28
  label: label,
17
- testId: testId,
18
- size: "xxsmall"
19
- }));
29
+ testId: testId
30
+ });
20
31
  };
@@ -10,6 +10,7 @@ export { ToolbarSection } from './ui/ToolbarSection';
10
10
  export { ToolbarTooltip } from './ui/ToolbarTooltip';
11
11
  export { ToolbarDropdownDivider } from './ui/ToolbarDropdownDivider';
12
12
  export { ToolbarColorSwatch } from './ui/ToolbarColorSwatch';
13
+ export { useToolbarDropdownMenu } from './ui/ToolbarDropdownMenuContext';
13
14
  export { AIAdjustLengthIcon } from './ui/icons/AIAdjustLengthIcon';
14
15
  export { AIChatIcon } from './ui/icons/AIChatIcon';
15
16
  export { AIBriefcaseIcon } from './ui/icons/AIProfessionalIcon';
@@ -55,5 +56,6 @@ export { AlignTextCenterIcon } from './ui/icons/AlignTextCenterIcon';
55
56
  export { AlignTextRightIcon } from './ui/icons/AlignTextRightIcon';
56
57
  export { IndentIcon } from './ui/icons/IndentIcon';
57
58
  export { OutdentIcon } from './ui/icons/OutdentIcon';
59
+ export { default as ColorPalette } from './ui/ColorPalette';
58
60
  export type { IconComponent, ToolbarButtonGroupLocation } from './types';
59
61
  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,4 +1,5 @@
1
1
  import React, { type ReactNode } from 'react';
2
+ import { type OnOpenChangeArgs } from '@atlaskit/dropdown-menu';
2
3
  import { type ToolbarButtonGroupLocation } from '../types';
3
4
  type ToolbarDropdownMenuProps = {
4
5
  iconBefore: React.ReactNode;
@@ -7,6 +8,8 @@ type ToolbarDropdownMenuProps = {
7
8
  isDisabled?: boolean;
8
9
  testId?: string;
9
10
  label?: string;
11
+ isOpen?: boolean;
12
+ onOpenChange?: (args: OnOpenChangeArgs) => void;
10
13
  };
11
14
  export declare const ToolbarDropdownMenu: ({ iconBefore, groupLocation, children, isDisabled, testId, label, }: ToolbarDropdownMenuProps) => React.JSX.Element;
12
15
  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 {};
@@ -1,7 +1,10 @@
1
- import React from 'react';
2
- type AIChatIconProps = {
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ interface AIChatIconProps {
3
6
  label: string;
4
7
  testId?: string;
5
- };
6
- export declare const AIChatIcon: ({ label, testId }: AIChatIconProps) => React.JSX.Element;
8
+ }
9
+ export declare const AIChatIcon: ({ label, testId }: AIChatIconProps) => JSX.Element;
7
10
  export {};
@@ -10,6 +10,7 @@ export { ToolbarSection } from './ui/ToolbarSection';
10
10
  export { ToolbarTooltip } from './ui/ToolbarTooltip';
11
11
  export { ToolbarDropdownDivider } from './ui/ToolbarDropdownDivider';
12
12
  export { ToolbarColorSwatch } from './ui/ToolbarColorSwatch';
13
+ export { useToolbarDropdownMenu } from './ui/ToolbarDropdownMenuContext';
13
14
  export { AIAdjustLengthIcon } from './ui/icons/AIAdjustLengthIcon';
14
15
  export { AIChatIcon } from './ui/icons/AIChatIcon';
15
16
  export { AIBriefcaseIcon } from './ui/icons/AIProfessionalIcon';
@@ -55,5 +56,6 @@ export { AlignTextCenterIcon } from './ui/icons/AlignTextCenterIcon';
55
56
  export { AlignTextRightIcon } from './ui/icons/AlignTextRightIcon';
56
57
  export { IndentIcon } from './ui/icons/IndentIcon';
57
58
  export { OutdentIcon } from './ui/icons/OutdentIcon';
59
+ export { default as ColorPalette } from './ui/ColorPalette';
58
60
  export type { IconComponent, ToolbarButtonGroupLocation } from './types';
59
61
  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;