@antscorp/antsomi-ui 1.3.3-beta.40 → 1.3.3-beta.41
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.
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Libraries
|
|
2
|
-
import React, { useEffect } from 'react';
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
3
|
import { Col, Row } from 'antd';
|
|
4
|
-
import { useImmer } from 'use-immer';
|
|
5
4
|
// Molecules
|
|
6
5
|
import { Modal } from '../../molecules';
|
|
7
6
|
// Components
|
|
@@ -22,7 +21,7 @@ const OPTIONS = [
|
|
|
22
21
|
];
|
|
23
22
|
export const PopupShortLink = props => {
|
|
24
23
|
const { open, onClose, onOk, disabledOpts, initSelectedProperties, callback } = props;
|
|
25
|
-
const [state, setState] =
|
|
24
|
+
const [state, setState] = useState({
|
|
26
25
|
link: '',
|
|
27
26
|
type: 'individual',
|
|
28
27
|
error: '',
|
|
@@ -32,33 +31,23 @@ export const PopupShortLink = props => {
|
|
|
32
31
|
if (initSelectedProperties && initSelectedProperties.keyTag) {
|
|
33
32
|
type = initSelectedProperties.keyTag === 'shortlink' ? 'individual' : 'general';
|
|
34
33
|
}
|
|
35
|
-
setState(
|
|
36
|
-
draft.link = initSelectedProperties.link;
|
|
37
|
-
draft.type = type;
|
|
38
|
-
});
|
|
34
|
+
setState(prev => (Object.assign(Object.assign({}, prev), { link: initSelectedProperties.link, type: type })));
|
|
39
35
|
}, [initSelectedProperties, setState]);
|
|
40
36
|
const handleClose = () => {
|
|
41
|
-
setState(
|
|
42
|
-
draft.link = '';
|
|
43
|
-
draft.error = '';
|
|
44
|
-
});
|
|
37
|
+
setState(prev => (Object.assign(Object.assign({}, prev), { link: '', error: '' })));
|
|
45
38
|
if (onClose)
|
|
46
39
|
onClose();
|
|
47
40
|
};
|
|
48
41
|
const handleValidate = ({ urlString = state.link, afterValidate }) => {
|
|
49
42
|
const isValid = validateURL(urlString);
|
|
50
|
-
setState(
|
|
51
|
-
draft.error = isValid ? '' : 'Invalid URL';
|
|
52
|
-
});
|
|
43
|
+
setState(prev => (Object.assign(Object.assign({}, prev), { error: isValid ? '' : 'Invalid URL' })));
|
|
53
44
|
if (typeof afterValidate === 'function')
|
|
54
45
|
afterValidate(isValid);
|
|
55
46
|
};
|
|
56
47
|
const handleOnChange = (value) => {
|
|
57
48
|
if (state.error)
|
|
58
49
|
handleValidate({ urlString: value });
|
|
59
|
-
setState(
|
|
60
|
-
draft.link = value;
|
|
61
|
-
});
|
|
50
|
+
setState(prev => (Object.assign(Object.assign({}, prev), { link: value })));
|
|
62
51
|
};
|
|
63
52
|
const handleOnOK = () => {
|
|
64
53
|
handleValidate({
|
|
@@ -74,9 +63,7 @@ export const PopupShortLink = props => {
|
|
|
74
63
|
});
|
|
75
64
|
};
|
|
76
65
|
const onChangeType = (event) => {
|
|
77
|
-
setState(
|
|
78
|
-
draft.type = event.target.value;
|
|
79
|
-
});
|
|
66
|
+
setState(prev => (Object.assign(Object.assign({}, prev), { type: event.target.value })));
|
|
80
67
|
};
|
|
81
68
|
return (React.createElement(Modal, { open: open, onCancel: handleClose, title: React.createElement("div", { style: { color: 'rgba(0, 0, 0, 0.87)', fontWeight: 'normal', fontSize: '16px' } }, "Add Short Link"), okText: "OK", cancelText: "Cancel", closable: false, onOk: handleOnOK, okButtonProps: {
|
|
82
69
|
disabled: !validateURL(state.link),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antscorp/antsomi-ui",
|
|
3
|
-
"version": "1.3.3-beta.
|
|
3
|
+
"version": "1.3.3-beta.41",
|
|
4
4
|
"description": "An enterprise-class UI design language and React UI library.",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"dist/*",
|
|
@@ -77,7 +77,6 @@
|
|
|
77
77
|
"html2canvas": "^1.4.1",
|
|
78
78
|
"i18next": "21.6.16",
|
|
79
79
|
"i18next-browser-languagedetector": "6.1.2",
|
|
80
|
-
"immer": "^10.0.3",
|
|
81
80
|
"lodash": "^4.17.21",
|
|
82
81
|
"moment": "2.29.2",
|
|
83
82
|
"qs": "6.10.3",
|
|
@@ -88,8 +87,7 @@
|
|
|
88
87
|
"rehype-highlight": "^6.0.0",
|
|
89
88
|
"remark-gfm": "^3.0.1",
|
|
90
89
|
"ts-dedent": "^2.2.0",
|
|
91
|
-
"tui-image-editor": "^3.15.3"
|
|
92
|
-
"use-immer": "^0.9.0"
|
|
90
|
+
"tui-image-editor": "^3.15.3"
|
|
93
91
|
},
|
|
94
92
|
"devDependencies": {
|
|
95
93
|
"@ant-design/cssinjs": "^1.6.2",
|