@eightshift/frontend-libs-tailwind 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/.gitattributes +37 -0
  2. package/.github/CODEOWNERS +1 -0
  3. package/.github/CONTRIBUTING.md +17 -0
  4. package/.github/ISSUE_TEMPLATE/bug_report.md +10 -0
  5. package/.github/ISSUE_TEMPLATE/feature_request.md +10 -0
  6. package/.github/ISSUE_TEMPLATE/question.md +10 -0
  7. package/.github/PULL_REQUEST_TEMPLATE.md +11 -0
  8. package/.github/workflows/ci.yml +31 -0
  9. package/.husky/pre-commit +1 -0
  10. package/.prettierrc +14 -0
  11. package/.stylelintrc +4 -0
  12. package/CHANGELOG.md +13 -0
  13. package/CODE_OF_CONDUCT.md +76 -0
  14. package/LICENSE +21 -0
  15. package/README.md +24 -0
  16. package/blocks/init/assets/application-admin.js +10 -0
  17. package/blocks/init/assets/application.js +13 -0
  18. package/blocks/init/assets/images/index.js +5 -0
  19. package/blocks/init/assets/scripts/application-admin.js +7 -0
  20. package/blocks/init/assets/scripts/application.js +3 -0
  21. package/blocks/init/assets/scripts/theme-colors.js +39 -0
  22. package/blocks/init/assets/styles/application-admin.css +6 -0
  23. package/blocks/init/assets/styles/application.css +3 -0
  24. package/blocks/init/src/Blocks/assets/application-blocks-editor.js +14 -0
  25. package/blocks/init/src/Blocks/assets/application-blocks-frontend.js +13 -0
  26. package/blocks/init/src/Blocks/assets/application-blocks.js +9 -0
  27. package/blocks/init/src/Blocks/assets/scripts/application-blocks-editor.js +65 -0
  28. package/blocks/init/src/Blocks/assets/scripts/application-blocks-frontend.js +24 -0
  29. package/blocks/init/src/Blocks/assets/scripts/link-section-editor.js +258 -0
  30. package/blocks/init/src/Blocks/assets/scripts/shared.js +25 -0
  31. package/blocks/init/src/Blocks/assets/styles/application-blocks-editor.css +15 -0
  32. package/blocks/init/src/Blocks/assets/styles/application-blocks-frontend.css +12 -0
  33. package/blocks/init/src/Blocks/assets/styles/application-blocks.css +0 -0
  34. package/blocks/init/src/Blocks/assets/styles/editor/editor-overrides.css +15 -0
  35. package/blocks/init/src/Blocks/assets/styles/tailwind.css +34 -0
  36. package/blocks/init/src/Blocks/components/admin-theme-options/admin-theme-options.php +20 -0
  37. package/blocks/init/src/Blocks/components/admin-theme-options/assets-admin/index.js +36 -0
  38. package/blocks/init/src/Blocks/components/admin-theme-options/assets-admin/pages/parts.js +55 -0
  39. package/blocks/init/src/Blocks/components/admin-theme-options/manifest.json +5 -0
  40. package/blocks/init/src/Blocks/components/button/assets/index.js +22 -0
  41. package/blocks/init/src/Blocks/components/button/button.php +77 -0
  42. package/blocks/init/src/Blocks/components/button/components/button-editor.js +40 -0
  43. package/blocks/init/src/Blocks/components/button/components/button-options.js +135 -0
  44. package/blocks/init/src/Blocks/components/button/manifest.json +299 -0
  45. package/blocks/init/src/Blocks/components/card/card.php +42 -0
  46. package/blocks/init/src/Blocks/components/card/components/card-editor.js +39 -0
  47. package/blocks/init/src/Blocks/components/card/components/card-options.js +56 -0
  48. package/blocks/init/src/Blocks/components/card/manifest.json +111 -0
  49. package/blocks/init/src/Blocks/components/head/head.php +52 -0
  50. package/blocks/init/src/Blocks/components/head/manifest.json +17 -0
  51. package/blocks/init/src/Blocks/components/heading/components/heading-editor.js +30 -0
  52. package/blocks/init/src/Blocks/components/heading/components/heading-options.js +62 -0
  53. package/blocks/init/src/Blocks/components/heading/heading.php +45 -0
  54. package/blocks/init/src/Blocks/components/heading/manifest.json +76 -0
  55. package/blocks/init/src/Blocks/components/hero/components/hero-editor.js +42 -0
  56. package/blocks/init/src/Blocks/components/hero/components/hero-options.js +100 -0
  57. package/blocks/init/src/Blocks/components/hero/hero.php +45 -0
  58. package/blocks/init/src/Blocks/components/hero/manifest.json +96 -0
  59. package/blocks/init/src/Blocks/components/icon/components/icon-editor.js +23 -0
  60. package/blocks/init/src/Blocks/components/icon/components/icon-options.js +65 -0
  61. package/blocks/init/src/Blocks/components/icon/icon.php +34 -0
  62. package/blocks/init/src/Blocks/components/icon/manifest.json +1234 -0
  63. package/blocks/init/src/Blocks/components/image/components/image-editor.js +65 -0
  64. package/blocks/init/src/Blocks/components/image/components/image-options.js +111 -0
  65. package/blocks/init/src/Blocks/components/image/image.php +62 -0
  66. package/blocks/init/src/Blocks/components/image/manifest.json +125 -0
  67. package/blocks/init/src/Blocks/components/list/components/list-editor.js +30 -0
  68. package/blocks/init/src/Blocks/components/list/components/list-options.js +62 -0
  69. package/blocks/init/src/Blocks/components/list/list.php +32 -0
  70. package/blocks/init/src/Blocks/components/list/manifest.json +127 -0
  71. package/blocks/init/src/Blocks/components/load-more/assets/index.js +19 -0
  72. package/blocks/init/src/Blocks/components/load-more/assets/load-more.js +147 -0
  73. package/blocks/init/src/Blocks/components/load-more/components/load-more-editor.js +14 -0
  74. package/blocks/init/src/Blocks/components/load-more/components/load-more-options.js +18 -0
  75. package/blocks/init/src/Blocks/components/load-more/load-more.php +47 -0
  76. package/blocks/init/src/Blocks/components/load-more/manifest.json +39 -0
  77. package/blocks/init/src/Blocks/components/modal/assets/index.js +27 -0
  78. package/blocks/init/src/Blocks/components/modal/manifest.json +48 -0
  79. package/blocks/init/src/Blocks/components/modal/modal.php +46 -0
  80. package/blocks/init/src/Blocks/components/paragraph/components/paragraph-editor.js +40 -0
  81. package/blocks/init/src/Blocks/components/paragraph/components/paragraph-options.js +48 -0
  82. package/blocks/init/src/Blocks/components/paragraph/manifest.json +83 -0
  83. package/blocks/init/src/Blocks/components/paragraph/paragraph.php +33 -0
  84. package/blocks/init/src/Blocks/components/post-header/manifest.json +5 -0
  85. package/blocks/init/src/Blocks/components/post-header/post-header.php +24 -0
  86. package/blocks/init/src/Blocks/components/quote/components/quote-editor.js +53 -0
  87. package/blocks/init/src/Blocks/components/quote/components/quote-options.js +29 -0
  88. package/blocks/init/src/Blocks/components/quote/manifest.json +47 -0
  89. package/blocks/init/src/Blocks/components/quote/quote.php +49 -0
  90. package/blocks/init/src/Blocks/components/share/assets/index.js +39 -0
  91. package/blocks/init/src/Blocks/components/share/components/share-editor.js +25 -0
  92. package/blocks/init/src/Blocks/components/share/components/share-options.js +112 -0
  93. package/blocks/init/src/Blocks/components/share/manifest.json +72 -0
  94. package/blocks/init/src/Blocks/components/share/share.php +66 -0
  95. package/blocks/init/src/Blocks/components/tracking-before-body-end/manifest.json +5 -0
  96. package/blocks/init/src/Blocks/components/tracking-before-body-end/tracking-before-body-end.php +9 -0
  97. package/blocks/init/src/Blocks/components/tracking-head/manifest.json +5 -0
  98. package/blocks/init/src/Blocks/components/tracking-head/tracking-head.php +9 -0
  99. package/blocks/init/src/Blocks/components/video/components/video-editor.js +74 -0
  100. package/blocks/init/src/Blocks/components/video/components/video-options.js +280 -0
  101. package/blocks/init/src/Blocks/components/video/manifest.json +116 -0
  102. package/blocks/init/src/Blocks/components/video/video.php +72 -0
  103. package/blocks/init/src/Blocks/custom/accordion/accordion-block.js +15 -0
  104. package/blocks/init/src/Blocks/custom/accordion/accordion.php +28 -0
  105. package/blocks/init/src/Blocks/custom/accordion/assets/index.js +37 -0
  106. package/blocks/init/src/Blocks/custom/accordion/components/accordion-editor.js +17 -0
  107. package/blocks/init/src/Blocks/custom/accordion/components/accordion-options.js +18 -0
  108. package/blocks/init/src/Blocks/custom/accordion/manifest.json +32 -0
  109. package/blocks/init/src/Blocks/custom/accordion-item/accordion-item-block.js +19 -0
  110. package/blocks/init/src/Blocks/custom/accordion-item/accordion-item.php +46 -0
  111. package/blocks/init/src/Blocks/custom/accordion-item/components/accordion-item-editor.js +60 -0
  112. package/blocks/init/src/Blocks/custom/accordion-item/manifest.json +69 -0
  113. package/blocks/init/src/Blocks/custom/button/button-block.js +13 -0
  114. package/blocks/init/src/Blocks/custom/button/button.php +11 -0
  115. package/blocks/init/src/Blocks/custom/button/components/button-editor.js +12 -0
  116. package/blocks/init/src/Blocks/custom/button/components/button-options.js +12 -0
  117. package/blocks/init/src/Blocks/custom/button/manifest.json +18 -0
  118. package/blocks/init/src/Blocks/custom/card/card-block.js +13 -0
  119. package/blocks/init/src/Blocks/custom/card/card.php +11 -0
  120. package/blocks/init/src/Blocks/custom/card/components/card-editor.js +12 -0
  121. package/blocks/init/src/Blocks/custom/card/components/card-options.js +15 -0
  122. package/blocks/init/src/Blocks/custom/card/manifest.json +18 -0
  123. package/blocks/init/src/Blocks/custom/carousel/assets/index.js +46 -0
  124. package/blocks/init/src/Blocks/custom/carousel/assets/navigation.js +31 -0
  125. package/blocks/init/src/Blocks/custom/carousel/assets/pagination.js +39 -0
  126. package/blocks/init/src/Blocks/custom/carousel/carousel-block.js +21 -0
  127. package/blocks/init/src/Blocks/custom/carousel/carousel.php +61 -0
  128. package/blocks/init/src/Blocks/custom/carousel/components/carousel-editor.js +25 -0
  129. package/blocks/init/src/Blocks/custom/carousel/components/carousel-options.js +47 -0
  130. package/blocks/init/src/Blocks/custom/carousel/manifest.json +130 -0
  131. package/blocks/init/src/Blocks/custom/column/column-block.js +21 -0
  132. package/blocks/init/src/Blocks/custom/column/column-hooks.js +32 -0
  133. package/blocks/init/src/Blocks/custom/column/column.php +21 -0
  134. package/blocks/init/src/Blocks/custom/column/components/column-editor.js +19 -0
  135. package/blocks/init/src/Blocks/custom/column/components/column-options.js +579 -0
  136. package/blocks/init/src/Blocks/custom/column/manifest.json +625 -0
  137. package/blocks/init/src/Blocks/custom/columns/columns-block.js +20 -0
  138. package/blocks/init/src/Blocks/custom/columns/columns.php +21 -0
  139. package/blocks/init/src/Blocks/custom/columns/components/columns-editor.js +81 -0
  140. package/blocks/init/src/Blocks/custom/columns/components/columns-options.js +104 -0
  141. package/blocks/init/src/Blocks/custom/columns/manifest.json +555 -0
  142. package/blocks/init/src/Blocks/custom/featured-content/components/featured-content-editor.js +28 -0
  143. package/blocks/init/src/Blocks/custom/featured-content/components/featured-content-options.js +239 -0
  144. package/blocks/init/src/Blocks/custom/featured-content/featured-content-block.js +13 -0
  145. package/blocks/init/src/Blocks/custom/featured-content/featured-content.php +139 -0
  146. package/blocks/init/src/Blocks/custom/featured-content/manifest.json +131 -0
  147. package/blocks/init/src/Blocks/custom/featured-content/partials/cards.php +39 -0
  148. package/blocks/init/src/Blocks/custom/group/components/group-editor.js +8 -0
  149. package/blocks/init/src/Blocks/custom/group/group-block.js +14 -0
  150. package/blocks/init/src/Blocks/custom/group/group.php +10 -0
  151. package/blocks/init/src/Blocks/custom/group/manifest.json +32 -0
  152. package/blocks/init/src/Blocks/custom/heading/components/heading-editor.js +15 -0
  153. package/blocks/init/src/Blocks/custom/heading/components/heading-options.js +38 -0
  154. package/blocks/init/src/Blocks/custom/heading/heading-block.js +13 -0
  155. package/blocks/init/src/Blocks/custom/heading/heading-transforms.js +25 -0
  156. package/blocks/init/src/Blocks/custom/heading/heading.php +15 -0
  157. package/blocks/init/src/Blocks/custom/heading/manifest.json +79 -0
  158. package/blocks/init/src/Blocks/custom/hero/components/hero-editor.js +12 -0
  159. package/blocks/init/src/Blocks/custom/hero/components/hero-options.js +14 -0
  160. package/blocks/init/src/Blocks/custom/hero/hero-block.js +13 -0
  161. package/blocks/init/src/Blocks/custom/hero/hero.php +11 -0
  162. package/blocks/init/src/Blocks/custom/hero/manifest.json +17 -0
  163. package/blocks/init/src/Blocks/custom/image/components/image-editor.js +12 -0
  164. package/blocks/init/src/Blocks/custom/image/components/image-options.js +14 -0
  165. package/blocks/init/src/Blocks/custom/image/image-block.js +13 -0
  166. package/blocks/init/src/Blocks/custom/image/image.php +11 -0
  167. package/blocks/init/src/Blocks/custom/image/manifest.json +105 -0
  168. package/blocks/init/src/Blocks/custom/list/components/list-editor.js +14 -0
  169. package/blocks/init/src/Blocks/custom/list/components/list-options.js +39 -0
  170. package/blocks/init/src/Blocks/custom/list/list-block.js +13 -0
  171. package/blocks/init/src/Blocks/custom/list/list.php +15 -0
  172. package/blocks/init/src/Blocks/custom/list/manifest.json +58 -0
  173. package/blocks/init/src/Blocks/custom/map/assets/index.js +20 -0
  174. package/blocks/init/src/Blocks/custom/map/assets/map-controller.js +42 -0
  175. package/blocks/init/src/Blocks/custom/map/assets/utils.js +161 -0
  176. package/blocks/init/src/Blocks/custom/map/components/map-components.js +403 -0
  177. package/blocks/init/src/Blocks/custom/map/components/map-editor.js +56 -0
  178. package/blocks/init/src/Blocks/custom/map/components/map-options.js +557 -0
  179. package/blocks/init/src/Blocks/custom/map/manifest.json +79 -0
  180. package/blocks/init/src/Blocks/custom/map/map-block.js +13 -0
  181. package/blocks/init/src/Blocks/custom/map/map.php +52 -0
  182. package/blocks/init/src/Blocks/custom/map/styles.css +2 -0
  183. package/blocks/init/src/Blocks/custom/modal/components/modal-editor.js +90 -0
  184. package/blocks/init/src/Blocks/custom/modal/manifest.json +51 -0
  185. package/blocks/init/src/Blocks/custom/modal/modal-block.js +14 -0
  186. package/blocks/init/src/Blocks/custom/modal/modal.php +20 -0
  187. package/blocks/init/src/Blocks/custom/paragraph/components/paragraph-editor.js +41 -0
  188. package/blocks/init/src/Blocks/custom/paragraph/components/paragraph-options.js +38 -0
  189. package/blocks/init/src/Blocks/custom/paragraph/manifest.json +79 -0
  190. package/blocks/init/src/Blocks/custom/paragraph/paragraph-block.js +13 -0
  191. package/blocks/init/src/Blocks/custom/paragraph/paragraph-transforms.js +45 -0
  192. package/blocks/init/src/Blocks/custom/paragraph/paragraph.php +15 -0
  193. package/blocks/init/src/Blocks/custom/quote/components/quote-editor.js +12 -0
  194. package/blocks/init/src/Blocks/custom/quote/components/quote-options.js +14 -0
  195. package/blocks/init/src/Blocks/custom/quote/manifest.json +17 -0
  196. package/blocks/init/src/Blocks/custom/quote/quote-block.js +13 -0
  197. package/blocks/init/src/Blocks/custom/quote/quote.php +13 -0
  198. package/blocks/init/src/Blocks/custom/share/components/share-editor.js +6 -0
  199. package/blocks/init/src/Blocks/custom/share/components/share-options.js +12 -0
  200. package/blocks/init/src/Blocks/custom/share/manifest.json +19 -0
  201. package/blocks/init/src/Blocks/custom/share/share-block.js +13 -0
  202. package/blocks/init/src/Blocks/custom/share/share.php +11 -0
  203. package/blocks/init/src/Blocks/custom/site-footer/components/site-footer-editor.js +57 -0
  204. package/blocks/init/src/Blocks/custom/site-footer/components/site-footer-options.js +106 -0
  205. package/blocks/init/src/Blocks/custom/site-footer/manifest.json +73 -0
  206. package/blocks/init/src/Blocks/custom/site-footer/site-footer-block.js +13 -0
  207. package/blocks/init/src/Blocks/custom/site-footer/site-footer.php +72 -0
  208. package/blocks/init/src/Blocks/custom/site-navigation/assets/index.js +9 -0
  209. package/blocks/init/src/Blocks/custom/site-navigation/components/site-navigation-editor.js +42 -0
  210. package/blocks/init/src/Blocks/custom/site-navigation/components/site-navigation-options.js +73 -0
  211. package/blocks/init/src/Blocks/custom/site-navigation/manifest.json +77 -0
  212. package/blocks/init/src/Blocks/custom/site-navigation/site-navigation-block.js +13 -0
  213. package/blocks/init/src/Blocks/custom/site-navigation/site-navigation.php +99 -0
  214. package/blocks/init/src/Blocks/custom/table-of-contents/assets/index.js +58 -0
  215. package/blocks/init/src/Blocks/custom/table-of-contents/components/table-of-contents-editor.js +38 -0
  216. package/blocks/init/src/Blocks/custom/table-of-contents/components/table-of-contents-options.js +32 -0
  217. package/blocks/init/src/Blocks/custom/table-of-contents/manifest.json +48 -0
  218. package/blocks/init/src/Blocks/custom/table-of-contents/table-of-contents-block.js +13 -0
  219. package/blocks/init/src/Blocks/custom/table-of-contents/table-of-contents.php +31 -0
  220. package/blocks/init/src/Blocks/custom/video/components/video-editor.js +6 -0
  221. package/blocks/init/src/Blocks/custom/video/components/video-options.js +12 -0
  222. package/blocks/init/src/Blocks/custom/video/manifest.json +105 -0
  223. package/blocks/init/src/Blocks/custom/video/video-block.js +13 -0
  224. package/blocks/init/src/Blocks/custom/video/video.php +22 -0
  225. package/blocks/init/src/Blocks/manifest.json +14 -0
  226. package/blocks/init/src/Blocks/variations/card-simple/manifest.json +17 -0
  227. package/blocks/init/src/Blocks/wrapper/components/wrapper-editor.js +12 -0
  228. package/blocks/init/src/Blocks/wrapper/components/wrapper-options.js +348 -0
  229. package/blocks/init/src/Blocks/wrapper/manifest.json +450 -0
  230. package/blocks/init/src/Blocks/wrapper/styles-editor.css +13 -0
  231. package/blocks/init/src/Blocks/wrapper/styles.css +19 -0
  232. package/blocks/init/src/Blocks/wrapper/wrapper.js +30 -0
  233. package/blocks/init/src/Blocks/wrapper/wrapper.php +34 -0
  234. package/eslint.config.mjs +3 -0
  235. package/linters/base.config.mjs +81 -0
  236. package/linters/eslint.config.mjs +4 -0
  237. package/linters/ignore-gitignored.mjs +9 -0
  238. package/linters/stylelint.config.js +146 -0
  239. package/package.json +93 -0
  240. package/readme/packages.md +74 -0
  241. package/schemas/block.json +302 -0
  242. package/schemas/component.json +240 -0
  243. package/schemas/globalManifest.json +73 -0
  244. package/schemas/variation.json +83 -0
  245. package/scripts/components/block-inserter.js +70 -0
  246. package/scripts/components/file-picker.js +243 -0
  247. package/scripts/components/index.js +6 -0
  248. package/scripts/components/link-section-editor.js +319 -0
  249. package/scripts/components/media-picker.js +86 -0
  250. package/scripts/components/server-side-render.js +37 -0
  251. package/scripts/components/settings/settings.js +48 -0
  252. package/scripts/components/settings/use-theme-options.js +52 -0
  253. package/scripts/editor/attributes.js +304 -0
  254. package/scripts/editor/colors.js +64 -0
  255. package/scripts/editor/editor.js +139 -0
  256. package/scripts/editor/fetch.js +102 -0
  257. package/scripts/editor/hooks.js +44 -0
  258. package/scripts/editor/index.js +11 -0
  259. package/scripts/editor/options.js +152 -0
  260. package/scripts/editor/registration.js +901 -0
  261. package/scripts/editor/store.js +213 -0
  262. package/scripts/editor/tailwindcss.js +224 -0
  263. package/scripts/editor/utility.js +47 -0
  264. package/scripts/helpers/breakpoints.js +48 -0
  265. package/scripts/helpers/cookies.js +65 -0
  266. package/scripts/helpers/dynamic-import.js +19 -0
  267. package/scripts/helpers/index.js +11 -0
  268. package/scripts/index.js +22 -0
  269. package/scripts/plugins/index.js +3 -0
  270. package/scripts/plugins/yoast-seo.js +70 -0
  271. package/webpack/base.mjs +138 -0
  272. package/webpack/helpers.mjs +67 -0
  273. package/webpack/index.mjs +52 -0
  274. package/webpack/production.mjs +60 -0
  275. package/webpack/project.mjs +55 -0
@@ -0,0 +1,213 @@
1
+ import { register, createReduxStore, select, dispatch } from '@wordpress/data';
2
+
3
+ // Store name defined by build version so we can have multiple themes and plugins.
4
+ export const BUILD_VERSION = process.env.VERSION;
5
+ export const STORE_NAME = `eightshift/${BUILD_VERSION}`;
6
+
7
+ // Set default store state.
8
+ const DEFAULT_STATE = {
9
+ blocks: {},
10
+ components: {},
11
+ config: {
12
+ useWrapper: true,
13
+ },
14
+ wrapper: {},
15
+ variations: {},
16
+ settings: {},
17
+ styles: [],
18
+ hasStylesUpdated: false,
19
+ };
20
+
21
+ // Define selectors - only getters.
22
+ const selectors = {
23
+ getBlocks(state) {
24
+ return state.blocks;
25
+ },
26
+ getBlock(state, blockName) {
27
+ return state.blocks.find((block) => block.blockName === blockName);
28
+ },
29
+ getComponents(state) {
30
+ return state.components;
31
+ },
32
+ getComponent(state, componentName) {
33
+ return state.components.find((component) => component.componentName === componentName);
34
+ },
35
+ getVariations(state) {
36
+ return state.variations;
37
+ },
38
+ getVariation(state, name) {
39
+ return state.variations.find((variation) => variation.name === name);
40
+ },
41
+ getConfig(state) {
42
+ return state.config;
43
+ },
44
+ getConfigUseWrapper(state) {
45
+ return state.config.useWrapper;
46
+ },
47
+ getWrapper(state) {
48
+ return state.wrapper;
49
+ },
50
+ getSettings(state) {
51
+ return state.settings;
52
+ },
53
+ getSettingsNamespace(state) {
54
+ return state.settings.namespace;
55
+ },
56
+ getSettingsGlobalVariables(state) {
57
+ return state.settings.globalVariables;
58
+ },
59
+ getSettingsGlobalVariablesCustomBlockName(state) {
60
+ return state.settings.globalVariables.customBlocksName;
61
+ },
62
+ getSettingsGlobalVariablesBreakpoints(state) {
63
+ return state.settings.globalVariables.breakpoints;
64
+ },
65
+ };
66
+
67
+ // Define actions - getters and setters.
68
+ const actions = {
69
+ setBlocks(blocks) {
70
+ return {
71
+ type: 'SET_BLOCKS',
72
+ blocks,
73
+ };
74
+ },
75
+ setComponents(components) {
76
+ return {
77
+ type: 'SET_COMPONENTS',
78
+ components,
79
+ };
80
+ },
81
+ setVariations(variations) {
82
+ return {
83
+ type: 'SET_VARIATIONS',
84
+ variations,
85
+ };
86
+ },
87
+ setConfigUseWrapper(config) {
88
+ return {
89
+ type: 'SET_CONFIG_USE_WRAPPER',
90
+ config,
91
+ };
92
+ },
93
+ setWrapper(wrapper) {
94
+ return {
95
+ type: 'SET_WRAPPER',
96
+ wrapper,
97
+ };
98
+ },
99
+ setSettings(settings) {
100
+ return {
101
+ type: 'SET_SETTINGS',
102
+ settings,
103
+ };
104
+ },
105
+ setSettingsGlobalVariablesBreakpoints(breakpoints) {
106
+ return {
107
+ type: 'SET_SETTINGS_GLOBAL_VARIABLES_BREAKPOINTS',
108
+ breakpoints,
109
+ };
110
+ },
111
+ };
112
+
113
+ // Define reducers - only setters.
114
+ const reducer = (state = DEFAULT_STATE, action) => {
115
+ switch (action.type) {
116
+ case 'SET_BLOCKS': {
117
+ return {
118
+ ...state,
119
+ blocks: action.blocks,
120
+ };
121
+ }
122
+ case 'SET_COMPONENTS': {
123
+ return {
124
+ ...state,
125
+ components: action.components,
126
+ };
127
+ }
128
+ case 'SET_VARIATIONS': {
129
+ return {
130
+ ...state,
131
+ variations: action.variations,
132
+ };
133
+ }
134
+ case 'SET_CONFIG_USE_WRAPPER': {
135
+ return {
136
+ ...state,
137
+ config: {
138
+ ...state.config,
139
+ useWrapper: action.config,
140
+ },
141
+ };
142
+ }
143
+ case 'SET_WRAPPER': {
144
+ return {
145
+ ...state,
146
+ wrapper: action.wrapper,
147
+ };
148
+ }
149
+ case 'SET_SETTINGS': {
150
+ return {
151
+ ...state,
152
+ settings: action.settings,
153
+ };
154
+ }
155
+ case 'SET_SETTINGS_GLOBAL_VARIABLES_BREAKPOINTS': {
156
+ return {
157
+ ...state,
158
+ settings: {
159
+ ...state.settings,
160
+ globalVariables: {
161
+ ...state.settings.globalVariables,
162
+ breakpoints: action.breakpoints,
163
+ },
164
+ },
165
+ };
166
+ }
167
+ default: {
168
+ return state;
169
+ }
170
+ }
171
+ };
172
+
173
+ // Register the store.
174
+ export const setStore = () => {
175
+ if (typeof window?.eightshift === 'undefined') {
176
+ window.eightshift = {};
177
+ }
178
+
179
+ register(
180
+ createReduxStore(STORE_NAME, {
181
+ selectors,
182
+ actions,
183
+ reducer,
184
+ }),
185
+ );
186
+ };
187
+
188
+ /**
189
+ * Set features config flag set in the global manifest settings.
190
+ *
191
+ * @access private
192
+ *
193
+ * @returns {void}
194
+ */
195
+ export const setConfigFlags = () => {
196
+ const config = select(STORE_NAME).getSettings()?.config;
197
+
198
+ if (typeof config !== 'undefined') {
199
+ // useWrapper
200
+ if (typeof config?.useWrapper === 'boolean') {
201
+ dispatch(STORE_NAME).setConfigUseWrapper(config.useWrapper);
202
+ }
203
+ }
204
+ };
205
+
206
+ // Set global window data for easier debugging.
207
+ export const setStoreGlobalWindow = () => {
208
+ if (typeof window?.eightshift?.store === 'undefined') {
209
+ window.eightshift.store = {};
210
+ }
211
+
212
+ window.eightshift.store[select(STORE_NAME).getSettingsNamespace()] = STORE_NAME;
213
+ };
@@ -0,0 +1,224 @@
1
+ import { checkAttr } from '../editor/attributes';
2
+ import { clsx } from '@eightshift/ui-components/utilities';
3
+
4
+ /**
5
+ * Gets Tailwind classes for the provided part.
6
+ *
7
+ * The part needs to be defined within the manifest, in the `tailwind` object.
8
+ *
9
+ * @param {string} attributes - Part name.
10
+ * @param {Object<string, mixed>} manifest - Component/block manifest.
11
+ * @param {...string?} custom - Custom classes to include in the ouptut.
12
+ *
13
+ * @returns {string} Output classes.
14
+ *
15
+ * @example
16
+ * const classes = getTwPart('intro', manifest);
17
+ *
18
+ * @example
19
+ * const classes = getTwPart('intro', manifest, 'p-4 bg-gray-100');
20
+ *
21
+ */
22
+ export const getTwPart = (part, manifest, ...custom) => {
23
+ if (!part || !manifest || !manifest?.tailwind || Object.keys(manifest?.tailwind ?? {}).length === 0) {
24
+ return '';
25
+ }
26
+
27
+ const partClasses = manifest?.tailwind?.parts?.[part]?.twClassesEditor ?? manifest?.tailwind?.parts?.[part]?.twClasses ?? '';
28
+
29
+ return clsx(partClasses, ...custom);
30
+ };
31
+
32
+ /**
33
+ * Get Tailwind classes from attributes and manifest.
34
+ *
35
+ * @param {Object<string, mixed>} attributes - Current attribute value.
36
+ * @param {Object<string, mixed>} manifest - Component/block manifest.
37
+ * @param {...string?} custom - Custom classes to include in the ouptut.
38
+ *
39
+ * @returns {string} Output classes
40
+ *
41
+ * @example
42
+ * const classes = getTwClasses(attributes, manifest);
43
+ *
44
+ * @example
45
+ * const classes = getTwClasses(attributes, manifest, 'p-4 bg-gray-100');
46
+ *
47
+ */
48
+ export const getTwClasses = (attributes, manifest, ...custom) => {
49
+ if (!attributes || !manifest || !manifest?.tailwind || Object.keys(manifest?.tailwind ?? {}).length === 0) {
50
+ return '';
51
+ }
52
+
53
+ const baseClasses = manifest?.tailwind?.base?.twClassesEditor ?? manifest?.tailwind?.base?.twClasses ?? '';
54
+
55
+ const mainClasses = Object.entries(manifest?.tailwind?.options ?? {}).reduce((current, [attributeName, { responsive, twClasses, twClassesEditor }]) => {
56
+ const value = checkAttr(attributeName, attributes, manifest, true);
57
+
58
+ if (!value) {
59
+ return current;
60
+ }
61
+
62
+ if (!responsive) {
63
+ return [...current, twClassesEditor?.[value] ?? twClasses?.[value]];
64
+ }
65
+
66
+ const responsiveClasses = Object.keys(value).reduce((curr, breakpoint) => {
67
+ if (breakpoint === '_desktopFirst') {
68
+ return curr;
69
+ }
70
+
71
+ const currentClasses = twClassesEditor?.[value[breakpoint]] ?? twClasses?.[value[breakpoint]];
72
+
73
+ if (breakpoint === '_default') {
74
+ return [...curr, currentClasses];
75
+ }
76
+
77
+ if (Array.isArray(currentClasses)) {
78
+ return [...curr, ...currentClasses.split(' ').map((currentClass) => `${breakpoint}:${currentClass}`)];
79
+ }
80
+
81
+ return [...curr, `${breakpoint}:${currentClasses}`];
82
+ }, []);
83
+
84
+ return [...current, ...responsiveClasses];
85
+ }, []);
86
+
87
+ const combinationClasses = manifest?.tailwind?.combinations?.reduce((current, { attributes: conditions, twClasses, twClassesEditor }) => {
88
+ const conditionKeys = Object.keys(conditions);
89
+
90
+ for (const key of conditionKeys) {
91
+ const value = checkAttr(key, attributes, manifest, true);
92
+
93
+ const isArrayCondition = Array.isArray(conditions[key]);
94
+
95
+ if (!value) {
96
+ return current;
97
+ } else if (isArrayCondition && !conditions[key].includes(value)) {
98
+ return current;
99
+ } else if (!isArrayCondition && value !== conditions[key]) {
100
+ return current;
101
+ }
102
+ }
103
+
104
+ return [...current, twClassesEditor ?? twClasses];
105
+ }, []) ?? [];
106
+
107
+ return clsx(baseClasses, ...mainClasses, ...combinationClasses, ...custom);
108
+ };
109
+
110
+ /**
111
+ * Custom transformer for JSON files. Required for processing responsive classes.
112
+ *
113
+ * @returns {Object} Custom transformation object for JSON.
114
+ *
115
+ * @example
116
+ * // Tailwind config
117
+ * module.exports = {
118
+ * content: {
119
+ * // ...
120
+ * transform: processEightshiftClasses(breakpointNames),
121
+ * },
122
+ * }
123
+ *
124
+ * @example
125
+ * // Tailwind config
126
+ * module.exports = {
127
+ * content: {
128
+ * // ...
129
+ * transform: {
130
+ * ...processEightshiftClasses(breakpointNames),
131
+ * // Your transformations.
132
+ * },
133
+ * },
134
+ * }
135
+ *
136
+ */
137
+ export const processEightshiftClasses = (breakpoints) => ({
138
+ // Make sure to include all the custom ES classes from JSON manifests.
139
+ json: (rawContent) => {
140
+ if (!(rawContent.includes('tailwind'))) {
141
+ return rawContent;
142
+ }
143
+
144
+ const content = JSON.parse(rawContent);
145
+
146
+ const results = Array.from(extractKeys(content));
147
+
148
+ const combinedResults = combineAndRemoveDuplicates(results);
149
+
150
+ for (let key in combinedResults) {
151
+ let combined = combinedResults[key].split(' ');
152
+ combined = [...new Set(combined)];
153
+ combinedResults[key] = combined.join(' ');
154
+ }
155
+
156
+ const responsiveVars = combinedResults?.responsive?.split(' ')?.map((cls) => {
157
+ return breakpoints.reduce((curr, breakpoint) => `${curr} ${breakpoint}:${cls} max-${breakpoint}:${cls}`, cls)
158
+ })?.join(' ') ?? '';
159
+
160
+ const nonResponsiveVars = combinedResults?.regular ?? '';
161
+
162
+ return `${nonResponsiveVars} ${responsiveVars}`.trim();
163
+ }
164
+ });
165
+
166
+ /**
167
+ * Converts global manifest breakpoints to Tailwind screen definitions.
168
+ *
169
+ * @param {Object<string, Number>} breakpointData - Breakpoint data from global manifest.
170
+ *
171
+ * @returns {Object} Tailwind screen definitions.
172
+ *
173
+ * @example
174
+ * // Tailwind config
175
+ * module.exports = {
176
+ * // ...
177
+ * theme: {
178
+ * screens: getScreens(globalManifest.globalVariables.breakpoints),
179
+ * // ...
180
+ * },
181
+ * }
182
+ *
183
+ */
184
+ export const getScreens = (breakpointData, unit = 'rem') => {
185
+ return Object.entries(breakpointData ?? []).reduce((acc, [key, value]) => ({
186
+ ...acc,
187
+ [key]: `${value}${unit}`,
188
+ }), {});
189
+ };
190
+
191
+ export const generateOptionsFromValue = (value, getLabel = (v) => v) => {
192
+ return Object.entries(value).filter(([breakpoint]) => breakpoint !== '_desktopFirst').map(([breakpoint, innerValue]) => ({
193
+ value: innerValue,
194
+ label: getLabel(innerValue, breakpoint),
195
+ }));
196
+ }
197
+
198
+ // Utilities
199
+ function* extractKeys(obj, parentKey = '', isResponsive = false) {
200
+ isResponsive = obj['responsive'] === true ? true : isResponsive;
201
+ let resultKey = isResponsive ? "responsive" : "regular";
202
+
203
+ for (let key in obj) {
204
+ let newKey = parentKey ? `${parentKey}.${key}` : key;
205
+ if (typeof obj[key] === 'object' && obj[key] !== null) {
206
+ yield* extractKeys(obj[key], newKey, isResponsive);
207
+ } else if (newKey.includes('twClasses')) {
208
+ if (typeof obj[key] === 'object') {
209
+ for (let subKey in obj[key]) {
210
+ yield {key: `${newKey}.${subKey}`, value: obj[key][subKey], responsive: resultKey};
211
+ }
212
+ } else {
213
+ yield {key: newKey, value: obj[key], responsive: resultKey};
214
+ }
215
+ }
216
+ }
217
+ }
218
+
219
+ const combineAndRemoveDuplicates = (results) => {
220
+ return results.reduce((acc, {key, value, responsive}) => {
221
+ acc[responsive] = acc[responsive] ? `${acc[responsive]} ${value}` : value;
222
+ return acc;
223
+ }, {});
224
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Prepares the hidden option object from provided string, for use within the component.
3
+ *
4
+ * @param {Object} props - Component props.
5
+ *
6
+ * @returns {Object} Disabled component reference.
7
+ *
8
+ * @example
9
+ * // ButtonEditor
10
+ * <IconEditor hideOptions='size' />
11
+ *
12
+ * // IconEditor
13
+ * const hiddenOptions = getHiddenOptions(attributes.hideOptions);
14
+ *
15
+ * ...
16
+ *
17
+ * {!hiddenOptions.size && <MyOptionComponent />}
18
+ *
19
+ */
20
+ export const getHiddenOptions = (options) => {
21
+ if (!options) {
22
+ return {};
23
+ }
24
+
25
+ return Object.fromEntries(options.split(',').map((item) => [item.trim(), true]));
26
+ };
27
+
28
+ /**
29
+ * Returns a unique ID, generally used with CSS variable generation.
30
+ *
31
+ * @access public
32
+ *
33
+ * @return {string}
34
+ *
35
+ * Usage:
36
+ * ```js
37
+ * getUnique();
38
+ * ```
39
+ *
40
+ * Output:
41
+ * ```js
42
+ * mg2shbh9
43
+ * ```
44
+ */
45
+ export const getUnique = () => {
46
+ return (Math.random() + 1).toString(36).substring(4);
47
+ };
@@ -0,0 +1,48 @@
1
+ import { select } from '@wordpress/data';
2
+ import { STORE_NAME } from '../editor/store';
3
+
4
+ export const getGlobalManifest = () => select(STORE_NAME)?.getSettings();
5
+
6
+ export const getBreakpointNames = () => {
7
+ const breakpoints = select(STORE_NAME)?.getSettings()?.globalVariables?.breakpoints;
8
+
9
+ return Object.entries(breakpoints)
10
+ .toSorted((a, b) => b[1] - a[1])
11
+ .map(([name]) => name).toReversed();
12
+ };
13
+
14
+ export const getBreakpointData = (convertToPx = false) => {
15
+ const breakpoints = select(STORE_NAME)?.getSettings()?.globalVariables?.breakpoints;
16
+
17
+ if (convertToPx) {
18
+ return Object.fromEntries(
19
+ Object.entries(breakpoints)
20
+ .map(([name, value]) => [
21
+ name,
22
+ value * 16,
23
+ ])
24
+ );
25
+ }
26
+
27
+ return breakpoints;
28
+ };
29
+
30
+ export const getBreakpointUiData = () => select(STORE_NAME)?.getSettings()?.globalVariables?.breakpointData;
31
+
32
+ export const getResponsiveData = (convertToPx = false) => {
33
+ const uiData = getBreakpointUiData();
34
+
35
+ const baseData = {
36
+ breakpoints: getBreakpointNames(),
37
+ breakpointData: getBreakpointData(convertToPx),
38
+ };
39
+
40
+ if (!uiData) {
41
+ return baseData;
42
+ }
43
+
44
+ return {
45
+ ...baseData,
46
+ breakpointUiData: uiData,
47
+ };
48
+ };
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Helper to set and unset cookies.
3
+ */
4
+ export const cookies = {
5
+ /**
6
+ * Set a cookie value
7
+ *
8
+ * @param {string} key - Unique cookie key.
9
+ * @param {string} value - Cookie value.
10
+ * @param {number} time - Number denoting the expiration of the cookie.
11
+ * @param {string} path - URL path that must exist in the requested URL in order to send the Cookie header.
12
+ *
13
+ * @access public
14
+ *
15
+ * @returns {void}
16
+ *
17
+ * Usage:
18
+ * ```js
19
+ * cookies.setCookie('gdpr', '2', cookies.setOneDay(), '/');
20
+ * ```
21
+ */
22
+ setCookie(key, value, time, path) {
23
+ const expires = new Date();
24
+ expires.setTime(expires.getTime() + (time));
25
+ let pathValue = '';
26
+
27
+ if (typeof path !== 'undefined') {
28
+ pathValue = `path=${path};`;
29
+ }
30
+
31
+ document.cookie = `${key}=${value};${pathValue}expires=${expires.toUTCString()}`;
32
+ },
33
+
34
+ /**
35
+ * Get a cookie
36
+ *
37
+ * @param {string} key Unique cookie key.
38
+ *
39
+ * @return Cookie value or null if the cookie doesn't exist.
40
+ *
41
+ * Usage:
42
+ * ```js
43
+ * cookies.getCookie('gdpr');
44
+ * ```
45
+ */
46
+ getCookie(key) {
47
+ const keyValue = document.cookie.match(`(^|;) ?${key}=([^;]*)(;|$)`);
48
+ return keyValue ? keyValue[2] : null;
49
+ },
50
+ setHalfDay() {
51
+ return 43200000;
52
+ },
53
+ setOneDay() {
54
+ return 86400000;
55
+ },
56
+ setOneYear() {
57
+ return 31540000000;
58
+ },
59
+ setHalfAnHour() {
60
+ return 1800000;
61
+ },
62
+ setOneMonth() {
63
+ return 2628000000;
64
+ },
65
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Loop all paths required using require.context method.
3
+ * Used to get (require) all the files using the `require.context` method.
4
+ * It will find all files recursively in the folder using a regex.
5
+ *
6
+ * @param {object} paths - All `require.context` paths to iterate.
7
+ *
8
+ * @access public
9
+ *
10
+ * @returns {void}
11
+ *
12
+ * Usage:
13
+ * ```js
14
+ * dynamicImport(require.context('./../../custom', true, /assets\/index.js$/));
15
+ * ```
16
+ */
17
+ export function dynamicImport(paths) {
18
+ paths.keys().forEach(paths);
19
+ }
@@ -0,0 +1,11 @@
1
+ // All exports are sorted in alphabetical order.
2
+
3
+ export {
4
+ getBreakpointData,
5
+ getBreakpointNames,
6
+ getGlobalManifest,
7
+ getBreakpointUiData,
8
+ getResponsiveData,
9
+ } from './breakpoints';
10
+ export { cookies } from './cookies';
11
+ export { dynamicImport } from './dynamic-import';
@@ -0,0 +1,22 @@
1
+ // Components.
2
+ export { BlockInserter } from './components/block-inserter';
3
+ export { ManageFileButton, FileSelector } from './components/file-picker';
4
+ export { MediaPicker } from './components/media-picker';
5
+ export { ServerSideRender } from './components/server-side-render';
6
+ export { ThemeOptionsPage, EsThemeOptionsContext } from './components/settings/settings';
7
+
8
+ // Editor.
9
+ export * from './editor/attributes';
10
+ export * from './editor/colors';
11
+ export * from './editor/editor';
12
+ export * from './editor/fetch';
13
+ export * from './editor/options';
14
+ export * from './editor/utility';
15
+ export * from './editor/tailwindcss';
16
+ export { getAttributes, getExample, getFullBlockName, getFullBlockNameVariation, registerBlocks, registerVariations } from './editor/registration';
17
+ export { STORE_NAME, BUILD_VERSION, setStore, setStoreGlobalWindow, setConfigFlags } from './editor/store';
18
+
19
+ // Helpers.
20
+ export { getBreakpointData, getBreakpointNames, getGlobalManifest, getBreakpointUiData, getResponsiveData } from './helpers/breakpoints';
21
+ export { cookies } from './helpers/cookies';
22
+ export { dynamicImport } from './helpers/dynamic-import';
@@ -0,0 +1,3 @@
1
+ // All exports are sorted in alphabetical order.
2
+
3
+ export { yoastSeo } from './yoast-seo';