reactaform 1.8.0 → 1.8.2
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/README.md +247 -379
- package/dist/common-B4FQDljX.mjs +112 -0
- package/dist/common-BeQ3x_ll.js +1 -0
- package/dist/{common-BeJOG7Z0.js → common-C9xi6Anp.js} +1 -1
- package/dist/{common-CTK4jqc5.mjs → common-CCGIMXY_.mjs} +44 -31
- package/dist/{common-DLr0UoG9.js → common-CiL5z7rS.js} +1 -1
- package/dist/{common-DRxsgpaH.mjs → common-Dd94fy-Y.mjs} +31 -15
- package/dist/common-Ws7ob6hh.mjs +112 -0
- package/dist/common-pqSYL5rx.js +1 -0
- package/dist/components/ReactaFormProvider.d.ts +4 -2
- package/dist/components/SubmissionButton.d.ts +8 -0
- package/dist/components/SubmissionMessage.d.ts +7 -0
- package/dist/components/fields/ColorInput.d.ts +1 -4
- package/dist/components/fields/EmailInput.d.ts +0 -1
- package/dist/components/fields/FloatInput.d.ts +1 -1
- package/dist/components/fields/IntegerInput.d.ts +1 -1
- package/dist/components/fields/SwitchInput.d.ts +0 -5
- package/dist/components/fields/TextInput.d.ts +3 -1
- package/dist/components/fields/UnitValueInput.d.ts +1 -4
- package/dist/components/fields/UrlInput.d.ts +0 -12
- package/dist/components/renderFields.d.ts +2 -2
- package/dist/core/componentRegistry.d.ts +7 -0
- package/dist/core/index.d.ts +1 -23
- package/dist/core/pluginRegistry.d.ts +4 -3
- package/dist/core/reactaFormTypes.d.ts +10 -3
- package/dist/hooks/useFieldValidator.d.ts +2 -0
- package/dist/hooks/useUncontrolledValidatedInput.d.ts +2 -2
- package/dist/index.d.ts +8 -8
- package/dist/reactaform.cjs.js +5 -5
- package/dist/reactaform.es.js +4051 -3677
- package/dist/utils/translationCache.d.ts +8 -0
- package/dist/validation/registerBuiltinTypeValidators.d.ts +11 -0
- package/dist/validation/validateFileField.d.ts +2 -0
- package/dist/validation/validation.d.ts +1 -1
- package/dist/validation/validationHandlerRegistry.d.ts +11 -10
- package/package.json +1 -1
- package/dist/common-Crb-me6O.js +0 -1
- package/dist/common-DINaqn4M.mjs +0 -98
- package/dist/common-DRIndE7S.js +0 -1
- package/dist/common-DXEjsP3o.mjs +0 -98
- package/dist/core/debounceConfig.d.ts +0 -6
- package/dist/utils/index.d.ts +0 -11
- package/dist/validation/index.d.ts +0 -13
- /package/dist/core/{debounceEnv.d.ts → env.d.ts} +0 -0
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import BaseRegistry from "./baseRegistry";
|
|
2
|
+
export type DebounceConfig = false | {
|
|
3
|
+
wait?: number;
|
|
4
|
+
leading?: boolean;
|
|
5
|
+
trailing?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const DEBOUNCE_CONFIG: Record<string, DebounceConfig>;
|
|
2
8
|
declare const registry: BaseRegistry<unknown>;
|
|
9
|
+
export declare function isBuiltinComponentType(typeName: string): boolean;
|
|
3
10
|
export declare function registerComponentInternal(type: string, component: unknown, isBaseComponent: boolean): void;
|
|
4
11
|
export declare function registerComponent(type: string, component: unknown): void;
|
|
5
12
|
export declare function getComponent(type: string): unknown;
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,23 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from "./submitForm";
|
|
3
|
-
export * from "./fieldVisibility";
|
|
4
|
-
export * from "./reactaFormModel";
|
|
5
|
-
export * from "./pluginRegistry";
|
|
6
|
-
export * from "./componentRegistry";
|
|
7
|
-
export * from "./submissionHandlerRegistry";
|
|
8
|
-
export * from "./baseRegistry";
|
|
9
|
-
import * as submitForm from "./submitForm";
|
|
10
|
-
import * as fieldVisibility from "./fieldVisibility";
|
|
11
|
-
import * as reactaFormModel from "./reactaFormModel";
|
|
12
|
-
import * as pluginRegistry from "./pluginRegistry";
|
|
13
|
-
import * as componentRegistry from "./componentRegistry";
|
|
14
|
-
import * as submissionRegistry from "./submissionHandlerRegistry";
|
|
15
|
-
declare const _default: {
|
|
16
|
-
submitForm: typeof submitForm;
|
|
17
|
-
fieldVisibility: typeof fieldVisibility;
|
|
18
|
-
reactaFormModel: typeof reactaFormModel;
|
|
19
|
-
pluginRegistry: typeof pluginRegistry;
|
|
20
|
-
componentRegistry: typeof componentRegistry;
|
|
21
|
-
submissionRegistry: typeof submissionRegistry;
|
|
22
|
-
};
|
|
23
|
-
export default _default;
|
|
1
|
+
export {};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Tracks installed plugins, components, validators, submission handlers
|
|
4
4
|
* Handles conflicts with customizable strategy
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { FieldCustomValidationHandler, FieldTypeValidationHandler, FormValidationHandler, FormSubmissionHandler } from './reactaFormTypes';
|
|
7
7
|
/** Conflict resolution strategies */
|
|
8
8
|
export type ConflictResolution = 'error' | 'warn' | 'override' | 'skip';
|
|
9
9
|
/** Plugin registration options */
|
|
@@ -13,7 +13,7 @@ export interface PluginRegistrationOptions {
|
|
|
13
13
|
}
|
|
14
14
|
/** Plugin conflict information */
|
|
15
15
|
export interface PluginConflict {
|
|
16
|
-
type: 'component' | '
|
|
16
|
+
type: 'component' | 'fieldCustomValidator' | 'fieldTypeValidator' | 'formValidator' | 'submissionHandler' | 'plugin';
|
|
17
17
|
name: string;
|
|
18
18
|
existingPlugin: string;
|
|
19
19
|
newPlugin: string;
|
|
@@ -24,7 +24,8 @@ export interface ReactaFormPlugin {
|
|
|
24
24
|
version: string;
|
|
25
25
|
description?: string;
|
|
26
26
|
components?: Record<string, React.ComponentType<unknown>>;
|
|
27
|
-
|
|
27
|
+
fieldCustomValidators?: Record<string, Record<string, FieldCustomValidationHandler>>;
|
|
28
|
+
fieldTypeValidators?: Record<string, FieldTypeValidationHandler>;
|
|
28
29
|
formValidators?: Record<string, FormValidationHandler>;
|
|
29
30
|
submissionHandlers?: Record<string, FormSubmissionHandler>;
|
|
30
31
|
setup?: () => void;
|
|
@@ -70,18 +70,23 @@ export interface ReactaFormProps {
|
|
|
70
70
|
className?: string;
|
|
71
71
|
theme?: string;
|
|
72
72
|
style?: React.CSSProperties;
|
|
73
|
+
fieldValidationMode?: FieldValidationMode;
|
|
73
74
|
}
|
|
74
75
|
export type TranslationFunction = (text: string, ...args: unknown[]) => string;
|
|
75
|
-
|
|
76
|
+
/** Validation mode controls where validation is performed. */
|
|
77
|
+
export type FieldValidationMode = 'realTime' | 'onSubmission';
|
|
78
|
+
export type FieldCustomValidationHandler = (fieldName: string, value: FieldValueType | unknown, t: TranslationFunction) => string | undefined;
|
|
79
|
+
export type FieldTypeValidationHandler = (field: DefinitionPropertyField, input: FieldValueType, t: TranslationFunction) => string | null;
|
|
76
80
|
export type FormValidationHandler = (valuesMap: Record<string, FieldValueType | unknown>, t: TranslationFunction) => string[] | undefined | Promise<string[] | undefined>;
|
|
77
|
-
export type FormSubmissionHandler = (definition: ReactaDefinition
|
|
78
|
-
export type InputOnChange<T> = (value: T | string
|
|
81
|
+
export type FormSubmissionHandler = (definition: ReactaDefinition, instanceName: string | null, valuesMap: Record<string, FieldValueType | unknown>, t: TranslationFunction) => string[] | undefined | Promise<string[] | undefined>;
|
|
82
|
+
export type InputOnChange<T> = (value: T | string) => void;
|
|
79
83
|
export interface BaseInputProps<TValue = unknown, TField extends DefinitionPropertyField = DefinitionPropertyField> {
|
|
80
84
|
field: TField;
|
|
81
85
|
value: TValue;
|
|
82
86
|
placeholder?: string;
|
|
83
87
|
onChange?: InputOnChange<TValue>;
|
|
84
88
|
onError?: (error: string | null) => void;
|
|
89
|
+
error?: string | null;
|
|
85
90
|
}
|
|
86
91
|
export type ReactaFormContextType = {
|
|
87
92
|
definitionName: string;
|
|
@@ -93,6 +98,7 @@ export type ReactaFormContextType = {
|
|
|
93
98
|
};
|
|
94
99
|
fieldStyle: Record<string, unknown>;
|
|
95
100
|
t: TranslationFunction;
|
|
101
|
+
fieldValidationMode?: FieldValidationMode;
|
|
96
102
|
};
|
|
97
103
|
export type ReactaFormProviderProps = {
|
|
98
104
|
children: ReactNode;
|
|
@@ -101,6 +107,7 @@ export type ReactaFormProviderProps = {
|
|
|
101
107
|
defaultLanguage?: string;
|
|
102
108
|
defaultTheme?: string;
|
|
103
109
|
defaultLocalizeName?: string;
|
|
110
|
+
defaultFieldValidationMode?: FieldValidationMode;
|
|
104
111
|
className?: string;
|
|
105
112
|
};
|
|
106
113
|
export type TranslationMap = Record<string, string>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
export type UseUncontrolledValidatedInputProps = {
|
|
3
|
-
value?: string;
|
|
4
|
-
onChange?: (value: string
|
|
3
|
+
value?: string | number;
|
|
4
|
+
onChange?: (value: string) => void;
|
|
5
5
|
onError?: (error: string | null) => void;
|
|
6
6
|
validate: (value: string) => string | null;
|
|
7
7
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -6,21 +6,21 @@ export { ReactaFormProvider } from './components/ReactaFormProvider';
|
|
|
6
6
|
export { default as useReactaFormContext } from './hooks/useReactaFormContext';
|
|
7
7
|
export { StandardFieldLayout } from './components/LayoutComponents';
|
|
8
8
|
export { CSS_CLASSES, combineClasses } from './utils/cssClasses';
|
|
9
|
-
export type { ReactaFormContextType, ReactaFormProviderProps, DefinitionPropertyField, ReactaDefinition, ReactaInstance, ReactaFormProps, FieldValueType, ErrorType,
|
|
9
|
+
export type { ReactaFormContextType, ReactaFormProviderProps, DefinitionPropertyField, ReactaDefinition, ReactaInstance, ReactaFormProps, FieldValueType, ErrorType, FieldCustomValidationHandler, FieldTypeValidationHandler, FormValidationHandler, FormSubmissionHandler, InputOnChange, BaseInputProps, TranslationFunction, FieldValidationMode } from './core/reactaFormTypes';
|
|
10
10
|
export { registerComponent, getComponent, } from './core/componentRegistry';
|
|
11
11
|
export { validateFieldValue, // Deprecated, use validateFieldWithHandler instead
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export { registerPlugin, unregisterPlugin, getPlugin, getAllPlugins, hasPlugin, registerComponents, } from './core/pluginRegistry';
|
|
15
|
-
export type { ReactaFormPlugin, ConflictResolution, PluginRegistrationOptions, PluginConflict, } from './core/pluginRegistry';
|
|
12
|
+
validateFieldWithCustomHandler } from './validation/validation';
|
|
13
|
+
export { type ReactaFormPlugin, type ConflictResolution, type PluginRegistrationOptions, type PluginConflict, registerPlugin, unregisterPlugin, getPlugin, getAllPlugins, hasPlugin, registerComponents, } from './core/pluginRegistry';
|
|
16
14
|
export type { LoadDefinitionOptions, DefinitionLoadResult, InstanceLoadResult, } from './core/reactaFormModel';
|
|
17
15
|
export { loadJsonDefinition, createInstanceFromDefinition, // Create new instance with default values
|
|
18
16
|
loadInstance, // Load existing instance (valuesMap)
|
|
19
17
|
upgradeInstanceToLatestDefinition } from './core/reactaFormModel';
|
|
20
18
|
export { registerSubmissionHandler, } from './core/submissionHandlerRegistry';
|
|
21
|
-
export {
|
|
22
|
-
export type
|
|
23
|
-
export {
|
|
19
|
+
export { registerFieldCustomValidationHandler, registerFieldTypeValidationHandler, registerFormValidationHandler, } from './validation/validationHandlerRegistry';
|
|
20
|
+
export { type DebouncedCallback, useDebouncedCallback } from './hooks/useDebouncedCallback';
|
|
21
|
+
export { useFieldValidator } from './hooks/useFieldValidator';
|
|
22
|
+
export { useUncontrolledValidatedInput, type UseUncontrolledValidatedInputProps } from './hooks/useUncontrolledValidatedInput';
|
|
24
23
|
export * as Units from './utils/unitValueMapper';
|
|
25
24
|
export { isDarkTheme } from './utils/themeUtils';
|
|
26
25
|
export { serializeInstance, deserializeInstance, serializeDefinition, deserializeDefinition } from './utils/definitionSerializers';
|
|
26
|
+
export { getSupportedLanguages } from './utils/translationCache';
|