@atlaskit/status 3.0.2 → 3.0.3

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 (68) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/components/Status.js +26 -43
  3. package/dist/cjs/components/StatusPicker.js +10 -17
  4. package/dist/cjs/components/analytics.js +1 -1
  5. package/dist/cjs/components/internal/color-palette.js +32 -48
  6. package/dist/cjs/components/internal/color.js +19 -30
  7. package/dist/cjs/element.js +7 -5
  8. package/dist/cjs/index.js +13 -7
  9. package/dist/cjs/picker.js +7 -5
  10. package/dist/es2019/components/Status.js +21 -44
  11. package/dist/es2019/components/StatusPicker.js +9 -18
  12. package/dist/es2019/components/analytics.js +1 -1
  13. package/dist/es2019/components/internal/color-palette.js +25 -46
  14. package/dist/es2019/components/internal/color.js +15 -38
  15. package/dist/es2019/element.js +1 -5
  16. package/dist/es2019/index.js +2 -8
  17. package/dist/es2019/picker.js +1 -5
  18. package/dist/esm/components/Status.js +21 -44
  19. package/dist/esm/components/StatusPicker.js +9 -18
  20. package/dist/esm/components/analytics.js +1 -1
  21. package/dist/esm/components/internal/color-palette.js +32 -49
  22. package/dist/esm/components/internal/color.js +19 -30
  23. package/dist/esm/element.js +1 -5
  24. package/dist/esm/index.js +2 -8
  25. package/dist/esm/picker.js +1 -5
  26. package/dist/types/components/internal/color-palette.d.ts +2 -2
  27. package/dist/types/components/internal/color.d.ts +2 -3
  28. package/dist/types/element.d.ts +1 -3
  29. package/dist/types/index.d.ts +2 -6
  30. package/dist/types/picker.d.ts +1 -5
  31. package/dist/types-ts4.5/components/internal/color-palette.d.ts +2 -2
  32. package/dist/types-ts4.5/components/internal/color.d.ts +2 -3
  33. package/dist/types-ts4.5/element.d.ts +1 -3
  34. package/dist/types-ts4.5/index.d.ts +2 -6
  35. package/dist/types-ts4.5/picker.d.ts +1 -5
  36. package/package.json +2 -2
  37. package/dist/cjs/components/compiled/Status.js +0 -132
  38. package/dist/cjs/components/compiled/StatusPicker.js +0 -116
  39. package/dist/cjs/components/compiled/internal/color-palette.js +0 -105
  40. package/dist/cjs/components/compiled/internal/color.js +0 -121
  41. package/dist/es2019/components/compiled/Status.js +0 -110
  42. package/dist/es2019/components/compiled/StatusPicker.js +0 -86
  43. package/dist/es2019/components/compiled/internal/color-palette.js +0 -78
  44. package/dist/es2019/components/compiled/internal/color.js +0 -90
  45. package/dist/esm/components/compiled/Status.js +0 -122
  46. package/dist/esm/components/compiled/StatusPicker.js +0 -106
  47. package/dist/esm/components/compiled/internal/color-palette.js +0 -95
  48. package/dist/esm/components/compiled/internal/color.js +0 -112
  49. package/dist/types/components/compiled/Status.d.ts +0 -16
  50. package/dist/types/components/compiled/StatusPicker.d.ts +0 -16
  51. package/dist/types/components/compiled/internal/color-palette.d.ts +0 -11
  52. package/dist/types/components/compiled/internal/color.d.ts +0 -22
  53. package/dist/types-ts4.5/components/compiled/Status.d.ts +0 -16
  54. package/dist/types-ts4.5/components/compiled/StatusPicker.d.ts +0 -16
  55. package/dist/types-ts4.5/components/compiled/internal/color-palette.d.ts +0 -11
  56. package/dist/types-ts4.5/components/compiled/internal/color.d.ts +0 -22
  57. /package/dist/cjs/components/{compiled/Status.compiled.css → Status.compiled.css} +0 -0
  58. /package/dist/cjs/components/{compiled/StatusPicker.compiled.css → StatusPicker.compiled.css} +0 -0
  59. /package/dist/cjs/components/{compiled/internal → internal}/color-palette.compiled.css +0 -0
  60. /package/dist/cjs/components/{compiled/internal → internal}/color.compiled.css +0 -0
  61. /package/dist/es2019/components/{compiled/Status.compiled.css → Status.compiled.css} +0 -0
  62. /package/dist/es2019/components/{compiled/StatusPicker.compiled.css → StatusPicker.compiled.css} +0 -0
  63. /package/dist/es2019/components/{compiled/internal → internal}/color-palette.compiled.css +0 -0
  64. /package/dist/es2019/components/{compiled/internal → internal}/color.compiled.css +0 -0
  65. /package/dist/esm/components/{compiled/Status.compiled.css → Status.compiled.css} +0 -0
  66. /package/dist/esm/components/{compiled/StatusPicker.compiled.css → StatusPicker.compiled.css} +0 -0
  67. /package/dist/esm/components/{compiled/internal → internal}/color-palette.compiled.css +0 -0
  68. /package/dist/esm/components/{compiled/internal → internal}/color.compiled.css +0 -0
@@ -1,110 +0,0 @@
1
- /* Status.tsx generated by @compiled/babel-plugin v0.36.1 */
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import "./Status.compiled.css";
4
- import * as React from 'react';
5
- import { ax, ix } from "@compiled/react/runtime";
6
- import { PureComponent } from 'react';
7
- import Lozenge from '@atlaskit/lozenge/compiled';
8
- import { withAnalyticsEvents } from '@atlaskit/analytics-next';
9
- import { createStatusAnalyticsAndFire } from '../analytics';
10
- import { ANALYTICS_HOVER_DELAY } from '../constants';
11
- const colorToLozengeAppearanceMap = {
12
- neutral: 'default',
13
- purple: 'new',
14
- blue: 'inprogress',
15
- red: 'removed',
16
- yellow: 'moved',
17
- green: 'success'
18
- };
19
- const DEFAULT_APPEARANCE = 'default';
20
- const MAX_WIDTH = 200;
21
-
22
- /**
23
- * This is to account for a bug in android chromium and should be removed
24
- * when the editor fixes its focus handling with respect to Status.
25
- *
26
- * See DSP-7701 for additional context.
27
- */
28
- const inlineBlockStyles = null;
29
-
30
- // eg. Version/4.0 Chrome/95.0.4638.50
31
- const isAndroidChromium = typeof window !== 'undefined' && /Version\/.* Chrome\/.*/.test(window.navigator.userAgent);
32
- class StatusInternal extends PureComponent {
33
- constructor(...args) {
34
- super(...args);
35
- _defineProperty(this, "hoverStartTime", 0);
36
- _defineProperty(this, "handleMouseEnter", _e => {
37
- this.hoverStartTime = Date.now();
38
- });
39
- _defineProperty(this, "handleMouseLeave", _e => {
40
- const {
41
- onHover
42
- } = this.props;
43
- const delay = Date.now() - this.hoverStartTime;
44
- if (delay >= ANALYTICS_HOVER_DELAY && onHover) {
45
- onHover();
46
- }
47
- this.hoverStartTime = 0;
48
- });
49
- }
50
- componentWillUnmount() {
51
- this.hoverStartTime = 0;
52
- }
53
- render() {
54
- const {
55
- text,
56
- color,
57
- style,
58
- role,
59
- onClick,
60
- isBold
61
- } = this.props;
62
- if (text.trim().length === 0) {
63
- return null;
64
- }
65
- const appearance = colorToLozengeAppearanceMap[color] || DEFAULT_APPEARANCE;
66
- // Note: ommitted data-local-id attribute to avoid copying/pasting the same localId
67
- return /*#__PURE__*/React.createElement("span", {
68
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
69
- className: ax([isAndroidChromium && "_d0dzdf4r _1k0l7vkz _1frxnkob", "status-lozenge-span"]),
70
- onClick: onClick,
71
- onMouseEnter: this.handleMouseEnter,
72
- onMouseLeave: this.handleMouseLeave,
73
- "data-node-type": "status",
74
- "data-color": color,
75
- "data-style": style,
76
- role: role
77
- }, /*#__PURE__*/React.createElement(Lozenge, {
78
- appearance: appearance,
79
- maxWidth: MAX_WIDTH,
80
- isBold: isBold
81
- }, text));
82
- }
83
- }
84
- _defineProperty(StatusInternal, "displayName", 'StatusInternal');
85
- export const Status = withAnalyticsEvents({
86
- onClick: (createEvent, props) => {
87
- const {
88
- localId
89
- } = props;
90
- return createStatusAnalyticsAndFire(createEvent)({
91
- action: 'clicked',
92
- actionSubject: 'statusLozenge',
93
- attributes: {
94
- localId
95
- }
96
- });
97
- },
98
- onHover: (createEvent, props) => {
99
- const {
100
- localId
101
- } = props;
102
- return createStatusAnalyticsAndFire(createEvent)({
103
- action: 'hovered',
104
- actionSubject: 'statusLozenge',
105
- attributes: {
106
- localId
107
- }
108
- });
109
- }
110
- })(StatusInternal);
@@ -1,86 +0,0 @@
1
- /* StatusPicker.tsx generated by @compiled/babel-plugin v0.36.1 */
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import "./StatusPicker.compiled.css";
4
- import { ax, ix } from "@compiled/react/runtime";
5
- import TextField from '@atlaskit/textfield';
6
- import React, { PureComponent } from 'react';
7
- import { injectIntl } from 'react-intl-next';
8
- import ColorPalette from './internal/color-palette';
9
- import { messages } from '../i18n';
10
- const fieldTextWrapperStyles = null;
11
- class Picker extends PureComponent {
12
- constructor(...args) {
13
- super(...args);
14
- _defineProperty(this, "fieldTextWrapperKey", Math.random().toString());
15
- _defineProperty(this, "colorPaletteKey", Math.random().toString());
16
- _defineProperty(this, "onChange", evt => {
17
- // @ts-ignore
18
- this.props.onTextChanged(evt.target.value);
19
- });
20
- _defineProperty(this, "onKeyPress", event => {
21
- if (event.key === 'Enter') {
22
- this.props.onEnter();
23
- }
24
- });
25
- _defineProperty(this, "handleInputRef", ref => {
26
- this.inputRef = ref;
27
- if (ref && this.props.autoFocus) {
28
- this.focusInput();
29
- }
30
- });
31
- _defineProperty(this, "focusInput", () => {
32
- if (!this.inputRef) {
33
- return;
34
- }
35
- // Defer to prevent editor scrolling to top
36
- this.autofocusTimeout = setTimeout(() => {
37
- var _this$inputRef;
38
- (_this$inputRef = this.inputRef) === null || _this$inputRef === void 0 ? void 0 : _this$inputRef.focus();
39
- });
40
- });
41
- }
42
- render() {
43
- const {
44
- text,
45
- selectedColor,
46
- onColorClick,
47
- onColorHover,
48
- intl
49
- } = this.props;
50
-
51
- // Using <React.Fragment> instead of [] to workaround Enzyme
52
- // (https://github.com/airbnb/enzyme/issues/1149)
53
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
54
- key: this.fieldTextWrapperKey,
55
- className: ax(["_19pkidpf _otyridpf _2hwxu2gc _18u0u2gc _n6347jlr"])
56
- }, /*#__PURE__*/React.createElement(TextField, {
57
- value: text,
58
- isCompact: true,
59
- ref: this.handleInputRef,
60
- onChange: this.onChange,
61
- onKeyPress: this.onKeyPress,
62
- spellCheck: false,
63
- autoComplete: "off",
64
- "aria-label": intl.formatMessage(messages.statusInputLabel)
65
- })), /*#__PURE__*/React.createElement(ColorPalette, {
66
- key: this.colorPaletteKey,
67
- onClick: onColorClick,
68
- onHover: onColorHover,
69
- selectedColor: selectedColor
70
- }));
71
- }
72
- componentDidUpdate() {
73
- if (this.inputRef && this.props.autoFocus) {
74
- this.focusInput();
75
- }
76
- }
77
- componentWillUnmount() {
78
- if (this.autofocusTimeout !== undefined) {
79
- clearTimeout(this.autofocusTimeout);
80
- }
81
- }
82
- }
83
- _defineProperty(Picker, "defaultProps", {
84
- autoFocus: true
85
- });
86
- export const StatusPicker = injectIntl(Picker);
@@ -1,78 +0,0 @@
1
- /* color-palette.tsx generated by @compiled/babel-plugin v0.36.1 */
2
- import "./color-palette.compiled.css";
3
- import { ax, ix } from "@compiled/react/runtime";
4
- import React, { useEffect, useRef, useCallback, useState } from 'react';
5
- import Color from './color';
6
- import { fg } from '@atlaskit/platform-feature-flags';
7
- const paletteLegacy = [['neutral', "var(--ds-background-neutral, #091E420F)", "var(--ds-border-bold, #758195)", "var(--ds-icon, #44546F)"], ['purple', "var(--ds-background-discovery, #F3F0FF)", "var(--ds-border-discovery, #8270DB)", "var(--ds-icon-discovery, #8270DB)"], ['blue', "var(--ds-background-information, #E9F2FF)", "var(--ds-border-information, #1D7AFC)", "var(--ds-icon-information, #1D7AFC)"], ['red', "var(--ds-background-danger, #FFECEB)", "var(--ds-border-danger, #E2483D)", "var(--ds-icon-danger, #C9372C)"], ['yellow', "var(--ds-background-warning, #FFF7D6)", "var(--ds-border-warning, #E56910)", "var(--ds-icon-warning, #E56910)"], ['green', "var(--ds-background-success, #DCFFF1)", "var(--ds-border-success, #22A06B)", "var(--ds-icon-success, #22A06B)"]];
8
- const paletteRefreshed = [['neutral', "var(--ds-background-accent-gray-subtler, #DCDFE4)", "var(--ds-border-bold, #758195)", "var(--ds-icon, #44546F)"], ['blue', "var(--ds-background-information-pressed, #85B8FF)", "var(--ds-border-information, #1D7AFC)", "var(--ds-icon, #44546F)"], ['green', "var(--ds-background-success-pressed, #7EE2B8)", "var(--ds-border-success, #22A06B)", "var(--ds-icon, #44546F)"], ['yellow', "var(--ds-background-warning-pressed, #F5CD47)", "var(--ds-border-warning, #E56910)", "var(--ds-icon, #44546F)"], ['red', "var(--ds-background-danger-pressed, #FD9891)", "var(--ds-border-danger, #E2483D)", "var(--ds-icon, #44546F)"], ['purple', "var(--ds-background-discovery-pressed, #B8ACF6)", "var(--ds-border-discovery, #8270DB)", "var(--ds-icon, #44546F)"]];
9
- const getPalette = () => fg('platform-component-visual-refresh') ? paletteRefreshed : paletteLegacy;
10
- const palette = getPalette();
11
-
12
- // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage, @atlaskit/design-system/no-css-tagged-template-expression -- Ignored via go/DSP-18766
13
- const colorPaletteWrapperStyles = null;
14
- const VK_LEFT = 37; //ArrowLeft
15
- const VK_RIGHT = 39; //ArrowRight
16
- const VK_UP = 38; //ArrowUp
17
- const VK_DOWN = 40; //ArrowDown
18
- const VK_TAB = 9;
19
- export default (({
20
- cols = 7,
21
- onClick,
22
- selectedColor,
23
- className,
24
- onHover
25
- }) => {
26
- const colorRefs = useRef([]);
27
- const [currentFocusedColor, setCurrentFocusedColor] = useState(0);
28
- useEffect(() => {
29
- colorRefs.current = colorRefs.current.slice(0, palette.length);
30
- }, []);
31
- const memoizedHandleKeyDown = useCallback(e => {
32
- let newColorIndex = null;
33
- const nextColor = () => currentFocusedColor + 1 > palette.length - 1 ? 0 : currentFocusedColor + 1;
34
- const previousColor = () => currentFocusedColor - 1 < 0 ? palette.length - 1 : currentFocusedColor - 1;
35
- switch (e.keyCode) {
36
- case VK_RIGHT:
37
- case VK_DOWN:
38
- e.preventDefault();
39
- newColorIndex = nextColor();
40
- break;
41
- case VK_LEFT:
42
- case VK_UP:
43
- e.preventDefault();
44
- newColorIndex = previousColor();
45
- break;
46
- case VK_TAB:
47
- setCurrentFocusedColor(0);
48
- break;
49
- }
50
- if (newColorIndex === null) {
51
- return;
52
- }
53
- setCurrentFocusedColor(newColorIndex);
54
- const newRef = colorRefs.current[newColorIndex];
55
- newRef === null || newRef === void 0 ? void 0 : newRef.focus();
56
- }, [currentFocusedColor, setCurrentFocusedColor, colorRefs]);
57
- return /*#__PURE__*/React.createElement("ul", {
58
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
59
- className: ax(["_19bvidpf _19pku2gc _2hwxu2gc _otyridpf _18u0u2gc _1e0c1txw _1n261g80", className]),
60
- style: {
61
- maxWidth: cols * 32
62
- },
63
- onKeyDown: memoizedHandleKeyDown
64
- }, palette.map(([colorValue, backgroundColor, borderColor, iconColor], i) => {
65
- return /*#__PURE__*/React.createElement(Color, {
66
- key: colorValue,
67
- value: colorValue,
68
- backgroundColor: backgroundColor,
69
- borderColor: borderColor,
70
- iconColor: iconColor,
71
- onClick: onClick,
72
- onHover: onHover,
73
- isSelected: colorValue === selectedColor,
74
- tabIndex: i === 0 ? 0 : -1,
75
- setRef: el => colorRefs.current[i] = el
76
- });
77
- }));
78
- });
@@ -1,90 +0,0 @@
1
- /* color.tsx generated by @compiled/babel-plugin v0.36.1 */
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import "./color.compiled.css";
4
- import * as React from 'react';
5
- import { ax, ix } from "@compiled/react/runtime";
6
- import EditorDoneIcon from '@atlaskit/icon/core/migration/check-mark--editor-done';
7
- import { Pressable } from '@atlaskit/primitives/compiled';
8
- import { PureComponent } from 'react';
9
- import { FormattedMessage } from 'react-intl-next';
10
- import { ANALYTICS_HOVER_DELAY } from '../../constants';
11
- import { messages } from '../../i18n';
12
- const styles = {
13
- button: "_2rkoglpi _19it7r9e _1reo15vq _18m915vq _4t3i1tcg _1bsb1tcg _bfhkm7j4 _ca0qze3t _u5f3ze3t _n3tdze3t _19bvze3t _1e0c1ule"
14
- };
15
-
16
- // We have tried with changing border and padding from 1px to token near version 2px,
17
- // the pop - up is being expanded to two lines.
18
- const buttonWrapperStyles = null;
19
- export default class Color extends PureComponent {
20
- constructor(...args) {
21
- super(...args);
22
- _defineProperty(this, "hoverStartTime", 0);
23
- _defineProperty(this, "onMouseEnter", () => {
24
- this.hoverStartTime = Date.now();
25
- });
26
- _defineProperty(this, "onMouseLeave", () => {
27
- const {
28
- onHover
29
- } = this.props;
30
- const delay = Date.now() - this.hoverStartTime;
31
- if (delay >= ANALYTICS_HOVER_DELAY && onHover) {
32
- onHover(this.props.value);
33
- }
34
- this.hoverStartTime = 0;
35
- });
36
- _defineProperty(this, "onMouseDown", e => {
37
- e.preventDefault();
38
- });
39
- _defineProperty(this, "onClick", e => {
40
- const {
41
- onClick,
42
- value
43
- } = this.props;
44
- e.preventDefault();
45
- onClick(value);
46
- });
47
- }
48
- render() {
49
- const {
50
- tabIndex,
51
- backgroundColor,
52
- isSelected,
53
- borderColor,
54
- iconColor,
55
- value,
56
- setRef
57
- } = this.props;
58
- return /*#__PURE__*/React.createElement("li", {
59
- className: ax(["_ca0qt94y _u5f3t94y _n3tdt94y _19bvt94y _2rko12x7 _189et94y _1dqonqa1 _1h6d1j28 _19pkidpf _2hwxv77o _otyridpf _18u0v77o _1e0c1txw _4cvr1h6o _bfw7zgxb"])
60
- }, /*#__PURE__*/React.createElement(FormattedMessage, messages[`${value}Color`], labels => /*#__PURE__*/React.createElement(Pressable, {
61
- xcss: styles.button,
62
- onClick: this.onClick,
63
- onMouseEnter: this.onMouseEnter,
64
- onMouseLeave: this.onMouseLeave,
65
- onMouseDown: this.onMouseDown,
66
- tabIndex: tabIndex,
67
- title: labels[0]
68
- // button element does not support aria-selected.
69
- // For button selected (to be precise pressed) or not
70
- // use aria-pressed as per
71
- // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role#associated_aria_roles_states_and_properties
72
- ,
73
- "aria-pressed": isSelected,
74
- style: {
75
- backgroundColor: backgroundColor || 'transparent',
76
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
77
- color: iconColor,
78
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
79
- borderColor
80
- },
81
- ref: setRef
82
- }, isSelected && /*#__PURE__*/React.createElement(EditorDoneIcon, {
83
- color: "currentColor",
84
- label: labels[0]
85
- }))));
86
- }
87
- componentWillUnmount() {
88
- this.hoverStartTime = 0;
89
- }
90
- }
@@ -1,122 +0,0 @@
1
- /* Status.tsx generated by @compiled/babel-plugin v0.36.1 */
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- import _inherits from "@babel/runtime/helpers/inherits";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- import "./Status.compiled.css";
9
- import * as React from 'react';
10
- import { ax, ix } from "@compiled/react/runtime";
11
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
12
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
- import { PureComponent } from 'react';
14
- import Lozenge from '@atlaskit/lozenge/compiled';
15
- import { withAnalyticsEvents } from '@atlaskit/analytics-next';
16
- import { createStatusAnalyticsAndFire } from '../analytics';
17
- import { ANALYTICS_HOVER_DELAY } from '../constants';
18
- var colorToLozengeAppearanceMap = {
19
- neutral: 'default',
20
- purple: 'new',
21
- blue: 'inprogress',
22
- red: 'removed',
23
- yellow: 'moved',
24
- green: 'success'
25
- };
26
- var DEFAULT_APPEARANCE = 'default';
27
- var MAX_WIDTH = 200;
28
-
29
- /**
30
- * This is to account for a bug in android chromium and should be removed
31
- * when the editor fixes its focus handling with respect to Status.
32
- *
33
- * See DSP-7701 for additional context.
34
- */
35
- var inlineBlockStyles = null;
36
-
37
- // eg. Version/4.0 Chrome/95.0.4638.50
38
- var isAndroidChromium = typeof window !== 'undefined' && /Version\/.* Chrome\/.*/.test(window.navigator.userAgent);
39
- var StatusInternal = /*#__PURE__*/function (_PureComponent) {
40
- function StatusInternal() {
41
- var _this;
42
- _classCallCheck(this, StatusInternal);
43
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
44
- args[_key] = arguments[_key];
45
- }
46
- _this = _callSuper(this, StatusInternal, [].concat(args));
47
- _defineProperty(_this, "hoverStartTime", 0);
48
- _defineProperty(_this, "handleMouseEnter", function (_e) {
49
- _this.hoverStartTime = Date.now();
50
- });
51
- _defineProperty(_this, "handleMouseLeave", function (_e) {
52
- var onHover = _this.props.onHover;
53
- var delay = Date.now() - _this.hoverStartTime;
54
- if (delay >= ANALYTICS_HOVER_DELAY && onHover) {
55
- onHover();
56
- }
57
- _this.hoverStartTime = 0;
58
- });
59
- return _this;
60
- }
61
- _inherits(StatusInternal, _PureComponent);
62
- return _createClass(StatusInternal, [{
63
- key: "componentWillUnmount",
64
- value: function componentWillUnmount() {
65
- this.hoverStartTime = 0;
66
- }
67
- }, {
68
- key: "render",
69
- value: function render() {
70
- var _this$props = this.props,
71
- text = _this$props.text,
72
- color = _this$props.color,
73
- style = _this$props.style,
74
- role = _this$props.role,
75
- onClick = _this$props.onClick,
76
- isBold = _this$props.isBold;
77
- if (text.trim().length === 0) {
78
- return null;
79
- }
80
- var appearance = colorToLozengeAppearanceMap[color] || DEFAULT_APPEARANCE;
81
- // Note: ommitted data-local-id attribute to avoid copying/pasting the same localId
82
- return /*#__PURE__*/React.createElement("span", {
83
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
84
- className: ax([isAndroidChromium && "_d0dzdf4r _1k0l7vkz _1frxnkob", "status-lozenge-span"]),
85
- onClick: onClick,
86
- onMouseEnter: this.handleMouseEnter,
87
- onMouseLeave: this.handleMouseLeave,
88
- "data-node-type": "status",
89
- "data-color": color,
90
- "data-style": style,
91
- role: role
92
- }, /*#__PURE__*/React.createElement(Lozenge, {
93
- appearance: appearance,
94
- maxWidth: MAX_WIDTH,
95
- isBold: isBold
96
- }, text));
97
- }
98
- }]);
99
- }(PureComponent);
100
- _defineProperty(StatusInternal, "displayName", 'StatusInternal');
101
- export var Status = withAnalyticsEvents({
102
- onClick: function onClick(createEvent, props) {
103
- var localId = props.localId;
104
- return createStatusAnalyticsAndFire(createEvent)({
105
- action: 'clicked',
106
- actionSubject: 'statusLozenge',
107
- attributes: {
108
- localId: localId
109
- }
110
- });
111
- },
112
- onHover: function onHover(createEvent, props) {
113
- var localId = props.localId;
114
- return createStatusAnalyticsAndFire(createEvent)({
115
- action: 'hovered',
116
- actionSubject: 'statusLozenge',
117
- attributes: {
118
- localId: localId
119
- }
120
- });
121
- }
122
- })(StatusInternal);
@@ -1,106 +0,0 @@
1
- /* StatusPicker.tsx generated by @compiled/babel-plugin v0.36.1 */
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- import _inherits from "@babel/runtime/helpers/inherits";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- import "./StatusPicker.compiled.css";
9
- import { ax, ix } from "@compiled/react/runtime";
10
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
12
- import TextField from '@atlaskit/textfield';
13
- import React, { PureComponent } from 'react';
14
- import { injectIntl } from 'react-intl-next';
15
- import ColorPalette from './internal/color-palette';
16
- import { messages } from '../i18n';
17
- var fieldTextWrapperStyles = null;
18
- var Picker = /*#__PURE__*/function (_PureComponent) {
19
- function Picker() {
20
- var _this;
21
- _classCallCheck(this, Picker);
22
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
23
- args[_key] = arguments[_key];
24
- }
25
- _this = _callSuper(this, Picker, [].concat(args));
26
- _defineProperty(_this, "fieldTextWrapperKey", Math.random().toString());
27
- _defineProperty(_this, "colorPaletteKey", Math.random().toString());
28
- _defineProperty(_this, "onChange", function (evt) {
29
- // @ts-ignore
30
- _this.props.onTextChanged(evt.target.value);
31
- });
32
- _defineProperty(_this, "onKeyPress", function (event) {
33
- if (event.key === 'Enter') {
34
- _this.props.onEnter();
35
- }
36
- });
37
- _defineProperty(_this, "handleInputRef", function (ref) {
38
- _this.inputRef = ref;
39
- if (ref && _this.props.autoFocus) {
40
- _this.focusInput();
41
- }
42
- });
43
- _defineProperty(_this, "focusInput", function () {
44
- if (!_this.inputRef) {
45
- return;
46
- }
47
- // Defer to prevent editor scrolling to top
48
- _this.autofocusTimeout = setTimeout(function () {
49
- var _this$inputRef;
50
- (_this$inputRef = _this.inputRef) === null || _this$inputRef === void 0 || _this$inputRef.focus();
51
- });
52
- });
53
- return _this;
54
- }
55
- _inherits(Picker, _PureComponent);
56
- return _createClass(Picker, [{
57
- key: "render",
58
- value: function render() {
59
- var _this$props = this.props,
60
- text = _this$props.text,
61
- selectedColor = _this$props.selectedColor,
62
- onColorClick = _this$props.onColorClick,
63
- onColorHover = _this$props.onColorHover,
64
- intl = _this$props.intl;
65
-
66
- // Using <React.Fragment> instead of [] to workaround Enzyme
67
- // (https://github.com/airbnb/enzyme/issues/1149)
68
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
69
- key: this.fieldTextWrapperKey,
70
- className: ax(["_19pkidpf _otyridpf _2hwxu2gc _18u0u2gc _n6347jlr"])
71
- }, /*#__PURE__*/React.createElement(TextField, {
72
- value: text,
73
- isCompact: true,
74
- ref: this.handleInputRef,
75
- onChange: this.onChange,
76
- onKeyPress: this.onKeyPress,
77
- spellCheck: false,
78
- autoComplete: "off",
79
- "aria-label": intl.formatMessage(messages.statusInputLabel)
80
- })), /*#__PURE__*/React.createElement(ColorPalette, {
81
- key: this.colorPaletteKey,
82
- onClick: onColorClick,
83
- onHover: onColorHover,
84
- selectedColor: selectedColor
85
- }));
86
- }
87
- }, {
88
- key: "componentDidUpdate",
89
- value: function componentDidUpdate() {
90
- if (this.inputRef && this.props.autoFocus) {
91
- this.focusInput();
92
- }
93
- }
94
- }, {
95
- key: "componentWillUnmount",
96
- value: function componentWillUnmount() {
97
- if (this.autofocusTimeout !== undefined) {
98
- clearTimeout(this.autofocusTimeout);
99
- }
100
- }
101
- }]);
102
- }(PureComponent);
103
- _defineProperty(Picker, "defaultProps", {
104
- autoFocus: true
105
- });
106
- export var StatusPicker = injectIntl(Picker);