@lowdefy/blocks-antd 4.0.0-rc.10 → 4.0.0-rc.11

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.
@@ -21,6 +21,12 @@ import Label from '../Label/Label.js';
21
21
  import disabledDate from '../../disabledDate.js';
22
22
  const DateTimeSelector = ({ blockId, components: { Icon }, events, loading, methods, properties, required, validation, value })=>{
23
23
  const timeUnit = !type.isString(properties.timeFormat) ? 'minute' : properties.timeFormat === 'HH:mm:ss' ? 'second' : properties.timeFormat === 'HH' ? 'hour' : 'minute';
24
+ const onChange = (newVal)=>{
25
+ methods.setValue(!newVal ? null : moment.utc(newVal.add(properties.selectUTC ? newVal.utcOffset() : 0, 'minutes')).startOf(timeUnit).toDate());
26
+ methods.triggerEvent({
27
+ name: 'onChange'
28
+ });
29
+ };
24
30
  return /*#__PURE__*/ React.createElement(Label, {
25
31
  blockId: blockId,
26
32
  components: {
@@ -72,14 +78,10 @@ const DateTimeSelector = ({ blockId, components: { Icon }, events, loading, meth
72
78
  minuteStep: properties.minuteStep || 5,
73
79
  secondStep: properties.secondStep || 30
74
80
  },
75
- onSelect: (newVal)=>{
76
- // NOTE: we use on select instead of onChange to make the block UX
77
- // more like the DataSelector which changes date on click and not on ok.
78
- methods.setValue(!newVal ? null : moment.utc(newVal.add(properties.selectUTC ? newVal.utcOffset() : 0, 'minutes')).startOf(timeUnit).toDate());
79
- methods.triggerEvent({
80
- name: 'onChange'
81
- });
82
- },
81
+ onChange: onChange,
82
+ onSelect: // NOTE: we use on select instead of onChange to make the block UX
83
+ // more like the DataSelector which changes date on click and not on ok.
84
+ onChange,
83
85
  value: !type.isDate(value) ? null : properties.selectUTC ? moment.utc(value) : moment(value)
84
86
  }))
85
87
  }
@@ -19,7 +19,25 @@ import { Select } from 'antd';
19
19
  import getUniqueValues from '../../getUniqueValues.js';
20
20
  import getValueIndex from '../../getValueIndex.js';
21
21
  import Label from '../Label/Label.js';
22
+ import Tag from '../Tag/Tag.js';
22
23
  const Option = Select.Option;
24
+ const tagRender = (props, option, methods, components)=>{
25
+ const { label, closable, onClose } = props;
26
+ return /*#__PURE__*/ React.createElement(Tag, {
27
+ components: components,
28
+ methods: methods,
29
+ onClose: onClose,
30
+ properties: {
31
+ title: label,
32
+ ...option?.tag || {},
33
+ closable,
34
+ style: {
35
+ marginRight: 3,
36
+ ...option.tag?.style || {}
37
+ }
38
+ }
39
+ });
40
+ };
23
41
  const MultipleSelector = ({ blockId, components: { Icon }, events, loading, methods, properties, required, validation, value })=>{
24
42
  const [fetchState, setFetch] = useState(false);
25
43
  const uniqueValueOptions = getUniqueValues(properties.options || []);
@@ -56,6 +74,10 @@ const MultipleSelector = ({ blockId, components: { Icon }, events, loading, meth
56
74
  disabled: properties.disabled || loading,
57
75
  getPopupContainer: ()=>document.getElementById(`${blockId}_popup`),
58
76
  mode: "multiple",
77
+ tagRender: properties.renderTags && ((props)=>tagRender(props, uniqueValueOptions[props.value], methods, {
78
+ Icon
79
+ })),
80
+ maxTagCount: properties.maxTagCount,
59
81
  notFoundContent: fetchState ? 'Loading' : 'Not found',
60
82
  placeholder: get(properties, 'placeholder', {
61
83
  default: 'Select items'
@@ -178,12 +178,39 @@
178
178
  "docs": {
179
179
  "displayType": "yaml"
180
180
  }
181
+ },
182
+ "tag": {
183
+ "type": "object",
184
+ "properties": {
185
+ "color": {
186
+ "type": "string",
187
+ "description": "Color of the Tag. Preset options are success, processing, error, warning, default, blue, cyan, geekblue, gold, green, lime, magenta, orange, purple, red, volcano, or alternatively any hex color.",
188
+ "docs": {
189
+ "displayType": "color"
190
+ }
191
+ },
192
+ "title": {
193
+ "type": "string",
194
+ "description": "Content title of tag - supports html."
195
+ },
196
+ "icon": {
197
+ "type": ["string", "object"],
198
+ "description": "Name of an Ant Design Icon or properties of an Icon block to customize alert icon.",
199
+ "docs": {
200
+ "displayType": "icon"
201
+ }
202
+ }
203
+ }
181
204
  }
182
205
  }
183
206
  }
184
207
  }
185
208
  ]
186
209
  },
210
+ "maxTagCount": {
211
+ "type": "number",
212
+ "description": "Max tag count to show."
213
+ },
187
214
  "placeholder": {
188
215
  "type": "string",
189
216
  "default": "Select item",
@@ -219,6 +246,10 @@
219
246
  "title": {
220
247
  "type": "string",
221
248
  "description": "Multiple selector label title - supports html."
249
+ },
250
+ "renderTags": {
251
+ "type": "boolean",
252
+ "description": "When true, the selected option labels are rendered as tags in the selector input. This field must be true to render option tag values."
222
253
  }
223
254
  }
224
255
  },
@@ -15,4 +15,5 @@
15
15
  */
16
16
 
17
17
  @import 'antd/lib/select/style/index.less';
18
+ @import 'antd/lib/tag/style/index.less';
18
19
  @import '../Label/style.less';
@@ -89,6 +89,7 @@ const ParagraphBlock = ({ blockId, components: { Icon }, events, methods, proper
89
89
  underline: properties.underline
90
90
  }, renderHtml({
91
91
  html: properties.content,
92
+ events,
92
93
  methods
93
94
  }));
94
95
  ParagraphBlock.defaultProps = blockDefaultProps;
@@ -125,6 +125,10 @@
125
125
  "onCopy": {
126
126
  "type": "array",
127
127
  "description": "Trigger action when copy text is clicked."
128
+ },
129
+ "onTextSelection": {
130
+ "type": "array",
131
+ "description": "Trigger action when text is selected and pass selected text to the event object."
128
132
  }
129
133
  }
130
134
  }
@@ -20,11 +20,11 @@ import Label from '../Label/Label.js';
20
20
  import getValueIndex from '../../getValueIndex.js';
21
21
  import getUniqueValues from '../../getUniqueValues.js';
22
22
  const Option = Select.Option;
23
- function getAllowedRegions({ allowedRegions, regions: regions1 }) {
23
+ function getAllowedRegions({ allowedRegions, regions }) {
24
24
  if (!allowedRegions || allowedRegions.length === 0) {
25
- return regions1;
25
+ return regions;
26
26
  }
27
- return regions1.filter((region)=>allowedRegions.includes(region.code));
27
+ return regions.filter((region)=>allowedRegions.includes(region.code));
28
28
  }
29
29
  function getDefaultRegion({ allowedRegions, defaultRegion, uniqueValueOptions }) {
30
30
  if (!defaultRegion) {
@@ -16,9 +16,13 @@
16
16
  import { Statistic } from 'antd';
17
17
  import { type } from '@lowdefy/helpers';
18
18
  import { blockDefaultProps, renderHtml } from '@lowdefy/block-utils';
19
- const StatisticBlock = ({ blockId, components: { Icon }, events, properties, methods })=>/*#__PURE__*/ React.createElement(Statistic, {
19
+ const StatisticBlock = ({ blockId, components: { Icon }, events, properties, methods })=>{
20
+ const additionalProps = {};
21
+ if (properties.decimalSeparator) {
22
+ additionalProps.decimalSeparator = properties.decimalSeparator;
23
+ }
24
+ return /*#__PURE__*/ React.createElement(Statistic, {
20
25
  className: methods.makeCssClass(properties.style),
21
- decimalSeparator: properties.decimalSeparator,
22
26
  groupSeparator: properties.groupSeparator,
23
27
  id: blockId,
24
28
  loading: properties.loading,
@@ -38,8 +42,10 @@ const StatisticBlock = ({ blockId, components: { Icon }, events, properties, met
38
42
  blockId: `${blockId}_suffixIcon`,
39
43
  events: events,
40
44
  properties: properties.suffixIcon
41
- }) : properties.suffix || ''
45
+ }) : properties.suffix || '',
46
+ ...additionalProps
42
47
  });
48
+ };
43
49
  StatisticBlock.defaultProps = blockDefaultProps;
44
50
  StatisticBlock.meta = {
45
51
  category: 'display',
@@ -0,0 +1,57 @@
1
+ /*
2
+ Copyright 2020-2023 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import React from 'react';
16
+ import { Tag } from 'antd';
17
+ import { blockDefaultProps, renderHtml } from '@lowdefy/block-utils';
18
+ import { type } from '@lowdefy/helpers';
19
+ const TagBlock = ({ blockId, components: { Icon }, events, methods, onClick, onClose, properties })=>{
20
+ const additionalProps = {};
21
+ if (properties.icon) {
22
+ additionalProps.icon = /*#__PURE__*/ React.createElement(Icon, {
23
+ blockId: `${blockId}_icon`,
24
+ events: events,
25
+ properties: properties.icon
26
+ });
27
+ }
28
+ if (onClick || events.onClick) {
29
+ additionalProps.onClick = onClick || (()=>methods.triggerEvent({
30
+ name: 'onClick'
31
+ }));
32
+ }
33
+ if (onClose || events.onClose) {
34
+ additionalProps.onClose = onClose || (()=>methods.triggerEvent({
35
+ name: 'onClose'
36
+ }));
37
+ }
38
+ return /*#__PURE__*/ React.createElement(Tag, {
39
+ id: blockId,
40
+ closable: properties.closable,
41
+ color: properties.color,
42
+ className: methods.makeCssClass(properties.style),
43
+ ...additionalProps
44
+ }, type.isString(properties.title) ? renderHtml({
45
+ html: properties.title,
46
+ methods
47
+ }) : properties.title ?? blockId);
48
+ };
49
+ TagBlock.defaultProps = blockDefaultProps;
50
+ TagBlock.meta = {
51
+ category: 'display',
52
+ icons: [],
53
+ styles: [
54
+ 'blocks/Tag/style.less'
55
+ ]
56
+ };
57
+ export default TagBlock;
@@ -0,0 +1,45 @@
1
+ {
2
+ "properties": {
3
+ "type": "object",
4
+ "additionalProperties": false,
5
+ "properties": {
6
+ "closable": {
7
+ "type": "boolean",
8
+ "default": false,
9
+ "description": "Allow tag to be closed."
10
+ },
11
+ "color": {
12
+ "type": "string",
13
+ "description": "Color of the Tag. Preset options are success, processing, error, warning, default, blue, cyan, geekblue, gold, green, lime, magenta, orange, purple, red, volcano, or alternatively any hex color.",
14
+ "docs": {
15
+ "displayType": "color"
16
+ }
17
+ },
18
+ "title": {
19
+ "type": "string",
20
+ "description": "Content title of tag - supports html."
21
+ },
22
+ "icon": {
23
+ "type": ["string", "object"],
24
+ "description": "Name of an Ant Design Icon or properties of an Icon block to customize alert icon.",
25
+ "docs": {
26
+ "displayType": "icon"
27
+ }
28
+ }
29
+ }
30
+ },
31
+ "events": {
32
+ "type": "object",
33
+ "additionalProperties": false,
34
+ "properties": {
35
+ "onClick": {
36
+ "type": "array",
37
+ "description": "Called when Tag is clicked."
38
+ },
39
+ "onClose": {
40
+ "type": "array",
41
+ "description": "Called when Tag close icon is clicked."
42
+ }
43
+ }
44
+ }
45
+ }
@@ -0,0 +1,17 @@
1
+ /*
2
+ Copyright 2020-2023 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ @import 'antd/lib/tag/style/index.less';
package/dist/blocks.js CHANGED
@@ -63,6 +63,7 @@ export { default as Sider } from './blocks/Sider/Sider.js';
63
63
  export { default as Statistic } from './blocks/Statistic/Statistic.js';
64
64
  export { default as Switch } from './blocks/Switch/Switch.js';
65
65
  export { default as Tabs } from './blocks/Tabs/Tabs.js';
66
+ export { default as Tag } from './blocks/Tag/Tag.js';
66
67
  export { default as TimelineList } from './blocks/TimelineList/TimelineList.js';
67
68
  export { default as TextArea } from './blocks/TextArea/TextArea.js';
68
69
  export { default as TextInput } from './blocks/TextInput/TextInput.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/blocks-antd",
3
- "version": "4.0.0-rc.10",
3
+ "version": "4.0.0-rc.11",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lowdefy Ant Design Blocks",
6
6
  "homepage": "https://lowdefy.com",
@@ -50,24 +50,24 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@ant-design/icons": "4.8.0",
53
- "@lowdefy/block-utils": "4.0.0-rc.10",
54
- "@lowdefy/helpers": "4.0.0-rc.10",
55
- "antd": "4.22.5",
53
+ "@lowdefy/block-utils": "4.0.0-rc.11",
54
+ "@lowdefy/helpers": "4.0.0-rc.11",
55
+ "antd": "4.24.14",
56
56
  "classnames": "2.3.2",
57
57
  "moment": "2.29.4",
58
- "rc-motion": "2.6.2",
58
+ "rc-motion": "2.9.0",
59
59
  "react": "18.2.0",
60
60
  "react-dom": "18.2.0",
61
- "tinycolor2": "1.5.2"
61
+ "tinycolor2": "1.6.0"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@emotion/jest": "11.10.5",
65
- "@lowdefy/block-dev": "4.0.0-rc.10",
66
- "@lowdefy/jest-yaml-transform": "4.0.0-rc.10",
67
- "@lowdefy/node-utils": "4.0.0-rc.10",
65
+ "@lowdefy/block-dev": "4.0.0-rc.11",
66
+ "@lowdefy/jest-yaml-transform": "4.0.0-rc.11",
67
+ "@lowdefy/node-utils": "4.0.0-rc.11",
68
68
  "@swc/cli": "0.1.62",
69
- "@swc/core": "1.3.70",
70
- "@swc/jest": "0.2.27",
69
+ "@swc/core": "1.3.92",
70
+ "@swc/jest": "0.2.29",
71
71
  "@testing-library/dom": "8.19.1",
72
72
  "@testing-library/react": "13.4.0",
73
73
  "@testing-library/user-event": "14.4.3",
@@ -79,5 +79,5 @@
79
79
  "publishConfig": {
80
80
  "access": "public"
81
81
  },
82
- "gitHead": "537af074f27770e32da9da8d48490f2eda94b406"
82
+ "gitHead": "dbc49d3688a6d2f44de25cc3f4bc071627f7ebfa"
83
83
  }