@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,550 +0,0 @@
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
-
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
- __('Copy the full style URL from MapTiler. Keep the API key inside the URL.', '%g_textdomain%')}
183
- {type === 'mapBoxVector' && __('Copy the full style URL from Mapbox.', '%g_textdomain%')}
184
- {type === 'mapBoxRaster' &&
185
- __(
186
- 'Copy the full style URL from Mapbox or a Mapbox-compatible source. Keep the access token inside the URL.',
187
- '%g_textdomain%',
188
- )}
189
- <br />
190
- <br />
191
- {['mapBoxRaster', 'mapTilerVector', 'mapTilerRasterXyz'].includes(type) && (
192
- <>
193
- <code className='es-bg-transparent es-p-0 es-text-3'>{'{z}/{x}/{y}'}</code>
194
- {__(
195
- "should be left as they are in the URL; they're needed for the map to work properly.",
196
- '%g_textdomain%',
197
- )}
198
- <br />
199
- <br />
200
- </>
201
- )}
202
- {__('Example', '%g_textdomain%')}:
203
- <br />
204
- <span className='es-word-break-all'>
205
- {['mapTilerRasterJson', 'vectorJson'].includes(type) &&
206
- 'https://api.maptiler.com/maps/{styleName}/tiles.json?key={apiKey}'}
207
-
208
- {type === 'mapTilerVector' && 'https://api.maptiler.com/tiles/v3/{z}/{x}/{y}.pbf?key={apiKey}'}
209
-
210
- {type === 'mapBoxVector' && (
211
- <>
212
- {'mapbox://styles/{styleName},'}
213
- <br />
214
- {'mapbox://styles/{userId}/{styleId}'}
215
- </>
216
- )}
217
-
218
- {type === 'mapBoxRaster' &&
219
- 'https://api.mapbox.com/v4/{tilesetId}/{z}/{x}/{y}[@2x].{imageFormat}?acess_token={apiKey}'}
220
-
221
- {type === 'mapTilerRasterXyz' &&
222
- 'https://api.maptiler.com/maps/{styleName}/{z}/{x}/{y}.png?key={apiKey}'}
223
- </span>
224
- </>
225
- }
226
- />
227
- )}
228
-
229
- {type === 'geoJson' && (
230
- <FileSelector
231
- onChange={({ id, url }) => updateData({ geoJsonUrl: url, geoJsonId: id })}
232
- fileId={geoJsonId}
233
- fileName={geoJsonUrl?.slice(geoJsonUrl?.lastIndexOf('/') + 1)}
234
- allowedTypes={['application/geo+json', 'application/json']}
235
- kind='geoJson'
236
- />
237
- )}
238
- </RepeaterItem>
239
- );
240
- }}
241
- </Repeater>
242
- <Spacer />
243
-
244
- <div>
245
- <Expandable
246
- label={__('Map display', '%g_textdomain%')}
247
- icon={icons.browser}
248
- >
249
- <Toggle
250
- icon={icons.tag}
251
- label={__('Attribution', '%g_textdomain%')}
252
- subtitle={__('Check map provider ToC', '%g_textdomain%')}
253
- checked={mapControls.attribution}
254
- onChange={(value) => {
255
- const newValue = { ...mapControls };
256
- newValue.attribution = value;
257
-
258
- setAttributes({ [getAttrKey('mapControls', attributes, manifest)]: newValue });
259
- }}
260
- />
261
-
262
- <Spacer />
263
-
264
- <Toggle
265
- icon={icons.mapPin}
266
- label={__('Minimap', '%g_textdomain%')}
267
- checked={mapControls.overviewMap}
268
- onChange={(value) => {
269
- const newValue = { ...mapControls };
270
- newValue.overviewMap = value;
271
-
272
- setAttributes({ [getAttrKey('mapControls', attributes, manifest)]: newValue });
273
- }}
274
- />
275
-
276
- <Toggle
277
- icon={icons.ruler}
278
- label={__('Map scale', '%g_textdomain%')}
279
- checked={mapControls.scaleLine}
280
- onChange={(value) => {
281
- const newValue = { ...mapControls };
282
- newValue.scaleLine = value;
283
-
284
- setAttributes({ [getAttrKey('mapControls', attributes, manifest)]: newValue });
285
- }}
286
- />
287
-
288
- <Spacer />
289
-
290
- <Toggle
291
- icon={icons.mouseCursor}
292
- label={__('Pointer position', '%g_textdomain%')}
293
- checked={mapControls.mousePosition}
294
- onChange={(value) => {
295
- const newValue = { ...mapControls };
296
- newValue.mousePosition = value;
297
-
298
- setAttributes({ [getAttrKey('mapControls', attributes, manifest)]: newValue });
299
- }}
300
- />
301
-
302
- <Spacer />
303
-
304
- <Toggle
305
- icon={icons.expandXl}
306
- label={__('Full screen', '%g_textdomain%')}
307
- checked={mapControls.fullScreen}
308
- onChange={(value) => {
309
- const newValue = { ...mapControls };
310
- newValue.fullScreen = value;
311
-
312
- setAttributes({ [getAttrKey('mapControls', attributes, manifest)]: newValue });
313
- }}
314
- />
315
-
316
- <Toggle
317
- icon={icons.slider}
318
- label={__('Zoom slider', '%g_textdomain%')}
319
- checked={mapControls.zoomSlider}
320
- onChange={(value) => {
321
- const newValue = { ...mapControls };
322
- newValue.zoomSlider = value;
323
- setAttributes({ [getAttrKey('mapControls', attributes, manifest)]: newValue });
324
- }}
325
- />
326
-
327
- <Toggle
328
- icon={icons.plusMinusButtonsV}
329
- label={__('Zoom buttons', '%g_textdomain%')}
330
- checked={mapControls.zoom}
331
- onChange={(value) => {
332
- const newValue = { ...mapControls };
333
- newValue.zoom = value;
334
-
335
- setAttributes({ [getAttrKey('mapControls', attributes, manifest)]: newValue });
336
- }}
337
- />
338
-
339
- <Toggle
340
- icon={icons.roundedCorners}
341
- label={__('Zoom to extent', '%g_textdomain%')}
342
- checked={mapControls.zoomToExtent}
343
- onChange={(value) => {
344
- const newValue = { ...mapControls };
345
- newValue.zoomToExtent = value;
346
-
347
- setAttributes({ [getAttrKey('mapControls', attributes, manifest)]: newValue });
348
- }}
349
- />
350
-
351
- <Toggle
352
- icon={icons.rotateLeft}
353
- label={__('Reset rotation', '%g_textdomain%')}
354
- checked={mapControls.rotate}
355
- onChange={(value) => {
356
- const newValue = { ...mapControls };
357
- newValue.rotate = value;
358
-
359
- setAttributes({ [getAttrKey('mapControls', attributes, manifest)]: newValue });
360
- }}
361
- />
362
- </Expandable>
363
-
364
- <Expandable
365
- label={__('Map interactions', '%g_textdomain%')}
366
- icon={icons.pointerHand}
367
- >
368
- <Toggle
369
- icon={icons.focus}
370
- label={__('Only when map is focused', '%g_textdomain%')}
371
- checked={mapInteractions.onFocusOnly}
372
- onChange={(value) => {
373
- const newValue = { ...mapInteractions };
374
- newValue.onFocusOnly = value;
375
-
376
- setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
377
- }}
378
- />
379
-
380
- <Spacer />
381
-
382
- <Toggle
383
- icon={icons.keyboard}
384
- label={__('Keyboard interactions', '%g_textdomain%')}
385
- checked={mapInteractions.keyboard}
386
- onChange={(value) => {
387
- const newValue = { ...mapInteractions };
388
- newValue.keyboard = value;
389
-
390
- setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
391
- }}
392
- />
393
-
394
- <Toggle
395
- icon={icons.cursorMove}
396
- label={__('Drag to move map', '%g_textdomain%')}
397
- checked={mapInteractions.dragPan}
398
- onChange={(value) => {
399
- const newValue = { ...mapInteractions };
400
- newValue.dragPan = value;
401
-
402
- setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
403
- }}
404
- />
405
-
406
- <Spacer />
407
-
408
- <Spacer
409
- icon={icons.rotateRight}
410
- text={__('Rotation', '%g_textdomain%')}
411
- border
412
- />
413
-
414
- <Toggle
415
- label={__('Alt+Shift and drag to rotate', '%g_textdomain%')}
416
- checked={mapInteractions.altShiftDragRotate}
417
- onChange={(value) => {
418
- const newValue = { ...mapInteractions };
419
- newValue.altShiftDragRotate = value;
420
-
421
- setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
422
- }}
423
- />
424
-
425
- <Toggle
426
- label={__('Pinch to rotate', '%g_textdomain%')}
427
- checked={mapInteractions.pinchRotate}
428
- onChange={(value) => {
429
- const newValue = { ...mapInteractions };
430
- newValue.pinchRotate = value;
431
-
432
- setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
433
- }}
434
- />
435
-
436
- <Spacer />
437
- <Spacer
438
- icon={icons.search}
439
- text={__('Zoom', '%g_textdomain%')}
440
- border
441
- />
442
-
443
- <Toggle
444
- label={__('Double-click to zoom', '%g_textdomain%')}
445
- checked={mapInteractions.doubleClickZoom}
446
- onChange={(value) => {
447
- const newValue = { ...mapInteractions };
448
- newValue.doubleClickZoom = value;
449
-
450
- setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
451
- }}
452
- />
453
-
454
- <Toggle
455
- label={__('Zoom with mousewheel', '%g_textdomain%')}
456
- checked={mapInteractions.mouseWheelZoom}
457
- onChange={(value) => {
458
- const newValue = { ...mapInteractions };
459
- newValue.mouseWheelZoom = value;
460
-
461
- setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
462
- }}
463
- />
464
-
465
- <Toggle
466
- label={__('Shift and drag to zoom', '%g_textdomain%')}
467
- checked={mapInteractions.shiftDragZoom}
468
- onChange={(value) => {
469
- const newValue = { ...mapInteractions };
470
- newValue.shiftDragZoom = value;
471
-
472
- setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
473
- }}
474
- />
475
-
476
- <Toggle
477
- label={__('Pinch to zoom', '%g_textdomain%')}
478
- checked={mapInteractions.pinchZoom}
479
- onChange={(value) => {
480
- const newValue = { ...mapInteractions };
481
- newValue.pinchZoom = value;
482
-
483
- setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
484
- }}
485
- />
486
-
487
- <NumberPicker
488
- label={__('Transition duration', '%g_textdomain%')}
489
- value={mapInteractions.zoomDuration}
490
- onChange={(value) => {
491
- const newValue = { ...mapInteractions };
492
- newValue.zoomDuration = value;
493
-
494
- setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
495
- }}
496
- min={0}
497
- max={10000}
498
- suffix='ms'
499
- inline
500
- />
501
-
502
- <NumberPicker
503
- label={__('Zoom-in step', '%g_textdomain%')}
504
- value={mapInteractions.zoomDelta}
505
- onChange={(value) => {
506
- const newValue = { ...mapInteractions };
507
- newValue.zoomDelta = value;
508
- setAttributes({ [getAttrKey('mapInteractions', attributes, manifest)]: newValue });
509
- }}
510
- min={1}
511
- max={10}
512
- inline
513
- />
514
- </Expandable>
515
- </div>
516
-
517
- <Spacer />
518
- <Spacer
519
- icon={icons.centerPoint}
520
- text={__('Start point', '%g_textdomain%')}
521
- border
522
- />
523
-
524
- <HStack noWrap>
525
- <InputField
526
- label={__('Lat', '%g_textdomain%')}
527
- value={mapCenterLat}
528
- onChange={(value) => setAttributes({ [getAttrKey('mapCenterLat', attributes, manifest)]: value })}
529
- placeholder='46.314045'
530
- />
531
-
532
- <InputField
533
- label={__('Lon', '%g_textdomain%')}
534
- value={mapCenterLon}
535
- onChange={(value) => setAttributes({ [getAttrKey('mapCenterLon', attributes, manifest)]: value })}
536
- placeholder='16.352532'
537
- />
538
-
539
- <NumberPicker
540
- label={__('Zoom', '%g_textdomain%')}
541
- value={mapZoom}
542
- onChange={(value) => setAttributes({ [getAttrKey('mapZoom', attributes, manifest)]: value })}
543
- min={1}
544
- max={30}
545
- placeholder='14'
546
- />
547
- </HStack>
548
- </>
549
- );
550
- };
@@ -1,79 +0,0 @@
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
- }
@@ -1,13 +0,0 @@
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
- };
@@ -1,52 +0,0 @@
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::tailwindClasses('base', $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>
@@ -1,2 +0,0 @@
1
- /* OpenLayers */
2
- @import '~ol/ol.css';