tntd 1.4.28 → 1.4.29

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.
@@ -17,7 +17,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
17
17
 
18
18
  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; }
19
19
 
20
- import React, { Fragment } from 'react';
20
+ import React, { Fragment, useRef } from 'react';
21
21
  import { getText, getLanguage } from '../locale';
22
22
  import Icon from '../Icon';
23
23
  import './index.less';
@@ -38,12 +38,10 @@ export default (function (props) {
38
38
  rest = _objectWithoutProperties(_ref, ["children", "type", "num", "divider", "lessOneMoreFit", "popConfirmHandle"]);
39
39
 
40
40
  var _ref2 = props || {},
41
- lang = _ref2.lang;
42
-
43
- if (!lang) {
44
- lang = getLanguage();
45
- }
41
+ propsLang = _ref2.lang;
46
42
 
43
+ var langRef = useRef(propsLang || getLanguage());
44
+ var lang = langRef == null ? void 0 : langRef.current;
47
45
  var newChildren = [];
48
46
 
49
47
  if (Array.isArray(children)) {
@@ -62,6 +60,14 @@ export default (function (props) {
62
60
  props = v.props;
63
61
 
64
62
  if ((type == null ? void 0 : type.name) === 'Popconfirm' || props.hasOwnProperty('onConfirm') && typeof (props == null ? void 0 : props.onConfirm) === 'function') {
63
+ var placement = {};
64
+
65
+ if (lang === 'en' || num && !isNaN(num) && i + 1 > num && !(lessOneMoreFit && newChildren.length - num === 1)) {
66
+ placement = {
67
+ placement: 'left'
68
+ };
69
+ }
70
+
65
71
  newChildren[i] = React.cloneElement(v, _objectSpread({
66
72
  overlayStyle: {
67
73
  width: 180
@@ -69,7 +75,8 @@ export default (function (props) {
69
75
  }, (v == null ? void 0 : v.props) || {}, {
70
76
  onClick: function onClick(e) {
71
77
  return e.stopPropagation();
72
- },
78
+ }
79
+ }, placement, {
73
80
  trigger: 'hover',
74
81
  getPopupContainer: function getPopupContainer(trigger) {
75
82
  return trigger.parentNode;
@@ -63,12 +63,10 @@ var _default = function _default(props) {
63
63
  rest = _objectWithoutProperties(_ref, ["children", "type", "num", "divider", "lessOneMoreFit", "popConfirmHandle"]);
64
64
 
65
65
  var _ref2 = props || {},
66
- lang = _ref2.lang;
67
-
68
- if (!lang) {
69
- lang = (0, _locale.getLanguage)();
70
- }
66
+ propsLang = _ref2.lang;
71
67
 
68
+ var langRef = (0, _react.useRef)(propsLang || (0, _locale.getLanguage)());
69
+ var lang = langRef == null ? void 0 : langRef.current;
72
70
  var newChildren = [];
73
71
 
74
72
  if (Array.isArray(children)) {
@@ -87,6 +85,14 @@ var _default = function _default(props) {
87
85
  props = v.props;
88
86
 
89
87
  if ((type == null ? void 0 : type.name) === 'Popconfirm' || props.hasOwnProperty('onConfirm') && typeof (props == null ? void 0 : props.onConfirm) === 'function') {
88
+ var placement = {};
89
+
90
+ if (lang === 'en' || num && !isNaN(num) && i + 1 > num && !(lessOneMoreFit && newChildren.length - num === 1)) {
91
+ placement = {
92
+ placement: 'left'
93
+ };
94
+ }
95
+
90
96
  newChildren[i] = _react["default"].cloneElement(v, _objectSpread({
91
97
  overlayStyle: {
92
98
  width: 180
@@ -94,7 +100,8 @@ var _default = function _default(props) {
94
100
  }, (v == null ? void 0 : v.props) || {}, {
95
101
  onClick: function onClick(e) {
96
102
  return e.stopPropagation();
97
- },
103
+ }
104
+ }, placement, {
98
105
  trigger: 'hover',
99
106
  getPopupContainer: function getPopupContainer(trigger) {
100
107
  return trigger.parentNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tntd",
3
- "version": "1.4.28",
3
+ "version": "1.4.29",
4
4
  "description": "ued tnt design",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",