@redneckz/wildless-cms-uni-blocks 0.6.19 → 0.6.20

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 (215) hide show
  1. package/bin/migration-scripts/0.6.19.js +21 -0
  2. package/bundle/bundle.umd.js +49 -22
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/bundle/components/Blocks.d.ts +2 -41
  5. package/bundle/components/Blocks.mobile.d.ts +2 -18
  6. package/bundle/components/ContentPage/ContentPage.d.ts +2 -2
  7. package/bundle/components/ContentPage/mapSlot.d.ts +2 -0
  8. package/bundle/components/ContentPage/normalizeBlock.d.ts +3 -11
  9. package/bundle/components/ContentPage/normalizeBlock.mobile.d.ts +3 -2
  10. package/bundle/components/ContentPage/renderBlock.d.ts +7 -3
  11. package/bundle/components/ContentPage/renderBlockList.d.ts +14 -0
  12. package/bundle/components/ContentPage/renderSlots.d.ts +12 -0
  13. package/bundle/model/BlockDecorator.d.ts +4 -3
  14. package/bundle/model/BlocksRegistry.d.ts +1 -1
  15. package/bundle/model/ContentPageDef.d.ts +1 -4
  16. package/bundle/model/JSXBlock.d.ts +3 -1
  17. package/dist/components/Blocks.d.ts +2 -41
  18. package/dist/components/Blocks.js.map +1 -1
  19. package/dist/components/Blocks.mobile.d.ts +2 -18
  20. package/dist/components/Blocks.mobile.js.map +1 -1
  21. package/dist/components/ContentPage/ContentPage.d.ts +2 -2
  22. package/dist/components/ContentPage/ContentPage.js +12 -11
  23. package/dist/components/ContentPage/ContentPage.js.map +1 -1
  24. package/dist/components/ContentPage/mapSlot.d.ts +2 -0
  25. package/dist/components/ContentPage/mapSlot.js +14 -0
  26. package/dist/components/ContentPage/mapSlot.js.map +1 -0
  27. package/dist/components/ContentPage/normalizeBlock.d.ts +3 -11
  28. package/dist/components/ContentPage/normalizeBlock.js +13 -3
  29. package/dist/components/ContentPage/normalizeBlock.js.map +1 -1
  30. package/dist/components/ContentPage/normalizeBlock.mobile.d.ts +3 -2
  31. package/dist/components/ContentPage/normalizeBlock.mobile.js +18 -3
  32. package/dist/components/ContentPage/normalizeBlock.mobile.js.map +1 -1
  33. package/dist/components/ContentPage/normalizePage.js +2 -14
  34. package/dist/components/ContentPage/normalizePage.js.map +1 -1
  35. package/dist/components/ContentPage/renderBlock.d.ts +7 -3
  36. package/dist/components/ContentPage/renderBlock.js +9 -9
  37. package/dist/components/ContentPage/renderBlock.js.map +1 -1
  38. package/dist/components/ContentPage/renderBlockList.d.ts +14 -0
  39. package/dist/components/ContentPage/renderBlockList.js +18 -0
  40. package/dist/components/ContentPage/renderBlockList.js.map +1 -0
  41. package/dist/components/ContentPage/renderSlots.d.ts +12 -0
  42. package/dist/components/ContentPage/renderSlots.js +17 -0
  43. package/dist/components/ContentPage/renderSlots.js.map +1 -0
  44. package/dist/model/BlockDecorator.d.ts +4 -3
  45. package/dist/model/BlockDecorator.js +1 -2
  46. package/dist/model/BlockDecorator.js.map +1 -1
  47. package/dist/model/BlocksRegistry.d.ts +1 -1
  48. package/dist/model/ContentPageDef.d.ts +1 -4
  49. package/dist/model/JSXBlock.d.ts +3 -1
  50. package/dist/model/getParentBlockDef.js +5 -2
  51. package/dist/model/getParentBlockDef.js.map +1 -1
  52. package/lib/components/Blocks.d.ts +2 -41
  53. package/lib/components/Blocks.js.map +1 -1
  54. package/lib/components/Blocks.mobile.d.ts +2 -18
  55. package/lib/components/Blocks.mobile.js.map +1 -1
  56. package/lib/components/ContentPage/ContentPage.d.ts +2 -2
  57. package/lib/components/ContentPage/ContentPage.js +12 -11
  58. package/lib/components/ContentPage/ContentPage.js.map +1 -1
  59. package/lib/components/ContentPage/mapSlot.d.ts +2 -0
  60. package/lib/components/ContentPage/mapSlot.js +11 -0
  61. package/lib/components/ContentPage/mapSlot.js.map +1 -0
  62. package/lib/components/ContentPage/normalizeBlock.d.ts +3 -11
  63. package/lib/components/ContentPage/normalizeBlock.js +13 -3
  64. package/lib/components/ContentPage/normalizeBlock.js.map +1 -1
  65. package/lib/components/ContentPage/normalizeBlock.mobile.d.ts +3 -2
  66. package/lib/components/ContentPage/normalizeBlock.mobile.js +18 -3
  67. package/lib/components/ContentPage/normalizeBlock.mobile.js.map +1 -1
  68. package/lib/components/ContentPage/normalizePage.js +2 -14
  69. package/lib/components/ContentPage/normalizePage.js.map +1 -1
  70. package/lib/components/ContentPage/renderBlock.d.ts +7 -3
  71. package/lib/components/ContentPage/renderBlock.js +9 -9
  72. package/lib/components/ContentPage/renderBlock.js.map +1 -1
  73. package/lib/components/ContentPage/renderBlockList.d.ts +14 -0
  74. package/lib/components/ContentPage/renderBlockList.js +15 -0
  75. package/lib/components/ContentPage/renderBlockList.js.map +1 -0
  76. package/lib/components/ContentPage/renderSlots.d.ts +12 -0
  77. package/lib/components/ContentPage/renderSlots.js +14 -0
  78. package/lib/components/ContentPage/renderSlots.js.map +1 -0
  79. package/lib/model/BlockDecorator.d.ts +4 -3
  80. package/lib/model/BlockDecorator.js +0 -1
  81. package/lib/model/BlockDecorator.js.map +1 -1
  82. package/lib/model/BlocksRegistry.d.ts +1 -1
  83. package/lib/model/ContentPageDef.d.ts +1 -4
  84. package/lib/model/JSXBlock.d.ts +3 -1
  85. package/lib/model/getParentBlockDef.js +5 -2
  86. package/lib/model/getParentBlockDef.js.map +1 -1
  87. package/mobile/bundle/bundle.umd.js +49 -22
  88. package/mobile/bundle/bundle.umd.min.js +1 -1
  89. package/mobile/bundle/components/Blocks.d.ts +2 -18
  90. package/mobile/bundle/components/ContentPage/ContentPage.d.ts +2 -2
  91. package/mobile/bundle/components/ContentPage/mapSlot.d.ts +2 -0
  92. package/mobile/bundle/components/ContentPage/normalizeBlock.d.ts +3 -2
  93. package/mobile/bundle/components/ContentPage/renderBlock.d.ts +7 -3
  94. package/mobile/bundle/components/ContentPage/renderBlockList.d.ts +14 -0
  95. package/mobile/bundle/components/ContentPage/renderSlots.d.ts +12 -0
  96. package/mobile/bundle/model/BlockDecorator.d.ts +4 -3
  97. package/mobile/bundle/model/BlocksRegistry.d.ts +1 -1
  98. package/mobile/bundle/model/ContentPageDef.d.ts +1 -4
  99. package/mobile/bundle/model/JSXBlock.d.ts +3 -1
  100. package/mobile/dist/components/Blocks.d.ts +2 -18
  101. package/mobile/dist/components/Blocks.js.map +1 -1
  102. package/mobile/dist/components/ContentPage/ContentPage.d.ts +2 -2
  103. package/mobile/dist/components/ContentPage/ContentPage.js +12 -11
  104. package/mobile/dist/components/ContentPage/ContentPage.js.map +1 -1
  105. package/mobile/dist/components/ContentPage/mapSlot.d.ts +2 -0
  106. package/mobile/dist/components/ContentPage/mapSlot.js +14 -0
  107. package/mobile/dist/components/ContentPage/mapSlot.js.map +1 -0
  108. package/mobile/dist/components/ContentPage/normalizeBlock.d.ts +3 -2
  109. package/mobile/dist/components/ContentPage/normalizeBlock.js +18 -3
  110. package/mobile/dist/components/ContentPage/normalizeBlock.js.map +1 -1
  111. package/mobile/dist/components/ContentPage/normalizePage.js +2 -14
  112. package/mobile/dist/components/ContentPage/normalizePage.js.map +1 -1
  113. package/mobile/dist/components/ContentPage/renderBlock.d.ts +7 -3
  114. package/mobile/dist/components/ContentPage/renderBlock.js +9 -9
  115. package/mobile/dist/components/ContentPage/renderBlock.js.map +1 -1
  116. package/mobile/dist/components/ContentPage/renderBlockList.d.ts +14 -0
  117. package/mobile/dist/components/ContentPage/renderBlockList.js +18 -0
  118. package/mobile/dist/components/ContentPage/renderBlockList.js.map +1 -0
  119. package/mobile/dist/components/ContentPage/renderSlots.d.ts +12 -0
  120. package/mobile/dist/components/ContentPage/renderSlots.js +17 -0
  121. package/mobile/dist/components/ContentPage/renderSlots.js.map +1 -0
  122. package/mobile/dist/model/BlockDecorator.d.ts +4 -3
  123. package/mobile/dist/model/BlockDecorator.js +1 -2
  124. package/mobile/dist/model/BlockDecorator.js.map +1 -1
  125. package/mobile/dist/model/BlocksRegistry.d.ts +1 -1
  126. package/mobile/dist/model/ContentPageDef.d.ts +1 -4
  127. package/mobile/dist/model/JSXBlock.d.ts +3 -1
  128. package/mobile/dist/model/getParentBlockDef.js +5 -2
  129. package/mobile/dist/model/getParentBlockDef.js.map +1 -1
  130. package/mobile/lib/components/Blocks.d.ts +2 -18
  131. package/mobile/lib/components/Blocks.js.map +1 -1
  132. package/mobile/lib/components/ContentPage/ContentPage.d.ts +2 -2
  133. package/mobile/lib/components/ContentPage/ContentPage.js +12 -11
  134. package/mobile/lib/components/ContentPage/ContentPage.js.map +1 -1
  135. package/mobile/lib/components/ContentPage/mapSlot.d.ts +2 -0
  136. package/mobile/lib/components/ContentPage/mapSlot.js +11 -0
  137. package/mobile/lib/components/ContentPage/mapSlot.js.map +1 -0
  138. package/mobile/lib/components/ContentPage/normalizeBlock.d.ts +3 -2
  139. package/mobile/lib/components/ContentPage/normalizeBlock.js +18 -3
  140. package/mobile/lib/components/ContentPage/normalizeBlock.js.map +1 -1
  141. package/mobile/lib/components/ContentPage/normalizePage.js +2 -14
  142. package/mobile/lib/components/ContentPage/normalizePage.js.map +1 -1
  143. package/mobile/lib/components/ContentPage/renderBlock.d.ts +7 -3
  144. package/mobile/lib/components/ContentPage/renderBlock.js +9 -9
  145. package/mobile/lib/components/ContentPage/renderBlock.js.map +1 -1
  146. package/mobile/lib/components/ContentPage/renderBlockList.d.ts +14 -0
  147. package/mobile/lib/components/ContentPage/renderBlockList.js +15 -0
  148. package/mobile/lib/components/ContentPage/renderBlockList.js.map +1 -0
  149. package/mobile/lib/components/ContentPage/renderSlots.d.ts +12 -0
  150. package/mobile/lib/components/ContentPage/renderSlots.js +14 -0
  151. package/mobile/lib/components/ContentPage/renderSlots.js.map +1 -0
  152. package/mobile/lib/model/BlockDecorator.d.ts +4 -3
  153. package/mobile/lib/model/BlockDecorator.js +0 -1
  154. package/mobile/lib/model/BlockDecorator.js.map +1 -1
  155. package/mobile/lib/model/BlocksRegistry.d.ts +1 -1
  156. package/mobile/lib/model/ContentPageDef.d.ts +1 -4
  157. package/mobile/lib/model/JSXBlock.d.ts +3 -1
  158. package/mobile/lib/model/getParentBlockDef.js +5 -2
  159. package/mobile/lib/model/getParentBlockDef.js.map +1 -1
  160. package/mobile/src/components/Blocks.ts +2 -1
  161. package/mobile/src/components/ContentPage/ContentPage.page.json +7 -10
  162. package/mobile/src/components/ContentPage/ContentPage.tsx +24 -28
  163. package/mobile/src/components/ContentPage/mapSlot.ts +17 -0
  164. package/mobile/src/components/ContentPage/normalizeBlock.ts +26 -4
  165. package/mobile/src/components/ContentPage/normalizePage.ts +3 -20
  166. package/mobile/src/components/ContentPage/renderBlock.tsx +16 -18
  167. package/mobile/src/components/ContentPage/renderBlockList.tsx +39 -0
  168. package/mobile/src/components/ContentPage/renderSlots.tsx +33 -0
  169. package/mobile/src/model/BlockDecorator.ts +4 -4
  170. package/mobile/src/model/BlocksRegistry.ts +1 -1
  171. package/mobile/src/model/ContentPageDef.ts +1 -5
  172. package/mobile/src/model/JSXBlock.ts +3 -1
  173. package/mobile/src/model/getParentBlockDef.ts +6 -2
  174. package/package.json +1 -1
  175. package/src/components/Accordion/Accordion.fixture.mobile.tsx +16 -4
  176. package/src/components/Blocks.mobile.ts +2 -1
  177. package/src/components/Blocks.ts +2 -1
  178. package/src/components/ContentPage/ContentPage.page.json +7 -10
  179. package/src/components/ContentPage/ContentPage.tsx +24 -28
  180. package/src/components/ContentPage/mapSlot.ts +17 -0
  181. package/src/components/ContentPage/normalizeBlock.mobile.ts +26 -4
  182. package/src/components/ContentPage/normalizeBlock.ts +17 -4
  183. package/src/components/ContentPage/normalizePage.ts +3 -20
  184. package/src/components/ContentPage/renderBlock.tsx +16 -18
  185. package/src/components/ContentPage/renderBlockList.tsx +39 -0
  186. package/src/components/ContentPage/renderSlots.tsx +33 -0
  187. package/src/model/BlockDecorator.ts +4 -4
  188. package/src/model/BlocksRegistry.ts +1 -1
  189. package/src/model/ContentPageDef.ts +1 -5
  190. package/src/model/JSXBlock.ts +3 -1
  191. package/src/model/getParentBlockDef.ts +6 -2
  192. package/bundle/components/ContentPage/filterBlocks.d.ts +0 -12
  193. package/bundle/components/ContentPage/filterBlocks.mobile.d.ts +0 -12
  194. package/dist/components/ContentPage/filterBlocks.d.ts +0 -12
  195. package/dist/components/ContentPage/filterBlocks.js +0 -6
  196. package/dist/components/ContentPage/filterBlocks.js.map +0 -1
  197. package/dist/components/ContentPage/filterBlocks.mobile.d.ts +0 -12
  198. package/dist/components/ContentPage/filterBlocks.mobile.js +0 -8
  199. package/dist/components/ContentPage/filterBlocks.mobile.js.map +0 -1
  200. package/lib/components/ContentPage/filterBlocks.d.ts +0 -12
  201. package/lib/components/ContentPage/filterBlocks.js +0 -3
  202. package/lib/components/ContentPage/filterBlocks.js.map +0 -1
  203. package/lib/components/ContentPage/filterBlocks.mobile.d.ts +0 -12
  204. package/lib/components/ContentPage/filterBlocks.mobile.js +0 -5
  205. package/lib/components/ContentPage/filterBlocks.mobile.js.map +0 -1
  206. package/mobile/bundle/components/ContentPage/filterBlocks.d.ts +0 -3
  207. package/mobile/dist/components/ContentPage/filterBlocks.d.ts +0 -3
  208. package/mobile/dist/components/ContentPage/filterBlocks.js +0 -8
  209. package/mobile/dist/components/ContentPage/filterBlocks.js.map +0 -1
  210. package/mobile/lib/components/ContentPage/filterBlocks.d.ts +0 -3
  211. package/mobile/lib/components/ContentPage/filterBlocks.js +0 -5
  212. package/mobile/lib/components/ContentPage/filterBlocks.js.map +0 -1
  213. package/mobile/src/components/ContentPage/filterBlocks.ts +0 -11
  214. package/src/components/ContentPage/filterBlocks.mobile.ts +0 -11
  215. package/src/components/ContentPage/filterBlocks.ts +0 -6
@@ -0,0 +1,21 @@
1
+ export const description = 'v0.6.19';
2
+
3
+ export default (unitPath, content) => {
4
+ if (!content?.slots) {
5
+ return content;
6
+ }
7
+
8
+ adjustRootSlots(content.slots);
9
+
10
+ return { ...content };
11
+ };
12
+
13
+ function adjustRootSlots(slots) {
14
+ Object.keys(slots).forEach((slotKey) => {
15
+ if (Array.isArray(slots[slotKey])) {
16
+ return;
17
+ }
18
+ const slotBlocks = slots[slotKey].blocks;
19
+ slots[slotKey] = slotBlocks;
20
+ });
21
+ }
@@ -2650,8 +2650,11 @@
2650
2650
  OtherProducts.childrenTypes = ['OtherProductsItem'];
2651
2651
 
2652
2652
  function getParentBlockDef(ancestors, type) {
2653
- const [, ...blocks] = ancestors || [];
2654
- return blocks.reverse().find((_) => !type || type === _?.type) || {};
2653
+ const [block] = (ancestors || [])
2654
+ .map((item) => item)
2655
+ .reverse()
2656
+ .find(([_]) => _ && 'type' in _ && (!type || type === _.type)) || [];
2657
+ return block || {};
2655
2658
  }
2656
2659
 
2657
2660
  function getParentBlockContent(ancestors, defaultContent) {
@@ -3546,19 +3549,30 @@
3546
3549
  });
3547
3550
 
3548
3551
  const DEFAULT_SLOT_NAME = null;
3549
- const DEFAULT_ANCESTORS = [DEFAULT_SLOT_NAME];
3550
3552
 
3551
- const defaultChildRenderer = (_) => _;
3552
- function renderBlock(block, options, ancestors = DEFAULT_ANCESTORS) {
3553
- const { key, page, blockDecorator, blocksRegistry, context } = options;
3554
- const { type, blocks: childBlocks } = block;
3553
+ function renderSlots({ slots = {}, parent, options, ancestors = [], }) {
3554
+ return Object.entries(slots).reduce((res, [slotName, slotBlocks]) => ({
3555
+ ...res,
3556
+ [slotName]: renderBlocksList({
3557
+ blocks: slotBlocks,
3558
+ parent,
3559
+ slotName,
3560
+ options,
3561
+ ancestors,
3562
+ }),
3563
+ }), {});
3564
+ }
3565
+
3566
+ function renderBlock({ block = {}, options, ancestors = [] }) {
3567
+ const { key, page, blockDecorator, blocksRegistry = {}, context } = options;
3568
+ const { type, slots, blocks: childBlocks } = block;
3555
3569
  if (!(type && type in blocksRegistry)) {
3556
3570
  console.warn(`No block with "${type}" is registered`);
3557
3571
  }
3558
3572
  const BlockComponent = type && blocksRegistry[type];
3559
- const { renderChild = defaultChildRenderer } = BlockComponent || {};
3560
- const renderChildBlock = (_, j) => renderChild(renderBlock(_, { ...options, key: `${options.key}-${j}` }, [...ancestors, block]), j);
3561
- const children = childBlocks?.length ? childBlocks.map(renderChildBlock) : null;
3573
+ const subBlockRenderProps = { parent: block, options, ancestors };
3574
+ const children = renderBlocksList({ ...subBlockRenderProps, blocks: childBlocks });
3575
+ const blockSlots = slots ? renderSlots({ ...subBlockRenderProps, slots }) : {};
3562
3576
  return blockDecorator({
3563
3577
  blockClassName: `scroll-mt-12 ${style2className(block.style)}`,
3564
3578
  block,
@@ -3566,32 +3580,45 @@
3566
3580
  // Adjusted by decorator block and blockClassName
3567
3581
  render: ({ block: adjustedBlock, blockClassName: adjustedBlockClassName }) => {
3568
3582
  const { version, anchor, labels, content } = adjustedBlock;
3569
- return BlockComponent ? (jsx(BlockComponent, { className: adjustedBlockClassName, context: context, page: page, ancestors: ancestors, version: version, anchor: anchor, labels: labels, ...content, children: children }, key)) : null;
3583
+ return BlockComponent ? (jsx(BlockComponent, { className: adjustedBlockClassName, context: context, page: page, ancestors: ancestors, version: version, anchor: anchor, labels: labels, slots: blockSlots, ...content, children: children }, key)) : null;
3570
3584
  },
3571
3585
  }, key);
3572
3586
  }
3573
3587
 
3588
+ const defaultChildRenderer = (_) => _;
3589
+ function renderBlocksList({ blocks = [], parent, slotName = DEFAULT_SLOT_NAME, options, ancestors = [], }) {
3590
+ const { blocksRegistry = {} } = options;
3591
+ const { type } = parent;
3592
+ const BlockComponent = type && blocksRegistry[type];
3593
+ const { renderChild = defaultChildRenderer } = BlockComponent || {};
3594
+ return blocks.map((_, j) => renderChild(renderBlock({
3595
+ block: _,
3596
+ options: { ...options, key: `${options.key ? options.key : _.type}-${j}` },
3597
+ ancestors: [...ancestors, [parent, slotName]],
3598
+ }), j));
3599
+ }
3600
+
3574
3601
  const defaultBlockDecorator = ({ blockClassName, block, render }) => render({ blockClassName, block });
3575
3602
  const ContentPage = JSX((props) => {
3576
- const { className = '', context, data = {} } = props;
3603
+ const { className = '', blocksRegistry, blockDecorator, context, data = {} } = props;
3577
3604
  const { style: pageStyle, blocks, slots, likeControl, colorPalette = 'pc' } = data;
3578
- const blocksListRenderer = renderBlocksList(props);
3579
- return (jsxs("section", { className: `relative ${style2className(pageStyle)} ${className}`, "data-theme": colorPalette, children: [slots?.header?.blocks?.length ? (jsx("div", { className: `${style2className(slots.header.style)}`, children: blocksListRenderer(slots.header.blocks, ['header']) })) : null, blocks?.length ? (jsx("div", { className: "container grid grid-cols-12 gap-1", children: blocksListRenderer(blocks) })) : null, likeControl ? renderLikeControl(context) : null] }));
3580
- });
3581
- function renderBlocksList({ blocksRegistry, data, blockDecorator, context }) {
3582
- return (blocks, ancestors) => blocks.map((block, i) => renderBlock(block, {
3583
- key: `${block.type || '#'}-${i}`,
3605
+ const options = {
3606
+ key: '',
3584
3607
  blocksRegistry,
3585
- page: data || {},
3608
+ page: data,
3586
3609
  blockDecorator: blockDecorator || defaultBlockDecorator,
3587
3610
  context,
3588
- }, ancestors));
3589
- }
3611
+ };
3612
+ const pageSlots = renderSlots({ slots, parent: data, options });
3613
+ return (jsxs("section", { className: `relative ${style2className(pageStyle)} ${className}`, "data-theme": colorPalette, children: [pageSlots?.header ? (jsx("div", { className: "mb-5 shadow-[0_8px_32px_0px_#00000014]", children: pageSlots.header })) : null, blocks?.length ? (jsx("div", { className: "container grid grid-cols-12 gap-1", children: renderBlocksList({ blocks, parent: data, options }) })) : null, likeControl ? renderLikeControl(context) : null] }));
3614
+ });
3615
+ ContentPage.childrenTypes = [];
3616
+ ContentPage.slots = () => ['header'];
3590
3617
  function renderLikeControl(context) {
3591
3618
  return (jsx("div", { className: "flex items-end absolute bottom-0 right-0 h-full pointer-events-none", children: jsx(LikeControl, { className: "rounded-tl-lg sticky bottom-0 pointer-events-auto", context: context }, "LikeControl") }));
3592
3619
  }
3593
3620
 
3594
- const packageVersion = "0.6.19";
3621
+ const packageVersion = "0.6.20";
3595
3622
 
3596
3623
  exports.Blocks = Blocks;
3597
3624
  exports.ContentPage = ContentPage;