@wise/dynamic-flow-client 3.11.0 → 3.11.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
@@ -7765,38 +7765,32 @@ var getComponentForLocalValueKey = (key, component) => {
7765
7765
 
7766
7766
  // src/revamp/domain/components/utils/isPartialLocalValueMatch.ts
7767
7767
  var isPartialLocalValueMatch = (partialValue, component) => {
7768
- if (isArray(partialValue) && component.type === "repeatable") {
7769
- const children = component.getChildren();
7770
- return partialValue.every((value, index) => {
7771
- const childComponent = children[index];
7772
- return childComponent ? isPartialLocalValueMatch(value, childComponent) : false;
7773
- });
7768
+ if (!component) {
7769
+ return false;
7774
7770
  }
7775
7771
  const componentValue = component.getLocalValue();
7776
7772
  if (component.type === "const") {
7777
7773
  return compareLocalValue(partialValue, componentValue);
7778
7774
  }
7779
7775
  if (isObjectLocalValue(partialValue) && isObjectLocalValue(componentValue)) {
7780
- const allKeys = Array.from(
7781
- /* @__PURE__ */ new Set([...Object.keys(partialValue), ...Object.keys(componentValue)])
7782
- );
7783
- const matchingKeys = allKeys.filter(
7784
- (key) => !isNullish(partialValue[key]) && !isNullish(componentValue[key])
7785
- );
7786
- return matchingKeys.length > 0 && matchingKeys.every((key) => {
7787
- const componentForKey = getComponentForLocalValueKey(key, component);
7788
- return componentForKey ? isPartialLocalValueMatch(partialValue[key], componentForKey) : false;
7789
- });
7776
+ return isPartialObjectMatch(partialValue, componentValue, component);
7790
7777
  }
7791
- if (partialValue instanceof File && componentValue instanceof File) {
7792
- return areEquivalentFiles(partialValue, componentValue);
7793
- }
7794
- if ("isPersisted" in component && component.isPersisted) {
7795
- return true;
7796
- }
7797
- return compareLocalValue(partialValue, componentValue);
7778
+ return true;
7779
+ };
7780
+ var isPartialObjectMatch = (partialValue, componentValue, component) => {
7781
+ const resultByKey = getMatchingKeys(partialValue, componentValue).map((key) => {
7782
+ const componentForKey = getComponentForLocalValueKey(key, component);
7783
+ if (componentForKey && componentForKey.type === "const") {
7784
+ return isPartialLocalValueMatch(partialValue[key], componentForKey);
7785
+ }
7786
+ return null;
7787
+ });
7788
+ return resultByKey.includes(true) && !resultByKey.includes(false);
7789
+ };
7790
+ var getMatchingKeys = (a, b) => {
7791
+ const allKeys = Array.from(/* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]));
7792
+ return allKeys.filter((key) => !isNullish(a[key]) && !isNullish(b[key]));
7798
7793
  };
7799
- var areEquivalentFiles = (fileA, fileB) => fileA.name === fileB.name && fileA.type === fileB.type && fileA.size === fileB.size;
7800
7794
 
7801
7795
  // src/revamp/domain/components/SelectInputComponent.ts
7802
7796
  var createSelectInputComponent = (selectProps, updateComponent) => {
@@ -8122,6 +8116,19 @@ var toBase64 = async (file) => new Promise((resolve, reject) => {
8122
8116
  reader.addEventListener("error", reject);
8123
8117
  reader.readAsDataURL(file);
8124
8118
  });
8119
+ var base64dataUrltoFile = (dataurl, filename) => {
8120
+ if (!isBase64DataUrl(dataurl)) {
8121
+ return null;
8122
+ }
8123
+ const [, base64data] = dataurl.split(",");
8124
+ return new File([base64ToBytes(base64data)], filename, { type: getMimeType(dataurl) });
8125
+ };
8126
+ var isBase64DataUrl = (dataurl) => dataurl.startsWith("data:") && dataurl.includes("base64") && dataurl.includes(",");
8127
+ var getMimeType = (base64dataUrl) => base64dataUrl.substring("data:".length).split(";")[0];
8128
+ var base64ToBytes = (base64) => {
8129
+ const charCodes = atob(base64).split("").map((m) => m.charCodeAt(0));
8130
+ return Uint8Array.from(charCodes);
8131
+ };
8125
8132
 
8126
8133
  // src/revamp/domain/components/UploadInputComponent.ts
8127
8134
  var createUploadInputComponent = (uploadInputProps, updateComponent) => {
@@ -8223,6 +8230,7 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
8223
8230
 
8224
8231
  // src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToUploadInputComponent.ts
8225
8232
  var stringSchemaToUploadInputComponent = (schemaMapperProps, mapperProps) => {
8233
+ var _a;
8226
8234
  const { schema, localValue, model, required = false } = schemaMapperProps;
8227
8235
  const { accepts, autocompleteHint, maxSize, validationMessages } = schema;
8228
8236
  const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
@@ -8230,7 +8238,7 @@ var stringSchemaToUploadInputComponent = (schemaMapperProps, mapperProps) => {
8230
8238
  const { performPersistAsync } = getPersistAsyncInitialState(schemaMapperProps, mapperProps);
8231
8239
  const persistedState = performPersistAsync ? getInitialPersistedState(null, model) : getInitialPersistedState();
8232
8240
  const validLocalValue = isFile(localValue) ? localValue : null;
8233
- const value = performPersistAsync ? validLocalValue : null;
8241
+ const value = (_a = getFileFromModel(model)) != null ? _a : validLocalValue;
8234
8242
  return createUploadInputComponent(
8235
8243
  __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
8236
8244
  accepts,
@@ -8247,6 +8255,7 @@ var stringSchemaToUploadInputComponent = (schemaMapperProps, mapperProps) => {
8247
8255
  updateComponent
8248
8256
  );
8249
8257
  };
8258
+ var getFileFromModel = (model) => isString(model) ? base64dataUrltoFile(model, "") : null;
8250
8259
 
8251
8260
  // src/revamp/domain/components/TextInputComponent.ts
8252
8261
  var createTextInputComponent = (textInputProps, updateComponent) => {