@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 CHANGED
@@ -1286,6 +1286,7 @@ var isObjectSchema = (schema) => "type" in schema && schema.type === "object";
1286
1286
  var isOneOfSchema = (schema) => "oneOf" in schema && !isNullish(schema.oneOf);
1287
1287
  var isArraySchema = (schema) => "items" in schema && !isNullish(schema.items);
1288
1288
  var isArrayListSchema = (schema) => "items" in schema && isObject(schema.items) && !isArray(schema.items);
1289
+ var isArrayTupleSchema = (schema) => "items" in schema && !isObject(schema.items) && isArray(schema.items);
1289
1290
  var isStringSchema = (schema) => "type" in schema && schema.type === "string";
1290
1291
  var isStringSchemaWithUpload = (schema) => isStringSchema(schema) && schema.format === "base64url";
1291
1292
  var isSchemaWithPersistAsync = (schema) => "persistAsync" in schema && !isNullish(schema.persistAsync);
@@ -1731,6 +1732,16 @@ var uploadInputComponentToProps = (component) => {
1731
1732
  });
1732
1733
  };
1733
1734
 
1735
+ // src/revamp/renderers/mappers/tupleComponentToProps.ts
1736
+ var tupleComponentToProps = ({ control, description, help, title }, children) => ({
1737
+ type: "form-section",
1738
+ children,
1739
+ control,
1740
+ description,
1741
+ help,
1742
+ title
1743
+ });
1744
+
1734
1745
  // src/revamp/renderers/mappers/componentToRendererProps.ts
1735
1746
  var componentToRendererProps = (component, nestedContent) => {
1736
1747
  const { children, startChildren, endChildren, editableItemChildren } = nestedContent;
@@ -1800,6 +1811,8 @@ var componentToRendererProps = (component, nestedContent) => {
1800
1811
  return statusListComponentToProps(component);
1801
1812
  case "text":
1802
1813
  return textInputComponentToProps(component);
1814
+ case "tuple":
1815
+ return tupleComponentToProps(component, children);
1803
1816
  case "upload":
1804
1817
  return uploadInputComponentToProps(component);
1805
1818
  default:
@@ -8017,6 +8030,9 @@ var isPartialLocalValueMatch = (partialValue, component) => {
8017
8030
  if (isObjectLocalValue(partialValue) && isObjectLocalValue(componentValue)) {
8018
8031
  return isPartialObjectMatch(partialValue, componentValue, component);
8019
8032
  }
8033
+ if (isArrayLocalValue(partialValue) && component.type === "tuple") {
8034
+ return isPartialTupleMatch(partialValue, component);
8035
+ }
8020
8036
  return null;
8021
8037
  };
8022
8038
  var isPartialObjectMatch = (partialValue, componentValue, component) => {
@@ -8032,6 +8048,23 @@ var isPartialObjectMatch = (partialValue, componentValue, component) => {
8032
8048
  }
8033
8049
  return null;
8034
8050
  };
8051
+ var isPartialTupleMatch = (partialValue, component) => {
8052
+ const children = component.getChildren();
8053
+ const shortest = partialValue.length < children.length ? partialValue : children;
8054
+ const results = shortest.map((_value, index) => {
8055
+ if (children[index].type !== "const") {
8056
+ return null;
8057
+ }
8058
+ return isPartialLocalValueMatch(partialValue[index], children[index]);
8059
+ });
8060
+ if (results.includes(false)) {
8061
+ return false;
8062
+ }
8063
+ if (results.includes(true)) {
8064
+ return true;
8065
+ }
8066
+ return null;
8067
+ };
8035
8068
  var getMatchingKeys = (a, b) => {
8036
8069
  const allKeys = Array.from(/* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]));
8037
8070
  return allKeys.filter((key) => !isNullish(a[key]) && !isNullish(b[key]));
@@ -9205,6 +9238,71 @@ var arraySchemaToMultiSelectComponent = (schemaMapperProps, mapperProps) => {
9205
9238
  );
9206
9239
  };
9207
9240
 
9241
+ // src/revamp/domain/components/TupleComponent.ts
9242
+ var createTupleComponent = (tupleProps) => {
9243
+ const { uid, analyticsId, components, control, description, help, hidden, summariser, title } = tupleProps;
9244
+ return {
9245
+ type: "tuple",
9246
+ uid,
9247
+ analyticsId,
9248
+ components,
9249
+ control,
9250
+ description,
9251
+ help,
9252
+ hidden,
9253
+ title,
9254
+ getChildren() {
9255
+ return this.components;
9256
+ },
9257
+ async getSubmittableValue() {
9258
+ return Promise.all(this.components.map((child) => child.getSubmittableValue()));
9259
+ },
9260
+ getSummary() {
9261
+ const summary = summariser(this.getLocalValue());
9262
+ const childSummary = summariseFromChildren(this.getChildren());
9263
+ return mergeSummaries(summary, childSummary);
9264
+ },
9265
+ getLocalValue() {
9266
+ return this.components.map((child) => child.getLocalValue());
9267
+ },
9268
+ validate() {
9269
+ return validateComponents(this.getChildren());
9270
+ }
9271
+ };
9272
+ };
9273
+
9274
+ // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToTupleComponent.ts
9275
+ var arraySchemaToTupleComponent = (schemaMapperProps, mapperProps) => {
9276
+ const {
9277
+ uid,
9278
+ localValue,
9279
+ schema,
9280
+ model: initialModel,
9281
+ required = false,
9282
+ validationErrors
9283
+ } = schemaMapperProps;
9284
+ const { items } = schema;
9285
+ const components = items.map(
9286
+ (childSchema, index) => {
9287
+ var _a, _b;
9288
+ return mapSchemaToComponent(
9289
+ {
9290
+ uid: `${uid}-arr.${index}`,
9291
+ schema: childSchema,
9292
+ model: isArray(initialModel) ? (_a = initialModel[index]) != null ? _a : null : null,
9293
+ localValue: isArray(localValue) ? (_b = localValue[index]) != null ? _b : null : null,
9294
+ validationErrors: isArray(validationErrors) ? validationErrors[index] : void 0,
9295
+ required
9296
+ },
9297
+ mapperProps
9298
+ );
9299
+ }
9300
+ );
9301
+ return createTupleComponent(__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
9302
+ components
9303
+ }));
9304
+ };
9305
+
9208
9306
  // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToComponent.ts
9209
9307
  var arraySchemaToComponent = (schemaMapperProps, mapperProps) => {
9210
9308
  const { schema, model: originalModel } = schemaMapperProps;
@@ -9215,10 +9313,10 @@ var arraySchemaToComponent = (schemaMapperProps, mapperProps) => {
9215
9313
  if (isArraySchemaListWithMultiSelect(schema)) {
9216
9314
  return arraySchemaToMultiSelectComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
9217
9315
  }
9218
- if (isArrayListSchema(schema)) {
9219
- return arraySchemaToRepeatableComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
9316
+ if (isArrayTupleSchema(schema)) {
9317
+ return arraySchemaToTupleComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
9220
9318
  }
9221
- throw new Error("Currently only repeatable array schemas are supported");
9319
+ return arraySchemaToRepeatableComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
9222
9320
  };
9223
9321
  var isArraySchemaListWithMultiFileUpload = (schema) => isArrayListSchema(schema) && (isPersistAsyncWithUploadSchema(schema.items) || isStringSchemaWithUpload(schema.items));
9224
9322
  var isPersistAsyncWithUploadSchema = (schema) => isSchemaWithPersistAsync(schema) && (isBlobSchema(schema.persistAsync.schema) || isStringSchemaWithUpload(schema.persistAsync.schema));
@@ -10489,7 +10587,7 @@ function useDynamicFlowCore(props) {
10489
10587
  const onAction = (0, import_react4.useCallback)(async (action) => {
10490
10588
  var _a2, _b, _c;
10491
10589
  try {
10492
- (_a2 = stepComponentRef.current) == null ? void 0 : _a2.setLoadingState("loading");
10590
+ (_a2 = stepComponentRef.current) == null ? void 0 : _a2.setLoadingState("submitting");
10493
10591
  const model = (_c = await ((_b = stepComponentRef.current) == null ? void 0 : _b.getSubmittableValue())) != null ? _c : null;
10494
10592
  const command = await executeSubmission({
10495
10593
  action,
@@ -10534,7 +10632,7 @@ function useDynamicFlowCore(props) {
10534
10632
  async (schemaId, refreshUrl = "", errorsOverride) => {
10535
10633
  var _a2, _b, _c, _d;
10536
10634
  try {
10537
- (_a2 = stepComponentRef.current) == null ? void 0 : _a2.setLoadingState("loading");
10635
+ (_a2 = stepComponentRef.current) == null ? void 0 : _a2.setLoadingState("refreshing");
10538
10636
  const model = (_c = await ((_b = stepComponentRef.current) == null ? void 0 : _b.getSubmittableValue())) != null ? _c : null;
10539
10637
  const command = await executeRefresh({
10540
10638
  abortSignal: abortCurrentAndGetNewAbortSignal(),