@wise/dynamic-flow-client 3.11.4-experimental-node20-6554c5d → 3.11.4-experimental-node-20-x-9761807

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.mjs CHANGED
@@ -6703,7 +6703,9 @@ var compareLocalValue = (valueA, valueB) => {
6703
6703
  return valueA.length === valueB.length && valueA.every((value, index) => compareLocalValue(value, valueB[index]));
6704
6704
  }
6705
6705
  if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
6706
- return Object.keys(valueA).every((key) => compareLocalValue(valueA[key], valueB[key]));
6706
+ const keysA = Object.keys(valueA);
6707
+ const keysB = Object.keys(valueB);
6708
+ return keysA.length === keysB.length && keysA.every((key) => compareLocalValue(valueA[key], valueB[key]));
6707
6709
  }
6708
6710
  return valueA === valueB;
6709
6711
  };
@@ -7770,17 +7772,20 @@ var isPartialLocalValueMatch = (partialValue, component) => {
7770
7772
  if (isObjectLocalValue(partialValue) && isObjectLocalValue(componentValue)) {
7771
7773
  return isPartialObjectMatch(partialValue, componentValue, component);
7772
7774
  }
7773
- return true;
7775
+ return null;
7774
7776
  };
7775
7777
  var isPartialObjectMatch = (partialValue, componentValue, component) => {
7776
- const resultByKey = getMatchingKeys(partialValue, componentValue).map((key) => {
7778
+ const results = getMatchingKeys(partialValue, componentValue).map((key) => {
7777
7779
  const componentForKey = getComponentForLocalValueKey(key, component);
7778
- if (componentForKey && componentForKey.type === "const") {
7779
- return isPartialLocalValueMatch(partialValue[key], componentForKey);
7780
- }
7781
- return null;
7780
+ return componentForKey && componentForKey.type === "const" ? isPartialLocalValueMatch(partialValue[key], componentForKey) : null;
7782
7781
  });
7783
- return resultByKey.includes(true) && !resultByKey.includes(false);
7782
+ if (results.includes(false)) {
7783
+ return false;
7784
+ }
7785
+ if (results.includes(true)) {
7786
+ return true;
7787
+ }
7788
+ return null;
7784
7789
  };
7785
7790
  var getMatchingKeys = (a, b) => {
7786
7791
  const allKeys = Array.from(/* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]));
@@ -7895,7 +7900,7 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
7895
7900
  }
7896
7901
  });
7897
7902
  };
7898
- var isTrue = (value) => value;
7903
+ var isTrue = (value) => value === true;
7899
7904
 
7900
7905
  // src/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.ts
7901
7906
  var oneOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
@@ -10418,7 +10423,7 @@ function $1746a345f3d73bb7$export$f680877a34711e37(deterministicId) {
10418
10423
  return deterministicId || (id ? `radix-${id}` : "");
10419
10424
  }
10420
10425
 
10421
- // ../../node_modules/.pnpm/@wise+forms@0.3.4_@transferwise+components@46.35.0_@types+react@18.0.29_react@18.2.0/node_modules/@wise/forms/dist/index.mjs
10426
+ // ../../node_modules/.pnpm/@wise+forms@0.3.4_@transferwise+components@46.36.0_@types+react@18.0.29_react@18.2.0/node_modules/@wise/forms/dist/index.mjs
10422
10427
  var import_classnames = __toESM(require_classnames(), 1);
10423
10428
  import { InlineAlert, Sentiment as Sentiment2, Input, TextArea } from "@transferwise/components";
10424
10429
  import { createContext as createContext2, useContext as useContext2, forwardRef } from "react";
@@ -10712,7 +10717,16 @@ function VariableDateInput({
10712
10717
  control,
10713
10718
  inputProps
10714
10719
  }) {
10715
- const { minimumDate, maximumDate, placeholder, disabled, onBlur, onChange, onFocus } = inputProps;
10720
+ const {
10721
+ autoComplete,
10722
+ minimumDate,
10723
+ maximumDate,
10724
+ placeholder,
10725
+ disabled,
10726
+ onBlur,
10727
+ onChange,
10728
+ onFocus
10729
+ } = inputProps;
10716
10730
  if (control === "date-lookup") {
10717
10731
  return /* @__PURE__ */ jsx16(
10718
10732
  DateLookup,
@@ -10730,8 +10744,20 @@ function VariableDateInput({
10730
10744
  }
10731
10745
  );
10732
10746
  }
10733
- return /* @__PURE__ */ jsx16(DateInput, __spreadValues({}, inputProps));
10747
+ return /* @__PURE__ */ jsx16(
10748
+ DateInput,
10749
+ __spreadProps(__spreadValues({}, inputProps), {
10750
+ dayAutoComplete: getAutocompleteString2(autoComplete, "day"),
10751
+ yearAutoComplete: getAutocompleteString2(autoComplete, "year")
10752
+ })
10753
+ );
10734
10754
  }
10755
+ var getAutocompleteString2 = (value, suffix) => {
10756
+ if (value === "bday") {
10757
+ return `${value}-${suffix}`;
10758
+ }
10759
+ return void 0;
10760
+ };
10735
10761
  var VariableDateInput_default = VariableDateInput;
10736
10762
 
10737
10763
  // src/revamp/wise/renderers/DateInputRenderer.tsx
@@ -15447,7 +15473,7 @@ var logInvalidTypeFallbackWarning = ({
15447
15473
  };
15448
15474
 
15449
15475
  // src/legacy/formControl/utils/getAutocompleteString.ts
15450
- var getAutocompleteString2 = (hints, { prefix = "", suffix = "" } = {}) => {
15476
+ var getAutocompleteString3 = (hints, { prefix = "", suffix = "" } = {}) => {
15451
15477
  const autoCompleteString = hints.map((hint) => {
15452
15478
  const builtHint = `${prefix}${hint}${suffix}`;
15453
15479
  return isAutocompleteToken(builtHint) ? autocompleteTokenMap2[builtHint] : void 0;
@@ -15530,7 +15556,7 @@ var _FormControl = class _FormControl extends PureComponent {
15530
15556
  this.getAutocompleteValue = ({ prefix = "", suffix = "" } = {}) => {
15531
15557
  const { autoComplete, autocompleteHint } = this.props;
15532
15558
  if (isArray2(autocompleteHint)) {
15533
- return getAutocompleteString2(autocompleteHint, { prefix, suffix });
15559
+ return getAutocompleteString3(autocompleteHint, { prefix, suffix });
15534
15560
  }
15535
15561
  return autoComplete ? "on" : "off";
15536
15562
  };
@@ -137,4 +137,4 @@ export var createSelectInputComponent = function (selectProps, updateComponent)
137
137
  });
138
138
  } });
139
139
  };
140
- var isTrue = function (value) { return value; };
140
+ var isTrue = function (value) { return value === true; };
@@ -23,17 +23,22 @@ export var isPartialLocalValueMatch = function (partialValue, component) {
23
23
  return isPartialObjectMatch(partialValue, componentValue, component);
24
24
  }
25
25
  // TODO: Handle tuples, when supported.
26
- return true;
26
+ return null;
27
27
  };
28
28
  var isPartialObjectMatch = function (partialValue, componentValue, component) {
29
- var resultByKey = getMatchingKeys(partialValue, componentValue).map(function (key) {
29
+ var results = getMatchingKeys(partialValue, componentValue).map(function (key) {
30
30
  var componentForKey = getComponentForLocalValueKey(key, component);
31
- if (componentForKey && componentForKey.type === 'const') {
32
- return isPartialLocalValueMatch(partialValue[key], componentForKey);
33
- }
34
- return null;
31
+ return componentForKey && componentForKey.type === 'const'
32
+ ? isPartialLocalValueMatch(partialValue[key], componentForKey)
33
+ : null;
35
34
  });
36
- return resultByKey.includes(true) && !resultByKey.includes(false);
35
+ if (results.includes(false)) {
36
+ return false;
37
+ }
38
+ if (results.includes(true)) {
39
+ return true;
40
+ }
41
+ return null;
37
42
  };
38
43
  var getMatchingKeys = function (a, b) {
39
44
  var allKeys = Array.from(new Set(__spreadArray(__spreadArray([], Object.keys(a), true), Object.keys(b), true)));
@@ -7,9 +7,12 @@ var makeConstComponent = function (value) {
7
7
  };
8
8
  describe('isPartialLocalValueMatch', function () {
9
9
  describe('when the component type is "const"', function () {
10
- it('should return false if values are different', function () {
10
+ it('should return false if values are different (object)', function () {
11
11
  expect(isPartialLocalValueMatch({ some: 'value' }, makeConstComponent({ some: 'other-value' }))).toBe(false);
12
12
  });
13
+ it('should return false if values are different (array)', function () {
14
+ expect(isPartialLocalValueMatch(['aaa', 'bbb'], makeConstComponent(['aaa', 'bbb', 'ccc']))).toBe(false);
15
+ });
13
16
  it('should return true if primitive values are identical', function () {
14
17
  expect(isPartialLocalValueMatch(1234, makeConstComponent(1234))).toBe(true);
15
18
  });
@@ -19,6 +22,9 @@ describe('isPartialLocalValueMatch', function () {
19
22
  it('should return true if object values are identical', function () {
20
23
  expect(isPartialLocalValueMatch({ a: 'aaa', b: 111 }, makeConstComponent({ a: 'aaa', b: 111 }))).toBe(true);
21
24
  });
25
+ it('should return true if array values are identical', function () {
26
+ expect(isPartialLocalValueMatch(['aaa', 'bbb'], makeConstComponent(['aaa', 'bbb']))).toBe(true);
27
+ });
22
28
  it('should return true if empty-object values are identical', function () {
23
29
  expect(isPartialLocalValueMatch({}, makeConstComponent({}))).toBe(true);
24
30
  });
@@ -48,11 +54,11 @@ describe('isPartialLocalValueMatch', function () {
48
54
  it('should return false if one mismatching constant value is present', function () {
49
55
  expect(isPartialLocalValueMatch({ type: 'OTHER-VALUE' }, objectComponent)).toBe(false);
50
56
  });
51
- it('should return false if NO matching constant value is present', function () {
52
- expect(isPartialLocalValueMatch({}, objectComponent)).toBe(false);
57
+ it('should return null if NO matching constant value is present', function () {
58
+ expect(isPartialLocalValueMatch({}, objectComponent)).toBeNull();
53
59
  });
54
- it('should return false when some other non-const property matches', function () {
55
- expect(isPartialLocalValueMatch({ other: 'some string' }, objectComponent)).toBe(false);
60
+ it('should return null when some other non-const property matches', function () {
61
+ expect(isPartialLocalValueMatch({ other: 'some string' }, objectComponent)).toBeNull();
56
62
  });
57
63
  });
58
64
  describe('when the component type is "all-of"', function () {
@@ -67,21 +73,21 @@ describe('isPartialLocalValueMatch', function () {
67
73
  it('should return false if one mismatching constant value is present', function () {
68
74
  expect(isPartialLocalValueMatch({ type: 'OTHER-VALUE' }, allofComponent)).toBe(false);
69
75
  });
70
- it('should return false if NO matching constant value is present', function () {
71
- expect(isPartialLocalValueMatch({}, allofComponent)).toBe(false);
76
+ it('should return null if NO matching constant value is present', function () {
77
+ expect(isPartialLocalValueMatch({}, allofComponent)).toBeNull();
72
78
  });
73
79
  });
74
80
  });
75
81
  describe('when the local value is a File instance', function () {
76
- it('should return true, when comparing files (with persist-async)', function () {
82
+ it('should return null, when comparing files (with persist-async)', function () {
77
83
  var localValue = new File(['ABCD'], 'a.txt', { type: 'text/plain' });
78
84
  var componentB = {
79
85
  isPersisted: true,
80
86
  getLocalValue: function () { return 'it doesnt matter what the value is'; },
81
87
  };
82
- expect(isPartialLocalValueMatch(localValue, componentB)).toBe(true);
88
+ expect(isPartialLocalValueMatch(localValue, componentB)).toBeNull();
83
89
  });
84
- it('should return true, when comparing files (base64url string)', function () {
90
+ it('should return null, when comparing files (base64url string)', function () {
85
91
  var localValue = new File(['ABCD'], 'a.txt', { type: 'text/plain' });
86
92
  var componentB = {
87
93
  type: 'upload',
@@ -89,17 +95,17 @@ describe('isPartialLocalValueMatch', function () {
89
95
  return new File(['it doesnt matter'], 'irrelevant.png', { type: 'image/png' });
90
96
  },
91
97
  };
92
- expect(isPartialLocalValueMatch(localValue, componentB)).toBe(true);
98
+ expect(isPartialLocalValueMatch(localValue, componentB)).toBeNull();
93
99
  });
94
100
  });
95
101
  describe('when the local value is an array and the component is "repeatable"', function () {
96
- it('should return true even with different elements', function () {
102
+ it('should return null, even with different elements', function () {
97
103
  var localValue = ['a', 'b', 'c'];
98
104
  var componentB = {
99
105
  type: 'repeatable',
100
106
  getLocalValue: function () { return ['d', 'e', 'f', 'g']; },
101
107
  };
102
- expect(isPartialLocalValueMatch(localValue, componentB)).toBe(true);
108
+ expect(isPartialLocalValueMatch(localValue, componentB)).toBeNull();
103
109
  });
104
110
  });
105
111
  describe('when the local value is an array and the component is "multi-upload"', function () {
@@ -107,13 +113,13 @@ describe('isPartialLocalValueMatch', function () {
107
113
  var fileB = new File(['B'], 'b.txt', { type: 'text/plain' });
108
114
  var fileC = new File(['C'], 'c.txt', { type: 'text/plain' });
109
115
  var fileD = new File(['D'], 'd.txt', { type: 'text/plain' });
110
- it('should return true even with different elements', function () {
116
+ it('should return null, even with different elements', function () {
111
117
  var localValue = [fileA, fileB];
112
118
  var componentB = {
113
119
  type: 'multi-upload',
114
120
  getLocalValue: function () { return [fileC, fileD]; },
115
121
  };
116
- expect(isPartialLocalValueMatch(localValue, componentB)).toBe(true);
122
+ expect(isPartialLocalValueMatch(localValue, componentB)).toBeNull();
117
123
  });
118
124
  });
119
125
  });
@@ -5,7 +5,10 @@ export var compareLocalValue = function (valueA, valueB) {
5
5
  valueA.every(function (value, index) { return compareLocalValue(value, valueB[index]); }));
6
6
  }
7
7
  if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
8
- return Object.keys(valueA).every(function (key) { return compareLocalValue(valueA[key], valueB[key]); });
8
+ var keysA = Object.keys(valueA);
9
+ var keysB = Object.keys(valueB);
10
+ return (keysA.length === keysB.length &&
11
+ keysA.every(function (key) { return compareLocalValue(valueA[key], valueB[key]); }));
9
12
  }
10
13
  return valueA === valueB;
11
14
  };
@@ -745,6 +745,7 @@ describe('OneOf Initialisation', function () {
745
745
  renderWithProviders(_jsx(DynamicFlowWise, __assign({}, getDefaultProps(), { initialStep: __assign(__assign({}, contrivedStep), { model: {
746
746
  frequency: 'MONTHLY',
747
747
  interval: 3,
748
+ letters: ['A', 'B'],
748
749
  } }) })));
749
750
  expect(screen.getByText(/Quarterly/)).toBeInTheDocument();
750
751
  return [2 /*return*/];
@@ -763,6 +764,18 @@ describe('OneOf Initialisation', function () {
763
764
  return [2 /*return*/];
764
765
  });
765
766
  }); });
767
+ it('should NOT select an option based on step model, when the const model has fewer properties', function () { return __awaiter(void 0, void 0, void 0, function () {
768
+ return __generator(this, function (_a) {
769
+ renderWithProviders(_jsx(DynamicFlowWise, __assign({}, getDefaultProps(), { initialStep: __assign(__assign({}, contrivedStep), { model: {
770
+ frequency: 'MONTHLY',
771
+ interval: 3,
772
+ // missing the `letters` property... letters: ['A', 'B'],
773
+ } }) })));
774
+ expect(screen.queryByText(/Quarterly/)).not.toBeInTheDocument();
775
+ expect(screen.queryByText(/Monthly/)).not.toBeInTheDocument();
776
+ return [2 /*return*/];
777
+ });
778
+ }); });
766
779
  });
767
780
  describe('when the model is an object with properties that are only present in one of the oneOf object schemas, but there are no discriminating consts', function () {
768
781
  var abxyStep = {
@@ -15,7 +15,7 @@ import { DateInput, DateLookup } from '@transferwise/components';
15
15
  import { dateStringToDateOrNull, dateToDateString } from '../utils/value-utils';
16
16
  function VariableDateInput(_a) {
17
17
  var control = _a.control, inputProps = _a.inputProps;
18
- var minimumDate = inputProps.minimumDate, maximumDate = inputProps.maximumDate, placeholder = inputProps.placeholder, disabled = inputProps.disabled, onBlur = inputProps.onBlur, onChange = inputProps.onChange, onFocus = inputProps.onFocus;
18
+ var autoComplete = inputProps.autoComplete, minimumDate = inputProps.minimumDate, maximumDate = inputProps.maximumDate, placeholder = inputProps.placeholder, disabled = inputProps.disabled, onBlur = inputProps.onBlur, onChange = inputProps.onChange, onFocus = inputProps.onFocus;
19
19
  if (control === 'date-lookup') {
20
20
  return (_jsx(DateLookup
21
21
  // DateLookup handles null values perfectly well, it's just typed incorrectly
@@ -25,6 +25,12 @@ function VariableDateInput(_a) {
25
25
  onChange(date !== null ? dateToDateString(date) : null);
26
26
  }, onBlur: onBlur, onFocus: onFocus }));
27
27
  }
28
- return _jsx(DateInput, __assign({}, inputProps));
28
+ return (_jsx(DateInput, __assign({}, inputProps, { dayAutoComplete: getAutocompleteString(autoComplete, 'day'), yearAutoComplete: getAutocompleteString(autoComplete, 'year') })));
29
29
  }
30
+ var getAutocompleteString = function (value, suffix) {
31
+ if (value === 'bday') {
32
+ return "".concat(value, "-").concat(suffix);
33
+ }
34
+ return undefined;
35
+ };
30
36
  export default VariableDateInput;
@@ -1,2 +1,2 @@
1
1
  import type { DomainComponent, LocalValue } from '../../types';
2
- export declare const isPartialLocalValueMatch: (partialValue: LocalValue, component: DomainComponent | null) => boolean;
2
+ export declare const isPartialLocalValueMatch: (partialValue: LocalValue, component: DomainComponent | null) => boolean | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-client",
3
- "version": "3.11.4-experimental-node20-6554c5d",
3
+ "version": "3.11.4-experimental-node-20-x-9761807",
4
4
  "description": "Dynamic Flow web client",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./build/main.min.js",
@@ -40,7 +40,7 @@
40
40
  "@testing-library/react": "14.3.0",
41
41
  "@testing-library/react-hooks": "8.0.1",
42
42
  "@testing-library/user-event": "14.5.2",
43
- "@transferwise/components": "46.35.0",
43
+ "@transferwise/components": "46.36.0",
44
44
  "@transferwise/formatting": "^2.13.0",
45
45
  "@transferwise/icons": "3.13.0",
46
46
  "@transferwise/neptune-css": "14.10.0",
@@ -90,7 +90,7 @@
90
90
  "classnames": "2.5.1",
91
91
  "react-webcam": "^7.2.0",
92
92
  "screenfull": "^5.2.0",
93
- "@wise/dynamic-flow-types": "2.15.1-experimental-node20-6554c5d"
93
+ "@wise/dynamic-flow-types": "2.15.1-experimental-node-20-x-9761807"
94
94
  },
95
95
  "scripts": {
96
96
  "dev": "storybook dev -p 3003",