@atlaskit/link-picker 4.2.9 → 4.2.10

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,13 @@
1
1
  # @atlaskit/link-picker
2
2
 
3
+ ## 4.2.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [`0f1cfed063364`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0f1cfed063364) -
8
+ NAVX-3742 Refactoring link picker helper message for text fields to be read by screen readers for
9
+ a11y
10
+
3
11
  ## 4.2.9
4
12
 
5
13
  ### Patch Changes
@@ -17,7 +17,7 @@ var _constants = require("../../common/constants");
17
17
  var _analytics2 = _interopRequireDefault(require("../../common/utils/analytics/analytics.codegen"));
18
18
  var _reducer = require("./reducer");
19
19
  var _utils = require("./utils");
20
- function usePlugins(state, activeTab, plugins, recentSearchListSize) {
20
+ function usePlugins(state, activeTab, plugins, recentSearchListSize, alwaysShowTabs) {
21
21
  var _activePlugin$tabKey;
22
22
  var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
23
23
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
@@ -114,7 +114,7 @@ function usePlugins(state, activeTab, plugins, recentSearchListSize) {
114
114
  return cancel;
115
115
  }, [activePlugin, state, retries, createAnalyticsEvent, dispatch, recentSearchListSize]);
116
116
  var tabs = (0, _react.useMemo)(function () {
117
- if (!plugins || plugins.length <= 1) {
117
+ if (!plugins || !alwaysShowTabs && plugins.length <= 1) {
118
118
  return [];
119
119
  }
120
120
  return plugins.filter(function (plugin) {
@@ -124,7 +124,7 @@ function usePlugins(state, activeTab, plugins, recentSearchListSize) {
124
124
  tabTitle: plugin.tabTitle
125
125
  };
126
126
  });
127
- }, [plugins]);
127
+ }, [plugins, alwaysShowTabs]);
128
128
  var handleRetry = (0, _react.useCallback)(function () {
129
129
  setRetries(function (prev) {
130
130
  return ++prev;
@@ -23,6 +23,7 @@ var _form = require("@atlaskit/form");
23
23
  var _linkProvider = require("@atlaskit/link-provider");
24
24
  var _url2 = require("@atlaskit/linking-common/url");
25
25
  var _userAgent = require("@atlaskit/linking-common/user-agent");
26
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
26
27
  var _compiled = require("@atlaskit/primitives/compiled");
27
28
  var _linkUrl = _interopRequireDefault(require("@atlaskit/smart-card/link-url"));
28
29
  var _colors = require("@atlaskit/theme/colors");
@@ -56,8 +57,7 @@ var testIds = exports.testIds = _objectSpread(_objectSpread(_objectSpread({
56
57
  linkPickerRoot: 'link-picker-root',
57
58
  linkPicker: 'link-picker',
58
59
  urlInputField: 'link-url',
59
- textInputField: 'link-text',
60
- linkHelperText: 'link-helper-text'
60
+ textInputField: 'link-text'
61
61
  }, _searchResults.testIds), _formFooter.testIds), _textInput.testIds);
62
62
  var initState = {
63
63
  url: '',
@@ -97,6 +97,7 @@ var LinkInputField = (0, _analytics.withInputFieldTracking)(_textInput.TextInput
97
97
  var DisplayTextInputField = (0, _analytics.withInputFieldTracking)(_textInput.TextInput, 'displayText');
98
98
  var client = new _linkProvider.CardClient();
99
99
  var LinkPicker = exports.LinkPicker = (0, _analytics.withLinkPickerAnalyticsContext)( /*#__PURE__*/(0, _react.memo)(function (_ref) {
100
+ var _customMessages$linkH;
100
101
  var onSubmit = _ref.onSubmit,
101
102
  onCancel = _ref.onCancel,
102
103
  onContentResize = _ref.onContentResize,
@@ -120,7 +121,8 @@ var LinkPicker = exports.LinkPicker = (0, _analytics.withLinkPickerAnalyticsCont
120
121
  _ref$submitOnInputCha = _ref.submitOnInputChange,
121
122
  submitOnInputChange = _ref$submitOnInputCha === void 0 ? false : _ref$submitOnInputCha,
122
123
  recentSearchListSize = _ref.recentSearchListSize,
123
- shouldRenderNoResultsImage = _ref.shouldRenderNoResultsImage;
124
+ shouldRenderNoResultsImage = _ref.shouldRenderNoResultsImage,
125
+ alwaysShowTabs = _ref.alwaysShowTabs;
124
126
  var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
125
127
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
126
128
  var _useReducer = (0, _react.useReducer)(reducer, _objectSpread(_objectSpread({}, initState), {}, {
@@ -139,7 +141,7 @@ var LinkPicker = exports.LinkPicker = (0, _analytics.withLinkPickerAnalyticsCont
139
141
  hasPreview = state.hasPreview;
140
142
  var intl = (0, _reactIntlNext.useIntl)();
141
143
  var queryState = (0, _useSearchQuery.useSearchQuery)(state);
142
- var _usePlugins = (0, _usePlugins2.usePlugins)(queryState, activeTab, plugins, recentSearchListSize),
144
+ var _usePlugins = (0, _usePlugins2.usePlugins)(queryState, activeTab, plugins, recentSearchListSize, alwaysShowTabs),
143
145
  items = _usePlugins.items,
144
146
  isLoadingResults = _usePlugins.isLoading,
145
147
  isActivePlugin = _usePlugins.isActivePlugin,
@@ -461,7 +463,7 @@ var LinkPicker = exports.LinkPicker = (0, _analytics.withLinkPickerAnalyticsCont
461
463
  onChange: handleChangeUrl,
462
464
  inputRef: inputRef,
463
465
  isRequired: true
464
- })), !hideDisplayText && /*#__PURE__*/React.createElement(_react.Fragment, null, /*#__PURE__*/React.createElement(DisplayTextInputField, {
466
+ })), !hideDisplayText && /*#__PURE__*/React.createElement(_react.Fragment, null, /*#__PURE__*/React.createElement(DisplayTextInputField, (0, _extends2.default)({
465
467
  autoComplete: "off",
466
468
  name: "displayText",
467
469
  testId: testIds.textInputField,
@@ -472,7 +474,9 @@ var LinkPicker = exports.LinkPicker = (0, _analytics.withLinkPickerAnalyticsCont
472
474
  readOnly: isSubmitting,
473
475
  onClear: handleClear,
474
476
  onChange: handleChangeText
475
- }), /*#__PURE__*/React.createElement(_form.HelperMessage, {
477
+ }, (0, _platformFeatureFlags.fg)('navx-3742-refactoring-link-picker-helper-text-a11y') ? {
478
+ helperMessage: intl.formatMessage((_customMessages$linkH = customMessages === null || customMessages === void 0 ? void 0 : customMessages.linkHelperTextLabel) !== null && _customMessages$linkH !== void 0 ? _customMessages$linkH : _messages.linkTextMessages.linkHelperTextLabel)
479
+ } : {})), !(0, _platformFeatureFlags.fg)('navx-3742-refactoring-link-picker-helper-text-a11y') && /*#__PURE__*/React.createElement(_form.HelperMessage, {
476
480
  testId: testIds.linkHelperText
477
481
  }, customMessages !== null && customMessages !== void 0 && customMessages.linkHelperTextLabel ? intl.formatMessage(customMessages === null || customMessages === void 0 ? void 0 : customMessages.linkHelperTextLabel) : intl.formatMessage(_messages.linkTextMessages.linkHelperTextLabel))), moveSubmitButton && /*#__PURE__*/React.createElement(_compiled.Box, {
478
482
  xcss: styles.fullWidthSubmitButton
@@ -15,12 +15,13 @@ var _react = _interopRequireWildcard(require("react"));
15
15
  var _useCallbackRef = require("use-callback-ref");
16
16
  var _form = require("@atlaskit/form");
17
17
  var _crossCircle = _interopRequireDefault(require("@atlaskit/icon/core/cross-circle"));
18
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
19
  var _compiled = require("@atlaskit/primitives/compiled");
19
20
  var _textfield = _interopRequireDefault(require("@atlaskit/textfield"));
20
21
  var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
21
22
  var _conditionalSpotlightTargetWrapper = require("./conditional-spotlight-target-wrapper");
22
23
  var _utils = require("./utils");
23
- var _excluded = ["name", "label", "autoFocus", "onRedo", "onUndo", "onKeyDown", "onClear", "clearLabel", "error", "spotlightTargetName", "inputRef", "isRequired"];
24
+ var _excluded = ["name", "label", "autoFocus", "onRedo", "onUndo", "onKeyDown", "onClear", "clearLabel", "error", "spotlightTargetName", "inputRef", "isRequired", "helperMessage"];
24
25
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
25
26
  var styles = {
26
27
  clearTextButton: "_19itglyw _ca0qze3t _u5f3ze3t _n3tdze3t _19bvze3t _2hwx1b66 _bfhksm61 _s7n4nkob",
@@ -42,7 +43,8 @@ var RequiredAsterisk = function RequiredAsterisk() {
42
43
  };
43
44
  var testIds = exports.testIds = {
44
45
  urlError: 'link-error',
45
- clearUrlButton: 'clear-text'
46
+ clearUrlButton: 'clear-text',
47
+ linkHelperText: 'link-helper-text'
46
48
  };
47
49
  var TextInput = exports.TextInput = function TextInput(_ref) {
48
50
  var name = _ref.name,
@@ -58,6 +60,7 @@ var TextInput = exports.TextInput = function TextInput(_ref) {
58
60
  inputRefProp = _ref.inputRef,
59
61
  _ref$isRequired = _ref.isRequired,
60
62
  isRequired = _ref$isRequired === void 0 ? false : _ref$isRequired,
63
+ helperMessage = _ref.helperMessage,
61
64
  restProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
62
65
  var inputRef = (0, _react.useRef)(null);
63
66
  var handleRef = (0, _react.useCallback)(function (input) {
@@ -120,8 +123,10 @@ var TextInput = exports.TextInput = function TextInput(_ref) {
120
123
  ref: textfieldRef,
121
124
  elemAfterInput: clearText,
122
125
  isInvalid: !!error,
123
- "aria-describedby": "".concat(restProps['aria-describedby'], " ").concat(fieldProps.id, "-error")
124
- })), error && /*#__PURE__*/_react.default.createElement(_form.ErrorMessage, {
126
+ "aria-describedby": "".concat(restProps['aria-describedby'], " ").concat(fieldProps.id, "-error ").concat((0, _platformFeatureFlags.fg)('navx-3742-refactoring-link-picker-helper-text-a11y') ? "".concat(fieldProps.id, "-helper") : '')
127
+ })), helperMessage && (0, _platformFeatureFlags.fg)('navx-3742-refactoring-link-picker-helper-text-a11y') && /*#__PURE__*/_react.default.createElement(_form.HelperMessage, {
128
+ testId: testIds.linkHelperText
129
+ }, helperMessage), error && /*#__PURE__*/_react.default.createElement(_form.ErrorMessage, {
125
130
  testId: testIds.urlError
126
131
  }, error)));
127
132
  }));
@@ -25,7 +25,7 @@ var testIds = exports.testIds = {
25
25
  };
26
26
  var PACKAGE_DATA = exports.PACKAGE_DATA = {
27
27
  packageName: "@atlaskit/link-picker" || '',
28
- packageVersion: "4.2.9" || '',
28
+ packageVersion: "0.0.0-development" || '',
29
29
  componentName: _constants.COMPONENT_NAME,
30
30
  source: _constants.COMPONENT_NAME
31
31
  };
@@ -7,7 +7,7 @@ import { ANALYTICS_CHANNEL, RECENT_SEARCH_LIST_SIZE } from '../../common/constan
7
7
  import createEventPayload from '../../common/utils/analytics/analytics.codegen';
8
8
  import { usePluginReducer } from './reducer';
9
9
  import { CancellationError, resolvePluginUpdates } from './utils';
10
- export function usePlugins(state, activeTab, plugins, recentSearchListSize) {
10
+ export function usePlugins(state, activeTab, plugins, recentSearchListSize, alwaysShowTabs) {
11
11
  var _activePlugin$tabKey;
12
12
  const {
13
13
  createAnalyticsEvent
@@ -76,13 +76,13 @@ export function usePlugins(state, activeTab, plugins, recentSearchListSize) {
76
76
  return cancel;
77
77
  }, [activePlugin, state, retries, createAnalyticsEvent, dispatch, recentSearchListSize]);
78
78
  const tabs = useMemo(() => {
79
- if (!plugins || plugins.length <= 1) {
79
+ if (!plugins || !alwaysShowTabs && plugins.length <= 1) {
80
80
  return [];
81
81
  }
82
82
  return plugins.filter(plugin => !!plugin.tabTitle).map(plugin => ({
83
83
  tabTitle: plugin.tabTitle
84
84
  }));
85
- }, [plugins]);
85
+ }, [plugins, alwaysShowTabs]);
86
86
  const handleRetry = useCallback(() => {
87
87
  setRetries(prev => ++prev);
88
88
  }, []);
@@ -12,6 +12,7 @@ import { HelperMessage } from '@atlaskit/form';
12
12
  import { CardClient } from '@atlaskit/link-provider';
13
13
  import { isSafeUrl, normalizeUrl } from '@atlaskit/linking-common/url';
14
14
  import { browser } from '@atlaskit/linking-common/user-agent';
15
+ import { fg } from '@atlaskit/platform-feature-flags';
15
16
  import { Box } from '@atlaskit/primitives/compiled';
16
17
  import LinkUrl from '@atlaskit/smart-card/link-url';
17
18
  import { N700 } from '@atlaskit/theme/colors';
@@ -43,7 +44,6 @@ export const testIds = {
43
44
  linkPicker: 'link-picker',
44
45
  urlInputField: 'link-url',
45
46
  textInputField: 'link-text',
46
- linkHelperText: 'link-helper-text',
47
47
  ...searchTestIds,
48
48
  ...formFooterTestIds,
49
49
  ...textFieldTestIds
@@ -108,8 +108,10 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
108
108
  additionalError,
109
109
  submitOnInputChange = false,
110
110
  recentSearchListSize,
111
- shouldRenderNoResultsImage
111
+ shouldRenderNoResultsImage,
112
+ alwaysShowTabs
112
113
  }) => {
114
+ var _customMessages$linkH;
113
115
  const {
114
116
  createAnalyticsEvent
115
117
  } = useAnalyticsEvents();
@@ -138,7 +140,7 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
138
140
  error,
139
141
  retry,
140
142
  pluginAction
141
- } = usePlugins(queryState, activeTab, plugins, recentSearchListSize);
143
+ } = usePlugins(queryState, activeTab, plugins, recentSearchListSize, alwaysShowTabs);
142
144
  const isEditing = !!initUrl;
143
145
  const selectedItem = items === null || items === void 0 ? void 0 : items[selectedIndex];
144
146
  const isSelectedItem = (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.url) === url;
@@ -266,7 +268,7 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
266
268
  hasPreview: false
267
269
  });
268
270
  }
269
- } catch (error) {
271
+ } catch {
270
272
  return dispatch({
271
273
  invalidUrl: true
272
274
  });
@@ -416,7 +418,7 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
416
418
  onChange: handleChangeUrl,
417
419
  inputRef: inputRef,
418
420
  isRequired: true
419
- })), !hideDisplayText && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(DisplayTextInputField, {
421
+ })), !hideDisplayText && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(DisplayTextInputField, _extends({
420
422
  autoComplete: "off",
421
423
  name: "displayText",
422
424
  testId: testIds.textInputField,
@@ -427,7 +429,9 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
427
429
  readOnly: isSubmitting,
428
430
  onClear: handleClear,
429
431
  onChange: handleChangeText
430
- }), /*#__PURE__*/React.createElement(HelperMessage, {
432
+ }, fg('navx-3742-refactoring-link-picker-helper-text-a11y') ? {
433
+ helperMessage: intl.formatMessage((_customMessages$linkH = customMessages === null || customMessages === void 0 ? void 0 : customMessages.linkHelperTextLabel) !== null && _customMessages$linkH !== void 0 ? _customMessages$linkH : linkTextMessages.linkHelperTextLabel)
434
+ } : {})), !fg('navx-3742-refactoring-link-picker-helper-text-a11y') && /*#__PURE__*/React.createElement(HelperMessage, {
431
435
  testId: testIds.linkHelperText
432
436
  }, customMessages !== null && customMessages !== void 0 && customMessages.linkHelperTextLabel ? intl.formatMessage(customMessages === null || customMessages === void 0 ? void 0 : customMessages.linkHelperTextLabel) : intl.formatMessage(linkTextMessages.linkHelperTextLabel))), moveSubmitButton && /*#__PURE__*/React.createElement(Box, {
433
437
  xcss: styles.fullWidthSubmitButton
@@ -4,8 +4,9 @@ import "./index.compiled.css";
4
4
  import { ax, ix } from "@compiled/react/runtime";
5
5
  import React, { Fragment, useCallback, useMemo, useRef } from 'react';
6
6
  import { useMergeRefs } from 'use-callback-ref';
7
- import { ErrorMessage, Field } from '@atlaskit/form';
7
+ import { ErrorMessage, Field, HelperMessage } from '@atlaskit/form';
8
8
  import Selectclear from '@atlaskit/icon/core/cross-circle';
9
+ import { fg } from '@atlaskit/platform-feature-flags';
9
10
  import { Box, Pressable } from '@atlaskit/primitives/compiled';
10
11
  import Textfield from '@atlaskit/textfield';
11
12
  import Tooltip from '@atlaskit/tooltip';
@@ -31,7 +32,8 @@ const RequiredAsterisk = () => {
31
32
  };
32
33
  export const testIds = {
33
34
  urlError: 'link-error',
34
- clearUrlButton: 'clear-text'
35
+ clearUrlButton: 'clear-text',
36
+ linkHelperText: 'link-helper-text'
35
37
  };
36
38
  export const TextInput = ({
37
39
  name,
@@ -46,6 +48,7 @@ export const TextInput = ({
46
48
  spotlightTargetName,
47
49
  inputRef: inputRefProp,
48
50
  isRequired = false,
51
+ helperMessage,
49
52
  ...restProps
50
53
  }) => {
51
54
  const inputRef = useRef(null);
@@ -108,8 +111,10 @@ export const TextInput = ({
108
111
  ref: textfieldRef,
109
112
  elemAfterInput: clearText,
110
113
  isInvalid: !!error,
111
- "aria-describedby": `${restProps['aria-describedby']} ${fieldProps.id}-error`
112
- })), error && /*#__PURE__*/React.createElement(ErrorMessage, {
114
+ "aria-describedby": `${restProps['aria-describedby']} ${fieldProps.id}-error ${fg('navx-3742-refactoring-link-picker-helper-text-a11y') ? `${fieldProps.id}-helper` : ''}`
115
+ })), helperMessage && fg('navx-3742-refactoring-link-picker-helper-text-a11y') && /*#__PURE__*/React.createElement(HelperMessage, {
116
+ testId: testIds.linkHelperText
117
+ }, helperMessage), error && /*#__PURE__*/React.createElement(ErrorMessage, {
113
118
  testId: testIds.urlError
114
119
  }, error)));
115
120
  }));
@@ -15,7 +15,7 @@ export const testIds = {
15
15
  };
16
16
  export const PACKAGE_DATA = {
17
17
  packageName: "@atlaskit/link-picker" || '',
18
- packageVersion: "4.2.9" || '',
18
+ packageVersion: "0.0.0-development" || '',
19
19
  componentName: COMPONENT_NAME,
20
20
  source: COMPONENT_NAME
21
21
  };
@@ -10,7 +10,7 @@ import { ANALYTICS_CHANNEL, RECENT_SEARCH_LIST_SIZE } from '../../common/constan
10
10
  import createEventPayload from '../../common/utils/analytics/analytics.codegen';
11
11
  import { usePluginReducer } from './reducer';
12
12
  import { CancellationError, resolvePluginUpdates } from './utils';
13
- export function usePlugins(state, activeTab, plugins, recentSearchListSize) {
13
+ export function usePlugins(state, activeTab, plugins, recentSearchListSize, alwaysShowTabs) {
14
14
  var _activePlugin$tabKey;
15
15
  var _useAnalyticsEvents = useAnalyticsEvents(),
16
16
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
@@ -107,7 +107,7 @@ export function usePlugins(state, activeTab, plugins, recentSearchListSize) {
107
107
  return cancel;
108
108
  }, [activePlugin, state, retries, createAnalyticsEvent, dispatch, recentSearchListSize]);
109
109
  var tabs = useMemo(function () {
110
- if (!plugins || plugins.length <= 1) {
110
+ if (!plugins || !alwaysShowTabs && plugins.length <= 1) {
111
111
  return [];
112
112
  }
113
113
  return plugins.filter(function (plugin) {
@@ -117,7 +117,7 @@ export function usePlugins(state, activeTab, plugins, recentSearchListSize) {
117
117
  tabTitle: plugin.tabTitle
118
118
  };
119
119
  });
120
- }, [plugins]);
120
+ }, [plugins, alwaysShowTabs]);
121
121
  var handleRetry = useCallback(function () {
122
122
  setRetries(function (prev) {
123
123
  return ++prev;
@@ -18,6 +18,7 @@ import { HelperMessage } from '@atlaskit/form';
18
18
  import { CardClient } from '@atlaskit/link-provider';
19
19
  import { isSafeUrl, normalizeUrl } from '@atlaskit/linking-common/url';
20
20
  import { browser } from '@atlaskit/linking-common/user-agent';
21
+ import { fg } from '@atlaskit/platform-feature-flags';
21
22
  import { Box } from '@atlaskit/primitives/compiled';
22
23
  import LinkUrl from '@atlaskit/smart-card/link-url';
23
24
  import { N700 } from '@atlaskit/theme/colors';
@@ -48,8 +49,7 @@ export var testIds = _objectSpread(_objectSpread(_objectSpread({
48
49
  linkPickerRoot: 'link-picker-root',
49
50
  linkPicker: 'link-picker',
50
51
  urlInputField: 'link-url',
51
- textInputField: 'link-text',
52
- linkHelperText: 'link-helper-text'
52
+ textInputField: 'link-text'
53
53
  }, searchTestIds), formFooterTestIds), textFieldTestIds);
54
54
  var initState = {
55
55
  url: '',
@@ -89,6 +89,7 @@ var LinkInputField = withInputFieldTracking(TextInput, 'link', function (event,
89
89
  var DisplayTextInputField = withInputFieldTracking(TextInput, 'displayText');
90
90
  var client = new CardClient();
91
91
  export var LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(function (_ref) {
92
+ var _customMessages$linkH;
92
93
  var onSubmit = _ref.onSubmit,
93
94
  onCancel = _ref.onCancel,
94
95
  onContentResize = _ref.onContentResize,
@@ -112,7 +113,8 @@ export var LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(functi
112
113
  _ref$submitOnInputCha = _ref.submitOnInputChange,
113
114
  submitOnInputChange = _ref$submitOnInputCha === void 0 ? false : _ref$submitOnInputCha,
114
115
  recentSearchListSize = _ref.recentSearchListSize,
115
- shouldRenderNoResultsImage = _ref.shouldRenderNoResultsImage;
116
+ shouldRenderNoResultsImage = _ref.shouldRenderNoResultsImage,
117
+ alwaysShowTabs = _ref.alwaysShowTabs;
116
118
  var _useAnalyticsEvents = useAnalyticsEvents(),
117
119
  createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
118
120
  var _useReducer = useReducer(reducer, _objectSpread(_objectSpread({}, initState), {}, {
@@ -131,7 +133,7 @@ export var LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(functi
131
133
  hasPreview = state.hasPreview;
132
134
  var intl = useIntl();
133
135
  var queryState = useSearchQuery(state);
134
- var _usePlugins = usePlugins(queryState, activeTab, plugins, recentSearchListSize),
136
+ var _usePlugins = usePlugins(queryState, activeTab, plugins, recentSearchListSize, alwaysShowTabs),
135
137
  items = _usePlugins.items,
136
138
  isLoadingResults = _usePlugins.isLoading,
137
139
  isActivePlugin = _usePlugins.isActivePlugin,
@@ -453,7 +455,7 @@ export var LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(functi
453
455
  onChange: handleChangeUrl,
454
456
  inputRef: inputRef,
455
457
  isRequired: true
456
- })), !hideDisplayText && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(DisplayTextInputField, {
458
+ })), !hideDisplayText && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(DisplayTextInputField, _extends({
457
459
  autoComplete: "off",
458
460
  name: "displayText",
459
461
  testId: testIds.textInputField,
@@ -464,7 +466,9 @@ export var LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(functi
464
466
  readOnly: isSubmitting,
465
467
  onClear: handleClear,
466
468
  onChange: handleChangeText
467
- }), /*#__PURE__*/React.createElement(HelperMessage, {
469
+ }, fg('navx-3742-refactoring-link-picker-helper-text-a11y') ? {
470
+ helperMessage: intl.formatMessage((_customMessages$linkH = customMessages === null || customMessages === void 0 ? void 0 : customMessages.linkHelperTextLabel) !== null && _customMessages$linkH !== void 0 ? _customMessages$linkH : linkTextMessages.linkHelperTextLabel)
471
+ } : {})), !fg('navx-3742-refactoring-link-picker-helper-text-a11y') && /*#__PURE__*/React.createElement(HelperMessage, {
468
472
  testId: testIds.linkHelperText
469
473
  }, customMessages !== null && customMessages !== void 0 && customMessages.linkHelperTextLabel ? intl.formatMessage(customMessages === null || customMessages === void 0 ? void 0 : customMessages.linkHelperTextLabel) : intl.formatMessage(linkTextMessages.linkHelperTextLabel))), moveSubmitButton && /*#__PURE__*/React.createElement(Box, {
470
474
  xcss: styles.fullWidthSubmitButton
@@ -1,13 +1,14 @@
1
1
  /* index.tsx generated by @compiled/babel-plugin v0.38.1 */
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["name", "label", "autoFocus", "onRedo", "onUndo", "onKeyDown", "onClear", "clearLabel", "error", "spotlightTargetName", "inputRef", "isRequired"];
4
+ var _excluded = ["name", "label", "autoFocus", "onRedo", "onUndo", "onKeyDown", "onClear", "clearLabel", "error", "spotlightTargetName", "inputRef", "isRequired", "helperMessage"];
5
5
  import "./index.compiled.css";
6
6
  import { ax, ix } from "@compiled/react/runtime";
7
7
  import React, { Fragment, useCallback, useMemo, useRef } from 'react';
8
8
  import { useMergeRefs } from 'use-callback-ref';
9
- import { ErrorMessage, Field } from '@atlaskit/form';
9
+ import { ErrorMessage, Field, HelperMessage } from '@atlaskit/form';
10
10
  import Selectclear from '@atlaskit/icon/core/cross-circle';
11
+ import { fg } from '@atlaskit/platform-feature-flags';
11
12
  import { Box, Pressable } from '@atlaskit/primitives/compiled';
12
13
  import Textfield from '@atlaskit/textfield';
13
14
  import Tooltip from '@atlaskit/tooltip';
@@ -33,7 +34,8 @@ var RequiredAsterisk = function RequiredAsterisk() {
33
34
  };
34
35
  export var testIds = {
35
36
  urlError: 'link-error',
36
- clearUrlButton: 'clear-text'
37
+ clearUrlButton: 'clear-text',
38
+ linkHelperText: 'link-helper-text'
37
39
  };
38
40
  export var TextInput = function TextInput(_ref) {
39
41
  var name = _ref.name,
@@ -49,6 +51,7 @@ export var TextInput = function TextInput(_ref) {
49
51
  inputRefProp = _ref.inputRef,
50
52
  _ref$isRequired = _ref.isRequired,
51
53
  isRequired = _ref$isRequired === void 0 ? false : _ref$isRequired,
54
+ helperMessage = _ref.helperMessage,
52
55
  restProps = _objectWithoutProperties(_ref, _excluded);
53
56
  var inputRef = useRef(null);
54
57
  var handleRef = useCallback(function (input) {
@@ -111,8 +114,10 @@ export var TextInput = function TextInput(_ref) {
111
114
  ref: textfieldRef,
112
115
  elemAfterInput: clearText,
113
116
  isInvalid: !!error,
114
- "aria-describedby": "".concat(restProps['aria-describedby'], " ").concat(fieldProps.id, "-error")
115
- })), error && /*#__PURE__*/React.createElement(ErrorMessage, {
117
+ "aria-describedby": "".concat(restProps['aria-describedby'], " ").concat(fieldProps.id, "-error ").concat(fg('navx-3742-refactoring-link-picker-helper-text-a11y') ? "".concat(fieldProps.id, "-helper") : '')
118
+ })), helperMessage && fg('navx-3742-refactoring-link-picker-helper-text-a11y') && /*#__PURE__*/React.createElement(HelperMessage, {
119
+ testId: testIds.linkHelperText
120
+ }, helperMessage), error && /*#__PURE__*/React.createElement(ErrorMessage, {
116
121
  testId: testIds.urlError
117
122
  }, error)));
118
123
  }));
@@ -16,7 +16,7 @@ export var testIds = {
16
16
  };
17
17
  export var PACKAGE_DATA = {
18
18
  packageName: "@atlaskit/link-picker" || '',
19
- packageVersion: "4.2.9" || '',
19
+ packageVersion: "0.0.0-development" || '',
20
20
  componentName: COMPONENT_NAME,
21
21
  source: COMPONENT_NAME
22
22
  };
@@ -174,6 +174,8 @@ export interface LinkPickerProps {
174
174
  recentSearchListSize?: number;
175
175
  /** Controls showing the image in the no results state */
176
176
  shouldRenderNoResultsImage?: boolean;
177
+ /** When true, tabs are displayed even if there is only one plugin. */
178
+ alwaysShowTabs?: boolean;
177
179
  }
178
180
  type CustomLinkPickerMessages = {
179
181
  /** Label for the link input field */
@@ -12,4 +12,4 @@ export interface LinkPickerPluginsService {
12
12
  errorFallback?: LinkPickerPluginErrorFallback;
13
13
  pluginAction?: LinkPickerPluginAction;
14
14
  }
15
- export declare function usePlugins(state: LinkPickerState | null, activeTab: number, plugins?: LinkPickerPlugin[], recentSearchListSize?: number): LinkPickerPluginsService;
15
+ export declare function usePlugins(state: LinkPickerState | null, activeTab: number, plugins?: LinkPickerPlugin[], recentSearchListSize?: number, alwaysShowTabs?: boolean): LinkPickerPluginsService;
@@ -2,6 +2,7 @@ import type { LinkPickerProps } from '../../common/types';
2
2
  export declare const testIds: {
3
3
  readonly urlError: string;
4
4
  readonly clearUrlButton: string;
5
+ readonly linkHelperText: string;
5
6
  readonly insertButton: "link-picker-insert-button";
6
7
  readonly cancelButton: "link-picker-cancel-button";
7
8
  readonly actionButton: "link-picker-action-button";
@@ -20,6 +21,5 @@ export declare const testIds: {
20
21
  readonly linkPicker: "link-picker";
21
22
  readonly urlInputField: "link-url";
22
23
  readonly textInputField: "link-text";
23
- readonly linkHelperText: "link-helper-text";
24
24
  };
25
25
  export declare const LinkPicker: import("react").ComponentType<LinkPickerProps>;
@@ -16,9 +16,11 @@ export type TextInputProps = Omit<TextFieldProps, 'name' | 'value'> & Pick<Condi
16
16
  error?: React.ReactNode;
17
17
  /** Ref to the link picker search input. */
18
18
  inputRef?: Ref<HTMLInputElement>;
19
+ helperMessage?: string;
19
20
  };
20
21
  export declare const testIds: {
21
22
  urlError: string;
22
23
  clearUrlButton: string;
24
+ linkHelperText: string;
23
25
  };
24
- export declare const TextInput: ({ name, label, autoFocus, onRedo, onUndo, onKeyDown, onClear, clearLabel, error, spotlightTargetName, inputRef: inputRefProp, isRequired, ...restProps }: TextInputProps) => JSX.Element;
26
+ export declare const TextInput: ({ name, label, autoFocus, onRedo, onUndo, onKeyDown, onClear, clearLabel, error, spotlightTargetName, inputRef: inputRefProp, isRequired, helperMessage, ...restProps }: TextInputProps) => JSX.Element;
@@ -177,6 +177,8 @@ export interface LinkPickerProps {
177
177
  recentSearchListSize?: number;
178
178
  /** Controls showing the image in the no results state */
179
179
  shouldRenderNoResultsImage?: boolean;
180
+ /** When true, tabs are displayed even if there is only one plugin. */
181
+ alwaysShowTabs?: boolean;
180
182
  }
181
183
  type CustomLinkPickerMessages = {
182
184
  /** Label for the link input field */
@@ -12,4 +12,4 @@ export interface LinkPickerPluginsService {
12
12
  errorFallback?: LinkPickerPluginErrorFallback;
13
13
  pluginAction?: LinkPickerPluginAction;
14
14
  }
15
- export declare function usePlugins(state: LinkPickerState | null, activeTab: number, plugins?: LinkPickerPlugin[], recentSearchListSize?: number): LinkPickerPluginsService;
15
+ export declare function usePlugins(state: LinkPickerState | null, activeTab: number, plugins?: LinkPickerPlugin[], recentSearchListSize?: number, alwaysShowTabs?: boolean): LinkPickerPluginsService;
@@ -2,6 +2,7 @@ import type { LinkPickerProps } from '../../common/types';
2
2
  export declare const testIds: {
3
3
  readonly urlError: string;
4
4
  readonly clearUrlButton: string;
5
+ readonly linkHelperText: string;
5
6
  readonly insertButton: "link-picker-insert-button";
6
7
  readonly cancelButton: "link-picker-cancel-button";
7
8
  readonly actionButton: "link-picker-action-button";
@@ -20,6 +21,5 @@ export declare const testIds: {
20
21
  readonly linkPicker: "link-picker";
21
22
  readonly urlInputField: "link-url";
22
23
  readonly textInputField: "link-text";
23
- readonly linkHelperText: "link-helper-text";
24
24
  };
25
25
  export declare const LinkPicker: import("react").ComponentType<LinkPickerProps>;
@@ -16,9 +16,11 @@ export type TextInputProps = Omit<TextFieldProps, 'name' | 'value'> & Pick<Condi
16
16
  error?: React.ReactNode;
17
17
  /** Ref to the link picker search input. */
18
18
  inputRef?: Ref<HTMLInputElement>;
19
+ helperMessage?: string;
19
20
  };
20
21
  export declare const testIds: {
21
22
  urlError: string;
22
23
  clearUrlButton: string;
24
+ linkHelperText: string;
23
25
  };
24
- export declare const TextInput: ({ name, label, autoFocus, onRedo, onUndo, onKeyDown, onClear, clearLabel, error, spotlightTargetName, inputRef: inputRefProp, isRequired, ...restProps }: TextInputProps) => JSX.Element;
26
+ export declare const TextInput: ({ name, label, autoFocus, onRedo, onUndo, onKeyDown, onClear, clearLabel, error, spotlightTargetName, inputRef: inputRefProp, isRequired, helperMessage, ...restProps }: TextInputProps) => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "4.2.9",
3
+ "version": "4.2.10",
4
4
  "description": "Standalone link picker",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "publishConfig": {
@@ -40,6 +40,9 @@
40
40
  },
41
41
  "navx-3332-update-link-picker-heading-levels": {
42
42
  "type": "boolean"
43
+ },
44
+ "navx-3742-refactoring-link-picker-helper-text-a11y": {
45
+ "type": "boolean"
43
46
  }
44
47
  },
45
48
  "scripts": {