@atlaskit/smart-card 23.13.2 → 23.14.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 (34) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/version.json +1 -1
  3. package/dist/cjs/view/CardWithUrl/component.js +3 -2
  4. package/dist/cjs/view/CardWithUrl/loader.js +2 -0
  5. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +88 -0
  6. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +90 -42
  7. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +5 -69
  8. package/dist/cjs/view/FlexibleCard/index.js +3 -1
  9. package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +27 -25
  10. package/dist/es2019/version.json +1 -1
  11. package/dist/es2019/view/CardWithUrl/component.js +3 -2
  12. package/dist/es2019/view/CardWithUrl/loader.js +2 -0
  13. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +64 -0
  14. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +75 -34
  15. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +3 -56
  16. package/dist/es2019/view/FlexibleCard/index.js +2 -2
  17. package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +24 -22
  18. package/dist/esm/version.json +1 -1
  19. package/dist/esm/view/CardWithUrl/component.js +3 -2
  20. package/dist/esm/view/CardWithUrl/loader.js +2 -0
  21. package/dist/esm/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +69 -0
  22. package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +89 -42
  23. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +4 -66
  24. package/dist/esm/view/FlexibleCard/index.js +4 -2
  25. package/dist/esm/view/HoverCard/components/HoverCardComponent.js +27 -25
  26. package/dist/types/view/Card/index.d.ts +1 -1
  27. package/dist/types/view/Card/types.d.ts +1 -0
  28. package/dist/types/view/CardWithUrl/component.d.ts +1 -1
  29. package/dist/types/view/CardWithUrl/types.d.ts +1 -0
  30. package/dist/types/view/FlexibleCard/components/blocks/action-group/action-group-item/index.d.ts +12 -0
  31. package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +2 -3
  32. package/package.json +2 -2
  33. package/report.api.md +3 -0
  34. package/tmp/api-report-tmp.d.ts +3 -1
@@ -3,23 +3,18 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
5
5
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
- var _excluded = ["name"],
7
- _excluded2 = ["name", "hideContent", "hideIcon", "onClick"];
6
+ var _excluded = ["name"];
8
7
 
9
8
  var _ElementDisplaySchema, _templateObject, _templateObject2, _templateObject3, _templateObject4;
10
9
 
11
- 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; }
12
-
13
- 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; }
14
-
15
10
  import React from 'react';
16
11
  import { css } from '@emotion/react';
17
12
  import { ElementName, SmartLinkDirection, SmartLinkSize } from '../../../../constants';
18
13
  import * as Elements from '../elements';
19
- import * as Actions from '../actions';
20
14
  import { isFlexibleUiElement } from '../../../../utils/flexible';
21
15
  import ActionGroup from './action-group';
22
- import ElementGroup from './element-group';
16
+ import ElementGroup from './element-group'; // Determine whether the element can be display as inline/block.
17
+
23
18
  export var ElementDisplaySchema = (_ElementDisplaySchema = {}, _defineProperty(_ElementDisplaySchema, ElementName.AttachmentCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.AuthorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ChecklistProgress, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CollaboratorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CommentCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ViewCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ReactCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.VoteCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.DueOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.LatestCommit, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.LinkIcon, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Preview, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.Priority, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ProgrammingLanguage, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Provider, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Snippet, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.SourceBranch, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.State, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.SubscriberCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.TargetBranch, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Title, ['inline']), _ElementDisplaySchema);
24
19
 
25
20
  var getDirectionStyles = function getDirectionStyles(direction) {
@@ -64,7 +59,7 @@ var isElementDisplayValid = function isElementDisplayValid(name, display) {
64
59
  return (_ElementDisplaySchema2 = (_ElementDisplaySchema3 = ElementDisplaySchema[name]) === null || _ElementDisplaySchema3 === void 0 ? void 0 : _ElementDisplaySchema3.includes(display)) !== null && _ElementDisplaySchema2 !== void 0 ? _ElementDisplaySchema2 : false;
65
60
  };
66
61
 
67
- var isJSXElementNull = function isJSXElementNull(children) {
62
+ export var isJSXElementNull = function isJSXElementNull(children) {
68
63
  return Boolean(children.type() === null);
69
64
  };
70
65
 
@@ -111,61 +106,4 @@ export var renderElementItems = function renderElementItems() {
111
106
  if (elements.length) {
112
107
  return elements;
113
108
  }
114
- };
115
- export var renderActionItems = function renderActionItems() {
116
- var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
117
- var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : SmartLinkSize.Medium;
118
- var appearance = arguments.length > 2 ? arguments[2] : undefined;
119
- var asDropDownItems = arguments.length > 3 ? arguments[3] : undefined;
120
- var onActionItemClick = arguments.length > 4 ? arguments[4] : undefined;
121
- var actions = items.reduce(function (acc, curr, idx) {
122
- var name = curr.name,
123
- hideContent = curr.hideContent,
124
- hideIcon = curr.hideIcon,
125
- onClick = curr.onClick,
126
- props = _objectWithoutProperties(curr, _excluded2);
127
-
128
- var Action = Actions[name];
129
-
130
- var actionProps = _objectSpread({}, props);
131
-
132
- if (hideContent && !asDropDownItems) {
133
- actionProps.content = '';
134
- }
135
-
136
- if (hideIcon) {
137
- actionProps.icon = undefined;
138
- }
139
-
140
- if (Action) {
141
- var handleOnClick = function handleOnClick() {
142
- if (onActionItemClick) {
143
- onActionItemClick();
144
- }
145
-
146
- if (onClick) {
147
- onClick();
148
- }
149
- };
150
-
151
- var action = /*#__PURE__*/React.createElement(Action, _extends({
152
- url: '',
153
- asDropDownItem: asDropDownItems,
154
- size: size,
155
- key: idx,
156
- appearance: appearance,
157
- onClick: handleOnClick
158
- }, actionProps));
159
-
160
- if (!isJSXElementNull(action)) {
161
- return [].concat(_toConsumableArray(acc), [action]);
162
- }
163
- }
164
-
165
- return acc;
166
- }, []);
167
-
168
- if (actions.length) {
169
- return actions;
170
- }
171
109
  };
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React, { useEffect } from 'react';
2
+ import React, { useEffect, useMemo } from 'react';
3
3
  import { SmartLinkStatus } from '../../constants';
4
4
  import Container from './components/container';
5
5
  import { FlexibleUiAnalyticsContext, FlexibleUiContext } from '../../state/flexible-ui-context';
@@ -27,7 +27,9 @@ var FlexibleCard = function FlexibleCard(_ref) {
27
27
  var cardType = cardState.status,
28
28
  details = cardState.details;
29
29
  var status = cardType;
30
- var context = getContextByStatus(url, status, details, renderers);
30
+ var context = useMemo(function () {
31
+ return getContextByStatus(url, status, details, renderers);
32
+ }, [details, renderers, status, url]);
31
33
  var retry = getRetryOptions(url, status, details, onAuthorize);
32
34
 
33
35
  var _ref2 = context || {},
@@ -120,6 +120,31 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
120
120
  hideCard();
121
121
  }
122
122
  }, [closeOnChildClick, hideCard]);
123
+ var content = useCallback(function (_ref2) {
124
+ var update = _ref2.update;
125
+ return jsx(HoverCardContent, {
126
+ onMouseEnter: initShowCard,
127
+ onMouseLeave: initHideCard,
128
+ analytics: analytics,
129
+ cardActions: linkActions,
130
+ cardState: linkState,
131
+ onActionClick: onActionClick,
132
+ onResolve: update,
133
+ renderers: renderers,
134
+ url: url
135
+ });
136
+ }, [analytics, initHideCard, initShowCard, linkActions, linkState, onActionClick, renderers, url]);
137
+ var trigger = useCallback(function (triggerProps) {
138
+ return jsx("span", {
139
+ ref: parentSpan
140
+ }, jsx("span", _extends({}, triggerProps, {
141
+ onMouseEnter: initShowCard,
142
+ onMouseLeave: initHideCard,
143
+ onMouseMove: setMousePosition,
144
+ onClick: onChildClick,
145
+ "data-testid": "hover-card-trigger-wrapper"
146
+ }), children));
147
+ }, [children, initHideCard, initShowCard, onChildClick, setMousePosition]);
123
148
  return jsx(Popup, {
124
149
  testId: "hover-card",
125
150
  isOpen: isOpen && canOpen,
@@ -127,31 +152,8 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
127
152
  placement: "bottom-start",
128
153
  offset: popupOffset.current,
129
154
  autoFocus: false,
130
- content: function content(_ref2) {
131
- var update = _ref2.update;
132
- return jsx(HoverCardContent, {
133
- onMouseEnter: initShowCard,
134
- onMouseLeave: initHideCard,
135
- analytics: analytics,
136
- cardActions: linkActions,
137
- cardState: linkState,
138
- onActionClick: onActionClick,
139
- onResolve: update,
140
- renderers: renderers,
141
- url: url
142
- });
143
- },
144
- trigger: function trigger(triggerProps) {
145
- return jsx("span", {
146
- ref: parentSpan
147
- }, jsx("span", _extends({}, triggerProps, {
148
- onMouseEnter: initShowCard,
149
- onMouseLeave: initHideCard,
150
- onMouseMove: setMousePosition,
151
- onClick: onChildClick,
152
- "data-testid": "hover-card-trigger-wrapper"
153
- }), children));
154
- },
155
+ content: content,
156
+ trigger: trigger,
155
157
  zIndex: 511 // Temporary fix for Confluence inline comment on editor mod has z-index of 500, Jira issue view has z-index of 510
156
158
 
157
159
  });
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { CardAppearance, CardPlatform, CardProps } from './types';
3
3
  import { WrappedComponentProps } from 'react-intl-next';
4
- export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "data" | "key" | "id" | "placeholder" | "onError" | "onClick" | "appearance" | "testId" | "analyticsContext" | "isSelected" | "inheritDimensions" | "ui" | "showActions" | "showHoverPreview" | "onResolve" | "platform" | "isFrameVisible" | "embedIframeRef" | "inlinePreloaderStyle" | "importer" | "container" | "analyticsEvents" | "forwardedRef"> & React.RefAttributes<any>>;
4
+ export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "data" | "key" | "id" | "placeholder" | "onError" | "onClick" | "appearance" | "testId" | "analyticsContext" | "isSelected" | "inheritDimensions" | "ui" | "showActions" | "showHoverPreview" | "onResolve" | "platform" | "showAuthTooltip" | "isFrameVisible" | "embedIframeRef" | "inlinePreloaderStyle" | "importer" | "container" | "analyticsEvents" | "forwardedRef"> & React.RefAttributes<any>>;
5
5
  export type { CardAppearance, CardProps, CardPlatform };
@@ -32,6 +32,7 @@ export interface CardProps extends WithAnalyticsEventsProps {
32
32
  ui?: FlexibleUiOptions;
33
33
  children?: React.ReactNode;
34
34
  showHoverPreview?: boolean;
35
+ showAuthTooltip?: boolean;
35
36
  analyticsEvents?: AnalyticsFacade;
36
37
  placeholder?: string;
37
38
  }
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { CardWithUrlContentProps } from './types';
3
- export declare function CardWithUrlContent({ id, url, isSelected, isFrameVisible, platform, onClick, appearance, dispatchAnalytics, onResolve, onError, testId, showActions, inheritDimensions, embedIframeRef, inlinePreloaderStyle, ui, children, showHoverPreview, analyticsEvents, }: CardWithUrlContentProps): JSX.Element;
3
+ export declare function CardWithUrlContent({ id, url, isSelected, isFrameVisible, platform, onClick, appearance, dispatchAnalytics, onResolve, onError, testId, showActions, inheritDimensions, embedIframeRef, inlinePreloaderStyle, ui, children, showHoverPreview, showAuthTooltip: showAuthTooltipProp, analyticsEvents, }: CardWithUrlContentProps): JSX.Element;
@@ -24,6 +24,7 @@ export declare type CardWithUrlContentProps = {
24
24
  ui?: FlexibleUiOptions;
25
25
  children?: React.ReactNode;
26
26
  showHoverPreview?: boolean;
27
+ showAuthTooltip?: boolean;
27
28
  analyticsEvents?: AnalyticsFacade;
28
29
  placeholder?: string;
29
30
  };
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { Appearance } from '@atlaskit/button';
3
+ import { SmartLinkSize } from '../../../../../../constants';
4
+ import { ActionItem } from '../../types';
5
+ declare const ActionGroupItem: React.FC<{
6
+ item: ActionItem;
7
+ size: SmartLinkSize;
8
+ appearance?: Appearance;
9
+ asDropDownItems?: boolean;
10
+ onActionItemClick?: () => void;
11
+ }>;
12
+ export default ActionGroupItem;
@@ -1,13 +1,12 @@
1
1
  import React from 'react';
2
2
  import { SerializedStyles } from '@emotion/react';
3
- import { ActionItem, ElementItem } from './types';
3
+ import { ElementItem } from './types';
4
4
  import { ElementName, SmartLinkDirection, SmartLinkSize } from '../../../../constants';
5
- import { Appearance } from '@atlaskit/button';
6
5
  export declare type ElementDisplaySchemaType = 'inline' | 'block';
7
6
  export declare const ElementDisplaySchema: Record<ElementName, ElementDisplaySchemaType[]>;
8
7
  export declare const getGapSize: (size: SmartLinkSize) => number;
9
8
  export declare const getBaseStyles: (direction: SmartLinkDirection, size: SmartLinkSize) => SerializedStyles;
10
9
  export declare const highlightRemoveStyles: SerializedStyles;
10
+ export declare const isJSXElementNull: (children: JSX.Element) => boolean;
11
11
  export declare const renderChildren: (children: React.ReactNode, size: SmartLinkSize) => React.ReactNode;
12
12
  export declare const renderElementItems: (items?: ElementItem[], display?: ElementDisplaySchemaType) => React.ReactNode | undefined;
13
- export declare const renderActionItems: (items?: ActionItem[], size?: SmartLinkSize, appearance?: Appearance | undefined, asDropDownItems?: boolean | undefined, onActionItemClick?: (() => void) | undefined) => React.ReactElement[] | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.13.2",
3
+ "version": "23.14.0",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -36,7 +36,7 @@
36
36
  "@atlaskit/linking-common": "^1.20.0",
37
37
  "@atlaskit/logo": "^13.10.0",
38
38
  "@atlaskit/lozenge": "^11.3.0",
39
- "@atlaskit/media-common": "^2.18.0",
39
+ "@atlaskit/media-common": "^2.19.0",
40
40
  "@atlaskit/modal-dialog": "^12.4.0",
41
41
  "@atlaskit/outbound-auth-flow-client": "^3.3.0",
42
42
  "@atlaskit/popup": "^1.5.0",
package/report.api.md CHANGED
@@ -254,6 +254,7 @@ export const Card: React_2.ForwardRefExoticComponent<
254
254
  | 'placeholder'
255
255
  | 'platform'
256
256
  | 'showActions'
257
+ | 'showAuthTooltip'
257
258
  | 'showHoverPreview'
258
259
  | 'testId'
259
260
  | 'ui'
@@ -316,6 +317,8 @@ export interface CardProps extends WithAnalyticsEventsProps {
316
317
  // (undocumented)
317
318
  showActions?: boolean;
318
319
  // (undocumented)
320
+ showAuthTooltip?: boolean;
321
+ // (undocumented)
319
322
  showHoverPreview?: boolean;
320
323
  // (undocumented)
321
324
  testId?: string;
@@ -178,7 +178,7 @@ type BlockProps = {
178
178
  };
179
179
 
180
180
  // @public (undocumented)
181
- export const Card: React_2.ForwardRefExoticComponent<Pick<Omit<React_2.PropsWithChildren<WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof WithAnalyticsEventsProps> & React_2.RefAttributes<any> & WithContextProps, "analyticsContext" | "analyticsEvents" | "appearance" | "children" | "container" | "data" | "embedIframeRef" | "forwardedRef" | "id" | "importer" | "inheritDimensions" | "inlinePreloaderStyle" | "isFrameVisible" | "isSelected" | "key" | "onClick" | "onError" | "onResolve" | "placeholder" | "platform" | "showActions" | "showHoverPreview" | "testId" | "ui" | "url"> & React_2.RefAttributes<any>>;
181
+ export const Card: React_2.ForwardRefExoticComponent<Pick<Omit<React_2.PropsWithChildren<WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof WithAnalyticsEventsProps> & React_2.RefAttributes<any> & WithContextProps, "analyticsContext" | "analyticsEvents" | "appearance" | "children" | "container" | "data" | "embedIframeRef" | "forwardedRef" | "id" | "importer" | "inheritDimensions" | "inlinePreloaderStyle" | "isFrameVisible" | "isSelected" | "key" | "onClick" | "onError" | "onResolve" | "placeholder" | "platform" | "showActions" | "showAuthTooltip" | "showHoverPreview" | "testId" | "ui" | "url"> & React_2.RefAttributes<any>>;
182
182
 
183
183
  export { CardAdf }
184
184
 
@@ -230,6 +230,8 @@ export interface CardProps extends WithAnalyticsEventsProps {
230
230
  // (undocumented)
231
231
  showActions?: boolean;
232
232
  // (undocumented)
233
+ showAuthTooltip?: boolean;
234
+ // (undocumented)
233
235
  showHoverPreview?: boolean;
234
236
  // (undocumented)
235
237
  testId?: string;