@eightshift/frontend-libs-tailwind 1.4.8 → 2.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/CHANGELOG.md +20 -0
- package/bun.lockb +0 -0
- package/package.json +28 -35
- package/scripts/components/block-inserter.js +1 -1
- package/scripts/components/file-picker.js +17 -3
- package/scripts/components/picker-placeholder.js +5 -7
- package/scripts/components/server-side-render.js +1 -1
- package/scripts/components/settings/settings.js +21 -20
- package/blocks/init/assets/application-admin.js +0 -10
- package/blocks/init/assets/application.js +0 -13
- package/blocks/init/assets/fonts/fraunces-italic-latin-extended.woff2 +0 -0
- package/blocks/init/assets/fonts/fraunces-italic-latin.woff2 +0 -0
- package/blocks/init/assets/fonts/fraunces-latin-extended.woff2 +0 -0
- package/blocks/init/assets/fonts/fraunces-latin.woff2 +0 -0
- package/blocks/init/assets/fonts/noto-sans-italic-latin-extended.woff2 +0 -0
- package/blocks/init/assets/fonts/noto-sans-italic-latin.woff2 +0 -0
- package/blocks/init/assets/fonts/noto-sans-latin-extended.woff2 +0 -0
- package/blocks/init/assets/fonts/noto-sans-latin.woff2 +0 -0
- package/blocks/init/assets/images/index.js +0 -5
- package/blocks/init/assets/scripts/application-admin.js +0 -7
- package/blocks/init/assets/scripts/application.js +0 -3
- package/blocks/init/assets/scripts/theme-colors.js +0 -39
- package/blocks/init/assets/styles/application-admin.css +0 -6
- package/blocks/init/assets/styles/application.css +0 -3
- package/blocks/init/src/Blocks/assets/application-blocks-editor.js +0 -14
- package/blocks/init/src/Blocks/assets/application-blocks-frontend.js +0 -13
- package/blocks/init/src/Blocks/assets/application-blocks.js +0 -9
- package/blocks/init/src/Blocks/assets/scripts/application-blocks-editor.js +0 -65
- package/blocks/init/src/Blocks/assets/scripts/application-blocks-frontend.js +0 -24
- package/blocks/init/src/Blocks/assets/scripts/link-section-editor.js +0 -262
- package/blocks/init/src/Blocks/assets/scripts/shared.js +0 -25
- package/blocks/init/src/Blocks/assets/styles/application-blocks-editor.css +0 -15
- package/blocks/init/src/Blocks/assets/styles/application-blocks-frontend.css +0 -9
- package/blocks/init/src/Blocks/assets/styles/application-blocks.css +0 -1
- package/blocks/init/src/Blocks/assets/styles/editor/editor-overrides.css +0 -15
- package/blocks/init/src/Blocks/assets/styles/fonts.css +0 -90
- package/blocks/init/src/Blocks/assets/styles/tailwind.css +0 -30
- package/blocks/init/src/Blocks/components/admin-theme-options/admin-theme-options.php +0 -20
- package/blocks/init/src/Blocks/components/admin-theme-options/assets-admin/index.js +0 -36
- package/blocks/init/src/Blocks/components/admin-theme-options/assets-admin/pages/parts.js +0 -56
- package/blocks/init/src/Blocks/components/admin-theme-options/manifest.json +0 -5
- package/blocks/init/src/Blocks/components/button/assets/index.js +0 -22
- package/blocks/init/src/Blocks/components/button/button.php +0 -88
- package/blocks/init/src/Blocks/components/button/components/button-editor.js +0 -36
- package/blocks/init/src/Blocks/components/button/components/button-options.js +0 -134
- package/blocks/init/src/Blocks/components/button/manifest.json +0 -302
- package/blocks/init/src/Blocks/components/card/card.php +0 -42
- package/blocks/init/src/Blocks/components/card/components/card-editor.js +0 -43
- package/blocks/init/src/Blocks/components/card/components/card-options.js +0 -55
- package/blocks/init/src/Blocks/components/card/manifest.json +0 -111
- package/blocks/init/src/Blocks/components/head/head.php +0 -52
- package/blocks/init/src/Blocks/components/head/manifest.json +0 -17
- package/blocks/init/src/Blocks/components/heading/components/heading-editor.js +0 -26
- package/blocks/init/src/Blocks/components/heading/components/heading-options.js +0 -62
- package/blocks/init/src/Blocks/components/heading/heading.php +0 -45
- package/blocks/init/src/Blocks/components/heading/manifest.json +0 -76
- package/blocks/init/src/Blocks/components/hero/components/hero-editor.js +0 -42
- package/blocks/init/src/Blocks/components/hero/components/hero-options.js +0 -100
- package/blocks/init/src/Blocks/components/hero/hero.php +0 -45
- package/blocks/init/src/Blocks/components/hero/manifest.json +0 -96
- package/blocks/init/src/Blocks/components/icon/components/icon-editor.js +0 -23
- package/blocks/init/src/Blocks/components/icon/components/icon-options.js +0 -65
- package/blocks/init/src/Blocks/components/icon/icon.php +0 -53
- package/blocks/init/src/Blocks/components/icon/manifest.json +0 -1238
- package/blocks/init/src/Blocks/components/image/components/image-editor.js +0 -64
- package/blocks/init/src/Blocks/components/image/components/image-options.js +0 -111
- package/blocks/init/src/Blocks/components/image/image.php +0 -68
- package/blocks/init/src/Blocks/components/image/manifest.json +0 -125
- package/blocks/init/src/Blocks/components/list/components/list-editor.js +0 -30
- package/blocks/init/src/Blocks/components/list/components/list-options.js +0 -62
- package/blocks/init/src/Blocks/components/list/list.php +0 -32
- package/blocks/init/src/Blocks/components/list/manifest.json +0 -127
- package/blocks/init/src/Blocks/components/load-more/assets/index.js +0 -19
- package/blocks/init/src/Blocks/components/load-more/assets/load-more.js +0 -146
- package/blocks/init/src/Blocks/components/load-more/components/load-more-editor.js +0 -14
- package/blocks/init/src/Blocks/components/load-more/components/load-more-options.js +0 -19
- package/blocks/init/src/Blocks/components/load-more/load-more.php +0 -47
- package/blocks/init/src/Blocks/components/load-more/manifest.json +0 -39
- package/blocks/init/src/Blocks/components/modal/assets/index.js +0 -27
- package/blocks/init/src/Blocks/components/modal/manifest.json +0 -48
- package/blocks/init/src/Blocks/components/modal/modal.php +0 -46
- package/blocks/init/src/Blocks/components/paragraph/components/paragraph-editor.js +0 -38
- package/blocks/init/src/Blocks/components/paragraph/components/paragraph-options.js +0 -48
- package/blocks/init/src/Blocks/components/paragraph/manifest.json +0 -81
- package/blocks/init/src/Blocks/components/paragraph/paragraph.php +0 -33
- package/blocks/init/src/Blocks/components/post-header/manifest.json +0 -5
- package/blocks/init/src/Blocks/components/post-header/post-header.php +0 -24
- package/blocks/init/src/Blocks/components/quote/components/quote-editor.js +0 -53
- package/blocks/init/src/Blocks/components/quote/components/quote-options.js +0 -29
- package/blocks/init/src/Blocks/components/quote/manifest.json +0 -47
- package/blocks/init/src/Blocks/components/quote/quote.php +0 -49
- package/blocks/init/src/Blocks/components/share/assets/index.js +0 -39
- package/blocks/init/src/Blocks/components/share/components/share-editor.js +0 -28
- package/blocks/init/src/Blocks/components/share/components/share-options.js +0 -112
- package/blocks/init/src/Blocks/components/share/manifest.json +0 -72
- package/blocks/init/src/Blocks/components/share/share.php +0 -69
- package/blocks/init/src/Blocks/components/tracking-before-body-end/manifest.json +0 -5
- package/blocks/init/src/Blocks/components/tracking-before-body-end/tracking-before-body-end.php +0 -9
- package/blocks/init/src/Blocks/components/tracking-head/manifest.json +0 -5
- package/blocks/init/src/Blocks/components/tracking-head/tracking-head.php +0 -9
- package/blocks/init/src/Blocks/components/video/components/video-editor.js +0 -74
- package/blocks/init/src/Blocks/components/video/components/video-options.js +0 -279
- package/blocks/init/src/Blocks/components/video/manifest.json +0 -120
- package/blocks/init/src/Blocks/components/video/video.php +0 -70
- package/blocks/init/src/Blocks/custom/accordion/accordion-block.js +0 -15
- package/blocks/init/src/Blocks/custom/accordion/accordion.php +0 -28
- package/blocks/init/src/Blocks/custom/accordion/assets/index.js +0 -37
- package/blocks/init/src/Blocks/custom/accordion/components/accordion-editor.js +0 -22
- package/blocks/init/src/Blocks/custom/accordion/components/accordion-options.js +0 -18
- package/blocks/init/src/Blocks/custom/accordion/manifest.json +0 -32
- package/blocks/init/src/Blocks/custom/accordion-item/accordion-item-block.js +0 -19
- package/blocks/init/src/Blocks/custom/accordion-item/accordion-item.php +0 -46
- package/blocks/init/src/Blocks/custom/accordion-item/components/accordion-item-editor.js +0 -60
- package/blocks/init/src/Blocks/custom/accordion-item/manifest.json +0 -69
- package/blocks/init/src/Blocks/custom/button/button-block.js +0 -13
- package/blocks/init/src/Blocks/custom/button/button.php +0 -11
- package/blocks/init/src/Blocks/custom/button/components/button-editor.js +0 -12
- package/blocks/init/src/Blocks/custom/button/components/button-options.js +0 -12
- package/blocks/init/src/Blocks/custom/button/manifest.json +0 -18
- package/blocks/init/src/Blocks/custom/card/card-block.js +0 -13
- package/blocks/init/src/Blocks/custom/card/card.php +0 -11
- package/blocks/init/src/Blocks/custom/card/components/card-editor.js +0 -12
- package/blocks/init/src/Blocks/custom/card/components/card-options.js +0 -15
- package/blocks/init/src/Blocks/custom/card/manifest.json +0 -18
- package/blocks/init/src/Blocks/custom/carousel/assets/index.js +0 -46
- package/blocks/init/src/Blocks/custom/carousel/assets/navigation.js +0 -31
- package/blocks/init/src/Blocks/custom/carousel/assets/pagination.js +0 -40
- package/blocks/init/src/Blocks/custom/carousel/carousel-block.js +0 -21
- package/blocks/init/src/Blocks/custom/carousel/carousel.php +0 -61
- package/blocks/init/src/Blocks/custom/carousel/components/carousel-editor.js +0 -25
- package/blocks/init/src/Blocks/custom/carousel/components/carousel-options.js +0 -47
- package/blocks/init/src/Blocks/custom/carousel/manifest.json +0 -130
- package/blocks/init/src/Blocks/custom/column/column-block.js +0 -21
- package/blocks/init/src/Blocks/custom/column/column-hooks.js +0 -32
- package/blocks/init/src/Blocks/custom/column/column.php +0 -21
- package/blocks/init/src/Blocks/custom/column/components/column-editor.js +0 -22
- package/blocks/init/src/Blocks/custom/column/components/column-options.js +0 -580
- package/blocks/init/src/Blocks/custom/column/manifest.json +0 -625
- package/blocks/init/src/Blocks/custom/columns/columns-block.js +0 -20
- package/blocks/init/src/Blocks/custom/columns/columns.php +0 -21
- package/blocks/init/src/Blocks/custom/columns/components/columns-editor.js +0 -81
- package/blocks/init/src/Blocks/custom/columns/components/columns-options.js +0 -104
- package/blocks/init/src/Blocks/custom/columns/manifest.json +0 -581
- package/blocks/init/src/Blocks/custom/featured-content/components/featured-content-editor.js +0 -28
- package/blocks/init/src/Blocks/custom/featured-content/components/featured-content-options.js +0 -248
- package/blocks/init/src/Blocks/custom/featured-content/featured-content-block.js +0 -13
- package/blocks/init/src/Blocks/custom/featured-content/featured-content.php +0 -139
- package/blocks/init/src/Blocks/custom/featured-content/manifest.json +0 -131
- package/blocks/init/src/Blocks/custom/featured-content/partials/cards.php +0 -39
- package/blocks/init/src/Blocks/custom/group/components/group-editor.js +0 -6
- package/blocks/init/src/Blocks/custom/group/group-block.js +0 -14
- package/blocks/init/src/Blocks/custom/group/group.php +0 -10
- package/blocks/init/src/Blocks/custom/group/manifest.json +0 -32
- package/blocks/init/src/Blocks/custom/heading/components/heading-editor.js +0 -15
- package/blocks/init/src/Blocks/custom/heading/components/heading-options.js +0 -38
- package/blocks/init/src/Blocks/custom/heading/heading-block.js +0 -13
- package/blocks/init/src/Blocks/custom/heading/heading-transforms.js +0 -26
- package/blocks/init/src/Blocks/custom/heading/heading.php +0 -15
- package/blocks/init/src/Blocks/custom/heading/manifest.json +0 -79
- package/blocks/init/src/Blocks/custom/hero/components/hero-editor.js +0 -12
- package/blocks/init/src/Blocks/custom/hero/components/hero-options.js +0 -14
- package/blocks/init/src/Blocks/custom/hero/hero-block.js +0 -13
- package/blocks/init/src/Blocks/custom/hero/hero.php +0 -11
- package/blocks/init/src/Blocks/custom/hero/manifest.json +0 -17
- package/blocks/init/src/Blocks/custom/image/components/image-editor.js +0 -12
- package/blocks/init/src/Blocks/custom/image/components/image-options.js +0 -14
- package/blocks/init/src/Blocks/custom/image/image-block.js +0 -13
- package/blocks/init/src/Blocks/custom/image/image.php +0 -11
- package/blocks/init/src/Blocks/custom/image/manifest.json +0 -33
- package/blocks/init/src/Blocks/custom/list/components/list-editor.js +0 -14
- package/blocks/init/src/Blocks/custom/list/components/list-options.js +0 -39
- package/blocks/init/src/Blocks/custom/list/list-block.js +0 -13
- package/blocks/init/src/Blocks/custom/list/list.php +0 -15
- package/blocks/init/src/Blocks/custom/list/manifest.json +0 -58
- package/blocks/init/src/Blocks/custom/map/assets/index.js +0 -20
- package/blocks/init/src/Blocks/custom/map/assets/map-controller.js +0 -41
- package/blocks/init/src/Blocks/custom/map/assets/utils.js +0 -161
- package/blocks/init/src/Blocks/custom/map/components/map-components.js +0 -403
- package/blocks/init/src/Blocks/custom/map/components/map-editor.js +0 -56
- package/blocks/init/src/Blocks/custom/map/components/map-options.js +0 -550
- package/blocks/init/src/Blocks/custom/map/manifest.json +0 -79
- package/blocks/init/src/Blocks/custom/map/map-block.js +0 -13
- package/blocks/init/src/Blocks/custom/map/map.php +0 -52
- package/blocks/init/src/Blocks/custom/map/styles.css +0 -2
- package/blocks/init/src/Blocks/custom/modal/components/modal-editor.js +0 -90
- package/blocks/init/src/Blocks/custom/modal/manifest.json +0 -51
- package/blocks/init/src/Blocks/custom/modal/modal-block.js +0 -14
- package/blocks/init/src/Blocks/custom/modal/modal.php +0 -20
- package/blocks/init/src/Blocks/custom/paragraph/components/paragraph-editor.js +0 -17
- package/blocks/init/src/Blocks/custom/paragraph/components/paragraph-options.js +0 -38
- package/blocks/init/src/Blocks/custom/paragraph/manifest.json +0 -82
- package/blocks/init/src/Blocks/custom/paragraph/paragraph-block.js +0 -13
- package/blocks/init/src/Blocks/custom/paragraph/paragraph-transforms.js +0 -46
- package/blocks/init/src/Blocks/custom/paragraph/paragraph.php +0 -15
- package/blocks/init/src/Blocks/custom/quote/components/quote-editor.js +0 -12
- package/blocks/init/src/Blocks/custom/quote/components/quote-options.js +0 -14
- package/blocks/init/src/Blocks/custom/quote/manifest.json +0 -17
- package/blocks/init/src/Blocks/custom/quote/quote-block.js +0 -13
- package/blocks/init/src/Blocks/custom/quote/quote.php +0 -13
- package/blocks/init/src/Blocks/custom/share/components/share-editor.js +0 -6
- package/blocks/init/src/Blocks/custom/share/components/share-options.js +0 -12
- package/blocks/init/src/Blocks/custom/share/manifest.json +0 -19
- package/blocks/init/src/Blocks/custom/share/share-block.js +0 -13
- package/blocks/init/src/Blocks/custom/share/share.php +0 -11
- package/blocks/init/src/Blocks/custom/site-footer/components/site-footer-editor.js +0 -57
- package/blocks/init/src/Blocks/custom/site-footer/components/site-footer-options.js +0 -106
- package/blocks/init/src/Blocks/custom/site-footer/manifest.json +0 -73
- package/blocks/init/src/Blocks/custom/site-footer/site-footer-block.js +0 -13
- package/blocks/init/src/Blocks/custom/site-footer/site-footer.php +0 -74
- package/blocks/init/src/Blocks/custom/site-navigation/assets/index.js +0 -9
- package/blocks/init/src/Blocks/custom/site-navigation/components/site-navigation-editor.js +0 -42
- package/blocks/init/src/Blocks/custom/site-navigation/components/site-navigation-options.js +0 -73
- package/blocks/init/src/Blocks/custom/site-navigation/manifest.json +0 -77
- package/blocks/init/src/Blocks/custom/site-navigation/site-navigation-block.js +0 -13
- package/blocks/init/src/Blocks/custom/site-navigation/site-navigation.php +0 -99
- package/blocks/init/src/Blocks/custom/table-of-contents/assets/index.js +0 -58
- package/blocks/init/src/Blocks/custom/table-of-contents/components/table-of-contents-editor.js +0 -38
- package/blocks/init/src/Blocks/custom/table-of-contents/components/table-of-contents-options.js +0 -32
- package/blocks/init/src/Blocks/custom/table-of-contents/manifest.json +0 -48
- package/blocks/init/src/Blocks/custom/table-of-contents/table-of-contents-block.js +0 -13
- package/blocks/init/src/Blocks/custom/table-of-contents/table-of-contents.php +0 -31
- package/blocks/init/src/Blocks/custom/video/components/video-editor.js +0 -6
- package/blocks/init/src/Blocks/custom/video/components/video-options.js +0 -12
- package/blocks/init/src/Blocks/custom/video/manifest.json +0 -29
- package/blocks/init/src/Blocks/custom/video/video-block.js +0 -13
- package/blocks/init/src/Blocks/custom/video/video.php +0 -22
- package/blocks/init/src/Blocks/manifest.json +0 -32
- package/blocks/init/src/Blocks/variations/card-simple/manifest.json +0 -17
- package/blocks/init/src/Blocks/wrapper/components/wrapper-editor.js +0 -12
- package/blocks/init/src/Blocks/wrapper/components/wrapper-options.js +0 -364
- package/blocks/init/src/Blocks/wrapper/manifest.json +0 -459
- package/blocks/init/src/Blocks/wrapper/styles-editor.css +0 -13
- package/blocks/init/src/Blocks/wrapper/styles.css +0 -19
- package/blocks/init/src/Blocks/wrapper/wrapper.js +0 -27
- package/blocks/init/src/Blocks/wrapper/wrapper.php +0 -34
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { OSM, Vector as VectorSource, VectorTile as VectorTileSource, XYZ, TileJSON } from 'ol/source';
|
|
2
|
-
import { Tile as TileLayer, Vector as VectorLayer, VectorTile as VectorTileLayer } from 'ol/layer';
|
|
3
|
-
import { MapboxVectorLayer } from 'ol-mapbox-style';
|
|
4
|
-
import OLVectorTileLayer from 'ol/layer/VectorTile';
|
|
5
|
-
import { MVT, GeoJSON } from 'ol/format';
|
|
6
|
-
|
|
7
|
-
import OLAttribution from 'ol/control/Attribution.js';
|
|
8
|
-
import OLFullScreen from 'ol/control/FullScreen.js';
|
|
9
|
-
import OLMousePosition from 'ol/control/MousePosition.js';
|
|
10
|
-
import OLOverviewMap from 'ol/control/OverviewMap.js';
|
|
11
|
-
import OLRotate from 'ol/control/Rotate.js';
|
|
12
|
-
import OLScaleLine from 'ol/control/ScaleLine.js';
|
|
13
|
-
import OLZoomSlider from 'ol/control/ZoomSlider.js';
|
|
14
|
-
import OLZoomToExtent from 'ol/control/ZoomToExtent.js';
|
|
15
|
-
import OLZoom from 'ol/control/Zoom.js';
|
|
16
|
-
|
|
17
|
-
import { applyStyle as OLMBStyleApply } from 'ol-mapbox-style';
|
|
18
|
-
|
|
19
|
-
import { Style, Fill, Stroke, Icon } from 'ol/style';
|
|
20
|
-
|
|
21
|
-
import manifest from '../manifest.json';
|
|
22
|
-
|
|
23
|
-
export const processMapInteraction = (type, options = {}) => {
|
|
24
|
-
switch (type) {
|
|
25
|
-
case 'attribution':
|
|
26
|
-
return new OLAttribution(options);
|
|
27
|
-
case 'fullScreen':
|
|
28
|
-
return new OLFullScreen(options);
|
|
29
|
-
case 'mousePosition':
|
|
30
|
-
return new OLMousePosition(options);
|
|
31
|
-
case 'overviewMap':
|
|
32
|
-
return new OLOverviewMap(
|
|
33
|
-
Object.keys(options).length > 0
|
|
34
|
-
? options
|
|
35
|
-
: {
|
|
36
|
-
layers: [new TileLayer({ source: new OSM() })],
|
|
37
|
-
mapOptions: {
|
|
38
|
-
maxResolution: 0.0015,
|
|
39
|
-
numZoomLevels: 2,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
);
|
|
43
|
-
case 'rotate':
|
|
44
|
-
return new OLRotate(options);
|
|
45
|
-
case 'scaleLine':
|
|
46
|
-
return new OLScaleLine(options);
|
|
47
|
-
case 'zoomSlider':
|
|
48
|
-
return new OLZoomSlider(options);
|
|
49
|
-
case 'zoomToExtent':
|
|
50
|
-
return new OLZoomToExtent(options);
|
|
51
|
-
case 'zoom':
|
|
52
|
-
return new OLZoom(options);
|
|
53
|
-
default:
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const processMapLayer = (layer) => {
|
|
59
|
-
if (layer?.type === 'vectorJson') {
|
|
60
|
-
const mapLayer = new OLVectorTileLayer({ declutter: true });
|
|
61
|
-
OLMBStyleApply(mapLayer, layer?.styleUrl, { accessToken: layer?.apiKey });
|
|
62
|
-
|
|
63
|
-
return mapLayer;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
switch (layer?.type) {
|
|
67
|
-
case 'openStreetMap':
|
|
68
|
-
return new TileLayer({
|
|
69
|
-
source: new OSM(),
|
|
70
|
-
});
|
|
71
|
-
case 'mapBoxVector':
|
|
72
|
-
if (!layer?.apiKey) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return new MapboxVectorLayer({
|
|
77
|
-
styleUrl: layer?.styleUrl,
|
|
78
|
-
accessToken: layer?.apiKey,
|
|
79
|
-
});
|
|
80
|
-
case 'mapBoxRaster':
|
|
81
|
-
if (!layer?.apiKey) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return new TileLayer({
|
|
86
|
-
source: new XYZ({
|
|
87
|
-
url: layer?.styleUrl,
|
|
88
|
-
}),
|
|
89
|
-
});
|
|
90
|
-
case 'mapTilerVector':
|
|
91
|
-
if (!layer?.apiKey) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return new VectorTileLayer({
|
|
96
|
-
source: new VectorTileSource({
|
|
97
|
-
format: new MVT(),
|
|
98
|
-
url: layer?.styleUrl,
|
|
99
|
-
}),
|
|
100
|
-
});
|
|
101
|
-
case 'mapTilerRasterXyz':
|
|
102
|
-
if (!layer?.apiKey) {
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return new TileLayer({
|
|
107
|
-
source: new XYZ({
|
|
108
|
-
url: layer?.styleUrl,
|
|
109
|
-
}),
|
|
110
|
-
});
|
|
111
|
-
case 'mapTilerRasterJson':
|
|
112
|
-
if (!layer?.apiKey) {
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return new TileLayer({
|
|
117
|
-
source: new TileJSON({
|
|
118
|
-
url: layer?.styleUrl,
|
|
119
|
-
}),
|
|
120
|
-
});
|
|
121
|
-
case 'geoJson':
|
|
122
|
-
if (!layer?.geoJsonUrl) {
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return new VectorLayer({
|
|
127
|
-
source: new VectorSource({
|
|
128
|
-
format: new GeoJSON(),
|
|
129
|
-
url: layer?.geoJsonUrl,
|
|
130
|
-
}),
|
|
131
|
-
// Stylize GeoJSON features based on type.
|
|
132
|
-
style: (feature, resolution) => {
|
|
133
|
-
const name = feature.getGeometry().getType();
|
|
134
|
-
|
|
135
|
-
if (name === 'Point') {
|
|
136
|
-
return new Style({
|
|
137
|
-
image: new Icon({
|
|
138
|
-
src: manifest.resources.markerIcon,
|
|
139
|
-
scale: 2 / Math.pow(resolution, 1 / 4),
|
|
140
|
-
displacement: [0, 15 / Math.pow(resolution, 1 / 4)],
|
|
141
|
-
}),
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return new Style({
|
|
146
|
-
fill: new Fill({
|
|
147
|
-
color: 'rgb(58 102 168 / 0.25)',
|
|
148
|
-
}),
|
|
149
|
-
stroke: new Stroke({
|
|
150
|
-
color: '#3A66A8',
|
|
151
|
-
lineJoin: 'round',
|
|
152
|
-
lineCap: 'round',
|
|
153
|
-
width: 2.5,
|
|
154
|
-
}),
|
|
155
|
-
});
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return null;
|
|
161
|
-
};
|
|
@@ -1,403 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useRef, useState, useEffect, useContext } from 'react';
|
|
2
|
-
import { Map as OLMap, View } from 'ol';
|
|
3
|
-
import { OSM, Vector as VectorSource, VectorTile as VectorTileSource, XYZ, TileJSON } from 'ol/source';
|
|
4
|
-
import { Tile as OLTileLayer, Vector as OLVectorLayer, VectorTile as OLVectorTile } from 'ol/layer';
|
|
5
|
-
import { MapboxVectorLayer } from 'ol-mapbox-style';
|
|
6
|
-
import OLVectorTileLayer from 'ol/layer/VectorTile';
|
|
7
|
-
import { useGeographic } from 'ol/proj';
|
|
8
|
-
import { MVT, GeoJSON } from 'ol/format';
|
|
9
|
-
import { defaults as OLDefaultInteractions } from 'ol/interaction/defaults';
|
|
10
|
-
import { defaults as OLDefaultControls } from 'ol/control/defaults';
|
|
11
|
-
|
|
12
|
-
import OLAttribution from 'ol/control/Attribution.js';
|
|
13
|
-
import OLFullScreen from 'ol/control/FullScreen.js';
|
|
14
|
-
import OLMousePosition from 'ol/control/MousePosition.js';
|
|
15
|
-
import OLOverviewMap from 'ol/control/OverviewMap.js';
|
|
16
|
-
import OLRotate from 'ol/control/Rotate.js';
|
|
17
|
-
import OLScaleLine from 'ol/control/ScaleLine.js';
|
|
18
|
-
import OLZoomSlider from 'ol/control/ZoomSlider.js';
|
|
19
|
-
import OLZoomToExtent from 'ol/control/ZoomToExtent.js';
|
|
20
|
-
import OLZoom from 'ol/control/Zoom.js';
|
|
21
|
-
|
|
22
|
-
import { applyStyle as OLMBStyleApply } from 'ol-mapbox-style';
|
|
23
|
-
|
|
24
|
-
import { Style, Fill, Stroke, Icon } from 'ol/style';
|
|
25
|
-
|
|
26
|
-
import manifest from '../manifest.json';
|
|
27
|
-
import { tailwindClasses } from '@eightshift/frontend-libs-tailwind/scripts';
|
|
28
|
-
|
|
29
|
-
export const MapContext = new createContext();
|
|
30
|
-
|
|
31
|
-
export const OpenLayersMap = ({ children, zoom, center, attributes, manifest }) => {
|
|
32
|
-
const mapRef = useRef();
|
|
33
|
-
const [map, setMap] = useState(null);
|
|
34
|
-
|
|
35
|
-
// Map init.
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
useGeographic();
|
|
38
|
-
|
|
39
|
-
let options = {
|
|
40
|
-
view: new View({ zoom, center }),
|
|
41
|
-
layers: [],
|
|
42
|
-
interactions: [],
|
|
43
|
-
controls: [],
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const mapObject = new OLMap(options);
|
|
47
|
-
mapObject.setTarget(mapRef.current);
|
|
48
|
-
setMap(mapObject);
|
|
49
|
-
|
|
50
|
-
return () => mapObject.setTarget(undefined);
|
|
51
|
-
}, []);
|
|
52
|
-
|
|
53
|
-
// Default zoom level change.
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
if (!map) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
map.getView().setZoom(zoom);
|
|
60
|
-
}, [zoom]);
|
|
61
|
-
|
|
62
|
-
// Default center point change.
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
if (!map) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
map.getView().setCenter(center);
|
|
69
|
-
}, [center]);
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<MapContext.Provider value={{ map }}>
|
|
73
|
-
<div
|
|
74
|
-
ref={mapRef}
|
|
75
|
-
className={tailwindClasses(attributes, manifest)}
|
|
76
|
-
>
|
|
77
|
-
{children}
|
|
78
|
-
</div>
|
|
79
|
-
</MapContext.Provider>
|
|
80
|
-
);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export const Layers = ({ children }) => children;
|
|
84
|
-
export const Interactions = ({ children }) => children;
|
|
85
|
-
export const Overlays = ({ children }) => children;
|
|
86
|
-
export const Controls = ({ children }) => children;
|
|
87
|
-
|
|
88
|
-
export const MapLayer = (props) => {
|
|
89
|
-
const { type = 'tile', source, accessToken, styleUrl, style } = props;
|
|
90
|
-
|
|
91
|
-
const { map } = useContext(MapContext);
|
|
92
|
-
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
if (!map) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
let tileLayer;
|
|
99
|
-
|
|
100
|
-
switch (type) {
|
|
101
|
-
case 'mapboxVector':
|
|
102
|
-
tileLayer = new MapboxVectorLayer({
|
|
103
|
-
styleUrl,
|
|
104
|
-
accessToken,
|
|
105
|
-
});
|
|
106
|
-
break;
|
|
107
|
-
case 'vectorJson':
|
|
108
|
-
tileLayer = new OLVectorTileLayer({ declutter: true });
|
|
109
|
-
break;
|
|
110
|
-
case 'vectorTile':
|
|
111
|
-
tileLayer = new OLVectorTile({
|
|
112
|
-
source,
|
|
113
|
-
});
|
|
114
|
-
break;
|
|
115
|
-
case 'vector':
|
|
116
|
-
tileLayer = new OLVectorLayer({
|
|
117
|
-
source,
|
|
118
|
-
style,
|
|
119
|
-
});
|
|
120
|
-
break;
|
|
121
|
-
default:
|
|
122
|
-
tileLayer = new OLTileLayer({
|
|
123
|
-
source,
|
|
124
|
-
});
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (type === 'vectorJson') {
|
|
129
|
-
OLMBStyleApply(tileLayer, styleUrl, { accessToken: accessToken });
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
map.addLayer(tileLayer);
|
|
133
|
-
|
|
134
|
-
return () => {
|
|
135
|
-
if (map) {
|
|
136
|
-
map.removeLayer(tileLayer);
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
}, [map]);
|
|
140
|
-
|
|
141
|
-
return null;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export const MapInteraction = (props) => {
|
|
145
|
-
const { type = 'defaults', options = {} } = props;
|
|
146
|
-
|
|
147
|
-
const { map } = useContext(MapContext);
|
|
148
|
-
|
|
149
|
-
useEffect(() => {
|
|
150
|
-
if (!map) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
let interaction;
|
|
155
|
-
|
|
156
|
-
switch (type) {
|
|
157
|
-
default:
|
|
158
|
-
interaction = OLDefaultInteractions(options).getArray();
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (Array.isArray(interaction)) {
|
|
163
|
-
interaction.forEach((i) => map.addInteraction(i));
|
|
164
|
-
} else {
|
|
165
|
-
map.addInteraction(interaction);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return () => {
|
|
169
|
-
if (map) {
|
|
170
|
-
if (Array.isArray(interaction)) {
|
|
171
|
-
interaction.forEach((i) => map.removeInteraction(i));
|
|
172
|
-
} else {
|
|
173
|
-
map.removeInteraction(interaction);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
}, [map]);
|
|
178
|
-
|
|
179
|
-
return null;
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
export const MapControl = (props) => {
|
|
183
|
-
const { type = 'defaults', options = {} } = props;
|
|
184
|
-
|
|
185
|
-
const { map } = useContext(MapContext);
|
|
186
|
-
|
|
187
|
-
useEffect(() => {
|
|
188
|
-
if (!map) {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
let control;
|
|
193
|
-
|
|
194
|
-
switch (type) {
|
|
195
|
-
case 'attribution':
|
|
196
|
-
control = new OLAttribution(options);
|
|
197
|
-
break;
|
|
198
|
-
case 'fullScreen':
|
|
199
|
-
control = new OLFullScreen(options);
|
|
200
|
-
break;
|
|
201
|
-
case 'mousePosition':
|
|
202
|
-
control = new OLMousePosition(options);
|
|
203
|
-
break;
|
|
204
|
-
case 'overviewMap':
|
|
205
|
-
control = new OLOverviewMap(
|
|
206
|
-
Object.keys(options).length > 0
|
|
207
|
-
? options
|
|
208
|
-
: {
|
|
209
|
-
layers: [new OLTileLayer({ source: new OSM() })],
|
|
210
|
-
mapOptions: {
|
|
211
|
-
maxResolution: 0.0015,
|
|
212
|
-
numZoomLevels: 2,
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
);
|
|
216
|
-
break;
|
|
217
|
-
case 'rotate':
|
|
218
|
-
control = new OLRotate(options);
|
|
219
|
-
break;
|
|
220
|
-
case 'scaleLine':
|
|
221
|
-
control = new OLScaleLine(options);
|
|
222
|
-
break;
|
|
223
|
-
case 'zoomSlider':
|
|
224
|
-
control = new OLZoomSlider(options);
|
|
225
|
-
break;
|
|
226
|
-
case 'zoomToExtent':
|
|
227
|
-
control = new OLZoomToExtent(options);
|
|
228
|
-
break;
|
|
229
|
-
case 'zoom':
|
|
230
|
-
control = new OLZoom(options);
|
|
231
|
-
break;
|
|
232
|
-
default:
|
|
233
|
-
control = OLDefaultControls(options).getArray();
|
|
234
|
-
break;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if (Array.isArray(control)) {
|
|
238
|
-
control.forEach((i) => map.addControl(i));
|
|
239
|
-
} else {
|
|
240
|
-
map.addControl(control);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return () => {
|
|
244
|
-
if (map) {
|
|
245
|
-
if (Array.isArray(control)) {
|
|
246
|
-
control.forEach((i) => map.removeControl(i));
|
|
247
|
-
} else {
|
|
248
|
-
map.removeControl(control);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
}, [map]);
|
|
253
|
-
|
|
254
|
-
return null;
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
export const processMapLayer = (layer) => {
|
|
258
|
-
if (layer?.hidden) {
|
|
259
|
-
return null;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
switch (layer?.type) {
|
|
263
|
-
case 'openStreetMap':
|
|
264
|
-
return <MapLayer source={new OSM()} />;
|
|
265
|
-
case 'mapBoxVector':
|
|
266
|
-
if (!layer?.apiKey || layer?.styleUrl?.length < 1) {
|
|
267
|
-
return null;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return (
|
|
271
|
-
<MapLayer
|
|
272
|
-
key={layer?.id ?? Math.random()}
|
|
273
|
-
type='mapboxVector'
|
|
274
|
-
styleUrl={layer?.styleUrl}
|
|
275
|
-
accessToken={layer?.apiKey}
|
|
276
|
-
/>
|
|
277
|
-
);
|
|
278
|
-
case 'mapBoxRaster':
|
|
279
|
-
if (!layer?.apiKey || layer?.styleUrl?.length < 1) {
|
|
280
|
-
return null;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
return (
|
|
284
|
-
<MapLayer
|
|
285
|
-
key={layer?.id ?? Math.random()}
|
|
286
|
-
source={
|
|
287
|
-
new XYZ({
|
|
288
|
-
url: layer?.styleUrl,
|
|
289
|
-
})
|
|
290
|
-
}
|
|
291
|
-
/>
|
|
292
|
-
);
|
|
293
|
-
case 'mapTilerVector':
|
|
294
|
-
if (!layer?.apiKey || layer?.styleUrl?.length < 1) {
|
|
295
|
-
return null;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
return (
|
|
299
|
-
<MapLayer
|
|
300
|
-
key={layer?.id ?? Math.random()}
|
|
301
|
-
type='vectorTile'
|
|
302
|
-
source={
|
|
303
|
-
new VectorTileSource({
|
|
304
|
-
format: new MVT(),
|
|
305
|
-
url: layer?.styleUrl,
|
|
306
|
-
})
|
|
307
|
-
}
|
|
308
|
-
/>
|
|
309
|
-
);
|
|
310
|
-
|
|
311
|
-
case 'vectorJson':
|
|
312
|
-
if (!layer?.apiKey || layer?.styleUrl?.length < 1) {
|
|
313
|
-
return null;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
return (
|
|
317
|
-
<MapLayer
|
|
318
|
-
key={layer?.id ?? Math.random()}
|
|
319
|
-
type='vectorJson'
|
|
320
|
-
styleUrl={layer?.styleUrl}
|
|
321
|
-
accessToken={layer?.apiKey}
|
|
322
|
-
/>
|
|
323
|
-
);
|
|
324
|
-
|
|
325
|
-
case 'mapTilerRasterXyz':
|
|
326
|
-
if (!layer?.apiKey || layer?.styleUrl?.length < 1) {
|
|
327
|
-
return null;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
return (
|
|
331
|
-
<MapLayer
|
|
332
|
-
key={layer?.id ?? Math.random()}
|
|
333
|
-
source={
|
|
334
|
-
new XYZ({
|
|
335
|
-
url: layer?.styleUrl,
|
|
336
|
-
})
|
|
337
|
-
}
|
|
338
|
-
/>
|
|
339
|
-
);
|
|
340
|
-
|
|
341
|
-
case 'mapTilerRasterJson':
|
|
342
|
-
if (!layer?.apiKey) {
|
|
343
|
-
return null;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
return (
|
|
347
|
-
<MapLayer
|
|
348
|
-
key={layer?.id ?? Math.random()}
|
|
349
|
-
source={
|
|
350
|
-
new TileJSON({
|
|
351
|
-
url: layer?.styleUrl,
|
|
352
|
-
})
|
|
353
|
-
}
|
|
354
|
-
/>
|
|
355
|
-
);
|
|
356
|
-
|
|
357
|
-
case 'geoJson':
|
|
358
|
-
if (!layer?.geoJsonUrl) {
|
|
359
|
-
return null;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
return (
|
|
363
|
-
<MapLayer
|
|
364
|
-
key={layer?.id ?? Math.random()}
|
|
365
|
-
type='vector'
|
|
366
|
-
source={
|
|
367
|
-
new VectorSource({
|
|
368
|
-
format: new GeoJSON(),
|
|
369
|
-
url: layer?.geoJsonUrl,
|
|
370
|
-
})
|
|
371
|
-
}
|
|
372
|
-
// Stylize GeoJSON features based on type.
|
|
373
|
-
style={(feature, resolution) => {
|
|
374
|
-
const name = feature.getGeometry().getType();
|
|
375
|
-
|
|
376
|
-
if (name === 'Point') {
|
|
377
|
-
return new Style({
|
|
378
|
-
image: new Icon({
|
|
379
|
-
src: manifest.resources.markerIcon,
|
|
380
|
-
scale: 2 / Math.pow(resolution, 1 / 4),
|
|
381
|
-
displacement: [0, 15 / Math.pow(resolution, 1 / 4)],
|
|
382
|
-
}),
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
return new Style({
|
|
387
|
-
fill: new Fill({
|
|
388
|
-
color: 'rgb(58 102 168 / 0.25)',
|
|
389
|
-
}),
|
|
390
|
-
stroke: new Stroke({
|
|
391
|
-
color: '#3A66A8',
|
|
392
|
-
lineJoin: 'round',
|
|
393
|
-
lineCap: 'round',
|
|
394
|
-
width: 2.5,
|
|
395
|
-
}),
|
|
396
|
-
});
|
|
397
|
-
}}
|
|
398
|
-
/>
|
|
399
|
-
);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
return null;
|
|
403
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { checkAttr } from '@eightshift/frontend-libs-tailwind/scripts';
|
|
2
|
-
import {
|
|
3
|
-
Interactions,
|
|
4
|
-
Layers,
|
|
5
|
-
MapInteraction,
|
|
6
|
-
OpenLayersMap,
|
|
7
|
-
Controls,
|
|
8
|
-
MapControl,
|
|
9
|
-
processMapLayer,
|
|
10
|
-
} from './map-components';
|
|
11
|
-
import manifest from '../manifest.json';
|
|
12
|
-
|
|
13
|
-
export const MapEditor = ({ attributes }) => {
|
|
14
|
-
const mapLayers = checkAttr('mapLayers', attributes, manifest);
|
|
15
|
-
const mapCenterLat = checkAttr('mapCenterLat', attributes, manifest, true);
|
|
16
|
-
const mapCenterLon = checkAttr('mapCenterLon', attributes, manifest, true);
|
|
17
|
-
const mapZoom = checkAttr('mapZoom', attributes, manifest);
|
|
18
|
-
const mapInteractions = checkAttr('mapInteractions', attributes, manifest);
|
|
19
|
-
const mapControls = checkAttr('mapControls', attributes, manifest);
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<OpenLayersMap
|
|
23
|
-
attributes={attributes}
|
|
24
|
-
manifest={manifest}
|
|
25
|
-
center={[mapCenterLon ?? 16.352532, mapCenterLat ?? 46.314045]}
|
|
26
|
-
zoom={mapZoom}
|
|
27
|
-
>
|
|
28
|
-
<Layers key={mapLayers.map(({ id, type }) => `${id}-${type}`).join(',')}>
|
|
29
|
-
{[...mapLayers].reverse().map((layer) => processMapLayer(layer))}
|
|
30
|
-
</Layers>
|
|
31
|
-
|
|
32
|
-
<Interactions>
|
|
33
|
-
<MapInteraction
|
|
34
|
-
key={Math.random()}
|
|
35
|
-
type='defaults'
|
|
36
|
-
options={mapInteractions}
|
|
37
|
-
/>
|
|
38
|
-
</Interactions>
|
|
39
|
-
|
|
40
|
-
<Controls>
|
|
41
|
-
{Object.entries(mapControls).map(([type, use]) => {
|
|
42
|
-
if (!use) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<MapControl
|
|
48
|
-
key={Math.random()}
|
|
49
|
-
type={type}
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
52
|
-
})}
|
|
53
|
-
</Controls>
|
|
54
|
-
</OpenLayersMap>
|
|
55
|
-
);
|
|
56
|
-
};
|