@wise/dynamic-flow-client 3.17.1 → 3.18.1

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
@@ -144,10 +144,10 @@ var init_clsx = __esm({
144
144
  }
145
145
  });
146
146
 
147
- // ../../node_modules/.pnpm/@wise+art@2.14.0_@transferwise+neptune-css@14.15.0_@types+react@18.3.4_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wise/art/dist/index-93a0c34e.esm.js
147
+ // ../../node_modules/.pnpm/@wise+art@2.14.0_@transferwise+neptune-css@14.18.0_@types+react@18.3.5_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wise/art/dist/index-93a0c34e.esm.js
148
148
  var import_react7, import_jsx_runtime17, unknownFlagName, Flag, Sizes, ImageSizes, imageSizes, Assets, RenderMode;
149
149
  var init_index_93a0c34e_esm = __esm({
150
- "../../node_modules/.pnpm/@wise+art@2.14.0_@transferwise+neptune-css@14.15.0_@types+react@18.3.4_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wise/art/dist/index-93a0c34e.esm.js"() {
150
+ "../../node_modules/.pnpm/@wise+art@2.14.0_@transferwise+neptune-css@14.18.0_@types+react@18.3.5_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wise/art/dist/index-93a0c34e.esm.js"() {
151
151
  "use strict";
152
152
  init_clsx();
153
153
  import_react7 = require("react");
@@ -1652,9 +1652,9 @@ var markdownComponentToProps = ({
1652
1652
  });
1653
1653
 
1654
1654
  // src/revamp/renderers/mappers/modalComponentToProps.ts
1655
- var modalComponentToProps = ({ control, margin, trigger }, components) => ({
1655
+ var modalComponentToProps = ({ content, control, margin, trigger }, components) => ({
1656
1656
  type: "modal",
1657
- content: { components },
1657
+ content: { components, title: content.title },
1658
1658
  control,
1659
1659
  margin,
1660
1660
  trigger
@@ -8042,7 +8042,7 @@ var createAllOfComponent = (allOfProps) => {
8042
8042
  return getLocalValues(this.components);
8043
8043
  },
8044
8044
  validate() {
8045
- return validateComponents(this.getChildren());
8045
+ return hidden ? true : validateComponents(this.getChildren());
8046
8046
  }
8047
8047
  };
8048
8048
  };
@@ -8242,82 +8242,29 @@ var integerSchemaToComponent = (schemaMapperProps, mapperProps) => {
8242
8242
  );
8243
8243
  };
8244
8244
 
8245
- // src/revamp/domain/components/utils/getComponentForLocalValueKey.ts
8246
- var getComponentForLocalValueKey = (key, component) => {
8247
- if (component.type === "object") {
8248
- return component.componentMap[key];
8249
- }
8250
- if (component.type === "select") {
8251
- const selectedChild = component.getSelectedChild();
8252
- return selectedChild ? getComponentForLocalValueKey(key, selectedChild) : null;
8253
- }
8254
- const child = hasChildren(component) ? [...component.getChildren()].reverse().find((c) => {
8255
- const v = c.getLocalValue();
8256
- return isObjectLocalValue(v) && key in v;
8257
- }) : void 0;
8258
- return child ? getComponentForLocalValueKey(key, child) : null;
8259
- };
8260
-
8261
- // src/revamp/domain/components/utils/isPartialLocalValueMatch.ts
8262
- var isPartialLocalValueMatch = (partialValue, component) => {
8263
- if (!component) {
8264
- return false;
8265
- }
8266
- const componentValue = component.getLocalValue();
8267
- if (component.type === "const") {
8268
- return isExactLocalValueMatch(partialValue, componentValue);
8269
- }
8270
- if (isObjectLocalValue(partialValue) && isObjectLocalValue(componentValue)) {
8271
- return isPartialObjectMatch(partialValue, componentValue, component);
8272
- }
8273
- if (isArrayLocalValue(partialValue) && component.type === "tuple") {
8274
- return isPartialTupleMatch(partialValue, component);
8275
- }
8276
- return null;
8277
- };
8278
- var isPartialObjectMatch = (partialValue, componentValue, component) => {
8279
- const results = getMatchingKeys(partialValue, componentValue).map((key) => {
8280
- const componentForKey = getComponentForLocalValueKey(key, component);
8281
- return componentForKey && componentForKey.type === "const" ? isPartialLocalValueMatch(partialValue[key], componentForKey) : null;
8282
- });
8283
- if (results.includes(false)) {
8284
- return false;
8285
- }
8286
- if (results.includes(true)) {
8287
- return true;
8245
+ // src/revamp/domain/components/utils/isPartialModelMatch.ts
8246
+ var isPartialModelMatch = (localModel, incomingModel) => {
8247
+ if (isArrayModel(localModel) && isArrayModel(incomingModel)) {
8248
+ return localModel.length === incomingModel.length && localModel.every((value, index) => isPartialModelMatch(value, incomingModel[index]));
8288
8249
  }
8289
- return null;
8290
- };
8291
- var isPartialTupleMatch = (partialValue, component) => {
8292
- const children = component.getChildren();
8293
- const shortest = partialValue.length < children.length ? partialValue : children;
8294
- const results = shortest.map((_value, index) => {
8295
- if (children[index].type !== "const") {
8296
- return null;
8297
- }
8298
- return isPartialLocalValueMatch(partialValue[index], children[index]);
8299
- });
8300
- if (results.includes(false)) {
8301
- return false;
8302
- }
8303
- if (results.includes(true)) {
8304
- return true;
8250
+ if (isObjectModel(localModel) && isObjectModel(incomingModel)) {
8251
+ const nonNullishKeysInBoth = nonNullishKeys(localModel).filter(
8252
+ (key) => nonNullishKeys(incomingModel).includes(key)
8253
+ );
8254
+ return nonNullishKeysInBoth.length > 0 && nonNullishKeysInBoth.every((key) => isPartialModelMatch(localModel[key], incomingModel[key]));
8305
8255
  }
8306
- return null;
8307
- };
8308
- var getMatchingKeys = (a, b) => {
8309
- const allKeys = Array.from(/* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]));
8310
- return allKeys.filter((key) => !isNullish(a[key]) && !isNullish(b[key]));
8256
+ return localModel === incomingModel;
8311
8257
  };
8258
+ var nonNullishKeys = (model) => Object.keys(model).filter((key) => !isNullish(model[key]));
8312
8259
 
8313
8260
  // src/revamp/domain/components/SelectInputComponent.ts
8314
8261
  var createSelectInputComponent = (selectProps, updateComponent) => {
8315
- const _a = selectProps, { uid, checks, initialValue, options, performRefresh, onValueChange, summariser } = _a, rest = __objRest(_a, ["uid", "checks", "initialValue", "options", "performRefresh", "onValueChange", "summariser"]);
8262
+ const _a = selectProps, { uid, checks, initialModel, options, performRefresh, onValueChange, summariser } = _a, rest = __objRest(_a, ["uid", "checks", "initialModel", "options", "performRefresh", "onValueChange", "summariser"]);
8316
8263
  const children = options.map((option) => option.component);
8317
8264
  const matchingOptions = options.map(
8318
- (option) => isPartialLocalValueMatch(selectProps.initialValue, option.component)
8265
+ (option) => isPartialModelMatch(option.component.getSubmittableValueSync(), initialModel)
8319
8266
  );
8320
- const selectedIndex = matchingOptions.filter(isTrue).length === 1 ? matchingOptions.indexOf(true) : null;
8267
+ const selectedIndex = matchingOptions.filter((match) => match).length === 1 ? matchingOptions.indexOf(true) : null;
8321
8268
  const update = getInputUpdateFunction(uid, updateComponent);
8322
8269
  const getValidationErrors = getLocalValueValidator(checks);
8323
8270
  const getAndSetValidationErrors = (currentValue) => {
@@ -8385,11 +8332,10 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
8385
8332
  }
8386
8333
  });
8387
8334
  };
8388
- var isTrue = (value) => value === true;
8389
8335
 
8390
8336
  // src/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.ts
8391
8337
  var oneOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
8392
- var _a, _b;
8338
+ var _a;
8393
8339
  const {
8394
8340
  uid,
8395
8341
  localValue,
@@ -8411,7 +8357,7 @@ var oneOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
8411
8357
  component: mapSchemaToComponent(
8412
8358
  {
8413
8359
  uid: `${uid}.oneOf-${index}`,
8414
- schema: supressSchemaTitleAndDescription(childSchema),
8360
+ schema: isFormSectionSchema(childSchema) ? supressSchemaTitleAndDescription(childSchema) : childSchema,
8415
8361
  model: initialModel,
8416
8362
  localValue,
8417
8363
  validationErrors: initialError,
@@ -8422,15 +8368,14 @@ var oneOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
8422
8368
  };
8423
8369
  });
8424
8370
  const { getErrorMessageFunctions, updateComponent, trackEvent, onRefresh, onValueChange } = mapperProps;
8425
- const { default: defaultValue, validationMessages } = schema;
8371
+ const { validationMessages } = schema;
8426
8372
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
8427
- const initialValue = (_b = model != null ? model : defaultValue) != null ? _b : null;
8428
8373
  return createSelectInputComponent(
8429
8374
  __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
8430
8375
  autoComplete: getAutocompleteString(schema.autocompleteHint),
8431
8376
  checks: schema.hidden ? [] : [getRequiredCheck(required, errorMessageFunctions)],
8432
8377
  options,
8433
- initialValue,
8378
+ initialModel,
8434
8379
  performRefresh: getPerformRefresh(schema, onRefresh),
8435
8380
  onValueChange,
8436
8381
  trackEvent
@@ -8438,6 +8383,7 @@ var oneOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
8438
8383
  updateComponent
8439
8384
  );
8440
8385
  };
8386
+ var isFormSectionSchema = (schema) => isObjectSchema(schema) || isArrayTupleSchema(schema) || isAllOfSchema(schema);
8441
8387
  var supressSchemaTitleAndDescription = (schema) => {
8442
8388
  const _a = schema, { title, description } = _a, headlessSchema = __objRest(_a, ["title", "description"]);
8443
8389
  return headlessSchema;
@@ -9940,13 +9886,14 @@ var createModalComponent = (modalProps) => __spreadProps(__spreadValues({
9940
9886
 
9941
9887
  // src/revamp/domain/mappers/layout/modalLayoutToComponent.ts
9942
9888
  var modalLayoutToComponent = (uid, { content, control, margin = "md", trigger }, mapperProps) => {
9943
- const { components } = content;
9889
+ const { components, title } = content;
9944
9890
  return createModalComponent({
9945
9891
  uid,
9946
9892
  content: {
9947
9893
  components: components.map(
9948
9894
  (component, index) => mapLayoutToComponent(`${uid}.modal-${index}`, component, mapperProps)
9949
- )
9895
+ ),
9896
+ title
9950
9897
  },
9951
9898
  control,
9952
9899
  margin,
@@ -11310,7 +11257,7 @@ var DateInputRenderer_default = DateInputRenderer;
11310
11257
  // ../renderers/src/DecisionRenderer.tsx
11311
11258
  var import_components9 = require("@transferwise/components");
11312
11259
 
11313
- // ../../node_modules/.pnpm/@wise+art@2.14.0_@transferwise+neptune-css@14.15.0_@types+react@18.3.4_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wise/art/dist/index.esm.js
11260
+ // ../../node_modules/.pnpm/@wise+art@2.14.0_@transferwise+neptune-css@14.18.0_@types+react@18.3.5_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wise/art/dist/index.esm.js
11314
11261
  init_index_93a0c34e_esm();
11315
11262
  init_clsx();
11316
11263
  var import_react8 = require("react");
@@ -11647,6 +11594,7 @@ var ModalRenderer = {
11647
11594
  var ModalRenderer_default = ModalRenderer;
11648
11595
  function DFModal({ content, margin, trigger }) {
11649
11596
  const [visible, setVisible] = (0, import_react10.useState)(false);
11597
+ const { components, title } = content;
11650
11598
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: getMargin(margin), children: [
11651
11599
  /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components17.Button, { priority: "tertiary", block: true, onClick: () => setVisible(true), children: trigger.title }),
11652
11600
  /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
@@ -11655,7 +11603,8 @@ function DFModal({ content, margin, trigger }) {
11655
11603
  scroll: "content",
11656
11604
  open: visible,
11657
11605
  size: "lg",
11658
- body: content.components,
11606
+ title,
11607
+ body: components,
11659
11608
  onClose: () => setVisible(false)
11660
11609
  }
11661
11610
  )
@@ -18087,6 +18036,7 @@ function DynamicModal(props) {
18087
18036
  scroll: "content",
18088
18037
  open: visible,
18089
18038
  size: "lg",
18039
+ title: component.content.title,
18090
18040
  body: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
18091
18041
  DynamicLayout_default,
18092
18042
  __spreadProps(__spreadValues({}, props), {