@atlaskit/editor-plugin-type-ahead 1.9.0 → 1.10.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,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-type-ahead
|
|
2
2
|
|
|
3
|
+
## 1.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#152480](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/152480)
|
|
8
|
+
[`a3b60fc1e1aef`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a3b60fc1e1aef) -
|
|
9
|
+
Refactored typeahead assistiveText component to functional component and added tests.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#152510](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/152510)
|
|
14
|
+
[`dcf9edde7ac7b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/dcf9edde7ac7b) -
|
|
15
|
+
bump adf-schema to 42.0.1
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 1.9.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
|
-
exports.AssistiveText = void 0;
|
|
8
|
+
exports.AssistiveTextNew = exports.AssistiveText = void 0;
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
8
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
12
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
@@ -12,9 +14,12 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
12
14
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
15
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
var _react =
|
|
17
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
16
18
|
var _react2 = require("@emotion/react");
|
|
17
19
|
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
20
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
22
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
23
|
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2.default)(t); if (r) { var s = (0, _getPrototypeOf2.default)(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2.default)(this, e); }; }
|
|
19
24
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /**
|
|
20
25
|
* @jsxRuntime classic
|
|
@@ -33,12 +38,12 @@ var assitiveTextStyles = (0, _react2.css)({
|
|
|
33
38
|
whitespace: 'nowrap',
|
|
34
39
|
width: '1px'
|
|
35
40
|
});
|
|
36
|
-
var
|
|
37
|
-
(0, _inherits2.default)(
|
|
38
|
-
var _super = _createSuper(
|
|
39
|
-
function
|
|
41
|
+
var AssistveTextOld = /*#__PURE__*/function (_React$Component) {
|
|
42
|
+
(0, _inherits2.default)(AssistveTextOld, _React$Component);
|
|
43
|
+
var _super = _createSuper(AssistveTextOld);
|
|
44
|
+
function AssistveTextOld() {
|
|
40
45
|
var _this;
|
|
41
|
-
(0, _classCallCheck2.default)(this,
|
|
46
|
+
(0, _classCallCheck2.default)(this, AssistveTextOld);
|
|
42
47
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
43
48
|
args[_key] = arguments[_key];
|
|
44
49
|
}
|
|
@@ -51,7 +56,7 @@ var AssistveTextComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
51
56
|
});
|
|
52
57
|
return _this;
|
|
53
58
|
}
|
|
54
|
-
(0, _createClass2.default)(
|
|
59
|
+
(0, _createClass2.default)(AssistveTextOld, [{
|
|
55
60
|
key: "UNSAFE_componentWillMount",
|
|
56
61
|
value: function UNSAFE_componentWillMount() {
|
|
57
62
|
var _this2 = this;
|
|
@@ -99,11 +104,13 @@ var AssistveTextComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
99
104
|
return (0, _react2.jsx)("div", {
|
|
100
105
|
css: assitiveTextStyles
|
|
101
106
|
}, (0, _react2.jsx)("div", {
|
|
107
|
+
"data-testId": id + '__status--A',
|
|
102
108
|
id: id + '__status--A',
|
|
103
109
|
role: "status",
|
|
104
110
|
"aria-atomic": "true",
|
|
105
111
|
"aria-live": "polite"
|
|
106
112
|
}, "".concat(!silenced && debounced && bump ? assistiveText : '')), (0, _react2.jsx)("div", {
|
|
113
|
+
"data-testId": id + '__status--B',
|
|
107
114
|
id: id + '__status--B',
|
|
108
115
|
role: "status",
|
|
109
116
|
"aria-atomic": "true",
|
|
@@ -111,13 +118,83 @@ var AssistveTextComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
111
118
|
}, "".concat(!silenced && debounced && !bump ? assistiveText : '')));
|
|
112
119
|
}
|
|
113
120
|
}]);
|
|
114
|
-
return
|
|
121
|
+
return AssistveTextOld;
|
|
115
122
|
}(_react.default.Component);
|
|
116
|
-
(0, _defineProperty2.default)(
|
|
123
|
+
(0, _defineProperty2.default)(AssistveTextOld, "defaultProps", {
|
|
117
124
|
statusDebounceMillis: 1400,
|
|
118
125
|
debounce: true,
|
|
119
126
|
assistiveText: '',
|
|
120
127
|
isInFocus: false,
|
|
121
128
|
id: ''
|
|
122
129
|
});
|
|
123
|
-
var
|
|
130
|
+
var AssistiveTextNew = exports.AssistiveTextNew = function AssistiveTextNew(_ref3) {
|
|
131
|
+
var _ref3$assistiveText = _ref3.assistiveText,
|
|
132
|
+
assistiveText = _ref3$assistiveText === void 0 ? '' : _ref3$assistiveText,
|
|
133
|
+
_ref3$isInFocus = _ref3.isInFocus,
|
|
134
|
+
isInFocus = _ref3$isInFocus === void 0 ? false : _ref3$isInFocus,
|
|
135
|
+
_ref3$id = _ref3.id,
|
|
136
|
+
id = _ref3$id === void 0 ? '' : _ref3$id,
|
|
137
|
+
_ref3$statusDebounceM = _ref3.statusDebounceMillis,
|
|
138
|
+
statusDebounceMillis = _ref3$statusDebounceM === void 0 ? 1400 : _ref3$statusDebounceM;
|
|
139
|
+
var _useState = (0, _react.useState)(false),
|
|
140
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
141
|
+
bump = _useState2[0],
|
|
142
|
+
setBump = _useState2[1];
|
|
143
|
+
var _useState3 = (0, _react.useState)(false),
|
|
144
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
145
|
+
debounced = _useState4[0],
|
|
146
|
+
setDebounced = _useState4[1];
|
|
147
|
+
var _useState5 = (0, _react.useState)(false),
|
|
148
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
149
|
+
silenced = _useState6[0],
|
|
150
|
+
setSilenced = _useState6[1];
|
|
151
|
+
var debounceStatusUpdate = (0, _react.useMemo)(function () {
|
|
152
|
+
return (0, _debounce.default)(function () {
|
|
153
|
+
var shouldSilence = !isInFocus;
|
|
154
|
+
setBump(function (prevBump) {
|
|
155
|
+
return !prevBump;
|
|
156
|
+
});
|
|
157
|
+
setDebounced(true);
|
|
158
|
+
setSilenced(shouldSilence);
|
|
159
|
+
});
|
|
160
|
+
}, [isInFocus]);
|
|
161
|
+
(0, _react.useEffect)(function () {
|
|
162
|
+
if (!debounced) {
|
|
163
|
+
debounceStatusUpdate();
|
|
164
|
+
return function () {
|
|
165
|
+
debounceStatusUpdate.cancel();
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}, [assistiveText, isInFocus, debounced, debounceStatusUpdate]);
|
|
169
|
+
(0, _react.useEffect)(function () {
|
|
170
|
+
if (debounced) {
|
|
171
|
+
setBump(function (prevBump) {
|
|
172
|
+
return !prevBump;
|
|
173
|
+
});
|
|
174
|
+
setDebounced(true);
|
|
175
|
+
setSilenced(!isInFocus);
|
|
176
|
+
}
|
|
177
|
+
}, [assistiveText, isInFocus, debounced]);
|
|
178
|
+
return (0, _react2.jsx)("div", {
|
|
179
|
+
css: assitiveTextStyles
|
|
180
|
+
}, (0, _react2.jsx)("div", {
|
|
181
|
+
"data-testid": id + '__status--A',
|
|
182
|
+
id: id + '__status--A',
|
|
183
|
+
role: "status",
|
|
184
|
+
"aria-atomic": "true",
|
|
185
|
+
"aria-live": "polite"
|
|
186
|
+
}, !silenced && debounced && bump ? assistiveText : ''), (0, _react2.jsx)("div", {
|
|
187
|
+
"data-testid": id + '__status--B',
|
|
188
|
+
id: id + '__status--B',
|
|
189
|
+
role: "status",
|
|
190
|
+
"aria-atomic": "true",
|
|
191
|
+
"aria-live": "polite"
|
|
192
|
+
}, !silenced && debounced && !bump ? assistiveText : ''));
|
|
193
|
+
};
|
|
194
|
+
var AssistiveText = exports.AssistiveText = function AssistiveText(props) {
|
|
195
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_react18_phase2')) {
|
|
196
|
+
return (0, _react2.jsx)(AssistiveTextNew, props);
|
|
197
|
+
} else {
|
|
198
|
+
return (0, _react2.jsx)(AssistveTextOld, props);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
@@ -4,11 +4,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
4
4
|
* @jsx jsx
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import React from 'react';
|
|
7
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
8
8
|
|
|
9
9
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
10
10
|
import { css, jsx } from '@emotion/react';
|
|
11
11
|
import debounce from 'lodash/debounce';
|
|
12
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
13
|
const statusDebounceMillis = 1400;
|
|
13
14
|
const assitiveTextStyles = css({
|
|
14
15
|
border: 0,
|
|
@@ -22,7 +23,7 @@ const assitiveTextStyles = css({
|
|
|
22
23
|
whitespace: 'nowrap',
|
|
23
24
|
width: '1px'
|
|
24
25
|
});
|
|
25
|
-
class
|
|
26
|
+
class AssistveTextOld extends React.Component {
|
|
26
27
|
constructor(...args) {
|
|
27
28
|
super(...args);
|
|
28
29
|
_defineProperty(this, "state", {
|
|
@@ -71,11 +72,13 @@ class AssistveTextComponent extends React.Component {
|
|
|
71
72
|
return jsx("div", {
|
|
72
73
|
css: assitiveTextStyles
|
|
73
74
|
}, jsx("div", {
|
|
75
|
+
"data-testId": id + '__status--A',
|
|
74
76
|
id: id + '__status--A',
|
|
75
77
|
role: "status",
|
|
76
78
|
"aria-atomic": "true",
|
|
77
79
|
"aria-live": "polite"
|
|
78
80
|
}, `${!silenced && debounced && bump ? assistiveText : ''}`), jsx("div", {
|
|
81
|
+
"data-testId": id + '__status--B',
|
|
79
82
|
id: id + '__status--B',
|
|
80
83
|
role: "status",
|
|
81
84
|
"aria-atomic": "true",
|
|
@@ -83,11 +86,63 @@ class AssistveTextComponent extends React.Component {
|
|
|
83
86
|
}, `${!silenced && debounced && !bump ? assistiveText : ''}`));
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
|
-
_defineProperty(
|
|
89
|
+
_defineProperty(AssistveTextOld, "defaultProps", {
|
|
87
90
|
statusDebounceMillis: 1400,
|
|
88
91
|
debounce: true,
|
|
89
92
|
assistiveText: '',
|
|
90
93
|
isInFocus: false,
|
|
91
94
|
id: ''
|
|
92
95
|
});
|
|
93
|
-
export const
|
|
96
|
+
export const AssistiveTextNew = ({
|
|
97
|
+
assistiveText = '',
|
|
98
|
+
isInFocus = false,
|
|
99
|
+
id = '',
|
|
100
|
+
statusDebounceMillis = 1400
|
|
101
|
+
}) => {
|
|
102
|
+
const [bump, setBump] = useState(false);
|
|
103
|
+
const [debounced, setDebounced] = useState(false);
|
|
104
|
+
const [silenced, setSilenced] = useState(false);
|
|
105
|
+
const debounceStatusUpdate = useMemo(() => debounce(() => {
|
|
106
|
+
const shouldSilence = !isInFocus;
|
|
107
|
+
setBump(prevBump => !prevBump);
|
|
108
|
+
setDebounced(true);
|
|
109
|
+
setSilenced(shouldSilence);
|
|
110
|
+
}), [isInFocus]);
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
if (!debounced) {
|
|
113
|
+
debounceStatusUpdate();
|
|
114
|
+
return () => {
|
|
115
|
+
debounceStatusUpdate.cancel();
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}, [assistiveText, isInFocus, debounced, debounceStatusUpdate]);
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
if (debounced) {
|
|
121
|
+
setBump(prevBump => !prevBump);
|
|
122
|
+
setDebounced(true);
|
|
123
|
+
setSilenced(!isInFocus);
|
|
124
|
+
}
|
|
125
|
+
}, [assistiveText, isInFocus, debounced]);
|
|
126
|
+
return jsx("div", {
|
|
127
|
+
css: assitiveTextStyles
|
|
128
|
+
}, jsx("div", {
|
|
129
|
+
"data-testid": id + '__status--A',
|
|
130
|
+
id: id + '__status--A',
|
|
131
|
+
role: "status",
|
|
132
|
+
"aria-atomic": "true",
|
|
133
|
+
"aria-live": "polite"
|
|
134
|
+
}, !silenced && debounced && bump ? assistiveText : ''), jsx("div", {
|
|
135
|
+
"data-testid": id + '__status--B',
|
|
136
|
+
id: id + '__status--B',
|
|
137
|
+
role: "status",
|
|
138
|
+
"aria-atomic": "true",
|
|
139
|
+
"aria-live": "polite"
|
|
140
|
+
}, !silenced && debounced && !bump ? assistiveText : ''));
|
|
141
|
+
};
|
|
142
|
+
export const AssistiveText = props => {
|
|
143
|
+
if (fg('platform_editor_react18_phase2')) {
|
|
144
|
+
return jsx(AssistiveTextNew, props);
|
|
145
|
+
} else {
|
|
146
|
+
return jsx(AssistveTextOld, props);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
4
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
@@ -12,11 +13,12 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
12
13
|
* @jsx jsx
|
|
13
14
|
*/
|
|
14
15
|
|
|
15
|
-
import React from 'react';
|
|
16
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
16
17
|
|
|
17
18
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
18
19
|
import { css, jsx } from '@emotion/react';
|
|
19
20
|
import debounce from 'lodash/debounce';
|
|
21
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
20
22
|
var statusDebounceMillis = 1400;
|
|
21
23
|
var assitiveTextStyles = css({
|
|
22
24
|
border: 0,
|
|
@@ -30,12 +32,12 @@ var assitiveTextStyles = css({
|
|
|
30
32
|
whitespace: 'nowrap',
|
|
31
33
|
width: '1px'
|
|
32
34
|
});
|
|
33
|
-
var
|
|
34
|
-
_inherits(
|
|
35
|
-
var _super = _createSuper(
|
|
36
|
-
function
|
|
35
|
+
var AssistveTextOld = /*#__PURE__*/function (_React$Component) {
|
|
36
|
+
_inherits(AssistveTextOld, _React$Component);
|
|
37
|
+
var _super = _createSuper(AssistveTextOld);
|
|
38
|
+
function AssistveTextOld() {
|
|
37
39
|
var _this;
|
|
38
|
-
_classCallCheck(this,
|
|
40
|
+
_classCallCheck(this, AssistveTextOld);
|
|
39
41
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
40
42
|
args[_key] = arguments[_key];
|
|
41
43
|
}
|
|
@@ -48,7 +50,7 @@ var AssistveTextComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
48
50
|
});
|
|
49
51
|
return _this;
|
|
50
52
|
}
|
|
51
|
-
_createClass(
|
|
53
|
+
_createClass(AssistveTextOld, [{
|
|
52
54
|
key: "UNSAFE_componentWillMount",
|
|
53
55
|
value: function UNSAFE_componentWillMount() {
|
|
54
56
|
var _this2 = this;
|
|
@@ -96,11 +98,13 @@ var AssistveTextComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
96
98
|
return jsx("div", {
|
|
97
99
|
css: assitiveTextStyles
|
|
98
100
|
}, jsx("div", {
|
|
101
|
+
"data-testId": id + '__status--A',
|
|
99
102
|
id: id + '__status--A',
|
|
100
103
|
role: "status",
|
|
101
104
|
"aria-atomic": "true",
|
|
102
105
|
"aria-live": "polite"
|
|
103
106
|
}, "".concat(!silenced && debounced && bump ? assistiveText : '')), jsx("div", {
|
|
107
|
+
"data-testId": id + '__status--B',
|
|
104
108
|
id: id + '__status--B',
|
|
105
109
|
role: "status",
|
|
106
110
|
"aria-atomic": "true",
|
|
@@ -108,13 +112,83 @@ var AssistveTextComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
108
112
|
}, "".concat(!silenced && debounced && !bump ? assistiveText : '')));
|
|
109
113
|
}
|
|
110
114
|
}]);
|
|
111
|
-
return
|
|
115
|
+
return AssistveTextOld;
|
|
112
116
|
}(React.Component);
|
|
113
|
-
_defineProperty(
|
|
117
|
+
_defineProperty(AssistveTextOld, "defaultProps", {
|
|
114
118
|
statusDebounceMillis: 1400,
|
|
115
119
|
debounce: true,
|
|
116
120
|
assistiveText: '',
|
|
117
121
|
isInFocus: false,
|
|
118
122
|
id: ''
|
|
119
123
|
});
|
|
120
|
-
export var
|
|
124
|
+
export var AssistiveTextNew = function AssistiveTextNew(_ref3) {
|
|
125
|
+
var _ref3$assistiveText = _ref3.assistiveText,
|
|
126
|
+
assistiveText = _ref3$assistiveText === void 0 ? '' : _ref3$assistiveText,
|
|
127
|
+
_ref3$isInFocus = _ref3.isInFocus,
|
|
128
|
+
isInFocus = _ref3$isInFocus === void 0 ? false : _ref3$isInFocus,
|
|
129
|
+
_ref3$id = _ref3.id,
|
|
130
|
+
id = _ref3$id === void 0 ? '' : _ref3$id,
|
|
131
|
+
_ref3$statusDebounceM = _ref3.statusDebounceMillis,
|
|
132
|
+
statusDebounceMillis = _ref3$statusDebounceM === void 0 ? 1400 : _ref3$statusDebounceM;
|
|
133
|
+
var _useState = useState(false),
|
|
134
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
135
|
+
bump = _useState2[0],
|
|
136
|
+
setBump = _useState2[1];
|
|
137
|
+
var _useState3 = useState(false),
|
|
138
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
139
|
+
debounced = _useState4[0],
|
|
140
|
+
setDebounced = _useState4[1];
|
|
141
|
+
var _useState5 = useState(false),
|
|
142
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
143
|
+
silenced = _useState6[0],
|
|
144
|
+
setSilenced = _useState6[1];
|
|
145
|
+
var debounceStatusUpdate = useMemo(function () {
|
|
146
|
+
return debounce(function () {
|
|
147
|
+
var shouldSilence = !isInFocus;
|
|
148
|
+
setBump(function (prevBump) {
|
|
149
|
+
return !prevBump;
|
|
150
|
+
});
|
|
151
|
+
setDebounced(true);
|
|
152
|
+
setSilenced(shouldSilence);
|
|
153
|
+
});
|
|
154
|
+
}, [isInFocus]);
|
|
155
|
+
useEffect(function () {
|
|
156
|
+
if (!debounced) {
|
|
157
|
+
debounceStatusUpdate();
|
|
158
|
+
return function () {
|
|
159
|
+
debounceStatusUpdate.cancel();
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}, [assistiveText, isInFocus, debounced, debounceStatusUpdate]);
|
|
163
|
+
useEffect(function () {
|
|
164
|
+
if (debounced) {
|
|
165
|
+
setBump(function (prevBump) {
|
|
166
|
+
return !prevBump;
|
|
167
|
+
});
|
|
168
|
+
setDebounced(true);
|
|
169
|
+
setSilenced(!isInFocus);
|
|
170
|
+
}
|
|
171
|
+
}, [assistiveText, isInFocus, debounced]);
|
|
172
|
+
return jsx("div", {
|
|
173
|
+
css: assitiveTextStyles
|
|
174
|
+
}, jsx("div", {
|
|
175
|
+
"data-testid": id + '__status--A',
|
|
176
|
+
id: id + '__status--A',
|
|
177
|
+
role: "status",
|
|
178
|
+
"aria-atomic": "true",
|
|
179
|
+
"aria-live": "polite"
|
|
180
|
+
}, !silenced && debounced && bump ? assistiveText : ''), jsx("div", {
|
|
181
|
+
"data-testid": id + '__status--B',
|
|
182
|
+
id: id + '__status--B',
|
|
183
|
+
role: "status",
|
|
184
|
+
"aria-atomic": "true",
|
|
185
|
+
"aria-live": "polite"
|
|
186
|
+
}, !silenced && debounced && !bump ? assistiveText : ''));
|
|
187
|
+
};
|
|
188
|
+
export var AssistiveText = function AssistiveText(props) {
|
|
189
|
+
if (fg('platform_editor_react18_phase2')) {
|
|
190
|
+
return jsx(AssistiveTextNew, props);
|
|
191
|
+
} else {
|
|
192
|
+
return jsx(AssistveTextOld, props);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
* @jsxRuntime classic
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
|
-
import React from 'react';
|
|
6
5
|
import { jsx } from '@emotion/react';
|
|
7
|
-
import debounce from 'lodash/debounce';
|
|
8
|
-
type Cancelable = ReturnType<typeof debounce>;
|
|
9
6
|
type AssistiveTextProps = {
|
|
10
7
|
assistiveText: string;
|
|
11
8
|
isInFocus: boolean;
|
|
@@ -13,23 +10,6 @@ type AssistiveTextProps = {
|
|
|
13
10
|
statusDebounceMillis?: number;
|
|
14
11
|
debounce?: boolean;
|
|
15
12
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
debounced: boolean;
|
|
19
|
-
silenced: boolean;
|
|
20
|
-
};
|
|
21
|
-
declare class AssistveTextComponent extends React.Component<AssistiveTextProps, AssistiveTextState> {
|
|
22
|
-
static defaultProps: AssistiveTextProps;
|
|
23
|
-
debounceStatusUpdate: (() => void) & Cancelable;
|
|
24
|
-
state: {
|
|
25
|
-
bump: boolean;
|
|
26
|
-
debounced: boolean;
|
|
27
|
-
silenced: boolean;
|
|
28
|
-
};
|
|
29
|
-
UNSAFE_componentWillMount(): void;
|
|
30
|
-
UNSAFE_componentWillUnmount(): void;
|
|
31
|
-
UNSAFE_componentWillReceiveProps(): void;
|
|
32
|
-
render(): jsx.JSX.Element;
|
|
33
|
-
}
|
|
34
|
-
export declare const AssistiveText: typeof AssistveTextComponent;
|
|
13
|
+
export declare const AssistiveTextNew: ({ assistiveText, isInFocus, id, statusDebounceMillis, }: AssistiveTextProps) => jsx.JSX.Element;
|
|
14
|
+
export declare const AssistiveText: (props: AssistiveTextProps) => jsx.JSX.Element;
|
|
35
15
|
export {};
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
* @jsxRuntime classic
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
|
-
import React from 'react';
|
|
6
5
|
import { jsx } from '@emotion/react';
|
|
7
|
-
import debounce from 'lodash/debounce';
|
|
8
|
-
type Cancelable = ReturnType<typeof debounce>;
|
|
9
6
|
type AssistiveTextProps = {
|
|
10
7
|
assistiveText: string;
|
|
11
8
|
isInFocus: boolean;
|
|
@@ -13,23 +10,6 @@ type AssistiveTextProps = {
|
|
|
13
10
|
statusDebounceMillis?: number;
|
|
14
11
|
debounce?: boolean;
|
|
15
12
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
debounced: boolean;
|
|
19
|
-
silenced: boolean;
|
|
20
|
-
};
|
|
21
|
-
declare class AssistveTextComponent extends React.Component<AssistiveTextProps, AssistiveTextState> {
|
|
22
|
-
static defaultProps: AssistiveTextProps;
|
|
23
|
-
debounceStatusUpdate: (() => void) & Cancelable;
|
|
24
|
-
state: {
|
|
25
|
-
bump: boolean;
|
|
26
|
-
debounced: boolean;
|
|
27
|
-
silenced: boolean;
|
|
28
|
-
};
|
|
29
|
-
UNSAFE_componentWillMount(): void;
|
|
30
|
-
UNSAFE_componentWillUnmount(): void;
|
|
31
|
-
UNSAFE_componentWillReceiveProps(): void;
|
|
32
|
-
render(): jsx.JSX.Element;
|
|
33
|
-
}
|
|
34
|
-
export declare const AssistiveText: typeof AssistveTextComponent;
|
|
13
|
+
export declare const AssistiveTextNew: ({ assistiveText, isInFocus, id, statusDebounceMillis, }: AssistiveTextProps) => jsx.JSX.Element;
|
|
14
|
+
export declare const AssistiveText: (props: AssistiveTextProps) => jsx.JSX.Element;
|
|
35
15
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-type-ahead",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Type-ahead plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,14 +31,15 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/adf-schema": "^
|
|
35
|
-
"@atlaskit/editor-common": "^93.
|
|
36
|
-
"@atlaskit/editor-plugin-analytics": "^1.
|
|
34
|
+
"@atlaskit/adf-schema": "^42.0.2",
|
|
35
|
+
"@atlaskit/editor-common": "^93.5.0",
|
|
36
|
+
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
37
37
|
"@atlaskit/editor-prosemirror": "6.0.0",
|
|
38
38
|
"@atlaskit/editor-shared-styles": "^3.0.0",
|
|
39
39
|
"@atlaskit/menu": "^2.12.0",
|
|
40
|
+
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
40
41
|
"@atlaskit/prosemirror-input-rules": "^3.2.0",
|
|
41
|
-
"@atlaskit/theme": "^13.
|
|
42
|
+
"@atlaskit/theme": "^13.1.0",
|
|
42
43
|
"@atlaskit/tokens": "^2.0.0",
|
|
43
44
|
"@babel/runtime": "^7.0.0",
|
|
44
45
|
"@emotion/react": "^11.7.1",
|
|
@@ -81,5 +82,10 @@
|
|
|
81
82
|
"emotion"
|
|
82
83
|
]
|
|
83
84
|
}
|
|
85
|
+
},
|
|
86
|
+
"platform-feature-flags": {
|
|
87
|
+
"platform_editor_react18_phase2": {
|
|
88
|
+
"type": "boolean"
|
|
89
|
+
}
|
|
84
90
|
}
|
|
85
91
|
}
|