@wise/dynamic-flow-client 3.12.1 → 3.13.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/build/main.js +103 -5
- package/build/main.min.js +1 -1
- package/build/main.mjs +103 -5
- package/build/types/legacy/layout/search/useSearch.d.ts +1 -1
- package/build/types/revamp/domain/components/TupleComponent.d.ts +12 -0
- package/build/types/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToComponent.d.ts +1 -1
- package/build/types/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToTupleComponent.d.ts +5 -0
- package/build/types/revamp/domain/types.d.ts +3 -2
- package/build/types/revamp/renderers/mappers/tupleComponentToProps.d.ts +4 -0
- package/build/types/revamp/renderers/types.d.ts +1 -1
- package/build/types/revamp/utils/type-utils.d.ts +1 -0
- package/package.json +2 -2
package/build/main.mjs
CHANGED
|
@@ -1264,6 +1264,7 @@ var isObjectSchema = (schema) => "type" in schema && schema.type === "object";
|
|
|
1264
1264
|
var isOneOfSchema = (schema) => "oneOf" in schema && !isNullish(schema.oneOf);
|
|
1265
1265
|
var isArraySchema = (schema) => "items" in schema && !isNullish(schema.items);
|
|
1266
1266
|
var isArrayListSchema = (schema) => "items" in schema && isObject(schema.items) && !isArray(schema.items);
|
|
1267
|
+
var isArrayTupleSchema = (schema) => "items" in schema && !isObject(schema.items) && isArray(schema.items);
|
|
1267
1268
|
var isStringSchema = (schema) => "type" in schema && schema.type === "string";
|
|
1268
1269
|
var isStringSchemaWithUpload = (schema) => isStringSchema(schema) && schema.format === "base64url";
|
|
1269
1270
|
var isSchemaWithPersistAsync = (schema) => "persistAsync" in schema && !isNullish(schema.persistAsync);
|
|
@@ -1709,6 +1710,16 @@ var uploadInputComponentToProps = (component) => {
|
|
|
1709
1710
|
});
|
|
1710
1711
|
};
|
|
1711
1712
|
|
|
1713
|
+
// src/revamp/renderers/mappers/tupleComponentToProps.ts
|
|
1714
|
+
var tupleComponentToProps = ({ control, description, help, title }, children) => ({
|
|
1715
|
+
type: "form-section",
|
|
1716
|
+
children,
|
|
1717
|
+
control,
|
|
1718
|
+
description,
|
|
1719
|
+
help,
|
|
1720
|
+
title
|
|
1721
|
+
});
|
|
1722
|
+
|
|
1712
1723
|
// src/revamp/renderers/mappers/componentToRendererProps.ts
|
|
1713
1724
|
var componentToRendererProps = (component, nestedContent) => {
|
|
1714
1725
|
const { children, startChildren, endChildren, editableItemChildren } = nestedContent;
|
|
@@ -1778,6 +1789,8 @@ var componentToRendererProps = (component, nestedContent) => {
|
|
|
1778
1789
|
return statusListComponentToProps(component);
|
|
1779
1790
|
case "text":
|
|
1780
1791
|
return textInputComponentToProps(component);
|
|
1792
|
+
case "tuple":
|
|
1793
|
+
return tupleComponentToProps(component, children);
|
|
1781
1794
|
case "upload":
|
|
1782
1795
|
return uploadInputComponentToProps(component);
|
|
1783
1796
|
default:
|
|
@@ -7995,6 +8008,9 @@ var isPartialLocalValueMatch = (partialValue, component) => {
|
|
|
7995
8008
|
if (isObjectLocalValue(partialValue) && isObjectLocalValue(componentValue)) {
|
|
7996
8009
|
return isPartialObjectMatch(partialValue, componentValue, component);
|
|
7997
8010
|
}
|
|
8011
|
+
if (isArrayLocalValue(partialValue) && component.type === "tuple") {
|
|
8012
|
+
return isPartialTupleMatch(partialValue, component);
|
|
8013
|
+
}
|
|
7998
8014
|
return null;
|
|
7999
8015
|
};
|
|
8000
8016
|
var isPartialObjectMatch = (partialValue, componentValue, component) => {
|
|
@@ -8010,6 +8026,23 @@ var isPartialObjectMatch = (partialValue, componentValue, component) => {
|
|
|
8010
8026
|
}
|
|
8011
8027
|
return null;
|
|
8012
8028
|
};
|
|
8029
|
+
var isPartialTupleMatch = (partialValue, component) => {
|
|
8030
|
+
const children = component.getChildren();
|
|
8031
|
+
const shortest = partialValue.length < children.length ? partialValue : children;
|
|
8032
|
+
const results = shortest.map((_value, index) => {
|
|
8033
|
+
if (children[index].type !== "const") {
|
|
8034
|
+
return null;
|
|
8035
|
+
}
|
|
8036
|
+
return isPartialLocalValueMatch(partialValue[index], children[index]);
|
|
8037
|
+
});
|
|
8038
|
+
if (results.includes(false)) {
|
|
8039
|
+
return false;
|
|
8040
|
+
}
|
|
8041
|
+
if (results.includes(true)) {
|
|
8042
|
+
return true;
|
|
8043
|
+
}
|
|
8044
|
+
return null;
|
|
8045
|
+
};
|
|
8013
8046
|
var getMatchingKeys = (a, b) => {
|
|
8014
8047
|
const allKeys = Array.from(/* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]));
|
|
8015
8048
|
return allKeys.filter((key) => !isNullish(a[key]) && !isNullish(b[key]));
|
|
@@ -9183,6 +9216,71 @@ var arraySchemaToMultiSelectComponent = (schemaMapperProps, mapperProps) => {
|
|
|
9183
9216
|
);
|
|
9184
9217
|
};
|
|
9185
9218
|
|
|
9219
|
+
// src/revamp/domain/components/TupleComponent.ts
|
|
9220
|
+
var createTupleComponent = (tupleProps) => {
|
|
9221
|
+
const { uid, analyticsId, components, control, description, help, hidden, summariser, title } = tupleProps;
|
|
9222
|
+
return {
|
|
9223
|
+
type: "tuple",
|
|
9224
|
+
uid,
|
|
9225
|
+
analyticsId,
|
|
9226
|
+
components,
|
|
9227
|
+
control,
|
|
9228
|
+
description,
|
|
9229
|
+
help,
|
|
9230
|
+
hidden,
|
|
9231
|
+
title,
|
|
9232
|
+
getChildren() {
|
|
9233
|
+
return this.components;
|
|
9234
|
+
},
|
|
9235
|
+
async getSubmittableValue() {
|
|
9236
|
+
return Promise.all(this.components.map((child) => child.getSubmittableValue()));
|
|
9237
|
+
},
|
|
9238
|
+
getSummary() {
|
|
9239
|
+
const summary = summariser(this.getLocalValue());
|
|
9240
|
+
const childSummary = summariseFromChildren(this.getChildren());
|
|
9241
|
+
return mergeSummaries(summary, childSummary);
|
|
9242
|
+
},
|
|
9243
|
+
getLocalValue() {
|
|
9244
|
+
return this.components.map((child) => child.getLocalValue());
|
|
9245
|
+
},
|
|
9246
|
+
validate() {
|
|
9247
|
+
return validateComponents(this.getChildren());
|
|
9248
|
+
}
|
|
9249
|
+
};
|
|
9250
|
+
};
|
|
9251
|
+
|
|
9252
|
+
// src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToTupleComponent.ts
|
|
9253
|
+
var arraySchemaToTupleComponent = (schemaMapperProps, mapperProps) => {
|
|
9254
|
+
const {
|
|
9255
|
+
uid,
|
|
9256
|
+
localValue,
|
|
9257
|
+
schema,
|
|
9258
|
+
model: initialModel,
|
|
9259
|
+
required = false,
|
|
9260
|
+
validationErrors
|
|
9261
|
+
} = schemaMapperProps;
|
|
9262
|
+
const { items } = schema;
|
|
9263
|
+
const components = items.map(
|
|
9264
|
+
(childSchema, index) => {
|
|
9265
|
+
var _a, _b;
|
|
9266
|
+
return mapSchemaToComponent(
|
|
9267
|
+
{
|
|
9268
|
+
uid: `${uid}-arr.${index}`,
|
|
9269
|
+
schema: childSchema,
|
|
9270
|
+
model: isArray(initialModel) ? (_a = initialModel[index]) != null ? _a : null : null,
|
|
9271
|
+
localValue: isArray(localValue) ? (_b = localValue[index]) != null ? _b : null : null,
|
|
9272
|
+
validationErrors: isArray(validationErrors) ? validationErrors[index] : void 0,
|
|
9273
|
+
required
|
|
9274
|
+
},
|
|
9275
|
+
mapperProps
|
|
9276
|
+
);
|
|
9277
|
+
}
|
|
9278
|
+
);
|
|
9279
|
+
return createTupleComponent(__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
9280
|
+
components
|
|
9281
|
+
}));
|
|
9282
|
+
};
|
|
9283
|
+
|
|
9186
9284
|
// src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToComponent.ts
|
|
9187
9285
|
var arraySchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
9188
9286
|
const { schema, model: originalModel } = schemaMapperProps;
|
|
@@ -9193,10 +9291,10 @@ var arraySchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
9193
9291
|
if (isArraySchemaListWithMultiSelect(schema)) {
|
|
9194
9292
|
return arraySchemaToMultiSelectComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
|
|
9195
9293
|
}
|
|
9196
|
-
if (
|
|
9197
|
-
return
|
|
9294
|
+
if (isArrayTupleSchema(schema)) {
|
|
9295
|
+
return arraySchemaToTupleComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
|
|
9198
9296
|
}
|
|
9199
|
-
|
|
9297
|
+
return arraySchemaToRepeatableComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
|
|
9200
9298
|
};
|
|
9201
9299
|
var isArraySchemaListWithMultiFileUpload = (schema) => isArrayListSchema(schema) && (isPersistAsyncWithUploadSchema(schema.items) || isStringSchemaWithUpload(schema.items));
|
|
9202
9300
|
var isPersistAsyncWithUploadSchema = (schema) => isSchemaWithPersistAsync(schema) && (isBlobSchema(schema.persistAsync.schema) || isStringSchemaWithUpload(schema.persistAsync.schema));
|
|
@@ -10467,7 +10565,7 @@ function useDynamicFlowCore(props) {
|
|
|
10467
10565
|
const onAction = useCallback2(async (action) => {
|
|
10468
10566
|
var _a2, _b, _c;
|
|
10469
10567
|
try {
|
|
10470
|
-
(_a2 = stepComponentRef.current) == null ? void 0 : _a2.setLoadingState("
|
|
10568
|
+
(_a2 = stepComponentRef.current) == null ? void 0 : _a2.setLoadingState("submitting");
|
|
10471
10569
|
const model = (_c = await ((_b = stepComponentRef.current) == null ? void 0 : _b.getSubmittableValue())) != null ? _c : null;
|
|
10472
10570
|
const command = await executeSubmission({
|
|
10473
10571
|
action,
|
|
@@ -10512,7 +10610,7 @@ function useDynamicFlowCore(props) {
|
|
|
10512
10610
|
async (schemaId, refreshUrl = "", errorsOverride) => {
|
|
10513
10611
|
var _a2, _b, _c, _d;
|
|
10514
10612
|
try {
|
|
10515
|
-
(_a2 = stepComponentRef.current) == null ? void 0 : _a2.setLoadingState("
|
|
10613
|
+
(_a2 = stepComponentRef.current) == null ? void 0 : _a2.setLoadingState("refreshing");
|
|
10516
10614
|
const model = (_c = await ((_b = stepComponentRef.current) == null ? void 0 : _b.getSubmittableValue())) != null ? _c : null;
|
|
10517
10615
|
const command = await executeRefresh({
|
|
10518
10616
|
abortSignal: abortCurrentAndGetNewAbortSignal(),
|
|
@@ -10,7 +10,7 @@ export type SearchState = {
|
|
|
10
10
|
status: 'error';
|
|
11
11
|
};
|
|
12
12
|
export declare const useSearch: (defaultSearchConfig: SearchConfig) => {
|
|
13
|
-
status: "error" | "idle" | "
|
|
13
|
+
status: "error" | "idle" | "success" | "loading";
|
|
14
14
|
results: SearchResult[];
|
|
15
15
|
search: (query: string, { url, method, param }?: SearchConfig) => Promise<void>;
|
|
16
16
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComponentWithTitle, DomainComponent, LocalValue, LocalValueArray, RepeatableSummary } from '../types';
|
|
2
|
+
export type TupleComponent = ComponentWithTitle & {
|
|
3
|
+
type: 'tuple';
|
|
4
|
+
components: DomainComponent[];
|
|
5
|
+
getChildren: () => DomainComponent[];
|
|
6
|
+
getLocalValue: () => LocalValueArray;
|
|
7
|
+
};
|
|
8
|
+
export declare const createTupleComponent: (tupleProps: Pick<TupleComponent, 'control' | 'description' | 'components' | 'title' | 'help' | 'hidden'> & {
|
|
9
|
+
uid: string;
|
|
10
|
+
analyticsId?: string;
|
|
11
|
+
summariser: (value: LocalValue | null) => RepeatableSummary;
|
|
12
|
+
}) => TupleComponent;
|
package/build/types/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToComponent.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import type { MapperProps, SchemaMapperProps } from '../types';
|
|
|
2
2
|
import type { ArraySchema } from '@wise/dynamic-flow-types/build/next';
|
|
3
3
|
export declare const arraySchemaToComponent: (schemaMapperProps: SchemaMapperProps & {
|
|
4
4
|
schema: ArraySchema;
|
|
5
|
-
}, mapperProps: MapperProps) => import("../../../components/MultiSelectInputComponent").MultiSelectComponent | import("../../../components/MultiUploadInputComponent").MultiUploadInputComponent | import("../../../components/repeatableComponent/RepeatableComponent").RepeatableComponent;
|
|
5
|
+
}, mapperProps: MapperProps) => import("../../../components/MultiSelectInputComponent").MultiSelectComponent | import("../../../components/MultiUploadInputComponent").MultiUploadInputComponent | import("../../../components/repeatableComponent/RepeatableComponent").RepeatableComponent | import("../../../components/TupleComponent").TupleComponent;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ArraySchemaTuple } from '@wise/dynamic-flow-types/build/next';
|
|
2
|
+
import { MapperProps, SchemaMapperProps } from '../types';
|
|
3
|
+
export declare const arraySchemaToTupleComponent: (schemaMapperProps: SchemaMapperProps & {
|
|
4
|
+
schema: ArraySchemaTuple;
|
|
5
|
+
}, mapperProps: MapperProps) => import("../../../components/TupleComponent").TupleComponent;
|
|
@@ -31,7 +31,8 @@ import type { StatusListComponent } from './components/StatusListComponent';
|
|
|
31
31
|
import type { StepDomainComponent } from './components/StepDomainComponent';
|
|
32
32
|
import type { TextInputComponent } from './components/TextInputComponent';
|
|
33
33
|
import type { UploadInputComponent } from './components/UploadInputComponent';
|
|
34
|
-
|
|
34
|
+
import { TupleComponent } from './components/TupleComponent';
|
|
35
|
+
export type DomainComponent = StepDomainComponent | AlertComponent | AllOfComponent | BooleanInputComponent | BoxComponent | ButtonComponent | ColumnsComponent | ConstComponent | ContainerComponent | DateInputComponent | DecisionComponent | DividerComponent | FormComponent | HeadingComponent | ImageComponent | InstructionsComponent | IntegerInputComponent | LoadingIndicatorComponent | MarkdownComponent | ModalComponent | MultiSelectComponent | MultiUploadInputComponent | NumberInputComponent | ObjectComponent | ParagraphComponent | RepeatableComponent | ReviewComponent | SearchComponent | SelectInputComponent | StatusListComponent | TextInputComponent | TupleComponent | UploadInputComponent;
|
|
35
36
|
export type LocalValue = LocalValuePrimitive | LocalValueObject | LocalValueArray;
|
|
36
37
|
export type LocalValuePrimitive = string | number | boolean | File | null;
|
|
37
38
|
export interface LocalValueObject extends Record<string, LocalValuePrimitive | LocalValueObject | LocalValueArray> {
|
|
@@ -98,4 +99,4 @@ export type ValidationState = {
|
|
|
98
99
|
error?: string;
|
|
99
100
|
};
|
|
100
101
|
};
|
|
101
|
-
export type LoadingState = 'idle' | '
|
|
102
|
+
export type LoadingState = 'idle' | 'submitting' | 'refreshing';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { TupleComponent } from '../../domain/components/TupleComponent';
|
|
3
|
+
import { FormSectionRendererProps } from '../types';
|
|
4
|
+
export declare const tupleComponentToProps: ({ control, description, help, title }: TupleComponent, children: ReactNode) => FormSectionRendererProps;
|
|
@@ -10,7 +10,7 @@ export type Bias = 'none' | 'start' | 'end';
|
|
|
10
10
|
export type Context = 'positive' | 'negative' | 'warning' | 'neutral';
|
|
11
11
|
export type Margin = DFMargin;
|
|
12
12
|
export type Size = DFSize;
|
|
13
|
-
export type LoadingState = 'idle' | '
|
|
13
|
+
export type LoadingState = 'idle' | 'submitting' | 'refreshing';
|
|
14
14
|
export type Image = {
|
|
15
15
|
url: string;
|
|
16
16
|
accessibilityDescription?: string;
|
|
@@ -36,6 +36,7 @@ export declare const isObjectSchema: (schema: Schema) => schema is ObjectSchema;
|
|
|
36
36
|
export declare const isOneOfSchema: (schema: Schema) => schema is OneOfSchema;
|
|
37
37
|
export declare const isArraySchema: (schema: Schema) => schema is ArraySchema;
|
|
38
38
|
export declare const isArrayListSchema: (schema: Schema) => schema is ArraySchemaList;
|
|
39
|
+
export declare const isArrayTupleSchema: (schema: Schema) => schema is ArraySchemaTuple;
|
|
39
40
|
export declare const isStringSchema: (schema: Schema) => schema is StringSchema;
|
|
40
41
|
export declare const isStringSchemaWithUpload: (schema: Schema) => schema is StringSchemaWithUpload;
|
|
41
42
|
export declare const isSchemaWithPersistAsync: (schema: Schema) => schema is SchemaWithPersistAsync;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wise/dynamic-flow-client",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0",
|
|
4
4
|
"description": "Dynamic Flow web client",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./build/main.min.js",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"classnames": "2.5.1",
|
|
96
96
|
"react-webcam": "^7.2.0",
|
|
97
97
|
"screenfull": "^5.2.0",
|
|
98
|
-
"@wise/dynamic-flow-types": "2.15.
|
|
98
|
+
"@wise/dynamic-flow-types": "2.15.4"
|
|
99
99
|
},
|
|
100
100
|
"scripts": {
|
|
101
101
|
"dev": "pnpm build:visual-tests && storybook dev -p 3003",
|