@compill/admin 1.0.51 → 1.0.53
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 +124 -85
- package/index.esm.js +121 -87
- package/package.json +1 -1
- package/src/index.d.ts +3 -0
- package/src/lib/json/dialog/ItemDeleteDialog.d.ts +3 -2
- package/src/lib/json/table/TableRowActionsView.d.ts +1 -1
- package/src/lib/json/table/TableViewContext.d.ts +3 -5
- package/src/lib/json/table/useTableProps.d.ts +1 -1
- package/src/lib/json/types/TableView.d.ts +7 -4
- package/src/lib/layout/ButtonBar.d.ts +5 -0
- package/src/lib/table/TableRowActionButton.d.ts +5 -0
- package/src/lib/table/TableRowActionDialogButton.d.ts +5 -0
- package/src/lib/table/TableRowPublishPostButton.d.ts +1 -1
package/index.cjs.js
CHANGED
@@ -192,6 +192,29 @@ function ButtonBarButton(_a) {
|
|
192
192
|
dflex: true,
|
193
193
|
alignItems: "center",
|
194
194
|
placeContent: "center",
|
195
|
+
corners: "square",
|
196
|
+
gap: "2"
|
197
|
+
}, props, {
|
198
|
+
children: [icon && jsxRuntime.jsx(ui.Icon, {
|
199
|
+
path: icon
|
200
|
+
}), children]
|
201
|
+
}));
|
202
|
+
}
|
203
|
+
function ButtonBarDialogButton(_a) {
|
204
|
+
var {
|
205
|
+
icon,
|
206
|
+
children
|
207
|
+
} = _a,
|
208
|
+
props = __rest$1(_a, ["icon", "children"]);
|
209
|
+
return jsxRuntime.jsxs(DialogButton, Object.assign({
|
210
|
+
scheme: "dark",
|
211
|
+
size: "sm",
|
212
|
+
aspectRatio: icon && !children ? "square" : undefined,
|
213
|
+
variant: "borderless",
|
214
|
+
dflex: true,
|
215
|
+
alignItems: "center",
|
216
|
+
placeContent: "center",
|
217
|
+
corners: "square",
|
195
218
|
gap: "2"
|
196
219
|
}, props, {
|
197
220
|
children: [icon && jsxRuntime.jsx(ui.Icon, {
|
@@ -1421,12 +1444,7 @@ function TableCreateButton(_a) {
|
|
1421
1444
|
children
|
1422
1445
|
} = _a,
|
1423
1446
|
props = __rest$1(_a, ["children"]);
|
1424
|
-
return jsxRuntime.jsx(
|
1425
|
-
scheme: "dark",
|
1426
|
-
size: "sm",
|
1427
|
-
aspectRatio: "square",
|
1428
|
-
variant: "borderless"
|
1429
|
-
}, props, {
|
1447
|
+
return jsxRuntime.jsx(admin.ButtonBarDialogButton, Object.assign({}, props, {
|
1430
1448
|
children: children !== null && children !== void 0 ? children : jsxRuntime.jsx(ui.Icon, {
|
1431
1449
|
path: mdiPlusThick
|
1432
1450
|
})
|
@@ -2200,11 +2218,13 @@ function ItemDeleteDialog(_a) {
|
|
2200
2218
|
invalidateQueriesOnSuccess = true,
|
2201
2219
|
invalidateQueryKey,
|
2202
2220
|
size = "lg",
|
2221
|
+
md_boxSizing,
|
2222
|
+
msg,
|
2203
2223
|
show,
|
2204
2224
|
onClose
|
2205
2225
|
} = _a,
|
2206
|
-
props = __rest$1(_a, ["itemLabel", "queryId", "api", "invalidateQueriesOnSuccess", "invalidateQueryKey", "size", "show", "onClose"]);
|
2207
|
-
const mutation = invalidateQueriesOnSuccess ? api.useInvalidateParentMutation(api$1.delete, invalidateQueryKey !== null && invalidateQueryKey !== void 0 ? invalidateQueryKey : api$1.queryKey) : api.useApiMutation(api$1.
|
2226
|
+
props = __rest$1(_a, ["itemLabel", "queryId", "api", "invalidateQueriesOnSuccess", "invalidateQueryKey", "size", "md_boxSizing", "msg", "show", "onClose"]);
|
2227
|
+
const mutation = invalidateQueriesOnSuccess ? api.useInvalidateParentMutation(api$1.delete, invalidateQueryKey !== null && invalidateQueryKey !== void 0 ? invalidateQueryKey : api$1.queryKey) : api.useApiMutation(api$1.delete, api$1.queryKey);
|
2208
2228
|
const mutate = api.useMutate(mutation, {
|
2209
2229
|
onSuccess: () => onClose === null || onClose === void 0 ? void 0 : onClose()
|
2210
2230
|
});
|
@@ -2221,7 +2241,7 @@ function ItemDeleteDialog(_a) {
|
|
2221
2241
|
children: `Delete ${itemLabel}`
|
2222
2242
|
}), jsxRuntime.jsxs(ui.Modal.Body, {
|
2223
2243
|
pb: "6",
|
2224
|
-
children: [
|
2244
|
+
children: [!msg && `Do you really want to delete ${itemLabel}?`, msg && msg(itemLabel)]
|
2225
2245
|
}), jsxRuntime.jsxs(ui.Modal.Footer, {
|
2226
2246
|
dflex: true,
|
2227
2247
|
placeContent: "end",
|
@@ -2268,15 +2288,16 @@ function TableViewProvider({
|
|
2268
2288
|
}
|
2269
2289
|
case "edit":
|
2270
2290
|
{
|
2271
|
-
|
2272
|
-
|
2291
|
+
const editConfig = react.runIfFn(editView, item);
|
2292
|
+
if (editConfig.type == "customDialog") {
|
2293
|
+
setDialog(editConfig.render({
|
2273
2294
|
show: true,
|
2274
2295
|
onClose: onCloseDialog
|
2275
2296
|
}));
|
2276
2297
|
} else {
|
2277
2298
|
setDialog(jsxRuntime.jsx(DialogRenderer, {
|
2278
2299
|
onClose: onCloseDialog,
|
2279
|
-
config:
|
2300
|
+
config: editConfig,
|
2280
2301
|
queryId: item.id,
|
2281
2302
|
invalidateQueryKey: queryKey
|
2282
2303
|
}));
|
@@ -2285,13 +2306,15 @@ function TableViewProvider({
|
|
2285
2306
|
}
|
2286
2307
|
case "delete":
|
2287
2308
|
{
|
2309
|
+
const deleteConfig = react.runIfFn(deleteItem, item);
|
2288
2310
|
setDialog(jsxRuntime.jsx(ItemDeleteDialog, Object.assign({
|
2289
2311
|
show: true,
|
2290
2312
|
onClose: onCloseDialog,
|
2291
2313
|
queryId: item.id,
|
2292
|
-
invalidateQueryKey: queryKey
|
2293
|
-
|
2294
|
-
|
2314
|
+
invalidateQueryKey: queryKey,
|
2315
|
+
msg: item.msg
|
2316
|
+
}, deleteConfig, {
|
2317
|
+
itemLabel: react.runIfFn(deleteConfig.itemLabel, item)
|
2295
2318
|
})));
|
2296
2319
|
// TODO
|
2297
2320
|
// const { initialValues, ...props } = editItem!!
|
@@ -2416,6 +2439,7 @@ function TableRowActionsView({
|
|
2416
2439
|
api,
|
2417
2440
|
queryKey
|
2418
2441
|
}) {
|
2442
|
+
var _a;
|
2419
2443
|
const item = row.original;
|
2420
2444
|
return jsxRuntime.jsx("div", {
|
2421
2445
|
dflex: true,
|
@@ -2423,7 +2447,7 @@ function TableRowActionsView({
|
|
2423
2447
|
alignItems: "stretch",
|
2424
2448
|
placeContent: "end",
|
2425
2449
|
h: "full",
|
2426
|
-
children: rowActions === null ||
|
2450
|
+
children: (_a = react.runIfFn(rowActions, item)) === null || _a === void 0 ? void 0 : _a.map((action, index) => jsxRuntime.jsxs(React__default["default"].Fragment, {
|
2427
2451
|
children: [action.type === "publish" && jsxRuntime.jsx(TableRowPublishPostButton$1, {
|
2428
2452
|
id: item.id,
|
2429
2453
|
api: api,
|
@@ -2452,16 +2476,7 @@ function ActionButton(_a) {
|
|
2452
2476
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
2453
2477
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
2454
2478
|
}, [onClick]);
|
2455
|
-
return jsxRuntime.jsx(
|
2456
|
-
dflex: true,
|
2457
|
-
alignContent: "center",
|
2458
|
-
placeContent: "center",
|
2459
|
-
py: "2.5",
|
2460
|
-
px: "3",
|
2461
|
-
h: "full",
|
2462
|
-
size: "lg",
|
2463
|
-
variant: "borderless",
|
2464
|
-
corners: "default",
|
2479
|
+
return jsxRuntime.jsx(admin.TableRowActionButton, Object.assign({
|
2465
2480
|
onClick: handleClick
|
2466
2481
|
}, props));
|
2467
2482
|
}
|
@@ -2619,23 +2634,26 @@ function TableButtonBar({
|
|
2619
2634
|
api,
|
2620
2635
|
children
|
2621
2636
|
}) {
|
2622
|
-
const
|
2623
|
-
|
2624
|
-
|
2625
|
-
|
2626
|
-
|
2627
|
-
|
2628
|
-
|
2629
|
-
|
2630
|
-
|
2631
|
-
|
2632
|
-
|
2637
|
+
const createDialogFn = React__default["default"].useCallback(data => {
|
2638
|
+
return onClose => {
|
2639
|
+
var _a;
|
2640
|
+
const view = (_a = react.runIfFn(createView, data)) !== null && _a !== void 0 ? _a : react.runIfFn(editView, null);
|
2641
|
+
if (view.type == "customDialog") return view.render({
|
2642
|
+
show: true,
|
2643
|
+
onClose
|
2644
|
+
});else return jsxRuntime.jsx(DialogRenderer, {
|
2645
|
+
config: view,
|
2646
|
+
onClose: onClose,
|
2647
|
+
invalidateQueryKey: api.queryKey
|
2648
|
+
});
|
2649
|
+
};
|
2650
|
+
}, [createView, editView, api]);
|
2633
2651
|
return jsxRuntime.jsxs(ButtonBar, {
|
2634
2652
|
children: [jsxRuntime.jsx(RefreshButton, {
|
2635
2653
|
queryKey: queryKey
|
2636
2654
|
}), buttonBar && buttonBar.map((button, index) => jsxRuntime.jsxs(React__default["default"].Fragment, {
|
2637
2655
|
children: [button.type === "create" && editView && jsxRuntime.jsx(TableCreateButton, {
|
2638
|
-
buildDialog:
|
2656
|
+
buildDialog: createDialogFn(button.data)
|
2639
2657
|
}), button.type === "invalidate" && jsxRuntime.jsx(InvalidateButton, {
|
2640
2658
|
pathOrPermalink: button.pathOrPermalink
|
2641
2659
|
}), button.type === "custom" && button.render()]
|
@@ -2976,7 +2994,7 @@ function LeftPanel({
|
|
2976
2994
|
const [isOpen, __, toggle] = hooks.useBoolean(true);
|
2977
2995
|
useHotkeys('ctrl+t', () => toggle(), [toggle]);
|
2978
2996
|
return jsxRuntime.jsxs("div", {
|
2979
|
-
ms: isOpen ? "0" : "-
|
2997
|
+
ms: isOpen ? "0" : "-14.5rem",
|
2980
2998
|
transition: "all",
|
2981
2999
|
duration: "500",
|
2982
3000
|
transform: true,
|
@@ -3483,6 +3501,31 @@ function StatusBadge(_a) {
|
|
3483
3501
|
}));
|
3484
3502
|
}
|
3485
3503
|
|
3504
|
+
function TableRowActionButton(_a) {
|
3505
|
+
var {
|
3506
|
+
icon,
|
3507
|
+
children
|
3508
|
+
} = _a,
|
3509
|
+
props = __rest$1(_a, ["icon", "children"]);
|
3510
|
+
return jsxRuntime.jsxs(ui.Button, Object.assign({
|
3511
|
+
dflex: true,
|
3512
|
+
alignContent: "center",
|
3513
|
+
placeContent: "center",
|
3514
|
+
py: "2.5",
|
3515
|
+
px: "3",
|
3516
|
+
h: "full",
|
3517
|
+
size: "lg",
|
3518
|
+
variant: "borderless",
|
3519
|
+
corners: "square",
|
3520
|
+
gap: "2"
|
3521
|
+
}, props, {
|
3522
|
+
children: [icon && jsxRuntime.jsx(ui.Icon, {
|
3523
|
+
path: icon,
|
3524
|
+
size: "sm"
|
3525
|
+
}), children]
|
3526
|
+
}));
|
3527
|
+
}
|
3528
|
+
|
3486
3529
|
function TableRowViewButton(_a) {
|
3487
3530
|
var {
|
3488
3531
|
path
|
@@ -3493,18 +3536,10 @@ function TableRowViewButton(_a) {
|
|
3493
3536
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
3494
3537
|
window.open(`${process.env["NEXT_PUBLIC_WEBSITE_URL"]}/${path}`, '_blank');
|
3495
3538
|
}, [path]);
|
3496
|
-
return jsxRuntime.jsx(
|
3497
|
-
|
3498
|
-
h: "10",
|
3499
|
-
variant: "borderless",
|
3500
|
-
corners: "pill",
|
3501
|
-
scheme: "dark",
|
3539
|
+
return jsxRuntime.jsx(TableRowActionButton, Object.assign({
|
3540
|
+
icon: mdiOpenInNew,
|
3502
3541
|
onClick: openPage
|
3503
|
-
}, props
|
3504
|
-
children: jsxRuntime.jsx(ui.Icon, {
|
3505
|
-
path: mdiOpenInNew
|
3506
|
-
})
|
3507
|
-
}));
|
3542
|
+
}, props));
|
3508
3543
|
}
|
3509
3544
|
|
3510
3545
|
function TableRowNavigateButton(_a) {
|
@@ -3518,15 +3553,34 @@ function TableRowNavigateButton(_a) {
|
|
3518
3553
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
3519
3554
|
navigate(`${path}`);
|
3520
3555
|
}, [navigate, path]);
|
3521
|
-
return jsxRuntime.jsx(
|
3522
|
-
|
3556
|
+
return jsxRuntime.jsx(TableRowActionButton, Object.assign({
|
3557
|
+
icon: mdiEye,
|
3558
|
+
onClick: handleClick
|
3559
|
+
}, props));
|
3560
|
+
}
|
3561
|
+
|
3562
|
+
function TableRowActionDialogButton(_a) {
|
3563
|
+
var {
|
3564
|
+
icon,
|
3565
|
+
children
|
3566
|
+
} = _a,
|
3567
|
+
props = __rest$1(_a, ["icon", "children"]);
|
3568
|
+
return jsxRuntime.jsxs(admin.DialogButton, Object.assign({
|
3569
|
+
dflex: true,
|
3570
|
+
alignContent: "center",
|
3571
|
+
placeContent: "center",
|
3572
|
+
py: "2.5",
|
3573
|
+
px: "3",
|
3574
|
+
h: "full",
|
3575
|
+
size: "lg",
|
3523
3576
|
variant: "borderless",
|
3524
3577
|
corners: "square",
|
3525
|
-
|
3578
|
+
gap: "2"
|
3526
3579
|
}, props, {
|
3527
|
-
children: jsxRuntime.jsx(ui.Icon, {
|
3528
|
-
path:
|
3529
|
-
|
3580
|
+
children: [icon && jsxRuntime.jsx(ui.Icon, {
|
3581
|
+
path: icon,
|
3582
|
+
size: "sm"
|
3583
|
+
}), children]
|
3530
3584
|
}));
|
3531
3585
|
}
|
3532
3586
|
|
@@ -3535,16 +3589,10 @@ function TableRowEditButton(_a) {
|
|
3535
3589
|
children
|
3536
3590
|
} = _a,
|
3537
3591
|
props = __rest$1(_a, ["children"]);
|
3538
|
-
return jsxRuntime.jsx(
|
3539
|
-
|
3540
|
-
h: "10",
|
3541
|
-
variant: "borderless",
|
3542
|
-
corners: "pill",
|
3543
|
-
scheme: "warning"
|
3592
|
+
return jsxRuntime.jsx(TableRowActionDialogButton, Object.assign({
|
3593
|
+
icon: mdiPencil
|
3544
3594
|
}, props, {
|
3545
|
-
children: children
|
3546
|
-
path: mdiPencil
|
3547
|
-
})
|
3595
|
+
children: children
|
3548
3596
|
}));
|
3549
3597
|
}
|
3550
3598
|
|
@@ -3553,16 +3601,10 @@ function TableRowDeleteButton(_a) {
|
|
3553
3601
|
children
|
3554
3602
|
} = _a,
|
3555
3603
|
props = __rest$1(_a, ["children"]);
|
3556
|
-
return jsxRuntime.jsx(
|
3557
|
-
|
3558
|
-
h: "10",
|
3559
|
-
scheme: "danger",
|
3560
|
-
variant: "borderless",
|
3561
|
-
corners: "pill"
|
3604
|
+
return jsxRuntime.jsx(TableRowActionDialogButton, Object.assign({
|
3605
|
+
icon: mdiDelete
|
3562
3606
|
}, props, {
|
3563
|
-
children: children
|
3564
|
-
path: mdiDelete
|
3565
|
-
})
|
3607
|
+
children: children
|
3566
3608
|
}));
|
3567
3609
|
}
|
3568
3610
|
|
@@ -3611,23 +3653,18 @@ function TableRowPublishPostButton(_a) {
|
|
3611
3653
|
mutation.reset();
|
3612
3654
|
mutation.mutateAsync(id).then(() => reactToastify.toast.success(isDraft ? "Published!" : "Unpublished!")).catch(error => reactToastify.toast.error(`Error: ${error}`));
|
3613
3655
|
}, [mutation, id]);
|
3614
|
-
return jsxRuntime.jsx(
|
3615
|
-
|
3616
|
-
h: "10",
|
3617
|
-
variant: "borderless",
|
3618
|
-
corners: "pill",
|
3619
|
-
scheme: "default",
|
3656
|
+
return jsxRuntime.jsx(TableRowActionButton, Object.assign({
|
3657
|
+
icon: isDraft ? mdiPublish : mdiPublishOff,
|
3620
3658
|
onClick: publish
|
3621
|
-
}, props
|
3622
|
-
children: jsxRuntime.jsx(ui.Icon, {
|
3623
|
-
path: isDraft ? mdiPublish : mdiPublishOff
|
3624
|
-
})
|
3625
|
-
}));
|
3659
|
+
}, props));
|
3626
3660
|
}
|
3627
3661
|
|
3628
3662
|
exports.AdminLayout = AdminLayout;
|
3629
3663
|
exports.AttachDialog = AttachDialog;
|
3630
3664
|
exports.Breadcrumbs = Breadcrumbs;
|
3665
|
+
exports.ButtonBar = ButtonBar;
|
3666
|
+
exports.ButtonBarButton = ButtonBarButton;
|
3667
|
+
exports.ButtonBarDialogButton = ButtonBarDialogButton;
|
3631
3668
|
exports.DialogButton = DialogButton;
|
3632
3669
|
exports.FormActionDialog = FormActionDialog;
|
3633
3670
|
exports.InvalidateButton = InvalidateButton;
|
@@ -3656,6 +3693,8 @@ exports.TableContainer = TableContainer;
|
|
3656
3693
|
exports.TableCreateButton = TableCreateButton;
|
3657
3694
|
exports.TableFilterButton = TableFilterButton;
|
3658
3695
|
exports.TableRowActionBar = TableRowActionBar;
|
3696
|
+
exports.TableRowActionButton = TableRowActionButton;
|
3697
|
+
exports.TableRowActionDialogButton = TableRowActionDialogButton;
|
3659
3698
|
exports.TableRowDeleteButton = TableRowDeleteButton;
|
3660
3699
|
exports.TableRowEditButton = TableRowEditButton;
|
3661
3700
|
exports.TableRowNavigateButton = TableRowNavigateButton;
|
package/index.esm.js
CHANGED
@@ -12,7 +12,7 @@ import 'react/jsx-runtime';
|
|
12
12
|
import { FlexCenter, QueryLoadingState, RetryOnError, TabContainer, ModalLoadingOverlay } from '@compill/components';
|
13
13
|
import { createContext as createContext$1, runIfFn, isFunction } from '@soperio/react';
|
14
14
|
import { Editor } from '@compill/editor';
|
15
|
-
import { PageSectionTitle as PageSectionTitle$1 } from '@compill/admin';
|
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
17
|
import { TableContextProvider, useTableContext, Table } from '@compill/table';
|
18
18
|
import { useOpenLink, useBoolean } from '@compill/hooks';
|
@@ -183,6 +183,29 @@ function ButtonBarButton(_a) {
|
|
183
183
|
dflex: true,
|
184
184
|
alignItems: "center",
|
185
185
|
placeContent: "center",
|
186
|
+
corners: "square",
|
187
|
+
gap: "2"
|
188
|
+
}, props, {
|
189
|
+
children: [icon && jsx(Icon, {
|
190
|
+
path: icon
|
191
|
+
}), children]
|
192
|
+
}));
|
193
|
+
}
|
194
|
+
function ButtonBarDialogButton(_a) {
|
195
|
+
var {
|
196
|
+
icon,
|
197
|
+
children
|
198
|
+
} = _a,
|
199
|
+
props = __rest$1(_a, ["icon", "children"]);
|
200
|
+
return jsxs(DialogButton, Object.assign({
|
201
|
+
scheme: "dark",
|
202
|
+
size: "sm",
|
203
|
+
aspectRatio: icon && !children ? "square" : undefined,
|
204
|
+
variant: "borderless",
|
205
|
+
dflex: true,
|
206
|
+
alignItems: "center",
|
207
|
+
placeContent: "center",
|
208
|
+
corners: "square",
|
186
209
|
gap: "2"
|
187
210
|
}, props, {
|
188
211
|
children: [icon && jsx(Icon, {
|
@@ -1412,12 +1435,7 @@ function TableCreateButton(_a) {
|
|
1412
1435
|
children
|
1413
1436
|
} = _a,
|
1414
1437
|
props = __rest$1(_a, ["children"]);
|
1415
|
-
return jsx(
|
1416
|
-
scheme: "dark",
|
1417
|
-
size: "sm",
|
1418
|
-
aspectRatio: "square",
|
1419
|
-
variant: "borderless"
|
1420
|
-
}, props, {
|
1438
|
+
return jsx(ButtonBarDialogButton$1, Object.assign({}, props, {
|
1421
1439
|
children: children !== null && children !== void 0 ? children : jsx(Icon, {
|
1422
1440
|
path: mdiPlusThick
|
1423
1441
|
})
|
@@ -2191,11 +2209,13 @@ function ItemDeleteDialog(_a) {
|
|
2191
2209
|
invalidateQueriesOnSuccess = true,
|
2192
2210
|
invalidateQueryKey,
|
2193
2211
|
size = "lg",
|
2212
|
+
md_boxSizing,
|
2213
|
+
msg,
|
2194
2214
|
show,
|
2195
2215
|
onClose
|
2196
2216
|
} = _a,
|
2197
|
-
props = __rest$1(_a, ["itemLabel", "queryId", "api", "invalidateQueriesOnSuccess", "invalidateQueryKey", "size", "show", "onClose"]);
|
2198
|
-
const mutation = invalidateQueriesOnSuccess ? useInvalidateParentMutation(api.delete, invalidateQueryKey !== null && invalidateQueryKey !== void 0 ? invalidateQueryKey : api.queryKey) : useApiMutation(api.
|
2217
|
+
props = __rest$1(_a, ["itemLabel", "queryId", "api", "invalidateQueriesOnSuccess", "invalidateQueryKey", "size", "md_boxSizing", "msg", "show", "onClose"]);
|
2218
|
+
const mutation = invalidateQueriesOnSuccess ? useInvalidateParentMutation(api.delete, invalidateQueryKey !== null && invalidateQueryKey !== void 0 ? invalidateQueryKey : api.queryKey) : useApiMutation(api.delete, api.queryKey);
|
2199
2219
|
const mutate = useMutate(mutation, {
|
2200
2220
|
onSuccess: () => onClose === null || onClose === void 0 ? void 0 : onClose()
|
2201
2221
|
});
|
@@ -2212,7 +2232,7 @@ function ItemDeleteDialog(_a) {
|
|
2212
2232
|
children: `Delete ${itemLabel}`
|
2213
2233
|
}), jsxs(Modal.Body, {
|
2214
2234
|
pb: "6",
|
2215
|
-
children: [
|
2235
|
+
children: [!msg && `Do you really want to delete ${itemLabel}?`, msg && msg(itemLabel)]
|
2216
2236
|
}), jsxs(Modal.Footer, {
|
2217
2237
|
dflex: true,
|
2218
2238
|
placeContent: "end",
|
@@ -2259,15 +2279,16 @@ function TableViewProvider({
|
|
2259
2279
|
}
|
2260
2280
|
case "edit":
|
2261
2281
|
{
|
2262
|
-
|
2263
|
-
|
2282
|
+
const editConfig = runIfFn(editView, item);
|
2283
|
+
if (editConfig.type == "customDialog") {
|
2284
|
+
setDialog(editConfig.render({
|
2264
2285
|
show: true,
|
2265
2286
|
onClose: onCloseDialog
|
2266
2287
|
}));
|
2267
2288
|
} else {
|
2268
2289
|
setDialog(jsx(DialogRenderer, {
|
2269
2290
|
onClose: onCloseDialog,
|
2270
|
-
config:
|
2291
|
+
config: editConfig,
|
2271
2292
|
queryId: item.id,
|
2272
2293
|
invalidateQueryKey: queryKey
|
2273
2294
|
}));
|
@@ -2276,13 +2297,15 @@ function TableViewProvider({
|
|
2276
2297
|
}
|
2277
2298
|
case "delete":
|
2278
2299
|
{
|
2300
|
+
const deleteConfig = runIfFn(deleteItem, item);
|
2279
2301
|
setDialog(jsx(ItemDeleteDialog, Object.assign({
|
2280
2302
|
show: true,
|
2281
2303
|
onClose: onCloseDialog,
|
2282
2304
|
queryId: item.id,
|
2283
|
-
invalidateQueryKey: queryKey
|
2284
|
-
|
2285
|
-
|
2305
|
+
invalidateQueryKey: queryKey,
|
2306
|
+
msg: item.msg
|
2307
|
+
}, deleteConfig, {
|
2308
|
+
itemLabel: runIfFn(deleteConfig.itemLabel, item)
|
2286
2309
|
})));
|
2287
2310
|
// TODO
|
2288
2311
|
// const { initialValues, ...props } = editItem!!
|
@@ -2407,6 +2430,7 @@ function TableRowActionsView({
|
|
2407
2430
|
api,
|
2408
2431
|
queryKey
|
2409
2432
|
}) {
|
2433
|
+
var _a;
|
2410
2434
|
const item = row.original;
|
2411
2435
|
return jsx("div", {
|
2412
2436
|
dflex: true,
|
@@ -2414,7 +2438,7 @@ function TableRowActionsView({
|
|
2414
2438
|
alignItems: "stretch",
|
2415
2439
|
placeContent: "end",
|
2416
2440
|
h: "full",
|
2417
|
-
children: rowActions === null ||
|
2441
|
+
children: (_a = runIfFn(rowActions, item)) === null || _a === void 0 ? void 0 : _a.map((action, index) => jsxs(React.Fragment, {
|
2418
2442
|
children: [action.type === "publish" && jsx(TableRowPublishPostButton$1, {
|
2419
2443
|
id: item.id,
|
2420
2444
|
api: api,
|
@@ -2443,16 +2467,7 @@ function ActionButton(_a) {
|
|
2443
2467
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
2444
2468
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
2445
2469
|
}, [onClick]);
|
2446
|
-
return jsx(
|
2447
|
-
dflex: true,
|
2448
|
-
alignContent: "center",
|
2449
|
-
placeContent: "center",
|
2450
|
-
py: "2.5",
|
2451
|
-
px: "3",
|
2452
|
-
h: "full",
|
2453
|
-
size: "lg",
|
2454
|
-
variant: "borderless",
|
2455
|
-
corners: "default",
|
2470
|
+
return jsx(TableRowActionButton$1, Object.assign({
|
2456
2471
|
onClick: handleClick
|
2457
2472
|
}, props));
|
2458
2473
|
}
|
@@ -2610,23 +2625,26 @@ function TableButtonBar({
|
|
2610
2625
|
api,
|
2611
2626
|
children
|
2612
2627
|
}) {
|
2613
|
-
const
|
2614
|
-
|
2615
|
-
|
2616
|
-
|
2617
|
-
|
2618
|
-
|
2619
|
-
|
2620
|
-
|
2621
|
-
|
2622
|
-
|
2623
|
-
|
2628
|
+
const createDialogFn = React.useCallback(data => {
|
2629
|
+
return onClose => {
|
2630
|
+
var _a;
|
2631
|
+
const view = (_a = runIfFn(createView, data)) !== null && _a !== void 0 ? _a : runIfFn(editView, null);
|
2632
|
+
if (view.type == "customDialog") return view.render({
|
2633
|
+
show: true,
|
2634
|
+
onClose
|
2635
|
+
});else return jsx(DialogRenderer, {
|
2636
|
+
config: view,
|
2637
|
+
onClose: onClose,
|
2638
|
+
invalidateQueryKey: api.queryKey
|
2639
|
+
});
|
2640
|
+
};
|
2641
|
+
}, [createView, editView, api]);
|
2624
2642
|
return jsxs(ButtonBar, {
|
2625
2643
|
children: [jsx(RefreshButton, {
|
2626
2644
|
queryKey: queryKey
|
2627
2645
|
}), buttonBar && buttonBar.map((button, index) => jsxs(React.Fragment, {
|
2628
2646
|
children: [button.type === "create" && editView && jsx(TableCreateButton, {
|
2629
|
-
buildDialog:
|
2647
|
+
buildDialog: createDialogFn(button.data)
|
2630
2648
|
}), button.type === "invalidate" && jsx(InvalidateButton, {
|
2631
2649
|
pathOrPermalink: button.pathOrPermalink
|
2632
2650
|
}), button.type === "custom" && button.render()]
|
@@ -2967,7 +2985,7 @@ function LeftPanel({
|
|
2967
2985
|
const [isOpen, __, toggle] = useBoolean(true);
|
2968
2986
|
useHotkeys('ctrl+t', () => toggle(), [toggle]);
|
2969
2987
|
return jsxs("div", {
|
2970
|
-
ms: isOpen ? "0" : "-
|
2988
|
+
ms: isOpen ? "0" : "-14.5rem",
|
2971
2989
|
transition: "all",
|
2972
2990
|
duration: "500",
|
2973
2991
|
transform: true,
|
@@ -3474,6 +3492,31 @@ function StatusBadge(_a) {
|
|
3474
3492
|
}));
|
3475
3493
|
}
|
3476
3494
|
|
3495
|
+
function TableRowActionButton(_a) {
|
3496
|
+
var {
|
3497
|
+
icon,
|
3498
|
+
children
|
3499
|
+
} = _a,
|
3500
|
+
props = __rest$1(_a, ["icon", "children"]);
|
3501
|
+
return jsxs(Button, Object.assign({
|
3502
|
+
dflex: true,
|
3503
|
+
alignContent: "center",
|
3504
|
+
placeContent: "center",
|
3505
|
+
py: "2.5",
|
3506
|
+
px: "3",
|
3507
|
+
h: "full",
|
3508
|
+
size: "lg",
|
3509
|
+
variant: "borderless",
|
3510
|
+
corners: "square",
|
3511
|
+
gap: "2"
|
3512
|
+
}, props, {
|
3513
|
+
children: [icon && jsx(Icon, {
|
3514
|
+
path: icon,
|
3515
|
+
size: "sm"
|
3516
|
+
}), children]
|
3517
|
+
}));
|
3518
|
+
}
|
3519
|
+
|
3477
3520
|
function TableRowViewButton(_a) {
|
3478
3521
|
var {
|
3479
3522
|
path
|
@@ -3484,18 +3527,10 @@ function TableRowViewButton(_a) {
|
|
3484
3527
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
3485
3528
|
window.open(`${process.env["NEXT_PUBLIC_WEBSITE_URL"]}/${path}`, '_blank');
|
3486
3529
|
}, [path]);
|
3487
|
-
return jsx(
|
3488
|
-
|
3489
|
-
h: "10",
|
3490
|
-
variant: "borderless",
|
3491
|
-
corners: "pill",
|
3492
|
-
scheme: "dark",
|
3530
|
+
return jsx(TableRowActionButton, Object.assign({
|
3531
|
+
icon: mdiOpenInNew,
|
3493
3532
|
onClick: openPage
|
3494
|
-
}, props
|
3495
|
-
children: jsx(Icon, {
|
3496
|
-
path: mdiOpenInNew
|
3497
|
-
})
|
3498
|
-
}));
|
3533
|
+
}, props));
|
3499
3534
|
}
|
3500
3535
|
|
3501
3536
|
function TableRowNavigateButton(_a) {
|
@@ -3509,15 +3544,34 @@ function TableRowNavigateButton(_a) {
|
|
3509
3544
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
3510
3545
|
navigate(`${path}`);
|
3511
3546
|
}, [navigate, path]);
|
3512
|
-
return jsx(
|
3513
|
-
|
3547
|
+
return jsx(TableRowActionButton, Object.assign({
|
3548
|
+
icon: mdiEye,
|
3549
|
+
onClick: handleClick
|
3550
|
+
}, props));
|
3551
|
+
}
|
3552
|
+
|
3553
|
+
function TableRowActionDialogButton(_a) {
|
3554
|
+
var {
|
3555
|
+
icon,
|
3556
|
+
children
|
3557
|
+
} = _a,
|
3558
|
+
props = __rest$1(_a, ["icon", "children"]);
|
3559
|
+
return jsxs(DialogButton$1, Object.assign({
|
3560
|
+
dflex: true,
|
3561
|
+
alignContent: "center",
|
3562
|
+
placeContent: "center",
|
3563
|
+
py: "2.5",
|
3564
|
+
px: "3",
|
3565
|
+
h: "full",
|
3566
|
+
size: "lg",
|
3514
3567
|
variant: "borderless",
|
3515
3568
|
corners: "square",
|
3516
|
-
|
3569
|
+
gap: "2"
|
3517
3570
|
}, props, {
|
3518
|
-
children: jsx(Icon, {
|
3519
|
-
path:
|
3520
|
-
|
3571
|
+
children: [icon && jsx(Icon, {
|
3572
|
+
path: icon,
|
3573
|
+
size: "sm"
|
3574
|
+
}), children]
|
3521
3575
|
}));
|
3522
3576
|
}
|
3523
3577
|
|
@@ -3526,16 +3580,10 @@ function TableRowEditButton(_a) {
|
|
3526
3580
|
children
|
3527
3581
|
} = _a,
|
3528
3582
|
props = __rest$1(_a, ["children"]);
|
3529
|
-
return jsx(
|
3530
|
-
|
3531
|
-
h: "10",
|
3532
|
-
variant: "borderless",
|
3533
|
-
corners: "pill",
|
3534
|
-
scheme: "warning"
|
3583
|
+
return jsx(TableRowActionDialogButton, Object.assign({
|
3584
|
+
icon: mdiPencil
|
3535
3585
|
}, props, {
|
3536
|
-
children: children
|
3537
|
-
path: mdiPencil
|
3538
|
-
})
|
3586
|
+
children: children
|
3539
3587
|
}));
|
3540
3588
|
}
|
3541
3589
|
|
@@ -3544,16 +3592,10 @@ function TableRowDeleteButton(_a) {
|
|
3544
3592
|
children
|
3545
3593
|
} = _a,
|
3546
3594
|
props = __rest$1(_a, ["children"]);
|
3547
|
-
return jsx(
|
3548
|
-
|
3549
|
-
h: "10",
|
3550
|
-
scheme: "danger",
|
3551
|
-
variant: "borderless",
|
3552
|
-
corners: "pill"
|
3595
|
+
return jsx(TableRowActionDialogButton, Object.assign({
|
3596
|
+
icon: mdiDelete
|
3553
3597
|
}, props, {
|
3554
|
-
children: children
|
3555
|
-
path: mdiDelete
|
3556
|
-
})
|
3598
|
+
children: children
|
3557
3599
|
}));
|
3558
3600
|
}
|
3559
3601
|
|
@@ -3602,18 +3644,10 @@ function TableRowPublishPostButton(_a) {
|
|
3602
3644
|
mutation.reset();
|
3603
3645
|
mutation.mutateAsync(id).then(() => toast.success(isDraft ? "Published!" : "Unpublished!")).catch(error => toast.error(`Error: ${error}`));
|
3604
3646
|
}, [mutation, id]);
|
3605
|
-
return jsx(
|
3606
|
-
|
3607
|
-
h: "10",
|
3608
|
-
variant: "borderless",
|
3609
|
-
corners: "pill",
|
3610
|
-
scheme: "default",
|
3647
|
+
return jsx(TableRowActionButton, Object.assign({
|
3648
|
+
icon: isDraft ? mdiPublish : mdiPublishOff,
|
3611
3649
|
onClick: publish
|
3612
|
-
}, props
|
3613
|
-
children: jsx(Icon, {
|
3614
|
-
path: isDraft ? mdiPublish : mdiPublishOff
|
3615
|
-
})
|
3616
|
-
}));
|
3650
|
+
}, props));
|
3617
3651
|
}
|
3618
3652
|
|
3619
|
-
export { AdminLayout, AttachDialog, Breadcrumbs, DialogButton, FormActionDialog, InvalidateButton, ItemEditDialog, NavigateButton, OrderCell, PageContainer, PageContentEditor, PageMain, PageQueryStateContainer, PageSectionTitle, PageSidebar, PageSidebarSection, PageStateContainer, PageSubSectionTitle, PageTabbedTopBar, PageTabbedTopBarProvider, PageTitle, PageTopBar, PageTopBarToolbar, PublishButton, ScreenRenderer, SectionTitle, StatusBadge, TableContainer, TableCreateButton, TableFilterButton, TableRowActionBar, TableRowDeleteButton, TableRowEditButton, TableRowNavigateButton, TableRowPublishPostButton, TableRowViewButton, TableTopBar, UpdateButton, ViewButton };
|
3653
|
+
export { AdminLayout, AttachDialog, Breadcrumbs, ButtonBar, ButtonBarButton, ButtonBarDialogButton, DialogButton, FormActionDialog, InvalidateButton, ItemEditDialog, NavigateButton, OrderCell, PageContainer, PageContentEditor, PageMain, PageQueryStateContainer, PageSectionTitle, PageSidebar, PageSidebarSection, PageStateContainer, PageSubSectionTitle, PageTabbedTopBar, PageTabbedTopBarProvider, PageTitle, PageTopBar, PageTopBarToolbar, PublishButton, ScreenRenderer, SectionTitle, StatusBadge, TableContainer, TableCreateButton, TableFilterButton, TableRowActionBar, TableRowActionButton, TableRowActionDialogButton, TableRowDeleteButton, TableRowEditButton, TableRowNavigateButton, TableRowPublishPostButton, TableRowViewButton, TableTopBar, UpdateButton, ViewButton };
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
@@ -17,6 +17,7 @@ export * from "./lib/json/types/QueryWrapperDialog";
|
|
17
17
|
export * from "./lib/json/types/MultiQueryWrapper";
|
18
18
|
export * from "./lib/json/ScreenRenderer";
|
19
19
|
export * from "./lib/layout/AdminLayout";
|
20
|
+
export * from "./lib/layout/ButtonBar";
|
20
21
|
export { MenuConfig } from "./lib/layout/Menu";
|
21
22
|
export * from "./lib/modal/AttachDialog";
|
22
23
|
export * from "./lib/modal/FormActionDialog";
|
@@ -37,6 +38,8 @@ export * from "./lib/table/TableContainer";
|
|
37
38
|
export * from "./lib/table/TableCreateButton";
|
38
39
|
export * from "./lib/table/TableFilterButton";
|
39
40
|
export * from "./lib/table/TableRowActionBar";
|
41
|
+
export * from "./lib/table/TableRowActionButton";
|
42
|
+
export * from "./lib/table/TableRowActionDialogButton";
|
40
43
|
export * from "./lib/table/TableRowDeleteButton";
|
41
44
|
export * from "./lib/table/TableRowEditButton";
|
42
45
|
export * from "./lib/table/TableRowNavigateButton";
|
@@ -1,11 +1,12 @@
|
|
1
|
-
/// <reference types="react" />
|
2
1
|
import { CRUDAPI } from "@compill/api";
|
3
2
|
import { ModalProps } from "@valerya/ui";
|
3
|
+
import React from "react";
|
4
4
|
export interface ItemDeleteDialogProps extends ModalProps {
|
5
5
|
itemLabel: string;
|
6
6
|
queryId: string;
|
7
7
|
api: CRUDAPI<any>;
|
8
8
|
invalidateQueriesOnSuccess?: boolean;
|
9
9
|
invalidateQueryKey?: string[];
|
10
|
+
msg?: (itemLabel: string) => string | React.ReactNode;
|
10
11
|
}
|
11
|
-
export declare function ItemDeleteDialog({ itemLabel, queryId, api, invalidateQueriesOnSuccess, invalidateQueryKey, size, show, onClose, ...props }: ItemDeleteDialogProps): JSX.Element;
|
12
|
+
export declare function ItemDeleteDialog({ itemLabel, queryId, api, invalidateQueriesOnSuccess, invalidateQueryKey, size, md_boxSizing, msg, show, onClose, ...props }: ItemDeleteDialogProps): JSX.Element;
|
@@ -4,7 +4,7 @@ import { API } from "@compill/admin-api";
|
|
4
4
|
interface TableRowActionViewProps {
|
5
5
|
row: any;
|
6
6
|
onAction: (action: TableRowAction, item: any) => void;
|
7
|
-
rowActions?: TableRowAction[];
|
7
|
+
rowActions?: TableRowAction[] | ((item?: any) => TableRowAction[]);
|
8
8
|
api: API<any>;
|
9
9
|
queryKey: string[];
|
10
10
|
}
|
@@ -1,7 +1,5 @@
|
|
1
1
|
import React from "react";
|
2
|
-
import {
|
3
|
-
import { EditItemDialogConfig } from "../types/EditItemDialog";
|
4
|
-
import { QueryWrapperDialogConfig } from "../types/QueryWrapperDialog";
|
2
|
+
import { TableRowAction, TableViewDeleteItem, TableViewEditView } from "../types/TableView";
|
5
3
|
type TableViewContextProps = {
|
6
4
|
onAction: (action: TableRowAction, item: any) => void;
|
7
5
|
dialog?: React.ReactNode;
|
@@ -9,8 +7,8 @@ type TableViewContextProps = {
|
|
9
7
|
declare const useContext: () => TableViewContextProps;
|
10
8
|
export interface TableViewProviderProps extends React.PropsWithChildren {
|
11
9
|
queryKey: string[];
|
12
|
-
editView?:
|
13
|
-
deleteItem?: TableViewDeleteItem;
|
10
|
+
editView?: TableViewEditView | ((item: any) => TableViewEditView);
|
11
|
+
deleteItem?: TableViewDeleteItem | ((item: any) => TableViewDeleteItem);
|
14
12
|
}
|
15
13
|
declare function TableViewProvider({ editView, deleteItem, queryKey, children }: TableViewProviderProps): JSX.Element;
|
16
14
|
export { TableViewProvider, useContext as useTableViewContext };
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { TableRowAction, TableViewTable } from "../types/TableView";
|
2
2
|
import { API } from "@compill/admin-api";
|
3
|
-
export declare function useTableProps(api: API<any>, table: TableViewTable, rowActions?: TableRowAction[]): any;
|
3
|
+
export declare function useTableProps(api: API<any>, table: TableViewTable, rowActions?: TableRowAction[] | ((item?: any) => TableRowAction[])): any;
|
@@ -15,11 +15,11 @@ export type TableViewScreen = {
|
|
15
15
|
buttonBar?: TableViewButtonConfig[];
|
16
16
|
filters?: TableFilters;
|
17
17
|
massActions?: TableMassActions;
|
18
|
-
createView?: TableViewEditView;
|
19
|
-
editView?: TableViewEditView;
|
20
|
-
deleteItem?: TableViewDeleteItem;
|
18
|
+
createView?: TableViewEditView | ((data?: any) => TableViewEditView);
|
19
|
+
editView?: TableViewEditView | ((item: any) => TableViewEditView);
|
20
|
+
deleteItem?: TableViewDeleteItem | ((item: any) => TableViewDeleteItem);
|
21
21
|
table: TableViewTable;
|
22
|
-
rowActions?: TableRowAction[];
|
22
|
+
rowActions?: TableRowAction[] | ((item: any) => TableRowAction[]);
|
23
23
|
};
|
24
24
|
export type TableViewConfig = {
|
25
25
|
type: "table";
|
@@ -56,6 +56,7 @@ export type TableRowAction = {
|
|
56
56
|
type: "edit";
|
57
57
|
} | {
|
58
58
|
type: "delete";
|
59
|
+
msg?: (itemLabel: string) => (string | React.ReactNode);
|
59
60
|
} | {
|
60
61
|
type: "publish";
|
61
62
|
} | {
|
@@ -67,6 +68,8 @@ export type TableRowAction = {
|
|
67
68
|
export type TableViewButtonBar = TableViewButtonConfig[];
|
68
69
|
type TableViewButtonConfig = {
|
69
70
|
type: "create";
|
71
|
+
data?: any;
|
72
|
+
label?: string;
|
70
73
|
} | {
|
71
74
|
type: "invalidate";
|
72
75
|
pathOrPermalink: string;
|
@@ -1,4 +1,5 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
+
import { DialogButtonProps } from "../buttons/DialogButton";
|
2
3
|
import { ParentComponent, SoperioComponent } from "@soperio/react";
|
3
4
|
import { ButtonProps } from "@valerya/ui";
|
4
5
|
export declare function ButtonBar({ children, ...props }: ParentComponent & SoperioComponent): JSX.Element;
|
@@ -6,3 +7,7 @@ export type ButtonBarButtonProps = {
|
|
6
7
|
icon?: string;
|
7
8
|
} & ButtonProps;
|
8
9
|
export declare function ButtonBarButton({ icon, children, ...props }: ButtonBarButtonProps): JSX.Element;
|
10
|
+
export type ButtonBarDialogButtonProps = {
|
11
|
+
icon?: string;
|
12
|
+
} & DialogButtonProps;
|
13
|
+
export declare function ButtonBarDialogButton({ icon, children, ...props }: ButtonBarDialogButtonProps): JSX.Element;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import { ButtonProps } from "@valerya/ui";
|
3
2
|
import { API } from "@compill/admin-api";
|
3
|
+
import { ButtonProps } from "@valerya/ui";
|
4
4
|
export declare function TableRowPublishPostButton({ id, api, status, invalidateQueryKey, ...props }: {
|
5
5
|
id: string;
|
6
6
|
api: API<any>;
|