@synerise/ds-information-card 0.3.10 → 0.3.12

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
@@ -3,6 +3,32 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.3.12](https://github.com/Synerise/synerise-design/compare/@synerise/ds-information-card@0.3.11...@synerise/ds-information-card@0.3.12) (2023-04-19)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **information-card:** adds support for plain text descriptions ([ebeb57f](https://github.com/Synerise/synerise-design/commit/ebeb57f8c6fafa035fdd664744a85f16aaa64304))
12
+ * **information-card:** removed children from props ([4451b88](https://github.com/Synerise/synerise-design/commit/4451b883364b89c4a9fb94aaf630e18f70f80505))
13
+
14
+
15
+ ### BREAKING CHANGES
16
+
17
+ * **information-card:** children prop no longer supported in information-card
18
+ * **information-card:** children prop no longer supported
19
+
20
+
21
+
22
+
23
+
24
+ ## [0.3.11](https://github.com/Synerise/synerise-design/compare/@synerise/ds-information-card@0.3.10...@synerise/ds-information-card@0.3.11) (2023-04-17)
25
+
26
+ **Note:** Version bump only for package @synerise/ds-information-card
27
+
28
+
29
+
30
+
31
+
6
32
  ## [0.3.10](https://github.com/Synerise/synerise-design/compare/@synerise/ds-information-card@0.3.9...@synerise/ds-information-card@0.3.10) (2023-04-14)
7
33
 
8
34
  **Note:** Version bump only for package @synerise/ds-information-card
@@ -1,94 +1,11 @@
1
1
  import * as React from 'react';
2
- import { IconProps } from '@synerise/ds-icon/dist/cjs';
3
2
  import { InlineAlertType } from '@synerise/ds-alert/dist/InlineAlert/InlineAlert.types';
4
- import { SubtleTextAreaProps } from '@synerise/ds-subtle-form/dist/Elements/TextArea/TextArea.types';
5
- import { Color, Size } from '@synerise/ds-avatar/dist/Avatar.types';
3
+ import { InformationCardProps, BadgeData } from './InformationCard.types';
6
4
  import 'rc-trigger/assets/index.less';
7
- export declare type BadgeData = {
8
- type?: string;
9
- title?: string;
10
- name?: string;
11
- iconColor?: Color | IconProps['color'];
12
- iconElement?: InformationCardProps['icon'];
13
- iconSize?: Size | string;
14
- avatarTooltipText?: string;
15
- };
16
5
  /**
17
6
  * Custom builder for badgeSlots with icon
18
7
  */
19
8
  export declare function buildIconBadge(data: BadgeData): JSX.Element;
20
- export declare type InformationCardProps = {
21
- /**
22
- * custom jsx element for rendering in action button (bottom-right)
23
- */
24
- actionButton?: boolean | (() => React.ReactNode);
25
- /**
26
- * default action button callback methodd
27
- */
28
- actionButtonCallback?: () => void;
29
- /**
30
- * default action button tooltip
31
- */
32
- actionButtonTooltipText?: string;
33
- /**
34
- * adjusts the styles to be displayed as a tooltip
35
- */
36
- asTooltip?: boolean;
37
- /**
38
- * description in a tooltip shown when user (note renderBadge has to be provided)
39
- */
40
- avatarTooltipText?: string;
41
- /**
42
- * content of the tooltip, it defaults to `SubtleForm.TextArea`
43
- */
44
- children?: React.ReactNode | ((props?: SubtleTextAreaProps | null) => React.ReactNode);
45
- /**
46
- * subtitle's value to be copied when clicking on the copy button
47
- */
48
- copyTooltip?: string;
49
- /**
50
- * feedback to the user once information card's subtitle has been copied
51
- */
52
- copiedTooltip?: string;
53
- /**
54
- * when information-card's `children` prop is not provided,
55
- * `defaultTextAreaProps` can be used to parametrize default textarea
56
- */
57
- descriptionConfig?: SubtleTextAreaProps | null | undefined;
58
- /**
59
- * render prop for rendering the bottom part of (by default section with a small text and an optional action button on the right)
60
- */
61
- renderFooter?: () => JSX.Element;
62
- /**
63
- * additional feedback info to the user, when set to null - footer is hidden
64
- */
65
- footerText?: string | React.ReactNode | null;
66
- /**
67
- * icon (note this needs to be pure SVG icon, it relies on `buildBadgeIcon` helper)
68
- */
69
- icon?: React.ReactNode;
70
- /**
71
- * icon color to be applied to `icon` element
72
- */
73
- iconColor?: string;
74
- /**
75
- * additional information shown between subtitle and description section.
76
- * Can be used for warnings, errors, destructive actions, notices. See `buildExtraInfo` and alert `level` there.
77
- */
78
- notice?: string | React.ReactNode;
79
- /**
80
- * Custom render prop for displaying. If set to `null` - badge won't be shown.
81
- */
82
- renderBadge?: Function | null;
83
- /**
84
- * Second line. Required prop. Can be copied.
85
- */
86
- subtitle?: string;
87
- /**
88
- * Title of the information-card. Can be copied.
89
- */
90
- title: string;
91
- };
92
9
  declare const InformationCard: React.ForwardRefExoticComponent<InformationCardProps & React.RefAttributes<HTMLDivElement>>;
93
10
  export declare function buildInitialsBadge(name: string): JSX.Element;
94
11
  /**
@@ -1,4 +1,4 @@
1
- var _excluded = ["actionButton", "actionButtonTooltipText", "actionButtonCallback", "asTooltip", "avatarTooltipText", "children", "copyTooltip", "copiedTooltip", "renderFooter", "renderBadge", "subtitle", "title", "notice", "footerText", "icon", "iconColor", "descriptionConfig"];
1
+ var _excluded = ["actionButton", "actionButtonTooltipText", "actionButtonCallback", "asTooltip", "avatarTooltipText", "copyTooltip", "copiedTooltip", "renderFooter", "renderBadge", "subtitle", "title", "notice", "footerText", "icon", "iconColor", "descriptionConfig"];
2
2
 
3
3
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
4
4
 
@@ -19,10 +19,10 @@ import Badge from '@synerise/ds-badge';
19
19
  import Alert from '@synerise/ds-alert';
20
20
  import * as S from './InformationCard.styles';
21
21
  import "rc-trigger/assets/index.css";
22
-
23
22
  /**
24
23
  * Custom builder for badgeSlots with icon
25
24
  */
25
+
26
26
  export function buildIconBadge(data) {
27
27
  var avatarExtra = {
28
28
  object: {}
@@ -41,22 +41,12 @@ export function buildIconBadge(data) {
41
41
  })
42
42
  }));
43
43
  }
44
-
45
- function renderChildren(renderChild, descriptionConfig) {
46
- if (typeof renderChild === 'function') {
47
- return renderChild(descriptionConfig);
48
- }
49
-
50
- return renderChild;
51
- }
52
-
53
44
  var InformationCard = React.forwardRef(function (_ref, ref) {
54
45
  var actionButton = _ref.actionButton,
55
46
  actionButtonTooltipText = _ref.actionButtonTooltipText,
56
47
  actionButtonCallback = _ref.actionButtonCallback,
57
48
  asTooltip = _ref.asTooltip,
58
49
  avatarTooltipText = _ref.avatarTooltipText,
59
- children = _ref.children,
60
50
  copyTooltip = _ref.copyTooltip,
61
51
  copiedTooltip = _ref.copiedTooltip,
62
52
  renderFooter = _ref.renderFooter,
@@ -89,9 +79,6 @@ var InformationCard = React.forwardRef(function (_ref, ref) {
89
79
  })));
90
80
  };
91
81
 
92
- var cachedChildren = React.useMemo(function () {
93
- return renderChildren(children, descriptionConfig);
94
- }, [children, descriptionConfig]);
95
82
  return /*#__PURE__*/React.createElement(S.InfoCardWrapper, {
96
83
  ref: ref,
97
84
  "aria-label": "information card",
@@ -120,9 +107,8 @@ var InformationCard = React.forwardRef(function (_ref, ref) {
120
107
  compactHeader: false,
121
108
  withoutPadding: true,
122
109
  lively: false,
123
- withHeader: true,
124
- className: cachedChildren ? 'custom-description' : ''
125
- }, (cachedChildren || descriptionConfig !== null || notice) && /*#__PURE__*/React.createElement(DescriptionField, {
110
+ withHeader: true
111
+ }, (descriptionConfig !== null || notice) && /*#__PURE__*/React.createElement(DescriptionField, {
126
112
  extraInformation: notice || /*#__PURE__*/React.createElement(React.Fragment, null),
127
113
  descriptionConfig: descriptionConfig
128
114
  }), renderFooter && renderFooter() || (footerText || actionButton) && /*#__PURE__*/React.createElement(Footer, _extends({
@@ -130,8 +116,7 @@ var InformationCard = React.forwardRef(function (_ref, ref) {
130
116
  }, props, {
131
117
  actionButton: actionButton,
132
118
  actionButtonCallback: actionButtonCallback,
133
- actionButtonTooltipText: actionButtonTooltipText,
134
- isCustomDescription: cachedChildren !== undefined
119
+ actionButtonTooltipText: actionButtonTooltipText
135
120
  }))));
136
121
  });
137
122
  export function buildInitialsBadge(name) {
@@ -185,28 +170,31 @@ function DescriptionField(_ref3) {
185
170
  description = _React$useState[0],
186
171
  setDescription = _React$useState[1];
187
172
 
188
- return /*#__PURE__*/React.createElement("div", {
189
- className: "information-card-description"
190
- }, extraInformation, descriptionConfig && /*#__PURE__*/React.createElement(SubtleForm.TextArea, _extends({
191
- minRows: 1,
192
- value: description // hideLabel
193
- ,
194
- onChange: function onChange(v) {
195
- descriptionConfig.onChange && descriptionConfig.onChange(v);
196
- setDescription(v);
197
- },
198
- placeholder: "placeholer",
199
- label: "Label",
200
- labelTooltip: "label tooltip",
201
- suffixTooltip: "Edit"
202
- }, descriptionConfig, descriptionConfig.error ? {
203
- error: descriptionConfig.error,
204
- errorText: function errorText(isErr, text) {
205
- return isErr ? text : '';
173
+ var renderDescription = function renderDescription() {
174
+ if (descriptionConfig) {
175
+ return typeof descriptionConfig === 'string' ? /*#__PURE__*/React.createElement(S.NonEditableWrapper, null, descriptionConfig) : /*#__PURE__*/React.createElement(SubtleForm.TextArea, _extends({
176
+ minRows: 1,
177
+ value: description,
178
+ onChange: function onChange(v) {
179
+ descriptionConfig.onChange && descriptionConfig.onChange(v);
180
+ setDescription(v);
181
+ },
182
+ placeholder: "placeholder",
183
+ suffixTooltip: "Edit"
184
+ }, descriptionConfig, descriptionConfig.error ? {
185
+ error: descriptionConfig.error,
186
+ errorText: function errorText(isErr, text) {
187
+ return isErr ? text : '';
188
+ }
189
+ } : {}, {
190
+ disabled: descriptionConfig.disabled
191
+ }));
206
192
  }
207
- } : {}, {
208
- disabled: descriptionConfig.disabled
209
- })));
193
+
194
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
195
+ };
196
+
197
+ return /*#__PURE__*/React.createElement(S.DescriptionWrapper, null, /*#__PURE__*/React.createElement(S.AlertWrapper, null, extraInformation), descriptionConfig && renderDescription());
210
198
  }
211
199
  /**
212
200
  * Tooltip helper for action button in footer
@@ -232,10 +220,9 @@ function Footer(_ref4) {
232
220
  _ref4$actionButtonToo = _ref4.actionButtonTooltipText,
233
221
  actionButtonTooltipText = _ref4$actionButtonToo === void 0 ? '' : _ref4$actionButtonToo,
234
222
  _ref4$text = _ref4.text,
235
- text = _ref4$text === void 0 ? '' : _ref4$text,
236
- isCustomDescription = _ref4.isCustomDescription;
223
+ text = _ref4$text === void 0 ? '' : _ref4$text;
237
224
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Divider, {
238
- marginTop: isCustomDescription ? 16 : 8,
225
+ marginTop: 8,
239
226
  marginBottom: 0,
240
227
  dashed: true
241
228
  }), /*#__PURE__*/React.createElement(S.Flex, {
@@ -8,6 +8,9 @@ export declare const InfoCardWrapper: import("styled-components").StyledComponen
8
8
  footerText?: string | undefined;
9
9
  asTooltip?: boolean | undefined;
10
10
  }, never>;
11
+ export declare const AlertWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
12
+ export declare const NonEditableWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
13
+ export declare const DescriptionWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
11
14
  /**
12
15
  * This component can be used to style container with popovers/tooltips to disable arrow.
13
16
  */
@@ -3,7 +3,7 @@ var _templateObject;
3
3
  function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
4
4
 
5
5
  import styled, { createGlobalStyle } from 'styled-components';
6
- import { IconContainer, Container as CardContainer, PaddingWrapper, ChildrenContainer, HeaderContent, Header, Title } from '@synerise/ds-card/dist/Card/Card.styles';
6
+ import { IconContainer, Container as CardContainer, PaddingWrapper, HeaderContent, Header, Title } from '@synerise/ds-card/dist/Card/Card.styles';
7
7
  import * as S from '@synerise/ds-tooltip/dist/Tooltip.styles';
8
8
  import { AntdButton } from '@synerise/ds-button/dist/Button.styles';
9
9
  export var Flex = styled.div.withConfig({
@@ -25,18 +25,30 @@ export var ActionButtonContainer = styled.div.withConfig({
25
25
  export var InfoCardWrapper = styled.div.withConfig({
26
26
  displayName: "InformationCardstyles__InfoCardWrapper",
27
27
  componentId: "zxu5qa-3"
28
- })(["margin-left:", ";", "{background-color:white;margin-bottom:1px;font-weight:400;min-width:250px;&.custom-description ", "{margin-top:8px;}padding:16px 16px 8px 16px;border-radius:3px;box-shadow:", ";}", "{padding-top:0;}", "{padding:0 0 1px 0;margin-bottom:8px;}", "{align-self:center;margin-left:10px;margin-right:10px;}", "{margin:0;}", "", "{margin-bottom:0;font-size:14px;}", "{width:32px;height:32px;}.ds-button{background:transparent;}.btn-focus,.btn-focus:hover{box-shadow:unset;}"], function (props) {
28
+ })(["margin-left:", ";", "{background-color:white;margin-bottom:1px;font-weight:400;min-width:250px;padding:16px 16px 8px 16px;border-radius:3px;box-shadow:", ";}", "{padding-top:0;}", "{padding:0 0 1px 0;margin-bottom:8px;}", "{align-self:center;margin-left:10px;margin-right:10px;}", "{margin:0;}", "", "{margin-bottom:0;font-size:14px;}", "{width:32px;height:32px;}.ds-button{background:transparent;}.btn-focus,.btn-focus:hover{box-shadow:unset;}"], function (props) {
29
29
  return props.asTooltip ? '0' : '8px';
30
- }, CardContainer, ChildrenContainer, function (props) {
30
+ }, CardContainer, function (props) {
31
31
  return props.asTooltip ? 'unset' : '0 16px 32px 0 rgba(35, 41, 54, 0.1)';
32
32
  }, PaddingWrapper, Header, IconContainer, HeaderContent, Title, Title, AntdButton);
33
+ export var AlertWrapper = styled.div.withConfig({
34
+ displayName: "InformationCardstyles__AlertWrapper",
35
+ componentId: "zxu5qa-4"
36
+ })(["padding-bottom:8px;:empty{display:none;}"]);
37
+ export var NonEditableWrapper = styled.div.withConfig({
38
+ displayName: "InformationCardstyles__NonEditableWrapper",
39
+ componentId: "zxu5qa-5"
40
+ })(["padding-bottom:8px;:empty{display:none;}"]);
41
+ export var DescriptionWrapper = styled.div.withConfig({
42
+ displayName: "InformationCardstyles__DescriptionWrapper",
43
+ componentId: "zxu5qa-6"
44
+ })([""]);
33
45
  /**
34
46
  * This component can be used to style container with popovers/tooltips to disable arrow.
35
47
  */
36
48
 
37
49
  export var HidePopoverArrowWrapper = styled.div.withConfig({
38
50
  displayName: "InformationCardstyles__HidePopoverArrowWrapper",
39
- componentId: "zxu5qa-4"
51
+ componentId: "zxu5qa-7"
40
52
  })([".ant-popover-arrow-content,.ant-tooltip-arrow-content{display:none;}"]);
41
53
  /**
42
54
  * Should be mounted in application where.
@@ -45,6 +57,6 @@ export var HidePopoverArrowWrapper = styled.div.withConfig({
45
57
  export var GlobalCSSHidePopoverArrow = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n .ant-popover-arrow-content,.ant-tooltip-arrow-content {\n display: none;\n}"])));
46
58
  export var ExtraInfo = styled.div.withConfig({
47
59
  displayName: "InformationCardstyles__ExtraInfo",
48
- componentId: "zxu5qa-5"
60
+ componentId: "zxu5qa-8"
49
61
  })(["margin-bottom:1px;"]);
50
62
  export var TooltipComponentClassName = S.TooltipComponent;
@@ -0,0 +1,81 @@
1
+ import * as React from 'react';
2
+ import { SubtleTextAreaProps } from '@synerise/ds-subtle-form/dist/Elements/TextArea/TextArea.types';
3
+ import { Color, Size } from '@synerise/ds-avatar/dist/Avatar.types';
4
+ import { IconProps } from '@synerise/ds-icon/dist/cjs';
5
+ export declare type BadgeData = {
6
+ type?: string;
7
+ title?: string;
8
+ name?: string;
9
+ iconColor?: Color | IconProps['color'];
10
+ iconElement?: InformationCardProps['icon'];
11
+ iconSize?: Size | string;
12
+ avatarTooltipText?: string;
13
+ };
14
+ export declare type InformationCardProps = {
15
+ /**
16
+ * custom jsx element for rendering in action button (bottom-right)
17
+ */
18
+ actionButton?: boolean | (() => React.ReactNode);
19
+ /**
20
+ * default action button callback methodd
21
+ */
22
+ actionButtonCallback?: () => void;
23
+ /**
24
+ * default action button tooltip
25
+ */
26
+ actionButtonTooltipText?: string;
27
+ /**
28
+ * adjusts the styles to be displayed as a tooltip
29
+ */
30
+ asTooltip?: boolean;
31
+ /**
32
+ * description in a tooltip shown when user (note renderBadge has to be provided)
33
+ */
34
+ avatarTooltipText?: string;
35
+ /**
36
+ * subtitle's value to be copied when clicking on the copy button
37
+ */
38
+ copyTooltip?: string;
39
+ /**
40
+ * feedback to the user once information card's subtitle has been copied
41
+ */
42
+ copiedTooltip?: string;
43
+ /**
44
+ * when information-card's `children` prop is not provided,
45
+ * `defaultTextAreaProps` can be used to parametrize default textarea
46
+ */
47
+ descriptionConfig?: SubtleTextAreaProps | string | null | undefined;
48
+ /**
49
+ * render prop for rendering the bottom part of (by default section with a small text and an optional action button on the right)
50
+ */
51
+ renderFooter?: () => JSX.Element;
52
+ /**
53
+ * additional feedback info to the user, when set to null - footer is hidden
54
+ */
55
+ footerText?: string | React.ReactNode | null;
56
+ /**
57
+ * icon (note this needs to be pure SVG icon, it relies on `buildBadgeIcon` helper)
58
+ */
59
+ icon?: React.ReactNode;
60
+ /**
61
+ * icon color to be applied to `icon` element
62
+ */
63
+ iconColor?: string;
64
+ /**
65
+ * additional information shown between subtitle and description section.
66
+ * Can be used for warnings, errors, destructive actions, notices. See `buildExtraInfo` and alert `level` there.
67
+ */
68
+ notice?: string | React.ReactNode;
69
+ /**
70
+ * Custom render prop for displaying. If set to `null` - badge won't be shown.
71
+ */
72
+ renderBadge?: Function | null;
73
+ /**
74
+ * Second line. Required prop. Can be copied.
75
+ */
76
+ subtitle?: string;
77
+ /**
78
+ * Title of the information-card. Can be copied.
79
+ */
80
+ title: string;
81
+ };
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export { default, buildExtraInfo, buildIconBadge, buildInitialsBadge } from './InformationCard';
2
- export type { InformationCardProps } from './InformationCard';
2
+ export type { InformationCardProps } from './InformationCard.types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-information-card",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
4
4
  "description": "InformationCard UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -34,15 +34,15 @@
34
34
  "types": "dist/index.d.ts",
35
35
  "dependencies": {
36
36
  "@synerise/ds-alert": "^0.4.4",
37
- "@synerise/ds-avatar": "^0.14.62",
38
- "@synerise/ds-card": "^0.14.1",
39
- "@synerise/ds-description": "^0.3.62",
40
- "@synerise/ds-subtle-form": "^0.9.50",
37
+ "@synerise/ds-avatar": "^0.14.63",
38
+ "@synerise/ds-card": "^0.14.2",
39
+ "@synerise/ds-description": "^0.3.63",
40
+ "@synerise/ds-subtle-form": "^0.9.52",
41
41
  "@synerise/ds-typography": "^0.12.7"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@synerise/ds-core": "^0.31.2",
45
45
  "react": ">=16.9.0 < 17.0.0"
46
46
  },
47
- "gitHead": "a81aad1ee5bb7249f069115cab0ec06b66ab12b0"
47
+ "gitHead": "3b8c3b1437ecbdda775a790ac3c27d6b1b6cbf26"
48
48
  }