@atlaskit/mention 26.0.4 → 26.2.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 +78 -0
- package/dist/cjs/api/ContextMentionResource.js +14 -0
- package/dist/cjs/api/MentionResource.js +6 -0
- package/dist/cjs/components/DisabledMentionTooltip/index.js +20 -0
- package/dist/cjs/components/DisabledMentionTooltip/main.js +24 -0
- package/dist/cjs/components/Mention/PrimitiveMention.js +8 -1
- package/dist/cjs/components/Mention/index.js +51 -12
- package/dist/cjs/components/MentionItem/index.js +9 -1
- package/dist/cjs/components/MentionItem/styles.js +5 -2
- package/dist/cjs/item.js +6 -0
- package/dist/cjs/types.js +10 -0
- package/dist/cjs/util/analytics.js +1 -1
- package/dist/es2019/api/ContextMentionResource.js +12 -0
- package/dist/es2019/api/MentionResource.js +4 -0
- package/dist/es2019/components/DisabledMentionTooltip/index.js +7 -0
- package/dist/es2019/components/DisabledMentionTooltip/main.js +14 -0
- package/dist/es2019/components/Mention/PrimitiveMention.js +8 -0
- package/dist/es2019/components/Mention/index.js +50 -12
- package/dist/es2019/components/MentionItem/index.js +4 -2
- package/dist/es2019/components/MentionItem/styles.js +16 -11
- package/dist/es2019/item.js +2 -2
- package/dist/es2019/types.js +12 -0
- package/dist/es2019/util/analytics.js +1 -1
- package/dist/esm/api/ContextMentionResource.js +14 -0
- package/dist/esm/api/MentionResource.js +6 -0
- package/dist/esm/components/DisabledMentionTooltip/index.js +9 -0
- package/dist/esm/components/DisabledMentionTooltip/main.js +17 -0
- package/dist/esm/components/Mention/PrimitiveMention.js +8 -1
- package/dist/esm/components/Mention/index.js +51 -12
- package/dist/esm/components/MentionItem/index.js +4 -2
- package/dist/esm/components/MentionItem/styles.js +4 -1
- package/dist/esm/item.js +2 -2
- package/dist/esm/types.js +12 -0
- package/dist/esm/util/analytics.js +1 -1
- package/dist/types/api/ContextMentionResource.d.ts +6 -1
- package/dist/types/api/MentionResource.d.ts +2 -1
- package/dist/types/components/DisabledMentionTooltip/index.d.ts +6 -0
- package/dist/types/components/DisabledMentionTooltip/main.d.ts +12 -0
- package/dist/types/components/Mention/index.d.ts +12 -0
- package/dist/types/components/MentionItem/index.d.ts +2 -1
- package/dist/types/components/MentionItem/styles.d.ts +2 -0
- package/dist/types/item.d.ts +2 -2
- package/dist/types/types.d.ts +67 -1
- package/dist/types-ts4.5/api/ContextMentionResource.d.ts +6 -1
- package/dist/types-ts4.5/api/MentionResource.d.ts +2 -1
- package/dist/types-ts4.5/components/DisabledMentionTooltip/index.d.ts +6 -0
- package/dist/types-ts4.5/components/DisabledMentionTooltip/main.d.ts +12 -0
- package/dist/types-ts4.5/components/Mention/index.d.ts +12 -0
- package/dist/types-ts4.5/components/MentionItem/index.d.ts +2 -1
- package/dist/types-ts4.5/components/MentionItem/styles.d.ts +2 -0
- package/dist/types-ts4.5/item.d.ts +2 -2
- package/dist/types-ts4.5/types.d.ts +67 -1
- package/docs/0-intro.tsx +21 -0
- package/package.json +7 -7
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type Props = {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
tooltip: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Wraps a disabled `<Mention>` chip with a tooltip explaining why the chip
|
|
8
|
+
* is disabled. The chip itself remains non-interactive; the tooltip is the
|
|
9
|
+
* sole hover affordance.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DisabledMentionTooltip: ({ tooltip, children }: Props) => React.JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -5,7 +5,19 @@ export declare const ANALYTICS_HOVER_DELAY = 1000;
|
|
|
5
5
|
export declare const UNKNOWN_USER_ID = "_|unknown|_";
|
|
6
6
|
export type OwnProps = {
|
|
7
7
|
accessLevel?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Tooltip text shown on hover when the chip is disabled. Ignored when
|
|
10
|
+
* `isDisabled` is false. When omitted, no tooltip is rendered even if
|
|
11
|
+
* `isDisabled` is true.
|
|
12
|
+
*/
|
|
13
|
+
disabledTooltip?: string;
|
|
8
14
|
id: string;
|
|
15
|
+
/**
|
|
16
|
+
* When true, the mention chip is rendered in its disabled visual state
|
|
17
|
+
* (`MentionType.DISABLED`) and click handlers are not invoked. Takes
|
|
18
|
+
* precedence over `isHighlighted` and the restricted state.
|
|
19
|
+
*/
|
|
20
|
+
isDisabled?: boolean;
|
|
9
21
|
isHighlighted?: boolean;
|
|
10
22
|
localId?: string;
|
|
11
23
|
onClick?: MentionEventHandler;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type MentionDescription, type OnMentionEvent } from '../../types';
|
|
3
|
-
export { MENTION_ITEM_HEIGHT } from './styles';
|
|
3
|
+
export { MENTION_ITEM_HEIGHT, MENTION_ITEM_HEIGHT_REFRESHED } from './styles';
|
|
4
4
|
export interface Props {
|
|
5
5
|
forwardedRef?: React.Ref<HTMLDivElement>;
|
|
6
|
+
height?: number;
|
|
6
7
|
mention: MentionDescription;
|
|
7
8
|
onMouseEnter?: OnMentionEvent;
|
|
8
9
|
onMouseMove?: OnMentionEvent;
|
|
@@ -2,6 +2,7 @@ import { type StyledComponent } from '@emotion/styled';
|
|
|
2
2
|
import type { Theme } from '@emotion/react';
|
|
3
3
|
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
|
|
4
4
|
export interface MentionItemStyleProps {
|
|
5
|
+
height?: number;
|
|
5
6
|
selected?: boolean;
|
|
6
7
|
}
|
|
7
8
|
export interface AvatarSectionStyleProps {
|
|
@@ -38,6 +39,7 @@ export declare const TimeStyle: StyledComponent<{
|
|
|
38
39
|
theme?: Theme;
|
|
39
40
|
}, DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
40
41
|
export declare const MENTION_ITEM_HEIGHT = 48;
|
|
42
|
+
export declare const MENTION_ITEM_HEIGHT_REFRESHED = 44;
|
|
41
43
|
export declare const MentionItemStyle: StyledComponent<{
|
|
42
44
|
as?: React.ElementType;
|
|
43
45
|
theme?: Theme;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import MentionItem, { MENTION_ITEM_HEIGHT } from './components/MentionItem';
|
|
2
|
-
export { MentionItem, MENTION_ITEM_HEIGHT, };
|
|
1
|
+
import MentionItem, { MENTION_ITEM_HEIGHT, MENTION_ITEM_HEIGHT_REFRESHED } from './components/MentionItem';
|
|
2
|
+
export { MentionItem, MENTION_ITEM_HEIGHT, MENTION_ITEM_HEIGHT_REFRESHED, };
|
|
@@ -39,6 +39,24 @@ export interface MentionResourceConfig extends ServiceConfig {
|
|
|
39
39
|
* calls to `filter` will be debounced to reduce the number of network requests.
|
|
40
40
|
*/
|
|
41
41
|
debounceTime?: number;
|
|
42
|
+
/**
|
|
43
|
+
* A function to determine whether a given mention should be rendered in
|
|
44
|
+
* its disabled visual state (`MentionType.DISABLED`), and what tooltip
|
|
45
|
+
* (if any) to display when the disabled chip is hovered.
|
|
46
|
+
*
|
|
47
|
+
* Returning `{ disabled: false }` (or `undefined`) leaves the mention in
|
|
48
|
+
* whatever state the other predicates resolve to.
|
|
49
|
+
*
|
|
50
|
+
* The input deliberately exposes only the mention's `id` because the
|
|
51
|
+
* canonical caller (the editor mentions `NodeView`) does not have the
|
|
52
|
+
* full `MentionDescription` in scope. Implementations should look the
|
|
53
|
+
* additional context they need (e.g. agent metadata) up via the `id`.
|
|
54
|
+
*
|
|
55
|
+
* @param mention - The minimal mention identifier to evaluate.
|
|
56
|
+
* @returns `{ disabled, tooltip? }` describing the disabled visual state,
|
|
57
|
+
* or `undefined` to leave it unchanged.
|
|
58
|
+
*/
|
|
59
|
+
getMentionDisabledState?: (mention: MentionDisabledStateInput) => MentionDisabledState | undefined;
|
|
42
60
|
/**
|
|
43
61
|
* Custom HTTP headers to include in mention service requests.
|
|
44
62
|
*/
|
|
@@ -94,6 +112,22 @@ export interface MentionResourceConfig extends ServiceConfig {
|
|
|
94
112
|
*/
|
|
95
113
|
userRole?: UserRole;
|
|
96
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Describes whether a mention should be rendered in its disabled visual
|
|
117
|
+
* state and what tooltip (if any) should be shown on hover.
|
|
118
|
+
*/
|
|
119
|
+
export interface MentionDisabledState {
|
|
120
|
+
disabled: boolean;
|
|
121
|
+
tooltip?: string;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The minimal input shape used by `getMentionDisabledState`. Kept as a named
|
|
125
|
+
* type so the config callback and the provider method share the same input
|
|
126
|
+
* surface, and so callers do not have to fabricate fields they do not have.
|
|
127
|
+
*/
|
|
128
|
+
export interface MentionDisabledStateInput {
|
|
129
|
+
id: string;
|
|
130
|
+
}
|
|
97
131
|
export interface ResourceProvider<Result> {
|
|
98
132
|
/**
|
|
99
133
|
* Subscribe to ResourceProvider results
|
|
@@ -119,9 +153,40 @@ export type MentionContextIdentifier = {
|
|
|
119
153
|
};
|
|
120
154
|
export interface MentionProvider extends ResourceProvider<MentionDescription[]>, InviteFromMentionProvider, XProductInviteMentionProvider {
|
|
121
155
|
filter(query?: string, contextIdentifier?: MentionContextIdentifier): void;
|
|
156
|
+
/**
|
|
157
|
+
* Optional. When implemented, lets the rendering surface ask whether a
|
|
158
|
+
* mention should be displayed in its disabled visual state, and what
|
|
159
|
+
* tooltip to surface on hover. Returning `undefined` (or omitting the
|
|
160
|
+
* method entirely) is equivalent to "not disabled".
|
|
161
|
+
*/
|
|
162
|
+
getMentionDisabledState?(mention: MentionDisabledStateInput): MentionDisabledState | undefined;
|
|
122
163
|
isFiltering(query: string): boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Optional. Called by the rendering surface (e.g. the editor NodeView)
|
|
166
|
+
* when a mention chip is destroyed (removed from the doc). This is the
|
|
167
|
+
* lowest-level deletion signal — it fires regardless of how the chip was
|
|
168
|
+
* removed (backspace, select-and-delete, programmatic replace, …) and
|
|
169
|
+
* does not depend on the editor's debounced `onChange` callback.
|
|
170
|
+
*
|
|
171
|
+
* Implementations typically forward the call to consumers via the chat
|
|
172
|
+
* layer so they can react (e.g. update `selectedAgentIds`).
|
|
173
|
+
*/
|
|
174
|
+
notifyMentionDestroyed?(mention: {
|
|
175
|
+
id: string;
|
|
176
|
+
}): void;
|
|
123
177
|
recordMentionSelection(mention: MentionDescription, contextIdentifier?: MentionContextIdentifier): void;
|
|
124
178
|
shouldHighlightMention(mention: MentionDescription): boolean;
|
|
179
|
+
/**
|
|
180
|
+
* Optional. When implemented, lets the rendering surface subscribe to
|
|
181
|
+
* changes in the disabled-state predicate so already-rendered chips can
|
|
182
|
+
* re-evaluate themselves when the external state that drives
|
|
183
|
+
* `getMentionDisabledState` changes (e.g. the active agent selection in
|
|
184
|
+
* Rovo Chat). Implementations should invoke the listener after their
|
|
185
|
+
* own state changes.
|
|
186
|
+
*
|
|
187
|
+
* Returns an unsubscribe function. Callers MUST invoke it on teardown.
|
|
188
|
+
*/
|
|
189
|
+
subscribeToDisabledStateChanges?(listener: () => void): () => void;
|
|
125
190
|
}
|
|
126
191
|
export interface HighlightDetail {
|
|
127
192
|
end: number;
|
|
@@ -188,7 +253,8 @@ export interface OnMentionEvent {
|
|
|
188
253
|
export declare enum MentionType {
|
|
189
254
|
SELF = 0,
|
|
190
255
|
RESTRICTED = 1,
|
|
191
|
-
DEFAULT = 2
|
|
256
|
+
DEFAULT = 2,
|
|
257
|
+
DISABLED = 3
|
|
192
258
|
}
|
|
193
259
|
export declare enum UserAccessLevel {
|
|
194
260
|
NONE = 0,
|
package/docs/0-intro.tsx
CHANGED
|
@@ -79,6 +79,27 @@ const _default_1: any = md`
|
|
|
79
79
|
/>
|
|
80
80
|
)}
|
|
81
81
|
|
|
82
|
+
## Mention chip variants
|
|
83
|
+
|
|
84
|
+
The \`<Mention>\` chip has four visual variants:
|
|
85
|
+
|
|
86
|
+
- **Default** — a neutral chip rendered for any in-scope mention.
|
|
87
|
+
- **Self** — emphasised brand-coloured chip rendered when \`isHighlighted\`
|
|
88
|
+
is set, typically used to highlight a mention of the current user.
|
|
89
|
+
- **Restricted** — outlined chip rendered when the mention's
|
|
90
|
+
\`accessLevel\` indicates the referenced user does not have access; on
|
|
91
|
+
hover the chip surfaces a "no access" tooltip.
|
|
92
|
+
- **Disabled** — muted grey chip rendered when \`isDisabled\` is set.
|
|
93
|
+
Click handlers are suppressed, the chip exposes
|
|
94
|
+
\`aria-disabled="true"\`, and (with a \`disabledTooltip\` set) hover or
|
|
95
|
+
keyboard focus surfaces an ADS tooltip explaining why the chip is
|
|
96
|
+
disabled. The disabled chip remains keyboard-focusable so screen-reader
|
|
97
|
+
users encounter it and hear the reason.
|
|
98
|
+
|
|
99
|
+
Inside the editor, the disabled state is driven by
|
|
100
|
+
\`MentionProvider.getMentionDisabledState({ id })\` so rendering surfaces
|
|
101
|
+
don't need to thread per-chip props through ProseMirror node views.
|
|
102
|
+
|
|
82
103
|
${(<Props props={MentionProps} />)}
|
|
83
104
|
|
|
84
105
|
`;
|
package/package.json
CHANGED
|
@@ -26,20 +26,20 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@atlaskit/afm-i18n-platform-elements-mention": "2.
|
|
29
|
+
"@atlaskit/afm-i18n-platform-elements-mention": "2.142.0",
|
|
30
30
|
"@atlaskit/analytics-gas-types": "^5.1.0",
|
|
31
|
-
"@atlaskit/analytics-next": "^11.
|
|
31
|
+
"@atlaskit/analytics-next": "^11.3.0",
|
|
32
32
|
"@atlaskit/avatar": "^25.15.0",
|
|
33
33
|
"@atlaskit/focus-ring": "^3.1.0",
|
|
34
34
|
"@atlaskit/heading": "^5.4.0",
|
|
35
|
-
"@atlaskit/icon": "^35.
|
|
35
|
+
"@atlaskit/icon": "^35.4.0",
|
|
36
36
|
"@atlaskit/lozenge": "^13.8.0",
|
|
37
37
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
38
38
|
"@atlaskit/primitives": "^19.0.0",
|
|
39
|
-
"@atlaskit/tag": "^14.
|
|
39
|
+
"@atlaskit/tag": "^14.15.0",
|
|
40
40
|
"@atlaskit/teams-avatar": "^2.7.0",
|
|
41
|
-
"@atlaskit/tokens": "^13.
|
|
42
|
-
"@atlaskit/tooltip": "^22.
|
|
41
|
+
"@atlaskit/tokens": "^13.1.0",
|
|
42
|
+
"@atlaskit/tooltip": "^22.6.0",
|
|
43
43
|
"@atlaskit/ufo": "^0.5.0",
|
|
44
44
|
"@atlaskit/util-service-support": "^6.4.0",
|
|
45
45
|
"@babel/runtime": "^7.0.0",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
]
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
|
-
"version": "26.0
|
|
123
|
+
"version": "26.2.0"
|
|
124
124
|
}
|