@atlaskit/smart-card 17.7.0 → 17.7.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 17.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`123201c5105`](https://bitbucket.org/atlassian/atlassian-frontend/commits/123201c5105) - Add ability to add custom action item
8
+
3
9
  ## 17.7.0
4
10
 
5
11
  ### Minor Changes
@@ -156,6 +156,7 @@ exports.ActionName = ActionName;
156
156
 
157
157
  (function (ActionName) {
158
158
  ActionName["DeleteAction"] = "DeleteAction";
159
+ ActionName["CustomAction"] = "CustomAction";
159
160
  })(ActionName || (exports.ActionName = ActionName = {}));
160
161
 
161
162
  var IconType;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.7.0",
3
+ "version": "17.7.1",
4
4
  "sideEffects": false
5
5
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.DeleteAction = void 0;
6
+ exports.DeleteAction = exports.CustomAction = void 0;
7
7
 
8
8
  var _constants = require("../../../../constants");
9
9
 
@@ -15,4 +15,6 @@ var _utils = require("./utils");
15
15
  // UIActions infer that you do not need to get any data from the context.
16
16
  // DataActions infer that the action depends on the data from the context.
17
17
  var DeleteAction = (0, _utils.createUIAction)(_constants.ActionName.DeleteAction);
18
- exports.DeleteAction = DeleteAction;
18
+ exports.DeleteAction = DeleteAction;
19
+ var CustomAction = (0, _utils.createUIAction)(_constants.ActionName.CustomAction);
20
+ exports.CustomAction = CustomAction;
@@ -27,6 +27,8 @@ var _messages = require("../../../../messages");
27
27
 
28
28
  var _cross = _interopRequireDefault(require("@atlaskit/icon/glyph/cross"));
29
29
 
30
+ var _actionMappings;
31
+
30
32
  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); }
31
33
 
32
34
  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; }
@@ -35,7 +37,10 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
35
37
 
36
38
  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) { (0, _defineProperty2.default)(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; }
37
39
 
38
- var actionMappings = (0, _defineProperty2.default)({}, _constants.ActionName.DeleteAction, {
40
+ var actionMappings = (_actionMappings = {}, (0, _defineProperty2.default)(_actionMappings, _constants.ActionName.CustomAction, {
41
+ component: _action.default,
42
+ props: {}
43
+ }), (0, _defineProperty2.default)(_actionMappings, _constants.ActionName.DeleteAction, {
39
44
  component: _action.default,
40
45
  props: {
41
46
  testId: 'smart-action-delete-action',
@@ -45,7 +50,7 @@ var actionMappings = (0, _defineProperty2.default)({}, _constants.ActionName.Del
45
50
  }),
46
51
  toolTipMessage: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.delete)
47
52
  }
48
- });
53
+ }), _actionMappings);
49
54
 
50
55
  var getContextKey = function getContextKey(name) {
51
56
  // Attempt to predict context prop name in advance to reduce the amount of
@@ -131,6 +131,7 @@ export let ActionName;
131
131
 
132
132
  (function (ActionName) {
133
133
  ActionName["DeleteAction"] = "DeleteAction";
134
+ ActionName["CustomAction"] = "CustomAction";
134
135
  })(ActionName || (ActionName = {}));
135
136
 
136
137
  export let IconType;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.7.0",
3
+ "version": "17.7.1",
4
4
  "sideEffects": false
5
5
  }
@@ -5,4 +5,5 @@ import { createUIAction } from './utils'; // Attention: Keep the export name and
5
5
  // UIActions infer that you do not need to get any data from the context.
6
6
  // DataActions infer that the action depends on the data from the context.
7
7
 
8
- export const DeleteAction = createUIAction(ActionName.DeleteAction);
8
+ export const DeleteAction = createUIAction(ActionName.DeleteAction);
9
+ export const CustomAction = createUIAction(ActionName.CustomAction);
@@ -7,6 +7,10 @@ import { FormattedMessage } from 'react-intl-next';
7
7
  import { messages } from '../../../../messages';
8
8
  import CrossIcon from '@atlaskit/icon/glyph/cross';
9
9
  const actionMappings = {
10
+ [ActionName.CustomAction]: {
11
+ component: Action,
12
+ props: {}
13
+ },
10
14
  [ActionName.DeleteAction]: {
11
15
  component: Action,
12
16
  props: {
@@ -131,6 +131,7 @@ export var ActionName;
131
131
 
132
132
  (function (ActionName) {
133
133
  ActionName["DeleteAction"] = "DeleteAction";
134
+ ActionName["CustomAction"] = "CustomAction";
134
135
  })(ActionName || (ActionName = {}));
135
136
 
136
137
  export var IconType;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.7.0",
3
+ "version": "17.7.1",
4
4
  "sideEffects": false
5
5
  }
@@ -5,4 +5,5 @@ import { createUIAction } from './utils'; // Attention: Keep the export name and
5
5
  // UIActions infer that you do not need to get any data from the context.
6
6
  // DataActions infer that the action depends on the data from the context.
7
7
 
8
- export var DeleteAction = createUIAction(ActionName.DeleteAction);
8
+ export var DeleteAction = createUIAction(ActionName.DeleteAction);
9
+ export var CustomAction = createUIAction(ActionName.CustomAction);
@@ -1,6 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
 
4
+ var _actionMappings;
5
+
4
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; }
5
7
 
6
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; }
@@ -12,8 +14,10 @@ import Action from './action';
12
14
  import { FormattedMessage } from 'react-intl-next';
13
15
  import { messages } from '../../../../messages';
14
16
  import CrossIcon from '@atlaskit/icon/glyph/cross';
15
-
16
- var actionMappings = _defineProperty({}, ActionName.DeleteAction, {
17
+ var actionMappings = (_actionMappings = {}, _defineProperty(_actionMappings, ActionName.CustomAction, {
18
+ component: Action,
19
+ props: {}
20
+ }), _defineProperty(_actionMappings, ActionName.DeleteAction, {
17
21
  component: Action,
18
22
  props: {
19
23
  testId: 'smart-action-delete-action',
@@ -23,7 +27,7 @@ var actionMappings = _defineProperty({}, ActionName.DeleteAction, {
23
27
  }),
24
28
  toolTipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.delete)
25
29
  }
26
- });
30
+ }), _actionMappings);
27
31
 
28
32
  var getContextKey = function getContextKey(name) {
29
33
  // Attempt to predict context prop name in advance to reduce the amount of
@@ -101,7 +101,8 @@ export declare enum ElementName {
101
101
  * Flexible UI action (button)
102
102
  */
103
103
  export declare enum ActionName {
104
- DeleteAction = "DeleteAction"
104
+ DeleteAction = "DeleteAction",
105
+ CustomAction = "CustomAction"
105
106
  }
106
107
  /**
107
108
  * Flexible UI icons - each mapped to AK icons.
@@ -1,3 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { ActionProps } from './action/types';
3
3
  export declare const DeleteAction: import("react").FC<ActionProps>;
4
+ export declare const CustomAction: import("react").FC<ActionProps>;
@@ -1,4 +1,5 @@
1
1
  import { ActionName, ElementName, SmartLinkDirection, SmartLinkSize, SmartLinkStatus } from '../../../../constants';
2
+ import { ActionProps } from '../actions/action/types';
2
3
  export declare type BlockProps = {
3
4
  direction?: SmartLinkDirection;
4
5
  size?: SmartLinkSize;
@@ -10,10 +11,23 @@ export declare type ElementItem = {
10
11
  size?: SmartLinkSize;
11
12
  testId?: string;
12
13
  };
13
- export declare type ActionItem = {
14
- name: ActionName;
14
+ export declare type BaseActionItem = {
15
15
  testId?: string;
16
16
  hideContent?: boolean;
17
17
  hideIcon?: boolean;
18
18
  onClick: () => any;
19
19
  };
20
+ /**
21
+ * Customer can define named action item. Icon and label will be provided implicitly.
22
+ */
23
+ export declare type NamedActionItem = BaseActionItem & {
24
+ name: Exclude<ActionName, ActionName.CustomAction>;
25
+ };
26
+ /**
27
+ * Customer can define a custom action item. This will require them to specify
28
+ * either `icon` and `iconPosition` OR `content` OR both BUT not neither of those things.
29
+ */
30
+ export declare type CustomActionItem = BaseActionItem & {
31
+ name: ActionName.CustomAction;
32
+ } & ((Required<Pick<ActionProps, 'icon' | 'iconPosition'>> & Pick<ActionProps, 'content'>) | ((Required<Pick<ActionProps, 'content'>> & Pick<ActionProps, 'icon' | 'iconPosition'>) & Pick<ActionProps, 'tooltipMessage'>));
33
+ export declare type ActionItem = NamedActionItem | CustomActionItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.7.0",
3
+ "version": "17.7.1",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"