@uxf/cms 11.40.0 → 11.41.1
Sign up to get free protection for your applications and to get access to all the features.
- package/api/index.d.ts +5 -0
- package/package.json +1 -1
- package/pages/content-builder/components/form-root-fields.d.ts +2 -0
- package/pages/content-builder/components/form-root-fields.js +29 -46
- package/pages/content-builder/components/form.d.ts +2 -0
- package/pages/content-builder/components/form.js +2 -1
- package/pages/content-builder/mapper.js +9 -7
- package/pages/content-builder/types.d.ts +2 -0
package/api/index.d.ts
CHANGED
@@ -29,6 +29,10 @@ export interface ContentResponse {
|
|
29
29
|
type: string;
|
30
30
|
name: string;
|
31
31
|
perex: string;
|
32
|
+
parent?: {
|
33
|
+
id: number;
|
34
|
+
label: string;
|
35
|
+
} | null;
|
32
36
|
seo: ContentSeoResponse;
|
33
37
|
visibilityLevel: VisibilityLevel;
|
34
38
|
hidden: boolean;
|
@@ -53,6 +57,7 @@ export interface ContentRequestBody {
|
|
53
57
|
type: string;
|
54
58
|
name: string;
|
55
59
|
perex: string;
|
60
|
+
parent: number | null;
|
56
61
|
seo: ContentSeoRequestBody;
|
57
62
|
visibilityLevel: VisibilityLevel;
|
58
63
|
hidden: boolean;
|
package/package.json
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { ComboboxOption } from "@uxf/ui/combobox";
|
1
2
|
import React, { Dispatch, ReactNode, SetStateAction } from "react";
|
2
3
|
import { Control } from "react-hook-form";
|
3
4
|
import { ContentBuilderTabs } from "../constants";
|
@@ -9,6 +10,7 @@ interface Props {
|
|
9
10
|
control: Control<any>;
|
10
11
|
id: number | null;
|
11
12
|
setActiveTab: Dispatch<SetStateAction<ContentBuilderTabs>>;
|
13
|
+
parentAutocomplete?: (value: string) => Promise<ComboboxOption[]>;
|
12
14
|
}
|
13
15
|
export declare function FormRootFields(props: Props): React.JSX.Element;
|
14
16
|
export {};
|
@@ -28,51 +28,34 @@ function FormRootFields(props) {
|
|
28
28
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
29
29
|
return (react_1.default.createElement("div", { className: "pb-2 pt-4" },
|
30
30
|
react_1.default.createElement(tabs_1.Tabs, { onChange: props.setActiveTab, value: props.activeTab },
|
31
|
-
react_1.default.createElement(tabs_1.Tabs.Panel, { isAlwaysMounted: true, label: "Z\u00E1kladn\u00ED", name: constants_1.ContentBuilderTabs.Basic },
|
32
|
-
react_1.default.createElement(
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
react_1.default.createElement(
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
react_1.default.createElement(
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
react_1.default.createElement("div", null,
|
61
|
-
react_1.default.createElement(text_input_1.TextInput, { control: props.control, helperText: "Slug = unik\u00E1tn\u00ED koncovka URL adresy", isRequired: true, label: "Slug", name: "seo.name", type: "text" })),
|
62
|
-
react_1.default.createElement(hide_1.Hide, { when: Boolean((_g = (_f = props.config.hide) === null || _f === void 0 ? void 0 : _f.seo) === null || _g === void 0 ? void 0 : _g.title) },
|
63
|
-
react_1.default.createElement("div", null,
|
64
|
-
react_1.default.createElement(text_input_1.TextInput, { control: props.control, label: "Nadpis", name: "seo.title", type: "text" }))),
|
65
|
-
react_1.default.createElement(hide_1.Hide, { when: Boolean((_j = (_h = props.config.hide) === null || _h === void 0 ? void 0 : _h.seo) === null || _j === void 0 ? void 0 : _j.description) },
|
66
|
-
react_1.default.createElement("div", null,
|
67
|
-
react_1.default.createElement(text_input_1.TextInput, { control: props.control, label: "Popis", name: "seo.description", type: "text" }))),
|
68
|
-
react_1.default.createElement(hide_1.Hide, { when: Boolean((_l = (_k = props.config.hide) === null || _k === void 0 ? void 0 : _k.seo) === null || _l === void 0 ? void 0 : _l.ogTitle) },
|
69
|
-
react_1.default.createElement("div", null,
|
70
|
-
react_1.default.createElement(text_input_1.TextInput, { control: props.control, helperText: "Nadpis kter\u00FD bude zobrazen p\u0159i sd\u00EDlen\u00ED na Facebooku, ...", label: "OG nadpis", name: "seo.ogTitle", type: "text" }))),
|
71
|
-
react_1.default.createElement(hide_1.Hide, { when: Boolean((_o = (_m = props.config.hide) === null || _m === void 0 ? void 0 : _m.seo) === null || _o === void 0 ? void 0 : _o.ogDescription) },
|
72
|
-
react_1.default.createElement("div", null,
|
73
|
-
react_1.default.createElement(text_input_1.TextInput, { control: props.control, helperText: "Popis kter\u00FD bude zobrazen p\u0159i sd\u00EDlen\u00ED na Facebooku, ...", label: "OG popis", name: "seo.ogDescription", type: "text" }))),
|
74
|
-
react_1.default.createElement(hide_1.Hide, { when: Boolean((_q = (_p = props.config.hide) === null || _p === void 0 ? void 0 : _p.seo) === null || _q === void 0 ? void 0 : _q.ogImage) },
|
75
|
-
react_1.default.createElement("div", null,
|
76
|
-
react_1.default.createElement(file_input_1.FileInput, { control: props.control, helperText: "Obr\u00E1zek kter\u00FD bude zobrazen p\u0159i sd\u00EDlen\u00ED na Facebooku, ...", id: "seo.ogImage", label: "OG obr\u00E1zek", name: "seo.ogImage", onUploadFile: on_upload_file_1.onUploadFile })))))),
|
31
|
+
react_1.default.createElement(tabs_1.Tabs.Panel, { classNamePanel: "space-y-8 px-4 pb-4", isAlwaysMounted: true, label: "Z\u00E1kladn\u00ED", name: constants_1.ContentBuilderTabs.Basic },
|
32
|
+
(0, is_not_nil_1.isNotNil)(props.parentAutocomplete) && (react_1.default.createElement(combobox_1.Combobox, { control: props.control, label: "Nad\u0159azen\u00FD \u010Dl\u00E1nek", loadOptions: props.parentAutocomplete, name: "parent" })),
|
33
|
+
props.config.allowedTypes && (react_1.default.createElement(select_1.Select, { control: props.control, isReadOnly: (0, is_not_nil_1.isNotNil)(props.id), isRequired: true, label: "Typ", name: "type", options: props.config.allowedTypes })),
|
34
|
+
react_1.default.createElement(text_input_1.TextInput, { control: props.control, isRequired: true, label: "Nadpis", name: "name", type: "text" }),
|
35
|
+
react_1.default.createElement(hide_1.Hide, { when: Boolean((_a = props.config.hide) === null || _a === void 0 ? void 0 : _a.publishedAt) },
|
36
|
+
react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { control: props.control, isRequired: true, label: "Datum publikace", name: "publishedAt" })),
|
37
|
+
react_1.default.createElement(hide_1.Hide, { when: Boolean((_b = props.config.hide) === null || _b === void 0 ? void 0 : _b.perex) },
|
38
|
+
react_1.default.createElement(textarea_1.Textarea, { control: props.control, label: "Perex", name: "perex", rows: 3 })),
|
39
|
+
react_1.default.createElement(hide_1.Hide, { when: Boolean((_c = props.config.hide) === null || _c === void 0 ? void 0 : _c.author) },
|
40
|
+
react_1.default.createElement(combobox_1.Combobox, { control: props.control, label: "Autor", loadOptions: (term) => (0, api_1.autocomplete)(null, { name: "content-author" }, { term }).then((r) => r.data), name: "author" })),
|
41
|
+
react_1.default.createElement(hide_1.Hide, { when: Boolean((_d = props.config.hide) === null || _d === void 0 ? void 0 : _d.category) },
|
42
|
+
react_1.default.createElement(combobox_1.Combobox, { control: props.control, label: "Kategorie", loadOptions: (term) => (0, api_1.autocomplete)(null, { name: "content-category" }, { term }).then((r) => r.data), name: "category" })),
|
43
|
+
react_1.default.createElement(multi_combobox_1.MultiCombobox, { control: props.control, label: "Tagy", loadOptions: (term) => (0, api_1.autocomplete)(null, { name: "content-tag" }, { term }).then((r) => r.data), name: "tags" }),
|
44
|
+
react_1.default.createElement(hide_1.Hide, { when: Boolean((_e = props.config.hide) === null || _e === void 0 ? void 0 : _e.image) },
|
45
|
+
react_1.default.createElement(file_input_1.FileInput, { control: props.control, id: "image", label: "Hlavn\u00ED obr\u00E1zek", name: "image", onUploadFile: on_upload_file_1.onUploadFile })),
|
46
|
+
react_1.default.createElement(checkbox_input_1.CheckboxInput, { control: props.control, label: "Aktivn\u00ED", name: "active" }),
|
47
|
+
react_1.default.createElement(select_1.Select, { control: props.control, isRequired: true, label: "Viditelnost", name: "visibilityLevel", options: options })),
|
48
|
+
react_1.default.createElement(tabs_1.Tabs.Panel, { classNamePanel: "space-y-8 px-4 pb-4", isAlwaysMounted: true, label: "SEO", name: constants_1.ContentBuilderTabs.Seo },
|
49
|
+
react_1.default.createElement(text_input_1.TextInput, { control: props.control, helperText: "Slug = unik\u00E1tn\u00ED koncovka URL adresy", isRequired: true, label: "Slug", name: "seo.name", type: "text" }),
|
50
|
+
react_1.default.createElement(hide_1.Hide, { when: Boolean((_g = (_f = props.config.hide) === null || _f === void 0 ? void 0 : _f.seo) === null || _g === void 0 ? void 0 : _g.title) },
|
51
|
+
react_1.default.createElement(text_input_1.TextInput, { control: props.control, label: "Nadpis", name: "seo.title", type: "text" })),
|
52
|
+
react_1.default.createElement(hide_1.Hide, { when: Boolean((_j = (_h = props.config.hide) === null || _h === void 0 ? void 0 : _h.seo) === null || _j === void 0 ? void 0 : _j.description) },
|
53
|
+
react_1.default.createElement(text_input_1.TextInput, { control: props.control, label: "Popis", name: "seo.description", type: "text" })),
|
54
|
+
react_1.default.createElement(hide_1.Hide, { when: Boolean((_l = (_k = props.config.hide) === null || _k === void 0 ? void 0 : _k.seo) === null || _l === void 0 ? void 0 : _l.ogTitle) },
|
55
|
+
react_1.default.createElement(text_input_1.TextInput, { control: props.control, helperText: "Nadpis kter\u00FD bude zobrazen p\u0159i sd\u00EDlen\u00ED na Facebooku, ...", label: "OG nadpis", name: "seo.ogTitle", type: "text" })),
|
56
|
+
react_1.default.createElement(hide_1.Hide, { when: Boolean((_o = (_m = props.config.hide) === null || _m === void 0 ? void 0 : _m.seo) === null || _o === void 0 ? void 0 : _o.ogDescription) },
|
57
|
+
react_1.default.createElement(text_input_1.TextInput, { control: props.control, helperText: "Popis kter\u00FD bude zobrazen p\u0159i sd\u00EDlen\u00ED na Facebooku, ...", label: "OG popis", name: "seo.ogDescription", type: "text" })),
|
58
|
+
react_1.default.createElement(hide_1.Hide, { when: Boolean((_q = (_p = props.config.hide) === null || _p === void 0 ? void 0 : _p.seo) === null || _q === void 0 ? void 0 : _q.ogImage) },
|
59
|
+
react_1.default.createElement(file_input_1.FileInput, { control: props.control, helperText: "Obr\u00E1zek kter\u00FD bude zobrazen p\u0159i sd\u00EDlen\u00ED na Facebooku, ...", id: "seo.ogImage", label: "OG obr\u00E1zek", name: "seo.ogImage", onUploadFile: on_upload_file_1.onUploadFile })))),
|
77
60
|
props.children));
|
78
61
|
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { FormProps as UXFFormProps } from "@uxf/form/form";
|
2
|
+
import { ComboboxOption } from "@uxf/ui/combobox";
|
2
3
|
import React from "react";
|
3
4
|
import { DefaultValues } from "react-hook-form";
|
4
5
|
import { ContentBuilderConfig, RootContent } from "../types";
|
@@ -6,5 +7,6 @@ export interface FormProps extends Omit<UXFFormProps<RootContent<any>>, "childre
|
|
6
7
|
config: ContentBuilderConfig<any>;
|
7
8
|
id: number | null;
|
8
9
|
defaultValues?: DefaultValues<any>;
|
10
|
+
parentAutocomplete?: (value: string) => Promise<ComboboxOption[]>;
|
9
11
|
}
|
10
12
|
export declare function Form(props: FormProps): React.JSX.Element;
|
@@ -35,6 +35,7 @@ const details_visibility_context_1 = require("../context/details-visibility-cont
|
|
35
35
|
const form_root_fields_1 = require("./form-root-fields");
|
36
36
|
// TODO: Mapování inputů na taby, asi by šlo udělat lépe
|
37
37
|
const INPUT_TAB_MAP = {
|
38
|
+
parent: constants_1.ContentBuilderTabs.Basic,
|
38
39
|
active: constants_1.ContentBuilderTabs.Basic,
|
39
40
|
author: constants_1.ContentBuilderTabs.Basic,
|
40
41
|
category: constants_1.ContentBuilderTabs.Basic,
|
@@ -77,5 +78,5 @@ function Form(props) {
|
|
77
78
|
react_1.default.createElement(content_field_1.ContentField, { contentComponents: props.config.contentComponents, control: formApi.control, name: "content" })),
|
78
79
|
react_1.default.createElement("div", { className: "shrink-0 basis-[500px] bg-white px-4 pb-8 xl:overflow-y-auto dark:bg-gray-950" },
|
79
80
|
react_1.default.createElement("h2", { className: "uxf-typo-h5 px-4 pb-4 pt-6" }, "Nastaven\u00ED"),
|
80
|
-
react_1.default.createElement(form_root_fields_1.FormRootFields, { activeTab: activeTab, config: props.config, control: formApi.control, id: props.id, setActiveTab: setActiveTab })))));
|
81
|
+
react_1.default.createElement(form_root_fields_1.FormRootFields, { activeTab: activeTab, config: props.config, control: formApi.control, id: props.id, parentAutocomplete: props.parentAutocomplete, setActiveTab: setActiveTab })))));
|
81
82
|
}
|
@@ -8,6 +8,7 @@ function mapResponseToFormData(response) {
|
|
8
8
|
return {
|
9
9
|
type: response.type || null,
|
10
10
|
name: response.name,
|
11
|
+
parent: response.parent,
|
11
12
|
perex: response.perex,
|
12
13
|
seo: {
|
13
14
|
name: response.seo.name,
|
@@ -39,26 +40,27 @@ function mapResponseToFormData(response) {
|
|
39
40
|
};
|
40
41
|
}
|
41
42
|
function mapFormDataToRequest(values) {
|
42
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
43
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
43
44
|
return {
|
44
45
|
name: values.name,
|
45
46
|
perex: values.perex,
|
46
47
|
type: (_a = values.type) !== null && _a !== void 0 ? _a : "",
|
48
|
+
parent: (_c = (_b = values.parent) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : null,
|
47
49
|
seo: {
|
48
|
-
name: (
|
50
|
+
name: (_d = values.seo.name) !== null && _d !== void 0 ? _d : "",
|
49
51
|
title: values.seo.title,
|
50
52
|
description: values.seo.description,
|
51
53
|
ogTitle: values.seo.ogTitle,
|
52
54
|
ogDescription: values.seo.ogDescription,
|
53
|
-
ogImage: (
|
55
|
+
ogImage: (_f = (_e = values.seo.ogImage) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : null,
|
54
56
|
},
|
55
57
|
hidden: !values.active,
|
56
|
-
category: (
|
57
|
-
author: (
|
58
|
+
category: (_h = (_g = values.category) === null || _g === void 0 ? void 0 : _g.id) !== null && _h !== void 0 ? _h : null,
|
59
|
+
author: (_k = (_j = values.author) === null || _j === void 0 ? void 0 : _j.id) !== null && _k !== void 0 ? _k : null,
|
58
60
|
publishedAt: values.publishedAt,
|
59
61
|
visibilityLevel: values.visibilityLevel,
|
60
|
-
image: (
|
61
|
-
tags: (
|
62
|
+
image: (_m = (_l = values.image) === null || _l === void 0 ? void 0 : _l.id) !== null && _m !== void 0 ? _m : null,
|
63
|
+
tags: (_p = (_o = values.tags) === null || _o === void 0 ? void 0 : _o.map((t) => t.id)) !== null && _p !== void 0 ? _p : empty_array_1.EMPTY_ARRAY,
|
62
64
|
content: {
|
63
65
|
data: values.content,
|
64
66
|
search: "", // TODO
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { FileResponse } from "@uxf/core/types";
|
2
2
|
import { SelectProps } from "@uxf/form/select";
|
3
|
+
import { ComboboxValue } from "@uxf/ui/combobox";
|
3
4
|
import { NextPageContext } from "next";
|
4
5
|
import { FC, PropsWithChildren, ReactNode } from "react";
|
5
6
|
import { Control, ControllerRenderProps } from "react-hook-form";
|
@@ -29,6 +30,7 @@ export type ContentComponent<T extends Content<string, any>, Props extends Conte
|
|
29
30
|
};
|
30
31
|
export type ContentPageType = "BLOG" | "LANDING_PAGE" | "QUESTION" | "TERM";
|
31
32
|
export type RootContent<T> = {
|
33
|
+
parent?: ComboboxValue<number> | null;
|
32
34
|
type: string | null;
|
33
35
|
active: boolean;
|
34
36
|
visibilityLevel: VisibilityLevel;
|