@factorialco/fcode-react-forms 3.1.0 → 3.3.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/dist/components/fcode-form/fcode-form.d.ts +5 -6
- package/dist/components/fcode-form/fcode-form.utils.d.ts +1 -1
- package/dist/components/json-schema-form/fcode-json-schema-form.d.ts +5 -3
- package/dist/components/json-schema-form/inner-rjsf-form.d.ts +10 -0
- package/dist/components/json-schema-form/multistep/default-multistep.d.ts +2 -0
- package/dist/components/json-schema-form/multistep/index.d.ts +4 -0
- package/dist/components/json-schema-form/multistep/multistep-controller.d.ts +16 -0
- package/dist/components/json-schema-form/multistep/multistep-controller.test.d.ts +1 -0
- package/dist/components/json-schema-form/multistep/parse-steps.d.ts +10 -0
- package/dist/components/json-schema-form/multistep/parse-steps.test.d.ts +1 -0
- package/dist/components/json-schema-form/multistep/slice-step.d.ts +24 -0
- package/dist/components/json-schema-form/multistep/types.d.ts +54 -0
- package/dist/fcode-form.cjs.js +79 -79
- package/dist/fcode-form.cjs.js.map +1 -1
- package/dist/fcode-form.es.js +17434 -17176
- package/dist/fcode-form.es.js.map +1 -1
- package/dist/fcode-form.umd.js +94 -94
- package/dist/fcode-form.umd.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/styles.css +141 -1
- package/package.json +1 -1
|
@@ -33,10 +33,10 @@ export interface FcodeFormProps extends Omit<FcodeJsonSchemaFormProps, 'onError'
|
|
|
33
33
|
async?: boolean;
|
|
34
34
|
/**
|
|
35
35
|
* A function called when the form is successfully submitted. Passing it
|
|
36
|
-
* replaces the default
|
|
37
|
-
* `fcode-forms-on-submit-success` event is emitted
|
|
38
|
-
*
|
|
39
|
-
*
|
|
36
|
+
* replaces the default outcome: no success view is rendered and no
|
|
37
|
+
* `fcode-forms-on-submit-success` event is emitted. By default the form is
|
|
38
|
+
* replaced by the result's `message` (markdown) or a generic confirmation.
|
|
39
|
+
* The result's `redirect` is followed either way, before this runs.
|
|
40
40
|
* Receives the following parameters:
|
|
41
41
|
* - formId: The ID of the form.
|
|
42
42
|
* - processExecutionResult: The result of the process execution as a generic object.
|
|
@@ -48,8 +48,7 @@ export interface FcodeFormProps extends Omit<FcodeJsonSchemaFormProps, 'onError'
|
|
|
48
48
|
* the outcome entirely to it, so a host that only needs to react to the
|
|
49
49
|
* submission (navigate, refresh, mark something installed) still shows the
|
|
50
50
|
* result's `message`. Only the view comes back: the
|
|
51
|
-
* `fcode-forms-on-submit-success` event
|
|
52
|
-
* since a host with its own callback owns navigation. Ignored without
|
|
51
|
+
* `fcode-forms-on-submit-success` event stays default-only. Ignored without
|
|
53
52
|
* `onSuccess` — the view is the default already.
|
|
54
53
|
*/
|
|
55
54
|
keepSuccessView?: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RedirectConfig, GenericObjectType } from '../../types';
|
|
2
2
|
export declare const emitEvent: (name: string, data: any) => void;
|
|
3
|
-
export declare const manageRedirect: (redirectConfig: RedirectConfig) => void;
|
|
3
|
+
export declare const manageRedirect: (redirectConfig: RedirectConfig, assign?: (url: string) => void) => void;
|
|
4
4
|
export declare const onNextStepDefault: (formId: string, previousProcessExecutionResult: GenericObjectType) => void;
|
|
5
5
|
export declare const DEFAULT_SUCCESS_MESSAGE = "The form has been successfully submitted";
|
|
6
6
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { default as ReactJsonSchemaForm
|
|
2
|
+
import { default as ReactJsonSchemaForm } from '@rjsf/core';
|
|
3
|
+
import { FcodeRjsfTheme } from './multistep';
|
|
3
4
|
import { EmbedFormOptions } from '../../types';
|
|
4
5
|
export interface FcodeJsonSchemaFormProps extends Omit<React.ComponentProps<typeof ReactJsonSchemaForm>, 'validator'> {
|
|
5
6
|
locale?: string;
|
|
@@ -10,9 +11,10 @@ export interface FcodeJsonSchemaFormProps extends Omit<React.ComponentProps<type
|
|
|
10
11
|
* Renders the form with a different set of RJSF templates, widgets and fields
|
|
11
12
|
* — e.g. `Theme` from `@factorialco/rjsf-f0` to render f0 components instead
|
|
12
13
|
* of the stylesheet-driven default theme. Individual `templates`, `widgets`
|
|
13
|
-
* and `fields` props still take precedence over the theme.
|
|
14
|
+
* and `fields` props still take precedence over the theme. A theme may also
|
|
15
|
+
* carry a `multistep` entry to restyle the `ui:steps` navigation.
|
|
14
16
|
*/
|
|
15
|
-
rjsfTheme?:
|
|
17
|
+
rjsfTheme?: FcodeRjsfTheme;
|
|
16
18
|
}
|
|
17
19
|
declare const FcodeJsonSchemaForm: ({ id, templates, widgets, fields, locale, fallbackLocale, validator, className, embedFormOptions, rjsfTheme, ...rest }: FcodeJsonSchemaFormProps) => React.JSX.Element;
|
|
18
20
|
export default FcodeJsonSchemaForm;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { GenericObjectType } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* The single RJSF form render. Receives already-merged `fields`/`templates`/
|
|
5
|
+
* `widgets` and a resolved `validator` from `FcodeJsonSchemaForm` (directly,
|
|
6
|
+
* or per step through `MultistepController`) and owns the local form data
|
|
7
|
+
* state.
|
|
8
|
+
*/
|
|
9
|
+
declare const InnerRjsfForm: ({ id, ...rest }: GenericObjectType) => React.JSX.Element;
|
|
10
|
+
export default InnerRjsfForm;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { parseMultistep } from './parse-steps';
|
|
2
|
+
export { DefaultMultistep } from './default-multistep';
|
|
3
|
+
export { default as MultistepController } from './multistep-controller';
|
|
4
|
+
export type { FcodeRjsfTheme, MultistepConfig, MultistepThemeComponents, ParsedMultistep, StepBackButtonProps, StepDefinition, StepsLayout, StepsNavigationItem, StepsNavigationProps, StepStatus, } from './types';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { GenericObjectType } from '../../../types';
|
|
3
|
+
import { MultistepThemeComponents, ParsedMultistep } from './types';
|
|
4
|
+
interface MultistepControllerProps extends GenericObjectType {
|
|
5
|
+
parsed: ParsedMultistep;
|
|
6
|
+
components: MultistepThemeComponents;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Renders a `ui:steps` form one step at a time. Each step is its own RJSF
|
|
10
|
+
* form over a slice of the schema, so RJSF validates exactly the fields on
|
|
11
|
+
* screen: the intermediate submit ("Next") advances instead of posting, and
|
|
12
|
+
* only the last step's submit reaches the real `onSubmit` — with the form
|
|
13
|
+
* data accumulated across every step.
|
|
14
|
+
*/
|
|
15
|
+
declare const MultistepController: ({ parsed, components, ...formProps }: MultistepControllerProps) => React.JSX.Element;
|
|
16
|
+
export default MultistepController;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JSONSchema7, UiSchema } from '../../../types';
|
|
2
|
+
import { ParsedMultistep } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Validates the schema-authored `ui:steps` declaration. Returns `null` on
|
|
5
|
+
* anything unusable — the form then renders single-page, exactly as if
|
|
6
|
+
* `ui:steps` were absent — so an authoring mistake can never leave a form
|
|
7
|
+
* unfillable. Schema properties not assigned to any step are appended to the
|
|
8
|
+
* last step, so no field (required ones especially) is silently dropped.
|
|
9
|
+
*/
|
|
10
|
+
export declare const parseMultistep: (uiSchema: UiSchema | undefined, schema: JSONSchema7) => ParsedMultistep | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { GenericObjectType, JSONSchema7, UiSchema } from '../../../types';
|
|
2
|
+
export declare const pickKeys: (object: GenericObjectType | undefined, keys: string[]) => GenericObjectType;
|
|
3
|
+
/**
|
|
4
|
+
* Property names a step renders beyond its own fields: the ones injected by
|
|
5
|
+
* `dependencies` entries keyed by a step field (their `properties` and the
|
|
6
|
+
* `properties` of every `oneOf` branch).
|
|
7
|
+
*/
|
|
8
|
+
export declare const dependencyFieldNames: (schema: JSONSchema7, fields: string[]) => string[];
|
|
9
|
+
/**
|
|
10
|
+
* The schema a single step renders: only its own `properties`, its subset of
|
|
11
|
+
* root `required`, and the `dependencies` it can satisfy. Root `title` and
|
|
12
|
+
* `description` are kept so every step shows the form heading as today.
|
|
13
|
+
* Property-list dependencies (`{a: ['b']}`) reaching outside the step are
|
|
14
|
+
* dropped — the step cannot see the other field, and the full constraint is
|
|
15
|
+
* still enforced by the process's own schema validation server-side.
|
|
16
|
+
*/
|
|
17
|
+
export declare const sliceSchemaForStep: (schema: JSONSchema7, fields: string[]) => JSONSchema7;
|
|
18
|
+
/**
|
|
19
|
+
* The uiSchema for a single step: the entries of the step's fields (including
|
|
20
|
+
* dependency-injected ones) plus every root `ui:*` key except `ui:steps` (the
|
|
21
|
+
* step engine's own input) and `ui:submitButtonOptions` (the actions row
|
|
22
|
+
* renders the submit button itself).
|
|
23
|
+
*/
|
|
24
|
+
export declare const sliceUiSchemaForStep: (uiSchema: UiSchema | undefined, fieldNames: string[]) => UiSchema;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ThemeProps } from '@rjsf/core';
|
|
3
|
+
export type StepsLayout = 'tabs' | 'sidebar';
|
|
4
|
+
/** One step as authored in the schema's `ui['ui:steps'].steps` array. */
|
|
5
|
+
export interface StepDefinition {
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
fields: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface MultistepConfig {
|
|
11
|
+
layout: StepsLayout;
|
|
12
|
+
nextLabel: string;
|
|
13
|
+
backLabel: string;
|
|
14
|
+
}
|
|
15
|
+
/** A validated `ui:steps` declaration; always carries at least two steps. */
|
|
16
|
+
export interface ParsedMultistep {
|
|
17
|
+
config: MultistepConfig;
|
|
18
|
+
steps: StepDefinition[];
|
|
19
|
+
}
|
|
20
|
+
export type StepStatus = 'completed' | 'current' | 'upcoming';
|
|
21
|
+
export interface StepsNavigationItem {
|
|
22
|
+
index: number;
|
|
23
|
+
title: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
status: StepStatus;
|
|
26
|
+
clickable: boolean;
|
|
27
|
+
/** The server rejected a field of this step on the final submit. */
|
|
28
|
+
hasErrors: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface StepsNavigationProps {
|
|
31
|
+
layout: StepsLayout;
|
|
32
|
+
items: StepsNavigationItem[];
|
|
33
|
+
currentIndex: number;
|
|
34
|
+
onNavigate: (index: number) => void;
|
|
35
|
+
/** The current step's form; the navigation lays itself out around it. */
|
|
36
|
+
children: React.ReactNode;
|
|
37
|
+
}
|
|
38
|
+
export interface StepBackButtonProps {
|
|
39
|
+
label: string;
|
|
40
|
+
onClick: () => void;
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The components a theme contributes to render multistep forms: the step
|
|
45
|
+
* navigation shell and the non-submitting Back button placed next to the
|
|
46
|
+
* submit button inside the form.
|
|
47
|
+
*/
|
|
48
|
+
export interface MultistepThemeComponents {
|
|
49
|
+
StepsNavigation: React.ComponentType<StepsNavigationProps>;
|
|
50
|
+
BackButton: React.ComponentType<StepBackButtonProps>;
|
|
51
|
+
}
|
|
52
|
+
export type FcodeRjsfTheme = ThemeProps & {
|
|
53
|
+
multistep?: MultistepThemeComponents;
|
|
54
|
+
};
|