@atlaskit/reactions 30.0.1 → 30.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.
- package/CHANGELOG.md +14 -0
- package/afm-cc/tsconfig.json +3 -0
- package/afm-jira/tsconfig.json +3 -0
- package/afm-post-office/tsconfig.json +3 -0
- package/dist/cjs/analytics/index.js +1 -1
- package/dist/cjs/components/ShowMore/ShowMore.js +4 -10
- package/dist/cjs/components/compiled/EmojiButton.compiled.css +17 -0
- package/dist/cjs/components/compiled/EmojiButton.js +48 -0
- package/dist/cjs/components/compiled/ReactionButton.compiled.css +4 -5
- package/dist/cjs/components/compiled/ReactionButton.js +5 -3
- package/dist/cjs/components/compiled/ReactionPicker.compiled.css +11 -0
- package/dist/cjs/components/compiled/ReactionPicker.js +325 -0
- package/dist/cjs/components/compiled/ReactionSummaryButton.compiled.css +7 -0
- package/dist/cjs/components/compiled/ReactionSummaryButton.js +110 -0
- package/dist/cjs/components/compiled/ReactionSummaryView.compiled.css +5 -0
- package/dist/cjs/components/compiled/ReactionSummaryView.js +117 -0
- package/dist/cjs/components/compiled/Reactions.js +4 -4
- package/dist/cjs/components/compiled/Selector.compiled.css +13 -0
- package/dist/cjs/components/compiled/Selector.js +81 -0
- package/dist/cjs/components/compiled/StaticReaction.compiled.css +3 -1
- package/dist/cjs/components/compiled/StaticReaction.js +3 -4
- package/dist/cjs/components/compiled/Trigger.compiled.css +34 -0
- package/dist/cjs/components/compiled/Trigger.js +100 -0
- package/dist/cjs/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +5 -1
- package/dist/cjs/index.js +3 -7
- package/dist/es2019/analytics/index.js +1 -1
- package/dist/es2019/components/ShowMore/ShowMore.js +3 -8
- package/dist/es2019/components/compiled/EmojiButton.compiled.css +17 -0
- package/dist/es2019/components/compiled/EmojiButton.js +40 -0
- package/dist/es2019/components/compiled/ReactionButton.compiled.css +4 -5
- package/dist/es2019/components/compiled/ReactionButton.js +5 -3
- package/dist/es2019/components/compiled/ReactionPicker.compiled.css +11 -0
- package/dist/es2019/components/compiled/ReactionPicker.js +295 -0
- package/dist/es2019/components/compiled/ReactionSummaryButton.compiled.css +7 -0
- package/dist/es2019/components/compiled/ReactionSummaryButton.js +88 -0
- package/dist/es2019/components/compiled/ReactionSummaryView.compiled.css +5 -0
- package/dist/es2019/components/compiled/ReactionSummaryView.js +87 -0
- package/dist/es2019/components/compiled/Reactions.js +3 -3
- package/dist/es2019/components/compiled/Selector.compiled.css +14 -0
- package/dist/es2019/components/compiled/Selector.js +69 -0
- package/dist/es2019/components/compiled/StaticReaction.compiled.css +3 -1
- package/dist/es2019/components/compiled/StaticReaction.js +4 -5
- package/dist/es2019/components/compiled/Trigger.compiled.css +34 -0
- package/dist/es2019/components/compiled/Trigger.js +90 -0
- package/dist/es2019/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +5 -1
- package/dist/es2019/index.js +6 -2
- package/dist/esm/analytics/index.js +1 -1
- package/dist/esm/components/ShowMore/ShowMore.js +4 -9
- package/dist/esm/components/compiled/EmojiButton.compiled.css +17 -0
- package/dist/esm/components/compiled/EmojiButton.js +39 -0
- package/dist/esm/components/compiled/ReactionButton.compiled.css +4 -5
- package/dist/esm/components/compiled/ReactionButton.js +5 -3
- package/dist/esm/components/compiled/ReactionPicker.compiled.css +11 -0
- package/dist/esm/components/compiled/ReactionPicker.js +316 -0
- package/dist/esm/components/compiled/ReactionSummaryButton.compiled.css +7 -0
- package/dist/esm/components/compiled/ReactionSummaryButton.js +100 -0
- package/dist/esm/components/compiled/ReactionSummaryView.compiled.css +5 -0
- package/dist/esm/components/compiled/ReactionSummaryView.js +107 -0
- package/dist/esm/components/compiled/Reactions.js +3 -3
- package/dist/esm/components/compiled/Selector.compiled.css +13 -0
- package/dist/esm/components/compiled/Selector.js +71 -0
- package/dist/esm/components/compiled/StaticReaction.compiled.css +3 -1
- package/dist/esm/components/compiled/StaticReaction.js +4 -5
- package/dist/esm/components/compiled/Trigger.compiled.css +34 -0
- package/dist/esm/components/compiled/Trigger.js +93 -0
- package/dist/esm/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +5 -1
- package/dist/esm/index.js +6 -2
- package/dist/types/components/ShowMore/ShowMore.d.ts +2 -7
- package/dist/types/components/compiled/EmojiButton.d.ts +21 -0
- package/dist/types/components/compiled/ReactionButton.d.ts +2 -1
- package/dist/types/components/compiled/ReactionPicker.d.ts +100 -0
- package/dist/types/components/compiled/ReactionSummaryButton.d.ts +34 -0
- package/dist/types/components/compiled/ReactionSummaryView.d.ts +58 -0
- package/dist/types/components/compiled/Reactions.d.ts +2 -2
- package/dist/types/components/compiled/Selector.d.ts +33 -0
- package/dist/types/components/compiled/Trigger.d.ts +64 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types-ts4.5/components/ShowMore/ShowMore.d.ts +2 -7
- package/dist/types-ts4.5/components/compiled/EmojiButton.d.ts +21 -0
- package/dist/types-ts4.5/components/compiled/ReactionButton.d.ts +2 -1
- package/dist/types-ts4.5/components/compiled/ReactionPicker.d.ts +100 -0
- package/dist/types-ts4.5/components/compiled/ReactionSummaryButton.d.ts +34 -0
- package/dist/types-ts4.5/components/compiled/ReactionSummaryView.d.ts +58 -0
- package/dist/types-ts4.5/components/compiled/Reactions.d.ts +2 -2
- package/dist/types-ts4.5/components/compiled/Selector.d.ts +33 -0
- package/dist/types-ts4.5/components/compiled/Trigger.d.ts +64 -0
- package/dist/types-ts4.5/index.d.ts +4 -2
- package/package.json +4 -3
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* EmojiButton.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import "./EmojiButton.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import { useIntl } from 'react-intl-next';
|
|
6
|
+
import { ResourcedEmoji } from '@atlaskit/emoji';
|
|
7
|
+
import { messages } from '../../shared/i18n';
|
|
8
|
+
import { isLeftClick } from '../../shared/utils';
|
|
9
|
+
import { Pressable } from '@atlaskit/primitives/compiled';
|
|
10
|
+
const styles = {
|
|
11
|
+
emojiButton: "_12ji1r31 _1qu2glyw _12y31o36 _2rkoglpi _189eidpf _1e0c1txw _bfhksm61 _19pkze3t _2hwxze3t _otyrze3t _18u0ze3t _ca0qu2gc _u5f3u2gc _n3tdu2gc _19bvu2gc _o7ksrkh3 _1llw1q5f"
|
|
12
|
+
};
|
|
13
|
+
export const RENDER_BUTTON_TESTID = 'button-emoji-id';
|
|
14
|
+
/**
|
|
15
|
+
* custom button to render the custom emoji selector inside the reaction picker
|
|
16
|
+
*/
|
|
17
|
+
export const EmojiButton = ({
|
|
18
|
+
emojiId,
|
|
19
|
+
onClick,
|
|
20
|
+
emojiProvider
|
|
21
|
+
}) => {
|
|
22
|
+
const onButtonClick = event => {
|
|
23
|
+
event.preventDefault();
|
|
24
|
+
if (onClick && isLeftClick(event)) {
|
|
25
|
+
onClick(emojiId, undefined, event);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const intl = useIntl();
|
|
29
|
+
return /*#__PURE__*/React.createElement(Pressable, {
|
|
30
|
+
testId: RENDER_BUTTON_TESTID,
|
|
31
|
+
onClick: onButtonClick,
|
|
32
|
+
"aria-label": intl.formatMessage(messages.reactWithEmoji, {
|
|
33
|
+
emoji: emojiId.shortName
|
|
34
|
+
}),
|
|
35
|
+
xcss: styles.emojiButton
|
|
36
|
+
}, /*#__PURE__*/React.createElement(ResourcedEmoji, {
|
|
37
|
+
emojiProvider: emojiProvider,
|
|
38
|
+
emojiId: emojiId
|
|
39
|
+
}));
|
|
40
|
+
};
|
|
@@ -4,15 +4,13 @@
|
|
|
4
4
|
._2rkoglpi{border-radius:var(--ds-border-radius,4px)}
|
|
5
5
|
._2rkogqwt{border-radius:var(--ds-border-radius-050,2px)}
|
|
6
6
|
._189ee4h9{border-width:var(--ds-border-width,1px)}
|
|
7
|
+
._1dqoglyw{border-style:none}
|
|
7
8
|
._1dqonqa1{border-style:solid}
|
|
8
9
|
._1h6d1yqz{border-color:var(--ds-border-selected,#0c66e4)}
|
|
9
|
-
._1h6dmuej{border-color:var(--ds-border,#091e4224)}
|
|
10
|
-
._1kl7glyw{border-left:none}
|
|
11
|
-
._1s7zglyw{border-right:none}
|
|
12
|
-
._n7zlglyw{border-bottom:none}
|
|
13
|
-
._x3doglyw{border-top:none}._12l21b66{margin-inline-end:var(--ds-space-050,4px)}
|
|
10
|
+
._1h6dmuej{border-color:var(--ds-border,#091e4224)}._12l21b66{margin-inline-end:var(--ds-space-050,4px)}
|
|
14
11
|
._18m915vq{overflow-y:hidden}
|
|
15
12
|
._19bvze3t{padding-left:var(--ds-space-0,0)}
|
|
13
|
+
._19pk12x7{margin-top:var(--ds-space-075,6px)}
|
|
16
14
|
._1e0c1txw{display:flex}
|
|
17
15
|
._1pfh1b66{margin-block-start:var(--ds-space-050,4px)}
|
|
18
16
|
._1reo15vq{overflow-x:hidden}
|
|
@@ -21,6 +19,7 @@
|
|
|
21
19
|
._4cvr1h6o{align-items:center}
|
|
22
20
|
._4cvr1y6m{align-items:flex-start}
|
|
23
21
|
._4t3i1tcg{height:24px}
|
|
22
|
+
._4t3igktf{height:20px}
|
|
24
23
|
._4t3iqslr{height:22px}
|
|
25
24
|
._bfhkfg4m{background-color:var(--ds-background-selected,#e9f2ff)}
|
|
26
25
|
._bfhksm61{background-color:var(--ds-background-neutral-subtle,#00000000)}
|
|
@@ -10,9 +10,10 @@ import { Pressable } from '@atlaskit/primitives/compiled';
|
|
|
10
10
|
const styles = {
|
|
11
11
|
reactionButton: "_2rko14q2 _1reo15vq _18m915vq _189ee4h9 _1dqonqa1 _1h6dmuej _1e0c1txw _2lx2vrvc _4cvr1y6m _1ul914no _4t3i1tcg _bfhksm61 _syaz1gjq _1pfh1b66 _12l21b66 _ca0qze3t _u5f3ze3t _n3tdze3t _19bvze3t _irr3166n _1di61dty",
|
|
12
12
|
reactionStylesRefresh: "_2rkoglpi",
|
|
13
|
-
borderless: "_x3doglyw _1kl7glyw _1s7zglyw _n7zlglyw",
|
|
14
13
|
reacted: "_1h6d1yqz _bfhkfg4m _irr3i1yw _1di619ru",
|
|
15
|
-
opaqueBackground: "_bfhkvuon _irr3108i _1di61ji5"
|
|
14
|
+
opaqueBackground: "_bfhkvuon _irr3108i _1di61ji5",
|
|
15
|
+
compactButton: "_4t3igktf _4cvr1h6o _19pk12x7",
|
|
16
|
+
borderless: "_1dqoglyw"
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -28,6 +29,7 @@ export const ReactionButton = ({
|
|
|
28
29
|
flash = false,
|
|
29
30
|
showSubtleStyle,
|
|
30
31
|
showOpaqueBackground,
|
|
32
|
+
useCompactStyles,
|
|
31
33
|
reacted,
|
|
32
34
|
ariaLabel,
|
|
33
35
|
ariaPressed,
|
|
@@ -44,7 +46,7 @@ export const ReactionButton = ({
|
|
|
44
46
|
"aria-label": ariaLabel,
|
|
45
47
|
"aria-pressed": ariaPressed,
|
|
46
48
|
testId: testId,
|
|
47
|
-
xcss: cx(styles.reactionButton, reacted && styles.reacted, !reacted && showSubtleStyle && styles.borderless, !reacted && showOpaqueBackground && styles.opaqueBackground,
|
|
49
|
+
xcss: cx(styles.reactionButton, useCompactStyles && styles.compactButton, reacted && styles.reacted, !reacted && showSubtleStyle && styles.borderless, !reacted && showOpaqueBackground && styles.opaqueBackground,
|
|
48
50
|
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
49
51
|
fg('platform-component-visual-refresh') && styles.reactionStylesRefresh)
|
|
50
52
|
}, dataAttributes), /*#__PURE__*/React.createElement(FlashAnimation, {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
._2rko1sit{border-radius:var(--ds-border-radius,3px)}._16qs1kf5{box-shadow:var(--ds-shadow-overlay,0 4px 8px -2px rgba(9,30,66,.25),0 0 1px rgba(9,30,66,.31))}
|
|
3
|
+
._1bch1b66>div{margin-top:var(--ds-space-050,4px)}
|
|
4
|
+
._1e0c1txw{display:flex}
|
|
5
|
+
._1pra1o8l.miniMode{display:inline-block}
|
|
6
|
+
._79pa1b66>div{margin-bottom:var(--ds-space-050,4px)}
|
|
7
|
+
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
8
|
+
._s7n4nkob{vertical-align:middle}
|
|
9
|
+
._1hvw1o36:focus{outline-width:medium}
|
|
10
|
+
._49pcglyw:focus{outline-style:none}
|
|
11
|
+
._nt751r31:focus{outline-color:currentColor}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/* ReactionPicker.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import "./ReactionPicker.compiled.css";
|
|
3
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
+
import React, { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
5
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
6
|
+
import { EmojiPicker } from '@atlaskit/emoji/picker';
|
|
7
|
+
import { Manager, Popper, Reference } from '@atlaskit/popper';
|
|
8
|
+
import { layers } from '@atlaskit/theme/constants';
|
|
9
|
+
import { useCloseManager } from '../../hooks/useCloseManager';
|
|
10
|
+
import { useFocusTrap } from '../../hooks/useFocusTrap';
|
|
11
|
+
import { messages } from '../../shared/i18n';
|
|
12
|
+
import { PickerRender } from '../../ufo';
|
|
13
|
+
import { Selector } from './Selector';
|
|
14
|
+
import { Trigger } from './Trigger';
|
|
15
|
+
import { N0, N50A, N60A } from '@atlaskit/theme/colors';
|
|
16
|
+
const pickerStyle = null;
|
|
17
|
+
const contentStyle = null;
|
|
18
|
+
const popupWrapperStyle = null;
|
|
19
|
+
const popupStyle = null;
|
|
20
|
+
import { RepositionOnUpdate } from '../ReactionPicker/RepositionOnUpdate';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Test id for wrapper ReactionPicker div
|
|
24
|
+
*/
|
|
25
|
+
export const RENDER_REACTIONPICKER_TESTID = 'reactionPicker-testid';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Test id for ReactionPicker panel div
|
|
29
|
+
*/
|
|
30
|
+
export const RENDER_REACTIONPICKERPANEL_TESTID = 'reactionPickerPanel-testid';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Emoji Picker Controller Id for Accessibility Labels
|
|
34
|
+
*/
|
|
35
|
+
const PICKER_CONTROL_ID = 'emoji-picker';
|
|
36
|
+
/**
|
|
37
|
+
* Picker component for adding reactions
|
|
38
|
+
*/
|
|
39
|
+
export const ReactionPicker = /*#__PURE__*/React.memo(props => {
|
|
40
|
+
const {
|
|
41
|
+
miniMode,
|
|
42
|
+
className,
|
|
43
|
+
emojiProvider,
|
|
44
|
+
onSelection,
|
|
45
|
+
allowAllEmojis,
|
|
46
|
+
disabled,
|
|
47
|
+
pickerQuickReactionEmojiIds,
|
|
48
|
+
onShowMore = () => {},
|
|
49
|
+
onOpen = () => {},
|
|
50
|
+
onCancel = () => {},
|
|
51
|
+
tooltipContent = /*#__PURE__*/React.createElement(FormattedMessage, messages.addReaction),
|
|
52
|
+
emojiPickerSize,
|
|
53
|
+
showOpaqueBackground = false,
|
|
54
|
+
subtleReactionsSummaryAndPicker = false,
|
|
55
|
+
showAddReactionText = false,
|
|
56
|
+
showRoundTrigger = false,
|
|
57
|
+
reactionPickerTriggerIcon,
|
|
58
|
+
reactionPickerPlacement,
|
|
59
|
+
reactionsPickerPreventOverflowOptions
|
|
60
|
+
} = props;
|
|
61
|
+
const [triggerRef, setTriggerRef] = useState(null);
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Container <div /> reference (used by custom hook to detect click outside)
|
|
65
|
+
*/
|
|
66
|
+
const wrapperRef = useRef(null);
|
|
67
|
+
const updatePopper = useRef();
|
|
68
|
+
const popperPlacement = showRoundTrigger ? 'left' : reactionPickerPlacement || 'bottom-start';
|
|
69
|
+
const popperModifiers = [
|
|
70
|
+
/**
|
|
71
|
+
Removing this applyStyle modifier as it throws client errors ref:
|
|
72
|
+
https://popper.js.org/docs/v1/#modifiers
|
|
73
|
+
https://popper.js.org/docs/v1/#modifiers..applyStyle
|
|
74
|
+
{ name: 'applyStyle', enabled: false },
|
|
75
|
+
*/
|
|
76
|
+
{
|
|
77
|
+
name: 'hide',
|
|
78
|
+
enabled: false
|
|
79
|
+
}, {
|
|
80
|
+
name: 'offset',
|
|
81
|
+
enabled: true,
|
|
82
|
+
options: {
|
|
83
|
+
offset: [0, 0]
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
name: 'flip',
|
|
87
|
+
enabled: true,
|
|
88
|
+
options: {
|
|
89
|
+
flipVariations: true,
|
|
90
|
+
boundariesElement: 'scrollParent'
|
|
91
|
+
}
|
|
92
|
+
}, {
|
|
93
|
+
name: 'preventOverflow',
|
|
94
|
+
enabled: true,
|
|
95
|
+
...(reactionsPickerPreventOverflowOptions && {
|
|
96
|
+
options: reactionsPickerPreventOverflowOptions
|
|
97
|
+
})
|
|
98
|
+
}];
|
|
99
|
+
const [settings, setSettings] = useState({
|
|
100
|
+
/**
|
|
101
|
+
* Show the picker floating panel
|
|
102
|
+
*/
|
|
103
|
+
isOpen: false,
|
|
104
|
+
/**
|
|
105
|
+
* Show the full custom emoji list picker or the default list of emojis
|
|
106
|
+
*/
|
|
107
|
+
showFullPicker: !!allowAllEmojis && Array.isArray(pickerQuickReactionEmojiIds) && pickerQuickReactionEmojiIds.length === 0,
|
|
108
|
+
/**
|
|
109
|
+
* Use left placement for popper - using value based on showRoundTrigger for now since it needs the left placement
|
|
110
|
+
*/
|
|
111
|
+
popperPlacement
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Custom hook triggers when user clicks outside the reactions picker
|
|
116
|
+
*/
|
|
117
|
+
useCloseManager(wrapperRef, callbackType => {
|
|
118
|
+
close();
|
|
119
|
+
onCancel();
|
|
120
|
+
if (triggerRef && callbackType === 'ESCAPE') {
|
|
121
|
+
requestAnimationFrame(() => triggerRef.focus());
|
|
122
|
+
}
|
|
123
|
+
}, true, settings.isOpen);
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Event callback when the picker is closed
|
|
127
|
+
* @param _id Optional id if an emoji button was selected or undefineed if was clicked outside the picker
|
|
128
|
+
*/
|
|
129
|
+
const close = useCallback(_id => {
|
|
130
|
+
setSettings({
|
|
131
|
+
...settings,
|
|
132
|
+
isOpen: false
|
|
133
|
+
});
|
|
134
|
+
// ufo abort reaction experience
|
|
135
|
+
PickerRender.abort({
|
|
136
|
+
metadata: {
|
|
137
|
+
emojiId: _id,
|
|
138
|
+
source: 'ReactionPicker',
|
|
139
|
+
reason: 'close dialog'
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}, [settings]);
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Event handle rwhen selecting to show the custom emoji icons picker
|
|
146
|
+
* @param e event param
|
|
147
|
+
*/
|
|
148
|
+
const onSelectMoreClick = useCallback(e => {
|
|
149
|
+
e.preventDefault();
|
|
150
|
+
setSettings({
|
|
151
|
+
isOpen: true,
|
|
152
|
+
showFullPicker: true,
|
|
153
|
+
popperPlacement
|
|
154
|
+
});
|
|
155
|
+
onShowMore();
|
|
156
|
+
}, [onShowMore, popperPlacement]);
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Event callback when an emoji icon is selected
|
|
160
|
+
* @param item selected item
|
|
161
|
+
*/
|
|
162
|
+
const onEmojiSelected = useCallback(item => {
|
|
163
|
+
// no emoji was selected
|
|
164
|
+
if (!item.id) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
onSelection(item.id, settings.showFullPicker ? 'emojiPicker' : 'quickSelector');
|
|
168
|
+
close(item.id);
|
|
169
|
+
}, [close, onSelection, settings.showFullPicker]);
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Event handler when the emoji icon to open the custom picker is selected
|
|
173
|
+
*/
|
|
174
|
+
const onTriggerClick = () => {
|
|
175
|
+
// ufo start reactions picker open experience
|
|
176
|
+
PickerRender.start();
|
|
177
|
+
setSettings({
|
|
178
|
+
isOpen: !settings.isOpen,
|
|
179
|
+
showFullPicker: !!allowAllEmojis && Array.isArray(pickerQuickReactionEmojiIds) && pickerQuickReactionEmojiIds.length === 0,
|
|
180
|
+
popperPlacement
|
|
181
|
+
});
|
|
182
|
+
onOpen();
|
|
183
|
+
// ufo reactions picker opened success
|
|
184
|
+
PickerRender.success();
|
|
185
|
+
};
|
|
186
|
+
const wrapperClassName = ` ${settings.isOpen ? 'isOpen' : ''} ${miniMode ? 'miniMode' : ''} ${className}`;
|
|
187
|
+
useLayoutEffect(() => {
|
|
188
|
+
var _updatePopper$current;
|
|
189
|
+
(_updatePopper$current = updatePopper.current) === null || _updatePopper$current === void 0 ? void 0 : _updatePopper$current.call(updatePopper);
|
|
190
|
+
}, [settings]);
|
|
191
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
192
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
193
|
+
className: ax(["_s7n4nkob _1pra1o8l", wrapperClassName]),
|
|
194
|
+
"data-testid": RENDER_REACTIONPICKER_TESTID,
|
|
195
|
+
ref: wrapperRef
|
|
196
|
+
}, /*#__PURE__*/React.createElement(Manager, null, /*#__PURE__*/React.createElement(Reference, null, ({
|
|
197
|
+
ref
|
|
198
|
+
}) =>
|
|
199
|
+
/*#__PURE__*/
|
|
200
|
+
// Render a button to open the <Selector /> panel
|
|
201
|
+
React.createElement(Trigger, {
|
|
202
|
+
ariaAttributes: {
|
|
203
|
+
'aria-expanded': settings.isOpen,
|
|
204
|
+
'aria-controls': PICKER_CONTROL_ID
|
|
205
|
+
},
|
|
206
|
+
ref: node => {
|
|
207
|
+
if (node && settings.isOpen) {
|
|
208
|
+
if (typeof ref === 'function') {
|
|
209
|
+
ref(node);
|
|
210
|
+
} else {
|
|
211
|
+
ref.current = node;
|
|
212
|
+
}
|
|
213
|
+
setTriggerRef(node);
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
isSelected: settings.isOpen,
|
|
217
|
+
onClick: onTriggerClick,
|
|
218
|
+
miniMode: miniMode,
|
|
219
|
+
disabled: disabled,
|
|
220
|
+
tooltipContent: settings.isOpen ? null : tooltipContent,
|
|
221
|
+
showOpaqueBackground: showOpaqueBackground,
|
|
222
|
+
showAddReactionText: showAddReactionText,
|
|
223
|
+
subtleReactionsSummaryAndPicker: subtleReactionsSummaryAndPicker,
|
|
224
|
+
showRoundTrigger: showRoundTrigger,
|
|
225
|
+
reactionPickerTriggerIcon: reactionPickerTriggerIcon
|
|
226
|
+
})), settings.isOpen && /*#__PURE__*/React.createElement(PopperWrapper, {
|
|
227
|
+
settings: settings,
|
|
228
|
+
popperModifiers: popperModifiers
|
|
229
|
+
}, settings.showFullPicker ? /*#__PURE__*/React.createElement(EmojiPicker, {
|
|
230
|
+
emojiProvider: emojiProvider,
|
|
231
|
+
onSelection: onEmojiSelected,
|
|
232
|
+
size: emojiPickerSize
|
|
233
|
+
}) : /*#__PURE__*/React.createElement("div", {
|
|
234
|
+
className: ax(["_1e0c1txw"])
|
|
235
|
+
}, /*#__PURE__*/React.createElement(Selector, {
|
|
236
|
+
emojiProvider: emojiProvider,
|
|
237
|
+
onSelection: onEmojiSelected,
|
|
238
|
+
showMore: allowAllEmojis,
|
|
239
|
+
onMoreClick: onSelectMoreClick,
|
|
240
|
+
pickerQuickReactionEmojiIds: pickerQuickReactionEmojiIds
|
|
241
|
+
})))));
|
|
242
|
+
});
|
|
243
|
+
export const PopperWrapper = props => {
|
|
244
|
+
const {
|
|
245
|
+
settings,
|
|
246
|
+
children,
|
|
247
|
+
popperModifiers
|
|
248
|
+
} = props;
|
|
249
|
+
const [popupRef, setPopupRef] = useState(null);
|
|
250
|
+
/**
|
|
251
|
+
* add focus lock to popup
|
|
252
|
+
*/
|
|
253
|
+
useFocusTrap({
|
|
254
|
+
initialFocusRef: null,
|
|
255
|
+
targetRef: popupRef
|
|
256
|
+
});
|
|
257
|
+
return /*#__PURE__*/React.createElement(Popper, {
|
|
258
|
+
placement: settings.popperPlacement,
|
|
259
|
+
modifiers: popperModifiers,
|
|
260
|
+
strategy: "absolute"
|
|
261
|
+
}, ({
|
|
262
|
+
ref,
|
|
263
|
+
style,
|
|
264
|
+
update
|
|
265
|
+
}) => {
|
|
266
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
267
|
+
id: PICKER_CONTROL_ID,
|
|
268
|
+
"data-testid": RENDER_REACTIONPICKERPANEL_TESTID
|
|
269
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
270
|
+
,
|
|
271
|
+
style: {
|
|
272
|
+
zIndex: layers.layer(),
|
|
273
|
+
...style
|
|
274
|
+
},
|
|
275
|
+
ref: node => {
|
|
276
|
+
if (node) {
|
|
277
|
+
if (typeof ref === 'function') {
|
|
278
|
+
ref(node);
|
|
279
|
+
} else {
|
|
280
|
+
ref.current = node;
|
|
281
|
+
}
|
|
282
|
+
setPopupRef(node);
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
286
|
+
tabIndex: 0,
|
|
287
|
+
className: ax(["_nt751r31 _49pcglyw _1hvw1o36"])
|
|
288
|
+
}, /*#__PURE__*/React.createElement(RepositionOnUpdate, {
|
|
289
|
+
update: update,
|
|
290
|
+
settings: settings
|
|
291
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
292
|
+
className: ax(["_2rko1sit _bfhk1bhr _16qs1kf5 _1bch1b66 _79pa1b66"])
|
|
293
|
+
}, children)));
|
|
294
|
+
});
|
|
295
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
._19bvu2gc{padding-left:var(--ds-space-100,8px)}
|
|
2
|
+
._8hrz1nam{transform-origin:center center 0}
|
|
3
|
+
._ca0q1b66{padding-top:var(--ds-space-050,4px)}
|
|
4
|
+
._ca0qv77o{padding-top:var(--ds-space-025,2px)}
|
|
5
|
+
._kqswh2mm{position:relative}
|
|
6
|
+
._n3td1b66{padding-bottom:var(--ds-space-050,4px)}
|
|
7
|
+
._u5f31b66{padding-right:var(--ds-space-050,4px)}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/* ReactionSummaryButton.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import "./ReactionSummaryButton.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import { forwardRef, useMemo } from 'react';
|
|
6
|
+
import { useIntl } from 'react-intl-next';
|
|
7
|
+
import { ResourcedEmoji } from '@atlaskit/emoji';
|
|
8
|
+
import { messages } from '../../shared/i18n';
|
|
9
|
+
import { Counter } from './Counter';
|
|
10
|
+
import { ReactionButton } from './ReactionButton';
|
|
11
|
+
import { Box, Flex, Inline } from '@atlaskit/primitives/compiled';
|
|
12
|
+
import { cx } from '@compiled/react';
|
|
13
|
+
const styles = {
|
|
14
|
+
emoji: "_8hrz1nam",
|
|
15
|
+
button: "_ca0q1b66 _u5f31b66 _n3td1b66 _19bvu2gc",
|
|
16
|
+
compactPadding: "_ca0qv77o",
|
|
17
|
+
container: "_kqswh2mm"
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Test id for summary reaction wrapper button
|
|
21
|
+
*/
|
|
22
|
+
export const RENDER_SUMMARY_BUTTON_TESTID = 'reaction-summary-button';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Test id for emojis displayed inside summary button. All emoji's in the summary button will have this test id
|
|
26
|
+
*/
|
|
27
|
+
export const RENDER_SUMMARY_EMOJI_TESTID = 'summary-emoji-display';
|
|
28
|
+
|
|
29
|
+
// forwardRef is used here so that the parent popup component can properly interact with the button
|
|
30
|
+
export const ReactionSummaryButton = /*#__PURE__*/forwardRef(({
|
|
31
|
+
emojiProvider,
|
|
32
|
+
reactions = [],
|
|
33
|
+
emojisToShow = 3,
|
|
34
|
+
onClick,
|
|
35
|
+
showOpaqueBackground = false,
|
|
36
|
+
subtleReactionsSummaryAndPicker = false,
|
|
37
|
+
useCompactStyles = false,
|
|
38
|
+
useButtonAlignmentStyling = false
|
|
39
|
+
}, ref) => {
|
|
40
|
+
const intl = useIntl();
|
|
41
|
+
|
|
42
|
+
// Helper function to sort reactions by count and return top N
|
|
43
|
+
const getTopReactions = (reactions, topN) => {
|
|
44
|
+
return [...reactions].sort((a, b) => b.count - a.count).slice(0, topN);
|
|
45
|
+
};
|
|
46
|
+
const totalReactionsCount = useMemo(() => {
|
|
47
|
+
return reactions.reduce((accum, current) => {
|
|
48
|
+
return accum += (current === null || current === void 0 ? void 0 : current.count) || 0;
|
|
49
|
+
}, 0);
|
|
50
|
+
}, [reactions]);
|
|
51
|
+
const topReactions = useMemo(() => getTopReactions(reactions, emojisToShow), [emojisToShow, reactions]);
|
|
52
|
+
return /*#__PURE__*/React.createElement(Flex, {
|
|
53
|
+
xcss: styles.container,
|
|
54
|
+
ref: ref,
|
|
55
|
+
alignItems: "center",
|
|
56
|
+
justifyContent: "center"
|
|
57
|
+
}, /*#__PURE__*/React.createElement(ReactionButton, {
|
|
58
|
+
onClick: onClick,
|
|
59
|
+
testId: RENDER_SUMMARY_BUTTON_TESTID,
|
|
60
|
+
ariaLabel: intl.formatMessage(messages.summary),
|
|
61
|
+
useCompactStyles: useCompactStyles,
|
|
62
|
+
showSubtleStyle: subtleReactionsSummaryAndPicker,
|
|
63
|
+
showOpaqueBackground: showOpaqueBackground
|
|
64
|
+
}, /*#__PURE__*/React.createElement(Inline, {
|
|
65
|
+
space: "space.050",
|
|
66
|
+
xcss: cx(styles.button, useCompactStyles && styles.compactPadding),
|
|
67
|
+
testId: "reaction-summary-wrapper"
|
|
68
|
+
}, topReactions.map(reaction => /*#__PURE__*/React.createElement(Box, {
|
|
69
|
+
xcss: styles.emoji,
|
|
70
|
+
testId: RENDER_SUMMARY_EMOJI_TESTID,
|
|
71
|
+
style: {
|
|
72
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/design-system/use-tokens-typography
|
|
73
|
+
lineHeight: '12px'
|
|
74
|
+
}
|
|
75
|
+
}, /*#__PURE__*/React.createElement(ResourcedEmoji, {
|
|
76
|
+
key: reaction.emojiId,
|
|
77
|
+
emojiProvider: emojiProvider,
|
|
78
|
+
emojiId: {
|
|
79
|
+
id: reaction.emojiId,
|
|
80
|
+
shortName: ''
|
|
81
|
+
},
|
|
82
|
+
fitToHeight: useCompactStyles ? 12 : 16
|
|
83
|
+
})))), /*#__PURE__*/React.createElement(Counter, {
|
|
84
|
+
value: totalReactionsCount,
|
|
85
|
+
useDarkerFont: useCompactStyles || useButtonAlignmentStyling,
|
|
86
|
+
useUpdatedStyles: !useCompactStyles && useButtonAlignmentStyling
|
|
87
|
+
})));
|
|
88
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/* ReactionSummaryView.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import "./ReactionSummaryView.compiled.css";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
6
|
+
import { useCallback, useState } from 'react';
|
|
7
|
+
import Popup from '@atlaskit/popup';
|
|
8
|
+
import { Reaction } from './Reaction';
|
|
9
|
+
import { ReactionSummaryViewEmojiPicker } from '../ReactionSummary/ReactionSummaryViewEmojiPicker';
|
|
10
|
+
import { ReactionSummaryButton } from './ReactionSummaryButton';
|
|
11
|
+
import { Inline } from '@atlaskit/primitives/compiled';
|
|
12
|
+
const styles = {
|
|
13
|
+
summaryPopup: "_ca0q1b66 _u5f3u2gc _n3tdu2gc _19bvu2gc _p12foiq5"
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Test id for the Reactions summary view popup
|
|
18
|
+
*/
|
|
19
|
+
export const RENDER_SUMMARY_VIEW_POPUP_TESTID = 'render-summary-view-popup';
|
|
20
|
+
export const ReactionSummaryView = ({
|
|
21
|
+
emojiProvider,
|
|
22
|
+
reactions = [],
|
|
23
|
+
flash = {},
|
|
24
|
+
particleEffectByEmoji = {},
|
|
25
|
+
placement = 'auto-start',
|
|
26
|
+
onReactionClick,
|
|
27
|
+
onReactionFocused,
|
|
28
|
+
onReactionMouseEnter,
|
|
29
|
+
showOpaqueBackground = false,
|
|
30
|
+
subtleReactionsSummaryAndPicker = false,
|
|
31
|
+
allowUserDialog,
|
|
32
|
+
handleOpenReactionsDialog,
|
|
33
|
+
isViewOnly = false,
|
|
34
|
+
allowSelectFromSummaryView,
|
|
35
|
+
disabled,
|
|
36
|
+
emojiPickerSize,
|
|
37
|
+
onSelection,
|
|
38
|
+
tooltipContent,
|
|
39
|
+
reactionPickerTriggerIcon,
|
|
40
|
+
onOpen,
|
|
41
|
+
useButtonAlignmentStyling
|
|
42
|
+
}) => {
|
|
43
|
+
const [isSummaryPopupOpen, setSummaryPopupOpen] = useState(false);
|
|
44
|
+
const handlePopupClose = useCallback(() => setSummaryPopupOpen(false), []);
|
|
45
|
+
const handleSummaryClick = useCallback(() => setSummaryPopupOpen(!isSummaryPopupOpen), [isSummaryPopupOpen]);
|
|
46
|
+
return /*#__PURE__*/React.createElement(Popup, {
|
|
47
|
+
placement: placement,
|
|
48
|
+
content: () => /*#__PURE__*/React.createElement(Inline, {
|
|
49
|
+
xcss: styles.summaryPopup,
|
|
50
|
+
testId: RENDER_SUMMARY_VIEW_POPUP_TESTID,
|
|
51
|
+
space: "space.025",
|
|
52
|
+
shouldWrap: true,
|
|
53
|
+
alignBlock: "center"
|
|
54
|
+
}, reactions.map(reaction => /*#__PURE__*/React.createElement(Reaction, {
|
|
55
|
+
key: reaction.emojiId,
|
|
56
|
+
reaction: reaction,
|
|
57
|
+
emojiProvider: emojiProvider,
|
|
58
|
+
onClick: onReactionClick,
|
|
59
|
+
onFocused: onReactionFocused,
|
|
60
|
+
onMouseEnter: onReactionMouseEnter,
|
|
61
|
+
flash: flash[reaction.emojiId],
|
|
62
|
+
showParticleEffect: particleEffectByEmoji[reaction.emojiId],
|
|
63
|
+
allowUserDialog: allowUserDialog,
|
|
64
|
+
handleOpenReactionsDialog: handleOpenReactionsDialog,
|
|
65
|
+
isViewOnly: isViewOnly
|
|
66
|
+
})), allowSelectFromSummaryView && /*#__PURE__*/React.createElement(ReactionSummaryViewEmojiPicker, {
|
|
67
|
+
emojiProvider: emojiProvider,
|
|
68
|
+
disabled: disabled,
|
|
69
|
+
onSelection: onSelection,
|
|
70
|
+
emojiPickerSize: emojiPickerSize,
|
|
71
|
+
tooltipContent: tooltipContent,
|
|
72
|
+
reactionPickerTriggerIcon: reactionPickerTriggerIcon,
|
|
73
|
+
onOpen: onOpen
|
|
74
|
+
})),
|
|
75
|
+
isOpen: isSummaryPopupOpen,
|
|
76
|
+
onClose: handlePopupClose,
|
|
77
|
+
trigger: triggerProps => /*#__PURE__*/React.createElement(ReactionSummaryButton, _extends({}, triggerProps, {
|
|
78
|
+
emojiProvider: emojiProvider,
|
|
79
|
+
reactions: reactions,
|
|
80
|
+
onClick: handleSummaryClick,
|
|
81
|
+
showOpaqueBackground: showOpaqueBackground,
|
|
82
|
+
subtleReactionsSummaryAndPicker: subtleReactionsSummaryAndPicker,
|
|
83
|
+
useCompactStyles: allowSelectFromSummaryView,
|
|
84
|
+
useButtonAlignmentStyling: useButtonAlignmentStyling
|
|
85
|
+
}))
|
|
86
|
+
});
|
|
87
|
+
};
|
|
@@ -14,8 +14,8 @@ import { ReactionStatus } from '../../types';
|
|
|
14
14
|
import { ReactionDialogOpened, ReactionDialogSelectedReactionChanged } from '../../ufo';
|
|
15
15
|
import { Reaction } from './Reaction';
|
|
16
16
|
import { ReactionsDialog } from './ReactionsDialog';
|
|
17
|
-
import { ReactionPicker } from '
|
|
18
|
-
import { ReactionSummaryView } from '
|
|
17
|
+
import { ReactionPicker } from './ReactionPicker';
|
|
18
|
+
import { ReactionSummaryView } from './ReactionSummaryView';
|
|
19
19
|
const wrapperStyle = null;
|
|
20
20
|
const noFlexWrapStyles = null;
|
|
21
21
|
const noContainerPositionStyles = null;
|
|
@@ -108,7 +108,7 @@ export const Reactions = /*#__PURE__*/React.memo(({
|
|
|
108
108
|
allowSelectFromSummaryView = false,
|
|
109
109
|
useButtonAlignmentStyling = false
|
|
110
110
|
}) => {
|
|
111
|
-
const [selectedEmojiId, setSelectedEmojiId] = useState();
|
|
111
|
+
const [selectedEmojiId, setSelectedEmojiId] = useState('');
|
|
112
112
|
const {
|
|
113
113
|
createAnalyticsEvent
|
|
114
114
|
} = useAnalyticsEvents();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
._y44v8out{animation:k12q5x3s .15s ease-in-out forwards}._12l2u2gc{margin-inline-end:var(--ds-space-100,8px)}
|
|
3
|
+
._19bv1b66{padding-left:var(--ds-space-050,4px)}
|
|
4
|
+
._1e0c1o8l{display:inline-block}
|
|
5
|
+
._1p3lnqa1{border-left-style:solid}
|
|
6
|
+
._4t3i1tcg{height:24px}
|
|
7
|
+
._5wramuej{border-left-color:var(--ds-border,#091e4224)}
|
|
8
|
+
._ahbq1b66{margin-inline-start:var(--ds-space-050,4px)}
|
|
9
|
+
._ca0q1b66{padding-top:var(--ds-space-050,4px)}
|
|
10
|
+
._n3td1b66{padding-bottom:var(--ds-space-050,4px)}
|
|
11
|
+
._t6vde4h9{border-left-width:var(--ds-border-width,1px)}
|
|
12
|
+
._tzy4idpf{opacity:0}
|
|
13
|
+
._u5f31b66{padding-right:var(--ds-space-050,4px)}
|
|
14
|
+
@keyframes k12q5x3s{0%{opacity:1;transform:scale(.5)}75%{transform:scale(1.25)}to{opacity:1;transform:scale(1)}}
|