@compill/admin 1.0.90 → 1.0.92
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 +32 -15
- package/index.esm.js +34 -17
- package/package.json +1 -1
- package/src/lib/buttons/ViewButton.d.ts +3 -3
- package/src/lib/json/types/DetailsView.d.ts +2 -0
package/index.cjs.js
CHANGED
|
@@ -1002,21 +1002,30 @@ function UpdateButton(_a) {
|
|
|
1002
1002
|
|
|
1003
1003
|
function ViewButton(_a) {
|
|
1004
1004
|
var {
|
|
1005
|
+
label,
|
|
1005
1006
|
path,
|
|
1006
1007
|
icon
|
|
1007
1008
|
} = _a,
|
|
1008
|
-
props = tslib.__rest(_a, ["path", "icon"]);
|
|
1009
|
+
props = tslib.__rest(_a, ["label", "path", "icon"]);
|
|
1009
1010
|
const openPage = React__default["default"].useCallback(() => {
|
|
1010
1011
|
window.open(path, '_blank');
|
|
1011
1012
|
}, [path]);
|
|
1012
|
-
return jsxRuntime.jsx(
|
|
1013
|
-
icon: icon ? icon : mdiOpenInNew,
|
|
1013
|
+
return jsxRuntime.jsx(admin.ButtonBarButton, Object.assign({
|
|
1014
1014
|
type: "submit",
|
|
1015
1015
|
scheme: "dark",
|
|
1016
1016
|
variant: "glass",
|
|
1017
1017
|
size: "md",
|
|
1018
|
-
onClick: openPage
|
|
1019
|
-
|
|
1018
|
+
onClick: openPage,
|
|
1019
|
+
dflex: true,
|
|
1020
|
+
alignItems: "center",
|
|
1021
|
+
gap: "2",
|
|
1022
|
+
icon: icon || mdiOpenInNew
|
|
1023
|
+
}, props, {
|
|
1024
|
+
children: label
|
|
1025
|
+
}));
|
|
1026
|
+
// return (
|
|
1027
|
+
// <IconButton icon={icon ? icon : mdiOpenInNew} type="submit" scheme="dark" variant="glass" size="md" onClick={openPage} {...props}/>
|
|
1028
|
+
// )
|
|
1020
1029
|
}
|
|
1021
1030
|
|
|
1022
1031
|
function OrderCell({
|
|
@@ -1338,14 +1347,17 @@ function Buttons$1({
|
|
|
1338
1347
|
buttonBar
|
|
1339
1348
|
}) {
|
|
1340
1349
|
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1341
|
-
children: [buttonBar
|
|
1342
|
-
children:
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1350
|
+
children: [buttonBar && buttonBar.length > 0 && jsxRuntime.jsx(admin.ButtonBar, {
|
|
1351
|
+
children: buttonBar.map((button, index) => jsxRuntime.jsxs(React__default["default"].Fragment, {
|
|
1352
|
+
children: [button.type === "link" && jsxRuntime.jsx(ViewButton, {
|
|
1353
|
+
label: button.label,
|
|
1354
|
+
path: button.path,
|
|
1355
|
+
icon: button.icon
|
|
1356
|
+
}), button.type === "invalidate" && jsxRuntime.jsx(InvalidateButton, {
|
|
1357
|
+
pathOrPermalink: button.pathOrPermalink
|
|
1358
|
+
}), button.type == "custom" && button.render(item)]
|
|
1359
|
+
}, index))
|
|
1360
|
+
}), jsxRuntime.jsxs(admin.ButtonBar, {
|
|
1349
1361
|
children: [api instanceof adminApi.API && jsxRuntime.jsx(PublishButton, {
|
|
1350
1362
|
api: api,
|
|
1351
1363
|
queryId: item.id,
|
|
@@ -1415,15 +1427,20 @@ function Internal({
|
|
|
1415
1427
|
sections,
|
|
1416
1428
|
buttonBar,
|
|
1417
1429
|
type,
|
|
1418
|
-
invalidateParentQueryKey
|
|
1430
|
+
invalidateParentQueryKey,
|
|
1431
|
+
invalidatePage
|
|
1419
1432
|
} = pScreen;
|
|
1420
1433
|
const mutation = api.useInvalidateParentMutation(api$1.update, invalidateParentQueryKey !== null && invalidateParentQueryKey !== void 0 ? invalidateParentQueryKey : api$1.queryKey, {
|
|
1421
1434
|
networkMode: "always"
|
|
1422
1435
|
});
|
|
1436
|
+
const invalidatePageFn = adminApi.useInvalidatePage(invalidatePage || "");
|
|
1423
1437
|
const save = api.useMutate(mutation, {
|
|
1424
1438
|
processInput,
|
|
1425
1439
|
successMsg: (item, values) => `${item.title || item.name} updated.`,
|
|
1426
|
-
errorMsg: (error, item) => `Error updating ${item.title || item.name}: ${error}
|
|
1440
|
+
errorMsg: (error, item) => `Error updating ${item.title || item.name}: ${error}`,
|
|
1441
|
+
onSuccess: () => {
|
|
1442
|
+
if (invalidatePage) invalidatePageFn();
|
|
1443
|
+
}
|
|
1427
1444
|
});
|
|
1428
1445
|
let editorMaxW = undefined;
|
|
1429
1446
|
if (!type || type == "post") editorMaxW = "calc(1280px - 28rem)";else if (type == "section") editorMaxW = "calc(1280px - 22rem)";
|
package/index.esm.js
CHANGED
|
@@ -2,11 +2,11 @@ import { __rest, __awaiter } from 'tslib';
|
|
|
2
2
|
import { jsx, jsxs, Fragment } from '@soperio/jsx-runtime';
|
|
3
3
|
import { useApiQuery, useApiMutation, useMutate, useInvalidateMutation, useInvalidateQuery, useInvalidateParentMutation, useApiQueries } from '@compill/api';
|
|
4
4
|
import { Shimmer, FlexCenter, QueryLoadingState, RetryOnError, TabContainer, ModalLoadingOverlay } from '@compill/components';
|
|
5
|
-
import { Icon, Button,
|
|
5
|
+
import { Icon, Button, Container, Tile, Popover, Collapse, Modal, Avatar, IconButton, Popup, Checkbox, Badge } from '@valerya/ui';
|
|
6
6
|
import Link from 'next/link';
|
|
7
7
|
import { useParams, useNavigate, Outlet, useLocation, useMatch, Link as Link$1 } from 'react-router-dom';
|
|
8
8
|
import React, { useRef, useCallback, useContext as useContext$2, useLayoutEffect, useEffect, createContext } from 'react';
|
|
9
|
-
import { INVALIDATE_API, API } from '@compill/admin-api';
|
|
9
|
+
import { INVALIDATE_API, API, useInvalidatePage } from '@compill/admin-api';
|
|
10
10
|
import { useFormikContext, Formik, Form } from 'formik';
|
|
11
11
|
import { ButtonBarButton as ButtonBarButton$1, ButtonBarSubmitButton as ButtonBarSubmitButton$1, PageSectionTitle as PageSectionTitle$1, ButtonBar as ButtonBar$1, ButtonBarDialogButton as ButtonBarDialogButton$1, Breadcrumbs as Breadcrumbs$1, TableRowActionButton as TableRowActionButton$1, DialogButton as DialogButton$1 } from '@compill/admin';
|
|
12
12
|
import { toast } from 'react-toastify';
|
|
@@ -992,21 +992,30 @@ function UpdateButton(_a) {
|
|
|
992
992
|
|
|
993
993
|
function ViewButton(_a) {
|
|
994
994
|
var {
|
|
995
|
+
label,
|
|
995
996
|
path,
|
|
996
997
|
icon
|
|
997
998
|
} = _a,
|
|
998
|
-
props = __rest(_a, ["path", "icon"]);
|
|
999
|
+
props = __rest(_a, ["label", "path", "icon"]);
|
|
999
1000
|
const openPage = React.useCallback(() => {
|
|
1000
1001
|
window.open(path, '_blank');
|
|
1001
1002
|
}, [path]);
|
|
1002
|
-
return jsx(
|
|
1003
|
-
icon: icon ? icon : mdiOpenInNew,
|
|
1003
|
+
return jsx(ButtonBarButton$1, Object.assign({
|
|
1004
1004
|
type: "submit",
|
|
1005
1005
|
scheme: "dark",
|
|
1006
1006
|
variant: "glass",
|
|
1007
1007
|
size: "md",
|
|
1008
|
-
onClick: openPage
|
|
1009
|
-
|
|
1008
|
+
onClick: openPage,
|
|
1009
|
+
dflex: true,
|
|
1010
|
+
alignItems: "center",
|
|
1011
|
+
gap: "2",
|
|
1012
|
+
icon: icon || mdiOpenInNew
|
|
1013
|
+
}, props, {
|
|
1014
|
+
children: label
|
|
1015
|
+
}));
|
|
1016
|
+
// return (
|
|
1017
|
+
// <IconButton icon={icon ? icon : mdiOpenInNew} type="submit" scheme="dark" variant="glass" size="md" onClick={openPage} {...props}/>
|
|
1018
|
+
// )
|
|
1010
1019
|
}
|
|
1011
1020
|
|
|
1012
1021
|
function OrderCell({
|
|
@@ -1328,14 +1337,17 @@ function Buttons$1({
|
|
|
1328
1337
|
buttonBar
|
|
1329
1338
|
}) {
|
|
1330
1339
|
return jsxs(Fragment, {
|
|
1331
|
-
children: [buttonBar
|
|
1332
|
-
children:
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1340
|
+
children: [buttonBar && buttonBar.length > 0 && jsx(ButtonBar$1, {
|
|
1341
|
+
children: buttonBar.map((button, index) => jsxs(React.Fragment, {
|
|
1342
|
+
children: [button.type === "link" && jsx(ViewButton, {
|
|
1343
|
+
label: button.label,
|
|
1344
|
+
path: button.path,
|
|
1345
|
+
icon: button.icon
|
|
1346
|
+
}), button.type === "invalidate" && jsx(InvalidateButton, {
|
|
1347
|
+
pathOrPermalink: button.pathOrPermalink
|
|
1348
|
+
}), button.type == "custom" && button.render(item)]
|
|
1349
|
+
}, index))
|
|
1350
|
+
}), jsxs(ButtonBar$1, {
|
|
1339
1351
|
children: [api instanceof API && jsx(PublishButton, {
|
|
1340
1352
|
api: api,
|
|
1341
1353
|
queryId: item.id,
|
|
@@ -1405,15 +1417,20 @@ function Internal({
|
|
|
1405
1417
|
sections,
|
|
1406
1418
|
buttonBar,
|
|
1407
1419
|
type,
|
|
1408
|
-
invalidateParentQueryKey
|
|
1420
|
+
invalidateParentQueryKey,
|
|
1421
|
+
invalidatePage
|
|
1409
1422
|
} = pScreen;
|
|
1410
1423
|
const mutation = useInvalidateParentMutation(api.update, invalidateParentQueryKey !== null && invalidateParentQueryKey !== void 0 ? invalidateParentQueryKey : api.queryKey, {
|
|
1411
1424
|
networkMode: "always"
|
|
1412
1425
|
});
|
|
1426
|
+
const invalidatePageFn = useInvalidatePage(invalidatePage || "");
|
|
1413
1427
|
const save = useMutate(mutation, {
|
|
1414
1428
|
processInput,
|
|
1415
1429
|
successMsg: (item, values) => `${item.title || item.name} updated.`,
|
|
1416
|
-
errorMsg: (error, item) => `Error updating ${item.title || item.name}: ${error}
|
|
1430
|
+
errorMsg: (error, item) => `Error updating ${item.title || item.name}: ${error}`,
|
|
1431
|
+
onSuccess: () => {
|
|
1432
|
+
if (invalidatePage) invalidatePageFn();
|
|
1433
|
+
}
|
|
1417
1434
|
});
|
|
1418
1435
|
let editorMaxW = undefined;
|
|
1419
1436
|
if (!type || type == "post") editorMaxW = "calc(1280px - 28rem)";else if (type == "section") editorMaxW = "calc(1280px - 22rem)";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
export declare function ViewButton({ path, icon, ...props }:
|
|
2
|
+
import { ButtonBarButtonProps } from "@compill/admin";
|
|
3
|
+
export declare function ViewButton({ label, path, icon, ...props }: ButtonBarButtonProps & {
|
|
4
|
+
label?: string;
|
|
4
5
|
path: string;
|
|
5
|
-
icon?: string;
|
|
6
6
|
}): JSX.Element;
|
|
@@ -14,6 +14,7 @@ export type DetailsViewConfig<T = any> = {
|
|
|
14
14
|
};
|
|
15
15
|
type Screen = {
|
|
16
16
|
invalidateParentQueryKey?: string[];
|
|
17
|
+
invalidatePage?: string;
|
|
17
18
|
breadcrumbs?: Breadcrumb[];
|
|
18
19
|
initialValues: any | ((data: any) => any);
|
|
19
20
|
schema: Yup.Schema;
|
|
@@ -49,6 +50,7 @@ export type DetailViewButton = {
|
|
|
49
50
|
type: "link";
|
|
50
51
|
path: string;
|
|
51
52
|
icon?: string;
|
|
53
|
+
label?: string;
|
|
52
54
|
} | {
|
|
53
55
|
type: "custom";
|
|
54
56
|
render: (item: any) => React.ReactNode;
|