@tachybase/module-hera 1.9.40 → 1.9.41

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.
@@ -19,7 +19,7 @@
19
19
  `,e)})});ExcelSheet.displayName="ExcelSheet";/*!
20
20
  * Signature Pad v4.2.0 | https://github.com/szimek/signature_pad
21
21
  * (c) 2024 Szymon Nowak | Released under the MIT license
22
- */class Point{constructor(e,s,i,r){if(isNaN(e)||isNaN(s))throw new Error(`Point is invalid: (${e}, ${s})`);this.x=+e,this.y=+s,this.pressure=i||0,this.time=r||Date.now()}distanceTo(e){return Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2))}equals(e){return this.x===e.x&&this.y===e.y&&this.pressure===e.pressure&&this.time===e.time}velocityFrom(e){return this.time!==e.time?this.distanceTo(e)/(this.time-e.time):0}}class Bezier{static fromPoints(e,s){const i=this.calculateControlPoints(e[0],e[1],e[2]).c2,r=this.calculateControlPoints(e[1],e[2],e[3]).c1;return new Bezier(e[1],i,r,e[2],s.start,s.end)}static calculateControlPoints(e,s,i){const r=e.x-s.x,o=e.y-s.y,l=s.x-i.x,a=s.y-i.y,c={x:(e.x+s.x)/2,y:(e.y+s.y)/2},d={x:(s.x+i.x)/2,y:(s.y+i.y)/2},u=Math.sqrt(r*r+o*o),f=Math.sqrt(l*l+a*a),m=c.x-d.x,p=c.y-d.y,g=f/(u+f),x={x:d.x+m*g,y:d.y+p*g},E=s.x-x.x,v=s.y-x.y;return{c1:new Point(c.x+E,c.y+v),c2:new Point(d.x+E,d.y+v)}}constructor(e,s,i,r,o,l){this.startPoint=e,this.control2=s,this.control1=i,this.endPoint=r,this.startWidth=o,this.endWidth=l}length(){let s=0,i,r;for(let o=0;o<=10;o+=1){const l=o/10,a=this.point(l,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),c=this.point(l,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(o>0){const d=a-i,u=c-r;s+=Math.sqrt(d*d+u*u)}i=a,r=c}return s}point(e,s,i,r,o){return s*(1-e)*(1-e)*(1-e)+3*i*(1-e)*(1-e)*e+3*r*(1-e)*e*e+o*e*e*e}}class SignatureEventTarget{constructor(){try{this._et=new EventTarget}catch(e){this._et=document}}addEventListener(e,s,i){this._et.addEventListener(e,s,i)}dispatchEvent(e){return this._et.dispatchEvent(e)}removeEventListener(e,s,i){this._et.removeEventListener(e,s,i)}}function throttle$1(n,e=250){let s=0,i=null,r,o,l;const a=()=>{s=Date.now(),i=null,r=n.apply(o,l),i||(o=null,l=[])};return function(...d){const u=Date.now(),f=e-(u-s);return o=this,l=d,f<=0||f>e?(i&&(clearTimeout(i),i=null),s=u,r=n.apply(o,l),i||(o=null,l=[])):i||(i=window.setTimeout(a,f)),r}}let SignaturePad$1=class G extends SignatureEventTarget{constructor(e,s={}){super(),this.canvas=e,this._drawingStroke=!1,this._isEmpty=!0,this._lastPoints=[],this._data=[],this._lastVelocity=0,this._lastWidth=0,this._handleMouseDown=i=>{i.buttons===1&&this._strokeBegin(i)},this._handleMouseMove=i=>{this._strokeMoveUpdate(i)},this._handleMouseUp=i=>{i.buttons===1&&this._strokeEnd(i)},this._handleTouchStart=i=>{if(i.cancelable&&i.preventDefault(),i.targetTouches.length===1){const r=i.changedTouches[0];this._strokeBegin(r)}},this._handleTouchMove=i=>{i.cancelable&&i.preventDefault();const r=i.targetTouches[0];this._strokeMoveUpdate(r)},this._handleTouchEnd=i=>{if(i.target===this.canvas){i.cancelable&&i.preventDefault();const o=i.changedTouches[0];this._strokeEnd(o)}},this._handlePointerStart=i=>{i.preventDefault(),this._strokeBegin(i)},this._handlePointerMove=i=>{this._strokeMoveUpdate(i)},this._handlePointerEnd=i=>{this._drawingStroke&&(i.preventDefault(),this._strokeEnd(i))},this.velocityFilterWeight=s.velocityFilterWeight||.7,this.minWidth=s.minWidth||.5,this.maxWidth=s.maxWidth||2.5,this.throttle="throttle"in s?s.throttle:16,this.minDistance="minDistance"in s?s.minDistance:5,this.dotSize=s.dotSize||0,this.penColor=s.penColor||"black",this.backgroundColor=s.backgroundColor||"rgba(0,0,0,0)",this.compositeOperation=s.compositeOperation||"source-over",this.canvasContextOptions="canvasContextOptions"in s?s.canvasContextOptions:{},this._strokeMoveUpdate=this.throttle?throttle$1(G.prototype._strokeUpdate,this.throttle):G.prototype._strokeUpdate,this._ctx=e.getContext("2d",this.canvasContextOptions),this.clear(),this.on()}clear(){const{_ctx:e,canvas:s}=this;e.fillStyle=this.backgroundColor,e.clearRect(0,0,s.width,s.height),e.fillRect(0,0,s.width,s.height),this._data=[],this._reset(this._getPointGroupOptions()),this._isEmpty=!0}fromDataURL(e,s={}){return new Promise((i,r)=>{const o=new Image,l=s.ratio||window.devicePixelRatio||1,a=s.width||this.canvas.width/l,c=s.height||this.canvas.height/l,d=s.xOffset||0,u=s.yOffset||0;this._reset(this._getPointGroupOptions()),o.onload=()=>{this._ctx.drawImage(o,d,u,a,c),i()},o.onerror=f=>{r(f)},o.crossOrigin="anonymous",o.src=e,this._isEmpty=!1})}toDataURL(e="image/png",s){switch(e){case"image/svg+xml":return typeof s!="object"&&(s=void 0),`data:image/svg+xml;base64,${btoa(this.toSVG(s))}`;default:return typeof s!="number"&&(s=void 0),this.canvas.toDataURL(e,s)}}on(){this.canvas.style.touchAction="none",this.canvas.style.msTouchAction="none",this.canvas.style.userSelect="none";const e=/Macintosh/.test(navigator.userAgent)&&"ontouchstart"in document;window.PointerEvent&&!e?this._handlePointerEvents():(this._handleMouseEvents(),"ontouchstart"in window&&this._handleTouchEvents())}off(){this.canvas.style.touchAction="auto",this.canvas.style.msTouchAction="auto",this.canvas.style.userSelect="auto",this.canvas.removeEventListener("pointerdown",this._handlePointerStart),this.canvas.removeEventListener("pointermove",this._handlePointerMove),this.canvas.ownerDocument.removeEventListener("pointerup",this._handlePointerEnd),this.canvas.removeEventListener("mousedown",this._handleMouseDown),this.canvas.removeEventListener("mousemove",this._handleMouseMove),this.canvas.ownerDocument.removeEventListener("mouseup",this._handleMouseUp),this.canvas.removeEventListener("touchstart",this._handleTouchStart),this.canvas.removeEventListener("touchmove",this._handleTouchMove),this.canvas.removeEventListener("touchend",this._handleTouchEnd)}isEmpty(){return this._isEmpty}fromData(e,{clear:s=!0}={}){s&&this.clear(),this._fromData(e,this._drawCurve.bind(this),this._drawDot.bind(this)),this._data=this._data.concat(e)}toData(){return this._data}_getPointGroupOptions(e){return{penColor:e&&"penColor"in e?e.penColor:this.penColor,dotSize:e&&"dotSize"in e?e.dotSize:this.dotSize,minWidth:e&&"minWidth"in e?e.minWidth:this.minWidth,maxWidth:e&&"maxWidth"in e?e.maxWidth:this.maxWidth,velocityFilterWeight:e&&"velocityFilterWeight"in e?e.velocityFilterWeight:this.velocityFilterWeight,compositeOperation:e&&"compositeOperation"in e?e.compositeOperation:this.compositeOperation}}_strokeBegin(e){if(!this.dispatchEvent(new CustomEvent("beginStroke",{detail:e,cancelable:!0})))return;this._drawingStroke=!0;const i=this._getPointGroupOptions(),r=Object.assign(Object.assign({},i),{points:[]});this._data.push(r),this._reset(i),this._strokeUpdate(e)}_strokeUpdate(e){if(!this._drawingStroke)return;if(this._data.length===0){this._strokeBegin(e);return}this.dispatchEvent(new CustomEvent("beforeUpdateStroke",{detail:e}));const s=e.clientX,i=e.clientY,r=e.pressure!==void 0?e.pressure:e.force!==void 0?e.force:0,o=this._createPoint(s,i,r),l=this._data[this._data.length-1],a=l.points,c=a.length>0&&a[a.length-1],d=c?o.distanceTo(c)<=this.minDistance:!1,u=this._getPointGroupOptions(l);if(!c||!(c&&d)){const f=this._addPoint(o,u);c?f&&this._drawCurve(f,u):this._drawDot(o,u),a.push({time:o.time,x:o.x,y:o.y,pressure:o.pressure})}this.dispatchEvent(new CustomEvent("afterUpdateStroke",{detail:e}))}_strokeEnd(e){this._drawingStroke&&(this._strokeUpdate(e),this._drawingStroke=!1,this.dispatchEvent(new CustomEvent("endStroke",{detail:e})))}_handlePointerEvents(){this._drawingStroke=!1,this.canvas.addEventListener("pointerdown",this._handlePointerStart),this.canvas.addEventListener("pointermove",this._handlePointerMove),this.canvas.ownerDocument.addEventListener("pointerup",this._handlePointerEnd)}_handleMouseEvents(){this._drawingStroke=!1,this.canvas.addEventListener("mousedown",this._handleMouseDown),this.canvas.addEventListener("mousemove",this._handleMouseMove),this.canvas.ownerDocument.addEventListener("mouseup",this._handleMouseUp)}_handleTouchEvents(){this.canvas.addEventListener("touchstart",this._handleTouchStart),this.canvas.addEventListener("touchmove",this._handleTouchMove),this.canvas.addEventListener("touchend",this._handleTouchEnd)}_reset(e){this._lastPoints=[],this._lastVelocity=0,this._lastWidth=(e.minWidth+e.maxWidth)/2,this._ctx.fillStyle=e.penColor,this._ctx.globalCompositeOperation=e.compositeOperation}_createPoint(e,s,i){const r=this.canvas.getBoundingClientRect();return new Point(e-r.left,s-r.top,i,new Date().getTime())}_addPoint(e,s){const{_lastPoints:i}=this;if(i.push(e),i.length>2){i.length===3&&i.unshift(i[0]);const r=this._calculateCurveWidths(i[1],i[2],s),o=Bezier.fromPoints(i,r);return i.shift(),o}return null}_calculateCurveWidths(e,s,i){const r=i.velocityFilterWeight*s.velocityFrom(e)+(1-i.velocityFilterWeight)*this._lastVelocity,o=this._strokeWidth(r,i),l={end:o,start:this._lastWidth};return this._lastVelocity=r,this._lastWidth=o,l}_strokeWidth(e,s){return Math.max(s.maxWidth/(e+1),s.minWidth)}_drawCurveSegment(e,s,i){const r=this._ctx;r.moveTo(e,s),r.arc(e,s,i,0,2*Math.PI,!1),this._isEmpty=!1}_drawCurve(e,s){const i=this._ctx,r=e.endWidth-e.startWidth,o=Math.ceil(e.length())*2;i.beginPath(),i.fillStyle=s.penColor;for(let l=0;l<o;l+=1){const a=l/o,c=a*a,d=c*a,u=1-a,f=u*u,m=f*u;let p=m*e.startPoint.x;p+=3*f*a*e.control1.x,p+=3*u*c*e.control2.x,p+=d*e.endPoint.x;let g=m*e.startPoint.y;g+=3*f*a*e.control1.y,g+=3*u*c*e.control2.y,g+=d*e.endPoint.y;const x=Math.min(e.startWidth+d*r,s.maxWidth);this._drawCurveSegment(p,g,x)}i.closePath(),i.fill()}_drawDot(e,s){const i=this._ctx,r=s.dotSize>0?s.dotSize:(s.minWidth+s.maxWidth)/2;i.beginPath(),this._drawCurveSegment(e.x,e.y,r),i.closePath(),i.fillStyle=s.penColor,i.fill()}_fromData(e,s,i){for(const r of e){const{points:o}=r,l=this._getPointGroupOptions(r);if(o.length>1)for(let a=0;a<o.length;a+=1){const c=o[a],d=new Point(c.x,c.y,c.pressure,c.time);a===0&&this._reset(l);const u=this._addPoint(d,l);u&&s(u,l)}else this._reset(l),i(o[0],l)}}toSVG({includeBackgroundColor:e=!1}={}){const s=this._data,i=Math.max(window.devicePixelRatio||1,1),r=0,o=0,l=this.canvas.width/i,a=this.canvas.height/i,c=document.createElementNS("http://www.w3.org/2000/svg","svg");if(c.setAttribute("xmlns","http://www.w3.org/2000/svg"),c.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),c.setAttribute("viewBox",`${r} ${o} ${l} ${a}`),c.setAttribute("width",l.toString()),c.setAttribute("height",a.toString()),e&&this.backgroundColor){const d=document.createElement("rect");d.setAttribute("width","100%"),d.setAttribute("height","100%"),d.setAttribute("fill",this.backgroundColor),c.appendChild(d)}return this._fromData(s,(d,{penColor:u})=>{const f=document.createElement("path");if(!isNaN(d.control1.x)&&!isNaN(d.control1.y)&&!isNaN(d.control2.x)&&!isNaN(d.control2.y)){const m=`M ${d.startPoint.x.toFixed(3)},${d.startPoint.y.toFixed(3)} C ${d.control1.x.toFixed(3)},${d.control1.y.toFixed(3)} ${d.control2.x.toFixed(3)},${d.control2.y.toFixed(3)} ${d.endPoint.x.toFixed(3)},${d.endPoint.y.toFixed(3)}`;f.setAttribute("d",m),f.setAttribute("stroke-width",(d.endWidth*2.25).toFixed(3)),f.setAttribute("stroke",u),f.setAttribute("fill","none"),f.setAttribute("stroke-linecap","round"),c.appendChild(f)}},(d,{penColor:u,dotSize:f,minWidth:m,maxWidth:p})=>{const g=document.createElement("circle"),x=f>0?f:(m+p)/2;g.setAttribute("r",x.toString()),g.setAttribute("cx",d.x.toString()),g.setAttribute("cy",d.y.toString()),g.setAttribute("fill",u),c.appendChild(g)}),c.outerHTML}};function throttle(n,e,s){var i=s||{},r=i.noTrailing,o=r===void 0?!1:r,l=i.noLeading,a=l===void 0?!1:l,c=i.debounceMode,d=c===void 0?void 0:c,u,f=!1,m=0;function p(){u&&clearTimeout(u)}function g(E){var v=E||{},y=v.upcomingOnly,w=y===void 0?!1:y;p(),f=!w}function x(){for(var E=arguments.length,v=new Array(E),y=0;y<E;y++)v[y]=arguments[y];var w=this,S=Date.now()-m;if(f)return;function D(){m=Date.now(),e.apply(w,v)}function F(){u=void 0}!a&&d&&!u&&D(),p(),d===void 0&&S>n?a?(m=Date.now(),o||(u=setTimeout(d?F:D,n))):D():o!==!0&&(u=setTimeout(d?F:D,d===void 0?n-S:n))}return x.cancel=g,x}function debounce(n,e,s){var i={},r=i.atBegin,o=r===void 0?!1:r;return throttle(n,e,{debounceMode:o!==!1})}class SignaturePad extends React__namespace.PureComponent{constructor(s){super(s);b(this,"canvasRef",React__namespace.createRef());b(this,"signaturePad");b(this,"callResizeHandler");this.state={canvasWidth:0,canvasHeight:0},this.callResizeHandler=debounce(this.props.debounceInterval,this.handleResize.bind(this))}componentDidMount(){const s=this.canvasRef.current;s&&((!this.props.width||!this.props.height)&&(s.style.width="100%",window.addEventListener("resize",this.callResizeHandler)),this.signaturePad=new SignaturePad$1(s,this.props.options),this.scaleCanvas(s))}componentWillUnmount(){(!this.props.width||!this.props.height)&&window.removeEventListener("resize",this.callResizeHandler),this.signaturePad.off()}get instance(){return this.signaturePad}get canvas(){return this.canvasRef}set dotSize(s){this.signaturePad.dotSize=s}get dotSize(){return this.signaturePad.dotSize}set minWidth(s){this.signaturePad.minWidth=s}get minWidth(){return this.signaturePad.minWidth}set maxWidth(s){this.signaturePad.maxWidth=s}get maxWidth(){return this.signaturePad.maxWidth}set throttle(s){this.signaturePad.throttle=s}get throttle(){return this.signaturePad.throttle}set backgroundColor(s){this.signaturePad.backgroundColor=s}get backgroundColor(){return this.signaturePad.backgroundColor}set penColor(s){this.signaturePad.penColor=s}get penColor(){return this.signaturePad.penColor}set velocityFilterWeight(s){this.signaturePad.velocityFilterWeight=s}get velocityFilterWeight(){return this.signaturePad.velocityFilterWeight}isEmpty(){return this.signaturePad.isEmpty()}clear(){this.signaturePad.clear()}fromDataURL(s,i={}){this.signaturePad.fromDataURL(s,i)}toDataURL(s,i){return this.signaturePad.toDataURL(s,i)}toSVG(s){return this.signaturePad.toSVG(s)}fromData(s){this.signaturePad.fromData(s)}toData(){return this.signaturePad.toData()}off(){this.signaturePad.off()}on(){this.signaturePad.on()}handleResize(){const s=this.canvasRef.current;s&&this.scaleCanvas(s)}scaleCanvas(s){const i=Math.max(window.devicePixelRatio||1,1),r=(this.props.width||s.offsetWidth)*i,o=(this.props.height||s.offsetHeight)*i,{canvasWidth:l,canvasHeight:a}=this.state;if(r===l&&o===a)return;let c;this.props.redrawOnResize&&this.signaturePad&&!this.signaturePad.isEmpty()&&(c=this.signaturePad.toDataURL()),s.width=r,s.height=o,this.setState({canvasWidth:r,canvasHeight:o});const d=s.getContext("2d");d&&d.scale(i,i),c?this.signaturePad.fromDataURL(c):this.signaturePad&&this.signaturePad.clear()}render(){const{canvasProps:s}=this.props;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("canvas",A({"data-testid":"canvas-element",ref:this.canvasRef},s))}}b(SignaturePad,"displayName","react-signature-pad-wrapper"),b(SignaturePad,"defaultProps",{redrawOnResize:!1,debounceInterval:150});const SignatureInput=schema.connect(n=>{const{onChange:e,value:s}=n,i=React.useRef(null);React.useEffect(()=>{s&&i.current.fromDataURL(s)},[]);const r=()=>{i.current&&(i.current.clear(),e&&e(""))},o=()=>{if(i.current){const a=i.current.toDataURL();e&&e(a)}},l={pointerEvents:n.disabled?"none":"auto",opacity:n.disabled?.8:1};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{style:l,children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(SignaturePad,{ref:i,options:{penColor:"black",backgroundColor:"lightgrey"}}),!n.disabled&&__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:r,children:"清空"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:o,children:"确认"})]})]})},schema.mapProps((n,e)=>A({},n))),ErrorBoundaryContext=React.createContext(null),initialState={didCatch:!1,error:null};class ErrorBoundary extends React.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=initialState}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){const{error:e}=this.state;if(e!==null){for(var s,i,r=arguments.length,o=new Array(r),l=0;l<r;l++)o[l]=arguments[l];(s=(i=this.props).onReset)===null||s===void 0||s.call(i,{args:o,reason:"imperative-api"}),this.setState(initialState)}}componentDidCatch(e,s){var i,r;(i=(r=this.props).onError)===null||i===void 0||i.call(r,e,s)}componentDidUpdate(e,s){const{didCatch:i}=this.state,{resetKeys:r}=this.props;if(i&&s.error!==null&&hasArrayChanged(e.resetKeys,r)){var o,l;(o=(l=this.props).onReset)===null||o===void 0||o.call(l,{next:r,prev:e.resetKeys,reason:"keys"}),this.setState(initialState)}}render(){const{children:e,fallbackRender:s,FallbackComponent:i,fallback:r}=this.props,{didCatch:o,error:l}=this.state;let a=e;if(o){const c={error:l,resetErrorBoundary:this.resetErrorBoundary};if(typeof s=="function")a=s(c);else if(i)a=React.createElement(i,c);else if(r!==void 0)a=r;else throw l}return React.createElement(ErrorBoundaryContext.Provider,{value:{didCatch:o,error:l,resetErrorBoundary:this.resetErrorBoundary}},a)}}function hasArrayChanged(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return n.length!==e.length||n.some((s,i)=>!Object.is(s,e[i]))}const ErrorBoundaryFallBack=()=>{const{t:n}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{children:n("Something went wrong. Please contact the developer to resolve the issue.")})},CustomAssociatedField=n=>{if(n.component)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundary,{fallback:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundaryFallBack,{}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{type:"string",name:n.component,"x-component":n.component,"x-component-props":n}})})},useCustomComponent=n=>{const e=client.useApp();return _.filter(e.components,s=>s.__componentType===n).map(s=>({label:s.__componentLabel,value:s.displayName}))};var CustomComponentType=(n=>(n.CUSTOM_FORM_ITEM="FORM_ITEM",n.CUSTOM_FIELD="FIELD",n.CUSTOM_ASSOCIATED_FIELD="ASSOCIATED_FIELD",n))(CustomComponentType||{});const CustomComponentStub=n=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{children:"请选择组件"}),CustomComponentDispatcher=n=>{if(n.component)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundary,{fallback:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundaryFallBack,{}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{type:"void",name:n.component,"x-component":n.component,"x-component-props":n}})})},customComponentDispatcherSettings=new client.SchemaSettings({name:"customComponentDispatcherSettings",items:[{name:"component",type:"select",useComponentProps(){var o;const n=useCustomComponent(CustomComponentType.CUSTOM_FORM_ITEM),{t:e}=useTranslation(),s=schema.useField(),i=schema.useFieldSchema(),{dn:r}=client.useDesignable();return{title:e("component"),value:((o=s.componentProps)==null?void 0:o.component)||"CustomComponentStub",options:[{label:"未选择组件",value:"CustomComponentStub"},...n],onChange(l){const a={"x-uid":i["x-uid"]};i["x-component-props"].component=l,i["x-acl-ignore"]=!0,a["x-component-props"]=i["x-component-props"],a["x-acl-ignore"]=!0,s.componentProps.component=l,r.emit("patch",{schema:a})}}}},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0}}]}),CustomField=n=>{if(n.component)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundary,{fallback:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundaryFallBack,{}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{type:"string",name:n.component,"x-component":n.component,"x-component-props":n}})})},viewerSchema={type:"void",title:'{{ t("View record") }}',"x-component":"AssociationField.Viewer","x-component-props":{className:"tb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"TabPaneInitializers",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"RecordBlockInitializers",properties:{}}}}}}}},useInsertSchema=n=>{const e=schema.useFieldSchema(),{insertAfterBegin:s}=client.useDesignable();return React.useCallback(r=>{e.reduceProperties((l,a)=>a["x-component"]==="AssociationField."+n?a:l,null)||s(_.cloneDeep(r))},[n])},AssociatedFieldImplement=schema.observer(n=>{var w,S,D;const{collection:e,fieldExp:s,dateFieldExp:i,sourceCollection:r,sourceField:o}=n,[l,a]=React.useState(!1),c=useInsertSchema("Viewer"),d=schema.useField(),u=schema.useForm(),f=schema.useFieldSchema(),{designable:m}=client.useDesignable(),p=s==null?void 0:s.replace(/{{(.*?)}}/,"$1"),g=i==null?void 0:i.replace(/{{(.*?)}}/,"$1"),{data:x,loading:E,run:v}=client.useRequest({url:`/${r}:get`,params:{appends:[o],filter:{contract_id:(w=u.values[p])==null?void 0:w.id,start_date:{$lte:u.values[g]},end_date:{$gte:u.values[g]}}}},{manual:!0});if(React.useEffect(()=>{var F;(F=u.values[p])!=null&&F.id&&u.values[g]&&v()},[(S=u.values[p])==null?void 0:S.id,u.values[g]]),E||!x)return null;if(!((D=x.data)!=null&&D[o+"_id"]))return u.setValues({[f.name]:null}),null;const y=x.data[o];return u.setValues({[f.name]:y}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("span",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{onClick:F=>{F.stopPropagation(),F.preventDefault(),m&&c(viewerSchema),a(!0)},children:y.name}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.CollectionProvider_deprecated,{name:e,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionContextProvider,{value:{visible:l,setVisible:a,openMode:"drawer",snapshot:!1},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RecordProvider,{record:y,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.FormProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(schema.RecursionField,{schema:f,onlyRenderProperties:!0,basePath:d.address,filterProperties:F=>F["x-component"]==="AssociationField.Viewer"})})})})})]})}),AssociatedField=schema.connect(AssociatedFieldImplement),transformFormula$1=n=>n?n.split(/([+\-*/?:()%])/).filter(s=>s):[],CalcResult=props=>{const form=schema.useForm(),fieldSchema=schema.useFieldSchema(),field=schema.useField(),{formula,prefix,suffix,decimal,panel}=props,path=field.path.entire,fieldPath=path==null?void 0:path.replace(`.${fieldSchema.name}`,""),engine=client$1.evaluators.get("math.js"),evaluate=engine.evaluate.bind(engine),defaultValue=fieldSchema.name==="subtotal"?"¥0.00":[],[value,setValue]=React.useState(defaultValue),transformFormulaArray=transformFormula$1(formula);let calculateData=[];const newFormulaArray=n=>{var i;calculateData=[];let e=0;const s={};if(transformFormulaArray.length!==0){for(let r=0;r<transformFormulaArray.length;r++){const o=transformFormulaArray[r];if(!o)continue;const l=!isNaN(Number(o)),a=["+","-","*","/","?",":","(",")","%"].includes(o);if(!l&&!a){let c;const d=/\${(.*?)}/g;if((i=o.match(d))!=null&&i.length){const m=o.match(d)[0].replace(/\${|}/g,""),p=o.split(".")[1];path===fieldPath?c=_.chain(n).get(m).get(p,0).value():c=_.chain(n).get(fieldPath).get(m).get(p,0).value()}else path===fieldPath?c=_.chain(n).get(o,0).value():c=_.chain(n).get(fieldPath).get(o,0).value();c||(c=0),e+=1;const u="var"+e,f=c;s[u]=f,calculateData.push("{{"+u+"}}")}else calculateData.push(o)}return[calculateData.join(""),s]}},fun=()=>R(this,null,function*(){if(!panel&&transformFormulaArray.length){const[n,e]=newFormulaArray(form.values);let s;try{const i=prefix||"",r=suffix||"",o=evaluate(n,e),l=isNaN(o)?o:Number(o).toFixed(decimal||0);s=i+l+r}catch(i){s=`${n}`,console.warn("code: ",n," scopes: ",e,"error: ",s," error message ",i.message)}setValue(s.toString())}else if(panel){let items=[],childrenType="";(yield import("react/jsx-runtime")).default,(yield import("dayjs")).default,childrenType="normal";try{eval(panel)}catch(n){items=[],items.push({key:"1",label:"数据异常",children:"请检查字段配置内容,error:"+n})}const showItems=items.map(n=>({label:n.label,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("p",{children:n.children})}));if(childrenType==="normal"){const n=__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Descriptions,{items:showItems});setValue(n)}else if(childrenType==="jsx"&&Array.isArray(items)){const n=__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:items.map(e=>e.children)});setValue(n)}}});return React.useEffect(()=>{fun()},[]),schema.useFormEffects(()=>{schema.onFormValuesChange(n=>{fun()})}),typeof value=="string"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Input.ReadPretty,{value}):value},Expression=n=>{var u;const{value:e="",useCurrentFields:s,onChange:i}=n,r=client.useCompile(),{interfaces:o,getCollectionFields:l}=client.useCollectionManager_deprecated(),a=(u=s==null?void 0:s())!=null?u:[],c=client.useAssociatedFields();console.log(c,"associatedFields",a);const d=a.map(f=>{var m,p;return{label:r(f.uiSchema.title),value:f.name,children:(p=(m=l(f.target))==null?void 0:m.filter(g=>g.uiSchema).map(g=>({label:g.uiSchema?r(g.uiSchema.title):"",value:g.name})))!=null?p:[]}});return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Variable.Input,{value:e,onChange:i,scope:d,changeOnSelect:!0})},ModalHeader=n=>{const{title:e,onOk:s,onCancel:i}=n;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{className:client.css`
22
+ */class Point{constructor(e,s,i,r){if(isNaN(e)||isNaN(s))throw new Error(`Point is invalid: (${e}, ${s})`);this.x=+e,this.y=+s,this.pressure=i||0,this.time=r||Date.now()}distanceTo(e){return Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2))}equals(e){return this.x===e.x&&this.y===e.y&&this.pressure===e.pressure&&this.time===e.time}velocityFrom(e){return this.time!==e.time?this.distanceTo(e)/(this.time-e.time):0}}class Bezier{static fromPoints(e,s){const i=this.calculateControlPoints(e[0],e[1],e[2]).c2,r=this.calculateControlPoints(e[1],e[2],e[3]).c1;return new Bezier(e[1],i,r,e[2],s.start,s.end)}static calculateControlPoints(e,s,i){const r=e.x-s.x,o=e.y-s.y,l=s.x-i.x,a=s.y-i.y,c={x:(e.x+s.x)/2,y:(e.y+s.y)/2},d={x:(s.x+i.x)/2,y:(s.y+i.y)/2},u=Math.sqrt(r*r+o*o),f=Math.sqrt(l*l+a*a),m=c.x-d.x,p=c.y-d.y,g=f/(u+f),x={x:d.x+m*g,y:d.y+p*g},E=s.x-x.x,v=s.y-x.y;return{c1:new Point(c.x+E,c.y+v),c2:new Point(d.x+E,d.y+v)}}constructor(e,s,i,r,o,l){this.startPoint=e,this.control2=s,this.control1=i,this.endPoint=r,this.startWidth=o,this.endWidth=l}length(){let s=0,i,r;for(let o=0;o<=10;o+=1){const l=o/10,a=this.point(l,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),c=this.point(l,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(o>0){const d=a-i,u=c-r;s+=Math.sqrt(d*d+u*u)}i=a,r=c}return s}point(e,s,i,r,o){return s*(1-e)*(1-e)*(1-e)+3*i*(1-e)*(1-e)*e+3*r*(1-e)*e*e+o*e*e*e}}class SignatureEventTarget{constructor(){try{this._et=new EventTarget}catch(e){this._et=document}}addEventListener(e,s,i){this._et.addEventListener(e,s,i)}dispatchEvent(e){return this._et.dispatchEvent(e)}removeEventListener(e,s,i){this._et.removeEventListener(e,s,i)}}function throttle$1(n,e=250){let s=0,i=null,r,o,l;const a=()=>{s=Date.now(),i=null,r=n.apply(o,l),i||(o=null,l=[])};return function(...d){const u=Date.now(),f=e-(u-s);return o=this,l=d,f<=0||f>e?(i&&(clearTimeout(i),i=null),s=u,r=n.apply(o,l),i||(o=null,l=[])):i||(i=window.setTimeout(a,f)),r}}let SignaturePad$1=class G extends SignatureEventTarget{constructor(e,s={}){super(),this.canvas=e,this._drawingStroke=!1,this._isEmpty=!0,this._lastPoints=[],this._data=[],this._lastVelocity=0,this._lastWidth=0,this._handleMouseDown=i=>{i.buttons===1&&this._strokeBegin(i)},this._handleMouseMove=i=>{this._strokeMoveUpdate(i)},this._handleMouseUp=i=>{i.buttons===1&&this._strokeEnd(i)},this._handleTouchStart=i=>{if(i.cancelable&&i.preventDefault(),i.targetTouches.length===1){const r=i.changedTouches[0];this._strokeBegin(r)}},this._handleTouchMove=i=>{i.cancelable&&i.preventDefault();const r=i.targetTouches[0];this._strokeMoveUpdate(r)},this._handleTouchEnd=i=>{if(i.target===this.canvas){i.cancelable&&i.preventDefault();const o=i.changedTouches[0];this._strokeEnd(o)}},this._handlePointerStart=i=>{i.preventDefault(),this._strokeBegin(i)},this._handlePointerMove=i=>{this._strokeMoveUpdate(i)},this._handlePointerEnd=i=>{this._drawingStroke&&(i.preventDefault(),this._strokeEnd(i))},this.velocityFilterWeight=s.velocityFilterWeight||.7,this.minWidth=s.minWidth||.5,this.maxWidth=s.maxWidth||2.5,this.throttle="throttle"in s?s.throttle:16,this.minDistance="minDistance"in s?s.minDistance:5,this.dotSize=s.dotSize||0,this.penColor=s.penColor||"black",this.backgroundColor=s.backgroundColor||"rgba(0,0,0,0)",this.compositeOperation=s.compositeOperation||"source-over",this.canvasContextOptions="canvasContextOptions"in s?s.canvasContextOptions:{},this._strokeMoveUpdate=this.throttle?throttle$1(G.prototype._strokeUpdate,this.throttle):G.prototype._strokeUpdate,this._ctx=e.getContext("2d",this.canvasContextOptions),this.clear(),this.on()}clear(){const{_ctx:e,canvas:s}=this;e.fillStyle=this.backgroundColor,e.clearRect(0,0,s.width,s.height),e.fillRect(0,0,s.width,s.height),this._data=[],this._reset(this._getPointGroupOptions()),this._isEmpty=!0}fromDataURL(e,s={}){return new Promise((i,r)=>{const o=new Image,l=s.ratio||window.devicePixelRatio||1,a=s.width||this.canvas.width/l,c=s.height||this.canvas.height/l,d=s.xOffset||0,u=s.yOffset||0;this._reset(this._getPointGroupOptions()),o.onload=()=>{this._ctx.drawImage(o,d,u,a,c),i()},o.onerror=f=>{r(f)},o.crossOrigin="anonymous",o.src=e,this._isEmpty=!1})}toDataURL(e="image/png",s){switch(e){case"image/svg+xml":return typeof s!="object"&&(s=void 0),`data:image/svg+xml;base64,${btoa(this.toSVG(s))}`;default:return typeof s!="number"&&(s=void 0),this.canvas.toDataURL(e,s)}}on(){this.canvas.style.touchAction="none",this.canvas.style.msTouchAction="none",this.canvas.style.userSelect="none";const e=/Macintosh/.test(navigator.userAgent)&&"ontouchstart"in document;window.PointerEvent&&!e?this._handlePointerEvents():(this._handleMouseEvents(),"ontouchstart"in window&&this._handleTouchEvents())}off(){this.canvas.style.touchAction="auto",this.canvas.style.msTouchAction="auto",this.canvas.style.userSelect="auto",this.canvas.removeEventListener("pointerdown",this._handlePointerStart),this.canvas.removeEventListener("pointermove",this._handlePointerMove),this.canvas.ownerDocument.removeEventListener("pointerup",this._handlePointerEnd),this.canvas.removeEventListener("mousedown",this._handleMouseDown),this.canvas.removeEventListener("mousemove",this._handleMouseMove),this.canvas.ownerDocument.removeEventListener("mouseup",this._handleMouseUp),this.canvas.removeEventListener("touchstart",this._handleTouchStart),this.canvas.removeEventListener("touchmove",this._handleTouchMove),this.canvas.removeEventListener("touchend",this._handleTouchEnd)}isEmpty(){return this._isEmpty}fromData(e,{clear:s=!0}={}){s&&this.clear(),this._fromData(e,this._drawCurve.bind(this),this._drawDot.bind(this)),this._data=this._data.concat(e)}toData(){return this._data}_getPointGroupOptions(e){return{penColor:e&&"penColor"in e?e.penColor:this.penColor,dotSize:e&&"dotSize"in e?e.dotSize:this.dotSize,minWidth:e&&"minWidth"in e?e.minWidth:this.minWidth,maxWidth:e&&"maxWidth"in e?e.maxWidth:this.maxWidth,velocityFilterWeight:e&&"velocityFilterWeight"in e?e.velocityFilterWeight:this.velocityFilterWeight,compositeOperation:e&&"compositeOperation"in e?e.compositeOperation:this.compositeOperation}}_strokeBegin(e){if(!this.dispatchEvent(new CustomEvent("beginStroke",{detail:e,cancelable:!0})))return;this._drawingStroke=!0;const i=this._getPointGroupOptions(),r=Object.assign(Object.assign({},i),{points:[]});this._data.push(r),this._reset(i),this._strokeUpdate(e)}_strokeUpdate(e){if(!this._drawingStroke)return;if(this._data.length===0){this._strokeBegin(e);return}this.dispatchEvent(new CustomEvent("beforeUpdateStroke",{detail:e}));const s=e.clientX,i=e.clientY,r=e.pressure!==void 0?e.pressure:e.force!==void 0?e.force:0,o=this._createPoint(s,i,r),l=this._data[this._data.length-1],a=l.points,c=a.length>0&&a[a.length-1],d=c?o.distanceTo(c)<=this.minDistance:!1,u=this._getPointGroupOptions(l);if(!c||!(c&&d)){const f=this._addPoint(o,u);c?f&&this._drawCurve(f,u):this._drawDot(o,u),a.push({time:o.time,x:o.x,y:o.y,pressure:o.pressure})}this.dispatchEvent(new CustomEvent("afterUpdateStroke",{detail:e}))}_strokeEnd(e){this._drawingStroke&&(this._strokeUpdate(e),this._drawingStroke=!1,this.dispatchEvent(new CustomEvent("endStroke",{detail:e})))}_handlePointerEvents(){this._drawingStroke=!1,this.canvas.addEventListener("pointerdown",this._handlePointerStart),this.canvas.addEventListener("pointermove",this._handlePointerMove),this.canvas.ownerDocument.addEventListener("pointerup",this._handlePointerEnd)}_handleMouseEvents(){this._drawingStroke=!1,this.canvas.addEventListener("mousedown",this._handleMouseDown),this.canvas.addEventListener("mousemove",this._handleMouseMove),this.canvas.ownerDocument.addEventListener("mouseup",this._handleMouseUp)}_handleTouchEvents(){this.canvas.addEventListener("touchstart",this._handleTouchStart),this.canvas.addEventListener("touchmove",this._handleTouchMove),this.canvas.addEventListener("touchend",this._handleTouchEnd)}_reset(e){this._lastPoints=[],this._lastVelocity=0,this._lastWidth=(e.minWidth+e.maxWidth)/2,this._ctx.fillStyle=e.penColor,this._ctx.globalCompositeOperation=e.compositeOperation}_createPoint(e,s,i){const r=this.canvas.getBoundingClientRect();return new Point(e-r.left,s-r.top,i,new Date().getTime())}_addPoint(e,s){const{_lastPoints:i}=this;if(i.push(e),i.length>2){i.length===3&&i.unshift(i[0]);const r=this._calculateCurveWidths(i[1],i[2],s),o=Bezier.fromPoints(i,r);return i.shift(),o}return null}_calculateCurveWidths(e,s,i){const r=i.velocityFilterWeight*s.velocityFrom(e)+(1-i.velocityFilterWeight)*this._lastVelocity,o=this._strokeWidth(r,i),l={end:o,start:this._lastWidth};return this._lastVelocity=r,this._lastWidth=o,l}_strokeWidth(e,s){return Math.max(s.maxWidth/(e+1),s.minWidth)}_drawCurveSegment(e,s,i){const r=this._ctx;r.moveTo(e,s),r.arc(e,s,i,0,2*Math.PI,!1),this._isEmpty=!1}_drawCurve(e,s){const i=this._ctx,r=e.endWidth-e.startWidth,o=Math.ceil(e.length())*2;i.beginPath(),i.fillStyle=s.penColor;for(let l=0;l<o;l+=1){const a=l/o,c=a*a,d=c*a,u=1-a,f=u*u,m=f*u;let p=m*e.startPoint.x;p+=3*f*a*e.control1.x,p+=3*u*c*e.control2.x,p+=d*e.endPoint.x;let g=m*e.startPoint.y;g+=3*f*a*e.control1.y,g+=3*u*c*e.control2.y,g+=d*e.endPoint.y;const x=Math.min(e.startWidth+d*r,s.maxWidth);this._drawCurveSegment(p,g,x)}i.closePath(),i.fill()}_drawDot(e,s){const i=this._ctx,r=s.dotSize>0?s.dotSize:(s.minWidth+s.maxWidth)/2;i.beginPath(),this._drawCurveSegment(e.x,e.y,r),i.closePath(),i.fillStyle=s.penColor,i.fill()}_fromData(e,s,i){for(const r of e){const{points:o}=r,l=this._getPointGroupOptions(r);if(o.length>1)for(let a=0;a<o.length;a+=1){const c=o[a],d=new Point(c.x,c.y,c.pressure,c.time);a===0&&this._reset(l);const u=this._addPoint(d,l);u&&s(u,l)}else this._reset(l),i(o[0],l)}}toSVG({includeBackgroundColor:e=!1}={}){const s=this._data,i=Math.max(window.devicePixelRatio||1,1),r=0,o=0,l=this.canvas.width/i,a=this.canvas.height/i,c=document.createElementNS("http://www.w3.org/2000/svg","svg");if(c.setAttribute("xmlns","http://www.w3.org/2000/svg"),c.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),c.setAttribute("viewBox",`${r} ${o} ${l} ${a}`),c.setAttribute("width",l.toString()),c.setAttribute("height",a.toString()),e&&this.backgroundColor){const d=document.createElement("rect");d.setAttribute("width","100%"),d.setAttribute("height","100%"),d.setAttribute("fill",this.backgroundColor),c.appendChild(d)}return this._fromData(s,(d,{penColor:u})=>{const f=document.createElement("path");if(!isNaN(d.control1.x)&&!isNaN(d.control1.y)&&!isNaN(d.control2.x)&&!isNaN(d.control2.y)){const m=`M ${d.startPoint.x.toFixed(3)},${d.startPoint.y.toFixed(3)} C ${d.control1.x.toFixed(3)},${d.control1.y.toFixed(3)} ${d.control2.x.toFixed(3)},${d.control2.y.toFixed(3)} ${d.endPoint.x.toFixed(3)},${d.endPoint.y.toFixed(3)}`;f.setAttribute("d",m),f.setAttribute("stroke-width",(d.endWidth*2.25).toFixed(3)),f.setAttribute("stroke",u),f.setAttribute("fill","none"),f.setAttribute("stroke-linecap","round"),c.appendChild(f)}},(d,{penColor:u,dotSize:f,minWidth:m,maxWidth:p})=>{const g=document.createElement("circle"),x=f>0?f:(m+p)/2;g.setAttribute("r",x.toString()),g.setAttribute("cx",d.x.toString()),g.setAttribute("cy",d.y.toString()),g.setAttribute("fill",u),c.appendChild(g)}),c.outerHTML}};function throttle(n,e,s){var i=s||{},r=i.noTrailing,o=r===void 0?!1:r,l=i.noLeading,a=l===void 0?!1:l,c=i.debounceMode,d=c===void 0?void 0:c,u,f=!1,m=0;function p(){u&&clearTimeout(u)}function g(E){var v=E||{},y=v.upcomingOnly,w=y===void 0?!1:y;p(),f=!w}function x(){for(var E=arguments.length,v=new Array(E),y=0;y<E;y++)v[y]=arguments[y];var w=this,S=Date.now()-m;if(f)return;function D(){m=Date.now(),e.apply(w,v)}function F(){u=void 0}!a&&d&&!u&&D(),p(),d===void 0&&S>n?a?(m=Date.now(),o||(u=setTimeout(d?F:D,n))):D():o!==!0&&(u=setTimeout(d?F:D,d===void 0?n-S:n))}return x.cancel=g,x}function debounce(n,e,s){var i={},r=i.atBegin,o=r===void 0?!1:r;return throttle(n,e,{debounceMode:o!==!1})}class SignaturePad extends React__namespace.PureComponent{constructor(s){super(s);b(this,"canvasRef",React__namespace.createRef());b(this,"signaturePad");b(this,"callResizeHandler");this.state={canvasWidth:0,canvasHeight:0},this.callResizeHandler=debounce(this.props.debounceInterval,this.handleResize.bind(this))}componentDidMount(){const s=this.canvasRef.current;s&&((!this.props.width||!this.props.height)&&(s.style.width="100%",window.addEventListener("resize",this.callResizeHandler)),this.signaturePad=new SignaturePad$1(s,this.props.options),this.scaleCanvas(s))}componentWillUnmount(){(!this.props.width||!this.props.height)&&window.removeEventListener("resize",this.callResizeHandler),this.signaturePad.off()}get instance(){return this.signaturePad}get canvas(){return this.canvasRef}set dotSize(s){this.signaturePad.dotSize=s}get dotSize(){return this.signaturePad.dotSize}set minWidth(s){this.signaturePad.minWidth=s}get minWidth(){return this.signaturePad.minWidth}set maxWidth(s){this.signaturePad.maxWidth=s}get maxWidth(){return this.signaturePad.maxWidth}set throttle(s){this.signaturePad.throttle=s}get throttle(){return this.signaturePad.throttle}set backgroundColor(s){this.signaturePad.backgroundColor=s}get backgroundColor(){return this.signaturePad.backgroundColor}set penColor(s){this.signaturePad.penColor=s}get penColor(){return this.signaturePad.penColor}set velocityFilterWeight(s){this.signaturePad.velocityFilterWeight=s}get velocityFilterWeight(){return this.signaturePad.velocityFilterWeight}isEmpty(){return this.signaturePad.isEmpty()}clear(){this.signaturePad.clear()}fromDataURL(s,i={}){this.signaturePad.fromDataURL(s,i)}toDataURL(s,i){return this.signaturePad.toDataURL(s,i)}toSVG(s){return this.signaturePad.toSVG(s)}fromData(s){this.signaturePad.fromData(s)}toData(){return this.signaturePad.toData()}off(){this.signaturePad.off()}on(){this.signaturePad.on()}handleResize(){const s=this.canvasRef.current;s&&this.scaleCanvas(s)}scaleCanvas(s){const i=Math.max(window.devicePixelRatio||1,1),r=(this.props.width||s.offsetWidth)*i,o=(this.props.height||s.offsetHeight)*i,{canvasWidth:l,canvasHeight:a}=this.state;if(r===l&&o===a)return;let c;this.props.redrawOnResize&&this.signaturePad&&!this.signaturePad.isEmpty()&&(c=this.signaturePad.toDataURL()),s.width=r,s.height=o,this.setState({canvasWidth:r,canvasHeight:o});const d=s.getContext("2d");d&&d.scale(i,i),c?this.signaturePad.fromDataURL(c):this.signaturePad&&this.signaturePad.clear()}render(){const{canvasProps:s}=this.props;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("canvas",A({"data-testid":"canvas-element",ref:this.canvasRef},s))}}b(SignaturePad,"displayName","react-signature-pad-wrapper"),b(SignaturePad,"defaultProps",{redrawOnResize:!1,debounceInterval:150});const SignatureInput=schema.connect(n=>{const{onChange:e,value:s}=n,i=React.useRef(null);React.useEffect(()=>{s&&i.current.fromDataURL(s)},[]);const r=()=>{i.current&&(i.current.clear(),e&&e(""))},o=()=>{if(i.current){const a=i.current.toDataURL();e&&e(a)}},l={pointerEvents:n.disabled?"none":"auto",opacity:n.disabled?.8:1};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{style:l,children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(SignaturePad,{ref:i,options:{penColor:"black",backgroundColor:"lightgrey"}}),!n.disabled&&__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:r,children:"清空"}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{onClick:o,children:"确认"})]})]})},schema.mapProps((n,e)=>A({},n))),ErrorBoundaryContext=React.createContext(null),initialState={didCatch:!1,error:null};class ErrorBoundary extends React.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=initialState}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){const{error:e}=this.state;if(e!==null){for(var s,i,r=arguments.length,o=new Array(r),l=0;l<r;l++)o[l]=arguments[l];(s=(i=this.props).onReset)===null||s===void 0||s.call(i,{args:o,reason:"imperative-api"}),this.setState(initialState)}}componentDidCatch(e,s){var i,r;(i=(r=this.props).onError)===null||i===void 0||i.call(r,e,s)}componentDidUpdate(e,s){const{didCatch:i}=this.state,{resetKeys:r}=this.props;if(i&&s.error!==null&&hasArrayChanged(e.resetKeys,r)){var o,l;(o=(l=this.props).onReset)===null||o===void 0||o.call(l,{next:r,prev:e.resetKeys,reason:"keys"}),this.setState(initialState)}}render(){const{children:e,fallbackRender:s,FallbackComponent:i,fallback:r}=this.props,{didCatch:o,error:l}=this.state;let a=e;if(o){const c={error:l,resetErrorBoundary:this.resetErrorBoundary};if(typeof s=="function")a=s(c);else if(i)a=React.createElement(i,c);else if(r!==void 0)a=r;else throw l}return React.createElement(ErrorBoundaryContext.Provider,{value:{didCatch:o,error:l,resetErrorBoundary:this.resetErrorBoundary}},a)}}function hasArrayChanged(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return n.length!==e.length||n.some((s,i)=>!Object.is(s,e[i]))}const ErrorBoundaryFallBack=()=>{const{t:n}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{children:n("Something went wrong. Please contact the developer to resolve the issue.")})},CustomAssociatedField=n=>{if(n.component)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundary,{fallback:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundaryFallBack,{}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{type:"string",name:n.component,"x-component":n.component,"x-component-props":n}})})},useCustomComponent=n=>{const e=client.useApp();return _.filter(e.components,s=>s.__componentType===n).map(s=>({label:s.__componentLabel,value:s.displayName}))};var CustomComponentType=(n=>(n.CUSTOM_FORM_ITEM="FORM_ITEM",n.CUSTOM_FIELD="FIELD",n.CUSTOM_ASSOCIATED_FIELD="ASSOCIATED_FIELD",n))(CustomComponentType||{});const CustomComponentStub=n=>__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{children:"请选择组件"}),CustomComponentDispatcher=n=>{if(n.component)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundary,{fallback:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundaryFallBack,{}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{type:"void",name:n.component,"x-component":n.component,"x-component-props":n}})})},customComponentDispatcherSettings=new client.SchemaSettings({name:"customComponentDispatcherSettings",items:[{name:"component",type:"select",useComponentProps(){var o;const n=useCustomComponent(CustomComponentType.CUSTOM_FORM_ITEM),{t:e}=useTranslation(),s=schema.useField(),i=schema.useFieldSchema(),{dn:r}=client.useDesignable();return{title:e("component"),value:((o=s.componentProps)==null?void 0:o.component)||"CustomComponentStub",options:[{label:"未选择组件",value:"CustomComponentStub"},...n],onChange(l){const a={"x-uid":i["x-uid"]};i["x-component-props"].component=l,i["x-acl-ignore"]=!0,a["x-component-props"]=i["x-component-props"],a["x-acl-ignore"]=!0,s.componentProps.component=l,r.emit("patch",{schema:a})}}}},{name:"divider",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0}}]}),CustomField=n=>{if(n.component)return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundary,{fallback:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ErrorBoundaryFallBack,{}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaComponent,{schema:{type:"string",name:n.component,"x-component":n.component,"x-component-props":n}})})},viewerSchema={type:"void",title:'{{ t("View record") }}',"x-component":"AssociationField.Viewer","x-component-props":{className:"tb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"RecordBlockInitializers",properties:{}}}}}}}},useInsertSchema=n=>{const e=schema.useFieldSchema(),{insertAfterBegin:s}=client.useDesignable();return React.useCallback(r=>{e.reduceProperties((l,a)=>a["x-component"]==="AssociationField."+n?a:l,null)||s(_.cloneDeep(r))},[n])},AssociatedFieldImplement=schema.observer(n=>{var w,S,D;const{collection:e,fieldExp:s,dateFieldExp:i,sourceCollection:r,sourceField:o}=n,[l,a]=React.useState(!1),c=useInsertSchema("Viewer"),d=schema.useField(),u=schema.useForm(),f=schema.useFieldSchema(),{designable:m}=client.useDesignable(),p=s==null?void 0:s.replace(/{{(.*?)}}/,"$1"),g=i==null?void 0:i.replace(/{{(.*?)}}/,"$1"),{data:x,loading:E,run:v}=client.useRequest({url:`/${r}:get`,params:{appends:[o],filter:{contract_id:(w=u.values[p])==null?void 0:w.id,start_date:{$lte:u.values[g]},end_date:{$gte:u.values[g]}}}},{manual:!0});if(React.useEffect(()=>{var F;(F=u.values[p])!=null&&F.id&&u.values[g]&&v()},[(S=u.values[p])==null?void 0:S.id,u.values[g]]),E||!x)return null;if(!((D=x.data)!=null&&D[o+"_id"]))return u.setValues({[f.name]:null}),null;const y=x.data[o];return u.setValues({[f.name]:y}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("span",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{onClick:F=>{F.stopPropagation(),F.preventDefault(),m&&c(viewerSchema),a(!0)},children:y.name}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.CollectionProvider_deprecated,{name:e,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionContextProvider,{value:{visible:l,setVisible:a,openMode:"drawer",snapshot:!1},children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RecordProvider,{record:y,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.FormProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(schema.RecursionField,{schema:f,onlyRenderProperties:!0,basePath:d.address,filterProperties:F=>F["x-component"]==="AssociationField.Viewer"})})})})})]})}),AssociatedField=schema.connect(AssociatedFieldImplement),transformFormula$1=n=>n?n.split(/([+\-*/?:()%])/).filter(s=>s):[],CalcResult=props=>{const form=schema.useForm(),fieldSchema=schema.useFieldSchema(),field=schema.useField(),{formula,prefix,suffix,decimal,panel}=props,path=field.path.entire,fieldPath=path==null?void 0:path.replace(`.${fieldSchema.name}`,""),engine=client$1.evaluators.get("math.js"),evaluate=engine.evaluate.bind(engine),defaultValue=fieldSchema.name==="subtotal"?"¥0.00":[],[value,setValue]=React.useState(defaultValue),transformFormulaArray=transformFormula$1(formula);let calculateData=[];const newFormulaArray=n=>{var i;calculateData=[];let e=0;const s={};if(transformFormulaArray.length!==0){for(let r=0;r<transformFormulaArray.length;r++){const o=transformFormulaArray[r];if(!o)continue;const l=!isNaN(Number(o)),a=["+","-","*","/","?",":","(",")","%"].includes(o);if(!l&&!a){let c;const d=/\${(.*?)}/g;if((i=o.match(d))!=null&&i.length){const m=o.match(d)[0].replace(/\${|}/g,""),p=o.split(".")[1];path===fieldPath?c=_.chain(n).get(m).get(p,0).value():c=_.chain(n).get(fieldPath).get(m).get(p,0).value()}else path===fieldPath?c=_.chain(n).get(o,0).value():c=_.chain(n).get(fieldPath).get(o,0).value();c||(c=0),e+=1;const u="var"+e,f=c;s[u]=f,calculateData.push("{{"+u+"}}")}else calculateData.push(o)}return[calculateData.join(""),s]}},fun=()=>R(this,null,function*(){if(!panel&&transformFormulaArray.length){const[n,e]=newFormulaArray(form.values);let s;try{const i=prefix||"",r=suffix||"",o=evaluate(n,e),l=isNaN(o)?o:Number(o).toFixed(decimal||0);s=i+l+r}catch(i){s=`${n}`,console.warn("code: ",n," scopes: ",e,"error: ",s," error message ",i.message)}setValue(s.toString())}else if(panel){let items=[],childrenType="";(yield import("react/jsx-runtime")).default,(yield import("dayjs")).default,childrenType="normal";try{eval(panel)}catch(n){items=[],items.push({key:"1",label:"数据异常",children:"请检查字段配置内容,error:"+n})}const showItems=items.map(n=>({label:n.label,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("p",{children:n.children})}));if(childrenType==="normal"){const n=__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Descriptions,{items:showItems});setValue(n)}else if(childrenType==="jsx"&&Array.isArray(items)){const n=__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:items.map(e=>e.children)});setValue(n)}}});return React.useEffect(()=>{fun()},[]),schema.useFormEffects(()=>{schema.onFormValuesChange(n=>{fun()})}),typeof value=="string"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Input.ReadPretty,{value}):value},Expression=n=>{var u;const{value:e="",useCurrentFields:s,onChange:i}=n,r=client.useCompile(),{interfaces:o,getCollectionFields:l}=client.useCollectionManager_deprecated(),a=(u=s==null?void 0:s())!=null?u:[],c=client.useAssociatedFields();console.log(c,"associatedFields",a);const d=a.map(f=>{var m,p;return{label:r(f.uiSchema.title),value:f.name,children:(p=(m=l(f.target))==null?void 0:m.filter(g=>g.uiSchema).map(g=>({label:g.uiSchema?r(g.uiSchema.title):"",value:g.name})))!=null?p:[]}});return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Variable.Input,{value:e,onChange:i,scope:d,changeOnSelect:!0})},ModalHeader=n=>{const{title:e,onOk:s,onCancel:i}=n;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{className:client.css`
23
23
  display: flex;
24
24
  flex-direction: row;
25
25
  justify-content: space-between;
@@ -1,19 +1,19 @@
1
1
  module.exports = {
2
- "@tachybase/client": "0.23.40",
3
- "@tachybase/components": "0.23.40",
4
- "@tachybase/server": "0.23.40",
2
+ "@tachybase/client": "0.23.41",
3
+ "@tachybase/components": "0.23.41",
4
+ "@tachybase/server": "0.23.41",
5
5
  "react": "18.3.1",
6
- "@tachybase/schema": "0.23.40",
6
+ "@tachybase/schema": "0.23.41",
7
7
  "@ant-design/icons": "5.3.7",
8
8
  "antd": "5.22.5",
9
9
  "lodash": "4.17.21",
10
- "@tachybase/utils": "0.23.40",
10
+ "@tachybase/utils": "0.23.41",
11
11
  "ahooks": "3.8.4",
12
12
  "react-router-dom": "6.28.1",
13
- "@tachybase/actions": "0.23.40",
13
+ "@tachybase/actions": "0.23.41",
14
14
  "axios": "1.7.7",
15
- "@tachybase/database": "0.23.40",
16
- "@tachybase/evaluators": "0.23.40",
15
+ "@tachybase/database": "0.23.41",
16
+ "@tachybase/evaluators": "0.23.41",
17
17
  "react-dom": "18.3.1",
18
18
  "dayjs": "1.11.13"
19
19
  };
@@ -1 +1 @@
1
- {"name":"fs-extra","version":"11.2.0","description":"fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.","engines":{"node":">=14.14"},"homepage":"https://github.com/jprichardson/node-fs-extra","repository":{"type":"git","url":"https://github.com/jprichardson/node-fs-extra"},"keywords":["fs","file","file system","copy","directory","extra","mkdirp","mkdir","mkdirs","recursive","json","read","write","extra","delete","remove","touch","create","text","output","move","promise"],"author":"JP Richardson <jprichardson@gmail.com>","license":"MIT","dependencies":{"graceful-fs":"^4.2.0","jsonfile":"^6.0.1","universalify":"^2.0.0"},"devDependencies":{"klaw":"^2.1.1","klaw-sync":"^3.0.2","minimist":"^1.1.1","mocha":"^10.1.0","nyc":"^15.0.0","proxyquire":"^2.0.1","read-dir-files":"^0.1.1","standard":"^17.0.0"},"main":"./lib/index.js","exports":{".":"./lib/index.js","./esm":"./lib/esm.mjs"},"files":["lib/","!lib/**/__tests__/"],"scripts":{"lint":"standard","test-find":"find ./lib/**/__tests__ -name *.test.js | xargs mocha","test":"npm run lint && npm run unit && npm run unit-esm","unit":"nyc node test.js","unit-esm":"node test.mjs"},"sideEffects":false,"_lastModified":"2025-01-18T18:52:58.007Z"}
1
+ {"name":"fs-extra","version":"11.2.0","description":"fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.","engines":{"node":">=14.14"},"homepage":"https://github.com/jprichardson/node-fs-extra","repository":{"type":"git","url":"https://github.com/jprichardson/node-fs-extra"},"keywords":["fs","file","file system","copy","directory","extra","mkdirp","mkdir","mkdirs","recursive","json","read","write","extra","delete","remove","touch","create","text","output","move","promise"],"author":"JP Richardson <jprichardson@gmail.com>","license":"MIT","dependencies":{"graceful-fs":"^4.2.0","jsonfile":"^6.0.1","universalify":"^2.0.0"},"devDependencies":{"klaw":"^2.1.1","klaw-sync":"^3.0.2","minimist":"^1.1.1","mocha":"^10.1.0","nyc":"^15.0.0","proxyquire":"^2.0.1","read-dir-files":"^0.1.1","standard":"^17.0.0"},"main":"./lib/index.js","exports":{".":"./lib/index.js","./esm":"./lib/esm.mjs"},"files":["lib/","!lib/**/__tests__/"],"scripts":{"lint":"standard","test-find":"find ./lib/**/__tests__ -name *.test.js | xargs mocha","test":"npm run lint && npm run unit && npm run unit-esm","unit":"nyc node test.js","unit-esm":"node test.mjs"},"sideEffects":false,"_lastModified":"2025-02-08T06:57:01.678Z"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tachybase/module-hera",
3
3
  "displayName": "Hera platform - Deprecated",
4
- "version": "1.9.40",
4
+ "version": "1.9.41",
5
5
  "description": "Hera platform - Deprecated",
6
6
  "keywords": [
7
7
  "System management"
@@ -41,21 +41,21 @@
41
41
  "throttle-debounce": "^5.0.2",
42
42
  "vitest": "^1.6.0",
43
43
  "ws": "^8.18.0",
44
- "@tachybase/components": "0.23.40",
45
- "@tachybase/schema": "0.23.40"
44
+ "@tachybase/components": "0.23.41",
45
+ "@tachybase/schema": "0.23.41"
46
46
  },
47
47
  "peerDependencies": {
48
- "@tachybase/actions": "0.23.40",
49
- "@tachybase/client": "0.23.40",
50
- "@tachybase/database": "0.23.40",
51
- "@tachybase/data-source": "0.23.40",
52
- "@tachybase/evaluators": "0.23.40",
53
- "@tachybase/module-acl": "0.23.40",
54
- "@tachybase/schema": "0.23.40",
55
- "@tachybase/module-workflow": "0.23.40",
56
- "@tachybase/server": "0.23.40",
57
- "@tachybase/test": "0.23.40",
58
- "@tachybase/utils": "0.23.40"
48
+ "@tachybase/actions": "0.23.41",
49
+ "@tachybase/data-source": "0.23.41",
50
+ "@tachybase/client": "0.23.41",
51
+ "@tachybase/database": "0.23.41",
52
+ "@tachybase/evaluators": "0.23.41",
53
+ "@tachybase/module-acl": "0.23.41",
54
+ "@tachybase/module-workflow": "0.23.41",
55
+ "@tachybase/schema": "0.23.41",
56
+ "@tachybase/test": "0.23.41",
57
+ "@tachybase/server": "0.23.41",
58
+ "@tachybase/utils": "0.23.41"
59
59
  },
60
60
  "description.zh-CN": "赫拉平台(已废弃)",
61
61
  "displayName.zh-CN": "赫拉平台",