@atlaskit/editor-plugin-type-ahead 2.2.4 → 2.3.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 +13 -0
- package/dist/cjs/ui/InputQuery.js +2 -2
- package/dist/cjs/ui/TypeAheadList.js +2 -2
- package/dist/es2019/ui/InputQuery.js +1 -1
- package/dist/es2019/ui/TypeAheadList.js +1 -1
- package/dist/esm/ui/InputQuery.js +1 -1
- package/dist/esm/ui/TypeAheadList.js +1 -1
- package/package.json +6 -6
- package/dist/cjs/ui/AssistiveText.js +0 -94
- package/dist/es2019/ui/AssistiveText.js +0 -68
- package/dist/esm/ui/AssistiveText.js +0 -87
- package/dist/types/ui/AssistiveText.d.ts +0 -14
- package/dist/types-ts4.5/ui/AssistiveText.d.ts +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-type-ahead
|
|
2
2
|
|
|
3
|
+
## 2.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#135301](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/135301)
|
|
8
|
+
[`282513a152fa2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/282513a152fa2) -
|
|
9
|
+
[A11Y-9960] Extract the AssistiveText component from the typeahead plugin for reuse in other
|
|
10
|
+
editor plugins
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 2.2.4
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -13,11 +13,11 @@ var _reactIntlNext = require("react-intl-next");
|
|
|
13
13
|
var _w3cKeyname = require("w3c-keyname");
|
|
14
14
|
var _browser = require("@atlaskit/editor-common/browser");
|
|
15
15
|
var _typeAhead = require("@atlaskit/editor-common/type-ahead");
|
|
16
|
+
var _ui = require("@atlaskit/editor-common/ui");
|
|
16
17
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
17
18
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
18
19
|
var _constants = require("../pm-plugins/constants");
|
|
19
20
|
var _utils = require("../pm-plugins/utils");
|
|
20
|
-
var _AssistiveText = require("./AssistiveText");
|
|
21
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
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; }
|
|
23
23
|
/**
|
|
@@ -450,7 +450,7 @@ var InputQuery = exports.InputQuery = /*#__PURE__*/_react.default.memo(function
|
|
|
450
450
|
style: {
|
|
451
451
|
display: 'none'
|
|
452
452
|
}
|
|
453
|
-
}, intl.formatMessage(_typeAhead.typeAheadListMessages.inputQueryAssistiveLabel)), (0, _react2.jsx)(
|
|
453
|
+
}, intl.formatMessage(_typeAhead.typeAheadListMessages.inputQueryAssistiveLabel)), (0, _react2.jsx)(_ui.AssistiveText, {
|
|
454
454
|
assistiveText: items.length === 0 ? intl.formatMessage(_typeAhead.typeAheadListMessages.noSearchResultsLabel, {
|
|
455
455
|
itemsLength: items.length
|
|
456
456
|
}) : '',
|
|
@@ -14,13 +14,13 @@ var _CellMeasurer = require("react-virtualized/dist/commonjs/CellMeasurer");
|
|
|
14
14
|
var _List = require("react-virtualized/dist/commonjs/List");
|
|
15
15
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
16
16
|
var _typeAhead = require("@atlaskit/editor-common/type-ahead");
|
|
17
|
+
var _ui = require("@atlaskit/editor-common/ui");
|
|
17
18
|
var _menu = require("@atlaskit/menu");
|
|
18
19
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
19
20
|
var _primitives = require("@atlaskit/primitives");
|
|
20
21
|
var _updateSelectedIndex = require("../pm-plugins/commands/update-selected-index");
|
|
21
22
|
var _constants = require("../pm-plugins/constants");
|
|
22
23
|
var _utils = require("../pm-plugins/utils");
|
|
23
|
-
var _AssistiveText = require("./AssistiveText");
|
|
24
24
|
var _ListRow = require("./ListRow");
|
|
25
25
|
var _TypeAheadListItem = require("./TypeAheadListItem");
|
|
26
26
|
var _ViewMore = require("./ViewMore");
|
|
@@ -44,7 +44,7 @@ var list = (0, _react2.css)({
|
|
|
44
44
|
var TypeaheadAssistiveTextPureComponent = /*#__PURE__*/_react.default.memo(function (_ref) {
|
|
45
45
|
var numberOfResults = _ref.numberOfResults;
|
|
46
46
|
var intl = (0, _reactIntlNext.useIntl)();
|
|
47
|
-
return (0, _react2.jsx)(
|
|
47
|
+
return (0, _react2.jsx)(_ui.AssistiveText, {
|
|
48
48
|
assistiveText: intl.formatMessage(_typeAhead.typeAheadListMessages.searchResultsLabel, {
|
|
49
49
|
itemsLength: numberOfResults
|
|
50
50
|
})
|
|
@@ -10,11 +10,11 @@ import { useIntl } from 'react-intl-next';
|
|
|
10
10
|
import { keyName as keyNameNormalized } from 'w3c-keyname';
|
|
11
11
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
12
12
|
import { SelectItemMode, typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
|
|
13
|
+
import { AssistiveText } from '@atlaskit/editor-common/ui';
|
|
13
14
|
import { blockNodesVerticalMargin } from '@atlaskit/editor-shared-styles';
|
|
14
15
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
15
16
|
import { CloseSelectionOptions, TYPE_AHEAD_DECORATION_ELEMENT_ID, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../pm-plugins/constants';
|
|
16
17
|
import { getPluginState } from '../pm-plugins/utils';
|
|
17
|
-
import { AssistiveText } from './AssistiveText';
|
|
18
18
|
const placeholderStyles = css({
|
|
19
19
|
'&::after': {
|
|
20
20
|
content: 'attr(data-place-holder)',
|
|
@@ -12,13 +12,13 @@ import { CellMeasurer, CellMeasurerCache } from 'react-virtualized/dist/commonjs
|
|
|
12
12
|
import { List } from 'react-virtualized/dist/commonjs/List';
|
|
13
13
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
14
14
|
import { SelectItemMode, typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
|
|
15
|
+
import { AssistiveText } from '@atlaskit/editor-common/ui';
|
|
15
16
|
import { MenuGroup } from '@atlaskit/menu';
|
|
16
17
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
18
|
import { Text, Box } from '@atlaskit/primitives';
|
|
18
19
|
import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
|
|
19
20
|
import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../pm-plugins/constants';
|
|
20
21
|
import { getTypeAheadListAriaLabels, moveSelectedIndex } from '../pm-plugins/utils';
|
|
21
|
-
import { AssistiveText } from './AssistiveText';
|
|
22
22
|
import { ListRow } from './ListRow';
|
|
23
23
|
import { TypeAheadListItem } from './TypeAheadListItem';
|
|
24
24
|
import { ViewMore } from './ViewMore';
|
|
@@ -11,11 +11,11 @@ import { useIntl } from 'react-intl-next';
|
|
|
11
11
|
import { keyName as keyNameNormalized } from 'w3c-keyname';
|
|
12
12
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
13
13
|
import { SelectItemMode, typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
|
|
14
|
+
import { AssistiveText } from '@atlaskit/editor-common/ui';
|
|
14
15
|
import { blockNodesVerticalMargin } from '@atlaskit/editor-shared-styles';
|
|
15
16
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
16
17
|
import { CloseSelectionOptions, TYPE_AHEAD_DECORATION_ELEMENT_ID, TYPE_AHEAD_POPUP_CONTENT_CLASS } from '../pm-plugins/constants';
|
|
17
18
|
import { getPluginState } from '../pm-plugins/utils';
|
|
18
|
-
import { AssistiveText } from './AssistiveText';
|
|
19
19
|
var placeholderStyles = css({
|
|
20
20
|
'&::after': {
|
|
21
21
|
content: 'attr(data-place-holder)',
|
|
@@ -13,13 +13,13 @@ import { CellMeasurer, CellMeasurerCache } from 'react-virtualized/dist/commonjs
|
|
|
13
13
|
import { List } from 'react-virtualized/dist/commonjs/List';
|
|
14
14
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
15
15
|
import { SelectItemMode, typeAheadListMessages } from '@atlaskit/editor-common/type-ahead';
|
|
16
|
+
import { AssistiveText } from '@atlaskit/editor-common/ui';
|
|
16
17
|
import { MenuGroup } from '@atlaskit/menu';
|
|
17
18
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
19
|
import { Text, Box } from '@atlaskit/primitives';
|
|
19
20
|
import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
|
|
20
21
|
import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../pm-plugins/constants';
|
|
21
22
|
import { getTypeAheadListAriaLabels, moveSelectedIndex } from '../pm-plugins/utils';
|
|
22
|
-
import { AssistiveText } from './AssistiveText';
|
|
23
23
|
import { ListRow } from './ListRow';
|
|
24
24
|
import { TypeAheadListItem } from './TypeAheadListItem';
|
|
25
25
|
import { ViewMore } from './ViewMore';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-type-ahead",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Type-ahead plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
37
|
-
"@atlaskit/editor-common": "^102.
|
|
37
|
+
"@atlaskit/editor-common": "^102.18.0",
|
|
38
38
|
"@atlaskit/editor-element-browser": "^0.1.0",
|
|
39
39
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
40
40
|
"@atlaskit/editor-plugin-connectivity": "^2.0.0",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
43
43
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
|
44
44
|
"@atlaskit/heading": "^5.1.0",
|
|
45
|
-
"@atlaskit/icon": "^25.
|
|
45
|
+
"@atlaskit/icon": "^25.5.0",
|
|
46
46
|
"@atlaskit/menu": "^3.2.0",
|
|
47
47
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
48
|
-
"@atlaskit/primitives": "^14.
|
|
48
|
+
"@atlaskit/primitives": "^14.3.0",
|
|
49
49
|
"@atlaskit/prosemirror-input-rules": "^3.3.0",
|
|
50
50
|
"@atlaskit/theme": "^18.0.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
52
|
-
"@atlaskit/tokens": "^4.
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^4.6.0",
|
|
52
|
+
"@atlaskit/tokens": "^4.6.0",
|
|
53
53
|
"@babel/runtime": "^7.0.0",
|
|
54
54
|
"@emotion/react": "^11.7.1",
|
|
55
55
|
"lodash": "^4.17.21",
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.AssistiveText = void 0;
|
|
8
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
-
var _react = require("react");
|
|
10
|
-
var _react2 = require("@emotion/react");
|
|
11
|
-
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
12
|
-
/**
|
|
13
|
-
* @jsxRuntime classic
|
|
14
|
-
* @jsx jsx
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
18
|
-
|
|
19
|
-
var assitiveTextStyles = (0, _react2.css)({
|
|
20
|
-
border: 0,
|
|
21
|
-
clip: 'rect(0 0 0 0)',
|
|
22
|
-
height: '1px',
|
|
23
|
-
marginbottom: '-1px',
|
|
24
|
-
marginright: '-1px',
|
|
25
|
-
overflow: 'hidden',
|
|
26
|
-
padding: 0,
|
|
27
|
-
position: 'absolute',
|
|
28
|
-
whitespace: 'nowrap',
|
|
29
|
-
width: '1px'
|
|
30
|
-
});
|
|
31
|
-
var AssistiveText = exports.AssistiveText = function AssistiveText(_ref) {
|
|
32
|
-
var _ref$assistiveText = _ref.assistiveText,
|
|
33
|
-
assistiveText = _ref$assistiveText === void 0 ? '' : _ref$assistiveText,
|
|
34
|
-
_ref$isInFocus = _ref.isInFocus,
|
|
35
|
-
isInFocus = _ref$isInFocus === void 0 ? false : _ref$isInFocus,
|
|
36
|
-
_ref$id = _ref.id,
|
|
37
|
-
id = _ref$id === void 0 ? '' : _ref$id,
|
|
38
|
-
_ref$statusDebounceMi = _ref.statusDebounceMillis,
|
|
39
|
-
statusDebounceMillis = _ref$statusDebounceMi === void 0 ? 1400 : _ref$statusDebounceMi;
|
|
40
|
-
var _useState = (0, _react.useState)(false),
|
|
41
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
42
|
-
bump = _useState2[0],
|
|
43
|
-
setBump = _useState2[1];
|
|
44
|
-
var _useState3 = (0, _react.useState)(false),
|
|
45
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
46
|
-
debounced = _useState4[0],
|
|
47
|
-
setDebounced = _useState4[1];
|
|
48
|
-
var _useState5 = (0, _react.useState)(false),
|
|
49
|
-
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
50
|
-
silenced = _useState6[0],
|
|
51
|
-
setSilenced = _useState6[1];
|
|
52
|
-
var debounceStatusUpdate = (0, _react.useMemo)(function () {
|
|
53
|
-
return (0, _debounce.default)(function () {
|
|
54
|
-
var shouldSilence = !isInFocus;
|
|
55
|
-
setBump(function (prevBump) {
|
|
56
|
-
return !prevBump;
|
|
57
|
-
});
|
|
58
|
-
setDebounced(true);
|
|
59
|
-
setSilenced(shouldSilence);
|
|
60
|
-
});
|
|
61
|
-
}, [isInFocus]);
|
|
62
|
-
(0, _react.useEffect)(function () {
|
|
63
|
-
if (!debounced) {
|
|
64
|
-
debounceStatusUpdate();
|
|
65
|
-
return function () {
|
|
66
|
-
debounceStatusUpdate.cancel();
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
}, [assistiveText, isInFocus, debounced, debounceStatusUpdate]);
|
|
70
|
-
(0, _react.useEffect)(function () {
|
|
71
|
-
if (debounced) {
|
|
72
|
-
setBump(function (prevBump) {
|
|
73
|
-
return !prevBump;
|
|
74
|
-
});
|
|
75
|
-
setDebounced(true);
|
|
76
|
-
setSilenced(!isInFocus);
|
|
77
|
-
}
|
|
78
|
-
}, [assistiveText, isInFocus, debounced]);
|
|
79
|
-
return (0, _react2.jsx)("div", {
|
|
80
|
-
css: assitiveTextStyles
|
|
81
|
-
}, (0, _react2.jsx)("div", {
|
|
82
|
-
"data-testid": id + '__status--A',
|
|
83
|
-
id: id + '__status--A',
|
|
84
|
-
role: "status",
|
|
85
|
-
"aria-atomic": "true",
|
|
86
|
-
"aria-live": "polite"
|
|
87
|
-
}, !silenced && debounced && bump ? assistiveText : ''), (0, _react2.jsx)("div", {
|
|
88
|
-
"data-testid": id + '__status--B',
|
|
89
|
-
id: id + '__status--B',
|
|
90
|
-
role: "status",
|
|
91
|
-
"aria-atomic": "true",
|
|
92
|
-
"aria-live": "polite"
|
|
93
|
-
}, !silenced && debounced && !bump ? assistiveText : ''));
|
|
94
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
7
|
-
|
|
8
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
9
|
-
import { css, jsx } from '@emotion/react';
|
|
10
|
-
import debounce from 'lodash/debounce';
|
|
11
|
-
const assitiveTextStyles = css({
|
|
12
|
-
border: 0,
|
|
13
|
-
clip: 'rect(0 0 0 0)',
|
|
14
|
-
height: '1px',
|
|
15
|
-
marginbottom: '-1px',
|
|
16
|
-
marginright: '-1px',
|
|
17
|
-
overflow: 'hidden',
|
|
18
|
-
padding: 0,
|
|
19
|
-
position: 'absolute',
|
|
20
|
-
whitespace: 'nowrap',
|
|
21
|
-
width: '1px'
|
|
22
|
-
});
|
|
23
|
-
export const AssistiveText = ({
|
|
24
|
-
assistiveText = '',
|
|
25
|
-
isInFocus = false,
|
|
26
|
-
id = '',
|
|
27
|
-
statusDebounceMillis = 1400
|
|
28
|
-
}) => {
|
|
29
|
-
const [bump, setBump] = useState(false);
|
|
30
|
-
const [debounced, setDebounced] = useState(false);
|
|
31
|
-
const [silenced, setSilenced] = useState(false);
|
|
32
|
-
const debounceStatusUpdate = useMemo(() => debounce(() => {
|
|
33
|
-
const shouldSilence = !isInFocus;
|
|
34
|
-
setBump(prevBump => !prevBump);
|
|
35
|
-
setDebounced(true);
|
|
36
|
-
setSilenced(shouldSilence);
|
|
37
|
-
}), [isInFocus]);
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
if (!debounced) {
|
|
40
|
-
debounceStatusUpdate();
|
|
41
|
-
return () => {
|
|
42
|
-
debounceStatusUpdate.cancel();
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}, [assistiveText, isInFocus, debounced, debounceStatusUpdate]);
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (debounced) {
|
|
48
|
-
setBump(prevBump => !prevBump);
|
|
49
|
-
setDebounced(true);
|
|
50
|
-
setSilenced(!isInFocus);
|
|
51
|
-
}
|
|
52
|
-
}, [assistiveText, isInFocus, debounced]);
|
|
53
|
-
return jsx("div", {
|
|
54
|
-
css: assitiveTextStyles
|
|
55
|
-
}, jsx("div", {
|
|
56
|
-
"data-testid": id + '__status--A',
|
|
57
|
-
id: id + '__status--A',
|
|
58
|
-
role: "status",
|
|
59
|
-
"aria-atomic": "true",
|
|
60
|
-
"aria-live": "polite"
|
|
61
|
-
}, !silenced && debounced && bump ? assistiveText : ''), jsx("div", {
|
|
62
|
-
"data-testid": id + '__status--B',
|
|
63
|
-
id: id + '__status--B',
|
|
64
|
-
role: "status",
|
|
65
|
-
"aria-atomic": "true",
|
|
66
|
-
"aria-live": "polite"
|
|
67
|
-
}, !silenced && debounced && !bump ? assistiveText : ''));
|
|
68
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
/**
|
|
3
|
-
* @jsxRuntime classic
|
|
4
|
-
* @jsx jsx
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { useEffect, useMemo, useState } 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';
|
|
11
|
-
import debounce from 'lodash/debounce';
|
|
12
|
-
var assitiveTextStyles = css({
|
|
13
|
-
border: 0,
|
|
14
|
-
clip: 'rect(0 0 0 0)',
|
|
15
|
-
height: '1px',
|
|
16
|
-
marginbottom: '-1px',
|
|
17
|
-
marginright: '-1px',
|
|
18
|
-
overflow: 'hidden',
|
|
19
|
-
padding: 0,
|
|
20
|
-
position: 'absolute',
|
|
21
|
-
whitespace: 'nowrap',
|
|
22
|
-
width: '1px'
|
|
23
|
-
});
|
|
24
|
-
export var AssistiveText = function AssistiveText(_ref) {
|
|
25
|
-
var _ref$assistiveText = _ref.assistiveText,
|
|
26
|
-
assistiveText = _ref$assistiveText === void 0 ? '' : _ref$assistiveText,
|
|
27
|
-
_ref$isInFocus = _ref.isInFocus,
|
|
28
|
-
isInFocus = _ref$isInFocus === void 0 ? false : _ref$isInFocus,
|
|
29
|
-
_ref$id = _ref.id,
|
|
30
|
-
id = _ref$id === void 0 ? '' : _ref$id,
|
|
31
|
-
_ref$statusDebounceMi = _ref.statusDebounceMillis,
|
|
32
|
-
statusDebounceMillis = _ref$statusDebounceMi === void 0 ? 1400 : _ref$statusDebounceMi;
|
|
33
|
-
var _useState = useState(false),
|
|
34
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
-
bump = _useState2[0],
|
|
36
|
-
setBump = _useState2[1];
|
|
37
|
-
var _useState3 = useState(false),
|
|
38
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
39
|
-
debounced = _useState4[0],
|
|
40
|
-
setDebounced = _useState4[1];
|
|
41
|
-
var _useState5 = useState(false),
|
|
42
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
43
|
-
silenced = _useState6[0],
|
|
44
|
-
setSilenced = _useState6[1];
|
|
45
|
-
var debounceStatusUpdate = useMemo(function () {
|
|
46
|
-
return debounce(function () {
|
|
47
|
-
var shouldSilence = !isInFocus;
|
|
48
|
-
setBump(function (prevBump) {
|
|
49
|
-
return !prevBump;
|
|
50
|
-
});
|
|
51
|
-
setDebounced(true);
|
|
52
|
-
setSilenced(shouldSilence);
|
|
53
|
-
});
|
|
54
|
-
}, [isInFocus]);
|
|
55
|
-
useEffect(function () {
|
|
56
|
-
if (!debounced) {
|
|
57
|
-
debounceStatusUpdate();
|
|
58
|
-
return function () {
|
|
59
|
-
debounceStatusUpdate.cancel();
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
}, [assistiveText, isInFocus, debounced, debounceStatusUpdate]);
|
|
63
|
-
useEffect(function () {
|
|
64
|
-
if (debounced) {
|
|
65
|
-
setBump(function (prevBump) {
|
|
66
|
-
return !prevBump;
|
|
67
|
-
});
|
|
68
|
-
setDebounced(true);
|
|
69
|
-
setSilenced(!isInFocus);
|
|
70
|
-
}
|
|
71
|
-
}, [assistiveText, isInFocus, debounced]);
|
|
72
|
-
return jsx("div", {
|
|
73
|
-
css: assitiveTextStyles
|
|
74
|
-
}, jsx("div", {
|
|
75
|
-
"data-testid": id + '__status--A',
|
|
76
|
-
id: id + '__status--A',
|
|
77
|
-
role: "status",
|
|
78
|
-
"aria-atomic": "true",
|
|
79
|
-
"aria-live": "polite"
|
|
80
|
-
}, !silenced && debounced && bump ? assistiveText : ''), jsx("div", {
|
|
81
|
-
"data-testid": id + '__status--B',
|
|
82
|
-
id: id + '__status--B',
|
|
83
|
-
role: "status",
|
|
84
|
-
"aria-atomic": "true",
|
|
85
|
-
"aria-live": "polite"
|
|
86
|
-
}, !silenced && debounced && !bump ? assistiveText : ''));
|
|
87
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
*/
|
|
5
|
-
import { jsx } from '@emotion/react';
|
|
6
|
-
type AssistiveTextProps = {
|
|
7
|
-
assistiveText: string;
|
|
8
|
-
isInFocus: boolean;
|
|
9
|
-
id: string;
|
|
10
|
-
statusDebounceMillis?: number;
|
|
11
|
-
debounce?: boolean;
|
|
12
|
-
};
|
|
13
|
-
export declare const AssistiveText: ({ assistiveText, isInFocus, id, statusDebounceMillis, }: AssistiveTextProps) => jsx.JSX.Element;
|
|
14
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
*/
|
|
5
|
-
import { jsx } from '@emotion/react';
|
|
6
|
-
type AssistiveTextProps = {
|
|
7
|
-
assistiveText: string;
|
|
8
|
-
isInFocus: boolean;
|
|
9
|
-
id: string;
|
|
10
|
-
statusDebounceMillis?: number;
|
|
11
|
-
debounce?: boolean;
|
|
12
|
-
};
|
|
13
|
-
export declare const AssistiveText: ({ assistiveText, isInFocus, id, statusDebounceMillis, }: AssistiveTextProps) => jsx.JSX.Element;
|
|
14
|
-
export {};
|