dinocollab-core 2.2.57 → 2.2.59
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.
- package/dist/components/index.js +1 -1
- package/dist/filter-bar/index.js +1 -1
- package/dist/form/index.js +1 -1
- package/dist/src/components/confirm-button.js +1 -1
- package/dist/src/components/confirm-button.js.map +1 -1
- package/dist/src/components/copy-to-clipboard.js +1 -1
- package/dist/src/components/copy-to-clipboard.js.map +1 -1
- package/dist/src/components/image-with-fallback.js +1 -1
- package/dist/src/components/image-with-fallback.js.map +1 -1
- package/dist/src/data-surface/index.create.js +1 -1
- package/dist/src/data-surface/index.create.js.map +1 -1
- package/dist/src/data-surface/types.js.map +1 -1
- package/dist/src/data-surface/ui.units.js +1 -1
- package/dist/src/data-surface/ui.units.js.map +1 -1
- package/dist/src/data-surface/view-grid/index.js +1 -1
- package/dist/src/data-surface/view-grid/index.js.map +1 -1
- package/dist/src/data-surface/view-list/column-selector.js +1 -1
- package/dist/src/data-surface/view-list/column-selector.js.map +1 -1
- package/dist/src/data-surface/view-list/helpers.js +1 -1
- package/dist/src/data-surface/view-list/helpers.js.map +1 -1
- package/dist/src/data-surface/view-list/hooks.js +1 -1
- package/dist/src/data-surface/view-list/hooks.js.map +1 -1
- package/dist/src/data-surface/view-list/index.js +1 -1
- package/dist/src/data-surface/view-list/index.js.map +1 -1
- package/dist/src/data-surface/view-list/types.js.map +1 -1
- package/dist/src/filter-bar/filter-input.js +1 -1
- package/dist/src/filter-bar/filter-input.js.map +1 -1
- package/dist/src/filter-bar/filter-input.types.js.map +1 -1
- package/dist/src/filter-bar/filter-input.units.js +1 -1
- package/dist/src/filter-bar/filter-input.units.js.map +1 -1
- package/dist/src/filter-bar/filter-menu.helpers.js +1 -1
- package/dist/src/filter-bar/filter-menu.helpers.js.map +1 -1
- package/dist/src/filter-bar/filter-menu.js +1 -1
- package/dist/src/filter-bar/filter-menu.js.map +1 -1
- package/dist/src/filter-bar/filter-summary.js +1 -1
- package/dist/src/filter-bar/filter-summary.js.map +1 -1
- package/dist/src/filter-bar/form-field/create-form-field-boolean.js +1 -1
- package/dist/src/filter-bar/form-field/create-form-field-boolean.js.map +1 -1
- package/dist/src/filter-bar/form-field/create-form-field-number.js +1 -1
- package/dist/src/filter-bar/form-field/create-form-field-number.js.map +1 -1
- package/dist/src/filter-bar/form-field/create-form-field-select-with-api.js +1 -1
- package/dist/src/filter-bar/form-field/create-form-field-select-with-api.js.map +1 -1
- package/dist/src/filter-bar/form-field/create-form-field-select.fallback.js +1 -1
- package/dist/src/filter-bar/form-field/create-form-field-select.fallback.js.map +1 -1
- package/dist/src/filter-bar/form-field/create-form-field-select.js +1 -1
- package/dist/src/filter-bar/form-field/create-form-field-select.js.map +1 -1
- package/dist/src/filter-bar/form-field/create-form-field-string.js +1 -1
- package/dist/src/filter-bar/form-field/create-form-field-string.js.map +1 -1
- package/dist/src/filter-bar/index.create.js +1 -1
- package/dist/src/filter-bar/index.create.js.map +1 -1
- package/dist/src/filter-bar/index.dino.js +1 -1
- package/dist/src/filter-bar/index.dino.js.map +1 -1
- package/dist/src/filter-bar/types.js.map +1 -1
- package/dist/src/form/create.form-base.js +1 -1
- package/dist/src/form/create.form-base.js.map +1 -1
- package/dist/src/form/create.form-confirm.js +2 -0
- package/dist/src/form/create.form-confirm.js.map +1 -0
- package/dist/src/form/create.form-grid-layout.js +1 -1
- package/dist/src/form/create.form-grid-layout.js.map +1 -1
- package/dist/src/form/create.form-grid-layout.units.js +1 -1
- package/dist/src/form/create.form-grid-layout.units.js.map +1 -1
- package/dist/src/form/create.input.object.js +1 -1
- package/dist/src/form/create.input.object.js.map +1 -1
- package/dist/src/form/create.input.object.styled.js +1 -1
- package/dist/src/form/create.input.object.styled.js.map +1 -1
- package/dist/src/form/create.input.object.units.js +2 -0
- package/dist/src/form/create.input.object.units.js.map +1 -0
- package/dist/src/form/decorator.form.js +1 -1
- package/dist/src/form/decorator.form.js.map +1 -1
- package/dist/src/form/decorator.units.js +1 -1
- package/dist/src/form/decorator.units.js.map +1 -1
- package/dist/src/form/dino-form.js +1 -1
- package/dist/src/form/dino-form.js.map +1 -1
- package/dist/src/form/error-handler.js +1 -1
- package/dist/src/form/error-handler.js.map +1 -1
- package/dist/src/form/v2/create.date-picker.js +1 -1
- package/dist/src/form/v2/create.date-picker.js.map +1 -1
- package/dist/src/form/v2/create.input.js +1 -1
- package/dist/src/form/v2/create.input.js.map +1 -1
- package/dist/src/form/v2/create.select-simple.js +1 -1
- package/dist/src/form/v2/create.select-simple.js.map +1 -1
- package/dist/src/form/validator.js +1 -1
- package/dist/src/form/validator.js.map +1 -1
- package/dist/src/form/validator.units.js +2 -0
- package/dist/src/form/validator.units.js.map +1 -0
- package/dist/src/table/create.table.js +1 -1
- package/dist/src/table/create.table.js.map +1 -1
- package/dist/src/table/dino.js +1 -1
- package/dist/src/table/dino.js.map +1 -1
- package/dist/src/table/table.error-panel.js +2 -0
- package/dist/src/table/table.error-panel.js.map +1 -0
- package/dist/table/index.js +1 -1
- package/dist/types/components/confirm-button.d.ts +7 -0
- package/dist/types/components/copy-to-clipboard.d.ts +2 -1
- package/dist/types/data-surface/index.create.d.ts +21 -6
- package/dist/types/data-surface/types.d.ts +1 -1
- package/dist/types/data-surface/ui.units.d.ts +2 -2
- package/dist/types/data-surface/view-list/column-selector.d.ts +2 -2
- package/dist/types/data-surface/view-list/helpers.d.ts +9 -4
- package/dist/types/data-surface/view-list/types.d.ts +32 -14
- package/dist/types/filter-bar/filter-input.types.d.ts +2 -2
- package/dist/types/filter-bar/filter-input.units.d.ts +6 -2
- package/dist/types/filter-bar/filter-menu.types.d.ts +2 -2
- package/dist/types/filter-bar/filter-summary.types.d.ts +2 -2
- package/dist/types/filter-bar/form-field/create-form-field-boolean.d.ts +1 -1
- package/dist/types/filter-bar/form-field/create-form-field-number.d.ts +1 -1
- package/dist/types/filter-bar/form-field/create-form-field-select-with-api.d.ts +1 -1
- package/dist/types/filter-bar/form-field/create-form-field-select.d.ts +1 -1
- package/dist/types/filter-bar/form-field/create-form-field-string.d.ts +1 -1
- package/dist/types/filter-bar/index.dino.d.ts +6 -6
- package/dist/types/filter-bar/types.d.ts +4 -2
- package/dist/types/form/create.form-confirm.d.ts +33 -0
- package/dist/types/form/create.form-grid-layout.d.ts +15 -5
- package/dist/types/form/create.form-grid-layout.units.d.ts +15 -1
- package/dist/types/form/create.input.object.d.ts +15 -57
- package/dist/types/form/create.input.object.styled.d.ts +5 -0
- package/dist/types/form/create.input.object.units.d.ts +88 -0
- package/dist/types/form/decorator.units.d.ts +3 -1
- package/dist/types/form/dino-form.d.ts +2 -2
- package/dist/types/form/error-handler.d.ts +34 -4
- package/dist/types/form/index.d.ts +4 -1
- package/dist/types/form/v2/create.date-picker.d.ts +3 -3
- package/dist/types/form/v2/create.input.d.ts +42 -3
- package/dist/types/form/v2/create.select-simple.d.ts +1 -1
- package/dist/types/form/validator.d.ts +3 -52
- package/dist/types/form/validator.units.d.ts +65 -0
- package/dist/types/table/create.table.d.ts +7 -2
- package/dist/types/table/dino.d.ts +1 -0
- package/dist/types/table/index.d.ts +1 -0
- package/dist/types/table/table.error-panel.d.ts +7 -0
- package/dist/types/table/types.d.ts +2 -0
- package/package.json +1 -1
- package/dist/src/form/create.form-comfirm.js +0 -2
- package/dist/src/form/create.form-comfirm.js.map +0 -1
- package/dist/types/form/create.form-comfirm.d.ts +0 -20
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{defineProperty as e}from"../../_virtual/_rollupPluginBabelHelpers.js";var i,r;!function(e){e.Required="Required",e.Regex="Regex",e.RequiredValue="RequiredValue",e.Array="Array",e.Number="Number",e.Email="Email",e.PhoneNumber="PhoneNumber",e.Url="Url",e.File="File",e.FileImage="FileImage",e.FileRequired="FileRequired",e.Custom="Custom"}(r||(r={}));var l=(e(e(e(e(e(e(e(e(e(e(i={},r.Required,"The {0} is required"),r.Regex,"The {0} is not match {1}"),r.RequiredValue,"The {0} is not equal {1}"),r.Array,"The {0} is not valid"),r.Number,"{0} must be a number"),r.Email,"The {0} is not valid"),r.PhoneNumber,"The {0} is not valid"),r.Url,"The {0} is not valid"),r.File,"The {0} is not valid"),r.FileImage,"The {0} is not valid"),e(e(i,r.FileRequired,"The {0} is required"),r.Custom,"The {0} is not valid (Custom)"));export{r as EValidateRule,l as defaultMessage};
|
|
2
|
+
//# sourceMappingURL=validator.units.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.units.js","sources":["../../../src/form/validator.units.ts"],"sourcesContent":["export enum EValidateRule {\n Required = 'Required',\n Regex = 'Regex',\n RequiredValue = 'RequiredValue',\n Array = 'Array',\n Number = 'Number',\n Email = 'Email',\n PhoneNumber = 'PhoneNumber',\n Url = 'Url',\n File = 'File',\n FileImage = 'FileImage',\n FileRequired = 'FileRequired',\n Custom = 'Custom'\n}\n\ntype IDefaultMessage = { [key in EValidateRule]: string }\n\nexport const defaultMessage: IDefaultMessage = {\n [EValidateRule.Required]: 'The {0} is required',\n [EValidateRule.Regex]: 'The {0} is not match {1}',\n [EValidateRule.RequiredValue]: 'The {0} is not equal {1}',\n [EValidateRule.Array]: 'The {0} is not valid',\n [EValidateRule.Number]: '{0} must be a number',\n [EValidateRule.Email]: 'The {0} is not valid',\n [EValidateRule.PhoneNumber]: 'The {0} is not valid',\n [EValidateRule.Url]: 'The {0} is not valid',\n [EValidateRule.File]: 'The {0} is not valid',\n [EValidateRule.FileImage]: 'The {0} is not valid',\n [EValidateRule.FileRequired]: 'The {0} is required',\n [EValidateRule.Custom]: 'The {0} is not valid (Custom)'\n}\n\nexport interface IFileRuleOptions {\n /** Max size of single file in bytes */\n maxSize?: number\n /** If true, maxSize applies to the total combined size of all files instead of each individual file */\n sumSize?: boolean\n /** Exact number of files required */\n count?: number\n /** Max number of files allowed */\n maxCount?: number\n /** Min number of files required */\n minCount?: number\n}\n\nexport interface IFileImageRuleOptions extends IFileRuleOptions {\n /** Max image width in pixels */\n maxWidth?: number\n /** Max image height in pixels */\n maxHeight?: number\n /** Min image width in pixels */\n minWidth?: number\n /** Min image height in pixels */\n minHeight?: number\n}\n\nexport interface IArrayRuleOptions {\n /** Exact number of items required in the array */\n count?: number\n /** Max number of items allowed in the array */\n maxCount?: number\n /** Min number of items required in the array */\n minCount?: number\n}\n\nexport interface INumberRuleOptions {\n /** Max number of value */\n max?: number\n /** Min number of value */\n min?: number\n}\n\nexport interface IRuleOptions {\n /** Only apply for file rule */\n file?: IFileRuleOptions\n /** Only apply for file image rule */\n image?: IFileImageRuleOptions\n /** Only apply for array rule */\n array?: IArrayRuleOptions\n /** Only apply for number rule */\n number?: INumberRuleOptions\n}\n"],"names":["EValidateRule","defaultMessage","_defineProperty","_defaultMessage","Required","Regex","RequiredValue","Array","Number","Email","PhoneNumber","Url","File","FileImage","FileRequired","Custom"],"mappings":"mFAAYA,GAAZ,SAAYA,GACVA,EAAA,SAAA,WACAA,EAAA,MAAA,QACAA,EAAA,cAAA,gBACAA,EAAA,MAAA,QACAA,EAAA,OAAA,SACAA,EAAA,MAAA,QACAA,EAAA,YAAA,cACAA,EAAA,IAAA,MACAA,EAAA,KAAA,OACAA,EAAA,UAAA,YACAA,EAAA,aAAA,eACAA,EAAA,OAAA,QACD,CAbD,CAAYA,IAAAA,EAaX,CAAA,IAIM,IAAMC,GAAcC,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAAC,KACxBH,EAAcI,SAAW,uBACzBJ,EAAcK,MAAQ,4BACtBL,EAAcM,cAAgB,4BAC9BN,EAAcO,MAAQ,wBACtBP,EAAcQ,OAAS,wBACvBR,EAAcS,MAAQ,wBACtBT,EAAcU,YAAc,wBAC5BV,EAAcW,IAAM,wBACpBX,EAAcY,KAAO,wBACrBZ,EAAca,UAAY,wBAAsBX,EAAAA,EAAAC,EAChDH,EAAcc,aAAe,uBAC7Bd,EAAce,OAAS"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{inherits as
|
|
1
|
+
import{inherits as o,createClass as e,objectSpread2 as r,classCallCheck as i,callSuper as l,defineProperty as n,toConsumableArray as a}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as t}from"react/jsx-runtime";import{Fragment as s,Component as d}from"react";import{DataGrid as u,GridNoRowsOverlay as p}from"@mui/x-data-grid";import{mergeObjects as g}from"../utils/helpers.js";import"../utils/dayjs-config.js";import"../utils/query-param.js";import{TableBaseContext as m}from"./context.js";import{customFilterOperators as c}from"./custom.filter-operators.js";import v from"./helpers.js";import f from"./toolbar-pannel.js";import{TableErrorPanel as h}from"./table.error-panel.js";import{dinoTableClasses as y,TableStyled as b}from"./styled.js";import{GlobalModal as C,mapGlobalModalContext as P}from"../api-context/global-modal.js";function w(w){return function(){function S(o){var e;return i(this,S),e=l(this,S,[o]),n(e,"setTableQueryParams",function(o){e.tableQueryParams=g({},e.tableQueryParams,o)}),n(e,"renderWrapContext",function(o){var e=w.disableGlobalModalProvider?s:C;return t(e,{children:P(function(e){return t(m.Provider,{value:{showModal:e.show,closeModal:e.close},children:o})})})}),n(e,"getDataGridProps",function(){var o,i,l,n,a=v.mapInitialState(e.props.query,{columns:{columnVisibilityModel:w.columnVisibilityModel}}),s=Boolean(e.mergeConfig.error),d=function(){var o,r,i,l,n;if(s){var a,d,u,g=null!==(a=null!==(d=null===(u=e.props.slots)||void 0===u?void 0:u.errorPanel)&&void 0!==d?d:w.errorPanel)&&void 0!==a?a:h;return t(g,{error:e.mergeConfig.error,onRetry:e.mergeConfig.onRetry})}var m=null!==(o=null!==(r=null!==(i=null===(l=e.props.slots)||void 0===l?void 0:l.noRowsOverlay)&&void 0!==i?i:w.noRowsOverlay)&&void 0!==r?r:null===(n=e.mergeConfig.dataGridProps)||void 0===n||null===(n=n.slots)||void 0===n?void 0:n.noRowsOverlay)&&void 0!==o?o:p;return t(m,{})},u={getRowId:w.getRowId,initialState:a,columns:e.columns,rows:null!==(o=null===(i=e.props.data)||void 0===i?void 0:i.items)&&void 0!==o?o:[],checkboxSelection:!0,pagination:!0,density:null!==(l=null===(n=e.props.slots)||void 0===n?void 0:n.density)&&void 0!==l?l:"standard",filterDebounceMs:800,sx:{border:0},slots:{toolbar:e.mergeConfig.toolbar,noRowsOverlay:d},rowSelectionModel:e.rowSelecteds,onRowSelectionModelChange:e.handleRowSelectionChange};if("server"===w.featureMode){var m,c,f={filterMode:"server",sortingMode:"server",paginationMode:"server",onPaginationModelChange:e.onPaginationModelChange,onFilterModelChange:e.onFilterModelChange,onSortModelChange:e.onSortModelChange,rowCount:null!==(m=null===(c=e.props.data)||void 0===c?void 0:c.rowTotal)&&void 0!==m?m:0,paginationModel:e.tableQueryParams.pagination,filterModel:e.tableQueryParams.filter,sortModel:v.mapSortModel(e.tableQueryParams.sort),loading:e.mergeConfig.loading};Object.assign(u,f)}var y=g(u,e.mergeConfig.dataGridProps);return y.slots=r(r({},y.slots),{},{noRowsOverlay:d}),y}),n(e,"initialColumns",function(){var o,i,l=e.mergeConfig,n=l.ActionRow,s=l.disableActionRow,d=[];return n&&!0!==s&&d.push(r({field:"Actions",minWidth:100,headerAlign:"right",align:"right",filterable:!1,sortable:!1,disableExport:!0,renderCell:function(o){return t(n,{value:o.row})}},w.actionRow)),o=d,i=Object.keys(w.columns).map(function(o){var e=r({field:o},w.columns[o]);return e.filterOperators=w.filterOperators?w.filterOperators(e):c(e),e}),o&&o.length>0&&i.push.apply(i,a(o)),i}),n(e,"onPaginationModelChange",function(o,r){e.mergeConfig.loading||(e.setTableQueryParams({pagination:o,detail:"pagination"}),e.handleChange())}),n(e,"onFilterModelChange",function(o,r){var i;if(!e.mergeConfig.loading){var l=e.tableQueryParams.pagination;e.setTableQueryParams({filter:o,pagination:{page:0,pageSize:null!==(i=null==l?void 0:l.pageSize)&&void 0!==i?i:25},detail:v.detectSearchType(o)}),e.handleChange()}}),n(e,"onSortModelChange",function(o,r){if(!e.mergeConfig.loading){var i,l,n,a,t,s=o,d=e.tableQueryParams.sort;if(null!=d&&d.length&&!s.length)if((null==d||null===(i=d[0])||void 0===i?void 0:i.field)===(null===(l=e.defaultTableQueryParams.sort)||void 0===l||null===(l=l[0])||void 0===l?void 0:l.field))s=[{field:null===(n=d[0])||void 0===n?void 0:n.field,sort:"desc"===(null===(a=d[0])||void 0===a?void 0:a.sort)?"asc":"desc"}];else s=null!==(t=e.defaultTableQueryParams.sort)&&void 0!==t?t:[];e.setTableQueryParams({sort:s,detail:"sort"}),e.handleChange()}}),n(e,"handleChange",function(){e.changeTimeout&&clearTimeout(e.changeTimeout),e.changeTimeout=setTimeout(function(){e.props.onChange&&e.props.onChange(e.tableQueryParams)},300)}),n(e,"handleRowSelectionChange",function(o,r){e.mergeConfig.maxSelcion&&o.length>e.mergeConfig.maxSelcion?e.rowSelecteds=o.slice(0,e.mergeConfig.maxSelcion):e.rowSelecteds=o,e.props.onRowSelectionChange&&e.props.onRowSelectionChange(e.rowSelecteds,r),e.forceUpdate()}),e.columns=e.initialColumns(),e.tableQueryParams=r({},o.query),e.defaultTableQueryParams=e.tableQueryParams,e.rowSelecteds=[],e}return o(S,d),e(S,[{key:"mergeConfig",get:function(){var o,e,i,l,n,a,s,d,u,p,m,c,v=g({},null==w?void 0:w.toolbarProps,null===(o=this.props.slots)||void 0===o?void 0:o.toolbarProps);return{toolbar:null!==(e=null===(i=this.props.slots)||void 0===i?void 0:i.toolbar)&&void 0!==e?e:function(){return t(f,r({},v))},ActionRow:null===(l=this.props.slots)||void 0===l?void 0:l.actionRow,disableActionRow:w.disableActionRow,columnVisibilityModel:w.columnVisibilityModel,maxSelcion:null!==(n=null===(a=this.props.slots)||void 0===a?void 0:a.maxSelection)&&void 0!==n?n:w.maxSelection,dataGridProps:g({},w.dataGridProps,null===(s=this.props.slots)||void 0===s?void 0:s.dataGridProps),wrapProps:g({},w.wrapProps,null===(d=this.props.slots)||void 0===d?void 0:d.wrapProps),loading:null!==(u=void 0!==this.props.loading?this.props.loading:null===(p=this.tableQueryParams)||void 0===p?void 0:p.loading)&&void 0!==u&&u,error:null!==(m=void 0!==this.props.error?this.props.error:null===(c=this.tableQueryParams)||void 0===c?void 0:c.error)&&void 0!==m&&m,onRetry:this.props.onRetry}}},{key:"componentWillUnmount",value:function(){this.changeTimeout&&clearTimeout(this.changeTimeout)}},{key:"shouldComponentUpdate",value:function(o){var e;return"server"!==w.featureMode||(v.equalTableQueryParams(o.query,this.props.query)?JSON.stringify(o.data)!==JSON.stringify(this.props.data)||o.loading!==this.props.loading||o.error!==this.props.error||o.onRetry!==this.props.onRetry:(this.setTableQueryParams(null!==(e=o.query)&&void 0!==e?e:{}),!0))}},{key:"render",value:function(){var o,e=[y.root,null===(o=this.mergeConfig.wrapProps)||void 0===o?void 0:o.className];return this.renderWrapContext(t(b,r(r({},this.mergeConfig.wrapProps),{},{className:e.filter(function(o){return!!o}).join(" "),children:t(u,r({loading:this.props.loading},this.getDataGridProps()))})))}}])}()}export{w as CreateTable,w as default};
|
|
2
2
|
//# sourceMappingURL=create.table.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.table.js","sources":["../../../src/table/create.table.tsx"],"sourcesContent":["import { Component, Fragment } from 'react'\r\nimport { Box, BoxProps, styled } from '@mui/material'\r\nimport { DataGrid, DataGridProps, GridColDef, GridFeatureMode, GridFilterOperator } from '@mui/x-data-grid'\r\nimport { GridSortModel, GridValidRowModel, GridRowIdGetter, GridRowSelectionModel } from '@mui/x-data-grid'\r\nimport { GridCallbackDetails, GridColumnVisibilityModel, GridDensity, GridFilterModel, GridPaginationModel } from '@mui/x-data-grid'\r\nimport type { ComponentType, ReactNode } from 'react'\r\nimport { mergeObjects } from '../utils'\r\nimport { TableBaseContext } from './context'\r\nimport { IActionRowProps } from './create.action-row'\r\nimport { customFilterOperators } from './custom.filter-operators'\r\nimport { GlobalModal, mapGlobalModalContext } from '../api-context'\r\nimport { ICustomGridColDef, ICustomGridFilterModel, ICustomGridSortModel, ITableData, ITableQueryParams } from './types'\r\nimport TableHelper from './helpers'\r\nimport ToolbarPannel, { IToolbarPannelProps } from './toolbar-pannel'\r\nimport { dinoTableClasses, TableStyled } from './styled'\r\n\r\nexport interface ITableSlots<T> {\r\n maxSelection?: number\r\n density?: GridDensity\r\n toolbar?: ComponentType<IToolbarPannelProps>\r\n actionRow?: ComponentType<IActionRowProps<T>>\r\n toolbarProps?: IToolbarPannelProps\r\n dataGridProps?: DataGridProps\r\n wrapProps?: BoxProps\r\n}\r\n\r\nexport type ITableParamsSlots<T> = Pick<ITableSlots<T>, 'maxSelection' | 'toolbarProps' | 'dataGridProps' | 'wrapProps'>\r\n\r\nexport interface ITableProps<T> {\r\n data?: ITableData<T>\r\n query?: ITableQueryParams<T>\r\n loading?: boolean\r\n onChange?: (query: ITableQueryParams<T>) => void\r\n onRowSelectionChange?: DataGridProps['onRowSelectionModelChange']\r\n slots?: ITableSlots<T>\r\n}\r\n\r\nexport interface ITableParams<T extends GridValidRowModel> extends ITableParamsSlots<T> {\r\n featureMode?: GridFeatureMode\r\n getRowId: GridRowIdGetter<T>\r\n columns: ICustomGridColDef<T>\r\n filterOperators?: (config: GridColDef) => GridFilterOperator[]\r\n columnVisibilityModel?: Partial<Record<keyof T, boolean>>\r\n actionRow?: Omit<GridColDef, 'field'>\r\n disableActionRow?: boolean\r\n disableGlobalModalProvider?: boolean\r\n}\r\n\r\nexport function CreateTable<T extends GridValidRowModel>(params: ITableParams<T>): ComponentType<ITableProps<T>> {\r\n const generateColumns = (extendColDefs?: GridColDef[]) => {\r\n const columns = Object.keys(params.columns).map<GridColDef>((key) => {\r\n const obj = { field: key, ...params.columns[key] }\r\n obj.filterOperators = params.filterOperators ? params.filterOperators(obj) : customFilterOperators(obj)\r\n return obj\r\n })\r\n\r\n if (!!extendColDefs && extendColDefs.length > 0) columns.push(...extendColDefs)\r\n return columns\r\n }\r\n\r\n class Table extends Component<ITableProps<T>> {\r\n private tableQueryParams: ITableQueryParams<T>\r\n // private tableQueryParamsCache: ITableQueryParams<T> = {}\r\n private defaultTableQueryParams: ITableQueryParams<T>\r\n private columns: GridColDef<T>[]\r\n private rowSelecteds: GridRowSelectionModel\r\n private changeTimeout?: ReturnType<typeof setTimeout>\r\n constructor(props: ITableProps<T>) {\r\n super(props)\r\n this.columns = this.initialColumns()\r\n this.tableQueryParams = { ...props.query }\r\n this.defaultTableQueryParams = this.tableQueryParams\r\n this.rowSelecteds = []\r\n }\r\n\r\n get mergeConfig() {\r\n const toolbarPannelProps = mergeObjects({}, params?.toolbarProps, this.props.slots?.toolbarProps)\r\n return {\r\n toolbar: this.props.slots?.toolbar ?? (() => <ToolbarPannel {...toolbarPannelProps} />),\r\n ActionRow: this.props.slots?.actionRow,\r\n disableActionRow: params.disableActionRow,\r\n columnVisibilityModel: params.columnVisibilityModel,\r\n maxSelcion: this.props.slots?.maxSelection ?? params.maxSelection,\r\n dataGridProps: mergeObjects({}, params.dataGridProps, this.props.slots?.dataGridProps),\r\n wrapProps: mergeObjects({}, params.wrapProps, this.props.slots?.wrapProps),\r\n loading: (this.props.loading !== undefined ? this.props.loading : this.tableQueryParams?.loading) ?? false\r\n }\r\n }\r\n\r\n setTableQueryParams = (value: Partial<ITableQueryParams<T>>) => {\r\n this.tableQueryParams = mergeObjects({}, this.tableQueryParams, value)\r\n }\r\n\r\n componentWillUnmount() {\r\n if (this.changeTimeout) {\r\n clearTimeout(this.changeTimeout)\r\n }\r\n }\r\n\r\n shouldComponentUpdate(nextProps: Readonly<ITableProps<T>>): boolean {\r\n if (params.featureMode === 'server') {\r\n // Check if query changed\r\n if (!TableHelper.equalTableQueryParams(nextProps.query, this.props.query)) {\r\n this.setTableQueryParams(nextProps.query ?? {})\r\n return true\r\n }\r\n // Check if data or loading changed\r\n if (JSON.stringify(nextProps.data) !== JSON.stringify(this.props.data) || nextProps.loading !== this.props.loading) {\r\n return true\r\n }\r\n return false\r\n } else {\r\n return true\r\n }\r\n }\r\n\r\n render() {\r\n const rootClasses = [dinoTableClasses.root, this.mergeConfig.wrapProps?.className]\r\n return this.renderWrapContext(\r\n <TableStyled {...this.mergeConfig.wrapProps} className={rootClasses.filter((x) => !!x).join(' ')}>\r\n <DataGrid loading={this.props.loading} {...this.getDataGridProps()} />\r\n </TableStyled>\r\n )\r\n }\r\n\r\n renderWrapContext = (children: ReactNode) => {\r\n const WrapComponent = params.disableGlobalModalProvider ? Fragment : GlobalModal\r\n return (\r\n <WrapComponent>\r\n {mapGlobalModalContext((context) => (\r\n <TableBaseContext.Provider value={{ showModal: context.show, closeModal: context.close }}>{children}</TableBaseContext.Provider>\r\n ))}\r\n </WrapComponent>\r\n )\r\n }\r\n\r\n getDataGridProps = (): DataGridProps<T> => {\r\n const initialState = TableHelper.mapInitialState(this.props.query, {\r\n columns: { columnVisibilityModel: params.columnVisibilityModel as GridColumnVisibilityModel }\r\n })\r\n const obj: DataGridProps<T> = {\r\n getRowId: params.getRowId,\r\n initialState,\r\n columns: this.columns,\r\n rows: this.props.data?.items ?? [],\r\n checkboxSelection: true,\r\n pagination: true,\r\n density: this.props.slots?.density ?? 'standard',\r\n filterDebounceMs: 800,\r\n sx: { border: 0 },\r\n slots: { toolbar: this.mergeConfig.toolbar },\r\n rowSelectionModel: this.rowSelecteds,\r\n onRowSelectionModelChange: this.handleRowSelectionChange\r\n }\r\n if (params.featureMode === 'server') {\r\n const objServer: Partial<DataGridProps<T>> = {\r\n filterMode: 'server',\r\n sortingMode: 'server',\r\n paginationMode: 'server',\r\n onPaginationModelChange: this.onPaginationModelChange,\r\n onFilterModelChange: this.onFilterModelChange,\r\n onSortModelChange: this.onSortModelChange,\r\n rowCount: this.props.data?.rowTotal ?? 0,\r\n paginationModel: this.tableQueryParams.pagination,\r\n filterModel: this.tableQueryParams.filter as GridFilterModel,\r\n sortModel: TableHelper.mapSortModel(this.tableQueryParams.sort),\r\n loading: this.mergeConfig.loading\r\n }\r\n Object.assign(obj, objServer)\r\n }\r\n return mergeObjects(obj, this.mergeConfig.dataGridProps)\r\n }\r\n\r\n initialColumns = (): GridColDef<T>[] => {\r\n const { ActionRow, disableActionRow } = this.mergeConfig\r\n const list: GridColDef<T>[] = []\r\n if (!!ActionRow && disableActionRow !== true) {\r\n list.push({\r\n field: 'Actions',\r\n minWidth: 100,\r\n headerAlign: 'right',\r\n align: 'right',\r\n filterable: false,\r\n sortable: false,\r\n disableExport: true,\r\n renderCell: (value) => <ActionRow value={value.row} />,\r\n ...params.actionRow\r\n })\r\n }\r\n return generateColumns(list)\r\n }\r\n\r\n onPaginationModelChange = (model: GridPaginationModel, details: GridCallbackDetails<'pagination'>) => {\r\n if (this.mergeConfig.loading) return\r\n this.setTableQueryParams({ pagination: model, detail: 'pagination' })\r\n this.handleChange()\r\n }\r\n\r\n onFilterModelChange = (model: GridFilterModel, details: GridCallbackDetails<'filter'>) => {\r\n if (this.mergeConfig.loading) return\r\n const { pagination } = this.tableQueryParams\r\n this.setTableQueryParams({\r\n filter: model as ICustomGridFilterModel<T>,\r\n pagination: { page: 0, pageSize: pagination?.pageSize ?? 25 },\r\n detail: TableHelper.detectSearchType(model)\r\n })\r\n this.handleChange()\r\n }\r\n\r\n onSortModelChange = (model: GridSortModel, details: GridCallbackDetails<any>) => {\r\n if (this.mergeConfig.loading) return\r\n let sortValue = model as ICustomGridSortModel<T>\r\n const { sort } = this.tableQueryParams\r\n if (!!sort?.length && !sortValue.length) {\r\n if (sort?.[0]?.field === this.defaultTableQueryParams.sort?.[0]?.field) {\r\n sortValue = [{ field: sort[0]?.field, sort: sort[0]?.sort === 'desc' ? 'asc' : 'desc' }]\r\n } else {\r\n sortValue = this.defaultTableQueryParams.sort ?? []\r\n }\r\n }\r\n this.setTableQueryParams({ sort: sortValue, detail: 'sort' })\r\n this.handleChange()\r\n }\r\n\r\n handleChange = () => {\r\n if (this.changeTimeout) clearTimeout(this.changeTimeout)\r\n this.changeTimeout = setTimeout(() => {\r\n this.props.onChange && this.props.onChange(this.tableQueryParams)\r\n }, 300)\r\n }\r\n\r\n handleRowSelectionChange = (value: GridRowSelectionModel, details: GridCallbackDetails) => {\r\n if (this.mergeConfig.maxSelcion && value.length > this.mergeConfig.maxSelcion) {\r\n this.rowSelecteds = value.slice(0, this.mergeConfig.maxSelcion)\r\n } else {\r\n this.rowSelecteds = value\r\n }\r\n this.props.onRowSelectionChange && this.props.onRowSelectionChange(this.rowSelecteds, details)\r\n this.forceUpdate()\r\n }\r\n }\r\n\r\n return Table\r\n}\r\n\r\nexport default CreateTable\r\n"],"names":["CreateTable","params","Table","props","_this","_classCallCheck","_callSuper","_defineProperty","value","tableQueryParams","mergeObjects","children","WrapComponent","disableGlobalModalProvider","Fragment","GlobalModal","_jsx","mapGlobalModalContext","context","TableBaseContext","Provider","showModal","show","closeModal","close","_this$props$data$item","_this$props$data","_this$props$slots$den","_this$props$slots","initialState","TableHelper","mapInitialState","query","columns","columnVisibilityModel","obj","getRowId","rows","data","items","checkboxSelection","pagination","density","slots","filterDebounceMs","sx","border","toolbar","mergeConfig","rowSelectionModel","rowSelecteds","onRowSelectionModelChange","handleRowSelectionChange","featureMode","_this$props$data$rowT","_this$props$data2","objServer","filterMode","sortingMode","paginationMode","onPaginationModelChange","onFilterModelChange","onSortModelChange","rowCount","rowTotal","paginationModel","filterModel","filter","sortModel","mapSortModel","sort","loading","Object","assign","dataGridProps","extendColDefs","_this$mergeConfig","ActionRow","disableActionRow","list","push","_objectSpread","field","minWidth","headerAlign","align","filterable","sortable","disableExport","renderCell","row","actionRow","keys","map","key","filterOperators","customFilterOperators","length","apply","_toConsumableArray","model","details","setTableQueryParams","detail","handleChange","_pagination$pageSize","page","pageSize","detectSearchType","_sort$","_this$defaultTableQue","_sort$2","_sort$3","_this$defaultTableQue2","sortValue","defaultTableQueryParams","changeTimeout","clearTimeout","setTimeout","onChange","maxSelcion","slice","onRowSelectionChange","forceUpdate","initialColumns","_inherits","Component","_createClass","get","_this$props$slots2","_this$props$slots$too","_this$props$slots3","_this$props$slots4","_this$props$slots$max","_this$props$slots5","_this$props$slots6","_this$props$slots7","_ref","_this$tableQueryParam","toolbarPannelProps","toolbarProps","this","ToolbarPannel","maxSelection","wrapProps","undefined","nextProps","_nextProps$query","equalTableQueryParams","JSON","stringify","_this$mergeConfig$wra","rootClasses","dinoTableClasses","root","className","renderWrapContext","TableStyled","x","join","DataGrid","getDataGridProps"],"mappings":"6vBAgDM,SAAUA,EAAyCC,GAkMvD,kBA/KE,SAAAC,EAAYC,GAAqB,IAAAC,EAKT,OALSC,OAAAH,GAC/BE,EAAAE,EAAAJ,KAAAA,GAAMC,IAAMI,EAAAH,EAqBQ,sBAAA,SAACI,GACrBJ,EAAKK,iBAAmBC,EAAa,CAAE,EAAEN,EAAKK,iBAAkBD,KACjED,EAAAH,EAkCmB,oBAAA,SAACO,GACnB,IAAMC,EAAgBX,EAAOY,2BAA6BC,EAAWC,EACrE,OACEC,EAACJ,EACE,CAAAD,SAAAM,EAAsB,SAACC,GAAO,OAC7BF,EAACG,EAAiBC,UAASZ,MAAO,CAAEa,UAAWH,EAAQI,KAAMC,WAAYL,EAAQM,gBAAUb,GAC5F,OAGNJ,EAAAH,EAAA,mBAEkB,WAAuB,IAAAqB,EAAAC,EAAAC,EAAAC,EAClCC,EAAeC,EAAYC,gBAAgB3B,EAAKD,MAAM6B,MAAO,CACjEC,QAAS,CAAEC,sBAAuBjC,EAAOiC,yBAErCC,EAAwB,CAC5BC,SAAUnC,EAAOmC,SACjBP,aAAAA,EACAI,QAAS7B,EAAK6B,QACdI,aAAIZ,UAAAC,EAAEtB,EAAKD,MAAMmC,YAAI,IAAAZ,OAAA,EAAfA,EAAiBa,aAAK,IAAAd,EAAAA,EAAI,GAChCe,mBAAmB,EACnBC,YAAY,EACZC,gBAAOf,UAAAC,EAAExB,EAAKD,MAAMwC,aAAK,IAAAf,OAAA,EAAhBA,EAAkBc,eAAO,IAAAf,EAAAA,EAAI,WACtCiB,iBAAkB,IAClBC,GAAI,CAAEC,OAAQ,GACdH,MAAO,CAAEI,QAAS3C,EAAK4C,YAAYD,SACnCE,kBAAmB7C,EAAK8C,aACx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AAK7F,YAAYgG,qBAASO,SAA1BA,EAA4BI,WACxE,OAAOd,KAAKe,kBACV5I,EAAC6I,EAAW5E,EAAAA,EAAK,CAAA,EAAA4D,KAAK7F,YAAYgG,WAAS,CAAA,EAAA,CAAEW,UAAWH,EAAYrF,OAAO,SAAC2F,GAAC,QAAOA,CAAC,GAAEC,KAAK,cAC1F/I,EAACgJ,EAAQ/E,EAAA,CAACV,QAASsE,KAAK1I,MAAMoE,SAAasE,KAAKoB,wBAGtD,IAAC,GAwHL"}
|
|
1
|
+
{"version":3,"file":"create.table.js","sources":["../../../src/table/create.table.tsx"],"sourcesContent":["import { Component, Fragment } from 'react'\r\nimport { Box, BoxProps, styled } from '@mui/material'\r\nimport { DataGrid, DataGridProps, GridColDef, GridFeatureMode, GridFilterOperator, GridNoRowsOverlay } from '@mui/x-data-grid'\r\nimport { GridSortModel, GridValidRowModel, GridRowIdGetter, GridRowSelectionModel } from '@mui/x-data-grid'\r\nimport { GridCallbackDetails, GridColumnVisibilityModel, GridDensity, GridFilterModel, GridPaginationModel } from '@mui/x-data-grid'\r\nimport type { ComponentType, ReactNode } from 'react'\r\nimport { mergeObjects } from '../utils'\r\nimport { TableBaseContext } from './context'\r\nimport { IActionRowProps } from './create.action-row'\r\nimport { customFilterOperators } from './custom.filter-operators'\r\nimport { GlobalModal, mapGlobalModalContext } from '../api-context'\r\nimport { ICustomGridColDef, ICustomGridFilterModel, ICustomGridSortModel, ITableData, ITableQueryParams } from './types'\r\nimport TableHelper from './helpers'\r\nimport ToolbarPannel, { IToolbarPannelProps } from './toolbar-pannel'\r\nimport TableErrorPanel, { ITableErrorPanelProps } from './table.error-panel'\r\nimport { dinoTableClasses, TableStyled } from './styled'\r\n\r\nexport interface ITableSlots<T> {\r\n maxSelection?: number\r\n density?: GridDensity\r\n toolbar?: ComponentType<IToolbarPannelProps>\r\n actionRow?: ComponentType<IActionRowProps<T>>\r\n toolbarProps?: IToolbarPannelProps\r\n dataGridProps?: DataGridProps\r\n wrapProps?: BoxProps\r\n errorPanel?: ComponentType<ITableErrorPanelProps>\r\n noRowsOverlay?: ComponentType<any>\r\n}\r\n\r\nexport type ITableParamsSlots<T> = Pick<\r\n ITableSlots<T>,\r\n 'maxSelection' | 'toolbarProps' | 'dataGridProps' | 'wrapProps' | 'errorPanel' | 'noRowsOverlay'\r\n>\r\n\r\nexport interface ITableProps<T> {\r\n data?: ITableData<T>\r\n query?: ITableQueryParams<T>\r\n loading?: boolean\r\n error?: boolean | string | Error | ReactNode\r\n onRetry?: () => void\r\n onChange?: (query: ITableQueryParams<T>) => void\r\n onRowSelectionChange?: DataGridProps['onRowSelectionModelChange']\r\n slots?: ITableSlots<T>\r\n}\r\n\r\nexport interface ITableParams<T extends GridValidRowModel> extends ITableParamsSlots<T> {\r\n featureMode?: GridFeatureMode\r\n getRowId: GridRowIdGetter<T>\r\n columns: ICustomGridColDef<T>\r\n filterOperators?: (config: GridColDef) => GridFilterOperator[]\r\n columnVisibilityModel?: Partial<Record<keyof T, boolean>>\r\n actionRow?: Omit<GridColDef, 'field'>\r\n disableActionRow?: boolean\r\n disableGlobalModalProvider?: boolean\r\n}\r\n\r\nexport function CreateTable<T extends GridValidRowModel>(params: ITableParams<T>): ComponentType<ITableProps<T>> {\r\n const generateColumns = (extendColDefs?: GridColDef[]) => {\r\n const columns = Object.keys(params.columns).map<GridColDef>((key) => {\r\n const obj = { field: key, ...params.columns[key] }\r\n obj.filterOperators = params.filterOperators ? params.filterOperators(obj) : customFilterOperators(obj)\r\n return obj\r\n })\r\n\r\n if (!!extendColDefs && extendColDefs.length > 0) columns.push(...extendColDefs)\r\n return columns\r\n }\r\n\r\n class Table extends Component<ITableProps<T>> {\r\n private tableQueryParams: ITableQueryParams<T>\r\n // private tableQueryParamsCache: ITableQueryParams<T> = {}\r\n private defaultTableQueryParams: ITableQueryParams<T>\r\n private columns: GridColDef<T>[]\r\n private rowSelecteds: GridRowSelectionModel\r\n private changeTimeout?: ReturnType<typeof setTimeout>\r\n constructor(props: ITableProps<T>) {\r\n super(props)\r\n this.columns = this.initialColumns()\r\n this.tableQueryParams = { ...props.query }\r\n this.defaultTableQueryParams = this.tableQueryParams\r\n this.rowSelecteds = []\r\n }\r\n\r\n get mergeConfig() {\r\n const toolbarPannelProps = mergeObjects({}, params?.toolbarProps, this.props.slots?.toolbarProps)\r\n return {\r\n toolbar: this.props.slots?.toolbar ?? (() => <ToolbarPannel {...toolbarPannelProps} />),\r\n ActionRow: this.props.slots?.actionRow,\r\n disableActionRow: params.disableActionRow,\r\n columnVisibilityModel: params.columnVisibilityModel,\r\n maxSelcion: this.props.slots?.maxSelection ?? params.maxSelection,\r\n dataGridProps: mergeObjects({}, params.dataGridProps, this.props.slots?.dataGridProps),\r\n wrapProps: mergeObjects({}, params.wrapProps, this.props.slots?.wrapProps),\r\n loading: (this.props.loading !== undefined ? this.props.loading : this.tableQueryParams?.loading) ?? false,\r\n error: (this.props.error !== undefined ? this.props.error : this.tableQueryParams?.error) ?? false,\r\n onRetry: this.props.onRetry\r\n }\r\n }\r\n\r\n setTableQueryParams = (value: Partial<ITableQueryParams<T>>) => {\r\n this.tableQueryParams = mergeObjects({}, this.tableQueryParams, value)\r\n }\r\n\r\n componentWillUnmount() {\r\n if (this.changeTimeout) {\r\n clearTimeout(this.changeTimeout)\r\n }\r\n }\r\n\r\n shouldComponentUpdate(nextProps: Readonly<ITableProps<T>>): boolean {\r\n if (params.featureMode === 'server') {\r\n // Check if query changed\r\n if (!TableHelper.equalTableQueryParams(nextProps.query, this.props.query)) {\r\n this.setTableQueryParams(nextProps.query ?? {})\r\n return true\r\n }\r\n // Check if data, loading, error, or onRetry changed\r\n if (\r\n JSON.stringify(nextProps.data) !== JSON.stringify(this.props.data) ||\r\n nextProps.loading !== this.props.loading ||\r\n nextProps.error !== this.props.error ||\r\n nextProps.onRetry !== this.props.onRetry\r\n ) {\r\n return true\r\n }\r\n return false\r\n } else {\r\n return true\r\n }\r\n }\r\n\r\n render() {\r\n const rootClasses = [dinoTableClasses.root, this.mergeConfig.wrapProps?.className]\r\n return this.renderWrapContext(\r\n <TableStyled {...this.mergeConfig.wrapProps} className={rootClasses.filter((x) => !!x).join(' ')}>\r\n <DataGrid loading={this.props.loading} {...this.getDataGridProps()} />\r\n </TableStyled>\r\n )\r\n }\r\n\r\n renderWrapContext = (children: ReactNode) => {\r\n const WrapComponent = params.disableGlobalModalProvider ? Fragment : GlobalModal\r\n return (\r\n <WrapComponent>\r\n {mapGlobalModalContext((context) => (\r\n <TableBaseContext.Provider value={{ showModal: context.show, closeModal: context.close }}>{children}</TableBaseContext.Provider>\r\n ))}\r\n </WrapComponent>\r\n )\r\n }\r\n\r\n getDataGridProps = (): DataGridProps<T> => {\r\n const initialState = TableHelper.mapInitialState(this.props.query, {\r\n columns: { columnVisibilityModel: params.columnVisibilityModel as GridColumnVisibilityModel }\r\n })\r\n const isError = Boolean(this.mergeConfig.error)\r\n const CustomNoRowsOverlay = () => {\r\n if (isError) {\r\n const ErrorComponent = this.props.slots?.errorPanel ?? params.errorPanel ?? TableErrorPanel\r\n return <ErrorComponent error={this.mergeConfig.error} onRetry={this.mergeConfig.onRetry} />\r\n }\r\n const NoRowsComponent =\r\n this.props.slots?.noRowsOverlay ?? params.noRowsOverlay ?? this.mergeConfig.dataGridProps?.slots?.noRowsOverlay ?? GridNoRowsOverlay\r\n return <NoRowsComponent />\r\n }\r\n\r\n const obj: DataGridProps<T> = {\r\n getRowId: params.getRowId,\r\n initialState,\r\n columns: this.columns,\r\n rows: this.props.data?.items ?? [],\r\n checkboxSelection: true,\r\n pagination: true,\r\n density: this.props.slots?.density ?? 'standard',\r\n filterDebounceMs: 800,\r\n sx: { border: 0 },\r\n slots: {\r\n toolbar: this.mergeConfig.toolbar,\r\n noRowsOverlay: CustomNoRowsOverlay\r\n },\r\n rowSelectionModel: this.rowSelecteds,\r\n onRowSelectionModelChange: this.handleRowSelectionChange\r\n }\r\n if (params.featureMode === 'server') {\r\n const objServer: Partial<DataGridProps<T>> = {\r\n filterMode: 'server',\r\n sortingMode: 'server',\r\n paginationMode: 'server',\r\n onPaginationModelChange: this.onPaginationModelChange,\r\n onFilterModelChange: this.onFilterModelChange,\r\n onSortModelChange: this.onSortModelChange,\r\n rowCount: this.props.data?.rowTotal ?? 0,\r\n paginationModel: this.tableQueryParams.pagination,\r\n filterModel: this.tableQueryParams.filter as GridFilterModel,\r\n sortModel: TableHelper.mapSortModel(this.tableQueryParams.sort),\r\n loading: this.mergeConfig.loading\r\n }\r\n Object.assign(obj, objServer)\r\n }\r\n const mergedGridProps = mergeObjects(obj, this.mergeConfig.dataGridProps)\r\n mergedGridProps.slots = {\r\n ...mergedGridProps.slots,\r\n noRowsOverlay: CustomNoRowsOverlay\r\n }\r\n return mergedGridProps\r\n }\r\n\r\n initialColumns = (): GridColDef<T>[] => {\r\n const { ActionRow, disableActionRow } = this.mergeConfig\r\n const list: GridColDef<T>[] = []\r\n if (!!ActionRow && disableActionRow !== true) {\r\n list.push({\r\n field: 'Actions',\r\n minWidth: 100,\r\n headerAlign: 'right',\r\n align: 'right',\r\n filterable: false,\r\n sortable: false,\r\n disableExport: true,\r\n renderCell: (value) => <ActionRow value={value.row} />,\r\n ...params.actionRow\r\n })\r\n }\r\n return generateColumns(list)\r\n }\r\n\r\n onPaginationModelChange = (model: GridPaginationModel, details: GridCallbackDetails<'pagination'>) => {\r\n if (this.mergeConfig.loading) return\r\n this.setTableQueryParams({ pagination: model, detail: 'pagination' })\r\n this.handleChange()\r\n }\r\n\r\n onFilterModelChange = (model: GridFilterModel, details: GridCallbackDetails<'filter'>) => {\r\n if (this.mergeConfig.loading) return\r\n const { pagination } = this.tableQueryParams\r\n this.setTableQueryParams({\r\n filter: model as ICustomGridFilterModel<T>,\r\n pagination: { page: 0, pageSize: pagination?.pageSize ?? 25 },\r\n detail: TableHelper.detectSearchType(model)\r\n })\r\n this.handleChange()\r\n }\r\n\r\n onSortModelChange = (model: GridSortModel, details: GridCallbackDetails<any>) => {\r\n if (this.mergeConfig.loading) return\r\n let sortValue = model as ICustomGridSortModel<T>\r\n const { sort } = this.tableQueryParams\r\n if (!!sort?.length && !sortValue.length) {\r\n if (sort?.[0]?.field === this.defaultTableQueryParams.sort?.[0]?.field) {\r\n sortValue = [{ field: sort[0]?.field, sort: sort[0]?.sort === 'desc' ? 'asc' : 'desc' }]\r\n } else {\r\n sortValue = this.defaultTableQueryParams.sort ?? []\r\n }\r\n }\r\n this.setTableQueryParams({ sort: sortValue, detail: 'sort' })\r\n this.handleChange()\r\n }\r\n\r\n handleChange = () => {\r\n if (this.changeTimeout) clearTimeout(this.changeTimeout)\r\n this.changeTimeout = setTimeout(() => {\r\n this.props.onChange && this.props.onChange(this.tableQueryParams)\r\n }, 300)\r\n }\r\n\r\n handleRowSelectionChange = (value: GridRowSelectionModel, details: GridCallbackDetails) => {\r\n if (this.mergeConfig.maxSelcion && value.length > this.mergeConfig.maxSelcion) {\r\n this.rowSelecteds = value.slice(0, this.mergeConfig.maxSelcion)\r\n } else {\r\n this.rowSelecteds = value\r\n }\r\n this.props.onRowSelectionChange && this.props.onRowSelectionChange(this.rowSelecteds, details)\r\n this.forceUpdate()\r\n }\r\n }\r\n\r\n return Table\r\n}\r\n\r\nexport default CreateTable\r\n"],"names":["CreateTable","params","Table","props","_this","_classCallCheck","_callSuper","_defineProperty","value","tableQueryParams","mergeObjects","children","WrapComponent","disableGlobalModalProvider","Fragment","GlobalModal","_jsx","mapGlobalModalContext","context","TableBaseContext","Provider","showModal","show","closeModal","close","_this$props$data$item","_this$props$data","_this$props$slots$den","_this$props$slots3","initialState","TableHelper","mapInitialState","query","columns","columnVisibilityModel","isError","Boolean","mergeConfig","error","CustomNoRowsOverlay","_ref2","_ref3","_this$props$slots$noR","_this$props$slots2","_this$mergeConfig$dat","_ref","_this$props$slots$err","_this$props$slots","ErrorComponent","slots","errorPanel","TableErrorPanel","onRetry","NoRowsComponent","noRowsOverlay","dataGridProps","GridNoRowsOverlay","obj","getRowId","rows","data","items","checkboxSelection","pagination","density","filterDebounceMs","sx","border","toolbar","rowSelectionModel","rowSelecteds","onRowSelectionModelChange","handleRowSelectionChange","featureMode","_this$props$data$rowT","_this$props$data2","objServer","filterMode","sortingMode","paginationMode","onPaginationModelChange","onFilterModelChange","onSortModelChange","rowCount","rowTotal","paginationModel","filterModel","filter","sortModel","mapSortModel","sort","loading","Object","assign","mergedGridProps","_objectSpread","extendColDefs","_this$mergeConfig","ActionRow","disableActionRow","list","push","field","minWidth","headerAlign","align","filterable","sortable","disableExport","renderCell","row","actionRow","keys","map","key","filterOperators","customFilterOperators","length","apply","_toConsumableArray","model","details","setTableQueryParams","detail","handleChange","_pagination$pageSize","page","pageSize","detectSearchType","_sort$","_this$defaultTableQue","_sort$2","_sort$3","_this$defaultTableQue2","sortValue","defaultTableQueryParams","changeTimeout","clearTimeout","setTimeout","onChange","maxSelcion","slice","onRowSelectionChange","forceUpdate","initialColumns","_inherits","Component","_createClass","get","_this$props$slots4","_this$props$slots$too","_this$props$slots5","_this$props$slots6","_this$props$slots$max","_this$props$slots7","_this$props$slots8","_this$props$slots9","_ref4","_this$tableQueryParam","_ref5","_this$tableQueryParam2","toolbarPannelProps","toolbarProps","this","ToolbarPannel","maxSelection","wrapProps","undefined","nextProps","_nextProps$query","equalTableQueryParams","JSON","stringify","_this$mergeConfig$wra","rootClasses","dinoTableClasses","root","className","renderWrapContext","TableStyled","x","join","DataGrid","getDataGridProps"],"mappings":"60BAwDM,SAAUA,EAAyCC,GA4NvD,kBAzME,SAAAC,EAAYC,GAAqB,IAAAC,EAKT,OALSC,OAAAH,GAC/BE,EAAAE,EAAAJ,KAAAA,GAAMC,IAAMI,EAAAH,EAuBQ,sBAAA,SAACI,GACrBJ,EAAKK,iBAAmBC,EAAa,CAAE,EAAEN,EAAKK,iBAAkBD,KACjED,EAAAH,EAuCmB,oBAAA,SAACO,GACnB,IAAMC,EAAgBX,EAAOY,2BAA6BC,EAAWC,EACrE,OACEC,EAACJ,EACE,CAAAD,SAAAM,EA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AA,EAArBA,EAAuB1H,aAAKyH,IAAAA,GAAAA,EACxF3G,QAAS+G,KAAKhK,MAAMiD,QAExB,GAAC,CAAA8D,IAAA,uBAAA1G,MAMD,WACM2J,KAAK3B,eACPC,aAAa0B,KAAK3B,cAEtB,GAAC,CAAAtB,IAAA,wBAAA1G,MAED,SAAsBgK,GAGyD,IAAAC,EAF7E,MAA2B,WAAvBxK,EAAOwE,cAEJ3C,EAAY4I,sBAAsBF,EAAUxI,MAAOmI,KAAKhK,MAAM6B,OAMjE2I,KAAKC,UAAUJ,EAAU5G,QAAU+G,KAAKC,UAAUT,KAAKhK,MAAMyD,OAC7D4G,EAAU7E,UAAYwE,KAAKhK,MAAMwF,SACjC6E,EAAUlI,QAAU6H,KAAKhK,MAAMmC,OAC/BkI,EAAUpH,UAAY+G,KAAKhK,MAAMiD,SARjC+G,KAAKzC,oBAAmC,QAAhB+C,EAACD,EAAUxI,aAAKyI,IAAAA,EAAAA,EAAI,KACrC,GAeb,GAAC,CAAAvD,IAAA,SAAA1G,MAED,WAAM,IAAAqK,EACEC,EAAc,CAACC,EAAiBC,KAAgCH,QAA5BA,EAAEV,KAAK9H,YAAYiI,qBAASO,SAA1BA,EAA4BI,WACxE,OAAOd,KAAKe,kBACVlK,EAACmK,EAAWpF,EAAAA,EAAK,CAAA,EAAAoE,KAAK9H,YAAYiI,WAAS,CAAA,EAAA,CAAEW,UAAWH,EAAYvF,OAAO,SAAC6F,GAAC,QAAOA,CAAC,GAAEC,KAAK,cAC1FrK,EAACsK,EAAQvF,EAAA,CAACJ,QAASwE,KAAKhK,MAAMwF,SAAawE,KAAKoB,wBAGtD,IAAC,GA2IL"}
|
package/dist/src/table/dino.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createClass as r,classCallCheck as t,defineProperty as e,objectSpread2 as o,objectWithoutProperties as n}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as a}from"react/jsx-runtime";import i from"dayjs";import"../utils/dayjs-config.js";import"../utils/query-param.js";import{MapTableBaseContext as
|
|
1
|
+
import{createClass as r,classCallCheck as t,defineProperty as e,objectSpread2 as o,objectWithoutProperties as n}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as a}from"react/jsx-runtime";import i from"dayjs";import"../utils/dayjs-config.js";import"../utils/query-param.js";import{MapTableBaseContext as l}from"./context.js";import{BtnFormDetail as u,BtnDetail as s}from"./ui.buttons.js";import{CreateStatusCell as c,CellChips as m,CellBase as p,CellImageSmall as f,CellDate as v}from"./ui.units.js";import h from"./toolbar-pannel.js";import d from"./helpers.js";import{CreateTable as g}from"./create.table.js";import y from"./create.action-row.js";import{TableErrorPanel as j}from"./table.error-panel.js";import{generateExportCsvOptions as b}from"./csv-export-helper.js";import{Breadcrumbs as C}from"../components/breadcrumbs.js";var P=["imageUrl","valueFormatter","typographyProps","typographyPropsGetter"],S=["formatString"],w="MM/DD/YYYY HH:mm",x=new(r(function r(){var x=this;t(this,r),e(this,"createTable",g),e(this,"createActionRow",y),e(this,"generateExportCsvOptions",b),e(this,"setUrlQuery",d.setUrlQuery),e(this,"getUrlQuery",d.getUrlQuery),e(this,"mapContext",l),e(this,"ToolbarPannel",h),e(this,"createToolbar",function(r){return function(t){return a(h,o({},o(o({},t),r)))}}),e(this,"BtnFormDetail",u),e(this,"BtnDetail",s),e(this,"createBreadcrumbConfigs",function(r){return r}),e(this,"createBreadcrumbs",function(r){return function(){return a(C,{value:r})}}),e(this,"ErrorPanel",j),e(this,"createStatusCell",c),e(this,"formatterDate",function(r,t){var e,o,n=null!==(e=null==t?void 0:t.formatString)&&void 0!==e?e:w,a=null!==(o=null==t?void 0:t.showRelative)&&void 0!==o&&o;try{if(!r)return"";var l=i(r),u=l.format(n);return a?"".concat(u," (").concat(i().to(l),")"):u}catch(r){return""}}),e(this,"valueFormatterDate",function(r){return function(t){return x.formatterDate(t.value,r)}}),e(this,"renderCellChips",function(r){return function(t){var e;return a(m,o(o({},r),{},{value:null!==(e=t.value)&&void 0!==e?e:null==r?void 0:r.value}))}}),e(this,"renderCellStatus",function(r,t){var e=c(r,o({sx:{minWidth:"90px"}},t));return function(r){return a(e,{value:r.value})}}),e(this,"renderCellBase",function(r){return function(t){var e=null!=r?r:{},i=e.imageUrl,l=e.valueFormatter,u=e.typographyProps,s=e.typographyPropsGetter,c=n(e,P),m=l?l(t.value,t.row):void 0,f=i?i(t.value,t.row):void 0,v=null!=r&&r.icon?"function"==typeof r.icon?r.icon(t.value,t.row):r.icon:void 0,h=s?s(t.value,t.row):u;return a(p,o(o({value:t.value,valueFormatted:m},c),{},{imageUrl:f,icon:v,typographyProps:h}))}}),e(this,"renderCellImage",function(r,t){return function(e){var o;return a(f,{value:e.value,imageUri:null===(o=r(e.row))||void 0===o?void 0:o.toString(),fallbackSrc:null==t?void 0:t.fallbackSrc})}}),e(this,"renderCellDate",function(r){return function(t){var e=null!=r?r:{},i=e.formatString,l=n(e,S);return a(v,o(o({},l),{},{value:t.value,formatString:null!=i?i:w}))}})}));export{x as default};
|
|
2
2
|
//# sourceMappingURL=dino.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dino.js","sources":["../../../src/table/dino.tsx"],"sourcesContent":["import { GridRenderCellParams, GridTreeNodeWithRender, GridValueFormatterParams } from '@mui/x-data-grid'\r\nimport type { FC, ReactNode } from 'react'\r\nimport { dayjsCustom } from '../utils'\r\nimport { MapTableBaseContext } from './context'\r\nimport { BtnDetail, BtnFormDetail } from './ui.buttons'\r\nimport { Breadcrumbs, IBreadcrumbConfig } from '../components'\r\nimport { CreateStatusCell, IStatusCellOptions, IStatusCellConfig } from './ui.units'\r\nimport { CellBase, CellImageSmall, CellBaseOptions, CellChips, CellChipsProps, CellDate, CellDatePropsOwner } from './ui.units'\r\nimport ToolbarPannel, { IToolbarPannelProps } from './toolbar-pannel'\r\nimport TableHelper from './helpers'\r\nimport CreateTable from './create.table'\r\nimport CreateActionRow from './create.action-row'\r\nimport { TypographyProps } from '@mui/material'\r\nimport { generateExportCsvOptions } from './csv-export-helper'\r\n\r\nconst formatDateString = 'MM/DD/YYYY HH:mm'\r\n\r\ntype RenderCellBaseParams<T> = Omit<CellBaseOptions, 'imageUrl'> & {\r\n imageUrl?: (value: any, model: T) => string\r\n valueFormatter?: (value: any, model: T) => string\r\n icon?: ReactNode | ((value: any, model: T) => ReactNode)\r\n typographyPropsGetter?: (value: any, model: T) => TypographyProps & { [key: string]: any }\r\n}\r\n\r\ninterface FormatterDateOptions {\r\n formatString?: string\r\n showRelative?: boolean\r\n}\r\n\r\nclass DinoTableBase {\r\n //#region Base\r\n\r\n createTable = CreateTable\r\n\r\n createActionRow = CreateActionRow\r\n\r\n generateExportCsvOptions = generateExportCsvOptions\r\n\r\n setUrlQuery = TableHelper.setUrlQuery\r\n\r\n getUrlQuery = TableHelper.getUrlQuery\r\n\r\n mapContext = MapTableBaseContext\r\n\r\n ToolbarPannel = ToolbarPannel\r\n\r\n createToolbar = (props: IToolbarPannelProps): FC<IToolbarPannelProps> => {\r\n return (p) => <ToolbarPannel {...{ ...p, ...props }} />\r\n }\r\n\r\n BtnFormDetail = BtnFormDetail\r\n\r\n BtnDetail = BtnDetail\r\n\r\n createBreadcrumbConfigs = (value: IBreadcrumbConfig[]) => value\r\n\r\n createBreadcrumbs = (value: IBreadcrumbConfig[]): FC => {\r\n return () => <Breadcrumbs value={value} />\r\n }\r\n\r\n createStatusCell = CreateStatusCell\r\n //#endregion\r\n\r\n //#region Value Formatter\r\n formatterDate = (value: any, options?: FormatterDateOptions): string => {\r\n const f = options?.formatString ?? formatDateString\r\n const showRelative = options?.showRelative ?? false\r\n try {\r\n if (!value) return ''\r\n\r\n const date = dayjsCustom(value)\r\n const formatted = date.format(f)\r\n\r\n return showRelative ? `${formatted} (${dayjsCustom().to(date)})` : formatted\r\n } catch (error) {\r\n return ''\r\n }\r\n }\r\n\r\n valueFormatterDate = (options?: FormatterDateOptions) => {\r\n return (params: GridValueFormatterParams<any>) => this.formatterDate(params.value, options)\r\n }\r\n //#endregion\r\n\r\n //#region Render Cell\r\n renderCellChips = (params?: CellChipsProps) => {\r\n return function func(tableRow: GridRenderCellParams<any, any, any, GridTreeNodeWithRender>) {\r\n return <CellChips {...params} value={tableRow.value ?? params?.value} />\r\n }\r\n }\r\n\r\n renderCellStatus = function <E extends string>(config: IStatusCellConfig<E>, options?: IStatusCellOptions) {\r\n const StatusCellInstance = CreateStatusCell(config, { sx: { minWidth: '90px' }, ...options })\r\n return function func(tableRow: GridRenderCellParams<any, any, any, GridTreeNodeWithRender>) {\r\n return <StatusCellInstance value={tableRow.value} />\r\n }\r\n }\r\n\r\n renderCellBase = function <T = any>(options?: RenderCellBaseParams<T>) {\r\n return function func(tableRow: GridRenderCellParams<any, any, any, GridTreeNodeWithRender>) {\r\n const { imageUrl, valueFormatter, typographyProps, typographyPropsGetter, ...p } = options ?? {}\r\n const value = valueFormatter ? valueFormatter(tableRow.value, tableRow.row) : undefined\r\n const img = imageUrl ? imageUrl(tableRow.value, tableRow.row) : undefined\r\n const icon = options?.icon ? (typeof options.icon === 'function' ? options.icon(tableRow.value, tableRow.row) : options.icon) : undefined\r\n const mergedTypographyProps = typographyPropsGetter ? typographyPropsGetter(tableRow.value, tableRow.row) : typographyProps\r\n return <CellBase value={tableRow.value} valueFormatted={value} {...p} imageUrl={img} icon={icon} typographyProps={mergedTypographyProps} />\r\n }\r\n }\r\n\r\n renderCellImage = function <T>(selectImage: (value: T) => T[keyof T], options?: { fallbackSrc?: string }) {\r\n return function func(tableRow: GridRenderCellParams<any, any, any, GridTreeNodeWithRender>) {\r\n return <CellImageSmall value={tableRow.value} imageUri={selectImage(tableRow.row)?.toString()} fallbackSrc={options?.fallbackSrc} />\r\n }\r\n }\r\n\r\n renderCellDate = function (params?: CellDatePropsOwner) {\r\n return function func(tableRow: GridRenderCellParams<any, any, any, GridTreeNodeWithRender>) {\r\n const { formatString, ...props } = params ?? {}\r\n return <CellDate {...props} value={tableRow.value} formatString={formatString ?? formatDateString} />\r\n }\r\n }\r\n //#endregion\r\n}\r\n\r\nconst DinoTable = new DinoTableBase()\r\n\r\nexport default DinoTable\r\n"],"names":["formatDateString","DinoTable","_createClass","DinoTableBase","_this","this","_classCallCheck","_defineProperty","CreateTable","CreateActionRow","generateExportCsvOptions","TableHelper","setUrlQuery","getUrlQuery","MapTableBaseContext","ToolbarPannel","props","p","_jsx","_objectSpread","BtnFormDetail","BtnDetail","value","Breadcrumbs","CreateStatusCell","options","_options$formatString","_options$showRelative","f","formatString","showRelative","date","dayjsCustom","formatted","format","concat","to","error","params","formatterDate","tableRow","_tableRow$value","CellChips","config","StatusCellInstance","sx","minWidth","_ref","imageUrl","valueFormatter","typographyProps","typographyPropsGetter","_objectWithoutProperties","_excluded","row","undefined","img","icon","mergedTypographyProps","CellBase","valueFormatted","selectImage","_selectImage","CellImageSmall","imageUri","toString","fallbackSrc","_ref2","_excluded2","CellDate"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dino.js","sources":["../../../src/table/dino.tsx"],"sourcesContent":["import { GridRenderCellParams, GridTreeNodeWithRender, GridValueFormatterParams } from '@mui/x-data-grid'\r\nimport type { FC, ReactNode } from 'react'\r\nimport { dayjsCustom } from '../utils'\r\nimport { MapTableBaseContext } from './context'\r\nimport { BtnDetail, BtnFormDetail } from './ui.buttons'\r\nimport { Breadcrumbs, IBreadcrumbConfig } from '../components'\r\nimport { CreateStatusCell, IStatusCellOptions, IStatusCellConfig } from './ui.units'\r\nimport { CellBase, CellImageSmall, CellBaseOptions, CellChips, CellChipsProps, CellDate, CellDatePropsOwner } from './ui.units'\r\nimport ToolbarPannel, { IToolbarPannelProps } from './toolbar-pannel'\r\nimport TableHelper from './helpers'\r\nimport CreateTable from './create.table'\r\nimport CreateActionRow from './create.action-row'\r\nimport TableErrorPanel from './table.error-panel'\r\nimport { TypographyProps } from '@mui/material'\r\nimport { generateExportCsvOptions } from './csv-export-helper'\r\n\r\nconst formatDateString = 'MM/DD/YYYY HH:mm'\r\n\r\ntype RenderCellBaseParams<T> = Omit<CellBaseOptions, 'imageUrl'> & {\r\n imageUrl?: (value: any, model: T) => string\r\n valueFormatter?: (value: any, model: T) => string\r\n icon?: ReactNode | ((value: any, model: T) => ReactNode)\r\n typographyPropsGetter?: (value: any, model: T) => TypographyProps & { [key: string]: any }\r\n}\r\n\r\ninterface FormatterDateOptions {\r\n formatString?: string\r\n showRelative?: boolean\r\n}\r\n\r\nclass DinoTableBase {\r\n //#region Base\r\n\r\n createTable = CreateTable\r\n\r\n createActionRow = CreateActionRow\r\n\r\n generateExportCsvOptions = generateExportCsvOptions\r\n\r\n setUrlQuery = TableHelper.setUrlQuery\r\n\r\n getUrlQuery = TableHelper.getUrlQuery\r\n\r\n mapContext = MapTableBaseContext\r\n\r\n ToolbarPannel = ToolbarPannel\r\n\r\n createToolbar = (props: IToolbarPannelProps): FC<IToolbarPannelProps> => {\r\n return (p) => <ToolbarPannel {...{ ...p, ...props }} />\r\n }\r\n\r\n BtnFormDetail = BtnFormDetail\r\n\r\n BtnDetail = BtnDetail\r\n\r\n createBreadcrumbConfigs = (value: IBreadcrumbConfig[]) => value\r\n\r\n createBreadcrumbs = (value: IBreadcrumbConfig[]): FC => {\r\n return () => <Breadcrumbs value={value} />\r\n }\r\n\r\n ErrorPanel = TableErrorPanel\r\n\r\n createStatusCell = CreateStatusCell\r\n //#endregion\r\n\r\n //#region Value Formatter\r\n formatterDate = (value: any, options?: FormatterDateOptions): string => {\r\n const f = options?.formatString ?? formatDateString\r\n const showRelative = options?.showRelative ?? false\r\n try {\r\n if (!value) return ''\r\n\r\n const date = dayjsCustom(value)\r\n const formatted = date.format(f)\r\n\r\n return showRelative ? `${formatted} (${dayjsCustom().to(date)})` : formatted\r\n } catch (error) {\r\n return ''\r\n }\r\n }\r\n\r\n valueFormatterDate = (options?: FormatterDateOptions) => {\r\n return (params: GridValueFormatterParams<any>) => this.formatterDate(params.value, options)\r\n }\r\n //#endregion\r\n\r\n //#region Render Cell\r\n renderCellChips = (params?: CellChipsProps) => {\r\n return function func(tableRow: GridRenderCellParams<any, any, any, GridTreeNodeWithRender>) {\r\n return <CellChips {...params} value={tableRow.value ?? params?.value} />\r\n }\r\n }\r\n\r\n renderCellStatus = function <E extends string>(config: IStatusCellConfig<E>, options?: IStatusCellOptions) {\r\n const StatusCellInstance = CreateStatusCell(config, { sx: { minWidth: '90px' }, ...options })\r\n return function func(tableRow: GridRenderCellParams<any, any, any, GridTreeNodeWithRender>) {\r\n return <StatusCellInstance value={tableRow.value} />\r\n }\r\n }\r\n\r\n renderCellBase = function <T = any>(options?: RenderCellBaseParams<T>) {\r\n return function func(tableRow: GridRenderCellParams<any, any, any, GridTreeNodeWithRender>) {\r\n const { imageUrl, valueFormatter, typographyProps, typographyPropsGetter, ...p } = options ?? {}\r\n const value = valueFormatter ? valueFormatter(tableRow.value, tableRow.row) : undefined\r\n const img = imageUrl ? imageUrl(tableRow.value, tableRow.row) : undefined\r\n const icon = options?.icon ? (typeof options.icon === 'function' ? options.icon(tableRow.value, tableRow.row) : options.icon) : undefined\r\n const mergedTypographyProps = typographyPropsGetter ? typographyPropsGetter(tableRow.value, tableRow.row) : typographyProps\r\n return <CellBase value={tableRow.value} valueFormatted={value} {...p} imageUrl={img} icon={icon} typographyProps={mergedTypographyProps} />\r\n }\r\n }\r\n\r\n renderCellImage = function <T>(selectImage: (value: T) => T[keyof T], options?: { fallbackSrc?: string }) {\r\n return function func(tableRow: GridRenderCellParams<any, any, any, GridTreeNodeWithRender>) {\r\n return <CellImageSmall value={tableRow.value} imageUri={selectImage(tableRow.row)?.toString()} fallbackSrc={options?.fallbackSrc} />\r\n }\r\n }\r\n\r\n renderCellDate = function (params?: CellDatePropsOwner) {\r\n return function func(tableRow: GridRenderCellParams<any, any, any, GridTreeNodeWithRender>) {\r\n const { formatString, ...props } = params ?? {}\r\n return <CellDate {...props} value={tableRow.value} formatString={formatString ?? formatDateString} />\r\n }\r\n }\r\n //#endregion\r\n}\r\n\r\nconst DinoTable = new DinoTableBase()\r\n\r\nexport default DinoTable\r\n"],"names":["formatDateString","DinoTable","_createClass","DinoTableBase","_this","this","_classCallCheck","_defineProperty","CreateTable","CreateActionRow","generateExportCsvOptions","TableHelper","setUrlQuery","getUrlQuery","MapTableBaseContext","ToolbarPannel","props","p","_jsx","_objectSpread","BtnFormDetail","BtnDetail","value","Breadcrumbs","TableErrorPanel","CreateStatusCell","options","_options$formatString","_options$showRelative","f","formatString","showRelative","date","dayjsCustom","formatted","format","concat","to","error","params","formatterDate","tableRow","_tableRow$value","CellChips","config","StatusCellInstance","sx","minWidth","_ref","imageUrl","valueFormatter","typographyProps","typographyPropsGetter","_objectWithoutProperties","_excluded","row","undefined","img","icon","mergedTypographyProps","CellBase","valueFormatted","selectImage","_selectImage","CellImageSmall","imageUri","toString","fallbackSrc","_ref2","_excluded2","CellDate"],"mappings":"86BAgBMA,EAAmB,mBA+GnBC,EAAY,IAjGCC,EAAA,SAAAC,IAAA,IAAAC,EAAAC,KAAAC,OAAAH,GACjBI,qBAEcC,GAAWD,yBAEPE,GAAeF,kCAENG,GAAwBH,EAAAF,KAAA,cAErCM,EAAYC,aAAWL,EAAAF,KAAA,cAEvBM,EAAYE,aAAWN,oBAExBO,GAAmBP,uBAEhBQ,GAAaR,EAAAF,KAAA,gBAEb,SAACW,GACf,OAAO,SAACC,GAAC,OAAKC,EAACH,EAAaI,EAAAA,GAAAA,EAAAA,EAAUF,GAAAA,GAAMD,IAAW,IACxDT,uBAEea,GAAab,mBAEjBc,GAASd,EAAAF,KAAA,0BAEK,SAACiB,GAA0B,OAAKA,CAAK,GAAAf,EAAAF,KAAA,oBAE3C,SAACiB,GACnB,OAAO,WAAA,OAAMJ,EAACK,GAAYD,MAAOA,GAAS,IAC3Cf,oBAEYiB,GAAejB,0BAETkB,GAGnBlB,EACgBF,KAAA,gBAAA,SAACiB,EAAYI,GAA0C,IAAAC,EAAAC,EAC/DC,EAAyBF,QAAxBA,EAAGD,aAAO,EAAPA,EAASI,oBAAYH,IAAAA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AsBhC,EAAQgC,KAAKjB,EAASnB,MAAOmB,EAASc,KAAO7B,EAAQgC,UAAQF,EAC1HG,EAAwBP,EAAwBA,EAAsBX,EAASnB,MAAOmB,EAASc,KAAOJ,EAC5G,OAAOjC,EAAC0C,EAAQzC,EAAAA,EAAA,CAACG,MAAOmB,EAASnB,MAAOuC,eAAgBvC,GAAWL,GAAC,GAAA,CAAEgC,SAAUQ,EAAKC,KAAMA,EAAMP,gBAAiBQ,IACnH,IACFpD,EAEiBF,KAAA,kBAAA,SAAayD,EAAuCpC,GACpE,OAAO,SAAce,GAAqE,IAAAsB,EACxF,OAAO7C,EAAC8C,EAAc,CAAC1C,MAAOmB,EAASnB,MAAO2C,SAAmC,QAA3BF,EAAED,EAAYrB,EAASc,YAArBQ,IAAyBA,OAAzBA,EAAAA,EAA2BG,WAAYC,YAAazC,aAAO,EAAPA,EAASyC,aACtH,IACF5D,EAAAF,KAAA,iBAEgB,SAAUkC,GACzB,OAAO,SAAcE,GACnB,IAAA2B,EAAmC7B,QAAAA,EAAU,CAAE,EAAvCT,EAAYsC,EAAZtC,aAAiBd,EAAKqC,EAAAe,EAAAC,GAC9B,OAAOnD,EAACoD,EAAQnD,EAAAA,KAAKH,GAAK,GAAA,CAAEM,MAAOmB,EAASnB,MAAOQ,aAAcA,QAAAA,EAAgB9B,IAClF,GACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as r,jsxs as e}from"react/jsx-runtime";import{isValidElement as t}from"react";import{styled as i,Box as a,Stack as n,Typography as o,Button as l}from"@mui/material";import s from"@mui/icons-material/ErrorOutline";var c=i(a)({display:"flex",alignItems:"center",justifyContent:"center",height:"100%",width:"100%"}),m=function(i){var a=i.error,m=i.onRetry;if(t(a))return r(c,{className:"MuiDataGrid-overlay",children:a});var d="Failed to load data";return"string"==typeof a&&a.trim().length>0?d=a:a instanceof Error&&a.message&&(d=a.message),r(c,{className:"MuiDataGrid-overlay",children:e(n,{alignItems:"center",justifyContent:"center",spacing:1,sx:{p:2,textAlign:"center"},children:[r(s,{color:"error",sx:{fontSize:40}}),r(o,{variant:"body2",color:"text.secondary",children:d}),"function"==typeof m&&r(l,{variant:"outlined",size:"small",color:"primary",onClick:m,sx:{mt:1},children:"Retry"})]})})};export{m as TableErrorPanel,m as default};
|
|
2
|
+
//# sourceMappingURL=table.error-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.error-panel.js","sources":["../../../src/table/table.error-panel.tsx"],"sourcesContent":["import { isValidElement } from 'react'\nimport type { FC, ReactNode } from 'react'\nimport { Box, Button, Stack, Typography, styled } from '@mui/material'\nimport ErrorOutlineIcon from '@mui/icons-material/ErrorOutline'\n\nexport interface ITableErrorPanelProps {\n error?: boolean | string | Error | ReactNode\n onRetry?: () => void\n}\n\nconst OverlayContainer = styled(Box)({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n height: '100%',\n width: '100%'\n})\n\nexport const TableErrorPanel: FC<ITableErrorPanelProps> = ({ error, onRetry }) => {\n if (isValidElement(error)) {\n return <OverlayContainer className='MuiDataGrid-overlay'>{error}</OverlayContainer>\n }\n\n let message = 'Failed to load data'\n if (typeof error === 'string' && error.trim().length > 0) {\n message = error\n } else if (error instanceof Error && error.message) {\n message = error.message\n }\n\n return (\n <OverlayContainer className='MuiDataGrid-overlay'>\n <Stack alignItems='center' justifyContent='center' spacing={1} sx={{ p: 2, textAlign: 'center' }}>\n <ErrorOutlineIcon color='error' sx={{ fontSize: 40 }} />\n <Typography variant='body2' color='text.secondary'>\n {message}\n </Typography>\n {typeof onRetry === 'function' && (\n <Button variant='outlined' size='small' color='primary' onClick={onRetry} sx={{ mt: 1 }}>\n Retry\n </Button>\n )}\n </Stack>\n </OverlayContainer>\n )\n}\n\nexport default TableErrorPanel\n\n"],"names":["OverlayContainer","styled","Box","display","alignItems","justifyContent","height","width","TableErrorPanel","_ref","error","onRetry","isValidElement","_jsx","className","children","message","trim","length","Error","_jsxs","Stack","spacing","sx","p","textAlign","ErrorOutlineIcon","color","fontSize","Typography","variant","Button","size","onClick","mt"],"mappings":"gOAUA,IAAMA,EAAmBC,EAAOC,EAAPD,CAAY,CACnCE,QAAS,OACTC,WAAY,SACZC,eAAgB,SAChBC,OAAQ,OACRC,MAAO,SAGIC,EAA6C,SAA9BC,GAAqD,IAApBC,EAAKD,EAALC,MAAOC,EAAOF,EAAPE,QAClE,GAAIC,EAAeF,GACjB,OAAOG,EAACb,EAAiB,CAAAc,UAAU,sBAAqBC,SAAEL,IAG5D,IAAIM,EAAU,sBAOd,MANqB,iBAAVN,GAAsBA,EAAMO,OAAOC,OAAS,EACrDF,EAAUN,EACDA,aAAiBS,OAAST,EAAMM,UACzCA,EAAUN,EAAMM,SAIhBH,EAACb,EAAgB,CAACc,UAAU,sBAC1BC,SAAAK,EAACC,EAAK,CAACjB,WAAW,SAASC,eAAe,SAASiB,QAAS,EAAGC,GAAI,CAAEC,EAAG,EAAGC,UAAW,UAAUV,SAAA,CAC9FF,EAACa,GAAiBC,MAAM,QAAQJ,GAAI,CAAEK,SAAU,MAChDf,EAACgB,EAAU,CAACC,QAAQ,QAAQH,MAAM,iBAAgBZ,SAC/CC,IAEiB,mBAAZL,GACNE,EAACkB,EAAO,CAAAD,QAAQ,WAAWE,KAAK,QAAQL,MAAM,UAAUM,QAAStB,EAASY,GAAI,CAAEW,GAAI,0BAO9F"}
|
package/dist/table/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{ELogic,EOperator,EOrder}from"../src/table/model-filter.js";import"react/jsx-runtime";import"react";import"@mui/material";import"@mui/icons-material/Edit";import"@mui/icons-material/Delete";import"dayjs";import"../src/utils/dayjs-config.js";import"../src/utils/query-param.js";export{CreateTable}from"../src/table/create.table.js";export{default as DinoTable}from"../src/table/dino.js";export{dinoTableClasses}from"../src/table/styled.js";
|
|
1
|
+
export{ELogic,EOperator,EOrder}from"../src/table/model-filter.js";import"react/jsx-runtime";import"react";import"@mui/material";import"@mui/icons-material/Edit";import"@mui/icons-material/Delete";import"dayjs";import"../src/utils/dayjs-config.js";import"../src/utils/query-param.js";export{CreateTable}from"../src/table/create.table.js";export{TableErrorPanel}from"../src/table/table.error-panel.js";export{default as DinoTable}from"../src/table/dino.js";export{dinoTableClasses}from"../src/table/styled.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -11,4 +11,11 @@ interface IIconButtonConfirmProps extends IconButtonProps {
|
|
|
11
11
|
question?: string;
|
|
12
12
|
}
|
|
13
13
|
export declare const IconButtonConfirm: FC<IIconButtonConfirmProps>;
|
|
14
|
+
export declare const buttonConfirmClasses: {
|
|
15
|
+
root: string;
|
|
16
|
+
confirmBox: string;
|
|
17
|
+
button: string;
|
|
18
|
+
iconButton: string;
|
|
19
|
+
question: string;
|
|
20
|
+
};
|
|
14
21
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, ComponentType, ReactNode } from 'react';
|
|
2
|
-
import { ButtonProps, TooltipProps } from '@mui/material';
|
|
2
|
+
import { ButtonProps, SvgIconOwnProps, TooltipProps } from '@mui/material';
|
|
3
3
|
type TTooltipTitleConfig = {
|
|
4
4
|
copy?: ReactNode;
|
|
5
5
|
copied?: ReactNode;
|
|
@@ -16,6 +16,7 @@ export interface ICopyToClipboardProps {
|
|
|
16
16
|
slots?: {
|
|
17
17
|
tooltipProps?: Partial<TooltipProps>;
|
|
18
18
|
buttonProps?: ButtonProps;
|
|
19
|
+
iconProps?: SvgIconOwnProps;
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
export interface ICopyToClipboardState {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { DataSurfaceViewMode, LoadingModeRule, DataSurfaceFeatureMode } from './types';
|
|
2
2
|
import type { BoxProps } from '@mui/material';
|
|
3
3
|
import type { ComponentType, FC } from 'react';
|
|
4
|
+
import type { TFieldSort } from '../filter-bar/types';
|
|
4
5
|
import type { IViewGridConfig, IViewGridProps } from './view-grid/types';
|
|
5
6
|
import type { TPagination, TDataSurfaceState, TRenderableNode } from './types';
|
|
6
|
-
import type { IViewListConfig, IViewListProps,
|
|
7
|
-
import type { TFieldSort } from '../filter-bar/types';
|
|
7
|
+
import type { IViewListConfig, IViewListProps, TColumnsState } from './view-list';
|
|
8
8
|
export interface IDataSurfaceSlots<T> {
|
|
9
|
-
listViewProps?: Partial<
|
|
9
|
+
listViewProps?: Partial<IViewListProps<T>>;
|
|
10
10
|
gridViewProps?: Partial<IViewGridProps<T>>;
|
|
11
11
|
/** Custom loading component. If not provided, a default loading component will be used. */
|
|
12
12
|
PanelLoading?: ComponentType<{
|
|
@@ -16,6 +16,10 @@ export interface IDataSurfaceSlots<T> {
|
|
|
16
16
|
PanelNoData?: ComponentType<{
|
|
17
17
|
viewMode: DataSurfaceViewMode;
|
|
18
18
|
}>;
|
|
19
|
+
/** Custom error component. If not provided, a default error component will be used. */
|
|
20
|
+
PanelError?: ComponentType<{
|
|
21
|
+
viewMode: DataSurfaceViewMode;
|
|
22
|
+
}>;
|
|
19
23
|
/** Custom load more component for infinite scroll mode. If not provided, a default loading indicator will be shown when fetching the next page. */
|
|
20
24
|
PanelLoadMore?: ComponentType;
|
|
21
25
|
footer?: {
|
|
@@ -40,10 +44,17 @@ export interface IDataSurfaceProps<T> {
|
|
|
40
44
|
viewMode?: DataSurfaceViewMode;
|
|
41
45
|
/** Pagination metadata shared by both modes. */
|
|
42
46
|
pagination?: TPagination;
|
|
47
|
+
/**
|
|
48
|
+
* Reset key that invalidates visited pagination history when filters, queries, or sort criteria change.
|
|
49
|
+
* Accepts string, number, or object (e.g. filter state).
|
|
50
|
+
*/
|
|
51
|
+
resetKey?: unknown;
|
|
43
52
|
/** Default page size. @default 20 */
|
|
44
53
|
defaultPageSize?: number;
|
|
45
54
|
/** True while a page fetch is in flight (shows loading indicator). */
|
|
46
55
|
loading?: boolean;
|
|
56
|
+
/** True if there is an error loading data. */
|
|
57
|
+
error?: boolean;
|
|
47
58
|
/**
|
|
48
59
|
* Called when the component needs a new page of data.
|
|
49
60
|
* - pagination mode: triggered by user clicking page control
|
|
@@ -72,10 +83,10 @@ export interface IDataSurfaceProps<T> {
|
|
|
72
83
|
*/
|
|
73
84
|
onSortChange?: (sort?: TFieldSort<T>) => void;
|
|
74
85
|
/**
|
|
75
|
-
*
|
|
76
|
-
* NOTE: This
|
|
86
|
+
* Runtime column state (hidden/priority) from ColumnSelector.
|
|
87
|
+
* NOTE: This is supported in ViewList (List view).
|
|
77
88
|
*/
|
|
78
|
-
|
|
89
|
+
columnsState?: TColumnsState<T>;
|
|
79
90
|
}
|
|
80
91
|
export interface IDataSurfaceConfig<T> {
|
|
81
92
|
/** Feature mode determines the internal optimizations and rendering strategies. @default 'client' */
|
|
@@ -102,6 +113,10 @@ export interface IDataSurfaceConfig<T> {
|
|
|
102
113
|
PanelNoData?: ComponentType<{
|
|
103
114
|
viewMode: DataSurfaceViewMode;
|
|
104
115
|
}>;
|
|
116
|
+
/** Custom error component. If not provided, a default error component will be used. */
|
|
117
|
+
PanelError?: ComponentType<{
|
|
118
|
+
viewMode: DataSurfaceViewMode;
|
|
119
|
+
}>;
|
|
105
120
|
/** Custom load more component for infinite scroll mode. If not provided, a default loading indicator will be shown when fetching the next page. */
|
|
106
121
|
PanelLoadMore?: ComponentType;
|
|
107
122
|
}
|
|
@@ -5,7 +5,7 @@ export declare const PanelLoading: FC<BoxProps & {
|
|
|
5
5
|
viewMode: DataSurfaceViewMode;
|
|
6
6
|
}>;
|
|
7
7
|
export declare const PanelError: FC<{
|
|
8
|
-
|
|
8
|
+
errorText?: string;
|
|
9
9
|
}>;
|
|
10
10
|
export declare const PanelNoData: FC;
|
|
11
11
|
export declare const PanelWaiting: FC;
|
|
@@ -33,7 +33,7 @@ export interface IPanelPaginationFooterProps {
|
|
|
33
33
|
onPrevPage?: () => void;
|
|
34
34
|
onNextPage?: () => void;
|
|
35
35
|
onPageJump?: (page: number) => void;
|
|
36
|
-
resetKey?:
|
|
36
|
+
resetKey?: unknown;
|
|
37
37
|
}
|
|
38
38
|
export declare const PanelPaginationFooter: FC<IPanelPaginationFooterProps>;
|
|
39
39
|
export declare const createPanelPaginationFooter: (params?: Partial<IPanelPaginationFooterProps>) => FC<IPanelPaginationFooterProps>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FC } from 'react';
|
|
2
|
-
import type { IColumnSelectorConfig, IColumnSelectorProps,
|
|
2
|
+
import type { IColumnSelectorConfig, IColumnSelectorProps, TColumnsState } from './types';
|
|
3
3
|
export declare function createColumnSelector<T>(config: IColumnSelectorConfig<T>): FC<IColumnSelectorProps<T>> & {
|
|
4
|
-
defaultValue:
|
|
4
|
+
defaultValue: TColumnsState<T>;
|
|
5
5
|
};
|
|
6
6
|
export default createColumnSelector;
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { TableCellProps } from '@mui/material';
|
|
2
|
-
import { ListDensity,
|
|
2
|
+
import { ListDensity, TColumnsConfig, TColumnsState, TListColumn } from './types';
|
|
3
3
|
export declare const LIST_HEADER_HEIGHT = 48;
|
|
4
4
|
export declare const LIST_DEFAULT_ROW_SPACING = 4;
|
|
5
5
|
export declare const CHECKBOX_COL_WIDTH = 48;
|
|
6
6
|
export declare const LIST_ROW_HEIGHT_BY_DENSITY: Record<ListDensity, number>;
|
|
7
7
|
export declare const LIST_CELL_PADDING_BY_DENSITY: Record<ListDensity, string>;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* Orders column keys such that priority columns appear first in priority order,
|
|
10
|
+
* followed by remaining keys in their original relative order.
|
|
11
11
|
*/
|
|
12
|
-
export declare
|
|
12
|
+
export declare function sortKeysByPriority<K extends string | number | symbol>(keys: K[], priorityKeys?: K[]): K[];
|
|
13
|
+
/**
|
|
14
|
+
* Converts TColumnsConfig<T> (or TListColumns<T>) Record type to TListColumn<T>[] array for internal use.
|
|
15
|
+
* Applies columnsState model for visibility and priority if provided.
|
|
16
|
+
*/
|
|
17
|
+
export declare const columnsRecordToArray: <T>(value: T[], columnsConfig?: Partial<Record<keyof T, Omit<TListColumn<T>, "field">>> | undefined, columnsState?: Partial<Record<keyof T, import("./types").IColumnStateItem>> | undefined) => TListColumn<T>[];
|
|
13
18
|
export declare function resolveListRowHeight(density?: number | ListDensity): number;
|
|
14
19
|
export declare function resolveListCellPadding(density?: number | ListDensity): string;
|
|
15
20
|
export declare function resolveListRowSpacing(spacing?: number): number;
|
|
@@ -54,13 +54,20 @@ export interface TListColumn<T> {
|
|
|
54
54
|
valueGetter?: (value: string, row: T, index: number) => any;
|
|
55
55
|
/** Allow sorting on this column */
|
|
56
56
|
sortable?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Highest priority visibility override.
|
|
59
|
+
* - `true`: Forces the column to always be visible, cannot be hidden, overrides colVisibleable (omitted from selector menu).
|
|
60
|
+
* - `false`: Forces the column to always be hidden, overrides colVisibleable (omitted from selector menu and hidden from table).
|
|
61
|
+
* - `undefined`: Normal behavior governed by `colVisibleable` and `visible` with ColumnSelector.
|
|
62
|
+
*/
|
|
63
|
+
forceVisible?: boolean;
|
|
57
64
|
/** If true, the column is visible in the list @default true */
|
|
58
65
|
visible?: boolean;
|
|
59
|
-
/** Allow toggling visibility of this column via ColumnSelector */
|
|
66
|
+
/** Allow toggling visibility of this column via ColumnSelector @default false */
|
|
60
67
|
colVisibleable?: boolean;
|
|
61
68
|
}
|
|
62
|
-
/** Columns configuration for List view. */
|
|
63
|
-
export type
|
|
69
|
+
/** Columns configuration record for List view. */
|
|
70
|
+
export type TColumnsConfig<T> = Partial<Record<keyof T, Omit<TListColumn<T>, 'field'>>>;
|
|
64
71
|
/**
|
|
65
72
|
* Row density preset for List view.
|
|
66
73
|
* Controls the row height and cell padding.
|
|
@@ -81,8 +88,10 @@ export interface IViewListVirtualizedOptions {
|
|
|
81
88
|
}
|
|
82
89
|
/** Base configuration for List view. */
|
|
83
90
|
export interface IViewListBase<T> {
|
|
84
|
-
/**
|
|
85
|
-
columns?:
|
|
91
|
+
/** Column definitions config for list rows. If not provided, default columns will be derived from data. */
|
|
92
|
+
columns?: TColumnsConfig<T>;
|
|
93
|
+
/** Dynamic runtime state of columns (visibility, priority). */
|
|
94
|
+
columnsState?: TColumnsState<T>;
|
|
86
95
|
/** Row height preset or an explicit row height in pixels. @default 'standard' */
|
|
87
96
|
density?: number | ListDensity;
|
|
88
97
|
/** Spacing between rows in pixels. @default 4 */
|
|
@@ -106,32 +115,41 @@ export interface IViewListBase<T> {
|
|
|
106
115
|
sort?: TFieldSort<T>;
|
|
107
116
|
/** Callback triggered when sorting changes */
|
|
108
117
|
onSortChange?: (sort?: TFieldSort<T>) => void;
|
|
109
|
-
/** Map specifying which managed columns are visible (true) or hidden (false) */
|
|
110
|
-
columnVisibility?: TColumnVisibility<T>;
|
|
111
118
|
}
|
|
112
|
-
/**
|
|
113
|
-
export
|
|
119
|
+
/** Runtime state item for an individual column. */
|
|
120
|
+
export interface IColumnStateItem {
|
|
121
|
+
/** When true, the column is hidden from view. */
|
|
122
|
+
hidden?: boolean;
|
|
123
|
+
/** When true, the column is prioritized and placed at the top. */
|
|
124
|
+
priority?: boolean;
|
|
125
|
+
}
|
|
126
|
+
/** Table-level runtime column state mapping column fields to their state. */
|
|
127
|
+
export type TColumnsState<T> = Partial<Record<keyof T, IColumnStateItem>>;
|
|
114
128
|
/** Factory configuration for ColumnSelector */
|
|
115
129
|
export interface IColumnSelectorConfig<T> {
|
|
116
130
|
/** Unique table key for namespacing localStorage data (required) */
|
|
117
131
|
persistenceKey: string;
|
|
118
|
-
/** Global storage key in localStorage @default 'dino-view-list-column
|
|
132
|
+
/** Global storage key in localStorage @default 'dino-view-list-column' */
|
|
119
133
|
storageKey?: string;
|
|
120
134
|
/** Target listConfig (e.g. DataSurfaceIns.listConfig) */
|
|
121
135
|
config?: IViewListConfig<T>;
|
|
122
136
|
/** Whether the column selector should be hidden */
|
|
123
137
|
hide?: boolean;
|
|
138
|
+
/** Whether column prioritization (starring/pinning to top) is enabled @default false */
|
|
139
|
+
prioritizable?: boolean;
|
|
124
140
|
}
|
|
125
141
|
/** Props for ColumnSelector component */
|
|
126
142
|
export interface IColumnSelectorProps<T> {
|
|
127
|
-
/**
|
|
128
|
-
|
|
129
|
-
/** Callback when column
|
|
130
|
-
onChange?: (model:
|
|
143
|
+
/** Dynamic runtime state of columns (visibility, priority). */
|
|
144
|
+
columnsState?: TColumnsState<T>;
|
|
145
|
+
/** Callback when custom column settings change */
|
|
146
|
+
onChange?: (model: TColumnsState<T>) => void;
|
|
131
147
|
/** Size of IconButton @default 'small' */
|
|
132
148
|
size?: 'small' | 'medium';
|
|
133
149
|
/** Whether the column selector should be hidden */
|
|
134
150
|
hide?: boolean;
|
|
151
|
+
/** Whether column prioritization (starring/pinning to top) is enabled @default false */
|
|
152
|
+
prioritizable?: boolean;
|
|
135
153
|
}
|
|
136
154
|
/** Configuration for List view. */
|
|
137
155
|
export interface IViewListConfig<T> extends IViewListBase<T> {
|
|
@@ -31,8 +31,8 @@ export interface IFilterInputBase {
|
|
|
31
31
|
fullWidth?: boolean;
|
|
32
32
|
}
|
|
33
33
|
export interface IFilterInputConfig<T> extends IFilterInputBase, IFilterInputLayoutSlots {
|
|
34
|
-
/** Enable or disable quick search, @default false */
|
|
35
|
-
enableQuickSearch?: boolean
|
|
34
|
+
/** Enable or disable quick search, or specify default search field @default false */
|
|
35
|
+
enableQuickSearch?: boolean | TFieldType<T>;
|
|
36
36
|
/** Placeholder text for input field */
|
|
37
37
|
placeholder?: string;
|
|
38
38
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import type { FC } from 'react';
|
|
2
|
-
import type { IconButtonProps } from '@mui/material';
|
|
1
|
+
import type { FC, ReactNode } from 'react';
|
|
2
|
+
import type { BoxProps, IconButtonProps } from '@mui/material';
|
|
3
3
|
import type { TFieldType, TFilterFieldConfig, TFilterFieldConfigs } from './types';
|
|
4
|
+
export interface IDefaultChipProps extends BoxProps {
|
|
5
|
+
label?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const DefaultChip: import("@emotion/styled").StyledComponent<IDefaultChipProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
4
8
|
export type TInputMatchedField<T> = TFilterFieldConfig<T> & {
|
|
5
9
|
field: TFieldType<T>;
|
|
6
10
|
};
|
|
@@ -36,8 +36,8 @@ export interface IFilterMenuParam<T> extends IFilterMenuSlots {
|
|
|
36
36
|
fields?: TFilterFieldConfigs<T>;
|
|
37
37
|
validation?: IFormValidatorConfig<Partial<TFieldModelValid<T>>>;
|
|
38
38
|
quickSearchHint?: string | ((currentHint: string) => string);
|
|
39
|
-
/** Option to enable or disable quick search @default false */
|
|
40
|
-
enableQuickSearch?: boolean
|
|
39
|
+
/** Option to enable or disable quick search, or specify default search field @default false */
|
|
40
|
+
enableQuickSearch?: boolean | TFieldType<T>;
|
|
41
41
|
/** Option to close the menu after submitting a value @default true */
|
|
42
42
|
closeAfterSubmit?: boolean;
|
|
43
43
|
/** Option to close the menu after clearing a value @default true */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { BoxProps } from '@mui/material';
|
|
2
|
-
import type { TFilterFieldConfigs } from './types';
|
|
2
|
+
import type { TFieldType, TFilterFieldConfigs } from './types';
|
|
3
3
|
/** Configuration parameters passed to `createFilterSummary(config)` factory function */
|
|
4
4
|
export interface IFilterSummaryConfig<T> {
|
|
5
5
|
/** Field configuration schema map */
|
|
6
6
|
fields?: TFilterFieldConfigs<T>;
|
|
7
7
|
/** Option to enable or disable quick search chip in summary @default true */
|
|
8
|
-
enableQuickSearch?: boolean
|
|
8
|
+
enableQuickSearch?: boolean | TFieldType<T>;
|
|
9
9
|
}
|
|
10
10
|
/** Props passed to the generated `FilterSummary` component */
|
|
11
11
|
export interface IFilterSummaryProps<T> {
|
|
@@ -31,7 +31,7 @@ export interface IFormFieldBooleanParam<T> {
|
|
|
31
31
|
* @param params - Static configuration (optional label overrides, optional field config override)
|
|
32
32
|
* @returns A React FC ready to be used as a boolean filter-menu field component
|
|
33
33
|
*/
|
|
34
|
-
declare function createFormFieldBoolean<T>(params?: IFormFieldBooleanParam<T>): FC<IFormFieldBooleanProps<T>>;
|
|
34
|
+
export declare function createFormFieldBoolean<T>(params?: IFormFieldBooleanParam<T>): FC<IFormFieldBooleanProps<T>>;
|
|
35
35
|
export default createFormFieldBoolean;
|
|
36
36
|
/**
|
|
37
37
|
* Creates a `labelFormatter` for use in `summaryConfig`.
|
|
@@ -44,7 +44,7 @@ export interface IFormFieldNumberParam<T> {
|
|
|
44
44
|
* @param params - Static configuration (optional field config override, default operator, step, min, max)
|
|
45
45
|
* @returns A React FC ready to be used as a number filter-menu field component
|
|
46
46
|
*/
|
|
47
|
-
declare function createFormFieldNumber<T>(params?: IFormFieldNumberParam<T>): FC<IFormFieldNumberProps<T>>;
|
|
47
|
+
export declare function createFormFieldNumber<T>(params?: IFormFieldNumberParam<T>): FC<IFormFieldNumberProps<T>>;
|
|
48
48
|
export default createFormFieldNumber;
|
|
49
49
|
/**
|
|
50
50
|
* Creates a labelFormatter for use in summaryConfig.
|