@eightshift/frontend-libs-tailwind 1.5.0 → 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.
Files changed (229) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/package.json +11 -18
  3. package/blocks/init/assets/application-admin.js +0 -10
  4. package/blocks/init/assets/application.js +0 -13
  5. package/blocks/init/assets/fonts/fraunces-italic-latin-extended.woff2 +0 -0
  6. package/blocks/init/assets/fonts/fraunces-italic-latin.woff2 +0 -0
  7. package/blocks/init/assets/fonts/fraunces-latin-extended.woff2 +0 -0
  8. package/blocks/init/assets/fonts/fraunces-latin.woff2 +0 -0
  9. package/blocks/init/assets/fonts/noto-sans-italic-latin-extended.woff2 +0 -0
  10. package/blocks/init/assets/fonts/noto-sans-italic-latin.woff2 +0 -0
  11. package/blocks/init/assets/fonts/noto-sans-latin-extended.woff2 +0 -0
  12. package/blocks/init/assets/fonts/noto-sans-latin.woff2 +0 -0
  13. package/blocks/init/assets/images/index.js +0 -5
  14. package/blocks/init/assets/scripts/application-admin.js +0 -7
  15. package/blocks/init/assets/scripts/application.js +0 -3
  16. package/blocks/init/assets/scripts/theme-colors.js +0 -39
  17. package/blocks/init/assets/styles/application-admin.css +0 -6
  18. package/blocks/init/assets/styles/application.css +0 -3
  19. package/blocks/init/src/Blocks/assets/application-blocks-editor.js +0 -14
  20. package/blocks/init/src/Blocks/assets/application-blocks-frontend.js +0 -13
  21. package/blocks/init/src/Blocks/assets/application-blocks.js +0 -9
  22. package/blocks/init/src/Blocks/assets/scripts/application-blocks-editor.js +0 -65
  23. package/blocks/init/src/Blocks/assets/scripts/application-blocks-frontend.js +0 -24
  24. package/blocks/init/src/Blocks/assets/scripts/link-section-editor.js +0 -262
  25. package/blocks/init/src/Blocks/assets/scripts/shared.js +0 -25
  26. package/blocks/init/src/Blocks/assets/styles/application-blocks-editor.css +0 -15
  27. package/blocks/init/src/Blocks/assets/styles/application-blocks-frontend.css +0 -9
  28. package/blocks/init/src/Blocks/assets/styles/application-blocks.css +0 -1
  29. package/blocks/init/src/Blocks/assets/styles/editor/editor-overrides.css +0 -15
  30. package/blocks/init/src/Blocks/assets/styles/fonts.css +0 -90
  31. package/blocks/init/src/Blocks/assets/styles/tailwind.css +0 -30
  32. package/blocks/init/src/Blocks/components/admin-theme-options/admin-theme-options.php +0 -20
  33. package/blocks/init/src/Blocks/components/admin-theme-options/assets-admin/index.js +0 -36
  34. package/blocks/init/src/Blocks/components/admin-theme-options/assets-admin/pages/parts.js +0 -56
  35. package/blocks/init/src/Blocks/components/admin-theme-options/manifest.json +0 -5
  36. package/blocks/init/src/Blocks/components/button/assets/index.js +0 -22
  37. package/blocks/init/src/Blocks/components/button/button.php +0 -88
  38. package/blocks/init/src/Blocks/components/button/components/button-editor.js +0 -36
  39. package/blocks/init/src/Blocks/components/button/components/button-options.js +0 -134
  40. package/blocks/init/src/Blocks/components/button/manifest.json +0 -302
  41. package/blocks/init/src/Blocks/components/card/card.php +0 -42
  42. package/blocks/init/src/Blocks/components/card/components/card-editor.js +0 -43
  43. package/blocks/init/src/Blocks/components/card/components/card-options.js +0 -55
  44. package/blocks/init/src/Blocks/components/card/manifest.json +0 -111
  45. package/blocks/init/src/Blocks/components/head/head.php +0 -52
  46. package/blocks/init/src/Blocks/components/head/manifest.json +0 -17
  47. package/blocks/init/src/Blocks/components/heading/components/heading-editor.js +0 -26
  48. package/blocks/init/src/Blocks/components/heading/components/heading-options.js +0 -62
  49. package/blocks/init/src/Blocks/components/heading/heading.php +0 -45
  50. package/blocks/init/src/Blocks/components/heading/manifest.json +0 -76
  51. package/blocks/init/src/Blocks/components/hero/components/hero-editor.js +0 -42
  52. package/blocks/init/src/Blocks/components/hero/components/hero-options.js +0 -100
  53. package/blocks/init/src/Blocks/components/hero/hero.php +0 -45
  54. package/blocks/init/src/Blocks/components/hero/manifest.json +0 -96
  55. package/blocks/init/src/Blocks/components/icon/components/icon-editor.js +0 -23
  56. package/blocks/init/src/Blocks/components/icon/components/icon-options.js +0 -65
  57. package/blocks/init/src/Blocks/components/icon/icon.php +0 -53
  58. package/blocks/init/src/Blocks/components/icon/manifest.json +0 -1238
  59. package/blocks/init/src/Blocks/components/image/components/image-editor.js +0 -64
  60. package/blocks/init/src/Blocks/components/image/components/image-options.js +0 -111
  61. package/blocks/init/src/Blocks/components/image/image.php +0 -68
  62. package/blocks/init/src/Blocks/components/image/manifest.json +0 -125
  63. package/blocks/init/src/Blocks/components/list/components/list-editor.js +0 -30
  64. package/blocks/init/src/Blocks/components/list/components/list-options.js +0 -62
  65. package/blocks/init/src/Blocks/components/list/list.php +0 -32
  66. package/blocks/init/src/Blocks/components/list/manifest.json +0 -127
  67. package/blocks/init/src/Blocks/components/load-more/assets/index.js +0 -19
  68. package/blocks/init/src/Blocks/components/load-more/assets/load-more.js +0 -146
  69. package/blocks/init/src/Blocks/components/load-more/components/load-more-editor.js +0 -14
  70. package/blocks/init/src/Blocks/components/load-more/components/load-more-options.js +0 -19
  71. package/blocks/init/src/Blocks/components/load-more/load-more.php +0 -47
  72. package/blocks/init/src/Blocks/components/load-more/manifest.json +0 -39
  73. package/blocks/init/src/Blocks/components/modal/assets/index.js +0 -27
  74. package/blocks/init/src/Blocks/components/modal/manifest.json +0 -48
  75. package/blocks/init/src/Blocks/components/modal/modal.php +0 -46
  76. package/blocks/init/src/Blocks/components/paragraph/components/paragraph-editor.js +0 -38
  77. package/blocks/init/src/Blocks/components/paragraph/components/paragraph-options.js +0 -48
  78. package/blocks/init/src/Blocks/components/paragraph/manifest.json +0 -81
  79. package/blocks/init/src/Blocks/components/paragraph/paragraph.php +0 -33
  80. package/blocks/init/src/Blocks/components/post-header/manifest.json +0 -5
  81. package/blocks/init/src/Blocks/components/post-header/post-header.php +0 -24
  82. package/blocks/init/src/Blocks/components/quote/components/quote-editor.js +0 -53
  83. package/blocks/init/src/Blocks/components/quote/components/quote-options.js +0 -29
  84. package/blocks/init/src/Blocks/components/quote/manifest.json +0 -47
  85. package/blocks/init/src/Blocks/components/quote/quote.php +0 -49
  86. package/blocks/init/src/Blocks/components/share/assets/index.js +0 -39
  87. package/blocks/init/src/Blocks/components/share/components/share-editor.js +0 -28
  88. package/blocks/init/src/Blocks/components/share/components/share-options.js +0 -112
  89. package/blocks/init/src/Blocks/components/share/manifest.json +0 -72
  90. package/blocks/init/src/Blocks/components/share/share.php +0 -69
  91. package/blocks/init/src/Blocks/components/tracking-before-body-end/manifest.json +0 -5
  92. package/blocks/init/src/Blocks/components/tracking-before-body-end/tracking-before-body-end.php +0 -9
  93. package/blocks/init/src/Blocks/components/tracking-head/manifest.json +0 -5
  94. package/blocks/init/src/Blocks/components/tracking-head/tracking-head.php +0 -9
  95. package/blocks/init/src/Blocks/components/video/components/video-editor.js +0 -74
  96. package/blocks/init/src/Blocks/components/video/components/video-options.js +0 -279
  97. package/blocks/init/src/Blocks/components/video/manifest.json +0 -120
  98. package/blocks/init/src/Blocks/components/video/video.php +0 -70
  99. package/blocks/init/src/Blocks/custom/accordion/accordion-block.js +0 -15
  100. package/blocks/init/src/Blocks/custom/accordion/accordion.php +0 -28
  101. package/blocks/init/src/Blocks/custom/accordion/assets/index.js +0 -37
  102. package/blocks/init/src/Blocks/custom/accordion/components/accordion-editor.js +0 -22
  103. package/blocks/init/src/Blocks/custom/accordion/components/accordion-options.js +0 -18
  104. package/blocks/init/src/Blocks/custom/accordion/manifest.json +0 -32
  105. package/blocks/init/src/Blocks/custom/accordion-item/accordion-item-block.js +0 -19
  106. package/blocks/init/src/Blocks/custom/accordion-item/accordion-item.php +0 -46
  107. package/blocks/init/src/Blocks/custom/accordion-item/components/accordion-item-editor.js +0 -60
  108. package/blocks/init/src/Blocks/custom/accordion-item/manifest.json +0 -69
  109. package/blocks/init/src/Blocks/custom/button/button-block.js +0 -13
  110. package/blocks/init/src/Blocks/custom/button/button.php +0 -11
  111. package/blocks/init/src/Blocks/custom/button/components/button-editor.js +0 -12
  112. package/blocks/init/src/Blocks/custom/button/components/button-options.js +0 -12
  113. package/blocks/init/src/Blocks/custom/button/manifest.json +0 -18
  114. package/blocks/init/src/Blocks/custom/card/card-block.js +0 -13
  115. package/blocks/init/src/Blocks/custom/card/card.php +0 -11
  116. package/blocks/init/src/Blocks/custom/card/components/card-editor.js +0 -12
  117. package/blocks/init/src/Blocks/custom/card/components/card-options.js +0 -15
  118. package/blocks/init/src/Blocks/custom/card/manifest.json +0 -18
  119. package/blocks/init/src/Blocks/custom/carousel/assets/index.js +0 -46
  120. package/blocks/init/src/Blocks/custom/carousel/assets/navigation.js +0 -31
  121. package/blocks/init/src/Blocks/custom/carousel/assets/pagination.js +0 -40
  122. package/blocks/init/src/Blocks/custom/carousel/carousel-block.js +0 -21
  123. package/blocks/init/src/Blocks/custom/carousel/carousel.php +0 -61
  124. package/blocks/init/src/Blocks/custom/carousel/components/carousel-editor.js +0 -25
  125. package/blocks/init/src/Blocks/custom/carousel/components/carousel-options.js +0 -47
  126. package/blocks/init/src/Blocks/custom/carousel/manifest.json +0 -130
  127. package/blocks/init/src/Blocks/custom/column/column-block.js +0 -21
  128. package/blocks/init/src/Blocks/custom/column/column-hooks.js +0 -32
  129. package/blocks/init/src/Blocks/custom/column/column.php +0 -21
  130. package/blocks/init/src/Blocks/custom/column/components/column-editor.js +0 -22
  131. package/blocks/init/src/Blocks/custom/column/components/column-options.js +0 -580
  132. package/blocks/init/src/Blocks/custom/column/manifest.json +0 -625
  133. package/blocks/init/src/Blocks/custom/columns/columns-block.js +0 -20
  134. package/blocks/init/src/Blocks/custom/columns/columns.php +0 -21
  135. package/blocks/init/src/Blocks/custom/columns/components/columns-editor.js +0 -81
  136. package/blocks/init/src/Blocks/custom/columns/components/columns-options.js +0 -104
  137. package/blocks/init/src/Blocks/custom/columns/manifest.json +0 -581
  138. package/blocks/init/src/Blocks/custom/featured-content/components/featured-content-editor.js +0 -28
  139. package/blocks/init/src/Blocks/custom/featured-content/components/featured-content-options.js +0 -248
  140. package/blocks/init/src/Blocks/custom/featured-content/featured-content-block.js +0 -13
  141. package/blocks/init/src/Blocks/custom/featured-content/featured-content.php +0 -139
  142. package/blocks/init/src/Blocks/custom/featured-content/manifest.json +0 -131
  143. package/blocks/init/src/Blocks/custom/featured-content/partials/cards.php +0 -39
  144. package/blocks/init/src/Blocks/custom/group/components/group-editor.js +0 -6
  145. package/blocks/init/src/Blocks/custom/group/group-block.js +0 -14
  146. package/blocks/init/src/Blocks/custom/group/group.php +0 -10
  147. package/blocks/init/src/Blocks/custom/group/manifest.json +0 -32
  148. package/blocks/init/src/Blocks/custom/heading/components/heading-editor.js +0 -15
  149. package/blocks/init/src/Blocks/custom/heading/components/heading-options.js +0 -38
  150. package/blocks/init/src/Blocks/custom/heading/heading-block.js +0 -13
  151. package/blocks/init/src/Blocks/custom/heading/heading-transforms.js +0 -26
  152. package/blocks/init/src/Blocks/custom/heading/heading.php +0 -15
  153. package/blocks/init/src/Blocks/custom/heading/manifest.json +0 -79
  154. package/blocks/init/src/Blocks/custom/hero/components/hero-editor.js +0 -12
  155. package/blocks/init/src/Blocks/custom/hero/components/hero-options.js +0 -14
  156. package/blocks/init/src/Blocks/custom/hero/hero-block.js +0 -13
  157. package/blocks/init/src/Blocks/custom/hero/hero.php +0 -11
  158. package/blocks/init/src/Blocks/custom/hero/manifest.json +0 -17
  159. package/blocks/init/src/Blocks/custom/image/components/image-editor.js +0 -12
  160. package/blocks/init/src/Blocks/custom/image/components/image-options.js +0 -14
  161. package/blocks/init/src/Blocks/custom/image/image-block.js +0 -13
  162. package/blocks/init/src/Blocks/custom/image/image.php +0 -11
  163. package/blocks/init/src/Blocks/custom/image/manifest.json +0 -33
  164. package/blocks/init/src/Blocks/custom/list/components/list-editor.js +0 -14
  165. package/blocks/init/src/Blocks/custom/list/components/list-options.js +0 -39
  166. package/blocks/init/src/Blocks/custom/list/list-block.js +0 -13
  167. package/blocks/init/src/Blocks/custom/list/list.php +0 -15
  168. package/blocks/init/src/Blocks/custom/list/manifest.json +0 -58
  169. package/blocks/init/src/Blocks/custom/map/assets/index.js +0 -20
  170. package/blocks/init/src/Blocks/custom/map/assets/map-controller.js +0 -41
  171. package/blocks/init/src/Blocks/custom/map/assets/utils.js +0 -161
  172. package/blocks/init/src/Blocks/custom/map/components/map-components.js +0 -403
  173. package/blocks/init/src/Blocks/custom/map/components/map-editor.js +0 -56
  174. package/blocks/init/src/Blocks/custom/map/components/map-options.js +0 -550
  175. package/blocks/init/src/Blocks/custom/map/manifest.json +0 -79
  176. package/blocks/init/src/Blocks/custom/map/map-block.js +0 -13
  177. package/blocks/init/src/Blocks/custom/map/map.php +0 -52
  178. package/blocks/init/src/Blocks/custom/map/styles.css +0 -2
  179. package/blocks/init/src/Blocks/custom/modal/components/modal-editor.js +0 -90
  180. package/blocks/init/src/Blocks/custom/modal/manifest.json +0 -51
  181. package/blocks/init/src/Blocks/custom/modal/modal-block.js +0 -14
  182. package/blocks/init/src/Blocks/custom/modal/modal.php +0 -20
  183. package/blocks/init/src/Blocks/custom/paragraph/components/paragraph-editor.js +0 -17
  184. package/blocks/init/src/Blocks/custom/paragraph/components/paragraph-options.js +0 -38
  185. package/blocks/init/src/Blocks/custom/paragraph/manifest.json +0 -82
  186. package/blocks/init/src/Blocks/custom/paragraph/paragraph-block.js +0 -13
  187. package/blocks/init/src/Blocks/custom/paragraph/paragraph-transforms.js +0 -46
  188. package/blocks/init/src/Blocks/custom/paragraph/paragraph.php +0 -15
  189. package/blocks/init/src/Blocks/custom/quote/components/quote-editor.js +0 -12
  190. package/blocks/init/src/Blocks/custom/quote/components/quote-options.js +0 -14
  191. package/blocks/init/src/Blocks/custom/quote/manifest.json +0 -17
  192. package/blocks/init/src/Blocks/custom/quote/quote-block.js +0 -13
  193. package/blocks/init/src/Blocks/custom/quote/quote.php +0 -13
  194. package/blocks/init/src/Blocks/custom/share/components/share-editor.js +0 -6
  195. package/blocks/init/src/Blocks/custom/share/components/share-options.js +0 -12
  196. package/blocks/init/src/Blocks/custom/share/manifest.json +0 -19
  197. package/blocks/init/src/Blocks/custom/share/share-block.js +0 -13
  198. package/blocks/init/src/Blocks/custom/share/share.php +0 -11
  199. package/blocks/init/src/Blocks/custom/site-footer/components/site-footer-editor.js +0 -57
  200. package/blocks/init/src/Blocks/custom/site-footer/components/site-footer-options.js +0 -106
  201. package/blocks/init/src/Blocks/custom/site-footer/manifest.json +0 -73
  202. package/blocks/init/src/Blocks/custom/site-footer/site-footer-block.js +0 -13
  203. package/blocks/init/src/Blocks/custom/site-footer/site-footer.php +0 -74
  204. package/blocks/init/src/Blocks/custom/site-navigation/assets/index.js +0 -9
  205. package/blocks/init/src/Blocks/custom/site-navigation/components/site-navigation-editor.js +0 -42
  206. package/blocks/init/src/Blocks/custom/site-navigation/components/site-navigation-options.js +0 -73
  207. package/blocks/init/src/Blocks/custom/site-navigation/manifest.json +0 -77
  208. package/blocks/init/src/Blocks/custom/site-navigation/site-navigation-block.js +0 -13
  209. package/blocks/init/src/Blocks/custom/site-navigation/site-navigation.php +0 -99
  210. package/blocks/init/src/Blocks/custom/table-of-contents/assets/index.js +0 -58
  211. package/blocks/init/src/Blocks/custom/table-of-contents/components/table-of-contents-editor.js +0 -38
  212. package/blocks/init/src/Blocks/custom/table-of-contents/components/table-of-contents-options.js +0 -32
  213. package/blocks/init/src/Blocks/custom/table-of-contents/manifest.json +0 -48
  214. package/blocks/init/src/Blocks/custom/table-of-contents/table-of-contents-block.js +0 -13
  215. package/blocks/init/src/Blocks/custom/table-of-contents/table-of-contents.php +0 -31
  216. package/blocks/init/src/Blocks/custom/video/components/video-editor.js +0 -6
  217. package/blocks/init/src/Blocks/custom/video/components/video-options.js +0 -12
  218. package/blocks/init/src/Blocks/custom/video/manifest.json +0 -29
  219. package/blocks/init/src/Blocks/custom/video/video-block.js +0 -13
  220. package/blocks/init/src/Blocks/custom/video/video.php +0 -22
  221. package/blocks/init/src/Blocks/manifest.json +0 -32
  222. package/blocks/init/src/Blocks/variations/card-simple/manifest.json +0 -17
  223. package/blocks/init/src/Blocks/wrapper/components/wrapper-editor.js +0 -12
  224. package/blocks/init/src/Blocks/wrapper/components/wrapper-options.js +0 -364
  225. package/blocks/init/src/Blocks/wrapper/manifest.json +0 -459
  226. package/blocks/init/src/Blocks/wrapper/styles-editor.css +0 -13
  227. package/blocks/init/src/Blocks/wrapper/styles.css +0 -19
  228. package/blocks/init/src/Blocks/wrapper/wrapper.js +0 -27
  229. 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
- };