@synerise/ds-form 0.5.1 → 0.5.5
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,38 @@
|
|
|
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.5](https://github.com/Synerise/synerise-design/compare/@synerise/ds-form@0.5.3...@synerise/ds-form@0.5.5) (2022-09-07)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-form
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.5.4](https://github.com/Synerise/synerise-design/compare/@synerise/ds-form@0.5.3...@synerise/ds-form@0.5.4) (2022-09-07)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @synerise/ds-form
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [0.5.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-form@0.5.2...@synerise/ds-form@0.5.3) (2022-09-06)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @synerise/ds-form
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [0.5.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-form@0.5.1...@synerise/ds-form@0.5.2) (2022-09-05)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @synerise/ds-form
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
## [0.5.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-form@0.5.0...@synerise/ds-form@0.5.1) (2022-08-31)
|
|
7
39
|
|
|
8
40
|
**Note:** Version bump only for package @synerise/ds-form
|
package/README.md
CHANGED
|
@@ -36,3 +36,15 @@ import Form from '@synerise/ds-form'
|
|
|
36
36
|
| className | Class name applied to the element | string | - |
|
|
37
37
|
| description | Description text | string | - |
|
|
38
38
|
| withLine | Whether divider should be displayed | boolean |`false` |
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### EditableList
|
|
42
|
+
|
|
43
|
+
| Property | Description | Type | Default |
|
|
44
|
+
| ----------- | ----------------------------------- | ------- | ------- |
|
|
45
|
+
| firstInputProps* | Enable overwriting first input props | AutocompleteProps / undefined | - |
|
|
46
|
+
| secondInputProps* | Enable overwriting second input props | InputProps / undefined | - |
|
|
47
|
+
| validation | Enable validation on first and second column | Record<'validateLeftColumn' / 'validateLeftColumn', (val: string) => string / ReactNode / null | - |
|
|
48
|
+
| addButtonConfig | Define props for button | AddButtonConfigProps / undefined | - |
|
|
49
|
+
|
|
50
|
+
* in order to overwrite f.e. styles in first two columns, it is possible to use spread operator used in component implementation, to overwrite style of third column it is required to import styled component wrapper and overwrite it
|
|
@@ -1,3 +1,5 @@
|
|
|
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
|
+
|
|
1
3
|
import { Input } from '@synerise/ds-input';
|
|
2
4
|
import Autocomplete from '@synerise/ds-autocomplete';
|
|
3
5
|
import * as React from 'react';
|
|
@@ -5,6 +7,16 @@ import theme from '@synerise/ds-core/dist/js/DSProvider/ThemeProvider/theme';
|
|
|
5
7
|
import Icon, { Add3M } from '@synerise/ds-icon';
|
|
6
8
|
import Cruds from '@synerise/ds-cruds';
|
|
7
9
|
import * as S from './editable-list.styles';
|
|
10
|
+
var defaultFirstInputProps = {
|
|
11
|
+
style: {
|
|
12
|
+
width: 350
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var defaultSecondInputProps = {
|
|
16
|
+
style: {
|
|
17
|
+
width: 300
|
|
18
|
+
}
|
|
19
|
+
};
|
|
8
20
|
export var EditableList = function EditableList(_ref) {
|
|
9
21
|
var _renderAddButton;
|
|
10
22
|
|
|
@@ -13,15 +25,19 @@ export var EditableList = function EditableList(_ref) {
|
|
|
13
25
|
autocompleteOptions = _ref.autocompleteOptions,
|
|
14
26
|
value = _ref.value,
|
|
15
27
|
_onChange = _ref.onChange,
|
|
16
|
-
|
|
28
|
+
addButtonConfig = _ref.addButtonConfig,
|
|
17
29
|
onSearch = _ref.onSearch,
|
|
18
|
-
onClickAddRow = _ref.onClickAddRow,
|
|
19
30
|
onClickDelete = _ref.onClickDelete,
|
|
20
31
|
renderAddButton = _ref.renderAddButton,
|
|
21
32
|
renderLeftColumn = _ref.renderLeftColumn,
|
|
22
33
|
renderRightColumn = _ref.renderRightColumn,
|
|
23
34
|
renderAdditionalColumn = _ref.renderAdditionalColumn,
|
|
24
|
-
renderActions = _ref.renderActions
|
|
35
|
+
renderActions = _ref.renderActions,
|
|
36
|
+
validation = _ref.validation,
|
|
37
|
+
_ref$firstInputProps = _ref.firstInputProps,
|
|
38
|
+
firstInputProps = _ref$firstInputProps === void 0 ? defaultFirstInputProps : _ref$firstInputProps,
|
|
39
|
+
_ref$secondInputProps = _ref.secondInputProps,
|
|
40
|
+
secondInputProps = _ref$secondInputProps === void 0 ? defaultSecondInputProps : _ref$secondInputProps;
|
|
25
41
|
|
|
26
42
|
var _React$useState = React.useState([]),
|
|
27
43
|
params = _React$useState[0],
|
|
@@ -57,10 +73,7 @@ export var EditableList = function EditableList(_ref) {
|
|
|
57
73
|
// eslint-disable-next-line react/no-array-index-key
|
|
58
74
|
React.createElement(S.RowWrapper, {
|
|
59
75
|
key: id
|
|
60
|
-
}, (_renderLeftColumn = renderLeftColumn == null ? void 0 : renderLeftColumn(param, id)) != null ? _renderLeftColumn : /*#__PURE__*/React.createElement(S.AutoCompleteWrapper, null, /*#__PURE__*/React.createElement(Autocomplete, {
|
|
61
|
-
style: {
|
|
62
|
-
width: 350
|
|
63
|
-
},
|
|
76
|
+
}, (_renderLeftColumn = renderLeftColumn == null ? void 0 : renderLeftColumn(param, id)) != null ? _renderLeftColumn : /*#__PURE__*/React.createElement(S.AutoCompleteWrapper, null, /*#__PURE__*/React.createElement(Autocomplete, _extends({
|
|
64
77
|
onSearch: onSearch,
|
|
65
78
|
value: param.name,
|
|
66
79
|
onChange: function onChange(paramName) {
|
|
@@ -68,19 +81,20 @@ export var EditableList = function EditableList(_ref) {
|
|
|
68
81
|
setParams(newParams);
|
|
69
82
|
if (_onChange) _onChange(newParams);
|
|
70
83
|
},
|
|
71
|
-
label: id === 0 ? leftColumnName : null
|
|
72
|
-
|
|
84
|
+
label: id === 0 ? leftColumnName : null,
|
|
85
|
+
error: Boolean(validation == null ? void 0 : validation.validateLeftColumn == null ? void 0 : validation.validateLeftColumn(param.name)),
|
|
86
|
+
errorText: validation == null ? void 0 : validation.validateLeftColumn == null ? void 0 : validation.validateLeftColumn(param.name)
|
|
87
|
+
}, firstInputProps), autocompleteOptions)), (_renderRightColumn = renderRightColumn == null ? void 0 : renderRightColumn(param, id)) != null ? _renderRightColumn : /*#__PURE__*/React.createElement(S.InputWrapper, null, /*#__PURE__*/React.createElement(Input, _extends({
|
|
73
88
|
value: param.value,
|
|
74
89
|
onChange: function onChange(ev) {
|
|
75
90
|
var newParams = paramsWithNewValue(id, param.name, ev.target.value);
|
|
76
91
|
setParams(newParams);
|
|
77
92
|
if (_onChange) _onChange(newParams);
|
|
78
93
|
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
})), renderAdditionalColumn == null ? void 0 : renderAdditionalColumn(), typeof renderActions === 'function' && (renderActions == null ? void 0 : renderActions(param, id, params, {
|
|
94
|
+
label: id === 0 ? rightColumnName : null,
|
|
95
|
+
error: Boolean(validation == null ? void 0 : validation.validateRightColumn == null ? void 0 : validation.validateRightColumn(param.value)),
|
|
96
|
+
errorText: validation == null ? void 0 : validation.validateRightColumn == null ? void 0 : validation.validateRightColumn(param.value)
|
|
97
|
+
}, secondInputProps))), renderAdditionalColumn == null ? void 0 : renderAdditionalColumn(), typeof renderActions === 'function' && (renderActions == null ? void 0 : renderActions(param, id, params, {
|
|
84
98
|
onClickDelete: onClickDelete
|
|
85
99
|
})) || renderActions === true && /*#__PURE__*/React.createElement(S.CrudWrapper, {
|
|
86
100
|
marginWithLabel: id === 0 ? leftColumnName : null
|
|
@@ -97,12 +111,13 @@ export var EditableList = function EditableList(_ref) {
|
|
|
97
111
|
})) || undefined)
|
|
98
112
|
);
|
|
99
113
|
}), (_renderAddButton = renderAddButton == null ? void 0 : renderAddButton()) != null ? _renderAddButton : /*#__PURE__*/React.createElement(S.ButtonWrapper, null, /*#__PURE__*/React.createElement(S.AddButton, {
|
|
100
|
-
onClick: onClickAddRow || onSetParamsDefault,
|
|
101
|
-
type: "ghost-primary"
|
|
114
|
+
onClick: (addButtonConfig == null ? void 0 : addButtonConfig.onClickAddRow) || onSetParamsDefault,
|
|
115
|
+
type: "ghost-primary",
|
|
116
|
+
disabled: addButtonConfig == null ? void 0 : addButtonConfig.disableAddButton
|
|
102
117
|
}, /*#__PURE__*/React.createElement(S.AddIconWrapper, null, /*#__PURE__*/React.createElement(Icon, {
|
|
103
118
|
component: /*#__PURE__*/React.createElement(Add3M, null),
|
|
104
119
|
size: 24,
|
|
105
120
|
color: theme.palette['blue-600']
|
|
106
|
-
})), /*#__PURE__*/React.createElement("span", null, textAddButton))));
|
|
121
|
+
})), /*#__PURE__*/React.createElement("span", null, addButtonConfig == null ? void 0 : addButtonConfig.textAddButton))));
|
|
107
122
|
};
|
|
108
123
|
export default EditableList;
|
|
@@ -3,7 +3,7 @@ import Button from '@synerise/ds-button';
|
|
|
3
3
|
export var RowWrapper = styled.div.withConfig({
|
|
4
4
|
displayName: "editable-liststyles__RowWrapper",
|
|
5
5
|
componentId: "ctaimf-0"
|
|
6
|
-
})(["@media (min-width:1280px){display:flex;
|
|
6
|
+
})(["@media (min-width:1280px){display:flex;align-items:start;}padding:8px 0px 8px 0px;"]);
|
|
7
7
|
export var AutoCompleteWrapper = styled.div.withConfig({
|
|
8
8
|
displayName: "editable-liststyles__AutoCompleteWrapper",
|
|
9
9
|
componentId: "ctaimf-1"
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import type { AutocompleteProps } from '@synerise/ds-autocomplete';
|
|
3
|
+
import type { InputProps } from 'antd/lib/input';
|
|
2
4
|
export declare type EditableParam = {
|
|
3
5
|
name: string;
|
|
4
6
|
value: string;
|
|
5
7
|
};
|
|
8
|
+
declare type AddButtonConfigProps = {
|
|
9
|
+
textAddButton?: string;
|
|
10
|
+
disableAddButton?: boolean;
|
|
11
|
+
onClickAddRow?: () => void;
|
|
12
|
+
};
|
|
6
13
|
export declare type EditListProps = {
|
|
7
14
|
autocompleteOptions?: string | React.ReactNode;
|
|
8
15
|
leftColumnName?: string | React.ReactNode;
|
|
@@ -10,12 +17,18 @@ export declare type EditListProps = {
|
|
|
10
17
|
value?: EditableParam[];
|
|
11
18
|
onChange?: (params: EditableParam[]) => void;
|
|
12
19
|
onSearch?: (query: string) => void;
|
|
13
|
-
onClickAddRow?: () => void;
|
|
14
20
|
onClickDelete?: (param?: EditableParam, index?: number, params?: EditableParam[]) => void;
|
|
15
|
-
|
|
21
|
+
addButtonConfig?: AddButtonConfigProps;
|
|
22
|
+
validation?: {
|
|
23
|
+
validateLeftColumn?: (val: string) => string | React.ReactNode | null;
|
|
24
|
+
validateRightColumn?: (val: string) => string | React.ReactNode | null;
|
|
25
|
+
};
|
|
16
26
|
renderAddButton?: (params?: EditableParam[]) => JSX.Element;
|
|
17
27
|
renderLeftColumn?: (param?: EditableParam, index?: number) => JSX.Element;
|
|
18
28
|
renderRightColumn?: (param?: EditableParam, index?: number, ref?: React.ClassAttributes<{}>['ref']) => JSX.Element;
|
|
19
29
|
renderAdditionalColumn?: (row?: EditableParam[]) => JSX.Element;
|
|
20
30
|
renderActions?: boolean | ((param?: EditableParam, idx?: number, params?: EditableParam[], actionsCallbacks?: object) => JSX.Element);
|
|
31
|
+
firstInputProps?: AutocompleteProps;
|
|
32
|
+
secondInputProps?: InputProps;
|
|
21
33
|
};
|
|
34
|
+
export {};
|
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-form",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "Form UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@synerise/ds-button": "^0.17.9",
|
|
36
36
|
"@synerise/ds-cruds": "^0.3.17",
|
|
37
|
-
"@synerise/ds-divider": "^0.5.
|
|
37
|
+
"@synerise/ds-divider": "^0.5.21",
|
|
38
38
|
"@synerise/ds-icon": "^0.51.0",
|
|
39
|
-
"@synerise/ds-input": "^0.18.
|
|
39
|
+
"@synerise/ds-input": "^0.18.22",
|
|
40
40
|
"@synerise/ds-typography": "^0.12.7"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"react": ">=16.9.0 < 17.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@synerise/ds-utils": "^0.22.
|
|
47
|
+
"@synerise/ds-utils": "^0.22.10"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "c90bb8af07578c7561792537ba59d87bab251b69"
|
|
50
50
|
}
|