@eightshift/frontend-libs-tailwind 1.0.0
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.
- package/.gitattributes +37 -0
- package/.github/CODEOWNERS +1 -0
- package/.github/CONTRIBUTING.md +17 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +10 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +10 -0
- package/.github/ISSUE_TEMPLATE/question.md +10 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +11 -0
- package/.github/workflows/ci.yml +31 -0
- package/.husky/pre-commit +1 -0
- package/.prettierrc +14 -0
- package/.stylelintrc +4 -0
- package/CHANGELOG.md +13 -0
- package/CODE_OF_CONDUCT.md +76 -0
- package/LICENSE +21 -0
- package/README.md +24 -0
- package/blocks/init/assets/application-admin.js +10 -0
- package/blocks/init/assets/application.js +13 -0
- package/blocks/init/assets/images/index.js +5 -0
- package/blocks/init/assets/scripts/application-admin.js +7 -0
- package/blocks/init/assets/scripts/application.js +3 -0
- package/blocks/init/assets/scripts/theme-colors.js +39 -0
- package/blocks/init/assets/styles/application-admin.css +6 -0
- package/blocks/init/assets/styles/application.css +3 -0
- package/blocks/init/src/Blocks/assets/application-blocks-editor.js +14 -0
- package/blocks/init/src/Blocks/assets/application-blocks-frontend.js +13 -0
- package/blocks/init/src/Blocks/assets/application-blocks.js +9 -0
- package/blocks/init/src/Blocks/assets/scripts/application-blocks-editor.js +65 -0
- package/blocks/init/src/Blocks/assets/scripts/application-blocks-frontend.js +24 -0
- package/blocks/init/src/Blocks/assets/scripts/link-section-editor.js +258 -0
- package/blocks/init/src/Blocks/assets/scripts/shared.js +25 -0
- package/blocks/init/src/Blocks/assets/styles/application-blocks-editor.css +15 -0
- package/blocks/init/src/Blocks/assets/styles/application-blocks-frontend.css +12 -0
- package/blocks/init/src/Blocks/assets/styles/application-blocks.css +0 -0
- package/blocks/init/src/Blocks/assets/styles/editor/editor-overrides.css +15 -0
- package/blocks/init/src/Blocks/assets/styles/tailwind.css +34 -0
- package/blocks/init/src/Blocks/components/admin-theme-options/admin-theme-options.php +20 -0
- package/blocks/init/src/Blocks/components/admin-theme-options/assets-admin/index.js +36 -0
- package/blocks/init/src/Blocks/components/admin-theme-options/assets-admin/pages/parts.js +55 -0
- package/blocks/init/src/Blocks/components/admin-theme-options/manifest.json +5 -0
- package/blocks/init/src/Blocks/components/button/assets/index.js +22 -0
- package/blocks/init/src/Blocks/components/button/button.php +77 -0
- package/blocks/init/src/Blocks/components/button/components/button-editor.js +40 -0
- package/blocks/init/src/Blocks/components/button/components/button-options.js +135 -0
- package/blocks/init/src/Blocks/components/button/manifest.json +299 -0
- package/blocks/init/src/Blocks/components/card/card.php +42 -0
- package/blocks/init/src/Blocks/components/card/components/card-editor.js +39 -0
- package/blocks/init/src/Blocks/components/card/components/card-options.js +56 -0
- package/blocks/init/src/Blocks/components/card/manifest.json +111 -0
- package/blocks/init/src/Blocks/components/head/head.php +52 -0
- package/blocks/init/src/Blocks/components/head/manifest.json +17 -0
- package/blocks/init/src/Blocks/components/heading/components/heading-editor.js +30 -0
- package/blocks/init/src/Blocks/components/heading/components/heading-options.js +62 -0
- package/blocks/init/src/Blocks/components/heading/heading.php +45 -0
- package/blocks/init/src/Blocks/components/heading/manifest.json +76 -0
- package/blocks/init/src/Blocks/components/hero/components/hero-editor.js +42 -0
- package/blocks/init/src/Blocks/components/hero/components/hero-options.js +100 -0
- package/blocks/init/src/Blocks/components/hero/hero.php +45 -0
- package/blocks/init/src/Blocks/components/hero/manifest.json +96 -0
- package/blocks/init/src/Blocks/components/icon/components/icon-editor.js +23 -0
- package/blocks/init/src/Blocks/components/icon/components/icon-options.js +65 -0
- package/blocks/init/src/Blocks/components/icon/icon.php +34 -0
- package/blocks/init/src/Blocks/components/icon/manifest.json +1234 -0
- package/blocks/init/src/Blocks/components/image/components/image-editor.js +65 -0
- package/blocks/init/src/Blocks/components/image/components/image-options.js +111 -0
- package/blocks/init/src/Blocks/components/image/image.php +62 -0
- package/blocks/init/src/Blocks/components/image/manifest.json +125 -0
- package/blocks/init/src/Blocks/components/list/components/list-editor.js +30 -0
- package/blocks/init/src/Blocks/components/list/components/list-options.js +62 -0
- package/blocks/init/src/Blocks/components/list/list.php +32 -0
- package/blocks/init/src/Blocks/components/list/manifest.json +127 -0
- package/blocks/init/src/Blocks/components/load-more/assets/index.js +19 -0
- package/blocks/init/src/Blocks/components/load-more/assets/load-more.js +147 -0
- package/blocks/init/src/Blocks/components/load-more/components/load-more-editor.js +14 -0
- package/blocks/init/src/Blocks/components/load-more/components/load-more-options.js +18 -0
- package/blocks/init/src/Blocks/components/load-more/load-more.php +47 -0
- package/blocks/init/src/Blocks/components/load-more/manifest.json +39 -0
- package/blocks/init/src/Blocks/components/modal/assets/index.js +27 -0
- package/blocks/init/src/Blocks/components/modal/manifest.json +48 -0
- package/blocks/init/src/Blocks/components/modal/modal.php +46 -0
- package/blocks/init/src/Blocks/components/paragraph/components/paragraph-editor.js +40 -0
- package/blocks/init/src/Blocks/components/paragraph/components/paragraph-options.js +48 -0
- package/blocks/init/src/Blocks/components/paragraph/manifest.json +83 -0
- package/blocks/init/src/Blocks/components/paragraph/paragraph.php +33 -0
- package/blocks/init/src/Blocks/components/post-header/manifest.json +5 -0
- package/blocks/init/src/Blocks/components/post-header/post-header.php +24 -0
- package/blocks/init/src/Blocks/components/quote/components/quote-editor.js +53 -0
- package/blocks/init/src/Blocks/components/quote/components/quote-options.js +29 -0
- package/blocks/init/src/Blocks/components/quote/manifest.json +47 -0
- package/blocks/init/src/Blocks/components/quote/quote.php +49 -0
- package/blocks/init/src/Blocks/components/share/assets/index.js +39 -0
- package/blocks/init/src/Blocks/components/share/components/share-editor.js +25 -0
- package/blocks/init/src/Blocks/components/share/components/share-options.js +112 -0
- package/blocks/init/src/Blocks/components/share/manifest.json +72 -0
- package/blocks/init/src/Blocks/components/share/share.php +66 -0
- package/blocks/init/src/Blocks/components/tracking-before-body-end/manifest.json +5 -0
- package/blocks/init/src/Blocks/components/tracking-before-body-end/tracking-before-body-end.php +9 -0
- package/blocks/init/src/Blocks/components/tracking-head/manifest.json +5 -0
- package/blocks/init/src/Blocks/components/tracking-head/tracking-head.php +9 -0
- package/blocks/init/src/Blocks/components/video/components/video-editor.js +74 -0
- package/blocks/init/src/Blocks/components/video/components/video-options.js +280 -0
- package/blocks/init/src/Blocks/components/video/manifest.json +116 -0
- package/blocks/init/src/Blocks/components/video/video.php +72 -0
- package/blocks/init/src/Blocks/custom/accordion/accordion-block.js +15 -0
- package/blocks/init/src/Blocks/custom/accordion/accordion.php +28 -0
- package/blocks/init/src/Blocks/custom/accordion/assets/index.js +37 -0
- package/blocks/init/src/Blocks/custom/accordion/components/accordion-editor.js +17 -0
- package/blocks/init/src/Blocks/custom/accordion/components/accordion-options.js +18 -0
- package/blocks/init/src/Blocks/custom/accordion/manifest.json +32 -0
- package/blocks/init/src/Blocks/custom/accordion-item/accordion-item-block.js +19 -0
- package/blocks/init/src/Blocks/custom/accordion-item/accordion-item.php +46 -0
- package/blocks/init/src/Blocks/custom/accordion-item/components/accordion-item-editor.js +60 -0
- package/blocks/init/src/Blocks/custom/accordion-item/manifest.json +69 -0
- package/blocks/init/src/Blocks/custom/button/button-block.js +13 -0
- package/blocks/init/src/Blocks/custom/button/button.php +11 -0
- package/blocks/init/src/Blocks/custom/button/components/button-editor.js +12 -0
- package/blocks/init/src/Blocks/custom/button/components/button-options.js +12 -0
- package/blocks/init/src/Blocks/custom/button/manifest.json +18 -0
- package/blocks/init/src/Blocks/custom/card/card-block.js +13 -0
- package/blocks/init/src/Blocks/custom/card/card.php +11 -0
- package/blocks/init/src/Blocks/custom/card/components/card-editor.js +12 -0
- package/blocks/init/src/Blocks/custom/card/components/card-options.js +15 -0
- package/blocks/init/src/Blocks/custom/card/manifest.json +18 -0
- package/blocks/init/src/Blocks/custom/carousel/assets/index.js +46 -0
- package/blocks/init/src/Blocks/custom/carousel/assets/navigation.js +31 -0
- package/blocks/init/src/Blocks/custom/carousel/assets/pagination.js +39 -0
- package/blocks/init/src/Blocks/custom/carousel/carousel-block.js +21 -0
- package/blocks/init/src/Blocks/custom/carousel/carousel.php +61 -0
- package/blocks/init/src/Blocks/custom/carousel/components/carousel-editor.js +25 -0
- package/blocks/init/src/Blocks/custom/carousel/components/carousel-options.js +47 -0
- package/blocks/init/src/Blocks/custom/carousel/manifest.json +130 -0
- package/blocks/init/src/Blocks/custom/column/column-block.js +21 -0
- package/blocks/init/src/Blocks/custom/column/column-hooks.js +32 -0
- package/blocks/init/src/Blocks/custom/column/column.php +21 -0
- package/blocks/init/src/Blocks/custom/column/components/column-editor.js +19 -0
- package/blocks/init/src/Blocks/custom/column/components/column-options.js +579 -0
- package/blocks/init/src/Blocks/custom/column/manifest.json +625 -0
- package/blocks/init/src/Blocks/custom/columns/columns-block.js +20 -0
- package/blocks/init/src/Blocks/custom/columns/columns.php +21 -0
- package/blocks/init/src/Blocks/custom/columns/components/columns-editor.js +81 -0
- package/blocks/init/src/Blocks/custom/columns/components/columns-options.js +104 -0
- package/blocks/init/src/Blocks/custom/columns/manifest.json +555 -0
- package/blocks/init/src/Blocks/custom/featured-content/components/featured-content-editor.js +28 -0
- package/blocks/init/src/Blocks/custom/featured-content/components/featured-content-options.js +239 -0
- package/blocks/init/src/Blocks/custom/featured-content/featured-content-block.js +13 -0
- package/blocks/init/src/Blocks/custom/featured-content/featured-content.php +139 -0
- package/blocks/init/src/Blocks/custom/featured-content/manifest.json +131 -0
- package/blocks/init/src/Blocks/custom/featured-content/partials/cards.php +39 -0
- package/blocks/init/src/Blocks/custom/group/components/group-editor.js +8 -0
- package/blocks/init/src/Blocks/custom/group/group-block.js +14 -0
- package/blocks/init/src/Blocks/custom/group/group.php +10 -0
- package/blocks/init/src/Blocks/custom/group/manifest.json +32 -0
- package/blocks/init/src/Blocks/custom/heading/components/heading-editor.js +15 -0
- package/blocks/init/src/Blocks/custom/heading/components/heading-options.js +38 -0
- package/blocks/init/src/Blocks/custom/heading/heading-block.js +13 -0
- package/blocks/init/src/Blocks/custom/heading/heading-transforms.js +25 -0
- package/blocks/init/src/Blocks/custom/heading/heading.php +15 -0
- package/blocks/init/src/Blocks/custom/heading/manifest.json +79 -0
- package/blocks/init/src/Blocks/custom/hero/components/hero-editor.js +12 -0
- package/blocks/init/src/Blocks/custom/hero/components/hero-options.js +14 -0
- package/blocks/init/src/Blocks/custom/hero/hero-block.js +13 -0
- package/blocks/init/src/Blocks/custom/hero/hero.php +11 -0
- package/blocks/init/src/Blocks/custom/hero/manifest.json +17 -0
- package/blocks/init/src/Blocks/custom/image/components/image-editor.js +12 -0
- package/blocks/init/src/Blocks/custom/image/components/image-options.js +14 -0
- package/blocks/init/src/Blocks/custom/image/image-block.js +13 -0
- package/blocks/init/src/Blocks/custom/image/image.php +11 -0
- package/blocks/init/src/Blocks/custom/image/manifest.json +105 -0
- package/blocks/init/src/Blocks/custom/list/components/list-editor.js +14 -0
- package/blocks/init/src/Blocks/custom/list/components/list-options.js +39 -0
- package/blocks/init/src/Blocks/custom/list/list-block.js +13 -0
- package/blocks/init/src/Blocks/custom/list/list.php +15 -0
- package/blocks/init/src/Blocks/custom/list/manifest.json +58 -0
- package/blocks/init/src/Blocks/custom/map/assets/index.js +20 -0
- package/blocks/init/src/Blocks/custom/map/assets/map-controller.js +42 -0
- package/blocks/init/src/Blocks/custom/map/assets/utils.js +161 -0
- package/blocks/init/src/Blocks/custom/map/components/map-components.js +403 -0
- package/blocks/init/src/Blocks/custom/map/components/map-editor.js +56 -0
- package/blocks/init/src/Blocks/custom/map/components/map-options.js +557 -0
- package/blocks/init/src/Blocks/custom/map/manifest.json +79 -0
- package/blocks/init/src/Blocks/custom/map/map-block.js +13 -0
- package/blocks/init/src/Blocks/custom/map/map.php +52 -0
- package/blocks/init/src/Blocks/custom/map/styles.css +2 -0
- package/blocks/init/src/Blocks/custom/modal/components/modal-editor.js +90 -0
- package/blocks/init/src/Blocks/custom/modal/manifest.json +51 -0
- package/blocks/init/src/Blocks/custom/modal/modal-block.js +14 -0
- package/blocks/init/src/Blocks/custom/modal/modal.php +20 -0
- package/blocks/init/src/Blocks/custom/paragraph/components/paragraph-editor.js +41 -0
- package/blocks/init/src/Blocks/custom/paragraph/components/paragraph-options.js +38 -0
- package/blocks/init/src/Blocks/custom/paragraph/manifest.json +79 -0
- package/blocks/init/src/Blocks/custom/paragraph/paragraph-block.js +13 -0
- package/blocks/init/src/Blocks/custom/paragraph/paragraph-transforms.js +45 -0
- package/blocks/init/src/Blocks/custom/paragraph/paragraph.php +15 -0
- package/blocks/init/src/Blocks/custom/quote/components/quote-editor.js +12 -0
- package/blocks/init/src/Blocks/custom/quote/components/quote-options.js +14 -0
- package/blocks/init/src/Blocks/custom/quote/manifest.json +17 -0
- package/blocks/init/src/Blocks/custom/quote/quote-block.js +13 -0
- package/blocks/init/src/Blocks/custom/quote/quote.php +13 -0
- package/blocks/init/src/Blocks/custom/share/components/share-editor.js +6 -0
- package/blocks/init/src/Blocks/custom/share/components/share-options.js +12 -0
- package/blocks/init/src/Blocks/custom/share/manifest.json +19 -0
- package/blocks/init/src/Blocks/custom/share/share-block.js +13 -0
- package/blocks/init/src/Blocks/custom/share/share.php +11 -0
- package/blocks/init/src/Blocks/custom/site-footer/components/site-footer-editor.js +57 -0
- package/blocks/init/src/Blocks/custom/site-footer/components/site-footer-options.js +106 -0
- package/blocks/init/src/Blocks/custom/site-footer/manifest.json +73 -0
- package/blocks/init/src/Blocks/custom/site-footer/site-footer-block.js +13 -0
- package/blocks/init/src/Blocks/custom/site-footer/site-footer.php +72 -0
- package/blocks/init/src/Blocks/custom/site-navigation/assets/index.js +9 -0
- package/blocks/init/src/Blocks/custom/site-navigation/components/site-navigation-editor.js +42 -0
- package/blocks/init/src/Blocks/custom/site-navigation/components/site-navigation-options.js +73 -0
- package/blocks/init/src/Blocks/custom/site-navigation/manifest.json +77 -0
- package/blocks/init/src/Blocks/custom/site-navigation/site-navigation-block.js +13 -0
- package/blocks/init/src/Blocks/custom/site-navigation/site-navigation.php +99 -0
- package/blocks/init/src/Blocks/custom/table-of-contents/assets/index.js +58 -0
- package/blocks/init/src/Blocks/custom/table-of-contents/components/table-of-contents-editor.js +38 -0
- package/blocks/init/src/Blocks/custom/table-of-contents/components/table-of-contents-options.js +32 -0
- package/blocks/init/src/Blocks/custom/table-of-contents/manifest.json +48 -0
- package/blocks/init/src/Blocks/custom/table-of-contents/table-of-contents-block.js +13 -0
- package/blocks/init/src/Blocks/custom/table-of-contents/table-of-contents.php +31 -0
- package/blocks/init/src/Blocks/custom/video/components/video-editor.js +6 -0
- package/blocks/init/src/Blocks/custom/video/components/video-options.js +12 -0
- package/blocks/init/src/Blocks/custom/video/manifest.json +105 -0
- package/blocks/init/src/Blocks/custom/video/video-block.js +13 -0
- package/blocks/init/src/Blocks/custom/video/video.php +22 -0
- package/blocks/init/src/Blocks/manifest.json +14 -0
- package/blocks/init/src/Blocks/variations/card-simple/manifest.json +17 -0
- package/blocks/init/src/Blocks/wrapper/components/wrapper-editor.js +12 -0
- package/blocks/init/src/Blocks/wrapper/components/wrapper-options.js +348 -0
- package/blocks/init/src/Blocks/wrapper/manifest.json +450 -0
- package/blocks/init/src/Blocks/wrapper/styles-editor.css +13 -0
- package/blocks/init/src/Blocks/wrapper/styles.css +19 -0
- package/blocks/init/src/Blocks/wrapper/wrapper.js +30 -0
- package/blocks/init/src/Blocks/wrapper/wrapper.php +34 -0
- package/eslint.config.mjs +3 -0
- package/linters/base.config.mjs +81 -0
- package/linters/eslint.config.mjs +4 -0
- package/linters/ignore-gitignored.mjs +9 -0
- package/linters/stylelint.config.js +146 -0
- package/package.json +93 -0
- package/readme/packages.md +74 -0
- package/schemas/block.json +302 -0
- package/schemas/component.json +240 -0
- package/schemas/globalManifest.json +73 -0
- package/schemas/variation.json +83 -0
- package/scripts/components/block-inserter.js +70 -0
- package/scripts/components/file-picker.js +243 -0
- package/scripts/components/index.js +6 -0
- package/scripts/components/link-section-editor.js +319 -0
- package/scripts/components/media-picker.js +86 -0
- package/scripts/components/server-side-render.js +37 -0
- package/scripts/components/settings/settings.js +48 -0
- package/scripts/components/settings/use-theme-options.js +52 -0
- package/scripts/editor/attributes.js +304 -0
- package/scripts/editor/colors.js +64 -0
- package/scripts/editor/editor.js +139 -0
- package/scripts/editor/fetch.js +102 -0
- package/scripts/editor/hooks.js +44 -0
- package/scripts/editor/index.js +11 -0
- package/scripts/editor/options.js +152 -0
- package/scripts/editor/registration.js +901 -0
- package/scripts/editor/store.js +213 -0
- package/scripts/editor/tailwindcss.js +224 -0
- package/scripts/editor/utility.js +47 -0
- package/scripts/helpers/breakpoints.js +48 -0
- package/scripts/helpers/cookies.js +65 -0
- package/scripts/helpers/dynamic-import.js +19 -0
- package/scripts/helpers/index.js +11 -0
- package/scripts/index.js +22 -0
- package/scripts/plugins/index.js +3 -0
- package/scripts/plugins/yoast-seo.js +70 -0
- package/webpack/base.mjs +138 -0
- package/webpack/helpers.mjs +67 -0
- package/webpack/index.mjs +52 -0
- package/webpack/production.mjs +60 -0
- package/webpack/project.mjs +55 -0
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
import { __ } from '@wordpress/i18n';
|
|
2
|
+
import { checkAttr, getAttrKey, FileSelector } from '@eightshift/frontend-libs-tailwind/scripts';
|
|
3
|
+
import {
|
|
4
|
+
Button,
|
|
5
|
+
Repeater,
|
|
6
|
+
RepeaterItem,
|
|
7
|
+
Notice,
|
|
8
|
+
InputField,
|
|
9
|
+
Menu,
|
|
10
|
+
MenuItem,
|
|
11
|
+
RichLabel,
|
|
12
|
+
MenuSeparator,
|
|
13
|
+
Spacer,
|
|
14
|
+
HStack,
|
|
15
|
+
NumberPicker,
|
|
16
|
+
Toggle,
|
|
17
|
+
Expandable,
|
|
18
|
+
} from '@eightshift/ui-components';
|
|
19
|
+
import { icons } from '@eightshift/ui-components/icons';
|
|
20
|
+
import { truncateMiddle } from '@eightshift/ui-components/utilities';
|
|
21
|
+
import manifest from '../manifest.json';
|
|
22
|
+
|
|
23
|
+
export const MapOptions = ({ attributes, setAttributes }) => {
|
|
24
|
+
const mapLayers = checkAttr('mapLayers', attributes, manifest);
|
|
25
|
+
const mapCenterLat = checkAttr('mapCenterLat', attributes, manifest);
|
|
26
|
+
const mapCenterLon = checkAttr('mapCenterLon', attributes, manifest);
|
|
27
|
+
const mapZoom = checkAttr('mapZoom', attributes, manifest);
|
|
28
|
+
const mapInteractions = checkAttr('mapInteractions', attributes, manifest);
|
|
29
|
+
const mapControls = checkAttr('mapControls', attributes, manifest);
|
|
30
|
+
|
|
31
|
+
const layerTypes = {
|
|
32
|
+
openStreetMap: {
|
|
33
|
+
icon: icons.mapLayer,
|
|
34
|
+
title: __('OpenStreetMap', '%g_textdomain%'),
|
|
35
|
+
hasSeparator: true,
|
|
36
|
+
},
|
|
37
|
+
vectorJson: {
|
|
38
|
+
icon: icons.mapLayerJson,
|
|
39
|
+
title: __('Vector map', '%g_textdomain%'),
|
|
40
|
+
subtitle: __('with JSON styles', '%g_textdomain%'),
|
|
41
|
+
hasSeparator: true,
|
|
42
|
+
},
|
|
43
|
+
mapBoxVector: {
|
|
44
|
+
icon: icons.mapLayerVector,
|
|
45
|
+
title: __('Mapbox map', '%g_textdomain%'),
|
|
46
|
+
subtitle: __('Vector tiles', '%g_textdomain%'),
|
|
47
|
+
},
|
|
48
|
+
mapBoxRaster: {
|
|
49
|
+
icon: icons.mapLayerRaster,
|
|
50
|
+
title: __('Mapbox map', '%g_textdomain%'),
|
|
51
|
+
subtitle: __('Raster tiles', '%g_textdomain%'),
|
|
52
|
+
hasSeparator: true,
|
|
53
|
+
},
|
|
54
|
+
mapTilerVector: {
|
|
55
|
+
icon: icons.mapLayerVector,
|
|
56
|
+
title: __('MapTiler tiles', '%g_textdomain%'),
|
|
57
|
+
subtitle: __('Vector - XYZ (PBF)', '%g_textdomain%'),
|
|
58
|
+
},
|
|
59
|
+
mapTilerRasterXyz: {
|
|
60
|
+
icon: icons.mapLayerRaster,
|
|
61
|
+
title: __('MapTiler map/tiles', '%g_textdomain%'),
|
|
62
|
+
subtitle: __('Raster - XYZ', '%g_textdomain%'),
|
|
63
|
+
},
|
|
64
|
+
mapTilerRasterJson: {
|
|
65
|
+
icon: icons.mapLayerRaster,
|
|
66
|
+
title: __('MapTiler map/tiles', '%g_textdomain%'),
|
|
67
|
+
subtitle: __('Raster - JSON', '%g_textdomain%'),
|
|
68
|
+
hasSeparator: true,
|
|
69
|
+
},
|
|
70
|
+
geoJson: { icon: icons.fileMetadata, title: __('GeoJSON', '%g_textdomain%') },
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<>
|
|
75
|
+
<Repeater
|
|
76
|
+
icon={icons.layers}
|
|
77
|
+
label={__('Layers', '%g_textdomain%')}
|
|
78
|
+
items={mapLayers}
|
|
79
|
+
onChange={(value) => setAttributes({ [getAttrKey('mapLayers', attributes, manifest)]: value })}
|
|
80
|
+
addButton={({ addItem, disabled }) => (
|
|
81
|
+
<Menu
|
|
82
|
+
triggerIcon={icons.add}
|
|
83
|
+
triggerProps={{ size: 'small', disabled: disabled }}
|
|
84
|
+
>
|
|
85
|
+
{Object.entries(layerTypes).map(([value, { icon, title, subtitle, hasSeparator }]) => {
|
|
86
|
+
return (
|
|
87
|
+
<>
|
|
88
|
+
<MenuItem
|
|
89
|
+
key={value}
|
|
90
|
+
icon={icon}
|
|
91
|
+
onClick={() => {
|
|
92
|
+
addItem({
|
|
93
|
+
type: value,
|
|
94
|
+
hidden: false,
|
|
95
|
+
});
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
<RichLabel
|
|
99
|
+
label={title}
|
|
100
|
+
subtitle={subtitle}
|
|
101
|
+
/>
|
|
102
|
+
</MenuItem>
|
|
103
|
+
|
|
104
|
+
{hasSeparator && <MenuSeparator />}
|
|
105
|
+
</>
|
|
106
|
+
);
|
|
107
|
+
})}
|
|
108
|
+
</Menu>
|
|
109
|
+
)}
|
|
110
|
+
>
|
|
111
|
+
{(layer) => {
|
|
112
|
+
const { type, apiKey, geoJsonUrl, geoJsonId, styleUrl, hidden, updateData } = layer;
|
|
113
|
+
|
|
114
|
+
const needsApiKey = [
|
|
115
|
+
'mapBoxVector',
|
|
116
|
+
'mapBoxRaster',
|
|
117
|
+
'mapTilerVector',
|
|
118
|
+
'vectorJson',
|
|
119
|
+
'mapTilerRasterXyz',
|
|
120
|
+
'mapTilerRasterJson',
|
|
121
|
+
].includes(type);
|
|
122
|
+
// eslint-disable-next-line max-len
|
|
123
|
+
const hasMapStyleOptions = [
|
|
124
|
+
'mapBoxVector',
|
|
125
|
+
'mapBoxRaster',
|
|
126
|
+
'mapTilerVector',
|
|
127
|
+
'vectorJson',
|
|
128
|
+
'mapTilerRasterXyz',
|
|
129
|
+
'mapTilerRasterJson',
|
|
130
|
+
].includes(type);
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<RepeaterItem
|
|
134
|
+
icon={layer?.type ? layerTypes?.[layer?.type]?.icon ?? icons.mapLayer : icons.layerOff}
|
|
135
|
+
label={layerTypes?.[type]?.title ?? __('New layer', '%g_textdomain%')}
|
|
136
|
+
subtitle={
|
|
137
|
+
type === 'geoJson'
|
|
138
|
+
? truncateMiddle(geoJsonUrl?.slice(geoJsonUrl?.lastIndexOf('/') + 1) ?? '', 20)
|
|
139
|
+
: layerTypes?.[type]?.subtitle
|
|
140
|
+
}
|
|
141
|
+
actions={
|
|
142
|
+
layer?.type?.length < 1 ? (
|
|
143
|
+
icons.dummySpacer
|
|
144
|
+
) : (
|
|
145
|
+
<Button
|
|
146
|
+
icon={hidden ? icons.dummySpacer : icons.visible}
|
|
147
|
+
onPress={() => updateData({ hidden: !hidden })}
|
|
148
|
+
tooltip={hidden ? __('Show', '%g_textdomain%') : __('Hide', '%g_textdomain%')}
|
|
149
|
+
size='small'
|
|
150
|
+
/>
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
textValue={layerTypes?.[type]?.title ?? __('New layer', '%g_textdomain%')}
|
|
154
|
+
expandDisabled={type === 'openStreetMap'}
|
|
155
|
+
>
|
|
156
|
+
{!type && (
|
|
157
|
+
<Notice
|
|
158
|
+
type='error'
|
|
159
|
+
label={__('Error', '%g_textdomain%')}
|
|
160
|
+
subtitle={__('Layer type is missing, please remove the layer and add a new one.', '%g_textdomain%')}
|
|
161
|
+
/>
|
|
162
|
+
)}
|
|
163
|
+
|
|
164
|
+
{needsApiKey && (
|
|
165
|
+
<InputField
|
|
166
|
+
icon={icons.key}
|
|
167
|
+
label={__('API key', '%g_textdomain%')}
|
|
168
|
+
value={apiKey}
|
|
169
|
+
onChange={(value) => updateData({ apiKey: value })}
|
|
170
|
+
/>
|
|
171
|
+
)}
|
|
172
|
+
|
|
173
|
+
{hasMapStyleOptions && (
|
|
174
|
+
<InputField
|
|
175
|
+
icon={icons.color}
|
|
176
|
+
label={__('Map style', '%g_textdomain%')}
|
|
177
|
+
value={styleUrl}
|
|
178
|
+
onChange={(value) => updateData({ styleUrl: value })}
|
|
179
|
+
help={
|
|
180
|
+
<>
|
|
181
|
+
{!type?.startsWith('mapBox') &&
|
|
182
|
+
__(
|
|
183
|
+
'Copy the full style URL from MapTiler. Keep the API key inside the URL.',
|
|
184
|
+
'%g_textdomain%',
|
|
185
|
+
)}
|
|
186
|
+
{type === 'mapBoxVector' && __('Copy the full style URL from Mapbox.', '%g_textdomain%')}
|
|
187
|
+
{type === 'mapBoxRaster' &&
|
|
188
|
+
// eslint-disable-next-line max-len
|
|
189
|
+
__(
|
|
190
|
+
'Copy the full style URL from Mapbox or a Mapbox-compatible source. Keep the access token inside the URL.',
|
|
191
|
+
'%g_textdomain%',
|
|
192
|
+
)}
|
|
193
|
+
<br />
|
|
194
|
+
<br />
|
|
195
|
+
{['mapBoxRaster', 'mapTilerVector', 'mapTilerRasterXyz'].includes(type) && (
|
|
196
|
+
<>
|
|
197
|
+
<code className='es-bg-transparent es-p-0 es-text-3'>{'{z}/{x}/{y}'}</code>
|
|
198
|
+
{
|
|
199
|
+
// eslint-disable-next-line max-len
|
|
200
|
+
__(
|
|
201
|
+
"should be left as they are in the URL; they're needed for the map to work properly.",
|
|
202
|
+
'%g_textdomain%',
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
<br />
|
|
206
|
+
<br />
|
|
207
|
+
</>
|
|
208
|
+
)}
|
|
209
|
+
{__('Example', '%g_textdomain%')}:
|
|
210
|
+
<br />
|
|
211
|
+
<span className='es-word-break-all'>
|
|
212
|
+
{['mapTilerRasterJson', 'vectorJson'].includes(type) &&
|
|
213
|
+
'https://api.maptiler.com/maps/{styleName}/tiles.json?key={apiKey}'}
|
|
214
|
+
|
|
215
|
+
{type === 'mapTilerVector' && 'https://api.maptiler.com/tiles/v3/{z}/{x}/{y}.pbf?key={apiKey}'}
|
|
216
|
+
|
|
217
|
+
{type === 'mapBoxVector' && (
|
|
218
|
+
<>
|
|
219
|
+
{'mapbox://styles/{styleName},'}
|
|
220
|
+
<br />
|
|
221
|
+
{'mapbox://styles/{userId}/{styleId}'}
|
|
222
|
+
</>
|
|
223
|
+
)}
|
|
224
|
+
|
|
225
|
+
{type === 'mapBoxRaster' &&
|
|
226
|
+
'https://api.mapbox.com/v4/{tilesetId}/{z}/{x}/{y}[@2x].{imageFormat}?acess_token={apiKey}'}
|
|
227
|
+
|
|
228
|
+
{type === 'mapTilerRasterXyz' &&
|
|
229
|
+
'https://api.maptiler.com/maps/{styleName}/{z}/{x}/{y}.png?key={apiKey}'}
|
|
230
|
+
</span>
|
|
231
|
+
</>
|
|
232
|
+
}
|
|
233
|
+
/>
|
|
234
|
+
)}
|
|
235
|
+
|
|
236
|
+
{type === 'geoJson' && (
|
|
237
|
+
<FileSelector
|
|
238
|
+
onChange={({ id, url }) => updateData({ geoJsonUrl: url, geoJsonId: id })}
|
|
239
|
+
fileId={geoJsonId}
|
|
240
|
+
fileName={geoJsonUrl?.slice(geoJsonUrl?.lastIndexOf('/') + 1)}
|
|
241
|
+
allowedTypes={['application/geo+json', 'application/json']}
|
|
242
|
+
kind='geoJson'
|
|
243
|
+
/>
|
|
244
|
+
)}
|
|
245
|
+
</RepeaterItem>
|
|
246
|
+
);
|
|
247
|
+
}}
|
|
248
|
+
</Repeater>
|
|
249
|
+
<Spacer />
|
|
250
|
+
|
|
251
|
+
<div>
|
|
252
|
+
<Expandable
|
|
253
|
+
label={__('Map display', '%g_textdomain%')}
|
|
254
|
+
icon={icons.browser}
|
|
255
|
+
>
|
|
256
|
+
<Toggle
|
|
257
|
+
icon={icons.tag}
|
|
258
|
+
label={__('Attribution', '%g_textdomain%')}
|
|
259
|
+
subtitle={__('Check map provider ToC', '%g_textdomain%')}
|
|
260
|
+
checked={mapControls.attribution}
|
|
261
|
+
onChange={(value) => {
|
|
262
|
+
const newValue = { ...mapControls };
|
|
263
|
+
newValue.attribution = value;
|
|
264
|
+
|
|
265
|
+
setAttributes({ [getAttrKey('mapControls', attributes, manifest)]: newValue });
|
|
266
|
+
}}
|
|
267
|
+
/>
|
|
268
|
+
|
|
269
|
+
<Spacer />
|
|
270
|
+
|
|
271
|
+
<Toggle
|
|
272
|
+
icon={icons.mapPin}
|
|
273
|
+
label={__('Minimap', '%g_textdomain%')}
|
|
274
|
+
checked={mapControls.overviewMap}
|
|
275
|
+
onChange={(value) => {
|
|
276
|
+
const newValue = { ...mapControls };
|
|
277
|
+
newValue.overviewMap = value;
|
|
278
|
+
|
|
279
|
+
setAttributes({ [getAttrKey('mapControls', attributes, manifest)]: newValue });
|
|
280
|
+
}}
|
|
281
|
+
/>
|
|
282
|
+
|
|
283
|
+
<Toggle
|
|
284
|
+
icon={icons.ruler}
|
|
285
|
+
label={__('Map scale', '%g_textdomain%')}
|
|
286
|
+
checked={mapControls.scaleLine}
|
|
287
|
+
onChange={(value) => {
|
|
288
|
+
const newValue = { ...mapControls };
|
|
289
|
+
newValue.scaleLine = value;
|
|
290
|
+
|
|
291
|
+
setAttributes({ [getAttrKey('mapControls', attributes, manifest)]: newValue });
|
|
292
|
+
}}
|
|
293
|
+
/>
|
|
294
|
+
|
|
295
|
+
<Spacer />
|
|
296
|
+
|
|
297
|
+
<Toggle
|
|
298
|
+
icon={icons.mouseCursor}
|
|
299
|
+
label={__('Pointer position', '%g_textdomain%')}
|
|
300
|
+
checked={mapControls.mousePosition}
|
|
301
|
+
onChange={(value) => {
|
|
302
|
+
const newValue = { ...mapControls };
|
|
303
|
+
newValue.mousePosition = value;
|
|
304
|
+
|
|
305
|
+
setAttributes({ [getAttrKey('mapControls', attributes, manifest)]: newValue });
|
|
306
|
+
}}
|
|
307
|
+
/>
|
|
308
|
+
|
|
309
|
+
<Spacer />
|
|
310
|
+
|
|
311
|
+
<Toggle
|
|
312
|
+
icon={icons.expandXl}
|
|
313
|
+
label={__('Full screen', '%g_textdomain%')}
|
|
314
|
+
checked={mapControls.fullScreen}
|
|
315
|
+
onChange={(value) => {
|
|
316
|
+
const newValue = { ...mapControls };
|
|
317
|
+
newValue.fullScreen = value;
|
|
318
|
+
|
|
319
|
+
setAttributes({ [getAttrKey('mapControls', attributes, manifest)]: newValue });
|
|
320
|
+
}}
|
|
321
|
+
/>
|
|
322
|
+
|
|
323
|
+
<Toggle
|
|
324
|
+
icon={icons.slider}
|
|
325
|
+
label={__('Zoom slider', '%g_textdomain%')}
|
|
326
|
+
checked={mapControls.zoomSlider}
|
|
327
|
+
onChange={(value) => {
|
|
328
|
+
const newValue = { ...mapControls };
|
|
329
|
+
newValue.zoomSlider = value;
|
|
330
|
+
setAttributes({ [getAttrKey('mapControls', attributes, manifest)]: newValue });
|
|
331
|
+
}}
|
|
332
|
+
/>
|
|
333
|
+
|
|
334
|
+
<Toggle
|
|
335
|
+
icon={icons.plusMinusButtonsV}
|
|
336
|
+
label={__('Zoom buttons', '%g_textdomain%')}
|
|
337
|
+
checked={mapControls.zoom}
|
|
338
|
+
onChange={(value) => {
|
|
339
|
+
const newValue = { ...mapControls };
|
|
340
|
+
newValue.zoom = value;
|
|
341
|
+
|
|
342
|
+
setAttributes({ [getAttrKey('mapControls', attributes, manifest)]: newValue });
|
|
343
|
+
}}
|
|
344
|
+
/>
|
|
345
|
+
|
|
346
|
+
<Toggle
|
|
347
|
+
icon={icons.roundedCorners}
|
|
348
|
+
label={__('Zoom to extent', '%g_textdomain%')}
|
|
349
|
+
checked={mapControls.zoomToExtent}
|
|
350
|
+
onChange={(value) => {
|
|
351
|
+
const newValue = { ...mapControls };
|
|
352
|
+
newValue.zoomToExtent = value;
|
|
353
|
+
|
|
354
|
+
setAttributes({ [getAttrKey('mapControls', attributes, manifest)]: newValue });
|
|
355
|
+
}}
|
|
356
|
+
/>
|
|
357
|
+
|
|
358
|
+
<Toggle
|
|
359
|
+
icon={icons.rotateLeft}
|
|
360
|
+
label={__('Reset rotation', '%g_textdomain%')}
|
|
361
|
+
checked={mapControls.rotate}
|
|
362
|
+
onChange={(value) => {
|
|
363
|
+
const newValue = { ...mapControls };
|
|
364
|
+
newValue.rotate = value;
|
|
365
|
+
|
|
366
|
+
setAttributes({ [getAttrKey('mapControls', attributes, manifest)]: newValue });
|
|
367
|
+
}}
|
|
368
|
+
/>
|
|
369
|
+
</Expandable>
|
|
370
|
+
|
|
371
|
+
<Expandable
|
|
372
|
+
label={__('Map interactions', '%g_textdomain%')}
|
|
373
|
+
icon={icons.pointerHand}
|
|
374
|
+
>
|
|
375
|
+
<Toggle
|
|
376
|
+
icon={icons.focus}
|
|
377
|
+
label={__('Only when map is focused', '%g_textdomain%')}
|
|
378
|
+
checked={mapInteractions.onFocusOnly}
|
|
379
|
+
onChange={(value) => {
|
|
380
|
+
const newValue = { ...mapInteractions };
|
|
381
|
+
newValue.onFocusOnly = value;
|
|
382
|
+
|
|
383
|
+
setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
|
|
384
|
+
}}
|
|
385
|
+
/>
|
|
386
|
+
|
|
387
|
+
<Spacer />
|
|
388
|
+
|
|
389
|
+
<Toggle
|
|
390
|
+
icon={icons.keyboard}
|
|
391
|
+
label={__('Keyboard interactions', '%g_textdomain%')}
|
|
392
|
+
checked={mapInteractions.keyboard}
|
|
393
|
+
onChange={(value) => {
|
|
394
|
+
const newValue = { ...mapInteractions };
|
|
395
|
+
newValue.keyboard = value;
|
|
396
|
+
|
|
397
|
+
setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
|
|
398
|
+
}}
|
|
399
|
+
/>
|
|
400
|
+
|
|
401
|
+
<Toggle
|
|
402
|
+
icon={icons.cursorMove}
|
|
403
|
+
label={__('Drag to move map', '%g_textdomain%')}
|
|
404
|
+
checked={mapInteractions.dragPan}
|
|
405
|
+
onChange={(value) => {
|
|
406
|
+
const newValue = { ...mapInteractions };
|
|
407
|
+
newValue.dragPan = value;
|
|
408
|
+
|
|
409
|
+
setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
|
|
410
|
+
}}
|
|
411
|
+
/>
|
|
412
|
+
|
|
413
|
+
<Spacer />
|
|
414
|
+
|
|
415
|
+
<Spacer
|
|
416
|
+
icon={icons.rotateRight}
|
|
417
|
+
text={__('Rotation', '%g_textdomain%')}
|
|
418
|
+
border
|
|
419
|
+
/>
|
|
420
|
+
|
|
421
|
+
<Toggle
|
|
422
|
+
label={__('Alt+Shift and drag to rotate', '%g_textdomain%')}
|
|
423
|
+
checked={mapInteractions.altShiftDragRotate}
|
|
424
|
+
onChange={(value) => {
|
|
425
|
+
const newValue = { ...mapInteractions };
|
|
426
|
+
newValue.altShiftDragRotate = value;
|
|
427
|
+
|
|
428
|
+
setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
|
|
429
|
+
}}
|
|
430
|
+
/>
|
|
431
|
+
|
|
432
|
+
<Toggle
|
|
433
|
+
label={__('Pinch to rotate', '%g_textdomain%')}
|
|
434
|
+
checked={mapInteractions.pinchRotate}
|
|
435
|
+
onChange={(value) => {
|
|
436
|
+
const newValue = { ...mapInteractions };
|
|
437
|
+
newValue.pinchRotate = value;
|
|
438
|
+
|
|
439
|
+
setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
|
|
440
|
+
}}
|
|
441
|
+
/>
|
|
442
|
+
|
|
443
|
+
<Spacer />
|
|
444
|
+
<Spacer
|
|
445
|
+
icon={icons.search}
|
|
446
|
+
text={__('Zoom', '%g_textdomain%')}
|
|
447
|
+
border
|
|
448
|
+
/>
|
|
449
|
+
|
|
450
|
+
<Toggle
|
|
451
|
+
label={__('Double-click to zoom', '%g_textdomain%')}
|
|
452
|
+
checked={mapInteractions.doubleClickZoom}
|
|
453
|
+
onChange={(value) => {
|
|
454
|
+
const newValue = { ...mapInteractions };
|
|
455
|
+
newValue.doubleClickZoom = value;
|
|
456
|
+
|
|
457
|
+
setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
|
|
458
|
+
}}
|
|
459
|
+
/>
|
|
460
|
+
|
|
461
|
+
<Toggle
|
|
462
|
+
label={__('Zoom with mousewheel', '%g_textdomain%')}
|
|
463
|
+
checked={mapInteractions.mouseWheelZoom}
|
|
464
|
+
onChange={(value) => {
|
|
465
|
+
const newValue = { ...mapInteractions };
|
|
466
|
+
newValue.mouseWheelZoom = value;
|
|
467
|
+
|
|
468
|
+
setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
|
|
469
|
+
}}
|
|
470
|
+
/>
|
|
471
|
+
|
|
472
|
+
<Toggle
|
|
473
|
+
label={__('Shift and drag to zoom', '%g_textdomain%')}
|
|
474
|
+
checked={mapInteractions.shiftDragZoom}
|
|
475
|
+
onChange={(value) => {
|
|
476
|
+
const newValue = { ...mapInteractions };
|
|
477
|
+
newValue.shiftDragZoom = value;
|
|
478
|
+
|
|
479
|
+
setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
|
|
480
|
+
}}
|
|
481
|
+
/>
|
|
482
|
+
|
|
483
|
+
<Toggle
|
|
484
|
+
label={__('Pinch to zoom', '%g_textdomain%')}
|
|
485
|
+
checked={mapInteractions.pinchZoom}
|
|
486
|
+
onChange={(value) => {
|
|
487
|
+
const newValue = { ...mapInteractions };
|
|
488
|
+
newValue.pinchZoom = value;
|
|
489
|
+
|
|
490
|
+
setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
|
|
491
|
+
}}
|
|
492
|
+
/>
|
|
493
|
+
|
|
494
|
+
<NumberPicker
|
|
495
|
+
label={__('Transition duration', '%g_textdomain%')}
|
|
496
|
+
value={mapInteractions.zoomDuration}
|
|
497
|
+
onChange={(value) => {
|
|
498
|
+
const newValue = { ...mapInteractions };
|
|
499
|
+
newValue.zoomDuration = value;
|
|
500
|
+
|
|
501
|
+
setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
|
|
502
|
+
}}
|
|
503
|
+
min={0}
|
|
504
|
+
max={10000}
|
|
505
|
+
suffix='ms'
|
|
506
|
+
inline
|
|
507
|
+
/>
|
|
508
|
+
|
|
509
|
+
<NumberPicker
|
|
510
|
+
label={__('Zoom-in step', '%g_textdomain%')}
|
|
511
|
+
value={mapInteractions.zoomDelta}
|
|
512
|
+
onChange={(value) => {
|
|
513
|
+
const newValue = { ...mapInteractions };
|
|
514
|
+
newValue.zoomDelta = value;
|
|
515
|
+
setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
|
|
516
|
+
}}
|
|
517
|
+
min={1}
|
|
518
|
+
max={10}
|
|
519
|
+
inline
|
|
520
|
+
/>
|
|
521
|
+
</Expandable>
|
|
522
|
+
</div>
|
|
523
|
+
|
|
524
|
+
<Spacer />
|
|
525
|
+
<Spacer
|
|
526
|
+
icon={icons.centerPoint}
|
|
527
|
+
text={__('Start point', '%g_textdomain%')}
|
|
528
|
+
border
|
|
529
|
+
/>
|
|
530
|
+
|
|
531
|
+
<HStack noWrap>
|
|
532
|
+
<InputField
|
|
533
|
+
label={__('Lat', '%g_textdomain%')}
|
|
534
|
+
value={mapCenterLat}
|
|
535
|
+
onChange={(value) => setAttributes({ [getAttrKey('mapCenterLat', attributes, manifest)]: value })}
|
|
536
|
+
placeholder='46.314045'
|
|
537
|
+
/>
|
|
538
|
+
|
|
539
|
+
<InputField
|
|
540
|
+
label={__('Lon', '%g_textdomain%')}
|
|
541
|
+
value={mapCenterLon}
|
|
542
|
+
onChange={(value) => setAttributes({ [getAttrKey('mapCenterLon', attributes, manifest)]: value })}
|
|
543
|
+
placeholder='16.352532'
|
|
544
|
+
/>
|
|
545
|
+
|
|
546
|
+
<NumberPicker
|
|
547
|
+
label={__('Zoom', '%g_textdomain%')}
|
|
548
|
+
value={mapZoom}
|
|
549
|
+
onChange={(value) => setAttributes({ [getAttrKey('mapZoom', attributes, manifest)]: value })}
|
|
550
|
+
min={1}
|
|
551
|
+
max={30}
|
|
552
|
+
placeholder='14'
|
|
553
|
+
/>
|
|
554
|
+
</HStack>
|
|
555
|
+
</>
|
|
556
|
+
);
|
|
557
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs-tailwind/main/schemas/block.json",
|
|
3
|
+
"blockName": "map",
|
|
4
|
+
"title": "Map",
|
|
5
|
+
"description": "Show locations on a map.",
|
|
6
|
+
"category": "eightshift",
|
|
7
|
+
"icon": {
|
|
8
|
+
"src": "es-map"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"Example Keyword"
|
|
12
|
+
],
|
|
13
|
+
"example": {
|
|
14
|
+
"attributes": {
|
|
15
|
+
"exampleContent": ""
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"attributes": {
|
|
19
|
+
"mapLayers": {
|
|
20
|
+
"type": "array",
|
|
21
|
+
"default": [
|
|
22
|
+
{
|
|
23
|
+
"id": 1,
|
|
24
|
+
"type": "openStreetMap"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"mapInteractions": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"default": {
|
|
31
|
+
"altShiftDragRotate": true,
|
|
32
|
+
"onFocusOnly": false,
|
|
33
|
+
"doubleClickZoom": true,
|
|
34
|
+
"keyboard": true,
|
|
35
|
+
"mouseWheelZoom": false,
|
|
36
|
+
"shiftDragZoom": true,
|
|
37
|
+
"dragPan": true,
|
|
38
|
+
"pinchRotate": true,
|
|
39
|
+
"pinchZoom": true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"mapControls": {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"default": {
|
|
45
|
+
"attribution": true,
|
|
46
|
+
"fullScreen": false,
|
|
47
|
+
"mousePosition": false,
|
|
48
|
+
"overviewMap": false,
|
|
49
|
+
"rotate": true,
|
|
50
|
+
"scaleLine": false,
|
|
51
|
+
"zoomSlider": false,
|
|
52
|
+
"zoomToExtent": false,
|
|
53
|
+
"zoom": true
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"mapCenterLat": {
|
|
57
|
+
"type": "string"
|
|
58
|
+
},
|
|
59
|
+
"mapCenterLon": {
|
|
60
|
+
"type": "string"
|
|
61
|
+
},
|
|
62
|
+
"mapZoom": {
|
|
63
|
+
"type": "number",
|
|
64
|
+
"default": 14
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"nodeDependency": [
|
|
68
|
+
"ol@8",
|
|
69
|
+
"ol-mapbox-style@12"
|
|
70
|
+
],
|
|
71
|
+
"resources": {
|
|
72
|
+
"markerIcon": "data:image/svg+xml,<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M16 7.35938C16 11.9873 11.8347 16.9857 10.1728 18.7958C9.80508 19.1964 9.19492 19.1964 8.82717 18.7958C7.16529 16.9857 3 11.9873 3 7.35938C3 3.84719 5.91015 1 9.5 1C13.0899 1 16 3.84719 16 7.35938Z\" fill=\"%233A66A8\" stroke=\"%232E5590\" stroke-linejoin=\"round\"/><path d=\"M9.5 9.25C10.4665 9.25 11.25 8.4665 11.25 7.5C11.25 6.5335 10.4665 5.75 9.5 5.75C8.5335 5.75 7.75 6.5335 7.75 7.5C7.75 8.4665 8.5335 9.25 9.5 9.25Z\" fill=\"white\"/></svg>"
|
|
73
|
+
},
|
|
74
|
+
"tailwind": {
|
|
75
|
+
"base": {
|
|
76
|
+
"twClasses": "w-full aspect-3/2 rounded-lg border border-gray-300 shadow-md overflow-hidden"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MapEditor } from './components/map-editor';
|
|
2
|
+
import { MapOptions } from './components/map-options';
|
|
3
|
+
import { GutenbergBlock } from '@eightshift/frontend-libs-tailwind/scripts';
|
|
4
|
+
|
|
5
|
+
export const Map = (props) => {
|
|
6
|
+
return (
|
|
7
|
+
<GutenbergBlock
|
|
8
|
+
{...props}
|
|
9
|
+
options={MapOptions}
|
|
10
|
+
editor={MapEditor}
|
|
11
|
+
/>
|
|
12
|
+
);
|
|
13
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Map block template.
|
|
5
|
+
*
|
|
6
|
+
* @package %g_namespace%
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
use %g_namespace_vendor_prefix%\EightshiftLibs\Helpers\Helpers;
|
|
10
|
+
|
|
11
|
+
$manifest = Helpers::getManifestByDir(__DIR__);
|
|
12
|
+
|
|
13
|
+
$blockClass = $attributes['blockClass'] ?? '';
|
|
14
|
+
$blockJsClass = $attributes['blockJsClass'] ?? '';
|
|
15
|
+
|
|
16
|
+
$mapLayers = Helpers::checkAttr('mapLayers', $attributes, $manifest);
|
|
17
|
+
$mapCenterLat = Helpers::checkAttr('mapCenterLat', $attributes, $manifest);
|
|
18
|
+
$mapCenterLon = Helpers::checkAttr('mapCenterLon', $attributes, $manifest);
|
|
19
|
+
$mapZoom = Helpers::checkAttr('mapZoom', $attributes, $manifest);
|
|
20
|
+
$mapInteractions = Helpers::checkAttr('mapInteractions', $attributes, $manifest);
|
|
21
|
+
$mapControls = Helpers::checkAttr('mapControls', $attributes, $manifest);
|
|
22
|
+
|
|
23
|
+
// Take only active map layers and clean them up a bit so the output JSON is smaller.
|
|
24
|
+
$activeLayers = array_filter($mapLayers, fn ($layer) => ($layer['hidden'] ?? false) === false);
|
|
25
|
+
|
|
26
|
+
$activeLayers = array_map(function ($layer) {
|
|
27
|
+
unset($layer['id']);
|
|
28
|
+
|
|
29
|
+
if (isset($layer['hidden'])) {
|
|
30
|
+
unset($layer['hidden']);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return $layer;
|
|
34
|
+
}, $activeLayers);
|
|
35
|
+
|
|
36
|
+
// Reverse array so the last element is on top, to match editor.
|
|
37
|
+
$activeLayers = array_reverse($activeLayers);
|
|
38
|
+
|
|
39
|
+
// Reset the keys.
|
|
40
|
+
$activeLayers = array_values($activeLayers);
|
|
41
|
+
?>
|
|
42
|
+
|
|
43
|
+
<div
|
|
44
|
+
class="<?php echo esc_attr(Helpers::getTwClasses($attributes, $manifest, $blockJsClass)); ?>"
|
|
45
|
+
data-center-lat="<?php echo esc_attr($mapCenterLat); ?>"
|
|
46
|
+
data-center-lon="<?php echo esc_attr($mapCenterLon); ?>"
|
|
47
|
+
data-center-zoom="<?php echo esc_attr($mapZoom); ?>"
|
|
48
|
+
data-map-interactions="<?php echo esc_attr(wp_json_encode($mapInteractions)); ?>"
|
|
49
|
+
data-map-controls="<?php echo esc_attr(wp_json_encode($mapControls)); ?>"
|
|
50
|
+
data-map-layers="<?php echo esc_attr(wp_json_encode($activeLayers)); ?>"
|
|
51
|
+
>
|
|
52
|
+
</div>
|