@ssplib/react-components 0.0.267 → 0.0.268

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.
@@ -0,0 +1,5 @@
1
+ import { LatLngExpression } from 'leaflet';
2
+ declare const AnimatedMarker: ({ coords }: {
3
+ coords: LatLngExpression;
4
+ }) => any;
5
+ export default AnimatedMarker;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const leaflet_1 = __importDefault(require("leaflet"));
7
+ const react_1 = require("react");
8
+ const react_leaflet_1 = require("react-leaflet");
9
+ const AnimatedMarker = ({ coords }) => {
10
+ const map = (0, react_leaflet_1.useMap)();
11
+ (0, react_1.useEffect)(() => {
12
+ // Criar o ícone do marcador com HTML
13
+ const markerElement = document.createElement('div');
14
+ markerElement.style.position = 'relative';
15
+ markerElement.style.width = '20px';
16
+ markerElement.style.height = '20px';
17
+ markerElement.style.backgroundColor = 'rgba(0, 100, 255, 0.6)';
18
+ markerElement.style.borderRadius = '50%';
19
+ markerElement.style.animation = 'sonarPulse 2s infinite';
20
+ // Criar o efeito de pulso (onda ao redor)
21
+ const pulseElement = document.createElement('div');
22
+ pulseElement.style.position = 'absolute';
23
+ pulseElement.style.top = '50%';
24
+ pulseElement.style.left = '50%';
25
+ pulseElement.style.width = '100%';
26
+ pulseElement.style.height = '100%';
27
+ pulseElement.style.backgroundColor = 'rgba(0, 100, 255, 0.4)';
28
+ pulseElement.style.borderRadius = '50%';
29
+ pulseElement.style.transform = 'translate(-50%, -50%) scale(1)';
30
+ pulseElement.style.animation = 'sonarPulse 2s infinite';
31
+ markerElement.appendChild(pulseElement);
32
+ // Adicionar a animação no CSS global
33
+ const keyframes = `
34
+ @keyframes sonarPulse {
35
+ 0% {
36
+ transform: translate(-50%, -50%) scale(1);
37
+ opacity: 0.8;
38
+ }
39
+ 100% {
40
+ transform: translate(-50%, -50%) scale(2);
41
+ opacity: 0;
42
+ }
43
+ }`;
44
+ const styleElement = document.createElement('style');
45
+ styleElement.innerHTML = keyframes;
46
+ document.head.appendChild(styleElement);
47
+ // Criar o marcador no mapa
48
+ const marker = leaflet_1.default.marker(coords, {
49
+ icon: leaflet_1.default.divIcon({
50
+ className: '',
51
+ html: markerElement.outerHTML,
52
+ iconSize: [40, 40],
53
+ iconAnchor: [0, 5], // Centraliza o ícone (metade do width e height)
54
+ }),
55
+ });
56
+ marker.addTo(map);
57
+ // Limpar marcador e estilos ao desmontar
58
+ return () => {
59
+ map.removeLayer(marker);
60
+ document.head.removeChild(styleElement);
61
+ };
62
+ }, [map, coords]);
63
+ return null; // Nenhum componente visível, já que o marcador é diretamente manipulado pelo Leaflet
64
+ };
65
+ exports.default = AnimatedMarker;
@@ -0,0 +1,10 @@
1
+ import { LatLngExpression } from 'leaflet';
2
+ import { ReactElement } from 'react';
3
+ interface DraggableMarkerProps {
4
+ startCoord: LatLngExpression;
5
+ onChange?: (coord: LatLngExpression) => void;
6
+ children?: ReactElement;
7
+ showPopup?: boolean;
8
+ }
9
+ export default function DraggableMarker({ ...props }: DraggableMarkerProps): JSX.Element;
10
+ export {};
@@ -0,0 +1,64 @@
1
+ 'use client';
2
+ "use strict";
3
+ var __rest = (this && this.__rest) || function (s, e) {
4
+ var t = {};
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
6
+ t[p] = s[p];
7
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
8
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
9
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
10
+ t[p[i]] = s[p[i]];
11
+ }
12
+ return t;
13
+ };
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const leaflet_1 = require("leaflet");
19
+ const react_1 = require("react");
20
+ const react_leaflet_1 = require("react-leaflet");
21
+ const react_2 = __importDefault(require("react"));
22
+ function DraggableMarker(_a) {
23
+ var props = __rest(_a, []);
24
+ const [position, setPosition] = (0, react_1.useState)(props.startCoord);
25
+ const markerRef = (0, react_1.useRef)(null);
26
+ const eventHandlers = (0, react_1.useMemo)(() => ({
27
+ dragend() {
28
+ const marker = markerRef.current;
29
+ if (marker != null) {
30
+ setPosition(marker.getLatLng());
31
+ }
32
+ },
33
+ }), []);
34
+ (0, react_leaflet_1.useMapEvents)({
35
+ click(e) {
36
+ setPosition({ lat: e.latlng.lat, lng: e.latlng.lng });
37
+ },
38
+ });
39
+ (0, react_1.useEffect)(() => {
40
+ if (!position)
41
+ return;
42
+ if (markerRef.current) {
43
+ markerRef.current.closePopup();
44
+ if (props.showPopup)
45
+ markerRef.current.openPopup();
46
+ }
47
+ if (props.onChange)
48
+ props.onChange(position);
49
+ // eslint-disable-next-line react-hooks/exhaustive-deps
50
+ }, [position, props.onChange]);
51
+ return (react_2.default.createElement(react_leaflet_1.Marker, { icon: redIcon, draggable: true, eventHandlers: eventHandlers, position: position, ref: markerRef },
52
+ react_2.default.createElement(react_leaflet_1.Popup, { className: 'custom-popup' }, props.children)));
53
+ }
54
+ exports.default = DraggableMarker;
55
+ //#region Marker Icon
56
+ const redIcon = (0, leaflet_1.icon)({
57
+ iconUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-icon.png',
58
+ shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-shadow.png',
59
+ iconSize: [25, 41],
60
+ iconAnchor: [12, 41],
61
+ popupAnchor: [1, -34],
62
+ shadowSize: [41, 41],
63
+ className: 'leaflet-red-marker',
64
+ });
@@ -0,0 +1,14 @@
1
+ import { BoxProps } from '@mui/material';
2
+ import 'leaflet-defaulticon-compatibility';
3
+ import 'leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.css';
4
+ import 'leaflet/dist/leaflet.css';
5
+ import { LatLngExpression } from 'leaflet';
6
+ import { ReactElement } from 'react';
7
+ export interface MapProps {
8
+ firstCoords: any;
9
+ onCoordsChange?: (coords: any) => void;
10
+ pulseMarkerList?: LatLngExpression[];
11
+ popupContent?: ReactElement;
12
+ style?: BoxProps;
13
+ }
14
+ export declare function Map(props: MapProps): JSX.Element;
@@ -0,0 +1,23 @@
1
+ 'use client';
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.Map = void 0;
8
+ const material_1 = require("@mui/material");
9
+ const react_leaflet_1 = require("react-leaflet");
10
+ const DraggableMarker_1 = __importDefault(require("./DraggableMarker"));
11
+ const react_1 = __importDefault(require("react"));
12
+ require("leaflet-defaulticon-compatibility");
13
+ require("leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.css");
14
+ require("leaflet/dist/leaflet.css");
15
+ const AnimatedMarker_1 = __importDefault(require("./AnimatedMarker"));
16
+ function Map(props) {
17
+ return (react_1.default.createElement(material_1.Box, Object.assign({ borderRadius: 2, border: '2px solid #c7c7c7', overflow: 'hidden' }, props.style),
18
+ react_1.default.createElement(react_leaflet_1.MapContainer, { center: props.firstCoords, zoom: 19, scrollWheelZoom: true, style: { height: '75vh', width: '100%' } },
19
+ react_1.default.createElement(react_leaflet_1.TileLayer, { attribution: '\u00A9 <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' }),
20
+ props.pulseMarkerList && props.pulseMarkerList.map((coord, idx) => react_1.default.createElement(AnimatedMarker_1.default, { key: JSON.stringify(coord) + idx, coords: coord })),
21
+ react_1.default.createElement(DraggableMarker_1.default, { startCoord: props.firstCoords, onChange: props.onCoordsChange, showPopup: typeof props.popupContent !== 'undefined' }, props.popupContent))));
22
+ }
23
+ exports.Map = Map;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const Map: import("react").ComponentType<import("./Map").MapProps>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.Map = void 0;
30
+ const dynamic_1 = __importDefault(require("next/dynamic"));
31
+ exports.Map = (0, dynamic_1.default)(() => Promise.resolve().then(() => __importStar(require('./Map'))).then((x) => x.Map), { ssr: false });
package/index.d.ts CHANGED
@@ -39,4 +39,5 @@ import { SspComponentsProvider } from './components/providers/SspComponentsProvi
39
39
  import Button from './components/utils/Bt';
40
40
  import Menu from './components/utils/CustomMenu';
41
41
  import GenericInput from './components/form/input/GenericInput';
42
- export { CheckBox, CheckBoxWarning, DatePicker, GenericDatePicker, TimePicker, FileUpload, ActiveInput, AutoComplete, FetchAutoComplete, GenericFetchAutoComplete, Input, GenericInput, MaskInput, MultInput, GenericMultInput, GenericMaskInput, OtherCheckBox, Stepper, StepperBlock, Switch, SwitchWatch, ToggleVisibility, Table, NavBar, FormProvider, OAuthProvider, AUTH_COOKIE_NAME, AuthContext, FormContext, KeycloakAuthProvider, CheckBoxAdditional, RequiredCheckBoxGroup, FixedAutoComplete, Category, Field, FieldLabel, File, DropFileUpload, MODAL, SspComponentsProvider, TabNavBar, Button, Menu, };
42
+ import { Map } from './components/map';
43
+ export { CheckBox, CheckBoxWarning, DatePicker, GenericDatePicker, TimePicker, FileUpload, ActiveInput, AutoComplete, FetchAutoComplete, GenericFetchAutoComplete, Input, GenericInput, MaskInput, MultInput, GenericMultInput, GenericMaskInput, OtherCheckBox, Stepper, StepperBlock, Switch, SwitchWatch, ToggleVisibility, Table, NavBar, FormProvider, OAuthProvider, AUTH_COOKIE_NAME, AuthContext, FormContext, KeycloakAuthProvider, CheckBoxAdditional, RequiredCheckBoxGroup, FixedAutoComplete, Category, Field, FieldLabel, File, DropFileUpload, MODAL, SspComponentsProvider, TabNavBar, Button, Menu, Map };
package/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Menu = exports.Button = exports.TabNavBar = exports.SspComponentsProvider = exports.MODAL = exports.DropFileUpload = exports.File = exports.FieldLabel = exports.Field = exports.Category = exports.FixedAutoComplete = exports.RequiredCheckBoxGroup = exports.CheckBoxAdditional = exports.KeycloakAuthProvider = exports.FormContext = exports.AuthContext = exports.AUTH_COOKIE_NAME = exports.OAuthProvider = exports.FormProvider = exports.NavBar = exports.Table = exports.ToggleVisibility = exports.SwitchWatch = exports.Switch = exports.StepperBlock = exports.Stepper = exports.OtherCheckBox = exports.GenericMaskInput = exports.GenericMultInput = exports.MultInput = exports.MaskInput = exports.GenericInput = exports.Input = exports.GenericFetchAutoComplete = exports.FetchAutoComplete = exports.AutoComplete = exports.ActiveInput = exports.FileUpload = exports.TimePicker = exports.GenericDatePicker = exports.DatePicker = exports.CheckBoxWarning = exports.CheckBox = void 0;
6
+ exports.Map = exports.Menu = exports.Button = exports.TabNavBar = exports.SspComponentsProvider = exports.MODAL = exports.DropFileUpload = exports.File = exports.FieldLabel = exports.Field = exports.Category = exports.FixedAutoComplete = exports.RequiredCheckBoxGroup = exports.CheckBoxAdditional = exports.KeycloakAuthProvider = exports.FormContext = exports.AuthContext = exports.AUTH_COOKIE_NAME = exports.OAuthProvider = exports.FormProvider = exports.NavBar = exports.Table = exports.ToggleVisibility = exports.SwitchWatch = exports.Switch = exports.StepperBlock = exports.Stepper = exports.OtherCheckBox = exports.GenericMaskInput = exports.GenericMultInput = exports.MultInput = exports.MaskInput = exports.GenericInput = exports.Input = exports.GenericFetchAutoComplete = exports.FetchAutoComplete = exports.AutoComplete = exports.ActiveInput = exports.FileUpload = exports.TimePicker = exports.GenericDatePicker = exports.DatePicker = exports.CheckBoxWarning = exports.CheckBox = void 0;
7
7
  const CheckBox_1 = __importDefault(require("./components/form/checkbox/CheckBox"));
8
8
  exports.CheckBox = CheckBox_1.default;
9
9
  const CheckBoxWarning_1 = __importDefault(require("./components/form/checkbox/CheckBoxWarning"));
@@ -88,3 +88,5 @@ const CustomMenu_1 = __importDefault(require("./components/utils/CustomMenu"));
88
88
  exports.Menu = CustomMenu_1.default;
89
89
  const GenericInput_1 = __importDefault(require("./components/form/input/GenericInput"));
90
90
  exports.GenericInput = GenericInput_1.default;
91
+ const map_1 = require("./components/map");
92
+ Object.defineProperty(exports, "Map", { enumerable: true, get: function () { return map_1.Map; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssplib/react-components",
3
- "version": "0.0.267",
3
+ "version": "0.0.268",
4
4
  "description": "SSP React Components",
5
5
  "main": "index.js",
6
6
  "author": "Pedro Henrique <sr.hudrick@gmail.com>",
@@ -20,7 +20,10 @@
20
20
  "keycloak-js": "^25.0.1",
21
21
  "react-toastify": "^10.0.4",
22
22
  "axios": "^1.6.7",
23
- "react-dropzone": "^14.2.3"
23
+ "react-dropzone": "^14.2.3",
24
+ "leaflet": "^1.9.4",
25
+ "leaflet-defaulticon-compatibility": "^0.1.2",
26
+ "react-leaflet": "^4.2.1"
24
27
  },
25
28
  "devDependencies": {
26
29
  "@types/lodash.get": "^4.4.7",