@atlaskit/smart-card 17.2.0 → 17.2.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.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/FlexibleCard/components/actions/{delete-action → action}/index.js +40 -25
- package/dist/cjs/view/FlexibleCard/components/actions/{types.js → action/types.js} +0 -0
- package/dist/cjs/view/FlexibleCard/components/actions/index.js +3 -1
- package/dist/cjs/view/FlexibleCard/components/actions/utils.js +34 -6
- package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/FlexibleCard/components/actions/{delete-action → action}/index.js +31 -15
- package/dist/es2019/view/FlexibleCard/components/actions/{types.js → action/types.js} +0 -0
- package/dist/es2019/view/FlexibleCard/components/actions/index.js +5 -3
- package/dist/es2019/view/FlexibleCard/components/actions/utils.js +27 -4
- package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/FlexibleCard/components/actions/action/index.js +82 -0
- package/dist/esm/view/FlexibleCard/components/actions/{types.js → action/types.js} +0 -0
- package/dist/esm/view/FlexibleCard/components/actions/index.js +5 -3
- package/dist/esm/view/FlexibleCard/components/actions/utils.js +26 -4
- package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +1 -1
- package/dist/types/view/FlexibleCard/components/actions/action/index.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/actions/action/types.d.ts +18 -0
- package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -1
- package/dist/types/view/FlexibleCard/components/actions/utils.d.ts +2 -1
- package/package.json +1 -1
- package/dist/esm/view/FlexibleCard/components/actions/delete-action/index.js +0 -64
- package/dist/types/view/FlexibleCard/components/actions/delete-action/index.d.ts +0 -5
- package/dist/types/view/FlexibleCard/components/actions/types.d.ts +0 -10
package/CHANGELOG.md
CHANGED
package/dist/cjs/version.json
CHANGED
|
@@ -11,22 +11,16 @@ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/hel
|
|
|
11
11
|
|
|
12
12
|
var _react = _interopRequireDefault(require("react"));
|
|
13
13
|
|
|
14
|
-
var _reactIntlNext = require("react-intl-next");
|
|
15
|
-
|
|
16
14
|
var _core = require("@emotion/core");
|
|
17
15
|
|
|
18
16
|
var _customThemeButton = _interopRequireDefault(require("@atlaskit/button/custom-theme-button"));
|
|
19
17
|
|
|
20
|
-
var _cross = _interopRequireDefault(require("@atlaskit/icon/glyph/cross"));
|
|
21
|
-
|
|
22
18
|
var _constants = require("../../../../../constants");
|
|
23
19
|
|
|
24
20
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
25
21
|
|
|
26
22
|
var _utils = require("../../utils");
|
|
27
23
|
|
|
28
|
-
var _messages = require("../../../../../messages");
|
|
29
|
-
|
|
30
24
|
var _token = require("../../../../../utils/token");
|
|
31
25
|
|
|
32
26
|
var _utils2 = require("../../../../../utils");
|
|
@@ -46,38 +40,59 @@ var getWidth = function getWidth(size) {
|
|
|
46
40
|
}
|
|
47
41
|
};
|
|
48
42
|
|
|
49
|
-
var
|
|
43
|
+
var getIconStyles = function getIconStyles(size) {
|
|
50
44
|
return (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n ", ";\n"])), _token.tokens.actionIcon, (0, _utils.getIconSizeStyles)(getWidth(size)));
|
|
51
45
|
};
|
|
52
46
|
|
|
53
|
-
var
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
47
|
+
var ActionIcon = function ActionIcon(_ref) {
|
|
48
|
+
var size = _ref.size,
|
|
49
|
+
testId = _ref.testId,
|
|
50
|
+
icon = _ref.icon;
|
|
51
|
+
return (0, _core.jsx)("span", {
|
|
52
|
+
css: getIconStyles(size),
|
|
53
|
+
"data-testid": "".concat(testId, "-icon")
|
|
54
|
+
}, icon);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
var Action = function Action(_ref2) {
|
|
58
|
+
var _ref2$appearance = _ref2.appearance,
|
|
59
|
+
appearance = _ref2$appearance === void 0 ? 'subtle' : _ref2$appearance,
|
|
60
|
+
content = _ref2.content,
|
|
61
|
+
onClick = _ref2.onClick,
|
|
62
|
+
_ref2$size = _ref2.size,
|
|
63
|
+
size = _ref2$size === void 0 ? _constants.SmartLinkSize.Medium : _ref2$size,
|
|
64
|
+
_ref2$testId = _ref2.testId,
|
|
65
|
+
testId = _ref2$testId === void 0 ? 'smart-action' : _ref2$testId,
|
|
66
|
+
icon = _ref2.icon,
|
|
67
|
+
_ref2$iconPosition = _ref2.iconPosition,
|
|
68
|
+
iconPosition = _ref2$iconPosition === void 0 ? 'before' : _ref2$iconPosition,
|
|
69
|
+
tooltipMessage = _ref2.tooltipMessage;
|
|
62
70
|
|
|
63
71
|
if (!onClick) {
|
|
64
72
|
return null;
|
|
65
73
|
}
|
|
66
74
|
|
|
75
|
+
var iconBefore = iconPosition === 'before' ? (0, _core.jsx)(ActionIcon, {
|
|
76
|
+
size: size,
|
|
77
|
+
testId: testId,
|
|
78
|
+
icon: icon
|
|
79
|
+
}) : undefined;
|
|
80
|
+
var iconAfter = iconPosition === 'after' ? (0, _core.jsx)(ActionIcon, {
|
|
81
|
+
size: size,
|
|
82
|
+
testId: testId,
|
|
83
|
+
icon: icon
|
|
84
|
+
}) : undefined;
|
|
67
85
|
return (0, _core.jsx)(_tooltip.default, {
|
|
68
|
-
content:
|
|
86
|
+
content: tooltipMessage
|
|
69
87
|
}, (0, _core.jsx)(_customThemeButton.default, {
|
|
70
88
|
spacing: "none",
|
|
71
89
|
appearance: appearance,
|
|
72
90
|
testId: testId,
|
|
73
|
-
onClick: (0, _utils2.handleOnClick)(onClick)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}, (0, _core.jsx)(_cross.default, {
|
|
78
|
-
label: "Delete"
|
|
79
|
-
}))));
|
|
91
|
+
onClick: (0, _utils2.handleOnClick)(onClick),
|
|
92
|
+
iconBefore: iconBefore,
|
|
93
|
+
iconAfter: iconAfter
|
|
94
|
+
}, content));
|
|
80
95
|
};
|
|
81
96
|
|
|
82
|
-
var _default =
|
|
97
|
+
var _default = Action;
|
|
83
98
|
exports.default = _default;
|
|
File without changes
|
|
@@ -12,5 +12,7 @@ var _utils = require("./utils");
|
|
|
12
12
|
// Attention: Keep the export name and action name the same.
|
|
13
13
|
// This will help reducing the code for mapping action inside
|
|
14
14
|
// createAction and renderActionItems
|
|
15
|
-
|
|
15
|
+
// UIActions infer that you do not need to get any data from the context.
|
|
16
|
+
// DataActions infer that the action depends on the data from the context.
|
|
17
|
+
var DeleteAction = (0, _utils.createUIAction)(_constants.ActionName.DeleteAction);
|
|
16
18
|
exports.DeleteAction = DeleteAction;
|
|
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports.
|
|
10
|
+
exports.createUIAction = exports.createDataAction = void 0;
|
|
11
11
|
|
|
12
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
13
|
|
|
@@ -19,14 +19,27 @@ var _flexibleUiContext = require("../../../../state/flexible-ui-context");
|
|
|
19
19
|
|
|
20
20
|
var _react = _interopRequireWildcard(require("react"));
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _action = _interopRequireDefault(require("./action"));
|
|
23
|
+
|
|
24
|
+
var _reactIntlNext = require("react-intl-next");
|
|
25
|
+
|
|
26
|
+
var _messages = require("../../../../messages");
|
|
27
|
+
|
|
28
|
+
var _cross = _interopRequireDefault(require("@atlaskit/icon/glyph/cross"));
|
|
23
29
|
|
|
24
30
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
31
|
|
|
26
32
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
33
|
|
|
28
34
|
var actionMappings = (0, _defineProperty2.default)({}, _constants.ActionName.DeleteAction, {
|
|
29
|
-
component:
|
|
35
|
+
component: _action.default,
|
|
36
|
+
props: {
|
|
37
|
+
testId: 'smart-action-delete-action',
|
|
38
|
+
icon: /*#__PURE__*/_react.default.createElement(_cross.default, {
|
|
39
|
+
label: "Delete"
|
|
40
|
+
}),
|
|
41
|
+
toolTipMessage: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.delete)
|
|
42
|
+
}
|
|
30
43
|
});
|
|
31
44
|
|
|
32
45
|
var getContextKey = function getContextKey(name) {
|
|
@@ -43,13 +56,12 @@ var getActionData = function getActionData(actionName, contextKey, context) {
|
|
|
43
56
|
var data = context[contextKey];
|
|
44
57
|
|
|
45
58
|
switch (actionName) {
|
|
46
|
-
case _constants.ActionName.DeleteAction:
|
|
47
59
|
default:
|
|
48
60
|
return data;
|
|
49
61
|
}
|
|
50
62
|
};
|
|
51
63
|
|
|
52
|
-
var
|
|
64
|
+
var createDataAction = function createDataAction(name) {
|
|
53
65
|
var _ref = actionMappings[name] || {},
|
|
54
66
|
BaseAction = _ref.component,
|
|
55
67
|
props = _ref.props;
|
|
@@ -67,4 +79,20 @@ var createAction = function createAction(name) {
|
|
|
67
79
|
};
|
|
68
80
|
};
|
|
69
81
|
|
|
70
|
-
exports.
|
|
82
|
+
exports.createDataAction = createDataAction;
|
|
83
|
+
|
|
84
|
+
var createUIAction = function createUIAction(name) {
|
|
85
|
+
var _ref2 = actionMappings[name] || {},
|
|
86
|
+
BaseAction = _ref2.component,
|
|
87
|
+
props = _ref2.props;
|
|
88
|
+
|
|
89
|
+
if (!BaseAction) {
|
|
90
|
+
throw Error("Action ".concat(name, " does not exist."));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return function (overrides) {
|
|
94
|
+
return /*#__PURE__*/_react.default.createElement(BaseAction, (0, _extends2.default)({}, props, overrides));
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
exports.createUIAction = createUIAction;
|
|
@@ -19,7 +19,7 @@ var _constants = require("../../../../../constants");
|
|
|
19
19
|
|
|
20
20
|
var _templateObject;
|
|
21
21
|
|
|
22
|
-
var styles = (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: inline-flex;\n line-height:
|
|
22
|
+
var styles = (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: inline-flex;\n line-height: 1rem;\n"])));
|
|
23
23
|
|
|
24
24
|
var ActionGroup = function ActionGroup(_ref) {
|
|
25
25
|
var _ref$items = _ref.items,
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { FormattedMessage } from 'react-intl-next';
|
|
4
3
|
import { css, jsx } from '@emotion/core';
|
|
5
4
|
import Button from '@atlaskit/button/custom-theme-button';
|
|
6
|
-
import CrossIcon from '@atlaskit/icon/glyph/cross';
|
|
7
5
|
import { SmartLinkSize } from '../../../../../constants';
|
|
8
6
|
import Tooltip from '@atlaskit/tooltip';
|
|
9
7
|
import { getIconSizeStyles } from '../../utils';
|
|
10
|
-
import { messages } from '../../../../../messages';
|
|
11
8
|
import { tokens } from '../../../../../utils/token';
|
|
12
9
|
import { handleOnClick } from '../../../../../utils';
|
|
13
10
|
|
|
@@ -24,35 +21,54 @@ const getWidth = size => {
|
|
|
24
21
|
}
|
|
25
22
|
};
|
|
26
23
|
|
|
27
|
-
const
|
|
24
|
+
const getIconStyles = size => css`
|
|
28
25
|
color: ${tokens.actionIcon};
|
|
29
26
|
${getIconSizeStyles(getWidth(size))};
|
|
30
27
|
`;
|
|
31
28
|
|
|
32
|
-
const
|
|
29
|
+
const ActionIcon = ({
|
|
30
|
+
size,
|
|
31
|
+
testId,
|
|
32
|
+
icon
|
|
33
|
+
}) => jsx("span", {
|
|
34
|
+
css: getIconStyles(size),
|
|
35
|
+
"data-testid": `${testId}-icon`
|
|
36
|
+
}, icon);
|
|
37
|
+
|
|
38
|
+
const Action = ({
|
|
33
39
|
appearance = 'subtle',
|
|
34
40
|
content,
|
|
35
41
|
onClick,
|
|
36
42
|
size = SmartLinkSize.Medium,
|
|
37
|
-
testId = 'smart-action
|
|
43
|
+
testId = 'smart-action',
|
|
44
|
+
icon,
|
|
45
|
+
iconPosition = 'before',
|
|
46
|
+
tooltipMessage
|
|
38
47
|
}) => {
|
|
39
48
|
if (!onClick) {
|
|
40
49
|
return null;
|
|
41
50
|
}
|
|
42
51
|
|
|
52
|
+
const iconBefore = iconPosition === 'before' ? jsx(ActionIcon, {
|
|
53
|
+
size: size,
|
|
54
|
+
testId: testId,
|
|
55
|
+
icon: icon
|
|
56
|
+
}) : undefined;
|
|
57
|
+
const iconAfter = iconPosition === 'after' ? jsx(ActionIcon, {
|
|
58
|
+
size: size,
|
|
59
|
+
testId: testId,
|
|
60
|
+
icon: icon
|
|
61
|
+
}) : undefined;
|
|
43
62
|
return jsx(Tooltip, {
|
|
44
|
-
content:
|
|
63
|
+
content: tooltipMessage
|
|
45
64
|
}, jsx(Button, {
|
|
46
65
|
spacing: "none",
|
|
47
66
|
appearance: appearance,
|
|
48
67
|
testId: testId,
|
|
49
|
-
onClick: handleOnClick(onClick)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}, jsx(CrossIcon, {
|
|
54
|
-
label: "Delete"
|
|
55
|
-
}))));
|
|
68
|
+
onClick: handleOnClick(onClick),
|
|
69
|
+
iconBefore: iconBefore,
|
|
70
|
+
iconAfter: iconAfter
|
|
71
|
+
}, content));
|
|
56
72
|
};
|
|
57
73
|
|
|
58
|
-
export default
|
|
74
|
+
export default Action;
|
|
File without changes
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ActionName } from '../../../../constants';
|
|
2
|
-
import {
|
|
3
|
-
// Attention: Keep the export name and action name the same.
|
|
2
|
+
import { createUIAction } from './utils'; // Attention: Keep the export name and action name the same.
|
|
4
3
|
// This will help reducing the code for mapping action inside
|
|
5
4
|
// createAction and renderActionItems
|
|
6
|
-
|
|
5
|
+
// UIActions infer that you do not need to get any data from the context.
|
|
6
|
+
// DataActions infer that the action depends on the data from the context.
|
|
7
|
+
|
|
8
|
+
export const DeleteAction = createUIAction(ActionName.DeleteAction);
|
|
@@ -2,10 +2,20 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import { ActionName } from '../../../../constants';
|
|
3
3
|
import { FlexibleUiContext } from '../../../../state/flexible-ui-context';
|
|
4
4
|
import React, { useContext } from 'react';
|
|
5
|
-
import
|
|
5
|
+
import Action from './action';
|
|
6
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
7
|
+
import { messages } from '../../../../messages';
|
|
8
|
+
import CrossIcon from '@atlaskit/icon/glyph/cross';
|
|
6
9
|
const actionMappings = {
|
|
7
10
|
[ActionName.DeleteAction]: {
|
|
8
|
-
component:
|
|
11
|
+
component: Action,
|
|
12
|
+
props: {
|
|
13
|
+
testId: 'smart-action-delete-action',
|
|
14
|
+
icon: /*#__PURE__*/React.createElement(CrossIcon, {
|
|
15
|
+
label: "Delete"
|
|
16
|
+
}),
|
|
17
|
+
toolTipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.delete)
|
|
18
|
+
}
|
|
9
19
|
}
|
|
10
20
|
};
|
|
11
21
|
|
|
@@ -23,13 +33,12 @@ const getActionData = (actionName, contextKey, context) => {
|
|
|
23
33
|
const data = context[contextKey];
|
|
24
34
|
|
|
25
35
|
switch (actionName) {
|
|
26
|
-
case ActionName.DeleteAction:
|
|
27
36
|
default:
|
|
28
37
|
return data;
|
|
29
38
|
}
|
|
30
39
|
};
|
|
31
40
|
|
|
32
|
-
export const
|
|
41
|
+
export const createDataAction = name => {
|
|
33
42
|
const {
|
|
34
43
|
component: BaseAction,
|
|
35
44
|
props
|
|
@@ -45,4 +54,18 @@ export const createAction = name => {
|
|
|
45
54
|
const data = getActionData(name, contextKey, context);
|
|
46
55
|
return /*#__PURE__*/React.createElement(BaseAction, _extends({}, props, data, overrides));
|
|
47
56
|
};
|
|
57
|
+
};
|
|
58
|
+
export const createUIAction = name => {
|
|
59
|
+
const {
|
|
60
|
+
component: BaseAction,
|
|
61
|
+
props
|
|
62
|
+
} = actionMappings[name] || {};
|
|
63
|
+
|
|
64
|
+
if (!BaseAction) {
|
|
65
|
+
throw Error(`Action ${name} does not exist.`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return overrides => {
|
|
69
|
+
return /*#__PURE__*/React.createElement(BaseAction, _extends({}, props, overrides));
|
|
70
|
+
};
|
|
48
71
|
};
|
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject;
|
|
4
|
+
|
|
5
|
+
/** @jsx jsx */
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { css, jsx } from '@emotion/core';
|
|
8
|
+
import Button from '@atlaskit/button/custom-theme-button';
|
|
9
|
+
import { SmartLinkSize } from '../../../../../constants';
|
|
10
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
11
|
+
import { getIconSizeStyles } from '../../utils';
|
|
12
|
+
import { tokens } from '../../../../../utils/token';
|
|
13
|
+
import { handleOnClick } from '../../../../../utils';
|
|
14
|
+
|
|
15
|
+
var getWidth = function getWidth(size) {
|
|
16
|
+
switch (size) {
|
|
17
|
+
case SmartLinkSize.XLarge:
|
|
18
|
+
case SmartLinkSize.Large:
|
|
19
|
+
return '1.5rem';
|
|
20
|
+
|
|
21
|
+
case SmartLinkSize.Medium:
|
|
22
|
+
case SmartLinkSize.Small:
|
|
23
|
+
default:
|
|
24
|
+
return '1rem';
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var getIconStyles = function getIconStyles(size) {
|
|
29
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n ", ";\n"])), tokens.actionIcon, getIconSizeStyles(getWidth(size)));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
var ActionIcon = function ActionIcon(_ref) {
|
|
33
|
+
var size = _ref.size,
|
|
34
|
+
testId = _ref.testId,
|
|
35
|
+
icon = _ref.icon;
|
|
36
|
+
return jsx("span", {
|
|
37
|
+
css: getIconStyles(size),
|
|
38
|
+
"data-testid": "".concat(testId, "-icon")
|
|
39
|
+
}, icon);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
var Action = function Action(_ref2) {
|
|
43
|
+
var _ref2$appearance = _ref2.appearance,
|
|
44
|
+
appearance = _ref2$appearance === void 0 ? 'subtle' : _ref2$appearance,
|
|
45
|
+
content = _ref2.content,
|
|
46
|
+
onClick = _ref2.onClick,
|
|
47
|
+
_ref2$size = _ref2.size,
|
|
48
|
+
size = _ref2$size === void 0 ? SmartLinkSize.Medium : _ref2$size,
|
|
49
|
+
_ref2$testId = _ref2.testId,
|
|
50
|
+
testId = _ref2$testId === void 0 ? 'smart-action' : _ref2$testId,
|
|
51
|
+
icon = _ref2.icon,
|
|
52
|
+
_ref2$iconPosition = _ref2.iconPosition,
|
|
53
|
+
iconPosition = _ref2$iconPosition === void 0 ? 'before' : _ref2$iconPosition,
|
|
54
|
+
tooltipMessage = _ref2.tooltipMessage;
|
|
55
|
+
|
|
56
|
+
if (!onClick) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
var iconBefore = iconPosition === 'before' ? jsx(ActionIcon, {
|
|
61
|
+
size: size,
|
|
62
|
+
testId: testId,
|
|
63
|
+
icon: icon
|
|
64
|
+
}) : undefined;
|
|
65
|
+
var iconAfter = iconPosition === 'after' ? jsx(ActionIcon, {
|
|
66
|
+
size: size,
|
|
67
|
+
testId: testId,
|
|
68
|
+
icon: icon
|
|
69
|
+
}) : undefined;
|
|
70
|
+
return jsx(Tooltip, {
|
|
71
|
+
content: tooltipMessage
|
|
72
|
+
}, jsx(Button, {
|
|
73
|
+
spacing: "none",
|
|
74
|
+
appearance: appearance,
|
|
75
|
+
testId: testId,
|
|
76
|
+
onClick: handleOnClick(onClick),
|
|
77
|
+
iconBefore: iconBefore,
|
|
78
|
+
iconAfter: iconAfter
|
|
79
|
+
}, content));
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default Action;
|
|
File without changes
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ActionName } from '../../../../constants';
|
|
2
|
-
import {
|
|
3
|
-
// Attention: Keep the export name and action name the same.
|
|
2
|
+
import { createUIAction } from './utils'; // Attention: Keep the export name and action name the same.
|
|
4
3
|
// This will help reducing the code for mapping action inside
|
|
5
4
|
// createAction and renderActionItems
|
|
6
|
-
|
|
5
|
+
// UIActions infer that you do not need to get any data from the context.
|
|
6
|
+
// DataActions infer that the action depends on the data from the context.
|
|
7
|
+
|
|
8
|
+
export var DeleteAction = createUIAction(ActionName.DeleteAction);
|
|
@@ -3,10 +3,20 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
import { ActionName } from '../../../../constants';
|
|
4
4
|
import { FlexibleUiContext } from '../../../../state/flexible-ui-context';
|
|
5
5
|
import React, { useContext } from 'react';
|
|
6
|
-
import
|
|
6
|
+
import Action from './action';
|
|
7
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
8
|
+
import { messages } from '../../../../messages';
|
|
9
|
+
import CrossIcon from '@atlaskit/icon/glyph/cross';
|
|
7
10
|
|
|
8
11
|
var actionMappings = _defineProperty({}, ActionName.DeleteAction, {
|
|
9
|
-
component:
|
|
12
|
+
component: Action,
|
|
13
|
+
props: {
|
|
14
|
+
testId: 'smart-action-delete-action',
|
|
15
|
+
icon: /*#__PURE__*/React.createElement(CrossIcon, {
|
|
16
|
+
label: "Delete"
|
|
17
|
+
}),
|
|
18
|
+
toolTipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.delete)
|
|
19
|
+
}
|
|
10
20
|
});
|
|
11
21
|
|
|
12
22
|
var getContextKey = function getContextKey(name) {
|
|
@@ -23,13 +33,12 @@ var getActionData = function getActionData(actionName, contextKey, context) {
|
|
|
23
33
|
var data = context[contextKey];
|
|
24
34
|
|
|
25
35
|
switch (actionName) {
|
|
26
|
-
case ActionName.DeleteAction:
|
|
27
36
|
default:
|
|
28
37
|
return data;
|
|
29
38
|
}
|
|
30
39
|
};
|
|
31
40
|
|
|
32
|
-
export var
|
|
41
|
+
export var createDataAction = function createDataAction(name) {
|
|
33
42
|
var _ref = actionMappings[name] || {},
|
|
34
43
|
BaseAction = _ref.component,
|
|
35
44
|
props = _ref.props;
|
|
@@ -45,4 +54,17 @@ export var createAction = function createAction(name) {
|
|
|
45
54
|
var data = getActionData(name, contextKey, context);
|
|
46
55
|
return /*#__PURE__*/React.createElement(BaseAction, _extends({}, props, data, overrides));
|
|
47
56
|
};
|
|
57
|
+
};
|
|
58
|
+
export var createUIAction = function createUIAction(name) {
|
|
59
|
+
var _ref2 = actionMappings[name] || {},
|
|
60
|
+
BaseAction = _ref2.component,
|
|
61
|
+
props = _ref2.props;
|
|
62
|
+
|
|
63
|
+
if (!BaseAction) {
|
|
64
|
+
throw Error("Action ".concat(name, " does not exist."));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return function (overrides) {
|
|
68
|
+
return /*#__PURE__*/React.createElement(BaseAction, _extends({}, props, overrides));
|
|
69
|
+
};
|
|
48
70
|
};
|
|
@@ -7,7 +7,7 @@ import { css, jsx } from '@emotion/core';
|
|
|
7
7
|
import ButtonGroup from '@atlaskit/button/button-group';
|
|
8
8
|
import { renderActionItems } from '../utils';
|
|
9
9
|
import { SmartLinkSize } from '../../../../../constants';
|
|
10
|
-
var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n line-height:
|
|
10
|
+
var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n line-height: 1rem;\n"])));
|
|
11
11
|
|
|
12
12
|
var ActionGroup = function ActionGroup(_ref) {
|
|
13
13
|
var _ref$items = _ref.items,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SmartLinkSize } from '../../../../../constants';
|
|
2
|
+
import { Appearance } from '@atlaskit/button/types';
|
|
3
|
+
import { ReactChild } from 'react';
|
|
4
|
+
export declare type ActionProps = {
|
|
5
|
+
size?: SmartLinkSize;
|
|
6
|
+
testId?: string;
|
|
7
|
+
content?: React.ReactNode;
|
|
8
|
+
appearance?: Appearance;
|
|
9
|
+
onClick: () => any;
|
|
10
|
+
icon?: ReactChild;
|
|
11
|
+
iconPosition?: 'before' | 'after';
|
|
12
|
+
tooltipMessage?: React.ReactNode;
|
|
13
|
+
};
|
|
14
|
+
export declare type ActionIconProps = {
|
|
15
|
+
size?: SmartLinkSize;
|
|
16
|
+
testId?: string;
|
|
17
|
+
icon?: ReactChild;
|
|
18
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { ActionName } from '../../../../constants';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const createDataAction: <P extends {}>(name: ActionName) => React.FC<P>;
|
|
4
|
+
export declare const createUIAction: <P extends {}>(name: ActionName) => React.FC<P>;
|
package/package.json
CHANGED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
|
|
3
|
-
var _templateObject;
|
|
4
|
-
|
|
5
|
-
/** @jsx jsx */
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import { FormattedMessage } from 'react-intl-next';
|
|
8
|
-
import { css, jsx } from '@emotion/core';
|
|
9
|
-
import Button from '@atlaskit/button/custom-theme-button';
|
|
10
|
-
import CrossIcon from '@atlaskit/icon/glyph/cross';
|
|
11
|
-
import { SmartLinkSize } from '../../../../../constants';
|
|
12
|
-
import Tooltip from '@atlaskit/tooltip';
|
|
13
|
-
import { getIconSizeStyles } from '../../utils';
|
|
14
|
-
import { messages } from '../../../../../messages';
|
|
15
|
-
import { tokens } from '../../../../../utils/token';
|
|
16
|
-
import { handleOnClick } from '../../../../../utils';
|
|
17
|
-
|
|
18
|
-
var getWidth = function getWidth(size) {
|
|
19
|
-
switch (size) {
|
|
20
|
-
case SmartLinkSize.XLarge:
|
|
21
|
-
case SmartLinkSize.Large:
|
|
22
|
-
return '1.5rem';
|
|
23
|
-
|
|
24
|
-
case SmartLinkSize.Medium:
|
|
25
|
-
case SmartLinkSize.Small:
|
|
26
|
-
default:
|
|
27
|
-
return '1rem';
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
var getStyles = function getStyles(size) {
|
|
32
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n ", ";\n"])), tokens.actionIcon, getIconSizeStyles(getWidth(size)));
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
var DeleteAction = function DeleteAction(_ref) {
|
|
36
|
-
var _ref$appearance = _ref.appearance,
|
|
37
|
-
appearance = _ref$appearance === void 0 ? 'subtle' : _ref$appearance,
|
|
38
|
-
content = _ref.content,
|
|
39
|
-
onClick = _ref.onClick,
|
|
40
|
-
_ref$size = _ref.size,
|
|
41
|
-
size = _ref$size === void 0 ? SmartLinkSize.Medium : _ref$size,
|
|
42
|
-
_ref$testId = _ref.testId,
|
|
43
|
-
testId = _ref$testId === void 0 ? 'smart-action-delete-action' : _ref$testId;
|
|
44
|
-
|
|
45
|
-
if (!onClick) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return jsx(Tooltip, {
|
|
50
|
-
content: jsx(FormattedMessage, messages.delete)
|
|
51
|
-
}, jsx(Button, {
|
|
52
|
-
spacing: "none",
|
|
53
|
-
appearance: appearance,
|
|
54
|
-
testId: testId,
|
|
55
|
-
onClick: handleOnClick(onClick)
|
|
56
|
-
}, content || jsx("span", {
|
|
57
|
-
css: getStyles(size),
|
|
58
|
-
"data-testid": "".concat(testId, "-icon")
|
|
59
|
-
}, jsx(CrossIcon, {
|
|
60
|
-
label: "Delete"
|
|
61
|
-
}))));
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export default DeleteAction;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { SmartLinkSize } from '../../../../constants';
|
|
3
|
-
import { Appearance } from '@atlaskit/button/types';
|
|
4
|
-
export declare type ActionProps = {
|
|
5
|
-
size?: SmartLinkSize;
|
|
6
|
-
testId?: string;
|
|
7
|
-
content?: React.ReactNode;
|
|
8
|
-
appearance?: Appearance;
|
|
9
|
-
onClick: () => any;
|
|
10
|
-
};
|