@compill/admin 1.0.108 → 1.0.110

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.
Files changed (86) hide show
  1. package/dist/index.cjs +2115 -0
  2. package/dist/index.d.ts +50 -565
  3. package/dist/index.js +605 -592
  4. package/dist/lib/SectionTitle.d.ts +2 -0
  5. package/dist/lib/breadcrumbs/BreadCrumbs.d.ts +15 -0
  6. package/dist/lib/buttons/DialogButton.d.ts +7 -0
  7. package/dist/lib/buttons/InvalidateButton.d.ts +6 -0
  8. package/dist/lib/buttons/NavigateButton.d.ts +4 -0
  9. package/dist/lib/buttons/PublishButton.d.ts +9 -0
  10. package/dist/lib/buttons/UpdateButton.d.ts +2 -0
  11. package/dist/lib/buttons/ViewButton.d.ts +5 -0
  12. package/dist/lib/cells/OrderCell.d.ts +11 -0
  13. package/dist/lib/json/DetailsView.d.ts +5 -0
  14. package/dist/lib/json/EditItemView.d.ts +2 -0
  15. package/dist/lib/json/MultiQueryWrapper.d.ts +5 -0
  16. package/dist/lib/json/QueryWrapper.d.ts +6 -0
  17. package/dist/lib/json/ScreenRenderer.d.ts +6 -0
  18. package/dist/lib/json/ScreenTopBar.d.ts +15 -0
  19. package/dist/lib/json/TabbedView.d.ts +3 -0
  20. package/dist/lib/json/buttons/ActionButton.d.ts +14 -0
  21. package/dist/lib/json/buttons/ConfirmationActionButton.d.ts +26 -0
  22. package/dist/lib/json/dialog/DialogRenderer.d.ts +11 -0
  23. package/dist/lib/json/dialog/ItemDeleteDialog.d.ts +17 -0
  24. package/dist/lib/json/dialog/ItemEditDialog.d.ts +32 -0
  25. package/dist/lib/json/dialog/MultiQueryWrapperDialog.d.ts +7 -0
  26. package/dist/lib/json/dialog/QueryWrapperDialog.d.ts +13 -0
  27. package/dist/lib/json/table/RefreshButton.d.ts +3 -0
  28. package/dist/lib/json/table/TableRowActionsView.d.ts +11 -0
  29. package/dist/lib/json/table/TableRowPublishPostButton.d.ts +8 -0
  30. package/dist/lib/json/table/TableView.d.ts +3 -0
  31. package/dist/lib/json/table/TableViewContext.d.ts +14 -0
  32. package/dist/lib/json/table/useTableProps.d.ts +3 -0
  33. package/dist/lib/json/types/DetailsView.d.ts +57 -0
  34. package/dist/lib/json/types/EditItemDialog.d.ts +4 -0
  35. package/dist/lib/json/types/MultiQueryWrapper.d.ts +18 -0
  36. package/dist/lib/json/types/MultiQueryWrapperDialog.d.ts +13 -0
  37. package/dist/lib/json/types/QueryWrapper.d.ts +27 -0
  38. package/dist/lib/json/types/QueryWrapperDialog.d.ts +22 -0
  39. package/dist/lib/json/types/ScreenConfig.d.ts +8 -0
  40. package/dist/lib/json/types/TabbedView.d.ts +22 -0
  41. package/dist/lib/json/types/TableView.d.ts +117 -0
  42. package/dist/lib/layout/AdminLayout.d.ts +13 -0
  43. package/dist/lib/layout/ButtonBar.d.ts +19 -0
  44. package/dist/lib/layout/Content.d.ts +9 -0
  45. package/dist/lib/layout/PageTitleBar.d.ts +6 -0
  46. package/dist/lib/layout/Sidebar.d.ts +20 -0
  47. package/dist/lib/layout/menu/Menu.d.ts +12 -0
  48. package/dist/lib/layout/menu/MenuButton.d.ts +6 -0
  49. package/dist/lib/layout/menu/MenuConfig.d.ts +13 -0
  50. package/dist/lib/layout/menu/MenuItem.d.ts +11 -0
  51. package/dist/lib/layout/menu/NextMenuItem.d.ts +11 -0
  52. package/dist/lib/layout/menu/SelectedIndicator.d.ts +3 -0
  53. package/dist/lib/layout/menu/UserBlock.d.ts +9 -0
  54. package/dist/lib/modal/AttachDialog.d.ts +30 -0
  55. package/dist/lib/modal/FormActionDialog.d.ts +23 -0
  56. package/dist/lib/page/PageContainer.d.ts +2 -0
  57. package/dist/lib/page/PageContentEditor.d.ts +4 -0
  58. package/dist/lib/page/PageMain.d.ts +2 -0
  59. package/dist/lib/page/PageQueryStateContainer.d.ts +21 -0
  60. package/dist/lib/page/PageSectionTitle.d.ts +2 -0
  61. package/dist/lib/page/PageSidebar.d.ts +2 -0
  62. package/dist/lib/page/PageSidebarSection.d.ts +4 -0
  63. package/dist/lib/page/PageStateContainer.d.ts +7 -0
  64. package/dist/lib/page/PageSubSectionTitle.d.ts +2 -0
  65. package/dist/lib/page/PageTitle.d.ts +2 -0
  66. package/dist/lib/page/PageTopBar.d.ts +13 -0
  67. package/dist/lib/status/StatusBadge.d.ts +4 -0
  68. package/dist/lib/table/TableColumnButton.d.ts +1 -0
  69. package/dist/lib/table/TableContainer.d.ts +10 -0
  70. package/dist/lib/table/TableContainerContext.d.ts +18 -0
  71. package/dist/lib/table/TableCreateButton.d.ts +4 -0
  72. package/dist/lib/table/TableFilterButton.d.ts +2 -0
  73. package/dist/lib/table/TableFilters.d.ts +9 -0
  74. package/dist/lib/table/TableMassActions.d.ts +6 -0
  75. package/dist/lib/table/TableRowActionBar.d.ts +10 -0
  76. package/dist/lib/table/TableRowActionButton.d.ts +4 -0
  77. package/dist/lib/table/TableRowActionDialogButton.d.ts +4 -0
  78. package/dist/lib/table/TableRowDeleteButton.d.ts +2 -0
  79. package/dist/lib/table/TableRowEditButton.d.ts +2 -0
  80. package/dist/lib/table/TableRowNavigateButton.d.ts +4 -0
  81. package/dist/lib/table/TableRowPublishPostButton.d.ts +8 -0
  82. package/dist/lib/table/TableRowViewButton.d.ts +4 -0
  83. package/dist/lib/table/TableTopBar.d.ts +8 -0
  84. package/package.json +17 -17
  85. package/dist/index.d.mts +0 -565
  86. package/dist/index.mjs +0 -2000
@@ -0,0 +1,2 @@
1
+ import { ParentComponent, SoperioComponent } from "@soperio/react";
2
+ export declare function SectionTitle({ children, ...props }: SoperioComponent & ParentComponent): JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { SoperioComponent } from "@soperio/react";
2
+ export interface Breadcrumb {
3
+ label: string;
4
+ path?: string;
5
+ }
6
+ interface BreadcrumbsProps extends SoperioComponent {
7
+ breadcrumbs: Breadcrumb[] | QueryBreadcrumbs;
8
+ }
9
+ export type QueryBreadcrumbs = {
10
+ queryFn: (...args: any) => Promise<any>;
11
+ queryField?: string;
12
+ generate: (results: any) => Breadcrumb[];
13
+ };
14
+ export declare function Breadcrumbs({ breadcrumbs, ...props }: BreadcrumbsProps): JSX.Element;
15
+ export {};
@@ -0,0 +1,7 @@
1
+ import { ParentComponent, SoperioComponent } from "@soperio/react";
2
+ import { ButtonProps } from "@valerya/ui";
3
+ import React from "react";
4
+ export interface DialogButtonProps extends SoperioComponent, ParentComponent, ButtonProps {
5
+ buildDialog: (onClose: () => void) => React.ReactNode;
6
+ }
7
+ export declare function DialogButton({ buildDialog, ...props }: DialogButtonProps): JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { ButtonBarButtonProps } from "../layout/ButtonBar";
2
+ interface InvalidateButtonProps extends ButtonBarButtonProps {
3
+ pathOrPermalink: string;
4
+ }
5
+ export declare function InvalidateButton({ pathOrPermalink, ...props }: InvalidateButtonProps): JSX.Element;
6
+ export {};
@@ -0,0 +1,4 @@
1
+ import { ButtonProps } from "@valerya/ui";
2
+ export declare function NavigateButton({ path, ...props }: {
3
+ path: string;
4
+ } & ButtonProps): JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { API } from "@compill/admin-api";
2
+ import { ButtonProps } from "@valerya/ui";
3
+ interface PublishButtonProps extends ButtonProps {
4
+ status: string;
5
+ queryId: string;
6
+ api: API<any>;
7
+ }
8
+ export declare function PublishButton({ status, queryId, api, ...props }: PublishButtonProps): JSX.Element;
9
+ export {};
@@ -0,0 +1,2 @@
1
+ import { ButtonProps } from "@valerya/ui";
2
+ export declare function UpdateButton({ ...props }: ButtonProps): JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { ButtonBarButtonProps } from "../layout/ButtonBar";
2
+ export declare function ViewButton({ label, path, icon, ...props }: ButtonBarButtonProps & {
3
+ label?: string;
4
+ path: string;
5
+ }): JSX.Element;
@@ -0,0 +1,11 @@
1
+ interface OrderApi {
2
+ moveUp: (id: string) => Promise<any>;
3
+ moveDown: (id: string) => Promise<any>;
4
+ queryKey: string[];
5
+ }
6
+ export declare function OrderCell({ api, postId, order }: {
7
+ api: OrderApi;
8
+ postId: string;
9
+ order: number;
10
+ }): JSX.Element;
11
+ export {};
@@ -0,0 +1,5 @@
1
+ import { SoperioComponent } from "@soperio/react";
2
+ import { DetailsViewConfig } from "./types/DetailsView";
3
+ export declare function DetailsView({ queryField, api, useNextRouter, processInput, screen, tabbed, ...props }: DetailsViewConfig & {
4
+ tabbed?: boolean;
5
+ } & SoperioComponent): JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ItemEditDialogProps } from "./dialog/ItemEditDialog";
2
+ export declare function EditItemView({ initialValues, ...props }: Omit<ItemEditDialogProps, "show">): JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { MultiQueryWrapperConfig } from "./types/MultiQueryWrapper";
2
+ import { SoperioComponent } from "@soperio/react";
3
+ export declare function MultiQueryWrapper({ queries, config, tabbed, ...props }: Omit<MultiQueryWrapperConfig, "type"> & {
4
+ tabbed?: boolean;
5
+ } & SoperioComponent): JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { QueryWrapperConfig } from "./types/QueryWrapper";
2
+ import { SoperioComponent } from "@soperio/react";
3
+ import { CRUD_MODEL } from "@compill/api";
4
+ export declare function QueryWrapper<T extends CRUD_MODEL, U>({ api, queryField, fn, transformFn, config, tabbed, ...props }: Omit<QueryWrapperConfig<T, U>, "type"> & {
5
+ tabbed?: boolean;
6
+ } & SoperioComponent): JSX.Element | null;
@@ -0,0 +1,6 @@
1
+ import { ScreenConfig } from "./types/ScreenConfig";
2
+ import { SoperioComponent } from "@soperio/react";
3
+ export declare function ScreenRenderer({ config, tabbed, ...props }: {
4
+ config: ScreenConfig;
5
+ tabbed?: boolean;
6
+ } & SoperioComponent): JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { API } from "@compill/admin-api";
2
+ import { Breadcrumb } from "../breadcrumbs/BreadCrumbs";
3
+ import { DetailViewButton } from "./types/DetailsView";
4
+ import { CRUDAPI } from "@compill/api";
5
+ interface ScreenTopBarProps {
6
+ tabbed?: boolean;
7
+ breadcrumbs?: Breadcrumb[];
8
+ buttonBar?: DetailViewButton[];
9
+ api: CRUDAPI<any> | API<any>;
10
+ item: any;
11
+ isLoading: boolean;
12
+ trackingRef?: Element | null;
13
+ }
14
+ export declare function ScreenTopBar({ tabbed, breadcrumbs, api, item, isLoading, buttonBar, trackingRef }: ScreenTopBarProps): JSX.Element;
15
+ export {};
@@ -0,0 +1,3 @@
1
+ import { TabbedViewConfig } from "./types/TabbedView";
2
+ import { SoperioComponent } from "@soperio/react";
3
+ export declare function TabbedView({ queryField, api, screen, ...props }: TabbedViewConfig & SoperioComponent): JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { MutationQueryFn, MutationQueryKey } from "@compill/api";
2
+ import { ButtonProps } from "@valerya/ui";
3
+ interface ActionButtonProps {
4
+ label: string;
5
+ buttonProps?: ButtonProps;
6
+ icon?: string;
7
+ queryKey: MutationQueryKey;
8
+ queryFn: MutationQueryFn<any, any>;
9
+ successMsg?: string;
10
+ errorMsg?: string;
11
+ invalidateParent?: boolean;
12
+ }
13
+ export declare function ActionButton({ label, buttonProps, icon, queryKey, queryFn, successMsg, errorMsg, invalidateParent }: ActionButtonProps): JSX.Element;
14
+ export {};
@@ -0,0 +1,26 @@
1
+ import { MutationQueryFn, MutationQueryKey } from "@compill/api";
2
+ import { ButtonProps, ModalProps } from "@valerya/ui";
3
+ interface ConfirmationActionButtonProps {
4
+ label: string;
5
+ buttonProps?: ButtonProps;
6
+ icon?: string;
7
+ queryKey: MutationQueryKey;
8
+ queryFn: MutationQueryFn<any, any>;
9
+ successMsg?: string;
10
+ errorMsg?: string;
11
+ invalidateParent?: boolean;
12
+ }
13
+ export declare function ConfirmationActionButton({ label, buttonProps, icon, queryKey, queryFn, successMsg, errorMsg, invalidateParent }: ConfirmationActionButtonProps): JSX.Element;
14
+ interface ConfirmationDialogProps extends Pick<ModalProps, "show" | "onClose"> {
15
+ title: string;
16
+ text: string;
17
+ positiveButtonLabel?: string;
18
+ negativeButtonLabel?: string;
19
+ queryKey: MutationQueryKey;
20
+ queryFn: MutationQueryFn<any, any>;
21
+ successMsg?: string;
22
+ errorMsg?: string;
23
+ invalidateParent?: boolean;
24
+ }
25
+ export declare function ConfirmationDialog({ title, text, positiveButtonLabel, negativeButtonLabel, queryKey, queryFn, successMsg, errorMsg, invalidateParent, show, onClose }: ConfirmationDialogProps): JSX.Element;
26
+ export {};
@@ -0,0 +1,11 @@
1
+ import { EditItemDialogConfig } from "../types/EditItemDialog";
2
+ import { QueryWrapperDialogConfig } from "../types/QueryWrapperDialog";
3
+ import { MultiQueryWrapperDialogConfig } from "../types/MultiQueryWrapperDialog";
4
+ interface DialogRendererProps {
5
+ config: EditItemDialogConfig | QueryWrapperDialogConfig<any> | MultiQueryWrapperDialogConfig;
6
+ onClose: () => void;
7
+ invalidateQueryKey?: string[];
8
+ queryId?: string;
9
+ }
10
+ export declare function DialogRenderer({ config, onClose, invalidateQueryKey, queryId }: DialogRendererProps): JSX.Element | null;
11
+ export {};
@@ -0,0 +1,17 @@
1
+ import { CRUDAPI } from "@compill/api";
2
+ import { ModalProps } from "@valerya/ui";
3
+ import React from "react";
4
+ export interface ItemDeleteDialogProps extends ModalProps {
5
+ itemLabel: string;
6
+ queryId: string;
7
+ api: CRUDAPI<any>;
8
+ apiFn?: string;
9
+ invalidateQueriesOnSuccess?: boolean;
10
+ invalidateQueryKey?: string[];
11
+ msg?: (itemLabel: string) => string | React.ReactNode;
12
+ actionButtonLabel?: string;
13
+ closeActionButtonLabel?: string;
14
+ title?: string;
15
+ onSuccess?: () => void;
16
+ }
17
+ export declare function ItemDeleteDialog({ title, actionButtonLabel, closeActionButtonLabel, itemLabel, queryId, api, apiFn, invalidateQueriesOnSuccess, invalidateQueryKey, size, md_boxSizing, msg, show, onClose, onSuccess, ...props }: ItemDeleteDialogProps): JSX.Element;
@@ -0,0 +1,32 @@
1
+ import { CRUDAPI } from "@compill/api";
2
+ import { FormRendererConfig } from "@compill/form";
3
+ import { UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
4
+ import { ModalProps } from "@valerya/ui";
5
+ import { FormikConfig } from "formik";
6
+ import React from "react";
7
+ export interface ItemEditDialogProps<TFormData extends {} = any, TResultData extends {} = any> extends Omit<ModalProps, "id" | "children" | "title" | "position"> {
8
+ itemLabel?: string;
9
+ queryId?: string;
10
+ api: CRUDAPI<any>;
11
+ initialValues?: any;
12
+ queryFetchOptions?: UseQueryOptions;
13
+ querySaveOptions?: UseMutationOptions<TResultData, unknown, TFormData>;
14
+ onSuccess?: (item: TResultData, response: any) => void;
15
+ onFetchError?: () => void;
16
+ fetchErrorMsg?: string;
17
+ onSaveError?: (item: TFormData) => void;
18
+ saveErrorMsg?: string;
19
+ fetchToFormData?: (item: TResultData) => TFormData;
20
+ formToQueryData?: (TFormData: any) => Partial<TResultData>;
21
+ invalidateQueriesOnSuccess?: boolean;
22
+ invalidateQueryKey?: string[];
23
+ retryText?: string;
24
+ cancelLabel?: string;
25
+ saveLabel?: string;
26
+ title?: ((item?: TResultData) => string);
27
+ formikProps: Omit<FormikConfig<any>, "initialValues" | "onSubmit">;
28
+ form: React.ReactNode | FormRendererConfig | ((item: TResultData) => FormRendererConfig);
29
+ show: boolean;
30
+ onClose: () => void;
31
+ }
32
+ export declare function ItemEditDialog<TFormData extends {}, TResultData extends {}>({ initialValues, itemLabel, queryId, api, queryFetchOptions, querySaveOptions, onSuccess, onFetchError, fetchErrorMsg, onSaveError, saveErrorMsg, fetchToFormData, formToQueryData, invalidateQueriesOnSuccess, invalidateQueryKey, retryText, cancelLabel, saveLabel, size, title, form, show, onClose, formikProps, ...props }: ItemEditDialogProps<TFormData, TResultData>): JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { MultiQueryWrapperDialogConfig } from "../types/MultiQueryWrapperDialog";
2
+ export type MultiQueryWrapperDialogProps = Omit<MultiQueryWrapperDialogConfig, "type"> & {
3
+ queryId?: string;
4
+ onClose: () => void;
5
+ invalidateQueryKey?: string[];
6
+ };
7
+ export declare function MultiQueryWrapperDialog({ queries, config, onClose, queryId, invalidateQueryKey }: MultiQueryWrapperDialogProps): JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { CRUDAPI, CRUD_MODEL } from "@compill/api";
2
+ import { QueryWrapperDialogConfig } from "../types/QueryWrapperDialog";
3
+ import { EditItemDialogConfig } from "../types/EditItemDialog";
4
+ export type QueryWrapperDialogProps<T extends CRUD_MODEL, U> = Omit<QueryWrapperDialogConfig<T, U>, "type"> & {
5
+ api: CRUDAPI<any>;
6
+ fn: "get" | "getTransformed" | "getAll" | "getAllTransformed";
7
+ transformFn?: (data: T) => U;
8
+ config: (data?: T | U) => Omit<EditItemDialogConfig, "type">;
9
+ onClose: () => void;
10
+ queryId?: string;
11
+ invalidateQueryKey?: string[];
12
+ };
13
+ export declare function QueryWrapperDialog<T extends CRUD_MODEL, U>({ api, fn, transformFn, config, onClose, queryId, invalidateQueryKey }: QueryWrapperDialogProps<T, U>): JSX.Element | null;
@@ -0,0 +1,3 @@
1
+ export declare function RefreshButton({ queryKey }: {
2
+ queryKey: string[];
3
+ }): JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { TableRowAction } from "../types/TableView";
2
+ import { API } from "@compill/admin-api";
3
+ interface TableRowActionViewProps {
4
+ row: any;
5
+ onAction: (action: TableRowAction, item: any) => void;
6
+ rowActions?: TableRowAction[] | ((item?: any) => TableRowAction[]);
7
+ api: API<any>;
8
+ queryKey: string[];
9
+ }
10
+ export declare function TableRowActionsView({ row, onAction, rowActions, api, queryKey }: TableRowActionViewProps): JSX.Element;
11
+ export {};
@@ -0,0 +1,8 @@
1
+ import { ButtonProps } from "@valerya/ui";
2
+ import { API } from "@compill/admin-api";
3
+ export declare function TableRowPublishPostButton({ id, api, status, invalidateQueryKey, ...props }: {
4
+ id: string;
5
+ api: API<any>;
6
+ status: "draft" | "published";
7
+ invalidateQueryKey?: string[];
8
+ } & ButtonProps): JSX.Element;
@@ -0,0 +1,3 @@
1
+ import { SoperioComponent } from "@soperio/react";
2
+ import { TableViewConfig } from "../types/TableView";
3
+ export declare function TableView({ queryField, title, subtitle, screen, ...props }: Omit<TableViewConfig, "type"> & SoperioComponent): JSX.Element;
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { TableRowAction, TableViewDeleteItem, TableViewEditView } from "../types/TableView";
3
+ type TableViewContextProps = {
4
+ onAction: (action: TableRowAction, item: any) => void;
5
+ dialog?: React.ReactNode;
6
+ };
7
+ declare const useContext: () => TableViewContextProps;
8
+ export interface TableViewProviderProps extends React.PropsWithChildren {
9
+ queryKey: string[];
10
+ editView?: TableViewEditView | ((item: any) => TableViewEditView);
11
+ deleteItem?: TableViewDeleteItem | ((item: any) => TableViewDeleteItem);
12
+ }
13
+ declare function TableViewProvider({ editView, deleteItem, queryKey, children }: TableViewProviderProps): JSX.Element;
14
+ export { TableViewProvider, useContext as useTableViewContext };
@@ -0,0 +1,3 @@
1
+ import { API } from "@compill/admin-api";
2
+ import { TableRowAction, TableViewTable } from "../types/TableView";
3
+ export declare function useTableProps(api: API<any>, table: TableViewTable, rowActions?: TableRowAction[] | ((item?: any) => TableRowAction[]), queryParams?: any): any;
@@ -0,0 +1,57 @@
1
+ import { API } from "@compill/admin-api";
2
+ import * as Yup from "yup";
3
+ import { Breadcrumb } from "../../breadcrumbs/BreadCrumbs";
4
+ import { FormRendererConfig } from "@compill/form";
5
+ import { CRUDAPI } from "@compill/api";
6
+ export type DetailsViewConfig<T = any> = {
7
+ type: "details";
8
+ api: CRUDAPI<T> | API<T>;
9
+ queryField: string;
10
+ useNextRouter?: boolean;
11
+ processInput?: (input: T) => any;
12
+ screen: Screen | ((data: T) => Screen);
13
+ };
14
+ type Screen = {
15
+ invalidateParentQueryKey?: string[];
16
+ invalidatePage?: string;
17
+ breadcrumbs?: Breadcrumb[];
18
+ initialValues: any | ((data: any) => any);
19
+ schema: Yup.Schema;
20
+ header?: React.ReactNode;
21
+ sections?: DetailSection[];
22
+ buttonBar?: DetailViewButton[];
23
+ } & ({
24
+ type: "form";
25
+ } | {
26
+ type?: "post" | "section";
27
+ editor?: DetailEditor;
28
+ editorFooter?: React.ReactNode;
29
+ });
30
+ type DetailEditor = {
31
+ type?: "blockEditor";
32
+ name: string;
33
+ } | {
34
+ type?: "textarea";
35
+ name: string;
36
+ };
37
+ export type DetailSection = {
38
+ type: "section";
39
+ title?: string;
40
+ form: FormRendererConfig | ((item: any) => FormRendererConfig);
41
+ } | {
42
+ type: "custom";
43
+ component: ((item: any) => React.ReactNode);
44
+ };
45
+ export type DetailViewButton = {
46
+ type: "invalidate";
47
+ pathOrPermalink: string;
48
+ } | {
49
+ type: "link";
50
+ path: string;
51
+ icon?: string;
52
+ label?: string;
53
+ } | {
54
+ type: "custom";
55
+ render: (item: any) => React.ReactNode;
56
+ };
57
+ export {};
@@ -0,0 +1,4 @@
1
+ import { ItemEditDialogProps } from "../dialog/ItemEditDialog";
2
+ export type EditItemDialogConfig = Omit<ItemEditDialogProps, "show" | "onClose"> & {
3
+ type: "dialog";
4
+ };
@@ -0,0 +1,18 @@
1
+ import { CRUDAPI } from "@compill/api";
2
+ import { DetailsViewConfig } from "./DetailsView";
3
+ import { TabbedViewConfig } from "./TabbedView";
4
+ import { TableViewConfig } from "./TableView";
5
+ type SubScreen = TableViewConfig | DetailsViewConfig | TabbedViewConfig;
6
+ export type QueryDef = {
7
+ api: CRUDAPI<any> | ((id: string) => CRUDAPI<any>);
8
+ fn: "get" | "getAll";
9
+ queryField?: string;
10
+ transformFn?: (data: any) => any;
11
+ params?: any;
12
+ };
13
+ export type MultiQueryWrapperConfig = {
14
+ type: "multiQuery";
15
+ queries: QueryDef[];
16
+ config: (...data: any[]) => SubScreen;
17
+ };
18
+ export {};
@@ -0,0 +1,13 @@
1
+ import { CRUDAPI } from "@compill/api";
2
+ import { EditItemDialogConfig } from "./EditItemDialog";
3
+ export type QueryDef = {
4
+ api: CRUDAPI<any>;
5
+ fn: "get" | "getAll";
6
+ transformFn?: (data: any) => any;
7
+ cache?: boolean;
8
+ };
9
+ export type MultiQueryWrapperDialogConfig = {
10
+ type: "multiQuery";
11
+ queries: QueryDef[];
12
+ config: (...data: any[]) => Omit<EditItemDialogConfig, "type">;
13
+ };
@@ -0,0 +1,27 @@
1
+ import { CRUDAPI, CRUD_MODEL } from "@compill/api";
2
+ import { DetailsViewConfig } from "./DetailsView";
3
+ import { TabbedViewConfig } from "./TabbedView";
4
+ import { TableViewConfig } from "./TableView";
5
+ type SubScreen<T extends CRUD_MODEL, U> = TableViewConfig | DetailsViewConfig | TabbedViewConfig | QueryWrapperConfig<T, U>;
6
+ export type QueryWrapperConfig<T extends CRUD_MODEL, U = T> = {
7
+ type: "query";
8
+ api: CRUDAPI<T> | ((id: string | number) => CRUDAPI<T>);
9
+ queryField?: string;
10
+ } & ({
11
+ fn: "get";
12
+ transformFn?: undefined;
13
+ config: (data: T) => SubScreen<T, U>;
14
+ } | {
15
+ fn: "getTransformed";
16
+ transformFn: (data: T) => U;
17
+ config: (data: U) => SubScreen<T, U>;
18
+ } | {
19
+ fn: "getAll";
20
+ transformFn?: undefined;
21
+ config: (data: T[]) => SubScreen<T, U>;
22
+ } | {
23
+ fn: "getAllTransformed";
24
+ transformFn: (data: T[]) => U;
25
+ config: (data: U) => SubScreen<T, U>;
26
+ });
27
+ export {};
@@ -0,0 +1,22 @@
1
+ import { CRUDAPI, CRUD_MODEL } from "@compill/api";
2
+ import { EditItemDialogConfig } from "./EditItemDialog";
3
+ export type QueryWrapperDialogConfig<T extends CRUD_MODEL, U = T> = {
4
+ type: "query";
5
+ api: CRUDAPI<any>;
6
+ } & ({
7
+ fn: "get";
8
+ transformFn?: undefined;
9
+ config: (data: T) => Omit<EditItemDialogConfig, "type">;
10
+ } | {
11
+ fn: "getTransformed";
12
+ transformFn: (data: T) => U;
13
+ config: (data: U) => Omit<EditItemDialogConfig, "type">;
14
+ } | {
15
+ fn: "getAll";
16
+ transformFn?: undefined;
17
+ config: (data: T[]) => Omit<EditItemDialogConfig, "type">;
18
+ } | {
19
+ fn: "getAllTransformed";
20
+ transformFn: (data: T[]) => U;
21
+ config: (data: U) => Omit<EditItemDialogConfig, "type">;
22
+ });
@@ -0,0 +1,8 @@
1
+ import { ItemEditDialogProps } from "../dialog/ItemEditDialog";
2
+ import { DetailsViewConfig } from "./DetailsView";
3
+ import { MultiQueryWrapperConfig } from "./MultiQueryWrapper";
4
+ import { QueryWrapperConfig } from "./QueryWrapper";
5
+ import { TabbedViewConfig } from "./TabbedView";
6
+ import { TableViewConfig } from "./TableView";
7
+ export type ScreenConfig = TableViewConfig | DetailsViewConfig | TabbedViewConfig | QueryWrapperConfig<any, any> | MultiQueryWrapperConfig;
8
+ export type TableViewEditItem = Omit<ItemEditDialogProps, "show" | "onClose">;
@@ -0,0 +1,22 @@
1
+ import { CRUDAPI } from "@compill/api";
2
+ import { Breadcrumb } from "../../breadcrumbs/BreadCrumbs";
3
+ import { DetailsViewConfig } from "./DetailsView";
4
+ import { QueryWrapperConfig } from "./QueryWrapper";
5
+ import { TableViewConfig } from "./TableView";
6
+ import { MultiQueryWrapperConfig } from "./MultiQueryWrapper";
7
+ export type TabbedViewConfig<T extends any = any> = {
8
+ type: "tabbed";
9
+ queryField: string;
10
+ api: CRUDAPI<any>;
11
+ screen: Screen | ((data: T) => Screen);
12
+ };
13
+ type Screen = {
14
+ breadcrumbs: Breadcrumb[];
15
+ tabs: Tab[];
16
+ };
17
+ export type Tab = {
18
+ label: string;
19
+ config?: TableViewConfig | DetailsViewConfig | QueryWrapperConfig<any> | MultiQueryWrapperConfig | TabbedViewConfig;
20
+ component?: () => React.ReactNode;
21
+ };
22
+ export {};
@@ -0,0 +1,117 @@
1
+ import { API } from "@compill/admin-api";
2
+ import { FormRendererConfig } from "@compill/form";
3
+ import { TableProps } from "@compill/table";
4
+ import { ButtonProps, ModalProps } from "@valerya/ui";
5
+ import { Breadcrumb, QueryBreadcrumbs } from "../../breadcrumbs/BreadCrumbs";
6
+ import { ItemDeleteDialogProps } from "../dialog/ItemDeleteDialog";
7
+ import { EditItemDialogConfig } from "./EditItemDialog";
8
+ import { QueryWrapperDialogConfig } from "./QueryWrapperDialog";
9
+ import * as Yup from "yup";
10
+ import { MutationQueryFn, MutationQueryKey } from "@compill/api";
11
+ export type TableViewScreen = {
12
+ api: API<any>;
13
+ breadcrumbs?: Breadcrumb[] | QueryBreadcrumbs;
14
+ buttonBar?: TableViewButtonConfig[];
15
+ filters?: TableFilters;
16
+ massActions?: TableMassActions;
17
+ createView?: TableViewEditView | ((data?: any) => TableViewEditView);
18
+ editView?: TableViewEditView | ((item: any) => TableViewEditView);
19
+ deleteItem?: TableViewDeleteItem | ((item: any) => TableViewDeleteItem);
20
+ table: TableViewTable;
21
+ rowActions?: TableRowAction[] | ((item: any) => TableRowAction[]);
22
+ queryParams?: any;
23
+ };
24
+ export type TableViewConfig = {
25
+ type: "table";
26
+ title: string;
27
+ subtitle?: string | React.ReactNode | ((data: any) => string | React.ReactNode);
28
+ queryField?: string;
29
+ screen: TableViewScreen | ((id: string) => TableViewScreen);
30
+ };
31
+ export type CustomDialog = {
32
+ type: "customDialog";
33
+ render: (props: ModalProps) => React.ReactNode;
34
+ };
35
+ export type TableViewEditView = CustomDialog | EditItemDialogConfig | QueryWrapperDialogConfig<any>;
36
+ export type TableViewTable = Omit<TableProps, "onRowClick" | "queryKey" | "queryFn" | "queryFilters"> & {
37
+ filtersMethod?: "internal" | "nextRouter" | "reactRouter";
38
+ initialVisibleColumns?: string[];
39
+ onRowClick?: {
40
+ type: "navigate" | "nextpush" | "link";
41
+ path: string | ((item: any) => string);
42
+ };
43
+ };
44
+ export type TableViewDeleteItem = Omit<ItemDeleteDialogProps, "show" | "onClose" | "itemLabel" | "queryId"> & {
45
+ itemLabel: string | ((item: any) => string);
46
+ };
47
+ export type TableRowAction = {
48
+ type: "link";
49
+ path: string | ((item: any) => string);
50
+ } | {
51
+ type: "view";
52
+ path: string | ((item: any) => string);
53
+ } | {
54
+ type: "edit";
55
+ } | {
56
+ type: "delete";
57
+ msg?: (itemLabel: string) => (string | React.ReactNode);
58
+ } | {
59
+ type: "publish";
60
+ api?: API<any>;
61
+ } | {
62
+ type: "custom";
63
+ component: (item: any, queryKey: string[], icon?: string, label?: string) => React.ReactNode;
64
+ icon?: string;
65
+ label?: string;
66
+ };
67
+ export type TableViewButtonBar = TableViewButtonConfig[];
68
+ type TableViewButtonConfig = {
69
+ type: "create";
70
+ data?: any;
71
+ label?: string;
72
+ icon?: string;
73
+ } | {
74
+ type: "invalidate";
75
+ pathOrPermalink: string;
76
+ } | {
77
+ type: "custom";
78
+ render: () => React.ReactNode;
79
+ };
80
+ type TableFilters = {
81
+ form: FormRendererConfig;
82
+ initialValues: any | ((data: any) => any);
83
+ schema?: Yup.AnySchema;
84
+ processInput?: (input: any) => any;
85
+ };
86
+ type TableMassActions = {
87
+ items: MassAction[];
88
+ };
89
+ export type MassAction = ({
90
+ type: "custom";
91
+ render: (selectedRows: any[]) => React.ReactNode;
92
+ } | {
93
+ type: "select";
94
+ provider?: Record<string, any>[] | ((selectedRows: any) => Record<string, any>[]);
95
+ labelField?: string;
96
+ valueField?: string;
97
+ queryFn: MutationQueryFn<any, any>;
98
+ queryKey: MutationQueryKey;
99
+ } | {
100
+ type: "dynamicChoiceList";
101
+ } | {
102
+ type: "button";
103
+ label: string;
104
+ icon?: string;
105
+ buttonProps?: ButtonProps;
106
+ queryFn: MutationQueryFn<any, any>;
107
+ queryKey: MutationQueryKey;
108
+ invalidateParent?: boolean;
109
+ showConfirmationDialog?: boolean;
110
+ confirmationDialogTitle?: string;
111
+ confirmationDialogText?: string;
112
+ confirmationDialogPositiveButtonLabel?: string;
113
+ confirmationDialogNegativeButtonLabel?: string;
114
+ successMsg?: (rows: any[]) => string;
115
+ errorMsg?: (rows: any[]) => string;
116
+ });
117
+ export {};
@@ -0,0 +1,13 @@
1
+ import { Color, ParentComponent, SoperioComponent } from "@soperio/react";
2
+ import { MenuConfig } from "./menu/MenuConfig";
3
+ interface LayoutProps extends SoperioComponent, ParentComponent {
4
+ color: Color;
5
+ darkMode?: boolean;
6
+ logo?: React.ReactNode;
7
+ title?: string;
8
+ menuConfig: MenuConfig;
9
+ userMenuConfig?: MenuConfig;
10
+ userSettingsPath: string;
11
+ }
12
+ export declare function AdminLayout({ color, darkMode, logo, title, menuConfig, userMenuConfig, userSettingsPath, ...props }: LayoutProps): JSX.Element;
13
+ export {};