UNPKG

@selfcommunity/react-ui

Version:

React UI Components to integrate a Community created with SelfCommunity Platform.

34 lines (33 loc) 2.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = tslib_1.__importStar(require("react")); const react_intl_1 = require("react-intl"); const material_1 = require("@mui/material"); const styles_1 = require("@mui/material/styles"); const Icon_1 = tslib_1.__importDefault(require("@mui/material/Icon")); const LocationAutocomplete_1 = tslib_1.__importDefault(require("../../../LocationAutocomplete")); const DialogContent_1 = tslib_1.__importDefault(require("@mui/material/DialogContent")); const classnames_1 = tslib_1.__importDefault(require("classnames")); const constants_1 = require("../../constants"); const classes = { root: `${constants_1.PREFIX}-layer-location-root`, title: `${constants_1.PREFIX}-layer-title`, content: `${constants_1.PREFIX}-layer-content` }; const Root = (0, styles_1.styled)(material_1.Box, { name: constants_1.PREFIX, slot: 'LayerLocationRoot' })(() => ({})); const LocationLayer = react_1.default.forwardRef((props, ref) => { // Props const { className, onClose, onSave, defaultValue = null } = props, rest = tslib_1.__rest(props, ["className", "onClose", "onSave", "defaultValue"]); // STATE const [value, setValue] = (0, react_1.useState)(defaultValue); // HANDLERS const handleSave = (0, react_1.useCallback)(() => onSave(value), [value, onSave]); const handleChange = (0, react_1.useCallback)((location) => setValue(location), []); return (0, jsx_runtime_1.jsxs)(Root, Object.assign({ ref: ref, className: (0, classnames_1.default)(className, classes.root) }, rest, { children: [(0, jsx_runtime_1.jsxs)(material_1.DialogTitle, Object.assign({ className: classes.title }, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: onClose }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "arrow_back" }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.layer.location.title", defaultMessage: "ui.composer.layer.location.title" }) }), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "small", color: "secondary", variant: "contained", onClick: handleSave }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.layer.save", defaultMessage: "ui.composer.layer.save" }) }))] })), (0, jsx_runtime_1.jsx)(DialogContent_1.default, Object.assign({ className: classes.content }, { children: (0, jsx_runtime_1.jsx)(LocationAutocomplete_1.default, { onChange: handleChange, defaultValue: value ? value : '' }) }))] })); }); exports.default = LocationLayer;