dinocollab-core 2.1.32 → 2.1.34
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/src/api-context/global-modal.js +1 -1
- package/dist/src/api-context/global-modal.js.map +1 -1
- package/dist/src/components/rich-tooltip.js +1 -1
- package/dist/src/components/rich-tooltip.js.map +1 -1
- package/dist/src/form/decorator.form.js +1 -1
- package/dist/src/form/decorator.form.js.map +1 -1
- package/dist/src/form/decorator.js.map +1 -1
- package/dist/src/http-service/base/service-base.js.map +1 -1
- package/dist/types/components/rich-tooltip.d.ts +2 -1
- package/dist/types/form/decorator.d.ts +2 -0
- package/dist/types/form/decorator.form.d.ts +10 -3
- package/dist/types/form/dino-form.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{inherits as t,createClass as e,classCallCheck as n,callSuper as r,defineProperty as o,objectSpread2 as s}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as a,jsxs as i,Fragment as l}from"react/jsx-runtime";import c,{Component as u}from"react";import{styled as d,Box as f,Modal as p,Backdrop as h}from"@mui/material";var
|
|
1
|
+
import{inherits as t,createClass as e,classCallCheck as n,callSuper as r,defineProperty as o,objectSpread2 as s}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as a,jsxs as i,Fragment as l}from"react/jsx-runtime";import c,{Component as u}from"react";import{styled as d,Box as f,Modal as p,Backdrop as h}from"@mui/material";var C=c.createContext({close:function(){console.warn("GlobalModal provider not found!")},show:function(){console.warn("GlobalModal provider not found!")}}),m=function(t){return a(C.Consumer,{children:t})},b=function(){function s(t){var e;return n(this,s),e=r(this,s,[t]),o(e,"show",function(t){e.setState(t)}),o(e,"close",function(t,n){"backdropClick"===n&&!1===e.state.backdropActivated||(e.state.onClose&&e.state.onClose(n),e.setState({renderContent:void 0}))}),o(e,"renderContent",function(){return e.state.renderContent?e.state.renderContent():a(l,{})}),e.state={},e}return t(s,u),e(s,[{key:"render",value:function(){return i(C.Provider,{value:this,children:[this.props.children,a(p,{open:!!this.state.renderContent,onClose:this.close,slots:{backdrop:h},slotProps:{backdrop:{timeout:300}},sx:this.state.sx,children:a(v,{sx:this.state.sxWrap,children:this.renderContent()})})]})}}])}(),v=d(f)({position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",outline:"none"}),x=function(t){return function(e){return a(b,{children:m(function(n){return a(t,s(s({},e),{},{contextGlobalModal:n}))})})}},k=function(t){return function(e){return m(function(n){return a(t,s(s({},e),{},{contextGlobalModal:n}))})}};export{b as GlobalModal,C as GlobalModalContext,b as default,m as mapGlobalModalContext,k as withApiGlobalModalConsumerContext,x as withApiGlobalModalContext};
|
|
2
2
|
//# sourceMappingURL=global-modal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global-modal.js","sources":["../../../src/api-context/global-modal.tsx"],"sourcesContent":["import React, { Component } from 'react'\r\nimport { Backdrop, Box, Modal, SxProps, styled } from '@mui/material'\r\n\r\nexport interface GlobalModalState {\r\n sx?: SxProps\r\n sxWrap?: SxProps\r\n /** @default true */\r\n backdropActivated?: boolean\r\n onClose?: (reason?: TModalReason) => void\r\n renderContent?: () => React.ReactNode\r\n}\r\n\r\nexport type TModalReason = 'backdropClick' | 'escapeKeyDown'\r\n\r\ninterface GlobalModalProps {}\r\n\r\nexport type TShowModal = (value: GlobalModalState) => void\r\n\r\nexport type TCloseModal = (event?: {}, reason?: TModalReason) => void\r\n\r\nexport interface IGlobalModalContext {\r\n show: TShowModal\r\n close: TCloseModal\r\n}\r\n\r\nexport const GlobalModalContext = React.createContext<IGlobalModalContext>({\r\n close: () => {\r\n console.warn('GlobalModal provider not found!')\r\n },\r\n show: () => {\r\n console.warn('GlobalModal provider not found!')\r\n }\r\n})\r\n\r\nexport interface IMapGlobalModal {\r\n context: IGlobalModalContext\r\n}\r\n\r\nexport const mapGlobalModalContext = (context: (state: IGlobalModalContext) => React.ReactNode) => (\r\n <GlobalModalContext.Consumer>{context}</GlobalModalContext.Consumer>\r\n)\r\n\r\nexport class GlobalModal extends Component<React.PropsWithChildren<GlobalModalProps>, GlobalModalState> implements IGlobalModalContext {\r\n constructor(props: any) {\r\n super(props)\r\n this.state = {}\r\n }\r\n\r\n show: TShowModal = (value) => {\r\n this.setState(value)\r\n }\r\n\r\n close: TCloseModal = (_, reason) => {\r\n if (reason === 'backdropClick' && this.state.backdropActivated === false) return\r\n this.setState({ renderContent: undefined })\r\n }\r\n\r\n render() {\r\n return (\r\n <GlobalModalContext.Provider value={this}>\r\n {this.props.children}\r\n <Modal\r\n open={!!this.state.renderContent}\r\n onClose={this.close}\r\n slots={{ backdrop: Backdrop }}\r\n slotProps={{ backdrop: { timeout: 300 } }}\r\n sx={this.state.sx}\r\n >\r\n <Wrapper sx={this.state.sxWrap}>{this.renderContent()}</Wrapper>\r\n </Modal>\r\n </GlobalModalContext.Provider>\r\n )\r\n }\r\n\r\n renderContent = (): React.ReactNode => {\r\n return this.state.renderContent ? this.state.renderContent() : <></>\r\n }\r\n}\r\nexport default GlobalModal\r\n\r\nconst Wrapper = styled(Box)({\r\n position: 'absolute',\r\n top: '50%',\r\n left: '50%',\r\n transform: 'translate(-50%, -50%)',\r\n outline: 'none'\r\n})\r\n\r\nexport interface IApiGlobalModalContextProps {\r\n contextGlobalModal: IGlobalModalContext\r\n}\r\n\r\nexport const withApiGlobalModalContext = <P extends IApiGlobalModalContextProps>(Component: React.ComponentType<P>) => {\r\n return (props: Omit<P, keyof IApiGlobalModalContextProps>) => {\r\n return (\r\n <GlobalModal>\r\n {mapGlobalModalContext((context) => (\r\n <Component {...(props as P)} contextGlobalModal={context} />\r\n ))}\r\n </GlobalModal>\r\n )\r\n }\r\n}\r\n\r\nexport const withApiGlobalModalConsumerContext = <P extends IApiGlobalModalContextProps>(Component: React.ComponentType<P>) => {\r\n return (props: Omit<P, keyof IApiGlobalModalContextProps>) => {\r\n return mapGlobalModalContext((context) => <Component {...(props as P)} contextGlobalModal={context} />)\r\n }\r\n}\r\n"],"names":["GlobalModalContext","React","createContext","close","console","warn","show","mapGlobalModalContext","context","_jsx","Consumer","GlobalModal","props","_this","_classCallCheck","_callSuper","_defineProperty","value","setState","_","reason","state","backdropActivated","renderContent","undefined","_inherits","Component","_createClass","key","_jsxs","Provider","this","children","Modal","open","
|
|
1
|
+
{"version":3,"file":"global-modal.js","sources":["../../../src/api-context/global-modal.tsx"],"sourcesContent":["import React, { Component } from 'react'\r\nimport { Backdrop, Box, Modal, SxProps, styled } from '@mui/material'\r\n\r\nexport interface GlobalModalState {\r\n sx?: SxProps\r\n sxWrap?: SxProps\r\n /** @default true */\r\n backdropActivated?: boolean\r\n onClose?: (reason?: TModalReason) => void\r\n renderContent?: () => React.ReactNode\r\n}\r\n\r\nexport type TModalReason = 'backdropClick' | 'escapeKeyDown'\r\n\r\ninterface GlobalModalProps {}\r\n\r\nexport type TShowModal = (value: GlobalModalState) => void\r\n\r\nexport type TCloseModal = (event?: {}, reason?: TModalReason) => void\r\n\r\nexport interface IGlobalModalContext {\r\n show: TShowModal\r\n close: TCloseModal\r\n}\r\n\r\nexport const GlobalModalContext = React.createContext<IGlobalModalContext>({\r\n close: () => {\r\n console.warn('GlobalModal provider not found!')\r\n },\r\n show: () => {\r\n console.warn('GlobalModal provider not found!')\r\n }\r\n})\r\n\r\nexport interface IMapGlobalModal {\r\n context: IGlobalModalContext\r\n}\r\n\r\nexport const mapGlobalModalContext = (context: (state: IGlobalModalContext) => React.ReactNode) => (\r\n <GlobalModalContext.Consumer>{context}</GlobalModalContext.Consumer>\r\n)\r\n\r\nexport class GlobalModal extends Component<React.PropsWithChildren<GlobalModalProps>, GlobalModalState> implements IGlobalModalContext {\r\n constructor(props: any) {\r\n super(props)\r\n this.state = {}\r\n }\r\n\r\n show: TShowModal = (value) => {\r\n this.setState(value)\r\n }\r\n\r\n close: TCloseModal = (_, reason) => {\r\n if (reason === 'backdropClick' && this.state.backdropActivated === false) return\r\n this.state.onClose && this.state.onClose(reason)\r\n this.setState({ renderContent: undefined })\r\n }\r\n\r\n render() {\r\n return (\r\n <GlobalModalContext.Provider value={this}>\r\n {this.props.children}\r\n <Modal\r\n open={!!this.state.renderContent}\r\n onClose={this.close}\r\n slots={{ backdrop: Backdrop }}\r\n slotProps={{ backdrop: { timeout: 300 } }}\r\n sx={this.state.sx}\r\n >\r\n <Wrapper sx={this.state.sxWrap}>{this.renderContent()}</Wrapper>\r\n </Modal>\r\n </GlobalModalContext.Provider>\r\n )\r\n }\r\n\r\n renderContent = (): React.ReactNode => {\r\n return this.state.renderContent ? this.state.renderContent() : <></>\r\n }\r\n}\r\nexport default GlobalModal\r\n\r\nconst Wrapper = styled(Box)({\r\n position: 'absolute',\r\n top: '50%',\r\n left: '50%',\r\n transform: 'translate(-50%, -50%)',\r\n outline: 'none'\r\n})\r\n\r\nexport interface IApiGlobalModalContextProps {\r\n contextGlobalModal: IGlobalModalContext\r\n}\r\n\r\nexport const withApiGlobalModalContext = <P extends IApiGlobalModalContextProps>(Component: React.ComponentType<P>) => {\r\n return (props: Omit<P, keyof IApiGlobalModalContextProps>) => {\r\n return (\r\n <GlobalModal>\r\n {mapGlobalModalContext((context) => (\r\n <Component {...(props as P)} contextGlobalModal={context} />\r\n ))}\r\n </GlobalModal>\r\n )\r\n }\r\n}\r\n\r\nexport const withApiGlobalModalConsumerContext = <P extends IApiGlobalModalContextProps>(Component: React.ComponentType<P>) => {\r\n return (props: Omit<P, keyof IApiGlobalModalContextProps>) => {\r\n return mapGlobalModalContext((context) => <Component {...(props as P)} contextGlobalModal={context} />)\r\n }\r\n}\r\n"],"names":["GlobalModalContext","React","createContext","close","console","warn","show","mapGlobalModalContext","context","_jsx","Consumer","GlobalModal","props","_this","_classCallCheck","_callSuper","_defineProperty","value","setState","_","reason","state","backdropActivated","onClose","renderContent","undefined","_inherits","Component","_createClass","key","_jsxs","Provider","this","children","Modal","open","slots","backdrop","Backdrop","slotProps","timeout","sx","Wrapper","sxWrap","styled","Box","position","top","left","transform","outline","withApiGlobalModalContext","_objectSpread","contextGlobalModal","withApiGlobalModalConsumerContext"],"mappings":"oVAyBaA,EAAqBC,EAAMC,cAAmC,CACzEC,MAAO,WACLC,QAAQC,KAAK,kCACd,EACDC,KAAM,WACJF,QAAQC,KAAK,kCACf,IAOWE,EAAwB,SAACC,GAAwD,OAC5FC,EAACT,EAAmBU,mBAAUF,GAAsC,EAGzDG,aACX,SAAAA,EAAYC,GAAU,IAAAC,EAEL,OAFKC,OAAAH,GACpBE,EAAAE,EAAAJ,KAAAA,GAAMC,IAAMI,EAAAH,EAIK,OAAA,SAACI,GAClBJ,EAAKK,SAASD,KACfD,EAAAH,EAAA,QAEoB,SAACM,EAAGC,GACR,kBAAXA,IAA+D,IAAjCP,EAAKQ,MAAMC,oBAC7CT,EAAKQ,MAAME,SAAWV,EAAKQ,MAAME,QAAQH,GACzCP,EAAKK,SAAS,CAAEM,mBAAeC,OAChCT,EAAAH,EAAA,gBAmBe,WACd,OAAOA,EAAKQ,MAAMG,cAAgBX,EAAKQ,MAAMG,gBAAkBf,UA/B/DI,EAAKQ,MAAQ,CAAE,EAAAR,CACjB,CAAC,OAAAa,EAAAf,EAJ8BgB,GAI9BC,EAAAjB,EAAA,CAAA,CAAAkB,IAAA,SAAAZ,MAYD,WACE,OACEa,EAAC9B,EAAmB+B,UAASd,MAAOe,KAAIC,SAAA,CACrCD,KAAKpB,MAAMqB,SACZxB,EAACyB,EAAK,CACJC,OAAQH,KAAKX,MAAMG,cACnBD,QAASS,KAAK7B,MACdiC,MAAO,CAAEC,SAAUC,GACnBC,UAAW,CAAEF,SAAU,CAAEG,QAAS,MAClCC,GAAIT,KAAKX,MAAMoB,GAEfR,SAAAxB,EAACiC,EAAQ,CAAAD,GAAIT,KAAKX,MAAMsB,OAASV,SAAAD,KAAKR,sBAI9C,IAAC,IAQGkB,EAAUE,EAAOC,EAAPD,CAAY,CAC1BE,SAAU,WACVC,IAAK,MACLC,KAAM,MACNC,UAAW,wBACXC,QAAS,SAOEC,EAA4B,SAAwCxB,GAC/E,OAAO,SAACf,GACN,OACEH,EAACE,EACE,CAAAsB,SAAA1B,EAAsB,SAACC,GAAO,OAC7BC,EAACkB,EAASyB,EAAAA,KAAMxC,GAAW,GAAA,CAAEyC,mBAAoB7C,IAClD,IAGN,CACH,EAEa8C,EAAoC,SAAwC3B,GACvF,OAAO,SAACf,GACN,OAAOL,EAAsB,SAACC,GAAO,OAAKC,EAACkB,EAASyB,EAAAA,KAAMxC,GAAW,GAAA,CAAEyC,mBAAoB7C,MAC5F,CACH"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{defineProperty as e,objectWithoutProperties as t,objectSpread2 as r,inherits as a,createClass as o,classCallCheck as n,callSuper as i}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as l,jsxs as p}from"react/jsx-runtime";import{Component as c}from"react";import{styled as s,Stack as d,Tooltip as u,tooltipClasses as m,
|
|
1
|
+
import{defineProperty as e,objectWithoutProperties as t,objectSpread2 as r,inherits as a,createClass as o,classCallCheck as n,callSuper as i}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as l,jsxs as p}from"react/jsx-runtime";import{Component as c}from"react";import{styled as s,Stack as d,Tooltip as u,tooltipClasses as m,Box as h,Typography as f,Divider as b}from"@mui/material";import x from"@mui/icons-material/HelpOutline";var g=["className"],v=function(){function t(){var r;n(this,t);for(var a=arguments.length,o=new Array(a),c=0;c<a;c++)o[c]=arguments[c];return r=i(this,t,[].concat(o)),e(r,"renderTitlePanel",function(){var e=r.props,t=e.panel,a=e.renderPanel;return a?a():t?p(k,{className:P.titlePanel,children:[r.renderTitle(t.title),l(b,{}),l(h,{className:P.content,children:r.renderContent(t.content)})]}):l(f,{variant:"body2",children:"Please provide a panel configuration"})}),e(r,"renderTitle",function(e){return e?"string"!=typeof e?e:l(f,{variant:"subtitle1",className:P.title,children:e}):null}),e(r,"renderContent",function(e){return e?"string"!=typeof e?e:l(f,{variant:"body2",children:e}):null}),r}return a(t,c),o(t,[{key:"render",value:function(){var e=this.props,t=e.children,a=e.slots;return l(w,r(r({arrow:!0,placement:"bottom",title:this.renderTitlePanel(),className:P.root},null==a?void 0:a.tooltipProps),{},{children:l(h,r(r({},null==a?void 0:a.wrapperProps),{},{children:t}))}))}}])}(),P={root:"RichTooltip-root",titlePanel:"RichTooltip-titlePanel",title:"RichTooltip-title",content:"RichTooltip-content"},y=function(e,t){return"".concat((null==t?void 0:t.prefix)||"",".").concat(P[e]).concat((null==t?void 0:t.suffix)||"")},k=s(d)(function(t){var r=t.theme;return e(e(e({},y("titlePanel",{prefix:"&"}),{gap:"6px"}),y("title"),{color:r.palette.primary.main,fontWeight:700,padding:r.spacing(1,1.5,0)}),y("content"),{padding:r.spacing(1,1.5,1.5),color:r.palette.text.primary})}),w=s(function(e){var a=e.className,o=t(e,g);return l(u,r(r({},o),{},{classes:{popper:a}}))})(function(t){var r=t.theme;return e(e({},"& .".concat(m.tooltip),{backgroundColor:r.palette.background.paper,color:r.palette.text.primary,padding:0,minWidth:"360px",maxWidth:"450px",borderRadius:r.shape.borderRadius,boxShadow:"dark"===r.palette.mode?"rgba(0, 0, 0, 0.4) 0px 6px 30px":"rgba(0, 0, 0, 0.08) 0px 6px 30px",border:"1px solid ".concat(r.palette.divider)}),"& .".concat(m.arrow),{color:r.palette.background.paper})}),T=s(x)(function(e){var t=e.theme;return{position:"relative",zIndex:1,color:t.palette.primary.main,borderRadius:"50%",cursor:"help",animation:"pulseGlow 1.5s infinite","@keyframes pulseGlow":{"0%":{boxShadow:"dark"===t.palette.mode?"0 0 0 0 rgba(144, 202, 249, 0.3)":"0 0 0 0 rgba(33, 150, 243, 0.3)"},"70%":{boxShadow:"dark"===t.palette.mode?"0 0 0 10px rgba(144, 202, 249, 0)":"0 0 0 10px rgba(33, 150, 243, 0)"},"100%":{boxShadow:"dark"===t.palette.mode?"0 0 0 0 rgba(144, 202, 249, 0)":"0 0 0 0 rgba(33, 150, 243, 0)"}}}});export{T as HelpOutlinePulseIcon,v as RichTooltip,v as default};
|
|
2
2
|
//# sourceMappingURL=rich-tooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich-tooltip.js","sources":["../../../src/components/rich-tooltip.tsx"],"sourcesContent":["import { Component } from 'react'\r\nimport { Box, Divider, Stack, Tooltip, Typography, styled, tooltipClasses } from '@mui/material'\r\nimport type { ReactNode } from 'react'\r\nimport type { TooltipProps } from '@mui/material'\r\nimport HelpOutlineIcon from '@mui/icons-material/HelpOutline'\r\n\r\nexport interface IRichTooltipPanelConfig {\r\n title: ReactNode\r\n content: ReactNode\r\n}\r\n\r\nexport interface IRichTooltipProps {\r\n panel?: IRichTooltipPanelConfig\r\n renderPanel?: () => ReactNode\r\n children: React.ReactNode\r\n slots?: {\r\n tooltipProps?: Partial<TooltipProps>\r\n }\r\n}\r\n\r\nexport class RichTooltip extends Component<IRichTooltipProps> {\r\n render() {\r\n const { children, slots } = this.props\r\n return (\r\n <TooltipStyled arrow placement='bottom' title={this.renderTitlePanel()} className={richTooltipClasses.root} {...slots?.tooltipProps}>\r\n <
|
|
1
|
+
{"version":3,"file":"rich-tooltip.js","sources":["../../../src/components/rich-tooltip.tsx"],"sourcesContent":["import { Component } from 'react'\r\nimport { Box, Divider, Stack, Tooltip, Typography, styled, tooltipClasses } from '@mui/material'\r\nimport type { ReactNode } from 'react'\r\nimport type { BoxProps, TooltipProps } from '@mui/material'\r\nimport HelpOutlineIcon from '@mui/icons-material/HelpOutline'\r\n\r\nexport interface IRichTooltipPanelConfig {\r\n title: ReactNode\r\n content: ReactNode\r\n}\r\n\r\nexport interface IRichTooltipProps {\r\n panel?: IRichTooltipPanelConfig\r\n renderPanel?: () => ReactNode\r\n children: React.ReactNode\r\n slots?: {\r\n tooltipProps?: Partial<TooltipProps>\r\n wrapperProps?: BoxProps\r\n }\r\n}\r\n\r\nexport class RichTooltip extends Component<IRichTooltipProps> {\r\n render() {\r\n const { children, slots } = this.props\r\n return (\r\n <TooltipStyled arrow placement='bottom' title={this.renderTitlePanel()} className={richTooltipClasses.root} {...slots?.tooltipProps}>\r\n <Box {...slots?.wrapperProps}>{children}</Box>\r\n </TooltipStyled>\r\n )\r\n }\r\n\r\n renderTitlePanel = () => {\r\n const { panel, renderPanel } = this.props\r\n if (renderPanel) return renderPanel()\r\n if (!panel) return <Typography variant='body2'>Please provide a panel configuration</Typography>\r\n return (\r\n <TooltipTitlePanelStyled className={richTooltipClasses.titlePanel}>\r\n {this.renderTitle(panel.title)}\r\n <Divider />\r\n <Box className={richTooltipClasses.content}>{this.renderContent(panel.content)}</Box>\r\n </TooltipTitlePanelStyled>\r\n )\r\n }\r\n\r\n renderTitle = (value: ReactNode) => {\r\n if (!value) return null\r\n if (typeof value !== 'string') return value\r\n return (\r\n <Typography variant='subtitle1' className={richTooltipClasses.title}>\r\n {value}\r\n </Typography>\r\n )\r\n }\r\n\r\n renderContent = (value: ReactNode) => {\r\n if (!value) return null\r\n if (typeof value !== 'string') return value\r\n return <Typography variant='body2'>{value}</Typography>\r\n }\r\n}\r\n\r\nexport default RichTooltip\r\n\r\nconst richTooltipClasses = {\r\n root: 'RichTooltip-root',\r\n titlePanel: 'RichTooltip-titlePanel',\r\n title: 'RichTooltip-title',\r\n content: 'RichTooltip-content'\r\n}\r\n\r\nconst getRichTooltipClass = (key: keyof typeof richTooltipClasses, options?: { prefix?: string; suffix?: string }) => {\r\n return `${options?.prefix || ''}.${richTooltipClasses[key]}${options?.suffix || ''}`\r\n}\r\n\r\nconst TooltipTitlePanelStyled = styled(Stack)(({ theme }) => ({\r\n [getRichTooltipClass('titlePanel', { prefix: '&' })]: {\r\n gap: '6px'\r\n },\r\n [getRichTooltipClass('title')]: {\r\n color: theme.palette.primary.main,\r\n fontWeight: 700,\r\n padding: theme.spacing(1, 1.5, 0)\r\n },\r\n [getRichTooltipClass('content')]: {\r\n padding: theme.spacing(1, 1.5, 1.5),\r\n color: theme.palette.text.primary\r\n }\r\n}))\r\n\r\nconst TooltipStyled = styled(({ className, ...props }: TooltipProps) => <Tooltip {...props} classes={{ popper: className }} />)(({ theme }) => ({\r\n [`& .${tooltipClasses.tooltip}`]: {\r\n backgroundColor: theme.palette.background.paper,\r\n color: theme.palette.text.primary,\r\n padding: 0,\r\n minWidth: '360px',\r\n maxWidth: '450px',\r\n borderRadius: theme.shape.borderRadius,\r\n boxShadow: theme.palette.mode === 'dark' ? 'rgba(0, 0, 0, 0.4) 0px 6px 30px' : 'rgba(0, 0, 0, 0.08) 0px 6px 30px',\r\n border: `1px solid ${theme.palette.divider}`\r\n },\r\n [`& .${tooltipClasses.arrow}`]: {\r\n color: theme.palette.background.paper\r\n }\r\n}))\r\n\r\nexport const HelpOutlinePulseIcon = styled(HelpOutlineIcon)(({ theme }) => ({\r\n position: 'relative',\r\n zIndex: 1,\r\n color: theme.palette.primary.main,\r\n borderRadius: '50%',\r\n cursor: 'help',\r\n animation: 'pulseGlow 1.5s infinite',\r\n '@keyframes pulseGlow': {\r\n '0%': {\r\n boxShadow: theme.palette.mode === 'dark' ? '0 0 0 0 rgba(144, 202, 249, 0.3)' : '0 0 0 0 rgba(33, 150, 243, 0.3)'\r\n },\r\n '70%': {\r\n boxShadow: theme.palette.mode === 'dark' ? '0 0 0 10px rgba(144, 202, 249, 0)' : '0 0 0 10px rgba(33, 150, 243, 0)'\r\n },\r\n '100%': {\r\n boxShadow: theme.palette.mode === 'dark' ? '0 0 0 0 rgba(144, 202, 249, 0)' : '0 0 0 0 rgba(33, 150, 243, 0)'\r\n }\r\n }\r\n}))\r\n"],"names":["RichTooltip","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_callSuper","this","concat","_defineProperty","_this$props","props","panel","renderPanel","_jsxs","TooltipTitlePanelStyled","className","richTooltipClasses","titlePanel","renderTitle","title","_jsx","Divider","Box","content","children","renderContent","Typography","variant","value","_inherits","Component","_createClass","key","_this$props2","slots","TooltipStyled","_objectSpread","arrow","placement","renderTitlePanel","root","tooltipProps","wrapperProps","getRichTooltipClass","options","prefix","suffix","styled","Stack","_ref","theme","gap","color","palette","primary","main","fontWeight","padding","spacing","text","_ref3","_objectWithoutProperties","_excluded","Tooltip","classes","popper","_ref4","tooltipClasses","tooltip","backgroundColor","background","paper","minWidth","maxWidth","borderRadius","shape","boxShadow","mode","border","divider","HelpOutlinePulseIcon","HelpOutlineIcon","_ref6","position","zIndex","cursor","animation"],"mappings":"+cAqBaA,aAAY,SAAAA,IAAA,IAAAC,EAAAC,OAAAF,GAAA,IAAA,IAAAG,EAAAC,UAAAC,OAAAC,EAAAC,IAAAA,MAAAJ,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAAAF,EAAAE,GAAAJ,UAAAI,GAqCtB,OArCsBP,EAAAQ,EAAAC,KAAAV,EAAAW,GAAAA,OAAAL,IAAAM,EAAAX,EAAA,mBAUJ,WACjB,IAAAY,EAA+BZ,EAAKa,MAA5BC,EAAKF,EAALE,MAAOC,EAAWH,EAAXG,YACf,OAAIA,EAAoBA,IACnBD,EAEHE,EAACC,GAAwBC,UAAWC,EAAmBC,qBACpDpB,EAAKqB,YAAYP,EAAMQ,OACxBC,EAACC,MACDD,EAACE,EAAI,CAAAP,UAAWC,EAAmBO,QAAUC,SAAA3B,EAAK4B,cAAcd,EAAMY,cALvDH,EAACM,EAAU,CAACC,QAAQ,4DAQxCnB,EAAAX,EAEa,cAAA,SAAC+B,GACb,OAAKA,EACgB,iBAAVA,EAA2BA,EAEpCR,EAACM,EAAW,CAAAC,QAAQ,YAAYZ,UAAWC,EAAmBG,eAC3DS,IAJc,OAOpBpB,EAAAX,EAEe,gBAAA,SAAC+B,GACf,OAAKA,EACgB,iBAAVA,EAA2BA,EAC/BR,EAACM,EAAW,CAAAC,QAAQ,QAAOH,SAAEI,IAFjB,OAGpB/B,CAAA,CAAA,OAAAgC,EAAAjC,EArC8BkC,GAqC9BC,EAAAnC,EAAA,CAAA,CAAAoC,IAAA,SAAAJ,MApCD,WACE,IAAAK,EAA4B3B,KAAKI,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C,SAAY,CAChCC,gBAAiBnB,EAAMG,QAAQiB,WAAWC,MAC1CnB,MAAOF,EAAMG,QAAQM,KAAKL,QAC1BG,QAAS,EACTe,SAAU,QACVC,SAAU,QACVC,aAAcxB,EAAMyB,MAAMD,aAC1BE,UAAkC,SAAvB1B,EAAMG,QAAQwB,KAAkB,kCAAoC,mCAC/EC,oBAAMvE,OAAe2C,EAAMG,QAAQ0B,iBACpCxE,OACM4D,EAAe9B,OAAU,CAC9Be,MAAOF,EAAMG,QAAQiB,WAAWC,OACjC,GAGUS,EAAuBjC,EAAOkC,EAAPlC,CAAwB,SAAAmC,GAAA,IAAGhC,EAAKgC,EAALhC,MAAK,MAAQ,CAC1EiC,SAAU,WACVC,OAAQ,EACRhC,MAAOF,EAAMG,QAAQC,QAAQC,KAC7BmB,aAAc,MACdW,OAAQ,OACRC,UAAW,0BACX,uBAAwB,CACtB,KAAM,CACJV,UAAkC,SAAvB1B,EAAMG,QAAQwB,KAAkB,mCAAqC,mCAElF,MAAO,CACLD,UAAkC,SAAvB1B,EAAMG,QAAQwB,KAAkB,oCAAsC,oCAEnF,OAAQ,CACND,UAAkC,SAAvB1B,EAAMG,QAAQwB,KAAkB,iCAAmC,kCAGnF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{objectWithoutProperties as r,objectSpread2 as e,asyncToGenerator as n,regenerator as o}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{useRef as a,useEffect as l}from"react";import{Box as s,Typography as u,Grid as d,Button as c}from"@mui/material";import{getErrorMessage as f}from"./helpers.js";import{getFormFields as m,getFormValidators as p,getFormPreSubmit as v,isFormRegistered as b}from"./decorator.js";import g from"./validator.js";import h from"./create.input.js";import x from"./create.form-base.js";var y=["type","renderInput"],C=["disabled","visible"],S=x({}),j=h({}),B=function(n){var o,a,l=n.type,s=n.renderInput,u=r(n,y),d=(null===(o=u.name)||void 0===o?void 0:o.toString())||"",c=(null===(a=u.data)||void 0===a?void 0:a[d])||u.defaultValue;return S.mapContext(function(r){var n=r.messageErrors,o=r.onBlur,a=f(r.messageErrors,u.name);if(s)return i(s,e(e({},u),{},{messageErrors:n,onBlur:o,formContext:r}));switch(l){case String:return i(j,e(e({},u),{},{messageErrors:n,onBlur:o,formContext:r}));case Number:return i(j,e(e({},u),{},{slots:e({textFieldProps:{type:"number"}},u.slots),messageErrors:n,onBlur:o,formContext:r}));case Boolean:return t("div",{children:[t("label",{children:[u.label||d,": "]}),i("input",{name:d,type:"checkbox",defaultChecked:c}),i("span",{style:{color:"red"},children:a.error?a.message:""})]});default:return t("div",{children:["Unsupported field type for ",d]})}})},E=function(f){var h,x=f.slots,y=m(f.configClass),j=p(f.configClass),E=v(f.configClass),w=a(null);if(!b(f.configClass)){var k,F=(null===(k=f.configClass)||void 0===k?void 0:k.name)||"Unknown";return t(s,{sx:{border:"1px dashed #ccc",padding:12,borderRadius:4,color:"#333",background:"#fafafa"},children:[i(u,{variant:"subtitle1",sx:{fontWeight:600,marginBottom:6},children:"Form configuration not registered"}),t(u,{variant:"body1",children:['Configuration for "',F,'" was not found. Did you forget to add ',i("code",{children:"@registerForm"})," to the class?"]})]})}var P,I=function(){var r=n(o().m(function r(e){var n,t,i;return o().w(function(r){for(;;)switch(r.p=r.n){case 0:if(w.current=new AbortController,n=w.current.signal,t=e,r.p=1,null==E||!E.handler){r.n=3;break}return r.n=2,E.handler(e,f.data);case 2:null==(t=r.v)&&(t=e);case 3:if(!f.onSubmit){r.n=4;break}return r.n=4,f.onSubmit(t,n);case 4:r.n=6;break;case 5:throw r.p=5,i=r.v,f.onError&&f.onError(i),i;case 6:return r.a(2)}},r,null,[[1,5]])}));return function(e){return r.apply(this,arguments)}}();return l(function(){return function(){var r;null===(r=w.current)||void 0===r||r.abort()}},[]),t(S.Form,{onSubmit:I,validate:new g(j),onError:f.onSubmitError,slots:null==x?void 0:x.formBase,children:[i(d,{container:!0,spacing:2,children:y.map(function(n){var o=n.disabled,t=n.visible,a=r(n,C);if(!("function"==typeof t?t(f.data):!1!==t))return null;var l="function"==typeof o?o(f.data):!0===o;return i(d,e(e({item:!0,xs:12},n.size),{},{children:i(B,e(e({data:f.data},a),{},{disabled:l}))}),n.name.toString())})}),!1===(null==x?void 0:x.isFooter)?null:null!=x&&x.renderSubmitButton?x.renderSubmitButton():i(s,e(e({},null==x?void 0:x.footerProps),{},{sx:e({display:"flex",justifyContent:"flex-end"},(null==x||null===(P=x.footerProps)||void 0===P?void 0:P.sx)||{}),children:i(c,{variant:"contained",color:"primary",type:"submit",sx:{mt:2,flex:"0 0 auto"},children:"Submit"})})),null===(h=f.slots)||void 0===h?void 0:h.bottom]})},w=function(r,n){return function(o){return i(E,e(e({configClass:r},n),o))}};export{B as DecoratorField,E as DecoratorForm,w as createDecoratorForm,E as default};
|
|
2
2
|
//# sourceMappingURL=decorator.form.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorator.form.js","sources":["../../../src/form/decorator.form.tsx"],"sourcesContent":["import { ComponentType, FC } from 'react'\r\nimport { Box, Button, Grid, Typography } from '@mui/material'\r\nimport { IFormInputBase } from './types'\r\nimport { getErrorMessage } from './helpers'\r\nimport { getFormFields, getFormPreSubmit, getFormValidators, isFormRegistered } from './decorator'\r\nimport FormValidator, { IPartialError } from './validator'\r\nimport createInput from './create.input'\r\nimport createFormBase from './create.form-base'\r\n\r\nconst FormBase = createFormBase<any>({})\r\nconst InputInstance = createInput<any>({})\r\n\r\nexport interface IDecoratorFieldProps<T = any> extends IFormInputBase<T> {\r\n type?: any\r\n renderInput?: ComponentType<IFormInputBase<T>>\r\n}\r\n\r\nexport const DecoratorField: FC<IDecoratorFieldProps> = ({ type: inputType, renderInput, ...props }) => {\r\n const name = props.name?.toString() || ''\r\n const defaultValue = props.data?.[name] || props.defaultValue\r\n\r\n return FormBase.mapContext((context) => {\r\n const { messageErrors, onBlur } = context\r\n const err = getErrorMessage(context.messageErrors, props.name as any)\r\n if (renderInput) {\r\n const InputComp = renderInput\r\n return <InputComp {...props} messageErrors={messageErrors} onBlur={onBlur} formContext={context} />\r\n }\r\n switch (inputType) {\r\n case String:\r\n return <InputInstance {...props} messageErrors={messageErrors} onBlur={onBlur} formContext={context} />\r\n case Number:\r\n return (\r\n <InputInstance\r\n {...props}\r\n slots={{ textFieldProps: { type: 'number' }, ...props.slots }}\r\n messageErrors={messageErrors}\r\n onBlur={onBlur}\r\n formContext={context}\r\n />\r\n )\r\n case Boolean:\r\n return (\r\n <div>\r\n <label>{props.label || name}: </label>\r\n <input name={name} type='checkbox' defaultChecked={defaultValue} />\r\n <span style={{ color: 'red' }}>{err.error ? err.message : ''}</span>\r\n </div>\r\n )\r\n default:\r\n return <div>Unsupported field type for {name}</div>\r\n }\r\n })\r\n}\r\n\r\nexport interface IDecoratorFormSlots {\r\n bottom?: React.ReactNode\r\n isFooter?: React.ReactNode | boolean\r\n renderSubmitButton?: () => React.ReactNode\r\n}\r\n\r\nexport interface IDecoratorFormProps<T = any> {\r\n configClass: any\r\n data?: any\r\n onSubmit?: (data: any) => Promise<void>\r\n onError?: (error: any) => void\r\n onSubmitError?: (error: IPartialError<T>) => void\r\n slots?: IDecoratorFormSlots\r\n}\r\n\r\nexport const DecoratorForm: FC<IDecoratorFormProps> = (props) => {\r\n const fields = getFormFields(props.configClass)\r\n const validators = getFormValidators(props.configClass)\r\n const preSubmitConfig = getFormPreSubmit(props.configClass)\r\n\r\n // If the provided configClass isn't registered via @registerForm,\r\n // show a simple, friendly error UI instead of throwing.\r\n if (!isFormRegistered(props.configClass)) {\r\n const name = props.configClass?.name || 'Unknown'\r\n return (\r\n <Box sx={{ border: '1px dashed #ccc', padding: 12, borderRadius: 4, color: '#333', background: '#fafafa' }}>\r\n <Typography variant='subtitle1' sx={{ fontWeight: 600, marginBottom: 6 }}>\r\n Form configuration not registered\r\n </Typography>\r\n <Typography variant='body1'>\r\n Configuration for \"{name}\" was not found. Did you forget to add <code>@registerForm</code> to the class?\r\n </Typography>\r\n </Box>\r\n )\r\n }\r\n\r\n const handleSubmit = async (data: any) => {\r\n let processedData = data\r\n try {\r\n // Execute presubmit handler if exists\r\n if (preSubmitConfig?.handler) {\r\n processedData = await preSubmitConfig.handler(data, props.data)\r\n // If handler returns null/undefined, use original data\r\n if (processedData === null || processedData === undefined) {\r\n processedData = data\r\n }\r\n }\r\n\r\n // Call the original onSubmit with processed data\r\n if (props.onSubmit) {\r\n await props.onSubmit(processedData)\r\n }\r\n } catch (error) {\r\n if (props.onError) {\r\n props.onError(error)\r\n }\r\n throw error\r\n }\r\n }\r\n\r\n const renderFooter = () => {\r\n if (props.slots?.isFooter === false) return null\r\n if (props.slots?.renderSubmitButton) {\r\n return props.slots.renderSubmitButton()\r\n }\r\n return (\r\n <Button variant='contained' color='primary' type='submit' sx={{ mt: 2 }}>\r\n Submit\r\n </Button>\r\n )\r\n }\r\n\r\n return (\r\n <FormBase.Form onSubmit={handleSubmit} validate={new FormValidator(validators)} onError={props.onSubmitError}>\r\n <Grid container spacing={2}>\r\n {fields.map((field) => (\r\n <Grid item key={field.name.toString()} xs={12} {...field.size}>\r\n <DecoratorField data={props.data} {...field} />\r\n </Grid>\r\n ))}\r\n </Grid>\r\n {renderFooter()}\r\n {props.slots?.bottom}\r\n </FormBase.Form>\r\n )\r\n}\r\nexport default DecoratorForm\r\n\r\nexport const createDecoratorForm = function <T>(\r\n configClass: any,\r\n params?: Partial<Omit<IDecoratorFormProps, 'configClass'>>\r\n): ComponentType<Omit<IDecoratorFormProps, 'configClass'>> {\r\n const DecoratorFormComp: FC<Omit<IDecoratorFormProps, 'configClass'>> = (props) => {\r\n return <DecoratorForm configClass={configClass} {...params} {...props} />\r\n }\r\n return DecoratorFormComp\r\n}\r\n"],"names":["FormBase","createFormBase","InputInstance","createInput","DecoratorField","_ref","_props$name","_props$data","inputType","type","renderInput","props","_objectWithoutProperties","_excluded","name","toString","defaultValue","data","mapContext","context","messageErrors","onBlur","err","getErrorMessage","_jsx","_objectSpread","formContext","String","Number","slots","textFieldProps","Boolean","_jsxs","children","label","defaultChecked","style","color","error","message","DecoratorForm","_props$slots3","fields","getFormFields","configClass","validators","getFormValidators","preSubmitConfig","getFormPreSubmit","isFormRegistered","_props$configClass","Box","sx","border","padding","borderRadius","background","Typography","variant","fontWeight","marginBottom","_props$slots","_props$slots2","handleSubmit","_ref2","_asyncToGenerator","_regenerator","m","_callee","processedData","_t","w","_context","p","n","handler","v","onSubmit","onError","a","_x","apply","this","arguments","Form","validate","FormValidator","onSubmitError","Grid","container","spacing","map","field","item","xs","size","isFooter","renderSubmitButton","Button","mt","bottom","createDecoratorForm","params"],"mappings":"8iBASMA,EAAWC,EAAoB,IAC/BC,EAAgBC,EAAiB,IAO1BC,EAA2C,SAA7BC,GAA4E,IAAAC,EAAAC,EAAtCC,EAASH,EAAfI,KAAiBC,EAAWL,EAAXK,YAAgBC,EAAKC,EAAAP,EAAAQ,GACzFC,GAAiBR,QAAVA,EAAAK,EAAMG,gBAAIR,SAAVA,EAAYS,aAAc,GACjCC,GAAyB,QAAVT,EAAAI,EAAMM,YAAI,IAAAV,OAAA,EAAVA,EAAaO,KAASH,EAAMK,aAEjD,OAAOhB,EAASkB,WAAW,SAACC,GAC1B,IAAQC,EAA0BD,EAA1BC,cAAeC,EAAWF,EAAXE,OACjBC,EAAMC,EAAgBJ,EAAQC,cAAeT,EAAMG,MACzD,GAAIJ,EAEF,OAAOc,EADWd,EACDe,EAAAA,KAAKd,GAAK,GAAA,CAAES,cAAeA,EAAeC,OAAQA,EAAQK,YAAaP,KAE1F,OAAQX,GACN,KAAKmB,OACH,OAAOH,EAACtB,EAAauB,EAAAA,KAAKd,GAAK,GAAA,CAAES,cAAeA,EAAeC,OAAQA,EAAQK,YAAaP,KAC9F,KAAKS,OACH,OACEJ,EAACtB,EAAauB,EAAAA,KACRd,GAAK,GAAA,CACTkB,MAAKJ,EAAA,CAAIK,eAAgB,CAAErB,KAAM,WAAeE,EAAMkB,O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WAcGQ,QADGA,EACd9B,EAAMkB,aAANY,IAAWA,OAAXA,EAAAA,EAAa2D,SAGpB,EAGaC,EAAsB,SACjCzD,EACA0D,GAKA,OAHwE,SAAC3F,GACvE,OAAOa,EAACgB,EAAaf,EAAAA,EAAA,CAACmB,YAAaA,GAAiB0D,GAAY3F,GACjE,CAEH"}
|
|
1
|
+
{"version":3,"file":"decorator.form.js","sources":["../../../src/form/decorator.form.tsx"],"sourcesContent":["import { ComponentType, FC, useEffect, useRef } from 'react'\r\nimport { Box, BoxProps, Button, Grid, Typography } from '@mui/material'\r\nimport { IFormInputBase } from './types'\r\nimport { getErrorMessage } from './helpers'\r\nimport { getFormFields, getFormPreSubmit, getFormValidators, isFormRegistered } from './decorator'\r\nimport FormValidator, { IPartialError } from './validator'\r\nimport createInput from './create.input'\r\nimport createFormBase, { IFormBaseSlots } from './create.form-base'\r\n\r\nconst FormBase = createFormBase<any>({})\r\nconst InputInstance = createInput<any>({})\r\n\r\nexport interface IDecoratorFieldProps<T = any> extends IFormInputBase<T> {\r\n type?: any\r\n visible?: boolean | ((data: T) => boolean)\r\n renderInput?: ComponentType<IFormInputBase<T>>\r\n}\r\n\r\nexport const DecoratorField: FC<IDecoratorFieldProps> = ({ type: inputType, renderInput, ...props }) => {\r\n const name = props.name?.toString() || ''\r\n const defaultValue = props.data?.[name] || props.defaultValue\r\n\r\n return FormBase.mapContext((context) => {\r\n const { messageErrors, onBlur } = context\r\n const err = getErrorMessage(context.messageErrors, props.name as any)\r\n if (renderInput) {\r\n const InputComp = renderInput\r\n return <InputComp {...props} messageErrors={messageErrors} onBlur={onBlur} formContext={context} />\r\n }\r\n switch (inputType) {\r\n case String:\r\n return <InputInstance {...props} messageErrors={messageErrors} onBlur={onBlur} formContext={context} />\r\n case Number:\r\n return (\r\n <InputInstance\r\n {...props}\r\n slots={{ textFieldProps: { type: 'number' }, ...props.slots }}\r\n messageErrors={messageErrors}\r\n onBlur={onBlur}\r\n formContext={context}\r\n />\r\n )\r\n case Boolean:\r\n return (\r\n <div>\r\n <label>{props.label || name}: </label>\r\n <input name={name} type='checkbox' defaultChecked={defaultValue} />\r\n <span style={{ color: 'red' }}>{err.error ? err.message : ''}</span>\r\n </div>\r\n )\r\n default:\r\n return <div>Unsupported field type for {name}</div>\r\n }\r\n })\r\n}\r\n\r\nexport interface IDecoratorFormSlots {\r\n bottom?: React.ReactNode\r\n isFooter?: React.ReactNode | boolean\r\n renderSubmitButton?: () => React.ReactNode\r\n formBase?: IFormBaseSlots\r\n footerProps?: BoxProps & { [key: string]: any }\r\n}\r\n\r\nexport interface IDecoratorFormProps<T = any> {\r\n configClass: any\r\n data?: Partial<T>\r\n onSubmit?: (data: Partial<T>, signal?: AbortSignal) => Promise<void>\r\n onError?: (error: any) => void\r\n onSubmitError?: (error: IPartialError<T>) => void\r\n slots?: IDecoratorFormSlots\r\n}\r\n\r\nexport const DecoratorForm: FC<IDecoratorFormProps> = (props) => {\r\n const { slots } = props\r\n const fields = getFormFields(props.configClass)\r\n const validators = getFormValidators(props.configClass)\r\n const preSubmitConfig = getFormPreSubmit(props.configClass)\r\n const abortControllerRef = useRef<AbortController | null>(null)\r\n\r\n // If the provided configClass isn't registered via @registerForm,\r\n // show a simple, friendly error UI instead of throwing.\r\n if (!isFormRegistered(props.configClass)) {\r\n const name = props.configClass?.name || 'Unknown'\r\n return (\r\n <Box sx={{ border: '1px dashed #ccc', padding: 12, borderRadius: 4, color: '#333', background: '#fafafa' }}>\r\n <Typography variant='subtitle1' sx={{ fontWeight: 600, marginBottom: 6 }}>\r\n Form configuration not registered\r\n </Typography>\r\n <Typography variant='body1'>\r\n Configuration for \"{name}\" was not found. Did you forget to add <code>@registerForm</code> to the class?\r\n </Typography>\r\n </Box>\r\n )\r\n }\r\n\r\n const handleSubmit = async (data: any) => {\r\n // Create new AbortController for this submit\r\n abortControllerRef.current = new AbortController()\r\n const signal = abortControllerRef.current.signal\r\n\r\n let processedData = data\r\n try {\r\n // Execute presubmit handler if exists\r\n if (preSubmitConfig?.handler) {\r\n processedData = await preSubmitConfig.handler(data, props.data)\r\n // If handler returns null/undefined, use original data\r\n if (processedData === null || processedData === undefined) {\r\n processedData = data\r\n }\r\n }\r\n\r\n // Call the original onSubmit with processed data and abort signal\r\n if (props.onSubmit) {\r\n await props.onSubmit(processedData, signal)\r\n }\r\n } catch (error) {\r\n if (props.onError) {\r\n props.onError(error)\r\n }\r\n throw error\r\n }\r\n }\r\n\r\n const renderFooter = () => {\r\n if (slots?.isFooter === false) return null\r\n if (slots?.renderSubmitButton) {\r\n return slots.renderSubmitButton()\r\n }\r\n return (\r\n <Box {...slots?.footerProps} sx={{ display: 'flex', justifyContent: 'flex-end', ...(slots?.footerProps?.sx || {}) }}>\r\n <Button variant='contained' color='primary' type='submit' sx={{ mt: 2, flex: '0 0 auto' }}>\r\n Submit\r\n </Button>\r\n </Box>\r\n )\r\n }\r\n\r\n useEffect(() => {\r\n return () => {\r\n // Abort any pending request when component unmounts\r\n abortControllerRef.current?.abort()\r\n }\r\n }, [])\r\n\r\n return (\r\n <FormBase.Form onSubmit={handleSubmit} validate={new FormValidator(validators)} onError={props.onSubmitError} slots={slots?.formBase}>\r\n <Grid container spacing={2}>\r\n {fields.map((field) => {\r\n const { disabled, visible, ...fieldOther } = field\r\n // Check visibility, default is visible (true or undefined)\r\n const isVisible = typeof visible === 'function' ? visible(props.data) : visible !== false\r\n if (!isVisible) return null\r\n // Check disabled state, default is enabled (false or undefined)\r\n const isDisabled = typeof disabled === 'function' ? disabled(props.data) : disabled === true\r\n return (\r\n <Grid item key={field.name.toString()} xs={12} {...field.size}>\r\n <DecoratorField data={props.data} {...fieldOther} disabled={isDisabled} />\r\n </Grid>\r\n )\r\n })}\r\n </Grid>\r\n {renderFooter()}\r\n {props.slots?.bottom}\r\n </FormBase.Form>\r\n )\r\n}\r\nexport default DecoratorForm\r\n\r\nexport const createDecoratorForm = function <T>(\r\n configClass: any,\r\n params?: Partial<Omit<IDecoratorFormProps<T>, 'configClass'>>\r\n): ComponentType<Omit<IDecoratorFormProps<T>, 'configClass'>> {\r\n const DecoratorFormComp: FC<Omit<IDecoratorFormProps<T>, 'configClass'>> = (props) => {\r\n return <DecoratorForm configClass={configClass} {...params} {...props} />\r\n }\r\n return DecoratorFormComp\r\n}\r\n"],"names":["FormBase","createFormBase","InputInstance","createInput","DecoratorField","_ref","_props$name","_props$data","inputType","type","renderInput","props","_objectWithoutProperties","_excluded","name","toString","defaultValue","data","mapContext","context","messageErrors","onBlur","err","getErrorMessage","_jsx","_objectSpread","formContext","String","Number","slots","textFieldProps","Boolean","_jsxs","children","label","defaultChecked","style","color","error","message","DecoratorForm","_props$slots","fields","getFormFields","configClass","validators","getFormValidators","preSubmitConfig","getFormPreSubmit","abortControllerRef","useRef","isFormRegistered","_props$configClass","Box","sx","border","padding","borderRadius","background","Typography","variant","fontWeight","marginBottom","_slots$footerProps","handleSubmit","_ref2","_asyncToGenerator","_regenerator","m","_callee","signal","processedData","_t","w","_context","p","n","current","AbortController","handler","v","onSubmit","onError","a","_x","apply","this","arguments","useEffect","_abortControllerRef$c","abort","Form","validate","FormValidator","onSubmitError","formBase","Grid","container","spacing","map","field","disabled","visible","fieldOther","_excluded2","isDisabled","item","xs","size","isFooter","renderSubmitButton","footerProps","display","justifyContent","Button","mt","flex","bottom","createDecoratorForm","params"],"mappings":"qnBASMA,EAAWC,EAAoB,IAC/BC,EAAgBC,EAAiB,IAQ1BC,EAA2C,SAA7BC,GAA4E,IAAAC,EAAAC,EAAtCC,EAASH,EAAfI,KAAiBC,EAAWL,EAAXK,YAAgBC,EAAKC,EAAAP,EAAAQ,GACzFC,GAAiBR,QAAVA,EAAAK,EAAMG,gBAAIR,SAAVA,EAAYS,aAAc,GACjCC,GAAyB,QAAVT,EAAAI,EAAMM,YAAI,IAAAV,OAAA,EAAVA,EAAaO,KAASH,EAAMK,aAEjD,OAAOhB,EAASkB,WAAW,SAACC,GAC1B,IAAQC,EAA0BD,EAA1BC,cAAeC,EAAWF,E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2E,SAAC5G,GAC1E,OAAOa,EAACgB,EAAaf,EAAAA,EAAA,CAACmB,YAAaA,GAAiB2E,GAAY5G,GACjE,CAEH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorator.js","sources":["../../../src/form/decorator.ts"],"sourcesContent":["import 'reflect-metadata'\r\nimport { ComponentType } from 'react'\r\nimport { IFormInputBase } from './types'\r\nimport { IConfigValue, IFormValidatorConfig } from './validator'\r\n\r\nconst ClassRegistry = new Map<string, any>()\r\n\r\nexport function registerForm(name?: string) {\r\n return function <T extends { new (...args: any[]): {} }>(constructor: T) {\r\n const key = name || constructor.name\r\n ClassRegistry.set(key, constructor)\r\n class RegisteredClass extends constructor {\r\n __class = key\r\n constructor(...args: any[]) {\r\n super(...args)\r\n this.__class = key\r\n }\r\n }\r\n Object.defineProperty(RegisteredClass, 'name', { value: constructor.name })\r\n Object.defineProperty(RegisteredClass, '__class', { value: key })\r\n return RegisteredClass\r\n }\r\n}\r\n\r\n/**\r\n * Check whether a class (constructor) or an instance has been registered\r\n * with the @registerForm decorator.\r\n *\r\n * Accepts:\r\n * - the decorated constructor (function)\r\n * - the original constructor (function)\r\n * - an instance of the class\r\n *\r\n * Returns true when the underlying registry contains an entry for the\r\n * class key (either the custom name provided to the decorator or the\r\n * constructor name).\r\n */\r\nexport function isFormRegistered(target: any): boolean {\r\n if (!target) return false\r\n const ctor = typeof target === 'function' ? target : target?.constructor\r\n if (!ctor) return false\r\n const key = (ctor as any).__class || (ctor as any).name\r\n if (!key) return false\r\n return ClassRegistry.has(key)\r\n}\r\n\r\nexport interface IPreSubmitMetadata<T = any> {\r\n handler: (data: T, oldData: T) => Promise<any> | any\r\n}\r\n\r\nexport function formPreSubmit<T = any>(handler: IPreSubmitMetadata<T>['handler']) {\r\n return function <T extends { new (...args: any[]): {} }>(constructor: T) {\r\n Reflect.defineMetadata('form:presubmit', { handler }, constructor)\r\n return constructor\r\n }\r\n}\r\n\r\nexport function getFormPreSubmit(targetClass: any): IPreSubmitMetadata | undefined {\r\n return Reflect.getMetadata('form:presubmit', targetClass)\r\n}\r\n\r\nexport interface IFieldMetadata<T = any> {\r\n name: keyof T | string\r\n label?: string\r\n placeholder?: string\r\n default?: any\r\n type?: any\r\n size?: Partial<Record<'xs' | 'sm' | 'md' | 'lg' | 'xl', number>>\r\n renderInput?: ComponentType<IFormInputBase<T>>\r\n}\r\n\r\nexport function formField(options: Omit<IFieldMetadata, 'name'>) {\r\n return function (target: any, propertyKey: string) {\r\n const designType = Reflect.getMetadata('design:type', target, propertyKey)\r\n const actualType = options.type || designType\r\n const existing: IFieldMetadata[] = Reflect.getMetadata('form:fields', target.constructor) || []\r\n const fields = [...existing]\r\n fields.push({ name: propertyKey, type: actualType, label: options.label || propertyKey, ...options })\r\n Reflect.defineMetadata('form:fields', fields, target.constructor)\r\n }\r\n}\r\n\r\nexport const getFormFields = (targetClass: any): IFieldMetadata[] => {\r\n return Reflect.getMetadata('form:fields', targetClass) || []\r\n}\r\n\r\nexport interface IValidationMetadata extends IConfigValue {\r\n name: string\r\n}\r\n\r\nexport function formValidate(options: Omit<IValidationMetadata, 'name'>) {\r\n return function (target: any, propertyKey: string) {\r\n const existing: IValidationMetadata[] = Reflect.getMetadata('form:validators', target.constructor) || []\r\n const validators = [...existing]\r\n validators.push({ name: propertyKey, ...options })\r\n Reflect.defineMetadata('form:validators', validators, target.constructor)\r\n }\r\n}\r\n\r\nexport function getFormValidators<T = any>(targetClass: any): IFormValidatorConfig<T> {\r\n const metas: IValidationMetadata[] = Reflect.getMetadata('form:validators', targetClass) || []\r\n return metas.reduce<IFormValidatorConfig<T>>((acc, curr) => {\r\n acc[curr.name as keyof T] = { Rules: curr.Rules, label: curr.label }\r\n return acc\r\n }, {})\r\n}\r\n"],"names":["ClassRegistry","Map","registerForm","name","constructor","key","set","RegisteredClass","_constructor","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_callSuper","this","concat","_defineProperty","__class","_inherits","_createClass","Object","defineProperty","value","isFormRegistered","target","ctor","has","formPreSubmit","handler","Reflect","defineMetadata","getFormPreSubmit","targetClass","getMetadata","formField","options","propertyKey","designType","actualType","type","existing","fields","_toConsumableArray","push","_objectSpread","label","getFormFields","formValidate","validators","getFormValidators","reduce","acc","curr","Rules"],"mappings":"2NAKA,IAAMA,EAAgB,IAAIC,IAEpB,SAAUC,EAAaC,GAC3B,OAAO,SAAkDC,GACvD,IAAMC,EAAMF,GAAQC,EAAYD,KAChCH,EAAcM,IAAID,EAAKD,GAAY,IAC7BG,WAAgBC,GAEpB,SAAAD,IAA0B,IAAAE,EAAAC,OAAAH,GAAA,IAAA,IAAAI,EAAAC,UAAAC,OAAXC,EAAWC,IAAAA,MAAAJ,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAAXF,EAAWE,GAAAJ,UAAAI,GAEN,OADlBP,EAAAQ,EAAAC,KAAAX,EAAAY,GAAAA,OAASL,IAAKM,EAAAX,EAAA,UAFNJ,GAGRI,EAAKY,QAAUhB,EAAGI,CACpB,CAAC,OAAAa,EAAAf,EAAAC,GAAAe,EAAAhB,EAAA,EAL2BH,GAS9B,OAFAoB,OAAOC,eAAelB,EAAiB,OAAQ,CAAEmB,MAAOtB,EAAYD,OACpEqB,OAAOC,eAAelB,EAAiB,UAAW,CAAEmB,MAAOrB,IACpDE,CACR,CACH,CAeM,SAAUoB,EAAiBC,GAC/B,IAAKA,EAAQ,OAAO,EACpB,IAAMC,EAAyB,mBAAXD,EAAwBA,EAASA,aAAAA,EAAAA,EAAQxB,YAC7D,IAAKyB,EAAM,OAAO,EAClB,IAAMxB,EAAOwB,EAAaR,SAAYQ,EAAa1B,KACnD,QAAKE,GACEL,EAAc8B,IAAIzB,EAC3B,CAMM,SAAU0B,EAAuBC,GACrC,OAAO,SAAkD5B,GAEvD,OADA6B,QAAQC,eAAe,iBAAkB,CAAEF,QAAAA,GAAW5B,GAC/CA,CACR,CACH,CAEM,SAAU+B,EAAiBC,GAC/B,OAAOH,QAAQI,YAAY,iBAAkBD,EAC/C,
|
|
1
|
+
{"version":3,"file":"decorator.js","sources":["../../../src/form/decorator.ts"],"sourcesContent":["import 'reflect-metadata'\r\nimport { ComponentType } from 'react'\r\nimport { IFormInputBase } from './types'\r\nimport { IConfigValue, IFormValidatorConfig } from './validator'\r\n\r\nconst ClassRegistry = new Map<string, any>()\r\n\r\nexport function registerForm(name?: string) {\r\n return function <T extends { new (...args: any[]): {} }>(constructor: T) {\r\n const key = name || constructor.name\r\n ClassRegistry.set(key, constructor)\r\n class RegisteredClass extends constructor {\r\n __class = key\r\n constructor(...args: any[]) {\r\n super(...args)\r\n this.__class = key\r\n }\r\n }\r\n Object.defineProperty(RegisteredClass, 'name', { value: constructor.name })\r\n Object.defineProperty(RegisteredClass, '__class', { value: key })\r\n return RegisteredClass\r\n }\r\n}\r\n\r\n/**\r\n * Check whether a class (constructor) or an instance has been registered\r\n * with the @registerForm decorator.\r\n *\r\n * Accepts:\r\n * - the decorated constructor (function)\r\n * - the original constructor (function)\r\n * - an instance of the class\r\n *\r\n * Returns true when the underlying registry contains an entry for the\r\n * class key (either the custom name provided to the decorator or the\r\n * constructor name).\r\n */\r\nexport function isFormRegistered(target: any): boolean {\r\n if (!target) return false\r\n const ctor = typeof target === 'function' ? target : target?.constructor\r\n if (!ctor) return false\r\n const key = (ctor as any).__class || (ctor as any).name\r\n if (!key) return false\r\n return ClassRegistry.has(key)\r\n}\r\n\r\nexport interface IPreSubmitMetadata<T = any> {\r\n handler: (data: T, oldData: T) => Promise<any> | any\r\n}\r\n\r\nexport function formPreSubmit<T = any>(handler: IPreSubmitMetadata<T>['handler']) {\r\n return function <T extends { new (...args: any[]): {} }>(constructor: T) {\r\n Reflect.defineMetadata('form:presubmit', { handler }, constructor)\r\n return constructor\r\n }\r\n}\r\n\r\nexport function getFormPreSubmit(targetClass: any): IPreSubmitMetadata | undefined {\r\n return Reflect.getMetadata('form:presubmit', targetClass)\r\n}\r\n\r\nexport interface IFieldMetadata<T = any> {\r\n name: keyof T | string\r\n label?: string\r\n placeholder?: string\r\n default?: any\r\n type?: any\r\n size?: Partial<Record<'xs' | 'sm' | 'md' | 'lg' | 'xl', number>>\r\n visible?: boolean | ((data?: T) => boolean)\r\n disabled?: boolean | ((data?: T) => boolean)\r\n renderInput?: ComponentType<IFormInputBase<T>>\r\n}\r\n\r\nexport function formField(options: Omit<IFieldMetadata, 'name'>) {\r\n return function (target: any, propertyKey: string) {\r\n const designType = Reflect.getMetadata('design:type', target, propertyKey)\r\n const actualType = options.type || designType\r\n const existing: IFieldMetadata[] = Reflect.getMetadata('form:fields', target.constructor) || []\r\n const fields = [...existing]\r\n fields.push({ name: propertyKey, type: actualType, label: options.label || propertyKey, ...options })\r\n Reflect.defineMetadata('form:fields', fields, target.constructor)\r\n }\r\n}\r\n\r\nexport const getFormFields = (targetClass: any): IFieldMetadata[] => {\r\n return Reflect.getMetadata('form:fields', targetClass) || []\r\n}\r\n\r\nexport interface IValidationMetadata extends IConfigValue {\r\n name: string\r\n}\r\n\r\nexport function formValidate(options: Omit<IValidationMetadata, 'name'>) {\r\n return function (target: any, propertyKey: string) {\r\n const existing: IValidationMetadata[] = Reflect.getMetadata('form:validators', target.constructor) || []\r\n const validators = [...existing]\r\n validators.push({ name: propertyKey, ...options })\r\n Reflect.defineMetadata('form:validators', validators, target.constructor)\r\n }\r\n}\r\n\r\nexport function getFormValidators<T = any>(targetClass: any): IFormValidatorConfig<T> {\r\n const metas: IValidationMetadata[] = Reflect.getMetadata('form:validators', targetClass) || []\r\n return metas.reduce<IFormValidatorConfig<T>>((acc, curr) => {\r\n acc[curr.name as keyof T] = { Rules: curr.Rules, label: curr.label }\r\n return acc\r\n }, {})\r\n}\r\n"],"names":["ClassRegistry","Map","registerForm","name","constructor","key","set","RegisteredClass","_constructor","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_callSuper","this","concat","_defineProperty","__class","_inherits","_createClass","Object","defineProperty","value","isFormRegistered","target","ctor","has","formPreSubmit","handler","Reflect","defineMetadata","getFormPreSubmit","targetClass","getMetadata","formField","options","propertyKey","designType","actualType","type","existing","fields","_toConsumableArray","push","_objectSpread","label","getFormFields","formValidate","validators","getFormValidators","reduce","acc","curr","Rules"],"mappings":"2NAKA,IAAMA,EAAgB,IAAIC,IAEpB,SAAUC,EAAaC,GAC3B,OAAO,SAAkDC,GACvD,IAAMC,EAAMF,GAAQC,EAAYD,KAChCH,EAAcM,IAAID,EAAKD,GAAY,IAC7BG,WAAgBC,GAEpB,SAAAD,IAA0B,IAAAE,EAAAC,OAAAH,GAAA,IAAA,IAAAI,EAAAC,UAAAC,OAAXC,EAAWC,IAAAA,MAAAJ,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAAXF,EAAWE,GAAAJ,UAAAI,GAEN,OADlBP,EAAAQ,EAAAC,KAAAX,EAAAY,GAAAA,OAASL,IAAKM,EAAAX,EAAA,UAFNJ,GAGRI,EAAKY,QAAUhB,EAAGI,CACpB,CAAC,OAAAa,EAAAf,EAAAC,GAAAe,EAAAhB,EAAA,EAL2BH,GAS9B,OAFAoB,OAAOC,eAAelB,EAAiB,OAAQ,CAAEmB,MAAOtB,EAAYD,OACpEqB,OAAOC,eAAelB,EAAiB,UAAW,CAAEmB,MAAOrB,IACpDE,CACR,CACH,CAeM,SAAUoB,EAAiBC,GAC/B,IAAKA,EAAQ,OAAO,EACpB,IAAMC,EAAyB,mBAAXD,EAAwBA,EAASA,aAAAA,EAAAA,EAAQxB,YAC7D,IAAKyB,EAAM,OAAO,EAClB,IAAMxB,EAAOwB,EAAaR,SAAYQ,EAAa1B,KACnD,QAAKE,GACEL,EAAc8B,IAAIzB,EAC3B,CAMM,SAAU0B,EAAuBC,GACrC,OAAO,SAAkD5B,GAEvD,OADA6B,QAAQC,eAAe,iBAAkB,CAAEF,QAAAA,GAAW5B,GAC/CA,CACR,CACH,CAEM,SAAU+B,EAAiBC,GAC/B,OAAOH,QAAQI,YAAY,iBAAkBD,EAC/C,CAcM,SAAUE,EAAUC,GACxB,OAAO,SAAUX,EAAaY,GAC5B,IAAMC,EAAaR,QAAQI,YAAY,cAAeT,EAAQY,GACxDE,EAAaH,EAAQI,MAAQF,EAC7BG,EAA6BX,QAAQI,YAAY,cAAeT,EAAOxB,cAAgB,GACvFyC,EAAMC,EAAOF,GACnBC,EAAOE,KAAIC,EAAA,CAAG7C,KAAMqC,EAAaG,KAAMD,EAAYO,MAAOV,EAAQU,OAAST,GAAgBD,IAC3FN,QAAQC,eAAe,cAAeW,EAAQjB,EAAOxB,YACtD,CACH,KAEa8C,EAAgB,SAACd,GAC5B,OAAOH,QAAQI,YAAY,cAAeD,IAAgB,EAC5D,EAMM,SAAUe,EAAaZ,GAC3B,OAAO,SAAUX,EAAaY,GAC5B,IAAMI,EAAkCX,QAAQI,YAAY,kBAAmBT,EAAOxB,cAAgB,GAChGgD,EAAUN,EAAOF,GACvBQ,EAAWL,KAAIC,EAAA,CAAG7C,KAAMqC,GAAgBD,IACxCN,QAAQC,eAAe,kBAAmBkB,EAAYxB,EAAOxB,YAC9D,CACH,CAEM,SAAUiD,EAA2BjB,GAEzC,OADqCH,QAAQI,YAAY,kBAAmBD,IAAgB,IAC/EkB,OAAgC,SAACC,EAAKC,GAEjD,OADAD,EAAIC,EAAKrD,MAAmB,CAAEsD,MAAOD,EAAKC,MAAOR,MAAOO,EAAKP,OACtDM,CACR,EAAE,GACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-base.js","sources":["../../../../src/http-service/base/service-base.ts"],"sourcesContent":["import { authService } from 'partner-oidc-auth'\r\nimport type { AxiosError, AxiosInstance, AxiosRequestConfig, InternalAxiosRequestConfig } from 'axios'\r\nimport axios from 'axios'\r\nimport { HttpService } from './gateway'\r\nimport { createObjectSingleton } from '../../utils/singletone'\r\nimport { handleResponseError, ApiAlertContext } from './helpers'\r\n\r\nexport interface ITokenProvider {\r\n getToken: () => Promise<string | undefined>\r\n reSignIn: () => Promise<void>\r\n getRoles: () => Promise<string[] | undefined>\r\n}\r\n\r\nclass TokenProviderDefault implements ITokenProvider {\r\n async getToken(): Promise<string | undefined> {\r\n return (await authService.getAccessToken()) || undefined\r\n }\r\n async reSignIn() {\r\n await authService.signIn({})\r\n }\r\n async getRoles(): Promise<string[] | undefined> {\r\n const roles = await authService.getRoles()\r\n return roles || undefined\r\n }\r\n}\r\n\r\n/**\r\n * Base service class for HTTP operations with authentication and error handling\r\n * Provides common CRUD operations with automatic token management and retry logic\r\n */\r\nexport default class ServiceBase {\r\n static key_token_provider = '__t1_22zzz_t_pro_key__'\r\n static get tokenProvider(): ITokenProvider {\r\n const ObjectProvider = createObjectSingleton<ITokenProvider>(ServiceBase.key_token_provider)\r\n return ObjectProvider.get() ?? new TokenProviderDefault()\r\n }\r\n static setTokenProvider(provider: ITokenProvider) {\r\n const ObjectProvider = createObjectSingleton<ITokenProvider>(ServiceBase.key_token_provider)\r\n ObjectProvider.set(provider ?? new TokenProviderDefault())\r\n }\r\n\r\n private _http: AxiosInstance\r\n constructor(http?: AxiosInstance) {\r\n if (http) {\r\n this._http = http\r\n } else {\r\n this._http = HttpService\r\n }\r\n this.mapResponse()\r\n }\r\n /**\r\n * Maps response and request interceptors for handling authentication and errors\r\n * Automatically adds authorization headers and retries requests on 401 errors\r\n */\r\n mapResponse = () => {\r\n this._http.interceptors.response.use(\r\n (res) => res,\r\n (err) => this.tryFetchToken(err, handleResponseError)\r\n )\r\n this._http.interceptors.request.use((req) => {\r\n return this.interuptHeader(req)\r\n })\r\n }\r\n /**\r\n * Tries to fetch a new token if the current one is expired\r\n * @param error - The axios error containing response data\r\n * @param next - The next middleware function to call\r\n * @returns A promise resolving to the response data or an error\r\n */\r\n tryFetchToken = async (error: AxiosError, next: (error: AxiosError) => Promise<any>): Promise<any> => {\r\n const originalRequest = error.config\r\n if (error?.response?.status === 401 && originalRequest) {\r\n await ServiceBase.tokenProvider.reSignIn()\r\n await this.interuptHeader(originalRequest)\r\n return axios(originalRequest)\r\n }\r\n return next(error)\r\n }\r\n private _token?: string\r\n /**\r\n * Sets the token to be used for authentication\r\n * @param token - The token string to set\r\n */\r\n setToken(token?: string) {\r\n this._token = token\r\n }\r\n /**\r\n * Gets the current token, fetching a new one if not set\r\n * @returns A promise resolving to the token string\r\n */\r\n getToken = async () => {\r\n return this._token === undefined ? await ServiceBase.tokenProvider.getToken() : this._token\r\n }\r\n /**\r\n * Adds custom headers to the request configuration\r\n * @param config - The Axios request configuration object\r\n * @returns A promise resolving to the updated configuration object\r\n */\r\n async addCustomHeader(config?: AxiosRequestConfig) {\r\n if (!config) {\r\n config = { headers: {} }\r\n }\r\n if (!config.headers) {\r\n config.headers = {}\r\n }\r\n return config\r\n }\r\n /**\r\n * Intercepts the request to add the authorization token\r\n * @param config - The Axios request configuration object\r\n * @returns The updated configuration object with the token added\r\n */\r\n private async interuptHeader(config: InternalAxiosRequestConfig) {\r\n await this.addtoken(config)\r\n return config\r\n }\r\n /**\r\n * Adds the authorization token to the request headers\r\n * @param config - The Axios request configuration object\r\n * @returns The updated configuration object with the token added\r\n */\r\n private addtoken = async (config?: AxiosRequestConfig) => {\r\n const _token = await this.getToken()\r\n if (_token && config?.headers) {\r\n config.headers.Authorization = 'Bearer ' + _token\r\n }\r\n return config\r\n }\r\n /**\r\n * HTTP GET request with automatic authentication\r\n * @param url - The request URL\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data\r\n */\r\n async get<TModel>(url: string, config?: AxiosRequestConfig | undefined) {\r\n const response = await this._http.get<TModel>(url, await this.addCustomHeader(config))\r\n return response.data\r\n }\r\n /**\r\n * HTTP GET request with error handling\r\n * @param url - The request URL\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data or null if an error occurs\r\n */\r\n async tryGet<TModel>(url: string, config?: AxiosRequestConfig | undefined) {\r\n try {\r\n return this.get<TModel>(url, config)\r\n } catch {\r\n return null\r\n }\r\n }\r\n /**\r\n * HTTP POST request with automatic authentication\r\n * @param url - The request URL\r\n * @param data - Optional data to send in the request body\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data\r\n */\r\n async post<TModel>(url: string, data?: any, config?: AxiosRequestConfig | undefined) {\r\n const response = await this._http.post<TModel>(url, data, await this.addCustomHeader(config))\r\n return response.data\r\n }\r\n /**\r\n * HTTP PUT request with automatic authentication\r\n * @param url - The request URL\r\n * @param data - Optional data to send in the request body\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data\r\n */\r\n async put<TModel>(url: string, data?: any, config?: AxiosRequestConfig | undefined) {\r\n const response = await this._http.put<TModel>(url, data, await this.addCustomHeader(config))\r\n return response.data\r\n }\r\n /**\r\n * HTTP PUT request with error handling\r\n * @param url - The request URL\r\n * @param data - Optional data to send in the request body\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data or null if an error occurs\r\n */\r\n async tryPut<TModel>(url: string, data?: any, config?: AxiosRequestConfig | undefined) {\r\n try {\r\n await this.addCustomHeader(config)\r\n return await this.put<TModel>(url, data, config)\r\n } catch (error) {\r\n // processError(error as any)\r\n return null\r\n }\r\n }\r\n /**\r\n * HTTP PATCH request with automatic authentication\r\n * @param url - The request URL\r\n * @param data - Optional data to send in the request body\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data\r\n */\r\n async patch<TModel>(url: string, data?: any, config?: AxiosRequestConfig | undefined) {\r\n const response = await this._http.patch<TModel>(url, data, await this.addCustomHeader(config))\r\n return response.data\r\n }\r\n /**\r\n * HTTP PATCH request with error handling\r\n * @param url - The request URL\r\n * @param data - Optional data to send in the request body\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data or null if an error occurs\r\n */\r\n async tryPatch<TModel>(url: string, data?: any, config?: AxiosRequestConfig | undefined) {\r\n try {\r\n await this.addCustomHeader(config)\r\n return await this.patch<TModel>(url, data, config)\r\n } catch (error) {\r\n // processError(error as any)\r\n return null\r\n }\r\n }\r\n /**\r\n * HTTP POST request with error handling\r\n * @param url - The request URL\r\n * @param data - Optional data to send in the request body\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data or null if an error occurs\r\n */\r\n async tryPost<TModel>(url: string, data?: any, config?: AxiosRequestConfig | undefined) {\r\n try {\r\n return await this.post<TModel>(url, data, config)\r\n } catch (error) {\r\n // processError(error as any)\r\n return null\r\n }\r\n }\r\n /**\r\n * HTTP DELETE request with automatic authentication\r\n * @param url - The request URL\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data\r\n */\r\n async delete<TModel>(url: string, config?: AxiosRequestConfig | undefined) {\r\n const response = await this._http.delete<TModel>(url, await this.addCustomHeader(config))\r\n return response.data\r\n }\r\n /**\r\n * HTTP DELETE request with error handling\r\n * @param url - The request URL\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data or null if an error occurs\r\n */\r\n async tryDelete<TModel>(url: string, config?: AxiosRequestConfig | undefined) {\r\n try {\r\n return await this.delete<TModel>(url, await this.addCustomHeader(config))\r\n } catch (error) {\r\n // processError(error as any)\r\n return null\r\n }\r\n }\r\n /**\r\n * Push notification with error handling\r\n * @param action - The function to execute\r\n * @param p - Parameters to pass to the function\r\n * @returns Promise with the result of the function execution\r\n */\r\n async tryPushNotify<TFunc extends (...param: any[]) => any>(action: TFunc, ...p: Parameters<TFunc>) {\r\n try {\r\n return await this.pushNotify(action, ...p)\r\n } catch (err) {}\r\n }\r\n /**\r\n * Push notification with error handling\r\n * @param action - The function to execute\r\n * @param p - Parameters to pass to the function\r\n * @returns Promise with the result of the function execution\r\n */\r\n async pushNotify<TFunc extends (...param: any[]) => any>(action: TFunc, ...p: Parameters<TFunc>): Promise<ReturnType<TFunc>> {\r\n try {\r\n return await action.bind(this)(...p)\r\n } catch (err) {\r\n const error = err as AxiosError\r\n const data = error.response?.data as any\r\n if (data) {\r\n const keys = Object.keys(data)\r\n keys.forEach((key) => {\r\n const errors = data[key] as string[]\r\n if (Array.isArray(errors)) {\r\n errors.forEach((message) => {\r\n ApiAlertContext?.ApiAlert?.PushError(message)\r\n })\r\n }\r\n })\r\n }\r\n throw error\r\n }\r\n }\r\n}\r\n/**\r\n * CancelAction class extends AbortController to provide a cancel method\r\n * This class can be used to cancel ongoing HTTP requests\r\n */\r\nexport class CancelAction extends AbortController {\r\n cancel = () => {\r\n this.trigger && this.trigger()\r\n super.abort()\r\n }\r\n trigger?: () => void\r\n}\r\n"],"names":["TokenProviderDefault","_createClass","_classCallCheck","key","value","_getToken","_asyncToGenerator","_regenerator","m","_callee","_t","w","_context","n","authService","getAccessToken","v","undefined","a","apply","this","arguments","_reSignIn","_callee2","_context2","signIn","_getRoles","_callee3","roles","_context3","getRoles","ServiceBase","http","_this","_defineProperty","_http","interceptors","response","use","res","err","tryFetchToken","handleResponseError","request","req","interuptHeader","_ref","_callee4","error","next","_error$response","originalRequest","_context4","config","status","tokenProvider","reSignIn","axios","_x","_x2","_callee5","_t2","_context5","_token","getToken","_ref3","_callee6","_context6","headers","Authorization","_x3","HttpService","mapResponse","token","_addCustomHeader","_callee7","_context7","_x4","_interuptHeader","_callee8","_context8","addtoken","_x5","_get","_callee9","url","_t3","_t4","_context9","addCustomHeader","get","call","data","_x6","_x7","_tryGet","_callee0","_context0","p","_x8","_x9","_post","_callee1","_t6","_t7","_t8","_context1","post","_x0","_x1","_x10","_put","_callee10","_t9","_t0","_t1","_context10","put","_x11","_x12","_x13","_tryPut","_callee11","_context11","_x14","_x15","_x16","_patch","_callee12","_t11","_t12","_t13","_context12","patch","_x17","_x18","_x19","_tryPatch","_callee13","_context13","_x20","_x21","_x22","_tryPost","_callee14","_context14","_x23","_x24","_x25","_delete2","_callee15","_t16","_t17","_context15","_x26","_x27","_tryDelete","_callee16","_t18","_t19","_context16","_x28","_x29","_tryPushNotify","_callee17","action","_len","_key","_args17","_context17","length","Array","pushNotify","concat","_x30","_pushNotify","_callee18","_len2","_key2","_error$response2","_t22","_args18","_context18","bind","Object","keys","forEach","errors","isArray","message","_ApiAlertContext$ApiA","ApiAlertContext","ApiAlert","PushError","_x31","_ObjectProvider$get","createObjectSingleton","key_token_provider","provider","set","CancelAction","_AbortController","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+BC"}
|
|
1
|
+
{"version":3,"file":"service-base.js","sources":["../../../../src/http-service/base/service-base.ts"],"sourcesContent":["import { authService } from 'partner-oidc-auth'\r\nimport type { AxiosError, AxiosInstance, AxiosRequestConfig, InternalAxiosRequestConfig } from 'axios'\r\nimport axios from 'axios'\r\nimport { HttpService } from './gateway'\r\nimport { createObjectSingleton } from '../../utils/singletone'\r\nimport { handleResponseError, ApiAlertContext } from './helpers'\r\n\r\nexport interface ITokenProvider {\r\n getToken: () => Promise<string | undefined>\r\n reSignIn: () => Promise<void>\r\n getRoles: () => Promise<string[] | undefined>\r\n}\r\n\r\nclass TokenProviderDefault implements ITokenProvider {\r\n async getToken(): Promise<string | undefined> {\r\n return (await authService.getAccessToken()) || undefined\r\n }\r\n async reSignIn() {\r\n await authService.signIn({})\r\n }\r\n async getRoles(): Promise<string[] | undefined> {\r\n const roles = await authService.getRoles()\r\n return roles || undefined\r\n }\r\n}\r\n\r\n/**\r\n * Base service class for HTTP operations with authentication and error handling\r\n * Provides common CRUD operations with automatic token management and retry logic\r\n */\r\nexport default class ServiceBase {\r\n static key_token_provider = '__t1_22zzz_t_pro_key__'\r\n static get tokenProvider(): ITokenProvider {\r\n const ObjectProvider = createObjectSingleton<ITokenProvider>(ServiceBase.key_token_provider)\r\n return ObjectProvider.get() ?? new TokenProviderDefault()\r\n }\r\n static setTokenProvider(provider: ITokenProvider) {\r\n const ObjectProvider = createObjectSingleton<ITokenProvider>(ServiceBase.key_token_provider)\r\n ObjectProvider.set(provider ?? new TokenProviderDefault())\r\n }\r\n\r\n private _http: AxiosInstance\r\n constructor(http?: AxiosInstance) {\r\n this._http = http || HttpService\r\n this.mapResponse()\r\n }\r\n /**\r\n * Maps response and request interceptors for handling authentication and errors\r\n * Automatically adds authorization headers and retries requests on 401 errors\r\n */\r\n mapResponse = () => {\r\n this._http.interceptors.response.use(\r\n (res) => res,\r\n (err) => this.tryFetchToken(err, handleResponseError)\r\n )\r\n this._http.interceptors.request.use((req) => {\r\n return this.interuptHeader(req)\r\n })\r\n }\r\n /**\r\n * Tries to fetch a new token if the current one is expired\r\n * @param error - The axios error containing response data\r\n * @param next - The next middleware function to call\r\n * @returns A promise resolving to the response data or an error\r\n */\r\n tryFetchToken = async (error: AxiosError, next: (error: AxiosError) => Promise<any>): Promise<any> => {\r\n const originalRequest = error.config\r\n if (error?.response?.status === 401 && originalRequest) {\r\n await ServiceBase.tokenProvider.reSignIn()\r\n await this.interuptHeader(originalRequest)\r\n return axios(originalRequest)\r\n }\r\n return next(error)\r\n }\r\n private _token?: string\r\n /**\r\n * Sets the token to be used for authentication\r\n * @param token - The token string to set\r\n */\r\n setToken(token?: string) {\r\n this._token = token\r\n }\r\n /**\r\n * Gets the current token, fetching a new one if not set\r\n * @returns A promise resolving to the token string\r\n */\r\n getToken = async () => {\r\n return this._token === undefined ? await ServiceBase.tokenProvider.getToken() : this._token\r\n }\r\n /**\r\n * Adds custom headers to the request configuration\r\n * @param config - The Axios request configuration object\r\n * @returns A promise resolving to the updated configuration object\r\n */\r\n async addCustomHeader(config?: AxiosRequestConfig) {\r\n if (!config) {\r\n config = { headers: {} }\r\n }\r\n if (!config.headers) {\r\n config.headers = {}\r\n }\r\n return config\r\n }\r\n /**\r\n * Intercepts the request to add the authorization token\r\n * @param config - The Axios request configuration object\r\n * @returns The updated configuration object with the token added\r\n */\r\n private async interuptHeader(config: InternalAxiosRequestConfig) {\r\n await this.addtoken(config)\r\n return config\r\n }\r\n /**\r\n * Adds the authorization token to the request headers\r\n * @param config - The Axios request configuration object\r\n * @returns The updated configuration object with the token added\r\n */\r\n private addtoken = async (config?: AxiosRequestConfig) => {\r\n const _token = await this.getToken()\r\n if (_token && config?.headers) {\r\n config.headers.Authorization = 'Bearer ' + _token\r\n }\r\n return config\r\n }\r\n /**\r\n * HTTP GET request with automatic authentication\r\n * @param url - The request URL\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data\r\n */\r\n async get<TModel>(url: string, config?: AxiosRequestConfig | undefined) {\r\n const response = await this._http.get<TModel>(url, await this.addCustomHeader(config))\r\n return response.data\r\n }\r\n /**\r\n * HTTP GET request with error handling\r\n * @param url - The request URL\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data or null if an error occurs\r\n */\r\n async tryGet<TModel>(url: string, config?: AxiosRequestConfig | undefined) {\r\n try {\r\n return this.get<TModel>(url, config)\r\n } catch {\r\n return null\r\n }\r\n }\r\n /**\r\n * HTTP POST request with automatic authentication\r\n * @param url - The request URL\r\n * @param data - Optional data to send in the request body\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data\r\n */\r\n async post<TModel>(url: string, data?: any, config?: AxiosRequestConfig | undefined) {\r\n const response = await this._http.post<TModel>(url, data, await this.addCustomHeader(config))\r\n return response.data\r\n }\r\n /**\r\n * HTTP PUT request with automatic authentication\r\n * @param url - The request URL\r\n * @param data - Optional data to send in the request body\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data\r\n */\r\n async put<TModel>(url: string, data?: any, config?: AxiosRequestConfig | undefined) {\r\n const response = await this._http.put<TModel>(url, data, await this.addCustomHeader(config))\r\n return response.data\r\n }\r\n /**\r\n * HTTP PUT request with error handling\r\n * @param url - The request URL\r\n * @param data - Optional data to send in the request body\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data or null if an error occurs\r\n */\r\n async tryPut<TModel>(url: string, data?: any, config?: AxiosRequestConfig | undefined) {\r\n try {\r\n await this.addCustomHeader(config)\r\n return await this.put<TModel>(url, data, config)\r\n } catch (error) {\r\n // processError(error as any)\r\n return null\r\n }\r\n }\r\n /**\r\n * HTTP PATCH request with automatic authentication\r\n * @param url - The request URL\r\n * @param data - Optional data to send in the request body\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data\r\n */\r\n async patch<TModel>(url: string, data?: any, config?: AxiosRequestConfig | undefined) {\r\n const response = await this._http.patch<TModel>(url, data, await this.addCustomHeader(config))\r\n return response.data\r\n }\r\n /**\r\n * HTTP PATCH request with error handling\r\n * @param url - The request URL\r\n * @param data - Optional data to send in the request body\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data or null if an error occurs\r\n */\r\n async tryPatch<TModel>(url: string, data?: any, config?: AxiosRequestConfig | undefined) {\r\n try {\r\n await this.addCustomHeader(config)\r\n return await this.patch<TModel>(url, data, config)\r\n } catch (error) {\r\n // processError(error as any)\r\n return null\r\n }\r\n }\r\n /**\r\n * HTTP POST request with error handling\r\n * @param url - The request URL\r\n * @param data - Optional data to send in the request body\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data or null if an error occurs\r\n */\r\n async tryPost<TModel>(url: string, data?: any, config?: AxiosRequestConfig | undefined) {\r\n try {\r\n return await this.post<TModel>(url, data, config)\r\n } catch (error) {\r\n // processError(error as any)\r\n return null\r\n }\r\n }\r\n /**\r\n * HTTP DELETE request with automatic authentication\r\n * @param url - The request URL\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data\r\n */\r\n async delete<TModel>(url: string, config?: AxiosRequestConfig | undefined) {\r\n const response = await this._http.delete<TModel>(url, await this.addCustomHeader(config))\r\n return response.data\r\n }\r\n /**\r\n * HTTP DELETE request with error handling\r\n * @param url - The request URL\r\n * @param config - Optional axios configuration\r\n * @returns Promise with the response data or null if an error occurs\r\n */\r\n async tryDelete<TModel>(url: string, config?: AxiosRequestConfig | undefined) {\r\n try {\r\n return await this.delete<TModel>(url, await this.addCustomHeader(config))\r\n } catch (error) {\r\n // processError(error as any)\r\n return null\r\n }\r\n }\r\n /**\r\n * Push notification with error handling\r\n * @param action - The function to execute\r\n * @param p - Parameters to pass to the function\r\n * @returns Promise with the result of the function execution\r\n */\r\n async tryPushNotify<TFunc extends (...param: any[]) => any>(action: TFunc, ...p: Parameters<TFunc>) {\r\n try {\r\n return await this.pushNotify(action, ...p)\r\n } catch (err) {}\r\n }\r\n /**\r\n * Push notification with error handling\r\n * @param action - The function to execute\r\n * @param p - Parameters to pass to the function\r\n * @returns Promise with the result of the function execution\r\n */\r\n async pushNotify<TFunc extends (...param: any[]) => any>(action: TFunc, ...p: Parameters<TFunc>): Promise<ReturnType<TFunc>> {\r\n try {\r\n return await action.bind(this)(...p)\r\n } catch (err) {\r\n const error = err as AxiosError\r\n const data = error.response?.data as any\r\n if (data) {\r\n const keys = Object.keys(data)\r\n keys.forEach((key) => {\r\n const errors = data[key] as string[]\r\n if (Array.isArray(errors)) {\r\n errors.forEach((message) => {\r\n ApiAlertContext?.ApiAlert?.PushError(message)\r\n })\r\n }\r\n })\r\n }\r\n throw error\r\n }\r\n }\r\n}\r\n/**\r\n * CancelAction class extends AbortController to provide a cancel method\r\n * This class can be used to cancel ongoing HTTP requests\r\n */\r\nexport class CancelAction extends AbortController {\r\n cancel = () => {\r\n this.trigger && this.trigger()\r\n super.abort()\r\n }\r\n trigger?: () => void\r\n}\r\n"],"names":["TokenProviderDefault","_createClass","_classCallCheck","key","value","_getToken","_asyncToGenerator","_regenerator","m","_callee","_t","w","_context","n","authService","getAccessToken","v","undefined","a","apply","this","arguments","_reSignIn","_callee2","_context2","signIn","_getRoles","_callee3","roles","_context3","getRoles","ServiceBase","http","_this","_defineProperty","_http","interceptors","response","use","res","err","tryFetchToken","handleResponseError","request","req","interuptHeader","_ref","_callee4","error","next","_error$response","originalRequest","_context4","config","status","tokenProvider","reSignIn","axios","_x","_x2","_callee5","_t2","_context5","_token","getToken","_ref3","_callee6","_context6","headers","Authorization","_x3","HttpService","mapResponse","token","_addCustomHeader","_callee7","_context7","_x4","_interuptHeader","_callee8","_context8","addtoken","_x5","_get","_callee9","url","_t3","_t4","_context9","addCustomHeader","get","call","data","_x6","_x7","_tryGet","_callee0","_context0","p","_x8","_x9","_post","_callee1","_t6","_t7","_t8","_context1","post","_x0","_x1","_x10","_put","_callee10","_t9","_t0","_t1","_context10","put","_x11","_x12","_x13","_tryPut","_callee11","_context11","_x14","_x15","_x16","_patch","_callee12","_t11","_t12","_t13","_context12","patch","_x17","_x18","_x19","_tryPatch","_callee13","_context13","_x20","_x21","_x22","_tryPost","_callee14","_context14","_x23","_x24","_x25","_delete2","_callee15","_t16","_t17","_context15","_x26","_x27","_tryDelete","_callee16","_t18","_t19","_context16","_x28","_x29","_tryPushNotify","_callee17","action","_len","_key","_args17","_context17","length","Array","pushNotify","concat","_x30","_pushNotify","_callee18","_len2","_key2","_error$response2","_t22","_args18","_context18","bind","Object","keys","forEach","errors","isArray","message","_ApiAlertContext$ApiA","ApiAlertContext","ApiAlert","PushError","_x31","_ObjectProvider$get","createObjectSingleton","key_token_provider","provider","set","CancelAction","_AbortController","_this2","_len3","args","_key3","_callSuper","trigger","_superPropGet","_inherits","_wrapNativeSuper","AbortController"],"mappings":"0dAKgE,IAQ1DA,EAAoB,WAAA,OAAAC,EAAA,SAAAD,IAAAE,OAAAF,EAAA,EAAA,CAAA,CAAAG,IAAA,WAAAC,OAAAC,EAAAC,EAAAC,IAAAC,EACxB,SAAAC,IAAA,IAAAC,EAAA,OAAAH,IAAAI,EAAA,SAAAC,GAAA,cAAAA,EAAAC,GAAA,KAAA,EAAA,OAAAD,EAAAC,EAAA,EACgBC,EAAYC,iBAAgB,KAAA,EAAA,GAAAL,EAAAE,EAAAI,EAAA,CAAAJ,EAAAC,EAAA,EAAA,KAAA,CAAAH,OAAKO,EAAS,KAAA,EAAA,OAAAL,EAAAM,EAAA,EAAAR,GAAA,EAAAD,MACzD,WAFa,OAAAJ,EAAAc,MAAAC,KAAAC,UAAA,IAAA,CAAAlB,IAAA,WAAAC,OAAAkB,EAAAhB,EAAAC,IAAAC,EAGd,SAAAe,IAAA,OAAAhB,IAAAI,EAAA,SAAAa,GAAA,cAAAA,EAAAX,GAAA,KAAA,EAAA,OAAAW,EAAAX,EAAA,EACQC,EAAYW,OAAO,IAAG,KAAA,EAAA,OAAAD,EAAAN,EAAA,GAAA,EAAAK,MAC7B,WAFa,OAAAD,EAAAH,MAAAC,KAAAC,UAAA,IAAA,CAAAlB,IAAA,WAAAC,OAAAsB,EAAApB,EAAAC,IAAAC,EAGd,SAAAmB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AAqJ,OAAAkC,EAAAjC,IAAAA,MAAAgC,GAAAE,EAAA,EAAAA,EAAAF,EAAAE,IAAAD,EAAAC,GAAAxL,UAAAwL,GAIvB,OAJuBH,EAAAI,EAAA1L,KAAAoL,EAAA3B,GAAAA,OAAA+B,IAAA1K,EAAAwK,EAAA,SACf,WACPA,EAAKK,SAAWL,EAAKK,UACrBC,EAAAR,UAAAE,EAAAM,CAAA,MACDN,CAAA,CAAA,OAAAO,EAAAT,EAAAC,GAAAxM,EAAAuM,EAAA,EAAAU,EAJ+BC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
|
-
import type { TooltipProps } from '@mui/material';
|
|
3
|
+
import type { BoxProps, TooltipProps } from '@mui/material';
|
|
4
4
|
export interface IRichTooltipPanelConfig {
|
|
5
5
|
title: ReactNode;
|
|
6
6
|
content: ReactNode;
|
|
@@ -11,6 +11,7 @@ export interface IRichTooltipProps {
|
|
|
11
11
|
children: React.ReactNode;
|
|
12
12
|
slots?: {
|
|
13
13
|
tooltipProps?: Partial<TooltipProps>;
|
|
14
|
+
wrapperProps?: BoxProps;
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
17
|
export declare class RichTooltip extends Component<IRichTooltipProps> {
|
|
@@ -33,6 +33,8 @@ export interface IFieldMetadata<T = any> {
|
|
|
33
33
|
default?: any;
|
|
34
34
|
type?: any;
|
|
35
35
|
size?: Partial<Record<'xs' | 'sm' | 'md' | 'lg' | 'xl', number>>;
|
|
36
|
+
visible?: boolean | ((data?: T) => boolean);
|
|
37
|
+
disabled?: boolean | ((data?: T) => boolean);
|
|
36
38
|
renderInput?: ComponentType<IFormInputBase<T>>;
|
|
37
39
|
}
|
|
38
40
|
export declare function formField(options: Omit<IFieldMetadata, 'name'>): (target: any, propertyKey: string) => void;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { ComponentType, FC } from 'react';
|
|
2
|
+
import { BoxProps } from '@mui/material';
|
|
2
3
|
import { IFormInputBase } from './types';
|
|
3
4
|
import { IPartialError } from './validator';
|
|
5
|
+
import { IFormBaseSlots } from './create.form-base';
|
|
4
6
|
export interface IDecoratorFieldProps<T = any> extends IFormInputBase<T> {
|
|
5
7
|
type?: any;
|
|
8
|
+
visible?: boolean | ((data: T) => boolean);
|
|
6
9
|
renderInput?: ComponentType<IFormInputBase<T>>;
|
|
7
10
|
}
|
|
8
11
|
export declare const DecoratorField: FC<IDecoratorFieldProps>;
|
|
@@ -10,15 +13,19 @@ export interface IDecoratorFormSlots {
|
|
|
10
13
|
bottom?: React.ReactNode;
|
|
11
14
|
isFooter?: React.ReactNode | boolean;
|
|
12
15
|
renderSubmitButton?: () => React.ReactNode;
|
|
16
|
+
formBase?: IFormBaseSlots;
|
|
17
|
+
footerProps?: BoxProps & {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
};
|
|
13
20
|
}
|
|
14
21
|
export interface IDecoratorFormProps<T = any> {
|
|
15
22
|
configClass: any;
|
|
16
|
-
data?:
|
|
17
|
-
onSubmit?: (data:
|
|
23
|
+
data?: Partial<T>;
|
|
24
|
+
onSubmit?: (data: Partial<T>, signal?: AbortSignal) => Promise<void>;
|
|
18
25
|
onError?: (error: any) => void;
|
|
19
26
|
onSubmitError?: (error: IPartialError<T>) => void;
|
|
20
27
|
slots?: IDecoratorFormSlots;
|
|
21
28
|
}
|
|
22
29
|
export declare const DecoratorForm: FC<IDecoratorFormProps>;
|
|
23
30
|
export default DecoratorForm;
|
|
24
|
-
export declare const createDecoratorForm: <T>(configClass: any, params?: Partial<Omit<IDecoratorFormProps
|
|
31
|
+
export declare const createDecoratorForm: <T>(configClass: any, params?: Partial<Omit<IDecoratorFormProps<T>, "configClass">> | undefined) => ComponentType<Omit<IDecoratorFormProps<T>, "configClass">>;
|
|
@@ -19,7 +19,7 @@ declare class DinoFormBase {
|
|
|
19
19
|
createFormComfirm: <T = any>(param?: import("./create.form-comfirm").IFormComfirmParam<T> | undefined) => import("react").ComponentType<import("react").PropsWithChildren<import("./create.form-comfirm").IFormComfirmProps<T>>>;
|
|
20
20
|
createFormGridLayout: <T>(params: import("./create.form-grid-layout").IFormGridLayoutParams<T>) => import("react").ComponentType<import("./create.form-grid-layout").IFormGridLayoutProps<T>>;
|
|
21
21
|
DecoratorForm: import("react").FC<import("./decorator.form").IDecoratorFormProps<any>>;
|
|
22
|
-
createDecoratorForm: <T>(configClass: any, params?: Partial<Omit<import("./decorator.form").IDecoratorFormProps<
|
|
22
|
+
createDecoratorForm: <T>(configClass: any, params?: Partial<Omit<import("./decorator.form").IDecoratorFormProps<T>, "configClass">> | undefined) => import("react").ComponentType<Omit<import("./decorator.form").IDecoratorFormProps<T>, "configClass">>;
|
|
23
23
|
createColorPicker: typeof createColorPicker;
|
|
24
24
|
createDateExpired: typeof CreateDateExpired;
|
|
25
25
|
createDatePicker: <T extends Object>(params?: import("./create.date-picker").IDatePickerSlots | undefined) => import("react").ComponentType<import("./create.date-picker").IDatePickerProps<T>>;
|