reactaform 1.8.8 → 1.8.91
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.full.md +29 -21
- package/dist/components/ReactaForm.d.ts +1 -0
- package/dist/components/ReactaFormProvider.d.ts +2 -1
- package/dist/components/ReactaFormRenderer.d.ts +3 -1
- package/dist/core/reactaFormTypes.d.ts +6 -1
- package/dist/core/submitForm.d.ts +2 -2
- package/dist/reactaform.cjs.js +45 -13
- package/dist/reactaform.css +1 -1
- package/dist/reactaform.es.js +1570 -1493
- package/dist/themes/ant-design-dark.css +3 -3
- package/dist/themes/ant-design.css +3 -3
- package/dist/themes/blueprint-dark.css +3 -3
- package/dist/themes/blueprint.css +4 -4
- package/dist/themes/fluent.css +3 -3
- package/dist/themes/glass-morphism.css +7 -7
- package/dist/themes/high-contrast-accessible.css +1 -1
- package/dist/themes/ios-mobile.css +3 -3
- package/dist/themes/macos-native.css +5 -5
- package/dist/themes/material-dark.css +3 -3
- package/dist/themes/material.css +5 -5
- package/dist/themes/midnight-dark.css +3 -3
- package/dist/themes/modern-light.css +3 -3
- package/dist/themes/neon-cyber-dark.css +3 -3
- package/dist/themes/shadcn.css +3 -3
- package/dist/themes/soft-pastel.css +3 -3
- package/dist/themes/tailwind-dark.css +3 -3
- package/dist/themes/tailwind.css +5 -5
- package/package.json +5 -3
package/README.full.md
CHANGED
|
@@ -276,11 +276,36 @@ ReactaForm supports both field-level and form-level validation.
|
|
|
276
276
|
---
|
|
277
277
|
|
|
278
278
|
## Submission Handler
|
|
279
|
-
|
|
279
|
+
|
|
280
|
+
ReactaForm provide two ways for submission process:
|
|
281
|
+
|
|
282
|
+
- Direct submission callback in ReactaForm props
|
|
283
|
+
- Since ReactaForm is a dynamic form system, it provides a registration submission mechanism that allows you to define and plug in custom submission logic. This can provide you flexible submission process for different submission logics.
|
|
284
|
+
|
|
285
|
+
Note: In bubmission proces, onSubmit callback will be used if it is provided. Otherwise if submissionHandler in defintion is spcified, the registration handler will be invoked.
|
|
280
286
|
|
|
281
287
|
**How It Works**
|
|
282
288
|
|
|
283
|
-
|
|
289
|
+
### Direct submission callback
|
|
290
|
+
|
|
291
|
+
```ts
|
|
292
|
+
async function submitFunction(definition, instanceName, valuesMap, t) => {
|
|
293
|
+
// send valuesMap to your API
|
|
294
|
+
const res = await fetch('/api/save', { method: 'POST', body: JSON.stringify(valuesMap), headers: { 'Content-Type': 'application/json' } });
|
|
295
|
+
if (!res.ok) return [t('Server error while submitting form')];
|
|
296
|
+
return undefined; // returning undefined (or falsy) means success
|
|
297
|
+
});
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Then in your app, when call ReactaForm, pass submitFunction to onSubmit:
|
|
301
|
+
```ts
|
|
302
|
+
<ReactaForm
|
|
303
|
+
definition={userDefintion}
|
|
304
|
+
onSubmit= {submitFunction}
|
|
305
|
+
/>
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Submission registration handling is configured in two steps:
|
|
284
309
|
|
|
285
310
|
1. Define and Register a Submission Handler
|
|
286
311
|
|
|
@@ -346,30 +371,21 @@ Status Legend:
|
|
|
346
371
|
- 🔵 Logical operators (AND / OR / NOT)
|
|
347
372
|
- 🔵 Multi-field conditions
|
|
348
373
|
- 🔵 Expression-based rules
|
|
349
|
-
- 🔵 Nested condition groups
|
|
350
|
-
- 🔵 Cross-group conditional logic
|
|
351
|
-
- 🔵 Conditional validation rules
|
|
352
|
-
- 🔵 Conditional default values
|
|
353
374
|
|
|
354
375
|
### Layout & Structure
|
|
376
|
+
- 🟢 Collapsible sections - Group
|
|
355
377
|
- 🔵 Multi-step / wizard forms
|
|
356
378
|
- 🔵 Tabbed layouts
|
|
357
379
|
- 🔵 Navigation sections / anchors
|
|
358
|
-
- 🔵 Collapsible sections
|
|
359
|
-
- 🔵 Reusable layout templates
|
|
360
|
-
- 🔵 Responsive layout rules
|
|
361
380
|
- 🔵 Grid & column layouts
|
|
362
|
-
- 🟡 Layout-aware conditional logic
|
|
363
381
|
|
|
364
382
|
### Visual Builders
|
|
365
383
|
- 🟢 Drag-and-drop form builder
|
|
366
384
|
- 🔵 Advanced conditional logic editor
|
|
367
385
|
- 🔵 Validation rule designer
|
|
368
386
|
- 🔵 Submission workflow editor
|
|
369
|
-
- 🔵 Layout editor (tabs, steps, groups)
|
|
370
|
-
- 🔵 Live schema diff & change preview
|
|
387
|
+
- 🔵 Layout editor (nav, tabs, steps, groups)
|
|
371
388
|
- 🔵 Schema version history & rollback
|
|
372
|
-
- 🔵 Import / export schema packs
|
|
373
389
|
- 🟡 Builder extensibility API
|
|
374
390
|
|
|
375
391
|
### Theme System
|
|
@@ -378,11 +394,8 @@ Status Legend:
|
|
|
378
394
|
- 🟢 Per-form theme customization
|
|
379
395
|
- 🔵 Visual theme builder
|
|
380
396
|
- 🔵 CSS variable editor
|
|
381
|
-
- 🔵 Light / dark theme generator
|
|
382
|
-
- 🔵 Live theme preview across field types
|
|
383
397
|
- 🔵 Exportable & versioned theme packages
|
|
384
398
|
- 🔵 Tailwind-compatible themes
|
|
385
|
-
- 🟡 Theme inheritance & overrides
|
|
386
399
|
|
|
387
400
|
### Plugin System
|
|
388
401
|
- 🟢 Component registry
|
|
@@ -392,10 +405,6 @@ Status Legend:
|
|
|
392
405
|
- 🔵 Custom field plugin builder
|
|
393
406
|
- 🔵 Validator plugin builder
|
|
394
407
|
- 🔵 Submission handler plugins
|
|
395
|
-
- 🔵 Plugin metadata & versioning
|
|
396
|
-
- 🔵 Plugin dependency management
|
|
397
|
-
- 🟡 One-click plugin export
|
|
398
|
-
- 🟡 Plugin compatibility checks
|
|
399
408
|
|
|
400
409
|
Internationalization (i18n)
|
|
401
410
|
|
|
@@ -406,7 +415,6 @@ Current: built-in i18n with per-form dictionaries
|
|
|
406
415
|
- 🔵 Translation key discovery
|
|
407
416
|
- 🔵 Missing translation detection
|
|
408
417
|
- 🔵 Locale fallback strategies
|
|
409
|
-
- 🟡 RTL layout support
|
|
410
418
|
- 🟡 Async translation loaders
|
|
411
419
|
|
|
412
420
|
### Ecosystem & Marketplace
|
|
@@ -10,6 +10,7 @@ import type { ReactaFormProps } from "../core/reactaFormTypes";
|
|
|
10
10
|
* @param {string} [props.theme] - Theme name ('light' or 'dark')
|
|
11
11
|
* @param {React.CSSProperties} [props.style] - Inline styles
|
|
12
12
|
* @param {FieldValidationMode} [props.fieldValidationMode] - Validation timing mode ('realTime' or 'onSubmission')
|
|
13
|
+
* @param {boolean} [props.displayInstanceName] - Whether to display the instance name
|
|
13
14
|
*/
|
|
14
15
|
declare const ReactaForm: React.FC<ReactaFormProps>;
|
|
15
16
|
export default ReactaForm;
|
|
@@ -11,7 +11,8 @@ import '../core/reactaform.css';
|
|
|
11
11
|
* @param {string} [props.defaultLocalizeName] - Name of custom localization file
|
|
12
12
|
* @param {FieldValidationMode} [props.defaultFieldValidationMode='realTime'] - Validation timing mode
|
|
13
13
|
* @param {string} [props.className='reactaform-container'] - CSS class name for the container
|
|
14
|
+
* @param {boolean} [props.displayInstanceName] - Whether to display the instance name
|
|
14
15
|
*/
|
|
15
|
-
export declare const ReactaFormProvider: ({ children, definitionName, defaultStyle, defaultLanguage, defaultTheme, defaultLocalizeName, defaultFieldValidationMode, className, }: ReactaFormProviderProps & {
|
|
16
|
+
export declare const ReactaFormProvider: ({ children, definitionName, defaultStyle, defaultLanguage, defaultTheme, defaultLocalizeName, defaultFieldValidationMode, className, defaultDisplayInstanceName }: ReactaFormProviderProps & {
|
|
16
17
|
defaultFieldValidationMode?: FieldValidationMode;
|
|
17
18
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import type { ReactaDefinition, ReactaInstance } from "../core/reactaFormTypes";
|
|
2
|
+
import type { ReactaDefinition, ReactaInstance, FormSubmissionHandler, FormValidationHandler } from "../core/reactaFormTypes";
|
|
3
3
|
export interface ReactaFormRendererProps {
|
|
4
4
|
definition: ReactaDefinition;
|
|
5
5
|
instance: ReactaInstance;
|
|
6
|
+
onSubmit?: FormSubmissionHandler;
|
|
7
|
+
onValidation?: FormValidationHandler;
|
|
6
8
|
chunkSize?: number;
|
|
7
9
|
chunkDelay?: number;
|
|
8
10
|
}
|
|
@@ -71,13 +71,16 @@ export interface ReactaFormProps {
|
|
|
71
71
|
theme?: string;
|
|
72
72
|
style?: React.CSSProperties;
|
|
73
73
|
fieldValidationMode?: FieldValidationMode;
|
|
74
|
+
displayInstanceName?: boolean;
|
|
75
|
+
onSubmit?: FormSubmissionHandler;
|
|
76
|
+
onValidation?: FormValidationHandler;
|
|
74
77
|
}
|
|
75
78
|
export type TranslationFunction = (text: string, ...args: unknown[]) => string;
|
|
76
79
|
/** Validation mode controls where validation is performed. */
|
|
77
80
|
export type FieldValidationMode = 'realTime' | 'onSubmission';
|
|
78
81
|
export type FieldCustomValidationHandler = (fieldName: string, value: FieldValueType | unknown, t: TranslationFunction) => string | undefined;
|
|
79
82
|
export type FieldTypeValidationHandler = (field: DefinitionPropertyField, input: FieldValueType, t: TranslationFunction) => string | null;
|
|
80
|
-
export type FormValidationHandler = (valuesMap: Record<string, FieldValueType | unknown>, t: TranslationFunction) => string[] | Promise<string[] | undefined
|
|
83
|
+
export type FormValidationHandler = (valuesMap: Record<string, FieldValueType | unknown>, t: TranslationFunction) => string[] | Promise<string[] | undefined> | undefined;
|
|
81
84
|
export type FormSubmissionHandler = (definition: ReactaDefinition, instanceName: string | null, valuesMap: Record<string, FieldValueType | unknown>, t: TranslationFunction) => string[] | undefined | Promise<string[] | undefined>;
|
|
82
85
|
export type InputOnChange<T> = (value: T | string) => void;
|
|
83
86
|
export interface BaseInputProps<TValue = unknown, TField extends DefinitionPropertyField = DefinitionPropertyField> {
|
|
@@ -99,6 +102,7 @@ export type ReactaFormContextType = {
|
|
|
99
102
|
fieldStyle: Record<string, unknown>;
|
|
100
103
|
t: TranslationFunction;
|
|
101
104
|
fieldValidationMode?: FieldValidationMode;
|
|
105
|
+
displayInstanceName?: boolean;
|
|
102
106
|
};
|
|
103
107
|
export type ReactaFormProviderProps = {
|
|
104
108
|
children: ReactNode;
|
|
@@ -109,6 +113,7 @@ export type ReactaFormProviderProps = {
|
|
|
109
113
|
defaultLocalizeName?: string;
|
|
110
114
|
defaultFieldValidationMode?: FieldValidationMode;
|
|
111
115
|
className?: string;
|
|
116
|
+
defaultDisplayInstanceName?: boolean;
|
|
112
117
|
};
|
|
113
118
|
export type TranslationMap = Record<string, string>;
|
|
114
119
|
export type TranslationCache = Map<string, TranslationMap>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ReactaDefinition, FieldValueType, ReactaInstance, TranslationFunction } from "./reactaFormTypes";
|
|
1
|
+
import type { ReactaDefinition, FieldValueType, ReactaInstance, TranslationFunction, FormSubmissionHandler, FormValidationHandler } from "./reactaFormTypes";
|
|
2
2
|
export interface SubmitResult {
|
|
3
3
|
success: boolean;
|
|
4
4
|
message: string;
|
|
5
5
|
data?: Record<string, unknown>;
|
|
6
6
|
errors?: string[];
|
|
7
7
|
}
|
|
8
|
-
export declare function submitForm(definition: ReactaDefinition, instance: ReactaInstance | null, valuesMap: Record<string, FieldValueType | unknown>, t: TranslationFunction, errors: Record<string, string
|
|
8
|
+
export declare function submitForm(definition: ReactaDefinition, instance: ReactaInstance | null, valuesMap: Record<string, FieldValueType | unknown>, t: TranslationFunction, errors: Record<string, string>, onSubmit?: FormSubmissionHandler | undefined, onValidation?: FormValidationHandler | undefined): Promise<SubmitResult>;
|
|
9
9
|
export default submitForm;
|