@atlaskit/editor-common 74.52.0 → 74.52.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 74.52.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`dbccd831543`](https://bitbucket.org/atlassian/atlassian-frontend/commits/dbccd831543) - [ux] tokenize ColorPicker, make charts package compatible with tokens, make check mark compatible with tokens
8
+
3
9
  ## 74.52.0
4
10
 
5
11
  ### Minor Changes
@@ -16,7 +16,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
18
18
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
19
- var packageVersion = "74.52.0";
19
+ var packageVersion = "74.52.1";
20
20
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
21
21
  // Remove URL as it has UGC
22
22
  // TODO: Sanitise the URL instead of just removing it
@@ -24,7 +24,7 @@ var _templateObject, _templateObject2, _templateObject3;
24
24
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
25
25
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "74.52.0";
27
+ var packageVersion = "74.52.1";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var DropList = /*#__PURE__*/function (_Component) {
@@ -21,13 +21,17 @@ var _utils = require("./utils");
21
21
  * For a given color pick the color from a list of colors with
22
22
  * the highest contrast
23
23
  *
24
- * @param color color string, suppports HEX, RGB, RGBA etc.
24
+ * @param color color string, supports HEX, RGB, RGBA etc.
25
+ * @param useIconToken boolean, describes if a token should be used for the icon color
25
26
  * @return Highest contrast color in pool
26
27
  */
27
28
  function getCheckMarkColor(color, useIconToken) {
29
+ var tokenVal = (0, _utils.getTokenCSSVariableValue)(color);
30
+ var colorValue = !!tokenVal ? tokenVal : color;
31
+
28
32
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
29
33
  var contrastColor = [_colors.N0, _colors.N500].sort(function (a, b) {
30
- return _chromatism.default.difference(b, color) - _chromatism.default.difference(a, color);
34
+ return _chromatism.default.difference(b, colorValue) - _chromatism.default.difference(a, colorValue);
31
35
  })[0];
32
36
  if (!useIconToken) {
33
37
  return contrastColor;
@@ -58,13 +62,13 @@ var ColorPalette = function ColorPalette(props) {
58
62
  var colorsPerRow = _react.default.useMemo(function () {
59
63
  return (0, _utils.getColorsPerRowFromPalette)(palette, cols);
60
64
  }, [palette, cols]);
61
- return (0, _react2.jsx)(_react.default.Fragment, null, colorsPerRow.map(function (row, rowIdx) {
65
+ return (0, _react2.jsx)(_react.default.Fragment, null, colorsPerRow.map(function (row) {
62
66
  return (0, _react2.jsx)("div", {
63
67
  css: _styles.colorPaletteWrapper,
64
68
  className: className,
65
69
  key: "row-first-color-".concat(row[0].value),
66
70
  role: "radiogroup"
67
- }, row.map(function (_ref, colorIdx) {
71
+ }, row.map(function (_ref) {
68
72
  var value = _ref.value,
69
73
  label = _ref.label,
70
74
  border = _ref.border,
@@ -7,6 +7,7 @@ exports.DEFAULT_COLOR_PICKER_COLUMNS = void 0;
7
7
  exports.getColorsPerRowFromPalette = getColorsPerRowFromPalette;
8
8
  exports.getSelectedRowAndColumn = getSelectedRowAndColumn;
9
9
  exports.getSelectedRowAndColumnFromPalette = getSelectedRowAndColumnFromPalette;
10
+ exports.getTokenCSSVariableValue = void 0;
10
11
  var DEFAULT_COLOR_PICKER_COLUMNS = 7;
11
12
  exports.DEFAULT_COLOR_PICKER_COLUMNS = DEFAULT_COLOR_PICKER_COLUMNS;
12
13
  function getColorsPerRowFromPalette(palette) {
@@ -39,4 +40,18 @@ function getSelectedRowAndColumnFromPalette(palette, selectedColor) {
39
40
  var cols = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_COLOR_PICKER_COLUMNS;
40
41
  var colorsPerRow = getColorsPerRowFromPalette(palette, cols);
41
42
  return getSelectedRowAndColumn(colorsPerRow, selectedColor);
42
- }
43
+ }
44
+ var getTokenCSSVariableValue = function getTokenCSSVariableValue(variableExpression) {
45
+ var matcher = variableExpression.match(/var\(([^,\)]+)(,.*)?\)/);
46
+ if (matcher) {
47
+ var variable = matcher[1].trim();
48
+ var fallback = matcher[2] ? matcher[2].replace(',', '').trim() : '';
49
+ if (typeof document === 'undefined') {
50
+ return fallback;
51
+ }
52
+ var value = window.getComputedStyle(document.documentElement).getPropertyValue(variable).trim();
53
+ return value || fallback;
54
+ }
55
+ return '';
56
+ };
57
+ exports.getTokenCSSVariableValue = getTokenCSSVariableValue;
@@ -1,6 +1,6 @@
1
1
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
2
2
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
3
- const packageVersion = "74.52.0";
3
+ const packageVersion = "74.52.1";
4
4
  const sanitiseSentryEvents = (data, _hint) => {
5
5
  // Remove URL as it has UGC
6
6
  // TODO: Sanitise the URL instead of just removing it
@@ -8,7 +8,7 @@ import { themed } from '@atlaskit/theme/components';
8
8
  import { borderRadius } from '@atlaskit/theme/constants';
9
9
  import Layer from '../Layer';
10
10
  const packageName = "@atlaskit/editor-common";
11
- const packageVersion = "74.52.0";
11
+ const packageVersion = "74.52.1";
12
12
  const halfFocusRing = 1;
13
13
  const dropOffset = '0, 8';
14
14
  class DropList extends Component {
@@ -8,17 +8,21 @@ import { useThemeObserver } from '@atlaskit/tokens';
8
8
  import Color from './Color';
9
9
  import getColorMessage from './Palettes/getColorMessage';
10
10
  import { colorPaletteWrapper } from './styles';
11
- import { DEFAULT_COLOR_PICKER_COLUMNS, getColorsPerRowFromPalette } from './utils';
11
+ import { DEFAULT_COLOR_PICKER_COLUMNS, getColorsPerRowFromPalette, getTokenCSSVariableValue } from './utils';
12
12
  /**
13
13
  * For a given color pick the color from a list of colors with
14
14
  * the highest contrast
15
15
  *
16
- * @param color color string, suppports HEX, RGB, RGBA etc.
16
+ * @param color color string, supports HEX, RGB, RGBA etc.
17
+ * @param useIconToken boolean, describes if a token should be used for the icon color
17
18
  * @return Highest contrast color in pool
18
19
  */
19
20
  function getCheckMarkColor(color, useIconToken) {
21
+ const tokenVal = getTokenCSSVariableValue(color);
22
+ const colorValue = !!tokenVal ? tokenVal : color;
23
+
20
24
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
21
- const contrastColor = [N0, N500].sort((a, b) => chromatism.difference(b, color) - chromatism.difference(a, color))[0];
25
+ const contrastColor = [N0, N500].sort((a, b) => chromatism.difference(b, colorValue) - chromatism.difference(a, colorValue))[0];
22
26
  if (!useIconToken) {
23
27
  return contrastColor;
24
28
  }
@@ -53,7 +57,7 @@ const ColorPalette = props => {
53
57
  const colorsPerRow = React.useMemo(() => {
54
58
  return getColorsPerRowFromPalette(palette, cols);
55
59
  }, [palette, cols]);
56
- return jsx(React.Fragment, null, colorsPerRow.map((row, rowIdx) => jsx("div", {
60
+ return jsx(React.Fragment, null, colorsPerRow.map(row => jsx("div", {
57
61
  css: colorPaletteWrapper,
58
62
  className: className,
59
63
  key: `row-first-color-${row[0].value}`,
@@ -63,7 +67,7 @@ const ColorPalette = props => {
63
67
  label,
64
68
  border,
65
69
  message
66
- }, colorIdx) => {
70
+ }) => {
67
71
  if (showSomewhatSemanticTooltips && paletteColorTooltipMessages) {
68
72
  if (tokenTheme === 'dark') {
69
73
  message = getColorMessage(paletteColorTooltipMessages.dark, value.toUpperCase());
@@ -28,4 +28,17 @@ export function getSelectedRowAndColumn(colorsPerRow, selectedColor) {
28
28
  export function getSelectedRowAndColumnFromPalette(palette, selectedColor, cols = DEFAULT_COLOR_PICKER_COLUMNS) {
29
29
  const colorsPerRow = getColorsPerRowFromPalette(palette, cols);
30
30
  return getSelectedRowAndColumn(colorsPerRow, selectedColor);
31
- }
31
+ }
32
+ export const getTokenCSSVariableValue = variableExpression => {
33
+ const matcher = variableExpression.match(/var\(([^,\)]+)(,.*)?\)/);
34
+ if (matcher) {
35
+ const variable = matcher[1].trim();
36
+ const fallback = matcher[2] ? matcher[2].replace(',', '').trim() : '';
37
+ if (typeof document === 'undefined') {
38
+ return fallback;
39
+ }
40
+ const value = window.getComputedStyle(document.documentElement).getPropertyValue(variable).trim();
41
+ return value || fallback;
42
+ }
43
+ return '';
44
+ };
@@ -6,7 +6,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
6
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
7
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
8
8
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
9
- var packageVersion = "74.52.0";
9
+ var packageVersion = "74.52.1";
10
10
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
11
11
  // Remove URL as it has UGC
12
12
  // TODO: Sanitise the URL instead of just removing it
@@ -18,7 +18,7 @@ import { themed } from '@atlaskit/theme/components';
18
18
  import { borderRadius } from '@atlaskit/theme/constants';
19
19
  import Layer from '../Layer';
20
20
  var packageName = "@atlaskit/editor-common";
21
- var packageVersion = "74.52.0";
21
+ var packageVersion = "74.52.1";
22
22
  var halfFocusRing = 1;
23
23
  var dropOffset = '0, 8';
24
24
  var DropList = /*#__PURE__*/function (_Component) {
@@ -8,18 +8,22 @@ import { useThemeObserver } from '@atlaskit/tokens';
8
8
  import Color from './Color';
9
9
  import getColorMessage from './Palettes/getColorMessage';
10
10
  import { colorPaletteWrapper } from './styles';
11
- import { DEFAULT_COLOR_PICKER_COLUMNS, getColorsPerRowFromPalette } from './utils';
11
+ import { DEFAULT_COLOR_PICKER_COLUMNS, getColorsPerRowFromPalette, getTokenCSSVariableValue } from './utils';
12
12
  /**
13
13
  * For a given color pick the color from a list of colors with
14
14
  * the highest contrast
15
15
  *
16
- * @param color color string, suppports HEX, RGB, RGBA etc.
16
+ * @param color color string, supports HEX, RGB, RGBA etc.
17
+ * @param useIconToken boolean, describes if a token should be used for the icon color
17
18
  * @return Highest contrast color in pool
18
19
  */
19
20
  function getCheckMarkColor(color, useIconToken) {
21
+ var tokenVal = getTokenCSSVariableValue(color);
22
+ var colorValue = !!tokenVal ? tokenVal : color;
23
+
20
24
  // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
21
25
  var contrastColor = [N0, N500].sort(function (a, b) {
22
- return chromatism.difference(b, color) - chromatism.difference(a, color);
26
+ return chromatism.difference(b, colorValue) - chromatism.difference(a, colorValue);
23
27
  })[0];
24
28
  if (!useIconToken) {
25
29
  return contrastColor;
@@ -50,13 +54,13 @@ var ColorPalette = function ColorPalette(props) {
50
54
  var colorsPerRow = React.useMemo(function () {
51
55
  return getColorsPerRowFromPalette(palette, cols);
52
56
  }, [palette, cols]);
53
- return jsx(React.Fragment, null, colorsPerRow.map(function (row, rowIdx) {
57
+ return jsx(React.Fragment, null, colorsPerRow.map(function (row) {
54
58
  return jsx("div", {
55
59
  css: colorPaletteWrapper,
56
60
  className: className,
57
61
  key: "row-first-color-".concat(row[0].value),
58
62
  role: "radiogroup"
59
- }, row.map(function (_ref, colorIdx) {
63
+ }, row.map(function (_ref) {
60
64
  var value = _ref.value,
61
65
  label = _ref.label,
62
66
  border = _ref.border,
@@ -29,4 +29,17 @@ export function getSelectedRowAndColumnFromPalette(palette, selectedColor) {
29
29
  var cols = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_COLOR_PICKER_COLUMNS;
30
30
  var colorsPerRow = getColorsPerRowFromPalette(palette, cols);
31
31
  return getSelectedRowAndColumn(colorsPerRow, selectedColor);
32
- }
32
+ }
33
+ export var getTokenCSSVariableValue = function getTokenCSSVariableValue(variableExpression) {
34
+ var matcher = variableExpression.match(/var\(([^,\)]+)(,.*)?\)/);
35
+ if (matcher) {
36
+ var variable = matcher[1].trim();
37
+ var fallback = matcher[2] ? matcher[2].replace(',', '').trim() : '';
38
+ if (typeof document === 'undefined') {
39
+ return fallback;
40
+ }
41
+ var value = window.getComputedStyle(document.documentElement).getPropertyValue(variable).trim();
42
+ return value || fallback;
43
+ }
44
+ return '';
45
+ };
@@ -1,7 +1,7 @@
1
1
  /** @jsx jsx */
2
2
  import React from 'react';
3
- import { WrappedComponentProps } from 'react-intl-next';
4
- import { PaletteColor, PaletteTooltipMessages } from './Palettes/type';
3
+ import type { WrappedComponentProps } from 'react-intl-next';
4
+ import type { PaletteColor, PaletteTooltipMessages } from './Palettes/type';
5
5
  interface Props {
6
6
  selectedColor: string | null;
7
7
  onClick: (value: string, label: string) => void;
@@ -27,7 +27,7 @@ interface Props {
27
27
  * tooltip messages. Which is same as palette, where consumer determines which
28
28
  * colors ColorPalette should render.
29
29
  * Same way now consumer will determine which tooltip messages should
30
- * be used using paletteColorTooltipMessages option.
30
+ * be using paletteColorTooltipMessages option.
31
31
  */
32
32
  paletteColorTooltipMessages?: PaletteTooltipMessages;
33
33
  /**
@@ -39,12 +39,6 @@ interface Props {
39
39
  };
40
40
  }
41
41
  declare const _default: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
42
- WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>; /**
43
- * If hexToPaletteColor is passed, it will be called to convert
44
- * hexCodes passed in palette props to DST token.
45
- * Different color palette will set different mapping function.
46
- * Such as text and background color palette uses different
47
- * mapping function to map tokens.
48
- */
42
+ WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
49
43
  };
50
44
  export default _default;
@@ -1,4 +1,4 @@
1
- import { PaletteColor } from './Palettes/type';
1
+ import type { PaletteColor } from './Palettes/type';
2
2
  export declare const DEFAULT_COLOR_PICKER_COLUMNS = 7;
3
3
  export declare function getColorsPerRowFromPalette(palette: PaletteColor[], cols?: number): PaletteColor[][];
4
4
  export declare function getSelectedRowAndColumn(colorsPerRow: PaletteColor[][], selectedColor: string | null): {
@@ -9,3 +9,4 @@ export declare function getSelectedRowAndColumnFromPalette(palette: PaletteColor
9
9
  selectedRowIndex: number;
10
10
  selectedColumnIndex: number;
11
11
  };
12
+ export declare const getTokenCSSVariableValue: (variableExpression: string) => string;
@@ -1,7 +1,7 @@
1
1
  /** @jsx jsx */
2
2
  import React from 'react';
3
- import { WrappedComponentProps } from 'react-intl-next';
4
- import { PaletteColor, PaletteTooltipMessages } from './Palettes/type';
3
+ import type { WrappedComponentProps } from 'react-intl-next';
4
+ import type { PaletteColor, PaletteTooltipMessages } from './Palettes/type';
5
5
  interface Props {
6
6
  selectedColor: string | null;
7
7
  onClick: (value: string, label: string) => void;
@@ -27,7 +27,7 @@ interface Props {
27
27
  * tooltip messages. Which is same as palette, where consumer determines which
28
28
  * colors ColorPalette should render.
29
29
  * Same way now consumer will determine which tooltip messages should
30
- * be used using paletteColorTooltipMessages option.
30
+ * be using paletteColorTooltipMessages option.
31
31
  */
32
32
  paletteColorTooltipMessages?: PaletteTooltipMessages;
33
33
  /**
@@ -39,12 +39,6 @@ interface Props {
39
39
  };
40
40
  }
41
41
  declare const _default: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
42
- WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>; /**
43
- * If hexToPaletteColor is passed, it will be called to convert
44
- * hexCodes passed in palette props to DST token.
45
- * Different color palette will set different mapping function.
46
- * Such as text and background color palette uses different
47
- * mapping function to map tokens.
48
- */
42
+ WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
49
43
  };
50
44
  export default _default;
@@ -1,4 +1,4 @@
1
- import { PaletteColor } from './Palettes/type';
1
+ import type { PaletteColor } from './Palettes/type';
2
2
  export declare const DEFAULT_COLOR_PICKER_COLUMNS = 7;
3
3
  export declare function getColorsPerRowFromPalette(palette: PaletteColor[], cols?: number): PaletteColor[][];
4
4
  export declare function getSelectedRowAndColumn(colorsPerRow: PaletteColor[][], selectedColor: string | null): {
@@ -9,3 +9,4 @@ export declare function getSelectedRowAndColumnFromPalette(palette: PaletteColor
9
9
  selectedRowIndex: number;
10
10
  selectedColumnIndex: number;
11
11
  };
12
+ export declare const getTokenCSSVariableValue: (variableExpression: string) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.52.0",
3
+ "version": "74.52.1",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"