@streamline-pulse/formkrafter-wc 0.34.0 → 0.36.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/README.md +14 -6
- package/dist/components/fk-address-search.js +1 -1
- package/dist/components/fk-brick-actions.js +1 -1
- package/dist/components/fk-brick-list.js +1 -1
- package/dist/components/fk-brick-mold-item.js +1 -1
- package/dist/components/fk-brick-render.js +1 -1
- package/dist/components/fk-data-grid.js +1 -1
- package/dist/components/fk-document-reader.js +1 -1
- package/dist/components/fk-drop-area.js +1 -1
- package/dist/components/fk-empty-form.js +1 -1
- package/dist/components/fk-file-input.js +1 -1
- package/dist/components/fk-form-builder.js +1 -1
- package/dist/components/fk-form-render.js +1 -1
- package/dist/components/fk-form-review.js +1 -1
- package/dist/components/fk-geo-map.js +1 -1
- package/dist/components/fk-key-value.js +1 -1
- package/dist/components/fk-property-panel.js +1 -1
- package/dist/components/fk-rules-editor.js +1 -1
- package/dist/components/fk-select-input.js +1 -1
- package/dist/components/fk-signature-input.js +1 -1
- package/dist/components/fk-slot-picker.js +1 -1
- package/dist/components/fk-stepper.js +1 -1
- package/dist/components/fk-tabs.js +1 -1
- package/dist/components/fk-variable-picker.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/{p-UXcOku2W.js → p-8HkjC_aE.js} +1 -1
- package/dist/components/{p-CdJ4KK1K.js → p-B-INxJBg.js} +1 -1
- package/dist/components/{p-DofmGNF8.js → p-BPQcQaPo.js} +1 -1
- package/dist/components/{p-Di8uembx.js → p-BY-HsBmr.js} +1 -1
- package/dist/components/p-BrVPi4s9.js +1 -0
- package/dist/components/{p-CqMsKC5q.js → p-Bza6nE37.js} +1 -1
- package/dist/components/{p-eAt6z8Zp.js → p-C6_gsHBy.js} +1 -1
- package/dist/components/{p-oqpWTt5a.js → p-CNu8nwtf.js} +1 -1
- package/dist/components/{p-DanS3BOE.js → p-CimJudBw.js} +1 -1
- package/dist/components/{p-5_voBBxg.js → p-ClRRfTDD.js} +1 -1
- package/dist/components/{p-8rlTOusP.js → p-CmPkfuLt.js} +1 -1
- package/dist/components/{p-Ue6N2laC.js → p-CtbPH5C7.js} +1 -1
- package/dist/components/{p-MWuEApWx.js → p-Cy93hSiU.js} +1 -1
- package/dist/components/{p-BHbLdGbh.js → p-CzRN0mMY.js} +1 -1
- package/dist/components/{p-V_F2_w97.js → p-D5nPxZXV.js} +1 -1
- package/dist/components/{p-D2ju8zdo.js → p-DC68wbT4.js} +1 -1
- package/dist/components/{p-SUfms7QY.js → p-DJRGXz7s.js} +1 -1
- package/dist/components/{p-BS4i6Ka9.js → p-DWSCT2ur.js} +1 -1
- package/dist/components/{p-B1mZobGL.js → p-Da741snY.js} +1 -1
- package/dist/components/{p-bmymYwS6.js → p-JQ8Ve1UU.js} +5 -5
- package/dist/components/{p-DrbqT8Fe.js → p-gKtzV7rX.js} +1 -1
- package/dist/components/{p-CfABzqjF.js → p-jEx6mM9z.js} +1 -1
- package/dist/formkrafter-wc/formkrafter-wc.css +1 -1
- package/dist/formkrafter-wc/formkrafter-wc.esm.js +1 -1
- package/dist/formkrafter-wc/index.esm.js +1 -1
- package/dist/formkrafter-wc/{p-b55b9283.entry.js → p-2d9fd8a7.entry.js} +1 -1
- package/dist/formkrafter-wc/{p-b7f609bf.entry.js → p-86373a08.entry.js} +1 -1
- package/dist/formkrafter-wc/{p-IpNzfjkq.js → p-CndT4oMV.js} +5 -5
- package/dist/formkrafter-wc/{p-B2Ar1jqa.js → p-CqcWR060.js} +1 -1
- package/dist/formkrafter-wc/{p-549c07f4.entry.js → p-a51534db.entry.js} +1 -1
- package/dist/types/components/fk-select-input/fk-select-input.d.ts +4 -0
- package/dist/types/components.d.ts +9 -0
- package/package.json +3 -3
- package/dist/components/p-BdHC-MIW.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e,p as t,H as o,c as l,h as a}from"./p-8ICOcloT.js";import{b as i}from"./p-bmymYwS6.js";const r=new Map,n=e=>Math.round(1e6*e)/1e6,s=e=>[n(e.lng),n(e.lat)],f=t(class extends o{constructor(e){super(),!1!==e&&this.__registerHost(),this.geoChange=l(this,"geoChange"),this.layerChange=l(this,"layerChange"),this.mode="point",this.zoom=6,this.tileUrl="https://tile.openstreetmap.org/{z}/{x}/{y}.png",this.attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',this.height=320,this.disabled=!1,this.readOnly=!1,this.manual=!0,this.layerCodeProperty="code",this.layerNameProperty="name",this.selected=[],this.multiple=!1,this.failed=!1,this.vertexCount=0,this.zones=[],this.layerFailed=!1,this.shapes=[],this.vertices=[],this.lastEmitted="",this.clear=()=>{this.locked||this.setVertices([])}}get locked(){return this.disabled||this.readOnly}async componentDidLoad(){var e;"layer"===this.mode&&this.fetchLayer();try{const t=await import("./p-CqMsKC5q.js").then((function(e){return e.l}));this.L=null!==(e=t.default)&&void 0!==e?e:t}catch(e){return void(this.failed=!0)}this.container&&this.initMap()}disconnectedCallback(){var e,t;null===(e=this.observer)||void 0===e||e.disconnect(),null===(t=this.map)||void 0===t||t.remove(),this.map=void 0}onValueChange(e){JSON.stringify(null!=e?e:null)!==this.lastEmitted&&this.draw(e)}onLockChange(){this.draw(this.value),this.restyleLayer()}onSelectedChange(){this.restyleLayer()}onLayerUrlChange(){this.fetchLayer()}initMap(){var e;const t=this.L,o=this.container,l=t.map(o,{attributionControl:!0,zoomControl:!this.locked});t.tileLayer(this.tileUrl,{attribution:this.attribution,maxZoom:19}).addTo(l),l.setView(null!==(e=this.center)&&void 0!==e?e:[0,0],this.center?this.zoom:2),this.locked&&(l.dragging.disable(),l.scrollWheelZoom.disable()),l.on("click",(e=>{this.locked||"layer"===this.mode||this.setVertices("point"===this.mode?[e.latlng]:[...this.vertices,e.latlng])})),this.map=l,this.draw(this.value),this.drawLayer(),"undefined"!=typeof ResizeObserver&&(this.observer=new ResizeObserver((()=>l.invalidateSize())),this.observer.observe(o)),setTimeout((()=>l.invalidateSize()),50)}draw(e){var t;const o=this.L,l=this.map;if(!o||!l)return void(this.vertexCount=this.countVertices(e));const a=[];if("Point"===(null==e?void 0:e.type)&&a.push(o.latLng(e.coordinates[1],e.coordinates[0])),"LineString"===(null==e?void 0:e.type))for(const[t,l]of e.coordinates)a.push(o.latLng(l,t));if("Polygon"===(null==e?void 0:e.type)){const l=null!==(t=e.coordinates[0])&&void 0!==t?t:[],i=l.length>1&&l[0][0]===l[l.length-1][0]&&l[0][1]===l[l.length-1][1]?l.slice(0,-1):l;for(const[e,t]of i)a.push(o.latLng(t,e))}this.vertices=a,this.vertexCount=a.length,this.render_shapes(),1===a.length?l.setView(a[0],Math.max(l.getZoom(),this.zoom)):a.length>1&&l.fitBounds(o.latLngBounds(a),{padding:[24,24]})}countVertices(e){var t,o;return e?"Point"===e.type?1:"LineString"===e.type?e.coordinates.length:Math.max((null!==(o=null===(t=e.coordinates[0])||void 0===t?void 0:t.length)&&void 0!==o?o:1)-1,0):0}render_shapes(){const e=this.L,t=this.map;if(!e||!t)return;for(const e of this.shapes)e.remove();this.shapes=[];const o=this.vertices;"polygon"===this.mode&&o.length>=3&&this.shapes.push(e.polygon(o,{className:"fk-geo__shape"}).addTo(t)),"line"===this.mode&&o.length>=2&&this.shapes.push(e.polyline(o,{className:"fk-geo__shape"}).addTo(t)),o.forEach(((o,l)=>{const a=e.marker(o,{draggable:!this.locked,icon:e.divIcon({className:"fk-geo__marker",iconSize:[14,14],iconAnchor:[7,7]})}).addTo(t);a.on("dragend",(()=>{const e=[...this.vertices];e[l]=a.getLatLng(),this.setVertices(e)})),"point"!==this.mode&&a.on("contextmenu",(()=>{this.locked||this.setVertices(this.vertices.filter(((e,t)=>t!==l)))})),this.shapes.push(a)}))}setVertices(e){this.vertices=e,this.vertexCount=e.length,this.render_shapes(),this.emit()}geometry(){const e=this.vertices;if("point"===this.mode)return e[0]?{type:"Point",coordinates:s(e[0])}:void 0;if("line"===this.mode)return e.length>=2?{type:"LineString",coordinates:e.map(s)}:void 0;if(e.length<3)return;const t=e.map(s);return{type:"Polygon",coordinates:[[...t,t[0]]]}}emit(){const e=this.geometry();this.lastEmitted=JSON.stringify(null!=e?e:null),this.geoChange.emit(e)}setManual(e,t){var o,l,a;if(this.locked)return;if(""===t.trim())return this.vertices=[],this.vertexCount=0,this.render_shapes(),void this.emit();const i="Point"===(null===(o=this.value)||void 0===o?void 0:o.type)?this.value.coordinates:void 0,r="lat"===e?Number(t):null!==(l=null==i?void 0:i[1])&&void 0!==l?l:NaN,n="lng"===e?Number(t):null!==(a=null==i?void 0:i[0])&&void 0!==a?a:NaN;if(Number.isNaN(r)||Number.isNaN(n))return;const s=this.L?this.L.latLng(r,n):{lat:r,lng:n};this.vertices=[s],this.vertexCount=1,this.render_shapes(),this.map&&this.map.setView(s,Math.max(this.map.getZoom(),this.zoom)),this.emit()}componentDidRender(){var e;this.selectEl&&"layer"===this.mode&&(this.selectEl.value=null!==(e=this.selected[0])&&void 0!==e?e:"")}zoneOf(e){var t;const o=null!==(t=e.properties)&&void 0!==t?t:{},l=o[this.layerCodeProperty],a=o[this.layerNameProperty];return null==l||""===l?null:{code:String(l),name:String(null==a?l:a)}}async fetchLayer(){var e;if(this.layerFailed=!1,!this.layerUrl)return this.layerData=void 0,this.zones=[],void this.drawLayer();try{const t=await(e=>{let t=r.get(e);return t||(t=fetch(e,{headers:{Accept:"application/geo+json, application/json"}}).then((async e=>{if(!e.ok)throw new Error(String(e.status));return await e.json()})),t.catch((()=>r.delete(e))),r.set(e,t)),t})(this.layerUrl);this.layerData=t,this.zones=(null!==(e=t.features)&&void 0!==e?e:[]).map((e=>this.zoneOf(e))).filter((e=>null!==e)).sort(((e,t)=>e.name.localeCompare(t.name))),this.drawLayer()}catch(e){this.layerFailed=!0}}layerStyle(e){const t=null!==e&&this.selected.includes(e);return{className:t?"fk-geo__zone fk-geo__zone--selected":"fk-geo__zone",weight:t?2:1,fillOpacity:t?.45:.1}}drawLayer(){var e;const t=this.L,o=this.map;if(!t||!o||"layer"!==this.mode)return;if(null===(e=this.layer)||void 0===e||e.remove(),this.layer=void 0,!this.layerData)return;const l=t.geoJSON(this.layerData,{style:e=>{var t,o;return this.layerStyle(e&&null!==(o=null===(t=this.zoneOf(e))||void 0===t?void 0:t.code)&&void 0!==o?o:null)},onEachFeature:(e,t)=>{const o=this.zoneOf(e);o&&(t.bindTooltip(o.name,{sticky:!0}),t.on("click",(()=>{this.locked||this.toggleZone(o)})))}}).addTo(o);this.layer=l;const a=l.getBounds();(a.isValid()&&!this.selected.length||a.isValid()&&this.selected.length)&&o.fitBounds(a,{padding:[16,16]})}restyleLayer(){const e=this.layer;e&&e.setStyle((e=>{var t,o;return this.layerStyle(e&&null!==(o=null===(t=this.zoneOf(e))||void 0===t?void 0:t.code)&&void 0!==o?o:null)}))}toggleZone(e){const t=this.selected.includes(e.code),o=this.multiple?t?this.selected.filter((t=>t!==e.code)):[...this.selected,e.code]:t?[]:[e.code];this.emitZones(o)}emitZones(e){const t=new Map(this.zones.map((e=>[e.code,e])));this.layerChange.emit(e.map((e=>{var o;return null!==(o=t.get(e))&&void 0!==o?o:{code:e,name:e}})))}renderLayerBar(){const e=this.selected.map((e=>{var t;return null!==(t=this.zones.find((t=>t.code===e)))&&void 0!==t?t:{code:e,name:e}}));return a("div",{class:"fk-geo__bar"},this.layerFailed?a("span",{class:"fk-geo__summary"},i("layer.unavailable")):this.multiple?a("span",{class:"fk-geo__chips"},0===e.length?a("span",{class:"fk-geo__summary"},i("layer.pickMany")):e.map((e=>a("span",{class:"fk-geo__chip"},e.name,this.locked?null:a("button",{type:"button",class:"fk-geo__chip-remove","aria-label":i("geo.clear"),onClick:()=>this.toggleZone(e)},"×"))))):a("select",{class:"fk-field__input fk-geo__select",ref:e=>{this.selectEl=e},disabled:this.locked,onChange:e=>{const t=e.target.value;this.emitZones(t?[t]:[])}},a("option",{value:"",selected:!this.selected.length},i("layer.pick")),this.zones.map((e=>a("option",{value:e.code,selected:this.selected[0]===e.code},e.name)))),this.locked||this.layerFailed?null:a("span",{class:"fk-geo__hint"},i("layer.hint")))}render(){var e;const t="Point"===(null===(e=this.value)||void 0===e?void 0:e.type)?this.value.coordinates:void 0,o=i("point"===this.mode?"geo.hintPoint":"geo.hintArea");return a("div",{key:"3adf67d52e87de730d1f33c1f4aa5d56d93c9201",class:{"fk-geo":!0,"fk-geo--locked":this.locked}},a("div",{key:"f78144732a57ea5f25d1d15b1608823b2cab50e7",class:"fk-geo__map",style:{height:`${this.height}px`},ref:e=>{this.container=e}},this.failed?a("div",{class:"fk-geo__unavailable"},i("geo.unavailable")):null),"layer"===this.mode?this.renderLayerBar():a("div",{class:"fk-geo__bar"},"point"===this.mode&&this.manual?a("div",{class:"fk-geo__manual"},a("label",{class:"fk-geo__coord"},a("span",null,i("geo.latitude")),a("input",{class:"fk-field__input",type:"number",step:"any",min:"-90",max:"90",value:t?String(t[1]):"",disabled:this.disabled,readOnly:this.readOnly,onChange:e=>this.setManual("lat",e.target.value)})),a("label",{class:"fk-geo__coord"},a("span",null,i("geo.longitude")),a("input",{class:"fk-field__input",type:"number",step:"any",min:"-180",max:"180",value:t?String(t[0]):"",disabled:this.disabled,readOnly:this.readOnly,onChange:e=>this.setManual("lng",e.target.value)}))):a("span",{class:"fk-geo__summary"},this.vertexCount," ",i("geo.points")),this.locked?null:a("span",{class:"fk-geo__actions"},a("span",{class:"fk-geo__hint"},o),this.vertexCount>0?a("button",{type:"button",class:"fk-geo__clear",onClick:this.clear},i("geo.clear")):null)))}get el(){return this}static get watchers(){return{value:[{onValueChange:0}],disabled:[{onLockChange:0}],readOnly:[{onLockChange:0}],selected:[{onSelectedChange:0}],layerUrl:[{onLayerUrlChange:0}]}}static get style(){return'.leaflet-pane,.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-tile-container,.leaflet-pane>svg,.leaflet-pane>canvas,.leaflet-zoom-box,.leaflet-image-layer,.leaflet-layer{position:absolute;left:0;top:0}.leaflet-container{overflow:hidden}.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow{-webkit-user-select:none;-moz-user-select:none;user-select:none;-webkit-user-drag:none}.leaflet-tile::selection{background:transparent}.leaflet-safari .leaflet-tile{image-rendering:-webkit-optimize-contrast}.leaflet-safari .leaflet-tile-container{width:1600px;height:1600px;-webkit-transform-origin:0 0}.leaflet-marker-icon,.leaflet-marker-shadow{display:block}.leaflet-container .leaflet-overlay-pane svg{max-width:none !important;max-height:none !important}.leaflet-container .leaflet-marker-pane img,.leaflet-container .leaflet-shadow-pane img,.leaflet-container .leaflet-tile-pane img,.leaflet-container img.leaflet-image-layer,.leaflet-container .leaflet-tile{max-width:none !important;max-height:none !important;width:auto;padding:0}.leaflet-container img.leaflet-tile{mix-blend-mode:plus-lighter}.leaflet-container.leaflet-touch-zoom{-ms-touch-action:pan-x pan-y;touch-action:pan-x pan-y}.leaflet-container.leaflet-touch-drag{-ms-touch-action:pinch-zoom;touch-action:none;touch-action:pinch-zoom}.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom{-ms-touch-action:none;touch-action:none}.leaflet-container{-webkit-tap-highlight-color:transparent}.leaflet-container a{-webkit-tap-highlight-color:rgba(51, 181, 229, 0.4)}.leaflet-tile{filter:inherit;visibility:hidden}.leaflet-tile-loaded{visibility:inherit}.leaflet-zoom-box{width:0;height:0;-moz-box-sizing:border-box;box-sizing:border-box;z-index:800}.leaflet-overlay-pane svg{-moz-user-select:none}.leaflet-pane{z-index:400}.leaflet-tile-pane{z-index:200}.leaflet-overlay-pane{z-index:400}.leaflet-shadow-pane{z-index:500}.leaflet-marker-pane{z-index:600}.leaflet-tooltip-pane{z-index:650}.leaflet-popup-pane{z-index:700}.leaflet-map-pane canvas{z-index:100}.leaflet-map-pane svg{z-index:200}.leaflet-vml-shape{width:1px;height:1px}.lvml{display:inline-block;position:absolute}.leaflet-control{position:relative;z-index:800;pointer-events:visiblePainted;pointer-events:auto}.leaflet-top,.leaflet-bottom{position:absolute;z-index:1000;pointer-events:none}.leaflet-top{top:0}.leaflet-right{right:0}.leaflet-bottom{bottom:0}.leaflet-left{left:0}.leaflet-control{float:left;clear:both}.leaflet-right .leaflet-control{float:right}.leaflet-top .leaflet-control{margin-top:10px}.leaflet-bottom .leaflet-control{margin-bottom:10px}.leaflet-left .leaflet-control{margin-left:10px}.leaflet-right .leaflet-control{margin-right:10px}.leaflet-fade-anim .leaflet-popup{opacity:0;-webkit-transition:opacity 0.2s linear;-moz-transition:opacity 0.2s linear;transition:opacity 0.2s linear}.leaflet-fade-anim .leaflet-map-pane .leaflet-popup{opacity:1}.leaflet-zoom-animated{-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0}svg.leaflet-zoom-animated{will-change:transform}.leaflet-zoom-anim .leaflet-zoom-animated{-webkit-transition:-webkit-transform 0.25s cubic-bezier(0,0,0.25,1);-moz-transition:-moz-transform 0.25s cubic-bezier(0,0,0.25,1);transition:transform 0.25s cubic-bezier(0,0,0.25,1)}.leaflet-zoom-anim .leaflet-tile,.leaflet-pan-anim .leaflet-tile{-webkit-transition:none;-moz-transition:none;transition:none}.leaflet-zoom-anim .leaflet-zoom-hide{visibility:hidden}.leaflet-interactive{cursor:pointer}.leaflet-grab{cursor:-webkit-grab;cursor:-moz-grab;cursor:grab}.leaflet-crosshair,.leaflet-crosshair .leaflet-interactive{cursor:crosshair}.leaflet-popup-pane,.leaflet-control{cursor:auto}.leaflet-dragging .leaflet-grab,.leaflet-dragging .leaflet-grab .leaflet-interactive,.leaflet-dragging .leaflet-marker-draggable{cursor:move;cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing}.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-image-layer,.leaflet-pane>svg path,.leaflet-tile-container{pointer-events:none}.leaflet-marker-icon.leaflet-interactive,.leaflet-image-layer.leaflet-interactive,.leaflet-pane>svg path.leaflet-interactive,svg.leaflet-image-layer.leaflet-interactive path{pointer-events:visiblePainted;pointer-events:auto}.leaflet-container{background:#ddd;outline-offset:1px}.leaflet-container a{color:#0078A8}.leaflet-zoom-box{border:2px dotted #38f;background:rgba(255,255,255,0.5)}.leaflet-container{font-family:"Helvetica Neue", Arial, Helvetica, sans-serif;font-size:12px;font-size:0.75rem;line-height:1.5}.leaflet-bar{box-shadow:0 1px 5px rgba(0,0,0,0.65);border-radius:4px}.leaflet-bar a{background-color:#fff;border-bottom:1px solid #ccc;width:26px;height:26px;line-height:26px;display:block;text-align:center;text-decoration:none;color:black}.leaflet-bar a,.leaflet-control-layers-toggle{background-position:50% 50%;background-repeat:no-repeat;display:block}.leaflet-bar a:hover,.leaflet-bar a:focus{background-color:#f4f4f4}.leaflet-bar a:first-child{border-top-left-radius:4px;border-top-right-radius:4px}.leaflet-bar a:last-child{border-bottom-left-radius:4px;border-bottom-right-radius:4px;border-bottom:none}.leaflet-bar a.leaflet-disabled{cursor:default;background-color:#f4f4f4;color:#bbb}.leaflet-touch .leaflet-bar a{width:30px;height:30px;line-height:30px}.leaflet-touch .leaflet-bar a:first-child{border-top-left-radius:2px;border-top-right-radius:2px}.leaflet-touch .leaflet-bar a:last-child{border-bottom-left-radius:2px;border-bottom-right-radius:2px}.leaflet-control-zoom-in,.leaflet-control-zoom-out{font:bold 18px \'Lucida Console\', Monaco, monospace;text-indent:1px}.leaflet-touch .leaflet-control-zoom-in,.leaflet-touch .leaflet-control-zoom-out{font-size:22px}.leaflet-control-layers{box-shadow:0 1px 5px rgba(0,0,0,0.4);background:#fff;border-radius:5px}.leaflet-control-layers-toggle{width:36px;height:36px}.leaflet-retina .leaflet-control-layers-toggle{background-size:26px 26px}.leaflet-touch .leaflet-control-layers-toggle{width:44px;height:44px}.leaflet-control-layers .leaflet-control-layers-list,.leaflet-control-layers-expanded .leaflet-control-layers-toggle{display:none}.leaflet-control-layers-expanded .leaflet-control-layers-list{display:block;position:relative}.leaflet-control-layers-expanded{padding:6px 10px 6px 6px;color:#333;background:#fff}.leaflet-control-layers-scrollbar{overflow-y:scroll;overflow-x:hidden;padding-right:5px}.leaflet-control-layers-selector{margin-top:2px;position:relative;top:1px}.leaflet-control-layers label{display:block;font-size:13px;font-size:1.08333em}.leaflet-control-layers-separator{height:0;border-top:1px solid #ddd;margin:5px -10px 5px -6px}.leaflet-default-icon-path{}.leaflet-container .leaflet-control-attribution{background:#fff;background:rgba(255, 255, 255, 0.8);margin:0}.leaflet-control-attribution,.leaflet-control-scale-line{padding:0 5px;color:#333;line-height:1.4}.leaflet-control-attribution a{text-decoration:none}.leaflet-control-attribution a:hover,.leaflet-control-attribution a:focus{text-decoration:underline}.leaflet-attribution-flag{display:inline !important;vertical-align:baseline !important;width:1em;height:0.6669em}.leaflet-left .leaflet-control-scale{margin-left:5px}.leaflet-bottom .leaflet-control-scale{margin-bottom:5px}.leaflet-control-scale-line{border:2px solid #777;border-top:none;line-height:1.1;padding:2px 5px 1px;white-space:nowrap;-moz-box-sizing:border-box;box-sizing:border-box;background:rgba(255, 255, 255, 0.8);text-shadow:1px 1px #fff}.leaflet-control-scale-line:not(:first-child){border-top:2px solid #777;border-bottom:none;margin-top:-2px}.leaflet-control-scale-line:not(:first-child):not(:last-child){border-bottom:2px solid #777}.leaflet-touch .leaflet-control-attribution,.leaflet-touch .leaflet-control-layers,.leaflet-touch .leaflet-bar{box-shadow:none}.leaflet-touch .leaflet-control-layers,.leaflet-touch .leaflet-bar{border:2px solid rgba(0,0,0,0.2);background-clip:padding-box}.leaflet-popup{position:absolute;text-align:center;margin-bottom:20px}.leaflet-popup-content-wrapper{padding:1px;text-align:left;border-radius:12px}.leaflet-popup-content{margin:13px 24px 13px 20px;line-height:1.3;font-size:13px;font-size:1.08333em;min-height:1px}.leaflet-popup-content p{margin:17px 0;margin:1.3em 0}.leaflet-popup-tip-container{width:40px;height:20px;position:absolute;left:50%;margin-top:-1px;margin-left:-20px;overflow:hidden;pointer-events:none}.leaflet-popup-tip{width:17px;height:17px;padding:1px;margin:-10px auto 0;pointer-events:auto;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg)}.leaflet-popup-content-wrapper,.leaflet-popup-tip{background:white;color:#333;box-shadow:0 3px 14px rgba(0,0,0,0.4)}.leaflet-container a.leaflet-popup-close-button{position:absolute;top:0;right:0;border:none;text-align:center;width:24px;height:24px;font:16px/24px Tahoma, Verdana, sans-serif;color:#757575;text-decoration:none;background:transparent}.leaflet-container a.leaflet-popup-close-button:hover,.leaflet-container a.leaflet-popup-close-button:focus{color:#585858}.leaflet-popup-scrolled{overflow:auto}.leaflet-oldie .leaflet-popup-content-wrapper{-ms-zoom:1}.leaflet-oldie .leaflet-popup-tip{width:24px;margin:0 auto;-ms-filter:"progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";filter:progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)}.leaflet-oldie .leaflet-control-zoom,.leaflet-oldie .leaflet-control-layers,.leaflet-oldie .leaflet-popup-content-wrapper,.leaflet-oldie .leaflet-popup-tip{border:1px solid #999}.leaflet-div-icon{background:#fff;border:1px solid #666}.leaflet-tooltip{position:absolute;padding:6px;background-color:#fff;border:1px solid #fff;border-radius:3px;color:#222;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;pointer-events:none;box-shadow:0 1px 3px rgba(0,0,0,0.4)}.leaflet-tooltip.leaflet-interactive{cursor:pointer;pointer-events:auto}.leaflet-tooltip-top:before,.leaflet-tooltip-bottom:before,.leaflet-tooltip-left:before,.leaflet-tooltip-right:before{position:absolute;pointer-events:none;border:6px solid transparent;background:transparent;content:""}.leaflet-tooltip-bottom{margin-top:6px}.leaflet-tooltip-top{margin-top:-6px}.leaflet-tooltip-bottom:before,.leaflet-tooltip-top:before{left:50%;margin-left:-6px}.leaflet-tooltip-top:before{bottom:0;margin-bottom:-12px;border-top-color:#fff}.leaflet-tooltip-bottom:before{top:0;margin-top:-12px;margin-left:-6px;border-bottom-color:#fff}.leaflet-tooltip-left{margin-left:-6px}.leaflet-tooltip-right{margin-left:6px}.leaflet-tooltip-left:before,.leaflet-tooltip-right:before{top:50%;margin-top:-6px}.leaflet-tooltip-left:before{right:0;margin-right:-12px;border-left-color:#fff}.leaflet-tooltip-right:before{left:0;margin-left:-12px;border-right-color:#fff}@media print{.leaflet-control{-webkit-print-color-adjust:exact;print-color-adjust:exact}}fk-geo-map{display:block;width:100%}.fk-geo__map{width:100%;border:1px solid var(--fk-color-border, #d4d4d8);border-radius:var(--fk-radius, 0.375rem);overflow:hidden;background:var(--fk-color-hover, #f4f4f5);position:relative}.fk-geo--locked .fk-geo__map{cursor:default}.fk-geo__unavailable{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:0.875rem;color:var(--fk-color-muted, #71717a)}.fk-geo__marker{width:14px;height:14px;border-radius:50%;background:var(--fk-color-primary, #16a34a);border:2px solid #fff;box-shadow:0 0 0 1px rgba(0, 0, 0, 0.25)}.fk-geo__shape{stroke:var(--fk-color-primary, #16a34a);fill:var(--fk-color-primary, #16a34a);fill-opacity:0.15}.fk-geo__bar{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:0.5rem 1rem;margin-top:0.5rem}.fk-geo__manual{display:flex;gap:0.75rem}.fk-geo__coord{display:flex;flex-direction:column;gap:0.25rem;font-size:0.75rem;color:var(--fk-color-muted, #71717a)}.fk-geo__coord input{width:9rem}.fk-geo__summary,.fk-geo__hint{font-size:0.75rem;color:var(--fk-color-muted, #71717a)}.fk-geo__actions{display:flex;align-items:center;gap:0.75rem}.fk-geo__clear{border:1px solid var(--fk-color-border, #d4d4d8);border-radius:var(--fk-radius, 0.375rem);background:transparent;color:inherit;font:inherit;font-size:0.75rem;padding:0.25rem 0.625rem;cursor:pointer}.fk-geo__clear:hover{background:var(--fk-color-hover, rgba(127, 127, 127, 0.12))}.fk-geo__zone{stroke:var(--fk-color-primary, #16a34a);fill:var(--fk-color-primary, #16a34a);cursor:pointer}.fk-geo__select{min-width:14rem}.fk-geo__chips{display:flex;flex-wrap:wrap;gap:0.375rem}.fk-geo__chip{display:inline-flex;align-items:center;gap:0.25rem;padding:0.125rem 0.5rem;border-radius:999px;background:var(--fk-color-hover, rgba(127, 127, 127, 0.12));font-size:0.75rem}.fk-geo__chip-remove{border:0;background:transparent;color:inherit;font:inherit;cursor:pointer;line-height:1}'}},[0,"fk-geo-map",{value:[16],mode:[1],center:[16],zoom:[2],tileUrl:[1,"tile-url"],attribution:[1],height:[2],disabled:[4],readOnly:[4,"read-only"],manual:[4],layerUrl:[1,"layer-url"],layerCodeProperty:[1,"layer-code-property"],layerNameProperty:[1,"layer-name-property"],selected:[16],multiple:[4],failed:[32],vertexCount:[32],zones:[32],layerFailed:[32]},void 0,{value:[{onValueChange:0}],disabled:[{onLockChange:0}],readOnly:[{onLockChange:0}],selected:[{onSelectedChange:0}],layerUrl:[{onLayerUrlChange:0}]}]);function p(){"undefined"!=typeof customElements&&["fk-geo-map"].forEach((t=>{"fk-geo-map"===t&&(customElements.get(e(t))||customElements.define(e(t),f))}))}p();export{f as F,p as d}
|
|
1
|
+
import{t as e,p as t,H as o,c as l,h as a}from"./p-8ICOcloT.js";import{b as i}from"./p-JQ8Ve1UU.js";const r=new Map,n=e=>Math.round(1e6*e)/1e6,s=e=>[n(e.lng),n(e.lat)],f=t(class extends o{constructor(e){super(),!1!==e&&this.__registerHost(),this.geoChange=l(this,"geoChange"),this.layerChange=l(this,"layerChange"),this.mode="point",this.zoom=6,this.tileUrl="https://tile.openstreetmap.org/{z}/{x}/{y}.png",this.attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',this.height=320,this.disabled=!1,this.readOnly=!1,this.manual=!0,this.layerCodeProperty="code",this.layerNameProperty="name",this.selected=[],this.multiple=!1,this.failed=!1,this.vertexCount=0,this.zones=[],this.layerFailed=!1,this.shapes=[],this.vertices=[],this.lastEmitted="",this.clear=()=>{this.locked||this.setVertices([])}}get locked(){return this.disabled||this.readOnly}async componentDidLoad(){var e;"layer"===this.mode&&this.fetchLayer();try{const t=await import("./p-Bza6nE37.js").then((function(e){return e.l}));this.L=null!==(e=t.default)&&void 0!==e?e:t}catch(e){return void(this.failed=!0)}this.container&&this.initMap()}disconnectedCallback(){var e,t;null===(e=this.observer)||void 0===e||e.disconnect(),null===(t=this.map)||void 0===t||t.remove(),this.map=void 0}onValueChange(e){JSON.stringify(null!=e?e:null)!==this.lastEmitted&&this.draw(e)}onLockChange(){this.draw(this.value),this.restyleLayer()}onSelectedChange(){this.restyleLayer()}onLayerUrlChange(){this.fetchLayer()}initMap(){var e;const t=this.L,o=this.container,l=t.map(o,{attributionControl:!0,zoomControl:!this.locked});t.tileLayer(this.tileUrl,{attribution:this.attribution,maxZoom:19}).addTo(l),l.setView(null!==(e=this.center)&&void 0!==e?e:[0,0],this.center?this.zoom:2),this.locked&&(l.dragging.disable(),l.scrollWheelZoom.disable()),l.on("click",(e=>{this.locked||"layer"===this.mode||this.setVertices("point"===this.mode?[e.latlng]:[...this.vertices,e.latlng])})),this.map=l,this.draw(this.value),this.drawLayer(),"undefined"!=typeof ResizeObserver&&(this.observer=new ResizeObserver((()=>l.invalidateSize())),this.observer.observe(o)),setTimeout((()=>l.invalidateSize()),50)}draw(e){var t;const o=this.L,l=this.map;if(!o||!l)return void(this.vertexCount=this.countVertices(e));const a=[];if("Point"===(null==e?void 0:e.type)&&a.push(o.latLng(e.coordinates[1],e.coordinates[0])),"LineString"===(null==e?void 0:e.type))for(const[t,l]of e.coordinates)a.push(o.latLng(l,t));if("Polygon"===(null==e?void 0:e.type)){const l=null!==(t=e.coordinates[0])&&void 0!==t?t:[],i=l.length>1&&l[0][0]===l[l.length-1][0]&&l[0][1]===l[l.length-1][1]?l.slice(0,-1):l;for(const[e,t]of i)a.push(o.latLng(t,e))}this.vertices=a,this.vertexCount=a.length,this.render_shapes(),1===a.length?l.setView(a[0],Math.max(l.getZoom(),this.zoom)):a.length>1&&l.fitBounds(o.latLngBounds(a),{padding:[24,24]})}countVertices(e){var t,o;return e?"Point"===e.type?1:"LineString"===e.type?e.coordinates.length:Math.max((null!==(o=null===(t=e.coordinates[0])||void 0===t?void 0:t.length)&&void 0!==o?o:1)-1,0):0}render_shapes(){const e=this.L,t=this.map;if(!e||!t)return;for(const e of this.shapes)e.remove();this.shapes=[];const o=this.vertices;"polygon"===this.mode&&o.length>=3&&this.shapes.push(e.polygon(o,{className:"fk-geo__shape"}).addTo(t)),"line"===this.mode&&o.length>=2&&this.shapes.push(e.polyline(o,{className:"fk-geo__shape"}).addTo(t)),o.forEach(((o,l)=>{const a=e.marker(o,{draggable:!this.locked,icon:e.divIcon({className:"fk-geo__marker",iconSize:[14,14],iconAnchor:[7,7]})}).addTo(t);a.on("dragend",(()=>{const e=[...this.vertices];e[l]=a.getLatLng(),this.setVertices(e)})),"point"!==this.mode&&a.on("contextmenu",(()=>{this.locked||this.setVertices(this.vertices.filter(((e,t)=>t!==l)))})),this.shapes.push(a)}))}setVertices(e){this.vertices=e,this.vertexCount=e.length,this.render_shapes(),this.emit()}geometry(){const e=this.vertices;if("point"===this.mode)return e[0]?{type:"Point",coordinates:s(e[0])}:void 0;if("line"===this.mode)return e.length>=2?{type:"LineString",coordinates:e.map(s)}:void 0;if(e.length<3)return;const t=e.map(s);return{type:"Polygon",coordinates:[[...t,t[0]]]}}emit(){const e=this.geometry();this.lastEmitted=JSON.stringify(null!=e?e:null),this.geoChange.emit(e)}setManual(e,t){var o,l,a;if(this.locked)return;if(""===t.trim())return this.vertices=[],this.vertexCount=0,this.render_shapes(),void this.emit();const i="Point"===(null===(o=this.value)||void 0===o?void 0:o.type)?this.value.coordinates:void 0,r="lat"===e?Number(t):null!==(l=null==i?void 0:i[1])&&void 0!==l?l:NaN,n="lng"===e?Number(t):null!==(a=null==i?void 0:i[0])&&void 0!==a?a:NaN;if(Number.isNaN(r)||Number.isNaN(n))return;const s=this.L?this.L.latLng(r,n):{lat:r,lng:n};this.vertices=[s],this.vertexCount=1,this.render_shapes(),this.map&&this.map.setView(s,Math.max(this.map.getZoom(),this.zoom)),this.emit()}componentDidRender(){var e;this.selectEl&&"layer"===this.mode&&(this.selectEl.value=null!==(e=this.selected[0])&&void 0!==e?e:"")}zoneOf(e){var t;const o=null!==(t=e.properties)&&void 0!==t?t:{},l=o[this.layerCodeProperty],a=o[this.layerNameProperty];return null==l||""===l?null:{code:String(l),name:String(null==a?l:a)}}async fetchLayer(){var e;if(this.layerFailed=!1,!this.layerUrl)return this.layerData=void 0,this.zones=[],void this.drawLayer();try{const t=await(e=>{let t=r.get(e);return t||(t=fetch(e,{headers:{Accept:"application/geo+json, application/json"}}).then((async e=>{if(!e.ok)throw new Error(String(e.status));return await e.json()})),t.catch((()=>r.delete(e))),r.set(e,t)),t})(this.layerUrl);this.layerData=t,this.zones=(null!==(e=t.features)&&void 0!==e?e:[]).map((e=>this.zoneOf(e))).filter((e=>null!==e)).sort(((e,t)=>e.name.localeCompare(t.name))),this.drawLayer()}catch(e){this.layerFailed=!0}}layerStyle(e){const t=null!==e&&this.selected.includes(e);return{className:t?"fk-geo__zone fk-geo__zone--selected":"fk-geo__zone",weight:t?2:1,fillOpacity:t?.45:.1}}drawLayer(){var e;const t=this.L,o=this.map;if(!t||!o||"layer"!==this.mode)return;if(null===(e=this.layer)||void 0===e||e.remove(),this.layer=void 0,!this.layerData)return;const l=t.geoJSON(this.layerData,{style:e=>{var t,o;return this.layerStyle(e&&null!==(o=null===(t=this.zoneOf(e))||void 0===t?void 0:t.code)&&void 0!==o?o:null)},onEachFeature:(e,t)=>{const o=this.zoneOf(e);o&&(t.bindTooltip(o.name,{sticky:!0}),t.on("click",(()=>{this.locked||this.toggleZone(o)})))}}).addTo(o);this.layer=l;const a=l.getBounds();(a.isValid()&&!this.selected.length||a.isValid()&&this.selected.length)&&o.fitBounds(a,{padding:[16,16]})}restyleLayer(){const e=this.layer;e&&e.setStyle((e=>{var t,o;return this.layerStyle(e&&null!==(o=null===(t=this.zoneOf(e))||void 0===t?void 0:t.code)&&void 0!==o?o:null)}))}toggleZone(e){const t=this.selected.includes(e.code),o=this.multiple?t?this.selected.filter((t=>t!==e.code)):[...this.selected,e.code]:t?[]:[e.code];this.emitZones(o)}emitZones(e){const t=new Map(this.zones.map((e=>[e.code,e])));this.layerChange.emit(e.map((e=>{var o;return null!==(o=t.get(e))&&void 0!==o?o:{code:e,name:e}})))}renderLayerBar(){const e=this.selected.map((e=>{var t;return null!==(t=this.zones.find((t=>t.code===e)))&&void 0!==t?t:{code:e,name:e}}));return a("div",{class:"fk-geo__bar"},this.layerFailed?a("span",{class:"fk-geo__summary"},i("layer.unavailable")):this.multiple?a("span",{class:"fk-geo__chips"},0===e.length?a("span",{class:"fk-geo__summary"},i("layer.pickMany")):e.map((e=>a("span",{class:"fk-geo__chip"},e.name,this.locked?null:a("button",{type:"button",class:"fk-geo__chip-remove","aria-label":i("geo.clear"),onClick:()=>this.toggleZone(e)},"×"))))):a("select",{class:"fk-field__input fk-geo__select",ref:e=>{this.selectEl=e},disabled:this.locked,onChange:e=>{const t=e.target.value;this.emitZones(t?[t]:[])}},a("option",{value:"",selected:!this.selected.length},i("layer.pick")),this.zones.map((e=>a("option",{value:e.code,selected:this.selected[0]===e.code},e.name)))),this.locked||this.layerFailed?null:a("span",{class:"fk-geo__hint"},i("layer.hint")))}render(){var e;const t="Point"===(null===(e=this.value)||void 0===e?void 0:e.type)?this.value.coordinates:void 0,o=i("point"===this.mode?"geo.hintPoint":"geo.hintArea");return a("div",{key:"3adf67d52e87de730d1f33c1f4aa5d56d93c9201",class:{"fk-geo":!0,"fk-geo--locked":this.locked}},a("div",{key:"f78144732a57ea5f25d1d15b1608823b2cab50e7",class:"fk-geo__map",style:{height:`${this.height}px`},ref:e=>{this.container=e}},this.failed?a("div",{class:"fk-geo__unavailable"},i("geo.unavailable")):null),"layer"===this.mode?this.renderLayerBar():a("div",{class:"fk-geo__bar"},"point"===this.mode&&this.manual?a("div",{class:"fk-geo__manual"},a("label",{class:"fk-geo__coord"},a("span",null,i("geo.latitude")),a("input",{class:"fk-field__input",type:"number",step:"any",min:"-90",max:"90",value:t?String(t[1]):"",disabled:this.disabled,readOnly:this.readOnly,onChange:e=>this.setManual("lat",e.target.value)})),a("label",{class:"fk-geo__coord"},a("span",null,i("geo.longitude")),a("input",{class:"fk-field__input",type:"number",step:"any",min:"-180",max:"180",value:t?String(t[0]):"",disabled:this.disabled,readOnly:this.readOnly,onChange:e=>this.setManual("lng",e.target.value)}))):a("span",{class:"fk-geo__summary"},this.vertexCount," ",i("geo.points")),this.locked?null:a("span",{class:"fk-geo__actions"},a("span",{class:"fk-geo__hint"},o),this.vertexCount>0?a("button",{type:"button",class:"fk-geo__clear",onClick:this.clear},i("geo.clear")):null)))}get el(){return this}static get watchers(){return{value:[{onValueChange:0}],disabled:[{onLockChange:0}],readOnly:[{onLockChange:0}],selected:[{onSelectedChange:0}],layerUrl:[{onLayerUrlChange:0}]}}static get style(){return'.leaflet-pane,.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-tile-container,.leaflet-pane>svg,.leaflet-pane>canvas,.leaflet-zoom-box,.leaflet-image-layer,.leaflet-layer{position:absolute;left:0;top:0}.leaflet-container{overflow:hidden}.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow{-webkit-user-select:none;-moz-user-select:none;user-select:none;-webkit-user-drag:none}.leaflet-tile::selection{background:transparent}.leaflet-safari .leaflet-tile{image-rendering:-webkit-optimize-contrast}.leaflet-safari .leaflet-tile-container{width:1600px;height:1600px;-webkit-transform-origin:0 0}.leaflet-marker-icon,.leaflet-marker-shadow{display:block}.leaflet-container .leaflet-overlay-pane svg{max-width:none !important;max-height:none !important}.leaflet-container .leaflet-marker-pane img,.leaflet-container .leaflet-shadow-pane img,.leaflet-container .leaflet-tile-pane img,.leaflet-container img.leaflet-image-layer,.leaflet-container .leaflet-tile{max-width:none !important;max-height:none !important;width:auto;padding:0}.leaflet-container img.leaflet-tile{mix-blend-mode:plus-lighter}.leaflet-container.leaflet-touch-zoom{-ms-touch-action:pan-x pan-y;touch-action:pan-x pan-y}.leaflet-container.leaflet-touch-drag{-ms-touch-action:pinch-zoom;touch-action:none;touch-action:pinch-zoom}.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom{-ms-touch-action:none;touch-action:none}.leaflet-container{-webkit-tap-highlight-color:transparent}.leaflet-container a{-webkit-tap-highlight-color:rgba(51, 181, 229, 0.4)}.leaflet-tile{filter:inherit;visibility:hidden}.leaflet-tile-loaded{visibility:inherit}.leaflet-zoom-box{width:0;height:0;-moz-box-sizing:border-box;box-sizing:border-box;z-index:800}.leaflet-overlay-pane svg{-moz-user-select:none}.leaflet-pane{z-index:400}.leaflet-tile-pane{z-index:200}.leaflet-overlay-pane{z-index:400}.leaflet-shadow-pane{z-index:500}.leaflet-marker-pane{z-index:600}.leaflet-tooltip-pane{z-index:650}.leaflet-popup-pane{z-index:700}.leaflet-map-pane canvas{z-index:100}.leaflet-map-pane svg{z-index:200}.leaflet-vml-shape{width:1px;height:1px}.lvml{display:inline-block;position:absolute}.leaflet-control{position:relative;z-index:800;pointer-events:visiblePainted;pointer-events:auto}.leaflet-top,.leaflet-bottom{position:absolute;z-index:1000;pointer-events:none}.leaflet-top{top:0}.leaflet-right{right:0}.leaflet-bottom{bottom:0}.leaflet-left{left:0}.leaflet-control{float:left;clear:both}.leaflet-right .leaflet-control{float:right}.leaflet-top .leaflet-control{margin-top:10px}.leaflet-bottom .leaflet-control{margin-bottom:10px}.leaflet-left .leaflet-control{margin-left:10px}.leaflet-right .leaflet-control{margin-right:10px}.leaflet-fade-anim .leaflet-popup{opacity:0;-webkit-transition:opacity 0.2s linear;-moz-transition:opacity 0.2s linear;transition:opacity 0.2s linear}.leaflet-fade-anim .leaflet-map-pane .leaflet-popup{opacity:1}.leaflet-zoom-animated{-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0}svg.leaflet-zoom-animated{will-change:transform}.leaflet-zoom-anim .leaflet-zoom-animated{-webkit-transition:-webkit-transform 0.25s cubic-bezier(0,0,0.25,1);-moz-transition:-moz-transform 0.25s cubic-bezier(0,0,0.25,1);transition:transform 0.25s cubic-bezier(0,0,0.25,1)}.leaflet-zoom-anim .leaflet-tile,.leaflet-pan-anim .leaflet-tile{-webkit-transition:none;-moz-transition:none;transition:none}.leaflet-zoom-anim .leaflet-zoom-hide{visibility:hidden}.leaflet-interactive{cursor:pointer}.leaflet-grab{cursor:-webkit-grab;cursor:-moz-grab;cursor:grab}.leaflet-crosshair,.leaflet-crosshair .leaflet-interactive{cursor:crosshair}.leaflet-popup-pane,.leaflet-control{cursor:auto}.leaflet-dragging .leaflet-grab,.leaflet-dragging .leaflet-grab .leaflet-interactive,.leaflet-dragging .leaflet-marker-draggable{cursor:move;cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing}.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-image-layer,.leaflet-pane>svg path,.leaflet-tile-container{pointer-events:none}.leaflet-marker-icon.leaflet-interactive,.leaflet-image-layer.leaflet-interactive,.leaflet-pane>svg path.leaflet-interactive,svg.leaflet-image-layer.leaflet-interactive path{pointer-events:visiblePainted;pointer-events:auto}.leaflet-container{background:#ddd;outline-offset:1px}.leaflet-container a{color:#0078A8}.leaflet-zoom-box{border:2px dotted #38f;background:rgba(255,255,255,0.5)}.leaflet-container{font-family:"Helvetica Neue", Arial, Helvetica, sans-serif;font-size:12px;font-size:0.75rem;line-height:1.5}.leaflet-bar{box-shadow:0 1px 5px rgba(0,0,0,0.65);border-radius:4px}.leaflet-bar a{background-color:#fff;border-bottom:1px solid #ccc;width:26px;height:26px;line-height:26px;display:block;text-align:center;text-decoration:none;color:black}.leaflet-bar a,.leaflet-control-layers-toggle{background-position:50% 50%;background-repeat:no-repeat;display:block}.leaflet-bar a:hover,.leaflet-bar a:focus{background-color:#f4f4f4}.leaflet-bar a:first-child{border-top-left-radius:4px;border-top-right-radius:4px}.leaflet-bar a:last-child{border-bottom-left-radius:4px;border-bottom-right-radius:4px;border-bottom:none}.leaflet-bar a.leaflet-disabled{cursor:default;background-color:#f4f4f4;color:#bbb}.leaflet-touch .leaflet-bar a{width:30px;height:30px;line-height:30px}.leaflet-touch .leaflet-bar a:first-child{border-top-left-radius:2px;border-top-right-radius:2px}.leaflet-touch .leaflet-bar a:last-child{border-bottom-left-radius:2px;border-bottom-right-radius:2px}.leaflet-control-zoom-in,.leaflet-control-zoom-out{font:bold 18px \'Lucida Console\', Monaco, monospace;text-indent:1px}.leaflet-touch .leaflet-control-zoom-in,.leaflet-touch .leaflet-control-zoom-out{font-size:22px}.leaflet-control-layers{box-shadow:0 1px 5px rgba(0,0,0,0.4);background:#fff;border-radius:5px}.leaflet-control-layers-toggle{width:36px;height:36px}.leaflet-retina .leaflet-control-layers-toggle{background-size:26px 26px}.leaflet-touch .leaflet-control-layers-toggle{width:44px;height:44px}.leaflet-control-layers .leaflet-control-layers-list,.leaflet-control-layers-expanded .leaflet-control-layers-toggle{display:none}.leaflet-control-layers-expanded .leaflet-control-layers-list{display:block;position:relative}.leaflet-control-layers-expanded{padding:6px 10px 6px 6px;color:#333;background:#fff}.leaflet-control-layers-scrollbar{overflow-y:scroll;overflow-x:hidden;padding-right:5px}.leaflet-control-layers-selector{margin-top:2px;position:relative;top:1px}.leaflet-control-layers label{display:block;font-size:13px;font-size:1.08333em}.leaflet-control-layers-separator{height:0;border-top:1px solid #ddd;margin:5px -10px 5px -6px}.leaflet-default-icon-path{}.leaflet-container .leaflet-control-attribution{background:#fff;background:rgba(255, 255, 255, 0.8);margin:0}.leaflet-control-attribution,.leaflet-control-scale-line{padding:0 5px;color:#333;line-height:1.4}.leaflet-control-attribution a{text-decoration:none}.leaflet-control-attribution a:hover,.leaflet-control-attribution a:focus{text-decoration:underline}.leaflet-attribution-flag{display:inline !important;vertical-align:baseline !important;width:1em;height:0.6669em}.leaflet-left .leaflet-control-scale{margin-left:5px}.leaflet-bottom .leaflet-control-scale{margin-bottom:5px}.leaflet-control-scale-line{border:2px solid #777;border-top:none;line-height:1.1;padding:2px 5px 1px;white-space:nowrap;-moz-box-sizing:border-box;box-sizing:border-box;background:rgba(255, 255, 255, 0.8);text-shadow:1px 1px #fff}.leaflet-control-scale-line:not(:first-child){border-top:2px solid #777;border-bottom:none;margin-top:-2px}.leaflet-control-scale-line:not(:first-child):not(:last-child){border-bottom:2px solid #777}.leaflet-touch .leaflet-control-attribution,.leaflet-touch .leaflet-control-layers,.leaflet-touch .leaflet-bar{box-shadow:none}.leaflet-touch .leaflet-control-layers,.leaflet-touch .leaflet-bar{border:2px solid rgba(0,0,0,0.2);background-clip:padding-box}.leaflet-popup{position:absolute;text-align:center;margin-bottom:20px}.leaflet-popup-content-wrapper{padding:1px;text-align:left;border-radius:12px}.leaflet-popup-content{margin:13px 24px 13px 20px;line-height:1.3;font-size:13px;font-size:1.08333em;min-height:1px}.leaflet-popup-content p{margin:17px 0;margin:1.3em 0}.leaflet-popup-tip-container{width:40px;height:20px;position:absolute;left:50%;margin-top:-1px;margin-left:-20px;overflow:hidden;pointer-events:none}.leaflet-popup-tip{width:17px;height:17px;padding:1px;margin:-10px auto 0;pointer-events:auto;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg)}.leaflet-popup-content-wrapper,.leaflet-popup-tip{background:white;color:#333;box-shadow:0 3px 14px rgba(0,0,0,0.4)}.leaflet-container a.leaflet-popup-close-button{position:absolute;top:0;right:0;border:none;text-align:center;width:24px;height:24px;font:16px/24px Tahoma, Verdana, sans-serif;color:#757575;text-decoration:none;background:transparent}.leaflet-container a.leaflet-popup-close-button:hover,.leaflet-container a.leaflet-popup-close-button:focus{color:#585858}.leaflet-popup-scrolled{overflow:auto}.leaflet-oldie .leaflet-popup-content-wrapper{-ms-zoom:1}.leaflet-oldie .leaflet-popup-tip{width:24px;margin:0 auto;-ms-filter:"progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";filter:progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)}.leaflet-oldie .leaflet-control-zoom,.leaflet-oldie .leaflet-control-layers,.leaflet-oldie .leaflet-popup-content-wrapper,.leaflet-oldie .leaflet-popup-tip{border:1px solid #999}.leaflet-div-icon{background:#fff;border:1px solid #666}.leaflet-tooltip{position:absolute;padding:6px;background-color:#fff;border:1px solid #fff;border-radius:3px;color:#222;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;pointer-events:none;box-shadow:0 1px 3px rgba(0,0,0,0.4)}.leaflet-tooltip.leaflet-interactive{cursor:pointer;pointer-events:auto}.leaflet-tooltip-top:before,.leaflet-tooltip-bottom:before,.leaflet-tooltip-left:before,.leaflet-tooltip-right:before{position:absolute;pointer-events:none;border:6px solid transparent;background:transparent;content:""}.leaflet-tooltip-bottom{margin-top:6px}.leaflet-tooltip-top{margin-top:-6px}.leaflet-tooltip-bottom:before,.leaflet-tooltip-top:before{left:50%;margin-left:-6px}.leaflet-tooltip-top:before{bottom:0;margin-bottom:-12px;border-top-color:#fff}.leaflet-tooltip-bottom:before{top:0;margin-top:-12px;margin-left:-6px;border-bottom-color:#fff}.leaflet-tooltip-left{margin-left:-6px}.leaflet-tooltip-right{margin-left:6px}.leaflet-tooltip-left:before,.leaflet-tooltip-right:before{top:50%;margin-top:-6px}.leaflet-tooltip-left:before{right:0;margin-right:-12px;border-left-color:#fff}.leaflet-tooltip-right:before{left:0;margin-left:-12px;border-right-color:#fff}@media print{.leaflet-control{-webkit-print-color-adjust:exact;print-color-adjust:exact}}fk-geo-map{display:block;width:100%}.fk-geo__map{width:100%;border:1px solid var(--fk-color-border, #d4d4d8);border-radius:var(--fk-radius, 0.375rem);overflow:hidden;background:var(--fk-color-hover, #f4f4f5);position:relative}.fk-geo--locked .fk-geo__map{cursor:default}.fk-geo__unavailable{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:0.875rem;color:var(--fk-color-muted, #71717a)}.fk-geo__marker{width:14px;height:14px;border-radius:50%;background:var(--fk-color-primary, #16a34a);border:2px solid #fff;box-shadow:0 0 0 1px rgba(0, 0, 0, 0.25)}.fk-geo__shape{stroke:var(--fk-color-primary, #16a34a);fill:var(--fk-color-primary, #16a34a);fill-opacity:0.15}.fk-geo__bar{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:0.5rem 1rem;margin-top:0.5rem}.fk-geo__manual{display:flex;gap:0.75rem}.fk-geo__coord{display:flex;flex-direction:column;gap:0.25rem;font-size:0.75rem;color:var(--fk-color-muted, #71717a)}.fk-geo__coord input{width:9rem}.fk-geo__summary,.fk-geo__hint{font-size:0.75rem;color:var(--fk-color-muted, #71717a)}.fk-geo__actions{display:flex;align-items:center;gap:0.75rem}.fk-geo__clear{border:1px solid var(--fk-color-border, #d4d4d8);border-radius:var(--fk-radius, 0.375rem);background:transparent;color:inherit;font:inherit;font-size:0.75rem;padding:0.25rem 0.625rem;cursor:pointer}.fk-geo__clear:hover{background:var(--fk-color-hover, rgba(127, 127, 127, 0.12))}.fk-geo__zone{stroke:var(--fk-color-primary, #16a34a);fill:var(--fk-color-primary, #16a34a);cursor:pointer}.fk-geo__select{min-width:14rem}.fk-geo__chips{display:flex;flex-wrap:wrap;gap:0.375rem}.fk-geo__chip{display:inline-flex;align-items:center;gap:0.25rem;padding:0.125rem 0.5rem;border-radius:999px;background:var(--fk-color-hover, rgba(127, 127, 127, 0.12));font-size:0.75rem}.fk-geo__chip-remove{border:0;background:transparent;color:inherit;font:inherit;cursor:pointer;line-height:1}'}},[0,"fk-geo-map",{value:[16],mode:[1],center:[16],zoom:[2],tileUrl:[1,"tile-url"],attribution:[1],height:[2],disabled:[4],readOnly:[4,"read-only"],manual:[4],layerUrl:[1,"layer-url"],layerCodeProperty:[1,"layer-code-property"],layerNameProperty:[1,"layer-name-property"],selected:[16],multiple:[4],failed:[32],vertexCount:[32],zones:[32],layerFailed:[32]},void 0,{value:[{onValueChange:0}],disabled:[{onLockChange:0}],readOnly:[{onLockChange:0}],selected:[{onSelectedChange:0}],layerUrl:[{onLayerUrlChange:0}]}]);function p(){"undefined"!=typeof customElements&&["fk-geo-map"].forEach((t=>{"fk-geo-map"===t&&(customElements.get(e(t))||customElements.define(e(t),f))}))}p();export{f as F,p as d}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t,p as s,H as a,c as i,h as e}from"./p-8ICOcloT.js";import{u as o,v as r}from"./p-
|
|
1
|
+
import{t,p as s,H as a,c as i,h as e}from"./p-8ICOcloT.js";import{u as o,v as r}from"./p-JQ8Ve1UU.js";const c=s(class extends a{constructor(t){super(),!1!==t&&this.__registerHost(),this.stepTouch=i(this,"stepTouch"),this.tabLabels=[],this.editable=!1,this.active=0}clampActive(){this.active>Math.max(this.tabLabels.length-1,0)&&(this.active=0)}componentDidRender(){const t=this.host.querySelector(".fk-tabs__body");t&&Array.from(t.children).forEach(((t,s)=>{const a=t;this.editable?a.style.removeProperty("display"):a.style.display=s===this.active?"":"none"}))}validateTabs(){var t,s;return!0===(null===(s=null===(t=this.spec)||void 0===t?void 0:t.configs)||void 0===s?void 0:s.validateTabs)}tabSpec(t){var s,a,i;const e=null===(a=null===(s=this.spec)||void 0===s?void 0:s.children)||void 0===a?void 0:a[t];if(e&&this.spec)return(null===(i=this.tabCache)||void 0===i?void 0:i.source)!==this.spec&&(this.tabCache={source:this.spec,specs:[]}),this.tabCache.specs[t]||(this.tabCache.specs[t]={type:"panel",id:"tab",name:"Tab",configs:{key:`tab_${t}`},children:[e]}),this.tabCache.specs[t]}tabKeys(t){var s,a,i;const e=null===(a=null===(s=this.spec)||void 0===s?void 0:s.children)||void 0===a?void 0:a[t];if(!e)return[];const r=[];for(const t of o(e))(null===(i=t.configs)||void 0===i?void 0:i.key)&&r.push(t.configs.key);return r}tabValid(t){var s;const a=this.tabSpec(t);if(!a)return!0;const i=Object.fromEntries(Object.entries(null!==(s=this.dataMap)&&void 0!==s?s:{}).filter((([,t])=>""!==t&&null!=t)));return r(a,i,this.locale).valid}goToTab(t){t!==this.active&&(this.editable||!this.validateTabs()||this.tabValid(this.active)?this.active=t:this.stepTouch.emit({keys:this.tabKeys(this.active)}))}render(){return e("div",{key:"cdafc62322154779cb7ce22b0fd246897f10d35e",class:"fk-tabs"},e("div",{key:"e9a8dc067ff9f7a877d6a0c9330dc3f1cd821243",class:"fk-tabs__nav",role:"tablist"},this.tabLabels.map(((t,s)=>e("button",{key:`${s}-${t}`,type:"button",role:"tab","aria-selected":s===this.active?"true":"false",tabIndex:s===this.active?0:-1,class:{"fk-tabs__tab":!0,"fk-tabs__tab--active":s===this.active},onKeyDown:t=>{const a=this.tabLabels.length;!a||"ArrowRight"!==t.key&&"ArrowLeft"!==t.key||(t.preventDefault(),this.goToTab((s+("ArrowRight"===t.key?1:-1)+a)%a),requestAnimationFrame((()=>{var t;null===(t=this.host.querySelector(".fk-tabs__tab--active"))||void 0===t||t.focus()})))},onClick:t=>{t.preventDefault(),this.goToTab(s)}},t)))),e("div",{key:"6ffcc7a0bceb19873c318c62b9695e98f6afba0a",class:"fk-tabs__body"},e("slot",{key:"2091e64b09722f3ce33d35550247b3f0963610c3"})))}get host(){return this}static get watchers(){return{tabLabels:[{clampActive:0}]}}static get style(){return".sc-fk-tabs-h{display:block}.fk-tabs.sc-fk-tabs{display:flex;flex-direction:column;gap:var(--fk-spacing)}.fk-tabs__nav.sc-fk-tabs{display:flex;flex-wrap:wrap;gap:2px;border-bottom:1px solid var(--fk-color-border)}.fk-tabs__tab.sc-fk-tabs{font:inherit;font-size:0.85rem;font-weight:500;padding:calc(var(--fk-spacing) / 1.5) var(--fk-spacing);min-height:24px;border:none;border-bottom:2px solid transparent;border-radius:0;background:transparent;color:var(--fk-color-muted);text-transform:none;letter-spacing:normal;cursor:pointer}.fk-tabs__tab.sc-fk-tabs:hover{color:var(--fk-color-text)}.fk-tabs__tab--active.sc-fk-tabs{color:var(--fk-color-primary);border-bottom-color:var(--fk-color-primary);font-weight:600}"}},[262,"fk-tabs",{tabLabels:[16],editable:[4],spec:[16],dataMap:[16],locale:[1],active:[32]},void 0,{tabLabels:[{clampActive:0}]}]);function n(){"undefined"!=typeof customElements&&["fk-tabs"].forEach((s=>{"fk-tabs"===s&&(customElements.get(t(s))||customElements.define(t(s),c))}))}n();export{c as F,n as d}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as i,p as e,H as s,c as t,h as r}from"./p-8ICOcloT.js";import{s as o,b as l,f as a}from"./p-
|
|
1
|
+
import{t as i,p as e,H as s,c as t,h as r}from"./p-8ICOcloT.js";import{s as o,b as l,f as a}from"./p-JQ8Ve1UU.js";const f=e(class extends s{constructor(i){super(),!1!==i&&this.__registerHost(),this.fileValueChange=t(this,"fileValueChange"),this.disabled=!1,this.multiple=!1,this.uploading=!1,this.handleFile=async i=>{var e;const s=i.target,t=Array.from(null!==(e=s.files)&&void 0!==e?e:[]);if(t.length){this.uploading=!0,this.uploadError=void 0;try{const i=[];for(const e of this.multiple?t:t.slice(0,1))i.push(await o.fileUploadService.upload(e,{url:this.uploadUrl}));this.emitFiles(this.multiple?[...this.files,...i]:i)}catch(i){this.uploadError=i instanceof Error?i.message:String(i)}finally{this.uploading=!1,s.value=""}}},this.handleRemove=async i=>{var e,s;this.removingUrl=i.url,this.uploadError=void 0;try{await(null===(s=(e=o.fileUploadService).remove)||void 0===s?void 0:s.call(e,i,{url:this.uploadUrl}))}catch(i){this.uploadError=i instanceof Error?i.message:String(i)}finally{this.removingUrl=void 0,this.emitFiles(this.files.filter((e=>e!==i)))}}}get files(){return Array.isArray(this.value)?this.value:this.value?[this.value]:[]}emitFiles(i){this.fileValueChange.emit(this.multiple?i.length?i:void 0:i[0])}formatSize(i){return i<1024?`${i} B`:i<1048576?`${(i/1024).toFixed(1)} KB`:`${(i/1048576).toFixed(1)} MB`}renderFile(i){const e=void 0!==this.removingUrl&&this.removingUrl===i.url;return r("div",{class:"fk-file__selected",key:`${i.url}:${i.name}`},r("span",{class:"fk-file__icon","aria-hidden":"true"},r("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},r("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),r("polyline",{points:"14 2 14 8 20 8"}))),r("span",{class:"fk-file__meta"},r("span",{class:"fk-file__name",title:i.name},i.name),r("span",{class:"fk-file__size"},this.formatSize(i.size))),r("button",{type:"button",class:"fk-file__remove",title:l("file.remove"),disabled:this.disabled||e,onClick:e=>{e.preventDefault(),this.handleRemove(i)}},e?"…":"✕"))}render(){const i=this.files,e=this.multiple||0===i.length;return r("div",{key:"423b1bd452ac810e8b84b2b63769fa93feab2a0e",class:"fk-file"},i.map((i=>this.renderFile(i))),e?r("button",{type:"button",class:"fk-file__choose",disabled:this.disabled||this.uploading,onClick:i=>{var e;i.preventDefault(),null===(e=this.inputEl)||void 0===e||e.click()}},this.uploading?l("file.uploading"):this.multiple&&i.length?a("file.addAnother","+ Add a file"):l("file.choose")):null,r("input",{key:"1e2912ced33b3aff036f488e927a136eabc9470b",class:"fk-file__native",type:"file",accept:this.accept,multiple:this.multiple,disabled:this.disabled,ref:i=>this.inputEl=i,onChange:this.handleFile}),this.uploadError?r("span",{class:"fk-field__error"},this.uploadError):null)}static get style(){return".sc-fk-file-input-h{display:block}.fk-file.sc-fk-file-input{display:flex;flex-direction:column;gap:calc(var(--fk-spacing) / 2);align-items:flex-start}.fk-file__native.sc-fk-file-input{display:none}.fk-file__choose.sc-fk-file-input{font:inherit;font-size:0.85rem;padding:calc(var(--fk-spacing) / 1.5) var(--fk-spacing);border:1px dashed var(--fk-color-border);border-radius:var(--fk-radius);background:transparent;color:var(--fk-color-muted);cursor:pointer}.fk-file__choose.sc-fk-file-input:hover:not(:disabled){border-color:var(--fk-color-primary);color:var(--fk-color-primary)}.fk-file__choose.sc-fk-file-input:disabled{opacity:0.55;cursor:not-allowed}.fk-file__selected.sc-fk-file-input{display:flex;align-items:center;gap:var(--fk-spacing);width:100%;box-sizing:border-box;padding:calc(var(--fk-spacing) * 0.75) var(--fk-spacing);border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface)}.fk-file__icon.sc-fk-file-input{display:inline-flex;flex-shrink:0;color:var(--fk-color-primary)}.fk-file__meta.sc-fk-file-input{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}.fk-file__name.sc-fk-file-input{font-size:0.85rem;font-weight:600;color:var(--fk-color-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.fk-file__size.sc-fk-file-input{font-size:0.72rem;color:var(--fk-color-muted);white-space:nowrap}.fk-file__remove.sc-fk-file-input{border:none;background:transparent;color:var(--fk-color-muted);font-size:0.8rem;cursor:pointer;padding:4px 6px;border-radius:calc(var(--fk-radius) / 2);flex-shrink:0}.fk-file__remove.sc-fk-file-input:hover:not(:disabled){background:color-mix(in srgb, var(--fk-color-danger) 12%, transparent)}.fk-file__remove.sc-fk-file-input:hover:not(:disabled){color:var(--fk-color-danger)}"}},[2,"fk-file-input",{value:[16],disabled:[4],accept:[1],uploadUrl:[1,"upload-url"],multiple:[4],uploading:[32],removingUrl:[32],uploadError:[32]}]);function n(){"undefined"!=typeof customElements&&["fk-file-input"].forEach((e=>{"fk-file-input"===e&&(customElements.get(i(e))||customElements.define(i(e),f))}))}n();export{f as F,n as d}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e,p as t,H as a,c as s,h as l}from"./p-8ICOcloT.js";import{b as i}from"./p-
|
|
1
|
+
import{t as e,p as t,H as a,c as s,h as l}from"./p-8ICOcloT.js";import{b as i}from"./p-JQ8Ve1UU.js";import{d as k}from"./p-jEx6mM9z.js";const r=e=>null==e?"":"object"==typeof e?JSON.stringify(e):String(e),o=e=>e&&"object"==typeof e&&!Array.isArray(e)?Object.entries(e).map((([e,t])=>({key:e,value:r(t)}))):[],n=t(class extends a{constructor(e){super(),!1!==e&&this.__registerHost(),this.keyValueChange=s(this,"keyValueChange"),this.variables=[],this.disabled=!1,this.readOnly=!1,this.rows=[]}componentWillLoad(){this.rows=o(this.value)}onValueChange(e){const t=o(e),a=this.rows.filter((e=>e.key.trim()));JSON.stringify(t)!==JSON.stringify(a)&&(this.rows=t)}get locked(){return this.disabled||this.readOnly}commit(e){this.rows=e;const t={};for(const a of e)a.key.trim()&&(t[a.key.trim()]=a.value);this.keyValueChange.emit(Object.keys(t).length?t:void 0)}update(e,t){this.commit(this.rows.map(((a,s)=>s===e?Object.assign(Object.assign({},a),t):a)))}render(){const e=this.keyLabel||i("keyValue.key"),t=this.valueLabel||i("keyValue.value"),a=this.variables.length>0&&!this.locked;return l("div",{key:"4596c41b5ac0404a442a68d229e27c701d15f773",class:"fk-kv"},0===this.rows.length&&this.locked?l("span",{class:"fk-kv__empty"},i("keyValue.empty")):null,this.rows.map(((s,k)=>l("div",{class:"fk-kv__row",key:k},l("input",{class:"fk-field__input fk-kv__key",type:"text","aria-label":e,placeholder:e,value:s.key,disabled:this.disabled,readOnly:this.readOnly,onInput:e=>this.update(k,{key:e.target.value})}),l("div",{class:{"fk-kv__value":!0,"fk-variables":a}},l("input",{class:"fk-field__input",type:"text","aria-label":t,placeholder:t,value:s.value,disabled:this.disabled,readOnly:this.readOnly,onInput:e=>this.update(k,{value:e.target.value})}),a?l("fk-variable-picker",{variables:this.variables,onVariablePick:e=>this.update(k,{value:e.detail})}):null),this.locked?null:l("button",{type:"button",class:"fk-kv__remove",title:i("keyValue.remove"),onClick:()=>this.commit(this.rows.filter(((e,t)=>t!==k)))},"✕")))),this.locked?null:l("button",{type:"button",class:"fk-kv__add",onClick:()=>this.rows=[...this.rows,{key:"",value:""}]},i("keyValue.add")))}static get watchers(){return{value:[{onValueChange:0}]}}static get style(){return".sc-fk-key-value-h{display:block}.fk-kv.sc-fk-key-value{display:flex;flex-direction:column;gap:0.375rem}.fk-kv__row.sc-fk-key-value{display:grid;grid-template-columns:minmax(6rem, 1fr) minmax(8rem, 2fr) auto;gap:0.375rem;align-items:start}.fk-kv__value.sc-fk-key-value{position:relative}.fk-kv__remove.sc-fk-key-value,.fk-kv__add.sc-fk-key-value{border:0;background:transparent;color:var(--fk-color-muted, #71717a);font:inherit;font-size:0.8125rem;cursor:pointer;padding:0.375rem 0.25rem}.fk-kv__add.sc-fk-key-value{align-self:flex-start;text-decoration:underline}.fk-kv__empty.sc-fk-key-value{font-size:0.8125rem;color:var(--fk-color-muted, #71717a)}"}},[2,"fk-key-value",{value:[16],keyLabel:[1,"key-label"],valueLabel:[1,"value-label"],variables:[16],disabled:[4],readOnly:[4,"read-only"],rows:[32]},void 0,{value:[{onValueChange:0}]}]);function u(){"undefined"!=typeof customElements&&["fk-key-value","fk-variable-picker"].forEach((t=>{switch(t){case"fk-key-value":customElements.get(e(t))||customElements.define(e(t),n);break;case"fk-variable-picker":customElements.get(e(t))||k()}}))}u();export{n as F,u as d}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e,p as r,H as t,c as o,h as s}from"./p-8ICOcloT.js";import{s as l,b as i}from"./p-bmymYwS6.js";import{d as a}from"./p-BE5v8BN3.js";const n=[{id:"equals",label:"equals"},{id:"notEquals",label:"does not equal"},{id:"greaterThan",label:"is greater than"},{id:"lessThan",label:"is less than"},{id:"isEmpty",label:"is empty"},{id:"isNotEmpty",label:"is not empty"}];function c(e){const r={var:e.field};switch(e.operator){case"equals":return{"==":[r,e.value]};case"notEquals":return{"!=":[r,e.value]};case"greaterThan":return{">":[r,e.value]};case"lessThan":return{"<":[r,e.value]};case"isEmpty":return{"!":r};case"isNotEmpty":return{"!!":r}}}const d=e=>null!==e&&"object"==typeof e&&"string"==typeof e.var?e.var:void 0,u={"==":"equals","!=":"notEquals",">":"greaterThan","<":"lessThan"};function f(e){if(!e||"object"!=typeof e)return;const r=Object.entries(e);if(1!==r.length)return;const[t,o]=r[0];if("!"===t||"!!"===t){const e=d(Array.isArray(o)?o[0]:o);if(!e)return;return{field:e,operator:"!"===t?"isEmpty":"isNotEmpty"}}const s=u[t];if(!s||!Array.isArray(o)||2!==o.length)return;const l=d(o[0]);return l?{field:l,operator:s,value:o[1]}:void 0}function p(e){if(""===e)return"";try{return JSON.parse(e)}catch(r){return e}}const k=["hidden","disabled","required","value"],v=r(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.brickRulesChange=o(this,"brickRulesChange"),this.fields=[],this.forcedModes={},this.jsonErrors={},this.codeErrors={},this.addRule=()=>{var e;this.commit([...this.rules(),{name:`Rule ${this.rules().length+1}`,type:"jsonLogic",logic:c({field:null!==(e=this.fields[0])&&void 0!==e?e:"",operator:"equals",value:""}),effects:[{property:{target:"hidden",type:"boolean"},boolean:!0}]}])}}rules(){var e;return null!==(e=this.brick.rules)&&void 0!==e?e:[]}commit(e){this.path&&this.brickRulesChange.emit({rules:e,path:this.path})}updateRule(e,r){this.commit(this.rules().map(((t,o)=>o===e?Object.assign(Object.assign({},t),r):t)))}removeRule(e){this.commit(this.rules().filter(((r,t)=>t!==e))),this.forcedModes=Object.assign(Object.assign({},this.forcedModes),{[e]:void 0})}modeOf(e,r){return"javaScript"===r.type?"javaScript":this.forcedModes[e]?this.forcedModes[e]:f(r.logic)?"simple":"json"}setMode(e,r,t){var o,s,l;this.forcedModes=Object.assign(Object.assign({},this.forcedModes),{[e]:t}),this.jsonErrors=Object.assign(Object.assign({},this.jsonErrors),{[e]:""}),this.codeErrors=Object.assign(Object.assign({},this.codeErrors),{[e]:""}),"javaScript"!==t||"javaScript"===r.type?"javaScript"!==t&&"jsonLogic"!==r.type&&this.updateRule(e,{type:"jsonLogic",logic:null!==(s=r.logic)&&void 0!==s?s:c({field:null!==(l=this.fields[0])&&void 0!==l?l:"",operator:"equals",value:""})}):this.updateRule(e,{type:"javaScript",code:null!==(o=r.code)&&void 0!==o?o:"return true;"})}updateCondition(e,r,t){var o,s;const l=null!==(o=f(r.logic))&&void 0!==o?o:{field:null!==(s=this.fields[0])&&void 0!==s?s:"",operator:"equals",value:""};this.updateRule(e,{logic:c(Object.assign(Object.assign({},l),t))})}commitJson(e,r){try{const t=JSON.parse(r);this.jsonErrors=Object.assign(Object.assign({},this.jsonErrors),{[e]:""}),this.updateRule(e,{logic:t})}catch(r){this.jsonErrors=Object.assign(Object.assign({},this.jsonErrors),{[e]:r instanceof Error?r.message:String(r)})}}commitCode(e,r){var t,o;const s=l.jsRunnerService.validateJs(`(() => {${r}})();`);this.codeErrors=Object.assign(Object.assign({},this.codeErrors),{[e]:s.valid?"":null!==(o=null===(t=s.error)||void 0===t?void 0:t.message)&&void 0!==o?o:"Invalid code"}),this.updateRule(e,{code:r})}updateEffect(e,r,t){var o;const s=(null!==(o=this.rules()[e].effects)&&void 0!==o?o:[]).map(((e,o)=>o===r?t:e));this.updateRule(e,{effects:s})}addEffect(e){var r;const t=this.rules()[e];this.updateRule(e,{effects:[...null!==(r=t.effects)&&void 0!==r?r:[],{property:{target:"hidden",type:"boolean"},boolean:!0}]})}removeEffect(e,r){var t;const o=this.rules()[e];this.updateRule(e,{effects:(null!==(t=o.effects)&&void 0!==t?t:[]).filter(((e,t)=>t!==r))})}renderCondition(e,r){var t,o;const l=null!==(t=f(r.logic))&&void 0!==t?t:{field:null!==(o=this.fields[0])&&void 0!==o?o:"",operator:"equals",value:""},a="isEmpty"!==l.operator&&"isNotEmpty"!==l.operator;return s("div",{class:"fk-rule__condition"},s("span",{class:"fk-rule__keyword"},i("rules.when")),s("select",{class:"fk-rule__control",onChange:t=>this.updateCondition(e,r,{field:t.target.value})},this.fields.map((e=>s("option",{value:e,selected:e===l.field},e)))),s("select",{class:"fk-rule__control",onChange:t=>this.updateCondition(e,r,{operator:t.target.value})},n.map((e=>s("option",{value:e.id,selected:e.id===l.operator},e.label)))),a?s("input",{class:"fk-rule__control",type:"text",value:(c=l.value,void 0===c?"":"string"==typeof c?c:JSON.stringify(c)),onChange:t=>this.updateCondition(e,r,{value:p(t.target.value)})}):null);var c}renderEffect(e,r,t){var o,l,a,n,c;const d=null!==(l=null===(o=r.property)||void 0===o?void 0:o.target)&&void 0!==l?l:"hidden",u=null!==(n=null===(a=r.property)||void 0===a?void 0:a.type)&&void 0!==n?n:"boolean";return s("div",{class:"fk-rule__effect"},s("select",{class:"fk-rule__control",onChange:o=>this.updateEffect(e,t,Object.assign(Object.assign({},r),{property:{target:o.target.value,type:u}}))},k.map((e=>s("option",{value:e,selected:e===d},e)))),s("select",{class:"fk-rule__control",onChange:r=>{const o=r.target.value;this.updateEffect(e,t,Object.assign({property:{target:d,type:o}},"boolean"===o?{boolean:!0}:{string:""}))}},s("option",{value:"boolean",selected:"boolean"===u},"boolean"),s("option",{value:"string",selected:"string"===u},"string")),"boolean"===u?s("select",{class:"fk-rule__control",onChange:o=>this.updateEffect(e,t,Object.assign(Object.assign({},r),{boolean:"true"===o.target.value}))},s("option",{value:"true",selected:!1!==r.boolean},"true"),s("option",{value:"false",selected:!1===r.boolean},"false")):s("input",{class:"fk-rule__control",type:"text",value:null!==(c=r.string)&&void 0!==c?c:"",onChange:o=>this.updateEffect(e,t,Object.assign(Object.assign({},r),{string:o.target.value}))}),s("button",{type:"button",class:"fk-rule__remove",title:i("rules.removeEffect"),onClick:()=>this.removeEffect(e,t)},"✕"))}render(){return s("div",{key:"9fbb756f3b680000c8c4740158b37cb9d923f98e",class:"fk-rules"},this.rules().map(((e,r)=>{var t,o,l;const a=this.modeOf(r,e);return s("article",{class:"fk-rule"},s("header",{class:"fk-rule__header"},s("input",{class:"fk-rule__name",type:"text",value:e.name,onChange:e=>this.updateRule(r,{name:e.target.value})}),s("button",{type:"button",class:"fk-rule__remove",title:i("rules.removeRule"),onClick:()=>this.removeRule(r)},"✕")),s("div",{class:"fk-rule__modes"},["simple","json","javaScript"].map((t=>s("button",{type:"button",class:{"fk-rule__mode":!0,"fk-rule__mode--active":a===t},onClick:()=>this.setMode(r,e,t)},i(`rules.mode.${"javaScript"===t?"js":t}`))))),"simple"===a?this.renderCondition(r,e):null,"json"===a?s("div",{class:"fk-rule__advanced"},s("textarea",{class:"fk-rule__code",onChange:e=>this.commitJson(r,e.target.value)},JSON.stringify(null!==(t=e.logic)&&void 0!==t?t:null,null,2)),this.jsonErrors[r]?s("p",{class:"fk-rule__error"},this.jsonErrors[r]):null):null,"javaScript"===a?s("div",{class:"fk-rule__advanced"},s("fk-code-editor",{completions:this.fields,value:null!==(o=e.code)&&void 0!==o?o:"",placeholder:"return dataMap.country === 'BJ';",onCodeChange:e=>this.commitCode(r,e.detail)}),this.codeErrors[r]?s("p",{class:"fk-rule__error"},this.codeErrors[r]):null):null,s("div",{class:"fk-rule__effects"},s("span",{class:"fk-rule__keyword"},i("rules.then")),(null!==(l=e.effects)&&void 0!==l?l:[]).map(((e,t)=>this.renderEffect(r,e,t))),s("button",{type:"button",class:"fk-rule__add",onClick:()=>this.addEffect(r)},i("rules.addEffect"))))})),s("button",{key:"cba5344c45611f139f69afd6f806ce8f6cf0cb05",type:"button",class:"fk-rule__add",onClick:this.addRule},i("rules.addRule")))}static get style(){return".sc-fk-rules-editor-h{display:block}.fk-rules.sc-fk-rules-editor{display:flex;flex-direction:column;gap:var(--fk-spacing)}.fk-rule.sc-fk-rules-editor{display:flex;flex-direction:column;gap:calc(var(--fk-spacing) / 1.5);padding:var(--fk-spacing);border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 1.5);background:color-mix(in srgb, var(--fk-color-surface) 60%, transparent)}.fk-rule__header.sc-fk-rules-editor{display:flex;align-items:center;gap:6px}.fk-rule__name.sc-fk-rules-editor{flex:1;min-width:0;font:inherit;font-size:0.8rem;font-weight:600;padding:4px 6px;border:1px solid transparent;border-radius:calc(var(--fk-radius) / 2);background:transparent;color:var(--fk-color-text)}.fk-rule__name.sc-fk-rules-editor:hover,.fk-rule__name.sc-fk-rules-editor:focus{border-color:var(--fk-color-border);background:var(--fk-color-surface);outline:none}.fk-rule__modes.sc-fk-rules-editor{display:flex;gap:4px}.fk-rule__mode.sc-fk-rules-editor{font:inherit;font-size:0.65rem;font-weight:600;text-transform:uppercase;letter-spacing:0.05em;padding:3px 8px;border:1px solid var(--fk-color-border);border-radius:999px;background:transparent;color:var(--fk-color-muted);cursor:pointer}.fk-rule__mode--active.sc-fk-rules-editor{border-color:var(--fk-color-primary);background:color-mix(in srgb, var(--fk-color-primary) 12%, transparent);color:var(--fk-color-primary)}.fk-rule__condition.sc-fk-rules-editor,.fk-rule__effect.sc-fk-rules-editor{display:flex;flex-wrap:wrap;align-items:center;gap:4px}.fk-rule__keyword.sc-fk-rules-editor{font-size:0.65rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--fk-color-muted)}.fk-rule__control.sc-fk-rules-editor{font:inherit;font-size:0.78rem;padding:4px 6px;max-width:100%;min-width:0;border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface);color:var(--fk-color-text)}.fk-rule__control.sc-fk-rules-editor:focus{outline:none;border-color:var(--fk-color-primary)}.fk-rule__advanced.sc-fk-rules-editor{display:flex;flex-direction:column;gap:4px}.fk-rule__code.sc-fk-rules-editor{font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-size:0.75rem;min-height:72px;padding:6px 8px;border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface);color:var(--fk-color-text);resize:vertical}.fk-rule__error.sc-fk-rules-editor{margin:0;font-size:0.72rem;color:var(--fk-color-danger)}.fk-rule__effects.sc-fk-rules-editor{display:flex;flex-direction:column;gap:6px}.fk-rule__remove.sc-fk-rules-editor{border:none;background:transparent;color:var(--fk-color-muted);font-size:0.75rem;cursor:pointer;padding:2px 4px;border-radius:calc(var(--fk-radius) / 2)}.fk-rule__remove.sc-fk-rules-editor:hover{color:var(--fk-color-danger);background:color-mix(in srgb, var(--fk-color-danger) 10%, transparent)}.fk-rule__add.sc-fk-rules-editor{align-self:flex-start;font:inherit;font-size:0.75rem;font-weight:600;padding:4px 10px;border:1px dashed var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:transparent;color:var(--fk-color-muted);cursor:pointer}.fk-rule__add.sc-fk-rules-editor:hover{border-color:var(--fk-color-primary);color:var(--fk-color-primary)}"}},[2,"fk-rules-editor",{brick:[16],path:[1],fields:[16],forcedModes:[32],jsonErrors:[32],codeErrors:[32]}]);function h(){"undefined"!=typeof customElements&&["fk-rules-editor","fk-code-editor"].forEach((r=>{switch(r){case"fk-rules-editor":customElements.get(e(r))||customElements.define(e(r),v);break;case"fk-code-editor":customElements.get(e(r))||a()}}))}h();export{v as F,h as d}
|
|
1
|
+
import{t as e,p as r,H as t,c as o,h as s}from"./p-8ICOcloT.js";import{s as l,b as i}from"./p-JQ8Ve1UU.js";import{d as a}from"./p-BE5v8BN3.js";const n=[{id:"equals",label:"equals"},{id:"notEquals",label:"does not equal"},{id:"greaterThan",label:"is greater than"},{id:"lessThan",label:"is less than"},{id:"isEmpty",label:"is empty"},{id:"isNotEmpty",label:"is not empty"}];function c(e){const r={var:e.field};switch(e.operator){case"equals":return{"==":[r,e.value]};case"notEquals":return{"!=":[r,e.value]};case"greaterThan":return{">":[r,e.value]};case"lessThan":return{"<":[r,e.value]};case"isEmpty":return{"!":r};case"isNotEmpty":return{"!!":r}}}const d=e=>null!==e&&"object"==typeof e&&"string"==typeof e.var?e.var:void 0,u={"==":"equals","!=":"notEquals",">":"greaterThan","<":"lessThan"};function f(e){if(!e||"object"!=typeof e)return;const r=Object.entries(e);if(1!==r.length)return;const[t,o]=r[0];if("!"===t||"!!"===t){const e=d(Array.isArray(o)?o[0]:o);if(!e)return;return{field:e,operator:"!"===t?"isEmpty":"isNotEmpty"}}const s=u[t];if(!s||!Array.isArray(o)||2!==o.length)return;const l=d(o[0]);return l?{field:l,operator:s,value:o[1]}:void 0}function p(e){if(""===e)return"";try{return JSON.parse(e)}catch(r){return e}}const k=["hidden","disabled","required","value"],v=r(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.brickRulesChange=o(this,"brickRulesChange"),this.fields=[],this.forcedModes={},this.jsonErrors={},this.codeErrors={},this.addRule=()=>{var e;this.commit([...this.rules(),{name:`Rule ${this.rules().length+1}`,type:"jsonLogic",logic:c({field:null!==(e=this.fields[0])&&void 0!==e?e:"",operator:"equals",value:""}),effects:[{property:{target:"hidden",type:"boolean"},boolean:!0}]}])}}rules(){var e;return null!==(e=this.brick.rules)&&void 0!==e?e:[]}commit(e){this.path&&this.brickRulesChange.emit({rules:e,path:this.path})}updateRule(e,r){this.commit(this.rules().map(((t,o)=>o===e?Object.assign(Object.assign({},t),r):t)))}removeRule(e){this.commit(this.rules().filter(((r,t)=>t!==e))),this.forcedModes=Object.assign(Object.assign({},this.forcedModes),{[e]:void 0})}modeOf(e,r){return"javaScript"===r.type?"javaScript":this.forcedModes[e]?this.forcedModes[e]:f(r.logic)?"simple":"json"}setMode(e,r,t){var o,s,l;this.forcedModes=Object.assign(Object.assign({},this.forcedModes),{[e]:t}),this.jsonErrors=Object.assign(Object.assign({},this.jsonErrors),{[e]:""}),this.codeErrors=Object.assign(Object.assign({},this.codeErrors),{[e]:""}),"javaScript"!==t||"javaScript"===r.type?"javaScript"!==t&&"jsonLogic"!==r.type&&this.updateRule(e,{type:"jsonLogic",logic:null!==(s=r.logic)&&void 0!==s?s:c({field:null!==(l=this.fields[0])&&void 0!==l?l:"",operator:"equals",value:""})}):this.updateRule(e,{type:"javaScript",code:null!==(o=r.code)&&void 0!==o?o:"return true;"})}updateCondition(e,r,t){var o,s;const l=null!==(o=f(r.logic))&&void 0!==o?o:{field:null!==(s=this.fields[0])&&void 0!==s?s:"",operator:"equals",value:""};this.updateRule(e,{logic:c(Object.assign(Object.assign({},l),t))})}commitJson(e,r){try{const t=JSON.parse(r);this.jsonErrors=Object.assign(Object.assign({},this.jsonErrors),{[e]:""}),this.updateRule(e,{logic:t})}catch(r){this.jsonErrors=Object.assign(Object.assign({},this.jsonErrors),{[e]:r instanceof Error?r.message:String(r)})}}commitCode(e,r){var t,o;const s=l.jsRunnerService.validateJs(`(() => {${r}})();`);this.codeErrors=Object.assign(Object.assign({},this.codeErrors),{[e]:s.valid?"":null!==(o=null===(t=s.error)||void 0===t?void 0:t.message)&&void 0!==o?o:"Invalid code"}),this.updateRule(e,{code:r})}updateEffect(e,r,t){var o;const s=(null!==(o=this.rules()[e].effects)&&void 0!==o?o:[]).map(((e,o)=>o===r?t:e));this.updateRule(e,{effects:s})}addEffect(e){var r;const t=this.rules()[e];this.updateRule(e,{effects:[...null!==(r=t.effects)&&void 0!==r?r:[],{property:{target:"hidden",type:"boolean"},boolean:!0}]})}removeEffect(e,r){var t;const o=this.rules()[e];this.updateRule(e,{effects:(null!==(t=o.effects)&&void 0!==t?t:[]).filter(((e,t)=>t!==r))})}renderCondition(e,r){var t,o;const l=null!==(t=f(r.logic))&&void 0!==t?t:{field:null!==(o=this.fields[0])&&void 0!==o?o:"",operator:"equals",value:""},a="isEmpty"!==l.operator&&"isNotEmpty"!==l.operator;return s("div",{class:"fk-rule__condition"},s("span",{class:"fk-rule__keyword"},i("rules.when")),s("select",{class:"fk-rule__control",onChange:t=>this.updateCondition(e,r,{field:t.target.value})},this.fields.map((e=>s("option",{value:e,selected:e===l.field},e)))),s("select",{class:"fk-rule__control",onChange:t=>this.updateCondition(e,r,{operator:t.target.value})},n.map((e=>s("option",{value:e.id,selected:e.id===l.operator},e.label)))),a?s("input",{class:"fk-rule__control",type:"text",value:(c=l.value,void 0===c?"":"string"==typeof c?c:JSON.stringify(c)),onChange:t=>this.updateCondition(e,r,{value:p(t.target.value)})}):null);var c}renderEffect(e,r,t){var o,l,a,n,c;const d=null!==(l=null===(o=r.property)||void 0===o?void 0:o.target)&&void 0!==l?l:"hidden",u=null!==(n=null===(a=r.property)||void 0===a?void 0:a.type)&&void 0!==n?n:"boolean";return s("div",{class:"fk-rule__effect"},s("select",{class:"fk-rule__control",onChange:o=>this.updateEffect(e,t,Object.assign(Object.assign({},r),{property:{target:o.target.value,type:u}}))},k.map((e=>s("option",{value:e,selected:e===d},e)))),s("select",{class:"fk-rule__control",onChange:r=>{const o=r.target.value;this.updateEffect(e,t,Object.assign({property:{target:d,type:o}},"boolean"===o?{boolean:!0}:{string:""}))}},s("option",{value:"boolean",selected:"boolean"===u},"boolean"),s("option",{value:"string",selected:"string"===u},"string")),"boolean"===u?s("select",{class:"fk-rule__control",onChange:o=>this.updateEffect(e,t,Object.assign(Object.assign({},r),{boolean:"true"===o.target.value}))},s("option",{value:"true",selected:!1!==r.boolean},"true"),s("option",{value:"false",selected:!1===r.boolean},"false")):s("input",{class:"fk-rule__control",type:"text",value:null!==(c=r.string)&&void 0!==c?c:"",onChange:o=>this.updateEffect(e,t,Object.assign(Object.assign({},r),{string:o.target.value}))}),s("button",{type:"button",class:"fk-rule__remove",title:i("rules.removeEffect"),onClick:()=>this.removeEffect(e,t)},"✕"))}render(){return s("div",{key:"9fbb756f3b680000c8c4740158b37cb9d923f98e",class:"fk-rules"},this.rules().map(((e,r)=>{var t,o,l;const a=this.modeOf(r,e);return s("article",{class:"fk-rule"},s("header",{class:"fk-rule__header"},s("input",{class:"fk-rule__name",type:"text",value:e.name,onChange:e=>this.updateRule(r,{name:e.target.value})}),s("button",{type:"button",class:"fk-rule__remove",title:i("rules.removeRule"),onClick:()=>this.removeRule(r)},"✕")),s("div",{class:"fk-rule__modes"},["simple","json","javaScript"].map((t=>s("button",{type:"button",class:{"fk-rule__mode":!0,"fk-rule__mode--active":a===t},onClick:()=>this.setMode(r,e,t)},i(`rules.mode.${"javaScript"===t?"js":t}`))))),"simple"===a?this.renderCondition(r,e):null,"json"===a?s("div",{class:"fk-rule__advanced"},s("textarea",{class:"fk-rule__code",onChange:e=>this.commitJson(r,e.target.value)},JSON.stringify(null!==(t=e.logic)&&void 0!==t?t:null,null,2)),this.jsonErrors[r]?s("p",{class:"fk-rule__error"},this.jsonErrors[r]):null):null,"javaScript"===a?s("div",{class:"fk-rule__advanced"},s("fk-code-editor",{completions:this.fields,value:null!==(o=e.code)&&void 0!==o?o:"",placeholder:"return dataMap.country === 'BJ';",onCodeChange:e=>this.commitCode(r,e.detail)}),this.codeErrors[r]?s("p",{class:"fk-rule__error"},this.codeErrors[r]):null):null,s("div",{class:"fk-rule__effects"},s("span",{class:"fk-rule__keyword"},i("rules.then")),(null!==(l=e.effects)&&void 0!==l?l:[]).map(((e,t)=>this.renderEffect(r,e,t))),s("button",{type:"button",class:"fk-rule__add",onClick:()=>this.addEffect(r)},i("rules.addEffect"))))})),s("button",{key:"cba5344c45611f139f69afd6f806ce8f6cf0cb05",type:"button",class:"fk-rule__add",onClick:this.addRule},i("rules.addRule")))}static get style(){return".sc-fk-rules-editor-h{display:block}.fk-rules.sc-fk-rules-editor{display:flex;flex-direction:column;gap:var(--fk-spacing)}.fk-rule.sc-fk-rules-editor{display:flex;flex-direction:column;gap:calc(var(--fk-spacing) / 1.5);padding:var(--fk-spacing);border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 1.5);background:color-mix(in srgb, var(--fk-color-surface) 60%, transparent)}.fk-rule__header.sc-fk-rules-editor{display:flex;align-items:center;gap:6px}.fk-rule__name.sc-fk-rules-editor{flex:1;min-width:0;font:inherit;font-size:0.8rem;font-weight:600;padding:4px 6px;border:1px solid transparent;border-radius:calc(var(--fk-radius) / 2);background:transparent;color:var(--fk-color-text)}.fk-rule__name.sc-fk-rules-editor:hover,.fk-rule__name.sc-fk-rules-editor:focus{border-color:var(--fk-color-border);background:var(--fk-color-surface);outline:none}.fk-rule__modes.sc-fk-rules-editor{display:flex;gap:4px}.fk-rule__mode.sc-fk-rules-editor{font:inherit;font-size:0.65rem;font-weight:600;text-transform:uppercase;letter-spacing:0.05em;padding:3px 8px;border:1px solid var(--fk-color-border);border-radius:999px;background:transparent;color:var(--fk-color-muted);cursor:pointer}.fk-rule__mode--active.sc-fk-rules-editor{border-color:var(--fk-color-primary);background:color-mix(in srgb, var(--fk-color-primary) 12%, transparent);color:var(--fk-color-primary)}.fk-rule__condition.sc-fk-rules-editor,.fk-rule__effect.sc-fk-rules-editor{display:flex;flex-wrap:wrap;align-items:center;gap:4px}.fk-rule__keyword.sc-fk-rules-editor{font-size:0.65rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--fk-color-muted)}.fk-rule__control.sc-fk-rules-editor{font:inherit;font-size:0.78rem;padding:4px 6px;max-width:100%;min-width:0;border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface);color:var(--fk-color-text)}.fk-rule__control.sc-fk-rules-editor:focus{outline:none;border-color:var(--fk-color-primary)}.fk-rule__advanced.sc-fk-rules-editor{display:flex;flex-direction:column;gap:4px}.fk-rule__code.sc-fk-rules-editor{font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-size:0.75rem;min-height:72px;padding:6px 8px;border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface);color:var(--fk-color-text);resize:vertical}.fk-rule__error.sc-fk-rules-editor{margin:0;font-size:0.72rem;color:var(--fk-color-danger)}.fk-rule__effects.sc-fk-rules-editor{display:flex;flex-direction:column;gap:6px}.fk-rule__remove.sc-fk-rules-editor{border:none;background:transparent;color:var(--fk-color-muted);font-size:0.75rem;cursor:pointer;padding:2px 4px;border-radius:calc(var(--fk-radius) / 2)}.fk-rule__remove.sc-fk-rules-editor:hover{color:var(--fk-color-danger);background:color-mix(in srgb, var(--fk-color-danger) 10%, transparent)}.fk-rule__add.sc-fk-rules-editor{align-self:flex-start;font:inherit;font-size:0.75rem;font-weight:600;padding:4px 10px;border:1px dashed var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:transparent;color:var(--fk-color-muted);cursor:pointer}.fk-rule__add.sc-fk-rules-editor:hover{border-color:var(--fk-color-primary);color:var(--fk-color-primary)}"}},[2,"fk-rules-editor",{brick:[16],path:[1],fields:[16],forcedModes:[32],jsonErrors:[32],codeErrors:[32]}]);function h(){"undefined"!=typeof customElements&&["fk-rules-editor","fk-code-editor"].forEach((r=>{switch(r){case"fk-rules-editor":customElements.get(e(r))||customElements.define(e(r),v);break;case"fk-code-editor":customElements.get(e(r))||a()}}))}h();export{v as F,h as d}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as s,p as t,H as l,c as o,h as e}from"./p-8ICOcloT.js";import{o as r,q as i,t as a,b as c}from"./p-
|
|
1
|
+
import{t as s,p as t,H as l,c as o,h as e}from"./p-8ICOcloT.js";import{o as r,q as i,t as a,b as c}from"./p-JQ8Ve1UU.js";const n=(s,t)=>{const[l,o,e]=s.split("-").map(Number);return new Date(l,o-1,e).toLocaleDateString(t,{weekday:"short",day:"numeric",month:"short"})},k=s=>s.slice(11,16),d=t(class extends l{constructor(s){super(),!1!==s&&this.__registerHost(),this.slotPick=o(this,"slotPick"),this.rules={},this.disabled=!1,this.readOnly=!1,this.slots=[],this.day="",this.loading=!1,this.failed=!1}componentWillLoad(){return this.day=this.value?this.value.start.slice(0,10):"",this.load()}reload(){return this.load()}onValueChange(s){s&&(this.day=s.start.slice(0,10))}get locked(){return this.disabled||this.readOnly}async load(){if(this.failed=!1,this.slotsUrl){this.loading=!0;try{const s=await fetch(this.slotsUrl,{headers:{Accept:"application/json"}});if(!s.ok)throw new Error(String(s.status));this.slots=i(await s.json())}catch(s){this.failed=!0,this.slots=[]}finally{this.loading=!1}}else this.slots=r(this.rules)}pick(s){this.locked||this.slotPick.emit({id:s.id,start:s.start,end:s.end})}render(){var s;const t=a(this.slots),l=this.value,o=null!==(s=t.find((s=>s.day===this.day)))&&void 0!==s?s:t[0];return this.locked?e("div",{class:"fk-slots fk-slots--locked"},l?e("span",{class:"fk-slots__picked"},n(l.start.slice(0,10),this.locale)," · ",k(l.start),"–",k(l.end)):e("span",{class:"fk-slots__empty"},c("slots.none"))):e("div",{class:"fk-slots"},this.loading?e("span",{class:"fk-slots__empty"},c("slots.loading")):null,this.failed?e("span",{class:"fk-slots__empty"},c("slots.unavailable")):null,this.loading||this.failed||0!==t.length?null:e("span",{class:"fk-slots__empty"},c("slots.empty")),t.length?e("div",{class:"fk-slots__days",role:"tablist"},t.map((s=>e("button",{type:"button",role:"tab","aria-selected":s.day===(null==o?void 0:o.day)?"true":"false",class:{"fk-slots__day":!0,"fk-slots__day--active":s.day===(null==o?void 0:o.day)},onClick:()=>{this.day=s.day}},n(s.day,this.locale))))):null,o?e("div",{class:"fk-slots__times"},o.slots.map((s=>e("button",{type:"button",class:{"fk-slots__time":!0,"fk-slots__time--picked":(null==l?void 0:l.id)===s.id},"aria-pressed":(null==l?void 0:l.id)===s.id?"true":"false",onClick:()=>this.pick(s)},k(s.start),void 0!==s.remaining?e("small",null," · ",s.remaining):null)))):null,l?e("p",{class:"fk-slots__picked"},c("slots.picked")," ",n(l.start.slice(0,10),this.locale)," · ",k(l.start),"–",k(l.end),e("button",{type:"button",class:"fk-slots__clear",onClick:()=>this.slotPick.emit(void 0)},c("geo.clear"))):null)}static get watchers(){return{slotsUrl:[{reload:0}],rules:[{reload:0}],value:[{onValueChange:0}]}}static get style(){return".sc-fk-slot-picker-h{display:block}.fk-slots__days.sc-fk-slot-picker{display:flex;gap:0.375rem;overflow-x:auto;padding-bottom:0.25rem}.fk-slots__day.sc-fk-slot-picker,.fk-slots__time.sc-fk-slot-picker{border:1px solid var(--fk-color-border, #d4d4d8);border-radius:var(--fk-radius, 0.375rem);background:transparent;color:inherit;font:inherit;font-size:0.8125rem;padding:0.375rem 0.625rem;cursor:pointer;white-space:nowrap}.fk-slots__day--active.sc-fk-slot-picker,.fk-slots__time--picked.sc-fk-slot-picker{border-color:var(--fk-color-primary, #16a34a);background:var(--fk-color-primary, #16a34a);color:#fff}.fk-slots__times.sc-fk-slot-picker{display:flex;flex-wrap:wrap;gap:0.375rem;margin-top:0.5rem}.fk-slots__time.sc-fk-slot-picker small.sc-fk-slot-picker{opacity:0.7}.fk-slots__picked.sc-fk-slot-picker,.fk-slots__empty.sc-fk-slot-picker{display:block;margin:0.5rem 0 0;font-size:0.8125rem}.fk-slots__empty.sc-fk-slot-picker{color:var(--fk-color-muted, #71717a)}.fk-slots__clear.sc-fk-slot-picker{margin-left:0.5rem;border:0;background:transparent;color:var(--fk-color-muted, #71717a);font:inherit;font-size:0.75rem;text-decoration:underline;cursor:pointer}"}},[2,"fk-slot-picker",{value:[16],slotsUrl:[1,"slots-url"],rules:[16],locale:[1],disabled:[4],readOnly:[4,"read-only"],slots:[32],day:[32],loading:[32],failed:[32]},void 0,{slotsUrl:[{reload:0}],rules:[{reload:0}],value:[{onValueChange:0}]}]);function f(){"undefined"!=typeof customElements&&["fk-slot-picker"].forEach((t=>{"fk-slot-picker"===t&&(customElements.get(s(t))||customElements.define(s(t),d))}))}f();export{d as F,f as d}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as r,p as i,H as t,c as o,h as e}from"./p-8ICOcloT.js";import{v as s,b as a,f as d}from"./p-
|
|
1
|
+
import{t as r,p as i,H as t,c as o,h as e}from"./p-8ICOcloT.js";import{v as s,b as a,f as d}from"./p-JQ8Ve1UU.js";import{d as n}from"./p-BPQcQaPo.js";import{d as c}from"./p-CIgvEKbO.js";import{d as l}from"./p-gKtzV7rX.js";import{d as f}from"./p-Da741snY.js";const h=i(class extends t{constructor(r){super(),!1!==r&&this.__registerHost(),this.gridValueChange=o(this,"gridValueChange"),this.brickReviewChange=o(this,"brickReviewChange"),this.disabled=!1,this.readOnly=!1,this.reviewable=!1,this.touched={},this.addRow=r=>{r.preventDefault(),this.gridValueChange.emit([...this.rows(),{}])}}gridKey(){var r,i;return null!==(i=null===(r=this.spec.configs)||void 0===r?void 0:r.key)&&void 0!==i?i:"grid"}rowScoped(r,i){if(!r)return;const t=`${this.gridKey()}[${i}].`,o={};for(const[i,e]of Object.entries(r))i.startsWith(t)&&(o[i.slice(t.length)]=e);return o}rowEditableKeys(r){if(void 0===this.editableKeys||this.editableKeys.includes(this.gridKey()))return;const i=`${this.gridKey()}[${r}].`;return this.editableKeys.filter((r=>r.startsWith(i))).map((r=>r.slice(i.length)))}rowsLocked(){return void 0!==this.editableKeys&&!this.editableKeys.includes(this.gridKey())}handleRowReviewChange(r){if(r.target===this.host)return;r.stopPropagation();const i=r.target.closest("[data-grid-row]"),t=null==i?void 0:i.getAttribute("data-grid-row");null!=t&&this.brickReviewChange.emit({key:`${this.gridKey()}[${t}].${r.detail.key}`,annotation:r.detail.annotation})}rows(){return Array.isArray(this.value)?this.value:[]}rowSpec(){var r,i;return(null===(r=this.rowSpecCache)||void 0===r?void 0:r.source)!==this.spec&&(this.rowSpecCache={source:this.spec,rowSpec:{type:"panel",id:"grid-row",name:"Row",configs:{key:"row"},children:null!==(i=this.spec.children)&&void 0!==i?i:[]}}),this.rowSpecCache.rowSpec}rowErrors(r){const i=Object.fromEntries(Object.entries(r).filter((([,r])=>""!==r&&null!=r)));return s(this.rowSpec(),i,this.locale).errors}visibleRowErrors(r){var i,t;const o=null!==(i=this.rows()[r])&&void 0!==i?i:{},e=null!==(t=this.touched[r])&&void 0!==t?t:{},s={};for(const[r,i]of Object.entries(this.rowErrors(o)))e[r]&&(s[r]=i);return s}handleRowChange(r){var i,t;r.stopPropagation();const o=r.target.closest("[data-grid-row]"),e=Number(null!==(i=null==o?void 0:o.getAttribute("data-grid-row"))&&void 0!==i?i:-1);if(e<0)return;const s=Object.assign({},null!==(t=this.touched[e])&&void 0!==t?t:{});for(const i of Object.keys(r.detail))s[i]=!0;this.touched=Object.assign(Object.assign({},this.touched),{[e]:s});const a=this.rows().map(((i,t)=>t===e?Object.assign(Object.assign({},i),r.detail):i));this.gridValueChange.emit(a)}async validateRows(){var r,i;const t=this.rows(),o=null!==(i=null===(r=this.spec.configs)||void 0===r?void 0:r.key)&&void 0!==i?i:"grid",e={},s={};return t.forEach(((r,i)=>{var t,a;const d={};for(const r of null!==(t=this.spec.children)&&void 0!==t?t:[])(null===(a=r.configs)||void 0===a?void 0:a.key)&&(d[r.configs.key]=!0);e[i]=d;for(const[t,e]of Object.entries(this.rowErrors(r)))s[`${o}[${i}].${t}`]=e})),this.touched=e,{valid:0===Object.keys(s).length,errors:s}}moveRow(r,i){const t=[...this.rows()],o=r+i;if(o<0||o>=t.length)return;const[e]=t.splice(r,1);t.splice(o,0,e);const s=Object.assign({},this.touched),a=s[r];s[r]=s[o],s[o]=a,this.touched=s,this.gridValueChange.emit(t)}removeRow(r){const i=this.rows().filter(((i,t)=>t!==r)),t={};for(const[i,o]of Object.entries(this.touched)){const e=Number(i);e<r?t[e]=o:e>r&&(t[e-1]=o)}this.touched=t,this.gridValueChange.emit(i.length?i:void 0)}contextMap(){var r;return Object.fromEntries(Object.entries(null!==(r=this.dataMap)&&void 0!==r?r:{}).filter((([r])=>r.startsWith("_"))))}render(){var r;const i=null!==(r=this.spec.children)&&void 0!==r?r:[],t=this.rows();return e("div",{key:"cd1bc1f56eb15927e4ac7562764e95528b1e054c",class:"fk-grid"},0===t.length?e("p",{class:"fk-grid__empty"},a("grid.empty")):null,t.map(((r,o)=>e("div",{class:"fk-grid__row","data-grid-row":o,key:o},e("div",{class:"fk-grid__cells"},i.map(((i,t)=>e("fk-brick-render",{brickSpec:i,data:r,dataMap:Object.assign(Object.assign({},this.contextMap()),r),errors:this.visibleRowErrors(o),annotations:this.rowScoped(this.annotations,o),notes:this.rowScoped(this.notes,o),reviewable:this.reviewable,editableKeys:this.rowEditableKeys(o),locale:this.locale,readOnly:this.readOnly,disabled:this.disabled&&!this.readOnly,path:`grid.${o}.${t}`,utils:this.utils})))),e("div",{class:"fk-grid__row-actions"},e("button",{type:"button",class:"fk-grid__move",title:d("grid.moveUp","Move row up"),"aria-label":d("grid.moveUp","Move row up"),disabled:this.disabled||this.rowsLocked()||0===o,onClick:r=>{r.preventDefault(),this.moveRow(o,-1)}},"↑"),e("button",{type:"button",class:"fk-grid__move",title:d("grid.moveDown","Move row down"),"aria-label":d("grid.moveDown","Move row down"),disabled:this.disabled||this.rowsLocked()||o===t.length-1,onClick:r=>{r.preventDefault(),this.moveRow(o,1)}},"↓"),e("button",{type:"button",class:"fk-grid__remove",title:a("grid.removeRow"),"aria-label":a("grid.removeRow"),disabled:this.disabled||this.rowsLocked(),onClick:r=>{r.preventDefault(),this.removeRow(o)}},"✕"))))),e("button",{key:"0d70026f45faffb24ba344fe773852ce0cb74121",type:"button",class:"fk-grid__add",disabled:this.disabled||this.rowsLocked(),onClick:this.addRow},a("grid.addRow")))}get host(){return this}static get style(){return".sc-fk-data-grid-h{display:block}.fk-grid.sc-fk-data-grid{display:flex;flex-direction:column;gap:var(--fk-spacing)}.fk-grid__empty.sc-fk-data-grid{margin:0;padding:var(--fk-spacing);border:1px dashed var(--fk-color-border);border-radius:var(--fk-radius);font-size:0.85rem;color:var(--fk-color-muted);text-align:center}.fk-grid__row.sc-fk-data-grid{display:flex;align-items:flex-start;gap:var(--fk-spacing);padding:var(--fk-spacing);border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:color-mix(in srgb, var(--fk-color-surface) 60%, transparent)}.fk-grid__cells.sc-fk-data-grid{display:grid;flex:1;grid-template-columns:repeat(auto-fit, minmax(min(var(--fk-grid-cell-min, 10rem), 100%), 1fr));align-items:start;gap:var(--fk-spacing);min-width:0}.fk-grid__cells.sc-fk-data-grid>*.sc-fk-data-grid{min-width:0}.fk-grid__remove.sc-fk-data-grid{border:none;background:transparent;color:var(--fk-color-muted);font-size:0.8rem;cursor:pointer;padding:4px 6px;min-width:24px;min-height:24px;border-radius:calc(var(--fk-radius) / 2)}.fk-grid__remove.sc-fk-data-grid:hover:not(:disabled){color:var(--fk-color-danger);background:color-mix(in srgb, var(--fk-color-danger) 10%, transparent)}.fk-grid__add.sc-fk-data-grid{align-self:flex-start;font:inherit;font-size:0.8rem;font-weight:600;padding:calc(var(--fk-spacing) / 1.5) var(--fk-spacing);border:1px dashed var(--fk-color-border);border-radius:var(--fk-radius);background:transparent;color:var(--fk-color-muted);cursor:pointer}.fk-grid__add.sc-fk-data-grid:hover:not(:disabled){border-color:var(--fk-color-primary);color:var(--fk-color-primary)}.fk-grid__row-actions.sc-fk-data-grid{display:flex;flex-direction:column;gap:2px;flex-shrink:0}.fk-grid__move.sc-fk-data-grid{border:none;background:transparent;color:var(--fk-color-muted);font-size:0.8rem;cursor:pointer;padding:2px 6px;min-width:24px;min-height:24px;border-radius:calc(var(--fk-radius) / 2)}.fk-grid__move.sc-fk-data-grid:hover:not(:disabled){color:var(--fk-color-primary);background:color-mix(in srgb, var(--fk-color-primary) 10%, transparent)}.fk-grid__move.sc-fk-data-grid:disabled{opacity:0.3;cursor:default}.fk-grid__move.sc-fk-data-grid:focus-visible,.fk-grid__remove.sc-fk-data-grid:focus-visible{outline:2px solid color-mix(in srgb, var(--fk-color-primary) 55%, transparent);outline-offset:1px}"}},[2,"fk-data-grid",{spec:[16],value:[16],disabled:[4],readOnly:[4,"read-only"],locale:[1],utils:[16],annotations:[16],notes:[16],reviewable:[4],editableKeys:[16],dataMap:[16],touched:[32],validateRows:[64]},[[0,"brickReviewChange","handleRowReviewChange"],[0,"brickDataChange","handleRowChange"]]]);function g(){"undefined"!=typeof customElements&&["fk-data-grid","fk-brick-actions","fk-brick-not-found","fk-brick-render","fk-drop-area"].forEach((i=>{switch(i){case"fk-data-grid":customElements.get(r(i))||customElements.define(r(i),h);break;case"fk-brick-actions":customElements.get(r(i))||n();break;case"fk-brick-not-found":customElements.get(r(i))||c();break;case"fk-brick-render":customElements.get(r(i))||l();break;case"fk-drop-area":customElements.get(r(i))||f()}}))}g();export{h as F,g as d}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e,p as t,H as s,c as l,h as a}from"./p-8ICOcloT.js";import{s as i,b as r,j as o,f as n}from"./p-bmymYwS6.js";import{d as p}from"./p-BE5v8BN3.js";import{d as c}from"./p-8rlTOusP.js";const h=t(class extends s{constructor(e){super(),!1!==e&&this.__registerHost(),this.brickConfigsChange=l(this,"brickConfigsChange"),this.brickValidationsChange=l(this,"brickValidationsChange"),this.brickStylesChange=l(this,"brickStylesChange"),this.fields=[],this.locales=[],this.activeTab="config",this.newStyleKey="",this.catalogs=[],this.catalogsRequested=!1}loadCatalogs(){var e,t;this.catalogsRequested=!0;const s=null===(t=null===(e=i.optionSourceService)||void 0===e?void 0:e.listCatalogs)||void 0===t?void 0:t.call(e);s&&s.then((e=>this.catalogs=e)).catch((()=>{}))}onBrickChange(){this.availableTabs().some((e=>e.id===this.activeTab))||(this.activeTab="config")}availableTabs(){const e=[{id:"config",label:r("panel.tab.config")}];return"input"===this.brick.type&&e.push({id:"validation",label:r("panel.tab.validation")}),e.push({id:"styles",label:r("panel.tab.styles")},{id:"rules",label:r("panel.tab.rules")}),e}localized(e,t){var s;if(this.locales.length<=1)return t||void 0;const l=o(e)?Object.assign({},e):{};return"string"==typeof e&&e&&!o(e)&&(l[this.locales[0]]=e),l[null!==(s=this.editLocale)&&void 0!==s?s:this.locales[0]]=t,l}readLocalized(e){var t,s,l;return o(e)?null!==(s=e[null!==(t=this.editLocale)&&void 0!==t?t:this.locales[0]])&&void 0!==s?s:"":null!==(l=e)&&void 0!==l?l:""}writeTextConfig(e,t){var s;this.emitConfigs({[e]:this.localized(null===(s=this.brick.configs)||void 0===s?void 0:s[e],t)})}emitConfigs(e){this.path&&this.brickConfigsChange.emit({configs:e,path:this.path})}emitValidations(e){this.path&&this.brickValidationsChange.emit({validations:e,path:this.path})}emitStyles(e){this.path&&this.brickStylesChange.emit({styles:e,path:this.path})}validationOf(e){var t;return null===(t=this.brick.validations)||void 0===t?void 0:t.find((t=>t.validator===e))}setValidation(e,t,s={}){var l;const a=this.validationOf(e),i=(null!==(l=this.brick.validations)&&void 0!==l?l:[]).filter((t=>t.validator!==e));this.emitValidations(t?[...i,Object.assign(Object.assign(Object.assign({},a),{validator:e}),s)]:i)}addStyle(e){const t=this.newStyleKey.trim();t&&(this.emitStyles({[t]:e}),this.newStyleKey="")}textField(e,t,s){var l;return a("label",{class:"fk-props__field"},a("span",{class:"fk-props__label"},e),a("input",{class:"fk-props__input",type:"text",value:null!==(l=t)&&void 0!==l?l:"",onChange:e=>s(e.target.value)}))}optionsFields(){var e,t,s,l;const i=this.brick.configs;if(!i||!("options"in i)&&!("optionsSource"in i))return[];const o="optionsSource"in i,n=o&&null!==(e=i.optionsSource)&&void 0!==e?e:"static",p=o?[a("label",{class:"fk-props__field"},a("span",{class:"fk-props__label"},r("panel.optionsSource")),a("select",{class:"fk-props__input",onChange:e=>this.emitConfigs({optionsSource:e.target.value})},["static","dataMap","remote","js","catalog"].map((e=>a("option",{value:e,selected:e===n},e)))))]:[];return"static"===n&&p.push(a("label",{class:"fk-props__field"},a("span",{class:"fk-props__label"},r("panel.options")),a("textarea",{class:"fk-props__input fk-props__input--textarea",onChange:e=>this.writeTextConfig("options",e.target.value)},this.readLocalized(i.options)))),"dataMap"===n&&p.push(this.textField(r("panel.dataKey"),i.optionsPath,(e=>this.emitConfigs({optionsPath:e})))),"remote"===n&&p.push(this.textField(r("panel.url"),i.optionsUrl,(e=>this.emitConfigs({optionsUrl:e}))),this.textField(r("panel.responsePath"),i.optionsPath,(e=>this.emitConfigs({optionsPath:e||void 0}))),a("label",{class:"fk-props__field"},a("span",{class:"fk-props__label"},r("panel.headers")),a("textarea",{class:"fk-props__input fk-props__input--textarea",placeholder:"Authorization: Bearer {token}",onChange:e=>this.emitConfigs({optionsHeaders:e.target.value||void 0})},null!==(t=i.optionsHeaders)&&void 0!==t?t:"")),this.textField(r("panel.searchParam"),i.searchParam,(e=>this.emitConfigs({searchParam:e||void 0})))),"js"===n&&p.push(a("label",{class:"fk-props__field"},a("span",{class:"fk-props__label"},"Code"),a("fk-code-editor",{completions:this.fields,value:null!==(s=i.optionsCode)&&void 0!==s?s:"",placeholder:"return dataMap.country === 'BJ' ? ['Cotonou'] : ['Paris'];",onCodeChange:e=>this.emitConfigs({optionsCode:e.detail})}))),"catalog"===n&&(this.catalogsRequested||this.loadCatalogs(),p.push(a("label",{class:"fk-props__field"},a("span",{class:"fk-props__label"},r("panel.optionsRef")),a("input",{class:"fk-props__input",type:"text",list:"fk-option-catalogs",value:null!==(l=i.optionsRef)&&void 0!==l?l:"",onChange:e=>this.emitConfigs({optionsRef:e.target.value})}),a("datalist",{id:"fk-option-catalogs"},this.catalogs.map((e=>{var t;return a("option",{value:e.ref},(null===(t=e.filters)||void 0===t?void 0:t.length)?`${e.label} (${e.filters.map((e=>`?${e}=`)).join(", ")})`:e.label)})))))),"remote"!==n&&"js"!==n&&"catalog"!==n||p.push(this.textField(r("panel.labelKey"),i.labelKey,(e=>this.emitConfigs({labelKey:e}))),this.textField(r("panel.valueKey"),i.valueKey,(e=>this.emitConfigs({valueKey:e})))),p}renderConfigTab(){const e=this.brick.configs,t="input"===this.brick.type;return a("section",{class:"fk-props__section"},this.textField(r("panel.key"),null==e?void 0:e.key,(e=>this.emitConfigs({key:e}))),this.textField(r("panel.label"),this.readLocalized(null==e?void 0:e.label),(e=>this.writeTextConfig("label",e))),e?this.textField(n("panel.description","Help text under the field"),this.readLocalized(e.description),(e=>this.writeTextConfig("description",e))):null,t?[this.textField(r("panel.placeholder"),this.readLocalized(null==e?void 0:e.placeholder),(e=>this.writeTextConfig("placeholder",e))),this.textField(r("panel.prefix"),null==e?void 0:e.prefix,(e=>this.emitConfigs({prefix:e||void 0}))),this.textField(r("panel.suffix"),null==e?void 0:e.suffix,(e=>this.emitConfigs({suffix:e||void 0})))]:null,e&&"specRef"in e?this.textField(n("panel.specRef","Referenced form (specRef)"),e.specRef,(e=>this.emitConfigs({specRef:e}))):null,e&&"mask"in e?this.textField(n("panel.mask","Input mask (9=digit, a=letter, *=any)"),e.mask,(e=>this.emitConfigs({mask:e}))):null,e&&"searchUrl"in e?[this.textField(n("panel.searchUrl","Geocoding URL ({q} = query)"),e.searchUrl,(e=>this.emitConfigs({searchUrl:e}))),this.textField(n("panel.countryCodes","Country codes (bj, tg)"),e.countryCodes,(e=>this.emitConfigs({countryCodes:e})))]:null,e&&"layerUrl"in e?[this.textField(n("panel.layerUrl","Reference layer URL (GeoJSON)"),e.layerUrl,(e=>this.emitConfigs({layerUrl:e}))),this.textField(n("panel.codeProperty","Code property"),e.codeProperty,(e=>this.emitConfigs({codeProperty:e||"code"}))),this.textField(n("panel.nameProperty","Name property"),e.nameProperty,(e=>this.emitConfigs({nameProperty:e||"name"})))]:null,e&&"idFormat"in e?this.textField(n("panel.idFormat","Identifier format (fr-nir, bj-npi, digits-10…)"),e.idFormat,(e=>this.emitConfigs({idFormat:e}))):null,e&&"currencies"in e?[this.textField(n("panel.currencies","Currencies offered (XOF, EUR, USD)"),e.currencies,(e=>this.emitConfigs({currencies:e}))),this.textField(n("panel.currency","Default currency"),e.currency,(e=>this.emitConfigs({currency:e.toUpperCase()})))]:null,e&&"slotsUrl"in e?[this.textField(n("panel.slotsUrl","Slots URL (empty = opening rules)"),e.slotsUrl,(e=>this.emitConfigs({slotsUrl:e}))),this.textField(n("panel.slotDays","Open days (1 = Monday … 7 = Sunday)"),e.days,(e=>this.emitConfigs({days:e}))),this.textField(n("panel.slotFrom","Opens at"),e.from,(e=>this.emitConfigs({from:e}))),this.textField(n("panel.slotTo","Closes at"),e.to,(e=>this.emitConfigs({to:e}))),this.textField(n("panel.slotDuration","Slot length (minutes)"),e.duration,(e=>this.emitConfigs({duration:""===e?void 0:Number(e)}))),this.textField(n("panel.slotHorizon","Bookable days ahead"),e.horizonDays,(e=>this.emitConfigs({horizonDays:""===e?void 0:Number(e)}))),this.textField(n("panel.slotNotice","Notice (hours)"),e.noticeHours,(e=>this.emitConfigs({noticeHours:""===e?void 0:Number(e)}))),this.textField(n("panel.slotExclude","Closed dates (YYYY-MM-DD, comma-separated)"),e.exclude,(e=>this.emitConfigs({exclude:e})))]:null,e&&"family"in e?[this.textField(n("panel.family","Measure family (length, area, mass, volume, duration)"),e.family,(e=>this.emitConfigs({family:e}))),this.textField(n("panel.units","Units offered (ids, comma-separated; empty = all)"),e.units,(e=>this.emitConfigs({units:e}))),this.textField(n("panel.unit","Default unit"),e.unit,(e=>this.emitConfigs({unit:e})))]:null,e&&"plateFormat"in e?this.textField(n("panel.plateFormat","Plate format (fr, bj, ci, sn, generic)"),e.plateFormat,(e=>this.emitConfigs({plateFormat:e}))):null,e&&"registryFormat"in e?this.textField(n("panel.registryFormat","Registration format (ohada-rccm, fr-rcs, generic)"),e.registryFormat,(e=>this.emitConfigs({registryFormat:e}))):null,e&&"readUrl"in e?[this.textField(n("panel.readUrl","Reader URL (empty = host default)"),e.readUrl,(e=>this.emitConfigs({readUrl:e}))),a("label",{class:"fk-props__field"},a("span",{class:"fk-props__label"},n("panel.documentFields","Fields to read (key|Label per line)")),a("textarea",{class:"fk-props__input fk-props__input--textarea",onChange:e=>this.emitConfigs({fields:e.target.value})},"string"==typeof e.fields?e.fields:"")),a("label",{class:"fk-props__field"},a("span",{class:"fk-props__label"},n("panel.documentFills","Fill the form (field=formKey per line)")),a("textarea",{class:"fk-props__input fk-props__input--textarea",onChange:e=>this.emitConfigs({fills:e.target.value})},"string"==typeof e.fills?e.fills:"")),this.textField(n("panel.documentLanguage","Document language (fr, en…)"),e.language,(e=>this.emitConfigs({language:e}))),this.textField(n("panel.accept","Accepted files"),e.accept,(e=>this.emitConfigs({accept:e}))),this.textField(n("panel.uploadUrl","Upload URL"),e.uploadUrl,(e=>this.emitConfigs({uploadUrl:e})))]:null,e&&"tileUrl"in e?[this.textField(n("panel.center","Initial center (lat, lng)"),e.center,(e=>this.emitConfigs({center:e}))),this.textField(n("panel.zoom","Initial zoom"),e.zoom,(e=>this.emitConfigs({zoom:""===e?void 0:Number(e)}))),this.textField(n("panel.height","Height (px)"),e.height,(e=>this.emitConfigs({height:""===e?void 0:Number(e)}))),this.textField(n("panel.tileUrl","Tile URL"),e.tileUrl,(e=>this.emitConfigs({tileUrl:e}))),"shape"in e?this.textField(n("panel.shape","Shape (polygon or line)"),e.shape,(e=>this.emitConfigs({shape:"line"===e?"line":"polygon"}))):null]:null,e&&"accept"in e?this.textField(n("panel.accept","Accepted file types"),e.accept,(e=>this.emitConfigs({accept:e}))):null,e&&"uploadUrl"in e?this.textField(n("panel.uploadUrl","Upload URL"),e.uploadUrl,(e=>this.emitConfigs({uploadUrl:e}))):null,this.optionsFields(),Object.entries(null!=e?e:{}).filter((([,e])=>"boolean"==typeof e)).map((([e,t])=>a("label",{class:"fk-props__field fk-props__field--inline",key:e},a("input",{type:"checkbox",checked:!0===t,onChange:t=>this.emitConfigs({[e]:t.target.checked})}),a("span",{class:"fk-props__label"},n(`panel.cfg.${e}`,e))))),e&&"content"in e?a("label",{class:"fk-props__field"},a("span",{class:"fk-props__label"},r("panel.content")),a("textarea",{class:"fk-props__input fk-props__input--textarea",onChange:e=>this.writeTextConfig("content",e.target.value)},this.readLocalized(e.content))):null)}validationRow(e,t,s){const l=this.validationOf(e);return a("div",{class:"fk-props__vrule"},a("label",{class:"fk-props__field fk-props__field--inline"},a("input",{type:"checkbox",checked:!!l,onChange:t=>this.setValidation(e,t.target.checked)}),a("span",{class:"fk-props__label"},t)),l&&s?a("input",{class:"fk-props__input",type:s,placeholder:"number"===s?"value":"regex",value:null==l.value?"":String(l.value),onChange:t=>{const l=t.target.value;this.setValidation(e,!0,{value:"number"===s?""===l?void 0:Number(l):l||void 0})}}):null,l?this.textField(r("panel.errorMessage"),this.readLocalized(l.message),(t=>this.setValidation(e,!0,{message:this.localized(l.message,t)}))):null)}renderValidationTab(){var e;const t=this.brick.dataType,s=this.validationOf("custom");return a("section",{class:"fk-props__section"},this.validationRow("required",r("panel.required")),"string"===t?[this.validationRow("minLength",r("panel.minLength"),"number"),this.validationRow("maxLength",r("panel.maxLength"),"number"),this.validationRow("pattern",r("panel.pattern"),"text"),this.validationRow("email",r("panel.emailFormat")),this.validationRow("url",r("panel.urlFormat"))]:null,"number"===t?[this.validationRow("min",r("panel.min"),"number"),this.validationRow("max",r("panel.max"),"number")]:null,"array"===t?[this.validationRow("minItems",r("panel.minItems"),"number"),this.validationRow("maxItems",r("panel.maxItems"),"number")]:null,a("div",{class:"fk-props__vrule"},a("label",{class:"fk-props__field fk-props__field--inline"},a("input",{type:"checkbox",checked:!!s,onChange:e=>{var t;return this.setValidation("custom",e.target.checked,{customValidator:null!==(t=null==s?void 0:s.customValidator)&&void 0!==t?t:"return true;"})}}),a("span",{class:"fk-props__label"},r("panel.custom"))),s?a("fk-code-editor",{completions:this.fields,value:null!==(e=s.customValidator)&&void 0!==e?e:"",placeholder:'return value?.startsWith("BJ-") ? true : "Must start with BJ-";',onCodeChange:e=>this.setValidation("custom",!0,{customValidator:e.detail})}):null,s?this.textField(r("panel.fallbackMessage"),this.readLocalized(s.message),(e=>this.setValidation("custom",!0,{message:this.localized(s.message,e)}))):null))}renderStylesTab(){var e;return a("section",{class:"fk-props__section"},Object.entries(null!==(e=this.brick.styles)&&void 0!==e?e:{}).map((([e,t])=>a("div",{class:"fk-props__style-row",key:e},a("span",{class:"fk-props__style-key"},e),a("input",{class:"fk-props__input fk-props__input--grow",type:"text",value:String(null!=t?t:""),onChange:t=>this.emitStyles({[e]:t.target.value})}),a("button",{type:"button",class:"fk-props__remove",title:"Remove style",onClick:()=>this.emitStyles({[e]:void 0})},"✕")))),a("div",{class:"fk-props__style-row"},a("input",{class:"fk-props__input",type:"text",placeholder:r("panel.styleProperty"),value:this.newStyleKey,onInput:e=>this.newStyleKey=e.target.value}),a("input",{class:"fk-props__input fk-props__input--grow",type:"text",placeholder:r("panel.styleValue"),onChange:e=>{const t=e.target;this.addStyle(t.value),t.value=""}})))}render(){return a("div",{key:"1801828d2b7854755eb52dd9feadb1f82d52fec5",class:"fk-props"},a("header",{key:"86919fae610ef2308936dda5023a4efe7c66bc9a",class:"fk-props__header"},a("span",{key:"134f14ce0c3a92b1027d103879ea73d914ebb4e4",class:"fk-props__type"},this.brick.type),a("h4",{key:"1525b0b52ff237e892c2a28aaa53ae6546d17f0c",class:"fk-props__title"},n(`brick.${this.brick.id}.name`,this.brick.name))),a("div",{key:"b0d78b3f9a69feea4ebba973361f703f1bc2a035",class:"fk-props__tabs"},this.availableTabs().map((e=>a("button",{key:e.id,type:"button",class:{"fk-props__tab":!0,"fk-props__tab--active":this.activeTab===e.id},onClick:()=>this.activeTab=e.id},e.label)))),"config"===this.activeTab?this.renderConfigTab():null,"validation"===this.activeTab?this.renderValidationTab():null,"styles"===this.activeTab?this.renderStylesTab():null,"rules"===this.activeTab?a("section",{class:"fk-props__section"},a("fk-rules-editor",{brick:this.brick,path:this.path,fields:this.fields})):null)}static get watchers(){return{brick:[{onBrickChange:0}]}}static get style(){return".sc-fk-property-panel-h{display:block}.fk-props.sc-fk-property-panel{display:flex;flex-direction:column;gap:calc(var(--fk-spacing) * 1.5)}.fk-props__header.sc-fk-property-panel{display:flex;flex-direction:column;gap:2px}.fk-props__type.sc-fk-property-panel{font-size:0.65rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--fk-color-primary)}.fk-props__title.sc-fk-property-panel{margin:0;font-size:0.95rem;color:var(--fk-color-text)}.fk-props__section.sc-fk-property-panel{display:flex;flex-direction:column;gap:var(--fk-spacing);padding-top:var(--fk-spacing)}.fk-props__tabs.sc-fk-property-panel{display:flex;gap:2px;border-bottom:1px solid var(--fk-color-border)}.fk-props__tab.sc-fk-property-panel{font:inherit;font-size:0.72rem;font-weight:600;padding:5px 9px;border:none;border-bottom:2px solid transparent;border-radius:0;background:transparent;color:var(--fk-color-muted);text-transform:none;letter-spacing:normal;cursor:pointer}.fk-props__tab.sc-fk-property-panel:hover{color:var(--fk-color-text)}.fk-props__tab--active.sc-fk-property-panel{color:var(--fk-color-primary);border-bottom-color:var(--fk-color-primary)}.fk-props__section-title.sc-fk-property-panel{margin:0;font-size:0.7rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--fk-color-muted)}.fk-props__field.sc-fk-property-panel{display:flex;flex-direction:column;gap:4px;font-style:normal;text-decoration:none}.fk-props__field--inline.sc-fk-property-panel{flex-direction:row;align-items:center;gap:8px}.fk-props__label.sc-fk-property-panel{font-size:0.75rem;font-weight:600;color:var(--fk-color-muted);font-style:normal;text-decoration:none}.fk-props__input.sc-fk-property-panel{font:inherit;font-size:0.85rem;padding:6px 8px;border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface);color:var(--fk-color-text)}.fk-props__input.sc-fk-property-panel:focus{outline:none;border-color:var(--fk-color-primary);box-shadow:0 0 0 2px color-mix(in srgb, var(--fk-color-primary) 20%, transparent)}.fk-props__input--textarea.sc-fk-property-panel{min-height:72px;resize:vertical}.fk-props__vrule.sc-fk-property-panel{display:flex;flex-direction:column;gap:6px;padding:calc(var(--fk-spacing) / 1.5);border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 1.5)}.fk-props__style-row.sc-fk-property-panel{display:flex;align-items:center;gap:6px}.fk-props__style-key.sc-fk-property-panel{font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-size:0.75rem;color:var(--fk-color-text);min-width:72px}.fk-props__input--grow.sc-fk-property-panel{flex:1;min-width:0}.fk-props__remove.sc-fk-property-panel{border:none;background:transparent;color:var(--fk-color-muted);font-size:0.75rem;cursor:pointer;padding:2px 4px;border-radius:calc(var(--fk-radius) / 2)}.fk-props__remove.sc-fk-property-panel:hover{color:var(--fk-color-danger);background:color-mix(in srgb, var(--fk-color-danger) 10%, transparent)}"}},[2,"fk-property-panel",{brick:[16],path:[1],fields:[16],locales:[16],locale:[1],editLocale:[1,"edit-locale"],activeTab:[32],newStyleKey:[32],catalogs:[32]},void 0,{brick:[{onBrickChange:0}]}]);function f(){"undefined"!=typeof customElements&&["fk-property-panel","fk-code-editor","fk-rules-editor"].forEach((t=>{switch(t){case"fk-property-panel":customElements.get(e(t))||customElements.define(e(t),h);break;case"fk-code-editor":customElements.get(e(t))||p();break;case"fk-rules-editor":customElements.get(e(t))||c()}}))}f();export{h as F,f as d}
|
|
1
|
+
import{t as e,p as t,H as s,c as l,h as a}from"./p-8ICOcloT.js";import{s as i,b as r,j as o,f as n}from"./p-JQ8Ve1UU.js";import{d as p}from"./p-BE5v8BN3.js";import{d as c}from"./p-CmPkfuLt.js";const h=t(class extends s{constructor(e){super(),!1!==e&&this.__registerHost(),this.brickConfigsChange=l(this,"brickConfigsChange"),this.brickValidationsChange=l(this,"brickValidationsChange"),this.brickStylesChange=l(this,"brickStylesChange"),this.fields=[],this.locales=[],this.activeTab="config",this.newStyleKey="",this.catalogs=[],this.catalogsRequested=!1}loadCatalogs(){var e,t;this.catalogsRequested=!0;const s=null===(t=null===(e=i.optionSourceService)||void 0===e?void 0:e.listCatalogs)||void 0===t?void 0:t.call(e);s&&s.then((e=>this.catalogs=e)).catch((()=>{}))}onBrickChange(){this.availableTabs().some((e=>e.id===this.activeTab))||(this.activeTab="config")}availableTabs(){const e=[{id:"config",label:r("panel.tab.config")}];return"input"===this.brick.type&&e.push({id:"validation",label:r("panel.tab.validation")}),e.push({id:"styles",label:r("panel.tab.styles")},{id:"rules",label:r("panel.tab.rules")}),e}localized(e,t){var s;if(this.locales.length<=1)return t||void 0;const l=o(e)?Object.assign({},e):{};return"string"==typeof e&&e&&!o(e)&&(l[this.locales[0]]=e),l[null!==(s=this.editLocale)&&void 0!==s?s:this.locales[0]]=t,l}readLocalized(e){var t,s,l;return o(e)?null!==(s=e[null!==(t=this.editLocale)&&void 0!==t?t:this.locales[0]])&&void 0!==s?s:"":null!==(l=e)&&void 0!==l?l:""}writeTextConfig(e,t){var s;this.emitConfigs({[e]:this.localized(null===(s=this.brick.configs)||void 0===s?void 0:s[e],t)})}emitConfigs(e){this.path&&this.brickConfigsChange.emit({configs:e,path:this.path})}emitValidations(e){this.path&&this.brickValidationsChange.emit({validations:e,path:this.path})}emitStyles(e){this.path&&this.brickStylesChange.emit({styles:e,path:this.path})}validationOf(e){var t;return null===(t=this.brick.validations)||void 0===t?void 0:t.find((t=>t.validator===e))}setValidation(e,t,s={}){var l;const a=this.validationOf(e),i=(null!==(l=this.brick.validations)&&void 0!==l?l:[]).filter((t=>t.validator!==e));this.emitValidations(t?[...i,Object.assign(Object.assign(Object.assign({},a),{validator:e}),s)]:i)}addStyle(e){const t=this.newStyleKey.trim();t&&(this.emitStyles({[t]:e}),this.newStyleKey="")}textField(e,t,s){var l;return a("label",{class:"fk-props__field"},a("span",{class:"fk-props__label"},e),a("input",{class:"fk-props__input",type:"text",value:null!==(l=t)&&void 0!==l?l:"",onChange:e=>s(e.target.value)}))}optionsFields(){var e,t,s,l;const i=this.brick.configs;if(!i||!("options"in i)&&!("optionsSource"in i))return[];const o="optionsSource"in i,n=o&&null!==(e=i.optionsSource)&&void 0!==e?e:"static",p=o?[a("label",{class:"fk-props__field"},a("span",{class:"fk-props__label"},r("panel.optionsSource")),a("select",{class:"fk-props__input",onChange:e=>this.emitConfigs({optionsSource:e.target.value})},["static","dataMap","remote","js","catalog"].map((e=>a("option",{value:e,selected:e===n},e)))))]:[];return"static"===n&&p.push(a("label",{class:"fk-props__field"},a("span",{class:"fk-props__label"},r("panel.options")),a("textarea",{class:"fk-props__input fk-props__input--textarea",onChange:e=>this.writeTextConfig("options",e.target.value)},this.readLocalized(i.options)))),"dataMap"===n&&p.push(this.textField(r("panel.dataKey"),i.optionsPath,(e=>this.emitConfigs({optionsPath:e})))),"remote"===n&&p.push(this.textField(r("panel.url"),i.optionsUrl,(e=>this.emitConfigs({optionsUrl:e}))),this.textField(r("panel.responsePath"),i.optionsPath,(e=>this.emitConfigs({optionsPath:e||void 0}))),a("label",{class:"fk-props__field"},a("span",{class:"fk-props__label"},r("panel.headers")),a("textarea",{class:"fk-props__input fk-props__input--textarea",placeholder:"Authorization: Bearer {token}",onChange:e=>this.emitConfigs({optionsHeaders:e.target.value||void 0})},null!==(t=i.optionsHeaders)&&void 0!==t?t:"")),this.textField(r("panel.searchParam"),i.searchParam,(e=>this.emitConfigs({searchParam:e||void 0})))),"js"===n&&p.push(a("label",{class:"fk-props__field"},a("span",{class:"fk-props__label"},"Code"),a("fk-code-editor",{completions:this.fields,value:null!==(s=i.optionsCode)&&void 0!==s?s:"",placeholder:"return dataMap.country === 'BJ' ? ['Cotonou'] : ['Paris'];",onCodeChange:e=>this.emitConfigs({optionsCode:e.detail})}))),"catalog"===n&&(this.catalogsRequested||this.loadCatalogs(),p.push(a("label",{class:"fk-props__field"},a("span",{class:"fk-props__label"},r("panel.optionsRef")),a("input",{class:"fk-props__input",type:"text",list:"fk-option-catalogs",value:null!==(l=i.optionsRef)&&void 0!==l?l:"",onChange:e=>this.emitConfigs({optionsRef:e.target.value})}),a("datalist",{id:"fk-option-catalogs"},this.catalogs.map((e=>{var t;return a("option",{value:e.ref},(null===(t=e.filters)||void 0===t?void 0:t.length)?`${e.label} (${e.filters.map((e=>`?${e}=`)).join(", ")})`:e.label)})))))),"remote"!==n&&"js"!==n&&"catalog"!==n||p.push(this.textField(r("panel.labelKey"),i.labelKey,(e=>this.emitConfigs({labelKey:e}))),this.textField(r("panel.valueKey"),i.valueKey,(e=>this.emitConfigs({valueKey:e})))),p}renderConfigTab(){const e=this.brick.configs,t="input"===this.brick.type;return a("section",{class:"fk-props__section"},this.textField(r("panel.key"),null==e?void 0:e.key,(e=>this.emitConfigs({key:e}))),this.textField(r("panel.label"),this.readLocalized(null==e?void 0:e.label),(e=>this.writeTextConfig("label",e))),e?this.textField(n("panel.description","Help text under the field"),this.readLocalized(e.description),(e=>this.writeTextConfig("description",e))):null,t?[this.textField(r("panel.placeholder"),this.readLocalized(null==e?void 0:e.placeholder),(e=>this.writeTextConfig("placeholder",e))),this.textField(r("panel.prefix"),null==e?void 0:e.prefix,(e=>this.emitConfigs({prefix:e||void 0}))),this.textField(r("panel.suffix"),null==e?void 0:e.suffix,(e=>this.emitConfigs({suffix:e||void 0})))]:null,e&&"specRef"in e?this.textField(n("panel.specRef","Referenced form (specRef)"),e.specRef,(e=>this.emitConfigs({specRef:e}))):null,e&&"mask"in e?this.textField(n("panel.mask","Input mask (9=digit, a=letter, *=any)"),e.mask,(e=>this.emitConfigs({mask:e}))):null,e&&"searchUrl"in e?[this.textField(n("panel.searchUrl","Geocoding URL ({q} = query)"),e.searchUrl,(e=>this.emitConfigs({searchUrl:e}))),this.textField(n("panel.countryCodes","Country codes (bj, tg)"),e.countryCodes,(e=>this.emitConfigs({countryCodes:e})))]:null,e&&"layerUrl"in e?[this.textField(n("panel.layerUrl","Reference layer URL (GeoJSON)"),e.layerUrl,(e=>this.emitConfigs({layerUrl:e}))),this.textField(n("panel.codeProperty","Code property"),e.codeProperty,(e=>this.emitConfigs({codeProperty:e||"code"}))),this.textField(n("panel.nameProperty","Name property"),e.nameProperty,(e=>this.emitConfigs({nameProperty:e||"name"})))]:null,e&&"idFormat"in e?this.textField(n("panel.idFormat","Identifier format (fr-nir, bj-npi, digits-10…)"),e.idFormat,(e=>this.emitConfigs({idFormat:e}))):null,e&&"currencies"in e?[this.textField(n("panel.currencies","Currencies offered (XOF, EUR, USD)"),e.currencies,(e=>this.emitConfigs({currencies:e}))),this.textField(n("panel.currency","Default currency"),e.currency,(e=>this.emitConfigs({currency:e.toUpperCase()})))]:null,e&&"slotsUrl"in e?[this.textField(n("panel.slotsUrl","Slots URL (empty = opening rules)"),e.slotsUrl,(e=>this.emitConfigs({slotsUrl:e}))),this.textField(n("panel.slotDays","Open days (1 = Monday … 7 = Sunday)"),e.days,(e=>this.emitConfigs({days:e}))),this.textField(n("panel.slotFrom","Opens at"),e.from,(e=>this.emitConfigs({from:e}))),this.textField(n("panel.slotTo","Closes at"),e.to,(e=>this.emitConfigs({to:e}))),this.textField(n("panel.slotDuration","Slot length (minutes)"),e.duration,(e=>this.emitConfigs({duration:""===e?void 0:Number(e)}))),this.textField(n("panel.slotHorizon","Bookable days ahead"),e.horizonDays,(e=>this.emitConfigs({horizonDays:""===e?void 0:Number(e)}))),this.textField(n("panel.slotNotice","Notice (hours)"),e.noticeHours,(e=>this.emitConfigs({noticeHours:""===e?void 0:Number(e)}))),this.textField(n("panel.slotExclude","Closed dates (YYYY-MM-DD, comma-separated)"),e.exclude,(e=>this.emitConfigs({exclude:e})))]:null,e&&"family"in e?[this.textField(n("panel.family","Measure family (length, area, mass, volume, duration)"),e.family,(e=>this.emitConfigs({family:e}))),this.textField(n("panel.units","Units offered (ids, comma-separated; empty = all)"),e.units,(e=>this.emitConfigs({units:e}))),this.textField(n("panel.unit","Default unit"),e.unit,(e=>this.emitConfigs({unit:e})))]:null,e&&"plateFormat"in e?this.textField(n("panel.plateFormat","Plate format (fr, bj, ci, sn, generic)"),e.plateFormat,(e=>this.emitConfigs({plateFormat:e}))):null,e&&"registryFormat"in e?this.textField(n("panel.registryFormat","Registration format (ohada-rccm, fr-rcs, generic)"),e.registryFormat,(e=>this.emitConfigs({registryFormat:e}))):null,e&&"readUrl"in e?[this.textField(n("panel.readUrl","Reader URL (empty = host default)"),e.readUrl,(e=>this.emitConfigs({readUrl:e}))),a("label",{class:"fk-props__field"},a("span",{class:"fk-props__label"},n("panel.documentFields","Fields to read (key|Label per line)")),a("textarea",{class:"fk-props__input fk-props__input--textarea",onChange:e=>this.emitConfigs({fields:e.target.value})},"string"==typeof e.fields?e.fields:"")),a("label",{class:"fk-props__field"},a("span",{class:"fk-props__label"},n("panel.documentFills","Fill the form (field=formKey per line)")),a("textarea",{class:"fk-props__input fk-props__input--textarea",onChange:e=>this.emitConfigs({fills:e.target.value})},"string"==typeof e.fills?e.fills:"")),this.textField(n("panel.documentLanguage","Document language (fr, en…)"),e.language,(e=>this.emitConfigs({language:e}))),this.textField(n("panel.accept","Accepted files"),e.accept,(e=>this.emitConfigs({accept:e}))),this.textField(n("panel.uploadUrl","Upload URL"),e.uploadUrl,(e=>this.emitConfigs({uploadUrl:e})))]:null,e&&"tileUrl"in e?[this.textField(n("panel.center","Initial center (lat, lng)"),e.center,(e=>this.emitConfigs({center:e}))),this.textField(n("panel.zoom","Initial zoom"),e.zoom,(e=>this.emitConfigs({zoom:""===e?void 0:Number(e)}))),this.textField(n("panel.height","Height (px)"),e.height,(e=>this.emitConfigs({height:""===e?void 0:Number(e)}))),this.textField(n("panel.tileUrl","Tile URL"),e.tileUrl,(e=>this.emitConfigs({tileUrl:e}))),"shape"in e?this.textField(n("panel.shape","Shape (polygon or line)"),e.shape,(e=>this.emitConfigs({shape:"line"===e?"line":"polygon"}))):null]:null,e&&"accept"in e?this.textField(n("panel.accept","Accepted file types"),e.accept,(e=>this.emitConfigs({accept:e}))):null,e&&"uploadUrl"in e?this.textField(n("panel.uploadUrl","Upload URL"),e.uploadUrl,(e=>this.emitConfigs({uploadUrl:e}))):null,this.optionsFields(),Object.entries(null!=e?e:{}).filter((([,e])=>"boolean"==typeof e)).map((([e,t])=>a("label",{class:"fk-props__field fk-props__field--inline",key:e},a("input",{type:"checkbox",checked:!0===t,onChange:t=>this.emitConfigs({[e]:t.target.checked})}),a("span",{class:"fk-props__label"},n(`panel.cfg.${e}`,e))))),e&&"content"in e?a("label",{class:"fk-props__field"},a("span",{class:"fk-props__label"},r("panel.content")),a("textarea",{class:"fk-props__input fk-props__input--textarea",onChange:e=>this.writeTextConfig("content",e.target.value)},this.readLocalized(e.content))):null)}validationRow(e,t,s){const l=this.validationOf(e);return a("div",{class:"fk-props__vrule"},a("label",{class:"fk-props__field fk-props__field--inline"},a("input",{type:"checkbox",checked:!!l,onChange:t=>this.setValidation(e,t.target.checked)}),a("span",{class:"fk-props__label"},t)),l&&s?a("input",{class:"fk-props__input",type:s,placeholder:"number"===s?"value":"regex",value:null==l.value?"":String(l.value),onChange:t=>{const l=t.target.value;this.setValidation(e,!0,{value:"number"===s?""===l?void 0:Number(l):l||void 0})}}):null,l?this.textField(r("panel.errorMessage"),this.readLocalized(l.message),(t=>this.setValidation(e,!0,{message:this.localized(l.message,t)}))):null)}renderValidationTab(){var e;const t=this.brick.dataType,s=this.validationOf("custom");return a("section",{class:"fk-props__section"},this.validationRow("required",r("panel.required")),"string"===t?[this.validationRow("minLength",r("panel.minLength"),"number"),this.validationRow("maxLength",r("panel.maxLength"),"number"),this.validationRow("pattern",r("panel.pattern"),"text"),this.validationRow("email",r("panel.emailFormat")),this.validationRow("url",r("panel.urlFormat"))]:null,"number"===t?[this.validationRow("min",r("panel.min"),"number"),this.validationRow("max",r("panel.max"),"number")]:null,"array"===t?[this.validationRow("minItems",r("panel.minItems"),"number"),this.validationRow("maxItems",r("panel.maxItems"),"number")]:null,a("div",{class:"fk-props__vrule"},a("label",{class:"fk-props__field fk-props__field--inline"},a("input",{type:"checkbox",checked:!!s,onChange:e=>{var t;return this.setValidation("custom",e.target.checked,{customValidator:null!==(t=null==s?void 0:s.customValidator)&&void 0!==t?t:"return true;"})}}),a("span",{class:"fk-props__label"},r("panel.custom"))),s?a("fk-code-editor",{completions:this.fields,value:null!==(e=s.customValidator)&&void 0!==e?e:"",placeholder:'return value?.startsWith("BJ-") ? true : "Must start with BJ-";',onCodeChange:e=>this.setValidation("custom",!0,{customValidator:e.detail})}):null,s?this.textField(r("panel.fallbackMessage"),this.readLocalized(s.message),(e=>this.setValidation("custom",!0,{message:this.localized(s.message,e)}))):null))}renderStylesTab(){var e;return a("section",{class:"fk-props__section"},Object.entries(null!==(e=this.brick.styles)&&void 0!==e?e:{}).map((([e,t])=>a("div",{class:"fk-props__style-row",key:e},a("span",{class:"fk-props__style-key"},e),a("input",{class:"fk-props__input fk-props__input--grow",type:"text",value:String(null!=t?t:""),onChange:t=>this.emitStyles({[e]:t.target.value})}),a("button",{type:"button",class:"fk-props__remove",title:"Remove style",onClick:()=>this.emitStyles({[e]:void 0})},"✕")))),a("div",{class:"fk-props__style-row"},a("input",{class:"fk-props__input",type:"text",placeholder:r("panel.styleProperty"),value:this.newStyleKey,onInput:e=>this.newStyleKey=e.target.value}),a("input",{class:"fk-props__input fk-props__input--grow",type:"text",placeholder:r("panel.styleValue"),onChange:e=>{const t=e.target;this.addStyle(t.value),t.value=""}})))}render(){return a("div",{key:"1801828d2b7854755eb52dd9feadb1f82d52fec5",class:"fk-props"},a("header",{key:"86919fae610ef2308936dda5023a4efe7c66bc9a",class:"fk-props__header"},a("span",{key:"134f14ce0c3a92b1027d103879ea73d914ebb4e4",class:"fk-props__type"},this.brick.type),a("h4",{key:"1525b0b52ff237e892c2a28aaa53ae6546d17f0c",class:"fk-props__title"},n(`brick.${this.brick.id}.name`,this.brick.name))),a("div",{key:"b0d78b3f9a69feea4ebba973361f703f1bc2a035",class:"fk-props__tabs"},this.availableTabs().map((e=>a("button",{key:e.id,type:"button",class:{"fk-props__tab":!0,"fk-props__tab--active":this.activeTab===e.id},onClick:()=>this.activeTab=e.id},e.label)))),"config"===this.activeTab?this.renderConfigTab():null,"validation"===this.activeTab?this.renderValidationTab():null,"styles"===this.activeTab?this.renderStylesTab():null,"rules"===this.activeTab?a("section",{class:"fk-props__section"},a("fk-rules-editor",{brick:this.brick,path:this.path,fields:this.fields})):null)}static get watchers(){return{brick:[{onBrickChange:0}]}}static get style(){return".sc-fk-property-panel-h{display:block}.fk-props.sc-fk-property-panel{display:flex;flex-direction:column;gap:calc(var(--fk-spacing) * 1.5)}.fk-props__header.sc-fk-property-panel{display:flex;flex-direction:column;gap:2px}.fk-props__type.sc-fk-property-panel{font-size:0.65rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--fk-color-primary)}.fk-props__title.sc-fk-property-panel{margin:0;font-size:0.95rem;color:var(--fk-color-text)}.fk-props__section.sc-fk-property-panel{display:flex;flex-direction:column;gap:var(--fk-spacing);padding-top:var(--fk-spacing)}.fk-props__tabs.sc-fk-property-panel{display:flex;gap:2px;border-bottom:1px solid var(--fk-color-border)}.fk-props__tab.sc-fk-property-panel{font:inherit;font-size:0.72rem;font-weight:600;padding:5px 9px;border:none;border-bottom:2px solid transparent;border-radius:0;background:transparent;color:var(--fk-color-muted);text-transform:none;letter-spacing:normal;cursor:pointer}.fk-props__tab.sc-fk-property-panel:hover{color:var(--fk-color-text)}.fk-props__tab--active.sc-fk-property-panel{color:var(--fk-color-primary);border-bottom-color:var(--fk-color-primary)}.fk-props__section-title.sc-fk-property-panel{margin:0;font-size:0.7rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--fk-color-muted)}.fk-props__field.sc-fk-property-panel{display:flex;flex-direction:column;gap:4px;font-style:normal;text-decoration:none}.fk-props__field--inline.sc-fk-property-panel{flex-direction:row;align-items:center;gap:8px}.fk-props__label.sc-fk-property-panel{font-size:0.75rem;font-weight:600;color:var(--fk-color-muted);font-style:normal;text-decoration:none}.fk-props__input.sc-fk-property-panel{font:inherit;font-size:0.85rem;padding:6px 8px;border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface);color:var(--fk-color-text)}.fk-props__input.sc-fk-property-panel:focus{outline:none;border-color:var(--fk-color-primary);box-shadow:0 0 0 2px color-mix(in srgb, var(--fk-color-primary) 20%, transparent)}.fk-props__input--textarea.sc-fk-property-panel{min-height:72px;resize:vertical}.fk-props__vrule.sc-fk-property-panel{display:flex;flex-direction:column;gap:6px;padding:calc(var(--fk-spacing) / 1.5);border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 1.5)}.fk-props__style-row.sc-fk-property-panel{display:flex;align-items:center;gap:6px}.fk-props__style-key.sc-fk-property-panel{font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-size:0.75rem;color:var(--fk-color-text);min-width:72px}.fk-props__input--grow.sc-fk-property-panel{flex:1;min-width:0}.fk-props__remove.sc-fk-property-panel{border:none;background:transparent;color:var(--fk-color-muted);font-size:0.75rem;cursor:pointer;padding:2px 4px;border-radius:calc(var(--fk-radius) / 2)}.fk-props__remove.sc-fk-property-panel:hover{color:var(--fk-color-danger);background:color-mix(in srgb, var(--fk-color-danger) 10%, transparent)}"}},[2,"fk-property-panel",{brick:[16],path:[1],fields:[16],locales:[16],locale:[1],editLocale:[1,"edit-locale"],activeTab:[32],newStyleKey:[32],catalogs:[32]},void 0,{brick:[{onBrickChange:0}]}]);function f(){"undefined"!=typeof customElements&&["fk-property-panel","fk-code-editor","fk-rules-editor"].forEach((t=>{switch(t){case"fk-property-panel":customElements.get(e(t))||customElements.define(e(t),h);break;case"fk-code-editor":customElements.get(e(t))||p();break;case"fk-rules-editor":customElements.get(e(t))||c()}}))}f();export{h as F,f as d}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e,p as t,H as r,c as o,h as n}from"./p-8ICOcloT.js";import{b as d,s}from"./p-
|
|
1
|
+
import{t as e,p as t,H as r,c as o,h as n}from"./p-8ICOcloT.js";import{b as d,s}from"./p-JQ8Ve1UU.js";const i=t(class extends r{constructor(e){super(),!1!==e&&this.__registerHost(),this.documentChange=o(this,"documentChange"),this.accept="image/*,.pdf",this.capture=!1,this.keepFile=!0,this.fields=[],this.disabled=!1,this.readOnly=!1,this.reading=!1,this.showText=!1,this.handleFile=async e=>{var t;const r=e.target,o=null===(t=r.files)||void 0===t?void 0:t[0];if(r.value="",o&&!this.locked){this.reading=!0,this.error=void 0;try{const e=s.documentReaderService;if(!e)throw new Error(d("document.noReader"));const[t,r]=await Promise.all([e.read(o,{url:this.readUrl||void 0,fields:this.fields,language:this.language||void 0,context:this.context}),this.keepFile&&void 0!==this.uploadUrl?s.fileUploadService.upload(o,{url:this.uploadUrl||void 0}):Promise.resolve(void 0)]),n=this.fields.length?Object.fromEntries(this.fields.map((e=>{var r,o;return[e.key,null!==(o=null===(r=t.fields)||void 0===r?void 0:r[e.key])&&void 0!==o?o:null]}))):t.fields,i=Object.assign(Object.assign(Object.assign(Object.assign({name:o.name,type:o.type,size:o.size},t),n?{fields:n}:{}),r?{file:r}:{}),{readAt:(new Date).toISOString()});this.documentChange.emit(i)}catch(e){this.error=e instanceof Error&&e.message?e.message:d("document.failed")}finally{this.reading=!1}}}}get locked(){return this.disabled||this.readOnly}updateField(e,t){var r;if(!this.value)return;const o=Object.assign(Object.assign({},null!==(r=this.value.fields)&&void 0!==r?r:{}),{[e]:""===t?null:t});this.documentChange.emit(Object.assign(Object.assign({},this.value),{fields:o}))}fieldLabel(e){var t,r;return null!==(r=null===(t=this.fields.find((t=>t.key===e)))||void 0===t?void 0:t.label)&&void 0!==r?r:e}renderFields(){var e;const t=null===(e=this.value)||void 0===e?void 0:e.fields;return t&&Object.keys(t).length?n("dl",{class:"fk-document__fields"},Object.entries(t).map((([e,t])=>n("div",{class:"fk-document__field",key:e},n("dt",null,this.fieldLabel(e)),n("dd",null,this.locked?n("span",{class:{"fk-document__missing":null==t||""===t}},null==t||""===t?d("document.notFound"):String(t)):n("input",{class:"fk-field__input fk-document__input",type:"text",value:null==t?"":String(t),placeholder:d("document.notFound"),"aria-label":this.fieldLabel(e),onInput:t=>this.updateField(e,t.target.value)})))))):null}renderText(){var e,t,r;const o=null===(t=null===(e=this.value)||void 0===e?void 0:e.text)||void 0===t?void 0:t.trim();if(!o)return null;const s=this.showText||o.length<=600?o:`${o.slice(0,600)}…`;return n("details",{class:"fk-document__text",open:this.showText,onToggle:e=>this.showText=e.target.open},n("summary",null,d("document.text"),(null===(r=this.value)||void 0===r?void 0:r.pages)?n("small",null," · ",this.value.pages," p."):null),n("pre",null,s))}render(){const e=this.value;return n("div",{key:"1972542875ad3025af1b3a23403c584eff28f1ca",class:"fk-document"},e?n("div",{class:"fk-document__file"},n("span",{class:"fk-document__icon","aria-hidden":"true"},n("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},n("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),n("polyline",{points:"14 2 14 8 20 8"}),n("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),n("line",{x1:"8",y1:"17",x2:"13",y2:"17"}))),n("span",{class:"fk-document__meta"},n("span",{class:"fk-document__name",title:e.name},e.name),n("span",{class:"fk-document__status"},d("document.read"))),this.locked?null:n("button",{type:"button",class:"fk-document__remove",title:d("document.remove"),onClick:()=>this.documentChange.emit(void 0)},"✕")):this.locked?n("span",{class:"fk-document__empty"},d("document.none")):null,this.locked||e?null:n("div",{class:"fk-document__actions"},n("button",{type:"button",class:"fk-document__choose",disabled:this.reading,onClick:()=>{var e;return null===(e=this.inputEl)||void 0===e?void 0:e.click()}},d(this.reading?"document.reading":"document.choose")),this.capture?n("button",{type:"button",class:"fk-document__choose fk-document__camera",disabled:this.reading,onClick:()=>{var e;return null===(e=this.cameraEl)||void 0===e?void 0:e.click()}},d("document.capture")):null),this.reading&&e?n("span",{class:"fk-document__empty"},d("document.reading")):null,this.renderFields(),this.renderText(),n("input",{key:"8fbea65e8cdadaa9afbf7a0b838783962a2d6f8a",class:"fk-document__native",type:"file",accept:this.accept,disabled:this.locked,ref:e=>this.inputEl=e,onChange:this.handleFile}),this.capture?n("input",{class:"fk-document__native",type:"file",accept:"image/*",capture:"environment",disabled:this.locked,ref:e=>this.cameraEl=e,onChange:this.handleFile}):null,this.error?n("span",{class:"fk-field__error",role:"alert"},this.error):null)}static get style(){return".sc-fk-document-reader-h{display:block}.fk-document__native.sc-fk-document-reader{display:none}.fk-document__actions.sc-fk-document-reader{display:flex;flex-wrap:wrap;gap:0.5rem}.fk-document__choose.sc-fk-document-reader{border:1px dashed var(--fk-color-border, #d4d4d8);border-radius:var(--fk-radius, 0.375rem);background:transparent;color:inherit;font:inherit;font-size:0.875rem;padding:0.5rem 0.75rem;cursor:pointer}.fk-document__choose.sc-fk-document-reader:disabled{opacity:0.6;cursor:progress}.fk-document__file.sc-fk-document-reader{display:flex;align-items:center;gap:0.5rem;border:1px solid var(--fk-color-border, #d4d4d8);border-radius:var(--fk-radius, 0.375rem);padding:0.375rem 0.625rem}.fk-document__meta.sc-fk-document-reader{display:flex;flex-direction:column;min-width:0;flex:1}.fk-document__name.sc-fk-document-reader{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:0.875rem}.fk-document__status.sc-fk-document-reader,.fk-document__empty.sc-fk-document-reader{font-size:0.75rem;color:var(--fk-color-muted, #71717a)}.fk-document__remove.sc-fk-document-reader{border:0;background:transparent;color:var(--fk-color-muted, #71717a);font:inherit;cursor:pointer}.fk-document__fields.sc-fk-document-reader{display:grid;grid-template-columns:minmax(6rem, max-content) 1fr;gap:0.375rem 0.75rem;margin:0.5rem 0 0}.fk-document__field.sc-fk-document-reader{display:contents}.fk-document__field.sc-fk-document-reader dt.sc-fk-document-reader{font-size:0.8125rem;color:var(--fk-color-muted, #71717a);align-self:center}.fk-document__field.sc-fk-document-reader dd.sc-fk-document-reader{margin:0;font-size:0.875rem}.fk-document__missing.sc-fk-document-reader{color:var(--fk-color-muted, #71717a);font-style:italic}.fk-document__text.sc-fk-document-reader{margin-top:0.5rem;font-size:0.8125rem}.fk-document__text.sc-fk-document-reader summary.sc-fk-document-reader{cursor:pointer;color:var(--fk-color-muted, #71717a)}.fk-document__text.sc-fk-document-reader pre.sc-fk-document-reader{margin:0.375rem 0 0;max-height:16rem;overflow:auto;white-space:pre-wrap;font:inherit;padding:0.5rem;border:1px solid var(--fk-color-border, #d4d4d8);border-radius:var(--fk-radius, 0.375rem)}"}},[2,"fk-document-reader",{value:[16],accept:[1],capture:[4],readUrl:[1,"read-url"],uploadUrl:[1,"upload-url"],keepFile:[4,"keep-file"],fields:[16],language:[1],context:[16],disabled:[4],readOnly:[4,"read-only"],reading:[32],error:[32],showText:[32]}]);function a(){"undefined"!=typeof customElements&&["fk-document-reader"].forEach((t=>{"fk-document-reader"===t&&(customElements.get(e(t))||customElements.define(e(t),i))}))}a();export{i as F,a as d}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t,p as s,H as e,c as i,h as r}from"./p-8ICOcloT.js";import{b as a,d as o,h as n,e as c,i as h,g as d,v as l}from"./p-
|
|
1
|
+
import{t,p as s,H as e,c as i,h as r}from"./p-8ICOcloT.js";import{b as a,d as o,h as n,e as c,i as h,g as d,v as l}from"./p-JQ8Ve1UU.js";import{registerDefaultBricks as m}from"./index.js";import{d as f}from"./p-BY-HsBmr.js";import{d as u}from"./p-BPQcQaPo.js";import{d as p}from"./p-CIgvEKbO.js";import{d as b}from"./p-gKtzV7rX.js";import{d as k}from"./p-BE5v8BN3.js";import{d as v}from"./p-Cy93hSiU.js";import{d as j}from"./p-D5nPxZXV.js";import{d as g}from"./p-Da741snY.js";import{d as y}from"./p-CimJudBw.js";import{d as E}from"./p-C6_gsHBy.js";import{d as O}from"./p-ClRRfTDD.js";import{d as S}from"./p-BrVPi4s9.js";import{d as C}from"./p-B-INxJBg.js";import{d as x}from"./p-CtbPH5C7.js";import{d as D}from"./p-DWSCT2ur.js";import{d as w}from"./p-CNu8nwtf.js";import{d as B}from"./p-jEx6mM9z.js";const V=s(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.formDataChange=i(this,"formDataChange"),this.formSubmit=i(this,"formSubmit"),this.validityChange=i(this,"validityChange"),this.editable=!1,this.readOnly=!1,this.disabled=!1,this.showSubmit=!1,this.reviewable=!1,this.currentData={},this.touched={},this.expanding=!1,this.utils={validateForm:()=>({isValid:this.runValidation().valid})}}componentWillLoad(){return m(),this.attachFormInternals(),this.currentData=this.seeded(this.data),this.runExpansion()}syncData(t){this.currentData=this.seeded(t)}onSpecChange(){this.currentData=this.seeded(this.data),this.runExpansion()}componentDidLoad(){this.emitValidity()}emitValidity(t){const{valid:s,errors:e}=null!=t?t:this.runValidation(),i=`${s}|${Object.keys(e).sort().join(",")}`;i!==this.lastValidity&&(this.lastValidity=i,this.validityChange.emit({valid:s,errors:e}),this.reportToForm(s,e))}attachFormInternals(){const t=this.host;if("function"==typeof t.attachInternals)try{this.internals=t.attachInternals()}catch(t){this.internals=void 0}}reportToForm(t,s){var e,i,r;if(null===(e=this.internals)||void 0===e?void 0:e.setValidity)try{this.internals.setFormValue(JSON.stringify(this.publicData())),t?this.internals.setValidity({}):this.internals.setValidity({customError:!0},null!==(i=Object.values(s)[0])&&void 0!==i?i:a("form.invalid"),null!==(r=this.host.querySelector("input, select, textarea"))&&void 0!==r?r:void 0)}catch(t){}}handleHostFormSubmit(t){var s;const e=null===(s=this.internals)||void 0===s?void 0:s.form;e&&t.target===e&&(t.preventDefault(),this.submit())}seeded(t){return Object.assign(Object.assign({},o(this.effectiveSpec())),t)}effectiveSpec(){var t;return null!==(t=this.expandedSpec)&&void 0!==t?t:this.spec}async runExpansion(){if(this.expandError=void 0,this.editable||!n(this.spec))return void(this.expandedSpec=void 0);const t=this.spec;this.expanding=!0;try{const s=await c(t);this.spec===t&&(this.expandedSpec=s,this.currentData=this.seeded(this.currentData))}catch(s){this.spec===t&&(this.expandedSpec=void 0,this.expandError=s instanceof Error?s.message:String(s))}finally{this.spec===t&&(this.expanding=!1)}}publicData(){return Object.fromEntries(Object.entries(this.currentData).filter((([t])=>!t.startsWith("_"))))}dataMap(t=this.currentData){return this.context?Object.assign(Object.assign({},t),this.context):t}handleBrickDataChange(t){t.stopPropagation(),this.currentData=this.applyValueEffects(Object.assign(Object.assign({},this.currentData),t.detail));const s=Object.assign({},this.touched);for(const e of Object.keys(t.detail))s[e]=!0;this.touched=s;const{valid:e,errors:i}=this.runValidation();this.formDataChange.emit({data:this.publicData(),isValid:e,errors:i}),this.emitValidity({valid:e,errors:i})}applyValueEffects(t){var s,e;let i=t;for(const{brick:t}of h(this.effectiveSpec())){const r=null===(s=t.configs)||void 0===s?void 0:s.key;if(!r||!(null===(e=t.rules)||void 0===e?void 0:e.length))continue;const a=d(t.rules,this.dataMap(i));void 0!==a.value&&i[r]!==a.value&&(i=Object.assign(Object.assign({},i),{[r]:a.value}))}return i}async validate(){var t;const s={};for(const{brick:e}of h(this.effectiveSpec())){const i=null===(t=e.configs)||void 0===t?void 0:t.key;i&&(s[i]=!0)}this.touched=s;const e=this.runValidation(),i=Object.assign({},e.errors);let r=e.valid;const a=Array.from(this.host.querySelectorAll("fk-data-grid"));for(const t of a){const s=await t.validateRows();r=r&&s.valid,Object.assign(i,s.errors)}const o={valid:r,errors:i};return this.emitValidity(o),this.formDataChange.emit({data:this.publicData(),isValid:o.valid,errors:o.errors}),o}async submit(){const t=await this.validate();return!t.valid||this.readOnly||this.disabled||this.formSubmit.emit({data:this.publicData(),isValid:!0,errors:{}}),t}handleStepTouch(t){t.stopPropagation();const s=Object.assign({},this.touched);for(const e of t.detail.keys)s[e]=!0;this.touched=s}async handleStepperSubmit(t){t.stopPropagation(),await this.submit()}runValidation(){const t=Object.fromEntries(Object.entries(this.currentData).filter((([,t])=>""!==t&&null!=t)));return l(this.effectiveSpec(),t,this.locale,this.context?this.dataMap(t):void 0)}visibleErrors(){if(this.editable)return{};const t={};for(const[s,e]of Object.entries(this.runValidation().errors))this.touched[s]&&(t[s]=e);return t}render(){var t;return this.spec?this.expanding?r("p",{class:"fk-form__expanding"},a("nestedForm.loading")):r("form",{class:"fk-form",onSubmit:t=>t.preventDefault()},this.expandError?r("span",{class:"fk-field__error",role:"alert"},this.expandError):null,r("fk-brick-render",{brickSpec:this.effectiveSpec(),rootSpec:this.effectiveSpec(),data:this.currentData,dataMap:this.dataMap(),errors:this.visibleErrors(),annotations:this.annotations,notes:this.notes,editableKeys:this.editableKeys,reviewable:this.reviewable,locale:this.locale,path:"0",editable:this.editable,readOnly:this.readOnly,disabled:this.disabled,selectedPath:this.selectedPath,utils:this.utils}),!this.showSubmit||this.editable||this.readOnly||this.disabled?null:r("button",{type:"submit",class:"fk-form__submit",onClick:t=>{t.preventDefault(),this.submit()}},null!==(t=this.submitLabel)&&void 0!==t?t:a("form.submit"))):null}static get formAssociated(){return!0}get host(){return this}static get watchers(){return{data:[{syncData:0}],spec:[{onSpecChange:0}]}}static get style(){return".fk-form.sc-fk-form-render{display:flex;flex-direction:column;gap:var(--fk-spacing);font-family:var(--fk-font);color:var(--fk-color-text)}"}},[66,"fk-form-render",{spec:[16],data:[16],context:[16],editable:[4],readOnly:[4,"read-only"],disabled:[4],showSubmit:[4,"show-submit"],submitLabel:[1,"submit-label"],selectedPath:[1,"selected-path"],locale:[1],annotations:[16],notes:[16],editableKeys:[16],reviewable:[4],currentData:[32],touched:[32],expandedSpec:[32],expanding:[32],expandError:[32],validate:[64],submit:[64]},[[8,"submit","handleHostFormSubmit"],[0,"brickDataChange","handleBrickDataChange"],[0,"stepTouch","handleStepTouch"],[0,"stepperSubmit","handleStepperSubmit"]],{data:[{syncData:0}],spec:[{onSpecChange:0}]}]);function _(){"undefined"!=typeof customElements&&["fk-form-render","fk-address-search","fk-brick-actions","fk-brick-not-found","fk-brick-render","fk-code-editor","fk-data-grid","fk-document-reader","fk-drop-area","fk-file-input","fk-geo-map","fk-key-value","fk-select-input","fk-signature-input","fk-slot-picker","fk-stepper","fk-tabs","fk-variable-picker"].forEach((s=>{switch(s){case"fk-form-render":customElements.get(t(s))||customElements.define(t(s),V);break;case"fk-address-search":customElements.get(t(s))||f();break;case"fk-brick-actions":customElements.get(t(s))||u();break;case"fk-brick-not-found":customElements.get(t(s))||p();break;case"fk-brick-render":customElements.get(t(s))||b();break;case"fk-code-editor":customElements.get(t(s))||k();break;case"fk-data-grid":customElements.get(t(s))||v();break;case"fk-document-reader":customElements.get(t(s))||j();break;case"fk-drop-area":customElements.get(t(s))||g();break;case"fk-file-input":customElements.get(t(s))||y();break;case"fk-geo-map":customElements.get(t(s))||E();break;case"fk-key-value":customElements.get(t(s))||O();break;case"fk-select-input":customElements.get(t(s))||S();break;case"fk-signature-input":customElements.get(t(s))||C();break;case"fk-slot-picker":customElements.get(t(s))||x();break;case"fk-stepper":customElements.get(t(s))||D();break;case"fk-tabs":customElements.get(t(s))||w();break;case"fk-variable-picker":customElements.get(t(s))||B()}}))}_();export{V as F,_ as d}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t,p as e,H as r,h as a,a as c}from"./p-8ICOcloT.js";import{b as s}from"./p-BMtyMU2R.js";import{f as o,b as l}from"./p-
|
|
1
|
+
import{t,p as e,H as r,h as a,a as c}from"./p-8ICOcloT.js";import{b as s}from"./p-BMtyMU2R.js";import{f as o,b as l}from"./p-JQ8Ve1UU.js";import{d as i}from"./p-8HkjC_aE.js";const f=e(class extends r{constructor(t){super(),!1!==t&&this.__registerHost(),this.query="",this.collapsed={}}toggle(t){this.collapsed=Object.assign(Object.assign({},this.collapsed),{[t]:!this.collapsed[t]})}render(){const t=s(),e=this.query.trim().toLowerCase(),r=Object.entries(t).map((([t,r])=>({category:t,molds:e?r.filter((r=>[r.name,o(`brick.${r.id}.name`,r.name),r.id,t,o(`category.${t}`,t)].some((t=>t.toLowerCase().includes(e))))):r}))).filter((t=>t.molds.length>0));return a(c,{key:"13d076c3e42dbed20f6d85d5f659f6cdffb97096"},a("div",{key:"adc27295b99dc5af51a006b25b78e4c4e1f4375d",class:"fk-palette"},a("input",{key:"d0e852d60de3cfec189243947c2b8a9028cadbcf",class:"fk-palette__search",type:"search",placeholder:l("palette.search"),value:this.query,onInput:t=>this.query=t.target.value}),r.map((({category:t,molds:r})=>{const c=!e&&this.collapsed[t];return a("section",{class:"fk-palette__group",key:t},a("button",{type:"button",class:"fk-palette__category",onClick:()=>this.toggle(t)},a("span",{class:{"fk-palette__chevron":!0,"fk-palette__chevron--collapsed":c}},"▾"),o(`category.${t}`,t),a("span",{class:"fk-palette__count"},r.length)),c?null:a("div",{class:"fk-palette__items"},r.map((t=>a("fk-brick-mold-item",{brickMold:t,key:`${t.type}:${t.id}`})))))})),0===r.length?a("p",{class:"fk-palette__empty"},l("palette.empty",{query:this.query})):null))}static get style(){return".fk-palette.sc-fk-brick-list{display:flex;flex-direction:column;gap:var(--fk-spacing);font-family:var(--fk-font)}.fk-palette__search.sc-fk-brick-list{font:inherit;font-size:0.85rem;padding:calc(var(--fk-spacing) / 1.5) var(--fk-spacing);border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 1.5);background:var(--fk-color-surface);color:var(--fk-color-text)}.fk-palette__search.sc-fk-brick-list:focus{outline:none;border-color:var(--fk-color-primary);box-shadow:0 0 0 2px color-mix(in srgb, var(--fk-color-primary) 20%, transparent)}.fk-palette__category.sc-fk-brick-list{display:flex;align-items:center;gap:calc(var(--fk-spacing) / 2);width:100%;margin:0 0 calc(var(--fk-spacing) / 2);padding:calc(var(--fk-spacing) / 2) 0;border:none;background:transparent;font:inherit;font-size:0.7rem;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;color:var(--fk-color-muted);cursor:pointer}.fk-palette__category.sc-fk-brick-list:hover{color:var(--fk-color-text)}.fk-palette__chevron.sc-fk-brick-list{display:inline-block;transition:transform 120ms ease}.fk-palette__chevron--collapsed.sc-fk-brick-list{transform:rotate(-90deg)}.fk-palette__count.sc-fk-brick-list{margin-inline-start:auto;font-weight:600;color:var(--fk-color-muted)}.fk-palette__items.sc-fk-brick-list{display:grid;grid-template-columns:repeat(2, minmax(0, 1fr));gap:calc(var(--fk-spacing) / 2)}.fk-palette__empty.sc-fk-brick-list{margin:0;font-size:0.8rem;color:var(--fk-color-muted)}"}},[2,"fk-brick-list",{locale:[1],query:[32],collapsed:[32]}]);function n(){"undefined"!=typeof customElements&&["fk-brick-list","fk-brick-mold-item"].forEach((e=>{switch(e){case"fk-brick-list":customElements.get(t(e))||customElements.define(t(e),f);break;case"fk-brick-mold-item":customElements.get(t(e))||i()}}))}n();export{f as F,n as d}
|