@atlaskit/link-datasource 1.29.4 → 1.30.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.js +126 -33
  3. package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/messages.js +50 -0
  4. package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.js +6 -4
  5. package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/trigger.js +6 -6
  6. package/dist/cjs/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.js +66 -0
  7. package/dist/cjs/ui/confluence-search-modal/basic-filters/index.js +12 -2
  8. package/dist/cjs/ui/confluence-search-modal/modal/index.js +36 -13
  9. package/dist/cjs/ui/table-footer/powered-by-jsm-assets/index.js +1 -1
  10. package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.js +116 -31
  11. package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/messages.js +50 -0
  12. package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.js +6 -4
  13. package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/trigger.js +6 -6
  14. package/dist/es2019/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.js +57 -0
  15. package/dist/es2019/ui/confluence-search-modal/basic-filters/index.js +8 -1
  16. package/dist/es2019/ui/confluence-search-modal/modal/index.js +32 -7
  17. package/dist/es2019/ui/table-footer/powered-by-jsm-assets/index.js +1 -1
  18. package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.js +128 -35
  19. package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/messages.js +50 -0
  20. package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/styled.js +6 -4
  21. package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/trigger.js +6 -6
  22. package/dist/esm/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.js +59 -0
  23. package/dist/esm/ui/confluence-search-modal/basic-filters/index.js +12 -2
  24. package/dist/esm/ui/confluence-search-modal/modal/index.js +36 -13
  25. package/dist/esm/ui/table-footer/powered-by-jsm-assets/index.js +1 -1
  26. package/dist/types/ui/common/modal/popup-select/types.d.ts +3 -1
  27. package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.d.ts +4 -3
  28. package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/messages.d.ts +50 -0
  29. package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/trigger.d.ts +4 -4
  30. package/dist/types/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.d.ts +6 -0
  31. package/dist/types/ui/confluence-search-modal/basic-filters/index.d.ts +2 -2
  32. package/dist/types/ui/confluence-search-modal/confluence-search-container/index.d.ts +1 -1
  33. package/dist/types/ui/confluence-search-modal/modal/index.d.ts +1 -1
  34. package/dist/types/ui/confluence-search-modal/types.d.ts +3 -3
  35. package/dist/types-ts4.5/ui/common/modal/popup-select/types.d.ts +3 -1
  36. package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/index.d.ts +4 -3
  37. package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/messages.d.ts +50 -0
  38. package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/trigger.d.ts +4 -4
  39. package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/filters/date-range-picker/utils.d.ts +6 -0
  40. package/dist/types-ts4.5/ui/confluence-search-modal/basic-filters/index.d.ts +2 -2
  41. package/dist/types-ts4.5/ui/confluence-search-modal/confluence-search-container/index.d.ts +1 -1
  42. package/dist/types-ts4.5/ui/confluence-search-modal/modal/index.d.ts +1 -1
  43. package/dist/types-ts4.5/ui/confluence-search-modal/types.d.ts +3 -3
  44. package/package.json +10 -9
@@ -1,38 +1,89 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import React, { useCallback, useState } from 'react';
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
3
6
  import { FormattedMessage, useIntl } from 'react-intl-next';
7
+ import { DatePicker } from '@atlaskit/datetime-picker';
8
+ import ErrorIcon from '@atlaskit/icon/glyph/error';
4
9
  import Popup from '@atlaskit/popup';
10
+ import { R400 } from '@atlaskit/theme/colors';
5
11
  import { layers } from '@atlaskit/theme/constants';
6
12
  import { CLOLBasicFilters } from '../../types';
7
13
  import { dateRangeMessages } from './messages';
8
14
  import { PopupComponent } from './PopupComponent';
9
- import { CustomDropdown, CustomDropdownItem } from './styled';
15
+ import { CustomDateWrapper, CustomDropdown, CustomDropdownItem, DatePickersWrapper, DateRangeErrorMessage, SelectDateRangeButton } from './styled';
10
16
  import { PopupTrigger } from './trigger';
17
+ import { getCurrentOptionLabel, getDropdownLabel, getInvalidDateRange } from './utils';
11
18
  var lastModifiedValues = ['anyTime', 'today', 'yesterday', 'past7Days', 'past30Days', 'pastYear', 'custom'];
12
19
  var defaultOptionValue = 'anyTime';
13
- var filterName = CLOLBasicFilters.lastModified;
14
20
  export var DateRangePicker = function DateRangePicker(_ref) {
15
- var onSelectionChange = _ref.onSelectionChange;
16
- var _useState = useState(null),
21
+ var onSelectionChange = _ref.onSelectionChange,
22
+ selection = _ref.selection;
23
+ var _useState = useState(selection === null || selection === void 0 ? void 0 : selection.value),
17
24
  _useState2 = _slicedToArray(_useState, 2),
18
25
  currentOption = _useState2[0],
19
26
  setCurrentOption = _useState2[1];
20
- var _useState3 = useState(false),
27
+ var _useState3 = useState(getInvalidDateRange(selection === null || selection === void 0 ? void 0 : selection.from, selection === null || selection === void 0 ? void 0 : selection.to)),
21
28
  _useState4 = _slicedToArray(_useState3, 2),
22
- isPickerOpen = _useState4[0],
23
- setIsPickerOpen = _useState4[1];
29
+ invalidDateRange = _useState4[0],
30
+ setInvalidDateRange = _useState4[1];
31
+ var customFromDate = useRef(selection === null || selection === void 0 ? void 0 : selection.from);
32
+ var customToDate = useRef(selection === null || selection === void 0 ? void 0 : selection.to);
33
+ var _useState5 = useState(false),
34
+ _useState6 = _slicedToArray(_useState5, 2),
35
+ isPickerOpen = _useState6[0],
36
+ setIsPickerOpen = _useState6[1];
24
37
  var _useIntl = useIntl(),
25
- formatMessage = _useIntl.formatMessage;
26
- var onClickFilterOption = useCallback(function (option) {
27
- setCurrentOption(option);
38
+ locale = _useIntl.locale,
39
+ formatMessage = _useIntl.formatMessage,
40
+ formatDate = _useIntl.formatDate;
41
+ var isCustomSelected = currentOption === 'custom' || (selection === null || selection === void 0 ? void 0 : selection.value) === 'custom';
42
+ var maxDate = new Date().toISOString();
43
+ useEffect(function () {
44
+ if (isPickerOpen) {
45
+ customFromDate.current = selection === null || selection === void 0 ? void 0 : selection.from;
46
+ customToDate.current = selection === null || selection === void 0 ? void 0 : selection.to;
47
+ }
48
+ }, [isPickerOpen, selection === null || selection === void 0 ? void 0 : selection.from, selection === null || selection === void 0 ? void 0 : selection.to]);
49
+ var handleFromOnChange = function handleFromOnChange(date) {
50
+ customFromDate.current = date;
51
+ setInvalidDateRange(getInvalidDateRange(customFromDate.current, customToDate.current));
52
+ };
53
+ var handleToOnChange = function handleToOnChange(date) {
54
+ customToDate.current = date;
55
+ setInvalidDateRange(getInvalidDateRange(customFromDate.current, customToDate.current));
56
+ };
57
+ var handleClickUpdateDateRange = function handleClickUpdateDateRange() {
58
+ var label = 'custom';
59
+ if (customFromDate.current && !customToDate.current) {
60
+ label = customFromDate.current;
61
+ } else if (customToDate.current && !customFromDate.current) {
62
+ label = customToDate.current;
63
+ }
64
+ onSelectionChange(CLOLBasicFilters.lastModified, {
65
+ optionType: 'dateRange',
66
+ label: label,
67
+ value: 'custom',
68
+ from: customFromDate.current,
69
+ to: customToDate.current
70
+ });
28
71
  setIsPickerOpen(false);
29
- onSelectionChange(filterName, [{
30
- optionType: 'defaultOption',
72
+ };
73
+ var handleClickFilterOption = useCallback(function (option) {
74
+ setCurrentOption(option);
75
+ onSelectionChange(CLOLBasicFilters.lastModified, {
76
+ optionType: 'dateRange',
31
77
  label: option,
32
78
  value: option
33
- }]);
79
+ });
80
+ if (option !== 'custom') {
81
+ setIsPickerOpen(false);
82
+ }
34
83
  }, [onSelectionChange]);
35
84
  var handleTogglePopup = useCallback(function () {
85
+ // If users click out of popup, we let selection prop define the current option when opened again until user sets state
86
+ setCurrentOption(undefined);
36
87
  setIsPickerOpen(!isPickerOpen);
37
88
  }, [isPickerOpen]);
38
89
  return /*#__PURE__*/React.createElement(Popup, {
@@ -44,36 +95,78 @@ export var DateRangePicker = function DateRangePicker(_ref) {
44
95
  return /*#__PURE__*/React.createElement(CustomDropdown, null, lastModifiedValues.map(function (option) {
45
96
  return /*#__PURE__*/React.createElement(CustomDropdownItem, {
46
97
  key: option
47
- //want to show Anytime as selected if none of the other options are selected
98
+ // want to show Anytime as selected if none of the other options are selected
48
99
  ,
49
- isSelected: currentOption ? option === currentOption : option === defaultOptionValue,
100
+ isSelected: selection !== null && selection !== void 0 && selection.value ? option === selection.value : option === defaultOptionValue,
50
101
  onClick: function onClick() {
51
- return onClickFilterOption(option);
102
+ return handleClickFilterOption(option);
103
+ }
104
+ }, getDropdownLabel(option, formatMessage));
105
+ }), isPickerOpen && isCustomSelected && /*#__PURE__*/React.createElement(CustomDateWrapper, null, /*#__PURE__*/React.createElement(DatePickersWrapper, null, /*#__PURE__*/React.createElement(DatePicker, {
106
+ maxDate: maxDate,
107
+ innerProps: {
108
+ style: {
109
+ width: 140
110
+ }
111
+ },
112
+ testId: "date-from-picker",
113
+ dateFormat: "D MMM YYYY",
114
+ onChange: handleFromOnChange,
115
+ defaultValue: selection === null || selection === void 0 ? void 0 : selection.from,
116
+ placeholder: formatMessage(dateRangeMessages.dateRangeFrom),
117
+ isInvalid: Boolean(invalidDateRange),
118
+ locale: locale,
119
+ selectProps: {
120
+ styles: {
121
+ placeholder: function placeholder(base) {
122
+ return _objectSpread(_objectSpread({}, base), {}, {
123
+ width: 'max-content'
124
+ });
125
+ }
52
126
  }
53
- }, /*#__PURE__*/React.createElement(FormattedMessage, getCurrentOptionLabel(option)));
54
- }));
127
+ }
128
+ }), /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeToLabel), /*#__PURE__*/React.createElement(DatePicker, {
129
+ maxDate: maxDate,
130
+ innerProps: {
131
+ style: {
132
+ width: 140
133
+ }
134
+ },
135
+ testId: "date-to-picker",
136
+ dateFormat: "D MMM YYYY",
137
+ onChange: handleToOnChange,
138
+ defaultValue: selection === null || selection === void 0 ? void 0 : selection.to,
139
+ placeholder: formatMessage(dateRangeMessages.dateRangeTo),
140
+ isInvalid: Boolean(invalidDateRange),
141
+ locale: locale,
142
+ selectProps: {
143
+ styles: {
144
+ placeholder: function placeholder(base) {
145
+ return _objectSpread(_objectSpread({}, base), {}, {
146
+ width: 'max-content'
147
+ });
148
+ }
149
+ }
150
+ }
151
+ })), invalidDateRange && /*#__PURE__*/React.createElement(DateRangeErrorMessage, null, /*#__PURE__*/React.createElement(ErrorIcon, {
152
+ size: "small",
153
+ primaryColor: "var(--ds-icon-danger, ".concat(R400, ")"),
154
+ label: "Date range error"
155
+ }), invalidDateRange), /*#__PURE__*/React.createElement(SelectDateRangeButton, {
156
+ "data-testId": "custom-date-range-update-button",
157
+ disabled: Boolean(invalidDateRange),
158
+ onClick: handleClickUpdateDateRange
159
+ }, formatMessage(dateRangeMessages.dateRangeUpdateButton))));
55
160
  },
56
161
  placement: "bottom-start",
57
162
  trigger: function trigger(triggerProps) {
58
163
  return /*#__PURE__*/React.createElement(PopupTrigger, {
59
164
  triggerProps: triggerProps,
60
- optionSelected: !!currentOption,
61
- label: formatMessage(dateRangeMessages.dateRangeTitle),
62
- selectedLabel: formatMessage(getCurrentOptionLabel(currentOption)),
63
- onClickButton: handleTogglePopup
165
+ isSelected: !!(selection !== null && selection !== void 0 && selection.value) || isPickerOpen,
166
+ labelPrefix: formatMessage(dateRangeMessages.dateRangeTitle),
167
+ selectedLabel: getCurrentOptionLabel(formatDate, formatMessage, selection),
168
+ onClick: handleTogglePopup
64
169
  });
65
170
  }
66
171
  });
67
- };
68
- var getCurrentOptionLabel = function getCurrentOptionLabel(option) {
69
- var mapping = {
70
- anyTime: 'dateRangeAnyTime',
71
- today: 'dateRangeToday',
72
- yesterday: 'dateRangeYesterday',
73
- past7Days: 'dateRangeLastWeek',
74
- past30Days: 'dateRangeLastMonth',
75
- pastYear: 'dateRangeLastYear',
76
- custom: 'dateRangeCustom'
77
- };
78
- return option ? dateRangeMessages[mapping[option]] : dateRangeMessages[mapping['anyTime']];
79
172
  };
@@ -39,5 +39,55 @@ export var dateRangeMessages = defineMessages({
39
39
  id: 'linkDataSource.confluence-search.configmodal.date.range.custom',
40
40
  defaultMessage: 'Custom',
41
41
  description: 'Custom date range'
42
+ },
43
+ dateRangeFrom: {
44
+ id: 'linkDataSource.confluence-search.configmodal.date.range.from',
45
+ defaultMessage: 'From',
46
+ description: 'Filter starting from a custom date'
47
+ },
48
+ dateRangeTo: {
49
+ id: 'linkDataSource.confluence-search.configmodal.date.range.to',
50
+ defaultMessage: 'To',
51
+ description: 'Filter up to a custom date'
52
+ },
53
+ dateRangeDateInputPlaceholder: {
54
+ id: 'linkDataSource.confluence-search.configmodal.date.range.input.placeholder',
55
+ defaultMessage: 'Choose a date',
56
+ description: 'Placeholder text for date input'
57
+ },
58
+ dateRangeCustomInvalidDateAfterToday: {
59
+ id: 'linkDataSource.confluence-search.configmodal.date.range.custom.invalid.after.today',
60
+ defaultMessage: 'The From date can’t be in the future',
61
+ description: 'error displayed when a date range begins after the current date'
62
+ },
63
+ dateRangeCustomInvalidToDateAfterToday: {
64
+ id: 'linkDataSource.confluence-search.configmodal.date.range.custom.invalid.to.after.today',
65
+ defaultMessage: 'The To date can’t be in the future',
66
+ description: 'error displayed when a date range ends after the current date'
67
+ },
68
+ dateRangeCustomInvalidDateAfterEnd: {
69
+ id: 'linkDataSource.confluence-search.configmodal.date.range.custom.invalid.after.end',
70
+ defaultMessage: 'The From date has to be before the To date',
71
+ description: 'error displayed when a date range begins after the end date'
72
+ },
73
+ dateRangeToLabel: {
74
+ id: 'linkDataSource.confluence-search.configmodal.date.range.to.Label',
75
+ defaultMessage: 'to',
76
+ description: "'to' in between from and to date pickers"
77
+ },
78
+ dateRangeUpdateButton: {
79
+ id: 'linkDataSource.confluence-search.configmodal.date.range.update.button',
80
+ defaultMessage: 'Update',
81
+ description: 'Text for update button in date filter picker'
82
+ },
83
+ dateRangeBeforeLabel: {
84
+ id: 'linkDataSource.confluence-search.configmodal.date.range.before.label',
85
+ defaultMessage: 'before {date}',
86
+ description: '`before date` for date picker dropdown'
87
+ },
88
+ dateRangeAfterLabel: {
89
+ id: 'linkDataSource.confluence-search.configmodal.date.range.after.label',
90
+ defaultMessage: 'after {date}',
91
+ description: '`after date` for date picker dropdown'
42
92
  }
43
93
  });
@@ -1,10 +1,12 @@
1
1
  import styled from '@emotion/styled';
2
2
  import { B400, B50, N0, N20, N30, R400 } from '@atlaskit/theme/colors';
3
+ import { layers } from '@atlaskit/theme/constants';
3
4
  export var PopupComponentContainer = styled.div({
4
5
  boxSizing: 'border-box',
5
6
  display: 'block',
6
7
  flex: '1 1 auto',
7
8
  overflow: 'visible',
9
+ borderRadius: "var(--ds-border-radius-200, 3px)",
8
10
  background: "var(--ds-background-input, ".concat(N0, ")"),
9
11
  ':focus': {
10
12
  outline: 'none'
@@ -12,11 +14,11 @@ export var PopupComponentContainer = styled.div({
12
14
  boxShadow: "var(--ds-shadow-overlay, 0px 0px 1px 0px rgba(9, 30, 66, 0.31), 0px 3px 5px 0px rgba(9, 30, 66, 0.20))"
13
15
  });
14
16
  export var CustomDropdown = styled.div({
15
- width: '360px',
17
+ width: '340px',
16
18
  background: "var(--ds-background-input, ".concat(N0, ")"),
17
- borderRadius: '3px',
19
+ borderRadius: "var(--ds-border-radius-200, 3px)",
18
20
  boxShadow: "var(--ds-shadow-overlay, 0px 0px 1px 0px rgba(9, 30, 66, 0.31), 0px 3px 5px 0px rgba(9, 30, 66, 0.20))",
19
- zIndex: '900'
21
+ zIndex: layers.modal()
20
22
  });
21
23
  export var CustomDropdownItem = styled.div(function (props) {
22
24
  return {
@@ -53,7 +55,7 @@ export var SelectDateRangeButton = styled.button({
53
55
  width: '70px',
54
56
  height: '40px',
55
57
  marginTop: "var(--ds-space-150, 12px)",
56
- borderRadius: '3px',
58
+ borderRadius: "var(--ds-border-radius-200, 3px)",
57
59
  '&:hover': {
58
60
  background: "var(--ds-background-accent-gray-subtler, ".concat(N30, ")"),
59
61
  cursor: 'pointer'
@@ -4,14 +4,14 @@ import Button from '@atlaskit/button/standard-button';
4
4
  import ChevronDownIcon from '@atlaskit/icon/glyph/chevron-down';
5
5
  export var PopupTrigger = function PopupTrigger(_ref) {
6
6
  var triggerProps = _ref.triggerProps,
7
- optionSelected = _ref.optionSelected,
8
- label = _ref.label,
7
+ isSelected = _ref.isSelected,
8
+ labelPrefix = _ref.labelPrefix,
9
9
  selectedLabel = _ref.selectedLabel,
10
- onClickButton = _ref.onClickButton;
10
+ onClick = _ref.onClick;
11
11
  return /*#__PURE__*/React.createElement(Button, _extends({}, triggerProps, {
12
12
  testId: 'confluence-search-modal--date-range-button',
13
- onClick: onClickButton,
14
- isSelected: optionSelected,
13
+ onClick: onClick,
14
+ isSelected: isSelected,
15
15
  iconAfter: /*#__PURE__*/React.createElement("span", {
16
16
  style: {
17
17
  display: 'flex',
@@ -21,5 +21,5 @@ export var PopupTrigger = function PopupTrigger(_ref) {
21
21
  size: "medium",
22
22
  label: ""
23
23
  }))
24
- }), label, selectedLabel ? ": ".concat(selectedLabel) : '');
24
+ }), labelPrefix, selectedLabel ? ": ".concat(selectedLabel) : '');
25
25
  };
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ import { FormattedMessage } from 'react-intl-next';
3
+ import { getFormattedDate } from '../../../../../ui/issue-like-table/render-type/date-time';
4
+ import { dateRangeMessages } from './messages';
5
+ export var getDropdownLabel = function getDropdownLabel() {
6
+ var option = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'anyTime';
7
+ var formatMessage = arguments.length > 1 ? arguments[1] : undefined;
8
+ var mapping = {
9
+ anyTime: 'dateRangeAnyTime',
10
+ today: 'dateRangeToday',
11
+ yesterday: 'dateRangeYesterday',
12
+ past7Days: 'dateRangeLastWeek',
13
+ past30Days: 'dateRangeLastMonth',
14
+ pastYear: 'dateRangeLastYear',
15
+ custom: 'dateRangeCustom'
16
+ };
17
+ return formatMessage(dateRangeMessages[mapping[option]]);
18
+ };
19
+ export var getCurrentOptionLabel = function getCurrentOptionLabel(formatDate, formatMessage, selection) {
20
+ var selectedOption = selection === null || selection === void 0 ? void 0 : selection.value;
21
+ if (selectedOption === 'custom') {
22
+ var hasFromDate = !!(selection !== null && selection !== void 0 && selection.from);
23
+ var hasToDate = !!(selection !== null && selection !== void 0 && selection.to);
24
+ var formattedFromDate = getFormattedDate((selection === null || selection === void 0 ? void 0 : selection.from) || '', 'date', formatDate);
25
+ var formattedToDate = getFormattedDate((selection === null || selection === void 0 ? void 0 : selection.to) || '', 'date', formatDate);
26
+ if (hasFromDate && !hasToDate) {
27
+ return formatMessage(dateRangeMessages.dateRangeAfterLabel, {
28
+ date: formattedFromDate
29
+ });
30
+ }
31
+ if (!hasFromDate && hasToDate) {
32
+ return formatMessage(dateRangeMessages.dateRangeBeforeLabel, {
33
+ date: formattedToDate
34
+ });
35
+ }
36
+ if (hasFromDate && hasToDate) {
37
+ return "".concat(formattedFromDate, " - ").concat(formattedToDate);
38
+ }
39
+ }
40
+ return getDropdownLabel(selectedOption, formatMessage);
41
+ };
42
+ export var getInvalidDateRange = function getInvalidDateRange(from, to) {
43
+ if (!from && !to) {
44
+ return null;
45
+ }
46
+ var dateFrom = new Date("".concat(from).concat(from ? 'T00:00:00' : ''));
47
+ var dateTo = new Date("".concat(to).concat(to ? 'T00:00:00' : ''));
48
+ var now = new Date();
49
+ if (dateFrom > now) {
50
+ return /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeCustomInvalidDateAfterToday);
51
+ }
52
+ if (dateFrom > dateTo) {
53
+ return /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeCustomInvalidDateAfterEnd);
54
+ }
55
+ if (dateTo > now) {
56
+ return /*#__PURE__*/React.createElement(FormattedMessage, dateRangeMessages.dateRangeCustomInvalidToDateAfterToday);
57
+ }
58
+ return null;
59
+ };
@@ -1,3 +1,4 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
1
2
  import React from 'react';
2
3
  import { Flex, xcss } from '@atlaskit/primitives';
3
4
  import { DateRangePicker } from './filters/date-range-picker';
@@ -11,7 +12,15 @@ var BasicFilterContainer = function BasicFilterContainer(_ref) {
11
12
  _ref$selections = _ref.selections,
12
13
  selections = _ref$selections === void 0 ? {} : _ref$selections,
13
14
  isHydrating = _ref.isHydrating;
14
- var editedOrCreatedBy = selections.editedOrCreatedBy;
15
+ var lastModified = selections.lastModified,
16
+ editedOrCreatedBy = selections.editedOrCreatedBy;
17
+ var _ref2 = lastModified || [],
18
+ _ref3 = _slicedToArray(_ref2, 1),
19
+ lastModifiedValue = _ref3[0];
20
+ var lastModifiedSelection = (lastModifiedValue === null || lastModifiedValue === void 0 ? void 0 : lastModifiedValue.optionType) === 'dateRange' ? lastModifiedValue : undefined;
21
+ var onDateRangePickerChange = function onDateRangePickerChange(filterType, updatedOption) {
22
+ onChange(filterType, [updatedOption]);
23
+ };
15
24
  return /*#__PURE__*/React.createElement(Flex, {
16
25
  xcss: basicFilterContainerStyles,
17
26
  gap: "space.100",
@@ -22,7 +31,8 @@ var BasicFilterContainer = function BasicFilterContainer(_ref) {
22
31
  selection: editedOrCreatedBy || [],
23
32
  isHydrating: isHydrating
24
33
  }), /*#__PURE__*/React.createElement(DateRangePicker, {
25
- onSelectionChange: onChange
34
+ selection: lastModifiedSelection,
35
+ onSelectionChange: onDateRangePickerChange
26
36
  }));
27
37
  };
28
38
  export default BasicFilterContainer;
@@ -99,14 +99,18 @@ export var PlainConfluenceSearchConfigModal = function PlainConfluenceSearchConf
99
99
  _useState10 = _slicedToArray(_useState9, 2),
100
100
  visibleColumnKeys = _useState10[0],
101
101
  setVisibleColumnKeys = _useState10[1];
102
- var _useState11 = useState(initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModified),
102
+ var _useState11 = useState((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.contributorAccountIds) || []),
103
103
  _useState12 = _slicedToArray(_useState11, 2),
104
- lastModified = _useState12[0],
105
- setLastModified = _useState12[1];
106
- var _useState13 = useState((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.contributorAccountIds) || []),
104
+ contributorAccountIds = _useState12[0],
105
+ setContributorAccountIds = _useState12[1];
106
+ var _useState13 = useState(initialParameters !== null && initialParameters !== void 0 && initialParameters.lastModified ? {
107
+ value: initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModified,
108
+ from: initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModifiedFrom,
109
+ to: initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModifiedTo
110
+ } : undefined),
107
111
  _useState14 = _slicedToArray(_useState13, 2),
108
- contributorAccountIds = _useState14[0],
109
- setContributorAccountIds = _useState14[1];
112
+ lastModified = _useState14[0],
113
+ setLastModified = _useState14[1];
110
114
 
111
115
  // analytics related parameters
112
116
  var searchCount = useRef(0);
@@ -116,15 +120,19 @@ export var PlainConfluenceSearchConfigModal = function PlainConfluenceSearchConf
116
120
  // TODO: further refactoring in EDM-9573
117
121
  // https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/pull-requests/82725/overview?commentId=6829210
118
122
  var parameters = useMemo(function () {
119
- return _objectSpread(_objectSpread(_objectSpread({}, initialParameters), {}, {
123
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, initialParameters), {}, {
120
124
  cloudId: cloudId,
121
125
  searchString: searchString
122
- }, ((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModified) || lastModified) && {
123
- lastModified: lastModified
126
+ }, ((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModified) || (lastModified === null || lastModified === void 0 ? void 0 : lastModified.value)) && {
127
+ lastModified: lastModified === null || lastModified === void 0 ? void 0 : lastModified.value
128
+ }), ((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModifiedFrom) || (lastModified === null || lastModified === void 0 ? void 0 : lastModified.from)) && {
129
+ lastModifiedFrom: lastModified === null || lastModified === void 0 ? void 0 : lastModified.from
130
+ }), ((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.lastModifiedTo) || (lastModified === null || lastModified === void 0 ? void 0 : lastModified.to)) && {
131
+ lastModifiedTo: lastModified === null || lastModified === void 0 ? void 0 : lastModified.to
124
132
  }), ((initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.contributorAccountIds) || (contributorAccountIds === null || contributorAccountIds === void 0 ? void 0 : contributorAccountIds.length) > 0) && {
125
133
  contributorAccountIds: contributorAccountIds
126
134
  });
127
- }, [cloudId, lastModified, contributorAccountIds, initialParameters, searchString /** Add more parameters when more filters are added */]);
135
+ }, [initialParameters, cloudId, searchString, lastModified, contributorAccountIds]);
128
136
  var initialFilterSelection = useMemo(function () {
129
137
  return {
130
138
  editedOrCreatedBy: (initialParameters === null || initialParameters === void 0 ? void 0 : initialParameters.contributorAccountIds) || []
@@ -303,8 +311,17 @@ export var PlainConfluenceSearchConfigModal = function PlainConfluenceSearchConf
303
311
  if (contributorAccountIds.length > 0) {
304
312
  params.append('contributors', contributorAccountIds.join(','));
305
313
  }
314
+ if (lastModified !== null && lastModified !== void 0 && lastModified.value) {
315
+ params.append('lastModified', lastModified.value);
316
+ }
317
+ if (lastModified !== null && lastModified !== void 0 && lastModified.from) {
318
+ params.append('from', lastModified === null || lastModified === void 0 ? void 0 : lastModified.from);
319
+ }
320
+ if (lastModified !== null && lastModified !== void 0 && lastModified.to) {
321
+ params.append('to', lastModified === null || lastModified === void 0 ? void 0 : lastModified.to);
322
+ }
306
323
  return "".concat(selectedConfluenceSiteUrl, "/wiki/search?").concat(params.toString());
307
- }, [contributorAccountIds, searchString, selectedConfluenceSiteUrl]);
324
+ }, [contributorAccountIds, lastModified, searchString, selectedConfluenceSiteUrl]);
308
325
  var analyticsPayload = useMemo(function () {
309
326
  return {
310
327
  extensionKey: extensionKey,
@@ -444,10 +461,16 @@ export var PlainConfluenceSearchConfigModal = function PlainConfluenceSearchConf
444
461
  var editedOrCreatedBy = filters.editedOrCreatedBy,
445
462
  _lastModified = filters.lastModified;
446
463
  if (_lastModified) {
447
- var lastModifiedValue = _lastModified.find(function (range) {
464
+ var updatedDateRangeOption = _lastModified.find(function (range) {
448
465
  return range.value;
449
466
  });
450
- setLastModified(lastModifiedValue === null || lastModifiedValue === void 0 ? void 0 : lastModifiedValue.value);
467
+ if ((updatedDateRangeOption === null || updatedDateRangeOption === void 0 ? void 0 : updatedDateRangeOption.optionType) === 'dateRange') {
468
+ setLastModified({
469
+ value: updatedDateRangeOption.value,
470
+ from: updatedDateRangeOption.from,
471
+ to: updatedDateRangeOption.to
472
+ });
473
+ }
451
474
  }
452
475
  if (editedOrCreatedBy) {
453
476
  var accountIds = editedOrCreatedBy.map(function (user) {
@@ -5,7 +5,7 @@ import { useDatasourceAnalyticsEvents } from '../../../analytics';
5
5
  var jsmTextStyles = xcss({
6
6
  fontSize: 'small',
7
7
  color: 'color.text.subtle',
8
- marginLeft: "var(--ds-space-075, 6px)",
8
+ marginLeft: 'space.075',
9
9
  ':hover': {
10
10
  color: 'color.link.pressed'
11
11
  }
@@ -20,8 +20,10 @@ export type AvatarLabelOption = OptionBase & {
20
20
  };
21
21
  export type DateRangeType = 'anyTime' | 'today' | 'yesterday' | 'past7Days' | 'past30Days' | 'pastYear' | 'custom';
22
22
  export type DateRangeOption = OptionBase & {
23
- optionType: 'defaultOption';
23
+ optionType: 'dateRange';
24
24
  value: DateRangeType;
25
+ from?: string;
26
+ to?: string;
25
27
  };
26
28
  export type SelectOption = IconLabelOption | LozengeLabelOption | AvatarLabelOption | DateRangeOption;
27
29
  export type FormatOptionLabel = (option: SelectOption) => ReactElement;
@@ -1,8 +1,9 @@
1
1
  /// <reference types="react" />
2
- import { SelectOption } from '../../../../common/modal/popup-select/types';
2
+ import { type DateRangeOption } from '../../../../common/modal/popup-select/types';
3
3
  import { CLOLBasicFilters } from '../../types';
4
4
  interface DateRangeProps {
5
- onSelectionChange: (filterType: CLOLBasicFilters, options: SelectOption[]) => void;
5
+ onSelectionChange: (filterType: CLOLBasicFilters, options: DateRangeOption) => void;
6
+ selection?: DateRangeOption;
6
7
  }
7
- export declare const DateRangePicker: ({ onSelectionChange }: DateRangeProps) => JSX.Element;
8
+ export declare const DateRangePicker: ({ onSelectionChange, selection, }: DateRangeProps) => JSX.Element;
8
9
  export {};
@@ -39,4 +39,54 @@ export declare const dateRangeMessages: {
39
39
  defaultMessage: string;
40
40
  description: string;
41
41
  };
42
+ dateRangeFrom: {
43
+ id: string;
44
+ defaultMessage: string;
45
+ description: string;
46
+ };
47
+ dateRangeTo: {
48
+ id: string;
49
+ defaultMessage: string;
50
+ description: string;
51
+ };
52
+ dateRangeDateInputPlaceholder: {
53
+ id: string;
54
+ defaultMessage: string;
55
+ description: string;
56
+ };
57
+ dateRangeCustomInvalidDateAfterToday: {
58
+ id: string;
59
+ defaultMessage: string;
60
+ description: string;
61
+ };
62
+ dateRangeCustomInvalidToDateAfterToday: {
63
+ id: string;
64
+ defaultMessage: string;
65
+ description: string;
66
+ };
67
+ dateRangeCustomInvalidDateAfterEnd: {
68
+ id: string;
69
+ defaultMessage: string;
70
+ description: string;
71
+ };
72
+ dateRangeToLabel: {
73
+ id: string;
74
+ defaultMessage: string;
75
+ description: string;
76
+ };
77
+ dateRangeUpdateButton: {
78
+ id: string;
79
+ defaultMessage: string;
80
+ description: string;
81
+ };
82
+ dateRangeBeforeLabel: {
83
+ id: string;
84
+ defaultMessage: string;
85
+ description: string;
86
+ };
87
+ dateRangeAfterLabel: {
88
+ id: string;
89
+ defaultMessage: string;
90
+ description: string;
91
+ };
42
92
  };
@@ -2,9 +2,9 @@
2
2
  import type { TriggerProps } from '@atlaskit/popup/types';
3
3
  export interface PopupTriggerProps {
4
4
  triggerProps: TriggerProps;
5
- optionSelected: boolean;
6
- label?: string;
5
+ isSelected: boolean;
6
+ labelPrefix: string;
7
7
  selectedLabel?: string;
8
- onClickButton: () => void;
8
+ onClick: () => void;
9
9
  }
10
- export declare const PopupTrigger: ({ triggerProps, optionSelected, label, selectedLabel, onClickButton, }: PopupTriggerProps) => JSX.Element;
10
+ export declare const PopupTrigger: ({ triggerProps, isSelected, labelPrefix, selectedLabel, onClick, }: PopupTriggerProps) => JSX.Element;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { type IntlShape } from 'react-intl-next';
3
+ import { type DateRangeOption, type DateRangeType } from '../../../../common/modal/popup-select/types';
4
+ export declare const getDropdownLabel: (option: DateRangeType | undefined, formatMessage: IntlShape['formatMessage']) => string;
5
+ export declare const getCurrentOptionLabel: (formatDate: IntlShape['formatDate'], formatMessage: IntlShape['formatMessage'], selection?: DateRangeOption) => string;
6
+ export declare const getInvalidDateRange: (from: string | undefined, to: string | undefined) => JSX.Element | null;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { SelectOption } from '../../common/modal/popup-select/types';
3
- import { CLOLBasicFilters, SelectedOptionsMap } from './types';
2
+ import { type SelectOption } from '../../common/modal/popup-select/types';
3
+ import { type CLOLBasicFilters, type SelectedOptionsMap } from './types';
4
4
  export interface BasicFilterContainerProps {
5
5
  cloudId?: string;
6
6
  selections: SelectedOptionsMap;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { CLOLBasicFilters, SelectedOptionsMap } from '../basic-filters/types';
2
+ import { CLOLBasicFilters, type SelectedOptionsMap } from '../basic-filters/types';
3
3
  export type FilterInitialSelectionMap = {
4
4
  [CLOLBasicFilters.editedOrCreatedBy]?: string[];
5
5
  };
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { jsx } from '@emotion/react';
3
3
  import { DatasourceAction } from '../../../analytics/types';
4
- import { ConfluenceSearchConfigModalProps } from '../types';
4
+ import { type ConfluenceSearchConfigModalProps } from '../types';
5
5
  export declare const getColumnAction: (oldVisibleColumnKeys: string[], newVisibleColumnKeys: string[]) => DatasourceAction;
6
6
  export declare const PlainConfluenceSearchConfigModal: (props: ConfluenceSearchConfigModalProps) => jsx.JSX.Element;
7
7
  export declare const ConfluenceSearchConfigModal: import("react").ForwardRefExoticComponent<ConfluenceSearchConfigModalProps & import("@atlaskit/analytics-next").WithContextProps & import("react").RefAttributes<any>>;