Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
@esri/calcite-components-react
Advanced tools
A set of React components that wrap calcite components
A set of React components that wrap Calcite Components. An application using this package is provided in the calcite-components-examples
repo.
npm install --save @esri/calcite-components-react
This package includes the compatible version of the main component library as a dependency, so no need to install @esri/calcite-components
separately.
There are two builds that are provided by the standard calcite-components
package.
Custom Elements is the recommended build when using frontend frameworks, such as React. To use this build, you will need to set the path to the calcite-components
assets. You can either use local assets, which will be explained in a subsequent step, or assets hosted on a CDN.
import { setAssetPath } from "@esri/calcite-components/dist/components";
// Local assets
setAssetPath(window.location.href);
// CDN hosted assets
// setAssetPath("https://unpkg.com/@esri/calcite-components/dist/calcite/assets");
Next, you need to import each component you use from the standard calcite-component
package's custom elements build. This will automatically define the custom elements on the window. Then import the same components from calcite-components-react
.
import "@esri/calcite-components/dist/components/calcite-button";
import "@esri/calcite-components/dist/components/calcite-icon";
import "@esri/calcite-components/dist/components/calcite-slider";
import { CalciteButton, CalciteIcon, CalciteSlider } from "@esri/calcite-components-react";
When using the Dist build, you'll need to manually define the custom elements on the window. You can also choose between local and CDN hosted assets.
import { defineCustomElements } from "@esri/calcite-components/dist/loader";
// Local assets
defineCustomElements(window);
// CDN hosted assets
// defineCustomElements(window, {
// resourcesUrl: "https://unpkg.com/@esri/calcite-components/dist/calcite/assets"
// });
Since you manually defined the custom elements on the window, you only need to import the individual components from calcite-components-react
.
import { CalciteButton, CalciteIcon, CalciteSlider } from "@esri/calcite-components-react";
Import the global stylesheet into your app (only do this once):
import "@esri/calcite-components/dist/calcite/calcite.css";
Some components (icon, date-picker) rely on assets being available at a particular path. If using assets locally, you'll need to copy these over to your public folder. Something like:
cp -r node_modules/@esri/calcite-components/dist/calcite/assets/* ./public/assets/
Because React uses a synthetic event system, the custom events emitted from calcite components won't work with JSX in React. For example, say you want to update some value when the calcite-slider
component changes. When using the standard web components, you need to save a ref to the element, and add a listener:
const sliderEl = useRef(null);
const [sliderValue, setSliderValue] = useState(50);
function onUpdate(event) {
setSliderValue(event.target.value);
}
// need to access the dom node to set custom event listeners for props that aren't strings / numbers
// https://stenciljs.com/docs/react#properties-and-events
useEffect(
(_) => {
sliderEl.current.addEventListener("calciteSliderUpdate", onUpdate);
},
[sliderEl],
);
Using calcite-components-react
, these events are connected for you:
const [sliderValue, setSliderValue] = useState(50);
<CalciteSlider onCalciteSliderUpdate={(e) => setSliderValue(e.target.value)} />;
If you're using TypeScript, you'll also get increased type safety for your event listeners, props, etc.
We welcome contributions to this project. See the main calcite-components CONTRIBUTING.md for an overview of contribution guidelines.
COPYRIGHT © 2021 Esri
All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
This material is licensed for use under the Esri Master License Agreement (MLA), and is bound by the terms of that agreement. You may redistribute and use this code without modification, provided you adhere to the terms of the MLA and include this copyright notice.
See use restrictions at http://www.esri.com/legal/pdfs/mla_e204_e300/english
For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA
email: contracts@esri.com
FAQs
A set of React components that wrap calcite components
The npm package @esri/calcite-components-react receives a total of 4,445 weekly downloads. As such, @esri/calcite-components-react popularity was classified as popular.
We found that @esri/calcite-components-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 42 open source maintainers collaborating on the project.
Did you know?
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.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.