tntd 1.3.66 → 1.4.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/babel.config.js +1 -1
- package/dist/0645cf743e4e44ca9da321d689897f07.png +0 -0
- package/dist/09db77de0c24fa0f45f8a5cf299a3d11.png +0 -0
- package/dist/1.tntd.js +12 -0
- package/dist/1d0b52448de217857b270af807e9360d.png +0 -0
- package/dist/25d78d77c9c2f0d403e5d899ceb5b1ef.png +0 -0
- package/dist/27fa44ff0c98e1594d79b73045aabedf.png +0 -0
- package/dist/2c95075adb68d6131b59cae9fa554ec2.png +0 -0
- package/dist/377c871d922a25c773a9e7c2f42ed7c0.png +0 -0
- package/dist/3d901589b40bd56ff1fde2bbb700bfe1.png +0 -0
- package/dist/4abe481e130d7be0574e45573de8beb7.png +0 -0
- package/dist/95ee2260a509cd630d89c5367ed1973b.png +0 -0
- package/dist/b9dd5ff3622296fbee51ed68f4bca1bf.png +0 -0
- package/dist/bd2921989f9296089ba58efb7a76f3ef.png +0 -0
- package/dist/stats.json +45855 -0
- package/dist/tntd.css +1 -0
- package/dist/tntd.js +15 -0
- package/es/ArrayInput/README.md +129 -0
- package/es/ArrayInput/icon.js +24 -0
- package/es/ArrayInput/index.js +282 -0
- package/es/ArrayInput/index.less +20 -0
- package/es/AuthContext.js +4 -0
- package/es/Columns/README.md +149 -0
- package/es/Columns/index.js +86 -0
- package/es/Columns/index.less +75 -0
- package/es/DevelopmentLogin/LoginModal.js +126 -0
- package/es/DevelopmentLogin/README.md +49 -0
- package/es/DevelopmentLogin/index.js +40 -0
- package/es/Ellipsis/README.md +104 -0
- package/es/Ellipsis/Svg/CopySVG.js +63 -0
- package/es/Ellipsis/Svg/TickSVG.js +41 -0
- package/es/Ellipsis/index.js +143 -0
- package/es/Ellipsis/index.less +56 -0
- package/es/Handle/README.md +104 -0
- package/es/Handle/index.js +92 -0
- package/es/Handle/index.less +9 -0
- package/es/Icon/README.md +119 -0
- package/es/Icon/fonts/demo.css +539 -0
- package/es/Icon/fonts/demo_index.html +3345 -0
- package/es/Icon/fonts/iconfont.css +569 -0
- package/es/Icon/fonts/iconfont.eot +0 -0
- package/es/Icon/fonts/iconfont.js +41 -0
- package/es/Icon/fonts/iconfont.json +975 -0
- package/es/Icon/fonts/iconfont.svg +440 -0
- package/es/Icon/fonts/iconfont.ttf +0 -0
- package/es/Icon/fonts/iconfont.woff +0 -0
- package/es/Icon/fonts/iconfont.woff2 +0 -0
- package/es/Icon/iconList.js +1 -0
- package/es/Icon/index.js +26 -0
- package/es/Icon/index.less +9 -0
- package/es/Img/Contain.js +69 -0
- package/es/Img/Cover.js +126 -0
- package/es/Img/README.md +131 -0
- package/es/Img/index.js +76 -0
- package/es/Layout/ActionsContext.js +3 -0
- package/es/Layout/AppList.js +233 -0
- package/es/Layout/Application.js +115 -0
- package/es/Layout/Avatar.js +116 -0
- package/es/Layout/CompatibleLanguage.js +179 -0
- package/es/Layout/EnterpriseLayout/Avatar.js +144 -0
- package/es/Layout/EnterpriseLayout/Language.js +81 -0
- package/es/Layout/EnterpriseLayout/Theme.js +77 -0
- package/es/Layout/EnterpriseLayout/index.js +31 -0
- package/es/Layout/GlobalNavigation/NavigationPopup.js +396 -0
- package/es/Layout/GlobalNavigation/index.js +137 -0
- package/es/Layout/Header.js +95 -0
- package/es/Layout/HeaderActions.js +107 -0
- package/es/Layout/HeaderNavs.js +93 -0
- package/es/Layout/HeaderTabs.js +264 -0
- package/es/Layout/Iconfont.js +4 -0
- package/es/Layout/Language.js +81 -0
- package/es/Layout/Layout.js +234 -0
- package/es/Layout/Logo.js +86 -0
- package/es/Layout/OrgAppList.js +310 -0
- package/es/Layout/README.md +783 -0
- package/es/Layout/SideMenu.js +340 -0
- package/es/Layout/Theme.js +107 -0
- package/es/Layout/checkAuth.js +29 -0
- package/es/Layout/createActions.js +39 -0
- package/es/Layout/images/avatar/empty.png +0 -0
- package/es/Layout/images/avatar/female1.png +0 -0
- package/es/Layout/images/avatar/female2.png +0 -0
- package/es/Layout/images/avatar/female3.png +0 -0
- package/es/Layout/images/avatar/female4.png +0 -0
- package/es/Layout/images/avatar/female5.png +0 -0
- package/es/Layout/images/avatar/female6.png +0 -0
- package/es/Layout/images/avatar/male1.png +0 -0
- package/es/Layout/images/avatar/male2.png +0 -0
- package/es/Layout/images/avatar/male3.png +0 -0
- package/es/Layout/images/avatar/male4.png +0 -0
- package/es/Layout/images/avatar/male5.png +0 -0
- package/es/Layout/images/avatar/male6.png +0 -0
- package/es/Layout/images/index.js +35 -0
- package/es/Layout/images/logo/baldur.svg +14 -0
- package/es/Layout/images/logo/bi.svg +14 -0
- package/es/Layout/images/logo/bridge.svg +15 -0
- package/es/Layout/images/logo/convert.svg +18 -0
- package/es/Layout/images/logo/dataocean.svg +31 -0
- package/es/Layout/images/logo/default.svg +19 -0
- package/es/Layout/images/logo/dispatch.svg +14 -0
- package/es/Layout/images/logo/graph.svg +26 -0
- package/es/Layout/images/logo/handle.svg +10 -0
- package/es/Layout/images/logo/indicator.svg +41 -0
- package/es/Layout/images/logo/kafka.svg +12 -0
- package/es/Layout/images/logo/logo-custom.svg +13 -0
- package/es/Layout/images/logo/model.svg +17 -0
- package/es/Layout/images/logo/mysql.svg +15 -0
- package/es/Layout/images/logo/orion.svg +24 -0
- package/es/Layout/images/logo/salaxy.svg +11 -0
- package/es/Layout/images/logo/storage.svg +16 -0
- package/es/Layout/images/logo/tnt_cli_identify.svg +19 -0
- package/es/Layout/images/logo/turing.svg +35 -0
- package/es/Layout/images/theme/theme1.svg +35 -0
- package/es/Layout/images/theme/theme2.svg +33 -0
- package/es/Layout/index.js +122 -0
- package/es/Layout/paaslayout/CompactSideMenu.js +167 -0
- package/es/Layout/paaslayout/Header.js +77 -0
- package/es/Layout/paaslayout/Logo.js +22 -0
- package/es/Layout/paaslayout/SideMenu.js +168 -0
- package/es/Layout/paaslayout/index.js +235 -0
- package/es/Layout/storage.js +47 -0
- package/es/Layout/utils.js +136 -0
- package/es/LoadingButton/README.md +75 -0
- package/es/LoadingButton/index.js +45 -0
- package/es/Modal/README.md +59 -0
- package/es/Modal/index.js +96 -0
- package/es/Modal/index.less +86 -0
- package/es/Page/Box.js +74 -0
- package/es/Page/README.md +180 -0
- package/es/Page/index.js +165 -0
- package/es/Page/index.less +144 -0
- package/es/Page/utils.js +23 -0
- package/es/QueryForm/Field/Checkbox.js +21 -0
- package/es/QueryForm/Field/Select.js +80 -0
- package/es/QueryForm/Field/SelectInput.js +92 -0
- package/es/QueryForm/Field/fieldsMap.js +32 -0
- package/es/QueryForm/Field/index.js +157 -0
- package/es/QueryForm/README.md +512 -0
- package/es/QueryForm/createActions.js +53 -0
- package/es/QueryForm/index.js +384 -0
- package/es/QueryForm/index.less +133 -0
- package/es/QueryForm/useForm.js +7 -0
- package/es/QueryListScene/List.js +378 -0
- package/es/QueryListScene/QueryForm.js +166 -0
- package/es/QueryListScene/QueryListScene.js +76 -0
- package/es/QueryListScene/README.md +790 -0
- package/es/QueryListScene/Title.js +12 -0
- package/es/QueryListScene/Toolbar.js +20 -0
- package/es/QueryListScene/createActions.js +72 -0
- package/es/QueryListScene/index.js +19 -0
- package/es/QueryListScene/index.less +97 -0
- package/es/QueryListScene/useActions.js +7 -0
- package/es/Select/DropDownWrap.js +116 -0
- package/es/Select/README.md +68 -0
- package/es/Select/index.js +622 -0
- package/es/Table/README.md +109 -0
- package/es/Table/ResizableTable/index.js +110 -0
- package/es/Table/ResizableTable/index.less +36 -0
- package/es/Table/index.js +35 -0
- package/es/Title/README.md +106 -0
- package/es/Title/index.js +40 -0
- package/es/Title/index.less +170 -0
- package/es/index.js +19 -0
- package/es/locale.js +60 -0
- package/package.json +1 -1
- package/doc-scripts.config.js +0 -37
- package/doc-scripts.renderer.js +0 -11
- package/docs/README.md +0 -1643
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default ['system', 'entry', 'permission', 'graph', 'guanjia', 'case', 'celve1', 'shoucang', 'deal-type', 'pm', 'shoukuan', 'zhibiao', 'puzzle', 'user-group', 'yuce', 'jianmo', 'zhuanzhang', 'yunwei', 'baozhang', 'jizhang', 'tongji', 'pingfen', 'limit', 'spider', 'loan', 'access', 'role', 'org', 'celve', 'book', 'tag', 'shixufenxipeizhi', 'all-cases', 'xianeguanli', 'api', 'network', 'analysis', 'calendar', 'backup', 'all', 'attachment', 'chart-line', 'branches', 'chart-area', 'clock', 'check', 'charging-setting', 'chart-pie-alt', 'dashboard', 'datebase', 'check-reply', 'datacenter', 'connection', 'download', 'date-set', 'event', 'event-wait', 'fieldanalysis', 'exchange', 'knowledge', 'key', 'log', 'list', 'menu', 'index', 'project', 'monitorin', 'pointmap', 'ranking', 'model', 'plan', 'task', 'wait', 'upload', 'question-list', 'read', 'setting', 'reply', 'jinjianguanli', 'change-theme', 'application', 'flag-en', 'flag-cn', 'down', 'up', 'workflow', 'sync', 'folder', 'database', 'circle', 'edit', 'edit-color', 'box', 'layer', 'box-color', 'home-color', 'record', 'monitor', 'time-color', 'user', 'function-color', 'record-color', 'warning-color', 'layer-color', 'template', 'template-color', 'monitor-color', 'search', 'user-color', 'function', 'warning', 'search-color', 'home', 'time', 'application', 'plus', 'minus'];
|
package/es/Icon/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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 _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
|
+
|
|
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
|
+
|
|
7
|
+
import './fonts/iconfont';
|
|
8
|
+
import './index.less';
|
|
9
|
+
export { default as iconList } from './iconList';
|
|
10
|
+
export default (function (_ref) {
|
|
11
|
+
var type = _ref.type,
|
|
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({
|
|
19
|
+
className: "tnt-icon ".concat(className),
|
|
20
|
+
type: type
|
|
21
|
+
}, props), React.createElement("svg", {
|
|
22
|
+
"aria-hidden": "true"
|
|
23
|
+
}, React.createElement("use", {
|
|
24
|
+
xlinkHref: "#".concat(prefix).concat(type)
|
|
25
|
+
})));
|
|
26
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
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 _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
|
+
|
|
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
|
+
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import classnames from 'classnames';
|
|
15
|
+
export default (function (props) {
|
|
16
|
+
var alt = props.alt,
|
|
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, {
|
|
31
|
+
display: 'inline-block',
|
|
32
|
+
width: width,
|
|
33
|
+
height: height,
|
|
34
|
+
overflow: 'hidden'
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (shape === 'rounded') {
|
|
38
|
+
styles.borderRadius = '5px';
|
|
39
|
+
} else if (shape === 'circle') {
|
|
40
|
+
styles.borderRadius = '50%';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var centerStyles = {
|
|
44
|
+
width: width,
|
|
45
|
+
height: height,
|
|
46
|
+
display: 'table-cell',
|
|
47
|
+
verticalAlign: 'middle',
|
|
48
|
+
textAlign: 'center'
|
|
49
|
+
};
|
|
50
|
+
var imgStyles = {
|
|
51
|
+
width: 'auto',
|
|
52
|
+
height: 'auto',
|
|
53
|
+
maxWidth: width,
|
|
54
|
+
maxHeight: height
|
|
55
|
+
};
|
|
56
|
+
var cls = classnames('tntd-img', shape, className);
|
|
57
|
+
return React.createElement("div", _extends({
|
|
58
|
+
className: cls,
|
|
59
|
+
style: styles
|
|
60
|
+
}, others), React.createElement("div", {
|
|
61
|
+
style: centerStyles
|
|
62
|
+
}, React.createElement("img", {
|
|
63
|
+
style: imgStyles,
|
|
64
|
+
onError: onError,
|
|
65
|
+
src: src,
|
|
66
|
+
alt: alt,
|
|
67
|
+
title: title
|
|
68
|
+
})));
|
|
69
|
+
});
|
package/es/Img/Cover.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
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
|
+
|
|
15
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
+
|
|
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
|
+
|
|
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
|
+
|
|
21
|
+
import React from 'react';
|
|
22
|
+
import { useEffect, useState, useRef } from 'react';
|
|
23
|
+
import classnames from 'classnames';
|
|
24
|
+
export default (function (props) {
|
|
25
|
+
var alt = props.alt,
|
|
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
|
+
|
|
39
|
+
var imgRef = useRef();
|
|
40
|
+
|
|
41
|
+
var _useState = useState({
|
|
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
|
+
|
|
53
|
+
var getStyles = function getStyles(wrapWidth, wrapHeight, imgWidth, imgHeight) {
|
|
54
|
+
// 进行等比运算
|
|
55
|
+
var wrapRatio = wrapWidth / wrapHeight;
|
|
56
|
+
var imgRatio = imgWidth / imgHeight;
|
|
57
|
+
var finalWidth = 0;
|
|
58
|
+
var finalHeight = 0;
|
|
59
|
+
var finalMarginTop = 0;
|
|
60
|
+
var finalMarginLeft = 0;
|
|
61
|
+
|
|
62
|
+
if (wrapRatio > imgRatio) {
|
|
63
|
+
// 父框宽度更大,以父框的宽度为准,拉伸图片上移
|
|
64
|
+
finalWidth = wrapWidth;
|
|
65
|
+
finalHeight = finalWidth / imgRatio;
|
|
66
|
+
finalMarginTop = (finalHeight - wrapHeight) / 2 * -1;
|
|
67
|
+
} else {
|
|
68
|
+
// 父框高度更大,以父框高度为准,拉伸图片左移动
|
|
69
|
+
finalHeight = wrapHeight;
|
|
70
|
+
finalWidth = finalHeight * imgRatio;
|
|
71
|
+
finalMarginLeft = (finalWidth - wrapWidth) / 2 * -1;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
height: finalHeight,
|
|
76
|
+
width: finalWidth,
|
|
77
|
+
marginLeft: finalMarginLeft,
|
|
78
|
+
marginTop: finalMarginTop
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
var imgOnload = function imgOnload() {
|
|
83
|
+
var imgDOM = imgRef.current;
|
|
84
|
+
var width = props.width,
|
|
85
|
+
height = props.height;
|
|
86
|
+
var imgWidth = imgDOM.width;
|
|
87
|
+
var imgHeight = imgDOM.height;
|
|
88
|
+
var imgStyles2 = getStyles(width, height, imgWidth, imgHeight);
|
|
89
|
+
setImgStyles(_objectSpread({}, imgStyles, {}, imgStyles2, {
|
|
90
|
+
opacity: 1
|
|
91
|
+
}));
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
useEffect(function () {
|
|
95
|
+
if (width || height) {
|
|
96
|
+
imgOnload();
|
|
97
|
+
}
|
|
98
|
+
}, [width, height]);
|
|
99
|
+
|
|
100
|
+
var styles = _objectSpread({}, style, {
|
|
101
|
+
display: 'inline-block',
|
|
102
|
+
overflow: 'hidden',
|
|
103
|
+
width: width,
|
|
104
|
+
height: height
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
if (shape === 'rounded') {
|
|
108
|
+
styles.borderRadius = '5px';
|
|
109
|
+
} else if (shape === 'circle') {
|
|
110
|
+
styles.borderRadius = '50%';
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
var cls = classnames('tntd-img', shape, className);
|
|
114
|
+
return React.createElement("div", _extends({
|
|
115
|
+
className: cls,
|
|
116
|
+
style: styles
|
|
117
|
+
}, others), React.createElement("img", {
|
|
118
|
+
style: imgStyles,
|
|
119
|
+
onError: onError,
|
|
120
|
+
ref: imgRef,
|
|
121
|
+
src: src,
|
|
122
|
+
alt: alt,
|
|
123
|
+
title: title,
|
|
124
|
+
onLoad: imgOnload
|
|
125
|
+
}));
|
|
126
|
+
});
|
package/es/Img/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
## Img图片组件
|
|
2
|
+
### 基本用法
|
|
3
|
+
```jsx
|
|
4
|
+
import React,{Fragment} from 'react';
|
|
5
|
+
import ReactDOM from 'react-dom';
|
|
6
|
+
import { Img } from 'tntd';
|
|
7
|
+
|
|
8
|
+
const Demo = props => {
|
|
9
|
+
const imgUrl="https://s3.ax1x.com/2020/12/22/rDn40O.jpg";
|
|
10
|
+
return (
|
|
11
|
+
<Fragment>
|
|
12
|
+
<div>
|
|
13
|
+
<h4>cover 模式强调填充铺平</h4>
|
|
14
|
+
<Img
|
|
15
|
+
width={200}
|
|
16
|
+
height={200}
|
|
17
|
+
type='cover'
|
|
18
|
+
src={imgUrl}
|
|
19
|
+
style={{border: '1px solid #ccc', margin: '10px'}}
|
|
20
|
+
/>
|
|
21
|
+
</div>
|
|
22
|
+
<div>
|
|
23
|
+
<h4>contain 模式强调信息全部展示</h4>
|
|
24
|
+
<Img
|
|
25
|
+
width={200}
|
|
26
|
+
height={200}
|
|
27
|
+
type='contain'
|
|
28
|
+
src={imgUrl}
|
|
29
|
+
style={{border: '1px solid #ccc', margin: '10px'}}
|
|
30
|
+
/>
|
|
31
|
+
</div>
|
|
32
|
+
</Fragment>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
ReactDOM.render(
|
|
37
|
+
<Demo />,
|
|
38
|
+
document.getElementById('root')
|
|
39
|
+
);
|
|
40
|
+
```
|
|
41
|
+
### 图片形状
|
|
42
|
+
```jsx
|
|
43
|
+
import React, { Fragment } from 'react';
|
|
44
|
+
import ReactDOM from 'react-dom';
|
|
45
|
+
import { Img } from 'tntd';
|
|
46
|
+
|
|
47
|
+
const Demo = props => {
|
|
48
|
+
const imgUrl="https://s3.ax1x.com/2020/12/22/rDn40O.jpg";
|
|
49
|
+
return (
|
|
50
|
+
<Fragment>
|
|
51
|
+
<div>
|
|
52
|
+
<h4>默认直角矩形</h4>
|
|
53
|
+
<Img
|
|
54
|
+
width={200}
|
|
55
|
+
height={200}
|
|
56
|
+
type='cover'
|
|
57
|
+
src={imgUrl}
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
<div>
|
|
61
|
+
<h4>形状是圆角矩形</h4>
|
|
62
|
+
<Img
|
|
63
|
+
width={200}
|
|
64
|
+
height={200}
|
|
65
|
+
type='cover'
|
|
66
|
+
src={imgUrl}
|
|
67
|
+
shape="rounded"
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
<div>
|
|
71
|
+
<h4>形状是圆形</h4>
|
|
72
|
+
<Img
|
|
73
|
+
width={200}
|
|
74
|
+
height={200}
|
|
75
|
+
type='cover'
|
|
76
|
+
src={imgUrl}
|
|
77
|
+
shape="circle"
|
|
78
|
+
/>
|
|
79
|
+
</div>
|
|
80
|
+
</Fragment>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
ReactDOM.render(
|
|
85
|
+
<Demo />,
|
|
86
|
+
document.getElementById('root')
|
|
87
|
+
);
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 图片加载失败的处理方法
|
|
91
|
+
```jsx
|
|
92
|
+
import React, { Fragment,useState } from 'react';
|
|
93
|
+
import ReactDOM from 'react-dom';
|
|
94
|
+
import { Img } from 'tntd';
|
|
95
|
+
|
|
96
|
+
const Demo = props => {
|
|
97
|
+
const imgUrl="https://sinan.tongdun.me/2020/12/22/rDn40O00.jpg"; // 默认错误的图谱
|
|
98
|
+
const errorImgSrc="https://s3.ax1x.com/2020/12/22/rDUzfx.png";
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<Img
|
|
102
|
+
width={200}
|
|
103
|
+
height={200}
|
|
104
|
+
type='cover'
|
|
105
|
+
src={imgUrl}
|
|
106
|
+
errorImgSrc={errorImgSrc}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
ReactDOM.render(
|
|
112
|
+
<Demo />,
|
|
113
|
+
document.getElementById('root')
|
|
114
|
+
);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### API
|
|
118
|
+
#### img
|
|
119
|
+
| 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 | 可选值 | 备注
|
|
120
|
+
| :-------- | :------------------------------ | :----------- | :---------- | :------- | :------ | :-------
|
|
121
|
+
| type | 图片显示模式 | string | cover | 否 | cover、contain |
|
|
122
|
+
| src | 图片url | string | | 是 | |
|
|
123
|
+
| shape | 图片形状 | string | sharp | 否 | circle、sharp、rounded |
|
|
124
|
+
| title | 图片的 title,hover 上去会显示出来 | string | | 否 | circle、sharp、rounded |
|
|
125
|
+
| alt | 图片的 alt 通常用于屏幕阅读器(盲人)识别 | string | | 否 | |
|
|
126
|
+
| className | 图片的 className | string | | 否 | |
|
|
127
|
+
| style | 图片的 style | object | {} | 否 | |
|
|
128
|
+
| width | 图片显示宽度 | number | | 否 | | 计算图片必需,不传则表现形式等同于普通 img 标签。
|
|
129
|
+
| height | 图片显示高度 | number | | 否 | | 计算图片必需,不传则表现形式等同于普通 img 标签。
|
|
130
|
+
| errorImgSrc | 图片加载失败的兜底图片 | string | | 否 | | 如果图片加载失败,那么将用这张图来代替如果图片加载失败,那么将用这张图来代替
|
|
131
|
+
| onError | 图片加载失败的回调方法 | function | | 否 | | 如果图片加载失败,那么将执行这个 callback 让你添加一些容错逻辑
|
package/es/Img/index.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
|
|
15
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
+
|
|
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
|
+
|
|
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
|
+
|
|
21
|
+
import { Fragment, useState } from 'react';
|
|
22
|
+
import Cover from './Cover';
|
|
23
|
+
import Contain from './Contain';
|
|
24
|
+
export default (function (props) {
|
|
25
|
+
var _ref = props || {},
|
|
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
|
+
|
|
45
|
+
var _useState = useState(src),
|
|
46
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
47
|
+
src2 = _useState2[0],
|
|
48
|
+
setSrc2 = _useState2[1];
|
|
49
|
+
|
|
50
|
+
var handleImgLoadError = function handleImgLoadError() {
|
|
51
|
+
if (errorImgSrc) {
|
|
52
|
+
setSrc2(props.errorImgSrc);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
props.onError && props.onError();
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
var params = _objectSpread({
|
|
59
|
+
type: type,
|
|
60
|
+
src: src2,
|
|
61
|
+
shape: shape,
|
|
62
|
+
title: title,
|
|
63
|
+
alt: alt,
|
|
64
|
+
className: className,
|
|
65
|
+
style: style,
|
|
66
|
+
width: width,
|
|
67
|
+
height: height,
|
|
68
|
+
errorImgSrc: errorImgSrc
|
|
69
|
+
}, rest);
|
|
70
|
+
|
|
71
|
+
return React.createElement(Fragment, null, type === 'contain' && React.createElement(Contain, _extends({}, params, {
|
|
72
|
+
onError: handleImgLoadError
|
|
73
|
+
})), type === 'cover' && React.createElement(Cover, _extends({}, params, {
|
|
74
|
+
onError: handleImgLoadError
|
|
75
|
+
})));
|
|
76
|
+
});
|