@compill/admin 1.0.52 → 1.0.54
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 +128 -88
- package/index.esm.js +127 -90
- package/package.json +1 -1
- package/src/index.d.ts +2 -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 +2 -2
- package/src/lib/json/types/TableView.d.ts +8 -8
- 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
@@ -20,6 +20,7 @@ var admin = require('@compill/admin');
|
|
20
20
|
var reactDom = require('react-dom');
|
21
21
|
var table = require('@compill/table');
|
22
22
|
var hooks = require('@compill/hooks');
|
23
|
+
var router = require('next/router');
|
23
24
|
var reactQuery = require('@tanstack/react-query');
|
24
25
|
|
25
26
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
@@ -192,6 +193,29 @@ function ButtonBarButton(_a) {
|
|
192
193
|
dflex: true,
|
193
194
|
alignItems: "center",
|
194
195
|
placeContent: "center",
|
196
|
+
corners: "square",
|
197
|
+
gap: "2"
|
198
|
+
}, props, {
|
199
|
+
children: [icon && jsxRuntime.jsx(ui.Icon, {
|
200
|
+
path: icon
|
201
|
+
}), children]
|
202
|
+
}));
|
203
|
+
}
|
204
|
+
function ButtonBarDialogButton(_a) {
|
205
|
+
var {
|
206
|
+
icon,
|
207
|
+
children
|
208
|
+
} = _a,
|
209
|
+
props = __rest$1(_a, ["icon", "children"]);
|
210
|
+
return jsxRuntime.jsxs(DialogButton, Object.assign({
|
211
|
+
scheme: "dark",
|
212
|
+
size: "sm",
|
213
|
+
aspectRatio: icon && !children ? "square" : undefined,
|
214
|
+
variant: "borderless",
|
215
|
+
dflex: true,
|
216
|
+
alignItems: "center",
|
217
|
+
placeContent: "center",
|
218
|
+
corners: "square",
|
195
219
|
gap: "2"
|
196
220
|
}, props, {
|
197
221
|
children: [icon && jsxRuntime.jsx(ui.Icon, {
|
@@ -1421,15 +1445,10 @@ function TableCreateButton(_a) {
|
|
1421
1445
|
children
|
1422
1446
|
} = _a,
|
1423
1447
|
props = __rest$1(_a, ["children"]);
|
1424
|
-
return jsxRuntime.
|
1425
|
-
|
1426
|
-
size: "sm",
|
1427
|
-
aspectRatio: "square",
|
1428
|
-
variant: "borderless"
|
1429
|
-
}, props, {
|
1430
|
-
children: children !== null && children !== void 0 ? children : jsxRuntime.jsx(ui.Icon, {
|
1448
|
+
return jsxRuntime.jsxs(admin.ButtonBarDialogButton, Object.assign({}, props, {
|
1449
|
+
children: [jsxRuntime.jsx(ui.Icon, {
|
1431
1450
|
path: mdiPlusThick
|
1432
|
-
})
|
1451
|
+
}), children]
|
1433
1452
|
}));
|
1434
1453
|
}
|
1435
1454
|
|
@@ -2200,11 +2219,13 @@ function ItemDeleteDialog(_a) {
|
|
2200
2219
|
invalidateQueriesOnSuccess = true,
|
2201
2220
|
invalidateQueryKey,
|
2202
2221
|
size = "lg",
|
2222
|
+
md_boxSizing,
|
2223
|
+
msg,
|
2203
2224
|
show,
|
2204
2225
|
onClose
|
2205
2226
|
} = _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.
|
2227
|
+
props = __rest$1(_a, ["itemLabel", "queryId", "api", "invalidateQueriesOnSuccess", "invalidateQueryKey", "size", "md_boxSizing", "msg", "show", "onClose"]);
|
2228
|
+
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
2229
|
const mutate = api.useMutate(mutation, {
|
2209
2230
|
onSuccess: () => onClose === null || onClose === void 0 ? void 0 : onClose()
|
2210
2231
|
});
|
@@ -2221,7 +2242,7 @@ function ItemDeleteDialog(_a) {
|
|
2221
2242
|
children: `Delete ${itemLabel}`
|
2222
2243
|
}), jsxRuntime.jsxs(ui.Modal.Body, {
|
2223
2244
|
pb: "6",
|
2224
|
-
children: [
|
2245
|
+
children: [!msg && `Do you really want to delete ${itemLabel}?`, msg && react.runIfFn(msg, itemLabel)]
|
2225
2246
|
}), jsxRuntime.jsxs(ui.Modal.Footer, {
|
2226
2247
|
dflex: true,
|
2227
2248
|
placeContent: "end",
|
@@ -2268,15 +2289,16 @@ function TableViewProvider({
|
|
2268
2289
|
}
|
2269
2290
|
case "edit":
|
2270
2291
|
{
|
2271
|
-
|
2272
|
-
|
2292
|
+
const editConfig = react.runIfFn(editView, item);
|
2293
|
+
if (editConfig.type == "customDialog") {
|
2294
|
+
setDialog(editConfig.render({
|
2273
2295
|
show: true,
|
2274
2296
|
onClose: onCloseDialog
|
2275
2297
|
}));
|
2276
2298
|
} else {
|
2277
2299
|
setDialog(jsxRuntime.jsx(DialogRenderer, {
|
2278
2300
|
onClose: onCloseDialog,
|
2279
|
-
config:
|
2301
|
+
config: editConfig,
|
2280
2302
|
queryId: item.id,
|
2281
2303
|
invalidateQueryKey: queryKey
|
2282
2304
|
}));
|
@@ -2285,13 +2307,15 @@ function TableViewProvider({
|
|
2285
2307
|
}
|
2286
2308
|
case "delete":
|
2287
2309
|
{
|
2310
|
+
const deleteConfig = react.runIfFn(deleteItem, item);
|
2288
2311
|
setDialog(jsxRuntime.jsx(ItemDeleteDialog, Object.assign({
|
2289
2312
|
show: true,
|
2290
2313
|
onClose: onCloseDialog,
|
2291
2314
|
queryId: item.id,
|
2292
|
-
invalidateQueryKey: queryKey
|
2293
|
-
|
2294
|
-
|
2315
|
+
invalidateQueryKey: queryKey,
|
2316
|
+
msg: item.msg
|
2317
|
+
}, deleteConfig, {
|
2318
|
+
itemLabel: react.runIfFn(deleteConfig.itemLabel, item)
|
2295
2319
|
})));
|
2296
2320
|
// TODO
|
2297
2321
|
// const { initialValues, ...props } = editItem!!
|
@@ -2416,6 +2440,7 @@ function TableRowActionsView({
|
|
2416
2440
|
api,
|
2417
2441
|
queryKey
|
2418
2442
|
}) {
|
2443
|
+
var _a;
|
2419
2444
|
const item = row.original;
|
2420
2445
|
return jsxRuntime.jsx("div", {
|
2421
2446
|
dflex: true,
|
@@ -2423,7 +2448,7 @@ function TableRowActionsView({
|
|
2423
2448
|
alignItems: "stretch",
|
2424
2449
|
placeContent: "end",
|
2425
2450
|
h: "full",
|
2426
|
-
children: rowActions === null ||
|
2451
|
+
children: (_a = react.runIfFn(rowActions, item)) === null || _a === void 0 ? void 0 : _a.map((action, index) => jsxRuntime.jsxs(React__default["default"].Fragment, {
|
2427
2452
|
children: [action.type === "publish" && jsxRuntime.jsx(TableRowPublishPostButton$1, {
|
2428
2453
|
id: item.id,
|
2429
2454
|
api: api,
|
@@ -2452,16 +2477,7 @@ function ActionButton(_a) {
|
|
2452
2477
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
2453
2478
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
2454
2479
|
}, [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",
|
2480
|
+
return jsxRuntime.jsx(admin.TableRowActionButton, Object.assign({
|
2465
2481
|
onClick: handleClick
|
2466
2482
|
}, props));
|
2467
2483
|
}
|
@@ -2484,6 +2500,7 @@ const schemes$1 = {
|
|
2484
2500
|
|
2485
2501
|
function useTableProps(api, table, rowActions) {
|
2486
2502
|
const navigate = reactRouterDom.useNavigate();
|
2503
|
+
const nextRouter = router.useRouter();
|
2487
2504
|
const openLink = hooks.useOpenLink();
|
2488
2505
|
const {
|
2489
2506
|
onAction
|
@@ -2494,7 +2511,7 @@ function useTableProps(api, table, rowActions) {
|
|
2494
2511
|
} = table,
|
2495
2512
|
props = __rest$1(table, ["onRowClick", "columns"]);
|
2496
2513
|
const onRowClickHandler = React__default["default"].useCallback(item => {
|
2497
|
-
if ((onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick.type) === "navigate") navigate(react.runIfFn(onRowClick.path, item));else if ((onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick.type) == "link") openLink(`${process.env["NEXT_PUBLIC_WEBSITE_URL"]}/${react.runIfFn(onRowClick.path, item)}`);
|
2514
|
+
if ((onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick.type) === "navigate") navigate(react.runIfFn(onRowClick.path, item));else if ((onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick.type) == "nextpush") nextRouter.push(react.runIfFn(onRowClick.path, item));else if ((onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick.type) == "link") openLink(`${process.env["NEXT_PUBLIC_WEBSITE_URL"]}/${react.runIfFn(onRowClick.path, item)}`);
|
2498
2515
|
}, [navigate, onRowClick]);
|
2499
2516
|
const columns = React__default["default"].useMemo(() => {
|
2500
2517
|
const columns = table.columns.concat([]);
|
@@ -2619,23 +2636,27 @@ function TableButtonBar({
|
|
2619
2636
|
api,
|
2620
2637
|
children
|
2621
2638
|
}) {
|
2622
|
-
const
|
2623
|
-
|
2624
|
-
|
2625
|
-
|
2626
|
-
|
2627
|
-
|
2628
|
-
|
2629
|
-
|
2630
|
-
|
2631
|
-
|
2632
|
-
|
2639
|
+
const createDialogFn = React__default["default"].useCallback(data => {
|
2640
|
+
return onClose => {
|
2641
|
+
var _a;
|
2642
|
+
const view = (_a = react.runIfFn(createView, data)) !== null && _a !== void 0 ? _a : react.runIfFn(editView, null);
|
2643
|
+
if (view.type == "customDialog") return view.render({
|
2644
|
+
show: true,
|
2645
|
+
onClose
|
2646
|
+
});else return jsxRuntime.jsx(DialogRenderer, {
|
2647
|
+
config: view,
|
2648
|
+
onClose: onClose,
|
2649
|
+
invalidateQueryKey: api.queryKey
|
2650
|
+
});
|
2651
|
+
};
|
2652
|
+
}, [createView, editView, api]);
|
2633
2653
|
return jsxRuntime.jsxs(ButtonBar, {
|
2634
2654
|
children: [jsxRuntime.jsx(RefreshButton, {
|
2635
2655
|
queryKey: queryKey
|
2636
2656
|
}), buttonBar && buttonBar.map((button, index) => jsxRuntime.jsxs(React__default["default"].Fragment, {
|
2637
2657
|
children: [button.type === "create" && editView && jsxRuntime.jsx(TableCreateButton, {
|
2638
|
-
buildDialog:
|
2658
|
+
buildDialog: createDialogFn(button.data),
|
2659
|
+
children: button.label
|
2639
2660
|
}), button.type === "invalidate" && jsxRuntime.jsx(InvalidateButton, {
|
2640
2661
|
pathOrPermalink: button.pathOrPermalink
|
2641
2662
|
}), button.type === "custom" && button.render()]
|
@@ -2976,7 +2997,7 @@ function LeftPanel({
|
|
2976
2997
|
const [isOpen, __, toggle] = hooks.useBoolean(true);
|
2977
2998
|
useHotkeys('ctrl+t', () => toggle(), [toggle]);
|
2978
2999
|
return jsxRuntime.jsxs("div", {
|
2979
|
-
ms: isOpen ? "0" : "-
|
3000
|
+
ms: isOpen ? "0" : "-14.5rem",
|
2980
3001
|
transition: "all",
|
2981
3002
|
duration: "500",
|
2982
3003
|
transform: true,
|
@@ -3483,6 +3504,31 @@ function StatusBadge(_a) {
|
|
3483
3504
|
}));
|
3484
3505
|
}
|
3485
3506
|
|
3507
|
+
function TableRowActionButton(_a) {
|
3508
|
+
var {
|
3509
|
+
icon,
|
3510
|
+
children
|
3511
|
+
} = _a,
|
3512
|
+
props = __rest$1(_a, ["icon", "children"]);
|
3513
|
+
return jsxRuntime.jsxs(ui.Button, Object.assign({
|
3514
|
+
dflex: true,
|
3515
|
+
alignContent: "center",
|
3516
|
+
placeContent: "center",
|
3517
|
+
py: "2.5",
|
3518
|
+
px: "3",
|
3519
|
+
h: "full",
|
3520
|
+
size: "lg",
|
3521
|
+
variant: "borderless",
|
3522
|
+
corners: "square",
|
3523
|
+
gap: "2"
|
3524
|
+
}, props, {
|
3525
|
+
children: [icon && jsxRuntime.jsx(ui.Icon, {
|
3526
|
+
path: icon,
|
3527
|
+
size: "sm"
|
3528
|
+
}), children]
|
3529
|
+
}));
|
3530
|
+
}
|
3531
|
+
|
3486
3532
|
function TableRowViewButton(_a) {
|
3487
3533
|
var {
|
3488
3534
|
path
|
@@ -3493,18 +3539,10 @@ function TableRowViewButton(_a) {
|
|
3493
3539
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
3494
3540
|
window.open(`${process.env["NEXT_PUBLIC_WEBSITE_URL"]}/${path}`, '_blank');
|
3495
3541
|
}, [path]);
|
3496
|
-
return jsxRuntime.jsx(
|
3497
|
-
|
3498
|
-
h: "10",
|
3499
|
-
variant: "borderless",
|
3500
|
-
corners: "pill",
|
3501
|
-
scheme: "dark",
|
3542
|
+
return jsxRuntime.jsx(TableRowActionButton, Object.assign({
|
3543
|
+
icon: mdiOpenInNew,
|
3502
3544
|
onClick: openPage
|
3503
|
-
}, props
|
3504
|
-
children: jsxRuntime.jsx(ui.Icon, {
|
3505
|
-
path: mdiOpenInNew
|
3506
|
-
})
|
3507
|
-
}));
|
3545
|
+
}, props));
|
3508
3546
|
}
|
3509
3547
|
|
3510
3548
|
function TableRowNavigateButton(_a) {
|
@@ -3518,15 +3556,34 @@ function TableRowNavigateButton(_a) {
|
|
3518
3556
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
3519
3557
|
navigate(`${path}`);
|
3520
3558
|
}, [navigate, path]);
|
3521
|
-
return jsxRuntime.jsx(
|
3522
|
-
|
3559
|
+
return jsxRuntime.jsx(TableRowActionButton, Object.assign({
|
3560
|
+
icon: mdiEye,
|
3561
|
+
onClick: handleClick
|
3562
|
+
}, props));
|
3563
|
+
}
|
3564
|
+
|
3565
|
+
function TableRowActionDialogButton(_a) {
|
3566
|
+
var {
|
3567
|
+
icon,
|
3568
|
+
children
|
3569
|
+
} = _a,
|
3570
|
+
props = __rest$1(_a, ["icon", "children"]);
|
3571
|
+
return jsxRuntime.jsxs(admin.DialogButton, Object.assign({
|
3572
|
+
dflex: true,
|
3573
|
+
alignContent: "center",
|
3574
|
+
placeContent: "center",
|
3575
|
+
py: "2.5",
|
3576
|
+
px: "3",
|
3577
|
+
h: "full",
|
3578
|
+
size: "lg",
|
3523
3579
|
variant: "borderless",
|
3524
3580
|
corners: "square",
|
3525
|
-
|
3581
|
+
gap: "2"
|
3526
3582
|
}, props, {
|
3527
|
-
children: jsxRuntime.jsx(ui.Icon, {
|
3528
|
-
path:
|
3529
|
-
|
3583
|
+
children: [icon && jsxRuntime.jsx(ui.Icon, {
|
3584
|
+
path: icon,
|
3585
|
+
size: "sm"
|
3586
|
+
}), children]
|
3530
3587
|
}));
|
3531
3588
|
}
|
3532
3589
|
|
@@ -3535,16 +3592,10 @@ function TableRowEditButton(_a) {
|
|
3535
3592
|
children
|
3536
3593
|
} = _a,
|
3537
3594
|
props = __rest$1(_a, ["children"]);
|
3538
|
-
return jsxRuntime.jsx(
|
3539
|
-
|
3540
|
-
h: "10",
|
3541
|
-
variant: "borderless",
|
3542
|
-
corners: "pill",
|
3543
|
-
scheme: "warning"
|
3595
|
+
return jsxRuntime.jsx(TableRowActionDialogButton, Object.assign({
|
3596
|
+
icon: mdiPencil
|
3544
3597
|
}, props, {
|
3545
|
-
children: children
|
3546
|
-
path: mdiPencil
|
3547
|
-
})
|
3598
|
+
children: children
|
3548
3599
|
}));
|
3549
3600
|
}
|
3550
3601
|
|
@@ -3553,16 +3604,10 @@ function TableRowDeleteButton(_a) {
|
|
3553
3604
|
children
|
3554
3605
|
} = _a,
|
3555
3606
|
props = __rest$1(_a, ["children"]);
|
3556
|
-
return jsxRuntime.jsx(
|
3557
|
-
|
3558
|
-
h: "10",
|
3559
|
-
scheme: "danger",
|
3560
|
-
variant: "borderless",
|
3561
|
-
corners: "pill"
|
3607
|
+
return jsxRuntime.jsx(TableRowActionDialogButton, Object.assign({
|
3608
|
+
icon: mdiDelete
|
3562
3609
|
}, props, {
|
3563
|
-
children: children
|
3564
|
-
path: mdiDelete
|
3565
|
-
})
|
3610
|
+
children: children
|
3566
3611
|
}));
|
3567
3612
|
}
|
3568
3613
|
|
@@ -3611,18 +3656,10 @@ function TableRowPublishPostButton(_a) {
|
|
3611
3656
|
mutation.reset();
|
3612
3657
|
mutation.mutateAsync(id).then(() => reactToastify.toast.success(isDraft ? "Published!" : "Unpublished!")).catch(error => reactToastify.toast.error(`Error: ${error}`));
|
3613
3658
|
}, [mutation, id]);
|
3614
|
-
return jsxRuntime.jsx(
|
3615
|
-
|
3616
|
-
h: "10",
|
3617
|
-
variant: "borderless",
|
3618
|
-
corners: "pill",
|
3619
|
-
scheme: "default",
|
3659
|
+
return jsxRuntime.jsx(TableRowActionButton, Object.assign({
|
3660
|
+
icon: isDraft ? mdiPublish : mdiPublishOff,
|
3620
3661
|
onClick: publish
|
3621
|
-
}, props
|
3622
|
-
children: jsxRuntime.jsx(ui.Icon, {
|
3623
|
-
path: isDraft ? mdiPublish : mdiPublishOff
|
3624
|
-
})
|
3625
|
-
}));
|
3662
|
+
}, props));
|
3626
3663
|
}
|
3627
3664
|
|
3628
3665
|
exports.AdminLayout = AdminLayout;
|
@@ -3630,6 +3667,7 @@ exports.AttachDialog = AttachDialog;
|
|
3630
3667
|
exports.Breadcrumbs = Breadcrumbs;
|
3631
3668
|
exports.ButtonBar = ButtonBar;
|
3632
3669
|
exports.ButtonBarButton = ButtonBarButton;
|
3670
|
+
exports.ButtonBarDialogButton = ButtonBarDialogButton;
|
3633
3671
|
exports.DialogButton = DialogButton;
|
3634
3672
|
exports.FormActionDialog = FormActionDialog;
|
3635
3673
|
exports.InvalidateButton = InvalidateButton;
|
@@ -3658,6 +3696,8 @@ exports.TableContainer = TableContainer;
|
|
3658
3696
|
exports.TableCreateButton = TableCreateButton;
|
3659
3697
|
exports.TableFilterButton = TableFilterButton;
|
3660
3698
|
exports.TableRowActionBar = TableRowActionBar;
|
3699
|
+
exports.TableRowActionButton = TableRowActionButton;
|
3700
|
+
exports.TableRowActionDialogButton = TableRowActionDialogButton;
|
3661
3701
|
exports.TableRowDeleteButton = TableRowDeleteButton;
|
3662
3702
|
exports.TableRowEditButton = TableRowEditButton;
|
3663
3703
|
exports.TableRowNavigateButton = TableRowNavigateButton;
|
package/index.esm.js
CHANGED
@@ -12,10 +12,11 @@ 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';
|
19
|
+
import { useRouter } from 'next/router';
|
19
20
|
import { useQueryClient } from '@tanstack/react-query';
|
20
21
|
|
21
22
|
/******************************************************************************
|
@@ -183,6 +184,29 @@ function ButtonBarButton(_a) {
|
|
183
184
|
dflex: true,
|
184
185
|
alignItems: "center",
|
185
186
|
placeContent: "center",
|
187
|
+
corners: "square",
|
188
|
+
gap: "2"
|
189
|
+
}, props, {
|
190
|
+
children: [icon && jsx(Icon, {
|
191
|
+
path: icon
|
192
|
+
}), children]
|
193
|
+
}));
|
194
|
+
}
|
195
|
+
function ButtonBarDialogButton(_a) {
|
196
|
+
var {
|
197
|
+
icon,
|
198
|
+
children
|
199
|
+
} = _a,
|
200
|
+
props = __rest$1(_a, ["icon", "children"]);
|
201
|
+
return jsxs(DialogButton, Object.assign({
|
202
|
+
scheme: "dark",
|
203
|
+
size: "sm",
|
204
|
+
aspectRatio: icon && !children ? "square" : undefined,
|
205
|
+
variant: "borderless",
|
206
|
+
dflex: true,
|
207
|
+
alignItems: "center",
|
208
|
+
placeContent: "center",
|
209
|
+
corners: "square",
|
186
210
|
gap: "2"
|
187
211
|
}, props, {
|
188
212
|
children: [icon && jsx(Icon, {
|
@@ -1412,15 +1436,10 @@ function TableCreateButton(_a) {
|
|
1412
1436
|
children
|
1413
1437
|
} = _a,
|
1414
1438
|
props = __rest$1(_a, ["children"]);
|
1415
|
-
return
|
1416
|
-
|
1417
|
-
size: "sm",
|
1418
|
-
aspectRatio: "square",
|
1419
|
-
variant: "borderless"
|
1420
|
-
}, props, {
|
1421
|
-
children: children !== null && children !== void 0 ? children : jsx(Icon, {
|
1439
|
+
return jsxs(ButtonBarDialogButton$1, Object.assign({}, props, {
|
1440
|
+
children: [jsx(Icon, {
|
1422
1441
|
path: mdiPlusThick
|
1423
|
-
})
|
1442
|
+
}), children]
|
1424
1443
|
}));
|
1425
1444
|
}
|
1426
1445
|
|
@@ -2191,11 +2210,13 @@ function ItemDeleteDialog(_a) {
|
|
2191
2210
|
invalidateQueriesOnSuccess = true,
|
2192
2211
|
invalidateQueryKey,
|
2193
2212
|
size = "lg",
|
2213
|
+
md_boxSizing,
|
2214
|
+
msg,
|
2194
2215
|
show,
|
2195
2216
|
onClose
|
2196
2217
|
} = _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.
|
2218
|
+
props = __rest$1(_a, ["itemLabel", "queryId", "api", "invalidateQueriesOnSuccess", "invalidateQueryKey", "size", "md_boxSizing", "msg", "show", "onClose"]);
|
2219
|
+
const mutation = invalidateQueriesOnSuccess ? useInvalidateParentMutation(api.delete, invalidateQueryKey !== null && invalidateQueryKey !== void 0 ? invalidateQueryKey : api.queryKey) : useApiMutation(api.delete, api.queryKey);
|
2199
2220
|
const mutate = useMutate(mutation, {
|
2200
2221
|
onSuccess: () => onClose === null || onClose === void 0 ? void 0 : onClose()
|
2201
2222
|
});
|
@@ -2212,7 +2233,7 @@ function ItemDeleteDialog(_a) {
|
|
2212
2233
|
children: `Delete ${itemLabel}`
|
2213
2234
|
}), jsxs(Modal.Body, {
|
2214
2235
|
pb: "6",
|
2215
|
-
children: [
|
2236
|
+
children: [!msg && `Do you really want to delete ${itemLabel}?`, msg && runIfFn(msg, itemLabel)]
|
2216
2237
|
}), jsxs(Modal.Footer, {
|
2217
2238
|
dflex: true,
|
2218
2239
|
placeContent: "end",
|
@@ -2259,15 +2280,16 @@ function TableViewProvider({
|
|
2259
2280
|
}
|
2260
2281
|
case "edit":
|
2261
2282
|
{
|
2262
|
-
|
2263
|
-
|
2283
|
+
const editConfig = runIfFn(editView, item);
|
2284
|
+
if (editConfig.type == "customDialog") {
|
2285
|
+
setDialog(editConfig.render({
|
2264
2286
|
show: true,
|
2265
2287
|
onClose: onCloseDialog
|
2266
2288
|
}));
|
2267
2289
|
} else {
|
2268
2290
|
setDialog(jsx(DialogRenderer, {
|
2269
2291
|
onClose: onCloseDialog,
|
2270
|
-
config:
|
2292
|
+
config: editConfig,
|
2271
2293
|
queryId: item.id,
|
2272
2294
|
invalidateQueryKey: queryKey
|
2273
2295
|
}));
|
@@ -2276,13 +2298,15 @@ function TableViewProvider({
|
|
2276
2298
|
}
|
2277
2299
|
case "delete":
|
2278
2300
|
{
|
2301
|
+
const deleteConfig = runIfFn(deleteItem, item);
|
2279
2302
|
setDialog(jsx(ItemDeleteDialog, Object.assign({
|
2280
2303
|
show: true,
|
2281
2304
|
onClose: onCloseDialog,
|
2282
2305
|
queryId: item.id,
|
2283
|
-
invalidateQueryKey: queryKey
|
2284
|
-
|
2285
|
-
|
2306
|
+
invalidateQueryKey: queryKey,
|
2307
|
+
msg: item.msg
|
2308
|
+
}, deleteConfig, {
|
2309
|
+
itemLabel: runIfFn(deleteConfig.itemLabel, item)
|
2286
2310
|
})));
|
2287
2311
|
// TODO
|
2288
2312
|
// const { initialValues, ...props } = editItem!!
|
@@ -2407,6 +2431,7 @@ function TableRowActionsView({
|
|
2407
2431
|
api,
|
2408
2432
|
queryKey
|
2409
2433
|
}) {
|
2434
|
+
var _a;
|
2410
2435
|
const item = row.original;
|
2411
2436
|
return jsx("div", {
|
2412
2437
|
dflex: true,
|
@@ -2414,7 +2439,7 @@ function TableRowActionsView({
|
|
2414
2439
|
alignItems: "stretch",
|
2415
2440
|
placeContent: "end",
|
2416
2441
|
h: "full",
|
2417
|
-
children: rowActions === null ||
|
2442
|
+
children: (_a = runIfFn(rowActions, item)) === null || _a === void 0 ? void 0 : _a.map((action, index) => jsxs(React.Fragment, {
|
2418
2443
|
children: [action.type === "publish" && jsx(TableRowPublishPostButton$1, {
|
2419
2444
|
id: item.id,
|
2420
2445
|
api: api,
|
@@ -2443,16 +2468,7 @@ function ActionButton(_a) {
|
|
2443
2468
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
2444
2469
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
2445
2470
|
}, [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",
|
2471
|
+
return jsx(TableRowActionButton$1, Object.assign({
|
2456
2472
|
onClick: handleClick
|
2457
2473
|
}, props));
|
2458
2474
|
}
|
@@ -2475,6 +2491,7 @@ const schemes$1 = {
|
|
2475
2491
|
|
2476
2492
|
function useTableProps(api, table, rowActions) {
|
2477
2493
|
const navigate = useNavigate();
|
2494
|
+
const nextRouter = useRouter();
|
2478
2495
|
const openLink = useOpenLink();
|
2479
2496
|
const {
|
2480
2497
|
onAction
|
@@ -2485,7 +2502,7 @@ function useTableProps(api, table, rowActions) {
|
|
2485
2502
|
} = table,
|
2486
2503
|
props = __rest$1(table, ["onRowClick", "columns"]);
|
2487
2504
|
const onRowClickHandler = React.useCallback(item => {
|
2488
|
-
if ((onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick.type) === "navigate") navigate(runIfFn(onRowClick.path, item));else if ((onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick.type) == "link") openLink(`${process.env["NEXT_PUBLIC_WEBSITE_URL"]}/${runIfFn(onRowClick.path, item)}`);
|
2505
|
+
if ((onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick.type) === "navigate") navigate(runIfFn(onRowClick.path, item));else if ((onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick.type) == "nextpush") nextRouter.push(runIfFn(onRowClick.path, item));else if ((onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick.type) == "link") openLink(`${process.env["NEXT_PUBLIC_WEBSITE_URL"]}/${runIfFn(onRowClick.path, item)}`);
|
2489
2506
|
}, [navigate, onRowClick]);
|
2490
2507
|
const columns = React.useMemo(() => {
|
2491
2508
|
const columns = table.columns.concat([]);
|
@@ -2610,23 +2627,27 @@ function TableButtonBar({
|
|
2610
2627
|
api,
|
2611
2628
|
children
|
2612
2629
|
}) {
|
2613
|
-
const
|
2614
|
-
|
2615
|
-
|
2616
|
-
|
2617
|
-
|
2618
|
-
|
2619
|
-
|
2620
|
-
|
2621
|
-
|
2622
|
-
|
2623
|
-
|
2630
|
+
const createDialogFn = React.useCallback(data => {
|
2631
|
+
return onClose => {
|
2632
|
+
var _a;
|
2633
|
+
const view = (_a = runIfFn(createView, data)) !== null && _a !== void 0 ? _a : runIfFn(editView, null);
|
2634
|
+
if (view.type == "customDialog") return view.render({
|
2635
|
+
show: true,
|
2636
|
+
onClose
|
2637
|
+
});else return jsx(DialogRenderer, {
|
2638
|
+
config: view,
|
2639
|
+
onClose: onClose,
|
2640
|
+
invalidateQueryKey: api.queryKey
|
2641
|
+
});
|
2642
|
+
};
|
2643
|
+
}, [createView, editView, api]);
|
2624
2644
|
return jsxs(ButtonBar, {
|
2625
2645
|
children: [jsx(RefreshButton, {
|
2626
2646
|
queryKey: queryKey
|
2627
2647
|
}), buttonBar && buttonBar.map((button, index) => jsxs(React.Fragment, {
|
2628
2648
|
children: [button.type === "create" && editView && jsx(TableCreateButton, {
|
2629
|
-
buildDialog:
|
2649
|
+
buildDialog: createDialogFn(button.data),
|
2650
|
+
children: button.label
|
2630
2651
|
}), button.type === "invalidate" && jsx(InvalidateButton, {
|
2631
2652
|
pathOrPermalink: button.pathOrPermalink
|
2632
2653
|
}), button.type === "custom" && button.render()]
|
@@ -2967,7 +2988,7 @@ function LeftPanel({
|
|
2967
2988
|
const [isOpen, __, toggle] = useBoolean(true);
|
2968
2989
|
useHotkeys('ctrl+t', () => toggle(), [toggle]);
|
2969
2990
|
return jsxs("div", {
|
2970
|
-
ms: isOpen ? "0" : "-
|
2991
|
+
ms: isOpen ? "0" : "-14.5rem",
|
2971
2992
|
transition: "all",
|
2972
2993
|
duration: "500",
|
2973
2994
|
transform: true,
|
@@ -3474,6 +3495,31 @@ function StatusBadge(_a) {
|
|
3474
3495
|
}));
|
3475
3496
|
}
|
3476
3497
|
|
3498
|
+
function TableRowActionButton(_a) {
|
3499
|
+
var {
|
3500
|
+
icon,
|
3501
|
+
children
|
3502
|
+
} = _a,
|
3503
|
+
props = __rest$1(_a, ["icon", "children"]);
|
3504
|
+
return jsxs(Button, Object.assign({
|
3505
|
+
dflex: true,
|
3506
|
+
alignContent: "center",
|
3507
|
+
placeContent: "center",
|
3508
|
+
py: "2.5",
|
3509
|
+
px: "3",
|
3510
|
+
h: "full",
|
3511
|
+
size: "lg",
|
3512
|
+
variant: "borderless",
|
3513
|
+
corners: "square",
|
3514
|
+
gap: "2"
|
3515
|
+
}, props, {
|
3516
|
+
children: [icon && jsx(Icon, {
|
3517
|
+
path: icon,
|
3518
|
+
size: "sm"
|
3519
|
+
}), children]
|
3520
|
+
}));
|
3521
|
+
}
|
3522
|
+
|
3477
3523
|
function TableRowViewButton(_a) {
|
3478
3524
|
var {
|
3479
3525
|
path
|
@@ -3484,18 +3530,10 @@ function TableRowViewButton(_a) {
|
|
3484
3530
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
3485
3531
|
window.open(`${process.env["NEXT_PUBLIC_WEBSITE_URL"]}/${path}`, '_blank');
|
3486
3532
|
}, [path]);
|
3487
|
-
return jsx(
|
3488
|
-
|
3489
|
-
h: "10",
|
3490
|
-
variant: "borderless",
|
3491
|
-
corners: "pill",
|
3492
|
-
scheme: "dark",
|
3533
|
+
return jsx(TableRowActionButton, Object.assign({
|
3534
|
+
icon: mdiOpenInNew,
|
3493
3535
|
onClick: openPage
|
3494
|
-
}, props
|
3495
|
-
children: jsx(Icon, {
|
3496
|
-
path: mdiOpenInNew
|
3497
|
-
})
|
3498
|
-
}));
|
3536
|
+
}, props));
|
3499
3537
|
}
|
3500
3538
|
|
3501
3539
|
function TableRowNavigateButton(_a) {
|
@@ -3509,15 +3547,34 @@ function TableRowNavigateButton(_a) {
|
|
3509
3547
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
3510
3548
|
navigate(`${path}`);
|
3511
3549
|
}, [navigate, path]);
|
3512
|
-
return jsx(
|
3513
|
-
|
3550
|
+
return jsx(TableRowActionButton, Object.assign({
|
3551
|
+
icon: mdiEye,
|
3552
|
+
onClick: handleClick
|
3553
|
+
}, props));
|
3554
|
+
}
|
3555
|
+
|
3556
|
+
function TableRowActionDialogButton(_a) {
|
3557
|
+
var {
|
3558
|
+
icon,
|
3559
|
+
children
|
3560
|
+
} = _a,
|
3561
|
+
props = __rest$1(_a, ["icon", "children"]);
|
3562
|
+
return jsxs(DialogButton$1, Object.assign({
|
3563
|
+
dflex: true,
|
3564
|
+
alignContent: "center",
|
3565
|
+
placeContent: "center",
|
3566
|
+
py: "2.5",
|
3567
|
+
px: "3",
|
3568
|
+
h: "full",
|
3569
|
+
size: "lg",
|
3514
3570
|
variant: "borderless",
|
3515
3571
|
corners: "square",
|
3516
|
-
|
3572
|
+
gap: "2"
|
3517
3573
|
}, props, {
|
3518
|
-
children: jsx(Icon, {
|
3519
|
-
path:
|
3520
|
-
|
3574
|
+
children: [icon && jsx(Icon, {
|
3575
|
+
path: icon,
|
3576
|
+
size: "sm"
|
3577
|
+
}), children]
|
3521
3578
|
}));
|
3522
3579
|
}
|
3523
3580
|
|
@@ -3526,16 +3583,10 @@ function TableRowEditButton(_a) {
|
|
3526
3583
|
children
|
3527
3584
|
} = _a,
|
3528
3585
|
props = __rest$1(_a, ["children"]);
|
3529
|
-
return jsx(
|
3530
|
-
|
3531
|
-
h: "10",
|
3532
|
-
variant: "borderless",
|
3533
|
-
corners: "pill",
|
3534
|
-
scheme: "warning"
|
3586
|
+
return jsx(TableRowActionDialogButton, Object.assign({
|
3587
|
+
icon: mdiPencil
|
3535
3588
|
}, props, {
|
3536
|
-
children: children
|
3537
|
-
path: mdiPencil
|
3538
|
-
})
|
3589
|
+
children: children
|
3539
3590
|
}));
|
3540
3591
|
}
|
3541
3592
|
|
@@ -3544,16 +3595,10 @@ function TableRowDeleteButton(_a) {
|
|
3544
3595
|
children
|
3545
3596
|
} = _a,
|
3546
3597
|
props = __rest$1(_a, ["children"]);
|
3547
|
-
return jsx(
|
3548
|
-
|
3549
|
-
h: "10",
|
3550
|
-
scheme: "danger",
|
3551
|
-
variant: "borderless",
|
3552
|
-
corners: "pill"
|
3598
|
+
return jsx(TableRowActionDialogButton, Object.assign({
|
3599
|
+
icon: mdiDelete
|
3553
3600
|
}, props, {
|
3554
|
-
children: children
|
3555
|
-
path: mdiDelete
|
3556
|
-
})
|
3601
|
+
children: children
|
3557
3602
|
}));
|
3558
3603
|
}
|
3559
3604
|
|
@@ -3602,18 +3647,10 @@ function TableRowPublishPostButton(_a) {
|
|
3602
3647
|
mutation.reset();
|
3603
3648
|
mutation.mutateAsync(id).then(() => toast.success(isDraft ? "Published!" : "Unpublished!")).catch(error => toast.error(`Error: ${error}`));
|
3604
3649
|
}, [mutation, id]);
|
3605
|
-
return jsx(
|
3606
|
-
|
3607
|
-
h: "10",
|
3608
|
-
variant: "borderless",
|
3609
|
-
corners: "pill",
|
3610
|
-
scheme: "default",
|
3650
|
+
return jsx(TableRowActionButton, Object.assign({
|
3651
|
+
icon: isDraft ? mdiPublish : mdiPublishOff,
|
3611
3652
|
onClick: publish
|
3612
|
-
}, props
|
3613
|
-
children: jsx(Icon, {
|
3614
|
-
path: isDraft ? mdiPublish : mdiPublishOff
|
3615
|
-
})
|
3616
|
-
}));
|
3653
|
+
}, props));
|
3617
3654
|
}
|
3618
3655
|
|
3619
|
-
export { AdminLayout, AttachDialog, Breadcrumbs, ButtonBar, ButtonBarButton, 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 };
|
3656
|
+
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
@@ -38,6 +38,8 @@ export * from "./lib/table/TableContainer";
|
|
38
38
|
export * from "./lib/table/TableCreateButton";
|
39
39
|
export * from "./lib/table/TableFilterButton";
|
40
40
|
export * from "./lib/table/TableRowActionBar";
|
41
|
+
export * from "./lib/table/TableRowActionButton";
|
42
|
+
export * from "./lib/table/TableRowActionDialogButton";
|
41
43
|
export * from "./lib/table/TableRowDeleteButton";
|
42
44
|
export * from "./lib/table/TableRowEditButton";
|
43
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
|
-
import { TableRowAction, TableViewTable } from "../types/TableView";
|
2
1
|
import { API } from "@compill/admin-api";
|
3
|
-
|
2
|
+
import { TableRowAction, TableViewTable } from "../types/TableView";
|
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";
|
@@ -36,10 +36,7 @@ export type TableViewEditView = CustomDialog | EditItemDialogConfig | QueryWrapp
|
|
36
36
|
export type TableViewTable = Omit<TableProps, "onRowClick" | "queryKey" | "queryFn"> & {
|
37
37
|
initialVisibleColumns?: string[];
|
38
38
|
onRowClick?: {
|
39
|
-
type: "navigate";
|
40
|
-
path: string | ((item: any) => string);
|
41
|
-
} | {
|
42
|
-
type: "link";
|
39
|
+
type: "navigate" | "nextpush" | "link";
|
43
40
|
path: string | ((item: any) => string);
|
44
41
|
};
|
45
42
|
};
|
@@ -56,6 +53,7 @@ export type TableRowAction = {
|
|
56
53
|
type: "edit";
|
57
54
|
} | {
|
58
55
|
type: "delete";
|
56
|
+
msg?: (itemLabel: string) => (string | React.ReactNode);
|
59
57
|
} | {
|
60
58
|
type: "publish";
|
61
59
|
} | {
|
@@ -67,6 +65,8 @@ export type TableRowAction = {
|
|
67
65
|
export type TableViewButtonBar = TableViewButtonConfig[];
|
68
66
|
type TableViewButtonConfig = {
|
69
67
|
type: "create";
|
68
|
+
data?: any;
|
69
|
+
label?: string;
|
70
70
|
} | {
|
71
71
|
type: "invalidate";
|
72
72
|
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>;
|