villianjs-pro 1.0.34 → 1.0.35

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.
Files changed (54) hide show
  1. package/dist/ProTable/components/form-content-container.d.ts +10 -0
  2. package/dist/ProTable/components/form-content-container.js +1 -0
  3. package/dist/ProTable/components/grid-card.d.ts +1 -1
  4. package/dist/ProTable/components/grid-card.js +1 -1
  5. package/dist/ProTable/components/grid-view.d.ts +1 -1
  6. package/dist/ProTable/components/grid-view.js +1 -1
  7. package/dist/ProTable/components/headerTitle.d.ts +4 -0
  8. package/dist/ProTable/components/headerTitle.js +1 -0
  9. package/dist/ProTable/components/list-container.d.ts +3 -0
  10. package/dist/ProTable/components/list-container.js +1 -0
  11. package/dist/ProTable/components/list.d.ts +3 -0
  12. package/dist/ProTable/components/list.js +1 -0
  13. package/dist/ProTable/components/operation-form-wrapper.d.ts +7 -0
  14. package/dist/ProTable/components/operation-form-wrapper.js +1 -0
  15. package/dist/ProTable/components/row-actions.d.ts +1 -1
  16. package/dist/ProTable/components/row-actions.js +1 -1
  17. package/dist/ProTable/components/search.d.ts +2 -2
  18. package/dist/ProTable/components/search.js +1 -1
  19. package/dist/ProTable/{utils.d.ts → components/utils.d.ts} +2 -2
  20. package/dist/ProTable/container.d.ts +3 -0
  21. package/dist/ProTable/container.js +1 -0
  22. package/dist/ProTable/context.d.ts +1 -20
  23. package/dist/ProTable/context.js +1 -1
  24. package/dist/ProTable/hooks/usePagination.js +1 -1
  25. package/dist/ProTable/index.d.ts +2 -3
  26. package/dist/ProTable/index.js +1 -1
  27. package/dist/ProTable/styles.js +1 -1
  28. package/dist/ProTable/table.d.ts +3 -3
  29. package/dist/ProTable/table.js +1 -1
  30. package/dist/ProTable/types.d.ts +333 -160
  31. package/dist/imports/components/import-detail-dialog.js +1 -1
  32. package/dist/imports/components/import-history-dialog.js +1 -1
  33. package/package.json +1 -1
  34. package/dist/ProTable/components/Container.d.ts +0 -27
  35. package/dist/ProTable/components/Container.js +0 -1
  36. package/dist/ProTable/components/form-content.d.ts +0 -34
  37. package/dist/ProTable/components/form-content.js +0 -1
  38. package/dist/ProTable/components/form-footer.d.ts +0 -32
  39. package/dist/ProTable/components/form-footer.js +0 -1
  40. package/dist/ProTable/components/header-buttons-wrapper.d.ts +0 -10
  41. package/dist/ProTable/components/header-buttons-wrapper.js +0 -1
  42. package/dist/ProTable/components/list/index.d.ts +0 -19
  43. package/dist/ProTable/components/list/index.js +0 -1
  44. package/dist/ProTable/components/operation-container.d.ts +0 -39
  45. package/dist/ProTable/components/operation-container.js +0 -1
  46. package/dist/ProTable/components/operation-content-router.d.ts +0 -37
  47. package/dist/ProTable/components/operation-content-router.js +0 -1
  48. package/dist/ProTable/components/operation-content.d.ts +0 -35
  49. package/dist/ProTable/components/operation-content.js +0 -1
  50. package/dist/ProTable/components/row-actions-router.d.ts +0 -8
  51. package/dist/ProTable/components/row-actions-router.js +0 -1
  52. package/dist/ProTable/hooks/useRouterNavigation.d.ts +0 -10
  53. package/dist/ProTable/hooks/useRouterNavigation.js +0 -1
  54. /package/dist/ProTable/{utils.js → components/utils.js} +0 -0
@@ -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 _array_without_holes(arr){if(Array.isArray(arr))return _array_like_to_array(arr)}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _async_to_generator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}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(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}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 _non_iterable_spread(){throw new TypeError("Invalid attempt to spread 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 _to_consumable_array(arr){return _array_without_holes(arr)||_iterable_to_array(arr)||_unsupported_iterable_to_array(arr)||_non_iterable_spread()}function _type_of(obj){"@swc/helpers - typeof";return obj&&typeof Symbol!=="undefined"&&obj.constructor===Symbol?"symbol":typeof obj}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)}function _ts_generator(thisArg,body){var f,y,t,_={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},g=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return g.next=verb(0),g["throw"]=verb(1),g["return"]=verb(2),typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError("Generator is already executing.");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}}import React,{useImperativeHandle}from"react";import{useCommonStyles}from"../hooks";import useStyle from"./styles";import{ButtonGroup}from"../ButtonGroup";import{PlusOutlined,DeleteOutlined}from"@ant-design/icons";import{useLocale}from"../locale";import{usePagination}from"./hooks/usePagination";import{ProTableContext}from"./context";import{Container}from"./components/Container";import{OperationContainer}from"./components/operation-container";import{OperationContent}from"./components/operation-content";import{OperationContentRouter}from"./components/operation-content-router";import{RowActions}from"./components/row-actions";import{RowActionsRouter}from"./components/row-actions-router";import{HeaderButtonsWrapper}from"./components/header-buttons-wrapper";import{MemoryRouter,Routes,Route}from"react-router-dom";import classNames from"classnames";import ConfirmButton from"../ConfirmButton/ConfirmButton";import{convertHeaderButtonToGroupItem,createOperationHandler,ColumnHelper}from"./utils";var ProTableComponent=function(props,ref){var _props_columns=props.columns,columns=_props_columns===void 0?[]:_props_columns,search=props.search,searchType=props.searchType,_props_showCreateBtn=props.showCreateBtn,showCreateBtn=_props_showCreateBtn===void 0?true:_props_showCreateBtn,createBtnProps=props.createBtnProps,onCreate=props.onCreate,_props_showBatchRemoveBtn=props.showBatchRemoveBtn,showBatchRemoveBtn=_props_showBatchRemoveBtn===void 0?true:_props_showBatchRemoveBtn,batchRemoveBtnProps=props.batchRemoveBtnProps,onBatchRemove=props.onBatchRemove,_props_headerButtonItems=props.headerButtonItems,headerButtonItems=_props_headerButtonItems===void 0?[]:_props_headerButtonItems,_props_headerButtonMaxCount=props.headerButtonMaxCount,headerButtonMaxCount=_props_headerButtonMaxCount===void 0?3:_props_headerButtonMaxCount,rowSelection=props.rowSelection,_props_openPageSizeCache=props.openPageSizeCache,openPageSizeCache=_props_openPageSizeCache===void 0?false:_props_openPageSizeCache,_props_defaultPageSize=props.defaultPageSize,defaultPageSize=_props_defaultPageSize===void 0?10:_props_defaultPageSize,_props_mode=props.mode,mode=_props_mode===void 0?"modal":_props_mode,_props_showViewBtn=props.showViewBtn,showViewBtn=_props_showViewBtn===void 0?true:_props_showViewBtn,viewBtnProps=props.viewBtnProps,_props_showUpdateBtn=props.showUpdateBtn,showUpdateBtn=_props_showUpdateBtn===void 0?true:_props_showUpdateBtn,updateBtnProps=props.updateBtnProps,_props_showRemoveBtn=props.showRemoveBtn,showRemoveBtn=_props_showRemoveBtn===void 0?true:_props_showRemoveBtn,removeBtnProps=props.removeBtnProps,_props_rowButtonItems=props.rowButtonItems,rowButtonItems=_props_rowButtonItems===void 0?[]:_props_rowButtonItems,_props_rowButtonMaxCount=props.rowButtonMaxCount,rowButtonMaxCount=_props_rowButtonMaxCount===void 0?3:_props_rowButtonMaxCount,modalProps=props.modalProps,drawerProps=props.drawerProps,_props_routerBasePath=props.routerBasePath,routerBasePath=_props_routerBasePath===void 0?"/table":_props_routerBasePath,operationContent=props.operationContent,onGetDetail=props.onGetDetail,onRemove=props.onRemove,actionRef=props.actionRef,tableRef=props.tableRef,formConfig=props.formConfig,_props_defaultViewMode=props.defaultViewMode,defaultViewMode=_props_defaultViewMode===void 0?"table":_props_defaultViewMode,gridCardRender=props.gridCardRender,gridColumns=props.gridColumns,_props_gridCardFieldsPerRow=props.gridCardFieldsPerRow,gridCardFieldsPerRow=_props_gridCardFieldsPerRow===void 0?3:_props_gridCardFieldsPerRow,restProps=_object_without_properties(props,["columns","search","searchType","showCreateBtn","createBtnProps","onCreate","showBatchRemoveBtn","batchRemoveBtnProps","onBatchRemove","headerButtonItems","headerButtonMaxCount","rowSelection","openPageSizeCache","defaultPageSize","mode","showViewBtn","viewBtnProps","showUpdateBtn","updateBtnProps","showRemoveBtn","removeBtnProps","rowButtonItems","rowButtonMaxCount","modalProps","drawerProps","routerBasePath","operationContent","onGetDetail","onRemove","actionRef","tableRef","formConfig","defaultViewMode","gridCardRender","gridColumns","gridCardFieldsPerRow"]);var _useCommonStyles=useCommonStyles("pro-table",props,useStyle),prefixCls=_useCommonStyles.prefixCls,cssVarCls=_useCommonStyles.cssVarCls,wrapCSS=_useCommonStyles.wrapCSS;var messages=useLocale().messages;var internalActionRef=React.useRef(undefined);var currentActionRef=React.useMemo(function(){if(!actionRef)return internalActionRef;if((typeof actionRef==="undefined"?"undefined":_type_of(actionRef))==="object"&&"current"in actionRef)return actionRef;return internalActionRef},[actionRef]);var currentPagination=usePagination({openPageSizeCache:openPageSizeCache,defaultPageSize:defaultPageSize,tableKey:restProps.tableKey,tableProps:restProps}).currentPagination;var _React_useState=_sliced_to_array(React.useState([]),2),selectedRowKeys=_React_useState[0],setSelectedRowKeys=_React_useState[1];var _React_useState1=_sliced_to_array(React.useState([]),2),selectedRows=_React_useState1[0],setSelectedRows=_React_useState1[1];var _React_useState2=_sliced_to_array(React.useState("list"),2),operationType=_React_useState2[0],setOperationType=_React_useState2[1];var _React_useState3=_sliced_to_array(React.useState(null),2),currentRecord=_React_useState3[0],setCurrentRecord=_React_useState3[1];var _React_useState4=_sliced_to_array(React.useState(-1),2),currentIndex=_React_useState4[0],setCurrentIndex=_React_useState4[1];var _React_useState5=_sliced_to_array(React.useState(false),2),operationVisible=_React_useState5[0],setOperationVisible=_React_useState5[1];var _React_useState6=_sliced_to_array(React.useState(defaultViewMode),2),viewMode=_React_useState6[0],setViewMode=_React_useState6[1];var _React_useState7=_sliced_to_array(React.useState([]),2),dataSource=_React_useState7[0],setDataSource=_React_useState7[1];var _React_useState8=_sliced_to_array(React.useState(false),2),loading=_React_useState8[0],setLoading=_React_useState8[1];var searchColumns=React.useMemo(function(){return columns.filter(function(column){var _column_hideInSearch=column.hideInSearch,hideInSearch=_column_hideInSearch===void 0?true:_column_hideInSearch;return!hideInSearch})},[columns]);var searchConfig=React.useMemo(function(){if(search===false){return null}var layoutType=(search===null||search===void 0?void 0:search.layoutType)||searchType||"Form";var layout=(search===null||search===void 0?void 0:search.layout)||"inline";var searchProps=(search===null||search===void 0?void 0:search.searchProps)||{};return _object_spread_props(_object_spread({layoutType:layoutType,layout:layout},searchProps),{onFinish:function(values){return _async_to_generator(function(){var _searchProps_onFinish,_currentActionRef_current_reload,_currentActionRef_current;return _ts_generator(this,function(_state){switch(_state.label){case 0:return[4,searchProps===null||searchProps===void 0?void 0:(_searchProps_onFinish=searchProps.onFinish)===null||_searchProps_onFinish===void 0?void 0:_searchProps_onFinish.call(searchProps,values)];case 1:_state.sent();if(!(currentActionRef===null||currentActionRef===void 0?void 0:currentActionRef.current))return[3,3];return[4,(_currentActionRef_current_reload=(_currentActionRef_current=currentActionRef.current).reload)===null||_currentActionRef_current_reload===void 0?void 0:_currentActionRef_current_reload.call(_currentActionRef_current,true)];case 2:_state.sent();_state.label=3;case 3:return[2]}})})()},onReset:function(values){return _async_to_generator(function(){var _searchProps_onReset,_currentActionRef_current_reloadAndRest,_currentActionRef_current;return _ts_generator(this,function(_state){switch(_state.label){case 0:searchProps===null||searchProps===void 0?void 0:(_searchProps_onReset=searchProps.onReset)===null||_searchProps_onReset===void 0?void 0:_searchProps_onReset.call(searchProps,values);if(!(currentActionRef===null||currentActionRef===void 0?void 0:currentActionRef.current))return[3,2];return[4,(_currentActionRef_current_reloadAndRest=(_currentActionRef_current=currentActionRef.current).reloadAndRest)===null||_currentActionRef_current_reloadAndRest===void 0?void 0:_currentActionRef_current_reloadAndRest.call(_currentActionRef_current)];case 1:_state.sent();_state.label=2;case 2:return[2]}})})()}})},[search,searchType,currentActionRef]);var handleCreateClick=React.useCallback(function(){return _async_to_generator(function(){return _ts_generator(this,function(_state){switch(_state.label){case 0:if(!onCreate)return[3,2];return[4,onCreate(selectedRowKeys)];case 1:_state.sent();return[3,3];case 2:setOperationType("create");setCurrentRecord(null);setCurrentIndex(-1);if(mode!=="router"){setOperationVisible(true)}_state.label=3;case 3:return[2]}})})()},[onCreate,selectedRowKeys,mode]);var handleViewClick=React.useCallback(createOperationHandler("view",setOperationType,setCurrentIndex,setCurrentRecord,setOperationVisible,onGetDetail,mode),[onGetDetail,mode]);var handleUpdateClick=React.useCallback(createOperationHandler("update",setOperationType,setCurrentIndex,setCurrentRecord,setOperationVisible,onGetDetail,mode),[onGetDetail,mode]);var handleRemoveClick=React.useCallback(function(record,index){return _async_to_generator(function(){var result,_currentActionRef_current_reload,_currentActionRef_current,error;return _ts_generator(this,function(_state){switch(_state.label){case 0:if(!onRemove)return[3,6];_state.label=1;case 1:_state.trys.push([1,5,,6]);return[4,onRemove(record,index)];case 2:result=_state.sent();if(result===false){return[2]}if(!(currentActionRef===null||currentActionRef===void 0?void 0:currentActionRef.current))return[3,4];return[4,(_currentActionRef_current_reload=(_currentActionRef_current=currentActionRef.current).reload)===null||_currentActionRef_current_reload===void 0?void 0:_currentActionRef_current_reload.call(_currentActionRef_current,true)];case 3:_state.sent();_state.label=4;case 4:setSelectedRowKeys([]);setSelectedRows([]);return[3,6];case 5:error=_state.sent();console.error("删除失败:",error);return[2];case 6:return[2]}})})()},[onRemove,currentActionRef]);var handleOperationClose=React.useCallback(function(){setOperationVisible(false);setOperationType("list");setCurrentRecord(null);setCurrentIndex(-1)},[]);var handleOperationSuccess=React.useCallback(function(){var shouldRefresh=arguments.length>0&&arguments[0]!==void 0?arguments[0]:true;return _async_to_generator(function(){var _currentActionRef_current_reload,_currentActionRef_current;return _ts_generator(this,function(_state){switch(_state.label){case 0:if(shouldRefresh===false){return[2]}handleOperationClose();if(!(currentActionRef===null||currentActionRef===void 0?void 0:currentActionRef.current))return[3,2];return[4,(_currentActionRef_current_reload=(_currentActionRef_current=currentActionRef.current).reload)===null||_currentActionRef_current_reload===void 0?void 0:_currentActionRef_current_reload.call(_currentActionRef_current,false)];case 1:_state.sent();_state.label=2;case 2:return[2]}})})()},[handleOperationClose,currentActionRef]);var handleBatchRemoveConfirm=React.useCallback(function(){return _async_to_generator(function(){var result,_currentActionRef_current_reload,_currentActionRef_current,error;return _ts_generator(this,function(_state){switch(_state.label){case 0:if(!onBatchRemove||selectedRowKeys.length===0){return[2,false]}_state.label=1;case 1:_state.trys.push([1,5,,6]);return[4,onBatchRemove(selectedRowKeys)];case 2:result=_state.sent();if(result===false){return[2,false]}if(!(currentActionRef===null||currentActionRef===void 0?void 0:currentActionRef.current))return[3,4];return[4,(_currentActionRef_current_reload=(_currentActionRef_current=currentActionRef.current).reload)===null||_currentActionRef_current_reload===void 0?void 0:_currentActionRef_current_reload.call(_currentActionRef_current,true)];case 3:_state.sent();_state.label=4;case 4:setSelectedRowKeys([]);setSelectedRows([]);return[2,true];case 5:error=_state.sent();console.error("批量删除失败:",error);return[2,false];case 6:return[2]}})})()},[onBatchRemove,selectedRowKeys,currentActionRef]);var convertToButtonItem=React.useCallback(function(config,defaultKey,defaultHandler){return convertHeaderButtonToGroupItem(config,defaultKey,selectedRowKeys,defaultHandler)},[selectedRowKeys]);var headerTitle=React.useMemo(function(){var items=[];if(showCreateBtn&&createBtnProps!==false){var createBtn=convertToButtonItem(createBtnProps,"$create",handleCreateClick);if(createBtn){if(!createBtn.icon){createBtn.icon=React.createElement(PlusOutlined,null)}if(createBtn.order===undefined){createBtn.order=1}if(!createBtn.label){createBtn.label=messages.table.createBtnText}if(!createBtn.type){createBtn.type="primary"}items.push(createBtn)}}if(showBatchRemoveBtn&&batchRemoveBtnProps!==false){var config=batchRemoveBtnProps||{};var visible=typeof(config===null||config===void 0?void 0:config.visible)==="function"?config.visible(selectedRowKeys):(config===null||config===void 0?void 0:config.visible)!==false;if(visible){var disabled=typeof(config===null||config===void 0?void 0:config.disabled)==="function"?config.disabled(selectedRowKeys):(config===null||config===void 0?void 0:config.disabled)||false;var batchRemoveBtnLabel=config.label||messages.table.batchRemoveBtnText;var batchRemoveBtnIcon=config.icon||React.createElement(DeleteOutlined,null);var _config_order;items.push({key:config.key||"$batchRemove",label:batchRemoveBtnLabel,order:(_config_order=config.order)!==null&&_config_order!==void 0?_config_order:2,isCustom:true,component:React.createElement(ConfirmButton,{key:config.key||"$batchRemove",mode:"modal",title:messages.table.batchRemoveModalTitle,content:messages.table.batchRemoveModalContent.replace("{count}",String(selectedRowKeys.length)),onConfirm:handleBatchRemoveConfirm,okText:"确定",cancelText:"取消",triggerBtnProps:{type:config.type,variant:config.variant||"outlined",color:config.color||"danger",disabled:selectedRowKeys.length===0||disabled,icon:batchRemoveBtnIcon,size:config.size,style:config.style,className:config.className}},batchRemoveBtnLabel)})}}headerButtonItems.forEach(function(item,index){var button=convertToButtonItem(item,item.key||"$custom-".concat(index));if(button){items.push(button)}});if(items.length===0){return null}return React.createElement(ButtonGroup,{items:items,maxCount:headerButtonMaxCount})},[showCreateBtn,createBtnProps,handleCreateClick,showBatchRemoveBtn,batchRemoveBtnProps,handleBatchRemoveConfirm,headerButtonItems,headerButtonMaxCount,selectedRowKeys,convertToButtonItem,messages]);var mergedRowSelection=React.useMemo(function(){if(rowSelection===false){return false}if(!rowSelection&&!showBatchRemoveBtn){return undefined}return _object_spread({},rowSelection)},[rowSelection,showBatchRemoveBtn]);var mergedColumns=React.useMemo(function(){var hasActions=showViewBtn||showUpdateBtn||showRemoveBtn||rowButtonItems.length>0;var columnsWithDefaults=ColumnHelper.addDefaultConfig(columns);if(!hasActions){return columnsWithDefaults}if(ColumnHelper.hasActionColumn(columns)){return columnsWithDefaults}var ActionComponent=mode==="router"?RowActionsRouter:RowActions;return _to_consumable_array(columnsWithDefaults).concat([{title:messages.table.operateColumnTitle||"操作",key:"actions",dataIndex:"actions",valueType:"option",fixed:"right",width:260,render:function(_,record,index){return React.createElement(ActionComponent,{record:record,index:index,showViewBtn:showViewBtn,viewBtnProps:viewBtnProps,onView:handleViewClick,showUpdateBtn:showUpdateBtn,updateBtnProps:updateBtnProps,onUpdate:handleUpdateClick,showRemoveBtn:showRemoveBtn,removeBtnProps:removeBtnProps,onRemove:handleRemoveClick,rowButtonItems:rowButtonItems,maxCount:rowButtonMaxCount,rowKey:restProps.rowKey})}}])},[columns,mode,showViewBtn,viewBtnProps,handleViewClick,showUpdateBtn,updateBtnProps,handleUpdateClick,showRemoveBtn,removeBtnProps,handleRemoveClick,rowButtonItems,rowButtonMaxCount,messages,restProps.rowKey]);var tableProps=React.useMemo(function(){var _prefixCls=restProps.prefixCls,_className=restProps.className,_style=restProps.style,_size=restProps.size,_tableKey=restProps.tableKey,_pagination=restProps.pagination,userOnLoadingChange=restProps.onLoadingChange,antdTableProps=_object_without_properties(restProps,["prefixCls","className","style","size","tableKey","pagination","onLoadingChange"]);return _object_spread_props(_object_spread({},antdTableProps),{onLoadingChange:function(newLoading){var loadingState=typeof newLoading==="boolean"?newLoading:!!newLoading;setLoading(loadingState);userOnLoadingChange===null||userOnLoadingChange===void 0?void 0:userOnLoadingChange(newLoading)}})},[restProps]);var contextValue=React.useMemo(function(){return{selectedRowKeys:selectedRowKeys,setSelectedRowKeys:setSelectedRowKeys,selectedRows:selectedRows,setSelectedRows:setSelectedRows,operationType:operationType,setOperationType:function(type){return setOperationType(type)},currentRecord:currentRecord,setCurrentRecord:function(record){return setCurrentRecord(record)},currentIndex:currentIndex,setCurrentIndex:function(index){return setCurrentIndex(index)},viewMode:viewMode,setViewMode:setViewMode,dataSource:dataSource,setDataSource:setDataSource,loading:loading,setLoading:setLoading}},[selectedRowKeys,selectedRows,operationType,currentRecord,currentIndex,viewMode,dataSource,loading]);var stateRef=React.useRef({selectedRowKeys:selectedRowKeys,selectedRows:selectedRows,operationType:operationType,currentRecord:currentRecord,currentIndex:currentIndex,viewMode:viewMode,dataSource:dataSource,loading:loading});React.useEffect(function(){stateRef.current={selectedRowKeys:selectedRowKeys,selectedRows:selectedRows,operationType:operationType,currentRecord:currentRecord,currentIndex:currentIndex,viewMode:viewMode,dataSource:dataSource,loading:loading}},[selectedRowKeys,selectedRows,operationType,currentRecord,currentIndex,viewMode,dataSource,loading]);var refValue=React.useMemo(function(){return{actionRef:currentActionRef,getContext:function(){return{selectedRowKeys:stateRef.current.selectedRowKeys,selectedRows:stateRef.current.selectedRows,operationType:stateRef.current.operationType,currentRecord:stateRef.current.currentRecord,currentIndex:stateRef.current.currentIndex,viewMode:stateRef.current.viewMode,dataSource:stateRef.current.dataSource,loading:stateRef.current.loading}}}},[currentActionRef,stateRef.current]);useImperativeHandle(ref,function(){return refValue},[refValue]);React.useEffect(function(){if(!tableRef){return}if(typeof tableRef==="function"){tableRef(refValue);return}if((typeof tableRef==="undefined"?"undefined":_type_of(tableRef))==="object"&&"current"in tableRef){if(ref&&(typeof ref==="undefined"?"undefined":_type_of(ref))==="object"&&"current"in ref&&ref===tableRef){return}if(tableRef.current){Object.assign(tableRef.current,refValue)}else{tableRef.current=refValue}}},[refValue,tableRef,ref]);var renderOperationContent=function(){if(operationContent){return operationContent({type:operationType,record:currentRecord||undefined,onClose:handleOperationClose,onSuccess:handleOperationSuccess})}return React.createElement(OperationContent,{type:operationType,record:currentRecord||undefined,onClose:handleOperationClose,onSuccess:handleOperationSuccess,tableColumns:columns,formConfig:formConfig})};var listContent=React.useMemo(function(){var content=React.createElement(Container,{prefixCls:prefixCls,cssVarCls:cssVarCls,className:restProps.className,style:restProps.style,searchConfig:searchConfig,searchColumns:searchColumns,columns:mergedColumns,headerTitle:mode==="router"?React.createElement(HeaderButtonsWrapper,{mode:mode,operationType:operationType},headerTitle):headerTitle,rowSelection:mergedRowSelection,pagination:currentPagination,tableProps:tableProps,actionRef:currentActionRef,wrapCSS:wrapCSS,gridCardRender:gridCardRender,gridColumns:gridColumns,gridCardFieldsPerRow:gridCardFieldsPerRow});return content},[prefixCls,cssVarCls,restProps.className,restProps.style,searchConfig,searchColumns,mergedColumns,headerTitle,mergedRowSelection,currentPagination,tableProps,currentActionRef,tableRef,wrapCSS,mode,operationType,gridCardRender,gridColumns,gridCardFieldsPerRow]);var renderOperationRoute=function(type){return React.createElement(OperationContentRouter,{type:type,currentRecord:currentRecord,operationContent:operationContent,onClose:handleOperationClose,onSuccess:handleOperationSuccess,tableColumns:columns,formConfig:formConfig})};if(mode==="router"){return wrapCSS(React.createElement(ProTableContext.Provider,{value:contextValue},React.createElement("div",{className:classNames(prefixCls,cssVarCls,restProps.className),style:restProps.style},React.createElement(MemoryRouter,{basename:routerBasePath,initialEntries:[routerBasePath]},React.createElement(Routes,null,React.createElement(Route,{path:"/",element:listContent}),React.createElement(Route,{path:"/create",element:renderOperationRoute("create")}),React.createElement(Route,{path:"/update/:id",element:renderOperationRoute("update")}),React.createElement(Route,{path:"/edit/:id",element:renderOperationRoute("update")}),React.createElement(Route,{path:"/view/:id",element:renderOperationRoute("view")}),React.createElement(Route,{path:"/detail/:id",element:renderOperationRoute("view")}))))))}return wrapCSS(React.createElement(ProTableContext.Provider,{value:contextValue},listContent,operationType!=="list"&&React.createElement(OperationContainer,{mode:mode,operationType:operationType,visible:operationVisible,onClose:handleOperationClose,modalProps:modalProps,drawerProps:drawerProps},renderOperationContent())))};export var ProTable=React.forwardRef(ProTableComponent);
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 _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 _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{ProTableContext}from"./context";import React from"react";import ProTableContainer from"./container";var ProTable=function(props){var _props_defaultViewMode=props.defaultViewMode,defaultViewMode=_props_defaultViewMode===void 0?"table":_props_defaultViewMode;var _React_useState=_sliced_to_array(React.useState([]),2),selectedRowKeys=_React_useState[0],setSelectedRowKeys=_React_useState[1];var _React_useState1=_sliced_to_array(React.useState([]),2),selectedRows=_React_useState1[0],setSelectedRows=_React_useState1[1];var _React_useState2=_sliced_to_array(React.useState("list"),2),operationType=_React_useState2[0],setOperationType=_React_useState2[1];var _React_useState3=_sliced_to_array(React.useState(null),2),currentRecord=_React_useState3[0],setCurrentRecord=_React_useState3[1];var _React_useState4=_sliced_to_array(React.useState(-1),2),currentIndex=_React_useState4[0],setCurrentIndex=_React_useState4[1];var _React_useState5=_sliced_to_array(React.useState(false),2),loading=_React_useState5[0],setLoading=_React_useState5[1];var _React_useState6=_sliced_to_array(React.useState(false),2),operationVisible=_React_useState6[0],setOperationVisible=_React_useState6[1];var _React_useState7=_sliced_to_array(React.useState(defaultViewMode),2),viewMode=_React_useState7[0],setViewMode=_React_useState7[1];var _React_useState8=_sliced_to_array(React.useState([]),2),dataSource=_React_useState8[0],setDataSource=_React_useState8[1];var _React_useState9=_sliced_to_array(React.useState({}),2),searchFormValues=_React_useState9[0],setSearchFormValues=_React_useState9[1];var actionRef=React.useRef(null);var formRef=React.useRef(null);var resetContextValue=function(){setSelectedRowKeys([]);setSelectedRows([]);setOperationType("list");setCurrentRecord(null);setCurrentIndex(-1);setViewMode(defaultViewMode);setDataSource([]);setOperationVisible(false)};var contextValue=React.useMemo(function(){return{selectedRowKeys:selectedRowKeys,setSelectedRowKeys:setSelectedRowKeys,selectedRows:selectedRows,setSelectedRows:setSelectedRows,operationType:operationType,setOperationType:function(type){return setOperationType(type)},currentRecord:currentRecord,setCurrentRecord:function(record){return setCurrentRecord(record)},currentIndex:currentIndex,setCurrentIndex:function(index){return setCurrentIndex(index)},viewMode:viewMode,setViewMode:setViewMode,dataSource:dataSource,setDataSource:setDataSource,loading:loading,setLoading:setLoading,searchFormValues:searchFormValues,setSearchFormValues:setSearchFormValues,actionRef:actionRef,operationVisible:operationVisible,setOperationVisible:setOperationVisible,resetContextValue:resetContextValue,formRef:formRef}},[selectedRowKeys,selectedRows,operationType,operationVisible,currentRecord,currentIndex,viewMode,dataSource,loading,searchFormValues,actionRef]);return React.createElement(ProTableContext.Provider,{value:contextValue},React.createElement(ProTableContainer,props))};export default ProTable;