@tachybase/module-hera 2.3.24 → 2.4.0
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/client/index.js
CHANGED
|
@@ -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),p=c.x-d.x,m=c.y-d.y,g=f/(u+f),x={x:d.x+p*g,y:d.y+m*g},b=s.x-x.x,E=s.y-x.y;return{c1:new Point(c.x+b,c.y+E),c2:new Point(d.x+b,d.y+E)}}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,p=f*u;let m=p*e.startPoint.x;m+=3*f*a*e.control1.x,m+=3*u*c*e.control2.x,m+=d*e.endPoint.x;let g=p*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(m,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 p=`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",p),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:p,maxWidth:m})=>{const g=document.createElement("circle"),x=f>0?f:(p+m)/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,p=0;function m(){u&&clearTimeout(u)}function g(b){var E=b||{},v=E.upcomingOnly,w=v===void 0?!1:v;m(),f=!w}function x(){for(var b=arguments.length,E=new Array(b),v=0;v<b;v++)E[v]=arguments[v];var w=this,C=Date.now()-p;if(f)return;function A(){p=Date.now(),e.apply(w,E)}function R(){u=void 0}!a&&d&&!u&&A(),m(),d===void 0&&C>n?a?(p=Date.now(),o||(u=setTimeout(d?R:A,n))):A():o!==!0&&(u=setTimeout(d?R:A,d===void 0?n-C: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})}const $=class $ extends React__namespace.PureComponent{constructor(e){super(e),this.canvasRef=React__namespace.createRef(),this.state={canvasWidth:0,canvasHeight:0},this.callResizeHandler=debounce(this.props.debounceInterval,this.handleResize.bind(this))}componentDidMount(){const e=this.canvasRef.current;e&&((!this.props.width||!this.props.height)&&(e.style.width="100%",window.addEventListener("resize",this.callResizeHandler)),this.signaturePad=new SignaturePad$1(e,this.props.options),this.scaleCanvas(e))}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(e){this.signaturePad.dotSize=e}get dotSize(){return this.signaturePad.dotSize}set minWidth(e){this.signaturePad.minWidth=e}get minWidth(){return this.signaturePad.minWidth}set maxWidth(e){this.signaturePad.maxWidth=e}get maxWidth(){return this.signaturePad.maxWidth}set throttle(e){this.signaturePad.throttle=e}get throttle(){return this.signaturePad.throttle}set backgroundColor(e){this.signaturePad.backgroundColor=e}get backgroundColor(){return this.signaturePad.backgroundColor}set penColor(e){this.signaturePad.penColor=e}get penColor(){return this.signaturePad.penColor}set velocityFilterWeight(e){this.signaturePad.velocityFilterWeight=e}get velocityFilterWeight(){return this.signaturePad.velocityFilterWeight}isEmpty(){return this.signaturePad.isEmpty()}clear(){this.signaturePad.clear()}fromDataURL(e,s={}){this.signaturePad.fromDataURL(e,s)}toDataURL(e,s){return this.signaturePad.toDataURL(e,s)}toSVG(e){return this.signaturePad.toSVG(e)}fromData(e){this.signaturePad.fromData(e)}toData(){return this.signaturePad.toData()}off(){this.signaturePad.off()}on(){this.signaturePad.on()}handleResize(){const e=this.canvasRef.current;e&&this.scaleCanvas(e)}scaleCanvas(e){const s=Math.max(window.devicePixelRatio||1,1),i=(this.props.width||e.offsetWidth)*s,r=(this.props.height||e.offsetHeight)*s,{canvasWidth:o,canvasHeight:l}=this.state;if(i===o&&r===l)return;let a;this.props.redrawOnResize&&this.signaturePad&&!this.signaturePad.isEmpty()&&(a=this.signaturePad.toDataURL()),e.width=i,e.height=r,this.setState({canvasWidth:i,canvasHeight:r});const c=e.getContext("2d");c&&c.scale(s,s),a?this.signaturePad.fromDataURL(a):this.signaturePad&&this.signaturePad.clear()}render(){const{canvasProps:e}=this.props;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("canvas",D({"data-testid":"canvas-element",ref:this.canvasRef},e))}};$.displayName="react-signature-pad-wrapper",$.defaultProps={redrawOnResize:!1,debounceInterval:150};let SignaturePad=$;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)=>D({},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,C,A;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:p}=client.useDesignable(),m=s==null?void 0:s.replace(/{{(.*?)}}/,"$1"),g=i==null?void 0:i.replace(/{{(.*?)}}/,"$1"),{data:x,loading:b,run:E}=client.useRequest({url:`/${r}:get`,params:{appends:[o],filter:{contract_id:(w=u.values[m])==null?void 0:w.id,start_date:{$lte:u.values[g]},end_date:{$gte:u.values[g]}}}},{manual:!0});if(React.useEffect(()=>{var R;(R=u.values[m])!=null&&R.id&&u.values[g]&&E()},[(C=u.values[m])==null?void 0:C.id,u.values[g]]),b||!x)return null;if(!((A=x.data)!=null&&A[o+"_id"]))return u.setValues({[f.name]:null}),null;const v=x.data[o];return u.setValues({[f.name]:v}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("span",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{onClick:R=>{R.stopPropagation(),R.preventDefault(),p&&c(viewerSchema),a(!0)},children:v.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:v,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:R=>R["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 p=o.match(d)[0].replace(/\${|}/g,""),m=o.split(".")[1];path===fieldPath?c=_.chain(n).get(p).get(m,0).value():c=_.chain(n).get(fieldPath).get(p).get(m,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=()=>T(null,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="";const{jsx}=(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 p,m;return{label:r(f.uiSchema.title),value:f.name,children:(m=(p=l(f.target))==null?void 0:p.filter(g=>g.uiSchema).map(g=>({label:g.uiSchema?r(g.uiSchema.title):"",value:g.name})))!=null?m:[]}});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),p=c.x-d.x,m=c.y-d.y,g=f/(u+f),x={x:d.x+p*g,y:d.y+m*g},b=s.x-x.x,E=s.y-x.y;return{c1:new Point(c.x+b,c.y+E),c2:new Point(d.x+b,d.y+E)}}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,p=f*u;let m=p*e.startPoint.x;m+=3*f*a*e.control1.x,m+=3*u*c*e.control2.x,m+=d*e.endPoint.x;let g=p*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(m,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 p=`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",p),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:p,maxWidth:m})=>{const g=document.createElement("circle"),x=f>0?f:(p+m)/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,p=0;function m(){u&&clearTimeout(u)}function g(b){var E=b||{},v=E.upcomingOnly,w=v===void 0?!1:v;m(),f=!w}function x(){for(var b=arguments.length,E=new Array(b),v=0;v<b;v++)E[v]=arguments[v];var w=this,C=Date.now()-p;if(f)return;function A(){p=Date.now(),e.apply(w,E)}function R(){u=void 0}!a&&d&&!u&&A(),m(),d===void 0&&C>n?a?(p=Date.now(),o||(u=setTimeout(d?R:A,n))):A():o!==!0&&(u=setTimeout(d?R:A,d===void 0?n-C: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})}const $=class $ extends React__namespace.PureComponent{constructor(e){super(e),this.canvasRef=React__namespace.createRef(),this.state={canvasWidth:0,canvasHeight:0},this.callResizeHandler=debounce(this.props.debounceInterval,this.handleResize.bind(this))}componentDidMount(){const e=this.canvasRef.current;e&&((!this.props.width||!this.props.height)&&(e.style.width="100%",window.addEventListener("resize",this.callResizeHandler)),this.signaturePad=new SignaturePad$1(e,this.props.options),this.scaleCanvas(e))}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(e){this.signaturePad.dotSize=e}get dotSize(){return this.signaturePad.dotSize}set minWidth(e){this.signaturePad.minWidth=e}get minWidth(){return this.signaturePad.minWidth}set maxWidth(e){this.signaturePad.maxWidth=e}get maxWidth(){return this.signaturePad.maxWidth}set throttle(e){this.signaturePad.throttle=e}get throttle(){return this.signaturePad.throttle}set backgroundColor(e){this.signaturePad.backgroundColor=e}get backgroundColor(){return this.signaturePad.backgroundColor}set penColor(e){this.signaturePad.penColor=e}get penColor(){return this.signaturePad.penColor}set velocityFilterWeight(e){this.signaturePad.velocityFilterWeight=e}get velocityFilterWeight(){return this.signaturePad.velocityFilterWeight}isEmpty(){return this.signaturePad.isEmpty()}clear(){this.signaturePad.clear()}fromDataURL(e,s={}){this.signaturePad.fromDataURL(e,s)}toDataURL(e,s){return this.signaturePad.toDataURL(e,s)}toSVG(e){return this.signaturePad.toSVG(e)}fromData(e){this.signaturePad.fromData(e)}toData(){return this.signaturePad.toData()}off(){this.signaturePad.off()}on(){this.signaturePad.on()}handleResize(){const e=this.canvasRef.current;e&&this.scaleCanvas(e)}scaleCanvas(e){const s=Math.max(window.devicePixelRatio||1,1),i=(this.props.width||e.offsetWidth)*s,r=(this.props.height||e.offsetHeight)*s,{canvasWidth:o,canvasHeight:l}=this.state;if(i===o&&r===l)return;let a;this.props.redrawOnResize&&this.signaturePad&&!this.signaturePad.isEmpty()&&(a=this.signaturePad.toDataURL()),e.width=i,e.height=r,this.setState({canvasWidth:i,canvasHeight:r});const c=e.getContext("2d");c&&c.scale(s,s),a?this.signaturePad.fromDataURL(a):this.signaturePad&&this.signaturePad.clear()}render(){const{canvasProps:e}=this.props;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("canvas",D({"data-testid":"canvas-element",ref:this.canvasRef},e))}};$.displayName="react-signature-pad-wrapper",$.defaultProps={redrawOnResize:!1,debounceInterval:150};let SignaturePad=$;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)=>D({},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,C,A;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:p}=client.useDesignable(),m=s==null?void 0:s.replace(/{{(.*?)}}/,"$1"),g=i==null?void 0:i.replace(/{{(.*?)}}/,"$1"),{data:x,loading:b,run:E}=client.useRequest({url:`/${r}:get`,params:{appends:[o],filter:{contract_id:(w=u.values[m])==null?void 0:w.id,start_date:{$lte:u.values[g]},end_date:{$gte:u.values[g]}}}},{manual:!0});if(React.useEffect(()=>{var R;(R=u.values[m])!=null&&R.id&&u.values[g]&&E()},[(C=u.values[m])==null?void 0:C.id,u.values[g]]),b||!x)return null;if(!((A=x.data)!=null&&A[o+"_id"]))return u.setValues({[f.name]:null}),null;const v=x.data[o];return u.setValues({[f.name]:v}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("span",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("a",{onClick:R=>{R.stopPropagation(),R.preventDefault(),p&&c(viewerSchema),a(!0)},children:v.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:v,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:R=>R["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==null?void 0: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 p=o.match(d)[0].replace(/\${|}/g,""),m=o.split(".")[1];path===fieldPath?c=_.chain(n).get(p).get(m,0).value():c=_.chain(n).get(fieldPath).get(p).get(m,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=()=>T(null,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="";const{jsx}=(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 p,m;return{label:r(f.uiSchema.title),value:f.name,children:(m=(p=l(f.target))==null?void 0:p.filter(g=>g.uiSchema).map(g=>({label:g.uiSchema?r(g.uiSchema.title):"",value:g.name})))!=null?m:[]}});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;
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
z-index: 0;
|
|
66
66
|
padding: 0px 50px;
|
|
67
67
|
}
|
|
68
|
-
`,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(reactRouterDom.Outlet,{})})});function NotAuthorityResult(){return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Result,{status:"403",title:"403",subTitle:"Sorry, you are not authorized to access this page."})}function useEmbedToken(){const n=new URL(window.location.href),e=client.useAPIClient(),s=n.searchParams.get("token");return s&&e.auth.setToken(s),e.auth.getToken()}const EmbedPage=()=>{const n=useEmbedToken(),e=reactRouterDom.useNavigate(),s=reactRouterDom.useLocation(),i=reactRouterDom.useMatch("/embed/:name");return React.useEffect(()=>()=>{setTimeout(()=>{i&&setTimeout(()=>{window.location.pathname!==s.pathname&&e("/embed/not-authorized")})})},[]),!n||s.pathname==="/embed/not-authorized"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(NotAuthorityResult,{}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.AdminProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(EmbedLayout,{})})};function EmbedSchemaComponent(){const n=reactRouterDom.useParams();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RemoteSchemaComponent,{uid:n.name})}function usePageSettingsProps(){const n=reactRouterDom.useMatch("/admin/:name"),e=reactRouterDom.useMatch("/embed/:name"),s=n||e,i=schema.useFieldSchema(),{message:r,notification:o}=antd.App.useApp(),{t:l}=useTranslation();return{title:l("Copy embedded link"),onClick:()=>{const a=window.location.href.replace("/admin","/embed").replace(s.params.name,i["x-uid"]).replace(window.location.search||"","");navigator.clipboard.writeText(a).then(()=>{r.success(l("Copy successful"))}).catch(c=>{o.error({message:l("Copy Failed"),description:c.message,placement:"topRight"})})}}}const keyEmbed="embed",pathEmbed=`/${keyEmbed}`;class EmbedPlugin extends client.Plugin{load(){return T(this,null,function*(){this.router.add(keyEmbed,{path:pathEmbed,Component:EmbedPage}),this.router.add(`${keyEmbed}.page`,{path:`${pathEmbed}/:name`,Component:EmbedSchemaComponent}),this.router.add(`${keyEmbed}.notAuthorized`,{path:`${pathEmbed}/not-authorized`,element:null}),this.schemaSettingsManager.addItem("PageSettings",keyEmbed,{type:"item",useComponentProps:usePageSettingsProps})})}}const{defaultProps:defaultProps$3}=client.interfacesProperties;class ShowFieldCodeInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="codeShow",this.type="object",this.group="advanced",this.title="jsCode(显示)",this.description="通过jsCode, 用于定制化显示用户界面内容.可使用的变量:scopes:{ form, path, recordData, result, setResult, formatFunc, dayjs}; handlers: { setResult, formatFunc }; modules: { dayjs }",this.sortable=!0,this.default={type:"virtual",uiSchema:{type:"string","x-component":"ViewCode","x-component-props":{jsCode:"",prefix:"",suffix:"",decimal:""},"x-read-pretty":!0}},this.properties=I(D({},defaultProps$3),{"uiSchema.x-component-props.prefix":{type:"string",title:"前缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.suffix":{type:"string",title:"后缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.decimal":{type:"string",title:'{{t("Precision")}}',"x-component":"Select","x-decorator":"FormItem",default:"0",enum:[{value:"0",label:"1"},{value:"1",label:"1.0"},{value:"2",label:"1.00"},{value:"3",label:"1.000"},{value:"4",label:"1.0000"},{value:"5",label:"1.00000"}]},"uiSchema.x-component-props.jsCode":{type:"string",title:"JSCode","x-decorator":"FormItem","x-component":"CodeMirror",default:"",required:!0}})}}const ViewCode=n=>{const e=useAction$1(n);return typeof e=="string"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ShowValue$1,{value:e}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:e})},ShowValue$1=React.memo(n=>{const{value:e}=n;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Input.ReadPretty,{value:e})});function useAction$1(n){var x,b,E,v;const e=schema.useForm(),s=schema.useFieldSchema(),i=schema.useField(),{jsCode:r,prefix:o,suffix:l,decimal:a}=n,c=i.path.entire,d=c==null?void 0:c.replace(`.${s.name}`,""),u=_.chain(e.values).get(d).value(),[f,p]=React.useState({items:[],childrenType:""}),m=w=>{let C=w;return typeof w=="number"&&(C=isNaN(w)?w:Number(w).toFixed(+a||0)),`${o}${C}${l}`};React.useEffect(()=>{dynamicCode({jsCode:r,form:e,path:c,recordData:u,result:f},{setResult:p,formatFunc:m})},[]);const g=(x=f==null?void 0:f.items)==null?void 0:x.map(w=>({label:w.label,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("p",{children:w.children})}));return f.childrenType==="normal"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Descriptions,{items:g}):f.childrenType==="jsx"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:(b=f==null?void 0:f.items)==null?void 0:b.map(w=>w.children)}):(v=(E=f.items)==null?void 0:E[0])==null?void 0:v.children}function dynamicCode(a,c){return T(this,arguments,function*({jsCode:n,form:e,path:s,recordData:i,result:r},{setResult:o,formatFunc:l}){try{const d={data:{form:e,path:s,recordData:i,result:r,setResult:o,formatFunc:l},body:{}};yield evalSimulate(n,{ctx:d,lib:{log:console.log,JSON,dayjs}}),o(d.body)}catch(d){o({childrenType:"",items:[{key:"1",label:"数据异常",children:"请检查字段配置内容,error:"+d}]})}})}function evalSimulate(i,r){return T(this,arguments,function*(n,{ctx:e,lib:s}){const o=(function(){return T(this,null,function*(){})}).constructor;try{return yield new o("$root",`with($root) { ${n}; }`)({ctx:e,lib:s})}catch(l){console.log("err",l)}})}const{defaultProps:defaultProps$2}=client.interfacesProperties;class ShowFieldFormulaInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="formulaShow",this.type="object",this.group="advanced",this.title="公式(显示)",this.description="通过公式, 用于定制化显示用户界面内容",this.sortable=!0,this.default={type:"virtual",uiSchema:{type:"string","x-component":"Viewformula","x-component-props":{formulaString:"",prefix:"",suffix:"",decimal:""},"x-read-pretty":!0}},this.properties=I(D({},defaultProps$2),{"uiSchema.x-component-props.prefix":{type:"string",title:"前缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.suffix":{type:"string",title:"后缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.decimal":{type:"string",title:'{{t("Precision")}}',"x-component":"Select","x-decorator":"FormItem",required:!0,default:"0",enum:[{value:"0",label:"1"},{value:"1",label:"1.0"},{value:"2",label:"1.00"},{value:"3",label:"1.000"},{value:"4",label:"1.0000"},{value:"5",label:"1.00000"}]},"uiSchema.x-component-props.formulaString":{type:"string",title:"公式","x-decorator":"FormItem","x-component":"Input",default:"",required:!0}})}}const ViewFormula=n=>{const{resultShowValue:e}=useAction(n);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ShowValue,{value:e})},ShowValue=React.memo(n=>{const{value:e}=n;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Input.ReadPretty,{value:e})});function useAction(n){const e=schema.useForm(),s=schema.useFieldSchema(),i=schema.useField(),{formulaString:r,prefix:o,suffix:l,decimal:a}=n,c=i.path.entire,d=c==null?void 0:c.replace(`.${s.name}`,""),u=_.chain(e.values).get(d).value(),f=transformFormula(r),p=getEvaluateArray(f,u);return p?{resultShowValue:getResultShowValue(p,{prefix:o,suffix:l,decimal:a})}:{resultShowValue:""}}function transformFormula(n){return n?n.split(/([+\-*/?:()%])/).filter(s=>s):[]}function getEvaluateArray(n,e){var o;if(n.length<1)return;let s=0;const i=[],r={};for(let l=0;l<n.length;l++){const a=n[l];if(!a)continue;const c=isNumberFunc(a),d=isSymbolFunc(a);if(!c&&!d){let u;const f=/\${(.*?)}/g;if((o=a.match(f))!=null&&o.length){const g=a.match(f)[0].replace(/\${|}/g,""),x=a.split(".")[1],b=_.chain(e).get(g).value();u=_.chain(b).get(x,0).value()}else u=_.chain(e).get(a,0).value();const p=`var${s++}`,m=u!=null?u:0;i.push(`{{${p}}}`),r[p]=m}else i.push(a)}return[i.join(""),r]}function getResultShowValue(n,{prefix:e,suffix:s,decimal:i}){const r=client$1.evaluators.get("math.js"),o=r.evaluate.bind(r),[l,a]=n;let c;try{const d=o(l,a),u=isNaN(d)?d:Number(d).toFixed(+i||0);c=`${e}${u}${s}`}catch(d){c=`${l}`,console.warn("code: ",l," scopes: ",a,"error: ",c," error message ",d.message)}return c}function isNumberFunc(n){return typeof n=="number"&&!isNaN(n)}function isSymbolFunc(n){return["+","-","*","/","?",":","(",")","%"].includes(n)}class PluginFieldAppends extends client.Plugin{load(){return T(this,null,function*(){this.app.addComponents({Viewformula:ViewFormula,ViewCode}),this.app.dataSourceManager.addFieldInterfaces([ShowFieldFormulaInterface,ShowFieldCodeInterface])})}}const usePluginVersion=()=>{var e,s;const{data:n}=client.useRequest({url:"hera:version"});return(s=(e=n==null?void 0:n.data)==null?void 0:e.packageJson)==null?void 0:s.version},useHeraVersion=()=>{const n=usePluginVersion();return{key:"hera-version",eventKey:"hera-version",label:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("span",{children:["赫拉系统 - ",n]})}},HeraVersionProvider=({children:n})=>{const{addMenuItem:e}=client.useCurrentUserSettingsMenu(),s=useHeraVersion();return React.useEffect(()=>{e(s,{before:"divider_1"})},[e,s]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:n})};class PluginHeraVersion extends client.Plugin{load(){return T(this,null,function*(){this.app.use(HeraVersionProvider)})}}const OutboundLinkActionInitializer=n=>{const e={title:tval("outbound"),"x-action":"outbound","x-component":"OutboundButton","x-designer":"Action.Designer","x-component-props":{icon:"ShareAltOutlined",useProps:"{{ useOutboundActionProps }}"}};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionInitializer,I(D({},n),{schema:e}))};OutboundLinkActionInitializer.displayName="OutboundLinkActionInitializer";const OutboundButton=n=>{const{onClick:e}=client.useProps(n),s=schema.useFieldSchema(),i=window.location.href.split("/",3).join("/"),{t:r}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Popover,{placement:"bottomRight",trigger:"click",autoAdjustOverflow:!0,content:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Space.Compact,{style:{width:"100%"},children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{defaultValue:`${i}/r/${s["x-uid"]}`}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{type:"primary",onClick:e,children:r("Copy link")})]}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Button,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.ShareAltOutlined,{}),r("Outbound")]})})};OutboundButton.displayName="OutboundButton";const OutboundPage=()=>{const n=reactRouterDom.useParams();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.AdminProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RemoteCollectionManagerProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RemoteSchemaComponent,{uid:n.id})})})};var toggleSelection,hasRequiredToggleSelection;function requireToggleSelection(){return hasRequiredToggleSelection||(hasRequiredToggleSelection=1,toggleSelection=function(){var n=document.getSelection();if(!n.rangeCount)return function(){};for(var e=document.activeElement,s=[],i=0;i<n.rangeCount;i++)s.push(n.getRangeAt(i));switch(e.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":e.blur();break;default:e=null;break}return n.removeAllRanges(),function(){n.type==="Caret"&&n.removeAllRanges(),n.rangeCount||s.forEach(function(r){n.addRange(r)}),e&&e.focus()}}),toggleSelection}var copyToClipboard,hasRequiredCopyToClipboard;function requireCopyToClipboard(){if(hasRequiredCopyToClipboard)return copyToClipboard;hasRequiredCopyToClipboard=1;var n=requireToggleSelection(),e={"text/plain":"Text","text/html":"Url",default:"Text"},s="Copy to clipboard: #{key}, Enter";function i(o){var l=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return o.replace(/#{\s*key\s*}/g,l)}function r(o,l){var a,c,d,u,f,p,m=!1;l||(l={}),a=l.debug||!1;try{d=n(),u=document.createRange(),f=document.getSelection(),p=document.createElement("span"),p.textContent=o,p.ariaHidden="true",p.style.all="unset",p.style.position="fixed",p.style.top=0,p.style.clip="rect(0, 0, 0, 0)",p.style.whiteSpace="pre",p.style.webkitUserSelect="text",p.style.MozUserSelect="text",p.style.msUserSelect="text",p.style.userSelect="text",p.addEventListener("copy",function(x){if(x.stopPropagation(),l.format)if(x.preventDefault(),typeof x.clipboardData=="undefined"){a&&console.warn("unable to use e.clipboardData"),a&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var b=e[l.format]||e.default;window.clipboardData.setData(b,o)}else x.clipboardData.clearData(),x.clipboardData.setData(l.format,o);l.onCopy&&(x.preventDefault(),l.onCopy(x.clipboardData))}),document.body.appendChild(p),u.selectNodeContents(p),f.addRange(u);var g=document.execCommand("copy");if(!g)throw new Error("copy command was unsuccessful");m=!0}catch(x){a&&console.error("unable to copy using execCommand: ",x),a&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(l.format||"text",o),l.onCopy&&l.onCopy(window.clipboardData),m=!0}catch(b){a&&console.error("unable to copy using clipboardData: ",b),a&&console.error("falling back to prompt"),c=i("message"in l?l.message:s),window.prompt(c,o)}}finally{f&&(typeof f.removeRange=="function"?f.removeRange(u):f.removeAllRanges()),p&&document.body.removeChild(p),d()}return m}return copyToClipboard=r,copyToClipboard}var copyToClipboardExports=requireCopyToClipboard();const copy=getDefaultExportFromCjs(copyToClipboardExports),useOutboundActionProps=()=>{let n=schema.useFieldSchema();const{t:e}=useTranslation();for(;!("x-decorator-props"in n);)n=n.parent;const s=window.location.href.split("/",3).join("/");return{onClick(){return T(this,null,function*(){copy(`${s}/r/${n["x-uid"]}`)?antd.message.success(e("Save link successful")):antd.message.success(e("Save link failed"))})}}};class PluginOutbound extends client.Plugin{load(){return T(this,null,function*(){this.app.router.add("outbound",{path:"/r/:id",Component:OutboundPage}),this.app.addScopes({useOutboundActionProps}),this.app.addComponents({OutboundButton,OutboundLinkActionInitializer});const e={type:"item",name:"enableActions.outbound",title:lang("outbound"),Component:"OutboundLinkActionInitializer",schema:{"x-align":"right"}};this.app.schemaInitializerManager.addItem("table:configureActions",e.name,e),this.app.schemaInitializerManager.addItem("details:configureActions",e.name,e),this.app.schemaInitializerManager.addItem("kanban:configureActions",e.name,e),this.app.schemaInitializerManager.addItem("pdfViewer:configureActions",e.name,e)})}}const PDFViewerContext=React.createContext(null),usePDFViewerRef=()=>React.useContext(PDFViewerContext),PDFViewerProvider=n=>{const e=React.useRef(null),s=client.useApp(),{decorator:i}=n,r=s.getComponent(i);return r?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(PDFViewerContext.Provider,{value:e,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(r,{children:n.children})}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(PDFViewerContext.Provider,{value:e,children:n.children})},usePDFViewerPrintActionProps=()=>{const n=usePDFViewerRef();return{onClick:()=>T(null,null,function*(){n.current.print()})}},PDFViewerPrintActionInitializer=n=>{const e={title:tval("Print"),"x-action":"print","x-component":"Action","x-designer":"Action.Designer","x-component-props":{useProps:"{{ usePDFViewerPrintActionProps }}",icon:"PrinterOutlined"}};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionInitializer,I(D({},n),{schema:e}))},pdfViewActionInitializer=new client.SchemaInitializer({name:"pdfViewer:configureActions",title:"Configure actions",icon:"SettingOutlined",style:{marginLeft:8},items:[{name:"enableActions",type:"itemGroup",title:tval("Enable actions"),children:[{name:"print",type:"item",title:tval("Print"),component:"PDFViewerPrintActionInitializer"},{name:"edit",title:tval("Edit"),Component:"UpdateActionInitializer",schema:{"x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{type:"primary"}}}]}]}),PDFViewerBlockInitializer=()=>{const{insert:n}=client.useSchemaInitializer(),e=client.useSchemaInitializerItem();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaInitializerItem,I(D({},e),{icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.PrinterOutlined,{}),onClick:()=>{var s;n({type:"void","x-designer":"Markdown.Void.Designer","x-decorator":"PDFViewerProvider","x-decorator-props":{decorator:(s=e.decorator)!=null?s:""},"x-component":"CardItem",properties:{actions:{type:"void","x-initializer":"pdfViewer:configureActions","x-component":"ActionBar","x-component-props":{},properties:{}},viewer:{type:"void","x-component":"PDFViwer","x-component-props":{target:e.target,usePdfPath:e.usePdfPath}}}})}}))},InternalPDFViewer=n=>{const{usePdfPath:e}=n,s=React.useRef(null),[i,r]=React.useState(0),[,o]=React.useState(0);React.useEffect(()=>{const d=_.debounce(()=>{s.current&&(r(s.current.offsetWidth),o(s.current.offsetHeight))},200),u=new ResizeObserver(()=>{d()});return s.current&&u.observe(s.current),()=>{u.disconnect()}},[s]);const l=usePDFViewerRef(),c=(e!=null?e:()=>"")();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{className:client.css`
|
|
68
|
+
`,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(reactRouterDom.Outlet,{})})});function NotAuthorityResult(){return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Result,{status:"403",title:"403",subTitle:"Sorry, you are not authorized to access this page."})}function useEmbedToken(){const n=new URL(window.location.href),e=client.useAPIClient(),s=n.searchParams.get("token");return s&&e.auth.setToken(s),e.auth.getToken()}const EmbedPage=()=>{const n=useEmbedToken(),e=reactRouterDom.useNavigate(),s=reactRouterDom.useLocation(),i=reactRouterDom.useMatch("/embed/:name");return React.useEffect(()=>()=>{setTimeout(()=>{i&&setTimeout(()=>{window.location.pathname!==s.pathname&&e("/embed/not-authorized")})})},[]),!n||s.pathname==="/embed/not-authorized"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(NotAuthorityResult,{}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.AdminProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(EmbedLayout,{})})};function EmbedSchemaComponent(){const n=reactRouterDom.useParams();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RemoteSchemaComponent,{uid:n.name})}function usePageSettingsProps(){const n=reactRouterDom.useMatch("/admin/:name"),e=reactRouterDom.useMatch("/embed/:name"),s=n||e,i=schema.useFieldSchema(),{message:r,notification:o}=antd.App.useApp(),{t:l}=useTranslation();return{title:l("Copy embedded link"),onClick:()=>{const a=window.location.href.replace("/admin","/embed").replace(s.params.name,i["x-uid"]).replace(window.location.search||"","");navigator.clipboard.writeText(a).then(()=>{r.success(l("Copy successful"))}).catch(c=>{o.error({message:l("Copy Failed"),description:c.message,placement:"topRight"})})}}}const keyEmbed="embed",pathEmbed=`/${keyEmbed}`;class EmbedPlugin extends client.Plugin{load(){return T(this,null,function*(){this.router.add(keyEmbed,{path:pathEmbed,Component:EmbedPage}),this.router.add(`${keyEmbed}.page`,{path:`${pathEmbed}/:name`,Component:EmbedSchemaComponent}),this.router.add(`${keyEmbed}.notAuthorized`,{path:`${pathEmbed}/not-authorized`,element:null}),this.schemaSettingsManager.addItem("PageSettings",keyEmbed,{type:"item",useComponentProps:usePageSettingsProps})})}}const{defaultProps:defaultProps$3}=client.interfacesProperties;class ShowFieldCodeInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="codeShow",this.type="object",this.group="advanced",this.title="jsCode(显示)",this.description="通过jsCode, 用于定制化显示用户界面内容.可使用的变量:scopes:{ form, path, recordData, result, setResult, formatFunc, dayjs}; handlers: { setResult, formatFunc }; modules: { dayjs }",this.sortable=!0,this.default={type:"virtual",uiSchema:{type:"string","x-component":"ViewCode","x-component-props":{jsCode:"",prefix:"",suffix:"",decimal:""},"x-read-pretty":!0}},this.properties=I(D({},defaultProps$3),{"uiSchema.x-component-props.prefix":{type:"string",title:"前缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.suffix":{type:"string",title:"后缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.decimal":{type:"string",title:'{{t("Precision")}}',"x-component":"Select","x-decorator":"FormItem",default:"0",enum:[{value:"0",label:"1"},{value:"1",label:"1.0"},{value:"2",label:"1.00"},{value:"3",label:"1.000"},{value:"4",label:"1.0000"},{value:"5",label:"1.00000"}]},"uiSchema.x-component-props.jsCode":{type:"string",title:"JSCode","x-decorator":"FormItem","x-component":"CodeMirror",default:"",required:!0}})}}const ViewCode=n=>{const e=useAction$1(n);return typeof e=="string"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ShowValue$1,{value:e}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:e})},ShowValue$1=React.memo(n=>{const{value:e}=n;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Input.ReadPretty,{value:e})});function useAction$1(n){var x,b,E,v;const e=schema.useForm(),s=schema.useFieldSchema(),i=schema.useField(),{jsCode:r,prefix:o,suffix:l,decimal:a}=n,c=i.path.entire,d=c==null?void 0:c.replace(`.${s.name}`,""),u=_.chain(e.values).get(d).value(),[f,p]=React.useState({items:[],childrenType:""}),m=w=>{let C=w;return typeof w=="number"&&(C=isNaN(w)?w:Number(w).toFixed(+a||0)),`${o}${C}${l}`};React.useEffect(()=>{dynamicCode({jsCode:r,form:e,path:c,recordData:u,result:f},{setResult:p,formatFunc:m})},[]);const g=(x=f==null?void 0:f.items)==null?void 0:x.map(w=>({label:w.label,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("p",{children:w.children})}));return f.childrenType==="normal"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Descriptions,{items:g}):f.childrenType==="jsx"?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:(b=f==null?void 0:f.items)==null?void 0:b.map(w=>w.children)}):(v=(E=f.items)==null?void 0:E[0])==null?void 0:v.children}function dynamicCode(a,c){return T(this,arguments,function*({jsCode:n,form:e,path:s,recordData:i,result:r},{setResult:o,formatFunc:l}){try{const d={data:{form:e,path:s,recordData:i,result:r,setResult:o,formatFunc:l},body:{}};yield evalSimulate(n,{ctx:d,lib:{log:console.log,JSON,dayjs}}),o(d.body)}catch(d){o({childrenType:"",items:[{key:"1",label:"数据异常",children:"请检查字段配置内容,error:"+d}]})}})}function evalSimulate(i,r){return T(this,arguments,function*(n,{ctx:e,lib:s}){const o=(function(){return T(this,null,function*(){})}).constructor;try{return yield new o("$root",`with($root) { ${n}; }`)({ctx:e,lib:s})}catch(l){console.log("err",l)}})}const{defaultProps:defaultProps$2}=client.interfacesProperties;class ShowFieldFormulaInterface extends client.CollectionFieldInterface{constructor(){super(...arguments),this.name="formulaShow",this.type="object",this.group="advanced",this.title="公式(显示)",this.description="通过公式, 用于定制化显示用户界面内容",this.sortable=!0,this.default={type:"virtual",uiSchema:{type:"string","x-component":"Viewformula","x-component-props":{formulaString:"",prefix:"",suffix:"",decimal:""},"x-read-pretty":!0}},this.properties=I(D({},defaultProps$2),{"uiSchema.x-component-props.prefix":{type:"string",title:"前缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.suffix":{type:"string",title:"后缀","x-decorator":"FormItem","x-component":"Input"},"uiSchema.x-component-props.decimal":{type:"string",title:'{{t("Precision")}}',"x-component":"Select","x-decorator":"FormItem",required:!0,default:"0",enum:[{value:"0",label:"1"},{value:"1",label:"1.0"},{value:"2",label:"1.00"},{value:"3",label:"1.000"},{value:"4",label:"1.0000"},{value:"5",label:"1.00000"}]},"uiSchema.x-component-props.formulaString":{type:"string",title:"公式","x-decorator":"FormItem","x-component":"Input",default:"",required:!0}})}}const ViewFormula=n=>{const{resultShowValue:e}=useAction(n);return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(ShowValue,{value:e})},ShowValue=React.memo(n=>{const{value:e}=n;return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.Input.ReadPretty,{value:e})});function useAction(n){const e=schema.useForm(),s=schema.useFieldSchema(),i=schema.useField(),{formulaString:r,prefix:o,suffix:l,decimal:a}=n,c=i.path.entire,d=c==null?void 0:c.replace(`.${s.name}`,""),u=_.chain(e.values).get(d).value(),f=transformFormula(r),p=getEvaluateArray(f,u);return p?{resultShowValue:getResultShowValue(p,{prefix:o,suffix:l,decimal:a})}:{resultShowValue:""}}function transformFormula(n){return n?n.split(/([+\-*/?:()%])/).filter(s=>s):[]}function getEvaluateArray(n,e){var o;if(n.length<1)return;let s=0;const i=[],r={};for(let l=0;l<n.length;l++){const a=n[l];if(!a)continue;const c=isNumberFunc(a),d=isSymbolFunc(a);if(!c&&!d){let u;const f=/\${(.*?)}/g;if((o=a.match(f))!=null&&o.length){const g=a.match(f)[0].replace(/\${|}/g,""),x=a.split(".")[1],b=_.chain(e).get(g).value();u=_.chain(b).get(x,0).value()}else u=_.chain(e).get(a,0).value();const p=`var${s++}`,m=u!=null?u:0;i.push(`{{${p}}}`),r[p]=m}else i.push(a)}return[i.join(""),r]}function getResultShowValue(n,{prefix:e,suffix:s,decimal:i}){const r=client$1.evaluators.get("math.js"),o=r==null?void 0:r.evaluate.bind(r),[l,a]=n;let c;try{const d=o(l,a),u=isNaN(d)?d:Number(d).toFixed(+i||0);c=`${e}${u}${s}`}catch(d){c=`${l}`,console.warn("code: ",l," scopes: ",a,"error: ",c," error message ",d.message)}return c}function isNumberFunc(n){return typeof n=="number"&&!isNaN(n)}function isSymbolFunc(n){return["+","-","*","/","?",":","(",")","%"].includes(n)}class PluginFieldAppends extends client.Plugin{load(){return T(this,null,function*(){this.app.addComponents({Viewformula:ViewFormula,ViewCode}),this.app.dataSourceManager.addFieldInterfaces([ShowFieldFormulaInterface,ShowFieldCodeInterface])})}}const usePluginVersion=()=>{var e,s;const{data:n}=client.useRequest({url:"hera:version"});return(s=(e=n==null?void 0:n.data)==null?void 0:e.packageJson)==null?void 0:s.version},useHeraVersion=()=>{const n=usePluginVersion();return{key:"hera-version",eventKey:"hera-version",label:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("span",{children:["赫拉系统 - ",n]})}},HeraVersionProvider=({children:n})=>{const{addMenuItem:e}=client.useCurrentUserSettingsMenu(),s=useHeraVersion();return React.useEffect(()=>{e(s,{before:"divider_1"})},[e,s]),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment,{children:n})};class PluginHeraVersion extends client.Plugin{load(){return T(this,null,function*(){this.app.use(HeraVersionProvider)})}}const OutboundLinkActionInitializer=n=>{const e={title:tval("outbound"),"x-action":"outbound","x-component":"OutboundButton","x-designer":"Action.Designer","x-component-props":{icon:"ShareAltOutlined",useProps:"{{ useOutboundActionProps }}"}};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionInitializer,I(D({},n),{schema:e}))};OutboundLinkActionInitializer.displayName="OutboundLinkActionInitializer";const OutboundButton=n=>{const{onClick:e}=client.useProps(n),s=schema.useFieldSchema(),i=window.location.href.split("/",3).join("/"),{t:r}=useTranslation();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Popover,{placement:"bottomRight",trigger:"click",autoAdjustOverflow:!0,content:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Space.Compact,{style:{width:"100%"},children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Input,{defaultValue:`${i}/r/${s["x-uid"]}`}),__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(antd.Button,{type:"primary",onClick:e,children:r("Copy link")})]}),children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs(antd.Button,{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.ShareAltOutlined,{}),r("Outbound")]})})};OutboundButton.displayName="OutboundButton";const OutboundPage=()=>{const n=reactRouterDom.useParams();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.AdminProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RemoteCollectionManagerProvider,{children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.RemoteSchemaComponent,{uid:n.id})})})};var toggleSelection,hasRequiredToggleSelection;function requireToggleSelection(){return hasRequiredToggleSelection||(hasRequiredToggleSelection=1,toggleSelection=function(){var n=document.getSelection();if(!n.rangeCount)return function(){};for(var e=document.activeElement,s=[],i=0;i<n.rangeCount;i++)s.push(n.getRangeAt(i));switch(e.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":e.blur();break;default:e=null;break}return n.removeAllRanges(),function(){n.type==="Caret"&&n.removeAllRanges(),n.rangeCount||s.forEach(function(r){n.addRange(r)}),e&&e.focus()}}),toggleSelection}var copyToClipboard,hasRequiredCopyToClipboard;function requireCopyToClipboard(){if(hasRequiredCopyToClipboard)return copyToClipboard;hasRequiredCopyToClipboard=1;var n=requireToggleSelection(),e={"text/plain":"Text","text/html":"Url",default:"Text"},s="Copy to clipboard: #{key}, Enter";function i(o){var l=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return o.replace(/#{\s*key\s*}/g,l)}function r(o,l){var a,c,d,u,f,p,m=!1;l||(l={}),a=l.debug||!1;try{d=n(),u=document.createRange(),f=document.getSelection(),p=document.createElement("span"),p.textContent=o,p.ariaHidden="true",p.style.all="unset",p.style.position="fixed",p.style.top=0,p.style.clip="rect(0, 0, 0, 0)",p.style.whiteSpace="pre",p.style.webkitUserSelect="text",p.style.MozUserSelect="text",p.style.msUserSelect="text",p.style.userSelect="text",p.addEventListener("copy",function(x){if(x.stopPropagation(),l.format)if(x.preventDefault(),typeof x.clipboardData=="undefined"){a&&console.warn("unable to use e.clipboardData"),a&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var b=e[l.format]||e.default;window.clipboardData.setData(b,o)}else x.clipboardData.clearData(),x.clipboardData.setData(l.format,o);l.onCopy&&(x.preventDefault(),l.onCopy(x.clipboardData))}),document.body.appendChild(p),u.selectNodeContents(p),f.addRange(u);var g=document.execCommand("copy");if(!g)throw new Error("copy command was unsuccessful");m=!0}catch(x){a&&console.error("unable to copy using execCommand: ",x),a&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(l.format||"text",o),l.onCopy&&l.onCopy(window.clipboardData),m=!0}catch(b){a&&console.error("unable to copy using clipboardData: ",b),a&&console.error("falling back to prompt"),c=i("message"in l?l.message:s),window.prompt(c,o)}}finally{f&&(typeof f.removeRange=="function"?f.removeRange(u):f.removeAllRanges()),p&&document.body.removeChild(p),d()}return m}return copyToClipboard=r,copyToClipboard}var copyToClipboardExports=requireCopyToClipboard();const copy=getDefaultExportFromCjs(copyToClipboardExports),useOutboundActionProps=()=>{let n=schema.useFieldSchema();const{t:e}=useTranslation();for(;!("x-decorator-props"in n);)n=n.parent;const s=window.location.href.split("/",3).join("/");return{onClick(){return T(this,null,function*(){copy(`${s}/r/${n["x-uid"]}`)?antd.message.success(e("Save link successful")):antd.message.success(e("Save link failed"))})}}};class PluginOutbound extends client.Plugin{load(){return T(this,null,function*(){this.app.router.add("outbound",{path:"/r/:id",Component:OutboundPage}),this.app.addScopes({useOutboundActionProps}),this.app.addComponents({OutboundButton,OutboundLinkActionInitializer});const e={type:"item",name:"enableActions.outbound",title:lang("outbound"),Component:"OutboundLinkActionInitializer",schema:{"x-align":"right"}};this.app.schemaInitializerManager.addItem("table:configureActions",e.name,e),this.app.schemaInitializerManager.addItem("details:configureActions",e.name,e),this.app.schemaInitializerManager.addItem("kanban:configureActions",e.name,e),this.app.schemaInitializerManager.addItem("pdfViewer:configureActions",e.name,e)})}}const PDFViewerContext=React.createContext(null),usePDFViewerRef=()=>React.useContext(PDFViewerContext),PDFViewerProvider=n=>{const e=React.useRef(null),s=client.useApp(),{decorator:i}=n,r=s.getComponent(i);return r?__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(PDFViewerContext.Provider,{value:e,children:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(r,{children:n.children})}):__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(PDFViewerContext.Provider,{value:e,children:n.children})},usePDFViewerPrintActionProps=()=>{const n=usePDFViewerRef();return{onClick:()=>T(null,null,function*(){n.current.print()})}},PDFViewerPrintActionInitializer=n=>{const e={title:tval("Print"),"x-action":"print","x-component":"Action","x-designer":"Action.Designer","x-component-props":{useProps:"{{ usePDFViewerPrintActionProps }}",icon:"PrinterOutlined"}};return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.ActionInitializer,I(D({},n),{schema:e}))},pdfViewActionInitializer=new client.SchemaInitializer({name:"pdfViewer:configureActions",title:"Configure actions",icon:"SettingOutlined",style:{marginLeft:8},items:[{name:"enableActions",type:"itemGroup",title:tval("Enable actions"),children:[{name:"print",type:"item",title:tval("Print"),component:"PDFViewerPrintActionInitializer"},{name:"edit",title:tval("Edit"),Component:"UpdateActionInitializer",schema:{"x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{type:"primary"}}}]}]}),PDFViewerBlockInitializer=()=>{const{insert:n}=client.useSchemaInitializer(),e=client.useSchemaInitializerItem();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(client.SchemaInitializerItem,I(D({},e),{icon:__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx(icons.PrinterOutlined,{}),onClick:()=>{var s;n({type:"void","x-designer":"Markdown.Void.Designer","x-decorator":"PDFViewerProvider","x-decorator-props":{decorator:(s=e.decorator)!=null?s:""},"x-component":"CardItem",properties:{actions:{type:"void","x-initializer":"pdfViewer:configureActions","x-component":"ActionBar","x-component-props":{},properties:{}},viewer:{type:"void","x-component":"PDFViwer","x-component-props":{target:e.target,usePdfPath:e.usePdfPath}}}})}}))},InternalPDFViewer=n=>{const{usePdfPath:e}=n,s=React.useRef(null),[i,r]=React.useState(0),[,o]=React.useState(0);React.useEffect(()=>{const d=_.debounce(()=>{s.current&&(r(s.current.offsetWidth),o(s.current.offsetHeight))},200),u=new ResizeObserver(()=>{d()});return s.current&&u.observe(s.current),()=>{u.disconnect()}},[s]);const l=usePDFViewerRef(),c=(e!=null?e:()=>"")();return __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs("div",{className:client.css`
|
|
69
69
|
display: flex;
|
|
70
70
|
`,children:[__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx("div",{className:client.css`
|
|
71
71
|
flex: 1;
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@tachybase/client": "1.
|
|
3
|
-
"@tego/client": "1.3.
|
|
4
|
-
"@tego/server": "1.3.
|
|
2
|
+
"@tachybase/client": "1.4.0",
|
|
3
|
+
"@tego/client": "1.3.52",
|
|
4
|
+
"@tego/server": "1.3.52",
|
|
5
5
|
"react": "18.3.1",
|
|
6
|
-
"@tachybase/schema": "1.3.
|
|
6
|
+
"@tachybase/schema": "1.3.52",
|
|
7
7
|
"@ant-design/icons": "5.6.1",
|
|
8
8
|
"antd": "5.22.5",
|
|
9
9
|
"lodash": "4.17.21",
|
|
10
10
|
"dayjs": "1.11.13",
|
|
11
11
|
"ahooks": "3.9.0",
|
|
12
12
|
"react-router-dom": "6.28.1",
|
|
13
|
-
"axios": "1.
|
|
13
|
+
"axios": "1.13.0",
|
|
14
14
|
"react-dom": "18.3.1"
|
|
15
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"fs-extra","version":"11.3.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-
|
|
1
|
+
{"name":"fs-extra","version":"11.3.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-11-10T07:37:54.784Z"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/module-hera",
|
|
3
3
|
"displayName": "Hera platform - Deprecated",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.4.0",
|
|
5
5
|
"description": "Hera platform - Deprecated",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"System management"
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
"main": "dist/server/index.js",
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@ant-design/icons": "^5.6.1",
|
|
12
|
-
"@tachybase/schema": "
|
|
12
|
+
"@tachybase/schema": "*",
|
|
13
13
|
"@tachybase/sheet": "1.0.0-alpha.5",
|
|
14
|
-
"@tachybase/test": "
|
|
15
|
-
"@tego/client": "
|
|
16
|
-
"@tego/server": "
|
|
14
|
+
"@tachybase/test": "*",
|
|
15
|
+
"@tego/client": "*",
|
|
16
|
+
"@tego/server": "*",
|
|
17
17
|
"@types/lodash": "^4.17.20",
|
|
18
18
|
"ahooks": "^3.9.0",
|
|
19
19
|
"antd": "5.22.5",
|
|
20
|
-
"axios": "1.
|
|
20
|
+
"axios": "1.13.0",
|
|
21
21
|
"copy-to-clipboard": "^3.3.3",
|
|
22
22
|
"dayjs": "1.11.13",
|
|
23
23
|
"file-saver": "^2.0.5",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"throttle-debounce": "^5.0.2",
|
|
32
32
|
"vitest": "^3.2.4",
|
|
33
33
|
"ws": "^8.18.3",
|
|
34
|
-
"@tachybase/
|
|
35
|
-
"@tachybase/
|
|
36
|
-
"@tachybase/module-workflow": "1.
|
|
34
|
+
"@tachybase/module-acl": "1.4.0",
|
|
35
|
+
"@tachybase/client": "1.4.0",
|
|
36
|
+
"@tachybase/module-workflow": "1.4.0"
|
|
37
37
|
},
|
|
38
38
|
"description.zh-CN": "赫拉平台(已废弃)",
|
|
39
39
|
"displayName.zh-CN": "赫拉平台",
|