@uxf/cms 11.31.2 → 11.33.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. package/api/index.js +22 -20
  2. package/config/container.js +3 -3
  3. package/context/cms-provider.d.ts +2 -2
  4. package/context/cms-provider.js +1 -2
  5. package/deprecated/redux/entities/selectors.js +3 -2
  6. package/deprecated/redux/redux-helper.js +1 -2
  7. package/forms/change-password-form/change-password-form.js +1 -1
  8. package/forms/components/wysiwyg-input/wysiwyg-input.js +8 -8
  9. package/forms/forgotten-password-form/forgotten-password-form.js +3 -3
  10. package/forms/invite-user-form/invite-user-form.js +7 -7
  11. package/forms/login-form/login-form.js +4 -4
  12. package/lib/api/create-axios-instance.d.ts +1 -1
  13. package/lib/api/create-axios-instance.js +1 -2
  14. package/lib/api/create-use-axios-request.d.ts +1 -1
  15. package/lib/layout/breadcrumbs.js +4 -2
  16. package/lib/layout/layout.js +3 -3
  17. package/lib/layout/sidebar.js +5 -5
  18. package/lib/layout/types.d.ts +9 -9
  19. package/lib/menu/factory.js +7 -8
  20. package/lib/menu/mobile-bar.js +6 -6
  21. package/lib/menu/model.js +4 -2
  22. package/lib/menu/ui/list-item/list-item.d.ts +1 -1
  23. package/lib/menu/ui/list-item/list-item.js +10 -10
  24. package/lib/menu/ui/menu-item.js +1 -1
  25. package/lib/menu/ui/sub-menu/sub-menu-item.js +1 -1
  26. package/lib/menu/ui/sub-menu/sub-menu-mobile.js +1 -1
  27. package/lib/menu/ui/sub-menu/sub-menu.js +1 -1
  28. package/lib/menu/ui/sub-menu/use-sub-menu.d.ts +7 -8
  29. package/lib/menu/ui/sub-menu/use-sub-menu.js +2 -3
  30. package/lib/menu/ui/user-menu.js +6 -4
  31. package/package.json +19 -19
  32. package/pages/content-builder/components/form-content.js +7 -7
  33. package/pages/content-builder/components/form-root-fields.js +20 -19
  34. package/pages/content-builder/components/form.js +2 -2
  35. package/pages/content-builder/components/header.js +1 -1
  36. package/pages/content-builder/content/feature-section.js +9 -9
  37. package/pages/content-builder/content/gallery.js +1 -1
  38. package/pages/content-builder/content/hero-section.js +4 -4
  39. package/pages/content-builder/content/people.js +9 -9
  40. package/pages/content-builder/content/wysiwyg.js +2 -2
  41. package/pages/content-builder/content-builder-page.js +2 -2
  42. package/pages/content-builder/content-field.js +12 -12
  43. package/pages/content-builder/content-header.js +4 -4
  44. package/pages/content-builder/context/details-visibility-context.js +2 -1
  45. package/pages/content-builder/mapper.js +5 -5
  46. package/pages/content-builder/types.d.ts +33 -33
  47. package/pages/forgotten-password-page/forgotten-password-page.js +1 -1
  48. package/pages/form-page/base-field.js +15 -15
  49. package/pages/form-page/field/content.js +1 -1
  50. package/pages/form-page/field-array.js +3 -3
  51. package/pages/form-page/form-page.d.ts +1 -1
  52. package/pages/form-page/form-page.js +3 -2
  53. package/pages/form-page/form.d.ts +1 -1
  54. package/pages/form-page/form.js +7 -8
  55. package/pages/form-page/mapper.js +2 -1
  56. package/pages/grid-page/get-initial-props-helper.js +2 -3
  57. package/pages/grid-page/grid-page.js +4 -3
  58. package/pages/grid-page/types.d.ts +12 -13
  59. package/pages/login-page/login-page.js +2 -1
  60. package/pages/renew-password-page/renew-password-page.js +1 -1
  61. package/security/use-logged-user.js +1 -2
  62. package/ui/avatar/get-avatar-user-letters.js +5 -4
  63. package/ui/copy-to-clipboard/copy-to-clipboard.js +3 -2
  64. package/utils/on-remove-confirm.js +1 -2
  65. package/utils/use-viewport-height.js +1 -2
@@ -33,29 +33,29 @@ const ContentField = (props) => {
33
33
  react_1.default.createElement("div", { className: "mb-4 mt-6 flex flex-wrap items-center justify-between gap-4" },
34
34
  react_1.default.createElement("h2", { className: "uxf-typo-h5" }, "Obsah"),
35
35
  fields.length > 1 && (react_1.default.createElement("div", { className: "flex justify-end space-x-4" },
36
- react_1.default.createElement(button_1.Button, { variant: "secondary", size: "sm", onClick: () => setVisibilityForAll(true) },
37
- react_1.default.createElement(icon_1.Icon, { name: "arrow-down-from-line", className: "mr-1" }),
36
+ react_1.default.createElement(button_1.Button, { onClick: () => setVisibilityForAll(true), size: "sm", variant: "secondary" },
37
+ react_1.default.createElement(icon_1.Icon, { className: "mr-1", name: "arrow-down-from-line" }),
38
38
  "otev\u0159\u00EDt v\u0161e"),
39
- react_1.default.createElement(button_1.Button, { variant: "secondary", size: "sm", onClick: () => setVisibilityForAll(false) },
40
- react_1.default.createElement(icon_1.Icon, { name: "arrow-up-to-line", className: "mr-1" }),
39
+ react_1.default.createElement(button_1.Button, { onClick: () => setVisibilityForAll(false), size: "sm", variant: "secondary" },
40
+ react_1.default.createElement(icon_1.Icon, { className: "mr-1", name: "arrow-up-to-line" }),
41
41
  "zav\u0159\u00EDt v\u0161e")))),
42
- react_1.default.createElement(core_1.DndContext, { sensors: memoizedSensors, onDragStart: onDragStart, onDragEnd: onDragEnd, onDragCancel: onDragCancel },
42
+ react_1.default.createElement(core_1.DndContext, { onDragCancel: onDragCancel, onDragEnd: onDragEnd, onDragStart: onDragStart, sensors: memoizedSensors },
43
43
  react_1.default.createElement(sortable_1.SortableContext, { items: itemsIds, strategy: sortable_1.verticalListSortingStrategy },
44
44
  react_1.default.createElement("div", { className: "space-y-4 pl-8" }, fields.map((field, index) => {
45
45
  var _a;
46
46
  return (react_1.default.createElement("div", { key: field.id },
47
- react_1.default.createElement(form_content_1.FormContent, { title: (_a = props.contentComponents
48
- .find((c) => c.getConfig().type === field.type)) === null || _a === void 0 ? void 0 : _a.getConfig().label, id: field.id, name: `${props.name}.data[${index}]`, contentComponents: props.contentComponents, index: index, onRemove: () => remove(index), control: props.control, createSection: createSection })));
47
+ react_1.default.createElement(form_content_1.FormContent, { contentComponents: props.contentComponents, control: props.control, createSection: createSection, id: field.id, index: index, name: `${props.name}.data[${index}]`, onRemove: () => remove(index), title: (_a = props.contentComponents
48
+ .find((c) => c.getConfig().type === field.type)) === null || _a === void 0 ? void 0 : _a.getConfig().label })));
49
49
  }))),
50
- react_1.default.createElement(core_1.DragOverlay, { dropAnimation: dropAnimationConfig }, activeItem ? (react_1.default.createElement(form_content_1.FormContent, { ...activeItem, name: `${props.name}.data[${activeItemIndex}]`, contentComponents: props.contentComponents, index: activeItemIndex, control: props.control, createSection: createSection, showAddButton: false })) : null)),
50
+ react_1.default.createElement(core_1.DragOverlay, { dropAnimation: dropAnimationConfig }, activeItem ? (react_1.default.createElement(form_content_1.FormContent, { ...activeItem, contentComponents: props.contentComponents, control: props.control, createSection: createSection, index: activeItemIndex, name: `${props.name}.data[${activeItemIndex}]`, showAddButton: false })) : null)),
51
51
  fields.length < 1 && (react_1.default.createElement("div", null,
52
- react_1.default.createElement(button_1.Button, { className: "h-20 border-2 border-dashed border-gray-600", size: "lg", variant: "text", isFullWidth: true, onClick: () => (0, modal_service_1.openModal)({
52
+ react_1.default.createElement(button_1.Button, { className: "h-20 border-2 border-dashed border-gray-600", isFullWidth: true, onClick: () => (0, modal_service_1.openModal)({
53
53
  children: (react_1.default.createElement("div", { className: "px-4 py-6" },
54
54
  react_1.default.createElement("h2", { className: "uxf-typo-h5 mb-4" }, "P\u0159idat sekci"),
55
- react_1.default.createElement("div", { className: "space-y-4" }, props.contentComponents.map((component) => (react_1.default.createElement(button_1.Button, { key: component.getConfig().type, isFullWidth: true, variant: "secondary", onClick: () => createSection(component, 0) }, component.getConfig().label)))))),
55
+ react_1.default.createElement("div", { className: "space-y-4" }, props.contentComponents.map((component) => (react_1.default.createElement(button_1.Button, { isFullWidth: true, key: component.getConfig().type, onClick: () => createSection(component, 0), variant: "secondary" }, component.getConfig().label)))))),
56
56
  width: "sm",
57
- }) },
58
- react_1.default.createElement(icon_1.Icon, { name: "plus", className: "mr-3", size: 16 }),
57
+ }), size: "lg", variant: "text" },
58
+ react_1.default.createElement(icon_1.Icon, { className: "mr-3", name: "plus", size: 16 }),
59
59
  "P\u0159idat sekci")))));
60
60
  };
61
61
  exports.ContentField = ContentField;
@@ -53,8 +53,8 @@ const ContentHeader = (props) => {
53
53
  event.stopPropagation();
54
54
  (0, modal_service_1.openModal)({
55
55
  children: (react_1.default.createElement(paper_1.Paper, { className: "space-y-4 p-4 dark:bg-gray-950" },
56
- react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { name: "visibilityFrom", label: "Platnost od", value: validityFrom, onChange: (value) => setValidityFrom(value) }),
57
- react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { name: "visibilityTo", label: "Platnost do", value: validityTo, onChange: (value) => setValidityTo(value) }))),
56
+ react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { label: "Platnost od", name: "visibilityFrom", onChange: (value) => setValidityFrom(value), value: validityFrom }),
57
+ react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { label: "Platnost do", name: "visibilityTo", onChange: (value) => setValidityTo(value), value: validityTo }))),
58
58
  width: "sm",
59
59
  });
60
60
  };
@@ -62,9 +62,9 @@ const ContentHeader = (props) => {
62
62
  react_1.default.createElement("h3", { className: "uxf-typo-h6" }, props.title),
63
63
  react_1.default.createElement("div", { className: "flex items-center space-x-4" },
64
64
  react_1.default.createElement("div", { className: "flex space-x-2" },
65
- react_1.default.createElement(button_1.Button, { size: "sm", variant: "secondary", isIconButton: true, onClick: (event) => setVisibilityHandler(event) },
65
+ react_1.default.createElement(button_1.Button, { isIconButton: true, onClick: (event) => setVisibilityHandler(event), size: "sm", variant: "secondary" },
66
66
  react_1.default.createElement(icon_1.Icon, { name: "calendar" })),
67
- react_1.default.createElement(button_1.Button, { size: "sm", onClick: (event) => removeHandler(event), variant: "secondary", isIconButton: true },
67
+ react_1.default.createElement(button_1.Button, { isIconButton: true, onClick: (event) => removeHandler(event), size: "sm", variant: "secondary" },
68
68
  react_1.default.createElement(icon_1.Icon, { name: "delete" }))),
69
69
  react_1.default.createElement(icon_1.Icon, { name: `${visibility ? "chevronUp" : "chevronDown"}`, size: 16 }))));
70
70
  };
@@ -24,8 +24,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.DetailsVisibilityProvider = exports.useDetailsVisibilityControls = exports.useDetailsVisibilityForSection = void 0;
27
+ const noop_1 = require("@uxf/core/utils/noop");
27
28
  const react_1 = __importStar(require("react"));
28
- const detailsVisibilityContext = (0, react_1.createContext)([[], () => void null, true, () => void null]);
29
+ const detailsVisibilityContext = (0, react_1.createContext)([[], noop_1.noop, true, noop_1.noop]);
29
30
  const useDetailsVisibility = () => (0, react_1.useContext)(detailsVisibilityContext);
30
31
  const useDetailsVisibilityForSection = (sectionId) => {
31
32
  var _a;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapFormDataToRequest = exports.mapResponseToFormData = void 0;
3
+ exports.mapResponseToFormData = mapResponseToFormData;
4
+ exports.mapFormDataToRequest = mapFormDataToRequest;
5
+ const empty_array_1 = require("@uxf/core/constants/empty-array");
4
6
  function mapResponseToFormData(response) {
5
7
  var _a, _b;
6
8
  return {
@@ -33,10 +35,9 @@ function mapResponseToFormData(response) {
33
35
  publishedAt: (_a = response.publishedAt) !== null && _a !== void 0 ? _a : new Date().toISOString(),
34
36
  active: !response.hidden,
35
37
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
36
- tags: (_b = response.tags) !== null && _b !== void 0 ? _b : [],
38
+ tags: (_b = response.tags) !== null && _b !== void 0 ? _b : empty_array_1.EMPTY_ARRAY,
37
39
  };
38
40
  }
39
- exports.mapResponseToFormData = mapResponseToFormData;
40
41
  function mapFormDataToRequest(values) {
41
42
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
42
43
  return {
@@ -57,11 +58,10 @@ function mapFormDataToRequest(values) {
57
58
  publishedAt: values.publishedAt,
58
59
  visibilityLevel: values.visibilityLevel,
59
60
  image: (_k = (_j = values.image) === null || _j === void 0 ? void 0 : _j.id) !== null && _k !== void 0 ? _k : null,
60
- tags: (_m = (_l = values.tags) === null || _l === void 0 ? void 0 : _l.map((t) => t.id)) !== null && _m !== void 0 ? _m : [],
61
+ tags: (_m = (_l = values.tags) === null || _l === void 0 ? void 0 : _l.map((t) => t.id)) !== null && _m !== void 0 ? _m : empty_array_1.EMPTY_ARRAY,
61
62
  content: {
62
63
  data: values.content,
63
64
  search: "", // TODO
64
65
  },
65
66
  };
66
67
  }
67
- exports.mapFormDataToRequest = mapFormDataToRequest;
@@ -5,6 +5,10 @@ import { FC, PropsWithChildren, ReactNode } from "react";
5
5
  import { Control, ControllerRenderProps } from "react-hook-form";
6
6
  import { ContentResponse, ContentTagResponse } from "../../api";
7
7
  export type VisibilityLevel = "PUBLIC" | "PUBLIC_WITHOUT_SITEMAP" | "PRIVATE";
8
+ export interface Content<Type extends string, ContentType> {
9
+ type: Type;
10
+ content: ContentType;
11
+ }
8
12
  export interface ContentProps {
9
13
  title: ReactNode;
10
14
  id: string;
@@ -24,39 +28,6 @@ export type ContentComponent<T extends Content<string, any>, Props extends Conte
24
28
  getConfig: ContentGetConfig<T>;
25
29
  };
26
30
  export type ContentPageType = "BLOG" | "LANDING_PAGE" | "QUESTION" | "TERM";
27
- export interface ContentBuilderConfig<Contents extends Content<string, any>> {
28
- type?: ContentPageType;
29
- allowedTypes?: Array<{
30
- id: ContentPageType;
31
- label: string;
32
- }>;
33
- contentComponents: ContentComponent<any>[];
34
- onSubmit?: (contentId: number | null, values: RootContent<Contents>) => Promise<ContentResponse>;
35
- onSubmitSuccess?: (contentId: number | null, values: RootContent<Contents>, response: ContentResponse) => Promise<void>;
36
- initialValues?: RootContent<Contents> | ((ctx: NextPageContext) => Promise<RootContent<Contents>>);
37
- allowedRoles?: string[];
38
- ui: {
39
- Layout?: FC<PropsWithChildren>;
40
- };
41
- hide?: {
42
- author?: boolean;
43
- category?: boolean;
44
- image?: boolean;
45
- perex?: boolean;
46
- publishedAt?: boolean;
47
- seo?: {
48
- title?: boolean;
49
- description?: boolean;
50
- ogTitle?: boolean;
51
- ogDescription?: boolean;
52
- ogImage?: boolean;
53
- };
54
- };
55
- }
56
- export interface Content<Type extends string, ContentType> {
57
- type: Type;
58
- content: ContentType;
59
- }
60
31
  export type RootContent<T> = {
61
32
  type: string | null;
62
33
  active: boolean;
@@ -87,3 +58,32 @@ export type RootContent<T> = {
87
58
  };
88
59
  tags?: ContentTagResponse[];
89
60
  };
61
+ export interface ContentBuilderConfig<Contents extends Content<string, any>> {
62
+ type?: ContentPageType;
63
+ allowedTypes?: Array<{
64
+ id: ContentPageType;
65
+ label: string;
66
+ }>;
67
+ contentComponents: ContentComponent<any>[];
68
+ onSubmit?: (contentId: number | null, values: RootContent<Contents>) => Promise<ContentResponse>;
69
+ onSubmitSuccess?: (contentId: number | null, values: RootContent<Contents>, response: ContentResponse) => Promise<void>;
70
+ initialValues?: RootContent<Contents> | ((ctx: NextPageContext) => Promise<RootContent<Contents>>);
71
+ allowedRoles?: string[];
72
+ ui: {
73
+ Layout?: FC<PropsWithChildren>;
74
+ };
75
+ hide?: {
76
+ author?: boolean;
77
+ category?: boolean;
78
+ image?: boolean;
79
+ perex?: boolean;
80
+ publishedAt?: boolean;
81
+ seo?: {
82
+ title?: boolean;
83
+ description?: boolean;
84
+ ogTitle?: boolean;
85
+ ogDescription?: boolean;
86
+ ogImage?: boolean;
87
+ };
88
+ };
89
+ }
@@ -43,7 +43,7 @@ const ForgottenPasswordPage = (config) => {
43
43
  }
44
44
  }, []);
45
45
  return (react_1.default.createElement(login_layout_1.LoginLayout, { Logo: (_a = config.ui) === null || _a === void 0 ? void 0 : _a.Logo, pageTitle: config.pageTitle, title: config.title },
46
- react_1.default.createElement(forgotten_password_form_1.ForgottenPasswordForm, { onSubmit: onSubmit, defaultValues: INITIAL_VALUES, onLogin: config.onLogin })));
46
+ react_1.default.createElement(forgotten_password_form_1.ForgottenPasswordForm, { defaultValues: INITIAL_VALUES, onLogin: config.onLogin, onSubmit: onSubmit })));
47
47
  };
48
48
  return Component;
49
49
  };
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BaseField = void 0;
7
+ const empty_array_1 = require("@uxf/core/constants/empty-array");
7
8
  const checkbox_input_1 = require("@uxf/form/checkbox-input");
8
9
  const combobox_1 = require("@uxf/form/combobox");
9
10
  const date_picker_input_1 = require("@uxf/form/date-picker-input");
@@ -23,8 +24,7 @@ const api_1 = require("../../api");
23
24
  const on_upload_dropzone_file_1 = require("../../forms/utils/on-upload-dropzone-file");
24
25
  const on_upload_file_1 = require("../../forms/utils/on-upload-file");
25
26
  const on_remove_confirm_1 = require("../../utils/on-remove-confirm");
26
- // eslint-disable-next-line import/no-cycle
27
- const field_array_1 = require("./field-array");
27
+ const field_array_1 = require("./field-array"); // eslint-disable-line import/no-cycle
28
28
  const content_1 = require("./field/content");
29
29
  // eslint-disable-next-line complexity
30
30
  const BaseField = (props) => {
@@ -39,30 +39,30 @@ const BaseField = (props) => {
39
39
  case "file":
40
40
  case "logo":
41
41
  case "image":
42
- return (react_1.default.createElement(file_input_1.FileInput, { id: fieldName, label: label, name: fieldName, isRequired: required, isDisabled: disabled, onUploadFile: on_upload_file_1.onUploadFile, control: control, isClearable: !required }));
42
+ return (react_1.default.createElement(file_input_1.FileInput, { control: control, id: fieldName, isClearable: !required, isDisabled: disabled, isRequired: required, label: label, name: fieldName, onUploadFile: on_upload_file_1.onUploadFile }));
43
43
  case "enum":
44
- return (react_1.default.createElement(select_1.Select, { options: options !== null && options !== void 0 ? options : [], name: fieldName, label: label, isRequired: required, isDisabled: disabled, control: control, isClearable: !required }));
44
+ return (react_1.default.createElement(select_1.Select, { control: control, isClearable: !required, isDisabled: disabled, isRequired: required, label: label, name: fieldName, options: options !== null && options !== void 0 ? options : empty_array_1.EMPTY_ARRAY }));
45
45
  case "content":
46
46
  return react_1.default.createElement(content_1.Content, { ...props });
47
47
  case "boolean":
48
- return (react_1.default.createElement(checkbox_input_1.CheckboxInput, { name: fieldName, label: label, isRequired: required, isDisabled: disabled, control: control }));
48
+ return (react_1.default.createElement(checkbox_input_1.CheckboxInput, { control: control, isDisabled: disabled, isRequired: required, label: label, name: fieldName }));
49
49
  case "date":
50
- return (react_1.default.createElement(date_picker_input_1.DatePickerInput, { name: fieldName, label: label, isRequired: required, isDisabled: disabled, control: control, isClearable: !required }));
50
+ return (react_1.default.createElement(date_picker_input_1.DatePickerInput, { control: control, isClearable: !required, isDisabled: disabled, isRequired: required, label: label, name: fieldName }));
51
51
  case "datetime":
52
- return (react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { name: fieldName, label: label, isRequired: required, isDisabled: disabled, control: control, isClearable: !required }));
52
+ return (react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { control: control, isClearable: !required, isDisabled: disabled, isRequired: required, label: label, name: fieldName }));
53
53
  case "time":
54
- return (react_1.default.createElement(time_picker_input_1.TimePickerInput, { name: fieldName, label: label, isRequired: required, isDisabled: disabled, control: control, isClearable: !required }));
54
+ return (react_1.default.createElement(time_picker_input_1.TimePickerInput, { control: control, isClearable: !required, isDisabled: disabled, isRequired: required, label: label, name: fieldName }));
55
55
  case "files":
56
56
  case "images":
57
57
  return (react_1.default.createElement(react_1.default.Fragment, null,
58
58
  react_1.default.createElement(label_1.Label, null, label),
59
59
  react_1.default.createElement("div", { className: "mb-3" },
60
- react_1.default.createElement(dropzone_input_1.DropzoneInput, { label: label, name: fieldName, control: control, onUploadFile: on_upload_dropzone_file_1.onUploadDropzoneFile })),
60
+ react_1.default.createElement(dropzone_input_1.DropzoneInput, { control: control, label: label, name: fieldName, onUploadFile: on_upload_dropzone_file_1.onUploadDropzoneFile })),
61
61
  react_1.default.createElement(dropzone_list_1.DropzoneList, { control: control, errorText: "Soubor se nepoda\u0159ilo nahr\u00E1t.", name: fieldName, onRemoveConfirm: on_remove_confirm_1.onRemoveConfirm })));
62
62
  case "manyToMany":
63
- return (react_1.default.createElement(multi_combobox_1.MultiCombobox, { name: fieldName, label: label, isRequired: required, isDisabled: disabled, control: control, loadOptions: (term) => { var _a; return (0, api_1.autocomplete)(null, { name: (_a = fieldSchema.autocomplete) !== null && _a !== void 0 ? _a : "" }, { term }).then((r) => r.data); } }));
63
+ return (react_1.default.createElement(multi_combobox_1.MultiCombobox, { control: control, isDisabled: disabled, isRequired: required, label: label, loadOptions: (term) => { var _a; return (0, api_1.autocomplete)(null, { name: (_a = fieldSchema.autocomplete) !== null && _a !== void 0 ? _a : "" }, { term }).then((r) => r.data); }, name: fieldName }));
64
64
  case "manyToOne":
65
- return (react_1.default.createElement(combobox_1.Combobox, { name: fieldName, label: label, isRequired: required, isDisabled: disabled, control: control, loadOptions: (term) => { var _a; return (0, api_1.autocomplete)(null, { name: (_a = fieldSchema.autocomplete) !== null && _a !== void 0 ? _a : "" }, { term }).then((r) => r.data); }, isClearable: !required }));
65
+ return (react_1.default.createElement(combobox_1.Combobox, { control: control, isClearable: !required, isDisabled: disabled, isRequired: required, label: label, loadOptions: (term) => { var _a; return (0, api_1.autocomplete)(null, { name: (_a = fieldSchema.autocomplete) !== null && _a !== void 0 ? _a : "" }, { term }).then((r) => r.data); }, name: fieldName }));
66
66
  case "oneToMany":
67
67
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
68
68
  if (fieldSchema.fields === null) {
@@ -70,7 +70,7 @@ const BaseField = (props) => {
70
70
  }
71
71
  return (react_1.default.createElement(react_1.default.Fragment, null,
72
72
  react_1.default.createElement("p", { className: "mb-2 font-medium" }, fieldSchema.label),
73
- react_1.default.createElement(field_array_1.FieldArray, { fieldName: fieldName, fieldSchema: fieldSchema, entityAlias: entityAlias, isEditing: isEditing, control: control })));
73
+ react_1.default.createElement(field_array_1.FieldArray, { control: control, entityAlias: entityAlias, fieldName: fieldName, fieldSchema: fieldSchema, isEditing: isEditing })));
74
74
  case "embedded":
75
75
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
76
76
  if (fieldSchema.fields === null) {
@@ -79,11 +79,11 @@ const BaseField = (props) => {
79
79
  return (react_1.default.createElement(react_1.default.Fragment, null, fieldSchema.fields.map((schema, i) => (react_1.default.createElement("div", { key: i },
80
80
  react_1.default.createElement(exports.BaseField, { ...props, fieldSchema: { ...schema, label: `${fieldSchema.label} ${schema.label}` }, prefix: `${fieldSchema.name}.` }))))));
81
81
  case "integer":
82
- return (react_1.default.createElement(number_input_1.NumberInput, { name: fieldName, label: label, isRequired: required, isDisabled: disabled, control: control }));
82
+ return (react_1.default.createElement(number_input_1.NumberInput, { control: control, isDisabled: disabled, isRequired: required, label: label, name: fieldName }));
83
83
  case "text":
84
- return (react_1.default.createElement(textarea_1.Textarea, { name: fieldName, label: label, isRequired: required, isDisabled: disabled, control: control }));
84
+ return (react_1.default.createElement(textarea_1.Textarea, { control: control, isDisabled: disabled, isRequired: required, label: label, name: fieldName }));
85
85
  default:
86
- return (react_1.default.createElement(text_input_1.TextInput, { name: fieldName, label: label, isRequired: required, isDisabled: disabled, control: control }));
86
+ return (react_1.default.createElement(text_input_1.TextInput, { control: control, isDisabled: disabled, isRequired: required, label: label, name: fieldName }));
87
87
  }
88
88
  };
89
89
  exports.BaseField = BaseField;
@@ -12,6 +12,6 @@ const Content = (props) => {
12
12
  const { fieldSchema, prefix = "", contentComponents, control } = props;
13
13
  return (react_1.default.createElement("fieldset", null,
14
14
  react_1.default.createElement("legend", null, fieldSchema.label),
15
- react_1.default.createElement(content_builder_1.ContentField, { contentComponents: contentComponents !== null && contentComponents !== void 0 ? contentComponents : [wysiwyg_1.Wysiwyg], name: `${prefix}${fieldSchema.name}`, control: control })));
15
+ react_1.default.createElement(content_builder_1.ContentField, { contentComponents: contentComponents !== null && contentComponents !== void 0 ? contentComponents : [wysiwyg_1.Wysiwyg], control: control, name: `${prefix}${fieldSchema.name}` })));
16
16
  };
17
17
  exports.Content = Content;
@@ -38,13 +38,13 @@ const FieldArray = (props) => {
38
38
  react_1.default.createElement("div", { className: "grid gap-2" }, fields.map((name, index) => (react_1.default.createElement(react_1.Fragment, { key: name.id },
39
39
  fieldSchema.fields.map((schema, i) => {
40
40
  if (schema.name === "id") {
41
- return react_1.default.createElement("input", { type: "hidden", key: `${schema.name}-${i}`, name: "id" });
41
+ return react_1.default.createElement("input", { key: `${schema.name}-${i}`, name: "id", type: "hidden" });
42
42
  }
43
43
  return (react_1.default.createElement("div", { key: `${schema.name}-${i}` },
44
- react_1.default.createElement(base_field_1.BaseField, { fieldSchema: schema, entityAlias: entityAlias, isEditing: isEditing, prefix: `${index}.`, control: control })));
44
+ react_1.default.createElement(base_field_1.BaseField, { control: control, entityAlias: entityAlias, fieldSchema: schema, isEditing: isEditing, prefix: `${index}.` })));
45
45
  }),
46
46
  react_1.default.createElement("div", { className: "flex justify-end" },
47
- react_1.default.createElement(button_1.Button, { variant: "secondary", isIconButton: true, onClick: () => remove(index) },
47
+ react_1.default.createElement(button_1.Button, { isIconButton: true, onClick: () => remove(index), variant: "secondary" },
48
48
  react_1.default.createElement(icon_1.Icon, { name: "trash", size: 20 }))))))),
49
49
  react_1.default.createElement("div", { className: "mt-2" },
50
50
  react_1.default.createElement(button_1.Button, { isIconButton: true, onClick: () => append({ id: null }), variant: "secondary" },
@@ -11,5 +11,5 @@ export interface InitialProps<T extends {
11
11
  entityMetaSchema: EntityMetaSchema;
12
12
  }
13
13
  export declare const FormPage: <T extends {
14
- id?: number | null | undefined;
14
+ id?: number | null;
15
15
  }>(config: FormPageConfig<T>) => import("next").NextComponentType<import("../../deprecated/types/app").IAppContext, object, object>;
@@ -27,6 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.FormPage = void 0;
30
+ const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
30
31
  const router_1 = __importDefault(require("next/router"));
31
32
  const react_1 = __importStar(require("react"));
32
33
  const react_hook_form_1 = require("react-hook-form");
@@ -37,7 +38,7 @@ const ValidationError_1 = require("../../errors/ValidationError");
37
38
  const base_field_1 = require("./base-field");
38
39
  const form_1 = require("./form");
39
40
  const mapper_1 = require("./mapper");
40
- const resolve = (value, ctx) => (typeof value === "function" ? value(ctx) : value !== null && value !== void 0 ? value : null);
41
+ const resolve = (value, ctx) => (typeof value === "function" ? value(ctx) : (value !== null && value !== void 0 ? value : null));
41
42
  const FormPage = (config) => {
42
43
  var _a, _b, _c;
43
44
  const entityIdResolver = (_a = config.entityId) !== null && _a !== void 0 ? _a : (({ query }) => (query.id ? Number.parseInt(query.id, 10) : null));
@@ -67,7 +68,7 @@ const FormPage = (config) => {
67
68
  }, [entityAlias, entityId, formSchema, formApi]);
68
69
  const FieldComponentElement = (_b = (_a = config.ui) === null || _a === void 0 ? void 0 : _a.Field) !== null && _b !== void 0 ? _b : base_field_1.BaseField;
69
70
  const Layout = (_d = (_c = config.ui) === null || _c === void 0 ? void 0 : _c.Layout) !== null && _d !== void 0 ? _d : react_1.default.createElement("div", null);
70
- const Content = (react_1.default.createElement(form_1.Form, { Field: FieldComponentElement, entityAlias: entityAlias, formApi: formApi, id: `${entityAlias}-form`, isEditing: !!entityId, onSubmit: onSubmit, schema: formSchema }));
71
+ const Content = (react_1.default.createElement(form_1.Form, { Field: FieldComponentElement, entityAlias: entityAlias, formApi: formApi, id: `${entityAlias}-form`, isEditing: (0, is_not_nil_1.isNotNil)(entityId), onSubmit: onSubmit, schema: formSchema }));
71
72
  return (0, react_1.cloneElement)(typeof Layout === "function" ? Layout(entityMetaSchema) : Layout, {
72
73
  children: Content,
73
74
  });
@@ -14,5 +14,5 @@ interface FormProps<T extends FieldValues> extends Omit<UXFFormProps<T>, "childr
14
14
  isEditing?: boolean;
15
15
  SubmitButton?: SubmitButtonComponent<T>;
16
16
  }
17
- export declare const Form: <T extends FieldValues>(props: FormProps<T>) => React.JSX.Element;
17
+ export declare function Form<T extends FieldValues>(props: FormProps<T>): React.JSX.Element;
18
18
  export {};
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Form = void 0;
6
+ exports.Form = Form;
7
7
  const form_1 = require("@uxf/form/form");
8
8
  const button_1 = require("@uxf/ui/button");
9
9
  const react_1 = __importDefault(require("react"));
@@ -11,16 +11,15 @@ const widget_1 = require("../../ui/widget");
11
11
  const base_field_1 = require("./base-field");
12
12
  const BaseSubmitButton = (props) => {
13
13
  const { isSubmitting } = props.formState;
14
- return (react_1.default.createElement(button_1.Button, { type: "submit", isDisabled: isSubmitting }, "Ulo\u017Eit"));
14
+ return (react_1.default.createElement(button_1.Button, { isDisabled: isSubmitting, type: "submit" }, "Ulo\u017Eit"));
15
15
  };
16
- const Form = (props) => {
16
+ function Form(props) {
17
17
  var _a, _b, _c;
18
18
  const SubmitButton = (_a = props.SubmitButton) !== null && _a !== void 0 ? _a : BaseSubmitButton;
19
19
  const Field = (_b = props.Field) !== null && _b !== void 0 ? _b : base_field_1.BaseField;
20
20
  return (react_1.default.createElement(form_1.Form, { formApi: props.formApi, id: props.id, onSubmit: props.onSubmit },
21
21
  react_1.default.createElement("div", { className: (_c = props.className) !== null && _c !== void 0 ? _c : "pb-10" },
22
- react_1.default.createElement(widget_1.Widget, { withDividers: true, footer: react_1.default.createElement("div", { className: "text-right" },
23
- react_1.default.createElement(SubmitButton, { formState: props.formApi.formState })) }, props.schema.fields.map((field, i) => (react_1.default.createElement("div", { key: i, className: "p-4" },
24
- react_1.default.createElement(Field, { fieldSchema: field, entityAlias: props.entityAlias, isEditing: props.isEditing, control: props.formApi.control }))))))));
25
- };
26
- exports.Form = Form;
22
+ react_1.default.createElement(widget_1.Widget, { footer: react_1.default.createElement("div", { className: "text-right" },
23
+ react_1.default.createElement(SubmitButton, { formState: props.formApi.formState })), withDividers: true }, props.schema.fields.map((field, i) => (react_1.default.createElement("div", { className: "p-4", key: i },
24
+ react_1.default.createElement(Field, { control: props.formApi.control, entityAlias: props.entityAlias, fieldSchema: field, isEditing: props.isEditing }))))))));
25
+ }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mapToRequestObject = void 0;
4
+ const empty_array_1 = require("@uxf/core/constants/empty-array");
4
5
  const mapToRequestObject = (values, schema) => {
5
6
  var _a, _b;
6
7
  const requestObject = { ...values };
@@ -14,7 +15,7 @@ const mapToRequestObject = (values, schema) => {
14
15
  break;
15
16
  case "content":
16
17
  // TODO search string
17
- requestObject[name] = value ? { data: (_a = value.data) !== null && _a !== void 0 ? _a : [], search: (_b = value.search) !== null && _b !== void 0 ? _b : "" } : null;
18
+ requestObject[name] = value ? { data: (_a = value.data) !== null && _a !== void 0 ? _a : empty_array_1.EMPTY_ARRAY, search: (_b = value.search) !== null && _b !== void 0 ? _b : "" } : null;
18
19
  break;
19
20
  case "embedded":
20
21
  requestObject[name] = (0, exports.mapToRequestObject)(value, field);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadEntityGridSchema = exports.loadEntityMetaSchema = void 0;
3
+ exports.loadEntityMetaSchema = loadEntityMetaSchema;
4
+ exports.loadEntityGridSchema = loadEntityGridSchema;
4
5
  const api_1 = require("../../api");
5
6
  const entities_1 = require("../../deprecated/redux/entities");
6
7
  async function loadEntityMetaSchema(ctx, entityAlias) {
@@ -10,7 +11,6 @@ async function loadEntityMetaSchema(ctx, entityAlias) {
10
11
  }
11
12
  return (0, entities_1.metaSchemaSelector)(entityAlias)(getState());
12
13
  }
13
- exports.loadEntityMetaSchema = loadEntityMetaSchema;
14
14
  async function loadEntityGridSchema(ctx, entityAlias) {
15
15
  const { reduxStore: { getState, dispatch }, } = ctx;
16
16
  if (!(0, entities_1.gridSchemaExistsSelector)(entityAlias)(getState())) {
@@ -18,4 +18,3 @@ async function loadEntityGridSchema(ctx, entityAlias) {
18
18
  }
19
19
  return (0, entities_1.gridSchemaSelector)(entityAlias)(getState());
20
20
  }
21
- exports.loadEntityGridSchema = loadEntityGridSchema;
@@ -27,6 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.GridPage = exports.dataGridLoader = void 0;
30
+ const empty_array_1 = require("@uxf/core/constants/empty-array");
30
31
  const buildArray_1 = require("@uxf/core/utils/buildArray");
31
32
  const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
32
33
  const data_grid_1 = require("@uxf/data-grid");
@@ -79,7 +80,7 @@ const GridPageComponent = (props) => {
79
80
  }), [onReload]);
80
81
  const hasOnAdd = props.onAdd && (!props.metaSchema || props.metaSchema.actions.includes("add"));
81
82
  const cActions = [
82
- ...((_d = props.customActions) !== null && _d !== void 0 ? _d : []),
83
+ ...((_d = props.customActions) !== null && _d !== void 0 ? _d : empty_array_1.EMPTY_ARRAY),
83
84
  hasOnAdd
84
85
  ? {
85
86
  label: (react_1.default.createElement(react_1.default.Fragment, null,
@@ -125,12 +126,12 @@ const GridPageComponent = (props) => {
125
126
  : undefined);
126
127
  return (react_1.default.createElement(Layout, { key: props.entityAlias, title: (_j = (_g = props.title) !== null && _g !== void 0 ? _g : (_h = props.metaSchema) === null || _h === void 0 ? void 0 : _h.title) !== null && _j !== void 0 ? _j : "" },
127
128
  react_1.default.createElement("div", { className: "mb-10" },
128
- react_1.default.createElement(data_grid_1.DataGrid, { state: state, actions: actions, data: data, isLoading: isLoading, error: error, onReload: onReload, noBorder: true, actionCell: actionCell, schema: props.gridSchema, gridName: props.entityAlias, rowHeight: props.rowHeight, customActions: cActions, onCsvDownload: (r) => window.open(`/api/cms/datagrid/export/${props.entityAlias}?${(0, qs_1.stringify)(r)}`), isRowSelectable: props.selectable, bodyCells: (_k = props.ui) === null || _k === void 0 ? void 0 : _k.BodyCells, filterHandlers: (_l = props.ui) === null || _l === void 0 ? void 0 : _l.FilterHandlers, SelectedRowsToolbarActions: (_m = props.ui) === null || _m === void 0 ? void 0 : _m.SelectedRowsToolbarActions, NoRowsFallback: (_o = props.ui) === null || _o === void 0 ? void 0 : _o.NoRowsFallback }))));
129
+ react_1.default.createElement(data_grid_1.DataGrid, { NoRowsFallback: (_k = props.ui) === null || _k === void 0 ? void 0 : _k.NoRowsFallback, SelectedRowsToolbarActions: (_l = props.ui) === null || _l === void 0 ? void 0 : _l.SelectedRowsToolbarActions, actionCell: actionCell, actions: actions, bodyCells: (_m = props.ui) === null || _m === void 0 ? void 0 : _m.BodyCells, customActions: cActions, data: data, error: error, filterHandlers: (_o = props.ui) === null || _o === void 0 ? void 0 : _o.FilterHandlers, gridName: props.entityAlias, isLoading: isLoading, isRowSelectable: props.selectable, noBorder: true, onCsvDownload: (r) => window.open(`/api/cms/datagrid/export/${props.entityAlias}?${(0, qs_1.stringify)(r)}`), onReload: onReload, rowHeight: props.rowHeight, schema: props.gridSchema, state: state }))));
129
130
  };
130
131
  GridPageComponent.displayName = "GridPageComponent";
131
132
  const GridPage = (config) => {
132
133
  const Component = (props) => {
133
- return (react_1.default.createElement(GridPageComponent, { ...props, AddIcon: config.AddIcon, customActions: config.customActions, getEditUrl: config.getEditUrl, getOpenUrl: config.getOpenUrl, loader: config.loader, onAdd: config.onAdd, onAddTitle: config.onAddTitle, onEdit: config.onEdit, onOpen: config.onOpen, onRemove: config.onRemove, rowHeight: config.rowHeight, selectable: config.selectable, title: config.title, ui: config.ui, initialUserConfig: config.initialUserConfig }));
134
+ return (react_1.default.createElement(GridPageComponent, { ...props, AddIcon: config.AddIcon, customActions: config.customActions, getEditUrl: config.getEditUrl, getOpenUrl: config.getOpenUrl, initialUserConfig: config.initialUserConfig, loader: config.loader, onAdd: config.onAdd, onAddTitle: config.onAddTitle, onEdit: config.onEdit, onOpen: config.onOpen, onRemove: config.onRemove, rowHeight: config.rowHeight, selectable: config.selectable, title: config.title, ui: config.ui }));
134
135
  };
135
136
  Component.getInitialProps = async (ctx) => {
136
137
  const entityAlias = typeof config.entityAlias === "function" ? config.entityAlias(ctx) : config.entityAlias;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Nullish } from "@uxf/core/types";
3
2
  import { ActionCellComponent, DataGridProps, DataGridUserConfig, Loader, Schema } from "@uxf/data-grid";
4
3
  import { NextPageContext } from "next";
@@ -6,10 +5,21 @@ import { ParsedUrlQuery } from "querystring";
6
5
  import { FC, ReactElement } from "react";
7
6
  import { EntityMetaSchema } from "../../api";
8
7
  import { LayoutProps } from "../../lib/layout";
9
- export type LayoutComponent = FC<LayoutProps>;
10
8
  export type ActionsBag = {
11
9
  reload: () => void;
12
10
  };
11
+ export type LayoutComponent = FC<LayoutProps>;
12
+ type UIComponents = {
13
+ BodyCells?: DataGridProps<any, any>["bodyCells"];
14
+ FilterHandlers?: DataGridProps<any, any>["filterHandlers"];
15
+ NoRowsFallback?: DataGridProps<any, any>["NoRowsFallback"];
16
+ SelectedRowsToolbarActions?: DataGridProps<any, any>["SelectedRowsToolbarActions"];
17
+ Layout?: LayoutComponent;
18
+ actionCell?: {
19
+ Component: ActionCellComponent<any>;
20
+ width: number;
21
+ };
22
+ };
13
23
  export type GridPageComponentProps = {
14
24
  ui?: UIComponents;
15
25
  entityAlias: string;
@@ -33,17 +43,6 @@ export type GridPageComponentProps = {
33
43
  initialUserConfig?: DataGridUserConfig<any> | Nullish;
34
44
  };
35
45
  export type EntityAliasExtractor = (ctx: NextPageContext) => string;
36
- type UIComponents = {
37
- BodyCells?: DataGridProps<any, any>["bodyCells"];
38
- FilterHandlers?: DataGridProps<any, any>["filterHandlers"];
39
- NoRowsFallback?: DataGridProps<any, any>["NoRowsFallback"];
40
- SelectedRowsToolbarActions?: DataGridProps<any, any>["SelectedRowsToolbarActions"];
41
- Layout?: LayoutComponent;
42
- actionCell?: {
43
- Component: ActionCellComponent<any>;
44
- width: number;
45
- };
46
- };
47
46
  export type GridPageConfig<T extends object = any> = {
48
47
  ui?: UIComponents;
49
48
  title?: string;
@@ -49,7 +49,7 @@ const LoginPage = (config) => {
49
49
  config_1.container.get("service.error").handleError(e);
50
50
  }
51
51
  }, [props.redirectUrl]);
52
- return (react_1.default.createElement(login_layout_1.LoginLayout, { hideTitle: (_a = config.ui) === null || _a === void 0 ? void 0 : _a.hideTitle, Logo: (_b = config.ui) === null || _b === void 0 ? void 0 : _b.Logo, pageTitle: config.pageTitle, title: config.title, subTitle: config.subTitle },
52
+ return (react_1.default.createElement(login_layout_1.LoginLayout, { Logo: (_a = config.ui) === null || _a === void 0 ? void 0 : _a.Logo, hideTitle: (_b = config.ui) === null || _b === void 0 ? void 0 : _b.hideTitle, pageTitle: config.pageTitle, subTitle: config.subTitle, title: config.title },
53
53
  react_1.default.createElement(login_form_1.LoginForm, { defaultValues: INITIAL_VALUES, onForgottenPassword: config.onForgottenPassword, onSubmit: onLogin })));
54
54
  };
55
55
  Component.getInitialProps = async (ctx) => {
@@ -66,6 +66,7 @@ const LoginPage = (config) => {
66
66
  else {
67
67
  await router_1.default.push(config.loggedUserRedirectUrl);
68
68
  }
69
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
69
70
  }
70
71
  catch (e) {
71
72
  // do nothing
@@ -38,7 +38,7 @@ const RenewPasswordPage = (config) => {
38
38
  const onSubmit = (0, react_1.useCallback)(async (values) => {
39
39
  await config.onSubmit(props.token, values);
40
40
  }, [props.token]);
41
- return (react_1.default.createElement(login_layout_1.LoginLayout, { title: config.title, pageTitle: config.pageTitle, Logo: (_a = config.ui) === null || _a === void 0 ? void 0 : _a.Logo },
41
+ return (react_1.default.createElement(login_layout_1.LoginLayout, { Logo: (_a = config.ui) === null || _a === void 0 ? void 0 : _a.Logo, pageTitle: config.pageTitle, title: config.title },
42
42
  react_1.default.createElement(renew_password_form_1.RenewPasswordForm, { defaultValues: INITIAL_VALUES, onSubmit: onSubmit, passwordRules: config.passwordRules })));
43
43
  };
44
44
  Component.getInitialProps = async (ctx) => {
@@ -3,10 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.useLoggedUser = void 0;
6
+ exports.useLoggedUser = useLoggedUser;
7
7
  const swr_1 = __importDefault(require("swr"));
8
8
  function useLoggedUser() {
9
9
  const { data, error, isLoading } = (0, swr_1.default)("/api/cms/user");
10
10
  return { data: data === null || data === void 0 ? void 0 : data.user, error, isLoading };
11
11
  }
12
- exports.useLoggedUser = useLoggedUser;
@@ -1,17 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAvatarUserLetters = void 0;
3
+ exports.getAvatarUserLetters = getAvatarUserLetters;
4
+ const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
4
5
  function getAvatarUserLetters(name) {
5
6
  let letters = name
6
7
  .split(" ")
7
8
  .slice(0, 2)
8
9
  .filter((i) => i);
9
- if (letters.length === 1) {
10
- letters = letters[0].slice(0, 2);
10
+ const firstLetter = letters.at(0);
11
+ if ((0, is_not_nil_1.isNotNil)(firstLetter)) {
12
+ letters = firstLetter.slice(0, 2);
11
13
  }
12
14
  else {
13
15
  letters = letters.map((i) => i.slice(0, 1)).join("");
14
16
  }
15
17
  return letters.toUpperCase();
16
18
  }
17
- exports.getAvatarUserLetters = getAvatarUserLetters;