@factorialco/fcode-react-forms 3.5.0 → 3.7.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 +13 -3
- package/dist/components/fcode-form/fcode-form.flow-render.test.d.ts +1 -0
- package/dist/components/fcode-form/fcode-form.flow.d.ts +66 -0
- package/dist/components/fcode-form/fcode-form.flow.test.d.ts +1 -0
- package/dist/components/form-skeleton/form-skeleton.d.ts +2 -2
- package/dist/components/json-schema-form/fcode-json-schema-form.d.ts +8 -2
- package/dist/components/json-schema-form/multistep/flow-navigation.d.ts +28 -0
- package/dist/components/json-schema-form/multistep/flow-page.d.ts +16 -0
- package/dist/components/json-schema-form/multistep/index.d.ts +2 -1
- package/dist/components/json-schema-form/multistep/leave-guard.d.ts +24 -0
- package/dist/components/json-schema-form/multistep/multistep-controller.d.ts +8 -9
- package/dist/components/json-schema-form/multistep/parse-steps.d.ts +2 -1
- package/dist/components/json-schema-form/multistep/step-actions.d.ts +30 -0
- package/dist/components/json-schema-form/multistep/types.d.ts +102 -6
- package/dist/components/json-schema-form/oauth/types.d.ts +14 -0
- package/dist/fcode-form.cjs.js +71 -71
- package/dist/fcode-form.cjs.js.map +1 -1
- package/dist/fcode-form.es.js +9262 -8806
- package/dist/fcode-form.es.js.map +1 -1
- package/dist/fcode-form.umd.js +82 -82
- package/dist/fcode-form.umd.js.map +1 -1
- package/dist/services/fcode.d.ts +1 -0
- package/dist/styles.css +28 -0
- package/dist/types.d.ts +14 -2
- package/dist/utils/kept-files.d.ts +35 -0
- package/dist/utils/kept-files.test.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { FormData, EmbedFormOptions, FormTransport, GenericObjectType } from '../../types';
|
|
2
2
|
import { Options as ReactMarkdownOptions } from 'react-markdown';
|
|
3
3
|
import { FcodeJsonSchemaFormProps } from '../json-schema-form';
|
|
4
|
+
import { ActiveFlow } from './fcode-form.flow';
|
|
4
5
|
export type FcodeFormOptions = EmbedFormOptions;
|
|
5
|
-
interface FcodeFormBaseProps extends Omit<FcodeJsonSchemaFormProps, 'onError' | 'schema'> {
|
|
6
|
+
interface FcodeFormBaseProps extends Omit<FcodeJsonSchemaFormProps, 'onError' | 'schema' | 'flow'> {
|
|
6
7
|
/**
|
|
7
8
|
* The host URL for Factorial Code (optional). Ignored with a `transport`.
|
|
8
9
|
*/
|
|
@@ -39,7 +40,9 @@ interface FcodeFormBaseProps extends Omit<FcodeJsonSchemaFormProps, 'onError' |
|
|
|
39
40
|
* Receives the following parameters:
|
|
40
41
|
* - formId: The ID of the form.
|
|
41
42
|
* - processExecutionResult: The result of the process execution as a generic object.
|
|
42
|
-
* - formSubmittedData: The data submitted with the form.
|
|
43
|
+
* - formSubmittedData: The data submitted with the form. A file above
|
|
44
|
+
* 50 MiB appears as its content-less placeholder `data:` URL
|
|
45
|
+
* (`;fcode-kept=…;`), not as its content: the form never reads it.
|
|
43
46
|
*/
|
|
44
47
|
onSuccess?: (formId: string, processExecutionResult: GenericObjectType, formSubmittedData: FormData) => void;
|
|
45
48
|
/**
|
|
@@ -60,7 +63,8 @@ interface FcodeFormBaseProps extends Omit<FcodeJsonSchemaFormProps, 'onError' |
|
|
|
60
63
|
* Receives the following parameters:
|
|
61
64
|
* - formId: The ID of the form.
|
|
62
65
|
* - error: The error that occurred, of unknown type.
|
|
63
|
-
* - formSubmittedData: The data submitted with the form
|
|
66
|
+
* - formSubmittedData: The data submitted with the form, large files as
|
|
67
|
+
* placeholders (see `onSuccess`).
|
|
64
68
|
*/
|
|
65
69
|
onError?: (formId: string, error: unknown, formSubmittedData: FormData) => void;
|
|
66
70
|
/**
|
|
@@ -104,6 +108,12 @@ export interface FcodeFormState {
|
|
|
104
108
|
processId: string;
|
|
105
109
|
steps: FcodeFormStep[];
|
|
106
110
|
variables: GenericObjectType;
|
|
111
|
+
/**
|
|
112
|
+
* The flow across processes in progress, once its entry form was submitted.
|
|
113
|
+
* Absent while the current form is not inside one, which makes it a
|
|
114
|
+
* possible entry form.
|
|
115
|
+
*/
|
|
116
|
+
flow?: ActiveFlow;
|
|
107
117
|
}
|
|
108
118
|
declare const FcodeForm: {
|
|
109
119
|
({ hostUrl, headers, team, transport, processId, processVersion, onNextStep, onSuccess, keepSuccessView, onError, markdownComponents, defaultValues, async, disabled, readonly, options, ...rest }: FcodeFormProps): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { FormData, GenericObjectType, JSONSchema7, UiSchema } from '../../types';
|
|
2
|
+
import { FormFlow, ParsedMultistep } from '../json-schema-form/multistep';
|
|
3
|
+
import { FcodeFormStep } from './fcode-form';
|
|
4
|
+
/** The position of the entry form; process steps are numbered from 0. */
|
|
5
|
+
export declare const ENTRY_POSITION = -1;
|
|
6
|
+
/** One form of a flow the user has reached, as it was when they reached it. */
|
|
7
|
+
export interface FlowVisit {
|
|
8
|
+
/** `ENTRY_POSITION`, or the index of the process step in the flow. */
|
|
9
|
+
position: number;
|
|
10
|
+
processId: string;
|
|
11
|
+
/** `metadata.steps` as this form was entered: restored on the way back. */
|
|
12
|
+
steps: FcodeFormStep[];
|
|
13
|
+
/** The variables as this form was entered: restored on the way back. */
|
|
14
|
+
variables: GenericObjectType;
|
|
15
|
+
/** What the user last submitted on this form, to refill it on the way back. */
|
|
16
|
+
formData?: FormData;
|
|
17
|
+
/** Entry form only: the in-form step to reopen it on. */
|
|
18
|
+
stepIndex?: number;
|
|
19
|
+
}
|
|
20
|
+
/** A flow across processes in progress: the last visit is the current form. */
|
|
21
|
+
export interface ActiveFlow {
|
|
22
|
+
multistep: ParsedMultistep;
|
|
23
|
+
visits: FlowVisit[];
|
|
24
|
+
}
|
|
25
|
+
export type FlowTransition = {
|
|
26
|
+
kind: 'step';
|
|
27
|
+
position: number;
|
|
28
|
+
processId: string;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'finish';
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'leave';
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Whether a uiSchema's `ui:steps` names any process step — the only case the
|
|
36
|
+
* form becomes the entry of a flow. Checked before parsing so a plain
|
|
37
|
+
* `ui:steps` is parsed (and warned about) once, by the schema form.
|
|
38
|
+
*/
|
|
39
|
+
export declare const declaresProcessSteps: (uiSchema: UiSchema | undefined) => boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The flow a form starts when its `ui:steps` names process steps: the form is
|
|
42
|
+
* its entry, and the flow's only visit so far.
|
|
43
|
+
*/
|
|
44
|
+
export declare const startFlow: (uiSchema: UiSchema | undefined, schema: JSONSchema7, entry: Pick<FlowVisit, "processId" | "steps" | "variables">) => ActiveFlow | null;
|
|
45
|
+
export declare const currentVisit: (flow: ActiveFlow) => FlowVisit;
|
|
46
|
+
/**
|
|
47
|
+
* Where a successful submit of the form at `position` leads. The flow's next
|
|
48
|
+
* process step by default; a returned `nextProcessId` overrides it when it
|
|
49
|
+
* names a later step of the flow. Any other `nextProcessId` leaves the flow:
|
|
50
|
+
* that process's form renders on its own, as plain chaining does.
|
|
51
|
+
*/
|
|
52
|
+
export declare const resolveFlowTransition: (multistep: ParsedMultistep, position: number, nextProcessId?: unknown) => FlowTransition;
|
|
53
|
+
/**
|
|
54
|
+
* The flow cut back to the form at navigation `index`, which becomes the
|
|
55
|
+
* current visit; `null` when no reached form sits there. Every later visit is
|
|
56
|
+
* dropped: submitting the form again re-runs its process.
|
|
57
|
+
*/
|
|
58
|
+
export declare const rewindFlow: (flow: ActiveFlow, index: number) => ActiveFlow | null;
|
|
59
|
+
/**
|
|
60
|
+
* What the current form of a flow needs to render it: the navigation items
|
|
61
|
+
* of the flow's other steps around its own, and its submit's role.
|
|
62
|
+
*/
|
|
63
|
+
export declare const buildFormFlow: (flow: ActiveFlow, actions: {
|
|
64
|
+
onNavigate: (index: number) => void;
|
|
65
|
+
hasErrors: boolean;
|
|
66
|
+
}) => FormFlow;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,8 +3,8 @@ import { default as React } from 'react';
|
|
|
3
3
|
* Form-shaped placeholder rendered while the form schema is being fetched —
|
|
4
4
|
* which includes the time a `preRenderProcess` takes to run server-side.
|
|
5
5
|
*
|
|
6
|
-
* Decorative only (`aria-hidden`): the
|
|
7
|
-
*
|
|
6
|
+
* Decorative only (`aria-hidden`): the loading overlay on top of it marks the
|
|
7
|
+
* form busy, and renders the embedder's `loadingContent` when there is one.
|
|
8
8
|
*/
|
|
9
9
|
declare const FormSkeleton: {
|
|
10
10
|
(): React.JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { default as ReactJsonSchemaForm } from '@rjsf/core';
|
|
3
|
-
import { FcodeRjsfTheme } from './multistep';
|
|
3
|
+
import { FcodeRjsfTheme, FormFlow } from './multistep';
|
|
4
4
|
import { EmbedFormOptions } from '../../types';
|
|
5
5
|
export interface FcodeJsonSchemaFormProps extends Omit<React.ComponentProps<typeof ReactJsonSchemaForm>, 'validator'> {
|
|
6
6
|
locale?: string;
|
|
@@ -16,6 +16,12 @@ export interface FcodeJsonSchemaFormProps extends Omit<React.ComponentProps<type
|
|
|
16
16
|
* `oauth` entry to restyle the `ui:widget: "oauth"` connect control.
|
|
17
17
|
*/
|
|
18
18
|
rjsfTheme?: FcodeRjsfTheme;
|
|
19
|
+
/**
|
|
20
|
+
* The part this form plays in a flow across processes, driven by
|
|
21
|
+
* `FcodeForm`. When given, the schema's own `ui:steps` is not read: the
|
|
22
|
+
* flow already carries the steps.
|
|
23
|
+
*/
|
|
24
|
+
flow?: FormFlow;
|
|
19
25
|
}
|
|
20
|
-
declare const FcodeJsonSchemaForm: ({ id, templates, widgets, fields, locale, fallbackLocale, validator, className, embedFormOptions, rjsfTheme, ...rest }: FcodeJsonSchemaFormProps) => React.JSX.Element;
|
|
26
|
+
declare const FcodeJsonSchemaForm: ({ id, templates, widgets, fields, locale, fallbackLocale, validator, className, embedFormOptions, rjsfTheme, flow, ...rest }: FcodeJsonSchemaFormProps) => React.JSX.Element;
|
|
21
27
|
export default FcodeJsonSchemaForm;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FlowContext, StepsNavigationItem } from './types';
|
|
2
|
+
/** What a navigation item stands for: one of the form's own steps, or a step of the flow. */
|
|
3
|
+
type Target = {
|
|
4
|
+
local: number;
|
|
5
|
+
} | {
|
|
6
|
+
flowIndex: number;
|
|
7
|
+
} | null;
|
|
8
|
+
/**
|
|
9
|
+
* Lays the flow's items around a form's own steps into the one list the
|
|
10
|
+
* theme's navigation renders, indexed by position in that list. A process
|
|
11
|
+
* step whose form steps through its own `ui:steps` keeps its item, as the
|
|
12
|
+
* parent of its own steps one level below.
|
|
13
|
+
*/
|
|
14
|
+
export declare const layoutFlowNavigation: (ownItems: StepsNavigationItem[], flow: FlowContext | undefined) => {
|
|
15
|
+
items: {
|
|
16
|
+
index: number;
|
|
17
|
+
title: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
status: import('./types').StepStatus;
|
|
20
|
+
clickable: boolean;
|
|
21
|
+
hasErrors: boolean;
|
|
22
|
+
depth?: number;
|
|
23
|
+
counter?: string;
|
|
24
|
+
}[];
|
|
25
|
+
targetOf: (index: number) => Target;
|
|
26
|
+
indexOfOwn: (local: number) => number;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { GenericObjectType } from '../../../types';
|
|
3
|
+
import { FlowContext, MultistepThemeComponents, StepsNavigationItem } from './types';
|
|
4
|
+
interface FlowPageProps extends GenericObjectType {
|
|
5
|
+
flow: FlowContext;
|
|
6
|
+
/** This form's own item in the flow's navigation. */
|
|
7
|
+
item: StepsNavigationItem;
|
|
8
|
+
components: MultistepThemeComponents;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A process step of a flow: the process's whole form on a single page, inside
|
|
12
|
+
* the flow's navigation. Its own `ui:steps`, if any, is ignored — the entry
|
|
13
|
+
* form declares the flow.
|
|
14
|
+
*/
|
|
15
|
+
declare const FlowPage: ({ flow, item, components, ...formProps }: FlowPageProps) => React.JSX.Element;
|
|
16
|
+
export default FlowPage;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { parseMultistep } from './parse-steps';
|
|
2
2
|
export { DefaultMultistep } from './default-multistep';
|
|
3
3
|
export { default as MultistepController } from './multistep-controller';
|
|
4
|
-
export
|
|
4
|
+
export { default as FlowPage } from './flow-page';
|
|
5
|
+
export type { FcodeRjsfTheme, FlowContext, FormFlow, LeaveConfirmProps, MultistepConfig, MultistepThemeComponents, ParsedMultistep, ProcessStepDefinition, StepBackButtonProps, StepDefinition, StepLabels, StepsLayout, StepsNavigationItem, StepsNavigationProps, StepStatus, } from './types';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { GenericObjectType } from '../../../types';
|
|
3
|
+
import { LeaveConfirmProps, MultistepConfig, MultistepThemeComponents } from './types';
|
|
4
|
+
/** Whether `next` holds a value the user changed from `initial`. */
|
|
5
|
+
export declare const changedFrom: (next: GenericObjectType | undefined, initial: GenericObjectType | undefined) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* The data a form opens with, its schema defaults applied: RJSF fills the
|
|
8
|
+
* defaults in through `onChange` as it mounts, and they are not something
|
|
9
|
+
* the user typed.
|
|
10
|
+
*/
|
|
11
|
+
export declare const openingDataOf: (formProps: GenericObjectType) => GenericObjectType;
|
|
12
|
+
/** The SDK's own confirmation, for themes that bring none. */
|
|
13
|
+
export declare const DefaultLeaveConfirm: ({ open, title, message, confirmLabel, cancelLabel, onConfirm, onCancel, }: LeaveConfirmProps) => React.JSX.Element | null;
|
|
14
|
+
/**
|
|
15
|
+
* Guards leaving a flow's process step for an earlier one: once the user has
|
|
16
|
+
* typed something into the form, leaving drops it unsubmitted, so the theme's
|
|
17
|
+
* confirmation is asked first. Moving between the form's own sub-steps keeps
|
|
18
|
+
* what was typed and is never guarded.
|
|
19
|
+
*/
|
|
20
|
+
export declare const useLeaveGuard: (config: MultistepConfig, components: MultistepThemeComponents) => {
|
|
21
|
+
noteChange: (isChange: boolean) => void;
|
|
22
|
+
guard: (leave: () => void) => void;
|
|
23
|
+
confirmation: React.JSX.Element;
|
|
24
|
+
};
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { GenericObjectType } from '../../../types';
|
|
3
|
-
import { MultistepThemeComponents, ParsedMultistep } from './types';
|
|
3
|
+
import { FlowContext, MultistepThemeComponents, ParsedMultistep } from './types';
|
|
4
4
|
interface MultistepControllerProps extends GenericObjectType {
|
|
5
5
|
parsed: ParsedMultistep;
|
|
6
6
|
components: MultistepThemeComponents;
|
|
7
|
+
/**
|
|
8
|
+
* The flow across processes this form is the entry of: its navigation lays
|
|
9
|
+
* the flow's process steps after the form's own, and its last submit moves
|
|
10
|
+
* the flow on instead of ending it.
|
|
11
|
+
*/
|
|
12
|
+
flow?: FlowContext;
|
|
7
13
|
}
|
|
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;
|
|
14
|
+
declare const MultistepController: ({ parsed, components, flow, ...formProps }: MultistepControllerProps) => React.JSX.Element;
|
|
16
15
|
export default MultistepController;
|
|
@@ -5,6 +5,7 @@ import { ParsedMultistep } from './types';
|
|
|
5
5
|
* anything unusable — the form then renders single-page, exactly as if
|
|
6
6
|
* `ui:steps` were absent — so an authoring mistake can never leave a form
|
|
7
7
|
* unfillable. Schema properties not assigned to any step are appended to the
|
|
8
|
-
* last step, so no field (required ones especially) is silently
|
|
8
|
+
* last in-form step, so no field (required ones especially) is silently
|
|
9
|
+
* dropped.
|
|
9
10
|
*/
|
|
10
11
|
export declare const parseMultistep: (uiSchema: UiSchema | undefined, schema: JSONSchema7) => ParsedMultistep | null;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { GenericObjectType, UiSchema } from '../../../types';
|
|
3
|
+
import { MultistepConfig, MultistepThemeComponents, StepLabels } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Set on the submit button's props so a theme can tell a submit that moves
|
|
6
|
+
* the form on ("next") from the one that ends it ("submit"), e.g. to add an
|
|
7
|
+
* arrow. A data attribute, since themes spread these props onto a `<button>`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const STEP_ROLE_ATTRIBUTE = "data-fcode-step";
|
|
10
|
+
interface StepActionsProps {
|
|
11
|
+
config: MultistepConfig;
|
|
12
|
+
components: MultistepThemeComponents;
|
|
13
|
+
/** The form's templates, for its theme's SubmitButton. */
|
|
14
|
+
templates?: GenericObjectType;
|
|
15
|
+
/** The form's authored uiSchema, for its submit button options. */
|
|
16
|
+
uiSchema: UiSchema | undefined;
|
|
17
|
+
/** Whether this submit is the last one: it then honors the authored options. */
|
|
18
|
+
isFinal: boolean;
|
|
19
|
+
/** The current step's own labels, over the config's. */
|
|
20
|
+
labels?: StepLabels;
|
|
21
|
+
onBack?: () => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The actions row of a stepped form: an optional Back button and the theme's
|
|
25
|
+
* submit button. The final submit honors the authored submit options in full
|
|
26
|
+
* (norender included); every other one is relabelled to "Next". A step's own
|
|
27
|
+
* labels win over both.
|
|
28
|
+
*/
|
|
29
|
+
declare const StepActions: ({ config, components, templates, uiSchema, isFinal, labels, onBack, }: StepActionsProps) => React.JSX.Element;
|
|
30
|
+
export default StepActions;
|
|
@@ -2,23 +2,51 @@ import { default as React } from 'react';
|
|
|
2
2
|
import { ThemeProps } from '@rjsf/core';
|
|
3
3
|
import { OauthThemeComponents } from '../oauth/types';
|
|
4
4
|
export type StepsLayout = 'tabs' | 'sidebar';
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/** An in-form step as authored in the schema's `ui['ui:steps'].steps` array. */
|
|
6
|
+
/** A step's own button labels, overriding the flow's `config` ones. */
|
|
7
|
+
export interface StepLabels {
|
|
8
|
+
nextLabel?: string;
|
|
9
|
+
backLabel?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface StepDefinition extends StepLabels {
|
|
7
12
|
title: string;
|
|
8
13
|
description?: string;
|
|
9
14
|
fields: string[];
|
|
10
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* A step backed by another process, as authored in the entry form's
|
|
18
|
+
* `ui['ui:steps'].steps` array: the form submits there and that process's form
|
|
19
|
+
* takes over.
|
|
20
|
+
*/
|
|
21
|
+
export interface ProcessStepDefinition extends StepLabels {
|
|
22
|
+
title: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
process: string;
|
|
25
|
+
}
|
|
11
26
|
export interface MultistepConfig {
|
|
12
27
|
layout: StepsLayout;
|
|
13
28
|
nextLabel: string;
|
|
14
29
|
backLabel: string;
|
|
30
|
+
/**
|
|
31
|
+
* The confirmation asked before leaving a flow's process step for an
|
|
32
|
+
* earlier one with values typed but not submitted, which would be lost.
|
|
33
|
+
*/
|
|
34
|
+
leaveTitle: string;
|
|
35
|
+
leaveMessage: string;
|
|
36
|
+
leaveConfirmLabel: string;
|
|
37
|
+
leaveCancelLabel: string;
|
|
15
38
|
}
|
|
16
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* A validated `ui:steps` declaration: at least one in-form step and at least
|
|
41
|
+
* two steps in all. `processSteps` turns it into a flow across processes; the
|
|
42
|
+
* in-form `steps` are the entry form's own and all come before them.
|
|
43
|
+
*/
|
|
17
44
|
export interface ParsedMultistep {
|
|
18
45
|
config: MultistepConfig;
|
|
19
46
|
steps: StepDefinition[];
|
|
47
|
+
processSteps: ProcessStepDefinition[];
|
|
20
48
|
}
|
|
21
|
-
export type StepStatus = 'completed' | 'current' | 'upcoming';
|
|
49
|
+
export type StepStatus = 'completed' | 'current' | 'upcoming' | 'skipped';
|
|
22
50
|
export interface StepsNavigationItem {
|
|
23
51
|
index: number;
|
|
24
52
|
title: string;
|
|
@@ -27,6 +55,13 @@ export interface StepsNavigationItem {
|
|
|
27
55
|
clickable: boolean;
|
|
28
56
|
/** The server rejected a field of this step on the final submit. */
|
|
29
57
|
hasErrors: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* 0 for a step of the flow, 1 for a step a process step's form splits
|
|
60
|
+
* itself into (rendered below that process step). Absent means 0.
|
|
61
|
+
*/
|
|
62
|
+
depth?: number;
|
|
63
|
+
/** The step's number as shown ("2", "2.1"); absent means `index + 1`. */
|
|
64
|
+
counter?: string;
|
|
30
65
|
}
|
|
31
66
|
export interface StepsNavigationProps {
|
|
32
67
|
layout: StepsLayout;
|
|
@@ -36,19 +71,80 @@ export interface StepsNavigationProps {
|
|
|
36
71
|
/** The current step's form; the navigation lays itself out around it. */
|
|
37
72
|
children: React.ReactNode;
|
|
38
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* How a form takes part in a flow across processes: the navigation items of
|
|
76
|
+
* the flow's other steps, laid around the form's own, and what its submit and
|
|
77
|
+
* Back do at the form's edges.
|
|
78
|
+
*/
|
|
79
|
+
export interface FlowContext {
|
|
80
|
+
config: MultistepConfig;
|
|
81
|
+
/** Items ahead of the form's own steps; their `index` is the flow's. */
|
|
82
|
+
before: StepsNavigationItem[];
|
|
83
|
+
/** Items after the form's own steps; their `index` is the flow's. */
|
|
84
|
+
after: StepsNavigationItem[];
|
|
85
|
+
/** Navigates to an item outside the form, by its flow index. */
|
|
86
|
+
onNavigate: (index: number) => void;
|
|
87
|
+
/** Back from the form's first step; absent on the flow's first step. */
|
|
88
|
+
onBack?: () => void;
|
|
89
|
+
/** Whether the form's final submit ends the flow, or moves it on. */
|
|
90
|
+
endsFlow: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* The button labels of the process step this form is, for its own steps
|
|
93
|
+
* that set none.
|
|
94
|
+
*/
|
|
95
|
+
labels?: StepLabels;
|
|
96
|
+
/**
|
|
97
|
+
* The process step this form's own steps belong to, when a process step's
|
|
98
|
+
* form splits itself through its own `ui:steps`: its item stays in the
|
|
99
|
+
* navigation, with the form's steps one level below it.
|
|
100
|
+
*/
|
|
101
|
+
parent?: StepsNavigationItem;
|
|
102
|
+
/**
|
|
103
|
+
* The step to open on, when coming back to a form; absent opens the first
|
|
104
|
+
* step, or the last one when revisiting.
|
|
105
|
+
*/
|
|
106
|
+
initialStepIndex?: number;
|
|
107
|
+
/**
|
|
108
|
+
* The form is being revisited from a later step: every one of its own steps
|
|
109
|
+
* was already completed, so all of them are reachable.
|
|
110
|
+
*/
|
|
111
|
+
revisiting: boolean;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The part a form plays in a flow: the entry form, stepped through its own
|
|
115
|
+
* in-form steps, or a process step rendered as a single page.
|
|
116
|
+
*/
|
|
117
|
+
export type FormFlow = (FlowContext & {
|
|
118
|
+
kind: 'entry';
|
|
119
|
+
multistep: ParsedMultistep;
|
|
120
|
+
}) | (FlowContext & {
|
|
121
|
+
kind: 'page';
|
|
122
|
+
item: StepsNavigationItem;
|
|
123
|
+
});
|
|
39
124
|
export interface StepBackButtonProps {
|
|
40
125
|
label: string;
|
|
41
126
|
onClick: () => void;
|
|
42
127
|
disabled?: boolean;
|
|
43
128
|
}
|
|
129
|
+
export interface LeaveConfirmProps {
|
|
130
|
+
open: boolean;
|
|
131
|
+
title: string;
|
|
132
|
+
message: string;
|
|
133
|
+
confirmLabel: string;
|
|
134
|
+
cancelLabel: string;
|
|
135
|
+
onConfirm: () => void;
|
|
136
|
+
onCancel: () => void;
|
|
137
|
+
}
|
|
44
138
|
/**
|
|
45
139
|
* The components a theme contributes to render multistep forms: the step
|
|
46
|
-
* navigation shell
|
|
47
|
-
*
|
|
140
|
+
* navigation shell, the non-submitting Back button placed next to the submit
|
|
141
|
+
* button inside the form, and the confirmation asked before leaving a flow's
|
|
142
|
+
* step with unsubmitted values (the SDK's own is used when a theme has none).
|
|
48
143
|
*/
|
|
49
144
|
export interface MultistepThemeComponents {
|
|
50
145
|
StepsNavigation: React.ComponentType<StepsNavigationProps>;
|
|
51
146
|
BackButton: React.ComponentType<StepBackButtonProps>;
|
|
147
|
+
LeaveConfirm?: React.ComponentType<LeaveConfirmProps>;
|
|
52
148
|
}
|
|
53
149
|
export type FcodeRjsfTheme = ThemeProps & {
|
|
54
150
|
multistep?: MultistepThemeComponents;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KeptFiles } from '../../../utils/kept-files';
|
|
1
2
|
import { default as React } from 'react';
|
|
2
3
|
export type OauthOnComplete = 'none' | 'submit' | 'reload';
|
|
3
4
|
export type OauthValueKind = 'boolean' | 'string' | 'object';
|
|
@@ -85,5 +86,18 @@ export interface FcodeFormContext {
|
|
|
85
86
|
/** Skip the loading overlay: a background refresh. */
|
|
86
87
|
silent?: boolean;
|
|
87
88
|
}) => void;
|
|
89
|
+
/**
|
|
90
|
+
* `false` stops the form from offering `keptFiles`, so every file is read
|
|
91
|
+
* into a `data:` URL as before.
|
|
92
|
+
*/
|
|
93
|
+
keepLargeFiles?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Where a file widget holds a large file instead of reading it into a
|
|
96
|
+
* `data:` URL, which a file near 1 GB cannot become. The widget stores the
|
|
97
|
+
* placeholder `keep` returns as the field's value; the form swaps the
|
|
98
|
+
* `File` back in at submit. Set by `FcodeForm`, read by the f0 theme's
|
|
99
|
+
* `FileWidget` (`@factorialco/rjsf-f0`) for top-level single-file fields.
|
|
100
|
+
*/
|
|
101
|
+
keptFiles?: KeptFiles;
|
|
88
102
|
};
|
|
89
103
|
}
|