@uxf/cms 11.0.0-beta.15 → 11.0.0-beta.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/cms",
3
- "version": "11.0.0-beta.15",
3
+ "version": "11.0.0-beta.17",
4
4
  "description": "UXF Cms",
5
5
  "author": "UXFans <dev@uxf.cz>",
6
6
  "homepage": "https://gitlab.com/uxf-npm/cms#readme",
@@ -31,11 +31,11 @@
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": "11.0.0-beta.15",
35
- "@uxf/form": "10.0.9",
34
+ "@uxf/data-grid": "11.0.0-beta.17",
35
+ "@uxf/form": "11.0.0-beta.17",
36
36
  "@uxf/router": "10.0.0",
37
- "@uxf/ui": "10.0.7",
38
- "@uxf/wysiwyg": "10.0.10",
37
+ "@uxf/ui": "11.0.0-beta.17",
38
+ "@uxf/wysiwyg": "11.0.0-beta.17",
39
39
  "axios": "1.5.1",
40
40
  "axios-hooks": "5.0.0",
41
41
  "es6-error": "4.1.1",
@@ -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> = {