@wise/dynamic-flow-client 3.5.2 → 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.
Files changed (23) hide show
  1. package/build/main.js +7906 -7664
  2. package/build/main.min.js +1 -1
  3. package/build/main.mjs +7801 -7559
  4. package/build/types/legacy/layout/search/useSearch.d.ts +10 -0
  5. package/build/types/legacy/test-utils/legacy-utils.d.ts +3 -2
  6. package/build/types/revamp/domain/components/StepDomainComponent.d.ts +8 -4
  7. package/build/types/revamp/domain/features/events.d.ts +2 -2
  8. package/build/types/revamp/domain/features/polling/getStepPolling.d.ts +12 -0
  9. package/build/types/revamp/domain/mappers/layout/buttonLayoutToComponent.d.ts +1 -1
  10. package/build/types/revamp/domain/mappers/layout/decisionLayoutToComponent.d.ts +1 -1
  11. package/build/types/revamp/domain/mappers/mapStepToComponent.d.ts +4 -3
  12. package/build/types/revamp/domain/mappers/utils/inlineAction.d.ts +2 -0
  13. package/build/types/revamp/flow/response-utils.d.ts +1 -0
  14. package/build/types/revamp/renderers/step/StepRendererContext.d.ts +12 -0
  15. package/build/types/revamp/renderers/stepComponentToProps.d.ts +1 -1
  16. package/build/types/revamp/renderers/types.d.ts +5 -2
  17. package/build/types/revamp/wise/renderers/SearchRenderer/BlockSearchRendererComponent.d.ts +7 -0
  18. package/build/types/revamp/wise/renderers/SearchRenderer/ErrorResult.d.ts +4 -0
  19. package/build/types/revamp/wise/renderers/SearchRenderer/InlineSearchRendererComponent.d.ts +3 -0
  20. package/build/types/revamp/wise/renderers/SearchRenderer/SearchRenderer.d.ts +3 -0
  21. package/package.json +3 -3
  22. package/build/types/revamp/renderers/LoadingContext.d.ts +0 -9
  23. package/build/types/revamp/wise/renderers/SearchRenderer.d.ts +0 -15
@@ -1,4 +1,14 @@
1
1
  import type { SearchConfig, SearchResult } from '@wise/dynamic-flow-types';
2
+ export type SearchState = {
3
+ status: 'idle';
4
+ } | {
5
+ status: 'loading';
6
+ } | {
7
+ status: 'success';
8
+ results: SearchResult[];
9
+ } | {
10
+ status: 'error';
11
+ };
2
12
  export declare const useSearch: (defaultSearchConfig: SearchConfig) => {
3
13
  status: "success" | "loading" | "error" | "idle";
4
14
  results: SearchResult[];
@@ -1,13 +1,14 @@
1
1
  import { type ReactWrapper } from 'enzyme';
2
2
  import type { ReactNode } from 'react';
3
3
  import type { EventHandler, LogEventHandler } from '../dynamic-flow-types';
4
+ import type { ProviderProps } from '@transferwise/components';
4
5
  declare const getMockFetchPromise: (status: number, jsonFn: () => void, delay: number, signal?: AbortSignal | null) => Promise<Response>;
5
6
  declare const wait: (t: number) => Promise<unknown>;
6
- declare function mountWithProviders(component: ReactNode, locale?: string, messages?: Record<string, unknown>, baseUrl?: string, onEvent?: EventHandler, onLog?: LogEventHandler): ReactWrapper;
7
+ declare function mountWithProviders(component: ReactNode, locale?: string, messages?: ProviderProps['i18n']['messages'], baseUrl?: string, onEvent?: EventHandler, onLog?: LogEventHandler): ReactWrapper;
7
8
  declare function mountWithOptions({ component, locale, messages, baseUrl, onEvent, onLog, }: {
8
9
  component: ReactNode;
9
10
  locale?: string;
10
- messages?: Record<string, unknown>;
11
+ messages?: ProviderProps['i18n']['messages'];
11
12
  baseUrl?: string;
12
13
  onEvent?: EventHandler;
13
14
  onLog?: LogEventHandler;
@@ -1,15 +1,19 @@
1
1
  import type { BaseComponent, DomainComponent, LoadingState, LocalValue, UpdateComponent } from '../types';
2
- import type { External } from '@wise/dynamic-flow-types/build/next/feature/External';
2
+ import type { Step } from '@wise/dynamic-flow-types/build/next';
3
+ import type { AnalyticsEventDispatcher } from '../features/events';
4
+ import type { StepPolling } from '../features/polling/getStepPolling';
3
5
  export type StepDomainComponent = BaseComponent & {
4
6
  type: 'step';
5
7
  components: DomainComponent[];
6
- external?: External;
8
+ external?: Step['external'];
7
9
  loadingState: LoadingState;
8
10
  setLoadingState: (loadingState: LoadingState) => void;
9
11
  getChildren: () => DomainComponent[];
10
12
  getLocalValue: () => LocalValue;
13
+ stop: () => void;
14
+ trackEvent: AnalyticsEventDispatcher<string>;
11
15
  };
12
- export declare const createStepComponent: (stepProps: Pick<StepDomainComponent, "external" | "components" | "loadingState" | "uid"> & {
16
+ export declare const createStepComponent: (stepProps: Pick<StepDomainComponent, "external" | "components" | "loadingState" | "uid" | "trackEvent"> & {
17
+ stepPolling?: StepPolling | undefined;
13
18
  updateComponent: UpdateComponent;
14
19
  }) => StepDomainComponent;
15
- export declare const createEmptyStepComponent: (updateComponent: UpdateComponent) => StepDomainComponent;
@@ -1,6 +1,6 @@
1
1
  export type AnalyticsEventHandler = (eventName: string, properties?: Record<string, unknown>) => void;
2
- export type AnalyticsEventDispatcher = (eventName: EventName, properties?: Record<string, unknown>) => void;
3
- export type EventName = 'Initiated' | 'Succeeded' | 'Failed' | 'Step Shown' | 'Action Triggered' | 'Action Succeeded' | 'Action Aborted' | 'Action Failed' | 'Refresh Triggered' | 'Refresh Succeeded' | 'Refresh Aborted' | 'Refresh Failed' | 'OneOf Selected' | 'PersistAsync Triggered' | 'PersistAsync Succeeded' | 'PersistAsync Failed' | 'ValidationAsync Triggered' | 'ValidationAsync Succeeded' | 'ValidationAsync Failed' | 'Search Started' | 'Search Result Selected';
2
+ export type AnalyticsEventDispatcher<E extends string = EventName> = (eventName: E, properties?: Record<string, unknown>) => void;
3
+ export type EventName = 'Initiated' | 'Succeeded' | 'Failed' | 'Step Shown' | 'Action Triggered' | 'Action Succeeded' | 'Action Aborted' | 'Action Failed' | 'Refresh Triggered' | 'Refresh Succeeded' | 'Refresh Aborted' | 'Refresh Failed' | 'OneOf Selected' | 'PersistAsync Triggered' | 'PersistAsync Succeeded' | 'PersistAsync Failed' | 'ValidationAsync Triggered' | 'ValidationAsync Succeeded' | 'ValidationAsync Failed';
4
4
  export type LogLevel = 'info' | 'warning' | 'error';
5
5
  export type LoggingEventHandler = (level: LogLevel, message: string, extra: Record<string, unknown>) => void;
6
6
  export type LoggingEventDispatcher = (level: LogLevel, message: string, extra?: Record<string, unknown>) => void;
@@ -0,0 +1,12 @@
1
+ import type { Polling } from '@wise/dynamic-flow-types/build/next';
2
+ import type { HttpClient } from '../../../types';
3
+ import type { OnAction } from '../../types';
4
+ export type StepPollingProps = {
5
+ httpClient: HttpClient;
6
+ pollingConfig: Polling;
7
+ onAction: OnAction;
8
+ };
9
+ export type StepPolling = {
10
+ stop: () => void;
11
+ };
12
+ export declare const getStepPolling: ({ httpClient, pollingConfig, onAction, }: StepPollingProps) => StepPolling;
@@ -1,3 +1,3 @@
1
1
  import type { ButtonLayout } from '@wise/dynamic-flow-types/build/next';
2
2
  import type { MapperProps } from '../schema/types';
3
- export declare const buttonLayoutToComponent: (uid: string, { action, context, control, disabled, margin, pinOrder, size, title }: ButtonLayout, { onAction, step }: MapperProps) => import("../../components/ButtonComponent").ButtonComponent;
3
+ export declare const buttonLayoutToComponent: (uid: string, button: ButtonLayout, { onAction, step }: MapperProps) => import("../../components/ButtonComponent").ButtonComponent;
@@ -1,3 +1,3 @@
1
1
  import type { DecisionLayout } from '@wise/dynamic-flow-types/build/next';
2
2
  import type { MapperProps } from '../schema/types';
3
- export declare const decisionLayoutToComponent: (uid: string, { control, margin, options }: DecisionLayout, { onAction }: MapperProps) => import("../../components/DecisionComponent").DecisionComponent;
3
+ export declare const decisionLayoutToComponent: (uid: string, { control, margin, options }: DecisionLayout, { onAction, step }: MapperProps) => import("../../components/DecisionComponent").DecisionComponent;
@@ -1,8 +1,9 @@
1
+ import type { AnalyticsEventDispatcher } from '../features/events';
1
2
  import type { LoadingState } from '../types';
2
3
  import type { MapperProps } from './schema/types';
3
- type MapStepToComponentProps = MapperProps & {
4
+ export type StepMapperProps = Omit<MapperProps, 'trackEvent'> & {
4
5
  displayStepTitle: boolean;
5
6
  loadingState: LoadingState;
7
+ trackEvent: AnalyticsEventDispatcher<string>;
6
8
  };
7
- export declare const mapStepToComponent: ({ loadingState, displayStepTitle, ...mapperProps }: MapStepToComponentProps) => import("../components/StepDomainComponent").StepDomainComponent;
8
- export {};
9
+ export declare const mapStepToComponent: ({ loadingState, displayStepTitle, trackEvent, ...restProps }: StepMapperProps) => import("../components/StepDomainComponent").StepDomainComponent;
@@ -0,0 +1,2 @@
1
+ import type { Action } from '@wise/dynamic-flow-types/build/next';
2
+ export declare const inlineAction: (action: Action, stepActions?: Action[]) => Action;
@@ -1,6 +1,7 @@
1
1
  import type { ActionResponseBody, ErrorResponseBody, JsonElement, Step } from '@wise/dynamic-flow-types/build/next';
2
2
  export declare const assertResponseIsValid: (response: unknown) => void;
3
3
  export declare const parseResponseBodyAsJsonElement: (response: Response) => Promise<JsonElement>;
4
+ export declare function isActionResponseBody(body: unknown): body is ActionResponseBody;
4
5
  export declare function assertActionResponseBody(body: unknown): asserts body is ActionResponseBody;
5
6
  export declare function isErrorResponseBody(body: unknown): body is ErrorResponseBody;
6
7
  export declare function assertErrorResponseBody(body: unknown): asserts body is ErrorResponseBody;
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import type { AnalyticsEventDispatcher } from '../../domain/features/events';
3
+ import type { LoadingState } from '../types';
4
+ export declare const StepRendererContextProvider: import("react").Provider<{
5
+ loadingState: LoadingState;
6
+ trackEvent: AnalyticsEventDispatcher<string>;
7
+ }>;
8
+ export declare const useLoadingContext: () => {
9
+ loadingState: LoadingState;
10
+ isLoading: boolean;
11
+ };
12
+ export declare const useTrackEvent: () => AnalyticsEventDispatcher<string>;
@@ -1,4 +1,4 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { StepDomainComponent } from '../domain/components/StepDomainComponent';
3
3
  import type { StepRendererProps } from './types';
4
- export declare const stepComponentToProps: ({ external, loadingState }: StepDomainComponent, children: ReactNode) => StepRendererProps;
4
+ export declare const stepComponentToProps: ({ external, loadingState, trackEvent }: StepDomainComponent, children: ReactNode) => StepRendererProps;
@@ -1,8 +1,9 @@
1
- import type { Margin as DFMargin, Size as DFSize, SearchResult as SearchResultSpec, Icon as DFIcon } from '@wise/dynamic-flow-types/build/next';
1
+ import type { Icon as DFIcon, Margin as DFMargin, Size as DFSize, SearchResult as SearchResultSpec } from '@wise/dynamic-flow-types/build/next';
2
2
  import type { ReactNode } from 'react';
3
3
  import type { DecisionOption as DomainDecisionOption } from '../domain/components/DecisionComponent';
4
4
  import type { InstructionItem as DomainInstructionItem } from '../domain/components/InstructionsComponent';
5
5
  import type { ReviewCallToAction as DomainReviewCallToAction, ReviewField as DomainReviewField } from '../domain/components/ReviewComponent';
6
+ import type { AnalyticsEventDispatcher } from '../domain/features/events';
6
7
  import type { CoreContainerRendererProps } from './CoreContainerRenderer';
7
8
  export type Align = 'start' | 'center' | 'end';
8
9
  export type Bias = 'none' | 'start' | 'end';
@@ -28,6 +29,7 @@ export type StepRendererProps = {
28
29
  url: string;
29
30
  };
30
31
  loadingState: LoadingState;
32
+ trackEvent: AnalyticsEventDispatcher<string>;
31
33
  children: ReactNode;
32
34
  };
33
35
  export type AlertRendererProps = {
@@ -170,7 +172,8 @@ export type ResultsSearchState = {
170
172
  type: 'results';
171
173
  results: SearchResult[];
172
174
  };
173
- export type SearchResult = Pick<SearchResultSpec, 'description' | 'icon' | 'image' | 'title'> & {
175
+ export type SearchResult = Pick<SearchResultSpec, 'description' | 'icon' | 'image' | 'title' | 'type'> & {
176
+ id?: string;
174
177
  onClick: () => void;
175
178
  };
176
179
  export type StatusListRendererProps = {
@@ -0,0 +1,7 @@
1
+ import type { ResultsSearchState, SearchRendererProps } from '../../../renderers/types';
2
+ declare function BlockSearchRendererComponent({ id, isLoading, margin, onChange, query, state, title, }: SearchRendererProps): JSX.Element;
3
+ export declare function SearchResults({ state, }: {
4
+ state: ResultsSearchState;
5
+ onChange: (query: string) => void;
6
+ }): JSX.Element;
7
+ export default BlockSearchRendererComponent;
@@ -0,0 +1,4 @@
1
+ import type { ErrorSearchState } from '../../../renderers/types';
2
+ export declare function ErrorResult({ state }: {
3
+ state: ErrorSearchState;
4
+ }): JSX.Element;
@@ -0,0 +1,3 @@
1
+ import type { SearchRendererProps } from '../../../renderers/types';
2
+ declare function InlineSearchRenderer({ id, isLoading, margin, onChange, state, title, }: SearchRendererProps): JSX.Element;
3
+ export default InlineSearchRenderer;
@@ -0,0 +1,3 @@
1
+ import type { Renderer, SearchRendererProps } from '../../../renderers/types';
2
+ declare const SearchRenderer: Renderer<SearchRendererProps>;
3
+ export default SearchRenderer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-client",
3
- "version": "3.5.2",
3
+ "version": "3.6.0",
4
4
  "description": "Dynamic Flow web client",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./build/main.min.js",
@@ -40,7 +40,7 @@
40
40
  "@testing-library/react": "14.3.0",
41
41
  "@testing-library/react-hooks": "8.0.1",
42
42
  "@testing-library/user-event": "14.5.2",
43
- "@transferwise/components": "46.25.0",
43
+ "@transferwise/components": "46.26.2",
44
44
  "@transferwise/formatting": "^2.13.0",
45
45
  "@transferwise/icons": "3.13.0",
46
46
  "@transferwise/neptune-css": "14.9.6",
@@ -92,7 +92,7 @@
92
92
  "classnames": "2.5.1",
93
93
  "react-webcam": "^7.2.0",
94
94
  "screenfull": "^5.2.0",
95
- "@wise/dynamic-flow-types": "2.12.1"
95
+ "@wise/dynamic-flow-types": "2.13.0"
96
96
  },
97
97
  "scripts": {
98
98
  "dev": "storybook dev -p 3003",
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import type { LoadingState } from './types';
3
- export declare const LoadingContextProvider: import("react").Provider<{
4
- loadingState: LoadingState;
5
- }>;
6
- export declare const useLoadingContext: () => {
7
- loadingState: LoadingState;
8
- isLoading: boolean;
9
- };
@@ -1,15 +0,0 @@
1
- import type { ErrorSearchState, Renderer, ResultsSearchState, SearchRendererProps } from '../../renderers/types';
2
- declare const SearchRenderer: Renderer<SearchRendererProps>;
3
- export declare function SearchInput({ id, query, onChange, }: {
4
- id: string;
5
- query: string;
6
- onChange: (query: string) => void;
7
- }): JSX.Element;
8
- export declare function ErrorResult({ state }: {
9
- state: ErrorSearchState;
10
- }): JSX.Element;
11
- export declare function SearchResults({ state, }: {
12
- state: ResultsSearchState;
13
- onChange: (query: string) => void;
14
- }): JSX.Element;
15
- export default SearchRenderer;