@redneckz/wildless-cms-uni-blocks 0.3.55 → 0.3.56
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/bundle.umd.js +2 -3
- package/bundle/bundle.umd.min.js +1 -1
- package/dist/components/ContentPage/ContentPage.js +3 -5
- package/dist/components/ContentPage/ContentPage.js.map +1 -1
- package/dist/components/ContentPage/CustomContentPage.d.ts +30 -0
- package/dist/components/ContentPage/CustomContentPage.js +33 -0
- package/dist/components/ContentPage/CustomContentPage.js.map +1 -0
- package/dist/types.d.ts +5 -0
- package/dist/utils/style2className.d.ts +1 -0
- package/dist/utils/style2className.js +5 -0
- package/dist/utils/style2className.js.map +1 -0
- package/lib/components/ContentPage/ContentPage.js +1 -3
- package/lib/components/ContentPage/ContentPage.js.map +1 -1
- package/lib/components/ContentPage/CustomContentPage.d.ts +30 -0
- package/lib/components/ContentPage/CustomContentPage.js +31 -0
- package/lib/components/ContentPage/CustomContentPage.js.map +1 -0
- package/lib/types.d.ts +5 -0
- package/lib/utils/style2className.d.ts +1 -0
- package/lib/utils/style2className.js +2 -0
- package/lib/utils/style2className.js.map +1 -0
- package/mobile/bundle/bundle.umd.js +2 -3
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/dist/components/ContentPage/ContentPage.js +3 -5
- package/mobile/dist/components/ContentPage/ContentPage.js.map +1 -1
- package/mobile/dist/components/ContentPage/CustomContentPage.d.ts +30 -0
- package/mobile/dist/components/ContentPage/CustomContentPage.js +33 -0
- package/mobile/dist/components/ContentPage/CustomContentPage.js.map +1 -0
- package/mobile/dist/types.d.ts +5 -0
- package/mobile/dist/utils/style2className.d.ts +1 -0
- package/mobile/dist/utils/style2className.js +5 -0
- package/mobile/dist/utils/style2className.js.map +1 -0
- package/mobile/lib/components/ContentPage/ContentPage.js +1 -3
- package/mobile/lib/components/ContentPage/ContentPage.js.map +1 -1
- package/mobile/lib/components/ContentPage/CustomContentPage.d.ts +30 -0
- package/mobile/lib/components/ContentPage/CustomContentPage.js +31 -0
- package/mobile/lib/components/ContentPage/CustomContentPage.js.map +1 -0
- package/mobile/lib/types.d.ts +5 -0
- package/mobile/lib/utils/style2className.d.ts +1 -0
- package/mobile/lib/utils/style2className.js +2 -0
- package/mobile/lib/utils/style2className.js.map +1 -0
- package/mobile/src/components/ContentPage/ContentPage.tsx +1 -4
- package/mobile/src/components/ContentPage/CustomContentPage.tsx +82 -0
- package/mobile/src/types.ts +7 -1
- package/mobile/src/utils/style2className.ts +2 -0
- package/package.json +1 -1
- package/src/components/ContentPage/ContentPage.tsx +1 -4
- package/src/components/ContentPage/CustomContentPage.tsx +82 -0
- package/src/types.ts +7 -1
- package/src/utils/style2className.ts +2 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ContentPageDef, CustomPageTemplate, UniBlockProps } from '../../types';
|
|
2
|
+
import { ContentPageContext } from './ContentPageContext';
|
|
3
|
+
interface PageDecoratorProps<VNode> {
|
|
4
|
+
pageClassName: string;
|
|
5
|
+
pageTemplate: CustomPageTemplate;
|
|
6
|
+
render: (props: {
|
|
7
|
+
pageClassName: string;
|
|
8
|
+
pageTemplate: CustomPageTemplate;
|
|
9
|
+
}) => VNode;
|
|
10
|
+
}
|
|
11
|
+
export declare type PageDecorator<VNode = any> = (props: PageDecoratorProps<VNode>, index?: number | string) => any;
|
|
12
|
+
export interface PageTemplate {
|
|
13
|
+
name: string;
|
|
14
|
+
template: any;
|
|
15
|
+
}
|
|
16
|
+
export declare type PageTemplatesRegistry = Record<string, PageTemplate>;
|
|
17
|
+
export interface CustomContentPageProps extends UniBlockProps {
|
|
18
|
+
pageTemplatesRegistry: PageTemplatesRegistry;
|
|
19
|
+
data: ContentPageDef;
|
|
20
|
+
pageDecorator?: PageDecorator;
|
|
21
|
+
}
|
|
22
|
+
export interface RenderPageFunc {
|
|
23
|
+
pageTemplate: CustomPageTemplate;
|
|
24
|
+
pageClassName: string;
|
|
25
|
+
pageDecorator: PageDecorator;
|
|
26
|
+
pageTemplatesRegistry: PageTemplatesRegistry;
|
|
27
|
+
context: ContentPageContext;
|
|
28
|
+
}
|
|
29
|
+
export declare const CustomContentPage: (props: import("@redneckz/uni-jsx").PropsWithChildren<CustomContentPageProps, any>, context?: any) => any;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.CustomContentPage = void 0;
|
|
3
|
+
const jsx_runtime_1 = require("@redneckz/uni-jsx/jsx-runtime");
|
|
4
|
+
const uni_jsx_1 = require("@redneckz/uni-jsx");
|
|
5
|
+
const style2className_1 = require("../../utils/style2className");
|
|
6
|
+
const defaultPageDecorator = ({ pageClassName, pageTemplate, render }) => render({ pageClassName, pageTemplate });
|
|
7
|
+
exports.CustomContentPage = (0, uni_jsx_1.JSX)(({ className = '', context, pageTemplatesRegistry, data: { style: pageStyle, customPageTmpl: pageTemplate }, pageDecorator = defaultPageDecorator, }) => {
|
|
8
|
+
return pageTemplate
|
|
9
|
+
? renderPage({
|
|
10
|
+
pageTemplate,
|
|
11
|
+
pageClassName: `${(0, style2className_1.style2className)(pageStyle)} ${className}`,
|
|
12
|
+
pageDecorator,
|
|
13
|
+
pageTemplatesRegistry,
|
|
14
|
+
context,
|
|
15
|
+
})
|
|
16
|
+
: null;
|
|
17
|
+
});
|
|
18
|
+
function renderPage({ pageTemplate, pageClassName, pageDecorator, pageTemplatesRegistry, context, }) {
|
|
19
|
+
const { type } = pageTemplate;
|
|
20
|
+
if (!(type && type in pageTemplatesRegistry) || !pageTemplatesRegistry[type].template) {
|
|
21
|
+
throw new Error(`No page template with "${type}" is registered`);
|
|
22
|
+
}
|
|
23
|
+
const { template: PageComponent } = pageTemplatesRegistry[type];
|
|
24
|
+
return pageDecorator({
|
|
25
|
+
pageClassName,
|
|
26
|
+
pageTemplate,
|
|
27
|
+
render: (props) => {
|
|
28
|
+
const { content } = props.pageTemplate;
|
|
29
|
+
return (0, jsx_runtime_1.jsx)(PageComponent, { className: props.pageClassName, context: context, ...content });
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=CustomContentPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomContentPage.js","sourceRoot":"","sources":["../../../src/components/ContentPage/CustomContentPage.tsx"],"names":[],"mappings":";;;AAAA,+CAAwC;AAExC,iEAA8D;AAmC9D,MAAM,oBAAoB,GAAkB,CAAC,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,CACtF,MAAM,CAAC,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC,CAAC;AAE7B,QAAA,iBAAiB,GAAG,IAAA,aAAG,EAClC,CAAC,EACC,SAAS,GAAG,EAAE,EACd,OAAO,EACP,qBAAqB,EACrB,IAAI,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,EACxD,aAAa,GAAG,oBAAoB,GACrC,EAAE,EAAE;IACH,OAAO,YAAY;QACjB,CAAC,CAAC,UAAU,CAAC;YACT,YAAY;YACZ,aAAa,EAAE,GAAG,IAAA,iCAAe,EAAC,SAAS,CAAC,IAAI,SAAS,EAAE;YAC3D,aAAa;YACb,qBAAqB;YACrB,OAAO;SACR,CAAC;QACJ,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CACF,CAAC;AAEF,SAAS,UAAU,CAAC,EAClB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,OAAO,GACQ;IACf,MAAM,EAAE,IAAI,EAAE,GAAG,YAAY,CAAC;IAC9B,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,IAAI,qBAAqB,CAAC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;QACrF,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,iBAAiB,CAAC,CAAC;KAClE;IAED,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAChE,OAAO,aAAa,CAAC;QACnB,aAAa;QACb,YAAY;QACZ,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YAChB,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,YAAY,CAAC;YACvC,OAAO,uBAAC,aAAa,IAAC,SAAS,EAAE,KAAK,CAAC,aAAa,EAAE,OAAO,EAAE,OAAO,KAAM,OAAO,GAAI,CAAC;QAC1F,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/mobile/dist/types.d.ts
CHANGED
|
@@ -37,10 +37,15 @@ export interface ContentPageMeta {
|
|
|
37
37
|
twitter?: Record<string, string>;
|
|
38
38
|
jsonLd?: string;
|
|
39
39
|
}
|
|
40
|
+
export interface CustomPageTemplate {
|
|
41
|
+
content?: Record<string, any>;
|
|
42
|
+
type?: string;
|
|
43
|
+
}
|
|
40
44
|
export interface ContentPageDef extends ContentPageMeta {
|
|
41
45
|
style?: string[];
|
|
42
46
|
blocks?: BlockDef[];
|
|
43
47
|
slots?: SlotsMap;
|
|
48
|
+
customPageTmpl?: CustomPageTemplate;
|
|
44
49
|
likeControl?: boolean;
|
|
45
50
|
colorPalette?: ColorPalette;
|
|
46
51
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const style2className: (style: string[] | undefined | null) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style2className.js","sourceRoot":"","sources":["../../src/utils/style2className.ts"],"names":[],"mappings":";;AAAO,MAAM,eAAe,GAAG,CAAC,KAAkC,EAAU,EAAE,CAC5E,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AADlB,QAAA,eAAe,mBACG"}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "@redneckz/uni-jsx/jsx-runtime";
|
|
|
2
2
|
import { JSX } from '@redneckz/uni-jsx';
|
|
3
3
|
import { changeHashOnScroll } from '../../utils/changeHashOnScroll.js';
|
|
4
4
|
import { isSSR } from '../../utils/isSSR.js';
|
|
5
|
+
import { style2className } from '../../utils/style2className.js';
|
|
5
6
|
import { LikeControl } from '../LikeControl/LikeControl.js';
|
|
6
7
|
import { Placeholder } from '../Placeholder/Placeholder.js';
|
|
7
8
|
const isClient = !isSSR();
|
|
@@ -32,7 +33,4 @@ function renderBlock({ block, blockDecorator, blocksRegistry, context }, i) {
|
|
|
32
33
|
},
|
|
33
34
|
}, `block-${i}`);
|
|
34
35
|
}
|
|
35
|
-
function style2className(style) {
|
|
36
|
-
return style ? style.join(' ') : '';
|
|
37
|
-
}
|
|
38
36
|
//# sourceMappingURL=ContentPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentPage.js","sourceRoot":"","sources":["../../../src/components/ContentPage/ContentPage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAqB,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ContentPage.js","sourceRoot":"","sources":["../../../src/components/ContentPage/ContentPage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAqB,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAkCzD,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,CAAC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IALN,GAAG,IAAI,IAAI,CAAC,EAAE,CAMnB,CACH,CAAC;QACJ,CAAC;KACF,EACD,SAAS,CAAC,EAAE,CACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ContentPageDef, CustomPageTemplate, UniBlockProps } from '../../types';
|
|
2
|
+
import { ContentPageContext } from './ContentPageContext';
|
|
3
|
+
interface PageDecoratorProps<VNode> {
|
|
4
|
+
pageClassName: string;
|
|
5
|
+
pageTemplate: CustomPageTemplate;
|
|
6
|
+
render: (props: {
|
|
7
|
+
pageClassName: string;
|
|
8
|
+
pageTemplate: CustomPageTemplate;
|
|
9
|
+
}) => VNode;
|
|
10
|
+
}
|
|
11
|
+
export declare type PageDecorator<VNode = any> = (props: PageDecoratorProps<VNode>, index?: number | string) => any;
|
|
12
|
+
export interface PageTemplate {
|
|
13
|
+
name: string;
|
|
14
|
+
template: any;
|
|
15
|
+
}
|
|
16
|
+
export declare type PageTemplatesRegistry = Record<string, PageTemplate>;
|
|
17
|
+
export interface CustomContentPageProps extends UniBlockProps {
|
|
18
|
+
pageTemplatesRegistry: PageTemplatesRegistry;
|
|
19
|
+
data: ContentPageDef;
|
|
20
|
+
pageDecorator?: PageDecorator;
|
|
21
|
+
}
|
|
22
|
+
export interface RenderPageFunc {
|
|
23
|
+
pageTemplate: CustomPageTemplate;
|
|
24
|
+
pageClassName: string;
|
|
25
|
+
pageDecorator: PageDecorator;
|
|
26
|
+
pageTemplatesRegistry: PageTemplatesRegistry;
|
|
27
|
+
context: ContentPageContext;
|
|
28
|
+
}
|
|
29
|
+
export declare const CustomContentPage: (props: import("@redneckz/uni-jsx").PropsWithChildren<CustomContentPageProps, any>, context?: any) => any;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@redneckz/uni-jsx/jsx-runtime";
|
|
2
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
3
|
+
import { style2className } from '../../utils/style2className.js';
|
|
4
|
+
const defaultPageDecorator = ({ pageClassName, pageTemplate, render }) => render({ pageClassName, pageTemplate });
|
|
5
|
+
export const CustomContentPage = JSX(({ className = '', context, pageTemplatesRegistry, data: { style: pageStyle, customPageTmpl: pageTemplate }, pageDecorator = defaultPageDecorator, }) => {
|
|
6
|
+
return pageTemplate
|
|
7
|
+
? renderPage({
|
|
8
|
+
pageTemplate,
|
|
9
|
+
pageClassName: `${style2className(pageStyle)} ${className}`,
|
|
10
|
+
pageDecorator,
|
|
11
|
+
pageTemplatesRegistry,
|
|
12
|
+
context,
|
|
13
|
+
})
|
|
14
|
+
: null;
|
|
15
|
+
});
|
|
16
|
+
function renderPage({ pageTemplate, pageClassName, pageDecorator, pageTemplatesRegistry, context, }) {
|
|
17
|
+
const { type } = pageTemplate;
|
|
18
|
+
if (!(type && type in pageTemplatesRegistry) || !pageTemplatesRegistry[type].template) {
|
|
19
|
+
throw new Error(`No page template with "${type}" is registered`);
|
|
20
|
+
}
|
|
21
|
+
const { template: PageComponent } = pageTemplatesRegistry[type];
|
|
22
|
+
return pageDecorator({
|
|
23
|
+
pageClassName,
|
|
24
|
+
pageTemplate,
|
|
25
|
+
render: (props) => {
|
|
26
|
+
const { content } = props.pageTemplate;
|
|
27
|
+
return _jsx(PageComponent, { className: props.pageClassName, context: context, ...content });
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=CustomContentPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomContentPage.js","sourceRoot":"","sources":["../../../src/components/ContentPage/CustomContentPage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAmC9D,MAAM,oBAAoB,GAAkB,CAAC,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,CACtF,MAAM,C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
|
@@ -37,10 +37,15 @@ export interface ContentPageMeta {
|
|
|
37
37
|
twitter?: Record<string, string>;
|
|
38
38
|
jsonLd?: string;
|
|
39
39
|
}
|
|
40
|
+
export interface CustomPageTemplate {
|
|
41
|
+
content?: Record<string, any>;
|
|
42
|
+
type?: string;
|
|
43
|
+
}
|
|
40
44
|
export interface ContentPageDef extends ContentPageMeta {
|
|
41
45
|
style?: string[];
|
|
42
46
|
blocks?: BlockDef[];
|
|
43
47
|
slots?: SlotsMap;
|
|
48
|
+
customPageTmpl?: CustomPageTemplate;
|
|
44
49
|
likeControl?: boolean;
|
|
45
50
|
colorPalette?: ColorPalette;
|
|
46
51
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const style2className: (style: string[] | undefined | null) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style2className.js","sourceRoot":"","sources":["../../src/utils/style2className.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAkC,EAAU,EAAE,CAC5E,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { JSX, PropsWithChildren } from '@redneckz/uni-jsx';
|
|
|
2
2
|
import type { BlockDef, ContentPageDef, UniBlockProps } from '../../types';
|
|
3
3
|
import { changeHashOnScroll } from '../../utils/changeHashOnScroll';
|
|
4
4
|
import { isSSR } from '../../utils/isSSR';
|
|
5
|
+
import { style2className } from '../../utils/style2className';
|
|
5
6
|
import type { BlockContent } from '../BlockContent';
|
|
6
7
|
import { LikeControl } from '../LikeControl/LikeControl';
|
|
7
8
|
import { Placeholder } from '../Placeholder/Placeholder';
|
|
@@ -128,7 +129,3 @@ function renderBlock(
|
|
|
128
129
|
`block-${i}`,
|
|
129
130
|
);
|
|
130
131
|
}
|
|
131
|
-
|
|
132
|
-
function style2className(style: string[] | undefined | null): string {
|
|
133
|
-
return style ? style.join(' ') : '';
|
|
134
|
-
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import type { ContentPageDef, CustomPageTemplate, UniBlockProps } from '../../types';
|
|
3
|
+
import { style2className } from '../../utils/style2className';
|
|
4
|
+
import { ContentPageContext } from './ContentPageContext';
|
|
5
|
+
|
|
6
|
+
interface PageDecoratorProps<VNode> {
|
|
7
|
+
pageClassName: string;
|
|
8
|
+
pageTemplate: CustomPageTemplate;
|
|
9
|
+
render: (props: { pageClassName: string; pageTemplate: CustomPageTemplate }) => VNode;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type PageDecorator<VNode = any> = (
|
|
13
|
+
props: PageDecoratorProps<VNode>,
|
|
14
|
+
index?: number | string,
|
|
15
|
+
) => any;
|
|
16
|
+
|
|
17
|
+
export interface PageTemplate {
|
|
18
|
+
name: string;
|
|
19
|
+
template: any;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type PageTemplatesRegistry = Record<string, PageTemplate>;
|
|
23
|
+
|
|
24
|
+
export interface CustomContentPageProps extends UniBlockProps {
|
|
25
|
+
pageTemplatesRegistry: PageTemplatesRegistry;
|
|
26
|
+
data: ContentPageDef;
|
|
27
|
+
pageDecorator?: PageDecorator;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface RenderPageFunc {
|
|
31
|
+
pageTemplate: CustomPageTemplate;
|
|
32
|
+
pageClassName: string;
|
|
33
|
+
pageDecorator: PageDecorator;
|
|
34
|
+
pageTemplatesRegistry: PageTemplatesRegistry;
|
|
35
|
+
context: ContentPageContext;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const defaultPageDecorator: PageDecorator = ({ pageClassName, pageTemplate, render }) =>
|
|
39
|
+
render({ pageClassName, pageTemplate });
|
|
40
|
+
|
|
41
|
+
export const CustomContentPage = JSX<CustomContentPageProps>(
|
|
42
|
+
({
|
|
43
|
+
className = '',
|
|
44
|
+
context,
|
|
45
|
+
pageTemplatesRegistry,
|
|
46
|
+
data: { style: pageStyle, customPageTmpl: pageTemplate },
|
|
47
|
+
pageDecorator = defaultPageDecorator,
|
|
48
|
+
}) => {
|
|
49
|
+
return pageTemplate
|
|
50
|
+
? renderPage({
|
|
51
|
+
pageTemplate,
|
|
52
|
+
pageClassName: `${style2className(pageStyle)} ${className}`,
|
|
53
|
+
pageDecorator,
|
|
54
|
+
pageTemplatesRegistry,
|
|
55
|
+
context,
|
|
56
|
+
})
|
|
57
|
+
: null;
|
|
58
|
+
},
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
function renderPage({
|
|
62
|
+
pageTemplate,
|
|
63
|
+
pageClassName,
|
|
64
|
+
pageDecorator,
|
|
65
|
+
pageTemplatesRegistry,
|
|
66
|
+
context,
|
|
67
|
+
}: RenderPageFunc) {
|
|
68
|
+
const { type } = pageTemplate;
|
|
69
|
+
if (!(type && type in pageTemplatesRegistry) || !pageTemplatesRegistry[type].template) {
|
|
70
|
+
throw new Error(`No page template with "${type}" is registered`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const { template: PageComponent } = pageTemplatesRegistry[type];
|
|
74
|
+
return pageDecorator({
|
|
75
|
+
pageClassName,
|
|
76
|
+
pageTemplate,
|
|
77
|
+
render: (props) => {
|
|
78
|
+
const { content } = props.pageTemplate;
|
|
79
|
+
return <PageComponent className={props.pageClassName} context={context} {...content} />;
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
package/mobile/src/types.ts
CHANGED
|
@@ -44,10 +44,16 @@ export interface ContentPageMeta {
|
|
|
44
44
|
jsonLd?: string;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
export interface CustomPageTemplate {
|
|
48
|
+
content?: Record<string, any>;
|
|
49
|
+
type?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
47
52
|
export interface ContentPageDef extends ContentPageMeta {
|
|
48
53
|
style?: string[];
|
|
49
|
-
blocks?: BlockDef[];
|
|
54
|
+
blocks?: BlockDef[];
|
|
50
55
|
slots?: SlotsMap;
|
|
56
|
+
customPageTmpl?: CustomPageTemplate;
|
|
51
57
|
likeControl?: boolean;
|
|
52
58
|
colorPalette?: ColorPalette;
|
|
53
59
|
}
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import { JSX, PropsWithChildren } from '@redneckz/uni-jsx';
|
|
|
2
2
|
import type { BlockDef, ContentPageDef, UniBlockProps } from '../../types';
|
|
3
3
|
import { changeHashOnScroll } from '../../utils/changeHashOnScroll';
|
|
4
4
|
import { isSSR } from '../../utils/isSSR';
|
|
5
|
+
import { style2className } from '../../utils/style2className';
|
|
5
6
|
import type { BlockContent } from '../BlockContent';
|
|
6
7
|
import { LikeControl } from '../LikeControl/LikeControl';
|
|
7
8
|
import { Placeholder } from '../Placeholder/Placeholder';
|
|
@@ -128,7 +129,3 @@ function renderBlock(
|
|
|
128
129
|
`block-${i}`,
|
|
129
130
|
);
|
|
130
131
|
}
|
|
131
|
-
|
|
132
|
-
function style2className(style: string[] | undefined | null): string {
|
|
133
|
-
return style ? style.join(' ') : '';
|
|
134
|
-
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import type { ContentPageDef, CustomPageTemplate, UniBlockProps } from '../../types';
|
|
3
|
+
import { style2className } from '../../utils/style2className';
|
|
4
|
+
import { ContentPageContext } from './ContentPageContext';
|
|
5
|
+
|
|
6
|
+
interface PageDecoratorProps<VNode> {
|
|
7
|
+
pageClassName: string;
|
|
8
|
+
pageTemplate: CustomPageTemplate;
|
|
9
|
+
render: (props: { pageClassName: string; pageTemplate: CustomPageTemplate }) => VNode;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type PageDecorator<VNode = any> = (
|
|
13
|
+
props: PageDecoratorProps<VNode>,
|
|
14
|
+
index?: number | string,
|
|
15
|
+
) => any;
|
|
16
|
+
|
|
17
|
+
export interface PageTemplate {
|
|
18
|
+
name: string;
|
|
19
|
+
template: any;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type PageTemplatesRegistry = Record<string, PageTemplate>;
|
|
23
|
+
|
|
24
|
+
export interface CustomContentPageProps extends UniBlockProps {
|
|
25
|
+
pageTemplatesRegistry: PageTemplatesRegistry;
|
|
26
|
+
data: ContentPageDef;
|
|
27
|
+
pageDecorator?: PageDecorator;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface RenderPageFunc {
|
|
31
|
+
pageTemplate: CustomPageTemplate;
|
|
32
|
+
pageClassName: string;
|
|
33
|
+
pageDecorator: PageDecorator;
|
|
34
|
+
pageTemplatesRegistry: PageTemplatesRegistry;
|
|
35
|
+
context: ContentPageContext;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const defaultPageDecorator: PageDecorator = ({ pageClassName, pageTemplate, render }) =>
|
|
39
|
+
render({ pageClassName, pageTemplate });
|
|
40
|
+
|
|
41
|
+
export const CustomContentPage = JSX<CustomContentPageProps>(
|
|
42
|
+
({
|
|
43
|
+
className = '',
|
|
44
|
+
context,
|
|
45
|
+
pageTemplatesRegistry,
|
|
46
|
+
data: { style: pageStyle, customPageTmpl: pageTemplate },
|
|
47
|
+
pageDecorator = defaultPageDecorator,
|
|
48
|
+
}) => {
|
|
49
|
+
return pageTemplate
|
|
50
|
+
? renderPage({
|
|
51
|
+
pageTemplate,
|
|
52
|
+
pageClassName: `${style2className(pageStyle)} ${className}`,
|
|
53
|
+
pageDecorator,
|
|
54
|
+
pageTemplatesRegistry,
|
|
55
|
+
context,
|
|
56
|
+
})
|
|
57
|
+
: null;
|
|
58
|
+
},
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
function renderPage({
|
|
62
|
+
pageTemplate,
|
|
63
|
+
pageClassName,
|
|
64
|
+
pageDecorator,
|
|
65
|
+
pageTemplatesRegistry,
|
|
66
|
+
context,
|
|
67
|
+
}: RenderPageFunc) {
|
|
68
|
+
const { type } = pageTemplate;
|
|
69
|
+
if (!(type && type in pageTemplatesRegistry) || !pageTemplatesRegistry[type].template) {
|
|
70
|
+
throw new Error(`No page template with "${type}" is registered`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const { template: PageComponent } = pageTemplatesRegistry[type];
|
|
74
|
+
return pageDecorator({
|
|
75
|
+
pageClassName,
|
|
76
|
+
pageTemplate,
|
|
77
|
+
render: (props) => {
|
|
78
|
+
const { content } = props.pageTemplate;
|
|
79
|
+
return <PageComponent className={props.pageClassName} context={context} {...content} />;
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -44,10 +44,16 @@ export interface ContentPageMeta {
|
|
|
44
44
|
jsonLd?: string;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
export interface CustomPageTemplate {
|
|
48
|
+
content?: Record<string, any>;
|
|
49
|
+
type?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
47
52
|
export interface ContentPageDef extends ContentPageMeta {
|
|
48
53
|
style?: string[];
|
|
49
|
-
blocks?: BlockDef[];
|
|
54
|
+
blocks?: BlockDef[];
|
|
50
55
|
slots?: SlotsMap;
|
|
56
|
+
customPageTmpl?: CustomPageTemplate;
|
|
51
57
|
likeControl?: boolean;
|
|
52
58
|
colorPalette?: ColorPalette;
|
|
53
59
|
}
|