villianjs-pro 1.0.92 → 1.0.93
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_without_holes(arr){if(Array.isArray(arr))return _array_like_to_array(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(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}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 _to_consumable_array(arr){return _array_without_holes(arr)||_iterable_to_array(arr)||_unsupported_iterable_to_array(arr)||_non_iterable_spread()}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,{useContext}from"react";import{Row,Col,Card,Pagination}from"antd";import useStyle from"../styles";import{useCommonStyles}from"../../hooks";import classNames from"classnames";import{ProTableContext}from"../context";export var GridView=function(props){var _props_dataSource=props.dataSource,dataSource=_props_dataSource===void 0?[]:_props_dataSource,cardRender=props.cardRender,_props_gridColumns=props.gridColumns,gridColumns=_props_gridColumns===void 0?{xs:1,sm:2,md:3,lg:
|
|
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_without_holes(arr){if(Array.isArray(arr))return _array_like_to_array(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(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}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 _to_consumable_array(arr){return _array_without_holes(arr)||_iterable_to_array(arr)||_unsupported_iterable_to_array(arr)||_non_iterable_spread()}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,{useContext}from"react";import{Row,Col,Card,Pagination}from"antd";import useStyle from"../styles";import{useCommonStyles}from"../../hooks";import classNames from"classnames";import{ProTableContext}from"../context";export var GridView=function(props){var _props_dataSource=props.dataSource,dataSource=_props_dataSource===void 0?[]:_props_dataSource,cardRender=props.cardRender,_props_gridColumns=props.gridColumns,gridColumns=_props_gridColumns===void 0?{xs:1,sm:2,md:3,lg:3,xl:3,xxl:3}:_props_gridColumns,pagination=props.pagination,rowSelection=props.rowSelection,_props_selectedRowKeys=props.selectedRowKeys,selectedRowKeys=_props_selectedRowKeys===void 0?[]:_props_selectedRowKeys,onSelectChange=props.onSelectChange,_props_rowKey=props.rowKey,rowKey=_props_rowKey===void 0?"id":_props_rowKey;var _useCommonStyles=useCommonStyles("vlian-table",props,useStyle),prefixCls=_useCommonStyles.prefixCls,wrapCSS=_useCommonStyles.wrapCSS,hashId=_useCommonStyles.hashId;var actionRef=useContext(ProTableContext).actionRef;var customPage=React.useMemo(function(){var _actionRef_current;var pageInfo=actionRef===null||actionRef===void 0?void 0:(_actionRef_current=actionRef.current)===null||_actionRef_current===void 0?void 0:_actionRef_current.pageInfo;return(pageInfo===null||pageInfo===void 0?void 0:pageInfo.total)===0&&dataSource.length>0},[actionRef,dataSource]);var mergedPagination=React.useMemo(function(){var _actionRef_current;if(pagination===false){return false}var pageInfo=actionRef===null||actionRef===void 0?void 0:(_actionRef_current=actionRef.current)===null||_actionRef_current===void 0?void 0:_actionRef_current.pageInfo;return _object_spread_props(_object_spread({},pagination,pageInfo),{defaultCurrent:(pageInfo===null||pageInfo===void 0?void 0:pageInfo.current)||(pagination===null||pagination===void 0?void 0:pagination.current)||1,total:(pageInfo===null||pageInfo===void 0?void 0:pageInfo.total)||(pagination===null||pagination===void 0?void 0:pagination.total)||dataSource.length||0})},[pagination,actionRef,dataSource.length]);var handlePageChange=React.useCallback(function(page,pageSize){var _pagination_onChange,_actionRef_current;pagination===null||pagination===void 0?void 0:(_pagination_onChange=pagination.onChange)===null||_pagination_onChange===void 0?void 0:_pagination_onChange.call(pagination,page,pageSize);if(actionRef===null||actionRef===void 0?void 0:(_actionRef_current=actionRef.current)===null||_actionRef_current===void 0?void 0:_actionRef_current.setPageInfo){actionRef.current.setPageInfo({current:page,pageSize:pageSize})}},[pagination,actionRef]);var handlePageSizeChange=React.useCallback(function(current,size){var _pagination_onShowSizeChange,_actionRef_current;pagination===null||pagination===void 0?void 0:(_pagination_onShowSizeChange=pagination.onShowSizeChange)===null||_pagination_onShowSizeChange===void 0?void 0:_pagination_onShowSizeChange.call(pagination,current,size);if(actionRef===null||actionRef===void 0?void 0:(_actionRef_current=actionRef.current)===null||_actionRef_current===void 0?void 0:_actionRef_current.setPageInfo){actionRef.current.setPageInfo({current:current,pageSize:size})}},[pagination,actionRef]);var colSpan=React.useMemo(function(){return{xs:gridColumns.xs?24/gridColumns.xs:24,sm:gridColumns.sm?24/gridColumns.sm:12,md:gridColumns.md?24/gridColumns.md:8,lg:gridColumns.lg?24/gridColumns.lg:8,xl:gridColumns.xl?24/gridColumns.xl:8,xxl:gridColumns.xxl?24/gridColumns.xxl:8}},[gridColumns]);var getRecordKey=React.useCallback(function(record,index){if(typeof rowKey==="function"){return rowKey(record,index)}return record[rowKey]},[rowKey]);var handleSelect=React.useCallback(function(record,index){return function(selected){var key=getRecordKey(record,index);var newKeys;var newRows;if(selected){newKeys=_to_consumable_array(selectedRowKeys).concat([key]);newRows=dataSource.filter(function(item,idx){var itemKey=getRecordKey(item,idx);return selectedRowKeys.includes(itemKey)||itemKey===key})}else{newKeys=selectedRowKeys.filter(function(k){return k!==key});newRows=dataSource.filter(function(item,idx){var itemKey=getRecordKey(item,idx);return newKeys.includes(itemKey)})}onSelectChange===null||onSelectChange===void 0?void 0:onSelectChange(newKeys,newRows)}},[dataSource,selectedRowKeys,onSelectChange,getRecordKey]);var list=React.useMemo(function(){if(!customPage){return dataSource.map(function(record,index){return{record:record,originalIndex:index}})}if(mergedPagination===false){return dataSource.map(function(record,index){return{record:record,originalIndex:index}})}var _mergedPagination_current=mergedPagination.current,current=_mergedPagination_current===void 0?1:_mergedPagination_current,_mergedPagination_pageSize=mergedPagination.pageSize,pageSize=_mergedPagination_pageSize===void 0?10:_mergedPagination_pageSize;var start=(current-1)*pageSize;var end=current*pageSize;return dataSource.slice(start,end).map(function(record,index){return{record:record,originalIndex:start+index}})},[dataSource,mergedPagination,customPage]);var showSelection=React.useMemo(function(){var currentSelection=rowSelection!==null&&rowSelection!==void 0?rowSelection:false;if(currentSelection===false){return false}return true},[rowSelection]);if(!dataSource||dataSource.length===0){return wrapCSS(React.createElement(Card,null,React.createElement("div",{className:classNames("".concat(prefixCls,"-grid-view-empty"),hashId)},"暂无数据")))}return wrapCSS(React.createElement("div",null,React.createElement(Row,{gutter:[16,16]},list.map(function(param){var record=param.record,originalIndex=param.originalIndex;var key=getRecordKey(record,originalIndex);var isSelected=selectedRowKeys.includes(key);return React.createElement(Col,_object_spread({key:String(key)},colSpan),cardRender({record:record,index:originalIndex,isSelected:isSelected,rowKey:key,onSelect:handleSelect(record,originalIndex),showSelection:showSelection}))})),mergedPagination!==false&&React.createElement("div",{className:classNames("".concat(prefixCls,"-grid-view-pagination"),hashId)},React.createElement(Pagination,_object_spread_props(_object_spread({showQuickJumper:false,showSizeChanger:true,align:"end",size:"small",showTotal:function(total,range){return"第 ".concat(range[0],"-").concat(range[1]," 条/总共 ").concat(total," 条")}},mergedPagination),{onChange:handlePageChange,onShowSizeChange:handlePageSizeChange})))))};
|
package/dist/ProTable/types.d.ts
CHANGED
|
@@ -338,7 +338,7 @@ export type ProTableProps<DataSource extends Record<string, any> = Record<string
|
|
|
338
338
|
gridCardRender?: GridCardRender<DataSource>;
|
|
339
339
|
/**
|
|
340
340
|
* @description 网格列数配置
|
|
341
|
-
* @default { xs: 1, sm: 2, md: 3, lg:
|
|
341
|
+
* @default { xs: 1, sm: 2, md: 3, lg: 3, xl: 3, xxl: 3 }
|
|
342
342
|
*/
|
|
343
343
|
gridColumns?: {
|
|
344
344
|
xs?: number;
|
package/package.json
CHANGED