react-crud-mui 0.2.42 → 0.2.44
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/dist/components/detail-page/components/DetailPageCommands.d.ts +3 -3
- package/dist/components/detail-page/hooks/useDetailPageModal.d.ts +2 -3
- package/dist/components/detail-page/pages/DetailPageContent.d.ts +3 -3
- package/dist/components/form/components/FormStatesProvider.d.ts +8 -0
- package/dist/components/form/hooks/index.d.ts +1 -0
- package/dist/components/form/hooks/useFormStatesContext.d.ts +3 -0
- package/dist/components/i18n/resources/en.json.d.ts +1 -1
- package/dist/components/list-page/components/ListPageCommands.d.ts +7 -47
- package/dist/components/list-page/hooks/useListPageCommandStates.d.ts +13 -2
- package/dist/components/list-page/hooks/useURLSearchFilter.d.ts +1 -2
- package/dist/components/list-page/pages/ListPage.d.ts +2 -0
- package/dist/components/list-page/pages/ListPageContent.d.ts +10 -2
- package/dist/components/list-page/pages/ListPageForm.d.ts +3 -1
- package/dist/coreui.js +6244 -6132
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { PropsWithChildren
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { ButtonProps } from '@mui/material';
|
|
2
3
|
import { UseFormReturn } from '../../form/hooks/useForm';
|
|
3
4
|
import { CloseReason } from '../../page/Page';
|
|
4
5
|
import { DetailPageCommandsFlag } from '../hooks/useDetailPageStates';
|
|
@@ -6,8 +7,6 @@ import { SaveMode } from '../pages/DetailPageData';
|
|
|
6
7
|
import { StepPane } from './DetailPageStepsHeader';
|
|
7
8
|
export type DetailPageStandartCommandsOptions = {
|
|
8
9
|
saveCommandMode?: SaveMode;
|
|
9
|
-
createCommandLabel?: ReactNode;
|
|
10
|
-
saveCommandLabel?: ReactNode;
|
|
11
10
|
};
|
|
12
11
|
export type DetailPageStepCommandsOptions = {
|
|
13
12
|
nextButtonTitle?: React.ReactNode;
|
|
@@ -39,6 +38,7 @@ export type DetailPageCommandsProps = DetailPageStandartCommandsEvents & DetailP
|
|
|
39
38
|
options: DetailPageCommandsOptions;
|
|
40
39
|
mode: 'standard' | 'steps';
|
|
41
40
|
moreCommands?: Partial<Record<keyof DetailPageCommandsFlag, true>>;
|
|
41
|
+
commandsProps?: Partial<Record<keyof DetailPageCommandsFlag, ButtonProps>>;
|
|
42
42
|
} & PropsWithChildren;
|
|
43
43
|
declare function DetailPageCommands(props: DetailPageCommandsProps): import("react/jsx-runtime").JSX.Element;
|
|
44
44
|
export default DetailPageCommands;
|
|
@@ -446,6 +446,7 @@ declare function useDetailPageModal<TModel extends FieldValues>({ models, unique
|
|
|
446
446
|
readonly onTabChanged?: (selected: import('../../page/components/DefaultTabs').TabChangedPayload) => void;
|
|
447
447
|
readonly onTabs?: (props: import('../../..').DefaultTabsProps) => import('react').ReactNode;
|
|
448
448
|
readonly bordered?: boolean;
|
|
449
|
+
readonly reason?: NeedDataReason;
|
|
449
450
|
readonly onDelete?: import('../pages/DetailPageData').DataEvent<TModel, import('../pages/DetailPageData').DeletePayload<TModel>> | undefined;
|
|
450
451
|
readonly enableClose?: boolean;
|
|
451
452
|
readonly enableCopy?: boolean;
|
|
@@ -453,10 +454,8 @@ declare function useDetailPageModal<TModel extends FieldValues>({ models, unique
|
|
|
453
454
|
readonly enableDelete?: boolean;
|
|
454
455
|
readonly enableDiscardChanges?: boolean;
|
|
455
456
|
readonly enableSave?: boolean;
|
|
456
|
-
readonly reason?: NeedDataReason;
|
|
457
457
|
readonly activeSegmentIndex?: number;
|
|
458
|
-
readonly
|
|
459
|
-
readonly saveCommandLabel?: import('react').ReactNode;
|
|
458
|
+
readonly commandsProps?: Partial<Record<keyof import('./useDetailPageStates').DetailPageCommandsFlag, import('@mui/material').ButtonProps>>;
|
|
460
459
|
readonly onCommands?: (props: import('../components/DetailPageCommands').DetailPageCommandsProps) => import('react').ReactNode;
|
|
461
460
|
readonly onExtraCommands?: () => import('react').ReactNode;
|
|
462
461
|
readonly alerts?: import('../../page/hooks/useNormalizeMessages').Message[];
|
|
@@ -5,7 +5,7 @@ import { Message } from '../../page/hooks/useNormalizeMessages';
|
|
|
5
5
|
import { PageProps } from '../../page/Page';
|
|
6
6
|
import { ServerError } from '../../utils';
|
|
7
7
|
import { AutoSaveOptions } from '../components/AutoSave';
|
|
8
|
-
import { DetailPageCommandsProps
|
|
8
|
+
import { DetailPageCommandsProps } from '../components/DetailPageCommands';
|
|
9
9
|
import { DetailPageLayoutProps } from '../components/DetailPageDefaultLayout';
|
|
10
10
|
import { DetailPageHeaderProps } from '../components/DetailPageHeader';
|
|
11
11
|
import { DetailPageStepsHeaderProps, StepPane } from '../components/DetailPageStepsHeader';
|
|
@@ -17,7 +17,7 @@ export type DetailPageWrapperLayoutProps = {
|
|
|
17
17
|
commandsContent: ReactNode;
|
|
18
18
|
alertsContent: ReactNode;
|
|
19
19
|
};
|
|
20
|
-
export interface DetailPageContentProps<TModel extends FieldValues> extends Omit<PageProps, 'commandsContent' | 'alertsContent' | 'autoSave' | 'onHeader' | 'tabExtraContent'>, Pick<
|
|
20
|
+
export interface DetailPageContentProps<TModel extends FieldValues> extends Omit<PageProps, 'commandsContent' | 'alertsContent' | 'autoSave' | 'onHeader' | 'tabExtraContent'>, Pick<DetailPageCommandsProps, 'commandsProps'> {
|
|
21
21
|
/**
|
|
22
22
|
* Custom commands node
|
|
23
23
|
*/
|
|
@@ -142,5 +142,5 @@ export interface DetailPageContentProps<TModel extends FieldValues> extends Omit
|
|
|
142
142
|
stepsProps?: Partial<DetailPageStepsHeaderProps>;
|
|
143
143
|
tabExtraContent?: ReactNode | ((data?: TModel) => ReactNode);
|
|
144
144
|
}
|
|
145
|
-
declare function DetailPageContent<TModel extends FieldValues>({ activeSegmentIndex, alerts, autoSave, children, commandsPosition, customSteps: CustomSteps,
|
|
145
|
+
declare function DetailPageContent<TModel extends FieldValues>({ activeSegmentIndex, alerts, autoSave, children, commandsPosition, commandsProps, customSteps: CustomSteps, data, defaultSaveMode, disabled, disableShortCuts, enableClose, enableCopy, enableCreate, enableDelete, enableDiscardChanges, enableSave, error, form, hotkeyScopes, loading, onClose, onCommands, onContentLayout, onCopy, onCreate, onDelete, onDiscardChanges, onSegmentChanged, onExtraCommands, onHeader, onSave, onSaveClose, onSaveCreate, onWrapperLayout, reason, showHeader, steps, stepsProps, tabExtraContent, ...pageProps }: DetailPageContentProps<TModel>): import("react/jsx-runtime").JSX.Element;
|
|
146
146
|
export default DetailPageContent;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React, PropsWithChildren } from 'react';
|
|
2
|
+
export interface FormStatesProviderProps {
|
|
3
|
+
isTouched?: boolean;
|
|
4
|
+
setTouched?: (value: boolean) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const FormStatesContext: React.Context<FormStatesProviderProps>;
|
|
7
|
+
declare function FormStatesProvider({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default FormStatesProvider;
|
|
@@ -12,4 +12,5 @@ export { default as useUniqueFieldsInArray } from './useUniqueFieldsInArray';
|
|
|
12
12
|
export { default as useFormInitEffect } from './useFormInitEffect';
|
|
13
13
|
export { default as useFieldWithContext } from './useFieldWithContext';
|
|
14
14
|
export { default as useFormCollectionContext } from './useFormCollectionContext';
|
|
15
|
+
export { default as useFormStatesContext } from './useFormStatesContext';
|
|
15
16
|
export { UNIQUE_IDENTIFIER_FIELD_NAME } from './useArrayFieldHelpers';
|
|
@@ -136,7 +136,7 @@ declare const _default: {
|
|
|
136
136
|
"nextstep": "Next Step",
|
|
137
137
|
"no": "No",
|
|
138
138
|
"nodatafound": "No item found to display",
|
|
139
|
-
"pleasewait": "Please wait",
|
|
139
|
+
"pleasewait": "Please wait..",
|
|
140
140
|
"takingtoolong": "We’re working on it,please hold on",
|
|
141
141
|
"prevpage": "Previous record",
|
|
142
142
|
"prevstep": "Previous Step",
|
|
@@ -1,55 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LoadingButtonProps } from '@mui/lab/LoadingButton';
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
3
2
|
import { ButtonProps } from '@mui/material/Button';
|
|
4
|
-
import {
|
|
5
|
-
export
|
|
6
|
-
search?: boolean;
|
|
7
|
-
export?: boolean;
|
|
8
|
-
clear?: boolean;
|
|
9
|
-
create?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export interface ListPageCommandsExtraProps {
|
|
12
|
-
search?: LoadingButtonProps;
|
|
13
|
-
clear?: ButtonProps;
|
|
14
|
-
create?: ButtonProps;
|
|
15
|
-
}
|
|
16
|
-
export interface ListPageCommandsOptions {
|
|
17
|
-
visible: ListPageCommandsFlag;
|
|
18
|
-
disabled: ListPageCommandsFlag;
|
|
19
|
-
loading?: boolean;
|
|
20
|
-
}
|
|
21
|
-
export type ListPageCommandsStates = {
|
|
3
|
+
import { ListPageCommandsFlag } from '../hooks/useListPageCommandStates';
|
|
4
|
+
export type ListPageCommandsEvents = {
|
|
22
5
|
onSearch: () => void;
|
|
23
6
|
onCreateItem?: () => void;
|
|
24
7
|
onClear?: () => void;
|
|
25
8
|
onExcelExport?: () => void;
|
|
26
|
-
createCommandLabel?: ReactNode;
|
|
27
9
|
};
|
|
28
|
-
export type
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export: ReactNode;
|
|
33
|
-
content: ReactNode;
|
|
34
|
-
renderMoreCommand: (items: MoreButtonItem[]) => ReactNode;
|
|
35
|
-
extra?: ReactNode;
|
|
36
|
-
};
|
|
37
|
-
export type ListPageCommmandsSettings = {
|
|
38
|
-
content: ReactNode;
|
|
39
|
-
layout: ListPageCommandsLayoutContents;
|
|
40
|
-
props: ListPageCommandsStates & ListPageCommandsOptions;
|
|
41
|
-
};
|
|
42
|
-
export interface ListPageCommandsProps extends ListPageCommandsStates {
|
|
43
|
-
onCommands?: (props: ListPageCommmandsSettings) => ReactNode;
|
|
44
|
-
onExtraCommands?: () => ReactNode;
|
|
45
|
-
commandsExtraProps?: ListPageCommandsExtraProps;
|
|
46
|
-
}
|
|
47
|
-
export declare enum ListPageCommandNames {
|
|
48
|
-
SEARCH = "search",
|
|
49
|
-
CLEAR = "clear",
|
|
50
|
-
CREATE = "create",
|
|
51
|
-
EXPORT = "export",
|
|
52
|
-
SELECT = "select"
|
|
53
|
-
}
|
|
10
|
+
export type ListPageCommandsProps = ListPageCommandsEvents & {
|
|
11
|
+
moreCommands?: Partial<Record<keyof ListPageCommandsFlag, true>>;
|
|
12
|
+
commandsProps?: Partial<Record<keyof ListPageCommandsFlag, ButtonProps>>;
|
|
13
|
+
} & PropsWithChildren;
|
|
54
14
|
declare function ListPageCommands(props: ListPageCommandsProps): import("react/jsx-runtime").JSX.Element;
|
|
55
15
|
export default ListPageCommands;
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import { FieldValues } from 'react-hook-form';
|
|
2
|
+
export interface ListPageCommandsFlag {
|
|
3
|
+
search?: boolean;
|
|
4
|
+
export?: boolean;
|
|
5
|
+
clear?: boolean;
|
|
6
|
+
create?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ListPageCommandsOptions {
|
|
9
|
+
visible: ListPageCommandsFlag;
|
|
10
|
+
disabled: ListPageCommandsFlag;
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
}
|
|
2
13
|
/**
|
|
3
14
|
* Returns buttons props depending on validation,loading etc
|
|
4
15
|
* Beware of rerender when state of form changes
|
|
5
16
|
*/
|
|
6
17
|
declare function useListPageCommandStates<TModel extends FieldValues>(): {
|
|
7
18
|
formStates: import('react-hook-form').UseFormStateReturn<FieldValues>;
|
|
8
|
-
visible:
|
|
9
|
-
disabled:
|
|
19
|
+
visible: ListPageCommandsFlag;
|
|
20
|
+
disabled: ListPageCommandsFlag;
|
|
10
21
|
loading?: boolean;
|
|
11
22
|
};
|
|
12
23
|
export default useListPageCommandStates;
|
|
@@ -4,10 +4,9 @@ export type MatchFields<TFilter extends FieldValues> = {
|
|
|
4
4
|
[k in keyof TFilter]?: true;
|
|
5
5
|
};
|
|
6
6
|
type UseURLSearchFilterOptions<TFilter extends FieldValues> = {
|
|
7
|
-
defaultValues?: Record<string, unknown>;
|
|
8
7
|
matcher?: MatchFields<TFilter>;
|
|
9
8
|
};
|
|
10
|
-
declare function useURLSearchFilter<TFilter extends FieldValues>({
|
|
9
|
+
declare function useURLSearchFilter<TFilter extends FieldValues>({ matcher, }: UseURLSearchFilterOptions<TFilter>): {
|
|
11
10
|
getFiltersInQS: () => {
|
|
12
11
|
filter: {
|
|
13
12
|
[key: string]: unknown;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FieldValues } from 'react-hook-form';
|
|
2
|
+
import { default as ListPageCommands } from '../components/ListPageCommands';
|
|
2
3
|
import { ListPageMeta } from './ListPageFilter';
|
|
3
4
|
import { ListPageFormProps } from './ListPageForm';
|
|
4
5
|
import { default as ListPageModal } from './ListPageModal';
|
|
@@ -22,5 +23,6 @@ declare namespace ListPage {
|
|
|
22
23
|
var Selection: typeof ListPageSelection;
|
|
23
24
|
var Modal: typeof ListPageModal;
|
|
24
25
|
var Route: typeof ListPageRoute;
|
|
26
|
+
var Commands: typeof ListPageCommands;
|
|
25
27
|
}
|
|
26
28
|
export default ListPage;
|
|
@@ -24,7 +24,15 @@ export type ListPageWrapperLayoutProps = {
|
|
|
24
24
|
};
|
|
25
25
|
type DetailPageRender<TDetailPageModel extends FieldValues> = (props: DetailPageModalProps<TDetailPageModel> | DetailPageDrawerProps<TDetailPageModel>, open: ReturnType<typeof useDetailPageModal<TDetailPageModel>>[0]) => ReactNode;
|
|
26
26
|
export type OnDetailPage<TDetailPageModel extends FieldValues> = Partial<Record<NeedDataReason, DetailPageRender<TDetailPageModel>>> | DetailPageRender<TDetailPageModel>;
|
|
27
|
-
export interface ListPageContentProps<TModel extends FieldValues> extends Omit<PageProps, 'commandsContent' | 'alertsContent' | 'autoSave' | 'onHeader' | 'onChange' | 'onCopy'>, Pick<ListPageCommandsProps, '
|
|
27
|
+
export interface ListPageContentProps<TModel extends FieldValues> extends Omit<PageProps, 'commandsContent' | 'alertsContent' | 'autoSave' | 'onHeader' | 'onChange' | 'onCopy'>, Pick<ListPageCommandsProps, 'commandsProps'> {
|
|
28
|
+
/**
|
|
29
|
+
* Custom commands node
|
|
30
|
+
*/
|
|
31
|
+
onCommands?: (props: ListPageCommandsProps) => ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* Extra commands positioned left side in commands section
|
|
34
|
+
*/
|
|
35
|
+
onExtraCommands?: () => ReactNode;
|
|
28
36
|
/**
|
|
29
37
|
* Alerts
|
|
30
38
|
*/
|
|
@@ -155,5 +163,5 @@ export interface ListPageContentProps<TModel extends FieldValues> extends Omit<P
|
|
|
155
163
|
*/
|
|
156
164
|
listType?: ListType;
|
|
157
165
|
}
|
|
158
|
-
declare function ListPageContent<TModel extends FieldValues>({ activeSegmentIndex, actionCommandsProps, actionColumnProps, alerts, autoSearch, cardProps, children, columns,
|
|
166
|
+
declare function ListPageContent<TModel extends FieldValues>({ activeSegmentIndex, actionCommandsProps, actionColumnProps, alerts, autoSearch, cardProps, children, columns, commandsProps, data, dataCount, disabled, disableShortCuts, enableActionCommands, enableRowClickToDetails, enableClear, enableCreateItem, enableRefetch, enableExport, enableSearch, error, filterContent, hotkeyScopes, listType, loading, onActionClick, onActionCommands, onClear, onClose, onCommands, onCustomTable, onDetailPage, onExcelExport, onExtraCommands, onHeader, onSearch, onTabChanged, tableProps, onWrapperLayout, showHeader, ...pageProps }: ListPageContentProps<TModel>): import("react/jsx-runtime").JSX.Element;
|
|
159
167
|
export default ListPageContent;
|
|
@@ -3,6 +3,8 @@ import { z } from 'zod';
|
|
|
3
3
|
import { UseFormReturn, ValidationOptions } from '../../form/hooks/useForm';
|
|
4
4
|
import { DeepNullable } from '../../utils';
|
|
5
5
|
import { ListPageFilterProps } from './ListPageFilter';
|
|
6
|
+
export type DefaultDataFn<TModel extends FieldValues> = (data?: TModel) => Promise<DeepNullable<TModel>>;
|
|
7
|
+
export type DefaultData<TModel extends FieldValues = FieldValues> = DeepNullable<TModel> | DefaultDataFn<TModel>;
|
|
6
8
|
export interface ListPageFormProps<TModel extends FieldValues, TFilter extends FieldValues = FieldValues> extends Omit<ListPageFilterProps<TModel, TFilter>, 'form'> {
|
|
7
9
|
form?: UseFormReturn<TFilter>;
|
|
8
10
|
schema?: z.ZodType<TFilter>;
|
|
@@ -13,7 +15,7 @@ export interface ListPageFormProps<TModel extends FieldValues, TFilter extends F
|
|
|
13
15
|
/**
|
|
14
16
|
* Default form fields values
|
|
15
17
|
*/
|
|
16
|
-
defaultValues?:
|
|
18
|
+
defaultValues?: DefaultData<TFilter>;
|
|
17
19
|
/**
|
|
18
20
|
* Optional validation options
|
|
19
21
|
*/
|