@lowdefy/blocks-antd 4.0.0 → 4.0.2
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/dist/blocks/Breadcrumb/Breadcrumb.js +2 -2
- package/dist/blocks/Modal/Modal.js +1 -0
- package/dist/blocks/Modal/schema.json +7 -0
- package/dist/blocks/MultipleSelector/MultipleSelector.js +1 -1
- package/dist/blocks/MultipleSelector/schema.json +10 -0
- package/dist/blocks/Pagination/Pagination.js +32 -19
- package/dist/blocks/Selector/Selector.js +1 -1
- package/dist/blocks/Selector/schema.json +10 -0
- package/dist/blocks/TextInput/TextInput.js +4 -3
- package/dist/blocks/TextInput/schema.json +5 -0
- package/package.json +6 -6
|
@@ -41,7 +41,7 @@ const BreadcrumbBlock = ({ blockId, events, components: { Icon, Link }, methods,
|
|
|
41
41
|
},
|
|
42
42
|
link.style
|
|
43
43
|
]),
|
|
44
|
-
...link
|
|
44
|
+
...type.isObject(link) ? link : {}
|
|
45
45
|
}, ()=>/*#__PURE__*/ React.createElement(React.Fragment, null, link.icon && /*#__PURE__*/ React.createElement(Icon, {
|
|
46
46
|
blockId: `${blockId}_${index}_icon`,
|
|
47
47
|
events: events,
|
|
@@ -50,7 +50,7 @@ const BreadcrumbBlock = ({ blockId, events, components: { Icon, Link }, methods,
|
|
|
50
50
|
...type.isObject(link.icon) ? link.icon : {},
|
|
51
51
|
style: {
|
|
52
52
|
marginRight: 8,
|
|
53
|
-
...link.icon.style
|
|
53
|
+
...type.isObject(link.icon?.style) ? link.icon.style : {}
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
}), type.isString(link) ? link : link.label)))));
|
|
@@ -69,6 +69,7 @@ const ModalBlock = ({ blockId, content, events, methods, properties })=>{
|
|
|
69
69
|
okButtonProps: properties.okButtonProps,
|
|
70
70
|
okText: properties.okText ?? 'Ok',
|
|
71
71
|
okType: properties.okButtonType ?? 'primary',
|
|
72
|
+
style: properties.style,
|
|
72
73
|
title: renderHtml({
|
|
73
74
|
html: properties.title,
|
|
74
75
|
methods
|
|
@@ -78,7 +78,7 @@ const MultipleSelector = ({ blockId, components: { Icon }, events, loading, meth
|
|
|
78
78
|
Icon
|
|
79
79
|
})),
|
|
80
80
|
maxTagCount: properties.maxTagCount,
|
|
81
|
-
notFoundContent: fetchState ? 'Loading' : 'Not found',
|
|
81
|
+
notFoundContent: fetchState ? properties.loadingPlaceholder || 'Loading' : properties.notFoundContent || 'Not found',
|
|
82
82
|
placeholder: loading ? 'Loading...' : get(properties, 'placeholder', {
|
|
83
83
|
default: 'Select items'
|
|
84
84
|
}),
|
|
@@ -216,6 +216,16 @@
|
|
|
216
216
|
"default": "Select item",
|
|
217
217
|
"description": "Placeholder text inside the block before user selects input."
|
|
218
218
|
},
|
|
219
|
+
"loadingPlaceholder": {
|
|
220
|
+
"type": "string",
|
|
221
|
+
"default": "Loading",
|
|
222
|
+
"description": "Placeholder text to show in options while the block is loading."
|
|
223
|
+
},
|
|
224
|
+
"notFoundContent": {
|
|
225
|
+
"type": "string",
|
|
226
|
+
"default": "not Found",
|
|
227
|
+
"description": "Placeholder text to show when list of options are empty."
|
|
228
|
+
},
|
|
219
229
|
"selectedIcon": {
|
|
220
230
|
"type": ["string", "object"],
|
|
221
231
|
"default": "AiOutlineCheck",
|
|
@@ -12,20 +12,16 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ import React from 'react';
|
|
15
|
+
*/ import React, { useState, useEffect } from 'react';
|
|
16
16
|
import { blockDefaultProps } from '@lowdefy/block-utils';
|
|
17
17
|
import { Pagination } from 'antd';
|
|
18
18
|
import { type } from '@lowdefy/helpers';
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
return 10;
|
|
27
|
-
};
|
|
28
|
-
const createChangeHandler = ({ eventName, methods })=>(current, pageSize)=>{
|
|
19
|
+
const createChangeHandler = ({ eventName, methods, setState })=>(current, pageSize)=>{
|
|
20
|
+
setState({
|
|
21
|
+
current,
|
|
22
|
+
pageSize,
|
|
23
|
+
skip: (current - 1) * pageSize
|
|
24
|
+
});
|
|
29
25
|
methods.setValue({
|
|
30
26
|
current,
|
|
31
27
|
pageSize,
|
|
@@ -41,6 +37,24 @@ const createChangeHandler = ({ eventName, methods })=>(current, pageSize)=>{
|
|
|
41
37
|
});
|
|
42
38
|
};
|
|
43
39
|
const PaginationBlock = ({ blockId, loading, methods, properties, value })=>{
|
|
40
|
+
const [state, setState] = useState({
|
|
41
|
+
current: parseInt(value?.current) || 1,
|
|
42
|
+
pageSize: parseInt(value?.pageSize) || properties.pageSizeOptions?.[0] || 10,
|
|
43
|
+
skip: parseInt(value?.skip) || 0
|
|
44
|
+
});
|
|
45
|
+
useEffect(()=>{
|
|
46
|
+
if (JSON.stringify(value) !== JSON.stringify(state)) {
|
|
47
|
+
const nextState = {
|
|
48
|
+
current: parseInt(value?.current) || state.current,
|
|
49
|
+
pageSize: parseInt(value?.pageSize) || state.pageSize,
|
|
50
|
+
skip: parseInt(value?.skip) || state.skip
|
|
51
|
+
};
|
|
52
|
+
setState(nextState);
|
|
53
|
+
methods.setValue(nextState);
|
|
54
|
+
}
|
|
55
|
+
}, [
|
|
56
|
+
value
|
|
57
|
+
]);
|
|
44
58
|
const showTotal = type.isFunction(properties.showTotal) ? properties.showTotal : (total, range)=>{
|
|
45
59
|
if (type.isString(properties.showTotal)) {
|
|
46
60
|
return properties.showTotal;
|
|
@@ -56,16 +70,15 @@ const PaginationBlock = ({ blockId, loading, methods, properties, value })=>{
|
|
|
56
70
|
hideOnSinglePage: properties.hideOnSinglePage,
|
|
57
71
|
onChange: createChangeHandler({
|
|
58
72
|
eventName: 'onChange',
|
|
59
|
-
methods
|
|
73
|
+
methods,
|
|
74
|
+
setState
|
|
60
75
|
}),
|
|
61
76
|
onShowSizeChange: createChangeHandler({
|
|
62
77
|
eventName: 'onSizeChange',
|
|
63
|
-
methods
|
|
64
|
-
|
|
65
|
-
pageSize: getPageSize({
|
|
66
|
-
properties,
|
|
67
|
-
value
|
|
78
|
+
methods,
|
|
79
|
+
setState
|
|
68
80
|
}),
|
|
81
|
+
pageSize: state.pageSize,
|
|
69
82
|
pageSizeOptions: properties.pageSizeOptions || [
|
|
70
83
|
10,
|
|
71
84
|
20,
|
|
@@ -78,14 +91,14 @@ const PaginationBlock = ({ blockId, loading, methods, properties, value })=>{
|
|
|
78
91
|
simple: !!properties.simple,
|
|
79
92
|
size: properties.size,
|
|
80
93
|
total: properties.total !== undefined ? properties.total : 100,
|
|
81
|
-
current:
|
|
94
|
+
current: state.current
|
|
82
95
|
});
|
|
83
96
|
};
|
|
84
97
|
PaginationBlock.defaultProps = blockDefaultProps;
|
|
85
98
|
PaginationBlock.meta = {
|
|
86
99
|
valueType: 'object',
|
|
87
100
|
initValue: {
|
|
88
|
-
current:
|
|
101
|
+
current: 1,
|
|
89
102
|
pageSize: 10,
|
|
90
103
|
skip: 0
|
|
91
104
|
},
|
|
@@ -78,7 +78,7 @@ const Selector = ({ blockId, components: { Icon, Link }, events, loading, method
|
|
|
78
78
|
}),
|
|
79
79
|
size: properties.size,
|
|
80
80
|
filterOption: (input, option)=>(option.filterstring || option.children.props.html || '').toLowerCase().indexOf(input.toLowerCase()) >= 0,
|
|
81
|
-
notFoundContent: fetchState ? 'Loading' : 'Not found',
|
|
81
|
+
notFoundContent: fetchState ? properties.loadingPlaceholder || 'Loading' : properties.notFoundContent || 'Not found',
|
|
82
82
|
onChange: (newVal)=>{
|
|
83
83
|
methods.setValue(type.isPrimitive(uniqueValueOptions[newVal]) ? uniqueValueOptions[newVal] : uniqueValueOptions[newVal].value);
|
|
84
84
|
methods.triggerEvent({
|
|
@@ -189,6 +189,16 @@
|
|
|
189
189
|
"default": "Select item",
|
|
190
190
|
"description": "Placeholder text inside the block before user selects input."
|
|
191
191
|
},
|
|
192
|
+
"loadingPlaceholder": {
|
|
193
|
+
"type": "string",
|
|
194
|
+
"default": "Loading",
|
|
195
|
+
"description": "Placeholder text to show in options while the block is loading."
|
|
196
|
+
},
|
|
197
|
+
"notFoundContent": {
|
|
198
|
+
"type": "string",
|
|
199
|
+
"default": "not Found",
|
|
200
|
+
"description": "Placeholder text to show when list of options are empty."
|
|
201
|
+
},
|
|
192
202
|
"showArrow": {
|
|
193
203
|
"type": "boolean",
|
|
194
204
|
"default": true,
|
|
@@ -17,7 +17,7 @@ import { Input } from 'antd';
|
|
|
17
17
|
import { blockDefaultProps } from '@lowdefy/block-utils';
|
|
18
18
|
import Label from '../Label/Label.js';
|
|
19
19
|
import useRunAfterUpdate from '../../useRunAfterUpdate.js';
|
|
20
|
-
const TextInput = ({ blockId, components: { Icon, Link }, events, loading, methods, properties, required, validation, value })=>{
|
|
20
|
+
const TextInput = ({ blockId, components: { Icon, Link }, events, loading, methods, onChange, properties, required, validation, value })=>{
|
|
21
21
|
return /*#__PURE__*/ React.createElement(Label, {
|
|
22
22
|
blockId: blockId,
|
|
23
23
|
components: {
|
|
@@ -45,9 +45,10 @@ const TextInput = ({ blockId, components: { Icon, Link }, events, loading, metho
|
|
|
45
45
|
maxLength: properties.maxLength,
|
|
46
46
|
placeholder: properties.placeholder,
|
|
47
47
|
size: properties.size,
|
|
48
|
+
showCount: properties.showCount,
|
|
48
49
|
status: validation.status,
|
|
49
50
|
value: value,
|
|
50
|
-
onChange: (event)=>{
|
|
51
|
+
onChange: onChange || ((event)=>{
|
|
51
52
|
let input = event.target.value;
|
|
52
53
|
if (properties.replaceInput) {
|
|
53
54
|
const regex = new RegExp(properties.replaceInput.pattern, properties.replaceInput.flags ?? 'gm');
|
|
@@ -62,7 +63,7 @@ const TextInput = ({ blockId, components: { Icon, Link }, events, loading, metho
|
|
|
62
63
|
runAfterUpdate(()=>{
|
|
63
64
|
event.target.setSelectionRange(cStart, cEnd);
|
|
64
65
|
});
|
|
65
|
-
},
|
|
66
|
+
}),
|
|
66
67
|
onPressEnter: ()=>{
|
|
67
68
|
methods.triggerEvent({
|
|
68
69
|
name: 'onPressEnter'
|
|
@@ -136,6 +136,11 @@
|
|
|
136
136
|
"default": "middle",
|
|
137
137
|
"description": "Size of the block."
|
|
138
138
|
},
|
|
139
|
+
"showCount": {
|
|
140
|
+
"type": "boolean",
|
|
141
|
+
"default": false,
|
|
142
|
+
"description": "Show text character count"
|
|
143
|
+
},
|
|
139
144
|
"suffix": {
|
|
140
145
|
"type": "string",
|
|
141
146
|
"description": "Suffix text for the block, priority over suffixIcon."
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/blocks-antd",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy Ant Design Blocks",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@ant-design/icons": "4.8.0",
|
|
46
|
-
"@lowdefy/block-utils": "4.0.
|
|
47
|
-
"@lowdefy/helpers": "4.0.
|
|
46
|
+
"@lowdefy/block-utils": "4.0.2",
|
|
47
|
+
"@lowdefy/helpers": "4.0.2",
|
|
48
48
|
"antd": "4.24.14",
|
|
49
49
|
"classnames": "2.3.2",
|
|
50
50
|
"moment": "2.29.4",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@emotion/jest": "11.10.5",
|
|
58
|
-
"@lowdefy/block-dev": "4.0.
|
|
59
|
-
"@lowdefy/jest-yaml-transform": "4.0.
|
|
60
|
-
"@lowdefy/node-utils": "4.0.
|
|
58
|
+
"@lowdefy/block-dev": "4.0.2",
|
|
59
|
+
"@lowdefy/jest-yaml-transform": "4.0.2",
|
|
60
|
+
"@lowdefy/node-utils": "4.0.2",
|
|
61
61
|
"@swc/cli": "0.1.63",
|
|
62
62
|
"@swc/core": "1.3.99",
|
|
63
63
|
"@swc/jest": "0.2.29",
|