@compill/admin 1.0.53 → 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 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 }; }
@@ -1444,10 +1445,10 @@ function TableCreateButton(_a) {
1444
1445
  children
1445
1446
  } = _a,
1446
1447
  props = __rest$1(_a, ["children"]);
1447
- return jsxRuntime.jsx(admin.ButtonBarDialogButton, Object.assign({}, props, {
1448
- 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, {
1449
1450
  path: mdiPlusThick
1450
- })
1451
+ }), children]
1451
1452
  }));
1452
1453
  }
1453
1454
 
@@ -2241,7 +2242,7 @@ function ItemDeleteDialog(_a) {
2241
2242
  children: `Delete ${itemLabel}`
2242
2243
  }), jsxRuntime.jsxs(ui.Modal.Body, {
2243
2244
  pb: "6",
2244
- children: [!msg && `Do you really want to delete ${itemLabel}?`, msg && msg(itemLabel)]
2245
+ children: [!msg && `Do you really want to delete ${itemLabel}?`, msg && react.runIfFn(msg, itemLabel)]
2245
2246
  }), jsxRuntime.jsxs(ui.Modal.Footer, {
2246
2247
  dflex: true,
2247
2248
  placeContent: "end",
@@ -2499,6 +2500,7 @@ const schemes$1 = {
2499
2500
 
2500
2501
  function useTableProps(api, table, rowActions) {
2501
2502
  const navigate = reactRouterDom.useNavigate();
2503
+ const nextRouter = router.useRouter();
2502
2504
  const openLink = hooks.useOpenLink();
2503
2505
  const {
2504
2506
  onAction
@@ -2509,7 +2511,7 @@ function useTableProps(api, table, rowActions) {
2509
2511
  } = table,
2510
2512
  props = __rest$1(table, ["onRowClick", "columns"]);
2511
2513
  const onRowClickHandler = React__default["default"].useCallback(item => {
2512
- 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)}`);
2513
2515
  }, [navigate, onRowClick]);
2514
2516
  const columns = React__default["default"].useMemo(() => {
2515
2517
  const columns = table.columns.concat([]);
@@ -2653,7 +2655,8 @@ function TableButtonBar({
2653
2655
  queryKey: queryKey
2654
2656
  }), buttonBar && buttonBar.map((button, index) => jsxRuntime.jsxs(React__default["default"].Fragment, {
2655
2657
  children: [button.type === "create" && editView && jsxRuntime.jsx(TableCreateButton, {
2656
- buildDialog: createDialogFn(button.data)
2658
+ buildDialog: createDialogFn(button.data),
2659
+ children: button.label
2657
2660
  }), button.type === "invalidate" && jsxRuntime.jsx(InvalidateButton, {
2658
2661
  pathOrPermalink: button.pathOrPermalink
2659
2662
  }), button.type === "custom" && button.render()]
package/index.esm.js CHANGED
@@ -16,6 +16,7 @@ import { PageSectionTitle as PageSectionTitle$1, ButtonBarDialogButton as Button
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
  /******************************************************************************
@@ -1435,10 +1436,10 @@ function TableCreateButton(_a) {
1435
1436
  children
1436
1437
  } = _a,
1437
1438
  props = __rest$1(_a, ["children"]);
1438
- return jsx(ButtonBarDialogButton$1, Object.assign({}, props, {
1439
- children: children !== null && children !== void 0 ? children : jsx(Icon, {
1439
+ return jsxs(ButtonBarDialogButton$1, Object.assign({}, props, {
1440
+ children: [jsx(Icon, {
1440
1441
  path: mdiPlusThick
1441
- })
1442
+ }), children]
1442
1443
  }));
1443
1444
  }
1444
1445
 
@@ -2232,7 +2233,7 @@ function ItemDeleteDialog(_a) {
2232
2233
  children: `Delete ${itemLabel}`
2233
2234
  }), jsxs(Modal.Body, {
2234
2235
  pb: "6",
2235
- children: [!msg && `Do you really want to delete ${itemLabel}?`, msg && msg(itemLabel)]
2236
+ children: [!msg && `Do you really want to delete ${itemLabel}?`, msg && runIfFn(msg, itemLabel)]
2236
2237
  }), jsxs(Modal.Footer, {
2237
2238
  dflex: true,
2238
2239
  placeContent: "end",
@@ -2490,6 +2491,7 @@ const schemes$1 = {
2490
2491
 
2491
2492
  function useTableProps(api, table, rowActions) {
2492
2493
  const navigate = useNavigate();
2494
+ const nextRouter = useRouter();
2493
2495
  const openLink = useOpenLink();
2494
2496
  const {
2495
2497
  onAction
@@ -2500,7 +2502,7 @@ function useTableProps(api, table, rowActions) {
2500
2502
  } = table,
2501
2503
  props = __rest$1(table, ["onRowClick", "columns"]);
2502
2504
  const onRowClickHandler = React.useCallback(item => {
2503
- 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)}`);
2504
2506
  }, [navigate, onRowClick]);
2505
2507
  const columns = React.useMemo(() => {
2506
2508
  const columns = table.columns.concat([]);
@@ -2644,7 +2646,8 @@ function TableButtonBar({
2644
2646
  queryKey: queryKey
2645
2647
  }), buttonBar && buttonBar.map((button, index) => jsxs(React.Fragment, {
2646
2648
  children: [button.type === "create" && editView && jsx(TableCreateButton, {
2647
- buildDialog: createDialogFn(button.data)
2649
+ buildDialog: createDialogFn(button.data),
2650
+ children: button.label
2648
2651
  }), button.type === "invalidate" && jsx(InvalidateButton, {
2649
2652
  pathOrPermalink: button.pathOrPermalink
2650
2653
  }), button.type === "custom" && button.render()]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compill/admin",
3
- "version": "1.0.53",
3
+ "version": "1.0.54",
4
4
  "module": "./index.esm.js",
5
5
  "main": "./index.cjs.js"
6
6
  }
@@ -1,3 +1,3 @@
1
- import { TableRowAction, TableViewTable } from "../types/TableView";
2
1
  import { API } from "@compill/admin-api";
2
+ import { TableRowAction, TableViewTable } from "../types/TableView";
3
3
  export declare function useTableProps(api: API<any>, table: TableViewTable, rowActions?: TableRowAction[] | ((item?: any) => TableRowAction[])): any;
@@ -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
  };