@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.
Files changed (109) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/index.js +15 -7
  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/ToolbarButton.compiled.css +1 -13
  11. package/dist/cjs/ui/ToolbarButton.js +2 -6
  12. package/dist/cjs/ui/ToolbarButtonGroup.compiled.css +7 -1
  13. package/dist/cjs/ui/ToolbarButtonGroup.js +17 -5
  14. package/dist/cjs/ui/ToolbarDropdownItem.compiled.css +4 -2
  15. package/dist/cjs/ui/ToolbarDropdownItem.js +1 -1
  16. package/dist/cjs/ui/ToolbarDropdownItemSection.js +7 -10
  17. package/dist/cjs/ui/ToolbarDropdownMenu.compiled.css +1 -0
  18. package/dist/cjs/ui/ToolbarDropdownMenu.js +51 -6
  19. package/dist/cjs/ui/ToolbarDropdownMenuContext.js +40 -0
  20. package/dist/es2019/index.js +2 -1
  21. package/dist/es2019/ui/ColorPalette/Color.compiled.css +25 -0
  22. package/dist/es2019/ui/ColorPalette/Color.js +65 -0
  23. package/dist/es2019/ui/ColorPalette/getColorMessage.js +18 -0
  24. package/dist/es2019/ui/ColorPalette/index.compiled.css +1 -0
  25. package/dist/es2019/ui/ColorPalette/index.js +110 -0
  26. package/dist/es2019/ui/ColorPalette/types.js +1 -0
  27. package/dist/es2019/ui/ColorPalette/utils.js +83 -0
  28. package/dist/es2019/ui/ToolbarButton.compiled.css +1 -13
  29. package/dist/es2019/ui/ToolbarButton.js +2 -6
  30. package/dist/es2019/ui/ToolbarButtonGroup.compiled.css +7 -1
  31. package/dist/es2019/ui/ToolbarButtonGroup.js +14 -3
  32. package/dist/es2019/ui/ToolbarDropdownItem.compiled.css +4 -2
  33. package/dist/es2019/ui/ToolbarDropdownItem.js +1 -1
  34. package/dist/es2019/ui/ToolbarDropdownItemSection.js +7 -10
  35. package/dist/es2019/ui/ToolbarDropdownMenu.compiled.css +1 -0
  36. package/dist/es2019/ui/ToolbarDropdownMenu.js +50 -6
  37. package/dist/es2019/ui/ToolbarDropdownMenuContext.js +26 -0
  38. package/dist/esm/index.js +2 -1
  39. package/dist/esm/ui/ColorPalette/Color.compiled.css +25 -0
  40. package/dist/esm/ui/ColorPalette/Color.js +67 -0
  41. package/dist/esm/ui/ColorPalette/getColorMessage.js +14 -0
  42. package/dist/esm/ui/ColorPalette/index.compiled.css +1 -0
  43. package/dist/esm/ui/ColorPalette/index.js +109 -0
  44. package/dist/esm/ui/ColorPalette/types.js +1 -0
  45. package/dist/esm/ui/ColorPalette/utils.js +84 -0
  46. package/dist/esm/ui/ToolbarButton.compiled.css +1 -13
  47. package/dist/esm/ui/ToolbarButton.js +2 -6
  48. package/dist/esm/ui/ToolbarButtonGroup.compiled.css +7 -1
  49. package/dist/esm/ui/ToolbarButtonGroup.js +14 -3
  50. package/dist/esm/ui/ToolbarDropdownItem.compiled.css +4 -2
  51. package/dist/esm/ui/ToolbarDropdownItem.js +1 -1
  52. package/dist/esm/ui/ToolbarDropdownItemSection.js +7 -10
  53. package/dist/esm/ui/ToolbarDropdownMenu.compiled.css +1 -0
  54. package/dist/esm/ui/ToolbarDropdownMenu.js +49 -6
  55. package/dist/esm/ui/ToolbarDropdownMenuContext.js +31 -0
  56. package/dist/types/index.d.ts +3 -2
  57. package/dist/types/types.d.ts +0 -1
  58. package/dist/types/ui/ColorPalette/Color.d.ts +11 -0
  59. package/dist/types/ui/ColorPalette/getColorMessage.d.ts +8 -0
  60. package/dist/types/ui/ColorPalette/index.d.ts +15 -0
  61. package/dist/types/ui/ColorPalette/types.d.ts +89 -0
  62. package/dist/types/ui/ColorPalette/utils.d.ts +40 -0
  63. package/dist/types/ui/ToolbarButton.d.ts +0 -2
  64. package/dist/types/ui/ToolbarButtonGroup.d.ts +6 -2
  65. package/dist/types/ui/ToolbarDropdownItemSection.d.ts +3 -1
  66. package/dist/types/ui/ToolbarDropdownMenu.d.ts +9 -3
  67. package/dist/types/ui/ToolbarDropdownMenuContext.d.ts +12 -0
  68. package/dist/types/ui/ToolbarTooltip.d.ts +1 -1
  69. package/dist/types-ts4.5/index.d.ts +3 -2
  70. package/dist/types-ts4.5/types.d.ts +0 -1
  71. package/dist/types-ts4.5/ui/ColorPalette/Color.d.ts +11 -0
  72. package/dist/types-ts4.5/ui/ColorPalette/getColorMessage.d.ts +8 -0
  73. package/dist/types-ts4.5/ui/ColorPalette/index.d.ts +15 -0
  74. package/dist/types-ts4.5/ui/ColorPalette/types.d.ts +89 -0
  75. package/dist/types-ts4.5/ui/ColorPalette/utils.d.ts +40 -0
  76. package/dist/types-ts4.5/ui/ToolbarButton.d.ts +0 -2
  77. package/dist/types-ts4.5/ui/ToolbarButtonGroup.d.ts +6 -2
  78. package/dist/types-ts4.5/ui/ToolbarDropdownItemSection.d.ts +3 -1
  79. package/dist/types-ts4.5/ui/ToolbarDropdownMenu.d.ts +9 -3
  80. package/dist/types-ts4.5/ui/ToolbarDropdownMenuContext.d.ts +12 -0
  81. package/dist/types-ts4.5/ui/ToolbarTooltip.d.ts +1 -1
  82. package/examples/toolbar/examples/ExampleManuallyComposedToolbar.tsx +2 -12
  83. package/package.json +5 -3
  84. package/src/index.ts +4 -2
  85. package/src/types.ts +0 -1
  86. package/src/ui/ColorPalette/Color.tsx +118 -0
  87. package/src/ui/ColorPalette/getColorMessage.ts +27 -0
  88. package/src/ui/ColorPalette/index.tsx +125 -0
  89. package/src/ui/ColorPalette/types.ts +96 -0
  90. package/src/ui/ColorPalette/utils.ts +102 -0
  91. package/src/ui/ToolbarButton.tsx +0 -28
  92. package/src/ui/ToolbarButtonGroup.tsx +42 -3
  93. package/src/ui/ToolbarDropdownItem.tsx +4 -2
  94. package/src/ui/ToolbarDropdownItemSection.tsx +13 -11
  95. package/src/ui/ToolbarDropdownMenu.tsx +68 -9
  96. package/src/ui/ToolbarDropdownMenuContext.tsx +44 -0
  97. package/src/ui/ToolbarTooltip.tsx +1 -1
  98. package/dist/cjs/ui/ToolbarDropdownDivider.compiled.css +0 -3
  99. package/dist/cjs/ui/ToolbarDropdownDivider.js +0 -20
  100. package/dist/cjs/ui/ToolbarDropdownItemSection.compiled.css +0 -2
  101. package/dist/es2019/ui/ToolbarDropdownDivider.compiled.css +0 -3
  102. package/dist/es2019/ui/ToolbarDropdownDivider.js +0 -12
  103. package/dist/es2019/ui/ToolbarDropdownItemSection.compiled.css +0 -2
  104. package/dist/esm/ui/ToolbarDropdownDivider.compiled.css +0 -3
  105. package/dist/esm/ui/ToolbarDropdownDivider.js +0 -12
  106. package/dist/esm/ui/ToolbarDropdownItemSection.compiled.css +0 -2
  107. package/dist/types/ui/ToolbarDropdownDivider.d.ts +0 -1
  108. package/dist/types-ts4.5/ui/ToolbarDropdownDivider.d.ts +0 -1
  109. package/src/ui/ToolbarDropdownDivider.tsx +0 -20
@@ -1,23 +1,48 @@
1
+ /* ToolbarDropdownMenu.tsx generated by @compiled/babel-plugin v0.36.1 */
1
2
  "use strict";
2
3
 
3
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
6
  Object.defineProperty(exports, "__esModule", {
5
7
  value: true
6
8
  });
7
9
  exports.ToolbarDropdownMenu = void 0;
8
- var _react = _interopRequireDefault(require("react"));
10
+ require("./ToolbarDropdownMenu.compiled.css");
11
+ var _runtime = require("@compiled/react/runtime");
12
+ var _react = _interopRequireWildcard(require("react"));
9
13
  var _dropdownMenu = _interopRequireDefault(require("@atlaskit/dropdown-menu"));
10
14
  var _uiContext = require("../hooks/ui-context");
11
15
  var _ToolbarButton = require("./ToolbarButton");
12
- var ToolbarDropdownMenu = exports.ToolbarDropdownMenu = function ToolbarDropdownMenu(_ref) {
16
+ var _ToolbarDropdownMenuContext = require("./ToolbarDropdownMenuContext");
17
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
18
+ var styles = {
19
+ sectionMargin: "_1mou1b66"
20
+ };
21
+ var ToolbarDropdownMenuContent = function ToolbarDropdownMenuContent(_ref) {
13
22
  var iconBefore = _ref.iconBefore,
14
- groupLocation = _ref.groupLocation,
15
23
  children = _ref.children,
16
24
  isDisabled = _ref.isDisabled,
17
25
  testId = _ref.testId,
18
26
  label = _ref.label;
19
27
  var _useToolbarUI = (0, _uiContext.useToolbarUI)(),
20
28
  onDropdownOpenChanged = _useToolbarUI.onDropdownOpenChanged;
29
+ var _useToolbarDropdownMe = (0, _ToolbarDropdownMenuContext.useToolbarDropdownMenu)(),
30
+ closeMenu = _useToolbarDropdownMe.closeMenu,
31
+ isOpen = _useToolbarDropdownMe.isOpen,
32
+ openMenu = _useToolbarDropdownMe.openMenu;
33
+ var handleOpenChange = (0, _react.useCallback)(function (args) {
34
+ onDropdownOpenChanged(args);
35
+ if (!args.isOpen) {
36
+ closeMenu();
37
+ }
38
+ }, [closeMenu, onDropdownOpenChanged]);
39
+ var handleClick = (0, _react.useCallback)(function () {
40
+ if (!isOpen) {
41
+ openMenu();
42
+ } else {
43
+ closeMenu();
44
+ }
45
+ }, [closeMenu, openMenu, isOpen]);
21
46
  return /*#__PURE__*/_react.default.createElement(_dropdownMenu.default, {
22
47
  trigger: function trigger(triggerProps) {
23
48
  return /*#__PURE__*/_react.default.createElement(_ToolbarButton.ToolbarButton, {
@@ -27,15 +52,35 @@ var ToolbarDropdownMenu = exports.ToolbarDropdownMenu = function ToolbarDropdown
27
52
  "aria-haspopup": triggerProps['aria-haspopup'],
28
53
  "aria-controls": triggerProps['aria-controls'],
29
54
  onBlur: triggerProps.onBlur,
30
- onClick: triggerProps.onClick,
55
+ onClick: function onClick(e) {
56
+ handleClick();
57
+ triggerProps.onClick && triggerProps.onClick(e);
58
+ },
31
59
  onFocus: triggerProps.onFocus,
32
60
  testId: testId,
33
61
  iconBefore: iconBefore,
34
- groupLocation: groupLocation,
35
62
  isDisabled: isDisabled,
36
63
  label: label
37
64
  });
38
65
  },
39
- onOpenChange: onDropdownOpenChanged
66
+ onOpenChange: handleOpenChange,
67
+ isOpen: isOpen
40
68
  }, children);
69
+ };
70
+ var ToolbarDropdownMenu = exports.ToolbarDropdownMenu = function ToolbarDropdownMenu(_ref2) {
71
+ var iconBefore = _ref2.iconBefore,
72
+ children = _ref2.children,
73
+ isDisabled = _ref2.isDisabled,
74
+ testId = _ref2.testId,
75
+ label = _ref2.label,
76
+ _ref2$hasSectionMargi = _ref2.hasSectionMargin,
77
+ hasSectionMargin = _ref2$hasSectionMargi === void 0 ? true : _ref2$hasSectionMargi;
78
+ return /*#__PURE__*/_react.default.createElement(_ToolbarDropdownMenuContext.ToolbarDropdownMenuProvider, null, /*#__PURE__*/_react.default.createElement(ToolbarDropdownMenuContent, {
79
+ iconBefore: iconBefore,
80
+ isDisabled: isDisabled,
81
+ testId: testId,
82
+ label: label
83
+ }, /*#__PURE__*/_react.default.createElement("div", {
84
+ className: (0, _runtime.ax)([hasSectionMargin && styles.sectionMargin])
85
+ }, children)));
41
86
  };
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.useToolbarDropdownMenu = exports.ToolbarDropdownMenuProvider = void 0;
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
+ var _react = _interopRequireWildcard(require("react"));
11
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
12
+ var ToolbarDropdownMenuContext = /*#__PURE__*/(0, _react.createContext)(undefined);
13
+ var useToolbarDropdownMenu = exports.useToolbarDropdownMenu = function useToolbarDropdownMenu() {
14
+ var context = (0, _react.useContext)(ToolbarDropdownMenuContext);
15
+ if (!context) {
16
+ throw new Error('useToolbarDropdownMenu must be used within ToolbarDropdownMenuProvider');
17
+ }
18
+ return context;
19
+ };
20
+ var ToolbarDropdownMenuProvider = exports.ToolbarDropdownMenuProvider = function ToolbarDropdownMenuProvider(_ref) {
21
+ var children = _ref.children;
22
+ var _useState = (0, _react.useState)(false),
23
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
24
+ isOpen = _useState2[0],
25
+ setIsOpen = _useState2[1];
26
+ var openMenu = function openMenu() {
27
+ return setIsOpen(true);
28
+ };
29
+ var closeMenu = function closeMenu() {
30
+ setIsOpen(false);
31
+ };
32
+ var contextValue = {
33
+ openMenu: openMenu,
34
+ closeMenu: closeMenu,
35
+ isOpen: isOpen
36
+ };
37
+ return /*#__PURE__*/_react.default.createElement(ToolbarDropdownMenuContext.Provider, {
38
+ value: contextValue
39
+ }, children);
40
+ };
@@ -9,8 +9,8 @@ export { ToolbarNestedDropdownMenu } from './ui/ToolbarNestedDropdownMenu';
9
9
  export { ToolbarKeyboardShortcutHint } from './ui/ToolbarKeyboardShortcutHint';
10
10
  export { ToolbarSection } from './ui/ToolbarSection';
11
11
  export { ToolbarTooltip } from './ui/ToolbarTooltip';
12
- export { ToolbarDropdownDivider } from './ui/ToolbarDropdownDivider';
13
12
  export { ToolbarColorSwatch } from './ui/ToolbarColorSwatch';
13
+ export { useToolbarDropdownMenu } from './ui/ToolbarDropdownMenuContext';
14
14
  export { AIAdjustLengthIcon } from './ui/icons/AIAdjustLengthIcon';
15
15
  export { AIChatIcon } from './ui/icons/AIChatIcon';
16
16
  export { AIBriefcaseIcon } from './ui/icons/AIProfessionalIcon';
@@ -56,4 +56,5 @@ export { AlignTextCenterIcon } from './ui/icons/AlignTextCenterIcon';
56
56
  export { AlignTextRightIcon } from './ui/icons/AlignTextRightIcon';
57
57
  export { IndentIcon } from './ui/icons/IndentIcon';
58
58
  export { OutdentIcon } from './ui/icons/OutdentIcon';
59
+ export { default as ColorPalette } from './ui/ColorPalette';
59
60
  export { useToolbarUI, ToolbarUIProvider } from './hooks/ui-context';
@@ -0,0 +1,25 @@
1
+
2
+ ._19itv4vr{border:1px solid var(--ds-border-inverse,#fff)}
3
+ ._2rko1hkb{border-radius:var(--ds-border-radius-050,4px)}
4
+ ._2rkoiti9{border-radius:var(--ds-border-radius-100,4px)}._189et94y{border-width:1px}
5
+ ._1dqonqa1{border-style:solid}
6
+ ._1h6d1j28{border-color:transparent}
7
+ ._19bvidpf{padding-left:0}
8
+ ._19bvv77o{padding-left:var(--ds-space-025,2px)}
9
+ ._1bsbcr4y{width:var(--ds-space-300,26px)}
10
+ ._1e0c1txw{display:flex}
11
+ ._1e0c1ule{display:block}
12
+ ._4cvr1h6o{align-items:center}
13
+ ._4t3icr4y{height:var(--ds-space-300,26px)}
14
+ ._80omtlke{cursor:pointer}
15
+ ._bfhkm7j4{background-color:var(--ds-background-neutral,#091e420f)}
16
+ ._ca0qidpf{padding-top:0}
17
+ ._ca0qv77o{padding-top:var(--ds-space-025,2px)}
18
+ ._kqswh2mm{position:relative}
19
+ ._n3tdidpf{padding-bottom:0}
20
+ ._n3tdv77o{padding-bottom:var(--ds-space-025,2px)}
21
+ ._u5f3idpf{padding-right:0}
22
+ ._u5f3v77o{padding-right:var(--ds-space-025,2px)}
23
+ ._y2mvugt7:focus{outline:2px solid var(--ds-border-focused,#388bff)}
24
+ ._858umuej:focus, ._jyzfmuej:focus-within, ._4cvxmuej:hover{border-color:var(--ds-border,#091e4224)}
25
+ ._1bg4v77o:focus{outline-offset:var(--ds-space-025,2px)}
@@ -0,0 +1,65 @@
1
+ /* Color.tsx generated by @compiled/babel-plugin v0.36.1 */
2
+ import "./Color.compiled.css";
3
+ import { ax, ix } from "@compiled/react/runtime";
4
+ import React, { useCallback, memo } from 'react';
5
+ import EditorDoneIcon from '@atlaskit/icon/core/migration/check-mark--editor-done';
6
+ import Tooltip from '@atlaskit/tooltip';
7
+ const buttonWrapperStyles = null;
8
+ const buttonStyles = null;
9
+
10
+ /**
11
+ * Individual color palette item component
12
+ * Displays a single color swatch with tooltip and selection state
13
+ */
14
+ export const Color = /*#__PURE__*/memo(({
15
+ autoFocus,
16
+ tabIndex,
17
+ value,
18
+ label,
19
+ isSelected,
20
+ borderColor,
21
+ checkMarkColor = "var(--ds-icon-inverse, #FFFFFF)",
22
+ hexToPaletteColor,
23
+ decorator,
24
+ onClick,
25
+ onKeyDown
26
+ }) => {
27
+ const colorStyle = hexToPaletteColor ? hexToPaletteColor(value) : value;
28
+ const handleMouseDown = useCallback(e => {
29
+ e.preventDefault();
30
+ }, []);
31
+ const handleClick = useCallback(e => {
32
+ e.preventDefault();
33
+ onClick(value, label);
34
+ }, [onClick, value, label]);
35
+ const handleKeyDown = useCallback(e => {
36
+ if (!onKeyDown) {
37
+ return;
38
+ }
39
+ e.preventDefault();
40
+ onKeyDown(value, label, e);
41
+ }, [onKeyDown, value, label]);
42
+ return /*#__PURE__*/React.createElement(Tooltip, {
43
+ content: label
44
+ }, /*#__PURE__*/React.createElement("span", {
45
+ className: ax(["_2rkoiti9 _1h6d1j28 _1dqonqa1 _189et94y _1e0c1txw _4cvr1h6o _ca0qv77o _u5f3v77o _n3tdv77o _19bvv77o _858umuej _jyzfmuej _4cvxmuej"])
46
+ }, /*#__PURE__*/React.createElement("button", {
47
+ type: "button",
48
+ "aria-label": label,
49
+ role: "radio",
50
+ "aria-checked": isSelected,
51
+ onClick: handleClick,
52
+ onKeyDown: handleKeyDown,
53
+ onMouseDown: handleMouseDown,
54
+ tabIndex: tabIndex,
55
+ style: {
56
+ backgroundColor: colorStyle || "var(--ds-background-input, #FFFFFF)",
57
+ border: `1px solid ${borderColor}`
58
+ },
59
+ autoFocus: autoFocus,
60
+ className: ax(["_ca0qidpf _u5f3idpf _n3tdidpf _19bvidpf _2rko1hkb _19itv4vr _4t3icr4y _1bsbcr4y _bfhkm7j4 _80omtlke _1e0c1ule _kqswh2mm _y2mvugt7 _1bg4v77o"])
61
+ }, !decorator && isSelected && /*#__PURE__*/React.createElement(EditorDoneIcon, {
62
+ LEGACY_primaryColor: checkMarkColor,
63
+ label: ""
64
+ }), decorator)));
65
+ });
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Retrieves the appropriate internationalization message for a given color
3
+ * @param messages - Record of color values to message descriptors
4
+ * @param color - The color value to look up
5
+ * @returns The message descriptor or undefined if not found
6
+ */
7
+ export default function getColorMessage(messages, color) {
8
+ const message = messages[color];
9
+ if (!message) {
10
+ // eslint-disable-next-line no-console
11
+ console.warn(`Color palette does not have an internationalization message for color ${color.toUpperCase()}.
12
+ You must add a message description to properly translate this color.
13
+ Using current label as default message.
14
+ This could have happened when someone changed the 'colorPalette' from 'adf-schema' without updating this file.
15
+ `);
16
+ }
17
+ return message;
18
+ }
@@ -0,0 +1 @@
1
+ ._1e0c1txw{display:flex}
@@ -0,0 +1,110 @@
1
+ /* index.tsx generated by @compiled/babel-plugin v0.36.1 */
2
+ import "./index.compiled.css";
3
+ import { ax, ix } from "@compiled/react/runtime";
4
+ import React, { useMemo } from 'react';
5
+ import chromatism from 'chromatism';
6
+ import { useIntl } from 'react-intl-next';
7
+ import { Box } from '@atlaskit/primitives/compiled';
8
+ import { useThemeObserver } from '@atlaskit/tokens';
9
+ import { Color } from './Color';
10
+ import getColorMessage from './getColorMessage';
11
+ import { DEFAULT_COLOR_PICKER_COLUMNS, getColorsPerRowFromPalette, getTokenCSSVariableValue } from './utils';
12
+ const styles = {
13
+ paletteWrapper: "_1e0c1txw"
14
+ };
15
+
16
+ /**
17
+ * For a given color pick the color from a list of colors with
18
+ * the highest contrast
19
+ *
20
+ * @param color color string, supports HEX, RGB, RGBA etc.
21
+ * @param useIconToken boolean, describes if a token should be used for the icon color
22
+ * @return Highest contrast color in pool
23
+ */
24
+ function getCheckMarkColor(color, useIconToken) {
25
+ const tokenVal = getTokenCSSVariableValue(color);
26
+ const colorValue = !!tokenVal ? tokenVal : color;
27
+
28
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
29
+ const contrastColor = ['#FFFFFF', '#42526E'].sort((a, b) => chromatism.difference(b, colorValue) - chromatism.difference(a, colorValue))[0];
30
+ if (!useIconToken) {
31
+ return contrastColor;
32
+ }
33
+
34
+ // Use of these token comes from guidance from designers in the Design System team
35
+ // they are only intended for use with text colors (and there are different tokens
36
+ // planned to be used when this extended to be used with other palettes).
37
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
38
+ return contrastColor === '#FFFFFF' ? "var(--ds-icon-inverse, #FFFFFF)" : "var(--ds-icon, #44546F)";
39
+ }
40
+
41
+ /**
42
+ * ColorPalette component for displaying a grid of selectable colors
43
+ *
44
+ * Features:
45
+ * - Responsive grid layout
46
+ * - Keyboard navigation support
47
+ * - Accessibility compliance (ARIA attributes)
48
+ * - Theme-aware tooltips
49
+ * - Design token integration
50
+ * - Customizable color mapping
51
+ */
52
+ const ColorPalette = ({
53
+ cols = DEFAULT_COLOR_PICKER_COLUMNS,
54
+ onClick,
55
+ onKeyDown,
56
+ selectedColor,
57
+ paletteOptions
58
+ }) => {
59
+ const {
60
+ formatMessage
61
+ } = useIntl();
62
+ const {
63
+ palette,
64
+ hexToPaletteColor,
65
+ paletteColorTooltipMessages
66
+ } = paletteOptions;
67
+ const {
68
+ colorMode: tokenTheme
69
+ } = useThemeObserver();
70
+ const useIconToken = !!hexToPaletteColor;
71
+ const colorsPerRow = useMemo(() => {
72
+ return getColorsPerRowFromPalette(palette, cols);
73
+ }, [palette, cols]);
74
+ return /*#__PURE__*/React.createElement(React.Fragment, null, colorsPerRow.map(row => /*#__PURE__*/React.createElement(Box, {
75
+ xcss: styles.paletteWrapper,
76
+ key: `row-first-color-${row[0].value}`,
77
+ role: "radiogroup"
78
+ }, row.map(({
79
+ value,
80
+ label,
81
+ border,
82
+ message,
83
+ decorator
84
+ }) => {
85
+ let tooltipMessage = message;
86
+
87
+ // Override with theme-specific tooltip messages if provided
88
+ if (paletteColorTooltipMessages) {
89
+ if (tokenTheme === 'dark') {
90
+ tooltipMessage = getColorMessage(paletteColorTooltipMessages.dark, value.toUpperCase());
91
+ }
92
+ if (tokenTheme === 'light') {
93
+ tooltipMessage = getColorMessage(paletteColorTooltipMessages.light, value.toUpperCase());
94
+ }
95
+ }
96
+ return /*#__PURE__*/React.createElement(Color, {
97
+ key: value,
98
+ value: value,
99
+ borderColor: border,
100
+ label: tooltipMessage ? formatMessage(tooltipMessage) : label,
101
+ onClick: onClick,
102
+ onKeyDown: onKeyDown,
103
+ isSelected: value === selectedColor,
104
+ checkMarkColor: getCheckMarkColor(value, useIconToken),
105
+ hexToPaletteColor: hexToPaletteColor,
106
+ decorator: decorator
107
+ });
108
+ }))));
109
+ };
110
+ export default ColorPalette;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Default number of columns in the color picker
3
+ */
4
+ export const 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, cols = DEFAULT_COLOR_PICKER_COLUMNS) {
13
+ return palette.reduce((resultArray, item, index) => {
14
+ const chunkIndex = Math.floor(index / cols);
15
+ resultArray[chunkIndex] = resultArray[chunkIndex] || []; // start a new chunk
16
+ resultArray[chunkIndex].push(item);
17
+ return resultArray;
18
+ }, []);
19
+ }
20
+
21
+ /**
22
+ * Finds the row and column indices of a selected color in the palette grid
23
+ * @param colorsPerRow - 2D array of colors organized by rows
24
+ * @param selectedColor - The currently selected color value
25
+ * @returns Object containing row and column indices
26
+ */
27
+ export function getSelectedRowAndColumn(colorsPerRow, selectedColor) {
28
+ let selectedRowIndex = -1;
29
+ let selectedColumnIndex = -1;
30
+ colorsPerRow.forEach((row, rowIndex) => {
31
+ row.forEach(({
32
+ value
33
+ }, columnIndex) => {
34
+ if (value === selectedColor) {
35
+ selectedRowIndex = rowIndex;
36
+ selectedColumnIndex = columnIndex;
37
+ }
38
+ });
39
+ });
40
+ return {
41
+ selectedRowIndex,
42
+ 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, cols = DEFAULT_COLOR_PICKER_COLUMNS) {
54
+ const colorsPerRow = getColorsPerRowFromPalette(palette, cols);
55
+ return getSelectedRowAndColumn(colorsPerRow, selectedColor);
56
+ }
57
+
58
+ /**
59
+ * Extracts the actual color value from a CSS variable expression
60
+ * Handles both token variables and fallback values
61
+ * @param variableExpression - CSS variable expression (e.g., "var(--ds-background-accent-blue-subtle, #0052CC)")
62
+ * @returns The resolved color value or empty string if not found
63
+ */
64
+ export const getTokenCSSVariableValue = variableExpression => {
65
+ // Match CSS variable pattern: var(--variable-name, fallback)
66
+ // Ignored via go/ees005
67
+ // eslint-disable-next-line require-unicode-regexp
68
+ const matcher = variableExpression.match(/var\(([^,\)]+)(,.*)?/);
69
+ if (matcher) {
70
+ const variable = matcher[1].trim();
71
+ const fallback = matcher[2] ? matcher[2].replace(',', '').trim() : '';
72
+
73
+ // Return fallback if we're in a server environment
74
+ if (typeof document === 'undefined') {
75
+ return fallback;
76
+ }
77
+
78
+ // Get the computed value from the document
79
+ const value = window.getComputedStyle(document.documentElement).getPropertyValue(variable).trim();
80
+ return value || fallback;
81
+ }
82
+ return '';
83
+ };
@@ -1,31 +1,19 @@
1
1
 
2
2
  ._2rkoiti9{border-radius:var(--ds-border-radius-100,4px)}
3
- ._zulp12x7{gap:var(--ds-space-075,6px)}._13liidpf{border-top-left-radius:0}
4
- ._19bv12x7{padding-left:var(--ds-space-075,6px)}
5
- ._19bv1b66{padding-left:var(--ds-space-050,4px)}
6
- ._19bvu2gc{padding-left:var(--ds-space-100,8px)}
7
- ._19bvv77o{padding-left:var(--ds-space-025,2px)}
3
+ ._zulp12x7{gap:var(--ds-space-075,6px)}._19bvu2gc{padding-left:var(--ds-space-100,8px)}
8
4
  ._1bah1h6o{justify-content:center}
9
- ._1bah1y6m{justify-content:flex-start}
10
- ._1bahesu3{justify-content:flex-end}
11
5
  ._1e0c1txw{display:flex}
12
- ._1o0zidpf{border-bottom-right-radius:0}
13
6
  ._1tke1f4h{min-height:28px}
14
7
  ._4cvr1h6o{align-items:center}
15
8
  ._80om13gf{cursor:not-allowed}
16
9
  ._bfhkfg4m{background-color:var(--ds-background-selected,#e9f2ff)}
17
10
  ._bfhksm61{background-color:var(--ds-background-neutral-subtle,#00000000)}
18
11
  ._k48p1wq8{font-weight:var(--ds-font-weight-medium,500)}
19
- ._mrkbidpf{border-bottom-left-radius:0}
20
12
  ._o5721q9c{white-space:nowrap}
21
- ._qrwqidpf{border-top-right-radius:0}
22
13
  ._syaz1gjq{color:var(--ds-text-subtle,#44546f)}
23
14
  ._syaz1lh4{color:var(--ds-text-disabled,#091e424f)}
24
15
  ._syazaqb7{color:var(--ds-text-selected,#0c66e4)}
25
- ._u5f312x7{padding-right:var(--ds-space-075,6px)}
26
- ._u5f31b66{padding-right:var(--ds-space-050,4px)}
27
16
  ._u5f3u2gc{padding-right:var(--ds-space-100,8px)}
28
- ._u5f3v77o{padding-right:var(--ds-space-025,2px)}
29
17
  ._1ah3idpf:focus-visible{outline-offset:0}
30
18
  ._g0pbkb7n:focus-visible{z-index:1}
31
19
  ._oh03h2mm:focus-visible{position:relative}
@@ -9,10 +9,7 @@ const styles = {
9
9
  button: "_zulp12x7 _2rkoiti9 _1e0c1txw _bfhksm61 _o5721q9c _4cvr1h6o _1bah1h6o _1tke1f4h _syaz1gjq _k48p1wq8 _19bvu2gc _u5f3u2gc _1ah3idpf _g0pbkb7n _oh03h2mm",
10
10
  enabled: "_irr3166n _1di61dty",
11
11
  disabled: "_syaz1lh4 _80om13gf",
12
- selected: "_bfhkfg4m _syazaqb7 _irr3i1yw _1di619ru",
13
- groupStart: "_qrwqidpf _1o0zidpf _1bahesu3 _19bv12x7 _u5f3v77o",
14
- groupMiddle: "_13liidpf _mrkbidpf _qrwqidpf _1o0zidpf _19bv1b66 _u5f31b66",
15
- groupEnd: "_13liidpf _mrkbidpf _1bah1y6m _19bvv77o _u5f312x7"
12
+ selected: "_bfhkfg4m _syazaqb7 _irr3i1yw _1di619ru"
16
13
  };
17
14
  export const ToolbarButton = /*#__PURE__*/forwardRef(({
18
15
  iconBefore,
@@ -26,7 +23,6 @@ export const ToolbarButton = /*#__PURE__*/forwardRef(({
26
23
  onBlur,
27
24
  onFocus,
28
25
  testId,
29
- groupLocation,
30
26
  isDisabled,
31
27
  ariaKeyshortcuts,
32
28
  label
@@ -36,7 +32,7 @@ export const ToolbarButton = /*#__PURE__*/forwardRef(({
36
32
  } = useToolbarUI();
37
33
  return /*#__PURE__*/React.createElement(Pressable, {
38
34
  ref: ref,
39
- xcss: cx(styles.button, isDisabled ? styles.disabled : isSelected ? styles.selected : styles.enabled, groupLocation === 'start' && styles.groupStart, groupLocation === 'middle' && styles.groupMiddle, groupLocation === 'end' && styles.groupEnd),
35
+ xcss: cx(styles.button, isDisabled ? styles.disabled : isSelected ? styles.selected : styles.enabled),
40
36
  "aria-pressed": isSelected,
41
37
  "aria-expanded": ariaExpanded,
42
38
  "aria-haspopup": ariaHasPopup,
@@ -1 +1,7 @@
1
- ._1e0c1txw{display:flex}
1
+
2
+ ._fb2512x7 button{padding-inline:var(--ds-space-075,6px)}
3
+ ._fb251b66 button{padding-inline:var(--ds-space-050,4px)}._1e0c1txw{display:flex}
4
+ ._1jiyidpf button{border-bottom-left-radius:0}
5
+ ._t1diidpf button{border-top-right-radius:0}
6
+ ._u6eridpf button{border-bottom-right-radius:0}
7
+ ._xk07idpf button{border-top-left-radius:0}
@@ -1,15 +1,26 @@
1
1
  /* ToolbarButtonGroup.tsx generated by @compiled/babel-plugin v0.36.1 */
2
2
  import "./ToolbarButtonGroup.compiled.css";
3
+ import * as React from 'react';
3
4
  import { ax, ix } from "@compiled/react/runtime";
4
- import React from 'react';
5
+ import { Children, Fragment } from 'react';
5
6
  import { Box } from '@atlaskit/primitives/compiled';
6
7
  const styles = {
7
- container: "_1e0c1txw"
8
+ container: "_1e0c1txw",
9
+ firstChild: "_fb251b66 _t1diidpf _u6eridpf",
10
+ lastChild: "_fb2512x7 _xk07idpf _1jiyidpf"
8
11
  };
9
12
  export const ToolbarButtonGroup = ({
10
13
  children
11
14
  }) => {
15
+ const items = Children.toArray(children);
16
+ const FirstChild = items.at(0);
17
+ const LastChild = items.at(-1);
18
+ const middleChildren = items.slice(1, -1);
12
19
  return /*#__PURE__*/React.createElement(Box, {
13
20
  xcss: styles.container
14
- }, children);
21
+ }, items.length <= 1 ? children : /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
22
+ className: ax([styles.firstChild])
23
+ }, FirstChild), middleChildren, /*#__PURE__*/React.createElement("div", {
24
+ className: ax([styles.lastChild])
25
+ }, LastChild)));
15
26
  };
@@ -1,13 +1,15 @@
1
- ._19bvutpp{padding-left:var(--ds-space-150,9pt)}
1
+ ._18zrpxbi{padding-inline:var(--ds-space-200,1pc)}
2
+ ._1rjcu2gc{padding-block:var(--ds-space-100,8px)}
2
3
  ._1bsb1osq{width:100%}
4
+ ._1e0c1txw{display:flex}
3
5
  ._1tke14no{min-height:36px}
6
+ ._1ul9163w{min-width:230px}
4
7
  ._80om13gf{cursor:not-allowed}
5
8
  ._bfhkfg4m{background-color:var(--ds-background-selected,#e9f2ff)}
6
9
  ._bfhksm61{background-color:var(--ds-background-neutral-subtle,#00000000)}
7
10
  ._kqswh2mm{position:relative}
8
11
  ._syaz1lh4{color:var(--ds-text-disabled,#091e424f)}
9
12
  ._syazaqb7{color:var(--ds-text-selected,#0c66e4)}
10
- ._u5f3utpp{padding-right:var(--ds-space-150,9pt)}
11
13
  ._1basglpi:focus-visible{border-radius:var(--ds-border-radius,4px)}
12
14
  ._1ah31i6y:focus-visible{outline-offset:var(--ds-space-negative-025,-2px)}
13
15
  ._irr3166n:hover{background-color:var(--ds-background-neutral-subtle-hovered,#091e420f)}
@@ -6,7 +6,7 @@ import { cx } from '@atlaskit/css';
6
6
  import { DropdownItem } from '@atlaskit/dropdown-menu';
7
7
  import { Pressable } from '@atlaskit/primitives/compiled';
8
8
  const styles = {
9
- toolbarDropdownItem: "_kqswh2mm _bfhksm61 _1bsb1osq _1tke14no _19bvutpp _u5f3utpp _1basglpi _1ah31i6y",
9
+ toolbarDropdownItem: "_18zrpxbi _1rjcu2gc _1e0c1txw _kqswh2mm _bfhksm61 _1bsb1osq _1tke14no _1ul9163w _1basglpi _1ah31i6y",
10
10
  enabled: "_irr3166n _1di61dty",
11
11
  disabled: "_syaz1lh4 _80om13gf",
12
12
  selected: "_bfhkfg4m _syazaqb7 _irr3i1yw _1di619ru"
@@ -1,15 +1,12 @@
1
- /* ToolbarDropdownItemSection.tsx generated by @compiled/babel-plugin v0.36.1 */
2
- import "./ToolbarDropdownItemSection.compiled.css";
3
- import { ax, ix } from "@compiled/react/runtime";
4
1
  import React from 'react';
5
- import { Box } from '@atlaskit/primitives/compiled';
6
- const styles = {
7
- container: "_1e0c1txw _2lx21bp4"
8
- };
2
+ import { DropdownItemGroup } from '@atlaskit/dropdown-menu';
9
3
  export const ToolbarDropdownItemSection = ({
10
- children
4
+ children,
5
+ hasSeparator,
6
+ title
11
7
  }) => {
12
- return /*#__PURE__*/React.createElement(Box, {
13
- xcss: styles.container
8
+ return /*#__PURE__*/React.createElement(DropdownItemGroup, {
9
+ hasSeparator: hasSeparator,
10
+ title: title
14
11
  }, children);
15
12
  };
@@ -0,0 +1 @@
1
+ ._1mou1b66{margin-block:var(--ds-space-050,4px)}