tntd 1.4.20 → 1.4.21
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/components/Handle/README.md +0 -20
- package/components/Handle/index.js +27 -6
- package/components/locale.js +8 -2
- package/dist/1.tntd.js +1 -1
- package/dist/stats.json +23819 -24067
- package/dist/tntd.css +1 -1
- package/dist/tntd.js +13 -8
- package/es/ArrayInput/icon.js +5 -5
- package/es/ArrayInput/index.js +108 -76
- package/es/AuthContext.js +1 -1
- package/es/Columns/index.js +38 -31
- package/es/DevelopmentLogin/LoginModal.js +45 -32
- package/es/DevelopmentLogin/index.js +17 -13
- package/es/Ellipsis/Svg/CopySVG.js +13 -13
- package/es/Ellipsis/Svg/TickSVG.js +8 -8
- package/es/Ellipsis/index.js +69 -58
- package/es/Handle/README.md +0 -20
- package/es/Handle/index.js +67 -32
- package/es/Icon/fonts/iconfont.js +12 -7
- package/es/Icon/index.js +13 -10
- package/es/Img/Contain.js +29 -24
- package/es/Img/Cover.js +54 -40
- package/es/Img/index.js +45 -36
- package/es/Layout/ActionsContext.js +2 -3
- package/es/Layout/AppList.js +92 -37
- package/es/Layout/Application.js +72 -26
- package/es/Layout/Avatar.js +66 -29
- package/es/Layout/CompatibleLanguage.js +94 -39
- package/es/Layout/EnterpriseLayout/Avatar.js +76 -38
- package/es/Layout/EnterpriseLayout/Language.js +32 -14
- package/es/Layout/EnterpriseLayout/Theme.js +34 -16
- package/es/Layout/EnterpriseLayout/index.js +16 -14
- package/es/Layout/GlobalNavigation/NavigationPopup.js +170 -59
- package/es/Layout/GlobalNavigation/index.js +54 -20
- package/es/Layout/Header.js +46 -25
- package/es/Layout/HeaderActions.js +56 -42
- package/es/Layout/HeaderNavs.js +47 -20
- package/es/Layout/HeaderTabs.js +102 -49
- package/es/Layout/Iconfont.js +1 -1
- package/es/Layout/Language.js +32 -14
- package/es/Layout/Layout.js +108 -86
- package/es/Layout/Logo.js +32 -16
- package/es/Layout/OrgAppList.js +107 -62
- package/es/Layout/SideMenu.js +124 -63
- package/es/Layout/Theme.js +61 -23
- package/es/Layout/checkAuth.js +29 -0
- package/es/Layout/index.js +34 -26
- package/es/Layout/paaslayout/CompactSideMenu.js +74 -35
- package/es/Layout/paaslayout/Header.js +45 -22
- package/es/Layout/paaslayout/Logo.js +13 -3
- package/es/Layout/paaslayout/SideMenu.js +78 -39
- package/es/Layout/paaslayout/index.js +102 -75
- package/es/Layout/storage.js +9 -10
- package/es/Layout/utils.js +136 -0
- package/es/LoadingButton/index.js +24 -15
- package/es/Modal/index.js +46 -38
- package/es/Page/Box.js +41 -34
- package/es/Page/index.js +67 -52
- package/es/Page/utils.js +5 -0
- package/es/QueryForm/Field/Checkbox.js +9 -5
- package/es/QueryForm/Field/Select.js +41 -31
- package/es/QueryForm/Field/SelectInput.js +41 -26
- package/es/QueryForm/Field/fieldsMap.js +1 -0
- package/es/QueryForm/Field/index.js +71 -41
- package/es/QueryForm/createActions.js +7 -6
- package/es/QueryForm/index.js +135 -76
- package/es/QueryListScene/List.js +128 -74
- package/es/QueryListScene/QueryForm.js +81 -46
- package/es/QueryListScene/QueryListScene.js +40 -25
- package/es/QueryListScene/Title.js +3 -3
- package/es/QueryListScene/Toolbar.js +12 -11
- package/es/Select/DropDownWrap.js +50 -29
- package/es/Select/index.js +231 -135
- package/es/Table/ResizableTable/index.js +40 -26
- package/es/Table/index.js +16 -18
- package/es/Title/index.js +23 -21
- package/es/locale.js +11 -3
- package/es/utils/checkAuth.js +5 -3
- package/es/utils/findMenuInfoByPath.js +4 -0
- package/es/utils/index.js +23 -12
- package/lib/ArrayInput/icon.js +6 -6
- package/lib/ArrayInput/index.js +127 -78
- package/lib/AuthContext.js +4 -1
- package/lib/Columns/index.js +47 -31
- package/lib/DevelopmentLogin/LoginModal.js +58 -32
- package/lib/DevelopmentLogin/index.js +27 -16
- package/lib/Ellipsis/Svg/CopySVG.js +15 -13
- package/lib/Ellipsis/Svg/TickSVG.js +10 -8
- package/lib/Ellipsis/index.js +80 -57
- package/lib/Handle/README.md +0 -20
- package/lib/Handle/index.js +80 -32
- package/lib/Icon/fonts/iconfont.js +12 -7
- package/lib/Icon/index.js +20 -11
- package/lib/Img/Contain.js +34 -24
- package/lib/Img/Cover.js +65 -42
- package/lib/Img/index.js +51 -36
- package/lib/Layout/ActionsContext.js +4 -1
- package/lib/Layout/AppList.js +118 -40
- package/lib/Layout/Application.js +86 -26
- package/lib/Layout/Avatar.js +86 -32
- package/lib/Layout/CompatibleLanguage.js +110 -39
- package/lib/Layout/EnterpriseLayout/Avatar.js +100 -41
- package/lib/Layout/EnterpriseLayout/Header.js +113 -0
- package/lib/Layout/EnterpriseLayout/HeaderActions.js +104 -0
- package/lib/Layout/EnterpriseLayout/Language.js +48 -17
- package/lib/Layout/EnterpriseLayout/Theme.js +44 -16
- package/lib/Layout/EnterpriseLayout/index.js +23 -14
- package/lib/Layout/GlobalNavigation/NavigationPopup.js +186 -59
- package/lib/Layout/GlobalNavigation/index.js +74 -23
- package/lib/Layout/Header.js +63 -28
- package/lib/Layout/HeaderActions.js +74 -45
- package/lib/Layout/HeaderNavs.js +61 -23
- package/lib/Layout/HeaderTabs.js +118 -51
- package/lib/Layout/Iconfont.js +5 -1
- package/lib/Layout/Language.js +48 -17
- package/lib/Layout/Layout.js +128 -88
- package/lib/Layout/Logo.js +43 -19
- package/lib/Layout/OrgAppList.js +127 -64
- package/lib/Layout/SideMenu.js +143 -65
- package/lib/Layout/Theme.js +73 -23
- package/lib/Layout/checkAuth.js +39 -0
- package/lib/Layout/createActions.js +5 -0
- package/lib/Layout/images/index.js +28 -0
- package/lib/Layout/index.js +55 -30
- package/lib/Layout/paaslayout/CompactSideMenu.js +84 -35
- package/lib/Layout/paaslayout/Header.js +55 -22
- package/lib/Layout/paaslayout/Logo.js +19 -3
- package/lib/Layout/paaslayout/SideMenu.js +87 -39
- package/lib/Layout/paaslayout/index.js +122 -77
- package/lib/Layout/storage.js +40 -11
- package/lib/Layout/utils.js +166 -0
- package/lib/LoadingButton/index.js +29 -15
- package/lib/Modal/index.js +53 -38
- package/lib/Page/Box.js +45 -34
- package/lib/Page/index.js +77 -52
- package/lib/Page/utils.js +9 -1
- package/lib/QueryForm/Field/Checkbox.js +13 -5
- package/lib/QueryForm/Field/Select.js +53 -33
- package/lib/QueryForm/Field/SelectInput.js +56 -28
- package/lib/QueryForm/Field/fieldsMap.js +15 -1
- package/lib/QueryForm/Field/index.js +81 -43
- package/lib/QueryForm/createActions.js +12 -6
- package/lib/QueryForm/index.js +157 -78
- package/lib/QueryForm/useForm.js +5 -0
- package/lib/QueryListScene/List.js +140 -76
- package/lib/QueryListScene/QueryForm.js +86 -46
- package/lib/QueryListScene/QueryListScene.js +46 -25
- package/lib/QueryListScene/Title.js +7 -3
- package/lib/QueryListScene/Toolbar.js +16 -11
- package/lib/QueryListScene/createActions.js +5 -0
- package/lib/QueryListScene/index.js +10 -0
- package/lib/QueryListScene/useActions.js +5 -0
- package/lib/Select/DropDownWrap.js +56 -31
- package/lib/Select/index.js +241 -135
- package/lib/Table/ResizableTable/index.js +48 -26
- package/lib/Table/index.js +28 -17
- package/lib/Title/index.js +28 -21
- package/lib/index.js +56 -35
- package/lib/locale.js +19 -4
- package/lib/utils/checkAuth.js +9 -4
- package/lib/utils/findMenuInfoByPath.js +8 -1
- package/lib/utils/index.js +42 -15
- package/package.json +2 -2
package/es/Icon/index.js
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
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
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
|
+
|
|
4
5
|
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; }
|
|
6
|
+
|
|
5
7
|
import './fonts/iconfont';
|
|
6
8
|
import './index.less';
|
|
7
9
|
export { default as iconList } from './iconList';
|
|
8
10
|
export default (function (_ref) {
|
|
9
11
|
var type = _ref.type,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
_ref$prefix = _ref.prefix,
|
|
13
|
+
prefix = _ref$prefix === void 0 ? 'tnt-' : _ref$prefix,
|
|
14
|
+
_ref$className = _ref.className,
|
|
15
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
16
|
+
props = _objectWithoutProperties(_ref, ["type", "prefix", "className"]);
|
|
17
|
+
|
|
18
|
+
return React.createElement("i", _extends({
|
|
16
19
|
className: "tnt-icon ".concat(className),
|
|
17
20
|
type: type
|
|
18
|
-
}, props),
|
|
21
|
+
}, props), React.createElement("svg", {
|
|
19
22
|
"aria-hidden": "true"
|
|
20
|
-
},
|
|
23
|
+
}, React.createElement("use", {
|
|
21
24
|
xlinkHref: "#".concat(prefix).concat(type)
|
|
22
25
|
})));
|
|
23
26
|
});
|
package/es/Img/Contain.js
CHANGED
|
@@ -1,40 +1,45 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source =
|
|
6
|
-
|
|
7
|
-
function
|
|
8
|
-
|
|
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
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
+
|
|
7
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
|
|
9
9
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
10
|
+
|
|
10
11
|
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; }
|
|
12
|
+
|
|
11
13
|
import React from 'react';
|
|
12
14
|
import classnames from 'classnames';
|
|
13
15
|
export default (function (props) {
|
|
14
16
|
var alt = props.alt,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
title = props.title,
|
|
18
|
+
src = props.src,
|
|
19
|
+
width = props.width,
|
|
20
|
+
height = props.height,
|
|
21
|
+
_props$style = props.style,
|
|
22
|
+
style = _props$style === void 0 ? {} : _props$style,
|
|
23
|
+
className = props.className,
|
|
24
|
+
onError = props.onError,
|
|
25
|
+
shape = props.shape,
|
|
26
|
+
errorImgSrc = props.errorImgSrc,
|
|
27
|
+
type = props.type,
|
|
28
|
+
others = _objectWithoutProperties(props, ["alt", "title", "src", "width", "height", "style", "className", "onError", "shape", "errorImgSrc", "type"]);
|
|
29
|
+
|
|
30
|
+
var styles = _objectSpread({}, style, {
|
|
28
31
|
display: 'inline-block',
|
|
29
32
|
width: width,
|
|
30
33
|
height: height,
|
|
31
34
|
overflow: 'hidden'
|
|
32
35
|
});
|
|
36
|
+
|
|
33
37
|
if (shape === 'rounded') {
|
|
34
38
|
styles.borderRadius = '5px';
|
|
35
39
|
} else if (shape === 'circle') {
|
|
36
40
|
styles.borderRadius = '50%';
|
|
37
41
|
}
|
|
42
|
+
|
|
38
43
|
var centerStyles = {
|
|
39
44
|
width: width,
|
|
40
45
|
height: height,
|
|
@@ -49,12 +54,12 @@ export default (function (props) {
|
|
|
49
54
|
maxHeight: height
|
|
50
55
|
};
|
|
51
56
|
var cls = classnames('tntd-img', shape, className);
|
|
52
|
-
return
|
|
57
|
+
return React.createElement("div", _extends({
|
|
53
58
|
className: cls,
|
|
54
59
|
style: styles
|
|
55
|
-
}, others),
|
|
60
|
+
}, others), React.createElement("div", {
|
|
56
61
|
style: centerStyles
|
|
57
|
-
},
|
|
62
|
+
}, React.createElement("img", {
|
|
58
63
|
style: imgStyles,
|
|
59
64
|
onError: onError,
|
|
60
65
|
src: src,
|
package/es/Img/Cover.js
CHANGED
|
@@ -1,48 +1,55 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source =
|
|
6
|
-
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) ||
|
|
10
|
-
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
function _iterableToArrayLimit(arr, i) {
|
|
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
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
+
|
|
7
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
10
|
+
|
|
11
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
12
|
+
|
|
13
|
+
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
14
|
+
|
|
14
15
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
+
|
|
15
17
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
18
|
+
|
|
16
19
|
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; }
|
|
20
|
+
|
|
17
21
|
import React from 'react';
|
|
18
22
|
import { useEffect, useState, useRef } from 'react';
|
|
19
23
|
import classnames from 'classnames';
|
|
20
24
|
export default (function (props) {
|
|
21
25
|
var alt = props.alt,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
title = props.title,
|
|
27
|
+
src = props.src,
|
|
28
|
+
width = props.width,
|
|
29
|
+
height = props.height,
|
|
30
|
+
_props$style = props.style,
|
|
31
|
+
style = _props$style === void 0 ? {} : _props$style,
|
|
32
|
+
className = props.className,
|
|
33
|
+
onError = props.onError,
|
|
34
|
+
shape = props.shape,
|
|
35
|
+
errorImgSrc = props.errorImgSrc,
|
|
36
|
+
type = props.type,
|
|
37
|
+
others = _objectWithoutProperties(props, ["alt", "title", "src", "width", "height", "style", "className", "onError", "shape", "errorImgSrc", "type"]);
|
|
38
|
+
|
|
34
39
|
var imgRef = useRef();
|
|
40
|
+
|
|
35
41
|
var _useState = useState({
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
display: 'block',
|
|
43
|
+
maxWidth: 'none',
|
|
44
|
+
width: 'auto',
|
|
45
|
+
height: 'auto',
|
|
46
|
+
// transition: 'opacity 0.2s ease',
|
|
47
|
+
opacity: 0
|
|
48
|
+
}),
|
|
49
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
50
|
+
imgStyles = _useState2[0],
|
|
51
|
+
setImgStyles = _useState2[1];
|
|
52
|
+
|
|
46
53
|
var getStyles = function getStyles(wrapWidth, wrapHeight, imgWidth, imgHeight) {
|
|
47
54
|
// 进行等比运算
|
|
48
55
|
var wrapRatio = wrapWidth / wrapHeight;
|
|
@@ -51,6 +58,7 @@ export default (function (props) {
|
|
|
51
58
|
var finalHeight = 0;
|
|
52
59
|
var finalMarginTop = 0;
|
|
53
60
|
var finalMarginLeft = 0;
|
|
61
|
+
|
|
54
62
|
if (wrapRatio > imgRatio) {
|
|
55
63
|
// 父框宽度更大,以父框的宽度为准,拉伸图片上移
|
|
56
64
|
finalWidth = wrapWidth;
|
|
@@ -62,6 +70,7 @@ export default (function (props) {
|
|
|
62
70
|
finalWidth = finalHeight * imgRatio;
|
|
63
71
|
finalMarginLeft = (finalWidth - wrapWidth) / 2 * -1;
|
|
64
72
|
}
|
|
73
|
+
|
|
65
74
|
return {
|
|
66
75
|
height: finalHeight,
|
|
67
76
|
width: finalWidth,
|
|
@@ -69,38 +78,43 @@ export default (function (props) {
|
|
|
69
78
|
marginTop: finalMarginTop
|
|
70
79
|
};
|
|
71
80
|
};
|
|
81
|
+
|
|
72
82
|
var imgOnload = function imgOnload() {
|
|
73
83
|
var imgDOM = imgRef.current;
|
|
74
84
|
var width = props.width,
|
|
75
|
-
|
|
85
|
+
height = props.height;
|
|
76
86
|
var imgWidth = imgDOM.width;
|
|
77
87
|
var imgHeight = imgDOM.height;
|
|
78
88
|
var imgStyles2 = getStyles(width, height, imgWidth, imgHeight);
|
|
79
|
-
setImgStyles(_objectSpread(
|
|
89
|
+
setImgStyles(_objectSpread({}, imgStyles, {}, imgStyles2, {
|
|
80
90
|
opacity: 1
|
|
81
91
|
}));
|
|
82
92
|
};
|
|
93
|
+
|
|
83
94
|
useEffect(function () {
|
|
84
95
|
if (width || height) {
|
|
85
96
|
imgOnload();
|
|
86
97
|
}
|
|
87
98
|
}, [width, height]);
|
|
88
|
-
|
|
99
|
+
|
|
100
|
+
var styles = _objectSpread({}, style, {
|
|
89
101
|
display: 'inline-block',
|
|
90
102
|
overflow: 'hidden',
|
|
91
103
|
width: width,
|
|
92
104
|
height: height
|
|
93
105
|
});
|
|
106
|
+
|
|
94
107
|
if (shape === 'rounded') {
|
|
95
108
|
styles.borderRadius = '5px';
|
|
96
109
|
} else if (shape === 'circle') {
|
|
97
110
|
styles.borderRadius = '50%';
|
|
98
111
|
}
|
|
112
|
+
|
|
99
113
|
var cls = classnames('tntd-img', shape, className);
|
|
100
|
-
return
|
|
114
|
+
return React.createElement("div", _extends({
|
|
101
115
|
className: cls,
|
|
102
116
|
style: styles
|
|
103
|
-
}, others),
|
|
117
|
+
}, others), React.createElement("img", {
|
|
104
118
|
style: imgStyles,
|
|
105
119
|
onError: onError,
|
|
106
120
|
ref: imgRef,
|
package/es/Img/index.js
CHANGED
|
@@ -1,52 +1,60 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source =
|
|
6
|
-
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) ||
|
|
10
|
-
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
function _iterableToArrayLimit(arr, i) {
|
|
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
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
+
|
|
7
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
10
|
+
|
|
11
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
12
|
+
|
|
13
|
+
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
14
|
+
|
|
14
15
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
+
|
|
15
17
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
18
|
+
|
|
16
19
|
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; }
|
|
20
|
+
|
|
17
21
|
import { Fragment, useState } from 'react';
|
|
18
22
|
import Cover from './Cover';
|
|
19
23
|
import Contain from './Contain';
|
|
20
24
|
export default (function (props) {
|
|
21
25
|
var _ref = props || {},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
_ref$type = _ref.type,
|
|
27
|
+
type = _ref$type === void 0 ? 'cover' : _ref$type,
|
|
28
|
+
src = _ref.src,
|
|
29
|
+
_ref$shape = _ref.shape,
|
|
30
|
+
shape = _ref$shape === void 0 ? 'sharp' : _ref$shape,
|
|
31
|
+
_ref$title = _ref.title,
|
|
32
|
+
title = _ref$title === void 0 ? '' : _ref$title,
|
|
33
|
+
_ref$alt = _ref.alt,
|
|
34
|
+
alt = _ref$alt === void 0 ? '' : _ref$alt,
|
|
35
|
+
className = _ref.className,
|
|
36
|
+
style = _ref.style,
|
|
37
|
+
_ref$width = _ref.width,
|
|
38
|
+
width = _ref$width === void 0 ? 'auto' : _ref$width,
|
|
39
|
+
_ref$height = _ref.height,
|
|
40
|
+
height = _ref$height === void 0 ? 'auto' : _ref$height,
|
|
41
|
+
errorImgSrc = _ref.errorImgSrc,
|
|
42
|
+
onError = _ref.onError,
|
|
43
|
+
rest = _objectWithoutProperties(_ref, ["type", "src", "shape", "title", "alt", "className", "style", "width", "height", "errorImgSrc", "onError"]);
|
|
44
|
+
|
|
40
45
|
var _useState = useState(src),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
47
|
+
src2 = _useState2[0],
|
|
48
|
+
setSrc2 = _useState2[1];
|
|
49
|
+
|
|
44
50
|
var handleImgLoadError = function handleImgLoadError() {
|
|
45
51
|
if (errorImgSrc) {
|
|
46
52
|
setSrc2(props.errorImgSrc);
|
|
47
53
|
}
|
|
54
|
+
|
|
48
55
|
props.onError && props.onError();
|
|
49
56
|
};
|
|
57
|
+
|
|
50
58
|
var params = _objectSpread({
|
|
51
59
|
type: type,
|
|
52
60
|
src: src2,
|
|
@@ -59,9 +67,10 @@ export default (function (props) {
|
|
|
59
67
|
height: height,
|
|
60
68
|
errorImgSrc: errorImgSrc
|
|
61
69
|
}, rest);
|
|
62
|
-
|
|
70
|
+
|
|
71
|
+
return React.createElement(Fragment, null, type === 'contain' && React.createElement(Contain, _extends({}, params, {
|
|
63
72
|
onError: handleImgLoadError
|
|
64
|
-
})), type === 'cover' &&
|
|
73
|
+
})), type === 'cover' && React.createElement(Cover, _extends({}, params, {
|
|
65
74
|
onError: handleImgLoadError
|
|
66
75
|
})));
|
|
67
76
|
});
|