experience-builder/1.12/widgets/sketch-widget/dist/runtime/widget.js

1 line
13 KiB
JavaScript

System.register(["jimu-core","jimu-arcgis","jimu-ui","jimu-ui/basic/color-picker","esri/widgets/Sketch","esri/widgets/Sketch/SketchViewModel","esri/layers/GraphicsLayer","esri/Graphic"],(function(e,t){var r={},n={},c={},o={},a={},s={},i={},l={};return{setters:[function(e){r.React=e.React,r.classNames=e.classNames},function(e){n.JimuMapViewComponent=e.JimuMapViewComponent},function(e){c.Button=e.Button,c.Popper=e.Popper,c.WidgetPlaceholder=e.WidgetPlaceholder},function(e){o.ColorPicker=e.ColorPicker},function(e){a.default=e.default},function(e){s.default=e.default},function(e){i.default=e.default},function(e){l.default=e.default}],execute:function(){e((()=>{var e={82:(e,t,r)=>{"use strict";r.d(t,{Z:()=>s});var n=r(81),c=r.n(n),o=r(645),a=r.n(o)()(c());a.push([e.id,"#sketch-button:hover{background-color:#b4c0c3}#text-button:hover{background-color:var(--calcite-ui-foreground-2);fill:var(--calcite-ui-text-1);color:var(--calcite-ui-text-1)}#text-button.active{fill:var(--calcite-ui-text-1);color:var(--calcite-ui-text-1);background-color:var(--calcite-ui-foreground-3)}\n",""]);const s=a},645:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var r="",n=void 0!==t[5];return t[4]&&(r+="@supports (".concat(t[4],") {")),t[2]&&(r+="@media ".concat(t[2]," {")),n&&(r+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),r+=e(t),n&&(r+="}"),t[2]&&(r+="}"),t[4]&&(r+="}"),r})).join("")},t.i=function(e,r,n,c,o){"string"==typeof e&&(e=[[null,e,void 0]]);var a={};if(n)for(var s=0;s<this.length;s++){var i=this[s][0];null!=i&&(a[i]=!0)}for(var l=0;l<e.length;l++){var u=[].concat(e[l]);n&&a[u[0]]||(void 0!==o&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=o),r&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=r):u[2]=r),c&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=c):u[4]="".concat(c)),t.push(u))}},t}},81:e=>{"use strict";e.exports=function(e){return e[1]}},379:e=>{"use strict";var t=[];function r(e){for(var r=-1,n=0;n<t.length;n++)if(t[n].identifier===e){r=n;break}return r}function n(e,n){for(var o={},a=[],s=0;s<e.length;s++){var i=e[s],l=n.base?i[0]+n.base:i[0],u=o[l]||0,p="".concat(l," ").concat(u);o[l]=u+1;var d=r(p),m={css:i[1],media:i[2],sourceMap:i[3],supports:i[4],layer:i[5]};if(-1!==d)t[d].references++,t[d].updater(m);else{var f=c(m,n);n.byIndex=s,t.splice(s,0,{identifier:p,updater:f,references:1})}a.push(p)}return a}function c(e,t){var r=t.domAPI(t);return r.update(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;r.update(e=t)}else r.remove()}}e.exports=function(e,c){var o=n(e=e||[],c=c||{});return function(e){e=e||[];for(var a=0;a<o.length;a++){var s=r(o[a]);t[s].references--}for(var i=n(e,c),l=0;l<o.length;l++){var u=r(o[l]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}o=i}}},569:e=>{"use strict";var t={};e.exports=function(e,r){var n=function(e){if(void 0===t[e]){var r=document.querySelector(e);if(window.HTMLIFrameElement&&r instanceof window.HTMLIFrameElement)try{r=r.contentDocument.head}catch(e){r=null}t[e]=r}return t[e]}(e);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(r)}},216:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},565:(e,t,r)=>{"use strict";e.exports=function(e){var t=r.nc;t&&e.setAttribute("nonce",t)}},795:e=>{"use strict";e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(r){!function(e,t,r){var n="";r.supports&&(n+="@supports (".concat(r.supports,") {")),r.media&&(n+="@media ".concat(r.media," {"));var c=void 0!==r.layer;c&&(n+="@layer".concat(r.layer.length>0?" ".concat(r.layer):""," {")),n+=r.css,c&&(n+="}"),r.media&&(n+="}"),r.supports&&(n+="}");var o=r.sourceMap;o&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),t.styleTagTransform(n,e,t.options)}(t,e,r)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},589:e=>{"use strict";e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}},339:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16"><path fill="#000" d="m8.745 8 6.1 6.1a.527.527 0 1 1-.745.746L8 8.746l-6.1 6.1a.527.527 0 1 1-.746-.746l6.1-6.1-6.1-6.1a.527.527 0 0 1 .746-.746l6.1 6.1 6.1-6.1a.527.527 0 0 1 .746.746L8.746 8Z"></path></svg>'},659:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16"><path fill="#000" fill-rule="evenodd" d="M11.226 1.312c-.403-.404-1.044-.417-1.431-.03L2.49 8.587l-.48 2.674a.637.637 0 0 0 .73.73l2.673-.48 7.305-7.306c.387-.387.374-1.028-.03-1.431l-1.462-1.462Zm-8.113 9.575.32-1.781 4.991-4.992 1.462 1.462-4.992 4.991-1.781.32Zm7.473-6.012 1.402-1.4-1.462-1.463-1.401 1.402 1.461 1.461Z" clip-rule="evenodd"></path><path fill="#000" d="M1.5 14a.5.5 0 0 0 0 1h13a.5.5 0 0 0 0-1h-13Z"></path></svg>'},160:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16"><path fill="#000" fill-rule="evenodd" d="M8.829 2.535a.909.909 0 0 0-1.657 0L2.291 13.356a.456.456 0 0 0 .831.377L4.818 10h6.364l1.697 3.733a.456.456 0 0 0 .831-.377L8.83 2.536ZM5.272 9 8 3l2.729 6H5.272Z" clip-rule="evenodd"></path></svg>'},844:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M10 4H6c-1.1 0-2 .9-2 2v4c0 1.1.9 2 2 2h4c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM22 12h4c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-4c-1.1 0-2 .9-2 2v4c0 1.1.9 2 2 2zm0-6h4v4h-4V6zM10 20H6c-1.1 0-2 .9-2 2v4c0 1.1.9 2 2 2h4c1.1 0 2-.9 2-2v-4c0-1.1-.9-2-2-2zm0 6H6v-4h4v4zM26 20h-4c-1.1 0-2 .9-2 2v4c0 1.1.9 2 2 2h4c1.1 0 2-.9 2-2v-4c0-1.1-.9-2-2-2z"></path><path d="M28 16h-2c-2.671 0-5.182-1.04-7.071-2.929S16 8.671 16 6V4c0-2.2-1.8-4-4-4H4C1.8 0 0 1.8 0 4v8c0 2.2 1.8 4 4 4h2c2.671 0 5.182 1.04 7.071 2.929S16 23.329 16 26v2c0 2.2 1.8 4 4 4h8c2.2 0 4-1.8 4-4v-8c0-2.2-1.8-4-4-4zm2 12c0 .53-.209 1.031-.589 1.411S28.53 30 28 30h-8c-.53 0-1.031-.209-1.411-.589S18 28.53 18 28v-2c0-6.627-5.373-12-12-12H4c-.53 0-1.031-.209-1.411-.589S2 12.53 2 12V4c0-.53.209-1.031.589-1.411S3.47 2 4 2h8c.53 0 1.031.209 1.411.589S14 3.47 14 4v2c0 6.627 5.373 12 12 12h2c.53 0 1.031.209 1.411.589S30 19.47 30 20v8z"></path></svg>'},129:e=>{"use strict";e.exports=l},231:e=>{"use strict";e.exports=i},560:e=>{"use strict";e.exports=a},878:e=>{"use strict";e.exports=s},826:e=>{"use strict";e.exports=n},891:e=>{"use strict";e.exports=r},726:e=>{"use strict";e.exports=c},362:e=>{"use strict";e.exports=o}},t={};function u(r){var n=t[r];if(void 0!==n)return n.exports;var c=t[r]={id:r,exports:{}};return e[r](c,c.exports,u),c.exports}u.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return u.d(t,{a:t}),t},u.d=(e,t)=>{for(var r in t)u.o(t,r)&&!u.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),u.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.p="",u.nc=void 0;var p={};return u.p=window.jimuConfig.baseUrl,(()=>{"use strict";u.r(p),u.d(p,{__set_webpack_public_path__:()=>_,default:()=>A});var e=u(891),t=u(826),r=u(726),n=u(339),c=u.n(n);const o=t=>{const r=window.SVG,{className:n}=t,o=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var c=0;for(n=Object.getOwnPropertySymbols(e);c<n.length;c++)t.indexOf(n[c])<0&&Object.prototype.propertyIsEnumerable.call(e,n[c])&&(r[n[c]]=e[n[c]])}return r}(t,["className"]),a=(0,e.classNames)("jimu-icon jimu-icon-component",n);return r?e.React.createElement(r,Object.assign({className:a,src:c()},o)):e.React.createElement("svg",Object.assign({className:a},o))};var a=u(659),s=u.n(a);const i=t=>{const r=window.SVG,{className:n}=t,c=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var c=0;for(n=Object.getOwnPropertySymbols(e);c<n.length;c++)t.indexOf(n[c])<0&&Object.prototype.propertyIsEnumerable.call(e,n[c])&&(r[n[c]]=e[n[c]])}return r}(t,["className"]),o=(0,e.classNames)("jimu-icon jimu-icon-component",n);return r?e.React.createElement(r,Object.assign({className:o,src:s()},c)):e.React.createElement("svg",Object.assign({className:o},c))};var l=u(160),d=u.n(l);const m=t=>{const r=window.SVG,{className:n}=t,c=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var c=0;for(n=Object.getOwnPropertySymbols(e);c<n.length;c++)t.indexOf(n[c])<0&&Object.prototype.propertyIsEnumerable.call(e,n[c])&&(r[n[c]]=e[n[c]])}return r}(t,["className"]),o=(0,e.classNames)("jimu-icon jimu-icon-component",n);return r?e.React.createElement(r,Object.assign({className:o,src:d()},c)):e.React.createElement("svg",Object.assign({className:o},c))};var f=u(362),v=u(560),h=u(878),g=u(231),y=u(129),b=u(844),w=u.n(b);var x=u(379),S=u.n(x),O=u(795),E=u.n(O),M=u(569),j=u.n(M),N=u(565),P=u.n(N),R=u(216),k=u.n(R),C=u(589),L=u.n(C),I=u(82),T={};T.styleTagTransform=L(),T.setAttributes=P(),T.insert=j().bind(null,"head"),T.domAPI=E(),T.insertStyleElement=k(),S()(I.Z,T),I.Z&&I.Z.locals&&I.Z.locals;const{useEffect:Z,useState:z,useRef:V}=e.React,A=n=>{var c;const a="#A92A4E",s=V(null),l=V(null),u=V(null),[p,d]=z(!1),[b,x]=z(a),[S,O]=z(null),E=V(null),M=V(null),j=V(null),N=V(null);N.current=b,Z((()=>{if(E.current&&E.current.destroy(),!E.current&&S){const e=S.view,t=document.createElement("div");if(s.current.append(t),e){const r=new g.default({title:n.intl.formatMessage({id:"sketchLayerName",defaultMessage:"Zeichnungen"})});e.map.add(r),l.current=r;const c=new v.default({layer:r,view:e,creationMode:"continuous",container:t,layout:"vertical",visibleElements:{createTools:{rectangle:!1,circle:!1},selectionTools:{"lasso-selection":!1},settingsMenu:!1}});E.current=c,P(a);const o=new h.default({layer:r,view:e,pointSymbol:{type:"text",text:"",font:{family:"Ubuntu",style:"normal",weight:"normal",size:"18px"}}});o.on("create",(e=>{var t;let r;if("complete"===e.state){const c=null===(t=S.view)||void 0===t?void 0:t.toScreen(e.graphic.geometry),a=document.querySelector(".esri-view-root");if(a){r=document.createElement("div"),r.id="popup-container",r.style.position="absolute",r.style.left=c.x-2+"px",r.style.top=c.y-24+"px";const t=document.createElement("input");t.type="text",t.placeholder=n.intl.formatMessage({id:"placeholderText",defaultMessage:"Geben Sie hier Ihren Text ein"}),t.size=30,t.style.border="none",t.style.backgroundColor="transparent",t.style.fontSize="18px",t.style.fontFamily="Arial",t.style.color=N.current,t.addEventListener("change",(t=>{l.current.remove(e.graphic),l.current.add(new y.default({geometry:e.graphic.geometry,symbol:{type:"text",color:N.current,text:t.target.value,horizontalAlignment:"left",font:{family:"Arial",style:"normal",weight:"normal",size:"18px"}}})),r.remove(),j.current.classList.remove("active")})),t.addEventListener("blur",(()=>{l.current.remove(e.graphic),r.remove(),o.cancel(),j.current.classList.remove("active")})),t.addEventListener("keyup",(t=>{"Escape"===t.code&&(l.current.remove(e.graphic),r.remove(),o.cancel(),j.current.classList.remove("active"))})),r.append(t),a.append(r),t.focus(),t.select()}}"cancel"===e.state&&j.current.classList.remove("active")})),M.current=o}}}),[S]);const P=e=>{if(E.current){const t=E.current.viewModel;t&&(t.pointSymbol.color=e,t.polylineSymbol.color=e,t.polygonSymbol.color=e)}x(e)};return e.React.createElement("div",{className:"widget-sketch-widget h-100"},n.useMapWidgetIds&&0===n.useMapWidgetIds.length&&e.React.createElement(r.WidgetPlaceholder,{icon:w(),widgetId:n.id,message:"Please select a map widget."}),e.React.createElement(t.JimuMapViewComponent,{useMapWidgetId:null===(c=n.useMapWidgetIds)||void 0===c?void 0:c[0],onActiveViewChange:e=>{O(e)}}),e.React.createElement(r.Button,{ref:u,onClick:()=>{p&&(E.current.cancel(),M.current.cancel()),d((e=>!e))},title:n.intl.formatMessage({id:"sketchLabel",defaultMessage:"Zeichnen"}),className:"border-0 rounded-0 w-100 h-100",id:"sketch-button"},p?e.React.createElement(o,{className:"mr-0"}):e.React.createElement(i,{className:"mr-0"})),e.React.createElement(r.Popper,{floating:!1,open:p,reference:u.current,keepMount:!0,showArrow:!1,placement:"right",offset:[0,15]},e.React.createElement("div",{style:{width:"46px"}},e.React.createElement("div",{className:"bg-white w-auto h-auto",ref:s}),e.React.createElement(f.ColorPicker,{onChange:e=>{x(e),P(e)},color:b,type:"default",className:"bg-white shadow-none",width:46}),e.React.createElement("div",{className:"p-2"},e.React.createElement(r.Button,{id:"text-button",onClick:()=>{M.current.create("point"),j.current.classList.add("active")},className:"d-flex justify-content-center border-0 w-100",ref:j},e.React.createElement(m,{className:"mr-0"}))))))};function _(e){u.p=e}})(),p})())}}}));