villianjs-pro 1.0.80 → 1.0.82

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 +1 @@
1
- function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_with_holes(arr){if(Array.isArray(arr))return arr}function _define_property(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}function _iterable_to_array_limit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_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}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}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}function _object_spread_props(target,source){source=source!=null?source:{};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}function _object_without_properties(source,excluded){if(source==null)return{};var target=_object_without_properties_loose(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}function _object_without_properties_loose(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}function _sliced_to_array(arr,i){return _array_with_holes(arr)||_iterable_to_array_limit(arr,i)||_unsupported_iterable_to_array(arr,i)||_non_iterable_rest()}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}import React,{useState,useContext,useCallback,useRef,useMemo}from"react";import{useCommonStyles}from"../hooks/commonStyles";import useStyle from"../styles";import classNames from"classnames";import{Modal}from"../../Modal";import{Typography}from"../../Text";import{TreeSelectContent}from"./content";import{TreeSelectContext}from"../context";import{Tag,Popover,Input,Flex}from"antd";import{DownOutlined,SearchOutlined}from"@ant-design/icons";import{Button}from"../../Button";import{useVirtualizer}from"@tanstack/react-virtual";var CustomModal=Modal.CustomModal;var Text=Typography.Text;var POPOVER_VIRTUAL_THRESHOLD=50;var POPOVER_ITEM_HEIGHT=36;var POPOVER_OVERSCAN=5;export var TreeSelectContainer=function(props){var _props_mode=props.mode,mode=_props_mode===void 0?"modal":_props_mode,_props_value=props.value,value=_props_value===void 0?[]:_props_value,onChange=props.onChange,className=props.className,style=props.style,_props_placeholder=props.placeholder,placeholder=_props_placeholder===void 0?"请选择":_props_placeholder,_props_maxDisplayCount=props.maxDisplayCount,maxDisplayCount=_props_maxDisplayCount===void 0?3:_props_maxDisplayCount,modalProps=props.modalProps,_props_size=props.size,size=_props_size===void 0?"middle":_props_size,_props_readOnly=props.readOnly,readOnly=_props_readOnly===void 0?false:_props_readOnly,_props_triggerType=props.triggerType,triggerType=_props_triggerType===void 0?"default":_props_triggerType,_props_triggerButtonProps=props.triggerButtonProps,triggerButtonProps=_props_triggerButtonProps===void 0?{}:_props_triggerButtonProps,renderTrigger=props.renderTrigger,restProps=_object_without_properties(props,["mode","value","onChange","className","style","placeholder","maxDisplayCount","modalProps","size","readOnly","triggerType","triggerButtonProps","renderTrigger"]);var context=useContext(TreeSelectContext);var _useCommonStyles=useCommonStyles("vlian-tree-select",props,useStyle),prefixCls=_useCommonStyles.prefixCls,wrapCSS=_useCommonStyles.wrapCSS,hashId=_useCommonStyles.hashId;var _useState=_sliced_to_array(useState(false),2),modalOpen=_useState[0],setModalOpen=_useState[1];var _useState1=_sliced_to_array(useState(false),2),buttonPopoverSearchVisible=_useState1[0],setButtonPopoverSearchVisible=_useState1[1];var _useState2=_sliced_to_array(useState(""),2),buttonPopoverSearchValue=_useState2[0],setButtonPopoverSearchValue=_useState2[1];var _useState3=_sliced_to_array(useState(false),2),remainingPopoverSearchVisible=_useState3[0],setRemainingPopoverSearchVisible=_useState3[1];var _useState4=_sliced_to_array(useState(""),2),remainingPopoverSearchValue=_useState4[0],setRemainingPopoverSearchValue=_useState4[1];var handleButtonPopoverSearchToggle=useCallback(function(){setButtonPopoverSearchVisible(function(prev){if(prev){setButtonPopoverSearchValue("")}return!prev})},[]);var handleRemainingPopoverSearchToggle=useCallback(function(){setRemainingPopoverSearchVisible(function(prev){if(prev){setRemainingPopoverSearchValue("")}return!prev})},[]);var handleOpenModal=useCallback(function(){if(readOnly&&mode==="modal"){return}if(mode==="modal"){var _context_setTempSelectedRows,_context_setTempSelectedKeys;var currentSelected=value.length>0?value:(context===null||context===void 0?void 0:context.selectedRows)||[];var currentKeys=currentSelected.length>0?currentSelected.map(function(row){return row.key}):(context===null||context===void 0?void 0:context.selectedKeys)||[];context===null||context===void 0?void 0:(_context_setTempSelectedRows=context.setTempSelectedRows)===null||_context_setTempSelectedRows===void 0?void 0:_context_setTempSelectedRows.call(context,currentSelected);context===null||context===void 0?void 0:(_context_setTempSelectedKeys=context.setTempSelectedKeys)===null||_context_setTempSelectedKeys===void 0?void 0:_context_setTempSelectedKeys.call(context,currentKeys)}setModalOpen(true)},[readOnly,mode,value,context]);var handleModalOk=useCallback(function(){if(mode==="modal"){var _context_setSelectedRows;var tempRows=(context===null||context===void 0?void 0:context.tempSelectedRows)||(context===null||context===void 0?void 0:context.selectedRows)||value;context===null||context===void 0?void 0:(_context_setSelectedRows=context.setSelectedRows)===null||_context_setSelectedRows===void 0?void 0:_context_setSelectedRows.call(context,tempRows);onChange===null||onChange===void 0?void 0:onChange(tempRows)}setModalOpen(false)},[mode,context,value,onChange]);var handleModalCancel=useCallback(function(){if(mode==="modal"){var _context_setTempSelectedRows,_context_setTempSelectedKeys;var confirmedRows=value.length>0?value:(context===null||context===void 0?void 0:context.selectedRows)||[];var confirmedKeys=confirmedRows.length>0?confirmedRows.map(function(row){return row.key}):(context===null||context===void 0?void 0:context.selectedKeys)||[];context===null||context===void 0?void 0:(_context_setTempSelectedRows=context.setTempSelectedRows)===null||_context_setTempSelectedRows===void 0?void 0:_context_setTempSelectedRows.call(context,confirmedRows);context===null||context===void 0?void 0:(_context_setTempSelectedKeys=context.setTempSelectedKeys)===null||_context_setTempSelectedKeys===void 0?void 0:_context_setTempSelectedKeys.call(context,confirmedKeys)}setModalOpen(false)},[mode,value,context]);var handleTagClose=function(e,node){e.stopPropagation();if(readOnly){return}var selectedRows=(context===null||context===void 0?void 0:context.selectedRows)||value;var newSelectedRows=selectedRows.filter(function(item){return item.key!==node.key});if(context){context.setSelectedRows(newSelectedRows);onChange===null||onChange===void 0?void 0:onChange(newSelectedRows)}};var PopoverTagList=function(param){var rows=param.rows,onTagClose=param.onTagClose,_param_closable=param.closable,closable=_param_closable===void 0?false:_param_closable,_param_searchValue=param.searchValue,searchValue=_param_searchValue===void 0?"":_param_searchValue;var parentRef=useRef(null);var filteredRows=useMemo(function(){if(!searchValue)return rows;var searchLower=searchValue.toLowerCase();return rows.filter(function(node){var _node_label,_node_path;return((_node_label=node.label)===null||_node_label===void 0?void 0:_node_label.toLowerCase().includes(searchLower))||((_node_path=node.path)===null||_node_path===void 0?void 0:_node_path.toLowerCase().includes(searchLower))})},[rows,searchValue]);var shouldUseVirtual=filteredRows.length>POPOVER_VIRTUAL_THRESHOLD;var virtualizer=useVirtualizer({count:filteredRows.length,getScrollElement:function(){return parentRef.current},estimateSize:function(){return POPOVER_ITEM_HEIGHT},overscan:POPOVER_OVERSCAN,enabled:shouldUseVirtual&&filteredRows.length>0});if(filteredRows.length===0){return React.createElement("div",{className:classNames("".concat(prefixCls,"-trigger-tooltip-content"),hashId)},React.createElement("div",{style:{padding:"8px",textAlign:"center",color:"#999"}},"暂无匹配项"))}if(!shouldUseVirtual){return React.createElement("div",{className:classNames("".concat(prefixCls,"-trigger-tooltip-content"),hashId)},filteredRows.map(function(row){return React.createElement(Tag,{key:row.key,className:classNames("".concat(prefixCls,"-trigger-tag"),hashId),closable:closable,onClose:function(e){return onTagClose===null||onTagClose===void 0?void 0:onTagClose(e,row)}},React.createElement(Text,{className:classNames("".concat(prefixCls,"-trigger-tag-text"),hashId),ellipsis:true},row.label))}))}var virtualItems=virtualizer.getVirtualItems();return React.createElement("div",{ref:parentRef,className:classNames("".concat(prefixCls,"-trigger-tooltip-content"),hashId),style:{maxHeight:"300px",maxWidth:"400px",overflowY:"auto",overflowX:"hidden"}},React.createElement("div",{style:{height:"".concat(virtualizer.getTotalSize(),"px"),width:"100%",position:"relative"}},virtualItems.map(function(virtualItem){var row=filteredRows[virtualItem.index];return React.createElement("div",{key:row.key,style:{position:"absolute",top:0,left:0,width:"100%",height:"".concat(virtualItem.size,"px"),transform:"translateY(".concat(virtualItem.start,"px)")}},React.createElement(Tag,{className:classNames("".concat(prefixCls,"-trigger-tag"),hashId),closable:closable,onClose:function(e){return onTagClose===null||onTagClose===void 0?void 0:onTagClose(e,row)}},React.createElement(Text,{className:classNames("".concat(prefixCls,"-trigger-tag-text"),hashId),ellipsis:true},row.label)))})))};var renderTriggerElement=function(){var selectedRows=(context===null||context===void 0?void 0:context.selectedRows)||value;var hasSelected=selectedRows.length>0;var displayTags=selectedRows.slice(0,maxDisplayCount);var remainingCount=selectedRows.length-maxDisplayCount;var remainingTags=remainingCount>0?selectedRows.slice(maxDisplayCount):[];var triggerClassName=classNames("".concat(prefixCls,"-trigger"),hashId,_define_property({},"".concat(prefixCls,"-trigger-readonly"),readOnly));var renderPopoverTitle=function(titleText,searchVisible,searchValue,onSearchToggle,onSearchChange){return React.createElement(Flex,{align:"center",justify:"space-between",style:{width:"100%"}},React.createElement("span",null,titleText),React.createElement(Flex,{align:"center",gap:8},!searchVisible?React.createElement(SearchOutlined,{className:classNames("".concat(prefixCls,"-trigger-popover-search-icon"),hashId),onClick:function(e){e.stopPropagation();onSearchToggle()},style:{cursor:"pointer",color:"#8c8c8c"}}):React.createElement(Input,{key:"popover-search-input-".concat(titleText),size:"small",placeholder:"搜索已选项",prefix:React.createElement(SearchOutlined,null),value:searchValue,onChange:function(e){e.stopPropagation();onSearchChange(e.target.value)},onClick:function(e){return e.stopPropagation()},onBlur:function(){if(!searchValue){onSearchToggle()}},autoFocus:true,style:{width:150},className:classNames("".concat(prefixCls,"-trigger-popover-search-input"),hashId)})))};if(triggerType==="button"){var buttonContent=hasSelected?React.createElement(Popover,{title:renderPopoverTitle("共 ".concat(selectedRows.length," 项"),buttonPopoverSearchVisible,buttonPopoverSearchValue,handleButtonPopoverSearchToggle,setButtonPopoverSearchValue),trigger:"click",content:React.createElement(PopoverTagList,{rows:selectedRows,onTagClose:handleTagClose,closable:!readOnly&&mode==="modal",searchValue:buttonPopoverSearchValue}),styles:{root:{maxHeight:"300px",maxWidth:"400px"}},overlayStyle:{maxHeight:"300px",maxWidth:"400px"},onOpenChange:function(open){if(!open){setButtonPopoverSearchVisible(false);setButtonPopoverSearchValue("")}}},React.createElement(Button,_object_spread_props(_object_spread({},triggerButtonProps),{onClick:function(e){e.stopPropagation()}}),"已选",selectedRows.length>99?"99+":selectedRows.length,"项")):React.createElement(Button,_object_spread_props(_object_spread({},triggerButtonProps),{onClick:handleOpenModal}),placeholder);return buttonContent}if(triggerType==="custom"&&renderTrigger){return renderTrigger(selectedRows,handleOpenModal)}return React.createElement("div",{className:triggerClassName,onClick:handleOpenModal,style:readOnly?{cursor:"default"}:undefined},React.createElement("div",{className:classNames("".concat(prefixCls,"-trigger-content"),hashId)},!hasSelected?React.createElement("span",{className:classNames("".concat(prefixCls,"-trigger-placeholder"),hashId)},placeholder):React.createElement("div",{className:classNames("".concat(prefixCls,"-trigger-tags"),hashId)},displayTags.map(function(row){return React.createElement(Tag,{key:row.key,className:classNames("".concat(prefixCls,"-trigger-tag"),hashId),closable:!readOnly&&mode==="modal",onClose:function(e){return handleTagClose(e,row)}},React.createElement(Text,{className:classNames("".concat(prefixCls,"-trigger-tag-text"),hashId),ellipsis:true},row.label))}),remainingCount>0&&React.createElement(Popover,{title:renderPopoverTitle("共 ".concat(remainingCount," 项"),remainingPopoverSearchVisible,remainingPopoverSearchValue,handleRemainingPopoverSearchToggle,setRemainingPopoverSearchValue),trigger:"click",content:React.createElement(PopoverTagList,{rows:remainingTags,onTagClose:handleTagClose,closable:!readOnly&&mode==="modal",searchValue:remainingPopoverSearchValue}),styles:{root:{maxHeight:"300px",maxWidth:"400px"}},overlayStyle:{maxHeight:"300px",maxWidth:"400px"},onOpenChange:function(open){if(!open){setRemainingPopoverSearchVisible(false);setRemainingPopoverSearchValue("")}}},React.createElement(Tag,{className:classNames("".concat(prefixCls,"-trigger-tag"),"".concat(prefixCls,"-trigger-tag-more"),hashId),closable:false,onClick:function(e){e.stopPropagation()}},"+",remainingCount)))),!readOnly&&React.createElement(DownOutlined,{className:classNames("".concat(prefixCls,"-trigger-arrow"),hashId)}))};var sizeClass=size==="small"?"".concat(prefixCls,"-small"):size==="large"?"".concat(prefixCls,"-large"):"";if(mode==="inline"){return wrapCSS(React.createElement("div",{className:classNames(prefixCls,sizeClass,className,hashId),style:style},React.createElement(TreeSelectContent,props)))}return wrapCSS(React.createElement("div",{className:classNames(prefixCls,sizeClass,className,hashId),style:style},renderTriggerElement(),React.createElement(CustomModal,_object_spread({open:modalOpen,onCancel:handleModalCancel,onOk:handleModalOk,maskClosable:false,destroyOnHidden:true,width:900},modalProps),React.createElement(TreeSelectContent,_object_spread({},props,restProps)))))};
1
+ function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _array_with_holes(arr){if(Array.isArray(arr))return arr}function _define_property(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}function _iterable_to_array_limit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_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}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};var ownKeys=Object.keys(source);if(typeof Object.getOwnPropertySymbols==="function"){ownKeys=ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym){return Object.getOwnPropertyDescriptor(source,sym).enumerable}))}ownKeys.forEach(function(key){_define_property(target,key,source[key])})}return target}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}function _object_spread_props(target,source){source=source!=null?source:{};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}function _object_without_properties(source,excluded){if(source==null)return{};var target=_object_without_properties_loose(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}function _object_without_properties_loose(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}function _sliced_to_array(arr,i){return _array_with_holes(arr)||_iterable_to_array_limit(arr,i)||_unsupported_iterable_to_array(arr,i)||_non_iterable_rest()}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o==="string")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(n);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}import React,{useState,useContext,useCallback,useRef,useMemo}from"react";import{useCommonStyles}from"../hooks/commonStyles";import useStyle from"../styles";import classNames from"classnames";import{Modal}from"../../Modal";import{Typography}from"../../Text";import{TreeSelectContent}from"./content";import{TreeSelectContext}from"../context";import{Tag,Popover,Input,Flex}from"antd";import{DownOutlined,SearchOutlined}from"@ant-design/icons";import{Button}from"../../Button";import{useVirtualizer}from"@tanstack/react-virtual";import{useClickAway}from"ahooks";var CustomModal=Modal.CustomModal;var Text=Typography.Text;var POPOVER_VIRTUAL_THRESHOLD=50;var POPOVER_ITEM_HEIGHT=36;var POPOVER_OVERSCAN=5;export var TreeSelectContainer=function(props){var _props_mode=props.mode,mode=_props_mode===void 0?"modal":_props_mode,_props_value=props.value,value=_props_value===void 0?[]:_props_value,onChange=props.onChange,className=props.className,style=props.style,_props_placeholder=props.placeholder,placeholder=_props_placeholder===void 0?"请选择":_props_placeholder,_props_maxDisplayCount=props.maxDisplayCount,maxDisplayCount=_props_maxDisplayCount===void 0?3:_props_maxDisplayCount,modalProps=props.modalProps,_props_size=props.size,size=_props_size===void 0?"middle":_props_size,_props_readOnly=props.readOnly,readOnly=_props_readOnly===void 0?false:_props_readOnly,_props_triggerType=props.triggerType,triggerType=_props_triggerType===void 0?"default":_props_triggerType,_props_triggerButtonProps=props.triggerButtonProps,triggerButtonProps=_props_triggerButtonProps===void 0?{}:_props_triggerButtonProps,renderTrigger=props.renderTrigger,restProps=_object_without_properties(props,["mode","value","onChange","className","style","placeholder","maxDisplayCount","modalProps","size","readOnly","triggerType","triggerButtonProps","renderTrigger"]);var context=useContext(TreeSelectContext);var _useCommonStyles=useCommonStyles("vlian-tree-select",props,useStyle),prefixCls=_useCommonStyles.prefixCls,wrapCSS=_useCommonStyles.wrapCSS,hashId=_useCommonStyles.hashId;var _useState=_sliced_to_array(useState(false),2),modalOpen=_useState[0],setModalOpen=_useState[1];var _useState1=_sliced_to_array(useState(false),2),buttonPopoverOpen=_useState1[0],setButtonPopoverOpen=_useState1[1];var buttonPopoverContainerRef=useRef(null);var _useState2=_sliced_to_array(useState(false),2),buttonPopoverSearchVisible=_useState2[0],setButtonPopoverSearchVisible=_useState2[1];var _useState3=_sliced_to_array(useState(""),2),buttonPopoverSearchValue=_useState3[0],setButtonPopoverSearchValue=_useState3[1];var _useState4=_sliced_to_array(useState(false),2),remainingPopoverSearchVisible=_useState4[0],setRemainingPopoverSearchVisible=_useState4[1];var _useState5=_sliced_to_array(useState(""),2),remainingPopoverSearchValue=_useState5[0],setRemainingPopoverSearchValue=_useState5[1];useClickAway(function(e){if(!buttonPopoverOpen){return}var target=e.target;var container=buttonPopoverContainerRef.current;if(container===null||container===void 0?void 0:container.contains(target)){return}var popoverElements=document.querySelectorAll(".ant-popover");for(var i=0;i<popoverElements.length;i++){if(popoverElements[i].contains(target)){return}}setButtonPopoverOpen(false);setButtonPopoverSearchVisible(false);setButtonPopoverSearchValue("")},buttonPopoverContainerRef,"mousedown");var handleButtonPopoverSearchToggle=useCallback(function(){setButtonPopoverSearchVisible(function(prev){if(prev){setButtonPopoverSearchValue("")}return!prev})},[]);var handleRemainingPopoverSearchToggle=useCallback(function(){setRemainingPopoverSearchVisible(function(prev){if(prev){setRemainingPopoverSearchValue("")}return!prev})},[]);var handleOpenModal=useCallback(function(){if(readOnly&&mode==="modal"){return}if(mode==="modal"){var _context_setTempSelectedRows,_context_setTempSelectedKeys;var currentSelected=value.length>0?value:(context===null||context===void 0?void 0:context.selectedRows)||[];var currentKeys=currentSelected.length>0?currentSelected.map(function(row){return row.key}):(context===null||context===void 0?void 0:context.selectedKeys)||[];context===null||context===void 0?void 0:(_context_setTempSelectedRows=context.setTempSelectedRows)===null||_context_setTempSelectedRows===void 0?void 0:_context_setTempSelectedRows.call(context,currentSelected);context===null||context===void 0?void 0:(_context_setTempSelectedKeys=context.setTempSelectedKeys)===null||_context_setTempSelectedKeys===void 0?void 0:_context_setTempSelectedKeys.call(context,currentKeys)}setButtonPopoverOpen(false);setButtonPopoverSearchVisible(false);setButtonPopoverSearchValue("");setModalOpen(true)},[readOnly,mode,value,context]);var handleModalOk=useCallback(function(){if(mode==="modal"){var _context_setSelectedRows;var tempRows=(context===null||context===void 0?void 0:context.tempSelectedRows)||(context===null||context===void 0?void 0:context.selectedRows)||value;context===null||context===void 0?void 0:(_context_setSelectedRows=context.setSelectedRows)===null||_context_setSelectedRows===void 0?void 0:_context_setSelectedRows.call(context,tempRows);onChange===null||onChange===void 0?void 0:onChange(tempRows)}setModalOpen(false)},[mode,context,value,onChange]);var handleModalCancel=useCallback(function(){if(mode==="modal"){var _context_setTempSelectedRows,_context_setTempSelectedKeys;var confirmedRows=value.length>0?value:(context===null||context===void 0?void 0:context.selectedRows)||[];var confirmedKeys=confirmedRows.length>0?confirmedRows.map(function(row){return row.key}):(context===null||context===void 0?void 0:context.selectedKeys)||[];context===null||context===void 0?void 0:(_context_setTempSelectedRows=context.setTempSelectedRows)===null||_context_setTempSelectedRows===void 0?void 0:_context_setTempSelectedRows.call(context,confirmedRows);context===null||context===void 0?void 0:(_context_setTempSelectedKeys=context.setTempSelectedKeys)===null||_context_setTempSelectedKeys===void 0?void 0:_context_setTempSelectedKeys.call(context,confirmedKeys)}setModalOpen(false)},[mode,value,context]);var handleTagClose=function(e,node){e.stopPropagation();if(readOnly){return}var selectedRows=(context===null||context===void 0?void 0:context.selectedRows)||value;var newSelectedRows=selectedRows.filter(function(item){return item.key!==node.key});if(context){context.setSelectedRows(newSelectedRows);onChange===null||onChange===void 0?void 0:onChange(newSelectedRows)}};var PopoverTagList=function(param){var rows=param.rows,onTagClose=param.onTagClose,_param_closable=param.closable,closable=_param_closable===void 0?false:_param_closable,_param_searchValue=param.searchValue,searchValue=_param_searchValue===void 0?"":_param_searchValue;var parentRef=useRef(null);var filteredRows=useMemo(function(){if(!searchValue)return rows;var searchLower=searchValue.toLowerCase();return rows.filter(function(node){var _node_label,_node_path;return((_node_label=node.label)===null||_node_label===void 0?void 0:_node_label.toLowerCase().includes(searchLower))||((_node_path=node.path)===null||_node_path===void 0?void 0:_node_path.toLowerCase().includes(searchLower))})},[rows,searchValue]);var shouldUseVirtual=filteredRows.length>POPOVER_VIRTUAL_THRESHOLD;var virtualizer=useVirtualizer({count:filteredRows.length,getScrollElement:function(){return parentRef.current},estimateSize:function(){return POPOVER_ITEM_HEIGHT},overscan:POPOVER_OVERSCAN,enabled:shouldUseVirtual&&filteredRows.length>0});if(filteredRows.length===0){return React.createElement("div",{className:classNames("".concat(prefixCls,"-trigger-tooltip-content"),hashId)},React.createElement("div",{style:{padding:"8px",textAlign:"center",color:"#999"}},"暂无匹配项"))}if(!shouldUseVirtual){return React.createElement("div",{className:classNames("".concat(prefixCls,"-trigger-tooltip-content"),hashId)},filteredRows.map(function(row){return React.createElement(Tag,{key:row.key,className:classNames("".concat(prefixCls,"-trigger-tag"),hashId),closable:closable,onClose:function(e){return onTagClose===null||onTagClose===void 0?void 0:onTagClose(e,row)}},React.createElement(Text,{className:classNames("".concat(prefixCls,"-trigger-tag-text"),hashId),ellipsis:true},row.label))}))}var virtualItems=virtualizer.getVirtualItems();return React.createElement("div",{ref:parentRef,className:classNames("".concat(prefixCls,"-trigger-tooltip-content"),hashId),style:{maxHeight:"300px",maxWidth:"400px",overflowY:"auto",overflowX:"hidden"}},React.createElement("div",{style:{height:"".concat(virtualizer.getTotalSize(),"px"),width:"100%",position:"relative"}},virtualItems.map(function(virtualItem){var row=filteredRows[virtualItem.index];return React.createElement("div",{key:row.key,style:{position:"absolute",top:0,left:0,width:"100%",height:"".concat(virtualItem.size,"px"),transform:"translateY(".concat(virtualItem.start,"px)")}},React.createElement(Tag,{className:classNames("".concat(prefixCls,"-trigger-tag"),hashId),closable:closable,onClose:function(e){return onTagClose===null||onTagClose===void 0?void 0:onTagClose(e,row)}},React.createElement(Text,{className:classNames("".concat(prefixCls,"-trigger-tag-text"),hashId),ellipsis:true},row.label)))})))};var renderTriggerElement=function(){var selectedRows=(context===null||context===void 0?void 0:context.selectedRows)||value;var hasSelected=selectedRows.length>0;var displayTags=selectedRows.slice(0,maxDisplayCount);var remainingCount=selectedRows.length-maxDisplayCount;var remainingTags=remainingCount>0?selectedRows.slice(maxDisplayCount):[];var triggerClassName=classNames("".concat(prefixCls,"-trigger"),hashId,_define_property({},"".concat(prefixCls,"-trigger-readonly"),readOnly));var renderPopoverTitle=function(titleText,searchVisible,searchValue,onSearchToggle,onSearchChange){return React.createElement(Flex,{align:"center",justify:"space-between",style:{width:"100%"}},React.createElement("span",null,titleText),React.createElement(Flex,{align:"center",gap:8},!searchVisible?React.createElement(SearchOutlined,{className:classNames("".concat(prefixCls,"-trigger-popover-search-icon"),hashId),onClick:function(e){e.stopPropagation();onSearchToggle()},style:{cursor:"pointer",color:"#8c8c8c"}}):React.createElement(Input,{key:"popover-search-input-".concat(titleText),size:"small",placeholder:"搜索已选项",prefix:React.createElement(SearchOutlined,null),value:searchValue,onChange:function(e){e.stopPropagation();onSearchChange(e.target.value)},onClick:function(e){return e.stopPropagation()},onBlur:function(){if(!searchValue){onSearchToggle()}},autoFocus:true,style:{width:150},className:classNames("".concat(prefixCls,"-trigger-popover-search-input"),hashId)})))};if(triggerType==="button"){var buttonContent=hasSelected?React.createElement("div",{ref:buttonPopoverContainerRef},React.createElement(Popover,{title:renderPopoverTitle("共 ".concat(selectedRows.length," 项"),buttonPopoverSearchVisible,buttonPopoverSearchValue,handleButtonPopoverSearchToggle,setButtonPopoverSearchValue),open:buttonPopoverOpen,trigger:[],content:React.createElement(PopoverTagList,{rows:selectedRows,onTagClose:handleTagClose,closable:!readOnly&&mode==="modal",searchValue:buttonPopoverSearchValue}),styles:{root:{maxHeight:"300px",maxWidth:"400px"}}},React.createElement(Button,_object_spread_props(_object_spread({},triggerButtonProps),{onClick:handleOpenModal,onMouseEnter:function(){setButtonPopoverOpen(true)}}),"已选",selectedRows.length>99?"99+":selectedRows.length,"项"))):React.createElement(Button,_object_spread_props(_object_spread({},triggerButtonProps),{onClick:handleOpenModal}),placeholder);return buttonContent}if(triggerType==="custom"&&renderTrigger){return renderTrigger(selectedRows,handleOpenModal)}return React.createElement("div",{className:triggerClassName,onClick:handleOpenModal,style:readOnly?{cursor:"default"}:undefined},React.createElement("div",{className:classNames("".concat(prefixCls,"-trigger-content"),hashId)},!hasSelected?React.createElement("span",{className:classNames("".concat(prefixCls,"-trigger-placeholder"),hashId)},placeholder):React.createElement("div",{className:classNames("".concat(prefixCls,"-trigger-tags"),hashId)},displayTags.map(function(row){return React.createElement(Tag,{key:row.key,className:classNames("".concat(prefixCls,"-trigger-tag"),hashId),closable:!readOnly&&mode==="modal",onClose:function(e){return handleTagClose(e,row)}},React.createElement(Text,{className:classNames("".concat(prefixCls,"-trigger-tag-text"),hashId),ellipsis:true},row.label))}),remainingCount>0&&React.createElement(Popover,{title:renderPopoverTitle("共 ".concat(remainingCount," 项"),remainingPopoverSearchVisible,remainingPopoverSearchValue,handleRemainingPopoverSearchToggle,setRemainingPopoverSearchValue),trigger:"click",content:React.createElement(PopoverTagList,{rows:remainingTags,onTagClose:handleTagClose,closable:!readOnly&&mode==="modal",searchValue:remainingPopoverSearchValue}),styles:{root:{maxHeight:"300px",maxWidth:"400px"}},overlayStyle:{maxHeight:"300px",maxWidth:"400px"},onOpenChange:function(open){if(!open){setRemainingPopoverSearchVisible(false);setRemainingPopoverSearchValue("")}}},React.createElement(Tag,{className:classNames("".concat(prefixCls,"-trigger-tag"),"".concat(prefixCls,"-trigger-tag-more"),hashId),closable:false,onClick:function(e){e.stopPropagation()}},"+",remainingCount)))),!readOnly&&React.createElement(DownOutlined,{className:classNames("".concat(prefixCls,"-trigger-arrow"),hashId)}))};var sizeClass=size==="small"?"".concat(prefixCls,"-small"):size==="large"?"".concat(prefixCls,"-large"):"";if(mode==="inline"){return wrapCSS(React.createElement("div",{className:classNames(prefixCls,sizeClass,className,hashId),style:style},React.createElement(TreeSelectContent,props)))}return wrapCSS(React.createElement("div",{className:classNames(prefixCls,sizeClass,className,hashId),style:style},renderTriggerElement(),React.createElement(CustomModal,_object_spread({open:modalOpen,onCancel:handleModalCancel,onOk:handleModalOk,maskClosable:false,destroyOnHidden:true,width:900},modalProps),React.createElement(TreeSelectContent,_object_spread({},props,restProps)))))};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "villianjs-pro",
3
- "version": "1.0.80",
3
+ "version": "1.0.82",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",