@atlaskit/editor-plugin-find-replace 6.0.9 → 6.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,11 +9,9 @@ import React from 'react';
9
9
 
10
10
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
11
11
  import { jsx } from '@emotion/react';
12
- import { fg } from '@atlaskit/platform-feature-flags';
13
12
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
14
13
  import Find from './Find';
15
14
  import Replace from './Replace';
16
- import ReplaceNext from './ReplaceNext';
17
15
  import { ruleStyles, wrapperPaddingStyles, wrapperStyles } from './ui-styles';
18
16
  // eslint-disable-next-line @repo/internal/react/no-class-components
19
17
  class FindReplace extends React.PureComponent {
@@ -21,32 +19,6 @@ class FindReplace extends React.PureComponent {
21
19
  super(props);
22
20
  _defineProperty(this, "findTextfield", null);
23
21
  _defineProperty(this, "replaceTextfield", null);
24
- /**
25
- * Delete this function on cleanup of
26
- * editor_a11y_refactor_find_replace_style
27
- */
28
- _defineProperty(this, "handleTabNavigation", event => {
29
- if (fg('editor_a11y_refactor_find_replace_style')) {
30
- return;
31
- }
32
- if (event.key === 'Tab') {
33
- event.preventDefault();
34
- const modalFindReplace = this.modalRef.current;
35
- if (!modalFindReplace || !modalFindReplace.contains(document.activeElement)) {
36
- return;
37
- }
38
- const focusableElements = Array.from(modalFindReplace.querySelectorAll('[tabindex]:not([tabindex="-1"]), input, button')).filter(el => el.getAttribute('tabindex') !== '-1');
39
- const currentIndex = focusableElements.findIndex(el => el === document.activeElement);
40
- const isShiftPressed = event.shiftKey;
41
- if (isShiftPressed) {
42
- const prevIndex = (currentIndex - 1 + focusableElements.length) % focusableElements.length;
43
- focusableElements[prevIndex].focus();
44
- } else {
45
- const nextIndex = (currentIndex + 1) % focusableElements.length;
46
- focusableElements[nextIndex].focus();
47
- }
48
- }
49
- });
50
22
  _defineProperty(this, "state", {
51
23
  findTyped: false
52
24
  });
@@ -73,14 +45,6 @@ class FindReplace extends React.PureComponent {
73
45
  });
74
46
  this.modalRef = /*#__PURE__*/React.createRef();
75
47
  }
76
- componentDidMount() {
77
- // eslint-disable-next-line
78
- window.addEventListener('keydown', this.handleTabNavigation);
79
- }
80
- componentWillUnmount() {
81
- // eslint-disable-next-line
82
- window.removeEventListener('keydown', this.handleTabNavigation);
83
- }
84
48
  render() {
85
49
  const {
86
50
  findText,
@@ -102,7 +66,9 @@ class FindReplace extends React.PureComponent {
102
66
  } = this.props;
103
67
  const focusToolbarButton = this.props.focusToolbarButton || (() => {});
104
68
  return jsx("div", {
105
- role: 'dialog',
69
+ role: 'dialog'
70
+ // eslint-disable-next-line @atlassian/i18n/no-literal-string-in-jsx
71
+ ,
106
72
  "aria-label": 'Find and Replace',
107
73
  "aria-modal": false,
108
74
  ref: this.modalRef
@@ -129,22 +95,7 @@ class FindReplace extends React.PureComponent {
129
95
  role: "presentation",
130
96
  css: ruleStyles,
131
97
  id: "replace-hr-element"
132
- }), fg('editor_a11y_refactor_find_replace_style') ? jsx(ReplaceNext, {
133
- canReplace: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? !!isReplaceable : count.total > 0,
134
- replaceText: replaceText,
135
- onReplace: onReplace,
136
- onReplaceAll: onReplaceAll,
137
- onReplaceTextfieldRefSet: this.setReplaceTextfieldRef,
138
- onArrowUp: this.setFocusToFind,
139
- onCancel: onCancel,
140
- count: count,
141
- onFindPrev: onFindPrev,
142
- onFindNext: onFindNext,
143
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
144
- findTyped: this.state.findTyped,
145
- setFindTyped: this.setFindTyped,
146
- focusToolbarButton: focusToolbarButton
147
- }) : jsx(Replace, {
98
+ }), jsx(Replace, {
148
99
  canReplace: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? !!isReplaceable : count.total > 0,
149
100
  replaceText: replaceText,
150
101
  onReplace: onReplace,
@@ -1,332 +1,243 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- /* eslint-disable @atlaskit/design-system/consistent-css-prop-usage */
3
- /**
4
- * @jsxRuntime classic
5
- * @jsx jsx
6
- */
7
- import React, { Fragment } from 'react';
8
-
9
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
10
- import { css, jsx } from '@emotion/react';
1
+ import React, { useState, useRef, useEffect } from 'react';
11
2
  import { injectIntl } from 'react-intl-next';
12
3
  import Button from '@atlaskit/button/new';
13
4
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, TRIGGER_METHOD } from '@atlaskit/editor-common/analytics';
14
5
  import { findReplaceMessages as messages } from '@atlaskit/editor-common/messages';
15
- import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
16
- import { Label, ValidMessage } from '@atlaskit/form';
6
+ import { ValidMessage } from '@atlaskit/form';
17
7
  import ChevronDownIcon from '@atlaskit/icon/core/migration/chevron-down--hipchat-chevron-down';
18
8
  import ChevronUpIcon from '@atlaskit/icon/core/migration/chevron-up--hipchat-chevron-up';
19
9
  // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
20
- import { Inline, xcss } from '@atlaskit/primitives';
10
+ import { Box, Inline, Text, xcss } from '@atlaskit/primitives';
21
11
  import Textfield from '@atlaskit/textfield';
22
12
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
23
13
  import { FindReplaceTooltipButton } from './FindReplaceTooltipButton';
24
- import { nextPreviousItemStyles, orderZeroStyles, textFieldWrapper } from './ui-styles';
25
- const sectionWrapperStyles = css({
26
- display: 'flex',
27
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
28
- '& > *': {
29
- display: 'inline-flex',
30
- height: '32px',
31
- flex: '0 0 auto'
32
- },
33
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
34
- '& > [data-ds--text-field--container]': {
35
- display: 'flex',
36
- flex: '1 1 auto'
37
- }
14
+ const replaceContainerStyles = xcss({
15
+ padding: 'space.100'
38
16
  });
39
- const sectionWrapperStylesAlternate = css({
40
- display: 'flex',
41
- padding: "var(--ds-space-100, 8px)",
42
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
43
- '& > *': {
44
- height: 'unset'
45
- }
17
+ const replaceWithLabelStyle = xcss({
18
+ paddingBottom: 'space.050'
19
+ });
20
+ const actionButtonContainerStyles = xcss({
21
+ paddingTop: 'space.200'
46
22
  });
47
- const sectionWrapperJustified = css({
23
+ const actionButtonParentInlineStyles = xcss({
48
24
  justifyContent: 'space-between',
49
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
50
- fontSize: relativeFontSizeToBase16(14)
25
+ flexDirection: 'row-reverse'
51
26
  });
52
- const sectionWrapperFlexWrap = css({
53
- flexWrap: 'wrap-reverse',
54
- gap: "var(--ds-space-075, 6px)"
27
+ const actionButtonParentInlineStylesNew = xcss({
28
+ justifyContent: 'space-between',
29
+ flexDirection: 'row-reverse',
30
+ flexWrap: 'wrap'
55
31
  });
56
- const orderOneStyles = css({
57
- order: '1'
32
+ const actionButtonInlineStyles = xcss({
33
+ gap: 'space.075'
58
34
  });
59
- const orderOneStylesNew = css({
60
- order: '1',
61
- marginLeft: 'auto'
35
+ const closeButtonInlineStyles = xcss({
36
+ marginRight: 'auto'
62
37
  });
63
- // eslint-disable-next-line @repo/internal/react/no-class-components
64
- class Replace extends React.PureComponent {
65
- constructor(props) {
66
- super(props);
67
- _defineProperty(this, "replaceTextfieldRef", /*#__PURE__*/React.createRef());
68
- _defineProperty(this, "successReplacementMessageRef", /*#__PURE__*/React.createRef());
69
- _defineProperty(this, "isComposing", false);
70
- _defineProperty(this, "skipWhileComposing", fn => {
71
- if (this.state.isComposing) {
72
- return;
73
- }
38
+ const Replace = ({
39
+ canReplace,
40
+ replaceText: initialReplaceText,
41
+ onReplace,
42
+ onReplaceAll,
43
+ onReplaceTextfieldRefSet,
44
+ onArrowUp,
45
+ onCancel,
46
+ count,
47
+ onFindNext,
48
+ onFindPrev,
49
+ dispatchAnalyticsEvent,
50
+ setFindTyped,
51
+ findTyped,
52
+ focusToolbarButton,
53
+ intl: {
54
+ formatMessage
55
+ }
56
+ }) => {
57
+ const [replaceText, setReplaceText] = useState(initialReplaceText || '');
58
+ const [isComposing, setIsComposing] = useState(false);
59
+ const [isHelperMessageVisible, setIsHelperMessageVisible] = useState(false);
60
+ const [fakeSuccessReplacementMessageUpdate, setFakeSuccessReplacementMessageUpdate] = useState(false);
61
+ const [replaceCount, setReplaceCount] = useState(0);
62
+ const replaceTextfieldRef = useRef(null);
63
+ const successReplacementMessageRef = useRef(null);
64
+ const replaceWith = formatMessage(messages.replaceWith);
65
+ const replaceAll = formatMessage(messages.replaceAll);
66
+ const findPrevious = formatMessage(messages.findPrevious);
67
+ const closeFindReplaceDialog = formatMessage(messages.closeFindReplaceDialog);
68
+ useEffect(() => {
69
+ onReplaceTextfieldRefSet(replaceTextfieldRef);
70
+ }, [onReplaceTextfieldRefSet]);
71
+ useEffect(() => {
72
+ setReplaceText(initialReplaceText || '');
73
+ }, [initialReplaceText]);
74
+ const skipWhileComposing = fn => {
75
+ if (!isComposing) {
74
76
  fn();
77
+ }
78
+ };
79
+ const triggerSuccessReplacementMessageUpdate = currentReplaceCount => {
80
+ if (replaceCount === currentReplaceCount) {
81
+ setFakeSuccessReplacementMessageUpdate(!fakeSuccessReplacementMessageUpdate);
82
+ }
83
+ if (successReplacementMessageRef.current) {
84
+ const ariaLiveRegion = successReplacementMessageRef.current.querySelector('[aria-live="polite"]');
85
+ ariaLiveRegion === null || ariaLiveRegion === void 0 ? void 0 : ariaLiveRegion.removeAttribute('aria-live');
86
+ ariaLiveRegion === null || ariaLiveRegion === void 0 ? void 0 : ariaLiveRegion.setAttribute('aria-live', 'polite');
87
+ }
88
+ };
89
+ const handleReplaceClick = () => skipWhileComposing(() => {
90
+ onReplace({
91
+ triggerMethod: TRIGGER_METHOD.BUTTON,
92
+ replaceText
75
93
  });
76
- _defineProperty(this, "handleReplaceClick", () => this.skipWhileComposing(() => {
77
- this.props.onReplace({
78
- triggerMethod: TRIGGER_METHOD.BUTTON,
79
- replaceText: this.state.replaceText
94
+ triggerSuccessReplacementMessageUpdate(1);
95
+ setIsHelperMessageVisible(true);
96
+ setReplaceCount(1);
97
+ setFindTyped(false);
98
+ });
99
+ const handleReplaceChange = event => skipWhileComposing(() => {
100
+ updateReplaceValue(event.target.value);
101
+ });
102
+ const updateReplaceValue = text => {
103
+ if (dispatchAnalyticsEvent) {
104
+ dispatchAnalyticsEvent({
105
+ eventType: EVENT_TYPE.TRACK,
106
+ action: ACTION.CHANGED_REPLACEMENT_TEXT,
107
+ actionSubject: ACTION_SUBJECT.FIND_REPLACE_DIALOG
80
108
  });
81
- // for replace button replaceCount always 1;
82
- const replaceCount = 1;
83
- this.triggerSuccessReplacementMessageUpdate(replaceCount);
84
- this.setState({
85
- isHelperMessageVisible: true,
86
- replaceCount
87
- });
88
- this.props.setFindTyped(false);
89
- }));
90
- _defineProperty(this, "handleReplaceChange", event => this.skipWhileComposing(() => {
91
- this.updateReplaceValue(event.target.value);
92
- }));
93
- _defineProperty(this, "updateReplaceValue", replaceText => {
94
- const {
95
- dispatchAnalyticsEvent
96
- } = this.props;
97
- if (dispatchAnalyticsEvent) {
98
- dispatchAnalyticsEvent({
99
- eventType: EVENT_TYPE.TRACK,
100
- action: ACTION.CHANGED_REPLACEMENT_TEXT,
101
- actionSubject: ACTION_SUBJECT.FIND_REPLACE_DIALOG
102
- });
103
- }
104
- this.setState({
109
+ }
110
+ setReplaceText(text);
111
+ };
112
+ const handleReplaceKeyDown = event => skipWhileComposing(() => {
113
+ if (event.key === 'Enter') {
114
+ onReplace({
115
+ triggerMethod: TRIGGER_METHOD.KEYBOARD,
105
116
  replaceText
106
117
  });
118
+ } else if (event.key === 'ArrowUp') {
119
+ onArrowUp();
120
+ }
121
+ });
122
+ const handleReplaceAllClick = () => skipWhileComposing(() => {
123
+ onReplaceAll({
124
+ replaceText
107
125
  });
108
- _defineProperty(this, "handleReplaceKeyDown", event => this.skipWhileComposing(() => {
109
- if (event.key === 'Enter') {
110
- this.props.onReplace({
111
- triggerMethod: TRIGGER_METHOD.KEYBOARD,
112
- replaceText: this.state.replaceText
113
- });
114
- } else if (event.key === 'ArrowUp') {
115
- // we want to move focus between find & replace texfields when user hits up/down arrows
116
- this.props.onArrowUp();
117
- }
118
- }));
119
- _defineProperty(this, "handleReplaceAllClick", () => this.skipWhileComposing(() => {
120
- this.props.onReplaceAll({
121
- replaceText: this.state.replaceText
122
- });
123
- this.setState({
124
- isHelperMessageVisible: true
125
- });
126
- if (this.props.count.totalReplaceable && expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
127
- this.triggerSuccessReplacementMessageUpdate(this.props.count.totalReplaceable);
128
- this.setState({
129
- replaceCount: this.props.count.totalReplaceable
130
- });
131
- } else {
132
- this.triggerSuccessReplacementMessageUpdate(this.props.count.total);
133
- this.setState({
134
- replaceCount: this.props.count.total
135
- });
136
- }
137
- this.props.setFindTyped(false);
138
- }));
139
- _defineProperty(this, "handleCompositionStart", () => {
140
- this.setState({
141
- isComposing: true
142
- });
143
- });
144
- _defineProperty(this, "handleCompositionEnd", event => {
145
- this.setState({
146
- isComposing: false
147
- });
148
- // type for React.CompositionEvent doesn't set type for target correctly
149
- this.updateReplaceValue(event.target.value);
150
- });
151
- _defineProperty(this, "clearSearch", () => {
152
- this.props.onCancel({
153
- triggerMethod: TRIGGER_METHOD.BUTTON
154
- });
155
- this.props.focusToolbarButton && this.props.focusToolbarButton();
156
- });
157
- _defineProperty(this, "handleFindNextClick", () => {
158
- if (this.isComposing) {
159
- return;
160
- }
161
- this.props.onFindNext({
162
- triggerMethod: TRIGGER_METHOD.BUTTON
163
- });
126
+ setIsHelperMessageVisible(true);
127
+ if (count.totalReplaceable && expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true)) {
128
+ triggerSuccessReplacementMessageUpdate(count.totalReplaceable);
129
+ setReplaceCount(count.totalReplaceable);
130
+ } else {
131
+ triggerSuccessReplacementMessageUpdate(count.total);
132
+ setReplaceCount(count.total);
133
+ }
134
+ setFindTyped(false);
135
+ });
136
+ const handleCompositionStart = () => {
137
+ setIsComposing(true);
138
+ };
139
+ const handleCompositionEnd = event => {
140
+ setIsComposing(false);
141
+ // type for React.CompositionEvent doesn't set type for target correctly
142
+ updateReplaceValue(event.target.value);
143
+ };
144
+ const clearSearch = () => {
145
+ onCancel({
146
+ triggerMethod: TRIGGER_METHOD.BUTTON
164
147
  });
165
- _defineProperty(this, "handleFindPrevClick", () => {
166
- if (this.isComposing) {
167
- return;
168
- }
169
- this.props.onFindPrev({
148
+ focusToolbarButton();
149
+ };
150
+ const handleFindNextClick = () => {
151
+ if (!isComposing) {
152
+ onFindNext({
170
153
  triggerMethod: TRIGGER_METHOD.BUTTON
171
154
  });
172
- });
173
- const {
174
- replaceText: _replaceText,
175
- intl: {
176
- formatMessage
177
- }
178
- } = props;
179
- this.state = {
180
- replaceText: _replaceText || '',
181
- isComposing: false,
182
- isHelperMessageVisible: false,
183
- fakeSuccessReplacementMessageUpdate: false,
184
- replaceCount: 0
185
- };
186
- this.replace = formatMessage(messages.replace);
187
- this.replaceWith = formatMessage(messages.replaceWith);
188
- this.replaceAll = formatMessage(messages.replaceAll);
189
- this.findNext = formatMessage(messages.findNext);
190
- this.findPrevious = formatMessage(messages.findPrevious);
191
- this.closeFindReplaceDialog = formatMessage(messages.closeFindReplaceDialog);
192
- }
193
- componentDidMount() {
194
- this.props.onReplaceTextfieldRefSet(this.replaceTextfieldRef);
195
- }
196
- componentDidUpdate({
197
- replaceText: prevReplaceText
198
- }) {
199
- const {
200
- replaceText
201
- } = this.props;
202
- if (replaceText && replaceText !== prevReplaceText) {
203
- this.setState({
204
- replaceText,
205
- isComposing: false
206
- });
207
- }
208
- const findTextField = document.getElementById('find-text-field');
209
- const replaceButton = document.getElementById('replace-button');
210
- const replaceAllButton = document.getElementById('replaceAll-button');
211
- if (((replaceButton === null || replaceButton === void 0 ? void 0 : replaceButton.tabIndex) === -1 || (replaceAllButton === null || replaceAllButton === void 0 ? void 0 : replaceAllButton.tabIndex) === -1) && findTextField) {
212
- findTextField.focus();
213
155
  }
214
- }
215
- triggerSuccessReplacementMessageUpdate(currentReplaceCount) {
216
- var _this$state;
217
- if (((_this$state = this.state) === null || _this$state === void 0 ? void 0 : _this$state.replaceCount) === currentReplaceCount) {
218
- this.setState({
219
- fakeSuccessReplacementMessageUpdate: !this.state.fakeSuccessReplacementMessageUpdate
156
+ };
157
+ const handleFindPrevClick = () => {
158
+ if (!isComposing) {
159
+ onFindPrev({
160
+ triggerMethod: TRIGGER_METHOD.BUTTON
220
161
  });
221
162
  }
222
- if (this.successReplacementMessageRef && this.successReplacementMessageRef.current) {
223
- const ariaLiveRegion = this.successReplacementMessageRef.current.querySelector('[aria-live="polite"]');
224
- ariaLiveRegion === null || ariaLiveRegion === void 0 ? void 0 : ariaLiveRegion.removeAttribute('aria-live');
225
- ariaLiveRegion === null || ariaLiveRegion === void 0 ? void 0 : ariaLiveRegion.setAttribute('aria-live', 'polite');
226
- }
227
- }
228
- render() {
229
- const {
230
- replaceText,
231
- isHelperMessageVisible,
232
- replaceCount
233
- } = this.state;
234
- const {
235
- canReplace,
236
- count,
237
- intl: {
238
- formatMessage
239
- }
240
- } = this.props;
241
- const resultsReplace = formatMessage(messages.replaceSuccess, {
242
- numberOfMatches: replaceCount
243
- });
244
- return jsx(Fragment, null, jsx("div", {
245
- css: [sectionWrapperStyles, sectionWrapperStylesAlternate]
246
- }, jsx("div", {
247
- css: textFieldWrapper
248
- }, jsx(Label, {
249
- htmlFor: "replace-text-field"
250
- }, this.replaceWith), jsx(Textfield, {
251
- name: "replace",
252
- id: "replace-text-field",
253
- testId: "replace-field",
254
- appearance: "standard",
255
- defaultValue: replaceText,
256
- ref: this.replaceTextfieldRef,
257
- autoComplete: "off",
258
- onChange: this.handleReplaceChange,
259
- onKeyDown: this.handleReplaceKeyDown,
260
- onCompositionStart: this.handleCompositionStart,
261
- onCompositionEnd: this.handleCompositionEnd
262
- }), isHelperMessageVisible && this.props.findTyped === false && jsx("div", {
263
- ref: this.successReplacementMessageRef
264
- }, jsx(ValidMessage, {
265
- testId: "message-success-replacement"
266
- },
267
- /*
268
- Replacement needed to trigger the SR announcement if message hasn't changed. e.g Replace button clicked twice.
269
- '\u00a0' is value for &nbsp
270
- */
271
- this.state.fakeSuccessReplacementMessageUpdate ?
272
- // Ignored via go/ees005
273
- // eslint-disable-next-line require-unicode-regexp
274
- resultsReplace.replace(/ /, '\u00a0') : resultsReplace)))), jsx("div", {
275
- css: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? [sectionWrapperStyles, sectionWrapperStylesAlternate, sectionWrapperJustified, sectionWrapperFlexWrap] : [sectionWrapperStyles, sectionWrapperStylesAlternate, sectionWrapperJustified]
276
- }, jsx("div", {
277
- css: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? orderOneStylesNew : orderOneStyles
278
- }, jsx("div", {
279
- css: nextPreviousItemStyles
280
- }, jsx(FindReplaceTooltipButton, {
281
- title: this.findNext,
282
- icon: iconProps => jsx(ChevronDownIcon, {
283
- label: iconProps.label,
284
- size: "small"
285
- }),
286
- iconLabel: this.findNext,
287
- keymapDescription: 'Enter',
288
- onClick: this.handleFindNextClick,
289
- disabled: count.total <= 1
290
- })), jsx("div", {
291
- css: nextPreviousItemStyles
292
- }, jsx(FindReplaceTooltipButton, {
293
- title: this.findPrevious,
294
- icon: iconProps => jsx(ChevronUpIcon, {
295
- label: iconProps.label,
296
- size: "small"
297
- }),
298
- iconLabel: this.findPrevious,
299
- keymapDescription: 'Shift Enter',
300
- onClick: this.handleFindPrevClick,
301
- disabled: count.total <= 1
302
- })), jsx(Inline, {
303
- space: "space.075"
304
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
305
- ,
306
- xcss: xcss({
307
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
308
- paddingInlineStart: 'space.050',
309
- // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
310
- paddingInlineEnd: 'space.025'
311
- })
312
- }, jsx(Button, {
313
- testId: this.replace,
314
- id: "replace-button",
315
- onClick: this.handleReplaceClick,
316
- isDisabled: !canReplace
317
- }, this.replace), jsx(Button, {
318
- appearance: "primary",
319
- testId: this.replaceAll,
320
- id: "replaceAll-button",
321
- onClick: this.handleReplaceAllClick,
322
- isDisabled: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? count.totalReplaceable === 0 : !canReplace
323
- }, this.replaceAll))), jsx("div", {
324
- css: orderZeroStyles
325
- }, jsx(Button, {
326
- appearance: "subtle",
327
- testId: this.closeFindReplaceDialog,
328
- onClick: this.clearSearch
329
- }, this.closeFindReplaceDialog))));
330
- }
331
- }
163
+ };
164
+ const resultsReplace = formatMessage(messages.replaceSuccess, {
165
+ numberOfMatches: replaceCount
166
+ });
167
+ return /*#__PURE__*/React.createElement(Box, {
168
+ xcss: replaceContainerStyles
169
+ }, /*#__PURE__*/React.createElement(Box, {
170
+ xcss: replaceWithLabelStyle
171
+ }, /*#__PURE__*/React.createElement(Text, {
172
+ id: "replace-text-field-label",
173
+ size: "medium",
174
+ weight: "bold",
175
+ color: "color.text.subtle"
176
+ }, replaceWith)), /*#__PURE__*/React.createElement(Textfield, {
177
+ name: "replace",
178
+ "aria-labelledby": "replace-text-field-label",
179
+ testId: "replace-field",
180
+ appearance: "standard",
181
+ defaultValue: replaceText,
182
+ ref: replaceTextfieldRef,
183
+ autoComplete: "off",
184
+ onChange: handleReplaceChange,
185
+ onKeyDown: handleReplaceKeyDown,
186
+ onCompositionStart: handleCompositionStart,
187
+ onCompositionEnd: handleCompositionEnd
188
+ }), isHelperMessageVisible && !findTyped && /*#__PURE__*/React.createElement("div", {
189
+ ref: successReplacementMessageRef
190
+ }, /*#__PURE__*/React.createElement(ValidMessage, {
191
+ testId: "message-success-replacement"
192
+ }, fakeSuccessReplacementMessageUpdate ?
193
+ // @ts-ignore - TS1501 TypeScript 5.9.2 upgrade
194
+ resultsReplace.replace(/ /u, '\u00a0') : resultsReplace)), /*#__PURE__*/React.createElement(Box, {
195
+ xcss: actionButtonContainerStyles
196
+ }, /*#__PURE__*/React.createElement(Inline, {
197
+ xcss: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? [actionButtonInlineStyles, actionButtonParentInlineStylesNew] : [actionButtonInlineStyles, actionButtonParentInlineStyles]
198
+ }, /*#__PURE__*/React.createElement(Inline, {
199
+ xcss: actionButtonInlineStyles
200
+ }, /*#__PURE__*/React.createElement(FindReplaceTooltipButton, {
201
+ title: formatMessage(messages.findNext),
202
+ icon: iconProps => /*#__PURE__*/React.createElement(ChevronDownIcon, {
203
+ label: iconProps.label,
204
+ size: "small"
205
+ }),
206
+ iconLabel: formatMessage(messages.findNext),
207
+ keymapDescription: 'Enter',
208
+ onClick: handleFindNextClick,
209
+ disabled: count.total <= 1
210
+ }), /*#__PURE__*/React.createElement(FindReplaceTooltipButton, {
211
+ title: findPrevious,
212
+ icon: iconProps => /*#__PURE__*/React.createElement(ChevronUpIcon, {
213
+ label: iconProps.label,
214
+ size: "small"
215
+ }),
216
+ iconLabel: findPrevious,
217
+ keymapDescription: 'Shift Enter',
218
+ onClick: handleFindPrevClick,
219
+ disabled: count.total <= 1
220
+ }), /*#__PURE__*/React.createElement(Button, {
221
+ testId: 'Replace',
222
+ id: "replace-button",
223
+ onClick: handleReplaceClick,
224
+ isDisabled: !canReplace
225
+ }, formatMessage(messages.replace)), /*#__PURE__*/React.createElement(Button, {
226
+ appearance: "primary",
227
+ testId: replaceAll,
228
+ id: "replaceAll-button",
229
+ onClick: handleReplaceAllClick,
230
+ isDisabled: expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? count.totalReplaceable === 0 : !canReplace
231
+ }, replaceAll)), expValEquals('platform_editor_find_and_replace_improvements', 'isEnabled', true) ? /*#__PURE__*/React.createElement(Inline, {
232
+ xcss: closeButtonInlineStyles
233
+ }, /*#__PURE__*/React.createElement(Button, {
234
+ appearance: "subtle",
235
+ testId: closeFindReplaceDialog,
236
+ onClick: clearSearch
237
+ }, closeFindReplaceDialog)) : /*#__PURE__*/React.createElement(Button, {
238
+ appearance: "subtle",
239
+ testId: closeFindReplaceDialog,
240
+ onClick: clearSearch
241
+ }, closeFindReplaceDialog))));
242
+ };
332
243
  export default injectIntl(Replace);