@compill/admin 1.0.25 → 1.0.26

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.
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import { MutationQueryFn, MutationQueryKey } from '../../../../../api/src/index.ts';
3
+ import { ButtonProps } from "@valerya/ui";
4
+ interface ActionButtonProps {
5
+ label: string;
6
+ buttonProps?: ButtonProps;
7
+ icon?: string;
8
+ queryKey: MutationQueryKey;
9
+ queryFn: MutationQueryFn<any, any>;
10
+ successMsg?: string;
11
+ errorMsg?: string;
12
+ invalidateParent?: boolean;
13
+ }
14
+ export declare function ActionButton({ label, buttonProps, icon, queryKey, queryFn, successMsg, errorMsg, invalidateParent }: ActionButtonProps): JSX.Element;
15
+ export {};
@@ -0,0 +1,27 @@
1
+ /// <reference types="react" />
2
+ import { MutationQueryFn, MutationQueryKey } from '../../../../../api/src/index.ts';
3
+ import { ButtonProps, ModalProps } from "@valerya/ui";
4
+ interface ConfirmationActionButtonProps {
5
+ label: string;
6
+ buttonProps?: ButtonProps;
7
+ icon?: string;
8
+ queryKey: MutationQueryKey;
9
+ queryFn: MutationQueryFn<any, any>;
10
+ successMsg?: string;
11
+ errorMsg?: string;
12
+ invalidateParent?: boolean;
13
+ }
14
+ export declare function ConfirmationActionButton({ label, buttonProps, icon, queryKey, queryFn, successMsg, errorMsg, invalidateParent }: ConfirmationActionButtonProps): JSX.Element;
15
+ interface ConfirmationDialogProps extends Pick<ModalProps, "show" | "onClose"> {
16
+ title: string;
17
+ text: string;
18
+ positiveButtonLabel?: string;
19
+ negativeButtonLabel?: string;
20
+ queryKey: MutationQueryKey;
21
+ queryFn: MutationQueryFn<any, any>;
22
+ successMsg?: string;
23
+ errorMsg?: string;
24
+ invalidateParent?: boolean;
25
+ }
26
+ export declare function ConfirmationDialog({ title, text, positiveButtonLabel, negativeButtonLabel, queryKey, queryFn, successMsg, errorMsg, invalidateParent, show, onClose }: ConfirmationDialogProps): JSX.Element;
27
+ export {};
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { SoperioComponent } from "@soperio/react";
3
3
  import { TableViewConfig } from "../types/TableView";
4
- export declare function TableView({ title, queryField, screen, ...props }: TableViewConfig & SoperioComponent): JSX.Element;
4
+ export declare function TableView({ queryField, title, subtitle, screen, ...props }: Omit<TableViewConfig, "type"> & SoperioComponent): JSX.Element;
@@ -2,17 +2,20 @@
2
2
  import { API } from '../../../../../admin-api/src/index.ts';
3
3
  import { FormRendererConfig } from '../../../../../form/src/index.ts';
4
4
  import { TableProps } from '../../../../../table/src/index.ts';
5
- import { ModalProps } from "@valerya/ui";
5
+ import { ButtonProps, ModalProps } from "@valerya/ui";
6
6
  import { Breadcrumb } from "../../breadcrumbs/BreadCrumbs";
7
7
  import { ItemDeleteDialogProps } from "../dialog/ItemDeleteDialog";
8
8
  import { EditItemDialogConfig } from "./EditItemDialog";
9
9
  import { QueryWrapperDialogConfig } from "./QueryWrapperDialog";
10
- type Screen = {
10
+ import * as Yup from "yup";
11
+ import { MutationQueryFn, MutationQueryKey } from '../../../../../api/src/index.ts';
12
+ export type TableViewScreen = {
11
13
  api: API<any>;
12
14
  breadcrumbs?: Breadcrumb[];
13
15
  buttonBar?: TableViewButtonConfig[];
14
16
  filters?: TableFilters;
15
17
  massActions?: TableMassActions;
18
+ createView?: TableViewEditView;
16
19
  editView?: TableViewEditView;
17
20
  deleteItem?: TableViewDeleteItem;
18
21
  table: TableViewTable;
@@ -21,8 +24,9 @@ type Screen = {
21
24
  export type TableViewConfig = {
22
25
  type: "table";
23
26
  title: string;
27
+ subtitle?: string | React.ReactNode | ((data: any) => string | React.ReactNode);
24
28
  queryField?: string;
25
- screen: Screen | ((id: string) => Screen);
29
+ screen: TableViewScreen | ((id: string) => TableViewScreen);
26
30
  };
27
31
  export type CustomDialog = {
28
32
  type: "customDialog";
@@ -30,6 +34,7 @@ export type CustomDialog = {
30
34
  };
31
35
  export type TableViewEditView = CustomDialog | EditItemDialogConfig | QueryWrapperDialogConfig<any>;
32
36
  export type TableViewTable = Omit<TableProps, "onRowClick" | "queryKey" | "queryFn"> & {
37
+ initialVisibleColumns?: string[];
33
38
  onRowClick?: {
34
39
  type: "navigate";
35
40
  path: string | ((item: any) => string);
@@ -72,6 +77,38 @@ type TableViewButtonConfig = {
72
77
  type TableFilters = {
73
78
  form: FormRendererConfig;
74
79
  initialValues: any | ((data: any) => any);
80
+ schema?: Yup.AnySchema;
81
+ processInput: (input: any) => any;
75
82
  };
76
- type TableMassActions = {};
83
+ type TableMassActions = {
84
+ items: MassAction[];
85
+ };
86
+ export type MassAction = ({
87
+ type: "custom";
88
+ render: (selectedRows: any[]) => React.ReactNode;
89
+ } | {
90
+ type: "select";
91
+ provider?: Record<string, any>[] | ((selectedRows: any) => Record<string, any>[]);
92
+ labelField?: string;
93
+ valueField?: string;
94
+ queryFn: MutationQueryFn<any, any>;
95
+ queryKey: MutationQueryKey;
96
+ } | {
97
+ type: "dynamicChoiceList";
98
+ } | {
99
+ type: "button";
100
+ label: string;
101
+ icon?: string;
102
+ buttonProps?: ButtonProps;
103
+ queryFn: MutationQueryFn<any, any>;
104
+ queryKey: MutationQueryKey;
105
+ invalidateParent?: boolean;
106
+ showConfirmationDialog?: boolean;
107
+ confirmationDialogTitle?: string;
108
+ confirmationDialogText?: string;
109
+ confirmationDialogPositiveButtonLabel?: string;
110
+ confirmationDialogNegativeButtonLabel?: string;
111
+ successMsg?: (rows: any[]) => string;
112
+ errorMsg?: (rows: any[]) => string;
113
+ });
77
114
  export {};
File without changes
@@ -1,3 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { ParentComponent, SoperioComponent } from "@soperio/react";
3
- export declare function TableContainer({ children, ...props }: SoperioComponent & ParentComponent): JSX.Element;
2
+ import { ColumnDef } from "@tanstack/react-table";
3
+ import { TileProps } from "@valerya/ui";
4
+ interface TableContainerProps extends TileProps {
5
+ initialPageSize?: number;
6
+ columns?: ColumnDef<any>[];
7
+ initialVisibleColumns?: string[];
8
+ }
9
+ export declare function TableContainer({ initialPageSize, initialVisibleColumns, columns, children, ...props }: TableContainerProps): JSX.Element;
10
+ export {};
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import { ColumnDef } from "@tanstack/react-table";
3
+ type TableContainerContextProps = {
4
+ showFilters?: boolean;
5
+ setShowFilters: (show: boolean) => void;
6
+ showMassActions?: boolean;
7
+ setShowMassActions: (show: boolean) => void;
8
+ columns: ColumnDef<any, any>[];
9
+ filteredColumns: ColumnDef<any, any>[];
10
+ toggleColumnVisibility: (id: string) => void;
11
+ isColumnVisible: (id: string) => boolean;
12
+ };
13
+ declare const useContext: () => TableContainerContextProps;
14
+ declare function TableContainerContextProvider({ initialVisibleColumns, columns, children }: {
15
+ initialVisibleColumns?: string[];
16
+ columns?: ColumnDef<any, any>[];
17
+ } & React.PropsWithChildren): JSX.Element;
18
+ export { TableContainerContextProvider, useContext as useTableContainerContext };
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { FormRendererConfig } from '../../../../form/src/index.ts';
3
+ interface TableFiltersProps {
4
+ form: FormRendererConfig;
5
+ initialValues: any;
6
+ schema?: any;
7
+ processInput?: (input: any) => any;
8
+ }
9
+ export declare function TableFilters({ form, initialValues, schema, processInput }: TableFiltersProps): JSX.Element;
10
+ export {};
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { MassAction } from "../json/types/TableView";
3
+ interface TableMassActionsProps {
4
+ actions: MassAction[];
5
+ }
6
+ export declare function TableMassActions({ actions }: TableMassActionsProps): JSX.Element;
7
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compill/admin",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {