UNPKG

terriajs

Version:

Geospatial data visualization platform.

32 lines 2.76 kB
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; import { useCallback, useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import Box from "../../../../Styled/Box"; import Spacing from "../../../../Styled/Spacing"; import Text, { TextSpan } from "../../../../Styled/Text"; import { useCallbackRef } from "../../../useCallbackRef"; import { canShorten } from "./BuildShareLink"; import { PrintSection } from "./Print/PrintSection"; import { shouldShorten as shouldShortenDefault } from "./SharePanel"; import { ShareUrl, ShareUrlBookmark } from "./ShareUrl"; import Checkbox from "../../../../Styled/Checkbox"; import { EmbedSection } from "./Embed/EmbedSection"; export const SharePanelContent = ({ terria, viewState, closePanel }) => { const { t } = useTranslation(); const canShortenUrl = useMemo(() => !!canShorten(terria), [terria]); const [includeStoryInShare, setIncludeStoryInShare] = useState(true); const [shouldShorten, setShouldShorten] = useState(shouldShortenDefault(terria)); const [_, update] = useState(); const shareUrlRef = useCallbackRef(null, () => update({})); const includeStoryInShareOnChange = useCallback(() => { setIncludeStoryInShare((prevState) => !prevState); }, []); const shouldShortenOnChange = useCallback(() => { setShouldShorten((prevState) => { terria.setLocalProperty("shortenShareUrls", !prevState); return !prevState; }); }, [terria]); return (_jsxs(Box, { paddedRatio: 3, column: true, children: [_jsx(Text, { semiBold: true, medium: true, children: t("clipboard.shareURL") }), _jsx(Spacing, { bottom: 1 }), _jsx(ShareUrl, { terria: terria, viewState: viewState, includeStories: includeStoryInShare, shouldShorten: shouldShorten, ref: shareUrlRef, callback: closePanel, children: _jsx(ShareUrlBookmark, { viewState: viewState }) }), _jsx(Spacing, { bottom: 1 }), terria.stories && terria.stories.length > 0 && (_jsxs(_Fragment, { children: [_jsx(Checkbox, { textProps: { medium: true }, id: "includeStory", title: "Include Story in Share", isChecked: includeStoryInShare, onChange: includeStoryInShareOnChange, children: _jsx(TextSpan, { children: t("includeStory.message") }) }), _jsx(Spacing, { bottom: 2 })] })), _jsx(Checkbox, { textProps: { medium: true }, id: "shortenUrl", isChecked: shouldShorten, onChange: shouldShortenOnChange, isDisabled: !canShortenUrl, children: _jsx(TextSpan, { children: t("share.shortenUsingService") }) }), _jsx(Spacing, { bottom: 4 }), _jsx(PrintSection, { viewState: viewState }), _jsx(Spacing, { bottom: 4 }), _jsx(EmbedSection, { shareUrl: shareUrlRef?.current })] })); }; //# sourceMappingURL=SharePanelContent.js.map