@jasperoosthoek/react-toolbox 0.5.5 → 0.5.7
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/LICENSE +1 -1
- package/change-log.md +7 -0
- package/dist/components/forms/FormFields.d.ts +1 -7
- package/dist/components/forms/FormModal.d.ts +41 -0
- package/dist/components/forms/FormModalProvider.d.ts +42 -0
- package/dist/components/tables/DataTable.d.ts +4 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +2 -2
- package/src/components/buttons/IconButtons.tsx +2 -2
- package/src/components/forms/FormFields.tsx +0 -4
- package/src/components/forms/{CreateEditModal.tsx → FormModal.tsx} +5 -4
- package/src/components/forms/{CreateEditModalProvider.tsx → FormModalProvider.tsx} +29 -21
- package/src/components/tables/DataTable.tsx +34 -13
- package/src/components/tables/DragAndDropList.tsx +0 -1
- package/src/index.ts +2 -2
package/LICENSE
CHANGED
package/change-log.md
CHANGED
|
@@ -239,3 +239,10 @@
|
|
|
239
239
|
|
|
240
240
|
##### Version 0.5.5
|
|
241
241
|
- Remove unnecessary packages from devDependencies
|
|
242
|
+
|
|
243
|
+
##### Version 0.5.6
|
|
244
|
+
- Rename `CreateEditModal` & `CreateEditModalProvider` to `FormModal` & `FormModalProvider`
|
|
245
|
+
- Remove out of context error when clicking row to open `EditModal` on `DataTable`
|
|
246
|
+
|
|
247
|
+
##### Version 0.5.7
|
|
248
|
+
- New optional footer with sum of values in `DataTable` component
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { ReactElement } from 'react';
|
|
2
2
|
import { BadgeProps, FormControlProps, FormCheckProps } from 'react-bootstrap';
|
|
3
3
|
import { Variant } from 'react-bootstrap/types';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
4
|
import { Moment } from 'moment';
|
|
6
5
|
export type FormValue = boolean | string | string[] | number | number[];
|
|
7
6
|
export type FormOnChange = (((value: FormValue) => void) | ((value: FormValue, formData: any) => any));
|
|
@@ -65,12 +64,7 @@ export type FormSelectProps = Omit<FormInputProps, 'disabled' | 'onChange'> & {
|
|
|
65
64
|
idKey?: string;
|
|
66
65
|
disabled?: boolean | ((props: DisabledProps) => boolean);
|
|
67
66
|
};
|
|
68
|
-
export declare const FormSelect: {
|
|
69
|
-
({ list, idKey, integer, value, defaultValue, onChange, label, controlId, htmlSize, state, formatTitle, multiple, disabled, isInvalid, initialState, initialValue, keyName, pristine, }: FormSelectProps): React.JSX.Element;
|
|
70
|
-
propTypes: {
|
|
71
|
-
onChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
72
|
-
};
|
|
73
|
-
};
|
|
67
|
+
export declare const FormSelect: ({ list, idKey, integer, value, defaultValue, onChange, label, controlId, htmlSize, state, formatTitle, multiple, disabled, isInvalid, initialState, initialValue, keyName, pristine, }: FormSelectProps) => React.JSX.Element;
|
|
74
68
|
export interface BadgeSelectionProps extends BadgeProps {
|
|
75
69
|
selected: boolean;
|
|
76
70
|
cursor: string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
import { FormComponentProps, FormSelectProps, FormOnChange, FormValue } from './FormFields';
|
|
3
|
+
export type FormField = {
|
|
4
|
+
initialValue?: any;
|
|
5
|
+
type?: 'string' | 'number';
|
|
6
|
+
required?: boolean;
|
|
7
|
+
formProps?: any;
|
|
8
|
+
component?: (props: FormComponentProps | FormSelectProps) => ReactElement;
|
|
9
|
+
onChange?: FormOnChange;
|
|
10
|
+
label?: ReactElement | string;
|
|
11
|
+
};
|
|
12
|
+
export type IncludeData<T> = {
|
|
13
|
+
[key in Exclude<string, keyof T>]: any;
|
|
14
|
+
};
|
|
15
|
+
export type InitialState<T> = Partial<{
|
|
16
|
+
[key in keyof T]: FormValue;
|
|
17
|
+
}>;
|
|
18
|
+
export type FormFields = {
|
|
19
|
+
[key: string]: FormField;
|
|
20
|
+
};
|
|
21
|
+
export type OnSave<T, K> = (state: ({
|
|
22
|
+
[key in keyof T]: FormValue;
|
|
23
|
+
}), callback: () => void) => void;
|
|
24
|
+
export type Validate = (state: any) => any;
|
|
25
|
+
export type ModalTitle = ReactElement | string;
|
|
26
|
+
export type Width = 25 | 50 | 75 | 100;
|
|
27
|
+
export type FormModalProps<T extends FormFields, K extends IncludeData<T>> = {
|
|
28
|
+
initialState: InitialState<T> | K;
|
|
29
|
+
includeData?: K;
|
|
30
|
+
formFields: T;
|
|
31
|
+
show?: boolean;
|
|
32
|
+
onSave: OnSave<T, K>;
|
|
33
|
+
onHide: () => void;
|
|
34
|
+
validate?: Validate;
|
|
35
|
+
modalTitle?: ModalTitle;
|
|
36
|
+
loading?: boolean;
|
|
37
|
+
dialogClassName?: string;
|
|
38
|
+
width?: Width;
|
|
39
|
+
};
|
|
40
|
+
export declare const FormModal: <T extends FormFields, K extends IncludeData<T>>({ initialState, formFields, includeData, show, onSave, onHide, validate, modalTitle, loading, dialogClassName, width, ...restProps }: FormModalProps<T, K>) => React.JSX.Element;
|
|
41
|
+
export declare const DisabledFormField: ({ value }: any) => React.JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { FormFields, IncludeData, InitialState, OnSave, Validate, ModalTitle, Width } from './FormModal';
|
|
3
|
+
import { FormValue } from './FormFields';
|
|
4
|
+
import { ButtonProps } from '../buttons/IconButtons';
|
|
5
|
+
export type ShowCreateModal = (show?: boolean) => void;
|
|
6
|
+
export type ShowEditModal<T, K> = (state: {
|
|
7
|
+
[key in keyof T]: FormValue;
|
|
8
|
+
} & K) => void;
|
|
9
|
+
export type ShowCreateModalButton = ButtonProps;
|
|
10
|
+
export declare const ShowCreateModalButton: ({ onClick, ...props }: ButtonProps) => React.JSX.Element;
|
|
11
|
+
export interface ShowEditModalButtonProps<T, K> extends ButtonProps {
|
|
12
|
+
state: {
|
|
13
|
+
[key in keyof T]: FormValue;
|
|
14
|
+
} & K;
|
|
15
|
+
}
|
|
16
|
+
export declare const ShowEditModalButton: ({ state, onClick, ...props }: ShowEditModalButtonProps<T, K>) => React.JSX.Element;
|
|
17
|
+
type FormModalContextType<T, K> = {
|
|
18
|
+
showCreateModal: ShowCreateModal;
|
|
19
|
+
showEditModal: ShowEditModal<T, K>;
|
|
20
|
+
hasProvider: boolean;
|
|
21
|
+
};
|
|
22
|
+
type T = any;
|
|
23
|
+
type K = any;
|
|
24
|
+
export declare const FormModalContext: React.Context<FormModalContextType<any, any>>;
|
|
25
|
+
export declare const useFormModal: () => FormModalContextType<any, any>;
|
|
26
|
+
export type FormModalProviderProps<T extends FormFields, K extends IncludeData<T>> = {
|
|
27
|
+
initialState: InitialState<T> | K;
|
|
28
|
+
includeData?: K;
|
|
29
|
+
formFields: T;
|
|
30
|
+
onSave?: OnSave<T, K>;
|
|
31
|
+
onCreate?: OnSave<T, K>;
|
|
32
|
+
onUpdate?: OnSave<T, K>;
|
|
33
|
+
validate?: Validate;
|
|
34
|
+
createModalTitle?: ModalTitle;
|
|
35
|
+
editModalTitle?: ModalTitle;
|
|
36
|
+
loading?: boolean;
|
|
37
|
+
dialogClassName?: string;
|
|
38
|
+
width?: Width;
|
|
39
|
+
children: ReactNode;
|
|
40
|
+
};
|
|
41
|
+
export declare const FormModalProvider: React.FC<FormModalProviderProps<T, K>>;
|
|
42
|
+
export {};
|
|
@@ -12,6 +12,8 @@ export type DataTableColumn<R> = {
|
|
|
12
12
|
orderBy?: OrderByColumn<R>;
|
|
13
13
|
optionsDropdown?: OptionsDropdown;
|
|
14
14
|
className?: string;
|
|
15
|
+
value?: number | string | ((row: R) => number);
|
|
16
|
+
formatSum?: ((value: number) => ReactElement | string | number) | ReactElement | string | number;
|
|
15
17
|
selector: number | string | ((row: R) => ReactElement | string | number | (ReactElement | string | number)[]);
|
|
16
18
|
onClick?: OnClickRow<R>;
|
|
17
19
|
};
|
|
@@ -47,5 +49,6 @@ export type DataTableProps<D extends any[]> = {
|
|
|
47
49
|
className?: string;
|
|
48
50
|
rowClassName?: string | ((row: D[number]) => string);
|
|
49
51
|
style?: any;
|
|
52
|
+
showSum?: boolean;
|
|
50
53
|
};
|
|
51
|
-
export declare const DataTable: <D extends any[]>({ data: allData, columns, rowsPerPage: rowsPerPageDefault, rowsPerPageOptions, filterColumn, orderByDefault, orderByDefaultDirection, onMove, moveId, moveIsLoading, showHeader, onClickRow, showEditModalOnClickRow, textOnEmpty, className, rowClassName, style, ...restProps }: DataTableProps<D>) => React.JSX.Element;
|
|
54
|
+
export declare const DataTable: <D extends any[]>({ data: allData, columns, rowsPerPage: rowsPerPageDefault, rowsPerPageOptions, filterColumn, orderByDefault, orderByDefaultDirection, onMove, moveId, moveIsLoading, showHeader, onClickRow, showEditModalOnClickRow, textOnEmpty, className, rowClassName, style, showSum, ...restProps }: DataTableProps<D>) => React.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export * from './components/buttons/ConfirmButton';
|
|
|
3
3
|
export { default as ConfirmButton } from './components/buttons/ConfirmButton';
|
|
4
4
|
export { default as DeleteConfirmButton } from './components/buttons/DeleteConfirmButton';
|
|
5
5
|
export * from './components/buttons/DeleteConfirmButton';
|
|
6
|
-
export * from './components/forms/
|
|
7
|
-
export * from './components/forms/
|
|
6
|
+
export * from './components/forms/FormModal';
|
|
7
|
+
export * from './components/forms/FormModalProvider';
|
|
8
8
|
export * from './components/forms/FormFields';
|
|
9
9
|
export * from './components/indicators/LoadingIndicator';
|
|
10
10
|
export * from './components/indicators/CheckIndicator';
|