tntd 1.4.20 → 1.4.22
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 +44 -7
- package/components/locale.js +8 -2
- package/dist/1.tntd.js +1 -1
- package/dist/stats.json +24430 -24390
- 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 +100 -33
- 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 +119 -33
- 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/lib/Icon/index.js
CHANGED
|
@@ -3,35 +3,44 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
6
|
Object.defineProperty(exports, "iconList", {
|
|
8
7
|
enumerable: true,
|
|
9
8
|
get: function get() {
|
|
10
9
|
return _iconList["default"];
|
|
11
10
|
}
|
|
12
11
|
});
|
|
12
|
+
exports["default"] = void 0;
|
|
13
|
+
|
|
13
14
|
require("./fonts/iconfont");
|
|
15
|
+
|
|
14
16
|
require("./index.less");
|
|
17
|
+
|
|
15
18
|
var _iconList = _interopRequireDefault(require("./iconList"));
|
|
16
|
-
|
|
19
|
+
|
|
17
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
18
|
-
|
|
21
|
+
|
|
22
|
+
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); }
|
|
23
|
+
|
|
19
24
|
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; }
|
|
25
|
+
|
|
20
26
|
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; }
|
|
27
|
+
|
|
21
28
|
var _default = function _default(_ref) {
|
|
22
29
|
var type = _ref.type,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
_ref$prefix = _ref.prefix,
|
|
31
|
+
prefix = _ref$prefix === void 0 ? 'tnt-' : _ref$prefix,
|
|
32
|
+
_ref$className = _ref.className,
|
|
33
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
34
|
+
props = _objectWithoutProperties(_ref, ["type", "prefix", "className"]);
|
|
35
|
+
|
|
36
|
+
return React.createElement("i", _extends({
|
|
29
37
|
className: "tnt-icon ".concat(className),
|
|
30
38
|
type: type
|
|
31
|
-
}, props),
|
|
39
|
+
}, props), React.createElement("svg", {
|
|
32
40
|
"aria-hidden": "true"
|
|
33
|
-
},
|
|
41
|
+
}, React.createElement("use", {
|
|
34
42
|
xlinkHref: "#".concat(prefix).concat(type)
|
|
35
43
|
})));
|
|
36
44
|
};
|
|
45
|
+
|
|
37
46
|
exports["default"] = _default;
|
package/lib/Img/Contain.js
CHANGED
|
@@ -1,47 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports["default"] = void 0;
|
|
7
|
+
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
9
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
-
|
|
11
|
+
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
function
|
|
13
|
+
|
|
14
|
+
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); }
|
|
15
|
+
|
|
16
|
+
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; }
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
18
22
|
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; }
|
|
23
|
+
|
|
19
24
|
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; }
|
|
25
|
+
|
|
20
26
|
var _default = function _default(props) {
|
|
21
27
|
var alt = props.alt,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
title = props.title,
|
|
29
|
+
src = props.src,
|
|
30
|
+
width = props.width,
|
|
31
|
+
height = props.height,
|
|
32
|
+
_props$style = props.style,
|
|
33
|
+
style = _props$style === void 0 ? {} : _props$style,
|
|
34
|
+
className = props.className,
|
|
35
|
+
onError = props.onError,
|
|
36
|
+
shape = props.shape,
|
|
37
|
+
errorImgSrc = props.errorImgSrc,
|
|
38
|
+
type = props.type,
|
|
39
|
+
others = _objectWithoutProperties(props, ["alt", "title", "src", "width", "height", "style", "className", "onError", "shape", "errorImgSrc", "type"]);
|
|
40
|
+
|
|
41
|
+
var styles = _objectSpread({}, style, {
|
|
35
42
|
display: 'inline-block',
|
|
36
43
|
width: width,
|
|
37
44
|
height: height,
|
|
38
45
|
overflow: 'hidden'
|
|
39
46
|
});
|
|
47
|
+
|
|
40
48
|
if (shape === 'rounded') {
|
|
41
49
|
styles.borderRadius = '5px';
|
|
42
50
|
} else if (shape === 'circle') {
|
|
43
51
|
styles.borderRadius = '50%';
|
|
44
52
|
}
|
|
53
|
+
|
|
45
54
|
var centerStyles = {
|
|
46
55
|
width: width,
|
|
47
56
|
height: height,
|
|
@@ -56,12 +65,12 @@ var _default = function _default(props) {
|
|
|
56
65
|
maxHeight: height
|
|
57
66
|
};
|
|
58
67
|
var cls = (0, _classnames["default"])('tntd-img', shape, className);
|
|
59
|
-
return
|
|
68
|
+
return _react["default"].createElement("div", _extends({
|
|
60
69
|
className: cls,
|
|
61
70
|
style: styles
|
|
62
|
-
}, others),
|
|
71
|
+
}, others), _react["default"].createElement("div", {
|
|
63
72
|
style: centerStyles
|
|
64
|
-
},
|
|
73
|
+
}, _react["default"].createElement("img", {
|
|
65
74
|
style: imgStyles,
|
|
66
75
|
onError: onError,
|
|
67
76
|
src: src,
|
|
@@ -69,4 +78,5 @@ var _default = function _default(props) {
|
|
|
69
78
|
title: title
|
|
70
79
|
})));
|
|
71
80
|
};
|
|
81
|
+
|
|
72
82
|
exports["default"] = _default;
|
package/lib/Img/Cover.js
CHANGED
|
@@ -1,56 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) {
|
|
3
|
+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports["default"] = void 0;
|
|
9
|
+
|
|
8
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
9
12
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
-
|
|
13
|
+
|
|
11
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
function
|
|
24
|
-
|
|
15
|
+
|
|
16
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
17
|
+
|
|
18
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
|
|
20
|
+
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); }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
28
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
29
|
+
|
|
30
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
31
|
+
|
|
32
|
+
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; }
|
|
33
|
+
|
|
25
34
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
35
|
+
|
|
26
36
|
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; }
|
|
37
|
+
|
|
27
38
|
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; }
|
|
39
|
+
|
|
28
40
|
var _default = function _default(props) {
|
|
29
41
|
var alt = props.alt,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
title = props.title,
|
|
43
|
+
src = props.src,
|
|
44
|
+
width = props.width,
|
|
45
|
+
height = props.height,
|
|
46
|
+
_props$style = props.style,
|
|
47
|
+
style = _props$style === void 0 ? {} : _props$style,
|
|
48
|
+
className = props.className,
|
|
49
|
+
onError = props.onError,
|
|
50
|
+
shape = props.shape,
|
|
51
|
+
errorImgSrc = props.errorImgSrc,
|
|
52
|
+
type = props.type,
|
|
53
|
+
others = _objectWithoutProperties(props, ["alt", "title", "src", "width", "height", "style", "className", "onError", "shape", "errorImgSrc", "type"]);
|
|
54
|
+
|
|
42
55
|
var imgRef = (0, _react.useRef)();
|
|
56
|
+
|
|
43
57
|
var _useState = (0, _react.useState)({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
display: 'block',
|
|
59
|
+
maxWidth: 'none',
|
|
60
|
+
width: 'auto',
|
|
61
|
+
height: 'auto',
|
|
62
|
+
// transition: 'opacity 0.2s ease',
|
|
63
|
+
opacity: 0
|
|
64
|
+
}),
|
|
65
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
66
|
+
imgStyles = _useState2[0],
|
|
67
|
+
setImgStyles = _useState2[1];
|
|
68
|
+
|
|
54
69
|
var getStyles = function getStyles(wrapWidth, wrapHeight, imgWidth, imgHeight) {
|
|
55
70
|
// 进行等比运算
|
|
56
71
|
var wrapRatio = wrapWidth / wrapHeight;
|
|
@@ -59,6 +74,7 @@ var _default = function _default(props) {
|
|
|
59
74
|
var finalHeight = 0;
|
|
60
75
|
var finalMarginTop = 0;
|
|
61
76
|
var finalMarginLeft = 0;
|
|
77
|
+
|
|
62
78
|
if (wrapRatio > imgRatio) {
|
|
63
79
|
// 父框宽度更大,以父框的宽度为准,拉伸图片上移
|
|
64
80
|
finalWidth = wrapWidth;
|
|
@@ -70,6 +86,7 @@ var _default = function _default(props) {
|
|
|
70
86
|
finalWidth = finalHeight * imgRatio;
|
|
71
87
|
finalMarginLeft = (finalWidth - wrapWidth) / 2 * -1;
|
|
72
88
|
}
|
|
89
|
+
|
|
73
90
|
return {
|
|
74
91
|
height: finalHeight,
|
|
75
92
|
width: finalWidth,
|
|
@@ -77,38 +94,43 @@ var _default = function _default(props) {
|
|
|
77
94
|
marginTop: finalMarginTop
|
|
78
95
|
};
|
|
79
96
|
};
|
|
97
|
+
|
|
80
98
|
var imgOnload = function imgOnload() {
|
|
81
99
|
var imgDOM = imgRef.current;
|
|
82
100
|
var width = props.width,
|
|
83
|
-
|
|
101
|
+
height = props.height;
|
|
84
102
|
var imgWidth = imgDOM.width;
|
|
85
103
|
var imgHeight = imgDOM.height;
|
|
86
104
|
var imgStyles2 = getStyles(width, height, imgWidth, imgHeight);
|
|
87
|
-
setImgStyles(_objectSpread(
|
|
105
|
+
setImgStyles(_objectSpread({}, imgStyles, {}, imgStyles2, {
|
|
88
106
|
opacity: 1
|
|
89
107
|
}));
|
|
90
108
|
};
|
|
109
|
+
|
|
91
110
|
(0, _react.useEffect)(function () {
|
|
92
111
|
if (width || height) {
|
|
93
112
|
imgOnload();
|
|
94
113
|
}
|
|
95
114
|
}, [width, height]);
|
|
96
|
-
|
|
115
|
+
|
|
116
|
+
var styles = _objectSpread({}, style, {
|
|
97
117
|
display: 'inline-block',
|
|
98
118
|
overflow: 'hidden',
|
|
99
119
|
width: width,
|
|
100
120
|
height: height
|
|
101
121
|
});
|
|
122
|
+
|
|
102
123
|
if (shape === 'rounded') {
|
|
103
124
|
styles.borderRadius = '5px';
|
|
104
125
|
} else if (shape === 'circle') {
|
|
105
126
|
styles.borderRadius = '50%';
|
|
106
127
|
}
|
|
128
|
+
|
|
107
129
|
var cls = (0, _classnames["default"])('tntd-img', shape, className);
|
|
108
|
-
return
|
|
130
|
+
return _react["default"].createElement("div", _extends({
|
|
109
131
|
className: cls,
|
|
110
132
|
style: styles
|
|
111
|
-
}, others),
|
|
133
|
+
}, others), _react["default"].createElement("img", {
|
|
112
134
|
style: imgStyles,
|
|
113
135
|
onError: onError,
|
|
114
136
|
ref: imgRef,
|
|
@@ -118,4 +140,5 @@ var _default = function _default(props) {
|
|
|
118
140
|
onLoad: imgOnload
|
|
119
141
|
}));
|
|
120
142
|
};
|
|
143
|
+
|
|
121
144
|
exports["default"] = _default;
|
package/lib/Img/index.js
CHANGED
|
@@ -1,59 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports["default"] = void 0;
|
|
7
|
+
|
|
8
8
|
var _react = require("react");
|
|
9
|
+
|
|
9
10
|
var _Cover = _interopRequireDefault(require("./Cover"));
|
|
11
|
+
|
|
10
12
|
var _Contain = _interopRequireDefault(require("./Contain"));
|
|
11
|
-
|
|
13
|
+
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
15
|
+
|
|
16
|
+
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); }
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
25
|
+
|
|
26
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
24
30
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
31
|
+
|
|
25
32
|
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; }
|
|
33
|
+
|
|
26
34
|
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; }
|
|
35
|
+
|
|
27
36
|
var _default = function _default(props) {
|
|
28
37
|
var _ref = props || {},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
_ref$type = _ref.type,
|
|
39
|
+
type = _ref$type === void 0 ? 'cover' : _ref$type,
|
|
40
|
+
src = _ref.src,
|
|
41
|
+
_ref$shape = _ref.shape,
|
|
42
|
+
shape = _ref$shape === void 0 ? 'sharp' : _ref$shape,
|
|
43
|
+
_ref$title = _ref.title,
|
|
44
|
+
title = _ref$title === void 0 ? '' : _ref$title,
|
|
45
|
+
_ref$alt = _ref.alt,
|
|
46
|
+
alt = _ref$alt === void 0 ? '' : _ref$alt,
|
|
47
|
+
className = _ref.className,
|
|
48
|
+
style = _ref.style,
|
|
49
|
+
_ref$width = _ref.width,
|
|
50
|
+
width = _ref$width === void 0 ? 'auto' : _ref$width,
|
|
51
|
+
_ref$height = _ref.height,
|
|
52
|
+
height = _ref$height === void 0 ? 'auto' : _ref$height,
|
|
53
|
+
errorImgSrc = _ref.errorImgSrc,
|
|
54
|
+
onError = _ref.onError,
|
|
55
|
+
rest = _objectWithoutProperties(_ref, ["type", "src", "shape", "title", "alt", "className", "style", "width", "height", "errorImgSrc", "onError"]);
|
|
56
|
+
|
|
47
57
|
var _useState = (0, _react.useState)(src),
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
59
|
+
src2 = _useState2[0],
|
|
60
|
+
setSrc2 = _useState2[1];
|
|
61
|
+
|
|
51
62
|
var handleImgLoadError = function handleImgLoadError() {
|
|
52
63
|
if (errorImgSrc) {
|
|
53
64
|
setSrc2(props.errorImgSrc);
|
|
54
65
|
}
|
|
66
|
+
|
|
55
67
|
props.onError && props.onError();
|
|
56
68
|
};
|
|
69
|
+
|
|
57
70
|
var params = _objectSpread({
|
|
58
71
|
type: type,
|
|
59
72
|
src: src2,
|
|
@@ -66,10 +79,12 @@ var _default = function _default(props) {
|
|
|
66
79
|
height: height,
|
|
67
80
|
errorImgSrc: errorImgSrc
|
|
68
81
|
}, rest);
|
|
69
|
-
|
|
82
|
+
|
|
83
|
+
return React.createElement(_react.Fragment, null, type === 'contain' && React.createElement(_Contain["default"], _extends({}, params, {
|
|
70
84
|
onError: handleImgLoadError
|
|
71
|
-
})), type === 'cover' &&
|
|
85
|
+
})), type === 'cover' && React.createElement(_Cover["default"], _extends({}, params, {
|
|
72
86
|
onError: handleImgLoadError
|
|
73
87
|
})));
|
|
74
88
|
};
|
|
89
|
+
|
|
75
90
|
exports["default"] = _default;
|
|
@@ -4,7 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
+
|
|
7
8
|
var _react = require("react");
|
|
9
|
+
|
|
8
10
|
// import createActions from './createActions';
|
|
9
|
-
var _default =
|
|
11
|
+
var _default = (0, _react.createContext)({});
|
|
12
|
+
|
|
10
13
|
exports["default"] = _default;
|