sel-esri-advance-search-aov
Advanced tools
Comparing version 1.0.3 to 2.0.0
@@ -1,1 +0,1 @@ | ||
import e,{useEffect as t,useState as n}from"react";import r from"@arcgis/core/rest/support/Query.js";import a from"@mui/material/Autocomplete";import o from"@mui/material/TextField";const s=(e,t)=>new r({outFields:[e],where:t,returnDistinctValues:!0}),c=(e,t,n)=>{const r=Object.entries(t).map((([e,t])=>({key:e,value:t})));if(!r.some((e=>e.value.length>0)))return n;const a=r.filter((t=>t.key!==e)),o=[];return a.forEach((e=>{const{key:t,value:n}=e;if(Array.isArray(n)&&n.length>0){const e=n.filter((e=>""!==e)).map((e=>`'${e}'`)).join(",");o.push(`${t} IN (${e})`)}})),0===o.length?n:o.join(" AND ")+` AND (${n})`},i=(e,t)=>{console.log("appQuery:",e,"field:",t);const n=new RegExp(`\\(${t}\\s+LIKE\\s+'[^']*'\\)\\s+AND\\s+|\\s+AND\\s+\\(${t}\\s+LIKE\\s+'[^']*'\\)`,"g");return e.replace(n,"").trim()},l=e=>{const{featureLayer:a,autocompleteFields:o,setFinalQuery:l,timeSlider:u,advanceSearchData:d,appQuery:p}=e,[m,h]=(e=>{const t={},r={};return e.forEach((e=>{const[a,o]=n([]);t[e]=a,r[`set_${e}`]=o})),[t,r]})(o);return t((()=>{if(null===a||!d)return;const e=(e,t)=>e.features.map((e=>{const n=e.attributes[t];return null!==n?n:null})).filter((e=>null!==e));Promise.all([(()=>{const t="Site_Type";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Site_Type([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Discipline";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Proj_Discipline([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Initiative";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Proj_Initiative([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Site_Place";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Site_Place([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Site_Name";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Site_Name([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Funding_Agency";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Proj_Funding_Agency([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_AON";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Proj_AON([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Contact_Name";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Proj_Contact_Name([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Institution";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Proj_Institution([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Award";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Proj_Award([...new Set(e)].sort(((e,t)=>e.localeCompare(t))))))])}),[d,u,a,p]),t((()=>{if(null===a)return;const e=((e,t)=>{const n=[];Object.entries(e).forEach((([e,t])=>{if(Array.isArray(t)&&t.length>0){const r=t.filter((e=>""!==e));if(r.length>0){const t=r.map((t=>`${e} LIKE '%${t}%'`)).join(" OR ");n.push(`(${t})`)}}}));const r=`(Proj_Start_Year <= ${t[1]} AND Proj_End_Year >= ${t[0]})`;return n.length?n.join(" AND ")+` AND ${r}`:r})(d,u);l(e)}),[u,a,d,u,p]),{state:m,fetchFeatures:async e=>{const t=new r({outFields:["*"],where:e,returnGeometry:!0});try{const{features:e}=await a.queryFeatures(t),n=[];return e.forEach((e=>{n.push(((e,t)=>{const n={longitude:0,latitude:0};for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=e[t]);return t&&"point"===t.type&&"longitude"in t&&"latitude"in t&&(n.longitude=t.longitude,n.latitude=t.latitude),n})(e.attributes,e.geometry))})),n}catch(e){console.error("Error fetching features:",e)}}}};function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},u.apply(null,arguments)}function d(t){const{data:n,autocompleteData:r,setAdvanceSearchData:s,label:c,stateLabel:i,selectedValues:l=[]}=t;function d(e){return e.trim().toLowerCase().replace(/\s+/g," ")}return e.createElement("div",{className:"autocomplete-input-wrapper"},e.createElement(a,{value:l,multiple:!0,"data-cy":`AOV-autocomplete-${i}`,id:"combo-box-demo",options:n,disabled:0===n.length,isOptionEqualToValue:(e,t)=>d(e)===d(t),sx:{display:"flex",justifyContent:"center",alignContent:"center"},onChange:(e,t)=>((e,t,n)=>{const a={...r,[n]:t.map((e=>e.trim().replace(/\s+/g," ")))||[]};s(a)})(0,t,i),renderInput:t=>e.createElement(o,u({style:{backgroundColor:"#fff",color:"#000",borderRadius:10},label:c},t,{placeholder:0===n.length?"No matching fields":c}))}))}!function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}(".advance-searc-container{display:flex;height:auto;justify-content:center;margin:auto;width:100%}.autcomplete-container{align-items:center;display:flex;flex-direction:column;justify-content:center;width:100%}.autocomplete-input-wrapper{margin:5px 0;width:100%}");const p={Site_Type:"Observation Type",Proj_Discipline:"Discipline",Proj_Initiative:"Network Initiative",Site_Place:"Place",Site_Name:"Site Name",Proj_Funding_Agency:"Funding Agency",Proj_AON:"NSF AON?",Proj_Contact_Name:"Contact Name",Proj_Institution:"Institution",Proj_Award:"Award Number"};function m(t){const{autocompleteFields:n,featureLayer:r,timeSlider:a,advanceSearchData:o,setAdvanceSearchData:s,setFinalQuery:c,appQuery:i}=t,{state:u}=l({autocompleteFields:n,featureLayer:r,timeSlider:a,advanceSearchData:o,setAdvanceSearchData:s,setFinalQuery:c,appQuery:i}),m=e.createElement("div",{className:"autcomplete-container"},n.map((t=>e.createElement(d,{key:t,data:u[t],autocompleteData:o,setAdvanceSearchData:s,label:p[t],stateLabel:t,selectedValues:o[t]}))));return e.createElement("div",{className:"advance-searc-container","data-cy":"AOV-advance-search-container"},m)}export{m as ESRIAdvanceSearchAOV,l as useWithAdvanceSearch}; | ||
import e,{useEffect as t,useState as n}from"react";import r from"@arcgis/core/rest/support/Query.js";import a from"@mui/material/Autocomplete";import o from"@mui/material/TextField";const s=(e,t)=>new r({outFields:[e],where:t,returnDistinctValues:!0}),c=(e,t,n)=>{const r=Object.entries(t).map((([e,t])=>({key:e,value:t})));if(!r.some((e=>e.value.length>0)))return n;const a=r.filter((t=>t.key!==e)),o=[];return a.forEach((e=>{const{key:t,value:n}=e;if(Array.isArray(n)&&n.length>0){const e=n.filter((e=>""!==e)).map((e=>`'${e}'`)).join(",");o.push(`${t} IN (${e})`)}})),0===o.length?n:o.join(" AND ")+` AND (${n})`},i=(e,t)=>{console.log("appQuery:",e,"field:",t);const n=new RegExp(`\\(${t}\\s+LIKE\\s+'[^']*'\\)\\s+AND\\s+|\\s+AND\\s+\\(${t}\\s+LIKE\\s+'[^']*'\\)`,"g");return e.replace(n,"").trim()},l=e=>{const{featureLayer:a,autocompleteFields:o,setFinalQuery:l,timeSlider:u,advanceSearchData:d,appQuery:p}=e,[m,h]=(e=>{const t={},r={};return e.forEach((e=>{const[a,o]=n([]);t[e]=a,r[`set_${e}`]=o})),[t,r]})(o);return t((()=>{if(null===a||!d)return;const e=(e,t)=>e.features.map((e=>{const n=e.attributes[t];return null!==n?n:null})).filter((e=>null!==e));Promise.all([(()=>{const t="Site_Type";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Site_Type([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Discipline";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Proj_Discipline([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Initiative";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Proj_Initiative([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Site_Place";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Site_Place([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Site_Name";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Site_Name([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Funding_Agency";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Proj_Funding_Agency([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_AON";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Proj_AON([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Contact_Name";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Proj_Contact_Name([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Institution";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Proj_Institution([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Award";let n=p.includes(t)?i(p,t):p;const r=c(t,d,n);return a.queryFeatures(s(t,r)).then((n=>e(n,t)))})().then((e=>h.set_Proj_Award([...new Set(e)].sort(((e,t)=>e.localeCompare(t))))))])}),[d,u,a,p]),t((()=>{if(null===a)return;const e=((e,t)=>{const n=[];Object.entries(e).forEach((([e,t])=>{if(Array.isArray(t)&&t.length>0){const r=t.filter((e=>""!==e));if(r.length>0){const t=r.map((t=>`${e} LIKE '%${t}%'`)).join(" OR ");n.push(`(${t})`)}}}));const r=`(Proj_Start_Year <= ${t[1]} AND Proj_End_Year >= ${t[0]})`;return n.length?n.join(" AND ")+` AND ${r}`:r})(d,u);l(e)}),[u,a,d,u,p]),{state:m,fetchFeatures:async e=>{const t=new r({outFields:["*"],where:e,returnGeometry:!0});try{const{features:e}=await a.queryFeatures(t),n=[];return e.forEach((e=>{n.push(((e,t)=>{const n={longitude:0,latitude:0};for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=e[t]);return t&&"point"===t.type&&"longitude"in t&&"latitude"in t&&(n.longitude=t.longitude,n.latitude=t.latitude),n})(e.attributes,e.geometry))})),n}catch(e){console.error("Error fetching features:",e)}}}};function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},u.apply(null,arguments)}function d(t){const{data:n,autocompleteData:r,setAdvanceSearchData:s,label:c,stateLabel:i,selectedValues:l=[]}=t;function d(e){return e.trim().toLowerCase().replace(/\s+/g," ")}return e.createElement("div",{className:"autocomplete-input-wrapper"},e.createElement(a,{value:l,multiple:!0,"data-cy":`AOV-autocomplete-${i}`,id:"combo-box-demo",options:n,disabled:0===n.length,isOptionEqualToValue:(e,t)=>d(e)===d(t),sx:{display:"flex",justifyContent:"center",alignContent:"center"},onChange:(e,t)=>((e,t,n)=>{const a={...r,[n]:t.map((e=>e.trim().replace(/\s+/g," ")))||[]};s(a)})(0,t,i),renderInput:t=>e.createElement(o,u({style:{backgroundColor:"#fff",color:"#000",borderRadius:10}},t,{placeholder:0===n.length?"No matching fields":c}))}))}!function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}(".advance-searc-container{display:flex;height:auto;justify-content:center;margin:auto;width:100%}.autcomplete-container{align-items:center;display:flex;flex-direction:column;justify-content:center;width:100%}.autocomplete-input-wrapper{margin:5px 0;width:100%}");const p={Site_Type:"Observation Type",Proj_Discipline:"Discipline",Proj_Initiative:"Network Initiative",Site_Place:"Place",Site_Name:"Site Name",Proj_Funding_Agency:"Funding Agency",Proj_AON:"NSF AON?",Proj_Contact_Name:"Contact Name",Proj_Institution:"Institution",Proj_Award:"Award Number"};function m(t){const{autocompleteFields:n,featureLayer:r,timeSlider:a,advanceSearchData:o,setAdvanceSearchData:s,setFinalQuery:c,appQuery:i}=t,{state:u}=l({autocompleteFields:n,featureLayer:r,timeSlider:a,advanceSearchData:o,setAdvanceSearchData:s,setFinalQuery:c,appQuery:i}),m=e.createElement("div",{className:"autcomplete-container"},n.map((t=>e.createElement(d,{key:t,data:u[t],autocompleteData:o,setAdvanceSearchData:s,label:p[t],stateLabel:t,selectedValues:o[t]}))));return e.createElement("div",{className:"advance-searc-container","data-cy":"AOV-advance-search-container"},m)}export{m as ESRIAdvanceSearchAOV,l as useWithAdvanceSearch}; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@arcgis/core/rest/support/Query.js"),r=require("@mui/material/Autocomplete"),n=require("@mui/material/TextField");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=a(e),s=a(t),c=a(r),l=a(n);const i=(e,t)=>new s.default({outFields:[e],where:t,returnDistinctValues:!0}),u=(e,t,r)=>{const n=Object.entries(t).map((([e,t])=>({key:e,value:t})));if(!n.some((e=>e.value.length>0)))return r;const a=n.filter((t=>t.key!==e)),o=[];return a.forEach((e=>{const{key:t,value:r}=e;if(Array.isArray(r)&&r.length>0){const e=r.filter((e=>""!==e)).map((e=>`'${e}'`)).join(",");o.push(`${t} IN (${e})`)}})),0===o.length?r:o.join(" AND ")+` AND (${r})`},d=(e,t)=>{console.log("appQuery:",e,"field:",t);const r=new RegExp(`\\(${t}\\s+LIKE\\s+'[^']*'\\)\\s+AND\\s+|\\s+AND\\s+\\(${t}\\s+LIKE\\s+'[^']*'\\)`,"g");return e.replace(r,"").trim()},p=t=>{const{featureLayer:r,autocompleteFields:n,setFinalQuery:a,timeSlider:o,advanceSearchData:c,appQuery:l}=t,[p,m]=(t=>{const r={},n={};return t.forEach((t=>{const[a,o]=e.useState([]);r[t]=a,n[`set_${t}`]=o})),[r,n]})(n);return e.useEffect((()=>{if(null===r||!c)return;const e=(e,t)=>e.features.map((e=>{const r=e.attributes[t];return null!==r?r:null})).filter((e=>null!==e));Promise.all([(()=>{const t="Site_Type";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Site_Type([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Discipline";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Proj_Discipline([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Initiative";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Proj_Initiative([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Site_Place";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Site_Place([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Site_Name";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Site_Name([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Funding_Agency";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Proj_Funding_Agency([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_AON";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Proj_AON([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Contact_Name";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Proj_Contact_Name([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Institution";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Proj_Institution([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Award";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Proj_Award([...new Set(e)].sort(((e,t)=>e.localeCompare(t))))))])}),[c,o,r,l]),e.useEffect((()=>{if(null===r)return;const e=((e,t)=>{const r=[];Object.entries(e).forEach((([e,t])=>{if(Array.isArray(t)&&t.length>0){const n=t.filter((e=>""!==e));if(n.length>0){const t=n.map((t=>`${e} LIKE '%${t}%'`)).join(" OR ");r.push(`(${t})`)}}}));const n=`(Proj_Start_Year <= ${t[1]} AND Proj_End_Year >= ${t[0]})`;return r.length?r.join(" AND ")+` AND ${n}`:n})(c,o);a(e)}),[o,r,c,o,l]),{state:p,fetchFeatures:async e=>{const t=new s.default({outFields:["*"],where:e,returnGeometry:!0});try{const{features:e}=await r.queryFeatures(t),n=[];return e.forEach((e=>{n.push(((e,t)=>{const r={longitude:0,latitude:0};for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return t&&"point"===t.type&&"longitude"in t&&"latitude"in t&&(r.longitude=t.longitude,r.latitude=t.latitude),r})(e.attributes,e.geometry))})),n}catch(e){console.error("Error fetching features:",e)}}}};function m(){return m=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},m.apply(null,arguments)}function h(e){const{data:t,autocompleteData:r,setAdvanceSearchData:n,label:a,stateLabel:s,selectedValues:i=[]}=e;function u(e){return e.trim().toLowerCase().replace(/\s+/g," ")}return o.default.createElement("div",{className:"autocomplete-input-wrapper"},o.default.createElement(c.default,{value:i,multiple:!0,"data-cy":`AOV-autocomplete-${s}`,id:"combo-box-demo",options:t,disabled:0===t.length,isOptionEqualToValue:(e,t)=>u(e)===u(t),sx:{display:"flex",justifyContent:"center",alignContent:"center"},onChange:(e,t)=>((e,t,a)=>{const o={...r,[a]:t.map((e=>e.trim().replace(/\s+/g," ")))||[]};n(o)})(0,t,s),renderInput:e=>o.default.createElement(l.default,m({style:{backgroundColor:"#fff",color:"#000",borderRadius:10},label:a},e,{placeholder:0===t.length?"No matching fields":a}))}))}!function(e,t){void 0===t&&(t={});var r=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===r&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}(".advance-searc-container{display:flex;height:auto;justify-content:center;margin:auto;width:100%}.autcomplete-container{align-items:center;display:flex;flex-direction:column;justify-content:center;width:100%}.autocomplete-input-wrapper{margin:5px 0;width:100%}");const f={Site_Type:"Observation Type",Proj_Discipline:"Discipline",Proj_Initiative:"Network Initiative",Site_Place:"Place",Site_Name:"Site Name",Proj_Funding_Agency:"Funding Agency",Proj_AON:"NSF AON?",Proj_Contact_Name:"Contact Name",Proj_Institution:"Institution",Proj_Award:"Award Number"};exports.ESRIAdvanceSearchAOV=function(e){const{autocompleteFields:t,featureLayer:r,timeSlider:n,advanceSearchData:a,setAdvanceSearchData:s,setFinalQuery:c,appQuery:l}=e,{state:i}=p({autocompleteFields:t,featureLayer:r,timeSlider:n,advanceSearchData:a,setAdvanceSearchData:s,setFinalQuery:c,appQuery:l}),u=o.default.createElement("div",{className:"autcomplete-container"},t.map((e=>o.default.createElement(h,{key:e,data:i[e],autocompleteData:a,setAdvanceSearchData:s,label:f[e],stateLabel:e,selectedValues:a[e]}))));return o.default.createElement("div",{className:"advance-searc-container","data-cy":"AOV-advance-search-container"},u)},exports.useWithAdvanceSearch=p; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@arcgis/core/rest/support/Query.js"),r=require("@mui/material/Autocomplete"),n=require("@mui/material/TextField");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=a(e),s=a(t),c=a(r),l=a(n);const i=(e,t)=>new s.default({outFields:[e],where:t,returnDistinctValues:!0}),u=(e,t,r)=>{const n=Object.entries(t).map((([e,t])=>({key:e,value:t})));if(!n.some((e=>e.value.length>0)))return r;const a=n.filter((t=>t.key!==e)),o=[];return a.forEach((e=>{const{key:t,value:r}=e;if(Array.isArray(r)&&r.length>0){const e=r.filter((e=>""!==e)).map((e=>`'${e}'`)).join(",");o.push(`${t} IN (${e})`)}})),0===o.length?r:o.join(" AND ")+` AND (${r})`},d=(e,t)=>{console.log("appQuery:",e,"field:",t);const r=new RegExp(`\\(${t}\\s+LIKE\\s+'[^']*'\\)\\s+AND\\s+|\\s+AND\\s+\\(${t}\\s+LIKE\\s+'[^']*'\\)`,"g");return e.replace(r,"").trim()},p=t=>{const{featureLayer:r,autocompleteFields:n,setFinalQuery:a,timeSlider:o,advanceSearchData:c,appQuery:l}=t,[p,m]=(t=>{const r={},n={};return t.forEach((t=>{const[a,o]=e.useState([]);r[t]=a,n[`set_${t}`]=o})),[r,n]})(n);return e.useEffect((()=>{if(null===r||!c)return;const e=(e,t)=>e.features.map((e=>{const r=e.attributes[t];return null!==r?r:null})).filter((e=>null!==e));Promise.all([(()=>{const t="Site_Type";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Site_Type([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Discipline";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Proj_Discipline([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Initiative";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Proj_Initiative([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Site_Place";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Site_Place([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Site_Name";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Site_Name([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Funding_Agency";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Proj_Funding_Agency([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_AON";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Proj_AON([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Contact_Name";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Proj_Contact_Name([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Institution";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Proj_Institution([...new Set(e)].sort(((e,t)=>e.localeCompare(t)))))),(()=>{const t="Proj_Award";let n=l.includes(t)?d(l,t):l;const a=u(t,c,n);return r.queryFeatures(i(t,a)).then((r=>e(r,t)))})().then((e=>m.set_Proj_Award([...new Set(e)].sort(((e,t)=>e.localeCompare(t))))))])}),[c,o,r,l]),e.useEffect((()=>{if(null===r)return;const e=((e,t)=>{const r=[];Object.entries(e).forEach((([e,t])=>{if(Array.isArray(t)&&t.length>0){const n=t.filter((e=>""!==e));if(n.length>0){const t=n.map((t=>`${e} LIKE '%${t}%'`)).join(" OR ");r.push(`(${t})`)}}}));const n=`(Proj_Start_Year <= ${t[1]} AND Proj_End_Year >= ${t[0]})`;return r.length?r.join(" AND ")+` AND ${n}`:n})(c,o);a(e)}),[o,r,c,o,l]),{state:p,fetchFeatures:async e=>{const t=new s.default({outFields:["*"],where:e,returnGeometry:!0});try{const{features:e}=await r.queryFeatures(t),n=[];return e.forEach((e=>{n.push(((e,t)=>{const r={longitude:0,latitude:0};for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return t&&"point"===t.type&&"longitude"in t&&"latitude"in t&&(r.longitude=t.longitude,r.latitude=t.latitude),r})(e.attributes,e.geometry))})),n}catch(e){console.error("Error fetching features:",e)}}}};function m(){return m=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},m.apply(null,arguments)}function h(e){const{data:t,autocompleteData:r,setAdvanceSearchData:n,label:a,stateLabel:s,selectedValues:i=[]}=e;function u(e){return e.trim().toLowerCase().replace(/\s+/g," ")}return o.default.createElement("div",{className:"autocomplete-input-wrapper"},o.default.createElement(c.default,{value:i,multiple:!0,"data-cy":`AOV-autocomplete-${s}`,id:"combo-box-demo",options:t,disabled:0===t.length,isOptionEqualToValue:(e,t)=>u(e)===u(t),sx:{display:"flex",justifyContent:"center",alignContent:"center"},onChange:(e,t)=>((e,t,a)=>{const o={...r,[a]:t.map((e=>e.trim().replace(/\s+/g," ")))||[]};n(o)})(0,t,s),renderInput:e=>o.default.createElement(l.default,m({style:{backgroundColor:"#fff",color:"#000",borderRadius:10}},e,{placeholder:0===t.length?"No matching fields":a}))}))}!function(e,t){void 0===t&&(t={});var r=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===r&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}(".advance-searc-container{display:flex;height:auto;justify-content:center;margin:auto;width:100%}.autcomplete-container{align-items:center;display:flex;flex-direction:column;justify-content:center;width:100%}.autocomplete-input-wrapper{margin:5px 0;width:100%}");const f={Site_Type:"Observation Type",Proj_Discipline:"Discipline",Proj_Initiative:"Network Initiative",Site_Place:"Place",Site_Name:"Site Name",Proj_Funding_Agency:"Funding Agency",Proj_AON:"NSF AON?",Proj_Contact_Name:"Contact Name",Proj_Institution:"Institution",Proj_Award:"Award Number"};exports.ESRIAdvanceSearchAOV=function(e){const{autocompleteFields:t,featureLayer:r,timeSlider:n,advanceSearchData:a,setAdvanceSearchData:s,setFinalQuery:c,appQuery:l}=e,{state:i}=p({autocompleteFields:t,featureLayer:r,timeSlider:n,advanceSearchData:a,setAdvanceSearchData:s,setFinalQuery:c,appQuery:l}),u=o.default.createElement("div",{className:"autcomplete-container"},t.map((e=>o.default.createElement(h,{key:e,data:i[e],autocompleteData:a,setAdvanceSearchData:s,label:f[e],stateLabel:e,selectedValues:a[e]}))));return o.default.createElement("div",{className:"advance-searc-container","data-cy":"AOV-advance-search-container"},u)},exports.useWithAdvanceSearch=p; |
{ | ||
"name": "sel-esri-advance-search-aov", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -60,3 +60,2 @@ /* | ||
}} | ||
label={label} | ||
{...params} | ||
@@ -63,0 +62,0 @@ placeholder={data.length === 0 ? "No matching fields" : label} |
178444
780