dinocollab-core 2.1.12 → 2.1.13
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/data-view/view-mode.content.js.map +1 -1
- package/dist/form/create.date-expired.js +1 -1
- package/dist/form/create.date-expired.js.map +1 -1
- package/dist/form/create.input-file.csv-local-parser.js +1 -1
- package/dist/form/create.input-file.csv-local-parser.js.map +1 -1
- package/dist/mfe-shared/navigation.js +1 -1
- package/dist/mfe-shared/navigation.js.map +1 -1
- package/package.json +1 -1
|
@@ -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\nexport interface 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-of-type': {\r\n borderLeft: '1px dashed var(--custom-border-color)',\r\n borderRadius: '6px 0 0 6px'\r\n },\r\n '&:last-of-type': {\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-of-type': {\r\n borderLeftStyle: 'solid'\r\n },\r\n '&:last-of-type': {\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,GAK1BC,EAAAV,EAAA,CAAA,CAAAW,IAAA,wBAAAC,MAED,SAAsBC,GACpB,IAAAC,EAAsDC,KAAKd,MAAMK,QAAhDU,EAAcF,EAAvBP,QAA4BU,EAAaC,EAAAJ,EAAAK,GACjDC,EAAiDP,EAAUP,QAA1Ce,EAAWD,EAApBb,QAAyBe,EAAWJ,EAAAE,EAAAG,GACnBP,IAAmBK,IAE1CN,KAAKV,iBAAmBQ,EAAUP,QAAQC,SAAWf,GAGvD,IAAMgC,EAAmBC,KAAKC,UAAUT,KAAmBQ,KAAKC,UAAUJ,GAE1E,OADsBG,KAAKC,UAAUX,KAAKd,MAAM0B,QAAUF,KAAKC,UAAUb,EAAUc,OAC3DH,CAC1B,GAAC,CAAAb,IAAA,SAAAC,MAED,WACE,IAAQP,EAAqBU,KAArBV,iBACRuB,EAA0Bb,KAAKd,MAAvB0B,EAAIC,EAAJD,KAAMrB,EAAOsB,EAAPtB,QACRuB,EAAOvB,EAAQuB,MAAQ,CAAEC,GAAI,GAAIC,GAAI,EAAGC,GAAI,EAAGC,GA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C,EAAOC,KAAK,IAC7BN,YAAa,cACbO,aAAc,OAEhB,sCAAuC,CACrC,mBAAoB,CAClBA,aAAc,MACdC,OAAQ,OACRC,WAAY,gBACZL,gBAAiB,yBACjB,oBAAqB,CACnBA,gBAAiB,yBACjBI,OAAQ,OACRE,UAAW,wCACXC,aAAc,wCACd,kBAAmB,CACjBC,WAAY,wCACZL,aAAc,eAEhB,iBAAkB,CAChBM,YAAa,wCACbN,aAAc,gBAGlB,UAAW,CACT,wBAAyBZ,EAAME,QAAQiB,QACvC,oBAAqBT,EAAOC,KAAK,IACjCS,UAAW,mBACXC,UAAW,wCACX,oBAAqB,CACnBC,eAAgB,QAChBC,kBAAmB,QACnB,kBAAmB,CACjBC,gBAAiB,SAEnB,iBAAkB,CAChBC,iBAAkB,aAM7B"}
|
|
1
|
+
{"version":3,"file":"view-mode.content.js","sources":["../../src/data-view/view-mode.content.tsx"],"sourcesContent":["import { 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\nexport interface 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-of-type': {\r\n borderLeft: '1px dashed var(--custom-border-color)',\r\n borderRadius: '6px 0 0 6px'\r\n },\r\n '&:last-of-type': {\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-of-type': {\r\n borderLeftStyle: 'solid'\r\n },\r\n '&:last-of-type': {\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,GAK1BC,EAAAV,EAAA,CAAA,CAAAW,IAAA,wBAAAC,MAED,SAAsBC,GACpB,IAAAC,EAAsDC,KAAKd,MAAMK,QAAhDU,EAAcF,EAAvBP,QAA4BU,EAAaC,EAAAJ,EAAAK,GACjDC,EAAiDP,EAAUP,QAA1Ce,EAAWD,EAApBb,QAAyBe,EAAWJ,EAAAE,EAAAG,GACnBP,IAAmBK,IAE1CN,KAAKV,iBAAmBQ,EAAUP,QAAQC,SAAWf,GAGvD,IAAMgC,EAAmBC,KAAKC,UAAUT,KAAmBQ,KAAKC,UAAUJ,GAE1E,OADsBG,KAAKC,UAAUX,KAAKd,MAAM0B,QAAUF,KAAKC,UAAUb,EAAUc,OAC3DH,CAC1B,GAAC,CAAAb,IAAA,SAAAC,MAED,WACE,IAAQP,EAAqBU,KAArBV,iBACRuB,EAA0Bb,KAAK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QAAS,OACTC,WAAY,UAEd,2DAA4D,CAC1DC,QAAS,QAEX,yEAA0E,CACxEA,QAAS,QAEX,iFAAkF,CAChFA,QAAS,QAEX,6BAA8B,CAC5BC,gBAAiBC,EAAOC,KAAK,IAC7BN,YAAa,cACbO,aAAc,OAEhB,sCAAuC,CACrC,mBAAoB,CAClBA,aAAc,MACdC,OAAQ,OACRC,WAAY,gBACZL,gBAAiB,yBACjB,oBAAqB,CACnBA,gBAAiB,yBACjBI,OAAQ,OACRE,UAAW,wCACXC,aAAc,wCACd,kBAAmB,CACjBC,WAAY,wCACZL,aAAc,eAEhB,iBAAkB,CAChBM,YAAa,wCACbN,aAAc,gBAGlB,UAAW,CACT,wBAAyBZ,EAAME,QAAQiB,QACvC,oBAAqBT,EAAOC,KAAK,IACjCS,UAAW,mBACXC,UAAW,wCACX,oBAAqB,CACnBC,eAAgB,QAChBC,kBAAmB,QACnB,kBAAmB,CACjBC,gBAAiB,SAEnB,iBAAkB,CAChBC,iBAAkB,aAM7B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{defineProperty as e,inherits as t,createClass as r,objectSpread2 as a,classCallCheck as i,callSuper as s}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsx as n,jsxs as o}from"react/jsx-runtime";import{Component as l}from"react";import{LocalizationProvider as u}from"@mui/x-date-pickers";import{AdapterDayjs as c}from"@mui/x-date-pickers/AdapterDayjs";import{styled as d,Box as p,colors as h,TextField as f,Typography as m,Switch as g}from"@mui/material";import{getErrorMessage as C}from"./helpers.js";import{mergeObjects as v,tryParseIntRequired as y}from"../utils/helpers.js";import"../utils/dayjs-config.js";import"../utils/query-param.js";import D from"dayjs";var b="DateExpired-root",x="DateExpired-control",k="DateExpired-label",w="DateExpired-expired",O="DateExpired-labelSwitch",j="DateExpired-input",E="DateExpired-switch";function
|
|
1
|
+
import{defineProperty as e,inherits as t,createClass as r,objectSpread2 as a,classCallCheck as i,callSuper as s}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsx as n,jsxs as o}from"react/jsx-runtime";import{Component as l}from"react";import{LocalizationProvider as u}from"@mui/x-date-pickers";import{AdapterDayjs as c}from"@mui/x-date-pickers/AdapterDayjs";import{styled as d,Box as p,colors as h,TextField as f,Typography as m,Switch as g}from"@mui/material";import{getErrorMessage as C}from"./helpers.js";import{mergeObjects as v,tryParseIntRequired as y}from"../utils/helpers.js";import"../utils/dayjs-config.js";import"../utils/query-param.js";import D from"dayjs";var b="DateExpired-root",x="DateExpired-control",k="DateExpired-label",w="DateExpired-expired",O="DateExpired-labelSwitch",j="DateExpired-input",E="DateExpired-switch";function M(d){var p=function(){function p(t){var r,a;return i(this,p),a=s(this,p,[t]),e(a,"defaultNumberOfDays",30),e(a,"mapTextFieldProps",(function(){var e=a.props,t=e.messageErrors,r=e.name,i=e.onBlur,s=a.props.disabled||!a.state.switchChecked,l={fullWidth:!0,className:j,label:o("span",{className:k,children:["Expiry date",a.state.switchChecked&&n("b",{children:a.getOffsetDate(a.state.numberOfDays)})]}),variant:"outlined",type:"number",disabled:s,value:a.state.switchChecked?a.state.numberOfDays:0,onChange:a.handleChange};if(r){l.onBlur=function(){return i&&i(r)};var u,c=C(t,r);if(c.error)l.error=Boolean(c.error),l.helperText=null!==(u=c.message)&&void 0!==u?u:""}return v({},l,a.mergeConfig.textFieldProps)})),e(a,"handleChange",(function(e){var t=""!=e.target.value?parseInt(e.target.value):0;a.setState({numberOfDays:t},(function(){var e=C(a.props.messageErrors,a.props.name);t>0&&e.error&&a.mergeConfig.handleBlur()}))})),e(a,"getRootClasses",(function(){var e=[b];return a.state.numberOfDays<1&&e.push(w),e.join(" ")})),e(a,"getNumberOfDays",(function(){return"number"===a.mergeConfig.type?y(a.mergeConfig.defaulValue,a.defaultNumberOfDays):a.getDaysUntilDate(a.mergeConfig.defaulValue,a.defaultNumberOfDays)})),e(a,"getOffsetDate",(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"MMMM D, YYYY";return D().add(e,"day").format(t)})),e(a,"getDaysUntilDate",(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;try{if(!e)return t;var r=D(e),a=D(),i=r.diff(a,"day",!0);return Math.round(i)}catch(e){return t}})),a.mergeConfigCached=null!==(r=a.updateMergeConfig(t.slots))&&void 0!==r?r:{},a.state={numberOfDays:a.getNumberOfDays(),switchChecked:a.mergeConfig.switchChecked},a.id=(new Date).getTime().toString(),a}return t(p,l),r(p,[{key:"mergeConfig",get:function(){return this.mergeConfigCached}},{key:"defaultValueInput",get:function(){return"number"===this.mergeConfig.type?this.state.numberOfDays:this.getOffsetDate(this.state.numberOfDays,"YYYY-MM-DDTHH:mm:ss.sssZ")}},{key:"componentDidUpdate",value:function(e){e.slots===this.props.slots&&e.data===this.props.data||(this.mergeConfigCached=this.updateMergeConfig(this.props.slots))}},{key:"render",value:function(){var e,t=this;return n(u,{dateAdapter:c,children:o(N,{className:this.getRootClasses(),children:[n("input",{type:"text",hidden:!0,name:null===(e=this.props.name)||void 0===e?void 0:e.toString(),defaultValue:this.defaultValueInput},this.defaultValueInput),n(f,a({},this.mapTextFieldProps())),o("div",{className:x,children:[n(m,a(a({variant:"caption",className:O},{component:"label",htmlFor:this.id}),{},{sx:{color:this.state.switchChecked?"success.main":"#767676"},children:this.state.switchChecked?"Use Expiration Date":"No Expiration"})),n(g,a({id:this.id,size:"small",color:"success",checked:this.state.switchChecked,onChange:function(e,r){return t.setState({switchChecked:r})}},this.mergeConfig.switchProps))]})]})})}},{key:"updateMergeConfig",value:function(e){var t,r=null!=e?e:{},i=r.switchChecked,s=r.switchCheckedGetter,n=v(d,e),o=this.props,l=o.data,u=o.name,c=o.onBlur,p=o.defaultValue,h=null!=p?p:l&&u?null===(t=l[u])||void 0===t?void 0:t.toString():void 0,f=!!l&&(!!h||!!i);return s&&(f=s(h,l)),a(a({},n),{},{switchChecked:f,defaulValue:h,handleBlur:function(){u&&c&&c(u)}})}}])}();return p}var N=d(p)(e(e(e(e(e(e({display:"flex",alignItems:"center",gap:"10px",position:"relative"},".".concat(E),{margin:0,flex:"0 0 auto"}),".".concat(k),{b:{color:h.blue[600],marginLeft:"8px"}}),".".concat(O),{fontWeight:600,cursor:"pointer"}),".".concat(x),{position:"absolute",top:0,right:0,height:"100%",display:"flex",alignItems:"center"}),".".concat(j),{".MuiInputBase-input":{paddingRight:"160px"}}),"&.".concat(w),e({},".".concat(k),{b:{color:h.red[600]}})));export{M as default};
|
|
2
2
|
//# sourceMappingURL=create.date-expired.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.date-expired.js","sources":["../../src/form/create.date-expired.tsx"],"sourcesContent":["import React, { Component } from 'react'\r\nimport { LocalizationProvider } from '@mui/x-date-pickers'\r\nimport { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'\r\nimport { Switch, Typography, TextField, styled, Box, TextFieldProps, SwitchProps, colors } from '@mui/material'\r\nimport { IFormInputBase } from './types'\r\nimport { getErrorMessage } from './helpers'\r\nimport { dayjsCustom, mergeObjects, tryParseIntRequired } from '../utils'\r\n\r\nconst defaultFormatString = 'MM-DD-YYYY'\r\n\r\nconst dateExpiredClasses = {\r\n root: 'DateExpired-root',\r\n control: 'DateExpired-control',\r\n label: 'DateExpired-label',\r\n expired: 'DateExpired-expired',\r\n labelSwitch: 'DateExpired-labelSwitch',\r\n input: 'DateExpired-input',\r\n switch: 'DateExpired-switch'\r\n}\r\n\r\ninterface ISlots<T> {\r\n /** @default string */\r\n type?: 'number' | 'string'\r\n textFieldProps?: Partial<TextFieldProps>\r\n switchProps?: SwitchProps\r\n switchChecked?: boolean\r\n switchCheckedGetter?: (value: any, model?: Partial<T>) => boolean\r\n}\r\n\r\ninterface MergeConfig<T> extends ISlots<T> {\r\n switchChecked: boolean\r\n defaulValue?: string\r\n handleBlur: () => void\r\n}\r\n\r\ninterface IProps<T> extends IFormInputBase<T> {\r\n slots?: ISlots<T>\r\n}\r\n\r\ninterface IState {\r\n numberOfDays: number\r\n switchChecked: boolean\r\n}\r\n\r\nfunction CreateDateExpired<T>(params?: ISlots<T>): React.ComponentType<IProps<T>> {\r\n class DateExpired extends Component<IProps<T>, IState> {\r\n defaultNumberOfDays: number = 30\r\n private id\r\n private mergeConfigCached: MergeConfig<T>\r\n constructor(props: IProps<T>) {\r\n super(props)\r\n this.mergeConfigCached = this.updateMergeConfig(props.slots) ?? {}\r\n this.state = {\r\n numberOfDays: this.getNumberOfDays(),\r\n switchChecked: this.mergeConfig.switchChecked\r\n }\r\n this.id = new Date().getTime().toString()\r\n }\r\n\r\n get mergeConfig(): MergeConfig<T> {\r\n return this.mergeConfigCached\r\n }\r\n\r\n get defaultValueInput(): string | number {\r\n if (this.mergeConfig.type === 'number') {\r\n return this.state.numberOfDays\r\n } else {\r\n return this.getOffsetDate(this.state.numberOfDays, 'YYYY-MM-DDTHH:mm:ss.sssZ')\r\n }\r\n }\r\n\r\n componentDidUpdate(prevProps: IProps<T>) {\r\n if (prevProps.slots !== this.props.slots || prevProps.data !== this.props.data) {\r\n this.mergeConfigCached = this.updateMergeConfig(this.props.slots)\r\n }\r\n }\r\n\r\n //#region Render\r\n render() {\r\n return (\r\n <LocalizationProvider dateAdapter={AdapterDayjs}>\r\n <Wrap className={this.getRootClasses()}>\r\n <input key={this.defaultValueInput} type='text' hidden name={this.props.name?.toString()} defaultValue={this.defaultValueInput} />\r\n <TextField {...this.mapTextFieldProps()} />\r\n <div className={dateExpiredClasses.control}>\r\n <Typography\r\n variant='caption'\r\n className={dateExpiredClasses.labelSwitch}\r\n {...{ component: 'label', htmlFor: this.id }}\r\n sx={{ color: this.state.switchChecked ? 'success.main' : '#767676' }}\r\n >\r\n {this.state.switchChecked ? 'Use Expiration Date' : 'No Expiration'}\r\n </Typography>\r\n <Switch\r\n id={this.id}\r\n size='small'\r\n color='success'\r\n checked={this.state.switchChecked}\r\n onChange={(_, checked) => this.setState({ switchChecked: checked })}\r\n {...this.mergeConfig.switchProps}\r\n />\r\n </div>\r\n </Wrap>\r\n </LocalizationProvider>\r\n )\r\n }\r\n //#endregion\r\n\r\n mapTextFieldProps = (): TextFieldProps => {\r\n const { messageErrors, name, onBlur } = this.props\r\n const disabled = this.props.disabled || !this.state.switchChecked\r\n const obj: TextFieldProps = {\r\n fullWidth: true,\r\n className: dateExpiredClasses.input,\r\n label: (\r\n <span className={dateExpiredClasses.label}>\r\n Expiry date\r\n {this.state.switchChecked && <b>{this.getOffsetDate(this.state.numberOfDays)}</b>}\r\n </span>\r\n ),\r\n variant: 'outlined',\r\n type: 'number',\r\n disabled: disabled,\r\n value: this.state.switchChecked ? this.state.numberOfDays : 0,\r\n onChange: this.handleChange\r\n }\r\n if (!!name) {\r\n obj.onBlur = () => onBlur && onBlur(name)\r\n const temp = getErrorMessage(messageErrors, name)\r\n if (temp.error) {\r\n obj.error = Boolean(temp.error)\r\n obj.helperText = temp.message ?? ''\r\n }\r\n }\r\n return mergeObjects<TextFieldProps>({}, obj, this.mergeConfig.textFieldProps)\r\n }\r\n\r\n updateMergeConfig(currentSlots?: ISlots<T>): MergeConfig<T> {\r\n const { switchChecked, switchCheckedGetter } = currentSlots ?? {}\r\n const obj = mergeObjects(params, currentSlots)\r\n const { data, name, onBlur, defaultValue } = this.props\r\n const dValue = defaultValue ?? (!!data && !!name ? data[name]?.toString() : undefined)\r\n let check = !data ? false : !!dValue || !!switchChecked\r\n if (switchCheckedGetter) check = switchCheckedGetter(dValue, data)\r\n return {\r\n ...obj,\r\n switchChecked: check,\r\n defaulValue: dValue,\r\n handleBlur: () => {\r\n if (!name || !onBlur) return\r\n onBlur(name)\r\n }\r\n }\r\n }\r\n\r\n handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\r\n const numberOfDays: number = e.target.value != '' ? parseInt(e.target.value) : 0\r\n this.setState({ numberOfDays }, () => {\r\n const err = getErrorMessage(this.props.messageErrors, this.props.name)\r\n if (numberOfDays > 0 && err.error) this.mergeConfig.handleBlur()\r\n })\r\n }\r\n\r\n getRootClasses = () => {\r\n const classes = [dateExpiredClasses.root]\r\n if (this.state.numberOfDays < 1) classes.push(dateExpiredClasses.expired)\r\n return classes.join(' ')\r\n }\r\n\r\n getNumberOfDays = (): number => {\r\n if (this.mergeConfig.type === 'number') {\r\n return tryParseIntRequired(this.mergeConfig.defaulValue, this.defaultNumberOfDays)\r\n } else {\r\n return this.getDaysUntilDate(this.mergeConfig.defaulValue, this.defaultNumberOfDays)\r\n }\r\n }\r\n\r\n getOffsetDate = (num: number, formatString = defaultFormatString): string => {\r\n return dayjsCustom().add(num, 'day').format(formatString)\r\n }\r\n\r\n getDaysUntilDate = (value?: string, defaultValue = 0): number => {\r\n try {\r\n if (!value) return defaultValue\r\n const target = dayjsCustom(value)\r\n const today = dayjsCustom()\r\n const diff = target.diff(today, 'day', true)\r\n return Math.round(diff)\r\n } catch {\r\n return defaultValue\r\n }\r\n }\r\n }\r\n return DateExpired\r\n}\r\nexport default CreateDateExpired\r\n\r\nconst Wrap = styled(Box)({\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '10px',\r\n position: 'relative',\r\n [`.${dateExpiredClasses.switch}`]: {\r\n margin: 0,\r\n flex: '0 0 auto'\r\n },\r\n [`.${dateExpiredClasses.label}`]: {\r\n b: {\r\n color: colors.blue[600],\r\n marginLeft: '8px'\r\n }\r\n },\r\n [`.${dateExpiredClasses.labelSwitch}`]: {\r\n fontWeight: 600,\r\n cursor: 'pointer'\r\n },\r\n [`.${dateExpiredClasses.control}`]: {\r\n position: 'absolute',\r\n top: 0,\r\n right: 0,\r\n height: '100%',\r\n display: 'flex',\r\n alignItems: 'center'\r\n },\r\n [`.${dateExpiredClasses.input}`]: {\r\n '.MuiInputBase-input': {\r\n paddingRight: '160px'\r\n }\r\n },\r\n [`&.${dateExpiredClasses.expired}`]: {\r\n [`.${dateExpiredClasses.label}`]: {\r\n b: {\r\n color: colors.red[600]\r\n }\r\n }\r\n }\r\n})\r\n"],"names":["dateExpiredClasses","CreateDateExpired","params","DateExpired","props","_this$updateMergeConf","_this","_classCallCheck","_callSuper","_defineProperty","_this$props","messageErrors","name","onBlur","disabled","state","switchChecked","obj","fullWidth","className","label","_jsxs","children","_jsx","getOffsetDate","numberOfDays","variant","type","value","onChange","handleChange","_temp$message","temp","getErrorMessage","error","Boolean","helperText","message","mergeObjects","mergeConfig","textFieldProps","e","target","parseInt","setState","err","handleBlur","classes","push","join","tryParseIntRequired","defaulValue","defaultNumberOfDays","getDaysUntilDate","num","formatString","arguments","length","undefined","dayjsCustom","add","format","defaultValue","today","diff","Math","round","_unused","mergeConfigCached","updateMergeConfig","slots","getNumberOfDays","id","Date","getTime","toString","_inherits","Component","_createClass","key","get","this","prevProps","data","_this$props$name","_this2","LocalizationProvider","dateAdapter","AdapterDayjs","Wrap","getRootClasses","hidden","defaultValueInput","TextField","_objectSpread","mapTextFieldProps","Typography","component","htmlFor","sx","color","Switch","size","checked","_","switchProps","currentSlots","_data$name","_ref","switchCheckedGetter","_this$props2","dValue","check","styled","Box","display","alignItems","gap","position","concat","margin","flex","b","colors","blue","marginLeft","fontWeight","cursor","top","right","height","paddingRight","red"],"mappings":"sqBAQA,IAEMA,EACE,mBADFA,EAEK,sBAFLA,EAGG,oBAHHA,EAIK,sBAJLA,EAKS,0BALTA,EAMG,oBANHA,EAOI,qBA2BV,SAASC,EAAqBC,GAAkB,IACxCC,aAIJ,SAAAA,EAAYC,GAAgB,IAAAC,EAAAC,EAOe,OAPfC,OAAAJ,GAC1BG,EAAAE,EAAAL,KAAAA,GAAMC,IAAMK,EAAAH,EAAA,sBAJgB,IA4D9BG,EAAAH,EAAA,qBAEoB,WAClB,IAAAI,EAAwCJ,EAAKF,MAArCO,EAAaD,EAAbC,cAAeC,EAAIF,EAAJE,KAAMC,EAAMH,EAANG,OACvBC,EAAWR,EAAKF,MAAMU,WAAaR,EAAKS,MAAMC,cAC9CC,EAAsB,CAC1BC,WAAW,EACXC,UAAWnB,EACXoB,MACEC,EAAM,OAAA,CAAAF,UAAWnB,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5B,IAC7DW,EAAAA,EAAA,CAAA,EACK7E,GAAG,CAAA,EAAA,CACND,cAAegG,EACf7D,YAAa4D,EACbjE,WAAY,WACLlC,GAASC,GACdA,EAAOD,EACT,GAEJ,IAAC,IAwCH,OAAOT,CACT,CAGA,IAAMsF,EAAOwB,EAAOC,EAAPD,CAAWxG,EAAAA,EAAAA,EAAAA,EAAAA,EAAAA,EAAA,CACtB0G,QAAS,OACTC,WAAY,SACZC,IAAK,OACLC,SAAU,YAAU,IAAAC,OACfvH,GAA8B,CACjCwH,OAAQ,EACRC,KAAM,iBACPF,OACIvH,GAA6B,CAChC0H,EAAG,CACDtB,MAAOuB,EAAOC,KAAK,KACnBC,WAAY,aAEfN,OACIvH,GAAmC,CACtC8H,WAAY,IACZC,OAAQ,gBACTR,OACIvH,GAA+B,CAClCsH,SAAU,WACVU,IAAK,EACLC,MAAO,EACPC,OAAQ,OACRf,QAAS,OACTC,WAAY,eACbG,OACIvH,GAA6B,CAChC,sBAAuB,CACrBmI,aAAc,WAEjBZ,KAAAA,OACKvH,GAA0BS,EAAA,CAAA,EAAA,IAAA8G,OACzBvH,GAA6B,CAChC0H,EAAG,CACDtB,MAAOuB,EAAOS,IAAI"}
|
|
1
|
+
{"version":3,"file":"create.date-expired.js","sources":["../../src/form/create.date-expired.tsx"],"sourcesContent":["import React, { Component } from 'react'\r\nimport { LocalizationProvider } from '@mui/x-date-pickers'\r\nimport { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'\r\nimport { Switch, Typography, TextField, styled, Box, TextFieldProps, SwitchProps, colors } from '@mui/material'\r\nimport { IFormInputBase } from './types'\r\nimport { getErrorMessage } from './helpers'\r\nimport { dayjsCustom, mergeObjects, tryParseIntRequired } from '../utils'\r\n\r\nconst defaultFormatString = 'MMMM D, YYYY'\r\n\r\nconst dateExpiredClasses = {\r\n root: 'DateExpired-root',\r\n control: 'DateExpired-control',\r\n label: 'DateExpired-label',\r\n expired: 'DateExpired-expired',\r\n labelSwitch: 'DateExpired-labelSwitch',\r\n input: 'DateExpired-input',\r\n switch: 'DateExpired-switch'\r\n}\r\n\r\ninterface ISlots<T> {\r\n /** @default string */\r\n type?: 'number' | 'string'\r\n textFieldProps?: Partial<TextFieldProps>\r\n switchProps?: SwitchProps\r\n switchChecked?: boolean\r\n switchCheckedGetter?: (value: any, model?: Partial<T>) => boolean\r\n}\r\n\r\ninterface MergeConfig<T> extends ISlots<T> {\r\n switchChecked: boolean\r\n defaulValue?: string\r\n handleBlur: () => void\r\n}\r\n\r\ninterface IProps<T> extends IFormInputBase<T> {\r\n slots?: ISlots<T>\r\n}\r\n\r\ninterface IState {\r\n numberOfDays: number\r\n switchChecked: boolean\r\n}\r\n\r\nfunction CreateDateExpired<T>(params?: ISlots<T>): React.ComponentType<IProps<T>> {\r\n class DateExpired extends Component<IProps<T>, IState> {\r\n defaultNumberOfDays: number = 30\r\n private id\r\n private mergeConfigCached: MergeConfig<T>\r\n constructor(props: IProps<T>) {\r\n super(props)\r\n this.mergeConfigCached = this.updateMergeConfig(props.slots) ?? {}\r\n this.state = {\r\n numberOfDays: this.getNumberOfDays(),\r\n switchChecked: this.mergeConfig.switchChecked\r\n }\r\n this.id = new Date().getTime().toString()\r\n }\r\n\r\n get mergeConfig(): MergeConfig<T> {\r\n return this.mergeConfigCached\r\n }\r\n\r\n get defaultValueInput(): string | number {\r\n if (this.mergeConfig.type === 'number') {\r\n return this.state.numberOfDays\r\n } else {\r\n return this.getOffsetDate(this.state.numberOfDays, 'YYYY-MM-DDTHH:mm:ss.sssZ')\r\n }\r\n }\r\n\r\n componentDidUpdate(prevProps: IProps<T>) {\r\n if (prevProps.slots !== this.props.slots || prevProps.data !== this.props.data) {\r\n this.mergeConfigCached = this.updateMergeConfig(this.props.slots)\r\n }\r\n }\r\n\r\n //#region Render\r\n render() {\r\n return (\r\n <LocalizationProvider dateAdapter={AdapterDayjs}>\r\n <Wrap className={this.getRootClasses()}>\r\n <input key={this.defaultValueInput} type='text' hidden name={this.props.name?.toString()} defaultValue={this.defaultValueInput} />\r\n <TextField {...this.mapTextFieldProps()} />\r\n <div className={dateExpiredClasses.control}>\r\n <Typography\r\n variant='caption'\r\n className={dateExpiredClasses.labelSwitch}\r\n {...{ component: 'label', htmlFor: this.id }}\r\n sx={{ color: this.state.switchChecked ? 'success.main' : '#767676' }}\r\n >\r\n {this.state.switchChecked ? 'Use Expiration Date' : 'No Expiration'}\r\n </Typography>\r\n <Switch\r\n id={this.id}\r\n size='small'\r\n color='success'\r\n checked={this.state.switchChecked}\r\n onChange={(_, checked) => this.setState({ switchChecked: checked })}\r\n {...this.mergeConfig.switchProps}\r\n />\r\n </div>\r\n </Wrap>\r\n </LocalizationProvider>\r\n )\r\n }\r\n //#endregion\r\n\r\n mapTextFieldProps = (): TextFieldProps => {\r\n const { messageErrors, name, onBlur } = this.props\r\n const disabled = this.props.disabled || !this.state.switchChecked\r\n const obj: TextFieldProps = {\r\n fullWidth: true,\r\n className: dateExpiredClasses.input,\r\n label: (\r\n <span className={dateExpiredClasses.label}>\r\n Expiry date\r\n {this.state.switchChecked && <b>{this.getOffsetDate(this.state.numberOfDays)}</b>}\r\n </span>\r\n ),\r\n variant: 'outlined',\r\n type: 'number',\r\n disabled: disabled,\r\n value: this.state.switchChecked ? this.state.numberOfDays : 0,\r\n onChange: this.handleChange\r\n }\r\n if (!!name) {\r\n obj.onBlur = () => onBlur && onBlur(name)\r\n const temp = getErrorMessage(messageErrors, name)\r\n if (temp.error) {\r\n obj.error = Boolean(temp.error)\r\n obj.helperText = temp.message ?? ''\r\n }\r\n }\r\n return mergeObjects<TextFieldProps>({}, obj, this.mergeConfig.textFieldProps)\r\n }\r\n\r\n updateMergeConfig(currentSlots?: ISlots<T>): MergeConfig<T> {\r\n const { switchChecked, switchCheckedGetter } = currentSlots ?? {}\r\n const obj = mergeObjects(params, currentSlots)\r\n const { data, name, onBlur, defaultValue } = this.props\r\n const dValue = defaultValue ?? (!!data && !!name ? data[name]?.toString() : undefined)\r\n let check = !data ? false : !!dValue || !!switchChecked\r\n if (switchCheckedGetter) check = switchCheckedGetter(dValue, data)\r\n return {\r\n ...obj,\r\n switchChecked: check,\r\n defaulValue: dValue,\r\n handleBlur: () => {\r\n if (!name || !onBlur) return\r\n onBlur(name)\r\n }\r\n }\r\n }\r\n\r\n handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {\r\n const numberOfDays: number = e.target.value != '' ? parseInt(e.target.value) : 0\r\n this.setState({ numberOfDays }, () => {\r\n const err = getErrorMessage(this.props.messageErrors, this.props.name)\r\n if (numberOfDays > 0 && err.error) this.mergeConfig.handleBlur()\r\n })\r\n }\r\n\r\n getRootClasses = () => {\r\n const classes = [dateExpiredClasses.root]\r\n if (this.state.numberOfDays < 1) classes.push(dateExpiredClasses.expired)\r\n return classes.join(' ')\r\n }\r\n\r\n getNumberOfDays = (): number => {\r\n if (this.mergeConfig.type === 'number') {\r\n return tryParseIntRequired(this.mergeConfig.defaulValue, this.defaultNumberOfDays)\r\n } else {\r\n return this.getDaysUntilDate(this.mergeConfig.defaulValue, this.defaultNumberOfDays)\r\n }\r\n }\r\n\r\n getOffsetDate = (num: number, formatString = defaultFormatString): string => {\r\n return dayjsCustom().add(num, 'day').format(formatString)\r\n }\r\n\r\n getDaysUntilDate = (value?: string, defaultValue = 0): number => {\r\n try {\r\n if (!value) return defaultValue\r\n const target = dayjsCustom(value)\r\n const today = dayjsCustom()\r\n const diff = target.diff(today, 'day', true)\r\n return Math.round(diff)\r\n } catch {\r\n return defaultValue\r\n }\r\n }\r\n }\r\n return DateExpired\r\n}\r\nexport default CreateDateExpired\r\n\r\nconst Wrap = styled(Box)({\r\n display: 'flex',\r\n alignItems: 'center',\r\n gap: '10px',\r\n position: 'relative',\r\n [`.${dateExpiredClasses.switch}`]: {\r\n margin: 0,\r\n flex: '0 0 auto'\r\n },\r\n [`.${dateExpiredClasses.label}`]: {\r\n b: {\r\n color: colors.blue[600],\r\n marginLeft: '8px'\r\n }\r\n },\r\n [`.${dateExpiredClasses.labelSwitch}`]: {\r\n fontWeight: 600,\r\n cursor: 'pointer'\r\n },\r\n [`.${dateExpiredClasses.control}`]: {\r\n position: 'absolute',\r\n top: 0,\r\n right: 0,\r\n height: '100%',\r\n display: 'flex',\r\n alignItems: 'center'\r\n },\r\n [`.${dateExpiredClasses.input}`]: {\r\n '.MuiInputBase-input': {\r\n paddingRight: '160px'\r\n }\r\n },\r\n [`&.${dateExpiredClasses.expired}`]: {\r\n [`.${dateExpiredClasses.label}`]: {\r\n b: {\r\n color: colors.red[600]\r\n }\r\n }\r\n }\r\n})\r\n"],"names":["dateExpiredClasses","CreateDateExpired","params","DateExpired","props","_this$updateMergeConf","_this","_classCallCheck","_callSuper","_defineProperty","_this$props","messageErrors","name","onBlur","disabled","state","switchChecked","obj","fullWidth","className","label","_jsxs","children","_jsx","getOffsetDate","numberOfDays","variant","type","value","onChange","handleChange","_temp$message","temp","getErrorMessage","error","Boolean","helperText","message","mergeObjects","mergeConfig","textFieldProps","e","target","parseInt","setState","err","handleBlur","classes","push","join","tryParseIntRequired","defaulValue","defaultNumberOfDays","getDaysUntilDate","num","formatString","arguments","length","undefined","dayjsCustom","add","format","defaultValue","today","diff","Math","round","_unused","mergeConfigCached","updateMergeConfig","slots","getNumberOfDays","id","Date","getTime","toString","_inherits","Component","_createClass","key","get","this","prevProps","data","_this$props$name","_this2","LocalizationProvider","dateAdapter","AdapterDayjs","Wrap","getRootClasses","hidden","defaultValueInput","TextField","_objectSpread","mapTextFieldProps","Typography","component","htmlFor","sx","color","Switch","size","checked","_","switchProps","currentSlots","_data$name","_ref","switchCheckedGetter","_this$props2","dValue","check","styled","Box","display","alignItems","gap","position","concat","margin","flex","b","colors","blue","marginLeft","fontWeight","cursor","top","right","height","paddingRight","red"],"mappings":"sqBAQA,IAEMA,EACE,mBADFA,EAEK,sBAFLA,EAGG,oBAHHA,EAIK,sBAJLA,EAKS,0BALTA,EAMG,oBANHA,EAOI,qBA2BV,SAASC,E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CallCheck as t,callSuper as o,defineProperty as i,asyncToGenerator as a,regenerator as l}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsx as s,jsxs as u}from"react/jsx-runtime";import{Component as p}from"react";import{styled as d,Typography as g,Box as f,TextField as m}from"@mui/material";import c from"@mui/icons-material/Download";import{getErrorMessage as h}from"./helpers.js";import{tryParseCsvFileToArray as v}from"../utils/helpers.js";import"../utils/dayjs-config.js";import"../utils/query-param.js";function C(d){var C=function(){function C(r){var n;return t(this,C),n=o(this,C,[r]),i(n,"mergeConfigsCache",{name:"",onBlur:function(){},messageErrors:{}}),i(n,"refInput",null),i(n,"refTextFiled",null),i(n,"getTextFieldProps",(function(){var r=n.props.label,t=h(n.mergeConfigs.messageErrors,n.mergeConfigs.name);return e({label:r,error:t.error,helperText:t.message,type:"file",variant:"outlined",fullWidth:!0,onChange:n.handleChange,inputProps:{accept:"text/csv"},InputLabelProps:{shrink:n.mergeConfigs.labelShrink}},n.mergeConfigs.textFieldProps)})),i(n,"upgradeMergeConfigs",(function(e){var r,n,t,o,i,a,l,s,u=e.name,p=e.label,g=e.onBlur,f=e.messageErrors;return{textFieldProps:Object.assign({},null==d?void 0:d.textFieldProps,null===(r=e.slots)||void 0===r?void 0:r.textFieldProps),wrapProps:Object.assign({},null==d?void 0:d.wrapProps,null===(n=e.slots)||void 0===n?void 0:n.wrapProps),name:u,onBlur:g||function(){},messageErrors:f||{},downloadSampleUrl:null!==(t=null===(o=e.slots)||void 0===o?void 0:o.downloadSampleUrl)&&void 0!==t?t:null==d?void 0:d.downloadSampleUrl,instructionalText:null!==(i=null===(a=e.slots)||void 0===a?void 0:a.instructionalText)&&void 0!==i?i:null==d?void 0:d.instructionalText,labelShrink:!1!==(null!==(l=null===(s=e.slots)||void 0===s?void 0:s.labelShrink)&&void 0!==l?l:null==d?void 0:d.labelShrink)&&!!p}})),i(n,"handleChange",function(){var e=a(l().m((function e(r){var t,o,i,a;return l().w((function(e){for(;;)switch(e.n){case 0:if(o=null===(t=r.target.files)||void 0===t?void 0:t[0]){e.n=1;break}return e.a(2);case 1:return e.p=1,e.n=2,v(o);case 2:i=e.v,n.refInput&&(n.refInput.value=JSON.stringify(i)),n.setState({parsedData:i},(function(){n.props.onChange&&n.props.onChange(i),n.mergeConfigs.onBlur(n.mergeConfigs.name)})),e.n=4;break;case 3:e.p=3,a=e.v,console.error("Error parsing CSV:",a),n.mergeConfigs.onBlur(n.mergeConfigs.name);case 4:return e.a(2)}}),e,null,[[1,3]])})));return function(r){return e.apply(this,arguments)}}()),n.mergeConfigsCache=n.upgradeMergeConfigs(r),n.state={parsedData:[]},n}return r(C,p),n(C,[{key:"mergeConfigs",get:function(){return this.mergeConfigsCache}},{key:"inputValue",get:function(){return this.state.parsedData.length>0?JSON.stringify(this.state.parsedData):""}},{key:"shouldComponentUpdate",value:function(e){return e!==this.props&&(this.mergeConfigsCache=this.upgradeMergeConfigs(e)),!0}},{key:"render",value:function(){var r,n,t=this;return u(f,e(e({},this.mergeConfigs.wrapProps),{},{children:[this.mergeConfigs.downloadSampleUrl&&u(f,{sx:{display:"flex",alignItems:"center",mb:"10px"},children:[s(g,{variant:"subtitle2",component:"span",children:null!==(r=this.mergeConfigs.instructionalText)&&void 0!==r?r:"Metadata file, please fill out the form we provide."}),u(x,{href:this.mergeConfigs.downloadSampleUrl,children:[s("span",{children:" Download sample"}),s(c,{fontSize:"small"})]})]}),s("input",{hidden:!0,name:null===(n=this.props.name)||void 0===n?void 0:n.toString(),type:"text",ref:function(e){return t.refInput=e},defaultValue:""}),s(m,e(e({},this.getTextFieldProps()),{},{inputRef:function(e){return t.refTextFiled=e}}))]}))}}])}();return C}var x=d((function(r){return s(g,e({variant:"subtitle2",component:"a",target:"_blank",download:!0},r))}))((function(e){var r=e.theme;return{display:"flex",alignItems:"center",color:r.palette.primary.light,cursor:"pointer",fontWeight:600,marginLeft:"6px",gap:"4px","&:hover":{textDecoration:"underline",color:r.palette.primary.dark}}}));export{C as createInputFileCsvLocalParser};
|
|
1
|
+
import{objectSpread2 as e,inherits as r,createClass as n,classCallCheck as t,callSuper as o,defineProperty as i,asyncToGenerator as a,regenerator as l}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsx as s,jsxs as u}from"react/jsx-runtime";import{Component as p}from"react";import{styled as d,Typography as g,Box as f,TextField as m}from"@mui/material";import c from"@mui/icons-material/Download";import{getErrorMessage as h}from"./helpers.js";import{tryParseCsvFileToArray as v}from"../utils/helpers.js";import"../utils/dayjs-config.js";import"../utils/query-param.js";function C(d){var C=function(){function C(r){var n;return t(this,C),n=o(this,C,[r]),i(n,"mergeConfigsCache",{name:"",onBlur:function(){},messageErrors:{}}),i(n,"refInput",null),i(n,"refTextFiled",null),i(n,"getTextFieldProps",(function(){var r=n.props.label,t=h(n.mergeConfigs.messageErrors,n.mergeConfigs.name);return e({label:r,error:t.error,helperText:t.message,type:"file",variant:"outlined",fullWidth:!0,onChange:n.handleChange,inputProps:{accept:"text/csv"},InputLabelProps:{shrink:n.mergeConfigs.labelShrink}},n.mergeConfigs.textFieldProps)})),i(n,"upgradeMergeConfigs",(function(e){var r,n,t,o,i,a,l,s,u=e.name,p=e.label,g=e.onBlur,f=e.messageErrors;return{textFieldProps:Object.assign({},null==d?void 0:d.textFieldProps,null===(r=e.slots)||void 0===r?void 0:r.textFieldProps),wrapProps:Object.assign({},null==d?void 0:d.wrapProps,null===(n=e.slots)||void 0===n?void 0:n.wrapProps),name:u,onBlur:g||function(){},messageErrors:f||{},downloadSampleUrl:null!==(t=null===(o=e.slots)||void 0===o?void 0:o.downloadSampleUrl)&&void 0!==t?t:null==d?void 0:d.downloadSampleUrl,instructionalText:null!==(i=null===(a=e.slots)||void 0===a?void 0:a.instructionalText)&&void 0!==i?i:null==d?void 0:d.instructionalText,labelShrink:!1!==(null!==(l=null===(s=e.slots)||void 0===s?void 0:s.labelShrink)&&void 0!==l?l:null==d?void 0:d.labelShrink)&&!!p}})),i(n,"handleChange",function(){var e=a(l().m((function e(r){var t,o,i,a;return l().w((function(e){for(;;)switch(e.n){case 0:if(o=null===(t=r.target.files)||void 0===t?void 0:t[0]){e.n=1;break}return e.a(2);case 1:return e.p=1,e.n=2,v(o);case 2:i=e.v,n.refInput&&(n.refInput.value=JSON.stringify(i)),n.setState({parsedData:i},(function(){n.props.onChange&&n.props.onChange(i),n.mergeConfigs.onBlur(n.mergeConfigs.name)})),e.n=4;break;case 3:e.p=3,a=e.v,console.error("Error parsing CSV:",a),n.mergeConfigs.onBlur(n.mergeConfigs.name);case 4:return e.a(2)}}),e,null,[[1,3]])})));return function(r){return e.apply(this,arguments)}}()),n.mergeConfigsCache=n.upgradeMergeConfigs(r),n.state={parsedData:[]},n}return r(C,p),n(C,[{key:"mergeConfigs",get:function(){return this.mergeConfigsCache}},{key:"inputValue",get:function(){return this.state.parsedData.length>0?JSON.stringify(this.state.parsedData):""}},{key:"shouldComponentUpdate",value:function(e){return e!==this.props&&(this.mergeConfigsCache=this.upgradeMergeConfigs(e)),!0}},{key:"render",value:function(){var r,n,t=this;return u(f,e(e({},this.mergeConfigs.wrapProps),{},{children:[this.mergeConfigs.downloadSampleUrl&&u(f,{sx:{display:"flex",alignItems:"center",mb:"10px"},children:[s(g,{variant:"subtitle2",component:"span",children:null!==(r=this.mergeConfigs.instructionalText)&&void 0!==r?r:"Metadata file, please fill out the form we provide."}),u(x,{href:this.mergeConfigs.downloadSampleUrl,children:[s("span",{children:" Download sample"}),s(c,{fontSize:"small"})]})]}),s("input",{hidden:!0,name:null===(n=this.props.name)||void 0===n?void 0:n.toString(),type:"text",ref:function(e){return t.refInput=e},defaultValue:""}),s(m,e(e({},this.getTextFieldProps()),{},{inputRef:function(e){return t.refTextFiled=e}}))]}))}}])}();return C}var x=d((function(r){return s(g,e({variant:"subtitle2",component:"a",target:"_blank",download:!0},r))}))((function(e){var r=e.theme;return{display:"flex",alignItems:"center",color:r.palette.primary.light,cursor:"pointer",fontWeight:600,marginLeft:"6px",gap:"4px",transition:"all 0.3s ease","&:hover":{textDecoration:"underline",color:r.palette.primary.dark}}}));export{C as createInputFileCsvLocalParser};
|
|
2
2
|
//# sourceMappingURL=create.input-file.csv-local-parser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.input-file.csv-local-parser.js","sources":["../../src/form/create.input-file.csv-local-parser.tsx"],"sourcesContent":["import React, { Component, ComponentType } from 'react'\r\nimport { Box, BoxProps, styled, TextField, TextFieldProps, Typography, TypographyProps } from '@mui/material'\r\nimport DownloadIcon from '@mui/icons-material/Download'\r\nimport { getErrorMessage } from './helpers'\r\nimport { tryParseCsvFileToArray } from '../utils'\r\nimport { IFormBase, IFormInputBase } from './types'\r\n\r\nexport interface IInputFileCsvLocalParserSlots {\r\n /**\r\n * The URL of the sample CSV file that users can download.\r\n * If provided, a \"Download sample\" link will be displayed.\r\n * Example: '/sample.csv' or 'https://example.com/sample.csv'\r\n */\r\n downloadSampleUrl?: string\r\n /**\r\n * Instructional text displayed alongside the download link or file input.\r\n * Useful for guiding users on how to use or fill out the CSV file.\r\n */\r\n instructionalText?: string\r\n /**\r\n * Props to customize the TextField used for uploading the CSV file.\r\n * Allows customization of appearance and behavior (e.g., placeholder, onChange, disabled).\r\n */\r\n textFieldProps?: TextFieldProps\r\n /**\r\n * Props passed to the wrapper element (typically a Box).\r\n * Useful for customizing layout styles such as margin, padding, or display.\r\n */\r\n wrapProps?: BoxProps\r\n /**\r\n * Whether the label should shrink when displayed.\r\n * Defaults to `true` if a label is present to prevent overlap.\r\n * @default true\r\n */\r\n labelShrink?: boolean\r\n}\r\n\r\nexport interface IInputFileCsvLocalParserParams extends IInputFileCsvLocalParserSlots {}\r\n\r\nexport interface IInputFileCsvLocalParserProps<T, C> extends IFormInputBase<T, IInputFileCsvLocalParserSlots> {\r\n onChange?: (value: C[]) => void\r\n}\r\n\r\nexport interface IInputFileCsvLocalParserState<C> {\r\n parsedData: C[]\r\n}\r\n\r\ntype IPickConfigs<T> = Required<Pick<IFormBase<T>, 'onBlur' | 'messageErrors'>>\r\n\r\ninterface IMergeConfigs<T> extends IPickConfigs<T>, IInputFileCsvLocalParserSlots {\r\n name: keyof T\r\n}\r\n\r\n/**\r\n * Creates a React component that renders a file input specifically for CSV files,\r\n * parses the selected file locally into a structured array, and integrates with a form system.\r\n *\r\n * @template T - The main data model used in the form. Represents the shape of the overall form data.\r\n * @template C - The type of each individual item parsed from the CSV file.\r\n *\r\n * @param params - Optional slot parameters to customize the appearance or behavior of the text field.\r\n * @returns A React component configured for uploading and parsing local CSV files.\r\n */\r\nexport function createInputFileCsvLocalParser<T, C>(params?: IInputFileCsvLocalParserParams): ComponentType<IInputFileCsvLocalParserProps<T, C>> {\r\n class InputFileCsvLocalParser extends Component<IInputFileCsvLocalParserProps<T, C>, IInputFileCsvLocalParserState<C>> {\r\n private mergeConfigsCache: IMergeConfigs<T> = { name: '' as keyof T, onBlur: () => {}, messageErrors: {} }\r\n constructor(props: IInputFileCsvLocalParserProps<T, C>) {\r\n super(props)\r\n this.mergeConfigsCache = this.upgradeMergeConfigs(props)\r\n this.state = { parsedData: [] }\r\n }\r\n\r\n get mergeConfigs(): IMergeConfigs<T> {\r\n return this.mergeConfigsCache\r\n }\r\n\r\n get inputValue() {\r\n return this.state.parsedData.length > 0 ? JSON.stringify(this.state.parsedData) : ''\r\n }\r\n\r\n shouldComponentUpdate(nextProps: Readonly<IInputFileCsvLocalParserProps<T, C>>): boolean {\r\n if (nextProps !== this.props) this.mergeConfigsCache = this.upgradeMergeConfigs(nextProps)\r\n return true\r\n }\r\n\r\n refInput: HTMLInputElement | null = null\r\n refTextFiled: HTMLInputElement | null = null\r\n render() {\r\n return (\r\n <Box {...this.mergeConfigs.wrapProps}>\r\n {this.mergeConfigs.downloadSampleUrl && (\r\n <Box sx={{ display: 'flex', alignItems: 'center', mb: '10px' }}>\r\n <Typography variant='subtitle2' component='span'>\r\n {this.mergeConfigs.instructionalText ?? 'Metadata file, please fill out the form we provide.'}\r\n </Typography>\r\n <DownloadButton href={this.mergeConfigs.downloadSampleUrl}>\r\n <span> Download sample</span>\r\n <DownloadIcon fontSize='small' />\r\n </DownloadButton>\r\n </Box>\r\n )}\r\n <input hidden name={this.props.name?.toString()} type='text' ref={(ref) => (this.refInput = ref)} defaultValue='' />\r\n <TextField {...this.getTextFieldProps()} inputRef={(ref) => (this.refTextFiled = ref)} />\r\n </Box>\r\n )\r\n }\r\n\r\n getTextFieldProps = (): TextFieldProps => {\r\n const { label } = this.props\r\n const eMessage = getErrorMessage(this.mergeConfigs.messageErrors, this.mergeConfigs.name)\r\n const mergedProps: TextFieldProps = {\r\n label,\r\n error: eMessage.error,\r\n helperText: eMessage.message,\r\n type: 'file',\r\n variant: 'outlined',\r\n fullWidth: true,\r\n onChange: this.handleChange,\r\n inputProps: { accept: 'text/csv' },\r\n InputLabelProps: { shrink: this.mergeConfigs.labelShrink },\r\n ...this.mergeConfigs.textFieldProps\r\n }\r\n return mergedProps\r\n }\r\n\r\n upgradeMergeConfigs = (currentProps: IInputFileCsvLocalParserProps<T, C>): IMergeConfigs<T> => {\r\n const { name, label, onBlur, messageErrors } = currentProps\r\n return {\r\n textFieldProps: Object.assign({}, params?.textFieldProps, currentProps.slots?.textFieldProps),\r\n wrapProps: Object.assign({}, params?.wrapProps, currentProps.slots?.wrapProps),\r\n name: name as keyof T,\r\n onBlur: onBlur || (() => {}),\r\n messageErrors: messageErrors || {},\r\n downloadSampleUrl: currentProps.slots?.downloadSampleUrl ?? params?.downloadSampleUrl,\r\n instructionalText: currentProps.slots?.instructionalText ?? params?.instructionalText,\r\n labelShrink: (currentProps.slots?.labelShrink ?? params?.labelShrink) !== false && !!label\r\n }\r\n }\r\n\r\n handleChange = async (e: React.ChangeEvent<HTMLInputElement>) => {\r\n const file = e.target.files?.[0]\r\n if (!file) return\r\n try {\r\n const result = await tryParseCsvFileToArray(file)\r\n if (this.refInput) this.refInput.value = JSON.stringify(result)\r\n this.setState({ parsedData: result as C[] }, () => {\r\n this.props.onChange && this.props.onChange(result as C[])\r\n this.mergeConfigs.onBlur(this.mergeConfigs.name)\r\n })\r\n } catch (err) {\r\n console.error('Error parsing CSV:', err)\r\n this.mergeConfigs.onBlur(this.mergeConfigs.name)\r\n }\r\n }\r\n }\r\n return InputFileCsvLocalParser\r\n}\r\n\r\nconst DownloadButton = styled((p: TypographyProps & { href: string }) => (\r\n <Typography variant='subtitle2' component='a' target='_blank' download {...p} />\r\n))(({ theme }) => ({\r\n display: 'flex',\r\n alignItems: 'center',\r\n color: theme.palette.primary.light,\r\n cursor: 'pointer',\r\n fontWeight: 600,\r\n marginLeft: '6px',\r\n gap: '4px',\r\n '&:hover': {\r\n textDecoration: 'underline',\r\n color: theme.palette.primary.dark\r\n }\r\n}))\r\n"],"names":["createInputFileCsvLocalParser","params","InputFileCsvLocalParser","props","_this","_classCallCheck","_callSuper","_defineProperty","name","onBlur","messageErrors","label","eMessage","getErrorMessage","mergeConfigs","_objectSpread","error","helperText","message","type","variant","fullWidth","onChange","handleChange","inputProps","accept","InputLabelProps","shrink","labelShrink","textFieldProps","currentProps","_currentProps$slots","_currentProps$slots2","_currentProps$slots$d","_currentProps$slots3","_currentProps$slots$i","_currentProps$slots4","_currentProps$slots$l","_currentProps$slots5","Object","assign","slots","wrapProps","downloadSampleUrl","instructionalText","_ref","_asyncToGenerator","_regenerator","m","_callee","e","_e$target$files","file","result","_t","w","_context","n","target","files","a","p","tryParseCsvFileToArray","v","refInput","value","JSON","stringify","setState","parsedData","console","_x","apply","this","arguments","mergeConfigsCache","upgradeMergeConfigs","state","_inherits","Component","_createClass","key","get","length","nextProps","_this$mergeConfigs$in","_this$props$name","_this2","_jsxs","Box","children","sx","display","alignItems","mb","_jsx","Typography","component","DownloadButton","href","DownloadIcon","fontSize","hidden","toString","ref","defaultValue","TextField","getTextFieldProps","inputRef","refTextFiled","styled","download","_ref3","theme","color","palette","primary","light","cursor","fontWeight","marginLeft","gap","textDecoration","dark"],"mappings":"kkBA+DM,SAAUA,EAAoCC,GAAuC,IACnFC,aAEJ,S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,KAAK,OAAOqF,IAAK,SAACA,GAAG,OAAMjB,EAAKvB,SAAWwC,CAAI,EAAEC,aAAa,KAC/GV,EAACW,EAAS3F,EAAAA,EAAK,CAAA,EAAA0D,KAAKkC,qBAAmB,GAAA,CAAEC,SAAU,SAACJ,GAAG,OAAMjB,EAAKsB,aAAeL,CAAG,QAG1F,IAAC,IAkDH,OAAOtG,CACT,CAEA,IAAMgG,EAAiBY,GAAO,SAACjD,GAAqC,OAClEkC,EAACC,EAAUjF,EAAA,CAACK,QAAQ,YAAY6E,UAAU,IAAIvC,OAAO,SAASqD,UAAQ,GAAKlD,GAAK,GAD3DiD,EAEpB,SAAAE,GAAA,IAAGC,EAAKD,EAALC,MAAK,MAAQ,CACjBrB,QAAS,OACTC,WAAY,SACZqB,MAAOD,EAAME,QAAQC,QAAQC,MAC7BC,OAAQ,UACRC,WAAY,IACZC,WAAY,MACZC,IAAK,MACL,UAAW,CACTC,eAAgB,YAChBR,MAAOD,EAAME,QAAQC,QAAQO,MAEhC"}
|
|
1
|
+
{"version":3,"file":"create.input-file.csv-local-parser.js","sources":["../../src/form/create.input-file.csv-local-parser.tsx"],"sourcesContent":["import React, { Component, ComponentType } from 'react'\r\nimport { Box, BoxProps, styled, TextField, TextFieldProps, Typography, TypographyProps } from '@mui/material'\r\nimport DownloadIcon from '@mui/icons-material/Download'\r\nimport { getErrorMessage } from './helpers'\r\nimport { tryParseCsvFileToArray } from '../utils'\r\nimport { IFormBase, IFormInputBase } from './types'\r\n\r\nexport interface IInputFileCsvLocalParserSlots {\r\n /**\r\n * The URL of the sample CSV file that users can download.\r\n * If provided, a \"Download sample\" link will be displayed.\r\n * Example: '/sample.csv' or 'https://example.com/sample.csv'\r\n */\r\n downloadSampleUrl?: string\r\n /**\r\n * Instructional text displayed alongside the download link or file input.\r\n * Useful for guiding users on how to use or fill out the CSV file.\r\n */\r\n instructionalText?: string\r\n /**\r\n * Props to customize the TextField used for uploading the CSV file.\r\n * Allows customization of appearance and behavior (e.g., placeholder, onChange, disabled).\r\n */\r\n textFieldProps?: TextFieldProps\r\n /**\r\n * Props passed to the wrapper element (typically a Box).\r\n * Useful for customizing layout styles such as margin, padding, or display.\r\n */\r\n wrapProps?: BoxProps\r\n /**\r\n * Whether the label should shrink when displayed.\r\n * Defaults to `true` if a label is present to prevent overlap.\r\n * @default true\r\n */\r\n labelShrink?: boolean\r\n}\r\n\r\nexport interface IInputFileCsvLocalParserParams extends IInputFileCsvLocalParserSlots {}\r\n\r\nexport interface IInputFileCsvLocalParserProps<T, C> extends IFormInputBase<T, IInputFileCsvLocalParserSlots> {\r\n onChange?: (value: C[]) => void\r\n}\r\n\r\nexport interface IInputFileCsvLocalParserState<C> {\r\n parsedData: C[]\r\n}\r\n\r\ntype IPickConfigs<T> = Required<Pick<IFormBase<T>, 'onBlur' | 'messageErrors'>>\r\n\r\ninterface IMergeConfigs<T> extends IPickConfigs<T>, IInputFileCsvLocalParserSlots {\r\n name: keyof T\r\n}\r\n\r\n/**\r\n * Creates a React component that renders a file input specifically for CSV files,\r\n * parses the selected file locally into a structured array, and integrates with a form system.\r\n *\r\n * @template T - The main data model used in the form. Represents the shape of the overall form data.\r\n * @template C - The type of each individual item parsed from the CSV file.\r\n *\r\n * @param params - Optional slot parameters to customize the appearance or behavior of the text field.\r\n * @returns A React component configured for uploading and parsing local CSV files.\r\n */\r\nexport function createInputFileCsvLocalParser<T, C>(params?: IInputFileCsvLocalParserParams): ComponentType<IInputFileCsvLocalParserProps<T, C>> {\r\n class InputFileCsvLocalParser extends Component<IInputFileCsvLocalParserProps<T, C>, IInputFileCsvLocalParserState<C>> {\r\n private mergeConfigsCache: IMergeConfigs<T> = { name: '' as keyof T, onBlur: () => {}, messageErrors: {} }\r\n constructor(props: IInputFileCsvLocalParserProps<T, C>) {\r\n super(props)\r\n this.mergeConfigsCache = this.upgradeMergeConfigs(props)\r\n this.state = { parsedData: [] }\r\n }\r\n\r\n get mergeConfigs(): IMergeConfigs<T> {\r\n return this.mergeConfigsCache\r\n }\r\n\r\n get inputValue() {\r\n return this.state.parsedData.length > 0 ? JSON.stringify(this.state.parsedData) : ''\r\n }\r\n\r\n shouldComponentUpdate(nextProps: Readonly<IInputFileCsvLocalParserProps<T, C>>): boolean {\r\n if (nextProps !== this.props) this.mergeConfigsCache = this.upgradeMergeConfigs(nextProps)\r\n return true\r\n }\r\n\r\n refInput: HTMLInputElement | null = null\r\n refTextFiled: HTMLInputElement | null = null\r\n render() {\r\n return (\r\n <Box {...this.mergeConfigs.wrapProps}>\r\n {this.mergeConfigs.downloadSampleUrl && (\r\n <Box sx={{ display: 'flex', alignItems: 'center', mb: '10px' }}>\r\n <Typography variant='subtitle2' component='span'>\r\n {this.mergeConfigs.instructionalText ?? 'Metadata file, please fill out the form we provide.'}\r\n </Typography>\r\n <DownloadButton href={this.mergeConfigs.downloadSampleUrl}>\r\n <span> Download sample</span>\r\n <DownloadIcon fontSize='small' />\r\n </DownloadButton>\r\n </Box>\r\n )}\r\n <input hidden name={this.props.name?.toString()} type='text' ref={(ref) => (this.refInput = ref)} defaultValue='' />\r\n <TextField {...this.getTextFieldProps()} inputRef={(ref) => (this.refTextFiled = ref)} />\r\n </Box>\r\n )\r\n }\r\n\r\n getTextFieldProps = (): TextFieldProps => {\r\n const { label } = this.props\r\n const eMessage = getErrorMessage(this.mergeConfigs.messageErrors, this.mergeConfigs.name)\r\n const mergedProps: TextFieldProps = {\r\n label,\r\n error: eMessage.error,\r\n helperText: eMessage.message,\r\n type: 'file',\r\n variant: 'outlined',\r\n fullWidth: true,\r\n onChange: this.handleChange,\r\n inputProps: { accept: 'text/csv' },\r\n InputLabelProps: { shrink: this.mergeConfigs.labelShrink },\r\n ...this.mergeConfigs.textFieldProps\r\n }\r\n return mergedProps\r\n }\r\n\r\n upgradeMergeConfigs = (currentProps: IInputFileCsvLocalParserProps<T, C>): IMergeConfigs<T> => {\r\n const { name, label, onBlur, messageErrors } = currentProps\r\n return {\r\n textFieldProps: Object.assign({}, params?.textFieldProps, currentProps.slots?.textFieldProps),\r\n wrapProps: Object.assign({}, params?.wrapProps, currentProps.slots?.wrapProps),\r\n name: name as keyof T,\r\n onBlur: onBlur || (() => {}),\r\n messageErrors: messageErrors || {},\r\n downloadSampleUrl: currentProps.slots?.downloadSampleUrl ?? params?.downloadSampleUrl,\r\n instructionalText: currentProps.slots?.instructionalText ?? params?.instructionalText,\r\n labelShrink: (currentProps.slots?.labelShrink ?? params?.labelShrink) !== false && !!label\r\n }\r\n }\r\n\r\n handleChange = async (e: React.ChangeEvent<HTMLInputElement>) => {\r\n const file = e.target.files?.[0]\r\n if (!file) return\r\n try {\r\n const result = await tryParseCsvFileToArray(file)\r\n if (this.refInput) this.refInput.value = JSON.stringify(result)\r\n this.setState({ parsedData: result as C[] }, () => {\r\n this.props.onChange && this.props.onChange(result as C[])\r\n this.mergeConfigs.onBlur(this.mergeConfigs.name)\r\n })\r\n } catch (err) {\r\n console.error('Error parsing CSV:', err)\r\n this.mergeConfigs.onBlur(this.mergeConfigs.name)\r\n }\r\n }\r\n }\r\n return InputFileCsvLocalParser\r\n}\r\n\r\nconst DownloadButton = styled((p: TypographyProps & { href: string }) => (\r\n <Typography variant='subtitle2' component='a' target='_blank' download {...p} />\r\n))(({ theme }) => ({\r\n display: 'flex',\r\n alignItems: 'center',\r\n color: theme.palette.primary.light,\r\n cursor: 'pointer',\r\n fontWeight: 600,\r\n marginLeft: '6px',\r\n gap: '4px',\r\n transition: 'all 0.3s ease',\r\n '&:hover': {\r\n textDecoration: 'underline',\r\n color: theme.palette.primary.dark\r\n }\r\n}))\r\n"],"names":["createInputFileCsvLocalParser","params","InputFileCsvLocalParser","props","_this","_classCallCheck","_callSuper","_defineProperty","name","onBlur","messageErrors","label","eMessage","getErrorMessage","mergeConfigs","_objectSpread","error","helperText","message","type","variant","fullWidth","onChange","handleChange","inputProps","accept","InputLabelProps","shrink","labelShrink","textFieldProps","currentProps","_currentProps$slots","_currentProps$slots2","_currentProps$slots$d","_currentProps$slots3","_currentProps$slots$i","_currentProps$slots4","_currentProps$slots$l","_currentProps$slots5","Object","assign","slots","wrapProps","downloadSampleUrl","instructionalText","_ref","_asyncToGenerator","_regenerator","m","_callee","e","_e$target$files","file","result","_t","w","_context","n","target","files","a","p","tryParseCsvFileToArray","v","refInput","value","JSON","stringify","setState","parsedData","console","_x","apply","this","arguments","mergeConfigsCache","upgradeMergeConfigs","state","_inherits","Component","_createClass","key","get","length","nextProps","_this$mergeConfigs$in","_this$props$name","_this2","_jsxs","Box","children","sx","display","alignItems","mb","_jsx","Typography","component","DownloadButton","href","DownloadIcon","fontSize","hidden","toString","ref","defaultValue","TextField","getTextFieldProps","inputRef","refTextFiled","styled","download","_ref3","theme","color","palette","primary","light","cursor","fontWeight","marginLeft","gap","transition","textDecoration","dark"],"mappings":"kkBA+DM,SAAUA,EAAoCC,GAAuC,IACnFC,aAEJ,SAAAA,EAAYC,GAA0C,IAAAC,EAGrB,OAHqBC,OAAAH,GACpDE,EAAAE,EAAAJ,KAAAA,GAAMC,IAAMI,EAAAH,EAFgC,oBAAA,CAAEI,KAAM,GAAeC,OAAQ,WAAQ,EAAEC,cAAe,CAAA,IAAIH,EAAAH,EAAA,WAoBtE,MAAIG,EAAAH,EAAA,eACA,MAAIG,EAAAH,EAAA,qBAqBxB,WAClB,IAAQO,EAAUP,EAAKD,MAAfQ,MACFC,EAAWC,EAAgBT,EAAKU,aAAaJ,cAAeN,EAAKU,aAAaN,MAapF,OAZiBO,EAAA,CACfJ,MAAAA,EACAK,MAAOJ,EAASI,MAChBC,WAAYL,EAASM,QACrBC,KAAM,OACNC,QAAS,WACTC,WAAW,EACXC,SAAUlB,EAAKmB,aACfC,WAAY,CAAEC,OAAQ,YACtBC,gBAAiB,CAAEC,OAAQvB,EAAKU,aAAac,cAC1CxB,EAAKU,aAAae,mBAGxBtB,EAAAH,EAEqB,uBAAA,SAAC0B,GAAuE,IAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EACpF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as e,createClass as t,superPropGet as r,typeof as n,objectWithoutProperties as i,objectSpread2 as o,classCallCheck as a,callSuper as s,defineProperty as u}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsx as c,Fragment as l}from"react/jsx-runtime";import f from"events";import{forwardRef as v,useEffect as p}from"react";var g=["onClick","routeKey"],
|
|
1
|
+
import{inherits as e,createClass as t,superPropGet as r,typeof as n,objectWithoutProperties as i,objectSpread2 as o,classCallCheck as a,callSuper as s,defineProperty as u}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsx as c,Fragment as l}from"react/jsx-runtime";import f from"events";import{forwardRef as v,useEffect as p}from"react";var g=["onClick","routeKey"],d=function(){function n(){var e;return a(this,n),e=s(this,n),u(e,"_createWrapListener",(function(e){return function(){try{e.apply(void 0,arguments)}catch(e){console.error("Error in MfeBridge listener:",e)}}})),e}return e(n,f),t(n,[{key:"subscribe",value:function(e,t){var i=this,o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2]?this._createWrapListener(t):t;return r(n,"addListener",this)([e,o]),function(){r(n,"removeListener",i)([e,o])}}}])}();function h(){if(void 0===("undefined"==typeof globalThis?"undefined":n(globalThis)))return null;void 0===globalThis.MfeNavigationEventStore&&(globalThis.MfeNavigationEventStore=new d);var e=globalThis.MfeNavigationEventStore;return e.setMaxListeners(50),e}var m=function(e){return p((function(){var t=h();if(t){var r=t.subscribe("navigation",(function(t){e.navigation&&e.navigation(t.routeKey)}));return function(){r()}}}),[]),c(l,{})},b=v((function(e,t){var r=e.onClick,n=e.routeKey,a=i(e,g);return c("a",o(o({},a),{},{ref:t,onClick:function(e){if(r&&r(e),!e.defaultPrevented){var t=h();t&&n&&(e.preventDefault(),e.stopPropagation(),t.emit("navigation",{routeKey:n,options:{message:"Link clicked"}}))}}}))})),y=function(e){var t=h();t&&t.emit("navigation",{routeKey:e,options:{message:"Navigating to ".concat(e)}})};export{b as MfeLink,d as MfeNavigationEventStore,m as MfeNavigationProvider,h as getMfeNavigationEventStore,y as mfeNavigation};
|
|
2
2
|
//# sourceMappingURL=navigation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.js","sources":["../../src/mfe-shared/navigation.tsx"],"sourcesContent":["import EventEmitter from 'events'\r\nimport { FC, forwardRef, useEffect } from 'react'\r\n\r\ninterface IEventOptions {\r\n message?: string\r\n}\r\n\r\nexport interface IMfeNavigationEventConfigs {\r\n navigation: [{ routeKey?: string; options?: IEventOptions }]\r\n}\r\n\r\nexport class MfeNavigationEventStore extends EventEmitter<IMfeNavigationEventConfigs> {\r\n constructor() {\r\n super()\r\n }\r\n /**\r\n * Subscribe to a specific channel\r\n * @param channel The channel to subscribe to\r\n * @param callback Function to call when an event occurs on this channel\r\n * @returns Unsubscribe function to remove the event listener\r\n */\r\n _createWrapListener = (callback: (...payload: any[]) => void) => {\r\n return (...payload: any[]) => {\r\n try {\r\n callback(...payload)\r\n } catch (error) {\r\n console.error('Error in MfeBridge listener:', error)\r\n }\r\n }\r\n }\r\n subscribe<K extends keyof IMfeNavigationEventConfigs>(\r\n eventName: K,\r\n listener: K extends keyof IMfeNavigationEventConfigs\r\n ? IMfeNavigationEventConfigs[K] extends unknown[]\r\n ? (...args: IMfeNavigationEventConfigs[K]) => void\r\n : never\r\n : never,\r\n isTry: boolean = true\r\n ) {\r\n const action = isTry ? this._createWrapListener(listener) : listener\r\n super.addListener(eventName, action as any)\r\n return () => {\r\n super.removeListener(eventName, action as any)\r\n }\r\n }\r\n}\r\n\r\nexport function getMfeNavigationEventStore() {\r\n if (typeof globalThis === undefined) return null\r\n\r\n if (typeof (globalThis as any).MfeNavigationEventStore === 'undefined') {\r\n // If MfeNavigationEventStore is not defined globally, define it\r\n // This allows it to be used in other parts of the application\r\n // without needing to import it explicitly\r\n ;(globalThis as any).MfeNavigationEventStore = new MfeNavigationEventStore()\r\n }\r\n const eventEmitter = (globalThis as any).MfeNavigationEventStore as MfeNavigationEventStore\r\n eventEmitter.setMaxListeners(50)\r\n return eventEmitter\r\n}\r\n\r\ntype INavigationFunction = (routeKey?: string) => void\r\n\r\nexport interface IMfeNavigationProviderProps {\r\n navigation?: INavigationFunction\r\n}\r\n\r\nexport const MfeNavigationProvider: FC<IMfeNavigationProviderProps> = (props) => {\r\n useEffect(() => {\r\n const eventStore = getMfeNavigationEventStore()\r\n if (!eventStore) return\r\n\r\n const unsubscribe = eventStore.subscribe('navigation', (payload) => {\r\n if (props.navigation) {\r\n props.navigation(payload.routeKey)\r\n }\r\n })\r\n\r\n return () => {\r\n unsubscribe()\r\n }\r\n }, [])\r\n\r\n return <></>\r\n}\r\n\r\nexport interface IMfeLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\r\n routeKey?: string\r\n}\r\n\r\nexport const MfeLink = forwardRef<HTMLAnchorElement, IMfeLinkProps>(({ onClick, routeKey, ...props }, ref) => {\r\n const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {\r\n if (onClick) {\r\n onClick(event)\r\n }\r\n const eventStore = getMfeNavigationEventStore()\r\n if (eventStore && !!routeKey) {\r\n event.preventDefault() // Prevent default link behavior\r\n event.stopPropagation() // Stop the event from bubbling up\r\n eventStore.emit('navigation', { routeKey: routeKey, options: { message: 'Link clicked' } })\r\n }\r\n }\r\n return <a {...props} ref={ref} onClick={handleClick} />\r\n})\r\n\r\nexport const mfeNavigation = (routeKey: string) => {\r\n const eventStore = getMfeNavigationEventStore()\r\n if (eventStore) {\r\n eventStore.emit('navigation', { routeKey: routeKey, options: { message: `Navigating to ${routeKey}` } })\r\n }\r\n}\r\n"],"names":["MfeNavigationEventStore","_this","_classCallCheck","_callSuper","this","_defineProperty","callback","apply","arguments","error","console","_inherits","EventEmitter","_createClass","key","value","eventName","listener","_this2","action","_createWrapListener","_superPropGet","getMfeNavigationEventStore","undefined","globalThis","_typeof","eventEmitter","setMaxListeners","MfeNavigationProvider","props","useEffect","eventStore","unsubscribe","subscribe","payload","navigation","routeKey","_jsx","MfeLink","forwardRef","_ref","ref","onClick","_objectWithoutProperties","_excluded","_objectSpread","event","preventDefault","stopPropagation","emit","options","message","mfeNavigation","concat"],"mappings":"qXAWaA,aACX,SAAAA,IAAA,IAAAC,EAiBC,OAjBDC,OAAAF,GACEC,EAAAE,EAAAC,KAAAJ,GAEFK,EAAAJ,EAMsB,uBAAA,SAACK,GACrB,OAAO,WACL,IACEA,EAAQC,WAAAC,EAAAA,UACT,CAAC,MAAOC,GACPC,QAAQD,MAAM,+BAAgCA,EAC/C,CACF,KACFR,CAfD,CAAC,OAAAU,EAAAX,EAH0CY,GAG1CC,EAAAb,EAAA,CAAA,CAAAc,IAAA,YAAAC,MAgBD,SACEC,EACAC,GAKqB,IAAAC,EAAAd,KAEfe,6DAAiBf,KAAKgB,oBAAoBH,GAAYA,EAE5D,OADAI,EAAArB,EAAkBgB,cAAAA,KAAlBK,CAAkBL,CAAAA,EAAWG,IACtB,WACLE,EAAArB,EAAA,iBAAAkB,EAAAG,CAAqBL,CAAAA,EAAWG,GACjC,CACH,IAAC,aAGaG,IACd,QAA0BC,KAAL,oBAAVC,WAAU,YAAAC,EAAVD,aAA0B,OAAO,UAEe,IAA/CA,WAAmBxB,0BAI3BwB,WAAmBxB,wBAA0B,IAAIA,GAErD,IAAM0B,EAAgBF,WAAmBxB,wBAEzC,OADA0B,EAAaC,gBAAgB,IACtBD,CACT,KAQaE,EAAyD,SAACC,GAgBrE,OAfAC,GAAU,WACR,IAAMC,EAAaT,IACnB,GAAKS,EAAL,CAEA,IAAMC,EAAcD,EAAWE,UAAU,cAAc,SAACC,GAClDL,EAAMM,YACRN,EAAMM,WAAWD,EAAQE,SAE7B,IAEA,OAAO,WACLJ,GACD,CAVgB,CAWlB,GAAE,IAEIK,OACT,EAMaC,EAAUC,GAA6C,SAAAC,EAAkCC,GAAO,IAAtCC,EAAOF,EAAPE,QAASN,EAAQI,EAARJ,SAAaP,EAAKc,EAAAH,EAAAI,
|
|
1
|
+
{"version":3,"file":"navigation.js","sources":["../../src/mfe-shared/navigation.tsx"],"sourcesContent":["import EventEmitter from 'events'\r\nimport { FC, forwardRef, useEffect } from 'react'\r\n\r\ninterface IEventOptions {\r\n message?: string\r\n}\r\n\r\nexport interface IMfeNavigationEventConfigs {\r\n navigation: [{ routeKey?: string; options?: IEventOptions }]\r\n}\r\n\r\nexport class MfeNavigationEventStore extends EventEmitter<IMfeNavigationEventConfigs> {\r\n constructor() {\r\n super()\r\n }\r\n /**\r\n * Subscribe to a specific channel\r\n * @param channel The channel to subscribe to\r\n * @param callback Function to call when an event occurs on this channel\r\n * @returns Unsubscribe function to remove the event listener\r\n */\r\n _createWrapListener = (callback: (...payload: any[]) => void) => {\r\n return (...payload: any[]) => {\r\n try {\r\n callback(...payload)\r\n } catch (error) {\r\n console.error('Error in MfeBridge listener:', error)\r\n }\r\n }\r\n }\r\n subscribe<K extends keyof IMfeNavigationEventConfigs>(\r\n eventName: K,\r\n listener: K extends keyof IMfeNavigationEventConfigs\r\n ? IMfeNavigationEventConfigs[K] extends unknown[]\r\n ? (...args: IMfeNavigationEventConfigs[K]) => void\r\n : never\r\n : never,\r\n isTry: boolean = true\r\n ) {\r\n const action = isTry ? this._createWrapListener(listener) : listener\r\n super.addListener(eventName, action as any)\r\n return () => {\r\n super.removeListener(eventName, action as any)\r\n }\r\n }\r\n}\r\n\r\nexport function getMfeNavigationEventStore() {\r\n if (typeof globalThis === undefined) return null\r\n\r\n if (typeof (globalThis as any).MfeNavigationEventStore === 'undefined') {\r\n // If MfeNavigationEventStore is not defined globally, define it\r\n // This allows it to be used in other parts of the application\r\n // without needing to import it explicitly\r\n ;(globalThis as any).MfeNavigationEventStore = new MfeNavigationEventStore()\r\n }\r\n const eventEmitter = (globalThis as any).MfeNavigationEventStore as MfeNavigationEventStore\r\n eventEmitter.setMaxListeners(50)\r\n return eventEmitter\r\n}\r\n\r\ntype INavigationFunction = (routeKey?: string) => void\r\n\r\nexport interface IMfeNavigationProviderProps {\r\n navigation?: INavigationFunction\r\n}\r\n\r\nexport const MfeNavigationProvider: FC<IMfeNavigationProviderProps> = (props) => {\r\n useEffect(() => {\r\n const eventStore = getMfeNavigationEventStore()\r\n if (!eventStore) return\r\n\r\n const unsubscribe = eventStore.subscribe('navigation', (payload) => {\r\n if (props.navigation) {\r\n props.navigation(payload.routeKey)\r\n }\r\n })\r\n\r\n return () => {\r\n unsubscribe()\r\n }\r\n }, [])\r\n\r\n return <></>\r\n}\r\n\r\nexport interface IMfeLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\r\n routeKey?: string\r\n}\r\n\r\nexport const MfeLink = forwardRef<HTMLAnchorElement, IMfeLinkProps>(({ onClick, routeKey, ...props }, ref) => {\r\n const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {\r\n if (onClick) {\r\n onClick(event)\r\n }\r\n if (event.defaultPrevented) {\r\n return // nothing to do if event already handled\r\n }\r\n const eventStore = getMfeNavigationEventStore()\r\n if (eventStore && !!routeKey) {\r\n event.preventDefault() // Prevent default link behavior\r\n event.stopPropagation() // Stop the event from bubbling up\r\n eventStore.emit('navigation', { routeKey: routeKey, options: { message: 'Link clicked' } })\r\n }\r\n }\r\n return <a {...props} ref={ref} onClick={handleClick} />\r\n})\r\n\r\nexport const mfeNavigation = (routeKey: string) => {\r\n const eventStore = getMfeNavigationEventStore()\r\n if (eventStore) {\r\n eventStore.emit('navigation', { routeKey: routeKey, options: { message: `Navigating to ${routeKey}` } })\r\n }\r\n}\r\n"],"names":["MfeNavigationEventStore","_this","_classCallCheck","_callSuper","this","_defineProperty","callback","apply","arguments","error","console","_inherits","EventEmitter","_createClass","key","value","eventName","listener","_this2","action","_createWrapListener","_superPropGet","getMfeNavigationEventStore","undefined","globalThis","_typeof","eventEmitter","setMaxListeners","MfeNavigationProvider","props","useEffect","eventStore","unsubscribe","subscribe","payload","navigation","routeKey","_jsx","MfeLink","forwardRef","_ref","ref","onClick","_objectWithoutProperties","_excluded","_objectSpread","event","defaultPrevented","preventDefault","stopPropagation","emit","options","message","mfeNavigation","concat"],"mapp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