@compill/admin 1.0.54 → 1.0.56

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
@@ -1442,12 +1442,13 @@ function TableContainer(_a) {
1442
1442
 
1443
1443
  function TableCreateButton(_a) {
1444
1444
  var {
1445
+ icon,
1445
1446
  children
1446
1447
  } = _a,
1447
- props = __rest$1(_a, ["children"]);
1448
+ props = __rest$1(_a, ["icon", "children"]);
1448
1449
  return jsxRuntime.jsxs(admin.ButtonBarDialogButton, Object.assign({}, props, {
1449
1450
  children: [jsxRuntime.jsx(ui.Icon, {
1450
- path: mdiPlusThick
1451
+ path: icon !== null && icon !== void 0 ? icon : mdiPlusThick
1451
1452
  }), children]
1452
1453
  }));
1453
1454
  }
@@ -2290,18 +2291,20 @@ function TableViewProvider({
2290
2291
  case "edit":
2291
2292
  {
2292
2293
  const editConfig = react.runIfFn(editView, item);
2293
- if (editConfig.type == "customDialog") {
2294
- setDialog(editConfig.render({
2295
- show: true,
2296
- onClose: onCloseDialog
2297
- }));
2298
- } else {
2299
- setDialog(jsxRuntime.jsx(DialogRenderer, {
2300
- onClose: onCloseDialog,
2301
- config: editConfig,
2302
- queryId: item.id,
2303
- invalidateQueryKey: queryKey
2304
- }));
2294
+ if (editConfig) {
2295
+ if (editConfig.type == "customDialog") {
2296
+ setDialog(editConfig.render({
2297
+ show: true,
2298
+ onClose: onCloseDialog
2299
+ }));
2300
+ } else {
2301
+ setDialog(jsxRuntime.jsx(DialogRenderer, {
2302
+ onClose: onCloseDialog,
2303
+ config: editConfig,
2304
+ queryId: item.id,
2305
+ invalidateQueryKey: queryKey
2306
+ }));
2307
+ }
2305
2308
  }
2306
2309
  break;
2307
2310
  }
@@ -2511,7 +2514,27 @@ function useTableProps(api, table, rowActions) {
2511
2514
  } = table,
2512
2515
  props = __rest$1(table, ["onRowClick", "columns"]);
2513
2516
  const onRowClickHandler = React__default["default"].useCallback(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)}`);
2517
+ var _a;
2518
+ const config = react.runIfFn(onRowClick, item);
2519
+ if (config) {
2520
+ switch (config.type) {
2521
+ case "navigate":
2522
+ {
2523
+ navigate((_a = react.runIfFn(config.path, item)) !== null && _a !== void 0 ? _a : "");
2524
+ break;
2525
+ }
2526
+ case "nextpush":
2527
+ {
2528
+ nextRouter.push(react.runIfFn(config.path, item));
2529
+ break;
2530
+ }
2531
+ case "link":
2532
+ {
2533
+ openLink(`${process.env["NEXT_PUBLIC_WEBSITE_URL"]}/${react.runIfFn(config.path, item)}`);
2534
+ break;
2535
+ }
2536
+ }
2537
+ }
2515
2538
  }, [navigate, onRowClick]);
2516
2539
  const columns = React__default["default"].useMemo(() => {
2517
2540
  const columns = table.columns.concat([]);
@@ -2529,7 +2552,7 @@ function useTableProps(api, table, rowActions) {
2529
2552
  }));
2530
2553
  }
2531
2554
  return columns;
2532
- }, [table]);
2555
+ }, [table, onAction, rowActions, api]);
2533
2556
  const tableProps = Object.assign({}, props);
2534
2557
  tableProps.columns = columns;
2535
2558
  tableProps.onRowClick = onRowClickHandler;
@@ -2656,6 +2679,7 @@ function TableButtonBar({
2656
2679
  }), buttonBar && buttonBar.map((button, index) => jsxRuntime.jsxs(React__default["default"].Fragment, {
2657
2680
  children: [button.type === "create" && editView && jsxRuntime.jsx(TableCreateButton, {
2658
2681
  buildDialog: createDialogFn(button.data),
2682
+ icon: button.icon,
2659
2683
  children: button.label
2660
2684
  }), button.type === "invalidate" && jsxRuntime.jsx(InvalidateButton, {
2661
2685
  pathOrPermalink: button.pathOrPermalink
package/index.esm.js CHANGED
@@ -1433,12 +1433,13 @@ function TableContainer(_a) {
1433
1433
 
1434
1434
  function TableCreateButton(_a) {
1435
1435
  var {
1436
+ icon,
1436
1437
  children
1437
1438
  } = _a,
1438
- props = __rest$1(_a, ["children"]);
1439
+ props = __rest$1(_a, ["icon", "children"]);
1439
1440
  return jsxs(ButtonBarDialogButton$1, Object.assign({}, props, {
1440
1441
  children: [jsx(Icon, {
1441
- path: mdiPlusThick
1442
+ path: icon !== null && icon !== void 0 ? icon : mdiPlusThick
1442
1443
  }), children]
1443
1444
  }));
1444
1445
  }
@@ -2281,18 +2282,20 @@ function TableViewProvider({
2281
2282
  case "edit":
2282
2283
  {
2283
2284
  const editConfig = runIfFn(editView, item);
2284
- if (editConfig.type == "customDialog") {
2285
- setDialog(editConfig.render({
2286
- show: true,
2287
- onClose: onCloseDialog
2288
- }));
2289
- } else {
2290
- setDialog(jsx(DialogRenderer, {
2291
- onClose: onCloseDialog,
2292
- config: editConfig,
2293
- queryId: item.id,
2294
- invalidateQueryKey: queryKey
2295
- }));
2285
+ if (editConfig) {
2286
+ if (editConfig.type == "customDialog") {
2287
+ setDialog(editConfig.render({
2288
+ show: true,
2289
+ onClose: onCloseDialog
2290
+ }));
2291
+ } else {
2292
+ setDialog(jsx(DialogRenderer, {
2293
+ onClose: onCloseDialog,
2294
+ config: editConfig,
2295
+ queryId: item.id,
2296
+ invalidateQueryKey: queryKey
2297
+ }));
2298
+ }
2296
2299
  }
2297
2300
  break;
2298
2301
  }
@@ -2502,7 +2505,27 @@ function useTableProps(api, table, rowActions) {
2502
2505
  } = table,
2503
2506
  props = __rest$1(table, ["onRowClick", "columns"]);
2504
2507
  const onRowClickHandler = React.useCallback(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)}`);
2508
+ var _a;
2509
+ const config = runIfFn(onRowClick, item);
2510
+ if (config) {
2511
+ switch (config.type) {
2512
+ case "navigate":
2513
+ {
2514
+ navigate((_a = runIfFn(config.path, item)) !== null && _a !== void 0 ? _a : "");
2515
+ break;
2516
+ }
2517
+ case "nextpush":
2518
+ {
2519
+ nextRouter.push(runIfFn(config.path, item));
2520
+ break;
2521
+ }
2522
+ case "link":
2523
+ {
2524
+ openLink(`${process.env["NEXT_PUBLIC_WEBSITE_URL"]}/${runIfFn(config.path, item)}`);
2525
+ break;
2526
+ }
2527
+ }
2528
+ }
2506
2529
  }, [navigate, onRowClick]);
2507
2530
  const columns = React.useMemo(() => {
2508
2531
  const columns = table.columns.concat([]);
@@ -2520,7 +2543,7 @@ function useTableProps(api, table, rowActions) {
2520
2543
  }));
2521
2544
  }
2522
2545
  return columns;
2523
- }, [table]);
2546
+ }, [table, onAction, rowActions, api]);
2524
2547
  const tableProps = Object.assign({}, props);
2525
2548
  tableProps.columns = columns;
2526
2549
  tableProps.onRowClick = onRowClickHandler;
@@ -2647,6 +2670,7 @@ function TableButtonBar({
2647
2670
  }), buttonBar && buttonBar.map((button, index) => jsxs(React.Fragment, {
2648
2671
  children: [button.type === "create" && editView && jsx(TableCreateButton, {
2649
2672
  buildDialog: createDialogFn(button.data),
2673
+ icon: button.icon,
2650
2674
  children: button.label
2651
2675
  }), button.type === "invalidate" && jsx(InvalidateButton, {
2652
2676
  pathOrPermalink: button.pathOrPermalink
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compill/admin",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "module": "./index.esm.js",
5
5
  "main": "./index.cjs.js"
6
6
  }
@@ -67,6 +67,7 @@ type TableViewButtonConfig = {
67
67
  type: "create";
68
68
  data?: any;
69
69
  label?: string;
70
+ icon?: string;
70
71
  } | {
71
72
  type: "invalidate";
72
73
  pathOrPermalink: string;
@@ -1,3 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import { DialogButtonProps } from "../buttons/DialogButton";
3
- export declare function TableCreateButton({ children, ...props }: DialogButtonProps): JSX.Element;
3
+ export declare function TableCreateButton({ icon, children, ...props }: {
4
+ icon?: string;
5
+ } & DialogButtonProps): JSX.Element;