@atlaskit/link-picker 1.8.0 → 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,23 @@
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
+
9
+ ## 1.8.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`8d4228767b0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8d4228767b0) - Upgrade Typescript from `4.2.4` to `4.3.5`.
14
+
15
+ ## 1.8.1
16
+
17
+ ### Patch Changes
18
+
19
+ - [`afd2368145a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/afd2368145a) - Added link picker mount/unmount analytic events
20
+
3
21
  ## 1.8.0
4
22
 
5
23
  ### Minor Changes
@@ -10,16 +10,16 @@ exports.default = void 0;
10
10
  *
11
11
  * Generates analytics utilities from the package analytics spec yaml
12
12
  *
13
- * @codegen <<SignedSource::0cc1b4d9c22b31491ded3e581114ab2c>>
13
+ * @codegen <<SignedSource::115bafba068f36f76da67200ee2d08c4>>
14
14
  * @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
15
15
  */
16
16
  function createEventPayload(eventKey, attributes) {
17
17
  var event = eventKey.split('.');
18
18
  return {
19
- eventType: 'ui',
20
- actionSubject: event[0],
21
- action: event[1],
22
- actionSubjectId: event[2],
19
+ eventType: event[0],
20
+ actionSubject: event[1],
21
+ action: event[2],
22
+ actionSubjectId: event[3],
23
23
  attributes: attributes
24
24
  };
25
25
  }
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
 
@@ -154,6 +156,16 @@ function LinkPicker(_ref) {
154
156
  var isEditing = !!initUrl;
155
157
  var selectedItem = items === null || items === void 0 ? void 0 : items[selectedIndex];
156
158
  var isSelectedItem = (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.url) === url;
159
+ (0, _react.useEffect)(function () {
160
+ // Anything in here is fired on component mount.
161
+ var event = createAnalyticsEvent((0, _analytics.default)('ui.inlineDialog.viewed.linkPicker', {}));
162
+ event.fire(_constants.ANALYTICS_CHANNEL);
163
+ return function () {
164
+ // Anything in here is fired on component unmount.
165
+ var event = createAnalyticsEvent((0, _analytics.default)('ui.inlineDialog.closed.linkPicker', {}));
166
+ event.fire(_constants.ANALYTICS_CHANNEL);
167
+ };
168
+ }, [createAnalyticsEvent]);
157
169
  (0, _react.useLayoutEffect)(function () {
158
170
  if (onContentResize) {
159
171
  onContentResize();
@@ -226,7 +238,7 @@ function LinkPicker(_ref) {
226
238
  }
227
239
  }, [activeIndex, items]);
228
240
  var handleInsert = (0, _react.useCallback)(function (url, title, inputType) {
229
- var event = createAnalyticsEvent((0, _analytics.default)('form.submitted.linkPicker', {}));
241
+ var event = createAnalyticsEvent((0, _analytics.default)('ui.form.submitted.linkPicker', {}));
230
242
  event.fire(_constants.ANALYTICS_CHANNEL);
231
243
  onSubmit(_objectSpread({
232
244
  url: url,
@@ -404,7 +416,8 @@ function LinkPicker(_ref) {
404
416
  }, intl.formatMessage(insertButtonMsg)))));
405
417
  }
406
418
 
407
- var _default = LinkPicker;
419
+ var _default = (0, _withLinkPickerAnalytics.withLinkPickerAnalyticsContext)( /*#__PURE__*/(0, _react.memo)(LinkPicker));
420
+
408
421
  exports.default = _default;
409
422
 
410
423
  function getScreenReaderText(items, selectedIndex, intl) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.8.0",
3
+ "version": "1.8.3",
4
4
  "sideEffects": false
5
5
  }
@@ -3,16 +3,16 @@
3
3
  *
4
4
  * Generates analytics utilities from the package analytics spec yaml
5
5
  *
6
- * @codegen <<SignedSource::0cc1b4d9c22b31491ded3e581114ab2c>>
6
+ * @codegen <<SignedSource::115bafba068f36f76da67200ee2d08c4>>
7
7
  * @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
8
8
  */
9
9
  function createEventPayload(eventKey, attributes) {
10
10
  const event = eventKey.split('.');
11
11
  return {
12
- eventType: 'ui',
13
- actionSubject: event[0],
14
- action: event[1],
15
- actionSubjectId: event[2],
12
+ eventType: event[0],
13
+ actionSubject: event[1],
14
+ action: event[2],
15
+ actionSubjectId: event[3],
16
16
  attributes: attributes
17
17
  };
18
18
  }
@@ -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, 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';
@@ -106,6 +107,16 @@ function LinkPicker({
106
107
  const isEditing = !!initUrl;
107
108
  const selectedItem = items === null || items === void 0 ? void 0 : items[selectedIndex];
108
109
  const isSelectedItem = (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.url) === url;
110
+ useEffect(() => {
111
+ // Anything in here is fired on component mount.
112
+ const event = createAnalyticsEvent(createEventPayload('ui.inlineDialog.viewed.linkPicker', {}));
113
+ event.fire(ANALYTICS_CHANNEL);
114
+ return () => {
115
+ // Anything in here is fired on component unmount.
116
+ const event = createAnalyticsEvent(createEventPayload('ui.inlineDialog.closed.linkPicker', {}));
117
+ event.fire(ANALYTICS_CHANNEL);
118
+ };
119
+ }, [createAnalyticsEvent]);
109
120
  useLayoutEffect(() => {
110
121
  if (onContentResize) {
111
122
  onContentResize();
@@ -178,7 +189,7 @@ function LinkPicker({
178
189
  }
179
190
  }, [activeIndex, items]);
180
191
  const handleInsert = useCallback((url, title, inputType) => {
181
- const event = createAnalyticsEvent(createEventPayload('form.submitted.linkPicker', {}));
192
+ const event = createAnalyticsEvent(createEventPayload('ui.form.submitted.linkPicker', {}));
182
193
  event.fire(ANALYTICS_CHANNEL);
183
194
  onSubmit({
184
195
  url,
@@ -351,7 +362,7 @@ function LinkPicker({
351
362
  }, intl.formatMessage(insertButtonMsg)))));
352
363
  }
353
364
 
354
- export default LinkPicker;
365
+ export default withLinkPickerAnalyticsContext( /*#__PURE__*/memo(LinkPicker));
355
366
 
356
367
  function getScreenReaderText(items, selectedIndex, intl) {
357
368
  if (items.length && selectedIndex > -1) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.8.0",
3
+ "version": "1.8.3",
4
4
  "sideEffects": false
5
5
  }
@@ -3,16 +3,16 @@
3
3
  *
4
4
  * Generates analytics utilities from the package analytics spec yaml
5
5
  *
6
- * @codegen <<SignedSource::0cc1b4d9c22b31491ded3e581114ab2c>>
6
+ * @codegen <<SignedSource::115bafba068f36f76da67200ee2d08c4>>
7
7
  * @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
8
8
  */
9
9
  function createEventPayload(eventKey, attributes) {
10
10
  var event = eventKey.split('.');
11
11
  return {
12
- eventType: 'ui',
13
- actionSubject: event[0],
14
- action: event[1],
15
- actionSubjectId: event[2],
12
+ eventType: event[0],
13
+ actionSubject: event[1],
14
+ action: event[2],
15
+ actionSubjectId: event[3],
16
16
  attributes: attributes
17
17
  };
18
18
  }
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, 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';
@@ -112,6 +113,16 @@ function LinkPicker(_ref) {
112
113
  var isEditing = !!initUrl;
113
114
  var selectedItem = items === null || items === void 0 ? void 0 : items[selectedIndex];
114
115
  var isSelectedItem = (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.url) === url;
116
+ useEffect(function () {
117
+ // Anything in here is fired on component mount.
118
+ var event = createAnalyticsEvent(createEventPayload('ui.inlineDialog.viewed.linkPicker', {}));
119
+ event.fire(ANALYTICS_CHANNEL);
120
+ return function () {
121
+ // Anything in here is fired on component unmount.
122
+ var event = createAnalyticsEvent(createEventPayload('ui.inlineDialog.closed.linkPicker', {}));
123
+ event.fire(ANALYTICS_CHANNEL);
124
+ };
125
+ }, [createAnalyticsEvent]);
115
126
  useLayoutEffect(function () {
116
127
  if (onContentResize) {
117
128
  onContentResize();
@@ -184,7 +195,7 @@ function LinkPicker(_ref) {
184
195
  }
185
196
  }, [activeIndex, items]);
186
197
  var handleInsert = useCallback(function (url, title, inputType) {
187
- var event = createAnalyticsEvent(createEventPayload('form.submitted.linkPicker', {}));
198
+ var event = createAnalyticsEvent(createEventPayload('ui.form.submitted.linkPicker', {}));
188
199
  event.fire(ANALYTICS_CHANNEL);
189
200
  onSubmit(_objectSpread({
190
201
  url: url,
@@ -362,7 +373,7 @@ function LinkPicker(_ref) {
362
373
  }, intl.formatMessage(insertButtonMsg)))));
363
374
  }
364
375
 
365
- export default LinkPicker;
376
+ export default withLinkPickerAnalyticsContext( /*#__PURE__*/memo(LinkPicker));
366
377
 
367
378
  function getScreenReaderText(items, selectedIndex, intl) {
368
379
  if (items.length && selectedIndex > -1) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.8.0",
3
+ "version": "1.8.3",
4
4
  "sideEffects": false
5
5
  }
@@ -3,12 +3,19 @@
3
3
  *
4
4
  * Generates analytics utilities from the package analytics spec yaml
5
5
  *
6
- * @codegen <<SignedSource::0cc1b4d9c22b31491ded3e581114ab2c>>
6
+ * @codegen <<SignedSource::115bafba068f36f76da67200ee2d08c4>>
7
7
  * @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
8
8
  */
9
- declare type FormSubmittedLinkPickerAttributesType = {};
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 = {};
10
15
  declare type AnalyticsEventAttributes = {
11
- 'form.submitted.linkPicker': FormSubmittedLinkPickerAttributesType;
16
+ 'ui.form.submitted.linkPicker': FormSubmittedLinkPickerAttributesType;
17
+ 'ui.inlineDialog.viewed.linkPicker': InlineDialogViewedLinkPickerAttributesType;
18
+ 'ui.inlineDialog.closed.linkPicker': InlineDialogClosedLinkPickerAttributesType;
12
19
  };
13
20
  declare function createEventPayload<K extends keyof AnalyticsEventAttributes>(eventKey: K, attributes: AnalyticsEventAttributes[K]): {
14
21
  eventType: string;
@@ -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.0",
3
+ "version": "1.8.3",
4
4
  "description": "Standalone link picker",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "publishConfig": {
@@ -64,8 +64,8 @@
64
64
  "@atlaskit/webdriver-runner": "*",
65
65
  "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
66
66
  "@atlassian/link-picker-atlassian-plugin": "^18.0.0",
67
- "@atlassian/link-picker-plugins": "^5.0.0",
68
- "@atlassian/recent-work-client": "^1.5.0",
67
+ "@atlassian/link-picker-plugins": "^5.1.0",
68
+ "@atlassian/recent-work-client": "^1.6.0",
69
69
  "@atlassian/search-provider": "^2.3.0",
70
70
  "@testing-library/dom": "^7.7.3",
71
71
  "@testing-library/jest-dom": "^4.1.0",
@@ -76,11 +76,12 @@
76
76
  "enzyme": "^3.10.0",
77
77
  "fetch-mock": "^8.0.0",
78
78
  "js-yaml": "^3.13.1",
79
+ "lodash": "^4.17.21",
79
80
  "mockdate": "^3.0.2",
80
81
  "prettier": "^2.1.1",
81
82
  "react-dom": "^16.8.0",
82
83
  "sinon": "^2.2.0",
83
- "typescript": "4.2.4"
84
+ "typescript": "4.3.5"
84
85
  },
85
86
  "techstack": {
86
87
  "@repo/internal": {
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';