@factorialco/fcode-react-forms 2.0.0 → 3.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.
@@ -1,4 +1,5 @@
1
1
  import { FormData, EmbedFormOptions, GenericObjectType } from '../../types';
2
+ import { Options as ReactMarkdownOptions } from 'react-markdown';
2
3
  import { FcodeJsonSchemaFormProps } from '../json-schema-form';
3
4
  export type FcodeFormOptions = EmbedFormOptions;
4
5
  export interface FcodeFormProps extends Omit<FcodeJsonSchemaFormProps, 'onError' | 'schema'> {
@@ -31,7 +32,11 @@ export interface FcodeFormProps extends Omit<FcodeJsonSchemaFormProps, 'onError'
31
32
  */
32
33
  async?: boolean;
33
34
  /**
34
- * A function called when the form is successfully submitted.
35
+ * A function called when the form is successfully submitted. Passing it
36
+ * replaces the default behavior entirely: no success view is rendered, no
37
+ * `fcode-forms-on-submit-success` event is emitted and `redirect` is not
38
+ * handled. By default the form is replaced by the result's `message`
39
+ * (markdown) or a generic confirmation.
35
40
  * Receives the following parameters:
36
41
  * - formId: The ID of the form.
37
42
  * - processExecutionResult: The result of the process execution as a generic object.
@@ -54,6 +59,13 @@ export interface FcodeFormProps extends Omit<FcodeJsonSchemaFormProps, 'onError'
54
59
  * The default values for the form.
55
60
  */
56
61
  defaultValues?: FormData;
62
+ /**
63
+ * react-markdown component overrides used when rendering the default
64
+ * success/error message and `schema.markdown.before/after`. f0 hosts pass
65
+ * the `markdownComponents` map exported by `@factorialco/rjsf-f0` so
66
+ * messages render with f0 components (tables, headings, links, images).
67
+ */
68
+ markdownComponents?: ReactMarkdownOptions['components'];
57
69
  /**
58
70
  * The options for Factorial Code form.
59
71
  */
@@ -70,7 +82,7 @@ export interface FcodeFormState {
70
82
  variables: GenericObjectType;
71
83
  }
72
84
  declare const FcodeForm: {
73
- ({ hostUrl, headers, team, processId, processVersion, onNextStep, onSuccess, onError, defaultValues, async, disabled, readonly, options, ...rest }: FcodeFormProps): import("react").JSX.Element;
85
+ ({ hostUrl, headers, team, processId, processVersion, onNextStep, onSuccess, onError, markdownComponents, defaultValues, async, disabled, readonly, options, ...rest }: FcodeFormProps): import("react").JSX.Element;
74
86
  displayName: string;
75
87
  };
76
88
  export default FcodeForm;
@@ -1,6 +1,6 @@
1
1
  declare global {
2
2
  interface Window {
3
- __rawHtmlScriptRan?: boolean;
3
+ __markdownScriptRan?: boolean;
4
4
  }
5
5
  }
6
6
  export {};
@@ -1,8 +1,16 @@
1
- import { FormData, GenericObjectType } from '../../types';
1
+ import { RedirectConfig, GenericObjectType } from '../../types';
2
2
  export declare const emitEvent: (name: string, data: any) => void;
3
- export declare const onSuccessDefault: (formId: string, processExecutionResult: GenericObjectType, formSubmittedData: FormData) => void;
3
+ export declare const manageRedirect: (redirectConfig: RedirectConfig) => void;
4
4
  export declare const onNextStepDefault: (formId: string, previousProcessExecutionResult: GenericObjectType) => void;
5
- export declare const onErrorDefault: (formId: string, error: unknown) => void;
5
+ export declare const DEFAULT_SUCCESS_MESSAGE = "The form has been successfully submitted";
6
+ /**
7
+ * Extracts a human-readable message from a submit failure. `submitForm`
8
+ * throws the parsed error body, so the message can arrive as `errorMessage`
9
+ * (the documented convention), as an `Error` whose `.message` is a JSON body
10
+ * carrying `errorMessage`, or as the `message` of a failed execution's 500
11
+ * body (whose `stacktrace` is deliberately ignored).
12
+ */
13
+ export declare const resolveErrorMessage: (error: unknown) => string;
6
14
  /**
7
15
  * Builds the message shown when the form schema fails to load. `fetchFormSpecs`
8
16
  * rejects with an `Error` for a missing form and with the API error body
@@ -1,12 +1,9 @@
1
1
  import { default as React } from 'react';
2
2
  import { FieldTemplateProps } from '@rjsf/utils';
3
- export interface RawHtmlContent {
4
- content: string;
5
- }
6
3
  /**
7
4
  * Renders one field row: label, widget, description, errors and help.
8
5
  *
9
- * `schema.rawHtml.before/after` lets a form author inject markup around the
10
- * field; it is sanitized first, so authored HTML can never execute code.
6
+ * `schema.markdown.before/after` lets a form author put markdown content
7
+ * around the field; HTML is never rendered.
11
8
  */
12
9
  export declare function FieldTemplate(props: FieldTemplateProps): React.JSX.Element;
@@ -1,2 +1,8 @@
1
1
  import { Options as ReactMarkdownProps } from 'react-markdown';
2
2
  export declare function MarkdownContent(props: ReactMarkdownProps): import("react").JSX.Element;
3
+ /**
4
+ * Block-level markdown (GFM) for standalone content: execution result
5
+ * messages and `schema.markdown.before/after`. `MarkdownContent` above stays
6
+ * intentionally narrow for inline field text.
7
+ */
8
+ export declare function MarkdownBlock(props: ReactMarkdownProps): import("react").JSX.Element;