@compill/admin 1.0.71 → 1.0.73
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/index.cjs.js +41 -24
- package/index.esm.js +41 -24
- package/package.json +1 -1
- package/src/lib/json/DetailsView.d.ts +1 -1
- package/src/lib/json/types/DetailsView.d.ts +7 -3
package/index.cjs.js
CHANGED
@@ -18,10 +18,10 @@ var react = require('@soperio/react');
|
|
18
18
|
var editor = require('@compill/editor');
|
19
19
|
var admin = require('@compill/admin');
|
20
20
|
var reactDom = require('react-dom');
|
21
|
+
var router = require('next/router');
|
21
22
|
var table = require('@compill/table');
|
22
23
|
var hooks = require('@compill/hooks');
|
23
24
|
var env = require('@compill/env');
|
24
|
-
var router = require('next/router');
|
25
25
|
var reactQuery = require('@tanstack/react-query');
|
26
26
|
var Image = require('next/image');
|
27
27
|
|
@@ -938,12 +938,7 @@ function PageSidebarSection(_a) {
|
|
938
938
|
} = _a,
|
939
939
|
props = __rest$1(_a, ["title", "children"]);
|
940
940
|
return jsxRuntime.jsxs("div", Object.assign({
|
941
|
-
w: "full"
|
942
|
-
bgColor: "white",
|
943
|
-
rounded: "lg",
|
944
|
-
p: "5",
|
945
|
-
textSize: "sm",
|
946
|
-
shadow: true
|
941
|
+
w: "full"
|
947
942
|
}, props, {
|
948
943
|
children: [title && jsxRuntime.jsx(admin.PageSectionTitle, {
|
949
944
|
children: title
|
@@ -1135,18 +1130,27 @@ function Buttons$1({
|
|
1135
1130
|
});
|
1136
1131
|
}
|
1137
1132
|
|
1133
|
+
function useQueryField(queryField, useNextRouter) {
|
1134
|
+
if (useNextRouter) {
|
1135
|
+
const router$1 = router.useRouter();
|
1136
|
+
return router$1.query[queryField];
|
1137
|
+
}
|
1138
|
+
const {
|
1139
|
+
[queryField]: id
|
1140
|
+
} = reactRouterDom.useParams();
|
1141
|
+
return id;
|
1142
|
+
}
|
1138
1143
|
function DetailsView(_a) {
|
1139
1144
|
var {
|
1140
1145
|
queryField,
|
1141
1146
|
api,
|
1147
|
+
useNextRouter,
|
1142
1148
|
processInput,
|
1143
1149
|
screen,
|
1144
1150
|
tabbed
|
1145
1151
|
} = _a,
|
1146
|
-
props = __rest$1(_a, ["queryField", "api", "processInput", "screen", "tabbed"]);
|
1147
|
-
const
|
1148
|
-
[queryField]: id
|
1149
|
-
} = reactRouterDom.useParams();
|
1152
|
+
props = __rest$1(_a, ["queryField", "api", "useNextRouter", "processInput", "screen", "tabbed"]);
|
1153
|
+
const id = useQueryField(queryField, useNextRouter);
|
1150
1154
|
const ref = React__default["default"].useRef(null);
|
1151
1155
|
return jsxRuntime.jsx(PageQueryStateContainer, Object.assign({
|
1152
1156
|
api: api,
|
@@ -1173,18 +1177,18 @@ function Internal({
|
|
1173
1177
|
tabbed,
|
1174
1178
|
containerRef
|
1175
1179
|
}) {
|
1180
|
+
var _a, _b, _c;
|
1181
|
+
const pScreen = react.runIfFn(screen, item);
|
1176
1182
|
const {
|
1177
1183
|
breadcrumbs,
|
1178
1184
|
schema,
|
1179
1185
|
initialValues,
|
1180
1186
|
header,
|
1181
|
-
editorFooter: editoFooter,
|
1182
1187
|
sections,
|
1183
1188
|
buttonBar,
|
1184
|
-
editor,
|
1185
1189
|
type,
|
1186
1190
|
invalidateParentQueryKey
|
1187
|
-
} =
|
1191
|
+
} = pScreen;
|
1188
1192
|
const mutation = api.useInvalidateParentMutation(api$1.update, invalidateParentQueryKey !== null && invalidateParentQueryKey !== void 0 ? invalidateParentQueryKey : api$1.queryKey, {
|
1189
1193
|
networkMode: "always"
|
1190
1194
|
});
|
@@ -1214,7 +1218,10 @@ function Internal({
|
|
1214
1218
|
item: item,
|
1215
1219
|
isLoading: mutation.isLoading,
|
1216
1220
|
trackingRef: containerRef === null || containerRef === void 0 ? void 0 : containerRef.current
|
1217
|
-
}), jsxRuntime.jsx(
|
1221
|
+
}), type == "form" && (sections === null || sections === void 0 ? void 0 : sections.map((section, index) => jsxRuntime.jsx(Section, {
|
1222
|
+
section: section,
|
1223
|
+
item: item
|
1224
|
+
}, index))), (pScreen.type == "post" || pScreen.type == "section") && jsxRuntime.jsx("div", {
|
1218
1225
|
p: "5",
|
1219
1226
|
bgColor: "slate-100",
|
1220
1227
|
rounded: "lg",
|
@@ -1230,7 +1237,7 @@ function Internal({
|
|
1230
1237
|
flexCol: true,
|
1231
1238
|
gap: "8",
|
1232
1239
|
flexGrow: true,
|
1233
|
-
children: [(editor === null ||
|
1240
|
+
children: [((_a = pScreen.editor) === null || _a === void 0 ? void 0 : _a.type) != "textarea" &&
|
1234
1241
|
// TODO Find a way to make this editor shrink in width when resizing the window...
|
1235
1242
|
jsxRuntime.jsx(PageContentEditor, {
|
1236
1243
|
name: "content",
|
@@ -1238,8 +1245,8 @@ function Internal({
|
|
1238
1245
|
minW: "144",
|
1239
1246
|
shadow: true,
|
1240
1247
|
rounded: "lg"
|
1241
|
-
}), (editor === null ||
|
1242
|
-
name: editor === null ||
|
1248
|
+
}), ((_b = pScreen.editor) === null || _b === void 0 ? void 0 : _b.type) == "textarea" && jsxRuntime.jsx(form.TextArea, {
|
1249
|
+
name: (_c = pScreen.editor) === null || _c === void 0 ? void 0 : _c.name,
|
1243
1250
|
maxW: editorMaxW,
|
1244
1251
|
minW: editorMaxW,
|
1245
1252
|
w: editorMaxW,
|
@@ -1250,11 +1257,12 @@ function Internal({
|
|
1250
1257
|
shadow: true,
|
1251
1258
|
p: "5",
|
1252
1259
|
textColor: "slate-800"
|
1253
|
-
}),
|
1260
|
+
}), pScreen.editorFooter]
|
1254
1261
|
}), jsxRuntime.jsx(PageSidebar, {
|
1255
1262
|
children: sections === null || sections === void 0 ? void 0 : sections.map((section, index) => jsxRuntime.jsx(Section, {
|
1256
1263
|
section: section,
|
1257
|
-
item: item
|
1264
|
+
item: item,
|
1265
|
+
cardStyle: true
|
1258
1266
|
}, index))
|
1259
1267
|
})]
|
1260
1268
|
})]
|
@@ -1264,15 +1272,24 @@ function Internal({
|
|
1264
1272
|
}
|
1265
1273
|
function Section({
|
1266
1274
|
section,
|
1267
|
-
item
|
1275
|
+
item,
|
1276
|
+
cardStyle
|
1268
1277
|
}) {
|
1269
1278
|
if (section.type === "section") {
|
1270
|
-
|
1271
|
-
|
1279
|
+
const style = cardStyle ? {
|
1280
|
+
bgColor: "white",
|
1281
|
+
rounded: "lg",
|
1282
|
+
p: "5",
|
1283
|
+
textSize: "sm",
|
1284
|
+
shadow: true
|
1285
|
+
} : {};
|
1286
|
+
return jsxRuntime.jsx(PageSidebarSection, Object.assign({
|
1287
|
+
title: section.title
|
1288
|
+
}, style, {
|
1272
1289
|
children: jsxRuntime.jsx(form.FormRenderer, {
|
1273
1290
|
form: react.runIfFn(section.form, item)
|
1274
1291
|
})
|
1275
|
-
});
|
1292
|
+
}));
|
1276
1293
|
}
|
1277
1294
|
if (section.type === "custom") return react.runIfFn(section.component, item);
|
1278
1295
|
return null;
|
package/index.esm.js
CHANGED
@@ -14,10 +14,10 @@ import { createContext as createContext$1, runIfFn, isFunction } from '@soperio/
|
|
14
14
|
import { Editor } from '@compill/editor';
|
15
15
|
import { PageSectionTitle as PageSectionTitle$1, ButtonBarDialogButton as ButtonBarDialogButton$1, TableRowActionButton as TableRowActionButton$1, DialogButton as DialogButton$1 } from '@compill/admin';
|
16
16
|
import { createPortal } from 'react-dom';
|
17
|
+
import { useRouter } from 'next/router';
|
17
18
|
import { TableContextProvider, useTableContext, Table } from '@compill/table';
|
18
19
|
import { useOpenLink, useBoolean } from '@compill/hooks';
|
19
20
|
import { Env } from '@compill/env';
|
20
|
-
import { useRouter } from 'next/router';
|
21
21
|
import { useQueryClient } from '@tanstack/react-query';
|
22
22
|
import Image from 'next/image';
|
23
23
|
|
@@ -928,12 +928,7 @@ function PageSidebarSection(_a) {
|
|
928
928
|
} = _a,
|
929
929
|
props = __rest$1(_a, ["title", "children"]);
|
930
930
|
return jsxs("div", Object.assign({
|
931
|
-
w: "full"
|
932
|
-
bgColor: "white",
|
933
|
-
rounded: "lg",
|
934
|
-
p: "5",
|
935
|
-
textSize: "sm",
|
936
|
-
shadow: true
|
931
|
+
w: "full"
|
937
932
|
}, props, {
|
938
933
|
children: [title && jsx(PageSectionTitle$1, {
|
939
934
|
children: title
|
@@ -1125,18 +1120,27 @@ function Buttons$1({
|
|
1125
1120
|
});
|
1126
1121
|
}
|
1127
1122
|
|
1123
|
+
function useQueryField(queryField, useNextRouter) {
|
1124
|
+
if (useNextRouter) {
|
1125
|
+
const router = useRouter();
|
1126
|
+
return router.query[queryField];
|
1127
|
+
}
|
1128
|
+
const {
|
1129
|
+
[queryField]: id
|
1130
|
+
} = useParams();
|
1131
|
+
return id;
|
1132
|
+
}
|
1128
1133
|
function DetailsView(_a) {
|
1129
1134
|
var {
|
1130
1135
|
queryField,
|
1131
1136
|
api,
|
1137
|
+
useNextRouter,
|
1132
1138
|
processInput,
|
1133
1139
|
screen,
|
1134
1140
|
tabbed
|
1135
1141
|
} = _a,
|
1136
|
-
props = __rest$1(_a, ["queryField", "api", "processInput", "screen", "tabbed"]);
|
1137
|
-
const
|
1138
|
-
[queryField]: id
|
1139
|
-
} = useParams();
|
1142
|
+
props = __rest$1(_a, ["queryField", "api", "useNextRouter", "processInput", "screen", "tabbed"]);
|
1143
|
+
const id = useQueryField(queryField, useNextRouter);
|
1140
1144
|
const ref = React.useRef(null);
|
1141
1145
|
return jsx(PageQueryStateContainer, Object.assign({
|
1142
1146
|
api: api,
|
@@ -1163,18 +1167,18 @@ function Internal({
|
|
1163
1167
|
tabbed,
|
1164
1168
|
containerRef
|
1165
1169
|
}) {
|
1170
|
+
var _a, _b, _c;
|
1171
|
+
const pScreen = runIfFn(screen, item);
|
1166
1172
|
const {
|
1167
1173
|
breadcrumbs,
|
1168
1174
|
schema,
|
1169
1175
|
initialValues,
|
1170
1176
|
header,
|
1171
|
-
editorFooter: editoFooter,
|
1172
1177
|
sections,
|
1173
1178
|
buttonBar,
|
1174
|
-
editor,
|
1175
1179
|
type,
|
1176
1180
|
invalidateParentQueryKey
|
1177
|
-
} =
|
1181
|
+
} = pScreen;
|
1178
1182
|
const mutation = useInvalidateParentMutation(api.update, invalidateParentQueryKey !== null && invalidateParentQueryKey !== void 0 ? invalidateParentQueryKey : api.queryKey, {
|
1179
1183
|
networkMode: "always"
|
1180
1184
|
});
|
@@ -1204,7 +1208,10 @@ function Internal({
|
|
1204
1208
|
item: item,
|
1205
1209
|
isLoading: mutation.isLoading,
|
1206
1210
|
trackingRef: containerRef === null || containerRef === void 0 ? void 0 : containerRef.current
|
1207
|
-
}),
|
1211
|
+
}), type == "form" && (sections === null || sections === void 0 ? void 0 : sections.map((section, index) => jsx(Section, {
|
1212
|
+
section: section,
|
1213
|
+
item: item
|
1214
|
+
}, index))), (pScreen.type == "post" || pScreen.type == "section") && jsx("div", {
|
1208
1215
|
p: "5",
|
1209
1216
|
bgColor: "slate-100",
|
1210
1217
|
rounded: "lg",
|
@@ -1220,7 +1227,7 @@ function Internal({
|
|
1220
1227
|
flexCol: true,
|
1221
1228
|
gap: "8",
|
1222
1229
|
flexGrow: true,
|
1223
|
-
children: [(editor === null ||
|
1230
|
+
children: [((_a = pScreen.editor) === null || _a === void 0 ? void 0 : _a.type) != "textarea" &&
|
1224
1231
|
// TODO Find a way to make this editor shrink in width when resizing the window...
|
1225
1232
|
jsx(PageContentEditor, {
|
1226
1233
|
name: "content",
|
@@ -1228,8 +1235,8 @@ function Internal({
|
|
1228
1235
|
minW: "144",
|
1229
1236
|
shadow: true,
|
1230
1237
|
rounded: "lg"
|
1231
|
-
}), (editor === null ||
|
1232
|
-
name: editor === null ||
|
1238
|
+
}), ((_b = pScreen.editor) === null || _b === void 0 ? void 0 : _b.type) == "textarea" && jsx(TextArea, {
|
1239
|
+
name: (_c = pScreen.editor) === null || _c === void 0 ? void 0 : _c.name,
|
1233
1240
|
maxW: editorMaxW,
|
1234
1241
|
minW: editorMaxW,
|
1235
1242
|
w: editorMaxW,
|
@@ -1240,11 +1247,12 @@ function Internal({
|
|
1240
1247
|
shadow: true,
|
1241
1248
|
p: "5",
|
1242
1249
|
textColor: "slate-800"
|
1243
|
-
}),
|
1250
|
+
}), pScreen.editorFooter]
|
1244
1251
|
}), jsx(PageSidebar, {
|
1245
1252
|
children: sections === null || sections === void 0 ? void 0 : sections.map((section, index) => jsx(Section, {
|
1246
1253
|
section: section,
|
1247
|
-
item: item
|
1254
|
+
item: item,
|
1255
|
+
cardStyle: true
|
1248
1256
|
}, index))
|
1249
1257
|
})]
|
1250
1258
|
})]
|
@@ -1254,15 +1262,24 @@ function Internal({
|
|
1254
1262
|
}
|
1255
1263
|
function Section({
|
1256
1264
|
section,
|
1257
|
-
item
|
1265
|
+
item,
|
1266
|
+
cardStyle
|
1258
1267
|
}) {
|
1259
1268
|
if (section.type === "section") {
|
1260
|
-
|
1261
|
-
|
1269
|
+
const style = cardStyle ? {
|
1270
|
+
bgColor: "white",
|
1271
|
+
rounded: "lg",
|
1272
|
+
p: "5",
|
1273
|
+
textSize: "sm",
|
1274
|
+
shadow: true
|
1275
|
+
} : {};
|
1276
|
+
return jsx(PageSidebarSection, Object.assign({
|
1277
|
+
title: section.title
|
1278
|
+
}, style, {
|
1262
1279
|
children: jsx(FormRenderer, {
|
1263
1280
|
form: runIfFn(section.form, item)
|
1264
1281
|
})
|
1265
|
-
});
|
1282
|
+
}));
|
1266
1283
|
}
|
1267
1284
|
if (section.type === "custom") return runIfFn(section.component, item);
|
1268
1285
|
return null;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { SoperioComponent } from "@soperio/react";
|
3
3
|
import { DetailsViewConfig } from "./types/DetailsView";
|
4
|
-
export declare function DetailsView({ queryField, api, processInput, screen, tabbed, ...props }: DetailsViewConfig & {
|
4
|
+
export declare function DetailsView({ queryField, api, useNextRouter, processInput, screen, tabbed, ...props }: DetailsViewConfig & {
|
5
5
|
tabbed?: boolean;
|
6
6
|
} & SoperioComponent): JSX.Element;
|
@@ -7,6 +7,7 @@ export type DetailsViewConfig<T = any> = {
|
|
7
7
|
type: "details";
|
8
8
|
api: API<T>;
|
9
9
|
queryField: string;
|
10
|
+
useNextRouter?: boolean;
|
10
11
|
processInput?: (input: T) => any;
|
11
12
|
screen: Screen | ((data: T) => Screen);
|
12
13
|
};
|
@@ -18,10 +19,13 @@ type Screen = {
|
|
18
19
|
header?: React.ReactNode;
|
19
20
|
sections?: DetailSection[];
|
20
21
|
buttonBar?: DetailViewButton[];
|
22
|
+
} & ({
|
23
|
+
type: "form";
|
24
|
+
} | {
|
25
|
+
type?: "post" | "section";
|
21
26
|
editor?: DetailEditor;
|
22
27
|
editorFooter?: React.ReactNode;
|
23
|
-
|
24
|
-
};
|
28
|
+
});
|
25
29
|
type DetailEditor = {
|
26
30
|
type?: "blockEditor";
|
27
31
|
name: string;
|
@@ -31,7 +35,7 @@ type DetailEditor = {
|
|
31
35
|
};
|
32
36
|
export type DetailSection = {
|
33
37
|
type: "section";
|
34
|
-
title
|
38
|
+
title?: string;
|
35
39
|
form: FormRendererConfig | ((item: any) => FormRendererConfig);
|
36
40
|
} | {
|
37
41
|
type: "custom";
|