@abgov/jsonforms-components 2.4.0 → 2.4.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/index.esm.js CHANGED
@@ -2719,59 +2719,201 @@ $$o({ global: true, constructor: true, forced: FORCED$3 }, {
2719
2719
  Iterator: IteratorConstructor
2720
2720
  });
2721
2721
 
2722
- // `GetIteratorDirect(obj)` abstract operation
2723
- // https://tc39.es/proposal-iterator-helpers/#sec-getiteratordirect
2724
- var getIteratorDirect$7 = function (obj) {
2725
- return {
2726
- iterator: obj,
2727
- next: obj.next,
2728
- done: false
2722
+ var uncurryThis$a = functionUncurryThisClause;
2723
+ var aCallable$d = aCallable$g;
2724
+ var NATIVE_BIND = functionBindNative;
2725
+
2726
+ var bind$5 = uncurryThis$a(uncurryThis$a.bind);
2727
+
2728
+ // optional / simple context binding
2729
+ var functionBindContext = function (fn, that) {
2730
+ aCallable$d(fn);
2731
+ return that === undefined ? fn : NATIVE_BIND ? bind$5(fn, that) : function (/* ...args */) {
2732
+ return fn.apply(that, arguments);
2729
2733
  };
2730
2734
  };
2731
2735
 
2732
- var defineBuiltIn$3 = defineBuiltIn$9;
2736
+ var wellKnownSymbol$8 = wellKnownSymbol$m;
2737
+ var Iterators$1 = iterators;
2733
2738
 
2734
- var defineBuiltIns$1 = function (target, src, options) {
2735
- for (var key in src) defineBuiltIn$3(target, key, src[key], options);
2736
- return target;
2739
+ var ITERATOR$3 = wellKnownSymbol$8('iterator');
2740
+ var ArrayPrototype = Array.prototype;
2741
+
2742
+ // check on default Array iterator
2743
+ var isArrayIteratorMethod$1 = function (it) {
2744
+ return it !== undefined && (Iterators$1.Array === it || ArrayPrototype[ITERATOR$3] === it);
2745
+ };
2746
+
2747
+ var classof$5 = classof$9;
2748
+ var getMethod$3 = getMethod$6;
2749
+ var isNullOrUndefined$2 = isNullOrUndefined$6;
2750
+ var Iterators = iterators;
2751
+ var wellKnownSymbol$7 = wellKnownSymbol$m;
2752
+
2753
+ var ITERATOR$2 = wellKnownSymbol$7('iterator');
2754
+
2755
+ var getIteratorMethod$2 = function (it) {
2756
+ if (!isNullOrUndefined$2(it)) return getMethod$3(it, ITERATOR$2)
2757
+ || getMethod$3(it, '@@iterator')
2758
+ || Iterators[classof$5(it)];
2737
2759
  };
2738
2760
 
2739
2761
  var call$a = functionCall;
2762
+ var aCallable$c = aCallable$g;
2740
2763
  var anObject$d = anObject$o;
2741
- var getMethod$3 = getMethod$6;
2764
+ var tryToString$2 = tryToString$4;
2765
+ var getIteratorMethod$1 = getIteratorMethod$2;
2766
+
2767
+ var $TypeError$9 = TypeError;
2768
+
2769
+ var getIterator$1 = function (argument, usingIterator) {
2770
+ var iteratorMethod = arguments.length < 2 ? getIteratorMethod$1(argument) : usingIterator;
2771
+ if (aCallable$c(iteratorMethod)) return anObject$d(call$a(iteratorMethod, argument));
2772
+ throw new $TypeError$9(tryToString$2(argument) + ' is not iterable');
2773
+ };
2774
+
2775
+ var call$9 = functionCall;
2776
+ var anObject$c = anObject$o;
2777
+ var getMethod$2 = getMethod$6;
2742
2778
 
2743
2779
  var iteratorClose$3 = function (iterator, kind, value) {
2744
2780
  var innerResult, innerError;
2745
- anObject$d(iterator);
2781
+ anObject$c(iterator);
2746
2782
  try {
2747
- innerResult = getMethod$3(iterator, 'return');
2783
+ innerResult = getMethod$2(iterator, 'return');
2748
2784
  if (!innerResult) {
2749
2785
  if (kind === 'throw') throw value;
2750
2786
  return value;
2751
2787
  }
2752
- innerResult = call$a(innerResult, iterator);
2788
+ innerResult = call$9(innerResult, iterator);
2753
2789
  } catch (error) {
2754
2790
  innerError = true;
2755
2791
  innerResult = error;
2756
2792
  }
2757
2793
  if (kind === 'throw') throw value;
2758
2794
  if (innerError) throw innerResult;
2759
- anObject$d(innerResult);
2795
+ anObject$c(innerResult);
2760
2796
  return value;
2761
2797
  };
2762
2798
 
2763
- var call$9 = functionCall;
2799
+ var bind$4 = functionBindContext;
2800
+ var call$8 = functionCall;
2801
+ var anObject$b = anObject$o;
2802
+ var tryToString$1 = tryToString$4;
2803
+ var isArrayIteratorMethod = isArrayIteratorMethod$1;
2804
+ var lengthOfArrayLike$4 = lengthOfArrayLike$7;
2805
+ var isPrototypeOf$2 = objectIsPrototypeOf;
2806
+ var getIterator = getIterator$1;
2807
+ var getIteratorMethod = getIteratorMethod$2;
2808
+ var iteratorClose$2 = iteratorClose$3;
2809
+
2810
+ var $TypeError$8 = TypeError;
2811
+
2812
+ var Result = function (stopped, result) {
2813
+ this.stopped = stopped;
2814
+ this.result = result;
2815
+ };
2816
+
2817
+ var ResultPrototype = Result.prototype;
2818
+
2819
+ var iterate$8 = function (iterable, unboundFunction, options) {
2820
+ var that = options && options.that;
2821
+ var AS_ENTRIES = !!(options && options.AS_ENTRIES);
2822
+ var IS_RECORD = !!(options && options.IS_RECORD);
2823
+ var IS_ITERATOR = !!(options && options.IS_ITERATOR);
2824
+ var INTERRUPTED = !!(options && options.INTERRUPTED);
2825
+ var fn = bind$4(unboundFunction, that);
2826
+ var iterator, iterFn, index, length, result, next, step;
2827
+
2828
+ var stop = function (condition) {
2829
+ if (iterator) iteratorClose$2(iterator, 'normal', condition);
2830
+ return new Result(true, condition);
2831
+ };
2832
+
2833
+ var callFn = function (value) {
2834
+ if (AS_ENTRIES) {
2835
+ anObject$b(value);
2836
+ return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
2837
+ } return INTERRUPTED ? fn(value, stop) : fn(value);
2838
+ };
2839
+
2840
+ if (IS_RECORD) {
2841
+ iterator = iterable.iterator;
2842
+ } else if (IS_ITERATOR) {
2843
+ iterator = iterable;
2844
+ } else {
2845
+ iterFn = getIteratorMethod(iterable);
2846
+ if (!iterFn) throw new $TypeError$8(tryToString$1(iterable) + ' is not iterable');
2847
+ // optimisation for array iterators
2848
+ if (isArrayIteratorMethod(iterFn)) {
2849
+ for (index = 0, length = lengthOfArrayLike$4(iterable); length > index; index++) {
2850
+ result = callFn(iterable[index]);
2851
+ if (result && isPrototypeOf$2(ResultPrototype, result)) return result;
2852
+ } return new Result(false);
2853
+ }
2854
+ iterator = getIterator(iterable, iterFn);
2855
+ }
2856
+
2857
+ next = IS_RECORD ? iterable.next : iterator.next;
2858
+ while (!(step = call$8(next, iterator)).done) {
2859
+ try {
2860
+ result = callFn(step.value);
2861
+ } catch (error) {
2862
+ iteratorClose$2(iterator, 'throw', error);
2863
+ }
2864
+ if (typeof result == 'object' && result && isPrototypeOf$2(ResultPrototype, result)) return result;
2865
+ } return new Result(false);
2866
+ };
2867
+
2868
+ // `GetIteratorDirect(obj)` abstract operation
2869
+ // https://tc39.es/proposal-iterator-helpers/#sec-getiteratordirect
2870
+ var getIteratorDirect$7 = function (obj) {
2871
+ return {
2872
+ iterator: obj,
2873
+ next: obj.next,
2874
+ done: false
2875
+ };
2876
+ };
2877
+
2878
+ var $$n = _export;
2879
+ var iterate$7 = iterate$8;
2880
+ var aCallable$b = aCallable$g;
2881
+ var anObject$a = anObject$o;
2882
+ var getIteratorDirect$6 = getIteratorDirect$7;
2883
+
2884
+ // `Iterator.prototype.find` method
2885
+ // https://github.com/tc39/proposal-iterator-helpers
2886
+ $$n({ target: 'Iterator', proto: true, real: true }, {
2887
+ find: function find(predicate) {
2888
+ anObject$a(this);
2889
+ aCallable$b(predicate);
2890
+ var record = getIteratorDirect$6(this);
2891
+ var counter = 0;
2892
+ return iterate$7(record, function (value, stop) {
2893
+ if (predicate(value, counter++)) return stop(value);
2894
+ }, { IS_RECORD: true, INTERRUPTED: true }).result;
2895
+ }
2896
+ });
2897
+
2898
+ var defineBuiltIn$3 = defineBuiltIn$9;
2899
+
2900
+ var defineBuiltIns$1 = function (target, src, options) {
2901
+ for (var key in src) defineBuiltIn$3(target, key, src[key], options);
2902
+ return target;
2903
+ };
2904
+
2905
+ var call$7 = functionCall;
2764
2906
  var create$1 = objectCreate;
2765
2907
  var createNonEnumerableProperty$1 = createNonEnumerableProperty$a;
2766
2908
  var defineBuiltIns = defineBuiltIns$1;
2767
- var wellKnownSymbol$8 = wellKnownSymbol$m;
2909
+ var wellKnownSymbol$6 = wellKnownSymbol$m;
2768
2910
  var InternalStateModule$1 = internalState;
2769
- var getMethod$2 = getMethod$6;
2911
+ var getMethod$1 = getMethod$6;
2770
2912
  var IteratorPrototype = iteratorsCore.IteratorPrototype;
2771
2913
  var createIterResultObject = createIterResultObject$2;
2772
- var iteratorClose$2 = iteratorClose$3;
2914
+ var iteratorClose$1 = iteratorClose$3;
2773
2915
 
2774
- var TO_STRING_TAG = wellKnownSymbol$8('toStringTag');
2916
+ var TO_STRING_TAG = wellKnownSymbol$6('toStringTag');
2775
2917
  var ITERATOR_HELPER = 'IteratorHelper';
2776
2918
  var WRAP_FOR_VALID_ITERATOR = 'WrapForValidIterator';
2777
2919
  var setInternalState$1 = InternalStateModule$1.set;
@@ -2799,15 +2941,15 @@ var createIteratorProxyPrototype = function (IS_ITERATOR) {
2799
2941
  var iterator = state.iterator;
2800
2942
  state.done = true;
2801
2943
  if (IS_ITERATOR) {
2802
- var returnMethod = getMethod$2(iterator, 'return');
2803
- return returnMethod ? call$9(returnMethod, iterator) : createIterResultObject(undefined, true);
2944
+ var returnMethod = getMethod$1(iterator, 'return');
2945
+ return returnMethod ? call$7(returnMethod, iterator) : createIterResultObject(undefined, true);
2804
2946
  }
2805
2947
  if (state.inner) try {
2806
- iteratorClose$2(state.inner.iterator, 'normal');
2948
+ iteratorClose$1(state.inner.iterator, 'normal');
2807
2949
  } catch (error) {
2808
- return iteratorClose$2(iterator, 'throw', error);
2950
+ return iteratorClose$1(iterator, 'throw', error);
2809
2951
  }
2810
- iteratorClose$2(iterator, 'normal');
2952
+ iteratorClose$1(iterator, 'normal');
2811
2953
  return createIterResultObject(undefined, true);
2812
2954
  }
2813
2955
  });
@@ -2836,28 +2978,28 @@ var iteratorCreateProxy = function (nextHandler, IS_ITERATOR) {
2836
2978
  return IteratorProxy;
2837
2979
  };
2838
2980
 
2839
- var anObject$c = anObject$o;
2840
- var iteratorClose$1 = iteratorClose$3;
2981
+ var anObject$9 = anObject$o;
2982
+ var iteratorClose = iteratorClose$3;
2841
2983
 
2842
2984
  // call something on iterator step with safe closing on error
2843
2985
  var callWithSafeIterationClosing$2 = function (iterator, fn, value, ENTRIES) {
2844
2986
  try {
2845
- return ENTRIES ? fn(anObject$c(value)[0], value[1]) : fn(value);
2987
+ return ENTRIES ? fn(anObject$9(value)[0], value[1]) : fn(value);
2846
2988
  } catch (error) {
2847
- iteratorClose$1(iterator, 'throw', error);
2989
+ iteratorClose(iterator, 'throw', error);
2848
2990
  }
2849
2991
  };
2850
2992
 
2851
- var call$8 = functionCall;
2852
- var aCallable$d = aCallable$g;
2853
- var anObject$b = anObject$o;
2854
- var getIteratorDirect$6 = getIteratorDirect$7;
2993
+ var call$6 = functionCall;
2994
+ var aCallable$a = aCallable$g;
2995
+ var anObject$8 = anObject$o;
2996
+ var getIteratorDirect$5 = getIteratorDirect$7;
2855
2997
  var createIteratorProxy$1 = iteratorCreateProxy;
2856
2998
  var callWithSafeIterationClosing$1 = callWithSafeIterationClosing$2;
2857
2999
 
2858
3000
  var IteratorProxy$1 = createIteratorProxy$1(function () {
2859
3001
  var iterator = this.iterator;
2860
- var result = anObject$b(call$8(this.next, iterator));
3002
+ var result = anObject$8(call$6(this.next, iterator));
2861
3003
  var done = this.done = !!result.done;
2862
3004
  if (!done) return callWithSafeIterationClosing$1(iterator, this.mapper, [result.value, this.counter++], true);
2863
3005
  });
@@ -2865,20 +3007,20 @@ var IteratorProxy$1 = createIteratorProxy$1(function () {
2865
3007
  // `Iterator.prototype.map` method
2866
3008
  // https://github.com/tc39/proposal-iterator-helpers
2867
3009
  var iteratorMap = function map(mapper) {
2868
- anObject$b(this);
2869
- aCallable$d(mapper);
2870
- return new IteratorProxy$1(getIteratorDirect$6(this), {
3010
+ anObject$8(this);
3011
+ aCallable$a(mapper);
3012
+ return new IteratorProxy$1(getIteratorDirect$5(this), {
2871
3013
  mapper: mapper
2872
3014
  });
2873
3015
  };
2874
3016
 
2875
- var $$n = _export;
3017
+ var $$m = _export;
2876
3018
  var map = iteratorMap;
2877
3019
  var IS_PURE$1 = isPure;
2878
3020
 
2879
3021
  // `Iterator.prototype.map` method
2880
3022
  // https://github.com/tc39/proposal-iterator-helpers
2881
- $$n({ target: 'Iterator', proto: true, real: true, forced: IS_PURE$1 }, {
3023
+ $$m({ target: 'Iterator', proto: true, real: true, forced: IS_PURE$1 }, {
2882
3024
  map: map
2883
3025
  });
2884
3026
 
@@ -2950,6 +3092,28 @@ const validateSinWithLuhn = input => {
2950
3092
  }
2951
3093
  return sum % 10 === 0;
2952
3094
  };
3095
+ /**
3096
+ * Gets the required field in the If/Then json schema condition.
3097
+ * @param props - ControlProps
3098
+ * @returns - The required field name.
3099
+ */
3100
+ const getRequiredIfThen = props => {
3101
+ var _a, _b, _c, _d;
3102
+ const {
3103
+ path
3104
+ } = props;
3105
+ const rootSchema = props.rootSchema;
3106
+ let rootRequired = '';
3107
+ if ((rootSchema === null || rootSchema === void 0 ? void 0 : rootSchema.if) && rootSchema.then) {
3108
+ if (((_a = rootSchema === null || rootSchema === void 0 ? void 0 : rootSchema.then) === null || _a === void 0 ? void 0 : _a.required) && Array.isArray((_b = rootSchema.then) === null || _b === void 0 ? void 0 : _b.required)) {
3109
+ const foundRequired = (_d = (_c = rootSchema.then) === null || _c === void 0 ? void 0 : _c.required) === null || _d === void 0 ? void 0 : _d.find(req => req === path);
3110
+ if (foundRequired !== undefined) {
3111
+ rootRequired = foundRequired;
3112
+ }
3113
+ }
3114
+ }
3115
+ return rootRequired;
3116
+ };
2953
3117
  /**
2954
3118
  * Check if a required, defined input value is valid. Returns an appropriate
2955
3119
  * error message if not.
@@ -2965,7 +3129,7 @@ const checkFieldValidity = props => {
2965
3129
  uischema,
2966
3130
  schema
2967
3131
  } = props;
2968
- const labelToUpdate = (uischema === null || uischema === void 0 ? void 0 : uischema.scope) ? getLabelText(uischema === null || uischema === void 0 ? void 0 : uischema.scope, label) : label;
3132
+ const labelToUpdate = (uischema === null || uischema === void 0 ? void 0 : uischema.scope) ? convertToSentenceCase(getLabelText(uischema === null || uischema === void 0 ? void 0 : uischema.scope, label)) : label;
2969
3133
  const extraSchema = schema;
2970
3134
  if (extraSchema && data && (extraSchema === null || extraSchema === void 0 ? void 0 : extraSchema.title) === sinTitle) {
2971
3135
  if (data.length === 11 && !validateSinWithLuhn(data)) {
@@ -2974,7 +3138,8 @@ const checkFieldValidity = props => {
2974
3138
  return extraSchema.errorMessage;
2975
3139
  }
2976
3140
  }
2977
- if (required) {
3141
+ const rootRequired = getRequiredIfThen(props);
3142
+ if (required || rootRequired.length > 0) {
2978
3143
  if (schema) {
2979
3144
  if (isEmptyBoolean(schema, data)) {
2980
3145
  return `${labelToUpdate} is required`;
@@ -3043,11 +3208,11 @@ const convertToSentenceCase = input => {
3043
3208
  return firstWord.concat(newWords).join(' ');
3044
3209
  };
3045
3210
 
3046
- var $$m = _export;
3047
- var call$7 = functionCall;
3048
- var aCallable$c = aCallable$g;
3049
- var anObject$a = anObject$o;
3050
- var getIteratorDirect$5 = getIteratorDirect$7;
3211
+ var $$l = _export;
3212
+ var call$5 = functionCall;
3213
+ var aCallable$9 = aCallable$g;
3214
+ var anObject$7 = anObject$o;
3215
+ var getIteratorDirect$4 = getIteratorDirect$7;
3051
3216
  var createIteratorProxy = iteratorCreateProxy;
3052
3217
  var callWithSafeIterationClosing = callWithSafeIterationClosing$2;
3053
3218
  var IS_PURE = isPure;
@@ -3058,7 +3223,7 @@ var IteratorProxy = createIteratorProxy(function () {
3058
3223
  var next = this.next;
3059
3224
  var result, done, value;
3060
3225
  while (true) {
3061
- result = anObject$a(call$7(next, iterator));
3226
+ result = anObject$7(call$5(next, iterator));
3062
3227
  done = this.done = !!result.done;
3063
3228
  if (done) return;
3064
3229
  value = result.value;
@@ -3068,11 +3233,11 @@ var IteratorProxy = createIteratorProxy(function () {
3068
3233
 
3069
3234
  // `Iterator.prototype.filter` method
3070
3235
  // https://github.com/tc39/proposal-iterator-helpers
3071
- $$m({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
3236
+ $$l({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
3072
3237
  filter: function filter(predicate) {
3073
- anObject$a(this);
3074
- aCallable$c(predicate);
3075
- return new IteratorProxy(getIteratorDirect$5(this), {
3238
+ anObject$7(this);
3239
+ aCallable$9(predicate);
3240
+ return new IteratorProxy(getIteratorDirect$4(this), {
3076
3241
  predicate: predicate
3077
3242
  });
3078
3243
  }
@@ -3352,19 +3517,19 @@ const ADD_NO_ANONYMOUS_ACTION = 'jsonforms/register/no_anonymous';
3352
3517
  const ADD_DATALIST_ACTION = 'jsonforms/register/add_datalist_action';
3353
3518
  const ADD_REGISTER_DATA_ERROR = 'jsonforms/register/add_register_data_error';
3354
3519
 
3355
- var classof$5 = classofRaw$2;
3520
+ var classof$4 = classofRaw$2;
3356
3521
 
3357
3522
  // `IsArray` abstract operation
3358
3523
  // https://tc39.es/ecma262/#sec-isarray
3359
3524
  // eslint-disable-next-line es/no-array-isarray -- safe
3360
3525
  var isArray$4 = Array.isArray || function isArray(argument) {
3361
- return classof$5(argument) === 'Array';
3526
+ return classof$4(argument) === 'Array';
3362
3527
  };
3363
3528
 
3364
3529
  var DESCRIPTORS$5 = descriptors;
3365
3530
  var isArray$3 = isArray$4;
3366
3531
 
3367
- var $TypeError$9 = TypeError;
3532
+ var $TypeError$7 = TypeError;
3368
3533
  // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
3369
3534
  var getOwnPropertyDescriptor$2 = Object.getOwnPropertyDescriptor;
3370
3535
 
@@ -3382,23 +3547,23 @@ var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS$5 && !function () {
3382
3547
 
3383
3548
  var arraySetLength = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) {
3384
3549
  if (isArray$3(O) && !getOwnPropertyDescriptor$2(O, 'length').writable) {
3385
- throw new $TypeError$9('Cannot set read only .length');
3550
+ throw new $TypeError$7('Cannot set read only .length');
3386
3551
  } return O.length = length;
3387
3552
  } : function (O, length) {
3388
3553
  return O.length = length;
3389
3554
  };
3390
3555
 
3391
- var $TypeError$8 = TypeError;
3556
+ var $TypeError$6 = TypeError;
3392
3557
  var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991
3393
3558
 
3394
3559
  var doesNotExceedSafeInteger$2 = function (it) {
3395
- if (it > MAX_SAFE_INTEGER) throw $TypeError$8('Maximum allowed index exceeded');
3560
+ if (it > MAX_SAFE_INTEGER) throw $TypeError$6('Maximum allowed index exceeded');
3396
3561
  return it;
3397
3562
  };
3398
3563
 
3399
- var $$l = _export;
3564
+ var $$k = _export;
3400
3565
  var toObject$2 = toObject$8;
3401
- var lengthOfArrayLike$4 = lengthOfArrayLike$7;
3566
+ var lengthOfArrayLike$3 = lengthOfArrayLike$7;
3402
3567
  var setArrayLength = arraySetLength;
3403
3568
  var doesNotExceedSafeInteger$1 = doesNotExceedSafeInteger$2;
3404
3569
  var fails$8 = fails$t;
@@ -3422,11 +3587,11 @@ var FORCED$2 = INCORRECT_TO_LENGTH || !properErrorOnNonWritableLength();
3422
3587
 
3423
3588
  // `Array.prototype.push` method
3424
3589
  // https://tc39.es/ecma262/#sec-array.prototype.push
3425
- $$l({ target: 'Array', proto: true, arity: 1, forced: FORCED$2 }, {
3590
+ $$k({ target: 'Array', proto: true, arity: 1, forced: FORCED$2 }, {
3426
3591
  // eslint-disable-next-line no-unused-vars -- required for `.length`
3427
3592
  push: function push(item) {
3428
3593
  var O = toObject$2(this);
3429
- var len = lengthOfArrayLike$4(O);
3594
+ var len = lengthOfArrayLike$3(O);
3430
3595
  var argCount = arguments.length;
3431
3596
  doesNotExceedSafeInteger$1(len + argCount);
3432
3597
  for (var i = 0; i < argCount; i++) {
@@ -3473,7 +3638,7 @@ function registerReducer(state, action) {
3473
3638
  return state;
3474
3639
  }
3475
3640
 
3476
- var $$k = _export;
3641
+ var $$j = _export;
3477
3642
  var $includes = arrayIncludes.includes;
3478
3643
  var fails$7 = fails$t;
3479
3644
  var addToUnscopables$1 = addToUnscopables$4;
@@ -3486,7 +3651,7 @@ var BROKEN_ON_SPARSE = fails$7(function () {
3486
3651
 
3487
3652
  // `Array.prototype.includes` method
3488
3653
  // https://tc39.es/ecma262/#sec-array.prototype.includes
3489
- $$k({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
3654
+ $$j({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
3490
3655
  includes: function includes(el /* , fromIndex = 0 */) {
3491
3656
  return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
3492
3657
  }
@@ -3495,17 +3660,17 @@ $$k({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
3495
3660
  // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
3496
3661
  addToUnscopables$1('includes');
3497
3662
 
3498
- var uncurryThis$a = functionUncurryThis;
3663
+ var uncurryThis$9 = functionUncurryThis;
3499
3664
 
3500
- var arraySlice$2 = uncurryThis$a([].slice);
3665
+ var arraySlice$2 = uncurryThis$9([].slice);
3501
3666
 
3502
- var uncurryThis$9 = functionUncurryThis;
3667
+ var uncurryThis$8 = functionUncurryThis;
3503
3668
  var isArray$2 = isArray$4;
3504
3669
  var isCallable$7 = isCallable$r;
3505
- var classof$4 = classofRaw$2;
3670
+ var classof$3 = classofRaw$2;
3506
3671
  var toString$7 = toString$f;
3507
3672
 
3508
- var push = uncurryThis$9([].push);
3673
+ var push = uncurryThis$8([].push);
3509
3674
 
3510
3675
  var getJsonReplacerFunction = function (replacer) {
3511
3676
  if (isCallable$7(replacer)) return replacer;
@@ -3515,7 +3680,7 @@ var getJsonReplacerFunction = function (replacer) {
3515
3680
  for (var i = 0; i < rawLength; i++) {
3516
3681
  var element = replacer[i];
3517
3682
  if (typeof element == 'string') push(keys, element);
3518
- else if (typeof element == 'number' || classof$4(element) === 'Number' || classof$4(element) === 'String') push(keys, toString$7(element));
3683
+ else if (typeof element == 'number' || classof$3(element) === 'Number' || classof$3(element) === 'String') push(keys, toString$7(element));
3519
3684
  }
3520
3685
  var keysLength = keys.length;
3521
3686
  var root = true;
@@ -3529,11 +3694,11 @@ var getJsonReplacerFunction = function (replacer) {
3529
3694
  };
3530
3695
  };
3531
3696
 
3532
- var $$j = _export;
3697
+ var $$i = _export;
3533
3698
  var getBuiltIn$4 = getBuiltIn$9;
3534
3699
  var apply$1 = functionApply;
3535
- var call$6 = functionCall;
3536
- var uncurryThis$8 = functionUncurryThis;
3700
+ var call$4 = functionCall;
3701
+ var uncurryThis$7 = functionUncurryThis;
3537
3702
  var fails$6 = fails$t;
3538
3703
  var isCallable$6 = isCallable$r;
3539
3704
  var isSymbol = isSymbol$3;
@@ -3543,11 +3708,11 @@ var NATIVE_SYMBOL$1 = symbolConstructorDetection;
3543
3708
 
3544
3709
  var $String = String;
3545
3710
  var $stringify = getBuiltIn$4('JSON', 'stringify');
3546
- var exec$3 = uncurryThis$8(/./.exec);
3547
- var charAt$1 = uncurryThis$8(''.charAt);
3548
- var charCodeAt = uncurryThis$8(''.charCodeAt);
3549
- var replace$3 = uncurryThis$8(''.replace);
3550
- var numberToString = uncurryThis$8(1.0.toString);
3711
+ var exec$3 = uncurryThis$7(/./.exec);
3712
+ var charAt$1 = uncurryThis$7(''.charAt);
3713
+ var charCodeAt = uncurryThis$7(''.charCodeAt);
3714
+ var replace$3 = uncurryThis$7(''.replace);
3715
+ var numberToString = uncurryThis$7(1.0.toString);
3551
3716
 
3552
3717
  var tester = /[\uD800-\uDFFF]/g;
3553
3718
  var low = /^[\uD800-\uDBFF]$/;
@@ -3575,7 +3740,7 @@ var stringifyWithSymbolsFix = function (it, replacer) {
3575
3740
  if (!isCallable$6($replacer) && (it === undefined || isSymbol(it))) return; // IE8 returns string on undefined
3576
3741
  args[1] = function (key, value) {
3577
3742
  // some old implementations (like WebKit) could pass numbers as keys
3578
- if (isCallable$6($replacer)) value = call$6($replacer, this, $String(key), value);
3743
+ if (isCallable$6($replacer)) value = call$4($replacer, this, $String(key), value);
3579
3744
  if (!isSymbol(value)) return value;
3580
3745
  };
3581
3746
  return apply$1($stringify, null, args);
@@ -3592,7 +3757,7 @@ var fixIllFormed = function (match, offset, string) {
3592
3757
  if ($stringify) {
3593
3758
  // `JSON.stringify` method
3594
3759
  // https://tc39.es/ecma262/#sec-json.stringify
3595
- $$j({ target: 'JSON', stat: true, arity: 3, forced: WRONG_SYMBOLS_CONVERSION || ILL_FORMED_UNICODE }, {
3760
+ $$i({ target: 'JSON', stat: true, arity: 3, forced: WRONG_SYMBOLS_CONVERSION || ILL_FORMED_UNICODE }, {
3596
3761
  // eslint-disable-next-line no-unused-vars -- required for `.length`
3597
3762
  stringify: function stringify(it, replacer, space) {
3598
3763
  var args = arraySlice$1(arguments);
@@ -3602,18 +3767,18 @@ if ($stringify) {
3602
3767
  });
3603
3768
  }
3604
3769
 
3605
- var $$i = _export;
3606
- var uncurryThis$7 = functionUncurryThis;
3770
+ var $$h = _export;
3771
+ var uncurryThis$6 = functionUncurryThis;
3607
3772
  var notARegExp$1 = notARegexp;
3608
3773
  var requireObjectCoercible$3 = requireObjectCoercible$b;
3609
3774
  var toString$6 = toString$f;
3610
3775
  var correctIsRegExpLogic$1 = correctIsRegexpLogic;
3611
3776
 
3612
- var stringIndexOf$1 = uncurryThis$7(''.indexOf);
3777
+ var stringIndexOf$1 = uncurryThis$6(''.indexOf);
3613
3778
 
3614
3779
  // `String.prototype.includes` method
3615
3780
  // https://tc39.es/ecma262/#sec-string.prototype.includes
3616
- $$i({ target: 'String', proto: true, forced: !correctIsRegExpLogic$1('includes') }, {
3781
+ $$h({ target: 'String', proto: true, forced: !correctIsRegExpLogic$1('includes') }, {
3617
3782
  includes: function includes(searchString /* , position = 0 */) {
3618
3783
  return !!~stringIndexOf$1(
3619
3784
  toString$6(requireObjectCoercible$3(this)),
@@ -3623,148 +3788,6 @@ $$i({ target: 'String', proto: true, forced: !correctIsRegExpLogic$1('includes')
3623
3788
  }
3624
3789
  });
3625
3790
 
3626
- var uncurryThis$6 = functionUncurryThisClause;
3627
- var aCallable$b = aCallable$g;
3628
- var NATIVE_BIND = functionBindNative;
3629
-
3630
- var bind$5 = uncurryThis$6(uncurryThis$6.bind);
3631
-
3632
- // optional / simple context binding
3633
- var functionBindContext = function (fn, that) {
3634
- aCallable$b(fn);
3635
- return that === undefined ? fn : NATIVE_BIND ? bind$5(fn, that) : function (/* ...args */) {
3636
- return fn.apply(that, arguments);
3637
- };
3638
- };
3639
-
3640
- var wellKnownSymbol$7 = wellKnownSymbol$m;
3641
- var Iterators$1 = iterators;
3642
-
3643
- var ITERATOR$3 = wellKnownSymbol$7('iterator');
3644
- var ArrayPrototype = Array.prototype;
3645
-
3646
- // check on default Array iterator
3647
- var isArrayIteratorMethod$1 = function (it) {
3648
- return it !== undefined && (Iterators$1.Array === it || ArrayPrototype[ITERATOR$3] === it);
3649
- };
3650
-
3651
- var classof$3 = classof$9;
3652
- var getMethod$1 = getMethod$6;
3653
- var isNullOrUndefined$2 = isNullOrUndefined$6;
3654
- var Iterators = iterators;
3655
- var wellKnownSymbol$6 = wellKnownSymbol$m;
3656
-
3657
- var ITERATOR$2 = wellKnownSymbol$6('iterator');
3658
-
3659
- var getIteratorMethod$2 = function (it) {
3660
- if (!isNullOrUndefined$2(it)) return getMethod$1(it, ITERATOR$2)
3661
- || getMethod$1(it, '@@iterator')
3662
- || Iterators[classof$3(it)];
3663
- };
3664
-
3665
- var call$5 = functionCall;
3666
- var aCallable$a = aCallable$g;
3667
- var anObject$9 = anObject$o;
3668
- var tryToString$2 = tryToString$4;
3669
- var getIteratorMethod$1 = getIteratorMethod$2;
3670
-
3671
- var $TypeError$7 = TypeError;
3672
-
3673
- var getIterator$1 = function (argument, usingIterator) {
3674
- var iteratorMethod = arguments.length < 2 ? getIteratorMethod$1(argument) : usingIterator;
3675
- if (aCallable$a(iteratorMethod)) return anObject$9(call$5(iteratorMethod, argument));
3676
- throw new $TypeError$7(tryToString$2(argument) + ' is not iterable');
3677
- };
3678
-
3679
- var bind$4 = functionBindContext;
3680
- var call$4 = functionCall;
3681
- var anObject$8 = anObject$o;
3682
- var tryToString$1 = tryToString$4;
3683
- var isArrayIteratorMethod = isArrayIteratorMethod$1;
3684
- var lengthOfArrayLike$3 = lengthOfArrayLike$7;
3685
- var isPrototypeOf$2 = objectIsPrototypeOf;
3686
- var getIterator = getIterator$1;
3687
- var getIteratorMethod = getIteratorMethod$2;
3688
- var iteratorClose = iteratorClose$3;
3689
-
3690
- var $TypeError$6 = TypeError;
3691
-
3692
- var Result = function (stopped, result) {
3693
- this.stopped = stopped;
3694
- this.result = result;
3695
- };
3696
-
3697
- var ResultPrototype = Result.prototype;
3698
-
3699
- var iterate$8 = function (iterable, unboundFunction, options) {
3700
- var that = options && options.that;
3701
- var AS_ENTRIES = !!(options && options.AS_ENTRIES);
3702
- var IS_RECORD = !!(options && options.IS_RECORD);
3703
- var IS_ITERATOR = !!(options && options.IS_ITERATOR);
3704
- var INTERRUPTED = !!(options && options.INTERRUPTED);
3705
- var fn = bind$4(unboundFunction, that);
3706
- var iterator, iterFn, index, length, result, next, step;
3707
-
3708
- var stop = function (condition) {
3709
- if (iterator) iteratorClose(iterator, 'normal', condition);
3710
- return new Result(true, condition);
3711
- };
3712
-
3713
- var callFn = function (value) {
3714
- if (AS_ENTRIES) {
3715
- anObject$8(value);
3716
- return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
3717
- } return INTERRUPTED ? fn(value, stop) : fn(value);
3718
- };
3719
-
3720
- if (IS_RECORD) {
3721
- iterator = iterable.iterator;
3722
- } else if (IS_ITERATOR) {
3723
- iterator = iterable;
3724
- } else {
3725
- iterFn = getIteratorMethod(iterable);
3726
- if (!iterFn) throw new $TypeError$6(tryToString$1(iterable) + ' is not iterable');
3727
- // optimisation for array iterators
3728
- if (isArrayIteratorMethod(iterFn)) {
3729
- for (index = 0, length = lengthOfArrayLike$3(iterable); length > index; index++) {
3730
- result = callFn(iterable[index]);
3731
- if (result && isPrototypeOf$2(ResultPrototype, result)) return result;
3732
- } return new Result(false);
3733
- }
3734
- iterator = getIterator(iterable, iterFn);
3735
- }
3736
-
3737
- next = IS_RECORD ? iterable.next : iterator.next;
3738
- while (!(step = call$4(next, iterator)).done) {
3739
- try {
3740
- result = callFn(step.value);
3741
- } catch (error) {
3742
- iteratorClose(iterator, 'throw', error);
3743
- }
3744
- if (typeof result == 'object' && result && isPrototypeOf$2(ResultPrototype, result)) return result;
3745
- } return new Result(false);
3746
- };
3747
-
3748
- var $$h = _export;
3749
- var iterate$7 = iterate$8;
3750
- var aCallable$9 = aCallable$g;
3751
- var anObject$7 = anObject$o;
3752
- var getIteratorDirect$4 = getIteratorDirect$7;
3753
-
3754
- // `Iterator.prototype.find` method
3755
- // https://github.com/tc39/proposal-iterator-helpers
3756
- $$h({ target: 'Iterator', proto: true, real: true }, {
3757
- find: function find(predicate) {
3758
- anObject$7(this);
3759
- aCallable$9(predicate);
3760
- var record = getIteratorDirect$4(this);
3761
- var counter = 0;
3762
- return iterate$7(record, function (value, stop) {
3763
- if (predicate(value, counter++)) return stop(value);
3764
- }, { IS_RECORD: true, INTERRUPTED: true }).result;
3765
- }
3766
- });
3767
-
3768
3791
  var $$g = _export;
3769
3792
  var iterate$6 = iterate$8;
3770
3793
  var aCallable$8 = aCallable$g;
@@ -4332,6 +4355,7 @@ const GoAInputBaseControl = props => {
4332
4355
  label,
4333
4356
  input,
4334
4357
  required,
4358
+ errors,
4335
4359
  path,
4336
4360
  isStepperReview,
4337
4361
  skipInitialValidation
@@ -4349,7 +4373,7 @@ const GoAInputBaseControl = props => {
4349
4373
  visible: visible,
4350
4374
  children: jsx(FormFieldWrapper, {
4351
4375
  children: jsx(GoAFormItem, {
4352
- requirement: required ? 'required' : undefined,
4376
+ requirement: required || getRequiredIfThen(props).length > 0 ? 'required' : undefined,
4353
4377
  error: isVisited === true ? modifiedErrors : undefined,
4354
4378
  testId: `${isStepperReview === true && 'review-base-'}${path}`,
4355
4379
  label: (props === null || props === void 0 ? void 0 : props.noLabel) === true ? '' : labelToUpdate,
@@ -10992,7 +11016,8 @@ const createDefaultAjv = (...schemas) => {
10992
11016
  const ajv = new Ajv({
10993
11017
  allErrors: true,
10994
11018
  verbose: true,
10995
- strict: 'log'
11019
+ strict: 'log',
11020
+ strictRequired: false
10996
11021
  });
10997
11022
  ajv.addSchema(schemas);
10998
11023
  addErrors(ajv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Government of Alberta - React renderers for JSON Forms based on the design system.",
6
6
  "repository": "https://github.com/GovAlta/adsp-monorepo",
@@ -22,6 +22,12 @@ export declare const getLabelText: (scope: string, label: string) => string;
22
22
  export declare const isEmptyBoolean: (schema: JsonSchema, data: unknown) => boolean;
23
23
  export declare const isEmptyNumber: (schema: JsonSchema, data: unknown) => boolean;
24
24
  export declare const validateSinWithLuhn: (input: number) => boolean;
25
+ /**
26
+ * Gets the required field in the If/Then json schema condition.
27
+ * @param props - ControlProps
28
+ * @returns - The required field name.
29
+ */
30
+ export declare const getRequiredIfThen: (props: ControlProps) => string;
25
31
  /**
26
32
  * Check if a required, defined input value is valid. Returns an appropriate
27
33
  * error message if not.