@wise/dynamic-flow-client-internal 3.9.0-experimental-bd037e3 → 3.9.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/README.md +9 -13
- package/build/main.js +8 -2
- package/build/main.min.js +1 -1
- package/build/main.mjs +10 -3
- package/build/types/dynamicFlow/DynamicFlow.d.ts +10 -2
- package/build/types/index.d.ts +2 -4
- package/build/types/stories/DynamicFragment.story.d.ts +6 -0
- package/package.json +4 -4
- package/build/dynamicFlow/DynamicFlow.js +0 -24
- package/build/index.js +0 -4
- package/build/stories/DynamicFlow.story.js +0 -52
- package/build/stories/DynamicFlowWithRef.story.js +0 -102
- package/build/stories/Editable.story.js +0 -70
- package/build/stories/Examples.story.js +0 -20
- package/build/stories/Features.story.js +0 -27
- package/build/stories/VisualTests.story.js +0 -39
- package/build/stories/utils/DynamicFlowSideBySide.js +0 -30
- package/build/stories/utils/fixtureHttpClient.js +0 -119
- package/build/test-utils/NeptuneProviders.js +0 -23
- package/build/test-utils/rtl-utils.js +0 -20
- package/build/types/stories/DynamicFlowWithRef.story.d.ts +0 -8
package/README.md
CHANGED
|
@@ -238,32 +238,28 @@ type LoaderConfig = {
|
|
|
238
238
|
| `initial` | boolean | Whether or not to display the Loader component while loading the initial step. | true |
|
|
239
239
|
| `submission` | boolean | Whether or not to display the Loader component during form submissions. | false |
|
|
240
240
|
|
|
241
|
-
##
|
|
241
|
+
## DynamicFragment
|
|
242
242
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
If you need to extract the submittable data outside of a submission, you can do so by providing us with a ref. This will give you access to two methods: `getValue` and `validate`. For example:
|
|
243
|
+
If you need to get the submittable data outside of a submission, you can use the `DynamicFragment` component. This will give you access to two methods: `getValue` and `validate` via a [ref](https://react.dev/reference/react/useRef). For example:
|
|
246
244
|
|
|
247
245
|
```tsx
|
|
248
|
-
import type {
|
|
249
|
-
import {
|
|
246
|
+
import type { DynamicFragmentController } from '@wise/dynamic-flow-client-internal';
|
|
247
|
+
import { DynamicFragment } from '@wise/dynamic-flow-client-internal';
|
|
250
248
|
import { useRef } from 'react';
|
|
251
249
|
|
|
252
250
|
function DynamicFlowWithRef() {
|
|
253
|
-
const ref = useRef<
|
|
251
|
+
const ref = useRef<DynamicFragmentController>(null);
|
|
254
252
|
|
|
255
253
|
return (
|
|
256
254
|
<>
|
|
257
|
-
<
|
|
255
|
+
<DynamicFragment
|
|
258
256
|
ref={ref}
|
|
259
257
|
flowId={"id"}
|
|
260
258
|
customFetch={fetch}
|
|
261
259
|
initialStep={selectedStep}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
// Value has changed.
|
|
266
|
-
}
|
|
260
|
+
onValueChange={async () => {
|
|
261
|
+
const value = (await ref.current?.getValue()) ?? null);
|
|
262
|
+
console.log('Value changed to', JSON.stringify(value));
|
|
267
263
|
}}
|
|
268
264
|
onCompletion={(error) => console.error(error)}
|
|
269
265
|
onCompletion={() => console.log('Completed')}
|
package/build/main.js
CHANGED
|
@@ -40,6 +40,7 @@ __export(src_exports, {
|
|
|
40
40
|
DynamicFlow: () => DynamicFlowLegacy,
|
|
41
41
|
DynamicFlowLegacy: () => DynamicFlowLegacy,
|
|
42
42
|
DynamicFlowRevamp: () => DynamicFlowRevamp,
|
|
43
|
+
DynamicFragment: () => DynamicFragment,
|
|
43
44
|
JsonSchemaForm: () => import_dynamic_flow_client3.JsonSchemaForm,
|
|
44
45
|
isValidSchema: () => import_dynamic_flow_client3.isValidSchema,
|
|
45
46
|
makeCustomFetch: () => makeCustomFetch,
|
|
@@ -58,10 +59,15 @@ function DynamicFlowLegacy(props) {
|
|
|
58
59
|
const coreProps = __spreadProps(__spreadValues({}, props), { httpClient: customFetch });
|
|
59
60
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dynamic_flow_client.DynamicFlow, __spreadValues({}, coreProps));
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
+
function DynamicFlowRevamp(props) {
|
|
62
63
|
const { customFetch = globalThis.fetch } = props;
|
|
63
64
|
const coreProps = __spreadProps(__spreadValues({}, props), { httpClient: customFetch });
|
|
64
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dynamic_flow_client.DynamicFlowRevamp, __spreadValues({
|
|
65
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dynamic_flow_client.DynamicFlowRevamp, __spreadValues({}, coreProps));
|
|
66
|
+
}
|
|
67
|
+
var DynamicFragment = (0, import_react.forwardRef)(function DynamicFragment2(props, ref) {
|
|
68
|
+
const { customFetch = globalThis.fetch } = props;
|
|
69
|
+
const coreProps = __spreadProps(__spreadValues({}, props), { httpClient: customFetch });
|
|
70
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dynamic_flow_client.DynamicFragmentWise, __spreadProps(__spreadValues({}, coreProps), { ref }));
|
|
65
71
|
});
|
|
66
72
|
|
|
67
73
|
// src/index.ts
|
package/build/main.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty,g=Object.defineProperties,C=Object.getOwnPropertyDescriptor,R=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertyNames,s=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable;var F=(t,o,e)=>o in t?p(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,a=(t,o)=>{for(var e in o||(o={}))w.call(o,e)&&F(t,e,o[e]);if(s)for(var e of s(o))u.call(o,e)&&F(t,e,o[e]);return t},c=(t,o)=>g(t,R(o));var d=(t,o)=>{for(var e in o)p(t,e,{get:o[e],enumerable:!0})},L=(t,o,e,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of v(o))!w.call(t,i)&&i!==e&&p(t,i,{get:()=>o[i],enumerable:!(r=C(o,i))||r.enumerable});return t};var W=t=>L(p({},"__esModule",{value:!0}),t);var I={};d(I,{DynamicFlow:()=>y,DynamicFlowLegacy:()=>y,DynamicFlowRevamp:()=>h,DynamicFragment:()=>P,JsonSchemaForm:()=>m.JsonSchemaForm,isValidSchema:()=>m.isValidSchema,makeCustomFetch:()=>x,translations:()=>m.translations});module.exports=W(I);var f=require("@wise/dynamic-flow-client"),m=require("@wise/dynamic-flow-client");var n=require("@wise/dynamic-flow-client"),D=require("react");var l=require("react/jsx-runtime");function y(t){let{customFetch:o=globalThis.fetch}=t,e=c(a({},t),{httpClient:o});return(0,l.jsx)(n.DynamicFlow,a({},e))}function h(t){let{customFetch:o=globalThis.fetch}=t,e=c(a({},t),{httpClient:o});return(0,l.jsx)(n.DynamicFlowRevamp,a({},e))}var P=(0,D.forwardRef)(function(o,e){let{customFetch:r=globalThis.fetch}=o,i=c(a({},o),{httpClient:r});return(0,l.jsx)(n.DynamicFragmentWise,c(a({},i),{ref:e}))});var x=f.makeHttpClient;
|
package/build/main.mjs
CHANGED
|
@@ -25,7 +25,8 @@ import { translations, JsonSchemaForm, isValidSchema } from "@wise/dynamic-flow-
|
|
|
25
25
|
// src/dynamicFlow/DynamicFlow.tsx
|
|
26
26
|
import {
|
|
27
27
|
DynamicFlowRevamp as DynamicFlowCoreRevamp,
|
|
28
|
-
DynamicFlow as DynamicFlowCoreLegacy
|
|
28
|
+
DynamicFlow as DynamicFlowCoreLegacy,
|
|
29
|
+
DynamicFragmentWise
|
|
29
30
|
} from "@wise/dynamic-flow-client";
|
|
30
31
|
import { forwardRef } from "react";
|
|
31
32
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -34,10 +35,15 @@ function DynamicFlowLegacy(props) {
|
|
|
34
35
|
const coreProps = __spreadProps(__spreadValues({}, props), { httpClient: customFetch });
|
|
35
36
|
return /* @__PURE__ */ jsx(DynamicFlowCoreLegacy, __spreadValues({}, coreProps));
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
+
function DynamicFlowRevamp(props) {
|
|
38
39
|
const { customFetch = globalThis.fetch } = props;
|
|
39
40
|
const coreProps = __spreadProps(__spreadValues({}, props), { httpClient: customFetch });
|
|
40
|
-
return /* @__PURE__ */ jsx(DynamicFlowCoreRevamp, __spreadValues({
|
|
41
|
+
return /* @__PURE__ */ jsx(DynamicFlowCoreRevamp, __spreadValues({}, coreProps));
|
|
42
|
+
}
|
|
43
|
+
var DynamicFragment = forwardRef(function DynamicFragment2(props, ref) {
|
|
44
|
+
const { customFetch = globalThis.fetch } = props;
|
|
45
|
+
const coreProps = __spreadProps(__spreadValues({}, props), { httpClient: customFetch });
|
|
46
|
+
return /* @__PURE__ */ jsx(DynamicFragmentWise, __spreadProps(__spreadValues({}, coreProps), { ref }));
|
|
41
47
|
});
|
|
42
48
|
|
|
43
49
|
// src/index.ts
|
|
@@ -46,6 +52,7 @@ export {
|
|
|
46
52
|
DynamicFlowLegacy as DynamicFlow,
|
|
47
53
|
DynamicFlowLegacy,
|
|
48
54
|
DynamicFlowRevamp,
|
|
55
|
+
DynamicFragment,
|
|
49
56
|
JsonSchemaForm,
|
|
50
57
|
isValidSchema,
|
|
51
58
|
makeCustomFetch,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { type DynamicFlowProps as DynamicFlowCoreLegacyProps, type DynamicFlowRevampProps as DynamicFlowCoreRevampProps, type DynamicFlowRevampPropsWithInitialAction, type DynamicFlowRevampPropsWithInitialStep, type
|
|
2
|
+
import { type DynamicFlowProps as DynamicFlowCoreLegacyProps, type DynamicFlowRevampProps as DynamicFlowCoreRevampProps, type DynamicFlowRevampPropsWithInitialAction, type DynamicFlowRevampPropsWithInitialStep, type DynamicFragmentController } from '@wise/dynamic-flow-client';
|
|
3
3
|
import type { DynamicFlowPropsWithInitialAction, DynamicFlowPropsWithInitialStep } from '@wise/dynamic-flow-client/build/types/legacy/dynamic-flow-types';
|
|
4
4
|
export type DynamicFlowLegacyProps = (Omit<DynamicFlowPropsWithInitialAction, 'httpClient'> | Omit<DynamicFlowPropsWithInitialStep, 'httpClient'>) & {
|
|
5
5
|
customFetch?: DynamicFlowCoreLegacyProps['httpClient'];
|
|
@@ -8,4 +8,12 @@ export type DynamicFlowRevampProps = (Omit<DynamicFlowRevampPropsWithInitialActi
|
|
|
8
8
|
customFetch?: DynamicFlowCoreRevampProps['httpClient'];
|
|
9
9
|
};
|
|
10
10
|
export declare function DynamicFlowLegacy(props: DynamicFlowLegacyProps): JSX.Element;
|
|
11
|
-
export declare
|
|
11
|
+
export declare function DynamicFlowRevamp(props: DynamicFlowRevampProps): JSX.Element;
|
|
12
|
+
/**
|
|
13
|
+
* DynamicFragment is like DynamicFlowRevamp, but it also accepts a ForwardedRef.
|
|
14
|
+
* This ref conforms to the DynamicFragmentController type, containing two functions: `getValue` and `validate`.
|
|
15
|
+
* @experimental This component may be changed in the future without notice.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DynamicFragment: import("react").ForwardRefExoticComponent<(DynamicFlowRevampProps & {
|
|
18
|
+
onValueChange?: (() => void) | undefined;
|
|
19
|
+
}) & import("react").RefAttributes<DynamicFragmentController>>;
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export type { DynamicFlowProps, Step, InitialAction } from '@wise/dynamic-flow-client';
|
|
1
|
+
export type { DynamicFlowProps, Step, InitialAction, DynamicFragmentController, } from '@wise/dynamic-flow-client';
|
|
3
2
|
export { translations, JsonSchemaForm, isValidSchema } from '@wise/dynamic-flow-client';
|
|
4
3
|
export type { DynamicFlowLegacyProps as WiseDynamicFlowProps, DynamicFlowLegacyProps, DynamicFlowRevampProps, } from './dynamicFlow/DynamicFlow';
|
|
5
|
-
export { DynamicFlowLegacy as DynamicFlow, DynamicFlowLegacy, DynamicFlowRevamp, } from './dynamicFlow/DynamicFlow';
|
|
4
|
+
export { DynamicFlowLegacy as DynamicFlow, DynamicFlowLegacy, DynamicFlowRevamp, DynamicFragment, } from './dynamicFlow/DynamicFlow';
|
|
6
5
|
export declare const makeCustomFetch: (baseUrl: string, additionalHeaders?: HeadersInit | undefined) => typeof fetch;
|
|
7
|
-
export type { DynamicFlowController };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
declare function DynamicFragmentStory(): JSX.Element;
|
|
4
|
+
declare const meta: Meta<typeof DynamicFragmentStory>;
|
|
5
|
+
export declare const AllFixtures: StoryObj<typeof DynamicFragmentStory>;
|
|
6
|
+
export default meta;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wise/dynamic-flow-client-internal",
|
|
3
|
-
"version": "3.9.0
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "Dynamic Flow web client for Wise",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./build/main.min.js",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"stylelint-value-no-unknown-custom-properties": "6.0.1",
|
|
73
73
|
"typescript": "5.1.6",
|
|
74
74
|
"webpack": "5.91.0",
|
|
75
|
-
"@wise/dynamic-flow-
|
|
76
|
-
"@wise/dynamic-flow-
|
|
75
|
+
"@wise/dynamic-flow-types": "2.14.0",
|
|
76
|
+
"@wise/dynamic-flow-fixtures": "0.0.1"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"react": "^18",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"react-intl": "^6"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@wise/dynamic-flow-client": "3.9.0
|
|
84
|
+
"@wise/dynamic-flow-client": "3.9.0"
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
87
|
"dev": "storybook dev -p 3005",
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { DynamicFlowRevamp as DynamicFlowCoreRevamp, DynamicFlow as DynamicFlowCoreLegacy, } from '@wise/dynamic-flow-client';
|
|
14
|
-
import { forwardRef } from 'react';
|
|
15
|
-
export function DynamicFlowLegacy(props) {
|
|
16
|
-
var _a = props.customFetch, customFetch = _a === void 0 ? globalThis.fetch : _a;
|
|
17
|
-
var coreProps = __assign(__assign({}, props), { httpClient: customFetch });
|
|
18
|
-
return _jsx(DynamicFlowCoreLegacy, __assign({}, coreProps));
|
|
19
|
-
}
|
|
20
|
-
export var DynamicFlowRevamp = forwardRef(function DynamicFlowRevamp(props, ref) {
|
|
21
|
-
var _a = props.customFetch, customFetch = _a === void 0 ? globalThis.fetch : _a;
|
|
22
|
-
var coreProps = __assign(__assign({}, props), { httpClient: customFetch });
|
|
23
|
-
return _jsx(DynamicFlowCoreRevamp, __assign({ ref: ref }, coreProps));
|
|
24
|
-
});
|
package/build/index.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { makeHttpClient } from '@wise/dynamic-flow-client';
|
|
2
|
-
export { translations, JsonSchemaForm, isValidSchema } from '@wise/dynamic-flow-client';
|
|
3
|
-
export { DynamicFlowLegacy as DynamicFlow, DynamicFlowLegacy, DynamicFlowRevamp, } from './dynamicFlow/DynamicFlow';
|
|
4
|
-
export var makeCustomFetch = makeHttpClient;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { action } from '@storybook/addon-actions';
|
|
14
|
-
import { layouts, features, examples, schemas } from '@wise/dynamic-flow-fixtures';
|
|
15
|
-
import { DynamicFlowLegacy, DynamicFlowRevamp } from '../index';
|
|
16
|
-
import { fixtureHttpClient } from './utils/fixtureHttpClient';
|
|
17
|
-
var fixtures = __assign(__assign(__assign(__assign({}, examples), schemas), layouts), features);
|
|
18
|
-
function DynamicFlowRenderer(_a) {
|
|
19
|
-
var _b = _a.initialStepName, initialStepName = _b === void 0 ? '' : _b, _c = _a.revampEnabled, revampEnabled = _c === void 0 ? false : _c;
|
|
20
|
-
var selectedStep = fixtures[initialStepName] || {};
|
|
21
|
-
var props = {
|
|
22
|
-
flowId: 'storybook',
|
|
23
|
-
customFetch: fixtureHttpClient,
|
|
24
|
-
onCompletion: action('onCompletion'),
|
|
25
|
-
onError: action('onError'),
|
|
26
|
-
onEvent: action('onEvent'),
|
|
27
|
-
onLog: action('onLog'),
|
|
28
|
-
};
|
|
29
|
-
return revampEnabled ? (_jsx(DynamicFlowRevamp, __assign({}, props, { initialAction: { method: 'GET', url: "/steps/".concat(initialStepName) } }), selectedStep.id)) : (_jsx(DynamicFlowLegacy, __assign({}, props, { initialAction: { method: 'GET', url: "/steps/".concat(initialStepName) }, loaderConfig: { size: 'xl', initial: true, submission: false } }), selectedStep.id));
|
|
30
|
-
}
|
|
31
|
-
var meta = {
|
|
32
|
-
title: 'Multi-fixture',
|
|
33
|
-
component: DynamicFlowRenderer,
|
|
34
|
-
};
|
|
35
|
-
export var AllFixtures = {
|
|
36
|
-
argTypes: {
|
|
37
|
-
initialStepName: {
|
|
38
|
-
label: 'Initial Step',
|
|
39
|
-
control: 'select',
|
|
40
|
-
options: Object.keys(fixtures),
|
|
41
|
-
},
|
|
42
|
-
revampEnabled: {
|
|
43
|
-
label: 'Enable revamp',
|
|
44
|
-
control: 'boolean',
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
args: { initialStepName: Object.keys(fixtures)[1], revampEnabled: false },
|
|
48
|
-
parameters: {
|
|
49
|
-
chromatic: { disableSnapshot: true },
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
export default meta;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
|
-
import { action } from '@storybook/addon-actions';
|
|
50
|
-
import { layouts, features, examples, schemas } from '@wise/dynamic-flow-fixtures';
|
|
51
|
-
import { fixtureHttpClient } from './utils/fixtureHttpClient';
|
|
52
|
-
import { useRef } from 'react';
|
|
53
|
-
import { Button } from '@transferwise/components';
|
|
54
|
-
import { DynamicFlowRevamp } from '../dynamicFlow/DynamicFlow';
|
|
55
|
-
var fixtures = __assign(__assign(__assign(__assign({}, examples), schemas), layouts), features);
|
|
56
|
-
function DynamicFlowWithRef(_a) {
|
|
57
|
-
var _this = this;
|
|
58
|
-
var _b = _a.initialStepName, initialStepName = _b === void 0 ? '' : _b;
|
|
59
|
-
var selectedStep = (fixtures[initialStepName] || {});
|
|
60
|
-
var ref = useRef(null);
|
|
61
|
-
var props = {
|
|
62
|
-
flowId: 'storybook',
|
|
63
|
-
customFetch: fixtureHttpClient,
|
|
64
|
-
onCompletion: action('onCompletion'),
|
|
65
|
-
onError: action('onError'),
|
|
66
|
-
onEvent: action('onEvent'),
|
|
67
|
-
onLog: action('onLog'),
|
|
68
|
-
};
|
|
69
|
-
return (_jsxs(_Fragment, { children: [_jsx(DynamicFlowRevamp, __assign({ ref: ref, initialStep: selectedStep }, props)), _jsx(Button, { onClick: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
70
|
-
var _a;
|
|
71
|
-
var _b, _c, _d;
|
|
72
|
-
return __generator(this, function (_e) {
|
|
73
|
-
switch (_e.label) {
|
|
74
|
-
case 0:
|
|
75
|
-
_a = action('getValue');
|
|
76
|
-
return [4 /*yield*/, ((_b = ref.current) === null || _b === void 0 ? void 0 : _b.getValue())];
|
|
77
|
-
case 1:
|
|
78
|
-
_a.apply(void 0, [(_c = (_e.sent())) !== null && _c !== void 0 ? _c : null]);
|
|
79
|
-
action('validate')((_d = ref.current) === null || _d === void 0 ? void 0 : _d.validate());
|
|
80
|
-
return [2 /*return*/];
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}); }, children: "Log value" })] }));
|
|
84
|
-
}
|
|
85
|
-
var meta = {
|
|
86
|
-
title: 'Dynamic Flow With Ref',
|
|
87
|
-
component: DynamicFlowWithRef,
|
|
88
|
-
};
|
|
89
|
-
export var AllFixtures = {
|
|
90
|
-
argTypes: {
|
|
91
|
-
initialStepName: {
|
|
92
|
-
label: 'Initial Step',
|
|
93
|
-
control: 'select',
|
|
94
|
-
options: Object.keys(fixtures),
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
args: { initialStepName: Object.keys(fixtures)[1] },
|
|
98
|
-
parameters: {
|
|
99
|
-
chromatic: { disableSnapshot: true },
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
export default meta;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
-
/* eslint-disable react/forbid-dom-props */
|
|
14
|
-
import { layouts, schemas, examples, features } from '@wise/dynamic-flow-fixtures';
|
|
15
|
-
import { useMemo, useState } from 'react';
|
|
16
|
-
import DynamicFlowSideBySide from './utils/DynamicFlowSideBySide';
|
|
17
|
-
var fixtures = __assign(__assign(__assign(__assign({}, features), schemas), layouts), examples);
|
|
18
|
-
export function Editable(_a) {
|
|
19
|
-
var _b = _a.initialStepName, initialStepName = _b === void 0 ? '' : _b;
|
|
20
|
-
var selectedStep = fixtures[initialStepName] || {};
|
|
21
|
-
var selectedInitialStep = JSON.stringify(selectedStep, null, 2);
|
|
22
|
-
return _jsx(InteractiveDemo, { selectedInitialStep: selectedInitialStep }, selectedInitialStep);
|
|
23
|
-
}
|
|
24
|
-
function InteractiveDemo(_a) {
|
|
25
|
-
var selectedInitialStep = _a.selectedInitialStep;
|
|
26
|
-
var _b = useState(200), initialStatusCode = _b[0], setInitialStatusCode = _b[1];
|
|
27
|
-
var _c = useState(selectedInitialStep), initialStep = _c[0], setInitialStep = _c[1];
|
|
28
|
-
var onTextAreaChange = function (event) {
|
|
29
|
-
setInitialStep(event.target.value);
|
|
30
|
-
};
|
|
31
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { children: [_jsx("h3", { children: "Editable Demo" }), _jsx("p", { children: "You can specify a response status code and body, and DF will load your step below." }), _jsxs("fieldset", { children: [_jsx("label", { htmlFor: "status-code", children: "Response Status code: " }), _jsx(StatusCodeSelect, { id: "status-code", state: [initialStatusCode, setInitialStatusCode] })] }), _jsxs("fieldset", { children: [_jsx("label", { htmlFor: "textarea", children: "Response Body:" }), _jsx(InvalidJsonWarning, { initialStep: initialStep }), _jsx("textarea", { id: "textarea", wrap: "off", rows: 40, style: {
|
|
32
|
-
fontFamily: 'monospace',
|
|
33
|
-
fontSize: '0.9em',
|
|
34
|
-
width: '100%',
|
|
35
|
-
maxHeight: '200px',
|
|
36
|
-
}, value: initialStep, onChange: onTextAreaChange })] })] }), isValidJson(initialStep) ? (_jsx(DynamicFlowSideBySide, { initialStep: JSON.parse(initialStep) }, "".concat(initialStep, "-").concat(initialStatusCode))) : null] }));
|
|
37
|
-
}
|
|
38
|
-
function InvalidJsonWarning(_a) {
|
|
39
|
-
var initialStep = _a.initialStep;
|
|
40
|
-
var validJson = useMemo(function () { return isValidJson(initialStep); }, [initialStep]);
|
|
41
|
-
return !validJson ? (_jsx("p", { children: "\u274C Invalid syntax or missing elements are preventing the JSON code you entered from being parsed." })) : null;
|
|
42
|
-
}
|
|
43
|
-
var isValidJson = function (value) {
|
|
44
|
-
try {
|
|
45
|
-
JSON.parse(value);
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
catch (_a) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
function StatusCodeSelect(_a) {
|
|
53
|
-
var id = _a.id, _b = _a.state, value = _b[0], setValue = _b[1];
|
|
54
|
-
return (_jsxs("select", { id: id, value: value, onChange: function (event) { return setValue(Number.parseInt(event.target.value, 10)); }, children: [_jsx("option", { children: "200" }), _jsx("option", { children: "400" }), _jsx("option", { children: "500" })] }));
|
|
55
|
-
}
|
|
56
|
-
export default {
|
|
57
|
-
component: Editable,
|
|
58
|
-
title: 'Multi-fixture',
|
|
59
|
-
parameters: {
|
|
60
|
-
chromatic: { disableSnapshot: true },
|
|
61
|
-
},
|
|
62
|
-
argTypes: {
|
|
63
|
-
initialStepName: {
|
|
64
|
-
label: 'Initial Step',
|
|
65
|
-
control: 'select',
|
|
66
|
-
options: Object.keys(fixtures),
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
args: { initialStepName: Object.keys(fixtures)[0] },
|
|
70
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { storiesOf } from '@storybook/react';
|
|
3
|
-
import { examples } from '@wise/dynamic-flow-fixtures';
|
|
4
|
-
import DynamicFlowSideBySide from './utils/DynamicFlowSideBySide';
|
|
5
|
-
import { getObjectKeys } from './utils/fixtureHttpClient';
|
|
6
|
-
var storyMap = {};
|
|
7
|
-
var allStepNames = getObjectKeys(examples);
|
|
8
|
-
allStepNames.forEach(function (stepName) {
|
|
9
|
-
// eslint-disable-next-line import/namespace
|
|
10
|
-
var label = examples[stepName].id;
|
|
11
|
-
if (label) {
|
|
12
|
-
var _a = label.split('/'), group = _a[0], name_1 = _a[1];
|
|
13
|
-
storyMap[group] || (storyMap[group] = storiesOf("Examples/".concat(group), module).addParameters({
|
|
14
|
-
chromatic: { disableSnapshot: true },
|
|
15
|
-
}));
|
|
16
|
-
storyMap[group].add(name_1, function () { return (
|
|
17
|
-
// eslint-disable-next-line import/namespace
|
|
18
|
-
_jsx(DynamicFlowSideBySide, { initialStep: examples[stepName] }, stepName)); });
|
|
19
|
-
}
|
|
20
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { storiesOf } from '@storybook/react';
|
|
3
|
-
import { features } from '@wise/dynamic-flow-fixtures';
|
|
4
|
-
import DynamicFlowSideBySide from './utils/DynamicFlowSideBySide';
|
|
5
|
-
var storyMap = {};
|
|
6
|
-
var selectedStepNames = [
|
|
7
|
-
'actionResponse',
|
|
8
|
-
'arrayUploadBase64',
|
|
9
|
-
'external',
|
|
10
|
-
'persistAsync',
|
|
11
|
-
'polling',
|
|
12
|
-
'search',
|
|
13
|
-
'modal',
|
|
14
|
-
];
|
|
15
|
-
selectedStepNames.forEach(function (stepName) {
|
|
16
|
-
// eslint-disable-next-line import/namespace
|
|
17
|
-
var label = features[stepName].id;
|
|
18
|
-
if (label) {
|
|
19
|
-
var _a = label.split('/'), group = _a[0], name_1 = _a[1];
|
|
20
|
-
storyMap[group] || (storyMap[group] = storiesOf("Examples/".concat(group), module).addParameters({
|
|
21
|
-
chromatic: { disableSnapshot: true },
|
|
22
|
-
}));
|
|
23
|
-
storyMap[group].add(name_1, function () { return (
|
|
24
|
-
// eslint-disable-next-line import/namespace
|
|
25
|
-
_jsx(DynamicFlowSideBySide, { initialStep: features[stepName] }, stepName)); });
|
|
26
|
-
}
|
|
27
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { action } from '@storybook/addon-actions';
|
|
14
|
-
import { storiesOf } from '@storybook/react';
|
|
15
|
-
import { step, layouts, schemas, generatedJson as generatedFixtures, } from '@wise/dynamic-flow-fixtures';
|
|
16
|
-
import { getObjectKeys } from './utils/fixtureHttpClient';
|
|
17
|
-
import DynamicFlowSideBySide from './utils/DynamicFlowSideBySide';
|
|
18
|
-
var fixtures = __assign(__assign(__assign({}, step), layouts), schemas);
|
|
19
|
-
var storyMap = {};
|
|
20
|
-
var allStepNames = getObjectKeys(fixtures);
|
|
21
|
-
allStepNames.forEach(function (stepName) {
|
|
22
|
-
var label = fixtures[stepName].id;
|
|
23
|
-
if (label) {
|
|
24
|
-
var _a = label.split('/'), group = _a[0], name_1 = _a[1];
|
|
25
|
-
storyMap[group] || (storyMap[group] = storiesOf("Visual Tests/".concat(group), module));
|
|
26
|
-
storyMap[group].add(name_1, function () { return (_jsx(DynamicFlowSideBySide, { initialStep: fixtures[stepName] }, stepName)); });
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
storyMap.generated || (storyMap.generated = storiesOf("Visual Tests/Generated", module));
|
|
30
|
-
Object.keys(generatedFixtures).forEach(function (fixtureName) {
|
|
31
|
-
var _a;
|
|
32
|
-
var initialStep = JSON.parse(
|
|
33
|
-
// eslint-disable-next-line import/namespace
|
|
34
|
-
generatedFixtures[fixtureName]);
|
|
35
|
-
(_a = storyMap.generated) === null || _a === void 0 ? void 0 : _a.add(initialStep.id ? initialStep.id.replaceAll(/([A-Z])/g, ' $1').trim() : 'Invalid id', function () {
|
|
36
|
-
action('Render Step')(initialStep);
|
|
37
|
-
return _jsx(DynamicFlowSideBySide, { initialStep: initialStep }, fixtureName);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { action } from '@storybook/addon-actions';
|
|
14
|
-
import { DynamicFlowRevamp } from '../../dynamicFlow/DynamicFlow';
|
|
15
|
-
import { fixtureHttpClient } from './fixtureHttpClient';
|
|
16
|
-
import { DynamicFlowLegacy } from '../..';
|
|
17
|
-
function DynamicFlowSideBySide(_a) {
|
|
18
|
-
var key = _a.key, initialStep = _a.initialStep;
|
|
19
|
-
var props = {
|
|
20
|
-
flowId: 'storybook',
|
|
21
|
-
customFetch: fixtureHttpClient,
|
|
22
|
-
features: [],
|
|
23
|
-
onCompletion: action('onCompletion'),
|
|
24
|
-
onError: action('onError'),
|
|
25
|
-
onEvent: action('onEvent'),
|
|
26
|
-
onLog: action('onLog'),
|
|
27
|
-
};
|
|
28
|
-
return (_jsxs("div", { className: "df-side-by-side-container", children: [_jsx("div", { className: "df-side-by-side-column", children: _jsx(DynamicFlowLegacy, __assign({}, props, { loaderConfig: { size: 'xl', initial: true, submission: false }, initialStep: initialStep }), "".concat(key, "-original")) }), _jsx("div", { className: "df-side-by-side-column", children: _jsx(DynamicFlowRevamp, __assign({}, props, { initialStep: initialStep }), "".concat(key, "-revamp")) })] }));
|
|
29
|
-
}
|
|
30
|
-
export default DynamicFlowSideBySide;
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
import { action } from '@storybook/addon-actions';
|
|
49
|
-
import { layouts, features, examples, schemas, responses } from '@wise/dynamic-flow-fixtures';
|
|
50
|
-
export var getObjectKeys = Object.keys;
|
|
51
|
-
var fixtures = __assign(__assign(__assign(__assign({}, examples), schemas), layouts), features);
|
|
52
|
-
var isObject = function (val) {
|
|
53
|
-
return typeof val === 'object' && val !== null;
|
|
54
|
-
};
|
|
55
|
-
export var fixtureHttpClient = function (input, init) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
-
var url;
|
|
57
|
-
return __generator(this, function (_a) {
|
|
58
|
-
action('httpClient')(input, init);
|
|
59
|
-
url = getURL(input);
|
|
60
|
-
if (url.pathname.startsWith('/steps/')) {
|
|
61
|
-
return [2 /*return*/, respondWithFixture(fixtures, url, init)];
|
|
62
|
-
}
|
|
63
|
-
if (url.pathname.startsWith('/responses/')) {
|
|
64
|
-
return [2 /*return*/, respondWithFixture(responses, url, init)];
|
|
65
|
-
}
|
|
66
|
-
if (url.pathname.startsWith('/validate')) {
|
|
67
|
-
return [2 /*return*/, new Response(JSON.stringify({ message: 'Validation-async OK' }))];
|
|
68
|
-
}
|
|
69
|
-
return [2 /*return*/, new Response(null, { status: 404 })];
|
|
70
|
-
});
|
|
71
|
-
}); };
|
|
72
|
-
var getURL = function (input) {
|
|
73
|
-
if (input instanceof URL) {
|
|
74
|
-
return input;
|
|
75
|
-
}
|
|
76
|
-
if (input instanceof Request) {
|
|
77
|
-
return new URL(input.url, 'http://foo');
|
|
78
|
-
}
|
|
79
|
-
return new URL(input, 'http://foo');
|
|
80
|
-
};
|
|
81
|
-
var respondWithFixture = function (fixtureList, url, init) { return __awaiter(void 0, void 0, void 0, function () {
|
|
82
|
-
var fixtureNames, name, fixture, body;
|
|
83
|
-
var _a;
|
|
84
|
-
return __generator(this, function (_b) {
|
|
85
|
-
switch (_b.label) {
|
|
86
|
-
case 0:
|
|
87
|
-
fixtureNames = getObjectKeys(fixtureList);
|
|
88
|
-
name = url.pathname
|
|
89
|
-
.split('/')
|
|
90
|
-
.filter(function (part) { return Boolean(part); })
|
|
91
|
-
.pop();
|
|
92
|
-
if (!fixtureNames.includes(name !== null && name !== void 0 ? name : '')) return [3 /*break*/, 3];
|
|
93
|
-
fixture = fixtureList[name];
|
|
94
|
-
if (!url.searchParams.has('delay')) return [3 /*break*/, 2];
|
|
95
|
-
return [4 /*yield*/, new Promise(function (resolve) {
|
|
96
|
-
setTimeout(resolve, Number(url.searchParams.get('delay')));
|
|
97
|
-
})];
|
|
98
|
-
case 1:
|
|
99
|
-
_b.sent();
|
|
100
|
-
_b.label = 2;
|
|
101
|
-
case 2:
|
|
102
|
-
// by convention if the url contains a "refresh"query parameterm we use the payload as model
|
|
103
|
-
if (url.searchParams.has('refresh') &&
|
|
104
|
-
(init === null || init === void 0 ? void 0 : init.body) &&
|
|
105
|
-
typeof init.body === 'string' &&
|
|
106
|
-
isObject(fixture)) {
|
|
107
|
-
body = JSON.parse(init.body);
|
|
108
|
-
return [2 /*return*/, new Response(JSON.stringify(__assign(__assign({}, fixture), { model: __assign(__assign({}, ((_a = fixture.model) !== null && _a !== void 0 ? _a : {})), body) })))];
|
|
109
|
-
}
|
|
110
|
-
if (url.pathname.includes('exit')) {
|
|
111
|
-
return [2 /*return*/, new Response(JSON.stringify(fixture), { headers: { 'X-DF-Exit': 'true' } })];
|
|
112
|
-
}
|
|
113
|
-
return [2 /*return*/, new Response(JSON.stringify(fixture))];
|
|
114
|
-
case 3:
|
|
115
|
-
action('ERROR 404')(url);
|
|
116
|
-
return [2 /*return*/, new Response(null, { status: 404 })];
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}); };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { Provider as ComponentProvider, DEFAULT_LANG, DEFAULT_LOCALE, SnackbarProvider, translations as componentTranslations, getLangFromLocale, } from '@transferwise/components';
|
|
14
|
-
import { ThemeProvider } from '@wise/components-theming';
|
|
15
|
-
import { translations } from '@wise/dynamic-flow-client';
|
|
16
|
-
var locale = DEFAULT_LOCALE;
|
|
17
|
-
var lang = getLangFromLocale(locale) || DEFAULT_LANG;
|
|
18
|
-
var messages = __assign(__assign({}, componentTranslations[lang]), translations[lang]);
|
|
19
|
-
function NeptuneProviders(_a) {
|
|
20
|
-
var children = _a.children;
|
|
21
|
-
return (_jsx(ThemeProvider, { theme: "personal", screenMode: "light", children: _jsx(SnackbarProvider, { children: _jsx(ComponentProvider, { i18n: { locale: locale, messages: messages }, children: children }) }) }));
|
|
22
|
-
}
|
|
23
|
-
export default NeptuneProviders;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { render } from '@testing-library/react';
|
|
14
|
-
import NeptuneProviders from './NeptuneProviders';
|
|
15
|
-
export var renderWithProviders = function (children, options) {
|
|
16
|
-
var renderedResult = render(_jsx(NeptuneProviders, { children: children }), options);
|
|
17
|
-
return __assign(__assign({}, renderedResult), { rerender: function (ui, renderOptions) {
|
|
18
|
-
return renderWithProviders(ui, __assign({ container: renderedResult.container }, renderOptions));
|
|
19
|
-
} });
|
|
20
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { StoryObj, Meta } from '@storybook/react';
|
|
3
|
-
declare function DynamicFlowWithRef({ initialStepName }: {
|
|
4
|
-
initialStepName?: string | undefined;
|
|
5
|
-
}): JSX.Element;
|
|
6
|
-
declare const meta: Meta<typeof DynamicFlowWithRef>;
|
|
7
|
-
export declare const AllFixtures: StoryObj<typeof DynamicFlowWithRef>;
|
|
8
|
-
export default meta;
|