@factorialco/fcode-react-forms 3.6.0 → 3.7.1

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.
@@ -40,7 +40,9 @@ interface FcodeFormBaseProps extends Omit<FcodeJsonSchemaFormProps, 'onError' |
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.
43
- * - 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.
44
46
  */
45
47
  onSuccess?: (formId: string, processExecutionResult: GenericObjectType, formSubmittedData: FormData) => void;
46
48
  /**
@@ -61,7 +63,8 @@ interface FcodeFormBaseProps extends Omit<FcodeJsonSchemaFormProps, 'onError' |
61
63
  * Receives the following parameters:
62
64
  * - formId: The ID of the form.
63
65
  * - error: The error that occurred, of unknown type.
64
- * - formSubmittedData: The data submitted with the form.
66
+ * - formSubmittedData: The data submitted with the form, large files as
67
+ * placeholders (see `onSuccess`).
65
68
  */
66
69
  onError?: (formId: string, error: unknown, formSubmittedData: FormData) => void;
67
70
  /**
@@ -5,6 +5,11 @@ import { EmbedFormOptions } from '../../types';
5
5
  export interface FcodeJsonSchemaFormProps extends Omit<React.ComponentProps<typeof ReactJsonSchemaForm>, 'validator'> {
6
6
  locale?: string;
7
7
  fallbackLocale?: string;
8
+ /**
9
+ * Replaces the default AJV validator. Either way, the validator only ever
10
+ * sees `oneOf`/`anyOf` lists of `{ const, title }` options as the equivalent
11
+ * `enum` (see `flat-const-options.ts`), so long selects cannot overflow it.
12
+ */
8
13
  validator?: React.ComponentProps<typeof ReactJsonSchemaForm>['validator'];
9
14
  embedFormOptions?: EmbedFormOptions;
10
15
  /**
@@ -0,0 +1,18 @@
1
+ import { FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '@rjsf/utils';
2
+ /**
3
+ * Rewrites every `oneOf`/`anyOf` that only lists `{ const, title }` options
4
+ * into the equivalent `enum`. Labels are not needed to validate, and AJV
5
+ * compiles each `oneOf` entry as one more nested `if`, so a select listing a
6
+ * whole directory (every employee of a company) overflows the call stack. An
7
+ * `enum` compiles flat whatever its length.
8
+ *
9
+ * Untouched subtrees keep their identity, and the same input always yields
10
+ * the same output, so AJV's per-object compilation cache keeps working.
11
+ */
12
+ export declare const flattenConstOptions: <S>(schema: S) => S;
13
+ /**
14
+ * Wraps a validator so every schema it receives is passed through
15
+ * `flattenConstOptions` first. Rendering keeps reading the original schema, so
16
+ * selects still show each option's `title`.
17
+ */
18
+ export declare const withFlatConstOptions: <T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>) => ValidatorType<T, S, F>;
@@ -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
  }