@atlaskit/link-picker 1.8.2 → 1.8.3

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,11 @@
1
1
  # @atlaskit/link-picker
2
2
 
3
+ ## 1.8.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`7e07778ec20`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7e07778ec20) - Add linkState attribute to link picker analytics context
8
+
3
9
  ## 1.8.2
4
10
 
5
11
  ### Patch Changes
@@ -10,7 +10,7 @@ exports.default = void 0;
10
10
  *
11
11
  * Generates analytics utilities from the package analytics spec yaml
12
12
  *
13
- * @codegen <<SignedSource::ffa7ec78cc793f941d06cdb25b07dc8a>>
13
+ * @codegen <<SignedSource::115bafba068f36f76da67200ee2d08c4>>
14
14
  * @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
15
15
  */
16
16
  function createEventPayload(eventKey, attributes) {
File without changes
@@ -7,7 +7,7 @@ exports.useSearchQuery = useSearchQuery;
7
7
 
8
8
  var _react = require("react");
9
9
 
10
- var _url = require("../../ui/link-picker/url");
10
+ var _url = require("../../common/utils/url");
11
11
 
12
12
  function useSearchQuery(state) {
13
13
  var _queryState$current;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.withLinkPickerAnalyticsContext = withLinkPickerAnalyticsContext;
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _analyticsNext = require("@atlaskit/analytics-next");
13
+
14
+ var _url = require("../../common/utils/url");
15
+
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
+
18
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
+
20
+ function withLinkPickerAnalyticsContext(WrappedComponent) {
21
+ return function (props) {
22
+ var data = (0, _react.useMemo)(function () {
23
+ return {
24
+ attributes: {
25
+ linkState: (0, _url.normalizeUrl)(props.url) ? 'editLink' : 'newLink'
26
+ }
27
+ };
28
+ }, [props.url]);
29
+ return /*#__PURE__*/_react.default.createElement(_analyticsNext.AnalyticsContext, {
30
+ data: data
31
+ }, /*#__PURE__*/_react.default.createElement(WrappedComponent, props));
32
+ };
33
+ }
@@ -41,13 +41,15 @@ var _usePlugins2 = require("../../services/use-plugins");
41
41
 
42
42
  var _useSearchQuery = require("../../services/use-search-query");
43
43
 
44
+ var _withLinkPickerAnalytics = require("../../services/with-link-picker-analytics");
45
+
44
46
  var _messages = require("./messages");
45
47
 
46
48
  var _textInput = _interopRequireDefault(require("./text-input"));
47
49
 
48
50
  var _linkSearchList = _interopRequireDefault(require("./link-search-list"));
49
51
 
50
- var _url2 = require("./url");
52
+ var _url2 = require("../../common/utils/url");
51
53
 
52
54
  var _styled = require("./styled");
53
55
 
@@ -414,7 +416,8 @@ function LinkPicker(_ref) {
414
416
  }, intl.formatMessage(insertButtonMsg)))));
415
417
  }
416
418
 
417
- var _default = LinkPicker;
419
+ var _default = (0, _withLinkPickerAnalytics.withLinkPickerAnalyticsContext)( /*#__PURE__*/(0, _react.memo)(LinkPicker));
420
+
418
421
  exports.default = _default;
419
422
 
420
423
  function getScreenReaderText(items, selectedIndex, intl) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "sideEffects": false
5
5
  }
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Generates analytics utilities from the package analytics spec yaml
5
5
  *
6
- * @codegen <<SignedSource::ffa7ec78cc793f941d06cdb25b07dc8a>>
6
+ * @codegen <<SignedSource::115bafba068f36f76da67200ee2d08c4>>
7
7
  * @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
8
8
  */
9
9
  function createEventPayload(eventKey, attributes) {
@@ -1,5 +1,5 @@
1
1
  import { useRef } from 'react';
2
- import { isSafeUrl } from '../../ui/link-picker/url';
2
+ import { isSafeUrl } from '../../common/utils/url';
3
3
  export function useSearchQuery(state) {
4
4
  var _queryState$current;
5
5
 
@@ -0,0 +1,15 @@
1
+ import React, { useMemo } from 'react';
2
+ import { AnalyticsContext } from '@atlaskit/analytics-next';
3
+ import { normalizeUrl } from '../../common/utils/url';
4
+ export function withLinkPickerAnalyticsContext(WrappedComponent) {
5
+ return props => {
6
+ const data = useMemo(() => ({
7
+ attributes: {
8
+ linkState: normalizeUrl(props.url) ? 'editLink' : 'newLink'
9
+ }
10
+ }), [props.url]);
11
+ return /*#__PURE__*/React.createElement(AnalyticsContext, {
12
+ data: data
13
+ }, /*#__PURE__*/React.createElement(WrappedComponent, props));
14
+ };
15
+ }
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
 
3
3
  /** @jsx jsx */
4
- import { Fragment, useCallback, useEffect, useLayoutEffect, useReducer } from 'react';
4
+ import { Fragment, useCallback, useEffect, useLayoutEffect, useReducer, memo } from 'react';
5
5
  import { jsx } from '@emotion/react';
6
6
  import { useIntl, FormattedMessage } from 'react-intl-next';
7
7
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
@@ -14,10 +14,11 @@ import createEventPayload from '../../analytics.codegen';
14
14
  import { ANALYTICS_CHANNEL } from '../../common/constants';
15
15
  import { usePlugins } from '../../services/use-plugins';
16
16
  import { useSearchQuery } from '../../services/use-search-query';
17
+ import { withLinkPickerAnalyticsContext } from '../../services/with-link-picker-analytics';
17
18
  import { messages } from './messages';
18
19
  import PanelTextInput from './text-input';
19
20
  import LinkSearchList from './link-search-list';
20
- import { normalizeUrl, isSafeUrl } from './url';
21
+ import { normalizeUrl, isSafeUrl } from '../../common/utils/url';
21
22
  import { rootContainerStyles, searchIconStyles, listTitleStyles, tabsWrapperStyles } from './styled';
22
23
  import { browser } from './browser';
23
24
  import Announcer from './announcer';
@@ -361,7 +362,7 @@ function LinkPicker({
361
362
  }, intl.formatMessage(insertButtonMsg)))));
362
363
  }
363
364
 
364
- export default LinkPicker;
365
+ export default withLinkPickerAnalyticsContext( /*#__PURE__*/memo(LinkPicker));
365
366
 
366
367
  function getScreenReaderText(items, selectedIndex, intl) {
367
368
  if (items.length && selectedIndex > -1) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "sideEffects": false
5
5
  }
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Generates analytics utilities from the package analytics spec yaml
5
5
  *
6
- * @codegen <<SignedSource::ffa7ec78cc793f941d06cdb25b07dc8a>>
6
+ * @codegen <<SignedSource::115bafba068f36f76da67200ee2d08c4>>
7
7
  * @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
8
8
  */
9
9
  function createEventPayload(eventKey, attributes) {
File without changes
@@ -1,5 +1,5 @@
1
1
  import { useRef } from 'react';
2
- import { isSafeUrl } from '../../ui/link-picker/url';
2
+ import { isSafeUrl } from '../../common/utils/url';
3
3
  export function useSearchQuery(state) {
4
4
  var _queryState$current;
5
5
 
@@ -0,0 +1,17 @@
1
+ import React, { useMemo } from 'react';
2
+ import { AnalyticsContext } from '@atlaskit/analytics-next';
3
+ import { normalizeUrl } from '../../common/utils/url';
4
+ export function withLinkPickerAnalyticsContext(WrappedComponent) {
5
+ return function (props) {
6
+ var data = useMemo(function () {
7
+ return {
8
+ attributes: {
9
+ linkState: normalizeUrl(props.url) ? 'editLink' : 'newLink'
10
+ }
11
+ };
12
+ }, [props.url]);
13
+ return /*#__PURE__*/React.createElement(AnalyticsContext, {
14
+ data: data
15
+ }, /*#__PURE__*/React.createElement(WrappedComponent, props));
16
+ };
17
+ }
@@ -7,7 +7,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
7
7
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
8
 
9
9
  /** @jsx jsx */
10
- import { Fragment, useCallback, useEffect, useLayoutEffect, useReducer } from 'react';
10
+ import { Fragment, useCallback, useEffect, useLayoutEffect, useReducer, memo } from 'react';
11
11
  import { jsx } from '@emotion/react';
12
12
  import { useIntl, FormattedMessage } from 'react-intl-next';
13
13
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
@@ -20,10 +20,11 @@ import createEventPayload from '../../analytics.codegen';
20
20
  import { ANALYTICS_CHANNEL } from '../../common/constants';
21
21
  import { usePlugins } from '../../services/use-plugins';
22
22
  import { useSearchQuery } from '../../services/use-search-query';
23
+ import { withLinkPickerAnalyticsContext } from '../../services/with-link-picker-analytics';
23
24
  import { messages } from './messages';
24
25
  import PanelTextInput from './text-input';
25
26
  import LinkSearchList from './link-search-list';
26
- import { normalizeUrl, isSafeUrl } from './url';
27
+ import { normalizeUrl, isSafeUrl } from '../../common/utils/url';
27
28
  import { rootContainerStyles, searchIconStyles, listTitleStyles, tabsWrapperStyles } from './styled';
28
29
  import { browser } from './browser';
29
30
  import Announcer from './announcer';
@@ -372,7 +373,7 @@ function LinkPicker(_ref) {
372
373
  }, intl.formatMessage(insertButtonMsg)))));
373
374
  }
374
375
 
375
- export default LinkPicker;
376
+ export default withLinkPickerAnalyticsContext( /*#__PURE__*/memo(LinkPicker));
376
377
 
377
378
  function getScreenReaderText(items, selectedIndex, intl) {
378
379
  if (items.length && selectedIndex > -1) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "sideEffects": false
5
5
  }
@@ -3,12 +3,15 @@
3
3
  *
4
4
  * Generates analytics utilities from the package analytics spec yaml
5
5
  *
6
- * @codegen <<SignedSource::ffa7ec78cc793f941d06cdb25b07dc8a>>
6
+ * @codegen <<SignedSource::115bafba068f36f76da67200ee2d08c4>>
7
7
  * @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
8
8
  */
9
- declare type FormSubmittedLinkPickerAttributesType = {};
10
- declare type InlineDialogViewedLinkPickerAttributesType = {};
11
- declare type InlineDialogClosedLinkPickerAttributesType = {};
9
+ export declare type LinkPickerAnalyticsContextType = {
10
+ linkState: 'editLink' | 'newLink';
11
+ };
12
+ export declare type FormSubmittedLinkPickerAttributesType = {};
13
+ export declare type InlineDialogViewedLinkPickerAttributesType = {};
14
+ export declare type InlineDialogClosedLinkPickerAttributesType = {};
12
15
  declare type AnalyticsEventAttributes = {
13
16
  'ui.form.submitted.linkPicker': FormSubmittedLinkPickerAttributesType;
14
17
  'ui.inlineDialog.viewed.linkPicker': InlineDialogViewedLinkPickerAttributesType;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare function withLinkPickerAnalyticsContext<P extends {
3
+ url?: string;
4
+ }>(WrappedComponent: React.ComponentType<P>): React.ComponentType<P>;
@@ -1,4 +1,4 @@
1
- import { jsx } from '@emotion/react';
1
+ /// <reference types="react" />
2
2
  import { LinkInputType, LinkPickerPlugin } from '../types';
3
3
  export declare const RECENT_SEARCH_LIST_SIZE = 5;
4
4
  export declare const CONTACT_SUPPORT_LINK = "https://support.atlassian.com/contact/";
@@ -63,5 +63,5 @@ export interface PickerState {
63
63
  invalidUrl: boolean;
64
64
  activeTab: number;
65
65
  }
66
- declare function LinkPicker({ onSubmit, onCancel, onContentResize, plugins, url: initUrl, displayText: initDisplayText, }: LinkPickerProps): jsx.JSX.Element;
67
- export default LinkPicker;
66
+ declare const _default: import("react").ComponentType<LinkPickerProps>;
67
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "description": "Standalone link picker",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "publishConfig": {
package/report.api.md CHANGED
@@ -5,6 +5,8 @@
5
5
  [Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
6
6
 
7
7
  ```ts
8
+ /// <reference types="react" />
9
+
8
10
  import { MessageDescriptor } from 'react-intl-next';
9
11
  import { default as React_2 } from 'react';
10
12
  import { ReactNode } from 'react';