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.
@@ -1,4 +1,4 @@
1
- import React, { Fragment } from 'react';
1
+ import React, { Fragment, useRef } from 'react';
2
2
  import { Dropdown, Menu, Divider } from 'antd';
3
3
  import { getText, getLanguage } from '../locale';
4
4
  import Icon from '../Icon';
@@ -8,10 +8,10 @@ const clsPrefix = 'tnt-more-menus';
8
8
 
9
9
  export default props => {
10
10
  const { children = [], type, num = 3, divider = true, lessOneMoreFit, popConfirmHandle, ...rest } = props || {};
11
- let { lang } = props||{};
12
- if(!lang){
13
- lang = getLanguage();
14
- }
11
+ let { lang:propsLang } = props||{};
12
+ const langRef = useRef(propsLang || getLanguage());
13
+ const lang = langRef?.current;
14
+
15
15
  let newChildren = [];
16
16
  if(Array.isArray(children)){
17
17
  newChildren = children?.filter(item => !!item) || [];
@@ -23,10 +23,17 @@ export default props => {
23
23
  newChildren?.forEach((v,i)=>{
24
24
  const { type, props } = v;
25
25
  if(type?.name === 'Popconfirm' || (props.hasOwnProperty('onConfirm') && typeof props?.onConfirm === 'function')){
26
+ let placement ={};
27
+ if(lang === 'en' || (num && !isNaN(num) && (i+1) > num && !(lessOneMoreFit && newChildren.length - num === 1))){
28
+ placement = {
29
+ placement:'left'
30
+ };
31
+ }
26
32
  newChildren[i]= React.cloneElement(v, {
27
33
  overlayStyle: { width: 180 },
28
34
  ...(v?.props || {}),
29
35
  onClick:(e) => e.stopPropagation(),
36
+ ...placement,
30
37
  trigger:'hover',
31
38
  getPopupContainer:(trigger) => trigger.parentNode,
32
39
  });