@uxf/cms 10.0.10 → 11.0.0-beta.1
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.
@@ -22,10 +22,10 @@ export declare function useSubMenu(options: SubMenuOptions): {
|
|
22
22
|
floating: HTMLElement | null;
|
23
23
|
} & import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
|
24
24
|
context: {
|
25
|
-
x: number;
|
26
|
-
y: number;
|
27
25
|
placement: import("@floating-ui/utils").Placement;
|
28
26
|
strategy: import("@floating-ui/utils").Strategy;
|
27
|
+
x: number;
|
28
|
+
y: number;
|
29
29
|
middlewareData: import("@floating-ui/core").MiddlewareData;
|
30
30
|
isPositioned: boolean;
|
31
31
|
update: () => void;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uxf/cms",
|
3
|
-
"version": "
|
3
|
+
"version": "11.0.0-beta.1",
|
4
4
|
"description": "UXF Cms",
|
5
5
|
"author": "UXFans <dev@uxf.cz>",
|
6
6
|
"homepage": "https://gitlab.com/uxf-npm/cms#readme",
|
@@ -31,7 +31,7 @@
|
|
31
31
|
"@floating-ui/react": "0.26.0",
|
32
32
|
"@redux-devtools/extension": "3.2.5",
|
33
33
|
"@uxf/core": "10.0.0",
|
34
|
-
"@uxf/data-grid": "
|
34
|
+
"@uxf/data-grid": "11.0.0-beta.1",
|
35
35
|
"@uxf/form": "10.0.9",
|
36
36
|
"@uxf/router": "10.0.0",
|
37
37
|
"@uxf/ui": "10.0.7",
|
@@ -28,7 +28,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
29
|
exports.GridPage = exports.dataGridLoader = void 0;
|
30
30
|
const data_grid_1 = require("@uxf/data-grid");
|
31
|
-
const
|
31
|
+
const use_data_grid_control_1 = require("@uxf/data-grid/use-data-grid-control");
|
32
|
+
const use_data_grid_fetching_1 = require("@uxf/data-grid/use-data-grid-fetching");
|
32
33
|
const router_1 = require("@uxf/router");
|
33
34
|
const context_1 = require("@uxf/ui/context");
|
34
35
|
const icon_1 = require("@uxf/ui/icon");
|
@@ -41,7 +42,6 @@ const config_1 = require("../../config");
|
|
41
42
|
const with_authenticate_1 = require("../../deprecated/hoc/with-authenticate");
|
42
43
|
const api_2 = require("../../lib/api");
|
43
44
|
const get_initial_props_helper_1 = require("./get-initial-props-helper");
|
44
|
-
const use_hidden_columns_1 = require("./use-hidden-columns");
|
45
45
|
const { axiosRequest } = (0, api_2.createAxiosInstance)();
|
46
46
|
const dataGridLoader = (gridName, request) => {
|
47
47
|
return axiosRequest(null, `/api/cms/datagrid/${gridName}`, "get", null, request).then((r) => r.data);
|
@@ -49,13 +49,11 @@ const dataGridLoader = (gridName, request) => {
|
|
49
49
|
exports.dataGridLoader = dataGridLoader;
|
50
50
|
const DefaultLayout = (props) => react_1.default.createElement("div", { ...props });
|
51
51
|
const GridPageComponent = (props) => {
|
52
|
-
var _a, _b;
|
52
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
53
53
|
// eslint-disable-next-line react/destructuring-assignment
|
54
|
-
const {
|
55
|
-
const
|
56
|
-
const
|
57
|
-
const { Layout = DefaultLayout, ...dataGridUi } = ui;
|
58
|
-
const uiContextValues = (0, react_1.useContext)(context_1.UiContext);
|
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;
|
55
|
+
const Layout = (_b = (_a = props.ui) === null || _a === void 0 ? void 0 : _a.Layout) !== null && _b !== void 0 ? _b : DefaultLayout;
|
56
|
+
const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)(props.gridSchema, query.filter ? (0, router_1.queryParamToString)(query.filter) : undefined);
|
59
57
|
const universalLoader = (0, react_1.useCallback)((gridName, request, encodedRequest) => {
|
60
58
|
var _a, _b;
|
61
59
|
const response = (0, exports.dataGridLoader)(gridName !== null && gridName !== void 0 ? gridName : "", request);
|
@@ -65,10 +63,11 @@ const GridPageComponent = (props) => {
|
|
65
63
|
router_2.default.replace(`${(0, url_1.parse)(((_a = window.history.state) === null || _a === void 0 ? void 0 : _a.url) || "").pathname}?${(0, qs_1.stringify)(newQuery)}`, `${(0, url_1.parse)(((_b = window.history.state) === null || _b === void 0 ? void 0 : _b.as) || "").pathname}?${(0, qs_1.stringify)(newQuery)}`, { shallow: true });
|
66
64
|
return response;
|
67
65
|
}, [query]);
|
68
|
-
const
|
66
|
+
const { data, isLoading, error, onReload } = (0, use_data_grid_fetching_1.useDataGridFetching)((_c = props.loader) !== null && _c !== void 0 ? _c : universalLoader, props.gridSchema, (_e = (_d = props.metaSchema) === null || _d === void 0 ? void 0 : _d.entityAlias) !== null && _e !== void 0 ? _e : "", state);
|
67
|
+
const uiContextValues = (0, react_1.useContext)(context_1.UiContext);
|
69
68
|
const actionsBag = (0, react_1.useMemo)(() => ({
|
70
|
-
reload:
|
71
|
-
}), [
|
69
|
+
reload: onReload,
|
70
|
+
}), [onReload]);
|
72
71
|
const hasOnAdd = onAdd && (!metaSchema || metaSchema.actions.includes("add"));
|
73
72
|
const cActions = [
|
74
73
|
...customActions,
|
@@ -82,14 +81,14 @@ const GridPageComponent = (props) => {
|
|
82
81
|
}
|
83
82
|
: undefined,
|
84
83
|
].filter(Boolean);
|
85
|
-
return (react_1.default.createElement(Layout, { key: entityAlias, title: (
|
84
|
+
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 : "" },
|
86
85
|
react_1.default.createElement("div", { className: "mb-10" },
|
87
|
-
react_1.default.createElement(
|
86
|
+
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 }))));
|
88
87
|
};
|
89
88
|
GridPageComponent.displayName = "GridPageComponent";
|
90
89
|
const GridPage = (config) => {
|
91
90
|
const Component = (props) => {
|
92
|
-
return (react_1.default.createElement(GridPageComponent, { ...props, AddIcon: config.AddIcon, customActions: config.customActions,
|
91
|
+
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 }));
|
93
92
|
};
|
94
93
|
Component.getInitialProps = async (ctx) => {
|
95
94
|
const entityAlias = typeof config.entityAlias === "function" ? config.entityAlias(ctx) : config.entityAlias;
|
@@ -25,7 +25,6 @@ export type GridPageComponentProps = {
|
|
25
25
|
gridSchema: Schema<any>;
|
26
26
|
metaSchema?: EntityMetaSchema;
|
27
27
|
rowHeight?: DataGridProps<any, any>["rowHeight"];
|
28
|
-
defaultConfig?: DataGridProps<any, any>["defaultConfig"];
|
29
28
|
AddIcon?: ReactElement;
|
30
29
|
onAddTitle?: string;
|
31
30
|
selectable?: boolean;
|
@@ -48,7 +47,6 @@ export type GridPageConfig<T extends object = any> = {
|
|
48
47
|
allowedRoles?: string[];
|
49
48
|
loader?: Loader;
|
50
49
|
rowHeight?: DataGridProps<any, any>["rowHeight"];
|
51
|
-
defaultConfig?: DataGridProps<any, any>["defaultConfig"];
|
52
50
|
AddIcon?: ReactElement;
|
53
51
|
onAddTitle?: string;
|
54
52
|
selectable?: boolean;
|