@atlaskit/smart-card 23.3.1 → 23.4.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.
- package/CHANGELOG.md +34 -0
- package/dist/cjs/constants.js +3 -0
- package/dist/cjs/extractors/common/actions/extractActions.js +3 -0
- package/dist/cjs/extractors/flexible/actions/extract-download-action.js +26 -0
- package/dist/cjs/extractors/flexible/actions/extract-preview-action.js +36 -0
- package/dist/cjs/extractors/flexible/actions/extract-view-action.js +26 -0
- package/dist/cjs/extractors/flexible/index.js +9 -0
- package/dist/cjs/state/flexible-ui-context/index.js +15 -2
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/FlexibleCard/components/actions/action/download-action/index.js +110 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/download-action/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/index.js +167 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/view-action/index.js +92 -0
- package/dist/cjs/view/FlexibleCard/components/actions/action/view-action/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/actions/index.js +26 -2
- package/dist/cjs/view/FlexibleCard/components/actions/utils.js +51 -2
- package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +19 -13
- package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +9 -4
- package/dist/cjs/view/FlexibleCard/components/elements/media/index.js +1 -1
- package/dist/cjs/view/FlexibleCard/index.js +6 -3
- package/dist/cjs/view/common/Icon.js +25 -13
- package/dist/es2019/constants.js +3 -0
- package/dist/es2019/extractors/common/actions/extractActions.js +1 -2
- package/dist/es2019/extractors/flexible/actions/extract-download-action.js +13 -0
- package/dist/es2019/extractors/flexible/actions/extract-preview-action.js +23 -0
- package/dist/es2019/extractors/flexible/actions/extract-view-action.js +13 -0
- package/dist/es2019/extractors/flexible/index.js +7 -1
- package/dist/es2019/state/flexible-ui-context/index.js +8 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/FlexibleCard/components/actions/action/download-action/index.js +66 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/download-action/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/index.js +104 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/view-action/index.js +46 -0
- package/dist/es2019/view/FlexibleCard/components/actions/action/view-action/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/actions/index.js +23 -2
- package/dist/es2019/view/FlexibleCard/components/actions/utils.js +48 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +12 -9
- package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +9 -4
- package/dist/es2019/view/FlexibleCard/components/elements/media/index.js +1 -1
- package/dist/es2019/view/FlexibleCard/index.js +7 -4
- package/dist/es2019/view/common/Icon.js +31 -13
- package/dist/esm/constants.js +3 -0
- package/dist/esm/extractors/common/actions/extractActions.js +1 -2
- package/dist/esm/extractors/flexible/actions/extract-download-action.js +15 -0
- package/dist/esm/extractors/flexible/actions/extract-preview-action.js +23 -0
- package/dist/esm/extractors/flexible/actions/extract-view-action.js +15 -0
- package/dist/esm/extractors/flexible/index.js +7 -1
- package/dist/esm/state/flexible-ui-context/index.js +9 -0
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/FlexibleCard/components/actions/action/download-action/index.js +96 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/download-action/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/index.js +136 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/view-action/index.js +77 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/view-action/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/actions/index.js +23 -2
- package/dist/esm/view/FlexibleCard/components/actions/utils.js +45 -2
- package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +19 -13
- package/dist/esm/view/FlexibleCard/components/blocks/utils.js +9 -4
- package/dist/esm/view/FlexibleCard/components/elements/media/index.js +1 -1
- package/dist/esm/view/FlexibleCard/index.js +7 -4
- package/dist/esm/view/common/Icon.js +27 -13
- package/dist/types/constants.d.ts +3 -0
- package/dist/types/extractors/common/__mocks__/jsonld.d.ts +112 -0
- package/dist/types/extractors/common/actions/extractActions.d.ts +1 -0
- package/dist/types/extractors/flexible/actions/extract-download-action.d.ts +3 -0
- package/dist/types/extractors/flexible/actions/extract-preview-action.d.ts +3 -0
- package/dist/types/extractors/flexible/actions/extract-view-action.d.ts +3 -0
- package/dist/types/state/flexible-ui-context/index.d.ts +76 -0
- package/dist/types/state/flexible-ui-context/types.d.ts +32 -0
- package/dist/types/view/BlockCard/actions/PreviewAction.d.ts +2 -2
- package/dist/types/view/EmbedModal/index.d.ts +20 -2
- package/dist/types/view/EmbedModal/types.d.ts +1 -2
- package/dist/types/view/FlexibleCard/components/actions/action/download-action/index.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/actions/action/download-action/types.d.ts +8 -0
- package/dist/types/view/FlexibleCard/components/actions/action/preview-action/index.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/actions/action/preview-action/types.d.ts +15 -0
- package/dist/types/view/FlexibleCard/components/actions/action/view-action/index.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/actions/action/view-action/types.d.ts +8 -0
- package/dist/types/view/FlexibleCard/components/actions/index.d.ts +21 -0
- package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +50 -3
- package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +1 -1
- package/dist/types/view/FlexibleCard/types.d.ts +6 -0
- package/dist/types/view/common/Icon.d.ts +2 -1
- package/package.json +1 -1
- package/report.api.md +30 -2
- package/tmp/api-report-tmp.d.ts +25 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ActionName } from '../../../../constants';
|
|
2
|
-
import { createUIAction } from './utils';
|
|
2
|
+
import { createDataAction, createUIAction } from './utils';
|
|
3
|
+
// Attention: Keep the export name and action name the same.
|
|
3
4
|
// This will help reducing the code for mapping action inside
|
|
4
5
|
// createAction and renderActionItems
|
|
5
6
|
|
|
@@ -8,7 +9,6 @@ import { createUIAction } from './utils'; // Attention: Keep the export name and
|
|
|
8
9
|
* the icon to a cross icon.
|
|
9
10
|
* @see Action
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
12
|
export const DeleteAction = createUIAction(ActionName.DeleteAction);
|
|
13
13
|
/**
|
|
14
14
|
* Creates a EditAction component. Accepts default ActionProps, but defaults
|
|
@@ -17,6 +17,27 @@ export const DeleteAction = createUIAction(ActionName.DeleteAction);
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
export const EditAction = createUIAction(ActionName.EditAction);
|
|
20
|
+
/**
|
|
21
|
+
* Creates a PreviewAction component. Accepts default PreviewActionProps, and defaults
|
|
22
|
+
* to the text 'Preview' inside the button.
|
|
23
|
+
* @see Action
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export const PreviewAction = createDataAction(ActionName.PreviewAction);
|
|
27
|
+
/**
|
|
28
|
+
* Creates a ViewAction component. Accepts default ViewActionProps, and defaults
|
|
29
|
+
* to the text 'View' inside the button.
|
|
30
|
+
* @see Action
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
export const ViewAction = createDataAction(ActionName.ViewAction);
|
|
34
|
+
/**
|
|
35
|
+
* Creates a DownloadAction component. Accepts default DownloadActionProps, and defaults
|
|
36
|
+
* to the text 'Download' inside the button.
|
|
37
|
+
* @see Action
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
export const DownloadAction = createDataAction(ActionName.DownloadAction);
|
|
20
41
|
/**
|
|
21
42
|
* Creates a CustomAction component. Accepts default ActionProps. Required to provide
|
|
22
43
|
* your own icon or text.
|
|
@@ -7,6 +7,12 @@ import { FormattedMessage } from 'react-intl-next';
|
|
|
7
7
|
import { messages } from '../../../../messages';
|
|
8
8
|
import CrossIcon from '@atlaskit/icon/glyph/cross';
|
|
9
9
|
import EditIcon from '@atlaskit/icon/glyph/edit';
|
|
10
|
+
import PreviewAction from './action/preview-action';
|
|
11
|
+
import VidFullScreenOnIcon from '@atlaskit/icon/glyph/vid-full-screen-on';
|
|
12
|
+
import ViewAction from './action/view-action';
|
|
13
|
+
import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
|
|
14
|
+
import DownloadAction from './action/download-action';
|
|
15
|
+
import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
10
16
|
const actionMappings = {
|
|
11
17
|
[ActionName.CustomAction]: {
|
|
12
18
|
component: Action,
|
|
@@ -33,6 +39,39 @@ const actionMappings = {
|
|
|
33
39
|
}),
|
|
34
40
|
tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.edit)
|
|
35
41
|
}
|
|
42
|
+
},
|
|
43
|
+
[ActionName.PreviewAction]: {
|
|
44
|
+
component: PreviewAction,
|
|
45
|
+
props: {
|
|
46
|
+
testId: 'smart-action-preview-action',
|
|
47
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview),
|
|
48
|
+
icon: /*#__PURE__*/React.createElement(VidFullScreenOnIcon, {
|
|
49
|
+
label: "Preview"
|
|
50
|
+
}),
|
|
51
|
+
tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview)
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
[ActionName.ViewAction]: {
|
|
55
|
+
component: ViewAction,
|
|
56
|
+
props: {
|
|
57
|
+
testId: 'smart-action-view-action',
|
|
58
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.view),
|
|
59
|
+
icon: /*#__PURE__*/React.createElement(ShortcutIcon, {
|
|
60
|
+
label: "View"
|
|
61
|
+
}),
|
|
62
|
+
tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.view)
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
[ActionName.DownloadAction]: {
|
|
66
|
+
component: DownloadAction,
|
|
67
|
+
props: {
|
|
68
|
+
testId: 'smart-action-download-action',
|
|
69
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.download),
|
|
70
|
+
icon: /*#__PURE__*/React.createElement(DownloadIcon, {
|
|
71
|
+
label: "Download"
|
|
72
|
+
}),
|
|
73
|
+
tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.download)
|
|
74
|
+
}
|
|
36
75
|
}
|
|
37
76
|
};
|
|
38
77
|
|
|
@@ -50,8 +89,13 @@ const getActionData = (actionName, contextKey, context) => {
|
|
|
50
89
|
const data = context[contextKey];
|
|
51
90
|
|
|
52
91
|
switch (actionName) {
|
|
53
|
-
|
|
92
|
+
case ActionName.PreviewAction:
|
|
93
|
+
case ActionName.ViewAction:
|
|
94
|
+
case ActionName.DownloadAction:
|
|
54
95
|
return data;
|
|
96
|
+
|
|
97
|
+
default:
|
|
98
|
+
return undefined;
|
|
55
99
|
}
|
|
56
100
|
};
|
|
57
101
|
|
|
@@ -69,7 +113,9 @@ export const createDataAction = name => {
|
|
|
69
113
|
return overrides => {
|
|
70
114
|
const context = useContext(FlexibleUiContext);
|
|
71
115
|
const data = getActionData(name, contextKey, context);
|
|
72
|
-
return /*#__PURE__*/React.createElement(BaseAction, _extends({}, props, data, overrides
|
|
116
|
+
return data ? /*#__PURE__*/React.createElement(BaseAction, _extends({}, props, data, overrides, {
|
|
117
|
+
url: context === null || context === void 0 ? void 0 : context.url
|
|
118
|
+
})) : null;
|
|
73
119
|
};
|
|
74
120
|
};
|
|
75
121
|
export const createUIAction = name => {
|
|
@@ -46,13 +46,7 @@ const ActionGroup = ({
|
|
|
46
46
|
onDropdownOpenChange,
|
|
47
47
|
testId
|
|
48
48
|
}) => {
|
|
49
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
50
|
-
const [buttonActions, dropdownItemActions] = useMemo(() => {
|
|
51
|
-
const isMoreThenTwoItems = items.length > visibleButtonsNum;
|
|
52
|
-
const buttons = isMoreThenTwoItems ? items.slice(0, visibleButtonsNum - 1) : items;
|
|
53
|
-
const dropdownItems = isMoreThenTwoItems ? items.slice(visibleButtonsNum - 1) : [];
|
|
54
|
-
return [buttons, dropdownItems];
|
|
55
|
-
}, [items, visibleButtonsNum]); // Stop AK dropdown menu to propagate event on click.
|
|
49
|
+
const [isOpen, setIsOpen] = useState(false); // Stop AK dropdown menu to propagate event on click.
|
|
56
50
|
|
|
57
51
|
const onClick = useCallback(e => e.stopPropagation(), []);
|
|
58
52
|
const onOpenChange = useCallback(attrs => {
|
|
@@ -69,11 +63,20 @@ const ActionGroup = ({
|
|
|
69
63
|
});
|
|
70
64
|
}
|
|
71
65
|
}, [isOpen, onOpenChange]);
|
|
66
|
+
const renderableActions = items.filter(action => renderActionItems([action]));
|
|
67
|
+
const [buttonActions, dropdownItemActions] = useMemo(() => {
|
|
68
|
+
const isMoreThenTwoItems = renderableActions && renderableActions.length > visibleButtonsNum;
|
|
69
|
+
const buttons = isMoreThenTwoItems ? renderableActions.slice(0, visibleButtonsNum - 1) : renderableActions;
|
|
70
|
+
const dropdownItems = isMoreThenTwoItems ? renderableActions.slice(visibleButtonsNum - 1) : [];
|
|
71
|
+
return [buttons, dropdownItems];
|
|
72
|
+
}, [renderableActions, visibleButtonsNum]);
|
|
73
|
+
const dropdownMenuElement = renderActionItems(dropdownItemActions, size, appearance, true, onActionClick);
|
|
74
|
+
const buttonGroupElement = renderActionItems(buttonActions, size, appearance, false, onActionClick);
|
|
72
75
|
return jsx("div", {
|
|
73
76
|
css: styles,
|
|
74
77
|
className: "actions-button-group",
|
|
75
78
|
onClick: onClick
|
|
76
|
-
}, jsx(ButtonGroup, null,
|
|
79
|
+
}, jsx(ButtonGroup, null, buttonGroupElement, dropdownItemActions.length > 0 && dropdownMenuElement && dropdownMenuElement.length > 0 ? jsx(DropdownMenu, {
|
|
77
80
|
isOpen: isOpen,
|
|
78
81
|
onOpenChange: onOpenChange,
|
|
79
82
|
trigger: ({
|
|
@@ -93,7 +96,7 @@ const ActionGroup = ({
|
|
|
93
96
|
ref: triggerRef
|
|
94
97
|
}))),
|
|
95
98
|
testId: "action-group-dropdown"
|
|
96
|
-
},
|
|
99
|
+
}, dropdownMenuElement) : null));
|
|
97
100
|
};
|
|
98
101
|
|
|
99
102
|
export default ActionGroup;
|
|
@@ -105,7 +105,7 @@ const isElementDisplayValid = (name, display) => {
|
|
|
105
105
|
return (_ElementDisplaySchema = (_ElementDisplaySchema2 = ElementDisplaySchema[name]) === null || _ElementDisplaySchema2 === void 0 ? void 0 : _ElementDisplaySchema2.includes(display)) !== null && _ElementDisplaySchema !== void 0 ? _ElementDisplaySchema : false;
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
const
|
|
108
|
+
const isJSXElementNull = children => {
|
|
109
109
|
return Boolean(children.type() === null);
|
|
110
110
|
};
|
|
111
111
|
|
|
@@ -138,7 +138,7 @@ export const renderElementItems = (items = [], display = 'inline') => {
|
|
|
138
138
|
key: idx
|
|
139
139
|
}, typedProps));
|
|
140
140
|
|
|
141
|
-
if (!
|
|
141
|
+
if (!isJSXElementNull(element)) {
|
|
142
142
|
return [...acc, element];
|
|
143
143
|
}
|
|
144
144
|
}
|
|
@@ -182,13 +182,18 @@ export const renderActionItems = (items = [], size = SmartLinkSize.Medium, appea
|
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
const action = /*#__PURE__*/React.createElement(Action, _extends({
|
|
186
|
+
url: '',
|
|
186
187
|
asDropDownItem: asDropDownItems,
|
|
187
188
|
size: size,
|
|
188
189
|
key: idx,
|
|
189
190
|
appearance: appearance,
|
|
190
191
|
onClick: handleOnClick
|
|
191
|
-
}, actionProps))
|
|
192
|
+
}, actionProps));
|
|
193
|
+
|
|
194
|
+
if (!isJSXElementNull(action)) {
|
|
195
|
+
return [...acc, action];
|
|
196
|
+
}
|
|
192
197
|
}
|
|
193
198
|
|
|
194
199
|
return acc;
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React, { useEffect } from 'react';
|
|
3
3
|
import { SmartLinkStatus } from '../../constants';
|
|
4
4
|
import Container from './components/container';
|
|
5
|
-
import { FlexibleUiContext } from '../../state/flexible-ui-context';
|
|
5
|
+
import { FlexibleUiAnalyticsContext, FlexibleUiContext } from '../../state/flexible-ui-context';
|
|
6
6
|
import { getContextByStatus, getRetryOptions } from './utils';
|
|
7
7
|
/**
|
|
8
8
|
* This represents a Flexible Card: a link represented by a card with metadata.
|
|
@@ -21,7 +21,8 @@ const FlexibleCard = ({
|
|
|
21
21
|
ui,
|
|
22
22
|
url,
|
|
23
23
|
onClick,
|
|
24
|
-
testId
|
|
24
|
+
testId,
|
|
25
|
+
analytics
|
|
25
26
|
}) => {
|
|
26
27
|
const {
|
|
27
28
|
status: cardType,
|
|
@@ -60,7 +61,9 @@ const FlexibleCard = ({
|
|
|
60
61
|
break;
|
|
61
62
|
}
|
|
62
63
|
}, [onError, onResolve, status, title, url]);
|
|
63
|
-
return /*#__PURE__*/React.createElement(
|
|
64
|
+
return /*#__PURE__*/React.createElement(FlexibleUiAnalyticsContext.Provider, {
|
|
65
|
+
value: analytics
|
|
66
|
+
}, /*#__PURE__*/React.createElement(FlexibleUiContext.Provider, {
|
|
64
67
|
value: context
|
|
65
68
|
}, /*#__PURE__*/React.createElement(Container, _extends({
|
|
66
69
|
testId: testId
|
|
@@ -68,7 +71,7 @@ const FlexibleCard = ({
|
|
|
68
71
|
onClick: onClick,
|
|
69
72
|
retry: retry,
|
|
70
73
|
status: status
|
|
71
|
-
}), children));
|
|
74
|
+
}), children)));
|
|
72
75
|
};
|
|
73
76
|
|
|
74
77
|
export default FlexibleCard;
|
|
@@ -1,15 +1,42 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { jsx } from '@emotion/react';
|
|
2
|
+
import { css, jsx } from '@emotion/react';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import ImageLoader from 'react-render-image';
|
|
5
5
|
import LinkIcon from '@atlaskit/icon/glyph/link';
|
|
6
6
|
import { gs } from './utils';
|
|
7
7
|
export const blockCardIconImageClassName = 'block-card-icon-image';
|
|
8
|
+
|
|
9
|
+
const getImageStyles = isFlexibleUi => {
|
|
10
|
+
if (isFlexibleUi) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return css`
|
|
15
|
+
height: ${gs(2)};
|
|
16
|
+
width: ${gs(2)};
|
|
17
|
+
`;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const getSpanStyles = isFlexibleUi => {
|
|
21
|
+
if (isFlexibleUi) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return css`
|
|
26
|
+
height: ${gs(2.5)};
|
|
27
|
+
width: ${gs(2)};
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
`;
|
|
32
|
+
};
|
|
33
|
+
|
|
8
34
|
export const Icon = ({
|
|
9
35
|
url,
|
|
10
36
|
icon,
|
|
11
37
|
defaultIcon,
|
|
12
|
-
testId = 'block-card-icon'
|
|
38
|
+
testId = 'block-card-icon',
|
|
39
|
+
isFlexibleUi = false
|
|
13
40
|
}) => {
|
|
14
41
|
const placeholder = defaultIcon || jsx(LinkIcon, {
|
|
15
42
|
label: "link",
|
|
@@ -19,23 +46,14 @@ export const Icon = ({
|
|
|
19
46
|
const image = url && jsx(ImageLoader, {
|
|
20
47
|
src: url,
|
|
21
48
|
loaded: jsx("img", {
|
|
22
|
-
css:
|
|
23
|
-
height: gs(2),
|
|
24
|
-
width: gs(2)
|
|
25
|
-
},
|
|
49
|
+
css: getImageStyles(isFlexibleUi),
|
|
26
50
|
src: url,
|
|
27
51
|
"data-testid": `${testId}-image`
|
|
28
52
|
}),
|
|
29
53
|
errored: placeholder
|
|
30
54
|
});
|
|
31
55
|
return jsx("span", {
|
|
32
|
-
css:
|
|
33
|
-
height: gs(2.5),
|
|
34
|
-
width: gs(2),
|
|
35
|
-
display: 'flex',
|
|
36
|
-
alignItems: 'center',
|
|
37
|
-
justifyContent: 'center'
|
|
38
|
-
},
|
|
56
|
+
css: getSpanStyles(isFlexibleUi),
|
|
39
57
|
"data-testid": testId,
|
|
40
58
|
className: blockCardIconImageClassName
|
|
41
59
|
}, icon || image || placeholder);
|
package/dist/esm/constants.js
CHANGED
|
@@ -142,6 +142,9 @@ export var ActionName;
|
|
|
142
142
|
(function (ActionName) {
|
|
143
143
|
ActionName["DeleteAction"] = "DeleteAction";
|
|
144
144
|
ActionName["EditAction"] = "EditAction";
|
|
145
|
+
ActionName["PreviewAction"] = "PreviewAction";
|
|
146
|
+
ActionName["ViewAction"] = "ViewAction";
|
|
147
|
+
ActionName["DownloadAction"] = "DownloadAction";
|
|
145
148
|
ActionName["CustomAction"] = "CustomAction";
|
|
146
149
|
})(ActionName || (ActionName = {}));
|
|
147
150
|
|
|
@@ -67,7 +67,7 @@ var getServerActionProps = function getServerActionProps(jsonLd, action, handler
|
|
|
67
67
|
};
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
var getActionsFromJsonLd = function getActionsFromJsonLd(jsonLd) {
|
|
70
|
+
export var getActionsFromJsonLd = function getActionsFromJsonLd(jsonLd) {
|
|
71
71
|
var actions = jsonLd && jsonLd['schema:potentialAction'];
|
|
72
72
|
|
|
73
73
|
if (!actions) {
|
|
@@ -80,7 +80,6 @@ var getActionsFromJsonLd = function getActionsFromJsonLd(jsonLd) {
|
|
|
80
80
|
|
|
81
81
|
return actions;
|
|
82
82
|
};
|
|
83
|
-
|
|
84
83
|
export function extractActions(jsonLd, handler) {
|
|
85
84
|
var actions = getActionsFromJsonLd(jsonLd);
|
|
86
85
|
var clientActions = actions.filter(isClientAction);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getActionsFromJsonLd } from '../../common/actions/extractActions';
|
|
2
|
+
import { extractDownloadUrl } from '../../common/detail';
|
|
3
|
+
export var extractDownloadAction = function extractDownloadAction(data) {
|
|
4
|
+
var downloadActionExists = getActionsFromJsonLd(data).find(function (action) {
|
|
5
|
+
return action['@type'] === 'DownloadAction';
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
if (downloadActionExists) {
|
|
9
|
+
return {
|
|
10
|
+
downloadUrl: extractDownloadUrl(data)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return undefined;
|
|
15
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { extractDownloadUrl } from '../../common/detail';
|
|
2
|
+
import { extractPreview as extractPreviewData } from '@atlaskit/linking-common';
|
|
3
|
+
import { extractLink, extractProvider, extractTitle } from '@atlaskit/linking-common/extractors';
|
|
4
|
+
import { extractLinkIcon } from '../icon';
|
|
5
|
+
export var extractPreviewAction = function extractPreviewAction(response) {
|
|
6
|
+
var _extractPreviewData;
|
|
7
|
+
|
|
8
|
+
var data = response.data;
|
|
9
|
+
var src = (_extractPreviewData = extractPreviewData(data, 'web')) === null || _extractPreviewData === void 0 ? void 0 : _extractPreviewData.src;
|
|
10
|
+
|
|
11
|
+
if (src) {
|
|
12
|
+
var _extractProvider;
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
downloadUrl: extractDownloadUrl(data),
|
|
16
|
+
providerName: (_extractProvider = extractProvider(data)) === null || _extractProvider === void 0 ? void 0 : _extractProvider.text,
|
|
17
|
+
src: src,
|
|
18
|
+
title: extractTitle(data),
|
|
19
|
+
linkIcon: extractLinkIcon(response),
|
|
20
|
+
url: extractLink(data)
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { extractLink } from '@atlaskit/linking-common/extractors';
|
|
2
|
+
import { getActionsFromJsonLd } from '../../common/actions/extractActions';
|
|
3
|
+
export var extractViewAction = function extractViewAction(data) {
|
|
4
|
+
var viewActionExists = getActionsFromJsonLd(data).find(function (action) {
|
|
5
|
+
return action['@type'] === 'ViewAction';
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
if (viewActionExists) {
|
|
9
|
+
return {
|
|
10
|
+
viewUrl: extractLink(data)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return undefined;
|
|
15
|
+
};
|
|
@@ -3,11 +3,14 @@ import { extractLozenge } from '../common/lozenge';
|
|
|
3
3
|
import { extractLinkIcon } from './icon';
|
|
4
4
|
import { extractAttachmentCount, extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount, extractViewCount, extractReactCount, extractVoteCount, extractSourceBranch, extractTargetBranch, extractDueOn } from './utils';
|
|
5
5
|
import { extractPersonsUpdatedBy } from './collaboratorGroup';
|
|
6
|
-
import { extractPersonCreatedBy,
|
|
6
|
+
import { extractPersonCreatedBy, extractTitle, extractDateUpdated, extractDateCreated, extractLink } from '@atlaskit/linking-common/extractors';
|
|
7
7
|
import extractPriority from './extract-priority';
|
|
8
8
|
import extractProviderIcon from './icon/extract-provider-icon';
|
|
9
9
|
import extractPreview from './extract-preview';
|
|
10
10
|
import { extractLatestCommit } from './latest-commit';
|
|
11
|
+
import { extractPreviewAction } from './actions/extract-preview-action';
|
|
12
|
+
import { extractDownloadAction } from './actions/extract-download-action';
|
|
13
|
+
import { extractViewAction } from './actions/extract-view-action';
|
|
11
14
|
|
|
12
15
|
var extractFlexibleUiContext = function extractFlexibleUiContext(response, renderers) {
|
|
13
16
|
if (!response) {
|
|
@@ -27,6 +30,9 @@ var extractFlexibleUiContext = function extractFlexibleUiContext(response, rende
|
|
|
27
30
|
createdBy: extractCreatedBy(data),
|
|
28
31
|
createdOn: extractDateCreated(data),
|
|
29
32
|
dueOn: extractDueOn(data),
|
|
33
|
+
previewAction: extractPreviewAction(response),
|
|
34
|
+
viewAction: extractViewAction(data),
|
|
35
|
+
downloadAction: extractDownloadAction(data),
|
|
30
36
|
latestCommit: extractLatestCommit(data),
|
|
31
37
|
linkIcon: extractLinkIcon(response, renderers),
|
|
32
38
|
modifiedBy: extractModifiedBy(data),
|
|
@@ -7,4 +7,13 @@ import { useContext, createContext } from 'react';
|
|
|
7
7
|
export var FlexibleUiContext = /*#__PURE__*/createContext(undefined);
|
|
8
8
|
export var useFlexibleUiContext = function useFlexibleUiContext() {
|
|
9
9
|
return useContext(FlexibleUiContext);
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* This provides the data that will be used by Smart Links Flexible UI to populate it's
|
|
13
|
+
* underlying elements.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export var FlexibleUiAnalyticsContext = /*#__PURE__*/createContext(undefined);
|
|
17
|
+
export var useFlexibleUiAnalyticsContext = function useFlexibleUiAnalyticsContext() {
|
|
18
|
+
return useContext(FlexibleUiAnalyticsContext);
|
|
10
19
|
};
|
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
|
|
6
|
+
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; }
|
|
7
|
+
|
|
8
|
+
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; }
|
|
9
|
+
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import Action from '../index';
|
|
12
|
+
|
|
13
|
+
var DownloadAction = function DownloadAction(props) {
|
|
14
|
+
var appearance = props.appearance,
|
|
15
|
+
asDropDownItem = props.asDropDownItem,
|
|
16
|
+
downloadUrl = props.downloadUrl,
|
|
17
|
+
_onClick = props.onClick,
|
|
18
|
+
testId = props.testId,
|
|
19
|
+
url = props.url;
|
|
20
|
+
|
|
21
|
+
if (downloadUrl && url) {
|
|
22
|
+
var action = _objectSpread(_objectSpread({}, props), {}, {
|
|
23
|
+
onClick: function onClick() {
|
|
24
|
+
downloadFunction({
|
|
25
|
+
url: downloadUrl
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (_onClick) {
|
|
29
|
+
_onClick();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return /*#__PURE__*/React.createElement(Action, _extends({}, action, {
|
|
35
|
+
appearance: appearance,
|
|
36
|
+
asDropDownItem: asDropDownItem,
|
|
37
|
+
testId: testId
|
|
38
|
+
}));
|
|
39
|
+
} else {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
function downloadFunction(_x) {
|
|
45
|
+
return _downloadFunction.apply(this, arguments);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function _downloadFunction() {
|
|
49
|
+
_downloadFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
50
|
+
var url, isIE11, isSafari, iframeName, link, iframe;
|
|
51
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
52
|
+
while (1) {
|
|
53
|
+
switch (_context.prev = _context.next) {
|
|
54
|
+
case 0:
|
|
55
|
+
url = _ref.url;
|
|
56
|
+
|
|
57
|
+
if (url) {
|
|
58
|
+
_context.next = 3;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return _context.abrupt("return");
|
|
63
|
+
|
|
64
|
+
case 3:
|
|
65
|
+
isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
|
|
66
|
+
isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
67
|
+
iframeName = 'media-download-iframe';
|
|
68
|
+
link = document.createElement('a');
|
|
69
|
+
iframe = document.getElementById(iframeName);
|
|
70
|
+
|
|
71
|
+
if (!iframe) {
|
|
72
|
+
iframe = document.createElement('iframe');
|
|
73
|
+
iframe.style.display = 'none';
|
|
74
|
+
iframe.id = iframeName;
|
|
75
|
+
iframe.name = iframeName;
|
|
76
|
+
document.body.appendChild(iframe);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
link.href = url;
|
|
80
|
+
link.download = url;
|
|
81
|
+
link.target = isIE11 || isSafari ? '_blank' : iframeName;
|
|
82
|
+
document.body.appendChild(link);
|
|
83
|
+
link.click();
|
|
84
|
+
document.body.removeChild(link);
|
|
85
|
+
|
|
86
|
+
case 15:
|
|
87
|
+
case "end":
|
|
88
|
+
return _context.stop();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}, _callee);
|
|
92
|
+
}));
|
|
93
|
+
return _downloadFunction.apply(this, arguments);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default DownloadAction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|