@wise/dynamic-flow-client 1.0.2 → 1.2.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 (27) hide show
  1. package/build/i18n/pl.json +2 -2
  2. package/build/i18n/zh.json +5 -5
  3. package/build/main.js +880 -743
  4. package/build/main.min.js +3 -3
  5. package/build/types/common/utils/step-utils.d.ts +1 -5
  6. package/build/types/dynamicFlow/utils/responseParsers/response-parsers.d.ts +1 -1
  7. package/build/types/dynamicFlow/utils/useDebouncedRefresh/useDebouncedRefresh.d.ts +3 -3
  8. package/build/types/dynamicFlow/utils/useLoader.d.ts +1 -1
  9. package/build/types/fixtures/components/decision-flags.d.ts +3 -0
  10. package/build/types/fixtures/components/decision-icons.d.ts +3 -0
  11. package/build/types/fixtures/components/index.d.ts +2 -0
  12. package/build/types/fixtures/index.d.ts +4 -0
  13. package/build/types/fixtures/schemas/all-of.d.ts +3 -0
  14. package/build/types/fixtures/schemas/boolean.d.ts +3 -0
  15. package/build/types/fixtures/schemas/index.d.ts +2 -0
  16. package/build/types/jsonSchemaForm/schemaFormControl/utils/mapping-utils.d.ts +10 -14
  17. package/build/types/layout/button/utils.d.ts +5 -0
  18. package/build/types/layout/icon/DynamicIcon.d.ts +2 -2
  19. package/build/types/layout/icon/FlagIcon.d.ts +7 -0
  20. package/build/types/layout/icon/NamedIcon.d.ts +6 -0
  21. package/build/types/layout/index.d.ts +1 -1
  22. package/build/types/layout/markdown/DynamicMarkdown.d.ts +10 -0
  23. package/build/types/types/specification/LayoutComponent.d.ts +11 -1
  24. package/build/types/types/specification/Step.d.ts +9 -26
  25. package/package.json +3 -2
  26. package/build/types/jsonSchemaForm/schemaFormControl/utils/currency-utils.d.ts +0 -3
  27. package/build/types/layout/info/DynamicInfo.d.ts +0 -6
@@ -1,7 +1,3 @@
1
1
  import { Schema, Step } from '../../types';
2
- export declare const stepType: {
3
- LAYOUT: string;
4
- CAMERA: string;
5
- };
2
+ export declare const isCameraStep: (step: Step) => boolean;
6
3
  export declare const filterHiddenSchemas: (schemas: Schema[]) => Schema[];
7
- export declare const getStepType: (step: Step) => string;
@@ -13,5 +13,5 @@ type ParsedBody = {
13
13
  };
14
14
  export declare const parseFetchResponse: (response: Response) => Promise<ParsedBody>;
15
15
  export declare const parseErrorResponse: (response: Response) => Promise<ErrorResponseBody>;
16
- export declare const parseExitResponse: (response: Response) => Promise<Parameters<DynamicFlowProps['onCompletion']>[0]>;
16
+ export declare const getJsonObjectOrNull: (response: Response) => Promise<Parameters<DynamicFlowProps['onCompletion']>[0]>;
17
17
  export {};
@@ -1,5 +1,5 @@
1
- import { Action, Schema } from '../../../types';
1
+ import { Schema } from '../../../types';
2
2
  import { ETag } from '../../DynamicFlowTypes';
3
- type FetchRefresh = (action: Action, data: unknown, etag: ETag | undefined) => Promise<void | null>;
4
- export declare function useDebouncedRefresh(fetchRefresh: FetchRefresh): (action: Action, data: unknown, etag: ETag | undefined, schema: Schema) => void;
3
+ type FetchRefresh = (url: string, data: unknown, etag: ETag | undefined) => Promise<void | null>;
4
+ export declare function useDebouncedRefresh(fetchRefresh: FetchRefresh): (url: string, data: unknown, etag: ETag | undefined, schema: Schema) => void;
5
5
  export {};
@@ -2,7 +2,7 @@
2
2
  import { DynamicFlowProps } from '../DynamicFlowTypes';
3
3
  type LoadingState = 'idle' | 'initial' | 'refresh' | 'submission';
4
4
  export declare function useLoader(loaderConfig: DynamicFlowProps['loaderConfig'], initialState: LoadingState): {
5
- loadingState: "initial" | "idle" | "refresh" | "submission";
5
+ isLoading: boolean;
6
6
  setLoadingState: import("react").Dispatch<import("react").SetStateAction<"initial" | "idle" | "refresh" | "submission">>;
7
7
  loader: JSX.Element | null;
8
8
  };
@@ -0,0 +1,3 @@
1
+ import { FormStep } from '../../types';
2
+ declare const step: FormStep;
3
+ export default step;
@@ -0,0 +1,3 @@
1
+ import { FormStep } from '../../types';
2
+ declare const step: FormStep;
3
+ export default step;
@@ -4,6 +4,8 @@ export { default as button } from './button';
4
4
  export { default as columns } from './columns';
5
5
  export { default as copyable } from './copyable';
6
6
  export { default as decision } from './decision';
7
+ export { default as decisionFlags } from './decision-flags';
8
+ export { default as decisionIcons } from './decision-icons';
7
9
  export { default as heading } from './heading';
8
10
  export { default as image } from './image';
9
11
  export { default as info } from './info';
@@ -10,6 +10,8 @@ export declare const fixtures: {
10
10
  numberAndInteger: import("../types").FormStep;
11
11
  oneOf: import("../types").FormStep;
12
12
  stringFormats: import("../types").FormStep;
13
+ boolean: import("../types").FormStep;
14
+ allOf: import("../types").FormStep;
13
15
  actionResponse: import("../types").FormStep;
14
16
  external: import("../types").FormStep;
15
17
  persistAsync: import("../types").FormStep;
@@ -26,6 +28,8 @@ export declare const fixtures: {
26
28
  columns: import("../types").FormStep;
27
29
  copyable: import("../types").FormStep;
28
30
  decision: import("../types").FormStep;
31
+ decisionFlags: import("../types").FormStep;
32
+ decisionIcons: import("../types").FormStep;
29
33
  heading: import("../types").FormStep;
30
34
  image: import("../types").FormStep;
31
35
  info: import("../types").FormStep;
@@ -0,0 +1,3 @@
1
+ import { FormStep } from '../../types';
2
+ declare const step: FormStep;
3
+ export default step;
@@ -0,0 +1,3 @@
1
+ import { FormStep } from '../../types';
2
+ declare const step: FormStep;
3
+ export default step;
@@ -2,3 +2,5 @@ export { default as simpleForm } from './basic-form';
2
2
  export { default as numberAndInteger } from './number-and-integer';
3
3
  export { default as oneOf } from './one-of';
4
4
  export { default as stringFormats } from './string-formats';
5
+ export { default as boolean } from './boolean';
6
+ export { default as allOf } from './all-of';
@@ -1,13 +1,13 @@
1
1
  import { Icon, Image, Schema } from '../../../types';
2
- export declare const mapConstSchemaToOption: (schema: Schema, controlType?: string) => RadioOption | SelectOption;
3
- export type RadioOption = {
2
+ declare const mapConstSchemaToOption: <ControlType extends string>(schema: Schema, controlType?: ControlType | undefined) => ControlType extends "select" ? SelectOption : RadioOption;
3
+ type RadioOption = {
4
4
  disabled?: boolean | undefined;
5
5
  avatar?: JSX.Element | undefined;
6
6
  currency?: string | undefined;
7
7
  label: string;
8
8
  value: string;
9
9
  };
10
- export type SelectOption = {
10
+ type SelectOption = {
11
11
  searchStrings?: string[];
12
12
  disabled?: boolean | undefined;
13
13
  icon?: JSX.Element | undefined;
@@ -15,20 +15,16 @@ export type SelectOption = {
15
15
  label: string;
16
16
  value: string;
17
17
  };
18
- export declare const mapImage: (image?: Image) => {
19
- icon: JSX.Element;
20
- } | null;
21
- export declare const mapIcon: (icon?: Icon) => {
22
- icon: JSX.Element;
23
- } | null;
24
- export declare const mapIconToAvatar: (icon?: Icon) => {
25
- avatar: JSX.Element;
26
- } | null;
27
- export declare const mapAvatar: (image?: Image) => {
18
+ declare const getAvatarPropertyForRadioOption: ({ image, icon }: {
19
+ image?: Image | undefined;
20
+ icon?: Icon | undefined;
21
+ }) => {
28
22
  avatar: JSX.Element;
29
23
  } | null;
30
- export declare const mapSchemaToUploadOptions: ({ accepts }: {
24
+ declare const mapSchemaToUploadOptions: ({ accepts }: {
31
25
  accepts?: string[] | undefined;
32
26
  }) => {
33
27
  usAccept?: string | undefined;
34
28
  };
29
+ export { mapConstSchemaToOption, getAvatarPropertyForRadioOption, mapSchemaToUploadOptions };
30
+ export type { RadioOption, SelectOption };
@@ -0,0 +1,5 @@
1
+ import { ButtonLayout } from '../../types';
2
+ import { Size } from '../../types';
3
+ export declare const getButtonPriority: (component: ButtonLayout) => "primary" | "secondary" | "tertiary";
4
+ export declare const getButtonType: (component: ButtonLayout) => "positive" | "negative" | "accent";
5
+ export declare const getButtonSize: (size: Size | undefined) => "sm" | "md" | "lg";
@@ -1,6 +1,6 @@
1
- type Props = {
1
+ export type Props = {
2
2
  type: string;
3
3
  };
4
- declare const DynamicIcon: ({ type }: Props) => JSX.Element;
4
+ declare const DynamicIcon: ({ type }: Props) => JSX.Element | null;
5
5
  export declare function isValidIconName(name: string): boolean;
6
6
  export default DynamicIcon;
@@ -0,0 +1,7 @@
1
+ type Props = {
2
+ name: string;
3
+ };
4
+ export declare const isFlagIcon: (name: string) => boolean;
5
+ export declare const FlagIcon: ({ name }: Props) => JSX.Element | null;
6
+ export declare const availableCurrencyFlags: string[];
7
+ export {};
@@ -0,0 +1,6 @@
1
+ type Props = {
2
+ name: string;
3
+ };
4
+ export declare const isNamedIcon: (name: string) => boolean;
5
+ export declare const NamedIcon: ({ name }: Props) => JSX.Element | null;
6
+ export {};
@@ -8,7 +8,7 @@ export { default as DynamicExternal } from './external/DynamicExternal';
8
8
  export { default as DynamicForm } from './form/DynamicForm';
9
9
  export { default as DynamicHeading } from './heading/DynamicHeading';
10
10
  export { default as DynamicIcon } from './icon/DynamicIcon';
11
- export { default as DynamicInfo } from './info/DynamicInfo';
11
+ export { DynamicInfo, DynamicMarkdown } from './markdown/DynamicMarkdown';
12
12
  export { default as DynamicImage } from './image/DynamicImage';
13
13
  export { default as DynamicLayout } from './DynamicLayout';
14
14
  export { default as DynamicList } from './list/DynamicList';
@@ -0,0 +1,10 @@
1
+ import { InfoLayout, MarkdownLayout } from '../../types';
2
+ type DynamicMarkdownProps = {
3
+ component: MarkdownLayout;
4
+ };
5
+ export declare const DynamicMarkdown: ({ component }: DynamicMarkdownProps) => JSX.Element;
6
+ type DynamicInfoProps = {
7
+ component: InfoLayout;
8
+ };
9
+ export declare const DynamicInfo: ({ component }: DynamicInfoProps) => JSX.Element;
10
+ export {};
@@ -2,7 +2,7 @@ import { ExternalStepPollingConfiguration } from '../../common/hooks';
2
2
  import { Action } from './Action';
3
3
  import { Schema } from './Schema';
4
4
  import { Margin, Size, Icon, Image, Align, Orientation, Reference, Alert } from './core';
5
- export type LayoutComponent = AlertLayout | BoxLayout | ButtonLayout | ColumnsLayout | DecisionLayout | DividerLayout | ExternalLayout | FormLayout | HeadingLayout | ImageLayout | InfoLayout | ListLayout | LoadingIndicatorLayout | ParagraphLayout | ReviewLayout;
5
+ export type LayoutComponent = AlertLayout | BoxLayout | ButtonLayout | ColumnsLayout | DecisionLayout | DividerLayout | ExternalLayout | FormLayout | HeadingLayout | ImageLayout | InfoLayout | ListLayout | LoadingIndicatorLayout | MarkdownLayout | ParagraphLayout | ReviewLayout;
6
6
  export type AlertLayout = {
7
7
  type: 'alert';
8
8
  } & Alert;
@@ -16,6 +16,10 @@ export type BoxLayout = {
16
16
  export type ButtonLayout = {
17
17
  type: 'button';
18
18
  action: Action | Reference;
19
+ title?: string;
20
+ control?: 'primary' | 'secondary' | 'tertiary';
21
+ context?: 'neutral' | 'positive' | 'negative';
22
+ disabled?: boolean;
19
23
  margin?: Margin;
20
24
  /**
21
25
  * @deprecated Only supported on web client
@@ -104,6 +108,12 @@ export type LoadingIndicatorLayout = {
104
108
  margin?: Margin;
105
109
  size?: Size;
106
110
  };
111
+ export type MarkdownLayout = {
112
+ type: 'markdown';
113
+ content: string;
114
+ margin?: Margin;
115
+ align?: Align;
116
+ };
107
117
  export type ParagraphLayout = {
108
118
  type: 'paragraph';
109
119
  text: string;
@@ -4,11 +4,15 @@ import { LayoutComponent } from './LayoutComponent';
4
4
  import { ObjectModel } from './Model';
5
5
  import { PollingConfiguration } from './Polling';
6
6
  import { Schema } from './Schema';
7
- import { Image, HttpMethod } from './core';
8
- export type Step = FormStep | DecisionStep | ExternalStep | WebStep | FinalStep;
7
+ import { Image } from './core';
8
+ export type Step = FormStep | DecisionStep | ExternalStep | FinalStep;
9
9
  type BaseStep = {
10
+ id?: string;
11
+ /**
12
+ * @deprecated Please use id instead
13
+ */
10
14
  key?: string;
11
- type: string;
15
+ type?: string;
12
16
  title?: string;
13
17
  description?: string;
14
18
  analytics?: Record<string, unknown>;
@@ -27,10 +31,9 @@ type BaseStep = {
27
31
  };
28
32
  };
29
33
  export type FormStep = BaseStep & {
30
- type: 'form';
34
+ type?: 'form';
31
35
  title: string;
32
36
  layout: LayoutComponent[];
33
- actions: Action[];
34
37
  schemas: Schema[];
35
38
  errors?: unknown;
36
39
  };
@@ -59,26 +62,6 @@ export type ExternalStep = BaseStep & {
59
62
  retryTitle?: string;
60
63
  title: string;
61
64
  };
62
- /**
63
- * @deprecated Please use the external feature set instead
64
- */
65
- type WebStep = BaseStep & {
66
- type: 'web';
67
- hideBackButton?: boolean;
68
- initialRequest: {
69
- body?: string;
70
- headers?: Record<string, string>;
71
- method: HttpMethod;
72
- url: string;
73
- };
74
- interceptablePatterns: {
75
- action?: Action;
76
- regexPattern: string;
77
- threshold?: number;
78
- type: 'submit' | 'cancel' | 'redirect' | 'abort-load' | 'log';
79
- }[];
80
- javaScriptMessageHandler?: unknown;
81
- };
82
65
  /**
83
66
  * @deprecated Please use DecisionLayout instead
84
67
  */
@@ -118,7 +101,7 @@ export type LegacyReviewFields = {
118
101
  }>;
119
102
  };
120
103
  export type LegacyFormStep = Step & {
121
- type: 'form';
104
+ type?: 'form';
122
105
  reviewFields?: LegacyReviewFields;
123
106
  schemas?: Schema[];
124
107
  actions?: Action[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-client",
3
- "version": "1.0.2",
3
+ "version": "1.2.0",
4
4
  "description": "Dynamic Flow web client",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./build/main.min.js",
@@ -102,10 +102,11 @@
102
102
  "build:messages-source": "formatjs extract 'src/**/*.messages.{js,ts}' --out-file src/i18n/en.json --format simple && prettier --find-config-path --write src/i18n/*.json",
103
103
  "build:compiled-messages": "mkdir -p build/i18n && cp src/i18n/*.json build/i18n",
104
104
  "test": "npm-run-all test:once test:tz",
105
- "test:once": "jest --config jest.config.js --env=jsdom",
105
+ "test:once": "jest --config jest.config.js --env=jsdom -w 2",
106
106
  "test:coverage": "jest --config jest.config.js --env=jsdom --coverage",
107
107
  "test:tz": "TZ=US/Pacific jest ./src/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.errors.spec.js ./src/formControl/FormControl.spec.js",
108
108
  "test:watch": "pnpm test:once --watch",
109
+ "types": "pnpm tsc",
109
110
  "lint": "npm-run-all lint:ts lint:css",
110
111
  "lint:ts": "eslint 'src/**/*.{js,jsx,ts,tsx}' --quiet",
111
112
  "lint:css": "stylelint './src/**/*.css'",
@@ -1,3 +0,0 @@
1
- export declare function getCurrencyFlag(iconName?: string): {
2
- currency: string;
3
- } | null;
@@ -1,6 +0,0 @@
1
- import { InfoLayout } from '../../types';
2
- type Props = {
3
- component: InfoLayout;
4
- };
5
- declare const DynamicInfo: ({ component }: Props) => JSX.Element;
6
- export default DynamicInfo;