@atlaskit/link-picker 1.9.1 → 1.9.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/analytics.codegen.js +1 -1
  3. package/dist/cjs/common/analytics/context.js +137 -0
  4. package/dist/cjs/common/analytics/index.js +27 -0
  5. package/dist/cjs/common/analytics/input-field-tracking.js +115 -0
  6. package/dist/cjs/common/constants.js +1 -1
  7. package/dist/cjs/ui/index.js +2 -1
  8. package/dist/cjs/ui/link-picker/index.js +56 -16
  9. package/dist/cjs/ui/link-picker/text-input/index.js +25 -28
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/es2019/analytics.codegen.js +1 -1
  12. package/dist/es2019/common/analytics/context.js +95 -0
  13. package/dist/es2019/common/analytics/index.js +2 -0
  14. package/dist/es2019/common/analytics/input-field-tracking.js +85 -0
  15. package/dist/es2019/common/constants.js +1 -1
  16. package/dist/es2019/ui/index.js +2 -1
  17. package/dist/es2019/ui/link-picker/index.js +51 -14
  18. package/dist/es2019/ui/link-picker/link-search-error/index.js +2 -2
  19. package/dist/es2019/ui/link-picker/text-input/index.js +21 -25
  20. package/dist/es2019/version.json +1 -1
  21. package/dist/esm/analytics.codegen.js +1 -1
  22. package/dist/esm/common/analytics/context.js +110 -0
  23. package/dist/esm/common/analytics/index.js +2 -0
  24. package/dist/esm/common/analytics/input-field-tracking.js +91 -0
  25. package/dist/esm/common/constants.js +1 -1
  26. package/dist/esm/ui/index.js +2 -1
  27. package/dist/esm/ui/link-picker/index.js +54 -14
  28. package/dist/esm/ui/link-picker/link-search-error/index.js +2 -2
  29. package/dist/esm/ui/link-picker/text-input/index.js +23 -26
  30. package/dist/esm/version.json +1 -1
  31. package/dist/types/analytics.codegen.d.ts +9 -1
  32. package/dist/types/common/analytics/context.d.ts +28 -0
  33. package/dist/types/common/analytics/index.d.ts +2 -0
  34. package/dist/types/common/analytics/input-field-tracking.d.ts +17 -0
  35. package/dist/types/common/constants.d.ts +1 -1
  36. package/dist/types/ui/index.d.ts +1 -0
  37. package/dist/types/ui/link-picker/text-input/index.d.ts +6 -8
  38. package/package.json +1 -1
  39. package/dist/cjs/services/with-link-picker-analytics/index.js +0 -33
  40. package/dist/es2019/services/with-link-picker-analytics/index.js +0 -15
  41. package/dist/esm/services/with-link-picker-analytics/index.js +0 -17
  42. package/dist/types/services/with-link-picker-analytics/index.d.ts +0 -4
@@ -8,7 +8,8 @@ import { LoaderFallback } from './loader-fallback';
8
8
  export var PACKAGE_DATA = {
9
9
  packageName: packageName,
10
10
  packageVersion: packageVersion,
11
- componentName: COMPONENT_NAME
11
+ componentName: COMPONENT_NAME,
12
+ source: COMPONENT_NAME
12
13
  };
13
14
  var LazyLinkPicker = lazyForPaint(function () {
14
15
  return import(
@@ -16,13 +16,13 @@ import Tabs, { Tab, TabList } from '@atlaskit/tabs';
16
16
  import VisuallyHidden from '@atlaskit/visually-hidden';
17
17
  import createEventPayload from '../../analytics.codegen';
18
18
  import { ANALYTICS_CHANNEL } from '../../common/constants';
19
+ import { useLinkPickerAnalytics, withInputFieldTracking, withLinkPickerAnalyticsContext } from '../../common/analytics';
20
+ import { normalizeUrl, isSafeUrl } from '../../common/utils/url';
19
21
  import { usePlugins } from '../../services/use-plugins';
20
22
  import { useSearchQuery } from '../../services/use-search-query';
21
- import { withLinkPickerAnalyticsContext } from '../../services/with-link-picker-analytics';
22
- import { messages } from './messages';
23
- import PanelTextInput from './text-input';
24
- import { normalizeUrl, isSafeUrl } from '../../common/utils/url';
25
23
  import useFixHeight from '../../controllers/use-fix-height';
24
+ import { messages } from './messages';
25
+ import TextInput from './text-input';
26
26
  import { rootContainerStyles, searchIconStyles, tabsWrapperStyles, flexColumnStyles, formFooterMargin } from './styled';
27
27
  import { browser } from './browser';
28
28
  import Announcer from './announcer';
@@ -62,6 +62,25 @@ function reducer(state, payload) {
62
62
 
63
63
  return _objectSpread(_objectSpread({}, state), payload);
64
64
  }
65
+ /**
66
+ * Bind input fields to analytics tracking
67
+ */
68
+
69
+
70
+ var getLinkFieldContent = function getLinkFieldContent(value) {
71
+ if (!Boolean(value)) {
72
+ return null;
73
+ }
74
+
75
+ return isSafeUrl(value) ? 'url' : 'text_string';
76
+ };
77
+
78
+ var LinkInputField = withInputFieldTracking(TextInput, 'link', function (event, attributes) {
79
+ return _objectSpread(_objectSpread({}, attributes), {}, {
80
+ linkFieldContent: getLinkFieldContent(event.currentTarget.value)
81
+ });
82
+ });
83
+ var DisplayTextInputField = withInputFieldTracking(TextInput, 'displayText');
65
84
 
66
85
  function LinkPicker(_ref) {
67
86
  var _errorFallback;
@@ -106,6 +125,11 @@ function LinkPicker(_ref) {
106
125
  var isEditing = !!initUrl;
107
126
  var selectedItem = items === null || items === void 0 ? void 0 : items[selectedIndex];
108
127
  var isSelectedItem = (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.url) === url;
128
+
129
+ var _useLinkPickerAnalyti = useLinkPickerAnalytics(),
130
+ trackAttribute = _useLinkPickerAnalyti.trackAttribute,
131
+ getAttributes = _useLinkPickerAnalyti.getAttributes;
132
+
109
133
  useEffect(function () {
110
134
  // Anything in here is fired on component mount.
111
135
  var event = createAnalyticsEvent(createEventPayload('ui.inlineDialog.viewed.linkPicker', {}));
@@ -121,14 +145,14 @@ function LinkPicker(_ref) {
121
145
  onContentResize();
122
146
  }
123
147
  }, [onContentResize, items, isLoading, isActivePlugin, tabs]);
124
- var handleChangeUrl = useCallback(function (url) {
148
+ var handleChangeUrl = useCallback(function (e) {
125
149
  dispatch({
126
- url: url
150
+ url: e.currentTarget.value
127
151
  });
128
152
  }, []);
129
- var handleChangeText = useCallback(function (displayText) {
153
+ var handleChangeText = useCallback(function (e) {
130
154
  dispatch({
131
- displayText: displayText
155
+ displayText: e.currentTarget.value
132
156
  });
133
157
  }, []);
134
158
  var handleKeyDown = useCallback(function (event) {
@@ -157,6 +181,11 @@ function LinkPicker(_ref) {
157
181
  }
158
182
 
159
183
  if ([KEY_CODE_ARROW_DOWN, KEY_CODE_ARROW_UP].includes(keyCode) && items[updatedIndex]) {
184
+ /**
185
+ * Manually track that the url has been updated using searchResult method
186
+ */
187
+ trackAttribute('linkFieldContent', getLinkFieldContent(items[updatedIndex].url));
188
+ trackAttribute('linkFieldContentInputMethod', 'searchResult');
160
189
  dispatch({
161
190
  activeIndex: updatedIndex,
162
191
  selectedIndex: updatedIndex,
@@ -164,7 +193,7 @@ function LinkPicker(_ref) {
164
193
  invalidUrl: false
165
194
  });
166
195
  }
167
- }, [activeIndex, items]);
196
+ }, [activeIndex, items, trackAttribute]);
168
197
  var handleClear = useCallback(function (field) {
169
198
  dispatch(_defineProperty({}, field, ''));
170
199
  }, []);
@@ -191,7 +220,12 @@ function LinkPicker(_ref) {
191
220
  var event = createAnalyticsEvent(createEventPayload('ui.form.submitted.linkPicker', {})); // Clone the event so that it can be emitted for consumer usage
192
221
  // This must happen BEFORE the original event is fired!
193
222
 
194
- var consumerEvent = event.clone(); // Dispatch the original event to our channel
223
+ var consumerEvent = event.clone(); // Cloned event doesnt have the attributes that are added by
224
+ // the analytics listener in the LinkPickerAnalyticsContext, add them here
225
+
226
+ consumerEvent === null || consumerEvent === void 0 ? void 0 : consumerEvent.update({
227
+ attributes: getAttributes()
228
+ }); // Dispatch the original event to our channel
195
229
 
196
230
  event.fire(ANALYTICS_CHANNEL);
197
231
  onSubmit(_objectSpread({
@@ -204,7 +238,7 @@ function LinkPicker(_ref) {
204
238
  }, inputType === 'manual' ? {
205
239
  rawUrl: state.url
206
240
  } : {}), consumerEvent);
207
- }, [displayText, onSubmit, state.url, createAnalyticsEvent]);
241
+ }, [displayText, onSubmit, state.url, createAnalyticsEvent, getAttributes]);
208
242
  var handleSelected = useCallback(function (objectId) {
209
243
  var selectedItem = items === null || items === void 0 ? void 0 : items.find(function (item) {
210
244
  return item.objectId === objectId;
@@ -214,9 +248,15 @@ function LinkPicker(_ref) {
214
248
  var _url = selectedItem.url,
215
249
  name = selectedItem.name;
216
250
  dispatchEvent(new Event('submit'));
251
+ /**
252
+ * Manually track that the url has been updated using searchResult method
253
+ */
254
+
255
+ trackAttribute('linkFieldContent', getLinkFieldContent(_url));
256
+ trackAttribute('linkFieldContentInputMethod', 'searchResult');
217
257
  handleInsert(_url, name, 'typeAhead');
218
258
  }
219
- }, [handleInsert, items]);
259
+ }, [handleInsert, trackAttribute, items]);
220
260
  var handleSubmit = useCallback(function (event) {
221
261
  event.preventDefault();
222
262
 
@@ -260,7 +300,7 @@ function LinkPicker(_ref) {
260
300
  delay: 250
261
301
  }), jsx(VisuallyHidden, {
262
302
  id: screenReaderDescriptionId
263
- }, jsx(FormattedMessage, messages.searchLinkAriaDescription)), jsx(PanelTextInput, {
303
+ }, jsx(FormattedMessage, messages.searchLinkAriaDescription)), jsx(LinkInputField, {
264
304
  role: "combobox",
265
305
  autoComplete: "off",
266
306
  name: "url",
@@ -280,7 +320,7 @@ function LinkPicker(_ref) {
280
320
  onClear: handleClear,
281
321
  onKeyDown: handleKeyDown,
282
322
  onChange: handleChangeUrl
283
- }), jsx(PanelTextInput, {
323
+ }), jsx(DisplayTextInputField, {
284
324
  autoComplete: "off",
285
325
  name: "displayText",
286
326
  testId: testIds.textInputField,
@@ -4,6 +4,8 @@ import _extends from "@babel/runtime/helpers/extends";
4
4
  import { jsx } from '@emotion/react';
5
5
  import { useIntl, FormattedMessage, defineMessages } from 'react-intl-next';
6
6
  import Button from '@atlaskit/button';
7
+ import EmptyState from '@atlaskit/empty-state';
8
+ import GenericErrorSVG from '../../../common/generic-error-svg';
7
9
  export var CONTACT_SUPPORT_LINK = 'https://support.atlassian.com/contact/';
8
10
  export var messages = defineMessages({
9
11
  searchErrorHeader: {
@@ -17,8 +19,6 @@ export var messages = defineMessages({
17
19
  description: 'Describes possible actions when search throws an error'
18
20
  }
19
21
  });
20
- import EmptyState from '@atlaskit/empty-state';
21
- import GenericErrorSVG from '../../../common/generic-error-svg';
22
22
  export var testIds = {
23
23
  searchError: 'link-search-error'
24
24
  };
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["name", "label", "autoFocus", "onRedo", "onUndo", "onChange", "onKeyDown", "onClear", "clearLabel", "error"];
3
+ var _excluded = ["name", "label", "autoFocus", "onRedo", "onUndo", "onKeyDown", "onClear", "clearLabel", "error"];
4
4
 
5
5
  /** @jsx jsx */
6
6
  import { useCallback, useRef, Fragment } from 'react';
@@ -10,21 +10,20 @@ import Tooltip from '@atlaskit/tooltip';
10
10
  import Textfield from '@atlaskit/textfield';
11
11
  import Selectclear from '@atlaskit/icon/glyph/select-clear';
12
12
  import { isRedoEvent, isUndoEvent } from '../utils';
13
- import { clearTextButtonStyles, fieldStyles } from './styled';
14
13
  import { testIds } from '../';
14
+ import { clearTextButtonStyles, fieldStyles } from './styled';
15
15
 
16
- var PanelTextInput = function PanelTextInput(props) {
17
- var name = props.name,
18
- label = props.label,
19
- autoFocus = props.autoFocus,
20
- onRedo = props.onRedo,
21
- onUndo = props.onUndo,
22
- onChange = props.onChange,
23
- onKeyDown = props.onKeyDown,
24
- onClear = props.onClear,
25
- clearLabel = props.clearLabel,
26
- error = props.error,
27
- restProps = _objectWithoutProperties(props, _excluded);
16
+ var TextInput = function TextInput(_ref) {
17
+ var name = _ref.name,
18
+ label = _ref.label,
19
+ autoFocus = _ref.autoFocus,
20
+ onRedo = _ref.onRedo,
21
+ onUndo = _ref.onUndo,
22
+ onKeyDown = _ref.onKeyDown,
23
+ onClear = _ref.onClear,
24
+ clearLabel = _ref.clearLabel,
25
+ error = _ref.error,
26
+ restProps = _objectWithoutProperties(_ref, _excluded);
28
27
 
29
28
  var inputRef = useRef(null);
30
29
  var handleRef = useCallback(function (input) {
@@ -39,9 +38,6 @@ var PanelTextInput = function PanelTextInput(props) {
39
38
  }
40
39
  }
41
40
  }, [autoFocus]);
42
- var handleChange = useCallback(function (e) {
43
- onChange(e.currentTarget.value);
44
- }, [onChange]);
45
41
  var handleKeydown = useCallback(function (e) {
46
42
  if (typeof onUndo === 'function' && isUndoEvent(e)) {
47
43
  e.preventDefault();
@@ -55,11 +51,13 @@ var PanelTextInput = function PanelTextInput(props) {
55
51
  onKeyDown(e);
56
52
  }
57
53
  }, [onUndo, onRedo, onKeyDown]);
58
- var handleClear = useCallback(function () {
59
- if (inputRef.current && onClear) {
60
- inputRef.current.focus();
61
- onClear(name);
62
- }
54
+ var handleClear = useCallback(function (e) {
55
+ var _inputRef$current;
56
+
57
+ e.preventDefault();
58
+ e.stopPropagation();
59
+ onClear === null || onClear === void 0 ? void 0 : onClear(name);
60
+ (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
63
61
  }, [name, onClear]);
64
62
  var clearText = restProps.value !== '' && jsx(Tooltip, {
65
63
  content: clearLabel
@@ -77,11 +75,10 @@ var PanelTextInput = function PanelTextInput(props) {
77
75
  }, jsx(Field, {
78
76
  label: label,
79
77
  name: name
80
- }, function (_ref) {
81
- var fieldProps = _ref.fieldProps;
78
+ }, function (_ref2) {
79
+ var fieldProps = _ref2.fieldProps;
82
80
  return jsx(Fragment, null, jsx(Textfield, _extends({}, fieldProps, restProps, {
83
81
  onKeyDown: handleKeydown,
84
- onChange: handleChange,
85
82
  ref: handleRef,
86
83
  elemAfterInput: clearText,
87
84
  isInvalid: !!error
@@ -91,4 +88,4 @@ var PanelTextInput = function PanelTextInput(props) {
91
88
  }));
92
89
  };
93
90
 
94
- export default PanelTextInput;
91
+ export default TextInput;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.9.1",
3
+ "version": "1.9.3",
4
4
  "sideEffects": false
5
5
  }
@@ -3,19 +3,27 @@
3
3
  *
4
4
  * Generates analytics utilities from the package analytics spec yaml
5
5
  *
6
- * @codegen <<SignedSource::115bafba068f36f76da67200ee2d08c4>>
6
+ * @codegen <<SignedSource::e4f7029050ef6edde92cac3d9535cd4a>>
7
7
  * @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
8
8
  */
9
9
  export declare type LinkPickerAnalyticsContextType = {
10
10
  linkState: 'editLink' | 'newLink';
11
+ linkFieldContent: 'url' | 'text_string' | null;
12
+ linkFieldContentInputMethod: 'manual' | 'paste' | 'searchResult' | null;
13
+ displayTextFieldContent: 'text_string' | null;
14
+ displayTextFieldContentInputMethod: 'manual' | 'paste' | null;
11
15
  };
12
16
  export declare type FormSubmittedLinkPickerAttributesType = {};
13
17
  export declare type InlineDialogViewedLinkPickerAttributesType = {};
14
18
  export declare type InlineDialogClosedLinkPickerAttributesType = {};
19
+ export declare type TextFieldUpdatedLinkFieldAttributesType = {};
20
+ export declare type TextFieldUpdatedDisplayTextFieldAttributesType = {};
15
21
  declare type AnalyticsEventAttributes = {
16
22
  'ui.form.submitted.linkPicker': FormSubmittedLinkPickerAttributesType;
17
23
  'ui.inlineDialog.viewed.linkPicker': InlineDialogViewedLinkPickerAttributesType;
18
24
  'ui.inlineDialog.closed.linkPicker': InlineDialogClosedLinkPickerAttributesType;
25
+ 'ui.textField.updated.linkField': TextFieldUpdatedLinkFieldAttributesType;
26
+ 'ui.textField.updated.displayTextField': TextFieldUpdatedDisplayTextFieldAttributesType;
19
27
  };
20
28
  declare function createEventPayload<K extends keyof AnalyticsEventAttributes>(eventKey: K, attributes: AnalyticsEventAttributes[K]): {
21
29
  eventType: string;
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import { LinkPickerAnalyticsContextType } from '../../analytics.codegen';
3
+ export declare type TrackAttribute = <K extends keyof LinkPickerAnalyticsContextType>(attribute: K, value: LinkPickerAnalyticsContextType[K]) => void;
4
+ interface AnalyticsContextType {
5
+ /**
6
+ * Update a single attribute in the analytics context
7
+ */
8
+ trackAttribute: TrackAttribute;
9
+ /**
10
+ * Update a set of attributes in the analytics context
11
+ */
12
+ trackAttributes: (attributes: Partial<LinkPickerAnalyticsContextType>) => void;
13
+ /**
14
+ * Retrieve the current set of attributes
15
+ * Can be used by components to derive/compute new attributes for specific events
16
+ */
17
+ getAttributes: () => LinkPickerAnalyticsContextType;
18
+ }
19
+ /**
20
+ * Hook that exposes the context-level attribute getters and setters.
21
+ */
22
+ export declare const useLinkPickerAnalytics: () => AnalyticsContextType;
23
+ /**
24
+ * Wraps a component with the analytics context + listener to update events with contextual-level attributes.
25
+ * Should be implemented once at the root of the link picker.
26
+ */
27
+ export declare function withLinkPickerAnalyticsContext<P>(WrappedComponent: React.ComponentType<P>): React.ComponentType<P>;
28
+ export {};
@@ -0,0 +1,2 @@
1
+ export { useLinkPickerAnalytics, withLinkPickerAnalyticsContext, } from './context';
2
+ export { withInputFieldTracking } from './input-field-tracking';
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { LinkPickerAnalyticsContextType } from '../../analytics.codegen';
3
+ declare type InputFields = 'link' | 'displayText';
4
+ /**
5
+ * Wraps an input field and connects it to the link picker analytics context to provide a baseline of analytics tracking
6
+ * @param WrappedComponent The input field to be tracked
7
+ * @param field The name of the field (ie matching actionSubjectId)
8
+ * @param filterOnChangeEventAttrs Function to hook into and filter/customise the default attribute tracking logic
9
+ * @returns HOC Input field with tracking
10
+ */
11
+ export declare const withInputFieldTracking: <P extends {
12
+ onBlur?: ((e: React.FocusEvent<HTMLInputElement>) => void) | undefined;
13
+ onChange?: ((e: React.ChangeEvent<HTMLInputElement>) => void) | undefined;
14
+ onClear?: Function | undefined;
15
+ onFocus?: ((e: React.FocusEvent<HTMLInputElement>) => void) | undefined;
16
+ }, Field extends InputFields>(WrappedComponent: React.ComponentType<P>, field: Field, filterOnChangeEventAttrs?: <OnChangeAttributes extends Partial<LinkPickerAnalyticsContextType>>(event: React.ChangeEvent<HTMLInputElement>, attributes: OnChangeAttributes) => OnChangeAttributes) => React.ComponentType<P>;
17
+ export {};
@@ -1,2 +1,2 @@
1
1
  export declare const ANALYTICS_CHANNEL = "media";
2
- export declare const COMPONENT_NAME = "LinkPicker";
2
+ export declare const COMPONENT_NAME = "linkPicker";
@@ -4,5 +4,6 @@ export declare const PACKAGE_DATA: {
4
4
  packageName: any;
5
5
  packageVersion: any;
6
6
  componentName: string;
7
+ source: string;
7
8
  };
8
9
  export declare const ComposedLinkPicker: React.MemoExoticComponent<(props: LinkPickerProps) => JSX.Element>;
@@ -1,16 +1,14 @@
1
1
  import { jsx } from '@emotion/react';
2
2
  import { TextFieldProps } from '@atlaskit/textfield';
3
- export interface Props extends Omit<TextFieldProps, 'value' | 'onChange' | 'autoFocus' | 'onSubmit'> {
3
+ export declare type TextInputProps = Omit<TextFieldProps, 'name' | 'value'> & {
4
4
  name: string;
5
- label?: string;
6
- autoFocus?: boolean;
7
5
  value: string;
8
- onChange: (value: string) => void;
6
+ label?: string;
9
7
  onUndo?: Function;
10
8
  onRedo?: Function;
11
- onClear?: Function;
9
+ onClear?: (name: string) => void;
12
10
  clearLabel?: string;
13
11
  error?: string | null;
14
- }
15
- declare const PanelTextInput: (props: Props) => jsx.JSX.Element;
16
- export default PanelTextInput;
12
+ };
13
+ declare const TextInput: ({ name, label, autoFocus, onRedo, onUndo, onKeyDown, onClear, clearLabel, error, ...restProps }: TextInputProps) => jsx.JSX.Element;
14
+ export default TextInput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.9.1",
3
+ "version": "1.9.3",
4
4
  "description": "Standalone link picker",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "publishConfig": {
@@ -1,33 +0,0 @@
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
- }
@@ -1,15 +0,0 @@
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,17 +0,0 @@
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
- }
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- export declare function withLinkPickerAnalyticsContext<P extends {
3
- url?: string;
4
- }>(WrappedComponent: React.ComponentType<P>): React.ComponentType<P>;