@dakataa/crud-react 1.0.10 → 2.0.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/CHANGELOG.md +83 -0
- package/README.md +439 -169
- package/dist/Crud.d.ts +15 -0
- package/dist/component/BaseButtonContent.d.ts +10 -0
- package/dist/component/Button.d.ts +9 -0
- package/dist/component/Dropdown.d.ts +17 -0
- package/dist/component/Empty.d.ts +5 -0
- package/dist/component/Link.d.ts +6 -0
- package/dist/component/LottieAnimation.d.ts +8 -0
- package/dist/component/Modal.d.ts +22 -0
- package/dist/component/Money.d.ts +7 -0
- package/dist/component/Preloader.d.ts +20 -0
- package/dist/component/Translation.d.ts +14 -0
- package/dist/component/crud/ActionLink.d.ts +10 -0
- package/dist/component/crud/CrudLoader.d.ts +29 -0
- package/dist/component/crud/DynamicView.d.ts +19 -0
- package/dist/component/crud/FiltersView.d.ts +6 -0
- package/dist/component/crud/GridView.d.ts +27 -0
- package/dist/component/crud/IsListItemActionGranted.d.ts +10 -0
- package/dist/component/crud/ItemAction.d.ts +9 -0
- package/dist/component/crud/ItemActions.d.ts +7 -0
- package/dist/component/crud/ItemLabel.d.ts +6 -0
- package/dist/component/crud/ItemValue.d.ts +6 -0
- package/dist/component/crud/List.d.ts +19 -0
- package/dist/component/crud/ListItem.d.ts +4 -0
- package/dist/component/crud/ListView.d.ts +8 -0
- package/dist/component/crud/Modify.d.ts +9 -0
- package/dist/component/crud/Navigation.d.ts +19 -0
- package/dist/component/crud/Paginator.d.ts +2 -0
- package/dist/component/crud/ViewLoader.d.ts +14 -0
- package/dist/component/crud/batch/BatchActionSelector.d.ts +2 -0
- package/dist/component/crud/batch/BatchActionsContext.d.ts +17 -0
- package/dist/component/crud/batch/BatchItemSelector.d.ts +4 -0
- package/dist/component/crud/form/Form.d.ts +31 -0
- package/dist/component/crud/form/FormError.d.ts +6 -0
- package/dist/component/crud/form/FormField.d.ts +11 -0
- package/dist/component/crud/form/FormGroup.d.ts +76 -0
- package/dist/component/crud/form/FormGroupViewLoader.d.ts +2 -0
- package/dist/component/crud/form/FormLabel.d.ts +4 -0
- package/dist/component/crud/form/FormRequestError.d.ts +14 -0
- package/dist/component/crud/form/FormRest.d.ts +2 -0
- package/dist/component/crud/form/FormRestError.d.ts +4 -0
- package/dist/component/error/ErrorBoundary.d.ts +13 -0
- package/dist/component/error/Exception.d.ts +9 -0
- package/dist/component/error/HttpException.d.ts +16 -0
- package/dist/component/form/Choice.d.ts +24 -0
- package/dist/component/form/Collection.d.ts +27 -0
- package/dist/component/form/Form.d.ts +62 -0
- package/dist/component/form/FormAlert.d.ts +3 -0
- package/dist/component/form/FormFieldError.d.ts +6 -0
- package/dist/component/form/FormGroup.d.ts +8 -0
- package/dist/component/form/FormHelp.d.ts +5 -0
- package/dist/component/form/FormLabel.d.ts +7 -0
- package/dist/component/form/FormSetting.d.ts +11 -0
- package/dist/component/form/FormStore.d.ts +93 -0
- package/dist/component/form/Input.d.ts +13 -0
- package/dist/component/form/Textarea.d.ts +15 -0
- package/dist/component/form/constraint/Contraint.d.ts +6 -0
- package/dist/component/form/constraint/NotBlank.d.ts +11 -0
- package/dist/component/form/formChoices.d.ts +8 -0
- package/dist/component/form/formSession.d.ts +3 -0
- package/dist/component/form/formView.d.ts +35 -0
- package/dist/component/router/Route.d.ts +11 -0
- package/dist/component/templating/Template.d.ts +17 -0
- package/dist/component/templating/TemplateBlock.d.ts +8 -0
- package/dist/component/templating/TemplateExtend.d.ts +9 -0
- package/dist/component/templating/TemplateParentBlock.d.ts +5 -0
- package/dist/context/ActionContext.d.ts +46 -0
- package/dist/context/AlertContext.d.ts +52 -0
- package/dist/context/ConfigContext.d.ts +34 -0
- package/dist/context/CrudProvider.d.ts +7 -0
- package/dist/context/GetData.d.ts +43 -0
- package/dist/context/ListContext.d.ts +69 -0
- package/dist/context/ListItemContext.d.ts +8 -0
- package/dist/context/LoaderContext.d.ts +5 -0
- package/dist/context/ModalContext.d.ts +18 -0
- package/dist/context/NamespaceContext.d.ts +5 -0
- package/dist/crud-react.css +2 -1
- package/dist/crud-react.js +4014 -2955
- package/dist/denied-Emsz18Y8.js +688 -0
- package/dist/helper/ObjectUtils.d.ts +3 -0
- package/dist/helper/PathUtils.d.ts +12 -0
- package/dist/helper/StringUtils.d.ts +3 -0
- package/dist/info-C897Uj_w.js +626 -0
- package/dist/layout/default/Base.d.ts +5 -0
- package/dist/layout/default/Error.d.ts +11 -0
- package/dist/layout/default/Main.d.ts +4 -0
- package/dist/main.d.ts +91 -79
- package/dist/setupTests.d.ts +0 -0
- package/dist/success-YbPKEx5j.js +559 -0
- package/dist/type/ActionRequestType.d.ts +17 -0
- package/dist/type/ActionType.d.ts +15 -0
- package/dist/type/ColumnType.d.ts +24 -0
- package/dist/type/ExceptionType.d.ts +6 -0
- package/dist/type/FormType.d.ts +6 -0
- package/dist/type/FormViewType.d.ts +96 -0
- package/dist/type/ListMetaType.d.ts +8 -0
- package/dist/type/ListType.d.ts +32 -0
- package/dist/type/ModifyType.d.ts +15 -0
- package/dist/type/RedirectType.d.ts +7 -0
- package/dist/type/RouteType.d.ts +7 -0
- package/dist/type/ViewType.d.ts +15 -0
- package/dist/warning-DJITKJj5.js +630 -0
- package/package.json +86 -81
- package/dist/denied-CgoMpaA7.js +0 -27
- package/dist/info-D-NzIEYs.js +0 -144
- package/dist/success-Bu_BJcf1.js +0 -27
- package/dist/warning-B1nr7TsB.js +0 -27
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FormFieldProps } from './Input.tsx';
|
|
3
|
+
import { ChoiceGroupType, ChoiceType, FormViewType } from '../../type/FormViewType';
|
|
4
|
+
export type ChoiceProps = Omit<FormFieldProps, "ref"> & {
|
|
5
|
+
choiceValueTransform?: (choice: ChoiceType) => unknown;
|
|
6
|
+
choiceLabelTransform?: Function;
|
|
7
|
+
ref?: React.Ref<HTMLSelectElement>;
|
|
8
|
+
};
|
|
9
|
+
declare const SelectOption: ({ choice }: {
|
|
10
|
+
view: FormViewType;
|
|
11
|
+
choice: ChoiceType;
|
|
12
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
declare const SelectGroupOption: ({ view, group }: {
|
|
14
|
+
view: FormViewType;
|
|
15
|
+
group: ChoiceGroupType;
|
|
16
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
declare const ChoiceOption: ({ view, choice, constraints, onChange, choiceValueTransform, choiceLabelTransform }: ChoiceProps & {
|
|
18
|
+
choice: ChoiceType;
|
|
19
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
declare const ChoiceGroupOption: ({ view, group, ...props }: ChoiceProps & {
|
|
21
|
+
group: ChoiceGroupType;
|
|
22
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
declare const Choice: ({ view, constraints, className, onChange, choiceValueTransform, choiceLabelTransform, ref }: ChoiceProps) => React.JSX.Element;
|
|
24
|
+
export { Choice as default, ChoiceOption, ChoiceGroupOption, SelectOption, SelectGroupOption };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FormViewType } from '../../type/FormViewType';
|
|
3
|
+
export type FormFieldProps = {
|
|
4
|
+
view: FormViewType;
|
|
5
|
+
};
|
|
6
|
+
export type InputProps = {} & FormFieldProps;
|
|
7
|
+
export type CollectionContextType = {
|
|
8
|
+
addItem: () => void;
|
|
9
|
+
removeItem: (name: string) => void;
|
|
10
|
+
items: string[];
|
|
11
|
+
isPrototype: boolean;
|
|
12
|
+
};
|
|
13
|
+
declare const UseCollection: () => CollectionContextType;
|
|
14
|
+
declare const Collection: ({ view }: InputProps) => React.JSX.Element;
|
|
15
|
+
declare const CollectionList: () => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export type CollectionItemContextType = {
|
|
17
|
+
index: number;
|
|
18
|
+
removeItem: () => void;
|
|
19
|
+
};
|
|
20
|
+
declare const UseCollectionItem: () => CollectionItemContextType;
|
|
21
|
+
declare const CollectionItem: ({ view, name: itemName, index, isPrototype }: {
|
|
22
|
+
view: FormViewType;
|
|
23
|
+
name?: string;
|
|
24
|
+
index: number;
|
|
25
|
+
isPrototype: boolean;
|
|
26
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export { Collection as default, CollectionList, CollectionItem, UseCollection, UseCollectionItem };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ReactNode, Ref, RefObject, default as React } from 'react';
|
|
2
|
+
import { Constraint } from './constraint/Contraint';
|
|
3
|
+
import { FormViewErrorType, FormViewType } from '../../type/FormViewType.tsx';
|
|
4
|
+
import { FormSubmission, FormStore } from './FormStore.ts';
|
|
5
|
+
export type FormValue = string | string[] | null;
|
|
6
|
+
export type FormValueField = string | FormViewType | null | undefined;
|
|
7
|
+
export type FormErrors = Record<string, FormViewErrorType[]>;
|
|
8
|
+
export type FormConstraints = Record<string, Constraint[]>;
|
|
9
|
+
export type FormState = {
|
|
10
|
+
constraints: FormConstraints;
|
|
11
|
+
errors: FormErrors;
|
|
12
|
+
success: boolean;
|
|
13
|
+
submitting: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type FormRef = {
|
|
16
|
+
getFormData: () => FormData;
|
|
17
|
+
setFormData: (data: FormData) => void;
|
|
18
|
+
setValue: (name: string, value: FormValue) => void;
|
|
19
|
+
setValues: (data: Record<string, FormValue>) => void;
|
|
20
|
+
setErrors: (errors: FormErrors) => void;
|
|
21
|
+
success: () => void;
|
|
22
|
+
reset: () => void;
|
|
23
|
+
submit: () => void;
|
|
24
|
+
};
|
|
25
|
+
export type FormContextType = {
|
|
26
|
+
store: FormStore;
|
|
27
|
+
apiRef: RefObject<FormRef | null>;
|
|
28
|
+
elementRef: RefObject<HTMLFormElement | null>;
|
|
29
|
+
};
|
|
30
|
+
export type FormProps = Omit<React.FormHTMLAttributes<HTMLFormElement>, "children" | "method" | "onReset" | "onSubmit"> & {
|
|
31
|
+
children?: ReactNode;
|
|
32
|
+
onSubmit?: (data: FormData, submission: FormSubmission, runtime: FormContextType) => void;
|
|
33
|
+
onBeforeSubmit?: (data: FormData) => void;
|
|
34
|
+
onReset?: () => void;
|
|
35
|
+
onStateChange?: (state: FormState) => void;
|
|
36
|
+
method?: "GET" | "POST";
|
|
37
|
+
ref?: Ref<FormRef>;
|
|
38
|
+
};
|
|
39
|
+
/** Returns stable form access without subscribing to state changes. */
|
|
40
|
+
export declare function UseForm(): FormContextType;
|
|
41
|
+
/** Subscribes to errors, validation rules and submission status. */
|
|
42
|
+
export declare function useFormState(): FormState;
|
|
43
|
+
/** Observes a value without registering a control or subscribing to its errors. */
|
|
44
|
+
export declare function useFormValue(field?: FormValueField): FormValue | undefined;
|
|
45
|
+
/** Observes values in the supplied order; unchanged values retain the same snapshot. */
|
|
46
|
+
export declare function useFormValues(fields: readonly FormValueField[]): readonly (FormValue | undefined)[];
|
|
47
|
+
export declare function useFormField(view: FormViewType, constraints?: Constraint[], initialize?: (view: FormViewType) => FormValue): {
|
|
48
|
+
value: FormValue;
|
|
49
|
+
name: string;
|
|
50
|
+
change: (value: FormValue | ((current: FormValue) => FormValue)) => FormValue;
|
|
51
|
+
changeNative: (value: unknown) => void;
|
|
52
|
+
errors: FormErrors[string];
|
|
53
|
+
dirty: boolean;
|
|
54
|
+
};
|
|
55
|
+
export declare function useFormErrors(names: string[]): FormViewErrorType[];
|
|
56
|
+
export declare function useFormCollection(name: string, initialItems: string[]): {
|
|
57
|
+
items: string[];
|
|
58
|
+
add: (item: string) => void;
|
|
59
|
+
remove: (item: string) => void;
|
|
60
|
+
};
|
|
61
|
+
export declare const nameToId: (name: string, index?: string | number | null) => string;
|
|
62
|
+
export declare const Form: ({ id, children, onBeforeSubmit, onSubmit: onSubmitCallback, onReset: onResetCallback, onStateChange, ref, ...props }: FormProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
export type FormFieldErrorProps = Omit<HTMLAttributes<HTMLDivElement>, "children" | "dangerouslySetInnerHTML"> & {
|
|
3
|
+
name: string | string[];
|
|
4
|
+
};
|
|
5
|
+
declare const FormFieldError: ({ name, ...attributes }: FormFieldErrorProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
export default FormFieldError;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FormViewType } from '../../type/FormViewType.tsx';
|
|
2
|
+
export declare const FormGroup: ({ view, className, size, type }: {
|
|
3
|
+
view: FormViewType;
|
|
4
|
+
className?: string;
|
|
5
|
+
size?: "lg" | "sm";
|
|
6
|
+
type?: string;
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default FormGroup;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
export type FormSettingContextType = {
|
|
3
|
+
size?: 'lg' | 'sm';
|
|
4
|
+
extraClassName?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
};
|
|
9
|
+
declare const UseFormSettings: () => FormSettingContextType | undefined;
|
|
10
|
+
declare const FormSetting: ({ children, ...props }: FormSettingContextType & PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export { FormSetting, UseFormSettings };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Constraint } from './constraint/Contraint';
|
|
2
|
+
import { FormErrors, FormState, FormValue } from './Form.tsx';
|
|
3
|
+
import { FormDefaults } from './formView.ts';
|
|
4
|
+
import { FormViewType } from '../../type/FormViewType.tsx';
|
|
5
|
+
type Listener = () => void;
|
|
6
|
+
export type FormSubmission = {
|
|
7
|
+
revision: number;
|
|
8
|
+
values: Record<string, FormValue>;
|
|
9
|
+
collections: Record<string, string[]>;
|
|
10
|
+
fields: string[];
|
|
11
|
+
collectionNames: string[];
|
|
12
|
+
};
|
|
13
|
+
export type FormSyncMode = "refresh" | "invalid" | "saved";
|
|
14
|
+
export type FieldSnapshot = {
|
|
15
|
+
value: FormValue | undefined;
|
|
16
|
+
errors: FormErrors[string];
|
|
17
|
+
dirty: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type FieldKind = "scalar" | "selection" | "multiple";
|
|
20
|
+
/** One synchronous source of form state; DOM controls and React are projections of it. */
|
|
21
|
+
export declare class FormStore {
|
|
22
|
+
private nativeDirty;
|
|
23
|
+
private values;
|
|
24
|
+
private kinds;
|
|
25
|
+
private initializers;
|
|
26
|
+
private localDefaults;
|
|
27
|
+
private overriddenDefaults;
|
|
28
|
+
private defaults;
|
|
29
|
+
private collections;
|
|
30
|
+
private collectionDefaults;
|
|
31
|
+
private versions;
|
|
32
|
+
private collectionVersions;
|
|
33
|
+
private deletedPrefixes;
|
|
34
|
+
private registrations;
|
|
35
|
+
private snapshots;
|
|
36
|
+
private listeners;
|
|
37
|
+
private errorSnapshots;
|
|
38
|
+
private stateListeners;
|
|
39
|
+
private collectionListeners;
|
|
40
|
+
private serverErrors;
|
|
41
|
+
private clientErrors;
|
|
42
|
+
private revision;
|
|
43
|
+
private state;
|
|
44
|
+
private views;
|
|
45
|
+
private errorViews;
|
|
46
|
+
private renderListeners;
|
|
47
|
+
private renderSnapshot;
|
|
48
|
+
subscribeState: (listener: Listener) => () => void;
|
|
49
|
+
getState: () => FormState;
|
|
50
|
+
subscribeField: (name: string, listener: Listener) => () => void;
|
|
51
|
+
subscribeCollection: (name: string, listener: Listener) => () => void;
|
|
52
|
+
private subscribe;
|
|
53
|
+
private notifyField;
|
|
54
|
+
getField: (name: string) => FieldSnapshot;
|
|
55
|
+
getErrors(names: string[]): import('../../type/FormViewType.tsx').FormViewErrorType[];
|
|
56
|
+
getValue: (name: string) => FormValue | undefined;
|
|
57
|
+
getNames: () => string[];
|
|
58
|
+
getInitialValue: (view: FormViewType) => FormValue;
|
|
59
|
+
getKind: (name: string) => FieldKind | undefined;
|
|
60
|
+
isRegistered: (name: string) => boolean;
|
|
61
|
+
private initialize;
|
|
62
|
+
isActiveValue(name: string): boolean;
|
|
63
|
+
private isDeleted;
|
|
64
|
+
registerField(name: string, value: FormValue, kind: FieldKind, constraints: Constraint[], owner: symbol, override?: boolean, grouped?: boolean, initialize?: (view: FormViewType) => FormValue): () => void;
|
|
65
|
+
private refreshConstraints;
|
|
66
|
+
setValue: (name: string, value: FormValue) => void;
|
|
67
|
+
change: (name: string, value: FormValue) => void;
|
|
68
|
+
changeNative: (name: string, value: unknown) => void;
|
|
69
|
+
validate: (name: string, value?: unknown) => boolean;
|
|
70
|
+
validateAll: (isActive: (name: string) => boolean, readValue?: (name: string) => unknown) => boolean;
|
|
71
|
+
setErrors: (errors: FormErrors, submission?: FormSubmission, preserveDirty?: boolean) => void;
|
|
72
|
+
private refreshErrors;
|
|
73
|
+
private updateState;
|
|
74
|
+
setSuccess: (success: boolean) => void;
|
|
75
|
+
setSubmitting: (submitting: boolean) => void;
|
|
76
|
+
getCollection: (name: string) => string[];
|
|
77
|
+
initializeCollection(name: string, items: string[]): void;
|
|
78
|
+
addItem(name: string, item: string): void;
|
|
79
|
+
removeItem(name: string, item: string): void;
|
|
80
|
+
snapshot: (fields?: string[], collectionNames?: string[]) => FormSubmission;
|
|
81
|
+
private shouldAcceptIncoming;
|
|
82
|
+
reconcile(defaults: FormDefaults, mode?: FormSyncMode, submission?: FormSubmission): void;
|
|
83
|
+
reset: () => void;
|
|
84
|
+
subscribeRendering: (listener: Listener) => () => void;
|
|
85
|
+
getRendering: () => {
|
|
86
|
+
elements: Record<string, string>;
|
|
87
|
+
errors: string[];
|
|
88
|
+
};
|
|
89
|
+
private notifyRendering;
|
|
90
|
+
registerView(name: string, id: string): () => void;
|
|
91
|
+
registerError(name: string, id: symbol | string): () => void;
|
|
92
|
+
}
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Constraint } from './constraint/Contraint';
|
|
3
|
+
import { FormViewType } from '../../type/FormViewType';
|
|
4
|
+
export type FormFieldProps = {
|
|
5
|
+
view: FormViewType;
|
|
6
|
+
className?: string;
|
|
7
|
+
constraints?: Constraint[];
|
|
8
|
+
onChange?: (value?: string | number | object) => void;
|
|
9
|
+
ref?: React.RefObject<HTMLInputElement | null>;
|
|
10
|
+
};
|
|
11
|
+
export type InputProps = FormFieldProps;
|
|
12
|
+
declare const Input: ({ view, constraints, onChange, ref }: InputProps) => React.JSX.Element;
|
|
13
|
+
export default Input;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Constraint } from './constraint/Contraint';
|
|
3
|
+
import { FormViewType } from '../../type/FormViewType';
|
|
4
|
+
export type FormFieldProps = {
|
|
5
|
+
view: FormViewType;
|
|
6
|
+
className?: string;
|
|
7
|
+
constraints?: Constraint[];
|
|
8
|
+
onChange?: (value: {
|
|
9
|
+
value: string;
|
|
10
|
+
}) => void;
|
|
11
|
+
ref?: React.Ref<HTMLTextAreaElement>;
|
|
12
|
+
};
|
|
13
|
+
export type InputProps = FormFieldProps;
|
|
14
|
+
declare const Textarea: ({ view, constraints, onChange, ref }: InputProps) => React.JSX.Element;
|
|
15
|
+
export default Textarea;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Constraint } from './Contraint';
|
|
2
|
+
export declare class NotBlank implements Constraint {
|
|
3
|
+
defaultMessage: string;
|
|
4
|
+
message: string | null;
|
|
5
|
+
options: {
|
|
6
|
+
message?: string;
|
|
7
|
+
};
|
|
8
|
+
constructor(options: Object);
|
|
9
|
+
isValid(value: any): boolean;
|
|
10
|
+
getMessage(): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ChoiceType } from '../../type/FormViewType.tsx';
|
|
2
|
+
import { FormValue } from './Form.tsx';
|
|
3
|
+
/** Resolves a choice's value to the string token used by form controls. */
|
|
4
|
+
export declare function choiceToken(choice: ChoiceType): string;
|
|
5
|
+
/** Normalizes single and multiple selections without changing the choices. */
|
|
6
|
+
export declare function choiceList(value: ChoiceType | ChoiceType[] | null | undefined): ChoiceType[];
|
|
7
|
+
/** Treats a scalar empty string as no selection; array tokens are preserved. */
|
|
8
|
+
export declare function selectionTokens(value: FormValue | undefined): string[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FormViewErrorType, FormViewType, ChoiceType } from '../../type/FormViewType.tsx';
|
|
2
|
+
import { FormValue } from './Form.tsx';
|
|
3
|
+
export declare const hasInitialOverride: (view: FormViewType) => boolean;
|
|
4
|
+
export declare const markInitialOverride: (view: FormViewType) => FormViewType;
|
|
5
|
+
export declare const fieldName: (name: string) => string;
|
|
6
|
+
export declare const choiceName: (view: FormViewType) => string;
|
|
7
|
+
export declare const stringValue: (value: unknown) => string;
|
|
8
|
+
export declare function equalFormValue(a: FormValue | undefined, b: FormValue | undefined): boolean;
|
|
9
|
+
export declare const selectedValues: (value: FormValue | undefined) => string[];
|
|
10
|
+
export declare const isSelection: (view: FormViewType) => boolean;
|
|
11
|
+
export declare const inputToken: (view: FormViewType) => string;
|
|
12
|
+
/** Convert backend/domain values once at the boundary, keeping editable values as strings. */
|
|
13
|
+
export declare function initialFieldValue(view: FormViewType, choiceValueTransform?: (choice: ChoiceType) => unknown): FormValue;
|
|
14
|
+
export type FormDefaults = {
|
|
15
|
+
values: Record<string, FormValue>;
|
|
16
|
+
collections: Record<string, string[]>;
|
|
17
|
+
};
|
|
18
|
+
export declare function formDefaults(view: FormViewType, initialize?: (view: FormViewType) => FormValue): FormDefaults;
|
|
19
|
+
/** Instantiate a prototype without mutating it or dropping function-valued options. */
|
|
20
|
+
export declare function instantiateView(view: FormViewType, collection: FormViewType, name: string, index: number): FormViewType;
|
|
21
|
+
export declare function formErrors(view: FormViewType): Record<string, FormViewErrorType[]>;
|
|
22
|
+
/** Resolve one property, passing its owner to callbacks without changing the result. */
|
|
23
|
+
export declare function resolveAttribute<T, K extends keyof T>(view: T, name: K): any;
|
|
24
|
+
/** Accept HTML attribute names while giving explicitly supplied React names priority. */
|
|
25
|
+
export declare function normalizeAttributes(attr: Record<string, any>): Record<string, any>;
|
|
26
|
+
/** Value ownership belongs to the binding; decorative attributes remain extensible. */
|
|
27
|
+
export declare function controlAttributes(attr: Record<string, any>): Record<string, any>;
|
|
28
|
+
type SelectionRule = {
|
|
29
|
+
required: boolean;
|
|
30
|
+
multiple: boolean;
|
|
31
|
+
override?: boolean;
|
|
32
|
+
emptyPlaceholder?: boolean;
|
|
33
|
+
};
|
|
34
|
+
export declare const selectionRules: WeakMap<HTMLInputElement, SelectionRule>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React, PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
type RouteItemType = {
|
|
3
|
+
path?: string;
|
|
4
|
+
element?: ReactNode;
|
|
5
|
+
items?: RouteItemType[];
|
|
6
|
+
parent?: RouteItemType;
|
|
7
|
+
};
|
|
8
|
+
declare const Outlet: () => string | number | bigint | true | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined>;
|
|
9
|
+
declare const Router: ({ children }: PropsWithChildren) => import("react/jsx-runtime").JSX.Element | undefined;
|
|
10
|
+
declare const Route: (props: PropsWithChildren & RouteItemType) => null;
|
|
11
|
+
export { Route, Router, Outlet };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { default as React, ComponentType, FC, PropsWithChildren } from 'react';
|
|
2
|
+
declare const Template: ({ name, children }: {
|
|
3
|
+
name: string;
|
|
4
|
+
} & PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare const Block: ({ name, template, children }: PropsWithChildren & {
|
|
6
|
+
name: string;
|
|
7
|
+
template?: string;
|
|
8
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare const Extend: ({ name, template, children }: PropsWithChildren & {
|
|
10
|
+
name: string;
|
|
11
|
+
template?: string;
|
|
12
|
+
}) => null;
|
|
13
|
+
declare const Parent: () => string | number | bigint | true | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null;
|
|
14
|
+
declare function AsTemplate<P extends {}>(Component: ComponentType<P>, options: {
|
|
15
|
+
name: string;
|
|
16
|
+
}): FC<P>;
|
|
17
|
+
export { AsTemplate, Template, Block, Extend, Parent };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
declare const TemplateBlock: React.MemoExoticComponent<({ name, content, children, data }: {
|
|
3
|
+
name: string;
|
|
4
|
+
content: any;
|
|
5
|
+
children?: any;
|
|
6
|
+
data?: any;
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element>;
|
|
8
|
+
export default TemplateBlock;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ComponentType, FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { ActionType } from '../type/ActionType.tsx';
|
|
3
|
+
import { ActionRequestType } from '../type/ActionRequestType.tsx';
|
|
4
|
+
import { RouteType } from '../type/RouteType.tsx';
|
|
5
|
+
export declare function UseActions(safe?: boolean): {
|
|
6
|
+
getAction: (entity: string, name: string, namespace?: string) => ActionType | undefined;
|
|
7
|
+
getActionByPath: (path: string) => ActionType | undefined | null;
|
|
8
|
+
getActionRequestByPath: (path: string) => ActionRequestType | null | undefined;
|
|
9
|
+
navigate: (to: string, replace?: boolean) => void;
|
|
10
|
+
actions: ActionType[] | null;
|
|
11
|
+
location: URL;
|
|
12
|
+
matchPath: (pattern: string, path: string) => {
|
|
13
|
+
pathname: string;
|
|
14
|
+
params: {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
} | undefined;
|
|
17
|
+
query: object;
|
|
18
|
+
pattern: string;
|
|
19
|
+
} | null;
|
|
20
|
+
generateRoute: (route?: RouteType, parameters?: {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}, query?: {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}, hash?: string) => string;
|
|
25
|
+
generateRoutePath: (path: string, parameters?: {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
}, query?: {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
}, hash?: string) => string;
|
|
30
|
+
crudToReactPathPattern: (path: string) => string;
|
|
31
|
+
generateActionLink: (actionRequest: ActionRequestType) => string;
|
|
32
|
+
generateLink: (route?: RouteType, parameters?: {
|
|
33
|
+
[key: string]: string;
|
|
34
|
+
}, query?: {
|
|
35
|
+
[key: string]: string;
|
|
36
|
+
}) => string;
|
|
37
|
+
generatePath: (pattern: string, parameters?: {
|
|
38
|
+
[key: string]: string;
|
|
39
|
+
}, query?: {
|
|
40
|
+
[key: string]: string;
|
|
41
|
+
}, hash?: string) => string;
|
|
42
|
+
internalToExternalPath: (path: string) => string;
|
|
43
|
+
externalToInternalPath: (path: string) => string;
|
|
44
|
+
};
|
|
45
|
+
export declare function ActionProvider(props: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
export declare function WithActionProviderContext<P extends {}>(Component: ComponentType<P>): FC<P>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ComponentType, FC, PropsWithChildren } from 'react';
|
|
2
|
+
type AlertConfigOptionalType = {
|
|
3
|
+
[K in keyof AlertConfigType]?: AlertConfigType[K];
|
|
4
|
+
};
|
|
5
|
+
type AlertContextType = {
|
|
6
|
+
open: (config: AlertConfigOptionalType) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare enum Icon {
|
|
9
|
+
success = 0,
|
|
10
|
+
denied = 1,
|
|
11
|
+
warning = 2,
|
|
12
|
+
info = 3,
|
|
13
|
+
confirm = 4
|
|
14
|
+
}
|
|
15
|
+
export declare enum Animation {
|
|
16
|
+
scale = "scale",
|
|
17
|
+
fade = "fade"
|
|
18
|
+
}
|
|
19
|
+
export declare enum Size {
|
|
20
|
+
small = "sm",
|
|
21
|
+
default = "auto",
|
|
22
|
+
large = "lg",
|
|
23
|
+
extraLarge = "xl"
|
|
24
|
+
}
|
|
25
|
+
export type AlertAction = {
|
|
26
|
+
label: string;
|
|
27
|
+
classList?: string[];
|
|
28
|
+
};
|
|
29
|
+
export type AlertConfigType = {
|
|
30
|
+
title: string;
|
|
31
|
+
text?: string | null;
|
|
32
|
+
icon: Icon | string;
|
|
33
|
+
animation: Animation | string;
|
|
34
|
+
size: Size | string;
|
|
35
|
+
actions?: {
|
|
36
|
+
[key: string]: AlertAction;
|
|
37
|
+
} | null;
|
|
38
|
+
allowClose?: boolean;
|
|
39
|
+
timeout?: number;
|
|
40
|
+
timeoutProgress?: boolean;
|
|
41
|
+
onResult?: (result: Result) => void;
|
|
42
|
+
};
|
|
43
|
+
export type Result = {
|
|
44
|
+
[action: string]: boolean;
|
|
45
|
+
isConfirmed: boolean;
|
|
46
|
+
isCancelled: boolean;
|
|
47
|
+
isDenied: boolean;
|
|
48
|
+
};
|
|
49
|
+
export declare function UseAlert(): AlertContextType;
|
|
50
|
+
export declare function AlertProvider({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
export declare function WithAlertProvider<P extends object>(Component: ComponentType<P>): FC<P>;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { HTMLAttributes, PropsWithChildren } from 'react';
|
|
2
|
+
import { TranslationFunction } from '../component/Translation.tsx';
|
|
3
|
+
export declare enum Environment {
|
|
4
|
+
PROD = "prod",
|
|
5
|
+
DEV = "dev",
|
|
6
|
+
TEST = "test"
|
|
7
|
+
}
|
|
8
|
+
export type ConfigLink = {
|
|
9
|
+
path?: string;
|
|
10
|
+
prefix?: string;
|
|
11
|
+
includePrefix?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type Templates = {
|
|
14
|
+
[path: string]: () => Promise<any>;
|
|
15
|
+
};
|
|
16
|
+
export type Config = {
|
|
17
|
+
env?: Environment | string;
|
|
18
|
+
link?: ConfigLink;
|
|
19
|
+
templates?: {
|
|
20
|
+
[path: string]: () => Promise<any>;
|
|
21
|
+
};
|
|
22
|
+
locale?: string;
|
|
23
|
+
currency?: string;
|
|
24
|
+
timezone?: string;
|
|
25
|
+
translate?: TranslationFunction;
|
|
26
|
+
options?: {
|
|
27
|
+
HTMLTableElement?: HTMLAttributes<HTMLTableElement>;
|
|
28
|
+
GridView?: HTMLAttributes<HTMLDivElement>;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare function UseConfig(): Config;
|
|
32
|
+
export declare function ConfigProvider({ config, ...props }: {
|
|
33
|
+
config: Config;
|
|
34
|
+
} & PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ComponentType, FC, ReactNode, default as React } from 'react';
|
|
2
|
+
import { ActionRequestType } from '../type/ActionRequestType.tsx';
|
|
3
|
+
import { RequestBodyType, Method } from '@dakataa/requester';
|
|
4
|
+
export type GetDataType = {
|
|
5
|
+
url: string;
|
|
6
|
+
status: number;
|
|
7
|
+
results: any;
|
|
8
|
+
response?: Response;
|
|
9
|
+
refresh: () => void;
|
|
10
|
+
cancel: () => void;
|
|
11
|
+
/** Subscribes to request failures; returning true consumes the error. Returns cleanup. */
|
|
12
|
+
registerErrorHandler?: (handler: (error: unknown) => boolean) => () => void;
|
|
13
|
+
};
|
|
14
|
+
export type GetDataProps = {
|
|
15
|
+
loadOnInit?: boolean;
|
|
16
|
+
/** Handles the error locally instead of propagating it to the global handler. */
|
|
17
|
+
onError?: (error: unknown) => void;
|
|
18
|
+
/** Propagates unhandled errors by default; false suppresses them without a callback. */
|
|
19
|
+
throwOnError?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type GetDataByActionRequestProps = GetDataProps & {
|
|
22
|
+
actionRequest: ActionRequestType;
|
|
23
|
+
};
|
|
24
|
+
export declare function UseDataProvider(): GetDataType | null;
|
|
25
|
+
declare const GetData: ({ path, method, body, bodyType, loadOnInit, onError, throwOnError }: GetDataProps & {
|
|
26
|
+
path: string;
|
|
27
|
+
method?: Method;
|
|
28
|
+
body?: FormData | string | {
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
};
|
|
31
|
+
bodyType?: RequestBodyType;
|
|
32
|
+
}) => GetDataType;
|
|
33
|
+
declare const GetDataByAction: ({ actionRequest, loadOnInit, onError, throwOnError }: GetDataByActionRequestProps) => GetDataType | null;
|
|
34
|
+
declare const DataProvider: ({ suspense, children }: {
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
suspense?: ReactNode;
|
|
37
|
+
}) => string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
|
|
38
|
+
declare const DataContextProvider: ({ data, children }: {
|
|
39
|
+
data: GetDataType | null;
|
|
40
|
+
children: ReactNode;
|
|
41
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
declare function WithDataProvider<P extends object>(Component: ComponentType<P>): FC<P>;
|
|
43
|
+
export { DataProvider, DataContextProvider, WithDataProvider, GetData, GetDataByAction };
|