@factorialco/fcode-react-forms 3.4.1 → 3.6.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 +32 -10
- package/dist/components/fcode-form/fcode-form.default-requests.test.d.ts +1 -0
- 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/fcode-form/fcode-form.transport.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/fcode-form.cjs.js +73 -73
- package/dist/fcode-form.cjs.js.map +1 -1
- package/dist/fcode-form.es.js +9583 -9077
- package/dist/fcode-form.es.js.map +1 -1
- package/dist/fcode-form.umd.js +87 -87
- package/dist/fcode-form.umd.js.map +1 -1
- package/dist/hooks/use-form-specs.d.ts +15 -2
- package/dist/hooks/use-submit-form.d.ts +13 -2
- package/dist/index.d.ts +2 -1
- package/dist/services/fcode.d.ts +11 -1
- package/dist/services/transport.d.ts +25 -0
- package/dist/services/transport.test.d.ts +1 -0
- package/dist/styles.css +28 -0
- package/dist/types.d.ts +66 -1
- package/package.json +1 -1
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { FormOptions, FormSpecs } from '../types';
|
|
2
|
-
|
|
1
|
+
import { FormOptions, FormSpecs, TransportFormOptions, UploadGrant } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* With a `transport`, the schema comes from it instead of the platform, and
|
|
4
|
+
* `hostUrl`, `team`, `headers` and `processVersion` do not apply. The
|
|
5
|
+
* transport is read when a fetch starts, so a new transport object alone does
|
|
6
|
+
* not refetch; a new `processId`, `locale` or `params` does.
|
|
7
|
+
*/
|
|
8
|
+
declare const useFormSpecs: (options: FormOptions | TransportFormOptions) => {
|
|
3
9
|
loading: boolean;
|
|
4
10
|
/** A `reload()` is in flight; the previous specs stay available meanwhile. */
|
|
5
11
|
reloading: boolean;
|
|
6
12
|
formSpecs: FormSpecs | undefined;
|
|
13
|
+
/** The upload grants the transport returned with the specs. */
|
|
14
|
+
uploads: UploadGrant[] | undefined;
|
|
7
15
|
error: unknown;
|
|
8
16
|
/**
|
|
9
17
|
* Refetches the specs bypassing the cache, keeping the current form on
|
|
@@ -15,5 +23,10 @@ declare const useFormSpecs: ({ hostUrl, headers, team, processId, processVersion
|
|
|
15
23
|
reload: (options?: {
|
|
16
24
|
silent?: boolean;
|
|
17
25
|
}) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Refetches the specs through the transport for fresh upload grants and
|
|
28
|
+
* resolves with them; `undefined` without a transport.
|
|
29
|
+
*/
|
|
30
|
+
reloadUploads: () => Promise<UploadGrant[] | undefined>;
|
|
18
31
|
};
|
|
19
32
|
export default useFormSpecs;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import { FormOptions, SubmitFormResults, FormData } from '../types';
|
|
2
|
-
|
|
1
|
+
import { FormOptions, SubmitFormResults, FormData, TransportFormOptions, UploadGrant } from '../types';
|
|
2
|
+
export type SubmitFormOptions = FormOptions | (TransportFormOptions & {
|
|
3
|
+
/** The grants `useFormSpecs` returned with the specs. */
|
|
4
|
+
uploads?: UploadGrant[];
|
|
5
|
+
/** `useFormSpecs().reloadUploads`, used once when a grant has expired. */
|
|
6
|
+
reloadUploads?: () => Promise<UploadGrant[] | undefined>;
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* With a `transport`, submits through it (uploading files to their grants
|
|
10
|
+
* first) instead of posting to the platform; `hostUrl`, `team`, `headers` and
|
|
11
|
+
* `processVersion` do not apply.
|
|
12
|
+
*/
|
|
13
|
+
declare const useSubmitForm: (options: SubmitFormOptions) => [(data: FormData) => Promise<any>, {
|
|
3
14
|
loading: boolean;
|
|
4
15
|
results: SubmitFormResults | undefined;
|
|
5
16
|
error: string | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { processFormSpecs } from './utils/process-form-specs';
|
|
|
4
4
|
import { buildId } from './utils';
|
|
5
5
|
import { resolveErrorMessage } from './components/fcode-form/fcode-form.utils';
|
|
6
6
|
export { FcodeForm, FcodeJsonSchemaForm, processFormSpecs, buildId, resolveErrorMessage, };
|
|
7
|
-
export type { RedirectConfig } from './types';
|
|
7
|
+
export type { FormTransport, RedirectConfig, SubmitFormResponse, TransportFetchSchemaParams, TransportFetchSchemaResult, TransportSubmitParams, UploadGrant, } from './types';
|
|
8
|
+
export type { FcodeFormProps } from './components/fcode-form/fcode-form';
|
|
8
9
|
export type { FcodeRjsfTheme, MultistepThemeComponents, StepBackButtonProps, StepsNavigationItem, StepsNavigationProps, } from './components/json-schema-form/multistep';
|
|
9
10
|
export type { FcodeFormContext, OauthCompletionMessage, OauthConnectControlProps, OauthConnectStatus, OauthOnComplete, OauthThemeComponents, } from './components/json-schema-form/oauth';
|
|
10
11
|
export default FcodeForm;
|
package/dist/services/fcode.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
import { SubmitFormParams, SubmitFormResponse, FetchFormSpecsParams } from '../types';
|
|
1
|
+
import { SubmitFormParams, SubmitFormResponse, FetchFormSpecsParams, FormData as YepFormData } from '../types';
|
|
2
|
+
export declare const FORM_NOT_AVAILABLE_MESSAGE = "Process form specs couldn't be loaded: the form does not exist, is not enabled, or needs a Factorial token this request did not carry or that was not accepted. Review documentation at https://code.factorialhr.com/docs/forms/";
|
|
2
3
|
export declare const fetchFormSpecs: ({ hostUrl, headers, team, processId, processVersion, locale, cache, }: FetchFormSpecsParams) => Promise<any>;
|
|
4
|
+
type ExtractedFile = {
|
|
5
|
+
key: string;
|
|
6
|
+
file: File;
|
|
7
|
+
};
|
|
8
|
+
export declare const extractFilesFromFormData: (formData: YepFormData) => {
|
|
9
|
+
sanitized: YepFormData;
|
|
10
|
+
files: ExtractedFile[];
|
|
11
|
+
};
|
|
3
12
|
export declare const submitForm: ({ hostUrl, headers, team, processId, processVersion, async, locale, formData, }: SubmitFormParams) => Promise<SubmitFormResponse>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FormData as YepFormData, FormOptions, FormTransport, SubmitFormResponse, TransportFormOptions, UploadGrant } from '../types';
|
|
2
|
+
export declare const isTransportOptions: (options: FormOptions | TransportFormOptions) => options is TransportFormOptions;
|
|
3
|
+
/**
|
|
4
|
+
* Thrown when a grant's URL refuses the upload twice: the grants were reloaded
|
|
5
|
+
* once already, so another attempt would only repeat the refusal.
|
|
6
|
+
*/
|
|
7
|
+
export declare class UploadGrantExpiredError extends Error {
|
|
8
|
+
constructor(field: string);
|
|
9
|
+
}
|
|
10
|
+
export interface SubmitThroughTransportParams {
|
|
11
|
+
transport: FormTransport;
|
|
12
|
+
processId: string;
|
|
13
|
+
locale?: string;
|
|
14
|
+
async?: boolean;
|
|
15
|
+
formData: YepFormData;
|
|
16
|
+
uploads?: UploadGrant[];
|
|
17
|
+
/** Fetches the schema again for fresh grants, when the current ones have expired. */
|
|
18
|
+
reloadUploads?: () => Promise<UploadGrant[] | undefined>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Submits through a transport. With grants, each file is sent to its grant's
|
|
22
|
+
* URL first and the submit carries the storage paths instead, as plain JSON;
|
|
23
|
+
* without grants the form data goes to the transport as it is.
|
|
24
|
+
*/
|
|
25
|
+
export declare const submitThroughTransport: ({ transport, processId, locale, async, formData, uploads, reloadUploads, }: SubmitThroughTransportParams) => Promise<SubmitFormResponse>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/styles.css
CHANGED
|
@@ -1730,6 +1730,30 @@ input[type='number'] {
|
|
|
1730
1730
|
color: var(--ycf-base-text-color);
|
|
1731
1731
|
}
|
|
1732
1732
|
|
|
1733
|
+
/* The confirmation's overlay layout is inline (leave-guard.tsx); only its text is styled here. */
|
|
1734
|
+
.fcode-steps-leave-title {
|
|
1735
|
+
margin: 0 0 0.5rem;
|
|
1736
|
+
font-size: 1.125rem;
|
|
1737
|
+
font-weight: 600;
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
.fcode-steps-leave-message {
|
|
1741
|
+
margin: 0 0 1.5rem;
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
.fcode-steps-item.is-substep {
|
|
1745
|
+
padding-left: 1.5rem;
|
|
1746
|
+
font-size: 0.875rem;
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
.fcode-steps-layout-tabs .fcode-steps-item.is-substep {
|
|
1750
|
+
padding-left: 0.5rem;
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
.fcode-steps-item.is-skipped .fcode-steps-item-title {
|
|
1754
|
+
text-decoration: line-through;
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1733
1757
|
.fcode-steps-item.is-current {
|
|
1734
1758
|
color: var(--ycf-base-text-color);
|
|
1735
1759
|
font-weight: 500;
|
|
@@ -1808,5 +1832,9 @@ input[type='number'] {
|
|
|
1808
1832
|
.fcode-form .fcode-steps-actions {
|
|
1809
1833
|
display: flex;
|
|
1810
1834
|
align-items: center;
|
|
1835
|
+
justify-content: flex-end;
|
|
1811
1836
|
gap: 0.75rem;
|
|
1837
|
+
margin-top: 1.5rem;
|
|
1838
|
+
padding-top: 1rem;
|
|
1839
|
+
border-top: 1px solid var(--ycf-base-border-color);
|
|
1812
1840
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -32,12 +32,18 @@ export interface EmbedFormOptions {
|
|
|
32
32
|
stylesheetBaseUrl?: string;
|
|
33
33
|
className?: string;
|
|
34
34
|
loadingOverlayDisabled?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Message shown under the spinner while the form is submitting. Unset by
|
|
37
|
+
* default, so the spinner shows on its own: the SDK has no translations of
|
|
38
|
+
* its own, and a fixed English default reached users of every locale. Can
|
|
39
|
+
* come from the schema, where `fcode.i18n("key")` translates it.
|
|
40
|
+
*/
|
|
35
41
|
loadingOverlayContent?: string;
|
|
36
42
|
/**
|
|
37
43
|
* Message shown while the form schema is loading (e.g. while a
|
|
38
44
|
* `preRenderProcess` runs). Must be set by the embedder — unlike the other
|
|
39
45
|
* options it cannot come from the schema, since the schema is what is being
|
|
40
|
-
* loaded.
|
|
46
|
+
* loaded. Unset by default: the skeleton and spinner show on their own.
|
|
41
47
|
*/
|
|
42
48
|
loadingContent?: string;
|
|
43
49
|
/**
|
|
@@ -102,3 +108,62 @@ export interface SubmitFormParams {
|
|
|
102
108
|
locale?: string;
|
|
103
109
|
formData: FormData;
|
|
104
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* A presigned write for one file field, handed out with the schema by a
|
|
113
|
+
* transport. The SDK sends the file there itself and submits `path` as the
|
|
114
|
+
* field's value, so the submit carries no file bytes.
|
|
115
|
+
*/
|
|
116
|
+
export interface UploadGrant {
|
|
117
|
+
/** The form field the file belongs to. */
|
|
118
|
+
field: string;
|
|
119
|
+
/** The `fcode.storage://` reference submitted as the field's value. */
|
|
120
|
+
path: string;
|
|
121
|
+
uploadUrl: string;
|
|
122
|
+
/** Defaults to `PUT`. */
|
|
123
|
+
method?: string;
|
|
124
|
+
/** Sent with the upload as they are; presigned URLs usually sign some. */
|
|
125
|
+
headers?: Record<string, string>;
|
|
126
|
+
expiresAt?: string;
|
|
127
|
+
}
|
|
128
|
+
export interface TransportFetchSchemaParams {
|
|
129
|
+
/**
|
|
130
|
+
* Whatever id the transport understands — a process slug, an opaque action
|
|
131
|
+
* id. The SDK passes it through, including a step's `nextProcessId`.
|
|
132
|
+
*/
|
|
133
|
+
processId: string;
|
|
134
|
+
locale?: string;
|
|
135
|
+
/** The form's variables: the embedder's `options.variables` plus what earlier steps returned. */
|
|
136
|
+
params?: GenericObjectType;
|
|
137
|
+
/** Always `no-store`: the schema is per user and must not be shared through a cache. */
|
|
138
|
+
cache: RequestCache;
|
|
139
|
+
}
|
|
140
|
+
export interface TransportFetchSchemaResult {
|
|
141
|
+
/** The form specs, the same body the platform's forms endpoint returns. */
|
|
142
|
+
schema: FormSpecs;
|
|
143
|
+
/** One grant per file field. Absent, the transport receives the files inside `formData`. */
|
|
144
|
+
uploads?: UploadGrant[];
|
|
145
|
+
}
|
|
146
|
+
export interface TransportSubmitParams {
|
|
147
|
+
processId: string;
|
|
148
|
+
/** Plain JSON: file fields with a grant already hold their storage path. */
|
|
149
|
+
formData: FormData;
|
|
150
|
+
locale?: string;
|
|
151
|
+
async?: boolean;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* A caller-supplied channel for fetching the schema and submitting the form,
|
|
155
|
+
* used instead of the SDK's own requests to the platform. A submit that fails
|
|
156
|
+
* rejects with the error body, as the platform's does (`formErrors`,
|
|
157
|
+
* `errorMessage`).
|
|
158
|
+
*/
|
|
159
|
+
export interface FormTransport {
|
|
160
|
+
fetchSchema: (params: TransportFetchSchemaParams) => Promise<TransportFetchSchemaResult>;
|
|
161
|
+
submit: (params: TransportSubmitParams) => Promise<SubmitFormResponse>;
|
|
162
|
+
}
|
|
163
|
+
export interface TransportFormOptions {
|
|
164
|
+
transport: FormTransport;
|
|
165
|
+
processId: string;
|
|
166
|
+
async?: boolean;
|
|
167
|
+
locale?: string;
|
|
168
|
+
params?: GenericObjectType;
|
|
169
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@factorialco/fcode-react-forms",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Factorial Code allows start process executions from any webpage embedding process input parameters forms. This allows each form submission to start one execution with the information filled in the form, and also allows to manage the execution result into that webpage.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://code.factorialhr.com/docs/forms/",
|