villianjs-pro 1.0.16 → 1.0.18

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 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_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 _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)}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{useState,useMemo,useEffect,useCallback,memo}from"react";import{message}from"antd";import{Modal}from"../../Modal";import{UploadStep}from"./upload-step";import{UploadProgressStep}from"./upload-progress-step";import{ImportProgressStep}from"./import-progress-step";import{ImportResultStep}from"./import-result-step";import{handleImportError,validateUploadResult}from"../utils/error-handler";import{useImportContextOptional}from"../context/import-context";import{useLocale}from"../../locale";export var ImportModal=memo(function(param){var title=param.title,open=param.open,onClose=param.onClose,propsOnFileSelect=param.onFileSelect,propsOnDownloadTemplate=param.onDownloadTemplate,propsQueryProgress=param.queryProgress,propsPollInterval=param.pollInterval,modalProps=param.modalProps,propsTaskKey=param.taskKey,propsImportProgressStepRender=param.importProgressStepRender,propsTips=param.tips,propsUploadStepConfig=param.uploadStepConfig;var context=useImportContextOptional();var _ref;var taskKey=(_ref=propsTaskKey!==null&&propsTaskKey!==void 0?propsTaskKey:context===null||context===void 0?void 0:context.taskKey)!==null&&_ref!==void 0?_ref:"id";var queryProgress=propsQueryProgress!==null&&propsQueryProgress!==void 0?propsQueryProgress:context===null||context===void 0?void 0:context.queryProgress;var importProgressStepRender=propsImportProgressStepRender!==null&&propsImportProgressStepRender!==void 0?propsImportProgressStepRender:context===null||context===void 0?void 0:context.importProgressStepRender;var onDownloadTemplate=propsOnDownloadTemplate!==null&&propsOnDownloadTemplate!==void 0?propsOnDownloadTemplate:context===null||context===void 0?void 0:context.onDownloadTemplate;var onFileSelect=propsOnFileSelect!==null&&propsOnFileSelect!==void 0?propsOnFileSelect:context===null||context===void 0?void 0:context.onFileSelect;var tips=propsTips!==null&&propsTips!==void 0?propsTips:context===null||context===void 0?void 0:context.tips;var uploadStepConfig=propsUploadStepConfig!==null&&propsUploadStepConfig!==void 0?propsUploadStepConfig:context===null||context===void 0?void 0:context.uploadStepConfig;var pollInterval=propsPollInterval!==null&&propsPollInterval!==void 0?propsPollInterval:context===null||context===void 0?void 0:context.pollInterval;var _useState=_sliced_to_array(useState("upload"),2),step=_useState[0],setStep=_useState[1];var _useState1=_sliced_to_array(useState(null),2),importId=_useState1[0],setImportId=_useState1[1];var _useState2=_sliced_to_array(useState(null),2),uploadResult=_useState2[0],setUploadResult=_useState2[1];var _useState3=_sliced_to_array(useState(0),2),uploadProgress=_useState3[0],setUploadProgress=_useState3[1];var _useState4=_sliced_to_array(useState(null),2),importResult=_useState4[0],setImportResult=_useState4[1];var messages=useLocale().messages;useEffect(function(){if(!open){var timer=setTimeout(function(){setStep("upload");setUploadProgress(0);setImportId(null);setUploadResult(null);setImportResult(null)},300);return function(){return clearTimeout(timer)}}return undefined},[open]);var handleFileSelect=useCallback(function(file){return _async_to_generator(function(){var uploadConfig,result,error,errorMessage;return _ts_generator(this,function(_state){switch(_state.label){case 0:if(!onFileSelect){throw new Error(messages.imports.errors.uploadMethodNotSet)}_state.label=1;case 1:_state.trys.push([1,3,,4]);setStep("uploading");setUploadProgress(0);uploadConfig={headers:{"Content-Type":"multipart/form-data"},onUploadProgress:function(event){if(event.total){var percent=Math.round(event.loaded/event.total*100);setUploadProgress(percent)}}};return[4,onFileSelect(file,uploadConfig)];case 2:result=_state.sent();if(validateUploadResult(result,taskKey)){setImportId(result[taskKey]);setUploadResult(result);setStep("importing")}else{throw new Error(messages.imports.errors.uploadFailed)}return[3,4];case 3:error=_state.sent();setStep("upload");setUploadProgress(0);errorMessage=handleImportError(error,messages.imports.errors.uploadError);message.error(errorMessage);throw error;case 4:return[2]}})})()},[onFileSelect,taskKey]);var handleImportComplete=useCallback(function(result){setImportResult(result);setStep("result")},[]);var handleClose=useCallback(function(){onClose()},[onClose]);var handleOpenChange=useCallback(function(visible){if(!visible){handleClose()}},[handleClose]);var stepTitleMap={upload:messages.imports.stepTitles.upload,uploading:messages.imports.stepTitles.uploading,importing:messages.imports.stepTitles.importing,result:messages.imports.stepTitles.result};var currentTitle=useMemo(function(){return stepTitleMap[step]||title},[step,title]);return React.createElement(Modal.CustomModal,_object_spread({title:currentTitle,open:open,onOpenChange:handleOpenChange,footer:false,onCancel:handleClose,maskClosable:false,width:600},modalProps),step==="upload"&&React.createElement(UploadStep,{onFileSelect:handleFileSelect,onDownloadTemplate:onDownloadTemplate,tips:tips,config:uploadStepConfig}),step==="uploading"&&React.createElement(UploadProgressStep,{progress:uploadProgress}),step==="importing"&&importId&&React.createElement(ImportProgressStep,{importId:importId,uploadResult:uploadResult||undefined,onComplete:handleImportComplete,onClose:handleClose,queryProgress:queryProgress,pollInterval:pollInterval,importProgressStepRender:importProgressStepRender}),step==="result"&&importResult&&React.createElement(ImportResultStep,{result:importResult,onClose:handleClose}))});ImportModal.displayName="ImportModal";
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 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_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 _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)}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{useState,useMemo,useEffect,useCallback,memo}from"react";import{message}from"antd";import React from"react";import{Modal}from"../../Modal";import{UploadStep}from"./upload-step";import{UploadProgressStep}from"./upload-progress-step";import{ImportProgressStep}from"./import-progress-step";import{ImportResultStep}from"./import-result-step";import{handleImportError,validateUploadResult}from"../utils/error-handler";import{useImportContextOptional}from"../context/import-context";import{useLocale}from"../../locale";export var ImportModal=memo(function(param){var title=param.title,open=param.open,onClose=param.onClose,propsOnFileSelect=param.onFileSelect,propsOnDownloadTemplate=param.onDownloadTemplate,propsQueryProgress=param.queryProgress,propsPollInterval=param.pollInterval,modalProps=param.modalProps,propsTaskKey=param.taskKey,propsImportProgressStepRender=param.importProgressStepRender,propsTips=param.tips,propsUploadStepConfig=param.uploadStepConfig;var context=useImportContextOptional();var _ref;var taskKey=(_ref=propsTaskKey!==null&&propsTaskKey!==void 0?propsTaskKey:context===null||context===void 0?void 0:context.taskKey)!==null&&_ref!==void 0?_ref:"id";var queryProgress=propsQueryProgress!==null&&propsQueryProgress!==void 0?propsQueryProgress:context===null||context===void 0?void 0:context.queryProgress;var importProgressStepRender=propsImportProgressStepRender!==null&&propsImportProgressStepRender!==void 0?propsImportProgressStepRender:context===null||context===void 0?void 0:context.importProgressStepRender;var onDownloadTemplate=propsOnDownloadTemplate!==null&&propsOnDownloadTemplate!==void 0?propsOnDownloadTemplate:context===null||context===void 0?void 0:context.onDownloadTemplate;var onFileSelect=propsOnFileSelect!==null&&propsOnFileSelect!==void 0?propsOnFileSelect:context===null||context===void 0?void 0:context.onFileSelect;var tips=propsTips!==null&&propsTips!==void 0?propsTips:context===null||context===void 0?void 0:context.tips;var uploadStepConfig=propsUploadStepConfig!==null&&propsUploadStepConfig!==void 0?propsUploadStepConfig:context===null||context===void 0?void 0:context.uploadStepConfig;var pollInterval=propsPollInterval!==null&&propsPollInterval!==void 0?propsPollInterval:context===null||context===void 0?void 0:context.pollInterval;var _useState=_sliced_to_array(useState("upload"),2),step=_useState[0],setStep=_useState[1];var _useState1=_sliced_to_array(useState(null),2),importId=_useState1[0],setImportId=_useState1[1];var _useState2=_sliced_to_array(useState(null),2),uploadResult=_useState2[0],setUploadResult=_useState2[1];var _useState3=_sliced_to_array(useState(0),2),uploadProgress=_useState3[0],setUploadProgress=_useState3[1];var _useState4=_sliced_to_array(useState(null),2),importResult=_useState4[0],setImportResult=_useState4[1];var messages=useLocale().messages;useEffect(function(){if(!open){var timer=setTimeout(function(){setStep("upload");setUploadProgress(0);setImportId(null);setUploadResult(null);setImportResult(null)},300);return function(){return clearTimeout(timer)}}return undefined},[open]);var handleFileSelect=useCallback(function(file){return _async_to_generator(function(){var uploadConfig,result,error,errorMessage;return _ts_generator(this,function(_state){switch(_state.label){case 0:if(!onFileSelect){throw new Error(messages.imports.errors.uploadMethodNotSet)}_state.label=1;case 1:_state.trys.push([1,3,,4]);setStep("uploading");setUploadProgress(0);uploadConfig={headers:{"Content-Type":"multipart/form-data"},onUploadProgress:function(event){if(event.total){var percent=Math.round(event.loaded/event.total*100);setUploadProgress(percent)}}};return[4,onFileSelect(file,uploadConfig)];case 2:result=_state.sent();if(validateUploadResult(result,taskKey)){setImportId(result[taskKey]);setUploadResult(result);setStep("importing")}else{throw new Error(messages.imports.errors.uploadFailed)}return[3,4];case 3:error=_state.sent();setStep("upload");setUploadProgress(0);errorMessage=handleImportError(error,messages.imports.errors.uploadError);message.error(errorMessage);throw error;case 4:return[2]}})})()},[onFileSelect,taskKey]);var handleImportComplete=useCallback(function(result){setImportResult(result);setStep("result")},[]);var handleClose=useCallback(function(){onClose()},[onClose]);var handleOpenChange=useCallback(function(visible){if(!visible){handleClose()}},[handleClose]);var stepTitleMap={upload:messages.imports.stepTitles.upload,uploading:messages.imports.stepTitles.uploading,importing:messages.imports.stepTitles.importing,result:messages.imports.stepTitles.result};var currentTitle=useMemo(function(){return stepTitleMap[step]||title},[step,title]);return React.createElement(Modal.CustomModal,_object_spread({title:currentTitle,open:open,onOpenChange:handleOpenChange,footer:false,onCancel:handleClose,maskClosable:false,width:600},modalProps),step==="upload"&&React.createElement(UploadStep,{onFileSelect:handleFileSelect,onDownloadTemplate:onDownloadTemplate,tips:tips,config:uploadStepConfig}),step==="uploading"&&React.createElement(UploadProgressStep,{progress:uploadProgress}),step==="importing"&&importId&&React.createElement(ImportProgressStep,{importId:importId,uploadResult:uploadResult||undefined,onComplete:handleImportComplete,onClose:handleClose,queryProgress:queryProgress,pollInterval:pollInterval,importProgressStepRender:importProgressStepRender}),step==="result"&&importResult&&React.createElement(ImportResultStep,{result:importResult,onClose:handleClose}))});ImportModal.displayName="ImportModal";
@@ -1 +1 @@
1
- import{createContext,useContext,useMemo}from"react";var ImportContext=createContext(null);export var ImportContextProvider=function(param){var value=param.value,children=param.children;var contextValue=useMemo(function(){return value},[value.taskKey,value.queryProgress,value.importProgressStepRender,value.onDownloadTemplate,value.onFileSelect,value.queryImportRecords,value.importRecordColumns,value.importRecordTableProps,value.queryImportErrors,value.importErrorColumns,value.importErrorTableProps,value.importDetailContentRender,value.tips,value.uploadStepConfig,value.pollInterval]);return React.createElement(ImportContext.Provider,{value:contextValue},children)};export var useImportContext=function(){var context=useContext(ImportContext);if(!context){throw new Error("useImportContext must be used within ImportContextProvider")}return context};export var useImportContextOptional=function(){return useContext(ImportContext)};
1
+ import{createContext,useContext,useMemo}from"react";import React from"react";var ImportContext=createContext(null);export var ImportContextProvider=function(param){var value=param.value,children=param.children;var contextValue=useMemo(function(){return value},[value.taskKey,value.queryProgress,value.importProgressStepRender,value.onDownloadTemplate,value.onFileSelect,value.queryImportRecords,value.importRecordColumns,value.importRecordTableProps,value.queryImportErrors,value.importErrorColumns,value.importErrorTableProps,value.importDetailContentRender,value.tips,value.uploadStepConfig,value.pollInterval]);return React.createElement(ImportContext.Provider,{value:contextValue},children)};export var useImportContext=function(){var context=useContext(ImportContext);if(!context){throw new Error("useImportContext must be used within ImportContextProvider")}return context};export var useImportContextOptional=function(){return useContext(ImportContext)};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "villianjs-pro",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",