@factorialco/fcode-react-forms 3.2.0 → 3.4.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.
Files changed (35) hide show
  1. package/dist/components/fcode-form/fcode-form.d.ts +5 -6
  2. package/dist/components/fcode-form/fcode-form.utils.d.ts +1 -1
  3. package/dist/components/json-schema-form/fcode-json-schema-form.d.ts +2 -1
  4. package/dist/components/json-schema-form/fields/index.d.ts +1 -0
  5. package/dist/components/json-schema-form/fields/oauth-field.d.ts +9 -0
  6. package/dist/components/json-schema-form/multistep/types.d.ts +2 -0
  7. package/dist/components/json-schema-form/oauth/default-connect-control.d.ts +8 -0
  8. package/dist/components/json-schema-form/oauth/index.d.ts +5 -0
  9. package/dist/components/json-schema-form/oauth/oauth-callback-page.test.d.ts +1 -0
  10. package/dist/components/json-schema-form/oauth/oauth-connect.d.ts +26 -0
  11. package/dist/components/json-schema-form/oauth/oauth-widget.d.ts +9 -0
  12. package/dist/components/json-schema-form/oauth/oauth-widget.test.d.ts +1 -0
  13. package/dist/components/json-schema-form/oauth/parse-oauth-options.d.ts +9 -0
  14. package/dist/components/json-schema-form/oauth/parse-oauth-options.test.d.ts +1 -0
  15. package/dist/components/json-schema-form/oauth/resolve-oauth-value.d.ts +8 -0
  16. package/dist/components/json-schema-form/oauth/resolve-oauth-value.test.d.ts +1 -0
  17. package/dist/components/json-schema-form/oauth/types.d.ts +78 -0
  18. package/dist/components/json-schema-form/oauth/use-oauth-flow.d.ts +12 -0
  19. package/dist/fcode-form.cjs.js +65 -65
  20. package/dist/fcode-form.cjs.js.map +1 -1
  21. package/dist/fcode-form.es.js +6575 -6178
  22. package/dist/fcode-form.es.js.map +1 -1
  23. package/dist/fcode-form.umd.js +79 -79
  24. package/dist/fcode-form.umd.js.map +1 -1
  25. package/dist/hooks/use-form-specs.d.ts +7 -0
  26. package/dist/index.d.ts +4 -1
  27. package/dist/services/fcode.d.ts +1 -1
  28. package/dist/styles.css +32 -0
  29. package/dist/types.d.ts +5 -0
  30. package/dist/utils/index.d.ts +1 -0
  31. package/dist/utils/is-http-url.d.ts +7 -0
  32. package/dist/utils/is-http-url.test.d.ts +1 -0
  33. package/dist/utils/oauth-popup.d.ts +30 -0
  34. package/dist/utils/oauth-popup.test.d.ts +1 -0
  35. package/package.json +1 -1
@@ -1,7 +1,14 @@
1
1
  import { FormOptions, FormSpecs } from '../types';
2
2
  declare const useFormSpecs: ({ hostUrl, headers, team, processId, processVersion, locale, }: FormOptions) => {
3
3
  loading: boolean;
4
+ /** A `reload()` is in flight; the previous specs stay available meanwhile. */
5
+ reloading: boolean;
4
6
  formSpecs: FormSpecs | undefined;
5
7
  error: unknown;
8
+ /**
9
+ * Refetches the specs bypassing the cache, keeping the current form on
10
+ * screen. A failed reload keeps the current specs too and sets no `error`.
11
+ */
12
+ reload: () => void;
6
13
  };
7
14
  export default useFormSpecs;
package/dist/index.d.ts CHANGED
@@ -2,6 +2,9 @@ import { FcodeForm } from './components/fcode-form';
2
2
  import { default as FcodeJsonSchemaForm } from './components/json-schema-form/fcode-json-schema-form';
3
3
  import { processFormSpecs } from './utils/process-form-specs';
4
4
  import { buildId } from './utils';
5
- export { FcodeForm, FcodeJsonSchemaForm, processFormSpecs, buildId };
5
+ import { resolveErrorMessage } from './components/fcode-form/fcode-form.utils';
6
+ export { FcodeForm, FcodeJsonSchemaForm, processFormSpecs, buildId, resolveErrorMessage, };
7
+ export type { RedirectConfig } from './types';
6
8
  export type { FcodeRjsfTheme, MultistepThemeComponents, StepBackButtonProps, StepsNavigationItem, StepsNavigationProps, } from './components/json-schema-form/multistep';
9
+ export type { FcodeFormContext, OauthCompletionMessage, OauthConnectControlProps, OauthConnectStatus, OauthOnComplete, OauthThemeComponents, } from './components/json-schema-form/oauth';
7
10
  export default FcodeForm;
@@ -1,3 +1,3 @@
1
1
  import { SubmitFormParams, SubmitFormResponse, FetchFormSpecsParams } from '../types';
2
- export declare const fetchFormSpecs: ({ hostUrl, headers, team, processId, processVersion, locale, }: FetchFormSpecsParams) => Promise<any>;
2
+ export declare const fetchFormSpecs: ({ hostUrl, headers, team, processId, processVersion, locale, cache, }: FetchFormSpecsParams) => Promise<any>;
3
3
  export declare const submitForm: ({ hostUrl, headers, team, processId, processVersion, async, locale, formData, }: SubmitFormParams) => Promise<SubmitFormResponse>;
package/dist/styles.css CHANGED
@@ -1025,6 +1025,38 @@ input[type='number'] {
1025
1025
  border-radius: 0.2rem;
1026
1026
  }
1027
1027
 
1028
+ /* oauth connect control */
1029
+
1030
+ .fcode-form .fcode-oauth {
1031
+ display: flex;
1032
+ flex-wrap: wrap;
1033
+ align-items: center;
1034
+ gap: 0.75rem;
1035
+ }
1036
+
1037
+ .fcode-form .fcode-oauth-button {
1038
+ gap: 0.375rem;
1039
+ }
1040
+
1041
+ .fcode-form .fcode-oauth-button.is-pending {
1042
+ cursor: progress;
1043
+ }
1044
+
1045
+ .fcode-form .fcode-oauth-button.is-connected {
1046
+ color: var(--ycf-base-text-color);
1047
+ border-color: var(--ycf-base-border-color);
1048
+ }
1049
+
1050
+ .fcode-form .fcode-oauth-error {
1051
+ flex-basis: 100%;
1052
+ margin: 0;
1053
+ font-size: 0.875rem;
1054
+ }
1055
+
1056
+ .fcode-form .fcode-oauth-field .fcode-oauth {
1057
+ margin-top: 0.5rem;
1058
+ }
1059
+
1028
1060
  /* form control */
1029
1061
 
1030
1062
  .fcode-form .form-control {
package/dist/types.d.ts CHANGED
@@ -86,6 +86,11 @@ export interface FetchFormSpecsParams {
86
86
  processId: string;
87
87
  processVersion?: string;
88
88
  locale?: string;
89
+ /**
90
+ * Fetch cache mode. Defaults to `force-cache`; `reload` when the form asks
91
+ * to be re-rendered after an OAuth flow, so the `preRenderProcess` runs again.
92
+ */
93
+ cache?: RequestCache;
89
94
  }
90
95
  export interface SubmitFormParams {
91
96
  hostUrl: string;
@@ -1,3 +1,4 @@
1
1
  export { buildProcessUrl } from './build-process-url';
2
2
  export { buildId } from './build-id';
3
3
  export { isValidURL } from './is-valid-url';
4
+ export { isHttpUrl } from './is-http-url';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Whether a value is an absolute `http:`/`https:` URL. Unlike `isValidURL`'s
3
+ * regex, this accepts everything the URL standard does — `:` in a `scope`,
4
+ * percent-encoded `redirect_uri`s — while still refusing `javascript:`,
5
+ * `data:` and relative paths.
6
+ */
7
+ export declare const isHttpUrl: (value: unknown) => value is string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ import { OauthCompletionMessage, OauthResult } from '../components/json-schema-form/oauth/types';
2
+ export interface OpenOauthPopupOptions {
3
+ url: string;
4
+ /** The window name; re-opening with the same name reuses the popup. */
5
+ name: string;
6
+ width: number;
7
+ height: number;
8
+ /** Milliseconds between the completion message and closing the popup. */
9
+ closeDelay: number;
10
+ /** How often to check whether the user closed the popup. */
11
+ pollInterval?: number;
12
+ onResult: (result: OauthResult) => void;
13
+ }
14
+ export interface OauthPopupHandle {
15
+ focus: () => void;
16
+ /** Stops listening without closing the popup (component unmount). */
17
+ dispose: () => void;
18
+ }
19
+ /** Whether `data` is the payload `oauth-callback.html` posts. */
20
+ export declare const isOauthCompletionMessage: (data: unknown) => data is OauthCompletionMessage;
21
+ /**
22
+ * Opens the authorization URL in a popup and reports how it ended, once:
23
+ * `success`/`error` when the callback page posts its completion message,
24
+ * `cancelled` when the popup closes without one, `blocked` when the browser
25
+ * refused to open it. Only messages coming from that very popup are accepted.
26
+ * After a completion message the popup is closed once `closeDelay` elapses.
27
+ *
28
+ * Must be called synchronously from a user gesture, or popup blockers step in.
29
+ */
30
+ export declare const openOauthPopup: ({ url, name, width, height, closeDelay, pollInterval, onResult, }: OpenOauthPopupOptions) => OauthPopupHandle | null;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorialco/fcode-react-forms",
3
- "version": "3.2.0",
3
+ "version": "3.4.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/",