New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sel-esri-advance-search-aov

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sel-esri-advance-search-aov

## Overview

  • 2.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

useWithAdvanceSearch Hook

Overview

The useWithAdvanceSearch hook is designed to manage state for dynamic fields in a React application. It uses data from a feature layer and a time query to fetch unique field values and update the state accordingly.

Installation

To use this hook in your project, ensure you have the required dependencies:

npm install sel-esri-advance-search-aov

Usage Component

The ESRIAdvanceSearchAOV component can be used directly in your React application as shown below:

import ESRIAdvanceSearchAOV from 'esri-advance-search';

const MyComponent = ({ featureLayer, autocompleteFields, setFinalQuery }) => {
  return (
    <ESRIAdvanceSearchAOV
      featureLayer={featureLayer}
      timeQuery={"Proj_Start_Year <= 2026 AND Proj_End_Year >= 2017"}
      autocompleteFields={autocompleteFields}
      setFinalQuery={setFinalQuery}
    />
  );
};

Usage Custom Hook

You can use the useWithAdvanceSearch custom hook for more control over the advanced search functionalities and get the attributes from the advance search.

import { useWithAdvanceSearch } from 'esri-advance-search';

const MyComponent = ({ featureLayer, autocompleteFields, setFinalQuery }) => {
  const { fetchFeatures } = useWithAdvanceSearch({
    featureLayer,
    timeQuery: "Proj_Start_Year <= 2026 AND Proj_End_Year >= 2017",
    autocompleteFields,
    setFinalQuery,
  });

  // Example usage of fetchFeatures
  useEffect(() => {
    const fetchData = async () => {
      // pass query to fetchFeatures()
      const features = await fetchFeatures("Proj_Status = 'Active'");
    };
    fetchData();
  }, [fetchFeatures]);

  return <div>My ESRI Advanced Search Component</div>;
};

API ESRIAdvanceSearchAOV

Props:

  • featureLayer (Object): The ESRI Feature Layer to be queried.
  • timeQuery (string): The time-based query string.
  • autocompleteFields (Array): Array of fields for autocompletion.
  • setFinalQuery (function): Function to set the final query string.

useWithAdvanceSearch

Parameters:

  • featureLayer (Object): The ESRI Feature Layer to be queried.
  • timeQuery (string): The time-based query string.
  • autocompleteFields (Array): Array of fields for autocompletion.
  • setFinalQuery (function): Function to set the final query string.

Returns:

  • state (Object): State object with keys corresponding to the autocompleteFields array.
  • autocompleteData (Array): Array containing autocomplete data.
  • setAutocompleteData (function): Function to update the autocomplete data.
  • fetchFeatures (function): Function to fetch features based on a query string.

Example

Here's a more detailed example demonstrating the usage of useWithAdvanceSearch:

import React, { useState } from 'react';
import { useWithAdvanceSearch } from 'esri-advance-search';

const MyComponent = ({ featureLayer }) => {
  const [finalQuery, setFinalQuery] = useState('');
  const autocompleteFields = ['Project_Name', 'Project_Manager'];

  const { state, autocompleteData, setAutocompleteData, fetchFeatures } = useWithAdvanceSearch({
    featureLayer,
    timeQuery: "Proj_Start_Year <= 2026 AND Proj_End_Year >= 2017",
    autocompleteFields,
    setFinalQuery,
  });

  const handleSearch = async () => {
    const features = await fetchFeatures(finalQuery);
  };

  return (
    <div>
      <button onClick={handleSearch}>Search</button>
      {/* Render UI based on state and autocompleteData */}
    </div>
  );
};

Important Notes

Ensure the featureLayer prop is valid and not null before using the hook. The hook will fetch and update field values whenever featureLayer, autocompleteData, timeQuery, or autocompleteFields change. You can manage autocompleteData using the provided setAutocompleteData function.

Error Handling

If there is an error updating the fields, it will be logged to the console with the message: "Error updating fields:"

Development

CI/CD Pipeline Diagram

Publishing the Package

To publish the npm package, follow these steps:

  1. Update the version in package.json:
{
    "version": "1.0.3"
}
  1. Commit your changes and push to GitHub:
git add .
git commit -m "Update version to 1.0.3"
git push origin main
  1. Create a Release on GitHub
  2. Go to the Releases page of your repository.
  3. Click on Draft a new release.
  4. Fill out the form:
  5. Tag version: v1.0.3
  6. Release title: v1.0.3
  7. Description: Describe the changes in this release.
  8. Click Publish release.
  9. Check on the Actions tab to see full workflow.
  10. Confirm it was published.

FAQs

Package last updated on 05 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc