@jasperoosthoek/react-toolbox 0.8.0 → 0.9.0
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/change-log.md +330 -309
- package/dist/components/buttons/ConfirmButton.d.ts +2 -2
- package/dist/components/buttons/DeleteConfirmButton.d.ts +2 -2
- package/dist/components/buttons/IconButtons.d.ts +40 -41
- package/dist/components/errors/Errors.d.ts +1 -2
- package/dist/components/forms/FormField.d.ts +22 -0
- package/dist/components/forms/FormFields.d.ts +1 -56
- package/dist/components/forms/FormModal.d.ts +7 -34
- package/dist/components/forms/FormModalProvider.d.ts +19 -26
- package/dist/components/forms/FormProvider.d.ts +66 -0
- package/dist/components/forms/fields/FormBadgesSelection.d.ts +26 -0
- package/dist/components/forms/fields/FormCheckbox.d.ts +7 -0
- package/dist/components/forms/fields/FormDropdown.d.ts +19 -0
- package/dist/components/forms/fields/FormInput.d.ts +17 -0
- package/dist/components/forms/fields/FormSelect.d.ts +12 -0
- package/dist/components/forms/fields/index.d.ts +5 -0
- package/dist/components/indicators/CheckIndicator.d.ts +1 -2
- package/dist/components/indicators/LoadingIndicator.d.ts +4 -4
- package/dist/components/login/LoginPage.d.ts +1 -1
- package/dist/components/tables/DataTable.d.ts +2 -2
- package/dist/components/tables/DragAndDropList.d.ts +2 -2
- package/dist/components/tables/SearchBox.d.ts +2 -2
- package/dist/index.d.ts +4 -1
- package/dist/index.js +2 -2
- package/dist/index.js.LICENSE.txt +0 -4
- package/dist/localization/LocalizationContext.d.ts +1 -1
- package/dist/utils/hooks.d.ts +1 -1
- package/dist/utils/timeAndDate.d.ts +5 -2
- package/dist/utils/utils.d.ts +3 -3
- package/package.json +10 -11
- package/src/__tests__/buttons.test.tsx +545 -0
- package/src/__tests__/errors.test.tsx +339 -0
- package/src/__tests__/forms.test.tsx +3021 -0
- package/src/__tests__/hooks.test.tsx +413 -0
- package/src/__tests__/indicators.test.tsx +284 -0
- package/src/__tests__/localization.test.tsx +462 -0
- package/src/__tests__/login.test.tsx +417 -0
- package/src/__tests__/setupTests.ts +328 -0
- package/src/__tests__/tables.test.tsx +609 -0
- package/src/__tests__/timeAndDate.test.tsx +308 -0
- package/src/__tests__/utils.test.tsx +422 -0
- package/src/components/forms/FormField.tsx +92 -0
- package/src/components/forms/FormFields.tsx +3 -423
- package/src/components/forms/FormModal.tsx +168 -243
- package/src/components/forms/FormModalProvider.tsx +141 -95
- package/src/components/forms/FormProvider.tsx +218 -0
- package/src/components/forms/fields/FormBadgesSelection.tsx +108 -0
- package/src/components/forms/fields/FormCheckbox.tsx +76 -0
- package/src/components/forms/fields/FormDropdown.tsx +123 -0
- package/src/components/forms/fields/FormInput.tsx +114 -0
- package/src/components/forms/fields/FormSelect.tsx +47 -0
- package/src/components/forms/fields/index.ts +6 -0
- package/src/index.ts +32 -28
- package/src/localization/LocalizationContext.tsx +156 -131
- package/src/localization/localization.ts +131 -131
- package/src/utils/hooks.ts +108 -94
- package/src/utils/timeAndDate.ts +33 -4
- package/src/utils/utils.ts +74 -66
- package/dist/components/forms/CreateEditModal.d.ts +0 -41
- package/dist/components/forms/CreateEditModalProvider.d.ts +0 -41
- package/dist/components/forms/FormFields.test.d.ts +0 -4
- package/dist/login/Login.d.ts +0 -70
- package/src/components/forms/FormFields.test.tsx +0 -107
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { ButtonProps as ReactBootstrapButtonProps } from 'react-bootstrap';
|
|
3
2
|
import { IconType } from 'react-icons';
|
|
4
3
|
export interface ButtonProps extends ReactBootstrapButtonProps {
|
|
@@ -8,47 +7,47 @@ export interface ButtonProps extends ReactBootstrapButtonProps {
|
|
|
8
7
|
export interface IconButtonProps extends ButtonProps {
|
|
9
8
|
icon: IconType;
|
|
10
9
|
}
|
|
11
|
-
export declare const IconButton: ({ onClick, loading, icon: Icon, iconSize, children, size, className, ...restProps }: IconButtonProps) =>
|
|
12
|
-
export declare const makeIconButton: (icon: IconType) => (props: ButtonProps) =>
|
|
13
|
-
export declare const CheckButton: (props: ButtonProps) =>
|
|
14
|
-
export declare const CopyButton: (props: ButtonProps) =>
|
|
15
|
-
export declare const PasteButton: (props: ButtonProps) =>
|
|
16
|
-
export declare const CloseButton: (props: ButtonProps) =>
|
|
17
|
-
export declare const CogButton: (props: ButtonProps) =>
|
|
18
|
-
export declare const CreateButton: (props: ButtonProps) =>
|
|
19
|
-
export declare const CreateFolderButton: (props: ButtonProps) =>
|
|
20
|
-
export declare const CreateSubFolderButton: (props: ButtonProps) =>
|
|
21
|
-
export declare const CreateFileButton: (props: ButtonProps) =>
|
|
22
|
-
export declare const DeleteButton: (props: ButtonProps) =>
|
|
23
|
-
export declare const DownButton: (props: ButtonProps) =>
|
|
24
|
-
export declare const DownloadButton: (props: ButtonProps) =>
|
|
25
|
-
export declare const EditButton: (props: ButtonProps) =>
|
|
26
|
-
export declare const FlagButton: (props: ButtonProps) =>
|
|
27
|
-
export declare const HideButton: (props: ButtonProps) =>
|
|
28
|
-
export declare const LinkButton: (props: ButtonProps) =>
|
|
29
|
-
export declare const ListButton: (props: ButtonProps) =>
|
|
30
|
-
export declare const MenuButton: (props: ButtonProps) =>
|
|
31
|
-
export declare const MoveButton: (props: ButtonProps) =>
|
|
32
|
-
export declare const NotesButton: (props: ButtonProps) =>
|
|
33
|
-
export declare const PencilButton: (props: ButtonProps) =>
|
|
34
|
-
export declare const PlayButton: (props: ButtonProps) =>
|
|
35
|
-
export declare const SaveButton: (props: ButtonProps) =>
|
|
36
|
-
export declare const SearchButton: (props: ButtonProps) =>
|
|
37
|
-
export declare const ShowButton: (props: ButtonProps) =>
|
|
38
|
-
export declare const SortButton: (props: ButtonProps) =>
|
|
39
|
-
export declare const SortUpButton: (props: ButtonProps) =>
|
|
40
|
-
export declare const SortDownButton: (props: ButtonProps) =>
|
|
41
|
-
export declare const StopButton: (props: ButtonProps) =>
|
|
42
|
-
export declare const SyncButton: (props: ButtonProps) =>
|
|
43
|
-
export declare const UnCheckButton: (props: ButtonProps) =>
|
|
44
|
-
export declare const UnlockButton: (props: ButtonProps) =>
|
|
45
|
-
export declare const UpButton: (props: ButtonProps) =>
|
|
46
|
-
export declare const UploadButton: (props: ButtonProps) =>
|
|
47
|
-
export declare const QuestionnaireButton: (props: ButtonProps) =>
|
|
48
|
-
export declare const DropdownButton: (props: ButtonProps) =>
|
|
49
|
-
export declare const ResetButton: (props: ButtonProps) =>
|
|
10
|
+
export declare const IconButton: ({ onClick, loading, icon: Icon, iconSize, children, size, className, ...restProps }: IconButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare const makeIconButton: (icon: IconType) => (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const CheckButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const CopyButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare const PasteButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare const CloseButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare const CogButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare const CreateButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare const CreateFolderButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare const CreateSubFolderButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare const CreateFileButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare const DeleteButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare const DownButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare const DownloadButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare const EditButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare const FlagButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare const HideButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export declare const LinkButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare const ListButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export declare const MenuButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export declare const MoveButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export declare const NotesButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
export declare const PencilButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export declare const PlayButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export declare const SaveButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
export declare const SearchButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
export declare const ShowButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
export declare const SortButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
export declare const SortUpButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export declare const SortDownButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
export declare const StopButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export declare const SyncButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
export declare const UnCheckButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
export declare const UnlockButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
export declare const UpButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
export declare const UploadButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
export declare const QuestionnaireButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
export declare const DropdownButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
export declare const ResetButton: (props: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
50
49
|
export interface UploadTextButtonProps extends ButtonProps {
|
|
51
50
|
accept?: string;
|
|
52
51
|
onLoadFile: (result: string | ArrayBuffer) => void;
|
|
53
52
|
}
|
|
54
|
-
export declare const UploadTextButton: ({ accept, onLoadFile, ...restProps }: UploadTextButtonProps) =>
|
|
53
|
+
export declare const UploadTextButton: ({ accept, onLoadFile, ...restProps }: UploadTextButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
export type ErrorPageProps = {
|
|
3
2
|
children: any;
|
|
4
3
|
};
|
|
5
|
-
export declare const ErrorPage: ({ children }: ErrorPageProps) =>
|
|
4
|
+
export declare const ErrorPage: ({ children }: ErrorPageProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormValue } from './FormFields';
|
|
3
|
+
import { FormInputProps } from './fields/FormInput';
|
|
4
|
+
export interface FormFieldProps extends FormInputProps {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const FormField: ({ children, ...props }: FormFieldProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
export declare const useFormField: (componentProps: {
|
|
9
|
+
name: string;
|
|
10
|
+
label?: any;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}) => {
|
|
14
|
+
value: FormValue;
|
|
15
|
+
onChange: (value: FormValue) => void;
|
|
16
|
+
isInvalid: boolean;
|
|
17
|
+
error: any;
|
|
18
|
+
label: any;
|
|
19
|
+
required: boolean | undefined;
|
|
20
|
+
mergedProps: any;
|
|
21
|
+
submit: () => void;
|
|
22
|
+
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { BadgeProps, FormControlProps, FormCheckProps } from 'react-bootstrap';
|
|
3
|
-
import { Variant } from 'react-bootstrap/types';
|
|
4
|
-
import { Moment } from 'moment';
|
|
1
|
+
import { ReactElement } from 'react';
|
|
5
2
|
export type FormValue = boolean | string | string[] | number | number[];
|
|
6
3
|
export type FormOnChange = (((value: FormValue, formData?: any) => any));
|
|
7
4
|
export type FormComponentProps = {
|
|
@@ -24,31 +21,6 @@ export type FormType = {
|
|
|
24
21
|
keyName: string;
|
|
25
22
|
pristine: boolean;
|
|
26
23
|
};
|
|
27
|
-
export interface FormInputProps extends Omit<FormControlProps, 'onChange'>, FormType {
|
|
28
|
-
onChange: (value: FormValue) => void;
|
|
29
|
-
controlId?: string;
|
|
30
|
-
label?: ReactElement;
|
|
31
|
-
onEnter?: () => void;
|
|
32
|
-
rows?: number;
|
|
33
|
-
}
|
|
34
|
-
export declare const FormInput: ({ label, value, onEnter, placeholder, onChange, controlId, state, setState, initialState, initialValue, keyName, pristine, id, ...formProps }: FormInputProps) => React.JSX.Element;
|
|
35
|
-
export declare const FormTextArea: ({ as, rows, ...restProps }: FormInputProps) => React.JSX.Element;
|
|
36
|
-
export type FormTextAreaProps = FormInputProps;
|
|
37
|
-
export declare const FormDate: (props: FormInputProps) => React.JSX.Element;
|
|
38
|
-
export interface FormDateTimeProps extends Omit<FormInputProps, 'onChange' | 'value'> {
|
|
39
|
-
value: string | Moment;
|
|
40
|
-
onChange: (value: string) => void;
|
|
41
|
-
}
|
|
42
|
-
export declare const FormDateTime: ({ value, onChange, ...restProps }: FormDateTimeProps) => React.JSX.Element;
|
|
43
|
-
export interface FormCheckboxProps extends Omit<FormCheckProps, 'onChange'>, FormType {
|
|
44
|
-
onChange: (value: boolean) => void;
|
|
45
|
-
controlId?: string;
|
|
46
|
-
label?: ReactElement;
|
|
47
|
-
onEnter?: () => void;
|
|
48
|
-
rows?: number;
|
|
49
|
-
}
|
|
50
|
-
export declare const FormCheckbox: ({ value, onChange, state, label, keyName, controlId, initialState, initialValue, setState, pristine, id, ...restProps }: FormCheckboxProps) => React.JSX.Element;
|
|
51
|
-
export declare const FormSwitch: ({ className, ...restProps }: FormCheckboxProps) => React.JSX.Element;
|
|
52
24
|
export type DisabledProps = {
|
|
53
25
|
list: any[];
|
|
54
26
|
value: string | number;
|
|
@@ -56,30 +28,3 @@ export type DisabledProps = {
|
|
|
56
28
|
initialState: any;
|
|
57
29
|
initialValue: any;
|
|
58
30
|
};
|
|
59
|
-
export interface FormSelectProps extends Omit<FormInputProps, 'disabled' | 'onChange' | 'list'> {
|
|
60
|
-
onChange: (value: number | string | number[] | string[] | null) => void;
|
|
61
|
-
list: any[];
|
|
62
|
-
multiple?: boolean;
|
|
63
|
-
integer?: boolean;
|
|
64
|
-
formatTitle?: (item: any) => ReactElement;
|
|
65
|
-
idKey?: string;
|
|
66
|
-
disabled?: boolean | ((props: DisabledProps) => boolean);
|
|
67
|
-
}
|
|
68
|
-
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;
|
|
69
|
-
export interface BadgeSelectionProps extends BadgeProps {
|
|
70
|
-
selected: boolean;
|
|
71
|
-
cursor: string;
|
|
72
|
-
disabled?: boolean;
|
|
73
|
-
}
|
|
74
|
-
export declare const BadgeSelection: ({ selected, disabled, cursor, onClick, style, bg, ...restProps }: BadgeSelectionProps) => React.JSX.Element;
|
|
75
|
-
export type FormBadgesSelectionProps = FormSelectProps;
|
|
76
|
-
export declare const FormBadgesSelection: ({ list, idKey, value, onChange, multiple, label, integer, controlId, isInvalid, state, setState, disabled, initialState, initialValue, keyName, pristine, ...restProps }: FormBadgesSelectionProps) => React.JSX.Element;
|
|
77
|
-
export interface FormDropdownProps<T> extends Omit<FormInputProps, 'disabled' | 'onChange' | 'list'> {
|
|
78
|
-
onChange: (value: number | string | number[] | string[] | null) => void;
|
|
79
|
-
list: T[];
|
|
80
|
-
idKey?: keyof T;
|
|
81
|
-
nameKey?: keyof T;
|
|
82
|
-
disabled?: boolean | ((props: DisabledProps) => boolean);
|
|
83
|
-
variant?: Variant;
|
|
84
|
-
}
|
|
85
|
-
export declare const FormDropdown: <T>({ list: listBase, idKey, nameKey, value, onChange, label, controlId, isInvalid, state, setState, disabled, initialState, initialValue, variant, pristine, keyName, onEnter, ...restProps }: FormDropdownProps<T>) => React.JSX.Element;
|
|
@@ -1,42 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { FormComponentProps, FormSelectProps, FormOnChange, FormValue } from './FormFields';
|
|
3
|
-
export type FormFieldComponent = (props: FormComponentProps | FormSelectProps) => ReactElement;
|
|
4
|
-
export type FormField = {
|
|
5
|
-
initialValue?: any;
|
|
6
|
-
type?: 'string' | 'number';
|
|
7
|
-
required?: boolean;
|
|
8
|
-
formProps?: any;
|
|
9
|
-
component?: FormFieldComponent;
|
|
10
|
-
onChange?: FormOnChange;
|
|
11
|
-
label?: ReactElement | string;
|
|
12
|
-
};
|
|
13
|
-
export type IncludeData<T> = {
|
|
14
|
-
[key in Exclude<string, keyof T>]: any;
|
|
15
|
-
};
|
|
16
|
-
export type InitialState<T> = Partial<{
|
|
17
|
-
[key in keyof T]: FormValue;
|
|
18
|
-
}>;
|
|
19
|
-
export type FormFields = {
|
|
20
|
-
[key: string]: FormField;
|
|
21
|
-
};
|
|
22
|
-
export type OnSave<T, K> = (state: ({
|
|
23
|
-
[key in keyof T]: FormValue;
|
|
24
|
-
}), callback: () => void) => void;
|
|
25
|
-
export type Validate = (state: any) => any;
|
|
1
|
+
import { ReactElement } from 'react';
|
|
26
2
|
export type ModalTitle = ReactElement | string;
|
|
27
3
|
export type Width = 25 | 50 | 75 | 100;
|
|
28
|
-
export type FormModalProps
|
|
29
|
-
initialState: InitialState<T> | K;
|
|
30
|
-
includeData?: K;
|
|
31
|
-
formFields: T;
|
|
4
|
+
export type FormModalProps = {
|
|
32
5
|
show?: boolean;
|
|
33
|
-
onSave: OnSave<T, K>;
|
|
34
6
|
onHide: () => void;
|
|
35
|
-
validate?: Validate;
|
|
36
7
|
modalTitle?: ModalTitle;
|
|
37
|
-
loading?: boolean;
|
|
38
8
|
dialogClassName?: string;
|
|
39
9
|
width?: Width;
|
|
10
|
+
submitText?: string;
|
|
11
|
+
cancelText?: string;
|
|
40
12
|
};
|
|
41
|
-
export declare const FormModal:
|
|
42
|
-
export declare const
|
|
13
|
+
export declare const FormModal: ({ show, onHide, modalTitle, dialogClassName, width, submitText, cancelText, }: FormModalProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
14
|
+
export declare const FormFieldsRenderer: () => import("react/jsx-runtime").JSX.Element | null;
|
|
15
|
+
export declare const DisabledFormField: ({ value }: any) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,35 +1,28 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import { FormFields,
|
|
3
|
-
import {
|
|
2
|
+
import { FormFields, InitialState, OnSubmit, Validate } from './FormProvider';
|
|
3
|
+
import { ModalTitle, Width } from './FormModal';
|
|
4
4
|
import { ButtonProps } from '../buttons/IconButtons';
|
|
5
5
|
export type ShowCreateModal = (show?: boolean) => void;
|
|
6
|
-
export type ShowEditModal<T
|
|
7
|
-
|
|
8
|
-
} & K) => void;
|
|
9
|
-
export type FormCreateModalButton = ButtonProps;
|
|
10
|
-
export declare const FormCreateModalButton: ({ onClick, ...props }: ButtonProps) => React.JSX.Element;
|
|
11
|
-
export interface FormEditModalButtonProps<T, K> extends ButtonProps {
|
|
12
|
-
state: {
|
|
13
|
-
[key in keyof T]: FormValue;
|
|
14
|
-
} & K;
|
|
15
|
-
}
|
|
16
|
-
export declare const FormEditModalButton: ({ state, onClick, ...props }: FormEditModalButtonProps<T, K>) => React.JSX.Element;
|
|
17
|
-
type FormModalContextType<T, K> = {
|
|
6
|
+
export type ShowEditModal<T extends FormFields> = (state: InitialState<T> | null) => void;
|
|
7
|
+
type FormModalContextType<T extends FormFields> = {
|
|
18
8
|
showCreateModal: ShowCreateModal;
|
|
19
|
-
showEditModal: ShowEditModal<T
|
|
9
|
+
showEditModal: ShowEditModal<T>;
|
|
20
10
|
hasProvider: boolean;
|
|
21
11
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export
|
|
25
|
-
export declare const
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
export declare const FormModalContext: React.Context<FormModalContextType<any>>;
|
|
13
|
+
export declare const useFormModal: <T extends FormFields>() => FormModalContextType<T>;
|
|
14
|
+
export type FormCreateModalButton = ButtonProps;
|
|
15
|
+
export declare const FormCreateModalButton: ({ onClick, ...props }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export interface FormEditModalButtonProps<T extends FormFields> extends ButtonProps {
|
|
17
|
+
state: InitialState<T>;
|
|
18
|
+
}
|
|
19
|
+
export declare const FormEditModalButton: <T extends FormFields>({ state, onClick, ...props }: FormEditModalButtonProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export type FormModalProviderProps<T extends FormFields> = {
|
|
29
21
|
formFields: T;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
initialState?: InitialState<T>;
|
|
23
|
+
onSave?: OnSubmit<T>;
|
|
24
|
+
onCreate?: OnSubmit<T>;
|
|
25
|
+
onUpdate?: OnSubmit<T>;
|
|
33
26
|
validate?: Validate;
|
|
34
27
|
createModalTitle?: ModalTitle;
|
|
35
28
|
editModalTitle?: ModalTitle;
|
|
@@ -38,5 +31,5 @@ export type FormModalProviderProps<T extends FormFields, K extends IncludeData<T
|
|
|
38
31
|
width?: Width;
|
|
39
32
|
children: ReactNode;
|
|
40
33
|
};
|
|
41
|
-
export declare const FormModalProvider:
|
|
34
|
+
export declare const FormModalProvider: <T extends FormFields>({ createModalTitle, editModalTitle, formFields, initialState, validate, loading, onCreate, onUpdate, onSave, dialogClassName, width, children, }: FormModalProviderProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
42
35
|
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { FormValue } from './FormFields';
|
|
3
|
+
export type FormFieldConfig = {
|
|
4
|
+
initialValue?: any;
|
|
5
|
+
type?: 'string' | 'number' | 'select' | 'checkbox' | 'boolean' | 'textarea' | 'dropdown';
|
|
6
|
+
required?: boolean;
|
|
7
|
+
formProps?: any;
|
|
8
|
+
component?: any;
|
|
9
|
+
onChange?: (value: FormValue, formData?: any) => any;
|
|
10
|
+
label?: React.ReactElement | string;
|
|
11
|
+
options?: Array<{
|
|
12
|
+
value: string | number;
|
|
13
|
+
label: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
list?: any[];
|
|
17
|
+
idKey?: string;
|
|
18
|
+
nameKey?: string;
|
|
19
|
+
};
|
|
20
|
+
export type FormFields = {
|
|
21
|
+
[key: string]: FormFieldConfig;
|
|
22
|
+
};
|
|
23
|
+
export type InitialState<T> = Partial<{
|
|
24
|
+
[key in keyof T]: FormValue;
|
|
25
|
+
}>;
|
|
26
|
+
export type OnSubmit<T> = (state: {
|
|
27
|
+
[key in keyof T]: FormValue;
|
|
28
|
+
}, callback?: () => void) => void;
|
|
29
|
+
export type Validate = (state: any) => any;
|
|
30
|
+
type FormContextType<T extends FormFields> = {
|
|
31
|
+
formFields: T;
|
|
32
|
+
formData: {
|
|
33
|
+
[key in keyof T]: FormValue;
|
|
34
|
+
} | null;
|
|
35
|
+
initialFormData: {
|
|
36
|
+
[key in keyof T]: FormValue;
|
|
37
|
+
} | null;
|
|
38
|
+
pristine: boolean;
|
|
39
|
+
validated: boolean;
|
|
40
|
+
validationErrors: {
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
};
|
|
43
|
+
loading: boolean;
|
|
44
|
+
getValue: (key: string) => FormValue;
|
|
45
|
+
setValue: (key: string, value: FormValue) => void;
|
|
46
|
+
setFormData: (data: Partial<{
|
|
47
|
+
[key in keyof T]: FormValue;
|
|
48
|
+
}>) => void;
|
|
49
|
+
resetForm: () => void;
|
|
50
|
+
submit: () => void;
|
|
51
|
+
setPristine: (pristine: boolean) => void;
|
|
52
|
+
setLoading: (loading: boolean) => void;
|
|
53
|
+
hasProvider: boolean;
|
|
54
|
+
};
|
|
55
|
+
export declare const useForm: <T extends FormFields>() => FormContextType<T>;
|
|
56
|
+
export type FormProviderProps<T extends FormFields> = {
|
|
57
|
+
formFields: T;
|
|
58
|
+
initialState?: InitialState<T>;
|
|
59
|
+
onSubmit: OnSubmit<T>;
|
|
60
|
+
validate?: Validate;
|
|
61
|
+
loading?: boolean;
|
|
62
|
+
children: ReactNode;
|
|
63
|
+
resetTrigger?: any;
|
|
64
|
+
};
|
|
65
|
+
export declare const FormProvider: <T extends FormFields>({ formFields, initialState, onSubmit, validate, loading, children, resetTrigger, }: FormProviderProps<T>) => import("react/jsx-runtime").JSX.Element | null;
|
|
66
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BadgeProps } from 'react-bootstrap';
|
|
3
|
+
export interface BadgeSelectionProps extends BadgeProps {
|
|
4
|
+
selected: boolean;
|
|
5
|
+
cursor: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const BadgeSelection: ({ selected, disabled, cursor, onClick, style, bg, ...restProps }: BadgeSelectionProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
type DisabledProps = {
|
|
10
|
+
list: any[];
|
|
11
|
+
value: string | number;
|
|
12
|
+
state: any;
|
|
13
|
+
initialState: any;
|
|
14
|
+
initialValue: any;
|
|
15
|
+
};
|
|
16
|
+
export interface FormBadgesSelectionProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'name' | 'value' | 'onChange' | 'disabled' | 'list'> {
|
|
17
|
+
name: string;
|
|
18
|
+
label?: React.ReactElement | string;
|
|
19
|
+
list: any[];
|
|
20
|
+
idKey?: string;
|
|
21
|
+
multiple?: boolean;
|
|
22
|
+
integer?: boolean;
|
|
23
|
+
disabled?: boolean | ((props: DisabledProps) => boolean);
|
|
24
|
+
}
|
|
25
|
+
export declare const FormBadgesSelection: (props: FormBadgesSelectionProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface FormCheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'name' | 'value' | 'onChange' | 'type'> {
|
|
3
|
+
name: string;
|
|
4
|
+
label?: React.ReactElement | string;
|
|
5
|
+
}
|
|
6
|
+
export declare const FormCheckbox: (props: FormCheckboxProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare const FormSwitch: (props: FormCheckboxProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type DisabledProps = {
|
|
3
|
+
list: any[];
|
|
4
|
+
value: string | number;
|
|
5
|
+
state: any;
|
|
6
|
+
initialState: any;
|
|
7
|
+
initialValue: any;
|
|
8
|
+
};
|
|
9
|
+
export interface FormDropdownProps<T> extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'name' | 'value' | 'onChange' | 'disabled' | 'list'> {
|
|
10
|
+
name: string;
|
|
11
|
+
label?: React.ReactElement | string;
|
|
12
|
+
list?: T[];
|
|
13
|
+
options?: T[];
|
|
14
|
+
idKey?: keyof T;
|
|
15
|
+
nameKey?: keyof T;
|
|
16
|
+
disabled?: boolean | ((props: DisabledProps) => boolean);
|
|
17
|
+
}
|
|
18
|
+
export declare const FormDropdown: <T>(props: FormDropdownProps<T>) => import("react/jsx-runtime").JSX.Element | null;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface FormInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'name' | 'onChange'> {
|
|
3
|
+
name: string;
|
|
4
|
+
label?: React.ReactElement | string;
|
|
5
|
+
as?: string;
|
|
6
|
+
rows?: number;
|
|
7
|
+
onChange: (value: string) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const FormInput: (props: FormInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const FormTextarea: ({ rows, ...props }: FormInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare const FormDate: (props: FormInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export interface FormDateTimeProps extends Omit<FormInputProps, 'value' | 'onChange'> {
|
|
13
|
+
value?: string | Date;
|
|
14
|
+
onChange?: (value: string) => void;
|
|
15
|
+
timezone?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const FormDateTime: ({ value, onChange, timezone, ...props }: FormDateTimeProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface FormSelectProps extends Omit<React.SelectHTMLAttributes<HTMLSelectElement>, 'name' | 'value' | 'onChange'> {
|
|
3
|
+
name: string;
|
|
4
|
+
label?: React.ReactElement | string;
|
|
5
|
+
options: Array<{
|
|
6
|
+
value: string | number;
|
|
7
|
+
label: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const FormSelect: (props: FormSelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
export type CheckIndicatorProps = {
|
|
3
2
|
checked: boolean;
|
|
4
3
|
className?: string;
|
|
5
4
|
};
|
|
6
|
-
export declare const CheckIndicator: ({ checked, className }: CheckIndicatorProps) =>
|
|
5
|
+
export declare const CheckIndicator: ({ checked, className }: CheckIndicatorProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export declare const LoadingIndicator: ({ style }: {
|
|
3
|
-
style?: {};
|
|
4
|
-
}) =>
|
|
3
|
+
style?: {} | undefined;
|
|
4
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export type SmallSpinnerProps = {
|
|
6
6
|
style?: any;
|
|
7
7
|
component?: ((props: any) => React.ReactElement | null) | string;
|
|
8
8
|
className?: string;
|
|
9
9
|
};
|
|
10
|
-
export declare const SmallSpinner: ({ style, component: Component, className }: SmallSpinnerProps) =>
|
|
11
|
-
export declare const BigSpinner: () =>
|
|
10
|
+
export declare const SmallSpinner: ({ style, component: Component, className }: SmallSpinnerProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare const BigSpinner: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -9,4 +9,4 @@ export type LoginPageProps = {
|
|
|
9
9
|
label?: string | React.ReactElement;
|
|
10
10
|
onResetPassword: string | (() => void);
|
|
11
11
|
};
|
|
12
|
-
export declare const LoginPage: ({ onSubmit, isAuthenticated, label, onResetPassword, callback, }: LoginPageProps) =>
|
|
12
|
+
export declare const LoginPage: ({ onSubmit, isAuthenticated, label, onResetPassword, callback, }: LoginPageProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
2
|
export type OrderByColumn<R> = string | ((row: R) => string | number);
|
|
3
3
|
export type OptionsDropdown = {
|
|
4
4
|
onSelect: (key: string | null) => void;
|
|
@@ -52,4 +52,4 @@ export type DataTableProps<D extends any[]> = {
|
|
|
52
52
|
style?: any;
|
|
53
53
|
showSum?: boolean;
|
|
54
54
|
};
|
|
55
|
-
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>) =>
|
|
55
|
+
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>) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
2
|
export type DragAndDropListOnDrop = (movedIndex: number, index: number, reset: () => void) => void;
|
|
3
3
|
export type DragAndDropListComponentProps = {
|
|
4
4
|
dropped?: boolean;
|
|
@@ -10,4 +10,4 @@ export type DragAndDropListProps<A extends any[]> = {
|
|
|
10
10
|
propsArray: A;
|
|
11
11
|
component: DragAndDropListComponent;
|
|
12
12
|
};
|
|
13
|
-
export declare const DragAndDropList: <A extends any[]>({ onDrop, propsArray, component }: DragAndDropListProps<A>) =>
|
|
13
|
+
export declare const DragAndDropList: <A extends any[]>({ onDrop, propsArray, component }: DragAndDropListProps<A>) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
export type SearchBoxProps = {
|
|
3
3
|
className?: string;
|
|
4
4
|
value: string;
|
|
@@ -8,4 +8,4 @@ export type SearchBoxProps = {
|
|
|
8
8
|
label?: ReactNode | string | number;
|
|
9
9
|
placeholder?: string | false;
|
|
10
10
|
};
|
|
11
|
-
export declare const SearchBox: ({ className, value, onChange, onClear, onSearch, label, placeholder, }: SearchBoxProps) =>
|
|
11
|
+
export declare const SearchBox: ({ className, value, onChange, onClear, onSearch, label, placeholder, }: SearchBoxProps) => import("react/jsx-runtime").JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,12 @@ 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/FormProvider';
|
|
6
7
|
export * from './components/forms/FormModal';
|
|
7
8
|
export * from './components/forms/FormModalProvider';
|
|
8
9
|
export * from './components/forms/FormFields';
|
|
10
|
+
export * from './components/forms/FormField';
|
|
11
|
+
export * from './components/forms/fields';
|
|
9
12
|
export * from './components/indicators/LoadingIndicator';
|
|
10
13
|
export * from './components/indicators/CheckIndicator';
|
|
11
14
|
export * from './components/tables/DataTable';
|
|
@@ -13,9 +16,9 @@ export * from './components/tables/DragAndDropList';
|
|
|
13
16
|
export * from './components/tables/SearchBox';
|
|
14
17
|
export * from './components/errors/Errors';
|
|
15
18
|
export * from './components/errors/ErrorBoundary';
|
|
19
|
+
export * from './components/login/LoginPage';
|
|
16
20
|
export * from './utils/hooks';
|
|
17
21
|
export * from './utils/timeAndDate';
|
|
18
22
|
export * from './utils/utils';
|
|
19
|
-
export * from './components/login/LoginPage';
|
|
20
23
|
export * from './localization/localization';
|
|
21
24
|
export * from './localization/LocalizationContext';
|