@atlaskit/mention 27.5.2 → 27.6.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @atlaskit/mention
2
2
 
3
+ ## 27.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`2aa9853a2c07d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2aa9853a2c07d) -
8
+ `ResourcedMention` and the editor-common `Mention` now accept an `isDisabled` (and
9
+ `disabledTooltip`) prop, forwarding the disabled mention visual state through the layered mention
10
+ components. A disabled mention bypasses the profile-card wrapper as it is non-interactive, while
11
+ retaining a readable neutral visual treatment so meaningful mention text remains perceivable.
12
+
13
+ Example usage:
14
+
15
+ ```tsx
16
+ <Mention
17
+ id="agent-2"
18
+ text="@Researcher"
19
+ isDisabled
20
+ disabledTooltip="Only one agent can be active at a time"
21
+ />
22
+ ```
23
+
24
+ Used in Rovo chat to grey out inactive (non-responding) agent @mentions in sent user messages: the
25
+ agent that responded to the turn stays fully styled while other mentioned agents render disabled.
26
+
3
27
  ## 27.5.2
4
28
 
5
29
  ### Patch Changes
@@ -8,10 +8,9 @@ exports.default = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
10
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
11
  var _react = require("@emotion/react");
13
- var _types = require("../../types");
14
12
  var _react2 = require("react");
13
+ var _mentionStyle = require("./mention-style");
15
14
  var _templateObject;
16
15
  var _excluded = ["mentionType"];
17
16
  /* eslint-disable @atlaskit/design-system/no-html-button */
@@ -20,36 +19,9 @@ var _excluded = ["mentionType"];
20
19
  * @jsx jsx
21
20
  */
22
21
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
23
- var mentionStyle = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _types.MentionType.SELF, {
24
- background: "var(--ds-background-brand-bold, #1868DB)",
25
- borderColor: 'transparent',
26
- text: "var(--ds-text-inverse, #FFFFFF)",
27
- hoveredBackground: "var(--ds-background-brand-bold-hovered, #1558BC)",
28
- pressedBackground: "var(--ds-background-brand-bold-pressed, #144794)"
29
- }), _types.MentionType.RESTRICTED, {
30
- background: 'transparent',
31
- borderColor: "var(--ds-border-bold, #7D818A)",
32
- text: "var(--ds-text, #292A2E)",
33
- hoveredBackground: 'transparent',
34
- pressedBackground: 'transparent'
35
- }), _types.MentionType.DEFAULT, {
36
- background: "var(--ds-background-neutral, #0515240F)",
37
- borderColor: 'transparent',
38
- text: "var(--ds-text-subtle, #505258)",
39
- hoveredBackground: "var(--ds-background-neutral-hovered, #0B120E24)",
40
- pressedBackground: "var(--ds-background-neutral-pressed, #080F214A)"
41
- }), _types.MentionType.DISABLED, {
42
- background: "var(--ds-background-disabled, #0515240F)",
43
- borderColor: 'transparent',
44
- text: "var(--ds-text-disabled, #080F214A)",
45
- // Disabled chips do not change on hover / press.
46
- hoveredBackground: "var(--ds-background-disabled, #0515240F)",
47
- pressedBackground: "var(--ds-background-disabled, #0515240F)"
48
- });
49
22
  var getStyle = function getStyle(_ref, property) {
50
23
  var mentionType = _ref.mentionType;
51
- var obj = mentionStyle[mentionType][property];
52
- return typeof obj === 'string' ? obj : obj;
24
+ return _mentionStyle.mentionStyle[mentionType][property];
53
25
  };
54
26
  var PrimitiveMention = /*#__PURE__*/(0, _react2.forwardRef)(function (_ref2, ref) {
55
27
  var mentionType = _ref2.mentionType,
@@ -120,6 +120,8 @@ var ResourcedMention = exports.default = /*#__PURE__*/function (_React$PureCompo
120
120
  id: props.id,
121
121
  text: props.text || state.resolvedMentionName || '',
122
122
  isHighlighted: state.isHighlighted,
123
+ isDisabled: props.isDisabled,
124
+ disabledTooltip: props.disabledTooltip,
123
125
  accessLevel: props.accessLevel,
124
126
  localId: props.localId,
125
127
  onClick: props.onClick,
@@ -148,7 +148,8 @@ var MentionInternal = exports.MentionInternal = /*#__PURE__*/function (_React$Pu
148
148
  // `aria-describedby`.
149
149
  var isDisabledChip = mentionType === _types.MentionType.DISABLED;
150
150
  var disabledA11yProps = isDisabledChip ? _objectSpread({
151
- 'aria-disabled': true
151
+ 'aria-disabled': true,
152
+ tabIndex: 0
152
153
  }, disabledTooltip ? {
153
154
  'aria-label': "".concat(text || '@...', " \u2014 ").concat(disabledTooltip)
154
155
  } : {}) : {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.mentionStyle = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _types = require("../../types");
10
+ var mentionStyle = exports.mentionStyle = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _types.MentionType.SELF, {
11
+ background: "var(--ds-background-brand-bold, #1868DB)",
12
+ borderColor: 'transparent',
13
+ text: "var(--ds-text-inverse, #FFFFFF)",
14
+ hoveredBackground: "var(--ds-background-brand-bold-hovered, #1558BC)",
15
+ pressedBackground: "var(--ds-background-brand-bold-pressed, #144794)"
16
+ }), _types.MentionType.RESTRICTED, {
17
+ background: 'transparent',
18
+ borderColor: "var(--ds-border-bold, #7D818A)",
19
+ text: "var(--ds-text, #292A2E)",
20
+ hoveredBackground: 'transparent',
21
+ pressedBackground: 'transparent'
22
+ }), _types.MentionType.DEFAULT, {
23
+ background: "var(--ds-background-neutral, #0515240F)",
24
+ borderColor: 'transparent',
25
+ text: "var(--ds-text-subtle, #505258)",
26
+ hoveredBackground: "var(--ds-background-neutral-hovered, #0B120E24)",
27
+ pressedBackground: "var(--ds-background-neutral-pressed, #080F214A)"
28
+ }), _types.MentionType.DISABLED, {
29
+ background: "var(--ds-background-disabled, #0515240F)",
30
+ borderColor: 'transparent',
31
+ text: "var(--ds-text-disabled, #080F214A)",
32
+ // Disabled chips do not change on hover / press.
33
+ hoveredBackground: "var(--ds-background-disabled, #0515240F)",
34
+ pressedBackground: "var(--ds-background-disabled, #0515240F)"
35
+ });
@@ -12,7 +12,7 @@ var _types = require("../types");
12
12
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
13
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
14
  var packageName = "@atlaskit/mention";
15
- var packageVersion = "27.5.1";
15
+ var packageVersion = "27.5.2";
16
16
  var SLI_EVENT_TYPE = exports.SLI_EVENT_TYPE = 'sli';
17
17
  var SMART_EVENT_TYPE = exports.SMART_EVENT_TYPE = 'smart';
18
18
  var fireAnalyticsMentionTypeaheadEvent = exports.fireAnalyticsMentionTypeaheadEvent = function fireAnalyticsMentionTypeaheadEvent(props) {
@@ -6,45 +6,11 @@ import _extends from "@babel/runtime/helpers/extends";
6
6
  */
7
7
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
8
8
  import { jsx, css } from '@emotion/react';
9
- import { MentionType } from '../../types';
10
9
  import { forwardRef } from 'react';
11
- const mentionStyle = {
12
- [MentionType.SELF]: {
13
- background: "var(--ds-background-brand-bold, #1868DB)",
14
- borderColor: 'transparent',
15
- text: "var(--ds-text-inverse, #FFFFFF)",
16
- hoveredBackground: "var(--ds-background-brand-bold-hovered, #1558BC)",
17
- pressedBackground: "var(--ds-background-brand-bold-pressed, #144794)"
18
- },
19
- [MentionType.RESTRICTED]: {
20
- background: 'transparent',
21
- borderColor: "var(--ds-border-bold, #7D818A)",
22
- text: "var(--ds-text, #292A2E)",
23
- hoveredBackground: 'transparent',
24
- pressedBackground: 'transparent'
25
- },
26
- [MentionType.DEFAULT]: {
27
- background: "var(--ds-background-neutral, #0515240F)",
28
- borderColor: 'transparent',
29
- text: "var(--ds-text-subtle, #505258)",
30
- hoveredBackground: "var(--ds-background-neutral-hovered, #0B120E24)",
31
- pressedBackground: "var(--ds-background-neutral-pressed, #080F214A)"
32
- },
33
- [MentionType.DISABLED]: {
34
- background: "var(--ds-background-disabled, #0515240F)",
35
- borderColor: 'transparent',
36
- text: "var(--ds-text-disabled, #080F214A)",
37
- // Disabled chips do not change on hover / press.
38
- hoveredBackground: "var(--ds-background-disabled, #0515240F)",
39
- pressedBackground: "var(--ds-background-disabled, #0515240F)"
40
- }
41
- };
10
+ import { mentionStyle } from './mention-style';
42
11
  const getStyle = ({
43
12
  mentionType
44
- }, property) => {
45
- const obj = mentionStyle[mentionType][property];
46
- return typeof obj === 'string' ? obj : obj;
47
- };
13
+ }, property) => mentionStyle[mentionType][property];
48
14
  const PrimitiveMention = /*#__PURE__*/forwardRef(({
49
15
  mentionType,
50
16
  ...other
@@ -94,6 +94,8 @@ export default class ResourcedMention extends React.PureComponent {
94
94
  id: props.id,
95
95
  text: props.text || state.resolvedMentionName || '',
96
96
  isHighlighted: state.isHighlighted,
97
+ isDisabled: props.isDisabled,
98
+ disabledTooltip: props.disabledTooltip,
97
99
  accessLevel: props.accessLevel,
98
100
  localId: props.localId,
99
101
  onClick: props.onClick,
@@ -128,6 +128,7 @@ export class MentionInternal extends React.PureComponent {
128
128
  const isDisabledChip = mentionType === MentionType.DISABLED;
129
129
  const disabledA11yProps = isDisabledChip ? {
130
130
  'aria-disabled': true,
131
+ tabIndex: 0,
131
132
  ...(disabledTooltip ? {
132
133
  'aria-label': `${text || '@...'} — ${disabledTooltip}`
133
134
  } : {})
@@ -0,0 +1,32 @@
1
+ import { MentionType } from '../../types';
2
+ export const mentionStyle = {
3
+ [MentionType.SELF]: {
4
+ background: "var(--ds-background-brand-bold, #1868DB)",
5
+ borderColor: 'transparent',
6
+ text: "var(--ds-text-inverse, #FFFFFF)",
7
+ hoveredBackground: "var(--ds-background-brand-bold-hovered, #1558BC)",
8
+ pressedBackground: "var(--ds-background-brand-bold-pressed, #144794)"
9
+ },
10
+ [MentionType.RESTRICTED]: {
11
+ background: 'transparent',
12
+ borderColor: "var(--ds-border-bold, #7D818A)",
13
+ text: "var(--ds-text, #292A2E)",
14
+ hoveredBackground: 'transparent',
15
+ pressedBackground: 'transparent'
16
+ },
17
+ [MentionType.DEFAULT]: {
18
+ background: "var(--ds-background-neutral, #0515240F)",
19
+ borderColor: 'transparent',
20
+ text: "var(--ds-text-subtle, #505258)",
21
+ hoveredBackground: "var(--ds-background-neutral-hovered, #0B120E24)",
22
+ pressedBackground: "var(--ds-background-neutral-pressed, #080F214A)"
23
+ },
24
+ [MentionType.DISABLED]: {
25
+ background: "var(--ds-background-disabled, #0515240F)",
26
+ borderColor: 'transparent',
27
+ text: "var(--ds-text-disabled, #080F214A)",
28
+ // Disabled chips do not change on hover / press.
29
+ hoveredBackground: "var(--ds-background-disabled, #0515240F)",
30
+ pressedBackground: "var(--ds-background-disabled, #0515240F)"
31
+ }
32
+ };
@@ -2,7 +2,7 @@ import { OPERATIONAL_EVENT_TYPE, UI_EVENT_TYPE } from '@atlaskit/analytics-gas-t
2
2
  import { ELEMENTS_CHANNEL } from '../_constants';
3
3
  import { ComponentNames, isSpecialMentionText } from '../types';
4
4
  const packageName = "@atlaskit/mention";
5
- const packageVersion = "27.5.1";
5
+ const packageVersion = "27.5.2";
6
6
  export const SLI_EVENT_TYPE = 'sli';
7
7
  export const SMART_EVENT_TYPE = 'smart';
8
8
  export const fireAnalyticsMentionTypeaheadEvent = props => (action, duration, userIds = [], query) => {
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
4
  var _templateObject;
6
5
  var _excluded = ["mentionType"];
7
6
  /* eslint-disable @atlaskit/design-system/no-html-button */
@@ -11,38 +10,11 @@ var _excluded = ["mentionType"];
11
10
  */
12
11
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
13
12
  import { jsx, css } from '@emotion/react';
14
- import { MentionType } from '../../types';
15
13
  import { forwardRef } from 'react';
16
- var mentionStyle = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, MentionType.SELF, {
17
- background: "var(--ds-background-brand-bold, #1868DB)",
18
- borderColor: 'transparent',
19
- text: "var(--ds-text-inverse, #FFFFFF)",
20
- hoveredBackground: "var(--ds-background-brand-bold-hovered, #1558BC)",
21
- pressedBackground: "var(--ds-background-brand-bold-pressed, #144794)"
22
- }), MentionType.RESTRICTED, {
23
- background: 'transparent',
24
- borderColor: "var(--ds-border-bold, #7D818A)",
25
- text: "var(--ds-text, #292A2E)",
26
- hoveredBackground: 'transparent',
27
- pressedBackground: 'transparent'
28
- }), MentionType.DEFAULT, {
29
- background: "var(--ds-background-neutral, #0515240F)",
30
- borderColor: 'transparent',
31
- text: "var(--ds-text-subtle, #505258)",
32
- hoveredBackground: "var(--ds-background-neutral-hovered, #0B120E24)",
33
- pressedBackground: "var(--ds-background-neutral-pressed, #080F214A)"
34
- }), MentionType.DISABLED, {
35
- background: "var(--ds-background-disabled, #0515240F)",
36
- borderColor: 'transparent',
37
- text: "var(--ds-text-disabled, #080F214A)",
38
- // Disabled chips do not change on hover / press.
39
- hoveredBackground: "var(--ds-background-disabled, #0515240F)",
40
- pressedBackground: "var(--ds-background-disabled, #0515240F)"
41
- });
14
+ import { mentionStyle } from './mention-style';
42
15
  var getStyle = function getStyle(_ref, property) {
43
16
  var mentionType = _ref.mentionType;
44
- var obj = mentionStyle[mentionType][property];
45
- return typeof obj === 'string' ? obj : obj;
17
+ return mentionStyle[mentionType][property];
46
18
  };
47
19
  var PrimitiveMention = /*#__PURE__*/forwardRef(function (_ref2, ref) {
48
20
  var mentionType = _ref2.mentionType,
@@ -111,6 +111,8 @@ var ResourcedMention = /*#__PURE__*/function (_React$PureComponent) {
111
111
  id: props.id,
112
112
  text: props.text || state.resolvedMentionName || '',
113
113
  isHighlighted: state.isHighlighted,
114
+ isDisabled: props.isDisabled,
115
+ disabledTooltip: props.disabledTooltip,
114
116
  accessLevel: props.accessLevel,
115
117
  localId: props.localId,
116
118
  onClick: props.onClick,
@@ -142,7 +142,8 @@ export var MentionInternal = /*#__PURE__*/function (_React$PureComponent) {
142
142
  // `aria-describedby`.
143
143
  var isDisabledChip = mentionType === MentionType.DISABLED;
144
144
  var disabledA11yProps = isDisabledChip ? _objectSpread({
145
- 'aria-disabled': true
145
+ 'aria-disabled': true,
146
+ tabIndex: 0
146
147
  }, disabledTooltip ? {
147
148
  'aria-label': "".concat(text || '@...', " \u2014 ").concat(disabledTooltip)
148
149
  } : {}) : {};
@@ -0,0 +1,28 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { MentionType } from '../../types';
3
+ export var mentionStyle = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, MentionType.SELF, {
4
+ background: "var(--ds-background-brand-bold, #1868DB)",
5
+ borderColor: 'transparent',
6
+ text: "var(--ds-text-inverse, #FFFFFF)",
7
+ hoveredBackground: "var(--ds-background-brand-bold-hovered, #1558BC)",
8
+ pressedBackground: "var(--ds-background-brand-bold-pressed, #144794)"
9
+ }), MentionType.RESTRICTED, {
10
+ background: 'transparent',
11
+ borderColor: "var(--ds-border-bold, #7D818A)",
12
+ text: "var(--ds-text, #292A2E)",
13
+ hoveredBackground: 'transparent',
14
+ pressedBackground: 'transparent'
15
+ }), MentionType.DEFAULT, {
16
+ background: "var(--ds-background-neutral, #0515240F)",
17
+ borderColor: 'transparent',
18
+ text: "var(--ds-text-subtle, #505258)",
19
+ hoveredBackground: "var(--ds-background-neutral-hovered, #0B120E24)",
20
+ pressedBackground: "var(--ds-background-neutral-pressed, #080F214A)"
21
+ }), MentionType.DISABLED, {
22
+ background: "var(--ds-background-disabled, #0515240F)",
23
+ borderColor: 'transparent',
24
+ text: "var(--ds-text-disabled, #080F214A)",
25
+ // Disabled chips do not change on hover / press.
26
+ hoveredBackground: "var(--ds-background-disabled, #0515240F)",
27
+ pressedBackground: "var(--ds-background-disabled, #0515240F)"
28
+ });
@@ -5,7 +5,7 @@ import { OPERATIONAL_EVENT_TYPE, UI_EVENT_TYPE } from '@atlaskit/analytics-gas-t
5
5
  import { ELEMENTS_CHANNEL } from '../_constants';
6
6
  import { ComponentNames, isSpecialMentionText } from '../types';
7
7
  var packageName = "@atlaskit/mention";
8
- var packageVersion = "27.5.1";
8
+ var packageVersion = "27.5.2";
9
9
  export var SLI_EVENT_TYPE = 'sli';
10
10
  export var SMART_EVENT_TYPE = 'smart';
11
11
  export var fireAnalyticsMentionTypeaheadEvent = function fireAnalyticsMentionTypeaheadEvent(props) {
@@ -1,5 +1,5 @@
1
- import { MentionType } from '../../types';
2
1
  import { type ForwardRefExoticComponent, type HTMLAttributes, type RefAttributes } from 'react';
2
+ import type { MentionType } from '../../types';
3
3
  export interface PrimitiveMentionProps extends HTMLAttributes<HTMLSpanElement> {
4
4
  mentionType: MentionType;
5
5
  }
@@ -3,7 +3,9 @@ import { type MentionProvider } from '../../api/MentionResource';
3
3
  import { type MentionEventHandler } from '../../types';
4
4
  export interface Props {
5
5
  accessLevel?: string;
6
+ disabledTooltip?: string;
6
7
  id: string;
8
+ isDisabled?: boolean;
7
9
  localId?: string;
8
10
  mentionProvider?: Promise<MentionProvider>;
9
11
  onClick?: MentionEventHandler;
@@ -0,0 +1,10 @@
1
+ import { MentionType } from '../../types';
2
+ type MentionStyleEntry = {
3
+ background: string;
4
+ borderColor: string;
5
+ hoveredBackground: string;
6
+ pressedBackground: string;
7
+ text: string;
8
+ };
9
+ export declare const mentionStyle: Record<MentionType, MentionStyleEntry>;
10
+ export {};
package/package.json CHANGED
@@ -117,5 +117,5 @@
117
117
  }
118
118
  },
119
119
  "types": "dist/types/index.d.ts",
120
- "version": "27.5.2"
120
+ "version": "27.6.0"
121
121
  }