@atlaskit/link-picker 1.22.2 → 1.23.1

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 (55) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/common/utils/date.js +16 -0
  3. package/dist/cjs/common/utils/dateUtils.js +72 -0
  4. package/dist/cjs/i18n/languages.js +38 -0
  5. package/dist/cjs/ui/link-picker/index.js +4 -4
  6. package/dist/cjs/ui/link-picker/link-search-list/index.js +15 -2
  7. package/dist/cjs/ui/link-picker/link-search-list/link-search-no-results/styled.js +5 -3
  8. package/dist/cjs/ui/link-picker/list-item/index.js +1 -4
  9. package/dist/cjs/ui/link-picker/messages.js +11 -16
  10. package/dist/cjs/ui/link-picker/transformTimeStamp.js +27 -22
  11. package/dist/cjs/ui/link-picker/utils.js +1 -2
  12. package/dist/cjs/version.json +1 -1
  13. package/dist/es2019/common/utils/date.js +9 -0
  14. package/dist/es2019/common/utils/dateUtils.js +61 -0
  15. package/dist/es2019/i18n/languages.js +31 -0
  16. package/dist/es2019/ui/link-picker/index.js +4 -4
  17. package/dist/es2019/ui/link-picker/link-search-list/index.js +14 -1
  18. package/dist/es2019/ui/link-picker/link-search-list/link-search-no-results/styled.js +3 -0
  19. package/dist/es2019/ui/link-picker/list-item/index.js +1 -4
  20. package/dist/es2019/ui/link-picker/messages.js +9 -14
  21. package/dist/es2019/ui/link-picker/transformTimeStamp.js +29 -23
  22. package/dist/es2019/ui/link-picker/utils.js +1 -2
  23. package/dist/es2019/version.json +1 -1
  24. package/dist/esm/common/utils/date.js +9 -0
  25. package/dist/esm/common/utils/dateUtils.js +63 -0
  26. package/dist/esm/i18n/languages.js +31 -0
  27. package/dist/esm/ui/link-picker/index.js +4 -4
  28. package/dist/esm/ui/link-picker/link-search-list/index.js +15 -2
  29. package/dist/esm/ui/link-picker/link-search-list/link-search-no-results/styled.js +3 -2
  30. package/dist/esm/ui/link-picker/list-item/index.js +1 -4
  31. package/dist/esm/ui/link-picker/messages.js +9 -14
  32. package/dist/esm/ui/link-picker/transformTimeStamp.js +28 -23
  33. package/dist/esm/ui/link-picker/utils.js +1 -2
  34. package/dist/esm/version.json +1 -1
  35. package/dist/types/common/utils/date.d.ts +1 -0
  36. package/dist/types/common/utils/dateUtils.d.ts +8 -0
  37. package/dist/types/i18n/languages.d.ts +32 -0
  38. package/dist/types/index.d.ts +1 -1
  39. package/dist/types/ui/link-picker/link-search-list/index.d.ts +2 -1
  40. package/dist/types/ui/link-picker/link-search-list/link-search-no-results/styled.d.ts +1 -0
  41. package/dist/types/ui/link-picker/messages.d.ts +3 -8
  42. package/dist/types/ui/link-picker/transformTimeStamp.d.ts +1 -2
  43. package/dist/types/ui/types.d.ts +3 -5
  44. package/dist/types-ts4.5/common/utils/date.d.ts +1 -0
  45. package/dist/types-ts4.5/common/utils/dateUtils.d.ts +8 -0
  46. package/dist/types-ts4.5/i18n/languages.d.ts +32 -0
  47. package/dist/types-ts4.5/index.d.ts +1 -1
  48. package/dist/types-ts4.5/ui/link-picker/link-search-list/index.d.ts +2 -1
  49. package/dist/types-ts4.5/ui/link-picker/link-search-list/link-search-no-results/styled.d.ts +1 -0
  50. package/dist/types-ts4.5/ui/link-picker/messages.d.ts +3 -8
  51. package/dist/types-ts4.5/ui/link-picker/transformTimeStamp.d.ts +1 -2
  52. package/dist/types-ts4.5/ui/types.d.ts +3 -5
  53. package/package.json +13 -4
  54. package/report.api.md +4 -0
  55. package/tmp/api-report-tmp.d.ts +4 -0
@@ -1,28 +1,34 @@
1
- import formatDistance from 'date-fns/formatDistance';
2
- import differenceInCalendarDays from 'date-fns/differenceInCalendarDays';
3
- import format from 'date-fns/format';
4
- import { messages } from './messages';
5
- const renderAbsoluteOrRelativeDate = (timeStamp, pageAction, intl) => {
6
- let pageActionText = '';
7
- switch (pageAction) {
8
- case 'updated':
9
- pageActionText = intl.formatMessage(messages.timeUpdated);
10
- break;
11
- case 'viewed':
12
- pageActionText = intl.formatMessage(messages.timeViewed);
13
- break;
1
+ import { timeMessages } from './messages';
2
+ import { isMoreThanOneWeekAgo } from '../../common/utils/date';
3
+ import { selectUnit } from '../../common/utils/dateUtils';
4
+ import isYesterday from 'date-fns/isYesterday';
5
+ const formatTime = (timeStamp, intl) => {
6
+ const isAbsolute = isMoreThanOneWeekAgo(timeStamp);
7
+ if (isAbsolute) {
8
+ return intl.formatDate(timeStamp, {
9
+ month: 'long',
10
+ day: 'numeric',
11
+ year: 'numeric'
12
+ });
14
13
  }
15
- if (differenceInCalendarDays(timeStamp, Date.now()) < -7) {
16
- return {
17
- pageAction: pageActionText,
18
- dateString: format(timeStamp, 'MMMM dd, yyyy')
19
- };
14
+ const {
15
+ value,
16
+ unit
17
+ } = selectUnit(timeStamp, new Date(), {
18
+ day: 7 // treat a week as 7 days (default is 5)
19
+ });
20
+ //formats as 'yesterday' instead of '1 day ago'
21
+ if (isYesterday(timeStamp)) {
22
+ return intl.formatRelativeTime(value, unit, {
23
+ numeric: 'auto'
24
+ });
20
25
  }
21
- return {
22
- pageAction: pageActionText,
23
- dateString: formatDistance(timeStamp, Date.now()),
24
- timeSince: intl.formatMessage(messages.timeAgo)
25
- };
26
+ return intl.formatRelativeTime(value, unit);
27
+ };
28
+ const renderAbsoluteOrRelativeDate = (timeStamp, pageAction, intl) => {
29
+ return intl.formatMessage(timeMessages[pageAction], {
30
+ time: formatTime(timeStamp, intl)
31
+ });
26
32
  };
27
33
  export const transformTimeStamp = (intl, lastViewedDate, lastUpdatedDate) => {
28
34
  if (lastViewedDate) {
@@ -38,8 +38,7 @@ export function getScreenReaderText(items, selectedIndex, intl) {
38
38
  lastViewedDate
39
39
  } = items[selectedIndex];
40
40
  const date = transformTimeStamp(intl, lastViewedDate, lastUpdatedDate);
41
- const formattedDate = [date === null || date === void 0 ? void 0 : date.pageAction, date === null || date === void 0 ? void 0 : date.dateString, date === null || date === void 0 ? void 0 : date.timeSince].filter(Boolean).join(' ');
42
- return [name, container, formattedDate].filter(Boolean).join(', ');
41
+ return [name, container, date].filter(Boolean).join(', ');
43
42
  }
44
43
  }
45
44
  export const handleNavKeyDown = (event, itemsLength, activeIndex) => {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.22.2",
3
+ "version": "1.23.1",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,9 @@
1
+ import isBefore from 'date-fns/isBefore';
2
+ import startOfDay from 'date-fns/startOfDay';
3
+ import subWeeks from 'date-fns/subWeeks';
4
+ export function isMoreThanOneWeekAgo(date) {
5
+ return isBefore(new Date(date), startOfOneWeekAgo());
6
+ }
7
+ function startOfOneWeekAgo() {
8
+ return startOfDay(subWeeks(new Date(), 1));
9
+ }
@@ -0,0 +1,63 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ 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; }
4
+ //copied from packages/activity-platform/recent-work-ui/src/common/ui/activity-event-type-message/utils.ts
5
+
6
+ var MS_PER_SECOND = 1e3;
7
+ var SECS_PER_MIN = 60;
8
+ var SECS_PER_HOUR = SECS_PER_MIN * 60;
9
+ var SECS_PER_DAY = SECS_PER_HOUR * 24;
10
+ var SECS_PER_WEEK = SECS_PER_DAY * 7;
11
+
12
+ // This function is a direct copy from https://github.com/formatjs/formatjs-old/blob/master/packages/intl-utils/src/diff.ts
13
+ // If the year between 'from' and 'to' is different and there is more than a week between them, the function returns
14
+ // 'year' as the unit. This means some activities display a '1 year ago' even though its 10 days old.
15
+ //
16
+ // In the below, we have removed the check for 'year' and 'month' as we display absolute dates for those periods.
17
+ export function selectUnit(from) {
18
+ var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now();
19
+ var thresholds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
20
+ var resolvedThresholds = _objectSpread(_objectSpread({}, DEFAULT_THRESHOLDS), thresholds || {});
21
+ var secs = (+from - +to) / MS_PER_SECOND;
22
+ if (Math.abs(secs) < resolvedThresholds.second) {
23
+ return {
24
+ value: Math.round(secs),
25
+ unit: 'second'
26
+ };
27
+ }
28
+ var mins = secs / SECS_PER_MIN;
29
+ if (Math.abs(mins) < resolvedThresholds.minute) {
30
+ return {
31
+ value: Math.round(mins),
32
+ unit: 'minute'
33
+ };
34
+ }
35
+ var hours = secs / SECS_PER_HOUR;
36
+ if (Math.abs(hours) < resolvedThresholds.hour) {
37
+ return {
38
+ value: Math.round(hours),
39
+ unit: 'hour'
40
+ };
41
+ }
42
+ var days = secs / SECS_PER_DAY;
43
+ if (Math.abs(days) < resolvedThresholds.day) {
44
+ return {
45
+ value: Math.round(days),
46
+ unit: 'day'
47
+ };
48
+ }
49
+ var weeks = secs / SECS_PER_WEEK;
50
+ return {
51
+ value: Math.round(weeks),
52
+ unit: 'week'
53
+ };
54
+ }
55
+ export var DEFAULT_THRESHOLDS = {
56
+ second: 45,
57
+ // seconds to minute
58
+ minute: 45,
59
+ // minutes to hour
60
+ hour: 22,
61
+ // hour to day
62
+ day: 5 // day to week
63
+ };
@@ -0,0 +1,31 @@
1
+ export default {
2
+ zh: 'Chinese',
3
+ zh_TW: 'Chinese (Traditional)',
4
+ cs: 'Czech',
5
+ nl: 'Dutch',
6
+ da: 'Danish',
7
+ en: 'English',
8
+ en_GB: 'English (United Kingdom)',
9
+ et: 'Estonian',
10
+ fi: 'Finnish',
11
+ fr: 'French',
12
+ de: 'German',
13
+ hu: 'Hungarian',
14
+ is: 'Icelandic',
15
+ it: 'Italian',
16
+ ja: 'Japanese',
17
+ ko: 'Korean',
18
+ nb: 'Norwegian Bokmål',
19
+ pl: 'Polish',
20
+ pt_BR: 'Portuguese (Brazil)',
21
+ pt_PT: 'Portuguese (Portugal)',
22
+ ro: 'Romanian',
23
+ ru: 'Russian',
24
+ sk: 'Slovak',
25
+ es: 'Spanish',
26
+ sv: 'Swedish',
27
+ th: 'Thai',
28
+ tr: 'Turkish',
29
+ uk: 'Ukrainian',
30
+ vi: 'Vietnamese'
31
+ };
@@ -77,7 +77,7 @@ var LinkInputField = withInputFieldTracking(TextInput, 'link', function (event,
77
77
  });
78
78
  var DisplayTextInputField = withInputFieldTracking(TextInput, 'displayText');
79
79
  function LinkPicker(_ref) {
80
- var _errorFallback;
80
+ var _activePlugin$errorFa, _activePlugin$errorFa2;
81
81
  var onSubmit = _ref.onSubmit,
82
82
  onCancel = _ref.onCancel,
83
83
  onContentResize = _ref.onContentResize,
@@ -111,7 +111,6 @@ function LinkPicker(_ref) {
111
111
  tabs = _usePlugins.tabs,
112
112
  error = _usePlugins.error,
113
113
  retry = _usePlugins.retry,
114
- errorFallback = _usePlugins.errorFallback,
115
114
  pluginAction = _usePlugins.pluginAction;
116
115
  var fixListHeightProps = useFixHeight(isLoading);
117
116
  var isEditing = !!initUrl;
@@ -357,8 +356,9 @@ function LinkPicker(_ref) {
357
356
  onSelect: handleSelected,
358
357
  onChange: handleSearchListOnChange,
359
358
  onKeyDown: handleKeyDown,
360
- hasSearchTerm: !!(queryState !== null && queryState !== void 0 && queryState.query.length)
361
- }), error && ((_errorFallback = errorFallback === null || errorFallback === void 0 ? void 0 : errorFallback(error, retry)) !== null && _errorFallback !== void 0 ? _errorFallback : jsx(LinkSearchError, null)))), jsx(FormFooter, {
359
+ hasSearchTerm: !!(queryState !== null && queryState !== void 0 && queryState.query.length),
360
+ activePlugin: activePlugin
361
+ }), error && ((_activePlugin$errorFa = activePlugin === null || activePlugin === void 0 ? void 0 : (_activePlugin$errorFa2 = activePlugin.errorFallback) === null || _activePlugin$errorFa2 === void 0 ? void 0 : _activePlugin$errorFa2.call(activePlugin, error, retry)) !== null && _activePlugin$errorFa !== void 0 ? _activePlugin$errorFa : jsx(LinkSearchError, null)))), jsx(FormFooter, {
362
362
  error: error,
363
363
  items: items,
364
364
  state: queryState,
@@ -1,12 +1,13 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
- var _excluded = ["onChange", "onSelect", "onKeyDown", "items", "activeIndex", "selectedIndex", "isLoading", "ariaControls", "ariaLabelledBy", "role", "id", "hasSearchTerm"];
4
+ var _excluded = ["onChange", "onSelect", "onKeyDown", "items", "activeIndex", "selectedIndex", "isLoading", "ariaControls", "ariaLabelledBy", "role", "id", "hasSearchTerm", "activePlugin"];
5
5
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
6
  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; }
7
7
  /** @jsx jsx */
8
8
  import { forwardRef, Fragment, useCallback, useRef } from 'react';
9
9
  import { jsx } from '@emotion/react';
10
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
11
  import { defineMessages, FormattedMessage } from 'react-intl-next';
11
12
  import Spinner from '@atlaskit/spinner';
12
13
  import VisuallyHidden from '@atlaskit/visually-hidden';
@@ -15,6 +16,7 @@ import { listContainerStyles, spinnerContainerStyles, listStyles, listTitleStyle
15
16
  import LinkSearchNoResults, { testIds as noResultsTestIds } from './link-search-no-results';
16
17
  import { useTrackResultsShown } from './use-track-results-shown';
17
18
  import { handleNavKeyDown } from '../utils';
19
+ import { emptyStateNoResultsWrapper } from './link-search-no-results/styled';
18
20
  export var messages = defineMessages({
19
21
  titleRecentlyViewed: {
20
22
  id: 'fabric.linkPicker.listTitle.recentlyViewed',
@@ -51,6 +53,7 @@ var LinkSearchList = /*#__PURE__*/forwardRef(function (_ref, ref) {
51
53
  role = _ref.role,
52
54
  id = _ref.id,
53
55
  hasSearchTerm = _ref.hasSearchTerm,
56
+ activePlugin = _ref.activePlugin,
54
57
  restProps = _objectWithoutProperties(_ref, _excluded);
55
58
  var itemsContent;
56
59
  var loadingContent;
@@ -98,7 +101,17 @@ var LinkSearchList = /*#__PURE__*/forwardRef(function (_ref, ref) {
98
101
  }
99
102
  }, [activeIndex, items, onChange, onKeyDown]);
100
103
  if ((items === null || items === void 0 ? void 0 : items.length) === 0) {
101
- return jsx(LinkSearchNoResults, null);
104
+ if (getBooleanFF('platform.linking-platform.link-picker.enable-empty-state')) {
105
+ if (hasSearchTerm) {
106
+ return jsx(LinkSearchNoResults, null);
107
+ } else {
108
+ return jsx("div", {
109
+ css: emptyStateNoResultsWrapper
110
+ }, activePlugin !== null && activePlugin !== void 0 && activePlugin.emptyStateNoResults ? activePlugin.emptyStateNoResults() : null);
111
+ }
112
+ } else {
113
+ return jsx(LinkSearchNoResults, null);
114
+ }
102
115
  }
103
116
  if (items && items.length > 0) {
104
117
  itemsContent = jsx(Fragment, null, jsx("div", {
@@ -1,4 +1,5 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
- var _templateObject;
2
+ var _templateObject, _templateObject2;
3
3
  import { css } from '@emotion/react';
4
- export var emptyStateWrapperStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n & p {\n margin: 0;\n }\n"])));
4
+ export var emptyStateWrapperStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n & p {\n margin: 0;\n }\n"])));
5
+ export var emptyStateNoResultsWrapper = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n min-height: ", ";\n"])), "var(--ds-space-200, 16px)");
@@ -49,12 +49,9 @@ var LinkSearchListItem = /*#__PURE__*/forwardRef(function (_ref, ref) {
49
49
  css: listItemContainerInnerStyles
50
50
  }, container)), date && jsx("div", {
51
51
  css: listItemContainerInnerStyles
52
- }, container && jsx(Fragment, null, "\xA0 \u2022\xA0 "), jsx(Fragment, null, formatDate(date))))));
52
+ }, container && jsx(Fragment, null, "\xA0 \u2022\xA0 "), jsx(Fragment, null, date)))));
53
53
  });
54
54
  export default LinkSearchListItem;
55
- var formatDate = function formatDate(date) {
56
- return [date.pageAction, date.dateString, date.timeSince].filter(Boolean).join(' ');
57
- };
58
55
  var isSVG = function isSVG(icon) {
59
56
  return icon.startsWith('<svg') && icon.endsWith('</svg>');
60
57
  };
@@ -67,20 +67,15 @@ export var linkTextMessages = defineMessages({
67
67
  description: 'Tooltip message for link input clear button'
68
68
  }
69
69
  });
70
- export var messages = defineMessages({
71
- timeUpdated: {
72
- id: 'fabric.linkPicker.time.updated',
73
- defaultMessage: 'Updated',
74
- description: 'Time last updated'
70
+ export var timeMessages = defineMessages({
71
+ updated: {
72
+ id: 'fabric.linkPicker.time.message.updated',
73
+ defaultMessage: 'Updated {time}',
74
+ description: 'Time last updated where {time} can be an absolute value e.g. June 5, 2023 or a relative value e.g. 3 hours ago'
75
75
  },
76
- timeViewed: {
77
- id: 'fabric.linkPicker.time.viewed',
78
- defaultMessage: 'Viewed',
79
- description: 'Time last viewed'
80
- },
81
- timeAgo: {
82
- id: 'fabric.linkPicker.time.ago',
83
- defaultMessage: 'ago',
84
- description: 'Some time ago'
76
+ viewed: {
77
+ id: 'fabric.linkPicker.time.message.viewed',
78
+ defaultMessage: 'Viewed {time}',
79
+ description: 'Time last viewed where {time} can be an absolute value e.g. June 5, 2023 or a relative value e.g. 3 hours ago'
85
80
  }
86
81
  });
@@ -1,28 +1,33 @@
1
- import formatDistance from 'date-fns/formatDistance';
2
- import differenceInCalendarDays from 'date-fns/differenceInCalendarDays';
3
- import format from 'date-fns/format';
4
- import { messages } from './messages';
5
- var renderAbsoluteOrRelativeDate = function renderAbsoluteOrRelativeDate(timeStamp, pageAction, intl) {
6
- var pageActionText = '';
7
- switch (pageAction) {
8
- case 'updated':
9
- pageActionText = intl.formatMessage(messages.timeUpdated);
10
- break;
11
- case 'viewed':
12
- pageActionText = intl.formatMessage(messages.timeViewed);
13
- break;
1
+ import { timeMessages } from './messages';
2
+ import { isMoreThanOneWeekAgo } from '../../common/utils/date';
3
+ import { selectUnit } from '../../common/utils/dateUtils';
4
+ import isYesterday from 'date-fns/isYesterday';
5
+ var formatTime = function formatTime(timeStamp, intl) {
6
+ var isAbsolute = isMoreThanOneWeekAgo(timeStamp);
7
+ if (isAbsolute) {
8
+ return intl.formatDate(timeStamp, {
9
+ month: 'long',
10
+ day: 'numeric',
11
+ year: 'numeric'
12
+ });
14
13
  }
15
- if (differenceInCalendarDays(timeStamp, Date.now()) < -7) {
16
- return {
17
- pageAction: pageActionText,
18
- dateString: format(timeStamp, 'MMMM dd, yyyy')
19
- };
14
+ var _selectUnit = selectUnit(timeStamp, new Date(), {
15
+ day: 7 // treat a week as 7 days (default is 5)
16
+ }),
17
+ value = _selectUnit.value,
18
+ unit = _selectUnit.unit;
19
+ //formats as 'yesterday' instead of '1 day ago'
20
+ if (isYesterday(timeStamp)) {
21
+ return intl.formatRelativeTime(value, unit, {
22
+ numeric: 'auto'
23
+ });
20
24
  }
21
- return {
22
- pageAction: pageActionText,
23
- dateString: formatDistance(timeStamp, Date.now()),
24
- timeSince: intl.formatMessage(messages.timeAgo)
25
- };
25
+ return intl.formatRelativeTime(value, unit);
26
+ };
27
+ var renderAbsoluteOrRelativeDate = function renderAbsoluteOrRelativeDate(timeStamp, pageAction, intl) {
28
+ return intl.formatMessage(timeMessages[pageAction], {
29
+ time: formatTime(timeStamp, intl)
30
+ });
26
31
  };
27
32
  export var transformTimeStamp = function transformTimeStamp(intl, lastViewedDate, lastUpdatedDate) {
28
33
  if (lastViewedDate) {
@@ -35,8 +35,7 @@ export function getScreenReaderText(items, selectedIndex, intl) {
35
35
  lastUpdatedDate = _items$selectedIndex.lastUpdatedDate,
36
36
  lastViewedDate = _items$selectedIndex.lastViewedDate;
37
37
  var date = transformTimeStamp(intl, lastViewedDate, lastUpdatedDate);
38
- var formattedDate = [date === null || date === void 0 ? void 0 : date.pageAction, date === null || date === void 0 ? void 0 : date.dateString, date === null || date === void 0 ? void 0 : date.timeSince].filter(Boolean).join(' ');
39
- return [name, container, formattedDate].filter(Boolean).join(', ');
38
+ return [name, container, date].filter(Boolean).join(', ');
40
39
  }
41
40
  }
42
41
  export var handleNavKeyDown = function handleNavKeyDown(event, itemsLength, activeIndex) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-picker",
3
- "version": "1.22.2",
3
+ "version": "1.23.1",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1 @@
1
+ export declare function isMoreThanOneWeekAgo(date: string | Date): boolean;
@@ -0,0 +1,8 @@
1
+ export type Unit = 'second' | 'minute' | 'hour' | 'day' | 'week';
2
+ export declare function selectUnit(from: Date | number, to?: Date | number, thresholds?: Partial<Thresholds>): {
3
+ value: number;
4
+ unit: Unit;
5
+ };
6
+ type Thresholds = Record<'second' | 'minute' | 'hour' | 'day', number>;
7
+ export declare const DEFAULT_THRESHOLDS: Thresholds;
8
+ export {};
@@ -0,0 +1,32 @@
1
+ declare const _default: {
2
+ zh: string;
3
+ zh_TW: string;
4
+ cs: string;
5
+ nl: string;
6
+ da: string;
7
+ en: string;
8
+ en_GB: string;
9
+ et: string;
10
+ fi: string;
11
+ fr: string;
12
+ de: string;
13
+ hu: string;
14
+ is: string;
15
+ it: string;
16
+ ja: string;
17
+ ko: string;
18
+ nb: string;
19
+ pl: string;
20
+ pt_BR: string;
21
+ pt_PT: string;
22
+ ro: string;
23
+ ru: string;
24
+ sk: string;
25
+ es: string;
26
+ sv: string;
27
+ th: string;
28
+ tr: string;
29
+ uk: string;
30
+ vi: string;
31
+ };
32
+ export default _default;
@@ -1,4 +1,4 @@
1
1
  export { ComposedLinkPicker as LinkPicker } from './ui';
2
2
  export type { LinkPickerProps } from './ui/link-picker';
3
- export type { LinkInputType, LinkPickerPluginAction, LinkPickerPlugin, LinkPickerState, LinkSearchListItemData, LinkPickerPluginErrorFallback, } from './ui/types';
3
+ export type { LinkInputType, LinkPickerPluginAction, LinkPickerPlugin, LinkPickerState, LinkSearchListItemData, LinkPickerPluginErrorFallback, LinkPickerPluginEmptyStateNoResults, } from './ui/types';
4
4
  export { UnauthenticatedError } from './common/utils/errors';
@@ -1,6 +1,6 @@
1
1
  /** @jsx jsx */
2
2
  import { KeyboardEvent } from 'react';
3
- import { LinkSearchListItemData } from '../../types';
3
+ import { LinkPickerPlugin, LinkSearchListItemData } from '../../types';
4
4
  export declare const messages: {
5
5
  titleRecentlyViewed: {
6
6
  id: string;
@@ -39,6 +39,7 @@ export interface LinkSearchListProps extends Omit<React.HTMLAttributes<LinkSearc
39
39
  role?: string;
40
40
  id?: string;
41
41
  hasSearchTerm?: boolean;
42
+ activePlugin?: LinkPickerPlugin;
42
43
  }
43
44
  declare const LinkSearchList: import("react").ForwardRefExoticComponent<LinkSearchListProps & import("react").RefAttributes<HTMLDivElement>>;
44
45
  export default LinkSearchList;
@@ -1 +1,2 @@
1
1
  export declare const emptyStateWrapperStyles: import("@emotion/react").SerializedStyles;
2
+ export declare const emptyStateNoResultsWrapper: import("@emotion/react").SerializedStyles;
@@ -66,18 +66,13 @@ export declare const linkTextMessages: {
66
66
  description: string;
67
67
  };
68
68
  };
69
- export declare const messages: {
70
- timeUpdated: {
69
+ export declare const timeMessages: {
70
+ updated: {
71
71
  id: string;
72
72
  defaultMessage: string;
73
73
  description: string;
74
74
  };
75
- timeViewed: {
76
- id: string;
77
- defaultMessage: string;
78
- description: string;
79
- };
80
- timeAgo: {
75
+ viewed: {
81
76
  id: string;
82
77
  defaultMessage: string;
83
78
  description: string;
@@ -1,3 +1,2 @@
1
1
  import { IntlShape } from 'react-intl-next';
2
- import { ListItemTimeStamp } from '../types';
3
- export declare const transformTimeStamp: (intl: IntlShape, lastViewedDate?: Date, lastUpdatedDate?: Date) => ListItemTimeStamp | undefined;
2
+ export declare const transformTimeStamp: (intl: IntlShape, lastViewedDate?: Date, lastUpdatedDate?: Date) => string | undefined;
@@ -28,11 +28,6 @@ export interface LinkSearchListItemData {
28
28
  source?: string;
29
29
  };
30
30
  }
31
- export type ListItemTimeStamp = {
32
- pageAction: string;
33
- dateString: string;
34
- timeSince?: string | undefined;
35
- };
36
31
  export interface LinkPickerState {
37
32
  /** Current query string / URL input field value */
38
33
  query: string;
@@ -48,6 +43,8 @@ export interface LinkPickerPlugin {
48
43
  tabTitle?: string;
49
44
  /** Render function to customise the UI that is displayed when an error occurs resolving results */
50
45
  errorFallback?: LinkPickerPluginErrorFallback;
46
+ /** Render function to customise the UI that is displayed when there are no results, but an empty form (no search term) */
47
+ emptyStateNoResults?: LinkPickerPluginEmptyStateNoResults;
51
48
  /** Metadata about the plugin */
52
49
  meta?: {
53
50
  /** The data source that provides all results provided by the plugin */
@@ -63,3 +60,4 @@ export interface LinkPickerPluginAction {
63
60
  callback: () => void;
64
61
  }
65
62
  export type LinkPickerPluginErrorFallback = (error: unknown, retry: () => void) => ReactNode;
63
+ export type LinkPickerPluginEmptyStateNoResults = () => ReactNode;
@@ -0,0 +1 @@
1
+ export declare function isMoreThanOneWeekAgo(date: string | Date): boolean;
@@ -0,0 +1,8 @@
1
+ export type Unit = 'second' | 'minute' | 'hour' | 'day' | 'week';
2
+ export declare function selectUnit(from: Date | number, to?: Date | number, thresholds?: Partial<Thresholds>): {
3
+ value: number;
4
+ unit: Unit;
5
+ };
6
+ type Thresholds = Record<'second' | 'minute' | 'hour' | 'day', number>;
7
+ export declare const DEFAULT_THRESHOLDS: Thresholds;
8
+ export {};
@@ -0,0 +1,32 @@
1
+ declare const _default: {
2
+ zh: string;
3
+ zh_TW: string;
4
+ cs: string;
5
+ nl: string;
6
+ da: string;
7
+ en: string;
8
+ en_GB: string;
9
+ et: string;
10
+ fi: string;
11
+ fr: string;
12
+ de: string;
13
+ hu: string;
14
+ is: string;
15
+ it: string;
16
+ ja: string;
17
+ ko: string;
18
+ nb: string;
19
+ pl: string;
20
+ pt_BR: string;
21
+ pt_PT: string;
22
+ ro: string;
23
+ ru: string;
24
+ sk: string;
25
+ es: string;
26
+ sv: string;
27
+ th: string;
28
+ tr: string;
29
+ uk: string;
30
+ vi: string;
31
+ };
32
+ export default _default;
@@ -1,4 +1,4 @@
1
1
  export { ComposedLinkPicker as LinkPicker } from './ui';
2
2
  export type { LinkPickerProps } from './ui/link-picker';
3
- export type { LinkInputType, LinkPickerPluginAction, LinkPickerPlugin, LinkPickerState, LinkSearchListItemData, LinkPickerPluginErrorFallback, } from './ui/types';
3
+ export type { LinkInputType, LinkPickerPluginAction, LinkPickerPlugin, LinkPickerState, LinkSearchListItemData, LinkPickerPluginErrorFallback, LinkPickerPluginEmptyStateNoResults, } from './ui/types';
4
4
  export { UnauthenticatedError } from './common/utils/errors';
@@ -1,6 +1,6 @@
1
1
  /** @jsx jsx */
2
2
  import { KeyboardEvent } from 'react';
3
- import { LinkSearchListItemData } from '../../types';
3
+ import { LinkPickerPlugin, LinkSearchListItemData } from '../../types';
4
4
  export declare const messages: {
5
5
  titleRecentlyViewed: {
6
6
  id: string;
@@ -39,6 +39,7 @@ export interface LinkSearchListProps extends Omit<React.HTMLAttributes<LinkSearc
39
39
  role?: string;
40
40
  id?: string;
41
41
  hasSearchTerm?: boolean;
42
+ activePlugin?: LinkPickerPlugin;
42
43
  }
43
44
  declare const LinkSearchList: import("react").ForwardRefExoticComponent<LinkSearchListProps & import("react").RefAttributes<HTMLDivElement>>;
44
45
  export default LinkSearchList;
@@ -1 +1,2 @@
1
1
  export declare const emptyStateWrapperStyles: import("@emotion/react").SerializedStyles;
2
+ export declare const emptyStateNoResultsWrapper: import("@emotion/react").SerializedStyles;
@@ -66,18 +66,13 @@ export declare const linkTextMessages: {
66
66
  description: string;
67
67
  };
68
68
  };
69
- export declare const messages: {
70
- timeUpdated: {
69
+ export declare const timeMessages: {
70
+ updated: {
71
71
  id: string;
72
72
  defaultMessage: string;
73
73
  description: string;
74
74
  };
75
- timeViewed: {
76
- id: string;
77
- defaultMessage: string;
78
- description: string;
79
- };
80
- timeAgo: {
75
+ viewed: {
81
76
  id: string;
82
77
  defaultMessage: string;
83
78
  description: string;
@@ -1,3 +1,2 @@
1
1
  import { IntlShape } from 'react-intl-next';
2
- import { ListItemTimeStamp } from '../types';
3
- export declare const transformTimeStamp: (intl: IntlShape, lastViewedDate?: Date, lastUpdatedDate?: Date) => ListItemTimeStamp | undefined;
2
+ export declare const transformTimeStamp: (intl: IntlShape, lastViewedDate?: Date, lastUpdatedDate?: Date) => string | undefined;