@redneckz/wildless-cms-uni-blocks 0.14.57 → 0.14.59
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.
- package/bundle/blocks.schema.json +1 -1
- package/bundle/bundle.umd.js +494 -479
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/AdTile/AdTile.d.ts +6 -0
- package/bundle/components/AdTile/AdTileContent.d.ts +5 -0
- package/bundle/components/AdTile/useAdTile.d.ts +2 -0
- package/bundle/components/ComparisonTable/TableCell.d.ts +1 -1
- package/bundle/components/ComparisonTable/TableCell.mobile.d.ts +1 -1
- package/bundle/components/ComparisonTable/TableColumn.d.ts +1 -1
- package/bundle/model/ContentPageDef.d.ts +1 -0
- package/bundle/utils/isOdd.d.ts +1 -0
- package/dist/components/AdTile/AdTile.d.ts +6 -0
- package/dist/components/AdTile/AdTile.js +12 -0
- package/dist/components/AdTile/AdTile.js.map +1 -0
- package/dist/components/AdTile/AdTileContent.d.ts +5 -0
- package/dist/components/AdTile/AdTileContent.js +2 -0
- package/dist/components/AdTile/AdTileContent.js.map +1 -0
- package/dist/components/AdTile/useAdTile.d.ts +2 -0
- package/dist/components/AdTile/useAdTile.js +12 -0
- package/dist/components/AdTile/useAdTile.js.map +1 -0
- package/dist/components/Blocks.js +4 -2
- package/dist/components/Blocks.js.map +1 -1
- package/dist/components/Blocks.mobile.js +2 -0
- package/dist/components/Blocks.mobile.js.map +1 -1
- package/dist/components/ComparisonTable/TableCell.d.ts +1 -1
- package/dist/components/ComparisonTable/TableCell.js +1 -1
- package/dist/components/ComparisonTable/TableCell.js.map +1 -1
- package/dist/components/ComparisonTable/TableCell.mobile.d.ts +1 -1
- package/dist/components/ComparisonTable/TableCell.mobile.js +1 -1
- package/dist/components/ComparisonTable/TableCell.mobile.js.map +1 -1
- package/dist/components/ComparisonTable/TableColumn.d.ts +1 -1
- package/dist/model/ContentPageDef.d.ts +1 -0
- package/dist/ui-kit/BaseFiltration/BaseFiltrationInner.js +4 -2
- package/dist/ui-kit/BaseFiltration/BaseFiltrationInner.js.map +1 -1
- package/dist/utils/isOdd.d.ts +1 -0
- package/dist/utils/isOdd.js +5 -0
- package/dist/utils/isOdd.js.map +1 -0
- package/lib/components/AdTile/AdTile.d.ts +6 -0
- package/lib/components/AdTile/AdTile.fixture.d.ts +6 -0
- package/lib/components/AdTile/AdTile.js +10 -0
- package/lib/components/AdTile/AdTile.js.map +1 -0
- package/lib/components/AdTile/AdTileContent.d.ts +5 -0
- package/lib/components/AdTile/AdTileContent.js +2 -0
- package/lib/components/AdTile/AdTileContent.js.map +1 -0
- package/lib/components/AdTile/useAdTile.d.ts +2 -0
- package/lib/components/AdTile/useAdTile.js +9 -0
- package/lib/components/AdTile/useAdTile.js.map +1 -0
- package/lib/components/Blocks.js +4 -2
- package/lib/components/Blocks.js.map +1 -1
- package/lib/components/Blocks.mobile.js +2 -0
- package/lib/components/Blocks.mobile.js.map +1 -1
- package/lib/components/ComparisonTable/TableCell.d.ts +1 -1
- package/lib/components/ComparisonTable/TableCell.js +1 -1
- package/lib/components/ComparisonTable/TableCell.js.map +1 -1
- package/lib/components/ComparisonTable/TableCell.mobile.d.ts +1 -1
- package/lib/components/ComparisonTable/TableCell.mobile.js +1 -1
- package/lib/components/ComparisonTable/TableCell.mobile.js.map +1 -1
- package/lib/components/ComparisonTable/TableColumn.d.ts +1 -1
- package/lib/model/ContentPageDef.d.ts +1 -0
- package/lib/ui-kit/BaseFiltration/BaseFiltrationInner.js +4 -2
- package/lib/ui-kit/BaseFiltration/BaseFiltrationInner.js.map +1 -1
- package/lib/utils/isOdd.d.ts +1 -0
- package/lib/utils/isOdd.js +2 -0
- package/lib/utils/isOdd.js.map +1 -0
- package/mobile/bundle/bundle.umd.js +451 -436
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/AdTile/AdTile.d.ts +6 -0
- package/mobile/bundle/components/AdTile/AdTileContent.d.ts +5 -0
- package/mobile/bundle/components/AdTile/useAdTile.d.ts +2 -0
- package/mobile/bundle/components/ComparisonTable/TableCell.d.ts +1 -1
- package/mobile/bundle/components/ComparisonTable/TableColumn.d.ts +1 -1
- package/mobile/bundle/model/ContentPageDef.d.ts +1 -0
- package/mobile/bundle/utils/isOdd.d.ts +1 -0
- package/mobile/dist/components/AdTile/AdTile.d.ts +6 -0
- package/mobile/dist/components/AdTile/AdTile.js +12 -0
- package/mobile/dist/components/AdTile/AdTile.js.map +1 -0
- package/mobile/dist/components/AdTile/AdTileContent.d.ts +5 -0
- package/mobile/dist/components/AdTile/AdTileContent.js +2 -0
- package/mobile/dist/components/AdTile/AdTileContent.js.map +1 -0
- package/mobile/dist/components/AdTile/useAdTile.d.ts +2 -0
- package/mobile/dist/components/AdTile/useAdTile.js +12 -0
- package/mobile/dist/components/AdTile/useAdTile.js.map +1 -0
- package/mobile/dist/components/Blocks.js +2 -0
- package/mobile/dist/components/Blocks.js.map +1 -1
- package/mobile/dist/components/ComparisonTable/TableCell.d.ts +1 -1
- package/mobile/dist/components/ComparisonTable/TableCell.js +1 -1
- package/mobile/dist/components/ComparisonTable/TableCell.js.map +1 -1
- package/mobile/dist/components/ComparisonTable/TableColumn.d.ts +1 -1
- package/mobile/dist/model/ContentPageDef.d.ts +1 -0
- package/mobile/dist/ui-kit/BaseFiltration/BaseFiltrationInner.js +4 -2
- package/mobile/dist/ui-kit/BaseFiltration/BaseFiltrationInner.js.map +1 -1
- package/mobile/dist/utils/isOdd.d.ts +1 -0
- package/mobile/dist/utils/isOdd.js +5 -0
- package/mobile/dist/utils/isOdd.js.map +1 -0
- package/mobile/lib/common.css +1 -1
- package/mobile/lib/components/AdTile/AdTile.d.ts +6 -0
- package/mobile/lib/components/AdTile/AdTile.js +10 -0
- package/mobile/lib/components/AdTile/AdTile.js.map +1 -0
- package/mobile/lib/components/AdTile/AdTileContent.d.ts +5 -0
- package/mobile/lib/components/AdTile/AdTileContent.js +2 -0
- package/mobile/lib/components/AdTile/AdTileContent.js.map +1 -0
- package/mobile/lib/components/AdTile/useAdTile.d.ts +2 -0
- package/mobile/lib/components/AdTile/useAdTile.js +9 -0
- package/mobile/lib/components/AdTile/useAdTile.js.map +1 -0
- package/mobile/lib/components/Blocks.js +2 -0
- package/mobile/lib/components/Blocks.js.map +1 -1
- package/mobile/lib/components/ComparisonTable/TableCell.d.ts +1 -1
- package/mobile/lib/components/ComparisonTable/TableCell.js +1 -1
- package/mobile/lib/components/ComparisonTable/TableCell.js.map +1 -1
- package/mobile/lib/components/ComparisonTable/TableColumn.d.ts +1 -1
- package/mobile/lib/model/ContentPageDef.d.ts +1 -0
- package/mobile/lib/ui-kit/BaseFiltration/BaseFiltrationInner.js +4 -2
- package/mobile/lib/ui-kit/BaseFiltration/BaseFiltrationInner.js.map +1 -1
- package/mobile/lib/utils/isOdd.d.ts +1 -0
- package/mobile/lib/utils/isOdd.js +2 -0
- package/mobile/lib/utils/isOdd.js.map +1 -0
- package/mobile/src/components/AdTile/AdTile.example.json +1 -0
- package/mobile/src/components/AdTile/AdTile.tsx +18 -0
- package/mobile/src/components/AdTile/AdTile.ui.json +1 -0
- package/mobile/src/components/AdTile/AdTileContent.ts +6 -0
- package/mobile/src/components/AdTile/useAdTile.ts +17 -0
- package/mobile/src/components/Blocks.ts +3 -0
- package/mobile/src/components/ComparisonTable/TableCell.tsx +2 -2
- package/mobile/src/components/ComparisonTable/TableColumn.tsx +1 -1
- package/mobile/src/model/ContentPageDef.ts +1 -0
- package/mobile/src/ui-kit/BaseFiltration/BaseFiltrationInner.tsx +4 -0
- package/mobile/src/utils/isOdd.ts +1 -0
- package/package.json +1 -1
- package/src/components/AdTile/AdTile.example.json +1 -0
- package/src/components/AdTile/AdTile.fixture.tsx +11 -0
- package/src/components/AdTile/AdTile.tsx +18 -0
- package/src/components/AdTile/AdTile.ui.json +1 -0
- package/src/components/AdTile/AdTileContent.ts +6 -0
- package/src/components/AdTile/useAdTile.ts +17 -0
- package/src/components/Blocks.mobile.ts +3 -0
- package/src/components/Blocks.ts +5 -2
- package/src/components/ComparisonTable/TableCell.mobile.tsx +2 -2
- package/src/components/ComparisonTable/TableCell.tsx +2 -2
- package/src/components/ComparisonTable/TableColumn.tsx +1 -1
- package/src/model/ContentPageDef.ts +1 -0
- package/src/ui-kit/BaseFiltration/BaseFiltrationInner.tsx +4 -0
- package/src/utils/isOdd.ts +1 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@redneckz/uni-jsx/jsx-runtime";
|
|
2
2
|
import { JSX } from '@redneckz/uni-jsx';
|
|
3
3
|
import { renderBlocksList } from '../../BlockRenderer/renderBlockList.js';
|
|
4
|
+
import { AdTile } from '../../components/AdTile/AdTile.js';
|
|
5
|
+
import { isOdd } from '../../utils/isOdd.js';
|
|
4
6
|
import { style } from '../../utils/style.js';
|
|
5
7
|
import { DefaultFoldButton } from '../Foldable/DefaultFoldButton.js';
|
|
6
8
|
import { Foldable } from '../Foldable/Foldable.js';
|
|
@@ -12,8 +14,8 @@ export const BaseFiltrationInner = JSX(({ label = '', blocksToRender = [], topIt
|
|
|
12
14
|
const [visibleBlocks, hiddenBlocks] = topItemsCount > 0
|
|
13
15
|
? [blocksToRender.slice(0, topItemsCount), blocksToRender.slice(topItemsCount)]
|
|
14
16
|
: [blocksToRender, []];
|
|
15
|
-
return (_jsxs("div", { children: [_jsx("div", { className: style(blocksToRender.length ? 'hidden' : 'block'), children: notFound ? _jsx(NotFound, { ...notFound }) : null }), _jsxs("div", { className: style('space-y-2xs', blocksToRender.length ? '' : 'hidden'), children: [
|
|
16
|
-
return (
|
|
17
|
+
return (_jsxs("div", { children: [_jsx("div", { className: style(blocksToRender.length ? 'hidden' : 'block'), children: notFound ? _jsx(NotFound, { ...notFound }) : null }), _jsxs("div", { className: style('space-y-2xs', blocksToRender.length ? '' : 'hidden'), children: [_jsxs("div", { className: style(resultsGridStyle), children: [renderBlocksList(visibleBlocks, { ...rest.options, parent: block }), isOdd(visibleBlocks.length) ? _jsx(AdTile, { className: "col-span-6" }) : null] }), _jsx(Foldable, { renderFoldableSection: ({ isUnfolded }) => {
|
|
18
|
+
return (_jsxs(FoldableSection, { className: style(resultsGridStyle), isUnfolded: isUnfolded, children: [renderBlocksList(hiddenBlocks, { ...rest.options, parent: block }), isOdd(hiddenBlocks.length) ? _jsx(AdTile, { className: "col-span-6" }) : null] }));
|
|
17
19
|
}, renderFoldButton: ({ isUnfolded, onToggle }) => (_jsx(DefaultFoldButton, { className: style(topItemsCount < 1 ? 'hidden' : ''), disabled: !hiddenBlocks?.length, label: label, icon: ICONS[Number(isUnfolded)], dataTheme: rest.options?.page?.colorPalette, onClick: onToggle })) })] })] }));
|
|
18
20
|
});
|
|
19
21
|
//# sourceMappingURL=BaseFiltrationInner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseFiltrationInner.js","sourceRoot":"","sources":["../../../src/ui-kit/BaseFiltration/BaseFiltrationInner.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseFiltrationInner.js","sourceRoot":"","sources":["../../../src/ui-kit/BaseFiltration/BaseFiltrationInner.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAIxD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM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@@
|
|
|
1
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { type UniBlockProps } from '../../model/JSXBlock';
|
|
3
|
+
import { ClientOnly } from '../../ui-kit/ClientOnly';
|
|
4
|
+
import { ProductBlock } from '../ProductBlock/ProductBlock';
|
|
5
|
+
import { type AdTileContent } from './AdTileContent';
|
|
6
|
+
import { useAdTile } from './useAdTile';
|
|
7
|
+
|
|
8
|
+
interface AdTileProps extends AdTileContent, UniBlockProps {}
|
|
9
|
+
|
|
10
|
+
export const AdTile = JSX<AdTileProps>((props) => {
|
|
11
|
+
const content = useAdTile(props.options?.page?.adSourceBook);
|
|
12
|
+
|
|
13
|
+
return content ? (
|
|
14
|
+
<ClientOnly>
|
|
15
|
+
<ProductBlock {...content} {...props} />
|
|
16
|
+
</ClientOnly>
|
|
17
|
+
) : null;
|
|
18
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useMemo } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
+
import { useSWRResource } from '../../hooks/useSWRResource';
|
|
3
|
+
import { type ProductBlockContent } from '../ProductBlock/ProductBlockContent';
|
|
4
|
+
|
|
5
|
+
interface AdvertisingTileSourceBook {
|
|
6
|
+
items?: ProductBlockContent[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const useAdTile = (sourceBook = 'reklamnaya-plitka'): ProductBlockContent | undefined => {
|
|
10
|
+
const data = useSWRResource<AdvertisingTileSourceBook>(sourceBook);
|
|
11
|
+
|
|
12
|
+
const tileIndex = useMemo(() => randomNumInRange(0, data?.items?.length), [data]);
|
|
13
|
+
|
|
14
|
+
return data?.items?.[tileIndex];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const randomNumInRange = (min = 0, max = 0) => Math.floor(Math.random() * (max - min) + min);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type BlocksRegistry } from '../model/BlocksRegistry';
|
|
2
|
+
|
|
3
|
+
import { AdTile } from './AdTile/AdTile';
|
|
2
4
|
import { ApplicationForm } from './ApplicationForm/ApplicationForm';
|
|
3
5
|
import { BenefitsBlock } from './BenefitsBlock/BenefitsBlock';
|
|
4
6
|
import { Bonus } from './Bonus/Bonus';
|
|
@@ -41,6 +43,7 @@ import { TextBlock } from './TextBlock/TextBlock';
|
|
|
41
43
|
import { VerticalLayout } from './VerticalLayout/VerticalLayout';
|
|
42
44
|
|
|
43
45
|
export const Blocks: BlocksRegistry = {
|
|
46
|
+
AdTile,
|
|
44
47
|
ApplicationForm,
|
|
45
48
|
BenefitsBlock,
|
|
46
49
|
Bonus,
|
|
@@ -4,7 +4,7 @@ import { type CellData } from './ComparisonTableContent';
|
|
|
4
4
|
import { dividerStyle } from './constants';
|
|
5
5
|
|
|
6
6
|
export interface TableCellProps {
|
|
7
|
-
cell
|
|
7
|
+
cell?: CellData[];
|
|
8
8
|
rowHeader?: string;
|
|
9
9
|
isLastRow?: boolean;
|
|
10
10
|
isFirstRow?: boolean;
|
|
@@ -16,7 +16,7 @@ const cellWrapperStyle = `box-border flex flex-col`;
|
|
|
16
16
|
export const TableCell = JSX<TableCellProps>(({ cell, rowHeader, isFillGradient = false }) => (
|
|
17
17
|
<div className={cellWrapperStyle} role="cell">
|
|
18
18
|
<div className={style('h-full', dividerStyle)}>
|
|
19
|
-
{cell.map(renderCellInner(isFillGradient, rowHeader))}
|
|
19
|
+
{cell ? cell.map(renderCellInner(isFillGradient, rowHeader)) : null}
|
|
20
20
|
</div>
|
|
21
21
|
</div>
|
|
22
22
|
));
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
2
|
import { renderBlocksList } from '../../BlockRenderer/renderBlockList';
|
|
3
|
+
import { AdTile } from '../../components/AdTile/AdTile';
|
|
3
4
|
import { type IconName } from '../../icons/IconName';
|
|
4
5
|
import { type BlockDef } from '../../model/ContentPageDef';
|
|
5
6
|
import { type UniBlockProps } from '../../model/JSXBlock';
|
|
7
|
+
import { isOdd } from '../../utils/isOdd';
|
|
6
8
|
import { style } from '../../utils/style';
|
|
7
9
|
import { DefaultFoldButton } from '../Foldable/DefaultFoldButton';
|
|
8
10
|
import { Foldable } from '../Foldable/Foldable';
|
|
@@ -33,12 +35,14 @@ export const BaseFiltrationInner = JSX<BaseFiltrationInnerProps>(
|
|
|
33
35
|
<div className={style('space-y-2xs', blocksToRender.length ? '' : 'hidden')}>
|
|
34
36
|
<div className={style(resultsGridStyle)}>
|
|
35
37
|
{renderBlocksList(visibleBlocks, { ...rest.options, parent: block })}
|
|
38
|
+
{isOdd(visibleBlocks.length) ? <AdTile className="col-span-6" /> : null}
|
|
36
39
|
</div>
|
|
37
40
|
<Foldable
|
|
38
41
|
renderFoldableSection={({ isUnfolded }) => {
|
|
39
42
|
return (
|
|
40
43
|
<FoldableSection className={style(resultsGridStyle)} isUnfolded={isUnfolded}>
|
|
41
44
|
{renderBlocksList(hiddenBlocks, { ...rest.options, parent: block })}
|
|
45
|
+
{isOdd(hiddenBlocks.length) ? <AdTile className="col-span-6" /> : null}
|
|
42
46
|
</FoldableSection>
|
|
43
47
|
);
|
|
44
48
|
}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isOdd = (n: number) => n % 2 !== 0;
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { type UniBlockProps } from '../../model/JSXBlock';
|
|
3
|
+
import { ClientOnly } from '../../ui-kit/ClientOnly';
|
|
4
|
+
import { ProductBlock } from '../ProductBlock/ProductBlock';
|
|
5
|
+
import { type AdTileContent } from './AdTileContent';
|
|
6
|
+
import { useAdTile } from './useAdTile';
|
|
7
|
+
|
|
8
|
+
interface AdTileProps extends AdTileContent, UniBlockProps {}
|
|
9
|
+
|
|
10
|
+
export const AdTile = JSX<AdTileProps>((props) => {
|
|
11
|
+
const content = useAdTile(props.options?.page?.adSourceBook);
|
|
12
|
+
|
|
13
|
+
return content ? (
|
|
14
|
+
<ClientOnly>
|
|
15
|
+
<ProductBlock {...content} {...props} />
|
|
16
|
+
</ClientOnly>
|
|
17
|
+
) : null;
|
|
18
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useMemo } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
+
import { useSWRResource } from '../../hooks/useSWRResource';
|
|
3
|
+
import { type ProductBlockContent } from '../ProductBlock/ProductBlockContent';
|
|
4
|
+
|
|
5
|
+
interface AdvertisingTileSourceBook {
|
|
6
|
+
items?: ProductBlockContent[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const useAdTile = (sourceBook = 'reklamnaya-plitka'): ProductBlockContent | undefined => {
|
|
10
|
+
const data = useSWRResource<AdvertisingTileSourceBook>(sourceBook);
|
|
11
|
+
|
|
12
|
+
const tileIndex = useMemo(() => randomNumInRange(0, data?.items?.length), [data]);
|
|
13
|
+
|
|
14
|
+
return data?.items?.[tileIndex];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const randomNumInRange = (min = 0, max = 0) => Math.floor(Math.random() * (max - min) + min);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type BlocksRegistry } from '../model/BlocksRegistry';
|
|
2
|
+
|
|
3
|
+
import { AdTile } from './AdTile/AdTile';
|
|
2
4
|
import { ApplicationForm } from './ApplicationForm/ApplicationForm';
|
|
3
5
|
import { BenefitsBlock } from './BenefitsBlock/BenefitsBlock';
|
|
4
6
|
import { Bonus } from './Bonus/Bonus';
|
|
@@ -41,6 +43,7 @@ import { TextBlock } from './TextBlock/TextBlock';
|
|
|
41
43
|
import { VerticalLayout } from './VerticalLayout/VerticalLayout';
|
|
42
44
|
|
|
43
45
|
export const Blocks: BlocksRegistry = {
|
|
46
|
+
AdTile,
|
|
44
47
|
ApplicationForm,
|
|
45
48
|
BenefitsBlock,
|
|
46
49
|
Bonus,
|
package/src/components/Blocks.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type BlocksRegistry } from '../model/BlocksRegistry';
|
|
2
|
+
|
|
3
|
+
import { AdTile } from './AdTile/AdTile';
|
|
2
4
|
import { ApplicationForm } from './ApplicationForm/ApplicationForm';
|
|
3
5
|
import { BenefitsBlock } from './BenefitsBlock/BenefitsBlock';
|
|
4
6
|
import { Bonus } from './Bonus/Bonus';
|
|
@@ -50,6 +52,7 @@ import { VerticalLayout } from './VerticalLayout/VerticalLayout';
|
|
|
50
52
|
import { Video } from './Video/Video';
|
|
51
53
|
|
|
52
54
|
export const Blocks: BlocksRegistry = {
|
|
55
|
+
AdTile,
|
|
53
56
|
ApplicationForm,
|
|
54
57
|
BenefitsBlock,
|
|
55
58
|
Bonus,
|
|
@@ -67,8 +70,8 @@ export const Blocks: BlocksRegistry = {
|
|
|
67
70
|
CarouselTariffsCard,
|
|
68
71
|
ComparisonTable,
|
|
69
72
|
ContactsBlock,
|
|
70
|
-
Depository,
|
|
71
73
|
DepositFiltration,
|
|
74
|
+
Depository,
|
|
72
75
|
ErrorBlock,
|
|
73
76
|
ExchangeRateTile,
|
|
74
77
|
Footer,
|
|
@@ -92,8 +95,8 @@ export const Blocks: BlocksRegistry = {
|
|
|
92
95
|
RollupItem,
|
|
93
96
|
SafeDepositRental,
|
|
94
97
|
StepsBlock,
|
|
95
|
-
SwipeListControlBlock,
|
|
96
98
|
StickyBottomMenu,
|
|
99
|
+
SwipeListControlBlock,
|
|
97
100
|
Tabs,
|
|
98
101
|
TariffsTable,
|
|
99
102
|
TextBlock,
|
|
@@ -4,7 +4,7 @@ import { type CellData } from './ComparisonTableContent';
|
|
|
4
4
|
import { dividerStyle } from './constants';
|
|
5
5
|
|
|
6
6
|
export interface TableCellProps {
|
|
7
|
-
cell
|
|
7
|
+
cell?: CellData[];
|
|
8
8
|
rowHeader?: string;
|
|
9
9
|
isLastRow?: boolean;
|
|
10
10
|
isFirstRow?: boolean;
|
|
@@ -16,7 +16,7 @@ const cellWrapperStyle = `box-border flex flex-col`;
|
|
|
16
16
|
export const TableCell = JSX<TableCellProps>(({ cell, rowHeader, isFillGradient = false }) => (
|
|
17
17
|
<div className={cellWrapperStyle} role="cell">
|
|
18
18
|
<div className={style('h-full', dividerStyle)}>
|
|
19
|
-
{cell.map(renderCellInner(isFillGradient, rowHeader))}
|
|
19
|
+
{cell ? cell.map(renderCellInner(isFillGradient, rowHeader)) : null}
|
|
20
20
|
</div>
|
|
21
21
|
</div>
|
|
22
22
|
));
|
|
@@ -4,7 +4,7 @@ import { type CellData } from './ComparisonTableContent';
|
|
|
4
4
|
import { borderStyle, dividerStyle, gradientStyle } from './constants';
|
|
5
5
|
|
|
6
6
|
export interface TableCellProps {
|
|
7
|
-
cell
|
|
7
|
+
cell?: CellData[];
|
|
8
8
|
isLastRow?: boolean;
|
|
9
9
|
isFirstRow?: boolean;
|
|
10
10
|
rowHeader?: string;
|
|
@@ -29,7 +29,7 @@ export const TableCell = JSX<TableCellProps>(({ cell, isFirstRow, isLastRow, isF
|
|
|
29
29
|
return (
|
|
30
30
|
<div className={cellWrapperStyle} role="cell">
|
|
31
31
|
<div className={cellStyle}>
|
|
32
|
-
{cell.map((item, i) => renderCellInner(item, i, isFillGradient))}
|
|
32
|
+
{cell ? cell.map((item, i) => renderCellInner(item, i, isFillGradient)) : null}
|
|
33
33
|
</div>
|
|
34
34
|
</div>
|
|
35
35
|
);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
2
|
import { renderBlocksList } from '../../BlockRenderer/renderBlockList';
|
|
3
|
+
import { AdTile } from '../../components/AdTile/AdTile';
|
|
3
4
|
import { type IconName } from '../../icons/IconName';
|
|
4
5
|
import { type BlockDef } from '../../model/ContentPageDef';
|
|
5
6
|
import { type UniBlockProps } from '../../model/JSXBlock';
|
|
7
|
+
import { isOdd } from '../../utils/isOdd';
|
|
6
8
|
import { style } from '../../utils/style';
|
|
7
9
|
import { DefaultFoldButton } from '../Foldable/DefaultFoldButton';
|
|
8
10
|
import { Foldable } from '../Foldable/Foldable';
|
|
@@ -33,12 +35,14 @@ export const BaseFiltrationInner = JSX<BaseFiltrationInnerProps>(
|
|
|
33
35
|
<div className={style('space-y-2xs', blocksToRender.length ? '' : 'hidden')}>
|
|
34
36
|
<div className={style(resultsGridStyle)}>
|
|
35
37
|
{renderBlocksList(visibleBlocks, { ...rest.options, parent: block })}
|
|
38
|
+
{isOdd(visibleBlocks.length) ? <AdTile className="col-span-6" /> : null}
|
|
36
39
|
</div>
|
|
37
40
|
<Foldable
|
|
38
41
|
renderFoldableSection={({ isUnfolded }) => {
|
|
39
42
|
return (
|
|
40
43
|
<FoldableSection className={style(resultsGridStyle)} isUnfolded={isUnfolded}>
|
|
41
44
|
{renderBlocksList(hiddenBlocks, { ...rest.options, parent: block })}
|
|
45
|
+
{isOdd(hiddenBlocks.length) ? <AdTile className="col-span-6" /> : null}
|
|
42
46
|
</FoldableSection>
|
|
43
47
|
);
|
|
44
48
|
}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isOdd = (n: number) => n % 2 !== 0;
|