@atlaskit/link-picker 1.48.3 → 1.49.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 +8 -0
- package/dist/cjs/common/generic-error-svg/index.compiled.css +2 -0
- package/dist/cjs/common/generic-error-svg/index.js +34 -25
- package/dist/cjs/common/generic-error-svg/old/index.js +66 -0
- package/dist/cjs/common/ui/empty-state/index.compiled.css +3 -0
- package/dist/cjs/common/ui/empty-state/index.js +26 -14
- package/dist/cjs/common/ui/empty-state/old/index.js +38 -0
- package/dist/cjs/common/ui/min-height-container/index.compiled.css +4 -0
- package/dist/cjs/common/ui/min-height-container/index.js +24 -14
- package/dist/cjs/common/ui/min-height-container/old/index.js +34 -0
- package/dist/cjs/ui/error-boundary/error-boundary-fallback/index.compiled.css +1 -0
- package/dist/cjs/ui/error-boundary/error-boundary-fallback/index.js +23 -18
- package/dist/cjs/ui/error-boundary/error-boundary-fallback/old/index.js +50 -0
- package/dist/cjs/ui/link-picker/form-footer/index.compiled.css +3 -0
- package/dist/cjs/ui/link-picker/form-footer/index.js +30 -35
- package/dist/cjs/ui/link-picker/form-footer/link-picker-submit-button/index.js +2 -8
- package/dist/cjs/ui/link-picker/form-footer/old/index.js +116 -0
- package/dist/cjs/ui/link-picker/index.compiled.css +10 -0
- package/dist/cjs/ui/link-picker/index.js +43 -59
- package/dist/cjs/ui/link-picker/old/index.js +435 -0
- package/dist/cjs/ui/link-picker/search-results/index.compiled.css +7 -0
- package/dist/cjs/ui/link-picker/search-results/index.js +33 -32
- package/dist/cjs/ui/link-picker/search-results/link-search-error/index.js +5 -11
- package/dist/cjs/ui/link-picker/search-results/link-search-list/index.compiled.css +23 -0
- package/dist/cjs/ui/link-picker/search-results/link-search-list/index.js +53 -43
- package/dist/cjs/ui/link-picker/search-results/link-search-list/link-search-no-results/no-results-svg/index.compiled.css +2 -0
- package/dist/cjs/ui/link-picker/search-results/link-search-list/link-search-no-results/no-results-svg/index.js +36 -28
- package/dist/cjs/ui/link-picker/search-results/link-search-list/link-search-no-results/no-results-svg/old/index.js +70 -0
- package/dist/cjs/ui/link-picker/search-results/link-search-list/list-item/index.compiled.css +34 -0
- package/dist/cjs/ui/link-picker/search-results/link-search-list/list-item/index.js +99 -76
- package/dist/cjs/ui/link-picker/search-results/link-search-list/list-item/old/index.js +145 -0
- package/dist/cjs/ui/link-picker/search-results/link-search-list/old/index.js +188 -0
- package/dist/cjs/ui/link-picker/search-results/old/index.js +105 -0
- package/dist/cjs/ui/link-picker/search-results/scrolling-tabs/index.compiled.css +29 -0
- package/dist/cjs/ui/link-picker/search-results/scrolling-tabs/index.js +54 -42
- package/dist/cjs/ui/link-picker/search-results/scrolling-tabs/old/index.js +163 -0
- package/dist/cjs/ui/link-picker/search-results/search-results-container/index.compiled.css +4 -0
- package/dist/cjs/ui/link-picker/search-results/search-results-container/index.js +21 -19
- package/dist/cjs/ui/link-picker/search-results/search-results-container/old/index.js +43 -0
- package/dist/cjs/ui/link-picker/text-input/index.compiled.css +10 -0
- package/dist/cjs/ui/link-picker/text-input/index.js +35 -39
- package/dist/cjs/ui/link-picker/text-input/old/index.js +125 -0
- package/dist/cjs/ui/loader-fallback/index.compiled.css +1 -0
- package/dist/cjs/ui/loader-fallback/index.js +21 -15
- package/dist/cjs/ui/loader-fallback/old/index.js +67 -0
- package/dist/cjs/ui/main.compiled.css +1 -0
- package/dist/cjs/ui/main.js +25 -24
- package/dist/cjs/ui/old/main.js +75 -0
- package/dist/es2019/common/generic-error-svg/index.compiled.css +2 -0
- package/dist/es2019/common/generic-error-svg/index.js +27 -23
- package/dist/es2019/common/generic-error-svg/old/index.js +58 -0
- package/dist/es2019/common/ui/empty-state/index.compiled.css +3 -0
- package/dist/es2019/common/ui/empty-state/index.js +18 -9
- package/dist/es2019/common/ui/empty-state/old/index.js +32 -0
- package/dist/es2019/common/ui/min-height-container/index.compiled.css +4 -0
- package/dist/es2019/common/ui/min-height-container/index.js +21 -12
- package/dist/es2019/common/ui/min-height-container/old/index.js +25 -0
- package/dist/es2019/ui/error-boundary/error-boundary-fallback/index.compiled.css +1 -0
- package/dist/es2019/ui/error-boundary/error-boundary-fallback/index.js +19 -16
- package/dist/es2019/ui/error-boundary/error-boundary-fallback/old/index.js +41 -0
- package/dist/es2019/ui/link-picker/form-footer/index.compiled.css +3 -0
- package/dist/es2019/ui/link-picker/form-footer/index.js +27 -32
- package/dist/es2019/ui/link-picker/form-footer/link-picker-submit-button/index.js +2 -7
- package/dist/es2019/ui/link-picker/form-footer/old/index.js +104 -0
- package/dist/es2019/ui/link-picker/index.compiled.css +10 -0
- package/dist/es2019/ui/link-picker/index.js +36 -58
- package/dist/es2019/ui/link-picker/old/index.js +436 -0
- package/dist/es2019/ui/link-picker/search-results/index.compiled.css +7 -0
- package/dist/es2019/ui/link-picker/search-results/index.js +29 -31
- package/dist/es2019/ui/link-picker/search-results/link-search-error/index.js +5 -10
- package/dist/es2019/ui/link-picker/search-results/link-search-list/index.compiled.css +23 -0
- package/dist/es2019/ui/link-picker/search-results/link-search-list/index.js +46 -42
- package/dist/es2019/ui/link-picker/search-results/link-search-list/link-search-no-results/no-results-svg/index.compiled.css +2 -0
- package/dist/es2019/ui/link-picker/search-results/link-search-list/link-search-no-results/no-results-svg/index.js +29 -26
- package/dist/es2019/ui/link-picker/search-results/link-search-list/link-search-no-results/no-results-svg/old/index.js +63 -0
- package/dist/es2019/ui/link-picker/search-results/link-search-list/list-item/index.compiled.css +34 -0
- package/dist/es2019/ui/link-picker/search-results/link-search-list/list-item/index.js +77 -72
- package/dist/es2019/ui/link-picker/search-results/link-search-list/list-item/old/index.js +132 -0
- package/dist/es2019/ui/link-picker/search-results/link-search-list/old/index.js +178 -0
- package/dist/es2019/ui/link-picker/search-results/old/index.js +98 -0
- package/dist/es2019/ui/link-picker/search-results/scrolling-tabs/index.compiled.css +29 -0
- package/dist/es2019/ui/link-picker/search-results/scrolling-tabs/index.js +39 -39
- package/dist/es2019/ui/link-picker/search-results/scrolling-tabs/old/index.js +130 -0
- package/dist/es2019/ui/link-picker/search-results/search-results-container/index.compiled.css +4 -0
- package/dist/es2019/ui/link-picker/search-results/search-results-container/index.js +16 -16
- package/dist/es2019/ui/link-picker/search-results/search-results-container/old/index.js +37 -0
- package/dist/es2019/ui/link-picker/text-input/index.compiled.css +10 -0
- package/dist/es2019/ui/link-picker/text-input/index.js +29 -38
- package/dist/es2019/ui/link-picker/text-input/old/index.js +121 -0
- package/dist/es2019/ui/loader-fallback/index.compiled.css +1 -0
- package/dist/es2019/ui/loader-fallback/index.js +17 -13
- package/dist/es2019/ui/loader-fallback/old/index.js +60 -0
- package/dist/es2019/ui/main.compiled.css +1 -0
- package/dist/es2019/ui/main.js +24 -22
- package/dist/es2019/ui/old/main.js +73 -0
- package/dist/esm/common/generic-error-svg/index.compiled.css +2 -0
- package/dist/esm/common/generic-error-svg/index.js +30 -23
- package/dist/esm/common/generic-error-svg/old/index.js +58 -0
- package/dist/esm/common/ui/empty-state/index.compiled.css +3 -0
- package/dist/esm/common/ui/empty-state/index.js +18 -9
- package/dist/esm/common/ui/empty-state/old/index.js +31 -0
- package/dist/esm/common/ui/min-height-container/index.compiled.css +4 -0
- package/dist/esm/common/ui/min-height-container/index.js +23 -14
- package/dist/esm/common/ui/min-height-container/old/index.js +25 -0
- package/dist/esm/ui/error-boundary/error-boundary-fallback/index.compiled.css +1 -0
- package/dist/esm/ui/error-boundary/error-boundary-fallback/index.js +19 -16
- package/dist/esm/ui/error-boundary/error-boundary-fallback/old/index.js +43 -0
- package/dist/esm/ui/link-picker/form-footer/index.compiled.css +3 -0
- package/dist/esm/ui/link-picker/form-footer/index.js +28 -34
- package/dist/esm/ui/link-picker/form-footer/link-picker-submit-button/index.js +2 -7
- package/dist/esm/ui/link-picker/form-footer/old/index.js +108 -0
- package/dist/esm/ui/link-picker/index.compiled.css +10 -0
- package/dist/esm/ui/link-picker/index.js +37 -59
- package/dist/esm/ui/link-picker/old/index.js +432 -0
- package/dist/esm/ui/link-picker/search-results/index.compiled.css +7 -0
- package/dist/esm/ui/link-picker/search-results/index.js +30 -32
- package/dist/esm/ui/link-picker/search-results/link-search-error/index.js +5 -10
- package/dist/esm/ui/link-picker/search-results/link-search-list/index.compiled.css +23 -0
- package/dist/esm/ui/link-picker/search-results/link-search-list/index.js +47 -43
- package/dist/esm/ui/link-picker/search-results/link-search-list/link-search-no-results/no-results-svg/index.compiled.css +2 -0
- package/dist/esm/ui/link-picker/search-results/link-search-list/link-search-no-results/no-results-svg/index.js +32 -26
- package/dist/esm/ui/link-picker/search-results/link-search-list/link-search-no-results/no-results-svg/old/index.js +63 -0
- package/dist/esm/ui/link-picker/search-results/link-search-list/list-item/index.compiled.css +34 -0
- package/dist/esm/ui/link-picker/search-results/link-search-list/list-item/index.js +94 -72
- package/dist/esm/ui/link-picker/search-results/link-search-list/list-item/old/index.js +136 -0
- package/dist/esm/ui/link-picker/search-results/link-search-list/old/index.js +186 -0
- package/dist/esm/ui/link-picker/search-results/old/index.js +100 -0
- package/dist/esm/ui/link-picker/search-results/scrolling-tabs/index.compiled.css +29 -0
- package/dist/esm/ui/link-picker/search-results/scrolling-tabs/index.js +52 -43
- package/dist/esm/ui/link-picker/search-results/scrolling-tabs/old/index.js +158 -0
- package/dist/esm/ui/link-picker/search-results/search-results-container/index.compiled.css +4 -0
- package/dist/esm/ui/link-picker/search-results/search-results-container/index.js +16 -16
- package/dist/esm/ui/link-picker/search-results/search-results-container/old/index.js +36 -0
- package/dist/esm/ui/link-picker/text-input/index.compiled.css +10 -0
- package/dist/esm/ui/link-picker/text-input/index.js +29 -38
- package/dist/esm/ui/link-picker/text-input/old/index.js +121 -0
- package/dist/esm/ui/loader-fallback/index.compiled.css +1 -0
- package/dist/esm/ui/loader-fallback/index.js +17 -13
- package/dist/esm/ui/loader-fallback/old/index.js +59 -0
- package/dist/esm/ui/main.compiled.css +1 -0
- package/dist/esm/ui/main.js +24 -22
- package/dist/esm/ui/old/main.js +64 -0
- package/dist/types/common/generic-error-svg/index.d.ts +3 -6
- package/dist/types/common/generic-error-svg/old/index.d.ts +6 -0
- package/dist/types/common/types.d.ts +0 -1
- package/dist/types/common/ui/empty-state/index.d.ts +3 -2
- package/dist/types/common/ui/empty-state/old/index.d.ts +9 -0
- package/dist/types/common/ui/min-height-container/index.d.ts +3 -0
- package/dist/types/common/ui/min-height-container/old/index.d.ts +8 -0
- package/dist/types/ui/error-boundary/error-boundary-fallback/index.d.ts +3 -6
- package/dist/types/ui/error-boundary/error-boundary-fallback/old/index.d.ts +6 -0
- package/dist/types/ui/link-picker/form-footer/index.d.ts +2 -5
- package/dist/types/ui/link-picker/form-footer/link-picker-submit-button/index.d.ts +2 -6
- package/dist/types/ui/link-picker/form-footer/old/index.d.ts +42 -0
- package/dist/types/ui/link-picker/index.d.ts +2 -2
- package/dist/types/ui/link-picker/old/index.d.ts +25 -0
- package/dist/types/ui/link-picker/search-results/index.d.ts +2 -2
- package/dist/types/ui/link-picker/search-results/link-search-error/index.d.ts +2 -6
- package/dist/types/ui/link-picker/search-results/link-search-list/index.d.ts +1 -0
- package/dist/types/ui/link-picker/search-results/link-search-list/link-search-no-results/no-results-svg/index.d.ts +3 -6
- package/dist/types/ui/link-picker/search-results/link-search-list/link-search-no-results/no-results-svg/old/index.d.ts +6 -0
- package/dist/types/ui/link-picker/search-results/link-search-list/list-item/index.d.ts +3 -2
- package/dist/types/ui/link-picker/search-results/link-search-list/list-item/old/index.d.ts +23 -0
- package/dist/types/ui/link-picker/search-results/link-search-list/old/index.d.ts +52 -0
- package/dist/types/ui/link-picker/search-results/old/index.d.ts +45 -0
- package/dist/types/ui/link-picker/search-results/scrolling-tabs/index.d.ts +4 -4
- package/dist/types/ui/link-picker/search-results/scrolling-tabs/old/index.d.ts +7 -0
- package/dist/types/ui/link-picker/search-results/search-results-container/index.d.ts +2 -2
- package/dist/types/ui/link-picker/search-results/search-results-container/old/index.d.ts +10 -0
- package/dist/types/ui/link-picker/text-input/index.d.ts +3 -2
- package/dist/types/ui/link-picker/text-input/old/index.d.ts +18 -0
- package/dist/types/ui/loader-fallback/index.d.ts +3 -6
- package/dist/types/ui/loader-fallback/old/index.d.ts +17 -0
- package/dist/types/ui/main.d.ts +2 -2
- package/dist/types/ui/old/main.d.ts +13 -0
- package/dist/types-ts4.5/common/generic-error-svg/index.d.ts +3 -6
- package/dist/types-ts4.5/common/generic-error-svg/old/index.d.ts +6 -0
- package/dist/types-ts4.5/common/types.d.ts +0 -1
- package/dist/types-ts4.5/common/ui/empty-state/index.d.ts +3 -2
- package/dist/types-ts4.5/common/ui/empty-state/old/index.d.ts +9 -0
- package/dist/types-ts4.5/common/ui/min-height-container/index.d.ts +3 -0
- package/dist/types-ts4.5/common/ui/min-height-container/old/index.d.ts +8 -0
- package/dist/types-ts4.5/ui/error-boundary/error-boundary-fallback/index.d.ts +3 -6
- package/dist/types-ts4.5/ui/error-boundary/error-boundary-fallback/old/index.d.ts +6 -0
- package/dist/types-ts4.5/ui/link-picker/form-footer/index.d.ts +2 -5
- package/dist/types-ts4.5/ui/link-picker/form-footer/link-picker-submit-button/index.d.ts +2 -6
- package/dist/types-ts4.5/ui/link-picker/form-footer/old/index.d.ts +42 -0
- package/dist/types-ts4.5/ui/link-picker/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/link-picker/old/index.d.ts +25 -0
- package/dist/types-ts4.5/ui/link-picker/search-results/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/link-picker/search-results/link-search-error/index.d.ts +2 -6
- package/dist/types-ts4.5/ui/link-picker/search-results/link-search-list/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/link-picker/search-results/link-search-list/link-search-no-results/no-results-svg/index.d.ts +3 -6
- package/dist/types-ts4.5/ui/link-picker/search-results/link-search-list/link-search-no-results/no-results-svg/old/index.d.ts +6 -0
- package/dist/types-ts4.5/ui/link-picker/search-results/link-search-list/list-item/index.d.ts +3 -2
- package/dist/types-ts4.5/ui/link-picker/search-results/link-search-list/list-item/old/index.d.ts +23 -0
- package/dist/types-ts4.5/ui/link-picker/search-results/link-search-list/old/index.d.ts +52 -0
- package/dist/types-ts4.5/ui/link-picker/search-results/old/index.d.ts +45 -0
- package/dist/types-ts4.5/ui/link-picker/search-results/scrolling-tabs/index.d.ts +4 -4
- package/dist/types-ts4.5/ui/link-picker/search-results/scrolling-tabs/old/index.d.ts +7 -0
- package/dist/types-ts4.5/ui/link-picker/search-results/search-results-container/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/link-picker/search-results/search-results-container/old/index.d.ts +10 -0
- package/dist/types-ts4.5/ui/link-picker/text-input/index.d.ts +3 -2
- package/dist/types-ts4.5/ui/link-picker/text-input/old/index.d.ts +18 -0
- package/dist/types-ts4.5/ui/loader-fallback/index.d.ts +3 -6
- package/dist/types-ts4.5/ui/loader-fallback/old/index.d.ts +17 -0
- package/dist/types-ts4.5/ui/main.d.ts +2 -2
- package/dist/types-ts4.5/ui/old/main.d.ts +13 -0
- package/lazy/package.json +3 -1
- package/package.json +11 -4
- package/dist/cjs/ui/link-picker/form-footer/feature-discovery/index.js +0 -69
- package/dist/cjs/ui/link-picker/form-footer/feature-discovery/styled.js +0 -25
- package/dist/es2019/ui/link-picker/form-footer/feature-discovery/index.js +0 -61
- package/dist/es2019/ui/link-picker/form-footer/feature-discovery/styled.js +0 -18
- package/dist/esm/ui/link-picker/form-footer/feature-discovery/index.js +0 -62
- package/dist/esm/ui/link-picker/form-footer/feature-discovery/styled.js +0 -18
- package/dist/types/ui/link-picker/form-footer/feature-discovery/index.d.ts +0 -15
- package/dist/types/ui/link-picker/form-footer/feature-discovery/styled.d.ts +0 -1
- package/dist/types-ts4.5/ui/link-picker/form-footer/feature-discovery/index.d.ts +0 -15
- package/dist/types-ts4.5/ui/link-picker/form-footer/feature-discovery/styled.d.ts +0 -1
- /package/dist/cjs/common/ui/min-height-container/{styled.js → old/styled.js} +0 -0
- /package/dist/cjs/ui/link-picker/search-results/link-search-list/list-item/{styled.js → old/styled.js} +0 -0
- /package/dist/cjs/ui/link-picker/search-results/link-search-list/{styled.js → old/styled.js} +0 -0
- /package/dist/cjs/ui/link-picker/search-results/scrolling-tabs/{styles.js → old/styles.js} +0 -0
- /package/dist/es2019/common/ui/min-height-container/{styled.js → old/styled.js} +0 -0
- /package/dist/es2019/ui/link-picker/search-results/link-search-list/list-item/{styled.js → old/styled.js} +0 -0
- /package/dist/es2019/ui/link-picker/search-results/link-search-list/{styled.js → old/styled.js} +0 -0
- /package/dist/es2019/ui/link-picker/search-results/scrolling-tabs/{styles.js → old/styles.js} +0 -0
- /package/dist/esm/common/ui/min-height-container/{styled.js → old/styled.js} +0 -0
- /package/dist/esm/ui/link-picker/search-results/link-search-list/list-item/{styled.js → old/styled.js} +0 -0
- /package/dist/esm/ui/link-picker/search-results/link-search-list/{styled.js → old/styled.js} +0 -0
- /package/dist/esm/ui/link-picker/search-results/scrolling-tabs/{styles.js → old/styles.js} +0 -0
- /package/dist/types/common/ui/min-height-container/{styled.d.ts → old/styled.d.ts} +0 -0
- /package/dist/types/ui/link-picker/search-results/link-search-list/list-item/{styled.d.ts → old/styled.d.ts} +0 -0
- /package/dist/types/ui/link-picker/search-results/link-search-list/{styled.d.ts → old/styled.d.ts} +0 -0
- /package/dist/types/ui/link-picker/search-results/scrolling-tabs/{styles.d.ts → old/styles.d.ts} +0 -0
- /package/dist/types-ts4.5/common/ui/min-height-container/{styled.d.ts → old/styled.d.ts} +0 -0
- /package/dist/types-ts4.5/ui/link-picker/search-results/link-search-list/list-item/{styled.d.ts → old/styled.d.ts} +0 -0
- /package/dist/types-ts4.5/ui/link-picker/search-results/link-search-list/{styled.d.ts → old/styled.d.ts} +0 -0
- /package/dist/types-ts4.5/ui/link-picker/search-results/scrolling-tabs/{styles.d.ts → old/styles.d.ts} +0 -0
|
@@ -1,19 +1,16 @@
|
|
|
1
|
+
/* index.tsx generated by @compiled/babel-plugin v0.36.0 */
|
|
1
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
*/
|
|
3
|
+
import "./index.compiled.css";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
6
6
|
import { Fragment, memo, useCallback, useLayoutEffect, useMemo, useReducer } 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
7
|
import { FormattedMessage, useIntl } from 'react-intl-next';
|
|
11
8
|
import uuid from 'uuid';
|
|
12
9
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
13
10
|
import { isSafeUrl, normalizeUrl } from '@atlaskit/linking-common/url';
|
|
14
11
|
import { browser } from '@atlaskit/linking-common/user-agent';
|
|
15
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
|
-
import { Box
|
|
13
|
+
import { Box } from '@atlaskit/primitives/compiled';
|
|
17
14
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
18
15
|
import { useLinkPickerAnalytics, withInputFieldTracking, withLinkPickerAnalyticsContext } from '../../common/analytics';
|
|
19
16
|
import { ANALYTICS_CHANNEL } from '../../common/constants';
|
|
@@ -25,24 +22,16 @@ import { Announcer } from './announcer';
|
|
|
25
22
|
import { FormFooter, testIds as formFooterTestIds } from './form-footer';
|
|
26
23
|
import { LinkPickerSubmitButton } from './form-footer/link-picker-submit-button';
|
|
27
24
|
import { formMessages, linkMessages, linkTextMessages, searchMessages } from './messages';
|
|
25
|
+
import { LinkPickerOld } from './old';
|
|
28
26
|
import { SearchResults, testIds as searchTestIds } from './search-results';
|
|
29
27
|
import { testIds as textFieldTestIds, TextInput } from './text-input';
|
|
30
28
|
import { TrackMount } from './track-mount';
|
|
31
29
|
import { getDataSource, getScreenReaderText } from './utils';
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
boxSizing: 'border-box',
|
|
38
|
-
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
39
|
-
lineHeight: 'initial',
|
|
40
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
41
|
-
display: 'block !important'
|
|
42
|
-
});
|
|
43
|
-
const formFooterMargin = css({
|
|
44
|
-
marginTop: "var(--ds-space-200, 16px)"
|
|
45
|
-
});
|
|
30
|
+
const styles = {
|
|
31
|
+
fullWidthSubmitButton: "_19pkpxbi _1e0c1txw _2lx21bp4"
|
|
32
|
+
};
|
|
33
|
+
const rootContainerStyles = null;
|
|
34
|
+
const formFooterMargin = null;
|
|
46
35
|
export const testIds = {
|
|
47
36
|
linkPickerRoot: 'link-picker-root',
|
|
48
37
|
linkPicker: 'link-picker',
|
|
@@ -59,23 +48,14 @@ const initState = {
|
|
|
59
48
|
selectedIndex: -1,
|
|
60
49
|
invalidUrl: false,
|
|
61
50
|
activeTab: 0,
|
|
62
|
-
preventHidingRecents: false
|
|
63
|
-
/** This only allows the feature discovery pulse - to be shown the ff must be on and active tab be Jira */
|
|
64
|
-
allowCreateFeatureDiscovery: true
|
|
51
|
+
preventHidingRecents: false
|
|
65
52
|
};
|
|
66
|
-
const FullWidthSubmitButtonStyles = xcss({
|
|
67
|
-
marginTop: 'space.200',
|
|
68
|
-
display: 'flex',
|
|
69
|
-
flexDirection: 'column'
|
|
70
|
-
});
|
|
71
53
|
function reducer(state, payload) {
|
|
72
54
|
if (payload.url && state.url !== payload.url) {
|
|
73
55
|
return {
|
|
74
56
|
...state,
|
|
75
57
|
invalidUrl: false,
|
|
76
58
|
selectedIndex: isSafeUrl(payload.url) && payload.url.length ? -1 : state.selectedIndex,
|
|
77
|
-
/** When the user starts entering a url, stop pulsing the create button */
|
|
78
|
-
allowCreateFeatureDiscovery: false,
|
|
79
59
|
...payload
|
|
80
60
|
};
|
|
81
61
|
}
|
|
@@ -88,7 +68,6 @@ function reducer(state, payload) {
|
|
|
88
68
|
/**
|
|
89
69
|
* Bind input fields to analytics tracking
|
|
90
70
|
*/
|
|
91
|
-
|
|
92
71
|
const getLinkFieldContent = value => {
|
|
93
72
|
if (!Boolean(value)) {
|
|
94
73
|
return null;
|
|
@@ -100,7 +79,7 @@ const LinkInputField = withInputFieldTracking(TextInput, 'link', (event, attribu
|
|
|
100
79
|
linkFieldContent: getLinkFieldContent(event.currentTarget.value)
|
|
101
80
|
}));
|
|
102
81
|
const DisplayTextInputField = withInputFieldTracking(TextInput, 'displayText');
|
|
103
|
-
export const
|
|
82
|
+
export const LinkPickerNew = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
104
83
|
onSubmit,
|
|
105
84
|
onCancel,
|
|
106
85
|
onContentResize,
|
|
@@ -129,8 +108,7 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
129
108
|
url,
|
|
130
109
|
displayText,
|
|
131
110
|
invalidUrl,
|
|
132
|
-
activeTab
|
|
133
|
-
allowCreateFeatureDiscovery
|
|
111
|
+
activeTab
|
|
134
112
|
} = state;
|
|
135
113
|
const intl = useIntl();
|
|
136
114
|
const queryState = useSearchQuery(state);
|
|
@@ -347,20 +325,19 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
347
325
|
// for details: https://a11y-internal.atlassian.net/browse/AK-740
|
|
348
326
|
const screenReaderText = browser().safari && getScreenReaderText(items !== null && items !== void 0 ? items : [], selectedIndex, intl);
|
|
349
327
|
const customSubmitButtonLabel = customMessages !== null && customMessages !== void 0 && customMessages.submitButtonLabel ? customMessages.submitButtonLabel : undefined;
|
|
350
|
-
return
|
|
328
|
+
return /*#__PURE__*/React.createElement("form", {
|
|
351
329
|
"data-testid": testIds.linkPicker,
|
|
352
|
-
css: rootContainerStyles
|
|
353
330
|
// Use onSubmitCapture instead of onSubmit so that any possible parent form isn't submitted
|
|
354
|
-
,
|
|
355
|
-
|
|
356
|
-
},
|
|
331
|
+
onSubmitCapture: handleSubmit,
|
|
332
|
+
className: ax(["_19bv164s _u5f31pah _ca0q1k79 _n3td1t3k _vchhusvi _vwz44jg8 _1e0ctcjq"])
|
|
333
|
+
}, /*#__PURE__*/React.createElement(TrackMount, null), isActivePlugin && /*#__PURE__*/React.createElement(Fragment, null, screenReaderText && /*#__PURE__*/React.createElement(Announcer, {
|
|
357
334
|
ariaLive: "assertive",
|
|
358
335
|
text: screenReaderText,
|
|
359
336
|
ariaRelevant: "additions",
|
|
360
337
|
delay: 250
|
|
361
|
-
}),
|
|
338
|
+
}), /*#__PURE__*/React.createElement(VisuallyHidden, {
|
|
362
339
|
id: screenReaderDescriptionId
|
|
363
|
-
}, customMessages !== null && customMessages !== void 0 && customMessages.linkAriaLabel ?
|
|
340
|
+
}, customMessages !== null && customMessages !== void 0 && customMessages.linkAriaLabel ? /*#__PURE__*/React.createElement(FormattedMessage, customMessages.linkAriaLabel) : /*#__PURE__*/React.createElement(FormattedMessage, messages.linkAriaLabel))), /*#__PURE__*/React.createElement(LinkInputField, _extends({
|
|
364
341
|
name: "url",
|
|
365
342
|
autoComplete: "off",
|
|
366
343
|
testId: testIds.urlInputField,
|
|
@@ -376,7 +353,7 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
376
353
|
onClear: handleUrlClear,
|
|
377
354
|
onKeyDown: handleKeyDown,
|
|
378
355
|
onChange: handleChangeUrl
|
|
379
|
-
})), !hideDisplayText &&
|
|
356
|
+
})), !hideDisplayText && /*#__PURE__*/React.createElement(DisplayTextInputField, {
|
|
380
357
|
autoComplete: "off",
|
|
381
358
|
name: "displayText",
|
|
382
359
|
testId: testIds.textInputField,
|
|
@@ -387,9 +364,9 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
387
364
|
readOnly: isSubmitting,
|
|
388
365
|
onClear: handleClear,
|
|
389
366
|
onChange: handleChangeText
|
|
390
|
-
}), UNSAFE_moveSubmitButton &&
|
|
391
|
-
xcss:
|
|
392
|
-
},
|
|
367
|
+
}), UNSAFE_moveSubmitButton && /*#__PURE__*/React.createElement(Box, {
|
|
368
|
+
xcss: styles.fullWidthSubmitButton
|
|
369
|
+
}, /*#__PURE__*/React.createElement(LinkPickerSubmitButton, {
|
|
393
370
|
isEditing: isEditing,
|
|
394
371
|
isLoading: isLoadingResults || !!isLoadingPlugins,
|
|
395
372
|
isSubmitting: isSubmitting,
|
|
@@ -400,7 +377,7 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
400
377
|
submitMessageId: submitMessageId,
|
|
401
378
|
testId: testIds.insertButton,
|
|
402
379
|
url: url
|
|
403
|
-
})), !!queryState && (isLoadingPlugins || isActivePlugin) &&
|
|
380
|
+
})), !!queryState && (isLoadingPlugins || isActivePlugin) && /*#__PURE__*/React.createElement(SearchResults, {
|
|
404
381
|
activeTab: activeTab,
|
|
405
382
|
tabs: tabs,
|
|
406
383
|
activePlugin: activePlugin,
|
|
@@ -420,7 +397,7 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
420
397
|
handleSearchListOnChange: handleSearchListOnChange,
|
|
421
398
|
adaptiveHeight: adaptiveHeight,
|
|
422
399
|
retry: retry
|
|
423
|
-
}),
|
|
400
|
+
}), /*#__PURE__*/React.createElement(FormFooter, {
|
|
424
401
|
error: error,
|
|
425
402
|
items: items
|
|
426
403
|
/** If the results section appears to be loading, impact whether the submit button is disabled */,
|
|
@@ -430,15 +407,16 @@ export const LinkPicker = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
|
430
407
|
url: url,
|
|
431
408
|
isEditing: isEditing,
|
|
432
409
|
onCancel: onCancel,
|
|
433
|
-
action: pluginAction
|
|
434
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
435
|
-
,
|
|
436
|
-
css: !queryState || !(plugins !== null && plugins !== void 0 && plugins.length) ? formFooterMargin : undefined
|
|
437
|
-
/* Show the feature discovery pulse when we're on the Jira tab, we haven't started typing a url and
|
|
438
|
-
the feature flag is enabled */,
|
|
439
|
-
createFeatureDiscovery: (activePlugin === null || activePlugin === void 0 ? void 0 : activePlugin.tabKey) === 'jira' && allowCreateFeatureDiscovery && fg('platform.linking-platform.link-picker.enable-jira-create'),
|
|
410
|
+
action: pluginAction,
|
|
440
411
|
customSubmitButtonLabel: customSubmitButtonLabel,
|
|
441
412
|
submitMessageId: submitMessageId,
|
|
442
|
-
hideSubmitButton: UNSAFE_moveSubmitButton
|
|
413
|
+
hideSubmitButton: UNSAFE_moveSubmitButton,
|
|
414
|
+
className: ax([(!queryState || !(plugins !== null && plugins !== void 0 && plugins.length)) && "_19pkpxbi"])
|
|
443
415
|
}));
|
|
444
|
-
}));
|
|
416
|
+
}));
|
|
417
|
+
export const LinkPicker = props => {
|
|
418
|
+
if (fg('platform_bandicoots-link-picker-css')) {
|
|
419
|
+
return /*#__PURE__*/React.createElement(LinkPickerNew, props);
|
|
420
|
+
}
|
|
421
|
+
return /*#__PURE__*/React.createElement(LinkPickerOld, props);
|
|
422
|
+
};
|
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/* eslint-disable @atlassian/tangerine/import/no-parent-imports */
|
|
3
|
+
/**
|
|
4
|
+
* @jsxRuntime classic
|
|
5
|
+
* @jsx jsx
|
|
6
|
+
*/
|
|
7
|
+
import { Fragment, memo, useCallback, useLayoutEffect, useMemo, useReducer } 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 { FormattedMessage, useIntl } from 'react-intl-next';
|
|
12
|
+
import uuid from 'uuid';
|
|
13
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
14
|
+
import { isSafeUrl, normalizeUrl } from '@atlaskit/linking-common/url';
|
|
15
|
+
import { browser } from '@atlaskit/linking-common/user-agent';
|
|
16
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
17
|
+
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
18
|
+
import { useLinkPickerAnalytics, withInputFieldTracking, withLinkPickerAnalyticsContext } from '../../../common/analytics';
|
|
19
|
+
import { ANALYTICS_CHANNEL } from '../../../common/constants';
|
|
20
|
+
import createEventPayload from '../../../common/utils/analytics/analytics.codegen';
|
|
21
|
+
import { handleNavKeyDown } from '../../../common/utils/handleNavKeyDown';
|
|
22
|
+
import { usePlugins } from '../../../services/use-plugins';
|
|
23
|
+
import { useSearchQuery } from '../../../services/use-search-query';
|
|
24
|
+
import { Announcer } from '../announcer';
|
|
25
|
+
import { FormFooter, testIds as formFooterTestIds } from '../form-footer';
|
|
26
|
+
import { LinkPickerSubmitButton } from '../form-footer/link-picker-submit-button';
|
|
27
|
+
import { formMessages, linkMessages, linkTextMessages, searchMessages } from '../messages';
|
|
28
|
+
import { SearchResults, testIds as searchTestIds } from '../search-results';
|
|
29
|
+
import { testIds as textFieldTestIds, TextInput } from '../text-input';
|
|
30
|
+
import { TrackMount } from '../track-mount';
|
|
31
|
+
import { getDataSource, getScreenReaderText } from '../utils';
|
|
32
|
+
const rootContainerStyles = css({
|
|
33
|
+
paddingLeft: 'var(--link-picker-padding-left)',
|
|
34
|
+
paddingRight: 'var(--link-picker-padding-right)',
|
|
35
|
+
paddingTop: 'var(--link-picker-padding-top)',
|
|
36
|
+
paddingBottom: 'var(--link-picker-padding-bottom)',
|
|
37
|
+
boxSizing: 'border-box',
|
|
38
|
+
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
39
|
+
lineHeight: 'initial',
|
|
40
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
41
|
+
display: 'block !important'
|
|
42
|
+
});
|
|
43
|
+
const formFooterMargin = css({
|
|
44
|
+
marginTop: "var(--ds-space-200, 16px)"
|
|
45
|
+
});
|
|
46
|
+
export const testIds = {
|
|
47
|
+
linkPickerRoot: 'link-picker-root',
|
|
48
|
+
linkPicker: 'link-picker',
|
|
49
|
+
urlInputField: 'link-url',
|
|
50
|
+
textInputField: 'link-text',
|
|
51
|
+
...searchTestIds,
|
|
52
|
+
...formFooterTestIds,
|
|
53
|
+
...textFieldTestIds
|
|
54
|
+
};
|
|
55
|
+
const initState = {
|
|
56
|
+
url: '',
|
|
57
|
+
displayText: '',
|
|
58
|
+
activeIndex: -1,
|
|
59
|
+
selectedIndex: -1,
|
|
60
|
+
invalidUrl: false,
|
|
61
|
+
activeTab: 0,
|
|
62
|
+
preventHidingRecents: false
|
|
63
|
+
};
|
|
64
|
+
const FullWidthSubmitButtonStyles = xcss({
|
|
65
|
+
marginTop: 'space.200',
|
|
66
|
+
display: 'flex',
|
|
67
|
+
flexDirection: 'column'
|
|
68
|
+
});
|
|
69
|
+
function reducer(state, payload) {
|
|
70
|
+
if (payload.url && state.url !== payload.url) {
|
|
71
|
+
return {
|
|
72
|
+
...state,
|
|
73
|
+
invalidUrl: false,
|
|
74
|
+
selectedIndex: isSafeUrl(payload.url) && payload.url.length ? -1 : state.selectedIndex,
|
|
75
|
+
...payload
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
...state,
|
|
80
|
+
...payload
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Bind input fields to analytics tracking
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
const getLinkFieldContent = value => {
|
|
89
|
+
if (!Boolean(value)) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
return isSafeUrl(value) ? 'url' : 'text_string';
|
|
93
|
+
};
|
|
94
|
+
const LinkInputField = withInputFieldTracking(TextInput, 'link', (event, attributes) => ({
|
|
95
|
+
...attributes,
|
|
96
|
+
linkFieldContent: getLinkFieldContent(event.currentTarget.value)
|
|
97
|
+
}));
|
|
98
|
+
const DisplayTextInputField = withInputFieldTracking(TextInput, 'displayText');
|
|
99
|
+
export const LinkPickerOld = withLinkPickerAnalyticsContext( /*#__PURE__*/memo(({
|
|
100
|
+
onSubmit,
|
|
101
|
+
onCancel,
|
|
102
|
+
onContentResize,
|
|
103
|
+
plugins,
|
|
104
|
+
isLoadingPlugins,
|
|
105
|
+
url: initUrl,
|
|
106
|
+
displayText: initDisplayText,
|
|
107
|
+
hideDisplayText,
|
|
108
|
+
featureFlags,
|
|
109
|
+
customMessages,
|
|
110
|
+
isSubmitting = false,
|
|
111
|
+
adaptiveHeight = false,
|
|
112
|
+
UNSAFE_moveSubmitButton = false
|
|
113
|
+
}) => {
|
|
114
|
+
const {
|
|
115
|
+
createAnalyticsEvent
|
|
116
|
+
} = useAnalyticsEvents();
|
|
117
|
+
const [state, dispatch] = useReducer(reducer, {
|
|
118
|
+
...initState,
|
|
119
|
+
url: normalizeUrl(initUrl) || '',
|
|
120
|
+
displayText: initDisplayText || ''
|
|
121
|
+
});
|
|
122
|
+
const {
|
|
123
|
+
activeIndex,
|
|
124
|
+
selectedIndex,
|
|
125
|
+
url,
|
|
126
|
+
displayText,
|
|
127
|
+
invalidUrl,
|
|
128
|
+
activeTab
|
|
129
|
+
} = state;
|
|
130
|
+
const intl = useIntl();
|
|
131
|
+
const queryState = useSearchQuery(state);
|
|
132
|
+
const {
|
|
133
|
+
items,
|
|
134
|
+
isLoading: isLoadingResults,
|
|
135
|
+
isActivePlugin,
|
|
136
|
+
activePlugin,
|
|
137
|
+
tabs,
|
|
138
|
+
error,
|
|
139
|
+
retry,
|
|
140
|
+
pluginAction
|
|
141
|
+
} = usePlugins(queryState, activeTab, plugins);
|
|
142
|
+
const isEditing = !!initUrl;
|
|
143
|
+
const selectedItem = items === null || items === void 0 ? void 0 : items[selectedIndex];
|
|
144
|
+
const isSelectedItem = (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.url) === url;
|
|
145
|
+
const {
|
|
146
|
+
trackAttribute,
|
|
147
|
+
getAttributes
|
|
148
|
+
} = useLinkPickerAnalytics();
|
|
149
|
+
const submitMessageId = useMemo(() => uuid(), []);
|
|
150
|
+
useLayoutEffect(() => {
|
|
151
|
+
if (onContentResize) {
|
|
152
|
+
onContentResize();
|
|
153
|
+
}
|
|
154
|
+
}, [onContentResize, items, isLoadingResults, isActivePlugin, tabs]);
|
|
155
|
+
const handleChangeUrl = useCallback(e => {
|
|
156
|
+
if (isSubmitting) {
|
|
157
|
+
// Prevent changing url while submitting
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Any on change event is triggered by manual input or paste, so source is null */
|
|
162
|
+
trackAttribute('linkFieldContentInputSource', null);
|
|
163
|
+
dispatch({
|
|
164
|
+
url: e.currentTarget.value,
|
|
165
|
+
// If the last action was changing tabs, make sure we're now allowing recents to be hidden
|
|
166
|
+
preventHidingRecents: false
|
|
167
|
+
});
|
|
168
|
+
}, [dispatch, trackAttribute, isSubmitting]);
|
|
169
|
+
const handleChangeText = useCallback(e => {
|
|
170
|
+
dispatch({
|
|
171
|
+
displayText: e.currentTarget.value
|
|
172
|
+
});
|
|
173
|
+
}, [dispatch]);
|
|
174
|
+
const handleClear = useCallback(field => {
|
|
175
|
+
dispatch({
|
|
176
|
+
activeIndex: -1,
|
|
177
|
+
selectedIndex: -1,
|
|
178
|
+
[field]: ''
|
|
179
|
+
});
|
|
180
|
+
}, [dispatch]);
|
|
181
|
+
const handleUrlClear = useCallback(() => {
|
|
182
|
+
if (isSubmitting) {
|
|
183
|
+
// Prevent clearing url while submitting
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
trackAttribute('linkFieldContentInputSource', null);
|
|
187
|
+
handleClear('url');
|
|
188
|
+
}, [trackAttribute, handleClear, isSubmitting]);
|
|
189
|
+
const handleInsert = useCallback((url, title, inputType, data) => {
|
|
190
|
+
const event = createAnalyticsEvent(createEventPayload('ui.form.submitted.linkPicker', {}));
|
|
191
|
+
|
|
192
|
+
// Clone the event so that it can be emitted for consumer usage
|
|
193
|
+
// This must happen BEFORE the original event is fired!
|
|
194
|
+
const consumerEvent = event.clone();
|
|
195
|
+
// Cloned event doesnt have the attributes that are added by
|
|
196
|
+
// the analytics listener in the LinkPickerAnalyticsContext, add them here
|
|
197
|
+
consumerEvent === null || consumerEvent === void 0 ? void 0 : consumerEvent.update({
|
|
198
|
+
attributes: getAttributes()
|
|
199
|
+
});
|
|
200
|
+
// Dispatch the original event to our channel
|
|
201
|
+
event.fire(ANALYTICS_CHANNEL);
|
|
202
|
+
onSubmit({
|
|
203
|
+
url,
|
|
204
|
+
displayText: displayText || null,
|
|
205
|
+
title: title || null,
|
|
206
|
+
meta: {
|
|
207
|
+
inputMethod: inputType
|
|
208
|
+
},
|
|
209
|
+
data,
|
|
210
|
+
...(inputType === 'manual' ? {
|
|
211
|
+
rawUrl: state.url
|
|
212
|
+
} : {})
|
|
213
|
+
}, consumerEvent);
|
|
214
|
+
}, [displayText, onSubmit, state.url, createAnalyticsEvent, getAttributes]);
|
|
215
|
+
const handleSelected = useCallback(objectId => {
|
|
216
|
+
if (isSubmitting) {
|
|
217
|
+
// Prevent changing selection while submitting
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const selectedItem = items === null || items === void 0 ? void 0 : items.find(item => item.objectId === objectId);
|
|
221
|
+
if (selectedItem) {
|
|
222
|
+
const {
|
|
223
|
+
url,
|
|
224
|
+
name
|
|
225
|
+
} = selectedItem;
|
|
226
|
+
/**
|
|
227
|
+
* Manually track that the url has been updated using searchResult method
|
|
228
|
+
*/
|
|
229
|
+
dispatchEvent(new Event('submit'));
|
|
230
|
+
trackAttribute('linkFieldContent', getLinkFieldContent(url));
|
|
231
|
+
trackAttribute('linkFieldContentInputMethod', 'searchResult');
|
|
232
|
+
trackAttribute('linkFieldContentInputSource', getDataSource(selectedItem, activePlugin));
|
|
233
|
+
handleInsert(url, name, 'typeAhead', {
|
|
234
|
+
...selectedItem
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}, [handleInsert, trackAttribute, items, activePlugin, isSubmitting]);
|
|
238
|
+
const handleSubmit = useCallback(event => {
|
|
239
|
+
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
240
|
+
if (isSubmitting) {
|
|
241
|
+
// Prevent submit while submitting
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (isSelectedItem && selectedItem) {
|
|
245
|
+
return handleInsert(selectedItem.url, selectedItem.name, 'typeAhead');
|
|
246
|
+
}
|
|
247
|
+
const normalized = normalizeUrl(url);
|
|
248
|
+
if (normalized) {
|
|
249
|
+
return handleInsert(normalized, null, 'manual');
|
|
250
|
+
}
|
|
251
|
+
return dispatch({
|
|
252
|
+
invalidUrl: true
|
|
253
|
+
});
|
|
254
|
+
}, [dispatch, handleInsert, isSelectedItem, selectedItem, url, isSubmitting]);
|
|
255
|
+
const handleTabChange = useCallback(activeTab => {
|
|
256
|
+
var _plugins$activeTab$ta, _plugins$activeTab;
|
|
257
|
+
dispatch({
|
|
258
|
+
// We don't want any selection to exist after changing tab, as the selection
|
|
259
|
+
// wouldn't mean anything.
|
|
260
|
+
activeIndex: -1,
|
|
261
|
+
selectedIndex: -1,
|
|
262
|
+
// We don't want recents to be hidden, even though we don't have a selection
|
|
263
|
+
preventHidingRecents: true,
|
|
264
|
+
invalidUrl: false,
|
|
265
|
+
activeTab
|
|
266
|
+
});
|
|
267
|
+
trackAttribute('tab', (_plugins$activeTab$ta = plugins === null || plugins === void 0 ? void 0 : (_plugins$activeTab = plugins[activeTab]) === null || _plugins$activeTab === void 0 ? void 0 : _plugins$activeTab.tabKey) !== null && _plugins$activeTab$ta !== void 0 ? _plugins$activeTab$ta : null);
|
|
268
|
+
}, [dispatch, plugins, trackAttribute]);
|
|
269
|
+
const handleSearchListOnChange = id => {
|
|
270
|
+
if (isSubmitting) {
|
|
271
|
+
// Prevent changing item while submitting
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const index = items === null || items === void 0 ? void 0 : items.findIndex(item => item.objectId === id);
|
|
275
|
+
if (typeof index === 'number') {
|
|
276
|
+
const item = items === null || items === void 0 ? void 0 : items[index];
|
|
277
|
+
if (item) {
|
|
278
|
+
/**
|
|
279
|
+
* Manually track that the url has been updated using searchResult method
|
|
280
|
+
*/
|
|
281
|
+
trackAttribute('linkFieldContent', getLinkFieldContent(item.url));
|
|
282
|
+
trackAttribute('linkFieldContentInputMethod', 'searchResult');
|
|
283
|
+
trackAttribute('linkFieldContentInputSource', getDataSource(item, activePlugin));
|
|
284
|
+
dispatch({
|
|
285
|
+
activeIndex: index,
|
|
286
|
+
selectedIndex: index,
|
|
287
|
+
url: item.url,
|
|
288
|
+
invalidUrl: false
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
const handleKeyDown = useCallback(event => {
|
|
294
|
+
if (!(items !== null && items !== void 0 && items.length)) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
let updatedIndex = activeIndex;
|
|
298
|
+
if (event.key === 'Enter') {
|
|
299
|
+
event.preventDefault();
|
|
300
|
+
if (selectedItem) {
|
|
301
|
+
handleSelected(selectedItem.objectId);
|
|
302
|
+
} else {
|
|
303
|
+
// triggers validation error message
|
|
304
|
+
handleSubmit();
|
|
305
|
+
}
|
|
306
|
+
} else {
|
|
307
|
+
updatedIndex = handleNavKeyDown(event, items.length, activeIndex);
|
|
308
|
+
}
|
|
309
|
+
const item = items[updatedIndex];
|
|
310
|
+
if (['Enter', 'ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key) && item) {
|
|
311
|
+
/**
|
|
312
|
+
* Manually track that the url has been updated using searchResult method
|
|
313
|
+
*/
|
|
314
|
+
trackAttribute('linkFieldContent', getLinkFieldContent(item.url));
|
|
315
|
+
trackAttribute('linkFieldContentInputMethod', 'searchResult');
|
|
316
|
+
trackAttribute('linkFieldContentInputSource', getDataSource(item, activePlugin));
|
|
317
|
+
dispatch({
|
|
318
|
+
activeIndex: updatedIndex,
|
|
319
|
+
selectedIndex: updatedIndex,
|
|
320
|
+
url: item.url,
|
|
321
|
+
invalidUrl: false
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}, [items, activeIndex, selectedItem, handleSelected, handleSubmit, trackAttribute, activePlugin]);
|
|
325
|
+
const messages = isActivePlugin ? searchMessages : linkMessages;
|
|
326
|
+
const screenReaderDescriptionId = 'search-recent-links-field-description';
|
|
327
|
+
const linkSearchListId = 'link-picker-search-list';
|
|
328
|
+
const ariaActiveDescendant = selectedIndex > -1 ? `link-search-list-item-${selectedIndex}` : '';
|
|
329
|
+
const a11yList = isActivePlugin || isLoadingPlugins ? {
|
|
330
|
+
role: 'combobox',
|
|
331
|
+
// When a combobox popup is not visible, the element with role combobox has aria-expanded set to false
|
|
332
|
+
// https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-expanded#combobox
|
|
333
|
+
'aria-expanded': !!(items !== null && items !== void 0 && items.length),
|
|
334
|
+
'aria-autocomplete': 'list',
|
|
335
|
+
'aria-controls': linkSearchListId,
|
|
336
|
+
'aria-activedescendant': ariaActiveDescendant,
|
|
337
|
+
'aria-describedby': screenReaderDescriptionId
|
|
338
|
+
} : undefined;
|
|
339
|
+
|
|
340
|
+
// Added workaround with a screen reader Announcer specifically for VoiceOver + Safari
|
|
341
|
+
// as the Aria design pattern for combobox does not work in this case
|
|
342
|
+
// for details: https://a11y-internal.atlassian.net/browse/AK-740
|
|
343
|
+
const screenReaderText = browser().safari && getScreenReaderText(items !== null && items !== void 0 ? items : [], selectedIndex, intl);
|
|
344
|
+
const customSubmitButtonLabel = customMessages !== null && customMessages !== void 0 && customMessages.submitButtonLabel ? customMessages.submitButtonLabel : undefined;
|
|
345
|
+
return jsx("form", {
|
|
346
|
+
"data-testid": testIds.linkPicker,
|
|
347
|
+
css: rootContainerStyles
|
|
348
|
+
// Use onSubmitCapture instead of onSubmit so that any possible parent form isn't submitted
|
|
349
|
+
,
|
|
350
|
+
onSubmitCapture: handleSubmit
|
|
351
|
+
}, jsx(TrackMount, null), isActivePlugin && jsx(Fragment, null, screenReaderText && jsx(Announcer, {
|
|
352
|
+
ariaLive: "assertive",
|
|
353
|
+
text: screenReaderText,
|
|
354
|
+
ariaRelevant: "additions",
|
|
355
|
+
delay: 250
|
|
356
|
+
}), jsx(VisuallyHidden, {
|
|
357
|
+
id: screenReaderDescriptionId
|
|
358
|
+
}, customMessages !== null && customMessages !== void 0 && customMessages.linkAriaLabel ? jsx(FormattedMessage, customMessages.linkAriaLabel) : jsx(FormattedMessage, messages.linkAriaLabel))), jsx(LinkInputField, _extends({
|
|
359
|
+
name: "url",
|
|
360
|
+
autoComplete: "off",
|
|
361
|
+
testId: testIds.urlInputField,
|
|
362
|
+
label: customMessages !== null && customMessages !== void 0 && customMessages.linkLabel ? intl.formatMessage(customMessages.linkLabel) : intl.formatMessage(messages.linkLabel),
|
|
363
|
+
placeholder: customMessages !== null && customMessages !== void 0 && customMessages.linkPlaceholder ? intl.formatMessage(customMessages === null || customMessages === void 0 ? void 0 : customMessages.linkPlaceholder) : intl.formatMessage(messages.linkPlaceholder),
|
|
364
|
+
value: url,
|
|
365
|
+
autoFocus: true,
|
|
366
|
+
clearLabel: intl.formatMessage(formMessages.clearLink),
|
|
367
|
+
error: invalidUrl ? intl.formatMessage(formMessages.linkInvalid) : null,
|
|
368
|
+
spotlightTargetName: "link-picker-search-field-spotlight-target",
|
|
369
|
+
"aria-readonly": isSubmitting
|
|
370
|
+
}, a11yList, {
|
|
371
|
+
onClear: handleUrlClear,
|
|
372
|
+
onKeyDown: handleKeyDown,
|
|
373
|
+
onChange: handleChangeUrl
|
|
374
|
+
})), !hideDisplayText && jsx(DisplayTextInputField, {
|
|
375
|
+
autoComplete: "off",
|
|
376
|
+
name: "displayText",
|
|
377
|
+
testId: testIds.textInputField,
|
|
378
|
+
value: displayText,
|
|
379
|
+
label: customMessages !== null && customMessages !== void 0 && customMessages.linkTextLabel ? intl.formatMessage(customMessages.linkTextLabel) : intl.formatMessage(linkTextMessages.linkTextLabel),
|
|
380
|
+
placeholder: customMessages !== null && customMessages !== void 0 && customMessages.linkTextPlaceholder ? intl.formatMessage(customMessages === null || customMessages === void 0 ? void 0 : customMessages.linkTextPlaceholder) : intl.formatMessage(linkTextMessages.linkTextPlaceholder),
|
|
381
|
+
clearLabel: intl.formatMessage(linkTextMessages.clearLinkText),
|
|
382
|
+
readOnly: isSubmitting,
|
|
383
|
+
onClear: handleClear,
|
|
384
|
+
onChange: handleChangeText
|
|
385
|
+
}), UNSAFE_moveSubmitButton && jsx(Box, {
|
|
386
|
+
xcss: FullWidthSubmitButtonStyles
|
|
387
|
+
}, jsx(LinkPickerSubmitButton, {
|
|
388
|
+
isEditing: isEditing,
|
|
389
|
+
isLoading: isLoadingResults || !!isLoadingPlugins,
|
|
390
|
+
isSubmitting: isSubmitting,
|
|
391
|
+
customSubmitButtonLabel: customSubmitButtonLabel,
|
|
392
|
+
error: error,
|
|
393
|
+
items: items,
|
|
394
|
+
queryState: queryState,
|
|
395
|
+
submitMessageId: submitMessageId,
|
|
396
|
+
testId: testIds.insertButton,
|
|
397
|
+
url: url
|
|
398
|
+
})), !!queryState && (isLoadingPlugins || isActivePlugin) && jsx(SearchResults, {
|
|
399
|
+
activeTab: activeTab,
|
|
400
|
+
tabs: tabs,
|
|
401
|
+
activePlugin: activePlugin,
|
|
402
|
+
isLoadingResults: isLoadingResults,
|
|
403
|
+
isLoadingPlugins: isLoadingPlugins,
|
|
404
|
+
isSubmitting: isSubmitting,
|
|
405
|
+
linkSearchListId: linkSearchListId,
|
|
406
|
+
error: error,
|
|
407
|
+
featureFlags: featureFlags,
|
|
408
|
+
activeIndex: activeIndex,
|
|
409
|
+
selectedIndex: selectedIndex,
|
|
410
|
+
items: items,
|
|
411
|
+
queryState: queryState,
|
|
412
|
+
handleKeyDown: handleKeyDown,
|
|
413
|
+
handleSelected: handleSelected,
|
|
414
|
+
handleTabChange: handleTabChange,
|
|
415
|
+
handleSearchListOnChange: handleSearchListOnChange,
|
|
416
|
+
adaptiveHeight: adaptiveHeight,
|
|
417
|
+
retry: retry
|
|
418
|
+
}), jsx(FormFooter, {
|
|
419
|
+
error: error,
|
|
420
|
+
items: items
|
|
421
|
+
/** If the results section appears to be loading, impact whether the submit button is disabled */,
|
|
422
|
+
isLoading: isLoadingResults || !!isLoadingPlugins,
|
|
423
|
+
isSubmitting: isSubmitting,
|
|
424
|
+
queryState: queryState,
|
|
425
|
+
url: url,
|
|
426
|
+
isEditing: isEditing,
|
|
427
|
+
onCancel: onCancel,
|
|
428
|
+
action: pluginAction
|
|
429
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
430
|
+
,
|
|
431
|
+
css: !queryState || !(plugins !== null && plugins !== void 0 && plugins.length) ? formFooterMargin : undefined,
|
|
432
|
+
customSubmitButtonLabel: customSubmitButtonLabel,
|
|
433
|
+
submitMessageId: submitMessageId,
|
|
434
|
+
hideSubmitButton: UNSAFE_moveSubmitButton
|
|
435
|
+
}));
|
|
436
|
+
}));
|