dinocollab-core 1.1.7 → 1.1.8

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,2 +1,2 @@
1
- import{inherits as r,createClass as e,objectWithoutProperties as o,objectSpread2 as t,classCallCheck as i,callSuper as n,defineProperty as a}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsx as s}from"react/jsx-runtime";import{memo as l,Component as u}from"react";import{styled as d,colors as c,Grid as p,Typography as m}from"@mui/material";import{DataGrid as f}from"@mui/x-data-grid";var g=["Element"],v=["Element"],h=function(){return s(m,{variant:"subtitle1",color:"textSecondary",children:"No items to display"})};function b(){return l(function(){function a(r){var e;return i(this,a),(e=n(this,a,[r])).ElementComponent=r.configs.Element||h,e}return r(a,u),e(a,[{key:"shouldComponentUpdate",value:function(r){var e=this.props.configs,t=e.Element,i=o(e,g),n=r.configs,a=n.Element,s=o(n,v);t!==a&&(this.ElementComponent=r.configs.Element||h);var l=JSON.stringify(i)!==JSON.stringify(s);return JSON.stringify(this.props.data)!==JSON.stringify(r.data)||l}},{key:"render",value:function(){var r=this.ElementComponent,e=this.props,o=e.data,i=e.configs,n=i.size||{xs:12,sm:6,md:4,lg:3};return s(p,t(t({container:!0,spacing:i.spacing||0},i.wrapProps),{},{children:o.map((function(e,o){var a=i.getElementId?i.getElementId(e):o.toString(),l=i.elementWrapPropsGetter?i.elementWrapPropsGetter({data:e,index:o}):i.elementWrapProps||{};return s(p,t(t(t({item:!0},n),l),{},{children:s(r,{data:e,index:o})}),a)}))}))}}])}())}function x(){var o=function(r){var e,o=null!==(e=null==r?void 0:r.columns)&&void 0!==e?e:{};return Object.keys(o).map((function(r){var e=o[r];return t({field:String(r),sortable:!1},e)}))};return l(function(){function l(r){var e;return i(this,l),e=n(this,l,[r]),a(e,"columns",[]),e.columns=o(r.configs),e}return r(l,u),e(l,[{key:"shouldComponentUpdate",value:function(r){var e=JSON.stringify(this.props.value)!==JSON.stringify(r.value),t=JSON.stringify(this.props.configs)!==JSON.stringify(r.configs);return t&&(this.columns=o()),e||t}},{key:"render",value:function(){var r,e,o,i,n;if(this.props.configs&&Object.keys(null!==(r=null===(e=this.props.configs)||void 0===e?void 0:e.columns)&&void 0!==r?r:{}).length>0){var a=this.props.value;return s(y,t({hideFooter:!0,disableColumnFilter:!0,disableColumnMenu:!0,getRowId:null===(o=this.props.configs)||void 0===o?void 0:o.getRowId,rows:a,rowHeight:null===(i=this.props.configs)||void 0===i?void 0:i.rowHeight,columnHeaderHeight:48,getRowSpacing:function(r){return{top:r.isFirstVisible?8:4,bottom:4}},columns:this.columns,disableColumnSelector:!0},null===(n=this.props.slots)||void 0===n?void 0:n.dataGridProps))}}}])}())}var y=d(f)((function(r){var e=r.theme;return{"*":{boxSizing:"border-box"},"--custom-border-color":"rgba(145, 158, 171, 0.16)",borderColor:"transparent","--DataGrid-rowBorderColor":"transparent",".MuiDataGrid-cell:focus, .MuiDataGrid-columnHeader:focus":{outline:"none"},".MuiDataGrid-cell:focus-within, .MuiDataGrid-columnHeader:focus-within":{outline:"none"},".MuiDataGrid-cell.Mui-focusVisible, .MuiDataGrid-columnHeader.Mui-focusVisible":{outline:"none"},".MuiDataGrid-columnHeaders":{backgroundColor:c.grey[50],borderColor:"transparent",borderRadius:"6px"},".MuiDataGrid-virtualScrollerContent":{".MuiDataGrid-virtualScrollerRenderZone":{width:"100%"},".MuiDataGrid-row":{"--rowBorderColor":"var(--custom-border-color)",borderRadius:"6px",position:"relative",overflow:"hidden",zIndex:1,borderStyle:"dashed",borderWidth:"1px",borderColor:"var(--rowBorderColor)",width:"100%",transition:"all 0.2s ease","&:hover":{"--rowBorderColor":e.palette.divider,borderStyle:"solid",transform:"translateY(-1px)",boxShadow:"rgba(99, 99, 99, 0.1) 0px 2px 8px 0px",zIndex:2}},".MuiDataGrid-cell":{"--rowBorderColor":"transparent",display:"flex",alignItems:"center"}}}}));export{x as createViewModeList,b as createViewModeModule};
1
+ import{inherits as r,createClass as o,objectWithoutProperties as e,objectSpread2 as t,classCallCheck as i,callSuper as n,defineProperty as a}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsx as s}from"react/jsx-runtime";import{memo as l,Component as d}from"react";import{styled as u,colors as c,Grid as p,Typography as m}from"@mui/material";import{DataGrid as f}from"@mui/x-data-grid";var g=["Element"],b=["Element"],h=function(){return s(m,{variant:"subtitle1",color:"textSecondary",children:"No items to display"})};function v(){return l(function(){function a(r){var o;return i(this,a),(o=n(this,a,[r])).ElementComponent=r.configs.Element||h,o}return r(a,d),o(a,[{key:"shouldComponentUpdate",value:function(r){var o=this.props.configs,t=o.Element,i=e(o,g),n=r.configs,a=n.Element,s=e(n,b);t!==a&&(this.ElementComponent=r.configs.Element||h);var l=JSON.stringify(i)!==JSON.stringify(s);return JSON.stringify(this.props.data)!==JSON.stringify(r.data)||l}},{key:"render",value:function(){var r=this.ElementComponent,o=this.props,e=o.data,i=o.configs,n=i.size||{xs:12,sm:6,md:4,lg:3};return s(p,t(t({container:!0,spacing:i.spacing||0},i.wrapProps),{},{children:e.map((function(o,e){var a=i.getElementId?i.getElementId(o):e.toString(),l=i.elementWrapPropsGetter?i.elementWrapPropsGetter({data:o,index:e}):i.elementWrapProps||{};return s(p,t(t(t({item:!0},n),l),{},{children:s(r,{data:o,index:e})}),a)}))}))}}])}())}function x(){var e=function(r){var o,e=null!==(o=null==r?void 0:r.columns)&&void 0!==o?o:{};return Object.keys(e).map((function(r){var o=e[r];return t({field:String(r),sortable:!1},o)}))};return l(function(){function l(r){var o;return i(this,l),o=n(this,l,[r]),a(o,"columns",[]),o.columns=e(r.configs),o}return r(l,d),o(l,[{key:"shouldComponentUpdate",value:function(r){var o=JSON.stringify(this.props.value)!==JSON.stringify(r.value),t=JSON.stringify(this.props.configs)!==JSON.stringify(r.configs);return t&&(this.columns=e()),o||t}},{key:"render",value:function(){var r,o,e,i,n;if(this.props.configs&&Object.keys(null!==(r=null===(o=this.props.configs)||void 0===o?void 0:o.columns)&&void 0!==r?r:{}).length>0){var a=this.props.value;return s(y,t({hideFooter:!0,disableColumnFilter:!0,disableColumnMenu:!0,getRowId:null===(e=this.props.configs)||void 0===e?void 0:e.getRowId,rows:a,rowHeight:null===(i=this.props.configs)||void 0===i?void 0:i.rowHeight,columnHeaderHeight:48,getRowSpacing:function(r){return{top:r.isFirstVisible?8:4,bottom:4}},columns:this.columns,disableColumnSelector:!0},null===(n=this.props.slots)||void 0===n?void 0:n.dataGridProps))}}}])}())}var y=u(f)((function(r){var o=r.theme;return{"*":{boxSizing:"border-box"},"--custom-border-color":"rgba(145, 158, 171, 0.16)","--custom-bg-color":o.palette.background.paper,"--DataGrid-rowBorderColor":"transparent",borderColor:"transparent",".MuiDataGrid-cell":{"--rowBorderColor":"transparent",display:"flex",alignItems:"center"},".MuiDataGrid-cell:focus, .MuiDataGrid-columnHeader:focus":{outline:"none"},".MuiDataGrid-cell:focus-within, .MuiDataGrid-columnHeader:focus-within":{outline:"none"},".MuiDataGrid-cell.Mui-focusVisible, .MuiDataGrid-columnHeader.Mui-focusVisible":{outline:"none"},".MuiDataGrid-columnHeaders":{backgroundColor:c.grey[50],borderColor:"transparent",borderRadius:"6px"},".MuiDataGrid-virtualScrollerContent":{".MuiDataGrid-row":{borderRadius:"6px",border:"none",transition:"all 0.2s ease",backgroundColor:"var(--custom-bg-color)",".MuiDataGrid-cell":{backgroundColor:"var(--custom-bg-color)",border:"none",borderTop:"1px dashed var(--custom-border-color)",borderBottom:"1px dashed var(--custom-border-color)","&:first-child":{borderLeft:"1px dashed var(--custom-border-color)",borderRadius:"6px 0 0 6px"},"&:last-child":{borderRight:"1px dashed var(--custom-border-color)",borderRadius:"0 6px 6px 0"}},"&:hover":{"--custom-border-color":o.palette.divider,"--custom-bg-color":c.grey[50],transform:"translateY(-1px)",boxShadow:"rgba(99, 99, 99, 0.1) 0px 2px 8px 0px",".MuiDataGrid-cell":{borderTopStyle:"solid",borderBottomStyle:"solid","&:first-child":{borderLeftStyle:"solid"},"&:last-child":{borderRightStyle:"solid"}}}}}}}));export{x as createViewModeList,v as createViewModeModule};
2
2
  //# sourceMappingURL=view-mode.content.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"view-mode.content.js","sources":["../../src/data-view/view-mode.content.tsx"],"sourcesContent":["import React, { Component, ComponentType, FC, memo } from 'react'\r\nimport { Typography, Grid, styled, colors } from '@mui/material'\r\nimport { DataGrid, DataGridProps, GridColDef, GridRowIdGetter, GridValidRowModel } from '@mui/x-data-grid'\r\nimport { GridColsDef, IViewModeListConfig, IViewModeModuleConfig, IViewModeValidModel } from './view-mode.types'\r\n\r\n//#region Mode Module\r\nconst EmptyModule: FC = () => (\r\n <Typography variant='subtitle1' color='textSecondary'>\r\n No items to display\r\n </Typography>\r\n)\r\n\r\ninterface IViewModeModuleProps<T extends IViewModeValidModel> {\r\n data: T[]\r\n configs: IViewModeModuleConfig<T>\r\n}\r\n\r\nexport function createViewModeModule<T extends IViewModeValidModel>(): ComponentType<IViewModeModuleProps<T>> {\r\n class ViewModeModule extends Component<IViewModeModuleProps<T>> {\r\n private ElementComponent\r\n constructor(props: IViewModeModuleProps<T>) {\r\n super(props)\r\n this.ElementComponent = props.configs.Element || EmptyModule\r\n }\r\n\r\n shouldComponentUpdate(nextProps: Readonly<IViewModeModuleProps<T>>): boolean {\r\n const { Element: currentElement, ...currentConfig } = this.props.configs\r\n const { Element: nextElement, ...nextConfigs } = nextProps.configs\r\n const checkElementDiff = currentElement !== nextElement\r\n if (checkElementDiff) {\r\n this.ElementComponent = nextProps.configs.Element || EmptyModule\r\n }\r\n\r\n const checkConfigsDiff = JSON.stringify(currentConfig) !== JSON.stringify(nextConfigs)\r\n const checkDataDiff = JSON.stringify(this.props.data) !== JSON.stringify(nextProps.data)\r\n return checkDataDiff || checkConfigsDiff\r\n }\r\n\r\n render() {\r\n const { ElementComponent } = this\r\n const { data, configs } = this.props\r\n const size = configs.size || { xs: 12, sm: 6, md: 4, lg: 3 }\r\n return (\r\n <Grid container spacing={configs.spacing || 0} {...configs.wrapProps}>\r\n {data.map((item, index) => {\r\n const key = configs.getElementId ? configs.getElementId(item) : index.toString()\r\n const itemProps = configs.elementWrapPropsGetter ? configs.elementWrapPropsGetter({ data: item, index }) : configs.elementWrapProps || {}\r\n return (\r\n <Grid item key={key} {...size} {...itemProps}>\r\n <ElementComponent data={item} index={index} />\r\n </Grid>\r\n )\r\n })}\r\n </Grid>\r\n )\r\n }\r\n }\r\n\r\n return memo(ViewModeModule)\r\n}\r\n//#endregion\r\n\r\n//#region View Mode List\r\nexport interface IViewModeListProps<T extends IViewModeValidModel> {\r\n value: T[]\r\n configs: IViewModeListConfig<T>\r\n slots?: {\r\n dataGridProps?: Partial<Omit<DataGridProps, 'columns' | 'rows'>>\r\n }\r\n}\r\n\r\nexport function createViewModeList<T extends IViewModeValidModel>(): ComponentType<IViewModeListProps<T>> {\r\n const genarateColumns = (configs?: IViewModeListConfig<T>): GridColDef[] => {\r\n const cols: GridColsDef<T> = configs?.columns ?? {}\r\n const fields = Object.keys(cols) as (keyof T)[]\r\n return fields.map((field) => {\r\n const config = cols[field]\r\n return { field: String(field), sortable: false, ...config }\r\n })\r\n }\r\n\r\n class ViewModeList extends Component<IViewModeListProps<T>> {\r\n private columns: GridColDef[] = []\r\n constructor(props: IViewModeListProps<T>) {\r\n super(props)\r\n this.columns = genarateColumns(props.configs)\r\n }\r\n\r\n shouldComponentUpdate(nextProps: Readonly<IViewModeListProps<T>>): boolean {\r\n const checkValueDiff = JSON.stringify(this.props.value) !== JSON.stringify(nextProps.value)\r\n const checkListConfigsDiff = JSON.stringify(this.props.configs) !== JSON.stringify(nextProps.configs)\r\n if (checkListConfigsDiff) {\r\n this.columns = genarateColumns()\r\n }\r\n return checkValueDiff || checkListConfigsDiff\r\n }\r\n\r\n render() {\r\n const isRender = this.props.configs && Object.keys(this.props.configs?.columns ?? {}).length > 0\r\n if (!isRender) {\r\n return\r\n }\r\n const rows = this.props.value as GridValidRowModel[]\r\n return (\r\n <DataGridCustom\r\n hideFooter\r\n // disableColumnSorting\r\n disableColumnFilter\r\n disableColumnMenu\r\n getRowId={this.props.configs?.getRowId as GridRowIdGetter<GridValidRowModel>}\r\n rows={rows}\r\n rowHeight={this.props.configs?.rowHeight}\r\n columnHeaderHeight={48}\r\n getRowSpacing={({ isFirstVisible }) => ({ top: isFirstVisible ? 8 : 4, bottom: 4 })}\r\n columns={this.columns}\r\n disableColumnSelector\r\n {...this.props.slots?.dataGridProps}\r\n />\r\n )\r\n }\r\n }\r\n\r\n return memo(ViewModeList)\r\n}\r\n\r\nconst DataGridCustom = styled(DataGrid)(({ theme }) => ({\r\n '*': {\r\n boxSizing: 'border-box'\r\n },\r\n '--custom-border-color': 'rgba(145, 158, 171, 0.16)',\r\n borderColor: 'transparent',\r\n '--DataGrid-rowBorderColor': 'transparent',\r\n '.MuiDataGrid-cell:focus, .MuiDataGrid-columnHeader:focus': {\r\n outline: 'none'\r\n },\r\n '.MuiDataGrid-cell:focus-within, .MuiDataGrid-columnHeader:focus-within': {\r\n outline: 'none'\r\n },\r\n '.MuiDataGrid-cell.Mui-focusVisible, .MuiDataGrid-columnHeader.Mui-focusVisible': {\r\n outline: 'none'\r\n },\r\n '.MuiDataGrid-columnHeaders': {\r\n backgroundColor: colors.grey[50],\r\n borderColor: 'transparent',\r\n borderRadius: '6px'\r\n },\r\n // '.MuiDataGrid-topContainer': {\r\n // '--DataGrid-containerBackground': colors.grey[50],\r\n // '.MuiDataGrid-columnHeader': {\r\n // backgroundColor: 'var(--DataGrid-containerBackground)'\r\n // }\r\n // },\r\n '.MuiDataGrid-virtualScrollerContent': {\r\n '.MuiDataGrid-virtualScrollerRenderZone': {\r\n width: '100%'\r\n },\r\n '.MuiDataGrid-row': {\r\n '--rowBorderColor': 'var(--custom-border-color)',\r\n borderRadius: '6px',\r\n position: 'relative',\r\n overflow: 'hidden',\r\n zIndex: 1,\r\n borderStyle: 'dashed',\r\n borderWidth: '1px',\r\n borderColor: 'var(--rowBorderColor)',\r\n width: '100%',\r\n transition: 'all 0.2s ease',\r\n '&:hover': {\r\n '--rowBorderColor': theme.palette.divider,\r\n borderStyle: 'solid',\r\n transform: 'translateY(-1px)',\r\n boxShadow: 'rgba(99, 99, 99, 0.1) 0px 2px 8px 0px',\r\n zIndex: 2\r\n }\r\n },\r\n '.MuiDataGrid-cell': {\r\n '--rowBorderColor': 'transparent',\r\n display: 'flex',\r\n alignItems: 'center'\r\n }\r\n }\r\n}))\r\n//#endregion\r\n"],"names":["EmptyModule","_jsx","Typography","variant","color","children","createViewModeModule","memo","ViewModeModule","props","_this","_classCallCheck","_callSuper","ElementComponent","configs","Element","_inherits","Component","_createClass","key","value","nextProps","_this$props$configs","this","currentElement","currentConfig","_objectWithoutProperties","_excluded","_nextProps$configs","nextElement","nextConfigs","_excluded2","checkConfigsDiff","JSON","stringify","data","_this$props","size","xs","sm","md","lg","Grid","_objectSpread","container","spacing","wrapProps","map","item","index","getElementId","toString","itemProps","elementWrapPropsGetter","elementWrapProps","createViewModeList","genarateColumns","_configs$columns","cols","columns","Object","keys","field","config","String","sortable","ViewModeList","_this2","_defineProperty","checkValueDiff","checkListConfigsDiff","_this$props$configs$c","_this$props$configs2","_this$props$configs3","_this$props$configs4","_this$props$slots","length","rows","DataGridCustom","hideFooter","disableColumnFilter","disableColumnMenu","getRowId","rowHeight","columnHeaderHeight","getRowSpacing","_ref","top","isFirstVisible","bottom","disableColumnSelector","slots","dataGridProps","styled","DataGrid","_ref2","theme","boxSizing","borderColor","outline","backgroundColor","colors","grey","borderRadius","width","position","overflow","zIndex","borderStyle","borderWidth","transition","palette","divider","transform","boxShadow","display","alignItems"],"mappings":"yaAMMA,EAAkB,WAAP,OACfC,EAACC,EAAU,CAACC,QAAQ,YAAYC,MAAM,gBAAeC,SAAA,uBAExC,WAQCC,IAyCd,OAAOC,aAtCL,SAAAC,EAAYC,GAA8B,IAAAC,EAEoB,OAFpBC,OAAAH,IACxCE,EAAAE,EAAAJ,KAAAA,GAAMC,KACDI,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AAlBA,EAAAA,EAAoBS,SAC9BL,KAAMA,EACNM,UAA6BT,QAApBA,EAAEnD,KAAKd,MAAMK,eAAX4D,IAAkBA,OAAlBA,EAAAA,EAAoBS,UAC/BC,mBAAoB,GACpBC,cAAe,SAAFC,GAAmB,MAAQ,CAAEC,IAAVD,EAAdE,eAA8C,EAAI,EAAGC,OAAQ,EAAI,EACnF9B,QAASpC,KAAKoC,QACd+B,uBAAqB,GACDf,QADCA,EACjBpD,KAAKd,MAAMkF,aAAXhB,IAAgBA,OAAhBA,EAAAA,EAAkBiB,eAfzB,CAkBH,IAAC,IAIL,CAEA,IAAMd,EAAiBe,EAAOC,EAAPD,EAAiB,SAAAE,GAAA,IAAGC,EAAKD,EAALC,MAAK,MAAQ,CACtD,IAAK,CACHC,UAAW,cAEb,wBAAyB,4BACzBC,YAAa,cACb,4BAA6B,cAC7B,2DAA4D,CAC1DC,QAAS,QAEX,yEAA0E,CACxEA,QAAS,QAEX,iFAAkF,CAChFA,QAAS,QAEX,6BAA8B,CAC5BC,gBAAiBC,EAAOC,KAAK,IAC7BJ,YAAa,cACbK,aAAc,OAQhB,sCAAuC,CACrC,yCAA0C,CACxCC,MAAO,QAET,mBAAoB,CAClB,mBAAoB,6BACpBD,aAAc,MACdE,SAAU,WACVC,SAAU,SACVC,OAAQ,EACRC,YAAa,SACbC,YAAa,MACbX,YAAa,wBACbM,MAAO,OACPM,WAAY,gBACZ,UAAW,CACT,mBAAoBd,EAAMe,QAAQC,QAClCJ,YAAa,QACbK,UAAW,mBACXC,UAAW,wCACXP,OAAQ,IAGZ,oBAAqB,CACnB,mBAAoB,cACpBQ,QAAS,OACTC,WAAY,WAGjB"}
1
+ {"version":3,"file":"view-mode.content.js","sources":["../../src/data-view/view-mode.content.tsx"],"sourcesContent":["import React, { Component, ComponentType, FC, memo } from 'react'\r\nimport { Typography, Grid, styled, colors } from '@mui/material'\r\nimport { DataGrid, DataGridProps, GridColDef, GridRowIdGetter, GridValidRowModel } from '@mui/x-data-grid'\r\nimport { GridColsDef, IViewModeListConfig, IViewModeModuleConfig, IViewModeValidModel } from './view-mode.types'\r\n\r\n//#region Mode Module\r\nconst EmptyModule: FC = () => (\r\n <Typography variant='subtitle1' color='textSecondary'>\r\n No items to display\r\n </Typography>\r\n)\r\n\r\ninterface IViewModeModuleProps<T extends IViewModeValidModel> {\r\n data: T[]\r\n configs: IViewModeModuleConfig<T>\r\n}\r\n\r\nexport function createViewModeModule<T extends IViewModeValidModel>(): ComponentType<IViewModeModuleProps<T>> {\r\n class ViewModeModule extends Component<IViewModeModuleProps<T>> {\r\n private ElementComponent\r\n constructor(props: IViewModeModuleProps<T>) {\r\n super(props)\r\n this.ElementComponent = props.configs.Element || EmptyModule\r\n }\r\n\r\n shouldComponentUpdate(nextProps: Readonly<IViewModeModuleProps<T>>): boolean {\r\n const { Element: currentElement, ...currentConfig } = this.props.configs\r\n const { Element: nextElement, ...nextConfigs } = nextProps.configs\r\n const checkElementDiff = currentElement !== nextElement\r\n if (checkElementDiff) {\r\n this.ElementComponent = nextProps.configs.Element || EmptyModule\r\n }\r\n\r\n const checkConfigsDiff = JSON.stringify(currentConfig) !== JSON.stringify(nextConfigs)\r\n const checkDataDiff = JSON.stringify(this.props.data) !== JSON.stringify(nextProps.data)\r\n return checkDataDiff || checkConfigsDiff\r\n }\r\n\r\n render() {\r\n const { ElementComponent } = this\r\n const { data, configs } = this.props\r\n const size = configs.size || { xs: 12, sm: 6, md: 4, lg: 3 }\r\n return (\r\n <Grid container spacing={configs.spacing || 0} {...configs.wrapProps}>\r\n {data.map((item, index) => {\r\n const key = configs.getElementId ? configs.getElementId(item) : index.toString()\r\n const itemProps = configs.elementWrapPropsGetter ? configs.elementWrapPropsGetter({ data: item, index }) : configs.elementWrapProps || {}\r\n return (\r\n <Grid item key={key} {...size} {...itemProps}>\r\n <ElementComponent data={item} index={index} />\r\n </Grid>\r\n )\r\n })}\r\n </Grid>\r\n )\r\n }\r\n }\r\n\r\n return memo(ViewModeModule)\r\n}\r\n//#endregion\r\n\r\n//#region View Mode List\r\nexport interface IViewModeListProps<T extends IViewModeValidModel> {\r\n value: T[]\r\n configs: IViewModeListConfig<T>\r\n slots?: {\r\n dataGridProps?: Partial<Omit<DataGridProps, 'columns' | 'rows'>>\r\n }\r\n}\r\n\r\nexport function createViewModeList<T extends IViewModeValidModel>(): ComponentType<IViewModeListProps<T>> {\r\n const genarateColumns = (configs?: IViewModeListConfig<T>): GridColDef[] => {\r\n const cols: GridColsDef<T> = configs?.columns ?? {}\r\n const fields = Object.keys(cols) as (keyof T)[]\r\n return fields.map((field) => {\r\n const config = cols[field]\r\n return { field: String(field), sortable: false, ...config }\r\n })\r\n }\r\n\r\n class ViewModeList extends Component<IViewModeListProps<T>> {\r\n private columns: GridColDef[] = []\r\n constructor(props: IViewModeListProps<T>) {\r\n super(props)\r\n this.columns = genarateColumns(props.configs)\r\n }\r\n\r\n shouldComponentUpdate(nextProps: Readonly<IViewModeListProps<T>>): boolean {\r\n const checkValueDiff = JSON.stringify(this.props.value) !== JSON.stringify(nextProps.value)\r\n const checkListConfigsDiff = JSON.stringify(this.props.configs) !== JSON.stringify(nextProps.configs)\r\n if (checkListConfigsDiff) {\r\n this.columns = genarateColumns()\r\n }\r\n return checkValueDiff || checkListConfigsDiff\r\n }\r\n\r\n render() {\r\n const isRender = this.props.configs && Object.keys(this.props.configs?.columns ?? {}).length > 0\r\n if (!isRender) {\r\n return\r\n }\r\n const rows = this.props.value as GridValidRowModel[]\r\n return (\r\n <DataGridCustom\r\n hideFooter\r\n // disableColumnSorting\r\n disableColumnFilter\r\n disableColumnMenu\r\n getRowId={this.props.configs?.getRowId as GridRowIdGetter<GridValidRowModel>}\r\n rows={rows}\r\n rowHeight={this.props.configs?.rowHeight}\r\n columnHeaderHeight={48}\r\n getRowSpacing={({ isFirstVisible }) => ({ top: isFirstVisible ? 8 : 4, bottom: 4 })}\r\n columns={this.columns}\r\n disableColumnSelector\r\n {...this.props.slots?.dataGridProps}\r\n />\r\n )\r\n }\r\n }\r\n\r\n return memo(ViewModeList)\r\n}\r\n\r\nconst DataGridCustom = styled(DataGrid)(({ theme }) => ({\r\n '*': {\r\n boxSizing: 'border-box'\r\n },\r\n '--custom-border-color': 'rgba(145, 158, 171, 0.16)',\r\n '--custom-bg-color': theme.palette.background.paper,\r\n '--DataGrid-rowBorderColor': 'transparent',\r\n borderColor: 'transparent',\r\n '.MuiDataGrid-cell': {\r\n '--rowBorderColor': 'transparent',\r\n display: 'flex',\r\n alignItems: 'center'\r\n },\r\n '.MuiDataGrid-cell:focus, .MuiDataGrid-columnHeader:focus': {\r\n outline: 'none'\r\n },\r\n '.MuiDataGrid-cell:focus-within, .MuiDataGrid-columnHeader:focus-within': {\r\n outline: 'none'\r\n },\r\n '.MuiDataGrid-cell.Mui-focusVisible, .MuiDataGrid-columnHeader.Mui-focusVisible': {\r\n outline: 'none'\r\n },\r\n '.MuiDataGrid-columnHeaders': {\r\n backgroundColor: colors.grey[50],\r\n borderColor: 'transparent',\r\n borderRadius: '6px'\r\n },\r\n '.MuiDataGrid-virtualScrollerContent': {\r\n '.MuiDataGrid-row': {\r\n borderRadius: '6px',\r\n border: 'none',\r\n transition: 'all 0.2s ease',\r\n backgroundColor: 'var(--custom-bg-color)',\r\n '.MuiDataGrid-cell': {\r\n backgroundColor: 'var(--custom-bg-color)',\r\n border: 'none',\r\n borderTop: '1px dashed var(--custom-border-color)',\r\n borderBottom: '1px dashed var(--custom-border-color)',\r\n '&:first-child': {\r\n borderLeft: '1px dashed var(--custom-border-color)',\r\n borderRadius: '6px 0 0 6px'\r\n },\r\n '&:last-child': {\r\n borderRight: '1px dashed var(--custom-border-color)',\r\n borderRadius: '0 6px 6px 0'\r\n }\r\n },\r\n '&:hover': {\r\n '--custom-border-color': theme.palette.divider,\r\n '--custom-bg-color': colors.grey[50],\r\n transform: 'translateY(-1px)',\r\n boxShadow: 'rgba(99, 99, 99, 0.1) 0px 2px 8px 0px',\r\n '.MuiDataGrid-cell': {\r\n borderTopStyle: 'solid',\r\n borderBottomStyle: 'solid',\r\n '&:first-child': {\r\n borderLeftStyle: 'solid'\r\n },\r\n '&:last-child': {\r\n borderRightStyle: 'solid'\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}))\r\n//#endregion\r\n"],"names":["EmptyModule","_jsx","Typography","variant","color","children","createViewModeModule","memo","ViewModeModule","props","_this","_classCallCheck","_callSuper","ElementComponent","configs","Element","_inherits","Component","_createClass","key","value","nextProps","_this$props$configs","this","currentElement","currentConfig","_objectWithoutProperties","_excluded","_nextProps$configs","nextElement","nextConfigs","_excluded2","checkConfigsDiff","JSON","stringify","data","_this$props","size","xs","sm","md","lg","Grid","_objectSpread","container","spacing","wrapProps","map","item","index","getElementId","toString","itemProps","elementWrapPropsGetter","elementWrapProps","createViewModeList","genarateColumns","_configs$columns","cols","columns","Object","keys","field","config","String","sortable","ViewModeList","_this2","_defineProperty","checkValueDiff","checkListConfigsDiff","_this$props$configs$c","_this$props$configs2","_this$props$configs3","_this$props$configs4","_this$props$slots","length","rows","DataGridCustom","hideFooter","disableColumnFilter","disableColumnMenu","getRowId","rowHeight","columnHeaderHeight","getRowSpacing","_ref","top","isFirstVisible","bottom","disableColumnSelector","slots","dataGridProps","styled","DataGrid","_ref2","theme","boxSizing","palette","background","paper","borderColor","display","alignItems","outline","backgroundColor","colors","grey","borderRadius","border","transition","borderTop","borderBottom","borderLeft","borderRight","divider","transform","boxShadow","borderTopStyle","borderBottomStyle","borderLeftStyle","borderRightStyle"],"mappings":"yaAMMA,EAAkB,WAAP,OACfC,EAACC,EAAU,CAACC,QAAQ,YAAYC,MAAM,gBAAeC,SAAA,uBAExC,WAQCC,IAyCd,OAAOC,aAtCL,SAAAC,EAAYC,GAA8B,IAAAC,EAEoB,OAFpBC,OAAAH,IACxCE,EAAAE,EAAAJ,KAAAA,GAAMC,KACDI,iBAAmBJ,EAAMK,QAAQC,SAAWf,EAAWU,CAC9D,CAAC,OAAAM,EAAAR,EAL0BS,GAK1B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version": "1.1.8",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",