@synerise/ds-action-area 0.4.2 → 0.5.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 +11 -0
- package/README.md +15 -13
- package/dist/ActionArea.d.ts +1 -1
- package/dist/ActionArea.js +9 -10
- package/dist/ActionArea.styles.d.ts +1 -0
- package/dist/ActionArea.styles.js +5 -1
- package/dist/ActionArea.types.d.ts +11 -4
- package/dist/ActionArea.utils.d.ts +3 -0
- package/dist/ActionArea.utils.js +23 -0
- package/dist/index.d.ts +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.5.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-action-area@0.4.2...@synerise/ds-action-area@0.5.0) (2024-07-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **action-area:** custom action content prop ([8335792](https://github.com/Synerise/synerise-design/commit/8335792f917a4247ba33c2fe86b0d881c43ca036))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [0.4.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-action-area@0.4.1...@synerise/ds-action-area@0.4.2) (2024-06-27)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @synerise/ds-action-area
|
package/README.md
CHANGED
|
@@ -26,16 +26,18 @@ import ActionArea from '@synerise/ds-action-area'
|
|
|
26
26
|
|
|
27
27
|
## API
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
|
32
|
-
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
29
|
+
Either both `action` & `actionLabel` OR `customAction` is required.
|
|
30
|
+
|
|
31
|
+
| Property | Description | Type | Default |
|
|
32
|
+
|--------------|--------------------------------------------------|-----------------------|---------|
|
|
33
|
+
| action | Function called when user clicks on ActionButton | `Function` | - |
|
|
34
|
+
| actionLabel | Label of action button | `React.ReactNode` | - |
|
|
35
|
+
| customAction | content to render below description | `React.ReactNode` | - |
|
|
36
|
+
| description | Description of ActionArea | `React.ReactNode` | - |
|
|
37
|
+
| label | Label of ActionArea | `React.ReactNode` | - |
|
|
38
|
+
| buttonProps | optional additional button props | see ds-button | - |
|
|
39
|
+
| isFullWidth | Set component width to 100% available space | `boolean` | false |
|
|
40
|
+
| isError | Set component state to invalid | `boolean` | false |
|
|
41
|
+
| errorText | Text to display when is invalid state | `React.ReactNode` | - |
|
|
42
|
+
| className | custom class name | `string` | - |
|
|
43
|
+
| style | custom CSS style | `React.CSSProperties` | - |
|
package/dist/ActionArea.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ActionAreaProps } from './ActionArea.types';
|
|
3
3
|
declare const ActionArea: {
|
|
4
|
-
({ label, description,
|
|
4
|
+
({ label, description, isFullWidth, isError, errorText, className, style, ...rest }: ActionAreaProps): React.JSX.Element;
|
|
5
5
|
ActionAreaWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
6
6
|
isFullWidth?: boolean | undefined;
|
|
7
7
|
}, never>;
|
package/dist/ActionArea.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
var _excluded = ["label", "description", "isFullWidth", "isError", "errorText", "className", "style"];
|
|
2
|
+
|
|
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; }
|
|
2
4
|
|
|
3
5
|
import React from 'react';
|
|
4
6
|
import classnames from 'classnames';
|
|
5
|
-
import Button from '@synerise/ds-button';
|
|
6
7
|
import { Title, Description } from '@synerise/ds-typography';
|
|
7
8
|
import * as S from './ActionArea.styles';
|
|
9
|
+
import { renderAction } from './ActionArea.utils';
|
|
8
10
|
|
|
9
11
|
var ActionArea = function ActionArea(_ref) {
|
|
10
12
|
var label = _ref.label,
|
|
11
13
|
description = _ref.description,
|
|
12
|
-
action = _ref.action,
|
|
13
|
-
actionLabel = _ref.actionLabel,
|
|
14
|
-
buttonProps = _ref.buttonProps,
|
|
15
14
|
_ref$isFullWidth = _ref.isFullWidth,
|
|
16
15
|
isFullWidth = _ref$isFullWidth === void 0 ? false : _ref$isFullWidth,
|
|
17
16
|
_ref$isError = _ref.isError,
|
|
18
17
|
isError = _ref$isError === void 0 ? false : _ref$isError,
|
|
19
18
|
errorText = _ref.errorText,
|
|
20
19
|
className = _ref.className,
|
|
21
|
-
style = _ref.style
|
|
20
|
+
style = _ref.style,
|
|
21
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
22
|
+
|
|
22
23
|
var isErrorText = isError && Boolean(errorText);
|
|
24
|
+
var actionContent = renderAction(rest);
|
|
23
25
|
return /*#__PURE__*/React.createElement(S.ActionAreaWrapper, {
|
|
24
26
|
style: style,
|
|
25
27
|
className: classnames('ds-action-area', className),
|
|
@@ -29,10 +31,7 @@ var ActionArea = function ActionArea(_ref) {
|
|
|
29
31
|
"data-testid": "action-area-content"
|
|
30
32
|
}, label && /*#__PURE__*/React.createElement(Title, {
|
|
31
33
|
level: 6
|
|
32
|
-
}, label), /*#__PURE__*/React.createElement(Description, null, description), /*#__PURE__*/React.createElement(
|
|
33
|
-
type: "primary",
|
|
34
|
-
onClick: action
|
|
35
|
-
}, buttonProps), actionLabel)), isErrorText && /*#__PURE__*/React.createElement(S.ErrorText, null, errorText));
|
|
34
|
+
}, label), /*#__PURE__*/React.createElement(Description, null, description), /*#__PURE__*/React.createElement(S.ActionAreaAction, null, actionContent)), isErrorText && /*#__PURE__*/React.createElement(S.ErrorText, null, errorText));
|
|
36
35
|
};
|
|
37
36
|
|
|
38
37
|
ActionArea.ActionAreaWrapper = S.ActionAreaWrapper;
|
|
@@ -4,4 +4,5 @@ export declare const ActionAreaWrapper: import("styled-components").StyledCompon
|
|
|
4
4
|
export declare const ActionAreaContent: import("styled-components").StyledComponent<"div", any, {
|
|
5
5
|
isError?: boolean | undefined;
|
|
6
6
|
}, never>;
|
|
7
|
+
export declare const ActionAreaAction: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
8
|
export declare const ErrorText: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -22,9 +22,13 @@ export var ActionAreaContent = styled.div.withConfig({
|
|
|
22
22
|
theme = _ref4.theme;
|
|
23
23
|
return isError && "border-color: " + theme.palette['red-600'] + ";";
|
|
24
24
|
}, Description);
|
|
25
|
+
export var ActionAreaAction = styled.div.withConfig({
|
|
26
|
+
displayName: "ActionAreastyles__ActionAreaAction",
|
|
27
|
+
componentId: "sc-10ey0kr-2"
|
|
28
|
+
})([""]);
|
|
25
29
|
export var ErrorText = styled.div.withConfig({
|
|
26
30
|
displayName: "ActionAreastyles__ErrorText",
|
|
27
|
-
componentId: "sc-10ey0kr-
|
|
31
|
+
componentId: "sc-10ey0kr-3"
|
|
28
32
|
})(["margin-top:8px;color:", ";"], function (_ref5) {
|
|
29
33
|
var theme = _ref5.theme;
|
|
30
34
|
return theme.palette['red-600'];
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import { ButtonProps } from '@synerise/ds-button';
|
|
3
|
-
|
|
4
|
-
action: () => void;
|
|
5
|
-
actionLabel: ReactNode;
|
|
6
|
-
buttonProps?: Partial<ButtonProps>;
|
|
3
|
+
type CommonProps = {
|
|
7
4
|
className?: string;
|
|
8
5
|
description: ReactNode;
|
|
9
6
|
errorText?: ReactNode;
|
|
@@ -12,3 +9,13 @@ export type ActionAreaProps = {
|
|
|
12
9
|
label?: ReactNode;
|
|
13
10
|
style?: CSSProperties;
|
|
14
11
|
};
|
|
12
|
+
export type ActionAreaWithCustomActionProps = {
|
|
13
|
+
customAction: ReactNode;
|
|
14
|
+
};
|
|
15
|
+
export type ActionAreaWithStandardActionProps = {
|
|
16
|
+
action: () => void;
|
|
17
|
+
actionLabel: ReactNode;
|
|
18
|
+
buttonProps?: Partial<ButtonProps>;
|
|
19
|
+
};
|
|
20
|
+
export type ActionAreaProps = CommonProps & (ActionAreaWithCustomActionProps | ActionAreaWithStandardActionProps);
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import Button from '@synerise/ds-button';
|
|
5
|
+
|
|
6
|
+
var isCustomActionArea = function isCustomActionArea(props) {
|
|
7
|
+
return 'customAction' in props;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export var renderAction = function renderAction(props) {
|
|
11
|
+
if (isCustomActionArea(props)) {
|
|
12
|
+
var customAction = props.customAction;
|
|
13
|
+
return customAction;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
var action = props.action,
|
|
17
|
+
actionLabel = props.actionLabel,
|
|
18
|
+
buttonProps = props.buttonProps;
|
|
19
|
+
return /*#__PURE__*/React.createElement(Button, _extends({
|
|
20
|
+
type: "primary",
|
|
21
|
+
onClick: action
|
|
22
|
+
}, buttonProps), actionLabel);
|
|
23
|
+
};
|
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-action-area",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "ActionArea UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"@testing-library/jest-dom": "5.1.1",
|
|
48
48
|
"@testing-library/react": "10.0.1"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "0692552b018dc9c8042f18c773f88890c9ad3270"
|
|
51
51
|
}
|