@redneckz/wildless-cms-uni-blocks 0.5.13 → 0.5.14

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 (118) hide show
  1. package/bundle/blocks.schema.json +1 -1
  2. package/bundle/bundle.umd.js +14 -18
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/bundle/components/Blocks.d.ts +2 -1
  5. package/bundle/components/OtherProducts/OtherProducts.d.ts +2 -1
  6. package/bundle/components/OtherProducts/OtherProductsContent.d.ts +1 -21
  7. package/bundle/components/OtherProductsItem/OtherProductsItem.d.ts +6 -0
  8. package/bundle/components/OtherProductsItem/OtherProductsItemContent.d.ts +14 -0
  9. package/dist/components/Blocks.d.ts +2 -1
  10. package/dist/components/Blocks.js +2 -0
  11. package/dist/components/Blocks.js.map +1 -1
  12. package/dist/components/ContentPage/renderBlock.js +7 -6
  13. package/dist/components/ContentPage/renderBlock.js.map +1 -1
  14. package/dist/components/OtherProducts/OtherProducts.d.ts +2 -1
  15. package/dist/components/OtherProducts/OtherProducts.js +2 -4
  16. package/dist/components/OtherProducts/OtherProducts.js.map +1 -1
  17. package/dist/components/OtherProducts/OtherProductsContent.d.ts +1 -21
  18. package/dist/components/OtherProductsItem/OtherProductsItem.d.ts +6 -0
  19. package/dist/components/OtherProductsItem/OtherProductsItem.js +11 -0
  20. package/dist/components/OtherProductsItem/OtherProductsItem.js.map +1 -0
  21. package/dist/components/OtherProductsItem/OtherProductsItemContent.d.ts +14 -0
  22. package/dist/components/OtherProductsItem/OtherProductsItemContent.js +2 -0
  23. package/dist/components/OtherProductsItem/OtherProductsItemContent.js.map +1 -0
  24. package/dist/ui-kit/Foldable/FoldableSection.js +1 -1
  25. package/dist/ui-kit/Foldable/FoldableSection.js.map +1 -1
  26. package/lib/components/Blocks.d.ts +2 -1
  27. package/lib/components/Blocks.js +2 -0
  28. package/lib/components/Blocks.js.map +1 -1
  29. package/lib/components/ContentPage/renderBlock.js +7 -6
  30. package/lib/components/ContentPage/renderBlock.js.map +1 -1
  31. package/lib/components/OtherProducts/OtherProducts.d.ts +2 -1
  32. package/lib/components/OtherProducts/OtherProducts.fixture.d.ts +1 -0
  33. package/lib/components/OtherProducts/OtherProducts.js +2 -4
  34. package/lib/components/OtherProducts/OtherProducts.js.map +1 -1
  35. package/lib/components/OtherProducts/OtherProductsContent.d.ts +1 -21
  36. package/lib/components/OtherProductsItem/OtherProductsItem.d.ts +6 -0
  37. package/lib/components/OtherProductsItem/OtherProductsItem.fixture.d.ts +5 -0
  38. package/lib/components/OtherProductsItem/OtherProductsItem.js +9 -0
  39. package/lib/components/OtherProductsItem/OtherProductsItem.js.map +1 -0
  40. package/lib/components/OtherProductsItem/OtherProductsItemContent.d.ts +14 -0
  41. package/lib/components/OtherProductsItem/OtherProductsItemContent.js +2 -0
  42. package/lib/components/OtherProductsItem/OtherProductsItemContent.js.map +1 -0
  43. package/lib/ui-kit/Foldable/FoldableSection.js +1 -1
  44. package/lib/ui-kit/Foldable/FoldableSection.js.map +1 -1
  45. package/mobile/bundle/bundle.umd.js +8 -7
  46. package/mobile/bundle/bundle.umd.min.js +1 -1
  47. package/mobile/bundle/components/OtherProducts/OtherProducts.d.ts +2 -1
  48. package/mobile/bundle/components/OtherProducts/OtherProductsContent.d.ts +1 -21
  49. package/mobile/bundle/components/OtherProductsItem/OtherProductsItem.d.ts +6 -0
  50. package/mobile/bundle/components/OtherProductsItem/OtherProductsItemContent.d.ts +14 -0
  51. package/mobile/dist/components/ContentPage/renderBlock.js +7 -6
  52. package/mobile/dist/components/ContentPage/renderBlock.js.map +1 -1
  53. package/mobile/dist/components/OtherProducts/OtherProducts.d.ts +2 -1
  54. package/mobile/dist/components/OtherProducts/OtherProducts.js +2 -4
  55. package/mobile/dist/components/OtherProducts/OtherProducts.js.map +1 -1
  56. package/mobile/dist/components/OtherProducts/OtherProductsContent.d.ts +1 -21
  57. package/mobile/dist/components/OtherProductsItem/OtherProductsItem.d.ts +6 -0
  58. package/mobile/dist/components/OtherProductsItem/OtherProductsItem.js +11 -0
  59. package/mobile/dist/components/OtherProductsItem/OtherProductsItem.js.map +1 -0
  60. package/mobile/dist/components/OtherProductsItem/OtherProductsItemContent.d.ts +14 -0
  61. package/mobile/dist/components/OtherProductsItem/OtherProductsItemContent.js +2 -0
  62. package/mobile/dist/components/OtherProductsItem/OtherProductsItemContent.js.map +1 -0
  63. package/mobile/dist/ui-kit/Foldable/FoldableSection.js +1 -1
  64. package/mobile/dist/ui-kit/Foldable/FoldableSection.js.map +1 -1
  65. package/mobile/lib/components/ContentPage/renderBlock.js +7 -6
  66. package/mobile/lib/components/ContentPage/renderBlock.js.map +1 -1
  67. package/mobile/lib/components/OtherProducts/OtherProducts.d.ts +2 -1
  68. package/mobile/lib/components/OtherProducts/OtherProducts.js +2 -4
  69. package/mobile/lib/components/OtherProducts/OtherProducts.js.map +1 -1
  70. package/mobile/lib/components/OtherProducts/OtherProductsContent.d.ts +1 -21
  71. package/mobile/lib/components/OtherProductsItem/OtherProductsItem.d.ts +6 -0
  72. package/mobile/lib/components/OtherProductsItem/OtherProductsItem.js +9 -0
  73. package/mobile/lib/components/OtherProductsItem/OtherProductsItem.js.map +1 -0
  74. package/mobile/lib/components/OtherProductsItem/OtherProductsItemContent.d.ts +14 -0
  75. package/mobile/lib/components/OtherProductsItem/OtherProductsItemContent.js +2 -0
  76. package/mobile/lib/components/OtherProductsItem/OtherProductsItemContent.js.map +1 -0
  77. package/mobile/lib/ui-kit/Foldable/FoldableSection.js +1 -1
  78. package/mobile/lib/ui-kit/Foldable/FoldableSection.js.map +1 -1
  79. package/mobile/src/components/ContentPage/renderBlock.tsx +14 -9
  80. package/mobile/src/components/OtherProducts/OtherProducts.example.json +1 -54
  81. package/mobile/src/components/OtherProducts/OtherProducts.tsx +13 -24
  82. package/mobile/src/components/OtherProducts/OtherProducts.ui.json +1 -76
  83. package/mobile/src/components/OtherProducts/OtherProductsContent.ts +1 -22
  84. package/mobile/src/components/OtherProductsItem/OtherProductsItem.example.json +3 -0
  85. package/mobile/src/components/OtherProductsItem/OtherProductsItem.tsx +39 -0
  86. package/mobile/src/components/OtherProductsItem/OtherProductsItem.ui.json +1 -0
  87. package/mobile/src/components/OtherProductsItem/OtherProductsItemContent.ts +17 -0
  88. package/mobile/src/ui-kit/Foldable/FoldableSection.tsx +1 -1
  89. package/package.json +1 -1
  90. package/src/components/Blocks.ts +2 -0
  91. package/src/components/ContentPage/renderBlock.tsx +14 -9
  92. package/src/components/OtherProducts/OtherProducts.example.json +1 -54
  93. package/src/components/OtherProducts/OtherProducts.fixture.tsx +77 -126
  94. package/src/components/OtherProducts/OtherProducts.tsx +13 -24
  95. package/src/components/OtherProducts/OtherProducts.ui.json +1 -76
  96. package/src/components/OtherProducts/OtherProductsContent.ts +1 -22
  97. package/src/components/OtherProductsItem/OtherProductsItem.example.json +3 -0
  98. package/src/components/OtherProductsItem/OtherProductsItem.fixture.tsx +5 -0
  99. package/src/components/OtherProductsItem/OtherProductsItem.tsx +39 -0
  100. package/src/components/OtherProductsItem/OtherProductsItem.ui.json +1 -0
  101. package/src/components/OtherProductsItem/OtherProductsItemContent.ts +17 -0
  102. package/src/ui-kit/Foldable/FoldableSection.tsx +1 -1
  103. package/bundle/components/OtherProducts/OtherProductsItem.d.ts +0 -6
  104. package/dist/components/OtherProducts/OtherProductsItem.d.ts +0 -6
  105. package/dist/components/OtherProducts/OtherProductsItem.js +0 -17
  106. package/dist/components/OtherProducts/OtherProductsItem.js.map +0 -1
  107. package/lib/components/OtherProducts/OtherProductsItem.d.ts +0 -6
  108. package/lib/components/OtherProducts/OtherProductsItem.js +0 -15
  109. package/lib/components/OtherProducts/OtherProductsItem.js.map +0 -1
  110. package/mobile/bundle/components/OtherProducts/OtherProductsItem.d.ts +0 -6
  111. package/mobile/dist/components/OtherProducts/OtherProductsItem.d.ts +0 -6
  112. package/mobile/dist/components/OtherProducts/OtherProductsItem.js +0 -17
  113. package/mobile/dist/components/OtherProducts/OtherProductsItem.js.map +0 -1
  114. package/mobile/lib/components/OtherProducts/OtherProductsItem.d.ts +0 -6
  115. package/mobile/lib/components/OtherProducts/OtherProductsItem.js +0 -15
  116. package/mobile/lib/components/OtherProducts/OtherProductsItem.js.map +0 -1
  117. package/mobile/src/components/OtherProducts/OtherProductsItem.tsx +0 -52
  118. package/src/components/OtherProducts/OtherProductsItem.tsx +0 -52
@@ -1,25 +1,5 @@
1
- import type { ColorPalette } from '../../model/ContentPageDef';
2
1
  import type { TitleProps } from '../../model/HeadlineType';
3
- import type { BlockDef } from '../../ui-kit/BlocksList/BlocksListProps';
4
- /**
5
- * @title Элемент списка
6
- */
7
- export interface BlockItemCommonProps {
8
- /**
9
- * @title Название
10
- * @default Список
11
- */
12
- label?: string;
13
- /** @title Отображать в раскрытом виде */
14
- isUnfolded?: boolean;
15
- /** @title Блоки */
16
- blocks?: BlockDef[];
17
- }
18
2
  /**
19
3
  * @title Другие продукты
20
4
  */
21
- export declare type OtherProductsContent = TitleProps & {
22
- /** @title Список */
23
- blockItems?: BlockItemCommonProps[];
24
- colorPalette?: ColorPalette;
25
- };
5
+ export declare type OtherProductsContent = TitleProps;
@@ -0,0 +1,6 @@
1
+ import { JSXBlock } from '../../model/BlocksRegistry';
2
+ import type { UniBlockProps } from '../../model/ContentPageDef';
3
+ import type { OtherProductsItemContent } from './OtherProductsItemContent';
4
+ export interface OtherProductsItemProps extends OtherProductsItemContent, UniBlockProps {
5
+ }
6
+ export declare const OtherProductsItem: JSXBlock<OtherProductsItemProps>;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "@redneckz/uni-jsx/jsx-runtime";
2
+ import { JSX } from '@redneckz/uni-jsx';
3
+ import { DefaultFoldButton } from '../../ui-kit/Foldable/DefaultFoldButton.js';
4
+ import { Foldable } from '../../ui-kit/Foldable/Foldable.js';
5
+ import { FoldableSection } from '../../ui-kit/Foldable/FoldableSection.js';
6
+ const icons = ['ArrowDownIcon', 'ArrowUpIcon'];
7
+ export const OtherProductsItem = JSX(({ className, label = '', colorPalette, isUnfolded: unfoldedByDefault, children }) => (_jsx("div", { className: `border-0 border-b border-solid border-main-divider ${className}`, children: _jsx(Foldable, { unfoldedByDefault: unfoldedByDefault, renderFoldableSection: ({ isUnfolded }) => (_jsx("div", { className: "box-border", children: _jsx(FoldableSection, { className: "grid grid-cols-12 gap-1 border-box", isUnfolded: isUnfolded, children: children }) })), renderFoldButton: ({ isUnfolded, onToggle }) => (_jsx(DefaultFoldButton, { label: label, icon: icons[Number(isUnfolded)], dataTheme: colorPalette, onClick: onToggle })) }) })));
8
+ OtherProductsItem.childrenTypes = []; // All types of blocks are suitable
9
+ //# sourceMappingURL=OtherProductsItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OtherProductsItem.js","sourceRoot":"","sources":["../../../src/components/OtherProductsItem/OtherProductsItem.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAMxE,MAAM,KAAK,GAAe,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;AAE3D,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAClC,CAAC,EAAE,SAAS,EAAE,KAAK,GAAG,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CACpF,cAAK,SAAS,EAAE,sDAAsD,SAAS,EAAE,YAC/E,KAAC,QAAQ,IACP,iBAAiB,EAAE,iBAAiB,EACpC,qBAAqB,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CACzC,cAAK,SAAS,EAAC,YAAY,YACzB,KAAC,eAAe,IAAC,SAAS,EAAC,oCAAoC,EAAC,UAAU,EAAE,UAAU,YACnF,QAAQ,GACO,GACd,CACP,EACD,gBAAgB,EAAE,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAC9C,KAAC,iBAAiB,IAChB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,EAC/B,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,QAAQ,GACjB,CACH,GACD,GACE,CACP,CACkC,CAAC;AAEtC,iBAAiB,CAAC,aAAa,GAAG,EAAE,CAAC,CAAC,mCAAmC"}
@@ -0,0 +1,14 @@
1
+ import type { ColorPalette } from '../../model/ContentPageDef';
2
+ /**
3
+ * @title Элемент списка
4
+ */
5
+ export interface OtherProductsItemContent {
6
+ /**
7
+ * @title Название
8
+ * @default Список
9
+ */
10
+ label?: string;
11
+ /** @title Отображать в раскрытом виде */
12
+ isUnfolded?: boolean;
13
+ colorPalette?: ColorPalette;
14
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=OtherProductsItemContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OtherProductsItemContent.js","sourceRoot":"","sources":["../../../src/components/OtherProductsItem/OtherProductsItemContent.ts"],"names":[],"mappings":""}
@@ -9,7 +9,7 @@ export const FoldableSection = JSX(({ className = '', isUnfolded, children }) =>
9
9
  ? `${containerRef.current.scrollHeight}px`
10
10
  : '';
11
11
  }
12
- }, [isUnfolded]);
12
+ }, [isUnfolded, children?.length]);
13
13
  return (_jsx("div", { ref: containerRef, className: `transition-max-h duration-300 overflow-hidden max-h-0 ${className}`, children: children }));
14
14
  });
15
15
  //# sourceMappingURL=FoldableSection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FoldableSection.js","sourceRoot":"","sources":["../../../src/ui-kit/Foldable/FoldableSection.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAOhE,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAChC,CAAC,EAAE,SAAS,GAAG,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC3C,MAAM,YAAY,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IAEzD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,YAAY,CAAC,OAAO,EAAE;YACxB,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,UAAU;gBAC/C,CAAC,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,YAAY,IAAI;gBAC1C,CAAC,CAAC,EAAE,CAAC;SACR;IACH,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,CACL,cACE,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,yDAAyD,SAAS,EAAE,YAE9E,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CACF,CAAC"}
1
+ {"version":3,"file":"FoldableSection.js","sourceRoot":"","sources":["../../../src/ui-kit/Foldable/FoldableSection.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAOhE,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAChC,CAAC,EAAE,SAAS,GAAG,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC3C,MAAM,YAAY,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IAEzD,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,YAAY,CAAC,OAAO,EAAE;YACxB,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,UAAU;gBAC/C,CAAC,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,YAAY,IAAI;gBAC1C,CAAC,CAAC,EAAE,CAAC;SACR;IACH,CAAC,EAAE,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAEnC,OAAO,CACL,cACE,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,yDAAyD,SAAS,EAAE,YAE9E,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CACF,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { BlockAncestors, BlockDecorator, DEFAULT_ANCESTORS } from '../../model/BlockDecorator';
2
2
  import type { BlocksRegistry } from '../../model/BlocksRegistry';
3
3
  import type { BlockDef, ContentPageDef } from '../../model/ContentPageDef';
4
+ import type { VNode } from '../../model/VNode';
4
5
  import { style2className } from '../../utils/style2className';
5
6
  import type { ContentPageContext } from './ContentPageContext';
6
7
 
@@ -12,13 +13,15 @@ interface RenderBlockOptions {
12
13
  context: ContentPageContext;
13
14
  }
14
15
 
16
+ const defaultChildRenderer = (_: VNode) => _;
17
+
15
18
  export function renderBlock(
16
19
  block: BlockDef,
17
20
  options: RenderBlockOptions,
18
21
  ancestors: BlockAncestors = DEFAULT_ANCESTORS, // Recursion context
19
22
  ) {
20
23
  const { key, page, blockDecorator, blocksRegistry, context } = options;
21
- const { type } = block;
24
+ const { type, blocks: childBlocks } = block;
22
25
 
23
26
  if (!(type && type in blocksRegistry)) {
24
27
  console.warn(`No block with "${type}" is registered`);
@@ -26,6 +29,14 @@ export function renderBlock(
26
29
 
27
30
  const BlockComponent = type && blocksRegistry[type];
28
31
 
32
+ const { renderChild = defaultChildRenderer } = BlockComponent || {};
33
+ const renderChildBlock = (_: BlockDef, j: number) =>
34
+ renderChild(
35
+ renderBlock(_, { ...options, key: `${options.key}-${j}` }, [...ancestors, block]),
36
+ j,
37
+ );
38
+ const children = childBlocks?.length ? childBlocks.map(renderChildBlock) : null;
39
+
29
40
  return blockDecorator(
30
41
  {
31
42
  blockClassName: `scroll-mt-12 ${style2className(block.style)}`, // TODO scroll-mt-12 ? here?
@@ -33,21 +44,15 @@ export function renderBlock(
33
44
  ancestors,
34
45
  // Adjusted by decorator block and blockClassName
35
46
  render: ({ block: adjustedBlock, blockClassName: adjustedBlockClassName }) => {
36
- const { version, content, anchor, labels, blocks: childBlocks } = adjustedBlock;
37
-
38
- const children = childBlocks
39
- ? childBlocks.map((_, j) =>
40
- renderBlock(_, { ...options, key: `${options.key}-${j}` }, [...ancestors, block]),
41
- )
42
- : null;
47
+ const { version, anchor, labels, content } = adjustedBlock;
43
48
 
44
49
  return BlockComponent ? (
45
50
  <BlockComponent
46
51
  key={key}
47
52
  className={adjustedBlockClassName}
48
- version={version}
49
53
  context={context}
50
54
  page={page}
55
+ version={version}
51
56
  anchor={anchor}
52
57
  labels={labels}
53
58
  {...content}
@@ -1,56 +1,3 @@
1
1
  {
2
- "title": "Другие продукты",
3
- "blockItems": [
4
- {
5
- "label": "Другие продукты 1",
6
- "blocks": [
7
- {
8
- "blockListType": "TextBlock",
9
- "title": "Текстовый блок",
10
- "description": "Описание текстового блока",
11
- "style": ["col-span-12"]
12
- },
13
- {
14
- "blockListType": "TextBlock",
15
- "title": "Текстовый блок №2",
16
- "description": "Описание текстового блока №2",
17
- "style": ["col-span-12"]
18
- }
19
- ]
20
- },
21
- {
22
- "label": "Другие продукты 2",
23
- "blocks": [
24
- {
25
- "blockListType": "TextBlock",
26
- "title": "Текстовый блок",
27
- "description": "Описание текстового блока",
28
- "style": ["col-span-12"]
29
- },
30
- {
31
- "blockListType": "TextBlock",
32
- "title": "Текстовый блок №2",
33
- "description": "Описание текстового блока №2",
34
- "style": ["col-span-12"]
35
- }
36
- ]
37
- },
38
- {
39
- "label": "Другие продукты 3",
40
- "blocks": [
41
- {
42
- "blockListType": "TextBlock",
43
- "title": "Текстовый блок",
44
- "description": "Описание текстового блока",
45
- "style": ["col-span-12"]
46
- },
47
- {
48
- "blockListType": "TextBlock",
49
- "title": "Текстовый блок №2",
50
- "description": "Описание текстового блока №2",
51
- "style": ["col-span-12"]
52
- }
53
- ]
54
- }
55
- ]
2
+ "title": "Другие продукты"
56
3
  }
@@ -1,32 +1,21 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
+ import type { JSXBlock } from '../../model/BlocksRegistry';
2
3
  import type { UniBlockProps } from '../../model/ContentPageDef';
3
4
  import { BlockWrapper } from '../../ui-kit/BlockWrapper';
4
5
  import type { OtherProductsContent } from './OtherProductsContent';
5
- import { OtherProductsItem } from './OtherProductsItem';
6
6
 
7
7
  export interface OtherProductsProps extends OtherProductsContent, UniBlockProps {}
8
8
 
9
9
  export const OtherProducts = JSX<OtherProductsProps>(
10
- ({ blockItems, colorPalette, context, className = '', ...rest }) => {
11
- return (
12
- <BlockWrapper
13
- context={context}
14
- className={`font-sans text-primary-text ${className}`}
15
- {...rest}
16
- >
17
- {blockItems?.length ? (
18
- <div className="box-border1">
19
- {blockItems.map((item, i) => (
20
- <OtherProductsItem
21
- key={`BlockItem${i}`}
22
- {...item}
23
- dataTheme={colorPalette}
24
- context={context}
25
- />
26
- ))}
27
- </div>
28
- ) : null}
29
- </BlockWrapper>
30
- );
31
- },
32
- );
10
+ ({ context, className = '', children, ...rest }) => (
11
+ <BlockWrapper
12
+ context={context}
13
+ className={`font-sans text-primary-text ${className}`}
14
+ {...rest}
15
+ >
16
+ {children ? <div className="box-border1">{children}</div> : null}
17
+ </BlockWrapper>
18
+ ),
19
+ ) as JSXBlock<OtherProductsProps>;
20
+
21
+ OtherProducts.childrenTypes = ['OtherProductsItem'];
@@ -1,76 +1 @@
1
- {
2
- "content": {
3
- "blockItems": {
4
- "items": {
5
- "blocks": {
6
- "items": {
7
- "blockListType": {
8
- "ui:widget": "hidden"
9
- },
10
- "image": {
11
- "ui:field": "picture"
12
- },
13
- "benefitList": {
14
- "items": {
15
- "description": {
16
- "benefitType": {
17
- "ui:widget": "hidden"
18
- }
19
- },
20
- "icon": {
21
- "ui:field": "icon"
22
- }
23
- }
24
- },
25
- "style": {
26
- "ui:field": "style"
27
- },
28
- "benefits": {
29
- "items": {
30
- "icon": {
31
- "ui:field": "icon"
32
- }
33
- }
34
- },
35
- "buttons": {
36
- "items": {
37
- "icon": {
38
- "ui:field": "icon"
39
- },
40
- "iconRight": {
41
- "ui:field": "icon"
42
- }
43
- }
44
- },
45
- "icon": {
46
- "ui:field": "icon"
47
- },
48
- "backwardButton": {
49
- "icon": {
50
- "ui:field": "icon"
51
- },
52
- "iconRight": {
53
- "ui:field": "icon"
54
- }
55
- },
56
- "cards": {
57
- "items": {
58
- "image": {
59
- "ui:field": "picture"
60
- },
61
- "button": {
62
- "icon": {
63
- "ui:field": "icon"
64
- },
65
- "iconRight": {
66
- "ui:field": "icon"
67
- }
68
- }
69
- }
70
- }
71
- }
72
- }
73
- }
74
- }
75
- }
76
- }
1
+ {}
@@ -1,27 +1,6 @@
1
- import type { ColorPalette } from '../../model/ContentPageDef';
2
1
  import type { TitleProps } from '../../model/HeadlineType';
3
- import type { BlockDef } from '../../ui-kit/BlocksList/BlocksListProps';
4
-
5
- /**
6
- * @title Элемент списка
7
- */
8
- export interface BlockItemCommonProps {
9
- /**
10
- * @title Название
11
- * @default Список
12
- */
13
- label?: string;
14
- /** @title Отображать в раскрытом виде */
15
- isUnfolded?: boolean;
16
- /** @title Блоки */
17
- blocks?: BlockDef[];
18
- }
19
2
 
20
3
  /**
21
4
  * @title Другие продукты
22
5
  */
23
- export type OtherProductsContent = TitleProps & {
24
- /** @title Список */
25
- blockItems?: BlockItemCommonProps[];
26
- colorPalette?: ColorPalette;
27
- };
6
+ export type OtherProductsContent = TitleProps;
@@ -0,0 +1,3 @@
1
+ {
2
+ "label": "Другие продукты N"
3
+ }
@@ -0,0 +1,39 @@
1
+ import { JSX } from '@redneckz/uni-jsx';
2
+ import { JSXBlock } from '../../model/BlocksRegistry';
3
+ import type { UniBlockProps } from '../../model/ContentPageDef';
4
+ import { DefaultFoldButton } from '../../ui-kit/Foldable/DefaultFoldButton';
5
+ import { Foldable } from '../../ui-kit/Foldable/Foldable';
6
+ import { FoldableSection } from '../../ui-kit/Foldable/FoldableSection';
7
+ import type { IconName } from '../../ui-kit/Icon/IconProps';
8
+ import type { OtherProductsItemContent } from './OtherProductsItemContent';
9
+
10
+ export interface OtherProductsItemProps extends OtherProductsItemContent, UniBlockProps {}
11
+
12
+ const icons: IconName[] = ['ArrowDownIcon', 'ArrowUpIcon'];
13
+
14
+ export const OtherProductsItem = JSX<OtherProductsItemProps>(
15
+ ({ className, label = '', colorPalette, isUnfolded: unfoldedByDefault, children }) => (
16
+ <div className={`border-0 border-b border-solid border-main-divider ${className}`}>
17
+ <Foldable
18
+ unfoldedByDefault={unfoldedByDefault}
19
+ renderFoldableSection={({ isUnfolded }) => (
20
+ <div className="box-border">
21
+ <FoldableSection className="grid grid-cols-12 gap-1 border-box" isUnfolded={isUnfolded}>
22
+ {children}
23
+ </FoldableSection>
24
+ </div>
25
+ )}
26
+ renderFoldButton={({ isUnfolded, onToggle }) => (
27
+ <DefaultFoldButton
28
+ label={label}
29
+ icon={icons[Number(isUnfolded)]}
30
+ dataTheme={colorPalette}
31
+ onClick={onToggle}
32
+ />
33
+ )}
34
+ />
35
+ </div>
36
+ ),
37
+ ) as JSXBlock<OtherProductsItemProps>;
38
+
39
+ OtherProductsItem.childrenTypes = []; // All types of blocks are suitable
@@ -0,0 +1,17 @@
1
+ import type { ColorPalette } from '../../model/ContentPageDef';
2
+
3
+ /**
4
+ * @title Элемент списка
5
+ */
6
+ export interface OtherProductsItemContent {
7
+ /**
8
+ * @title Название
9
+ * @default Список
10
+ */
11
+ label?: string;
12
+
13
+ /** @title Отображать в раскрытом виде */
14
+ isUnfolded?: boolean;
15
+
16
+ colorPalette?: ColorPalette;
17
+ }
@@ -16,7 +16,7 @@ export const FoldableSection = JSX<FoldableSectionProps>(
16
16
  ? `${containerRef.current.scrollHeight}px`
17
17
  : '';
18
18
  }
19
- }, [isUnfolded]);
19
+ }, [isUnfolded, children?.length]);
20
20
 
21
21
  return (
22
22
  <div
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.5.13",
3
+ "version": "0.5.14",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -20,6 +20,7 @@ import { MiniGallery } from './MiniGallery/MiniGallery';
20
20
  import { MobileAppTile } from './MobileAppTile/MobileAppTile';
21
21
  import { OfficeServicesBlock } from './OfficeServicesBlock/OfficeServicesBlock';
22
22
  import { OtherProducts } from './OtherProducts/OtherProducts';
23
+ import { OtherProductsItem } from './OtherProductsItem/OtherProductsItem';
23
24
  import { PictureText } from './PictureText/PictureText';
24
25
  import { Placeholder } from './Placeholder/Placeholder';
25
26
  import { ProductBlock } from './ProductBlock/ProductBlock';
@@ -59,6 +60,7 @@ export const Blocks = {
59
60
  ProductTile,
60
61
  PromoTile,
61
62
  OtherProducts,
63
+ OtherProductsItem,
62
64
  Recommendation,
63
65
  StepsBlock,
64
66
  TariffsTable,
@@ -1,6 +1,7 @@
1
1
  import { BlockAncestors, BlockDecorator, DEFAULT_ANCESTORS } from '../../model/BlockDecorator';
2
2
  import type { BlocksRegistry } from '../../model/BlocksRegistry';
3
3
  import type { BlockDef, ContentPageDef } from '../../model/ContentPageDef';
4
+ import type { VNode } from '../../model/VNode';
4
5
  import { style2className } from '../../utils/style2className';
5
6
  import type { ContentPageContext } from './ContentPageContext';
6
7
 
@@ -12,13 +13,15 @@ interface RenderBlockOptions {
12
13
  context: ContentPageContext;
13
14
  }
14
15
 
16
+ const defaultChildRenderer = (_: VNode) => _;
17
+
15
18
  export function renderBlock(
16
19
  block: BlockDef,
17
20
  options: RenderBlockOptions,
18
21
  ancestors: BlockAncestors = DEFAULT_ANCESTORS, // Recursion context
19
22
  ) {
20
23
  const { key, page, blockDecorator, blocksRegistry, context } = options;
21
- const { type } = block;
24
+ const { type, blocks: childBlocks } = block;
22
25
 
23
26
  if (!(type && type in blocksRegistry)) {
24
27
  console.warn(`No block with "${type}" is registered`);
@@ -26,6 +29,14 @@ export function renderBlock(
26
29
 
27
30
  const BlockComponent = type && blocksRegistry[type];
28
31
 
32
+ const { renderChild = defaultChildRenderer } = BlockComponent || {};
33
+ const renderChildBlock = (_: BlockDef, j: number) =>
34
+ renderChild(
35
+ renderBlock(_, { ...options, key: `${options.key}-${j}` }, [...ancestors, block]),
36
+ j,
37
+ );
38
+ const children = childBlocks?.length ? childBlocks.map(renderChildBlock) : null;
39
+
29
40
  return blockDecorator(
30
41
  {
31
42
  blockClassName: `scroll-mt-12 ${style2className(block.style)}`, // TODO scroll-mt-12 ? here?
@@ -33,21 +44,15 @@ export function renderBlock(
33
44
  ancestors,
34
45
  // Adjusted by decorator block and blockClassName
35
46
  render: ({ block: adjustedBlock, blockClassName: adjustedBlockClassName }) => {
36
- const { version, content, anchor, labels, blocks: childBlocks } = adjustedBlock;
37
-
38
- const children = childBlocks
39
- ? childBlocks.map((_, j) =>
40
- renderBlock(_, { ...options, key: `${options.key}-${j}` }, [...ancestors, block]),
41
- )
42
- : null;
47
+ const { version, anchor, labels, content } = adjustedBlock;
43
48
 
44
49
  return BlockComponent ? (
45
50
  <BlockComponent
46
51
  key={key}
47
52
  className={adjustedBlockClassName}
48
- version={version}
49
53
  context={context}
50
54
  page={page}
55
+ version={version}
51
56
  anchor={anchor}
52
57
  labels={labels}
53
58
  {...content}
@@ -1,56 +1,3 @@
1
1
  {
2
- "title": "Другие продукты",
3
- "blockItems": [
4
- {
5
- "label": "Другие продукты 1",
6
- "blocks": [
7
- {
8
- "blockListType": "TextBlock",
9
- "title": "Текстовый блок",
10
- "description": "Описание текстового блока",
11
- "style": ["col-span-12"]
12
- },
13
- {
14
- "blockListType": "TextBlock",
15
- "title": "Текстовый блок №2",
16
- "description": "Описание текстового блока №2",
17
- "style": ["col-span-12"]
18
- }
19
- ]
20
- },
21
- {
22
- "label": "Другие продукты 2",
23
- "blocks": [
24
- {
25
- "blockListType": "TextBlock",
26
- "title": "Текстовый блок",
27
- "description": "Описание текстового блока",
28
- "style": ["col-span-12"]
29
- },
30
- {
31
- "blockListType": "TextBlock",
32
- "title": "Текстовый блок №2",
33
- "description": "Описание текстового блока №2",
34
- "style": ["col-span-12"]
35
- }
36
- ]
37
- },
38
- {
39
- "label": "Другие продукты 3",
40
- "blocks": [
41
- {
42
- "blockListType": "TextBlock",
43
- "title": "Текстовый блок",
44
- "description": "Описание текстового блока",
45
- "style": ["col-span-12"]
46
- },
47
- {
48
- "blockListType": "TextBlock",
49
- "title": "Текстовый блок №2",
50
- "description": "Описание текстового блока №2",
51
- "style": ["col-span-12"]
52
- }
53
- ]
54
- }
55
- ]
2
+ "title": "Другие продукты"
56
3
  }