this code is...
/** @jsx jsx */
import { React, AllWidgetProps, BaseWidget, jsx, React } from "jimu-core";
import { Tabs, Tab, Label, Card, CardHeader, CardBody, CardFooter, Switch, Input, Row, Col, Form, FormGroup, Container, Button } from 'jimu-ui'
import { TrashOutlined } from 'jimu-icons/outlined/editor/trash'
import { JimuMapViewComponent, JimuMapView } from "jimu-arcgis";
import Sketch = require("esri/widgets/Sketch");
import GraphicsLayer = require("esri/layers/GraphicsLayer");
import { any } from "prop-types";
import "../css/style.css"
import { CardImg, CardTitle } from "reactstrap/lib";
export default class Widget extends React.PureComponent<AllWidgetProps<any>, any> {
myRef = React.createRef<HTMLDivElement>();
state = {
jimuMapView: null,
currentWidget: null,
switch : false,
layersOnMap: []
}
activeViewChangeHandler = (jmv: JimuMapView) => {
alert('aqui')
if (this.state.jimuMapView) {
if (this.state.currentWidget) {
this.state.currentWidget.destroy();
}
}
if (jmv) {
this.setState({
jimuMapView: jmv as JimuMapView
});
if (this.myRef.current) {
//const container = document.createElement("div");
//this.myRef.current.appendChild(container);
const layer = new GraphicsLayer();
jmv.view.map.add(layer);
const sketch = new Sketch({
layer: layer,
view: jmv.view,
container: document.createElement("div"),
creationMode: "update"
});
jmv.view.ui.add(sketch, "top-right");
this.setState({
currentWidget: sketch
});
} else {
console.error('could not find this.myRef.current');
}
}
};
componentDidUpdate = evt => {
if (this.props.useMapWidgetIds.length === 0) {
if (this.state.currentWidget) {
this.state.currentWidget.destroy();
}
}
};
render() {
let jmc = <p>Please select a map.</p>;
if (
this.props.hasOwnProperty("useMapWidgetIds") &&
this.props.useMapWidgetIds &&
this.props.useMapWidgetIds[0]
) {
alert('jmc')
jmc = (
<JimuMapViewComponent
useMapWidgetIds={this.props.useMapWidgetIds}
onActiveViewChange={this.activeViewChangeHandler}
/>
);
return (
<Container fluid>
<Row>
<Col>
<Tabs
defaultValue="tab-1"
onChange={function noRefCheck(){}}
onClose={function noRefCheck(){}}
>
<Tab className="tab-select" id="tab-1" title="Atual">
<div width="100%" >
<Card>
<CardBody>
<Label className="menu" size="default"><TrashOutlined /> Apagar Seleção</Label> <br/>
<Label className="menu" size="default">
<div className="widget-js-api-widget-wrapper jimu-widget" >
<div ref={this.myRef}></div>
{jmc}
</div>
</Label>
</CardBody>
<CardFooter className="d-flex justify-content-between">
<Label size="default">
<Switch
aria-label="Switch"
checked={this.state.switch}
onClick={() => this.setState({ switch: !this.state.switch })}
/>
Habilitar Streaming
</Label>
</CardFooter>
</Card>
</div>
</Tab>
<Tab className="tab-select" id="tab-2" title="Histórica">
<div width="100%" >
<Card>
<CardHeader>
<Label className="menu" size="default"><TrashOutlined /> Apagar Seleção</Label> <br/>
<Label className="menu" size="default">
<div className="widget-js-api-widget-wrapper jimu-widget" style={{ overflow: "auto" }}>
<div className="here" ref={this.myRef}></div>
{jmc}
</div>
</Label>
</CardHeader>
<CardBody>
<Form>
<FormGroup>
<Row>
<Col sm="12">
<Input id="busca_datas_hist" name="busca_datas_hist" placeholder="<i class='icon-search'></i>" type="search" />
</Col>
</Row>
</FormGroup>
<FormGroup>
<Row>
<Col sm="6">
<Label for="datas_historicas">Datas</Label>
<br/>
<Input id="datas_historicas" multiple name="datas_historicas" type="select" className="lista_datas">
<option>30/08/2022</option>
<option>29/08/2022</option>
<option>28/08/2022</option>
</Input>
</Col>
<Col sm="6">
<CardTitle tag="h5">Miniatura</CardTitle>
</Col>
</Row>
</FormGroup>
</Form>
</CardBody>
<CardFooter className="d-flex justify-content-between">
<Button className="botao_sucesso">Adicionar ao Mapa</Button>
</CardFooter>
</Card>
</div>
</Tab>
</Tabs>
</Col>
</Row>
</Container>
);
}
}