@uxf/cms 11.0.0-beta.9 → 11.1.0

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/api/index.d.ts CHANGED
@@ -154,6 +154,10 @@ export declare function saveFormValues<T extends Record<string, any>>(ctx: any,
154
154
  entityAlias: string;
155
155
  id?: number | null;
156
156
  }, body: T): Promise<import("axios").AxiosResponse<T, any>>;
157
+ export declare function removeEntity(ctx: any, path: {
158
+ entityAlias: string;
159
+ id: number;
160
+ }): Promise<import("axios").AxiosResponse<undefined, any>>;
157
161
  export declare function userConfigSave(name: string, data: any): Promise<import("axios").AxiosResponse<UserConfigBagResponse, any>>;
158
162
  export declare function userConfigGetAll(ctx: any): Promise<import("axios").AxiosResponse<UserConfigBagResponse, any>>;
159
163
  export declare function userConfigGet<T>(ctx: any, name: string, defaultValue?: T): Promise<T | undefined>;
package/api/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uploadFile = exports.userConfigGet = exports.userConfigGetAll = exports.userConfigSave = exports.saveFormValues = exports.autocomplete = exports.login = exports.getFormValues = exports.getFormSchema = exports.getEntityMetaSchemas = exports.getLoggedUser = exports.forgottenPassword = exports.dataGridAutocompleteGet = exports.dataGridSchemaGet = exports.contentUpdate = exports.contentCreate = exports.contentGet = void 0;
3
+ exports.uploadFile = exports.userConfigGet = exports.userConfigGetAll = exports.userConfigSave = exports.removeEntity = exports.saveFormValues = exports.autocomplete = exports.login = exports.getFormValues = exports.getFormSchema = exports.getEntityMetaSchemas = exports.getLoggedUser = exports.forgottenPassword = exports.dataGridAutocompleteGet = exports.dataGridSchemaGet = exports.contentUpdate = exports.contentCreate = exports.contentGet = void 0;
4
4
  // eslint-disable-next-line import/no-cycle
5
5
  const api_1 = require("../lib/api");
6
6
  const { axiosRequest, axiosInstance } = (0, api_1.createAxiosInstance)();
@@ -58,6 +58,10 @@ function saveFormValues(ctx, path, body) {
58
58
  : axiosRequest(ctx, `/api/cms/form/${path.entityAlias}`, "post", body, null);
59
59
  }
60
60
  exports.saveFormValues = saveFormValues;
61
+ function removeEntity(ctx, path) {
62
+ return axiosRequest(ctx, `/api/cms/form/${path.entityAlias}/${path.id}`, "delete", null, null);
63
+ }
64
+ exports.removeEntity = removeEntity;
61
65
  async function userConfigSave(name, data) {
62
66
  return axiosRequest(null, "/api/cms/user-config", "post", { name, data }, null);
63
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/cms",
3
- "version": "11.0.0-beta.9",
3
+ "version": "11.1.0",
4
4
  "description": "UXF Cms",
5
5
  "author": "UXFans <dev@uxf.cz>",
6
6
  "homepage": "https://gitlab.com/uxf-npm/cms#readme",
@@ -30,12 +30,12 @@
30
30
  "@dnd-kit/utilities": "3.2.1",
31
31
  "@floating-ui/react": "0.26.0",
32
32
  "@redux-devtools/extension": "3.2.5",
33
- "@uxf/core": "10.0.0",
34
- "@uxf/data-grid": "11.0.0-beta.9",
35
- "@uxf/form": "10.0.9",
33
+ "@uxf/core": "10.10.1",
34
+ "@uxf/data-grid": "11.1.0",
35
+ "@uxf/form": "11.1.0",
36
36
  "@uxf/router": "10.0.0",
37
- "@uxf/ui": "10.0.7",
38
- "@uxf/wysiwyg": "10.0.10",
37
+ "@uxf/ui": "11.1.0",
38
+ "@uxf/wysiwyg": "11.1.0",
39
39
  "axios": "1.5.1",
40
40
  "axios-hooks": "5.0.0",
41
41
  "es6-error": "4.1.1",
@@ -45,13 +45,11 @@
45
45
  "redux": "4.2.1"
46
46
  },
47
47
  "peerDependencies": {
48
- "@next/font": ">=12",
49
- "next": ">=12",
48
+ "next": ">=13.2.0",
50
49
  "react": ">=18.2.0",
51
50
  "react-dom": ">=18.2.0"
52
51
  },
53
52
  "devDependencies": {
54
- "@next/font": "13.5.4",
55
53
  "@types/node": "18.18.4",
56
54
  "@types/qs": "6.9.8",
57
55
  "@types/react": "18.2.27",
@@ -27,11 +27,13 @@ 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 buildArray_1 = require("@uxf/core/utils/buildArray");
31
+ const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
30
32
  const data_grid_1 = require("@uxf/data-grid");
33
+ const table_1 = require("@uxf/data-grid/table");
31
34
  const use_data_grid_control_1 = require("@uxf/data-grid/use-data-grid-control");
32
35
  const use_data_grid_fetching_1 = require("@uxf/data-grid/use-data-grid-fetching");
33
36
  const router_1 = require("@uxf/router");
34
- const context_1 = require("@uxf/ui/context");
35
37
  const icon_1 = require("@uxf/ui/icon");
36
38
  const router_2 = __importDefault(require("next/router"));
37
39
  const qs_1 = require("qs");
@@ -49,9 +51,9 @@ const dataGridLoader = (gridName, request) => {
49
51
  exports.dataGridLoader = dataGridLoader;
50
52
  const DefaultLayout = (props) => react_1.default.createElement("div", { ...props });
51
53
  const GridPageComponent = (props) => {
52
- var _a, _b, _c, _d, _e, _f, _g, _h;
54
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
53
55
  // eslint-disable-next-line react/destructuring-assignment
54
- const { metaSchema, entityAlias, gridSchema, getOpenUrl, getEditUrl, onOpen, onAdd, onEdit, onRemove, query, rowHeight, AddIcon = react_1.default.createElement(icon_1.Icon, { name: "plus" }), onAddTitle = "Přidat záznam", customActions = [], } = props;
56
+ const { query, AddIcon = react_1.default.createElement(icon_1.Icon, { name: "plus" }), onAddTitle = "Přidat záznam" } = props;
55
57
  const Layout = (_b = (_a = props.ui) === null || _a === void 0 ? void 0 : _a.Layout) !== null && _b !== void 0 ? _b : DefaultLayout;
56
58
  const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)({
57
59
  schema: props.gridSchema,
@@ -72,26 +74,58 @@ const GridPageComponent = (props) => {
72
74
  gridName: (_e = (_d = props.metaSchema) === null || _d === void 0 ? void 0 : _d.entityAlias) !== null && _e !== void 0 ? _e : "",
73
75
  state,
74
76
  });
75
- const uiContextValues = (0, react_1.useContext)(context_1.UiContext);
76
77
  const actionsBag = (0, react_1.useMemo)(() => ({
77
78
  reload: onReload,
78
79
  }), [onReload]);
79
- const hasOnAdd = onAdd && (!metaSchema || metaSchema.actions.includes("add"));
80
+ const hasOnAdd = props.onAdd && (!props.metaSchema || props.metaSchema.actions.includes("add"));
80
81
  const cActions = [
81
- ...customActions,
82
+ ...((_f = props.customActions) !== null && _f !== void 0 ? _f : []),
82
83
  hasOnAdd
83
84
  ? {
84
85
  label: (react_1.default.createElement(react_1.default.Fragment, null,
85
86
  AddIcon,
86
87
  "\u00A0",
87
88
  onAddTitle)),
88
- onClick: () => onAdd(entityAlias, actionsBag),
89
+ onClick: () => { var _a; return (_a = props.onAdd) === null || _a === void 0 ? void 0 : _a.call(props, props.entityAlias, actionsBag); },
89
90
  }
90
91
  : undefined,
91
92
  ].filter(Boolean);
92
- return (react_1.default.createElement(Layout, { key: entityAlias, title: (_g = (_f = props.title) !== null && _f !== void 0 ? _f : metaSchema === null || metaSchema === void 0 ? void 0 : metaSchema.title) !== null && _g !== void 0 ? _g : "" },
93
+ const actionColumnButtonsCount = (props.onEdit || props.getEditUrl ? 1 : 0) +
94
+ (props.onOpen || props.getOpenUrl ? 1 : 0) +
95
+ (props.onRemove ? 1 : 0);
96
+ const actionCell = actionColumnButtonsCount > 0
97
+ ? {
98
+ width: actionColumnButtonsCount * 40,
99
+ Component: (actionCellProps) => {
100
+ var _a, _b, _c, _d, _e, _f;
101
+ const buttons = (0, buildArray_1.buildArray)()
102
+ .when((0, is_not_nil_1.isNotNil)((_a = props.onOpen) !== null && _a !== void 0 ? _a : props.getOpenUrl), {
103
+ icon: "circle-info",
104
+ onClick: () => { var _a; return (_a = props.onOpen) === null || _a === void 0 ? void 0 : _a.call(props, props.entityAlias, actionCellProps.row, actionsBag); },
105
+ href: (_c = (_b = props.getOpenUrl) === null || _b === void 0 ? void 0 : _b.call(props, props.entityAlias, actionCellProps.row)) !== null && _c !== void 0 ? _c : undefined,
106
+ isIconButton: true,
107
+ title: "Detail",
108
+ })
109
+ .when((0, is_not_nil_1.isNotNil)((_d = props.onEdit) !== null && _d !== void 0 ? _d : props.getEditUrl), {
110
+ icon: "pen",
111
+ onClick: () => { var _a; return (_a = props.onEdit) === null || _a === void 0 ? void 0 : _a.call(props, props.entityAlias, actionCellProps.row, actionsBag); },
112
+ href: (_f = (_e = props.getEditUrl) === null || _e === void 0 ? void 0 : _e.call(props, props.entityAlias, actionCellProps.row)) !== null && _f !== void 0 ? _f : undefined,
113
+ isIconButton: true,
114
+ title: "Upravit",
115
+ })
116
+ .when((0, is_not_nil_1.isNotNil)(props.onRemove), {
117
+ icon: "trash",
118
+ onClick: () => { var _a; return (_a = props.onRemove) === null || _a === void 0 ? void 0 : _a.call(props, props.entityAlias, actionCellProps.row, actionsBag); },
119
+ isIconButton: true,
120
+ title: "Smazat",
121
+ });
122
+ return react_1.default.createElement(table_1.ActionCell, { buttons: buttons, visibleButtonsCount: 3 });
123
+ },
124
+ }
125
+ : undefined;
126
+ 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 : "" },
93
127
  react_1.default.createElement("div", { className: "mb-10" },
94
- react_1.default.createElement(data_grid_1.DataGrid, { state: state, actions: actions, data: data, isLoading: isLoading, error: error, onReload: onReload, noBorder: true, schema: gridSchema, gridName: entityAlias, onOpen: onOpen && ((row) => onOpen(entityAlias, row, actionsBag)), getOpenUrl: getOpenUrl && ((row) => getOpenUrl(entityAlias, row)), onEdit: onEdit && ((row) => onEdit(entityAlias, row, actionsBag)), getEditUrl: getEditUrl && ((row) => getEditUrl(entityAlias, row)), onRemove: onRemove && ((row) => onRemove(entityAlias, row, actionsBag)), rowHeight: rowHeight, ui: props.ui, customActions: cActions, mode: (_h = uiContextValues === null || uiContextValues === void 0 ? void 0 : uiContextValues.colorScheme.getUserSettings()) !== null && _h !== void 0 ? _h : "light", onCsvDownload: (r) => window.open(`/api/cms/datagrid/export/${entityAlias}?${(0, qs_1.stringify)(r)}`), isRowSelectable: props.selectable }))));
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 }))));
95
129
  };
96
130
  GridPageComponent.displayName = "GridPageComponent";
97
131
  const GridPage = (config) => {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { DataGridProps, UIComponents as DataGridUIComponents, Loader, Schema } from "@uxf/data-grid";
2
+ import { DataGridProps, Loader, Schema } from "@uxf/data-grid";
3
3
  import { NextPageContext } from "next";
4
4
  import { ParsedUrlQuery } from "querystring";
5
5
  import { FC, ReactElement } from "react";
@@ -31,7 +31,11 @@ export type GridPageComponentProps = {
31
31
  customActions?: DataGridProps<any, any>["customActions"];
32
32
  };
33
33
  export type EntityAliasExtractor = (ctx: NextPageContext) => string;
34
- type UIComponents = Partial<DataGridUIComponents<any, any>> & {
34
+ type UIComponents = {
35
+ BodyCells?: DataGridProps<any, any>["bodyCells"];
36
+ FilterHandlers?: DataGridProps<any, any>["filterHandlers"];
37
+ NoRowsFallback?: DataGridProps<any, any>["NoRowsFallback"];
38
+ SelectedRowsToolbarActions?: DataGridProps<any, any>["SelectedRowsToolbarActions"];
35
39
  Layout?: LayoutComponent;
36
40
  };
37
41
  export type GridPageConfig<T extends object = any> = {
File without changes
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /** @type {import('@uxf/icons-generator/types').Config['icons']} */
2
3
  module.exports = {
3
4
  ...require("@uxf/ui/utils/icons-config"),