@abgov/jsonforms-components 1.50.3 → 1.50.5

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
@@ -3994,892 +3994,947 @@ fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNa
3994
3994
  ];
3995
3995
  });
3996
3996
 
3997
- const formatSin = value => {
3998
- const inputVal = value.replace(/ /g, '');
3999
- let inputNumbersOnly = inputVal.replace(/\D/g, '');
4000
- if (inputNumbersOnly.length > 16) {
4001
- inputNumbersOnly = inputNumbersOnly.substr(0, 9);
4002
- }
4003
- const splits = inputNumbersOnly.match(/.{1,3}/g);
4004
- let spacedNumber = '';
4005
- if (splits) {
4006
- spacedNumber = splits.join(' ');
4007
- }
4008
- const formatVal = spacedNumber.length > 11 ? spacedNumber.slice(0, 11) : spacedNumber;
4009
- return formatVal;
4010
- };
4011
- const GoAInputText = props => {
4012
- var _a, _b, _c, _d, _e, _f, _g, _h;
4013
- const {
4014
- data,
4015
- config,
4016
- id,
4017
- enabled,
4018
- uischema,
4019
- schema,
4020
- label
4021
- } = props;
4022
- const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4023
- const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
4024
- const errorsFormInput = checkFieldValidity(props);
4025
- const isSinField = schema.title === sinTitle;
4026
- const autoCapitalize = ((_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.autoCapitalize) === true || ((_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.autoCapitalize) === true;
4027
- const readOnly = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.readOnly) !== null && _f !== void 0 ? _f : false;
4028
- return jsx(GoAInput, Object.assign({
4029
- error: errorsFormInput.length > 0,
4030
- type: appliedUiSchemaOptions.format === 'password' ? 'password' : 'text',
4031
- disabled: !enabled,
4032
- value: data,
4033
- width: '100%',
4034
- readonly: readOnly,
4035
- maxLength: isSinField ? 11 : '',
4036
- placeholder: placeholder
4037
- }, (_g = uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps, {
4038
- // maxLength={appliedUiSchemaOptions?.maxLength}
4039
- name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4040
- testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4041
- // Don't use handleChange in the onChange event, use the keyPress or onBlur.
4042
- // If you use it onChange along with keyPress event it will cause a
4043
- // side effect that causes the validation to render when it shouldn't.
4044
- onChange: (name, value) => {
4045
- let formattedValue = value;
4046
- if (schema && schema.title === sinTitle && value !== '') {
4047
- formattedValue = formatSin(value);
4048
- }
4049
- onChangeForInputControl({
4050
- name,
4051
- value: formattedValue,
4052
- controlProps: props
4053
- });
4054
- },
4055
- onKeyPress: (name, value, key) => {
4056
- onKeyPressForTextControl({
4057
- name,
4058
- value: autoCapitalize ? value.toUpperCase() : value,
4059
- key,
4060
- controlProps: props
4061
- });
4062
- },
4063
- onBlur: (name, value) => {
4064
- onBlurForTextControl({
4065
- name,
4066
- controlProps: props,
4067
- value: autoCapitalize ? value.toUpperCase() : value
4068
- });
4069
- }
4070
- }, (_h = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _h === void 0 ? void 0 : _h.componentProps));
4071
- };
4072
- const GoATextControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
4073
- input: GoAInputText
4074
- }));
4075
- const GoATextControlTester = rankWith(1, isStringControl);
4076
- const GoAInputTextControl = withJsonFormsControlProps(GoATextControl);
3997
+ // a string of all valid unicode whitespaces
3998
+ var whitespaces$2 = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
3999
+ '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
4077
4000
 
4078
- const MultiLineText = props => {
4079
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
4080
- const {
4081
- data,
4082
- config,
4083
- id,
4084
- enabled,
4085
- uischema,
4086
- path,
4087
- handleChange,
4088
- schema,
4089
- label
4090
- } = props;
4091
- const {
4092
- required
4093
- } = props;
4094
- const [textAreaValue, _] = React.useState(data);
4095
- const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4096
- const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
4097
- const errorsFormInput = checkFieldValidity(props);
4098
- const width = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : '100%';
4099
- const autoCapitalize = ((_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.autoCapitalize) === true || ((_f = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _f === void 0 ? void 0 : _f.autoCapitalize) === true;
4100
- const readOnly = (_j = (_h = (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps) === null || _h === void 0 ? void 0 : _h.readOnly) !== null && _j !== void 0 ? _j : false;
4101
- const textAreaName = `${label || path}-text-area` || '';
4102
- (_k = document.getElementsByName(textAreaName)[0]) !== null && _k !== void 0 ? _k : null;
4103
- const txtAreaComponent = jsx(GoATextArea, Object.assign({
4104
- error: errorsFormInput.length > 0,
4105
- value: textAreaValue,
4106
- disabled: !enabled,
4107
- readOnly: readOnly,
4108
- placeholder: placeholder,
4109
- testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4110
- name: textAreaName,
4111
- width: width,
4112
- // Note: Paul Jan-09-2023. The latest ui-component come with the maxCount. We need to uncomment the following line when the component is updated
4113
- // maxCount={schema.maxLength || 256}
4114
- onKeyPress: (name, value, key) => {
4115
- const newValue = autoCapitalize ? value.toUpperCase() : value;
4116
- if (value.length === 0 || required && errorsFormInput.length === 0 && value.length > 0) {
4117
- onKeyPressForTextControl({
4118
- name,
4119
- value: newValue,
4120
- key,
4121
- controlProps: props
4122
- });
4123
- }
4124
- onChangeForInputControl({
4125
- name,
4126
- value: newValue,
4127
- controlProps: props
4128
- });
4129
- },
4130
- onChange: (name, value) => {
4131
- // this is not triggered unless you tab out
4132
- }
4133
- }, (_l = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _l === void 0 ? void 0 : _l.componentProps));
4134
- return txtAreaComponent;
4135
- };
4136
- const MultiLineTextControlInput = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
4137
- input: MultiLineText
4138
- }));
4139
- const MultiLineTextControlTester = rankWith(3, and(isStringControl, optionIs('multi', true)));
4140
- const MultiLineTextControl = withJsonFormsControlProps(MultiLineTextControlInput);
4001
+ var uncurryThis$3 = functionUncurryThis;
4002
+ var requireObjectCoercible$1 = requireObjectCoercible$b;
4003
+ var toString$1 = toString$e;
4004
+ var whitespaces$1 = whitespaces$2;
4141
4005
 
4142
- // Used locally for callout presentation
4143
- const callout = props => {
4144
- var _a;
4145
- const componentProps = Object.assign({
4146
- size: 'medium',
4147
- type: 'emergency',
4148
- message: 'unknown'
4149
- }, props);
4150
- const testid = (_a = componentProps.message) === null || _a === void 0 ? void 0 : _a.replace(/\s/g, '');
4151
- return jsx(GoACallout, Object.assign({}, componentProps, {
4152
- "data-testid": testid,
4153
- children: componentProps.message
4154
- }));
4155
- };
4156
- const CalloutControl = props => {
4157
- var _a, _b;
4158
- return callout(((_b = (_a = props === null || props === void 0 ? void 0 : props.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.componentProps) || {});
4159
- };
4160
- const GoACalloutControlTester = rankWith(1, uiTypeIs('Callout'));
4161
- var GoACalloutControl = withJsonFormsRendererProps(CalloutControl);
4006
+ var replace = uncurryThis$3(''.replace);
4007
+ var ltrim = RegExp('^[' + whitespaces$1 + ']+');
4008
+ var rtrim = RegExp('(^|[^' + whitespaces$1 + '])[' + whitespaces$1 + ']+$');
4162
4009
 
4163
- const errMalformedDate = (scope, type) => {
4164
- return `${type}-date for variable '${scope}' has an incorrect format.`;
4010
+ // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
4011
+ var createMethod$1 = function (TYPE) {
4012
+ return function ($this) {
4013
+ var string = toString$1(requireObjectCoercible$1($this));
4014
+ if (TYPE & 1) string = replace(string, ltrim, '');
4015
+ if (TYPE & 2) string = replace(string, rtrim, '$1');
4016
+ return string;
4017
+ };
4165
4018
  };
4166
- const isValidDateFormat = date => {
4167
- const standardized = standardizeDate(date);
4168
- return standardized !== undefined;
4019
+
4020
+ var stringTrim = {
4021
+ // `String.prototype.{ trimLeft, trimStart }` methods
4022
+ // https://tc39.es/ecma262/#sec-string.prototype.trimstart
4023
+ start: createMethod$1(1),
4024
+ // `String.prototype.{ trimRight, trimEnd }` methods
4025
+ // https://tc39.es/ecma262/#sec-string.prototype.trimend
4026
+ end: createMethod$1(2),
4027
+ // `String.prototype.trim` method
4028
+ // https://tc39.es/ecma262/#sec-string.prototype.trim
4029
+ trim: createMethod$1(3)
4169
4030
  };
4170
- const invalidDateFormat = (scope, type) => {
4171
- return callout({
4172
- message: errMalformedDate(scope, type)
4031
+
4032
+ var PROPER_FUNCTION_NAME = functionName.PROPER;
4033
+ var fails$3 = fails$r;
4034
+ var whitespaces = whitespaces$2;
4035
+
4036
+ var non = '\u200B\u0085\u180E';
4037
+
4038
+ // check that a method works with the correct list
4039
+ // of whitespaces and has a correct name
4040
+ var stringTrimForced = function (METHOD_NAME) {
4041
+ return fails$3(function () {
4042
+ return !!whitespaces[METHOD_NAME]()
4043
+ || non[METHOD_NAME]() !== non
4044
+ || (PROPER_FUNCTION_NAME && whitespaces[METHOD_NAME].name !== METHOD_NAME);
4173
4045
  });
4174
4046
  };
4175
- // eslint-disable-next-line
4176
- const reformatDateProps = props => {
4177
- const newProps = Object.assign({}, props);
4178
- if (newProps) {
4179
- if ((newProps === null || newProps === void 0 ? void 0 : newProps.min) && typeof newProps.min === 'string') {
4180
- newProps.min = standardizeDate(newProps.min);
4181
- }
4182
- if ((newProps === null || newProps === void 0 ? void 0 : newProps.max) && typeof newProps.max === 'string') {
4183
- newProps.max = standardizeDate(newProps.max);
4184
- }
4047
+
4048
+ var $$a = _export;
4049
+ var $trim = stringTrim.trim;
4050
+ var forcedStringTrimMethod = stringTrimForced;
4051
+
4052
+ // `String.prototype.trim` method
4053
+ // https://tc39.es/ecma262/#sec-string.prototype.trim
4054
+ $$a({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
4055
+ trim: function trim() {
4056
+ return $trim(this);
4185
4057
  }
4186
- return newProps;
4187
- };
4188
- const GoADateInput = props => {
4189
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
4190
- const {
4191
- data,
4192
- config,
4193
- id,
4194
- enabled,
4195
- uischema,
4196
- path,
4197
- handleChange,
4198
- label
4199
- } = props;
4200
- const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4201
- const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
4202
- const width = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : '100%';
4203
- const minDate = (_h = (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps) === null || _h === void 0 ? void 0 : _h.min;
4204
- if (minDate && !isValidDateFormat(minDate)) {
4205
- return invalidDateFormat(uischema.scope, 'Min');
4058
+ });
4059
+
4060
+ const ENTER_KEY = 'Enter';
4061
+ const ESCAPE_KEY = 'Escape';
4062
+ const ARROW_DOWN_KEY = 'ArrowDown';
4063
+ const ARROW_UP_KEY = 'ArrowUp';
4064
+ const TAB_KEY = 'Tab';
4065
+ const SPACE_KEY = ' ';
4066
+ const ALT_KEY = 'Alt';
4067
+ const SHIFT_KEY = 'Shift';
4068
+
4069
+ let _$8 = t => t,
4070
+ _t$8,
4071
+ _t2$5,
4072
+ _t3$4,
4073
+ _t4$3;
4074
+ const GoADropdownTextbox = styled.div(_t$8 || (_t$8 = _$8`
4075
+ border-radius: var(--goa-space-2xs);
4076
+ box-shadow: ${0};
4077
+ &:hover {
4078
+ cursor: pointer;
4206
4079
  }
4207
- const maxDate = (_k = (_j = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _j === void 0 ? void 0 : _j.componentProps) === null || _k === void 0 ? void 0 : _k.max;
4208
- if (maxDate && !isValidDateFormat(maxDate)) {
4209
- return invalidDateFormat(uischema.scope, 'Max');
4080
+
4081
+ .inputStyle {
4082
+ box-shadow: ${0};
4210
4083
  }
4211
- return jsx(GoAInputDate, Object.assign({
4212
- error: checkFieldValidity(props).length > 0,
4213
- width: width,
4214
- name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4215
- value: standardizeDate(data) || '',
4216
- testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4217
- disabled: !enabled,
4218
- readonly: readOnly,
4219
- onChange: (name, value) => {
4220
- onChangeForDateControl({
4221
- name,
4222
- value,
4223
- controlProps: props
4224
- });
4225
- },
4226
- onKeyPress: (name, value, key) => {
4227
- onKeyPressForDateControl({
4228
- name,
4229
- value,
4230
- key,
4231
- controlProps: props
4232
- });
4233
- },
4234
- onBlur: (name, value) => {
4235
- onBlurForDateControl({
4236
- name,
4237
- value,
4238
- controlProps: props
4239
- });
4240
- }
4241
- }, reformatDateProps((_l = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _l === void 0 ? void 0 : _l.componentProps)));
4242
- };
4243
- const GoADateControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
4244
- input: GoADateInput
4245
- }));
4246
- const GoADateControlTester = rankWith(4, isDateControl);
4247
- const GoAInputDateControl = withJsonFormsControlProps(GoADateControl);
4084
+ `), p => p.isOpen ? `0 0 0 3px var(--goa-color-interactive-focus)` : '', p => p.isOpen ? `0 0 0 3px var(--goa-color-interactive-focus) !important` : '');
4085
+ const GoADropdownListContainerWrapper = styled.div(_t2$5 || (_t2$5 = _$8`
4086
+ position: relative;
4087
+ display: ${0};
4088
+ `), p => !(p === null || p === void 0 ? void 0 : p.isOpen) && 'none');
4089
+ const GoADropdownListContainer = styled.div(_t3$4 || (_t3$4 = _$8`
4090
+ border: solid 1px var(--goa-color-greyscale-200);
4091
+ border-radius: var(--goa-space-2xs);
4092
+ background: var(--goa-color-greyscale-white);
4093
+ padding: 0;
4094
+ margin-top: 3px;
4095
+ width: 100%;
4096
+ overflow-y: auto;
4097
+ z-index: 1000;
4098
+ caret-color: transparent;
4099
+ position: absolute;
4100
+ line-height: var(--goa-space-xl);
4101
+ max-height: ${0};
4248
4102
 
4249
- const GoANumberInput = props => {
4250
- var _a, _b, _c, _d, _e, _f, _g;
4251
- // eslint-disable-next-line
4103
+ &:focus-visible {
4104
+ outline-color: var(--goa-color-interactive-default);
4105
+ }
4106
+ &:hover {
4107
+ background-color: var(--goa-color-interactive-hover) !important;
4108
+ color: #fff !important;
4109
+ /* Fix to override scrollbar color in Firefox */
4110
+ scrollbar-color: #a8a8a8 var(--goa-color-greyscale-100) !important;
4111
+ }
4112
+ `), p => p.optionListMaxHeight || '272px');
4113
+ const GoADropdownListOption = styled.div(_t4$3 || (_t4$3 = _$8`
4114
+ padding: var(--goa-space-2xs) var(--goa-space-s);
4115
+ text-overflow: ellipsis;
4116
+ color: ${0} !important;
4117
+ border: 0px solid var(--goa-color-greyscale-100);
4118
+ z-index: 1001;
4119
+ cursor: pointer;
4120
+ background: ${0};
4121
+ :has(div:focus) {
4122
+ background-color: ${0};
4123
+ color: ${0};
4124
+ }
4125
+ &:hover {
4126
+ background-color: ${0};
4127
+ color: ${0};
4128
+ }
4129
+
4130
+ &:focus-visible {
4131
+ caret-color: transparent;
4132
+ color: black !important;
4133
+ background-color: ${0};
4134
+ }
4135
+ &:focus-within {
4136
+ caret-color: transparent;
4137
+ color: #fff !important;
4138
+ background-color: ${0};
4139
+ }
4140
+ .dropDownListItem:focus-visible {
4141
+ caret-color: transparent;
4142
+ outline: none !important;
4143
+ color: ${0};
4144
+ }
4145
+ `), p => p.isSelected ? '#fff' : 'var(--goa-color-greyscale-black)', p => p.isSelected ? 'var(--goa-color-interactive-default)' : '#fff', p => p.isSelected ? 'var(--goa-color-interactive-hover)' : 'var(--goa-color-greyscale-100) !important', p => p.isSelected ? 'var(--goa-color-interactive-default)' : 'var(--goa-color-interactive-hover) !important', p => p.isSelected ? 'var(--goa-color-interactive-hover)' : 'var(--goa-color-greyscale-100) !important', p => p.isSelected ? 'var(--goa-color-interactive-default)' : 'var(--goa-color-interactive-hover) !important', p => p.isSelected ? 'var(--goa-color-interactive-hover)' : 'var(--goa-color-greyscale-100) !important', p => p.isSelected ? 'var(--goa-color-interactive-hover)' : 'var(--goa-color-greyscale-100) !important', p => p.isSelected ? '#fff' : 'var(--goa-color-interactive-hover) !important');
4146
+
4147
+ const isValidKey = keyCode => {
4148
+ if (keyCode === SHIFT_KEY || keyCode === ALT_KEY) return false;
4149
+ const regex = new RegExp(/^[a-zA-Z0-9!%$@.#?\-_]+$/);
4150
+ return regex.test(keyCode);
4151
+ };
4152
+ const Dropdown = props => {
4153
+ var _a;
4252
4154
  const {
4253
- data,
4254
- config,
4255
- id,
4155
+ label,
4156
+ selected,
4157
+ onChange,
4158
+ optionListMaxHeight,
4159
+ isAutoCompletion,
4256
4160
  enabled,
4257
- uischema,
4258
- isValid,
4259
- path,
4260
- handleChange,
4261
- schema,
4262
- label
4161
+ id
4263
4162
  } = props;
4264
- const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4265
- const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
4266
- const InputValue = data && data !== undefined ? data : '';
4267
- const clonedSchema = JSON.parse(JSON.stringify(schema));
4268
- const StepValue = clonedSchema.multipleOf ? clonedSchema.multipleOf : 0.01;
4269
- const MinValue = clonedSchema.minimum ? clonedSchema.minimum : '';
4270
- const MaxValue = clonedSchema.exclusiveMaximum ? clonedSchema.exclusiveMaximum : '';
4271
- const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
4272
- const width = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : '100%';
4273
- const errorsFormInput = checkFieldValidity(props);
4274
- return jsx(GoAInput, Object.assign({
4275
- type: "number",
4276
- error: errorsFormInput.length > 0,
4277
- disabled: !enabled,
4278
- readonly: readOnly,
4279
- value: InputValue,
4280
- placeholder: placeholder,
4281
- step: StepValue,
4282
- min: MinValue,
4283
- max: MaxValue,
4284
- width: width,
4285
- name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4286
- testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4287
- onKeyPress: (name, value, key) => {
4288
- onKeyPressNumericControl({
4289
- name,
4290
- value,
4291
- key,
4292
- controlProps: props
4293
- });
4294
- },
4295
- onBlur: (name, value) => {
4296
- onBlurForNumericControl({
4297
- name,
4298
- value,
4299
- controlProps: props
4300
- });
4301
- },
4302
- onChange: (name, value) => {
4303
- onChangeForNumericControl({
4304
- name,
4305
- value,
4306
- controlProps: props
4163
+ const [isOpen, setIsOpen] = useState(false);
4164
+ const [selectedOption, setSelectedOption] = useState(selected);
4165
+ const [items, setItems] = useState(props.items);
4166
+ const [inputText, setInputText] = useState(selected);
4167
+ const prevCountRef = useRef(props.items);
4168
+ const trailingIcon = isOpen ? 'chevron-up' : 'chevron-down';
4169
+ const textInputName = `dropdown-${label}`;
4170
+ const textInput = (_a = document.getElementsByName(textInputName)[0]) !== null && _a !== void 0 ? _a : null;
4171
+ const PREFIX = 'jsonforms-dropdown';
4172
+ useEffect(() => {
4173
+ setItems(props.items);
4174
+ prevCountRef.current = props.items;
4175
+ // eslint-disable-next-line react-hooks/exhaustive-deps
4176
+ }, [isEqual(props.items, prevCountRef.current)]);
4177
+ useEffect(() => {
4178
+ if (textInput) {
4179
+ textInput.addEventListener('keydown', handleKeyDown);
4180
+ textInput.addEventListener('blur', handleTextInputOnBlur);
4181
+ }
4182
+ document.addEventListener('keydown', handleDocumentKeyDown);
4183
+ return () => {
4184
+ if (textInput) {
4185
+ textInput.removeEventListener('keydown', handleKeyDown);
4186
+ textInput.removeEventListener('blur', handleTextInputOnBlur);
4187
+ }
4188
+ document.removeEventListener('keydown', handleDocumentKeyDown);
4189
+ };
4190
+ // eslint-disable-next-line react-hooks/exhaustive-deps
4191
+ }, [textInput, document]);
4192
+ /* istanbul ignore next */
4193
+ const handleTextInputOnBlur = e => {
4194
+ if (e.relatedTarget === null) {
4195
+ setIsOpen(false);
4196
+ } else if (e.relatedTarget && !isAutoCompletion) {
4197
+ const dropDownEl = e.relatedTarget;
4198
+ if (dropDownEl) {
4199
+ if (!dropDownEl.id.startsWith(`${PREFIX}-${label}`)) {
4200
+ setIsOpen(false);
4201
+ }
4202
+ }
4203
+ }
4204
+ };
4205
+ const updateDropDownData = item => {
4206
+ onChange(item.value);
4207
+ setSelectedOption(item.value);
4208
+ setInputText(item.label);
4209
+ if (isAutoCompletion) {
4210
+ const selectedItems = props.items.filter(filterItem => {
4211
+ return filterItem.label === item.label;
4307
4212
  });
4213
+ setItems(selectedItems);
4308
4214
  }
4309
- }, (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps));
4310
- };
4311
- const GoANumberControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
4312
- input: GoANumberInput
4313
- }));
4314
- const GoANumberControlTester = rankWith(2, isNumberControl);
4315
- const GoAInputNumberControl = withJsonFormsControlProps(GoANumberControl);
4316
-
4317
- const GoAInputInteger = props => {
4318
- var _a, _b, _c, _d, _e, _f, _g;
4319
- // eslint-disable-next-line
4320
- const {
4321
- data,
4322
- config,
4323
- id,
4324
- enabled,
4325
- uischema,
4326
- isValid,
4327
- path,
4328
- handleChange,
4329
- schema,
4330
- label
4331
- } = props;
4332
- const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4333
- const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
4334
- const InputValue = data && data !== undefined ? data : '';
4335
- const clonedSchema = JSON.parse(JSON.stringify(schema));
4336
- const StepValue = clonedSchema.multipleOf ? clonedSchema.multipleOf : 0;
4337
- const MinValue = clonedSchema.minimum ? clonedSchema.minimum : '';
4338
- const MaxValue = clonedSchema.exclusiveMaximum ? clonedSchema.exclusiveMaximum : '';
4339
- const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
4340
- const width = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : '100%';
4341
- const errorsFormInput = checkFieldValidity(props);
4342
- return jsx(GoAInput, Object.assign({
4343
- type: "number",
4344
- error: errorsFormInput.length > 0,
4345
- width: width,
4346
- disabled: !enabled,
4347
- readonly: readOnly,
4348
- value: InputValue,
4349
- step: StepValue,
4350
- min: MinValue,
4351
- max: MaxValue,
4352
- placeholder: placeholder,
4353
- name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4354
- testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4355
- onKeyPress: (name, value, key) => {
4356
- onKeyPressNumericControl({
4357
- name,
4358
- value,
4359
- key,
4360
- controlProps: props
4361
- });
4362
- },
4363
- onBlur: (name, value) => {
4364
- onBlurForNumericControl({
4365
- name,
4366
- value,
4367
- controlProps: props
4368
- });
4369
- },
4370
- onChange: (name, value) => {
4371
- onChangeForNumericControl({
4372
- name,
4373
- value,
4374
- controlProps: props
4375
- });
4215
+ setIsOpen(false);
4216
+ };
4217
+ const setInputTextFocus = () => {
4218
+ const inputEl = document.getElementById(`${id}-input`);
4219
+ if (inputEl) {
4220
+ //The 'focused' property is part of the GoAInput component that is used to
4221
+ //set focus on the input field. We need to set it back to false once we set focus on the input field. Doing with just .focus() doesnt work.
4222
+ inputEl.focused = true;
4223
+ inputEl.focus();
4224
+ inputEl.focused = false;
4376
4225
  }
4377
- }, (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps));
4226
+ };
4227
+ const setElementFocus = (e, element, preventDefault) => {
4228
+ if (element) {
4229
+ element.focus();
4230
+ if (preventDefault) {
4231
+ e.preventDefault();
4232
+ }
4233
+ }
4234
+ };
4235
+ /* istanbul ignore next */
4236
+ const handleDocumentKeyDown = e => {
4237
+ if (e.key === ESCAPE_KEY || e.key === TAB_KEY) {
4238
+ setIsOpen(false);
4239
+ }
4240
+ };
4241
+ /* istanbul ignore next */
4242
+ const handleKeyDown = e => {
4243
+ var _a, _b, _c;
4244
+ if (e.key === ENTER_KEY || e.key === SPACE_KEY) {
4245
+ setIsOpen(previousIsOpen => !previousIsOpen);
4246
+ const el = document.getElementById(`${PREFIX}-${label}-${(_a = items.at(0)) === null || _a === void 0 ? void 0 : _a.value}`);
4247
+ setInputTextFocus();
4248
+ setElementFocus(e, el, false);
4249
+ } else if (e.key === ARROW_UP_KEY) {
4250
+ setIsOpen(true);
4251
+ const val = `${PREFIX}-${label}-${(_b = items.at(1)) === null || _b === void 0 ? void 0 : _b.value}`;
4252
+ const el = document.getElementById(val);
4253
+ setElementFocus(e, el, false);
4254
+ } else if (e.key === ARROW_DOWN_KEY) {
4255
+ setIsOpen(true);
4256
+ const firstItem = props.items.at(0);
4257
+ let index = 0;
4258
+ if ((firstItem === null || firstItem === void 0 ? void 0 : firstItem.label.trim()) === '') {
4259
+ index = 1;
4260
+ }
4261
+ let el = document.getElementById(`${PREFIX}-${label}-${(_c = props.items.at(index)) === null || _c === void 0 ? void 0 : _c.value}`);
4262
+ if (el === null && !isAutoCompletion) {
4263
+ const elements = document.querySelectorAll(`[id='${PREFIX}-dropDownList-${label}']`);
4264
+ const element = elements.item(0).children.item(1);
4265
+ el = document.getElementById(`${PREFIX}-${label}-${element.innerText}`);
4266
+ } else if (el === null && isAutoCompletion) {
4267
+ const elements = document.querySelectorAll(`[id=${PREFIX}-dropDownList-${label}]`);
4268
+ const element = elements[0].children[0];
4269
+ el = document.getElementById(`${PREFIX}-${label}-${element.innerText}`);
4270
+ }
4271
+ setElementFocus(e, el, true);
4272
+ } else if (e.key === ESCAPE_KEY || e.key === TAB_KEY) {
4273
+ setIsOpen(false);
4274
+ } else {
4275
+ if (isValidKey(e.key)) {
4276
+ setIsOpen(true);
4277
+ }
4278
+ }
4279
+ };
4280
+ const handDropDownItemOnKeyDown = (e, item) => {
4281
+ var _a, _b, _c, _d;
4282
+ if (e.key === ENTER_KEY || e.key === SPACE_KEY) {
4283
+ updateDropDownData(item);
4284
+ setInputTextFocus();
4285
+ }
4286
+ if (e.key === ESCAPE_KEY) {
4287
+ setIsOpen(false);
4288
+ setInputTextFocus();
4289
+ }
4290
+ let index = items.findIndex(val => {
4291
+ return val.label === e.currentTarget.innerText;
4292
+ });
4293
+ //Prevent jumping to the next control/DOM element if
4294
+ //we are on the last item in the drop down list
4295
+ if (e.key === ARROW_DOWN_KEY) {
4296
+ if (item.label === ((_a = items.at(-1)) === null || _a === void 0 ? void 0 : _a.label)) {
4297
+ e.preventDefault();
4298
+ }
4299
+ if (index === -1 && item.label.trim() === '') {
4300
+ index = 0;
4301
+ }
4302
+ const el = document.getElementById(`${PREFIX}-${label}-${(_b = items.at(index + 1)) === null || _b === void 0 ? void 0 : _b.value}`);
4303
+ if (el) {
4304
+ setElementFocus(e, el, true);
4305
+ return;
4306
+ }
4307
+ }
4308
+ if (e.key === ARROW_UP_KEY) {
4309
+ if (index <= 0) {
4310
+ e.preventDefault();
4311
+ return;
4312
+ }
4313
+ const el = document.getElementById(`${PREFIX}-${label}-${(_c = items.at(index - 1)) === null || _c === void 0 ? void 0 : _c.value}`);
4314
+ if (el) {
4315
+ el.focus();
4316
+ }
4317
+ }
4318
+ if (e.key === TAB_KEY) {
4319
+ const val = `${PREFIX}-${label}-${(_d = items.at(index - 1)) === null || _d === void 0 ? void 0 : _d.value}`;
4320
+ const el = document.getElementById(val);
4321
+ if (el) {
4322
+ setIsOpen(false);
4323
+ }
4324
+ }
4325
+ };
4326
+ return jsxs("div", {
4327
+ "data-testid": id,
4328
+ children: [jsx(GoADropdownTextbox, {
4329
+ isOpen: isOpen,
4330
+ onClick: e => {
4331
+ setIsOpen(previousIsOpen => !previousIsOpen);
4332
+ },
4333
+ children: jsx(GoAInput, {
4334
+ disabled: !enabled,
4335
+ name: `dropdown-${label}`,
4336
+ width: "100%",
4337
+ value: inputText,
4338
+ testId: `${id}-input`,
4339
+ id: `${id}-input`,
4340
+ readonly: !isAutoCompletion,
4341
+ onChange: (name, value) => {
4342
+ if (isAutoCompletion) {
4343
+ setInputText(value);
4344
+ const selectedItems = props.items.filter(item => {
4345
+ return item.label.includes(value);
4346
+ });
4347
+ setItems(selectedItems);
4348
+ }
4349
+ },
4350
+ onTrailingIconClick: () => {},
4351
+ trailingIcon: trailingIcon
4352
+ })
4353
+ }), jsx(GoADropdownListContainerWrapper, {
4354
+ isOpen: isOpen,
4355
+ id: `${PREFIX}-dropDownListContainerWrapper-${label}`,
4356
+ children: jsx(GoADropdownListContainer, {
4357
+ id: `${PREFIX}-dropDownList-${label}`,
4358
+ optionListMaxHeight: optionListMaxHeight,
4359
+ children: items.map(item => {
4360
+ return jsx(GoADropdownListOption, {
4361
+ id: `${PREFIX}-option-${label}-${item.value}`,
4362
+ isSelected: item.value === selected || item.value === selectedOption,
4363
+ children: jsx("div", {
4364
+ tabIndex: 0,
4365
+ className: "dropDownListItem",
4366
+ "data-testid": `${id}-${item.label}-option`,
4367
+ id: `${PREFIX}-${label}-${item.value}`,
4368
+ onKeyDown: e => {
4369
+ handDropDownItemOnKeyDown(e, item);
4370
+ },
4371
+ onClick: e => {
4372
+ updateDropDownData(item);
4373
+ },
4374
+ children: item.label
4375
+ }, `${PREFIX}-${label}-${item.value}`)
4376
+ }, `${PREFIX}-option-${label}-${item.value}`);
4377
+ })
4378
+ }, `${PREFIX}-dropDownList-${label}`)
4379
+ }, `${PREFIX}-dropDownListContainerWrapper-${label}`)]
4380
+ }, id);
4378
4381
  };
4379
- const GoAIntegerControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
4380
- input: GoAInputInteger
4381
- }));
4382
- const GoAIntegerControlTester = rankWith(2, isIntegerControl);
4383
- const GoAInputIntegerControl = withJsonFormsControlProps(GoAIntegerControl);
4384
4382
 
4385
- const GoADateTimeInput = props => {
4386
- var _a, _b, _c, _d, _e, _f, _g;
4387
- // eslint-disable-next-line
4383
+ function fetchRegisterConfigFromOptions$1(options) {
4384
+ if (!(options === null || options === void 0 ? void 0 : options.url) && !(options === null || options === void 0 ? void 0 : options.urn)) return undefined;
4385
+ const config = Object.assign({}, options);
4386
+ return config;
4387
+ }
4388
+ const formatSin = value => {
4389
+ const inputVal = value.replace(/ /g, '');
4390
+ let inputNumbersOnly = inputVal.replace(/\D/g, '');
4391
+ if (inputNumbersOnly.length > 16) {
4392
+ inputNumbersOnly = inputNumbersOnly.substr(0, 9);
4393
+ }
4394
+ const splits = inputNumbersOnly.match(/.{1,3}/g);
4395
+ let spacedNumber = '';
4396
+ if (splits) {
4397
+ spacedNumber = splits.join(' ');
4398
+ }
4399
+ const formatVal = spacedNumber.length > 11 ? spacedNumber.slice(0, 11) : spacedNumber;
4400
+ return formatVal;
4401
+ };
4402
+ const GoAInputText = props => {
4403
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
4388
4404
  const {
4389
4405
  data,
4390
4406
  config,
4391
4407
  id,
4392
4408
  enabled,
4393
4409
  uischema,
4394
- isValid,
4395
- path,
4396
- errors,
4397
- handleChange,
4398
4410
  schema,
4399
- label
4411
+ label,
4412
+ path,
4413
+ handleChange
4400
4414
  } = props;
4401
- const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4402
- const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
4403
- const width = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : '100%';
4404
- return jsx(GoAInputDateTime, Object.assign({
4405
- error: checkFieldValidity(props).length > 0,
4406
- width: width,
4407
- name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4408
- value: data ? new Date(data).toISOString() : '',
4409
- testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4410
- disabled: !enabled,
4411
- readonly: readOnly,
4412
- onChange: (name, value) => {
4413
- onChangeForDateTimeControl({
4414
- name,
4415
- value,
4416
- controlProps: props
4417
- });
4418
- },
4419
- onKeyPress: (name, value, key) => {
4420
- onKeyPressForDateControl({
4421
- name,
4422
- value,
4423
- key,
4424
- controlProps: props
4415
+ const registerCtx = useContext(JsonFormsRegisterContext);
4416
+ const registerConfig = fetchRegisterConfigFromOptions$1((_b = (_a = props.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.register);
4417
+ // eslint-disable-next-line react-hooks/exhaustive-deps
4418
+ let registerData = [];
4419
+ if (registerConfig) {
4420
+ registerData = registerCtx === null || registerCtx === void 0 ? void 0 : registerCtx.selectRegisterData(registerConfig);
4421
+ }
4422
+ const autoCompletion = ((_d = (_c = props.uischema) === null || _c === void 0 ? void 0 : _c.options) === null || _d === void 0 ? void 0 : _d.autoComplete) === true;
4423
+ const mergedOptions = useMemo(() => {
4424
+ const newOptions = [...((registerData === null || registerData === void 0 ? void 0 : registerData.map(d => {
4425
+ if (typeof d === 'string') {
4426
+ return {
4427
+ value: d,
4428
+ label: d
4429
+ };
4430
+ } else {
4431
+ return Object.assign({}, d);
4432
+ }
4433
+ })) || [])];
4434
+ const hasNonEmptyOptions = newOptions.some(option => option.value !== '');
4435
+ if (!hasNonEmptyOptions && newOptions.length === 1 && newOptions[0].value === '') {
4436
+ return newOptions;
4437
+ }
4438
+ if (newOptions && newOptions.length === 0) {
4439
+ newOptions.push({
4440
+ label: '',
4441
+ value: ''
4425
4442
  });
4426
- },
4427
- onBlur: (name, value) => {
4428
- onBlurForDateControl({
4443
+ }
4444
+ return newOptions.filter(option => option.value !== '');
4445
+ }, [registerData]);
4446
+ useEffect(() => {
4447
+ if (registerConfig) {
4448
+ registerCtx === null || registerCtx === void 0 ? void 0 : registerCtx.fetchRegisterByUrl(registerConfig);
4449
+ }
4450
+ }, [registerCtx, registerConfig]);
4451
+ const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4452
+ const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
4453
+ const errorsFormInput = checkFieldValidity(props);
4454
+ const isSinField = schema.title === sinTitle;
4455
+ const autoCapitalize = ((_f = (_e = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _e === void 0 ? void 0 : _e.componentProps) === null || _f === void 0 ? void 0 : _f.autoCapitalize) === true || ((_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.autoCapitalize) === true;
4456
+ const readOnly = (_k = (_j = (_h = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _h === void 0 ? void 0 : _h.componentProps) === null || _j === void 0 ? void 0 : _j.readOnly) !== null && _k !== void 0 ? _k : false;
4457
+ return jsx("div", {
4458
+ children: mergedOptions.length > 0 ? jsx(Dropdown, {
4459
+ items: mergedOptions,
4460
+ enabled: enabled,
4461
+ selected: data,
4462
+ id: `jsonforms-${label}-dropdown`,
4463
+ label: label || '',
4464
+ isAutoCompletion: autoCompletion,
4465
+ onChange: value => {
4466
+ handleChange(path, value);
4467
+ }
4468
+ }, `jsonforms-${label}-dropdown`) : jsx(GoAInput, Object.assign({
4469
+ error: errorsFormInput.length > 0,
4470
+ type: appliedUiSchemaOptions.format === 'password' ? 'password' : 'text',
4471
+ disabled: !enabled,
4472
+ value: data,
4473
+ width: '100%',
4474
+ readonly: readOnly,
4475
+ maxLength: isSinField ? 11 : '',
4476
+ placeholder: placeholder
4477
+ }, (_l = uischema.options) === null || _l === void 0 ? void 0 : _l.componentProps, {
4478
+ // maxLength={appliedUiSchemaOptions?.maxLength}
4479
+ name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4480
+ testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4481
+ // Don't use handleChange in the onChange event, use the keyPress or onBlur.
4482
+ // If you use it onChange along with keyPress event it will cause a
4483
+ // side effect that causes the validation to render when it shouldn't.
4484
+ onChange: (name, value) => {
4485
+ let formattedValue = value;
4486
+ if (schema && schema.title === sinTitle && value !== '') {
4487
+ formattedValue = formatSin(value);
4488
+ }
4489
+ onChangeForInputControl({
4490
+ name,
4491
+ value: formattedValue,
4492
+ controlProps: props
4493
+ });
4494
+ },
4495
+ onKeyPress: (name, value, key) => {
4496
+ onKeyPressForTextControl({
4497
+ name,
4498
+ value: autoCapitalize ? value.toUpperCase() : value,
4499
+ key,
4500
+ controlProps: props
4501
+ });
4502
+ },
4503
+ onBlur: (name, value) => {
4504
+ onBlurForTextControl({
4505
+ name,
4506
+ controlProps: props,
4507
+ value: autoCapitalize ? value.toUpperCase() : value
4508
+ });
4509
+ }
4510
+ }, (_m = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _m === void 0 ? void 0 : _m.componentProps))
4511
+ });
4512
+ };
4513
+ const GoATextControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
4514
+ input: GoAInputText
4515
+ }));
4516
+ const GoATextControlTester = rankWith(1, isStringControl);
4517
+ const GoAInputTextControl = withJsonFormsControlProps(GoATextControl);
4518
+
4519
+ const MultiLineText = props => {
4520
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
4521
+ const {
4522
+ data,
4523
+ config,
4524
+ id,
4525
+ enabled,
4526
+ uischema,
4527
+ path,
4528
+ handleChange,
4529
+ schema,
4530
+ label
4531
+ } = props;
4532
+ const {
4533
+ required
4534
+ } = props;
4535
+ const [textAreaValue, _] = React.useState(data);
4536
+ const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4537
+ const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
4538
+ const errorsFormInput = checkFieldValidity(props);
4539
+ const width = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : '100%';
4540
+ const autoCapitalize = ((_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.autoCapitalize) === true || ((_f = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _f === void 0 ? void 0 : _f.autoCapitalize) === true;
4541
+ const readOnly = (_j = (_h = (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps) === null || _h === void 0 ? void 0 : _h.readOnly) !== null && _j !== void 0 ? _j : false;
4542
+ const textAreaName = `${label || path}-text-area` || '';
4543
+ (_k = document.getElementsByName(textAreaName)[0]) !== null && _k !== void 0 ? _k : null;
4544
+ const txtAreaComponent = jsx(GoATextArea, Object.assign({
4545
+ error: errorsFormInput.length > 0,
4546
+ value: textAreaValue,
4547
+ disabled: !enabled,
4548
+ readOnly: readOnly,
4549
+ placeholder: placeholder,
4550
+ testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4551
+ name: textAreaName,
4552
+ width: width,
4553
+ // Note: Paul Jan-09-2023. The latest ui-component come with the maxCount. We need to uncomment the following line when the component is updated
4554
+ // maxCount={schema.maxLength || 256}
4555
+ onKeyPress: (name, value, key) => {
4556
+ const newValue = autoCapitalize ? value.toUpperCase() : value;
4557
+ if (value.length === 0 || required && errorsFormInput.length === 0 && value.length > 0) {
4558
+ onKeyPressForTextControl({
4559
+ name,
4560
+ value: newValue,
4561
+ key,
4562
+ controlProps: props
4563
+ });
4564
+ }
4565
+ onChangeForInputControl({
4429
4566
  name,
4430
- value,
4567
+ value: newValue,
4431
4568
  controlProps: props
4432
4569
  });
4570
+ },
4571
+ onChange: (name, value) => {
4572
+ // this is not triggered unless you tab out
4433
4573
  }
4434
- }, (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps));
4574
+ }, (_l = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _l === void 0 ? void 0 : _l.componentProps));
4575
+ return txtAreaComponent;
4435
4576
  };
4436
- const GoADateTimeControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
4437
- input: GoADateTimeInput
4577
+ const MultiLineTextControlInput = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
4578
+ input: MultiLineText
4438
4579
  }));
4439
- const GoADateTimeControlTester = rankWith(2, isDateTimeControl);
4440
- const GoAInputDateTimeControl = withJsonFormsControlProps(GoADateTimeControl);
4580
+ const MultiLineTextControlTester = rankWith(3, and(isStringControl, optionIs('multi', true)));
4581
+ const MultiLineTextControl = withJsonFormsControlProps(MultiLineTextControlInput);
4441
4582
 
4442
- const GoATimeInput = props => {
4443
- var _a, _b, _c, _d, _e, _f, _g;
4444
- // eslint-disable-next-line
4583
+ // Used locally for callout presentation
4584
+ const callout = props => {
4585
+ var _a;
4586
+ const componentProps = Object.assign({
4587
+ size: 'medium',
4588
+ type: 'emergency',
4589
+ message: 'unknown'
4590
+ }, props);
4591
+ const testid = (_a = componentProps.message) === null || _a === void 0 ? void 0 : _a.replace(/\s/g, '');
4592
+ return jsx(GoACallout, Object.assign({}, componentProps, {
4593
+ "data-testid": testid,
4594
+ children: componentProps.message
4595
+ }));
4596
+ };
4597
+ const CalloutControl = props => {
4598
+ var _a, _b;
4599
+ return callout(((_b = (_a = props === null || props === void 0 ? void 0 : props.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.componentProps) || {});
4600
+ };
4601
+ const GoACalloutControlTester = rankWith(1, uiTypeIs('Callout'));
4602
+ var GoACalloutControl = withJsonFormsRendererProps(CalloutControl);
4603
+
4604
+ const errMalformedDate = (scope, type) => {
4605
+ return `${type}-date for variable '${scope}' has an incorrect format.`;
4606
+ };
4607
+ const isValidDateFormat = date => {
4608
+ const standardized = standardizeDate(date);
4609
+ return standardized !== undefined;
4610
+ };
4611
+ const invalidDateFormat = (scope, type) => {
4612
+ return callout({
4613
+ message: errMalformedDate(scope, type)
4614
+ });
4615
+ };
4616
+ // eslint-disable-next-line
4617
+ const reformatDateProps = props => {
4618
+ const newProps = Object.assign({}, props);
4619
+ if (newProps) {
4620
+ if ((newProps === null || newProps === void 0 ? void 0 : newProps.min) && typeof newProps.min === 'string') {
4621
+ newProps.min = standardizeDate(newProps.min);
4622
+ }
4623
+ if ((newProps === null || newProps === void 0 ? void 0 : newProps.max) && typeof newProps.max === 'string') {
4624
+ newProps.max = standardizeDate(newProps.max);
4625
+ }
4626
+ }
4627
+ return newProps;
4628
+ };
4629
+ const GoADateInput = props => {
4630
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
4445
4631
  const {
4446
4632
  data,
4447
4633
  config,
4448
4634
  id,
4449
4635
  enabled,
4450
4636
  uischema,
4451
- isValid,
4452
4637
  path,
4453
4638
  handleChange,
4454
- schema,
4455
4639
  label
4456
4640
  } = props;
4457
4641
  const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4458
- (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
4459
4642
  const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
4460
- const errorsFormInput = checkFieldValidity(props);
4461
- const width = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.readOnly) !== null && _f !== void 0 ? _f : '100%';
4462
- return jsx(GoAInputTime, Object.assign({
4463
- error: errorsFormInput.length > 0,
4464
- name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4465
- value: data,
4466
- step: 1,
4643
+ const width = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : '100%';
4644
+ const minDate = (_h = (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps) === null || _h === void 0 ? void 0 : _h.min;
4645
+ if (minDate && !isValidDateFormat(minDate)) {
4646
+ return invalidDateFormat(uischema.scope, 'Min');
4647
+ }
4648
+ const maxDate = (_k = (_j = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _j === void 0 ? void 0 : _j.componentProps) === null || _k === void 0 ? void 0 : _k.max;
4649
+ if (maxDate && !isValidDateFormat(maxDate)) {
4650
+ return invalidDateFormat(uischema.scope, 'Max');
4651
+ }
4652
+ return jsx(GoAInputDate, Object.assign({
4653
+ error: checkFieldValidity(props).length > 0,
4467
4654
  width: width,
4655
+ name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4656
+ value: standardizeDate(data) || '',
4657
+ testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4468
4658
  disabled: !enabled,
4469
4659
  readonly: readOnly,
4470
- testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4471
- onBlur: (name, value) => {
4472
- onBlurForTimeControl({
4660
+ onChange: (name, value) => {
4661
+ onChangeForDateControl({
4473
4662
  name,
4474
4663
  value,
4475
4664
  controlProps: props
4476
4665
  });
4477
4666
  },
4478
- // Dont use handleChange in the onChange event, use the keyPress or onBlur.
4479
- // If you use it onChange along with keyPress event it will cause a
4480
- // side effect that causes the validation to render when it shouldnt.
4481
- onChange: (name, value) => {},
4482
4667
  onKeyPress: (name, value, key) => {
4483
- onKeyPressForTimeControl({
4668
+ onKeyPressForDateControl({
4484
4669
  name,
4485
4670
  value,
4486
4671
  key,
4487
4672
  controlProps: props
4488
4673
  });
4674
+ },
4675
+ onBlur: (name, value) => {
4676
+ onBlurForDateControl({
4677
+ name,
4678
+ value,
4679
+ controlProps: props
4680
+ });
4489
4681
  }
4490
- }, (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps));
4682
+ }, reformatDateProps((_l = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _l === void 0 ? void 0 : _l.componentProps)));
4491
4683
  };
4492
- const GoATimeControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
4493
- input: GoATimeInput
4684
+ const GoADateControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
4685
+ input: GoADateInput
4494
4686
  }));
4495
- const GoATimeControlTester = rankWith(4, isTimeControl);
4496
- const GoAInputTimeControl = withJsonFormsControlProps(GoATimeControl);
4497
-
4498
- // a string of all valid unicode whitespaces
4499
- var whitespaces$2 = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
4500
- '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
4501
-
4502
- var uncurryThis$3 = functionUncurryThis;
4503
- var requireObjectCoercible$1 = requireObjectCoercible$b;
4504
- var toString$1 = toString$e;
4505
- var whitespaces$1 = whitespaces$2;
4506
-
4507
- var replace = uncurryThis$3(''.replace);
4508
- var ltrim = RegExp('^[' + whitespaces$1 + ']+');
4509
- var rtrim = RegExp('(^|[^' + whitespaces$1 + '])[' + whitespaces$1 + ']+$');
4687
+ const GoADateControlTester = rankWith(4, isDateControl);
4688
+ const GoAInputDateControl = withJsonFormsControlProps(GoADateControl);
4510
4689
 
4511
- // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
4512
- var createMethod$1 = function (TYPE) {
4513
- return function ($this) {
4514
- var string = toString$1(requireObjectCoercible$1($this));
4515
- if (TYPE & 1) string = replace(string, ltrim, '');
4516
- if (TYPE & 2) string = replace(string, rtrim, '$1');
4517
- return string;
4518
- };
4519
- };
4520
-
4521
- var stringTrim = {
4522
- // `String.prototype.{ trimLeft, trimStart }` methods
4523
- // https://tc39.es/ecma262/#sec-string.prototype.trimstart
4524
- start: createMethod$1(1),
4525
- // `String.prototype.{ trimRight, trimEnd }` methods
4526
- // https://tc39.es/ecma262/#sec-string.prototype.trimend
4527
- end: createMethod$1(2),
4528
- // `String.prototype.trim` method
4529
- // https://tc39.es/ecma262/#sec-string.prototype.trim
4530
- trim: createMethod$1(3)
4531
- };
4532
-
4533
- var PROPER_FUNCTION_NAME = functionName.PROPER;
4534
- var fails$3 = fails$r;
4535
- var whitespaces = whitespaces$2;
4536
-
4537
- var non = '\u200B\u0085\u180E';
4538
-
4539
- // check that a method works with the correct list
4540
- // of whitespaces and has a correct name
4541
- var stringTrimForced = function (METHOD_NAME) {
4542
- return fails$3(function () {
4543
- return !!whitespaces[METHOD_NAME]()
4544
- || non[METHOD_NAME]() !== non
4545
- || (PROPER_FUNCTION_NAME && whitespaces[METHOD_NAME].name !== METHOD_NAME);
4546
- });
4547
- };
4548
-
4549
- var $$a = _export;
4550
- var $trim = stringTrim.trim;
4551
- var forcedStringTrimMethod = stringTrimForced;
4552
-
4553
- // `String.prototype.trim` method
4554
- // https://tc39.es/ecma262/#sec-string.prototype.trim
4555
- $$a({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
4556
- trim: function trim() {
4557
- return $trim(this);
4558
- }
4559
- });
4560
-
4561
- const ENTER_KEY = 'Enter';
4562
- const ESCAPE_KEY = 'Escape';
4563
- const ARROW_DOWN_KEY = 'ArrowDown';
4564
- const ARROW_UP_KEY = 'ArrowUp';
4565
- const TAB_KEY = 'Tab';
4566
- const SPACE_KEY = ' ';
4567
- const ALT_KEY = 'Alt';
4568
- const SHIFT_KEY = 'Shift';
4569
-
4570
- let _$8 = t => t,
4571
- _t$8,
4572
- _t2$5,
4573
- _t3$4,
4574
- _t4$3;
4575
- const GoADropdownTextbox = styled.div(_t$8 || (_t$8 = _$8`
4576
- border-radius: var(--goa-space-2xs);
4577
- box-shadow: ${0};
4578
- &:hover {
4579
- cursor: pointer;
4580
- }
4581
-
4582
- .inputStyle {
4583
- box-shadow: ${0};
4584
- }
4585
- `), p => p.isOpen ? `0 0 0 3px var(--goa-color-interactive-focus)` : '', p => p.isOpen ? `0 0 0 3px var(--goa-color-interactive-focus) !important` : '');
4586
- const GoADropdownListContainerWrapper = styled.div(_t2$5 || (_t2$5 = _$8`
4587
- position: relative;
4588
- display: ${0};
4589
- `), p => !(p === null || p === void 0 ? void 0 : p.isOpen) && 'none');
4590
- const GoADropdownListContainer = styled.div(_t3$4 || (_t3$4 = _$8`
4591
- border: solid 1px var(--goa-color-greyscale-200);
4592
- border-radius: var(--goa-space-2xs);
4593
- background: var(--goa-color-greyscale-white);
4594
- padding: 0;
4595
- margin-top: 3px;
4596
- width: 100%;
4597
- overflow-y: auto;
4598
- z-index: 1000;
4599
- caret-color: transparent;
4600
- position: absolute;
4601
- line-height: var(--goa-space-xl);
4602
- max-height: ${0};
4603
-
4604
- &:focus-visible {
4605
- outline-color: var(--goa-color-interactive-default);
4606
- }
4607
- &:hover {
4608
- background-color: var(--goa-color-interactive-hover) !important;
4609
- color: #fff !important;
4610
- /* Fix to override scrollbar color in Firefox */
4611
- scrollbar-color: #a8a8a8 var(--goa-color-greyscale-100) !important;
4612
- }
4613
- `), p => p.optionListMaxHeight || '272px');
4614
- const GoADropdownListOption = styled.div(_t4$3 || (_t4$3 = _$8`
4615
- padding: var(--goa-space-2xs) var(--goa-space-s);
4616
- text-overflow: ellipsis;
4617
- color: ${0} !important;
4618
- border: 0px solid var(--goa-color-greyscale-100);
4619
- z-index: 1001;
4620
- cursor: pointer;
4621
- background: ${0};
4622
- :has(div:focus) {
4623
- background-color: ${0};
4624
- color: ${0};
4625
- }
4626
- &:hover {
4627
- background-color: ${0};
4628
- color: ${0};
4629
- }
4630
-
4631
- &:focus-visible {
4632
- caret-color: transparent;
4633
- color: black !important;
4634
- background-color: ${0};
4635
- }
4636
- &:focus-within {
4637
- caret-color: transparent;
4638
- color: #fff !important;
4639
- background-color: ${0};
4640
- }
4641
- .dropDownListItem:focus-visible {
4642
- caret-color: transparent;
4643
- outline: none !important;
4644
- color: ${0};
4645
- }
4646
- `), p => p.isSelected ? '#fff' : 'var(--goa-color-greyscale-black)', p => p.isSelected ? 'var(--goa-color-interactive-default)' : '#fff', p => p.isSelected ? 'var(--goa-color-interactive-hover)' : 'var(--goa-color-greyscale-100) !important', p => p.isSelected ? 'var(--goa-color-interactive-default)' : 'var(--goa-color-interactive-hover) !important', p => p.isSelected ? 'var(--goa-color-interactive-hover)' : 'var(--goa-color-greyscale-100) !important', p => p.isSelected ? 'var(--goa-color-interactive-default)' : 'var(--goa-color-interactive-hover) !important', p => p.isSelected ? 'var(--goa-color-interactive-hover)' : 'var(--goa-color-greyscale-100) !important', p => p.isSelected ? 'var(--goa-color-interactive-hover)' : 'var(--goa-color-greyscale-100) !important', p => p.isSelected ? '#fff' : 'var(--goa-color-interactive-hover) !important');
4647
-
4648
- const isValidKey = keyCode => {
4649
- if (keyCode === SHIFT_KEY || keyCode === ALT_KEY) return false;
4650
- const regex = new RegExp(/^[a-zA-Z0-9!%$@.#?\-_]+$/);
4651
- return regex.test(keyCode);
4652
- };
4653
- const Dropdown = props => {
4654
- var _a;
4690
+ const GoANumberInput = props => {
4691
+ var _a, _b, _c, _d, _e, _f, _g;
4692
+ // eslint-disable-next-line
4655
4693
  const {
4656
- label,
4657
- selected,
4658
- onChange,
4659
- optionListMaxHeight,
4660
- isAutoCompletion,
4694
+ data,
4695
+ config,
4696
+ id,
4661
4697
  enabled,
4662
- id
4698
+ uischema,
4699
+ isValid,
4700
+ path,
4701
+ handleChange,
4702
+ schema,
4703
+ label
4663
4704
  } = props;
4664
- const [isOpen, setIsOpen] = useState(false);
4665
- const [selectedOption, setSelectedOption] = useState(selected);
4666
- const [items, setItems] = useState(props.items);
4667
- const [inputText, setInputText] = useState(selected);
4668
- const prevCountRef = useRef(props.items);
4669
- const trailingIcon = isOpen ? 'chevron-up' : 'chevron-down';
4670
- const textInputName = `dropdown-${label}`;
4671
- const textInput = (_a = document.getElementsByName(textInputName)[0]) !== null && _a !== void 0 ? _a : null;
4672
- const PREFIX = 'jsonforms-dropdown';
4673
- useEffect(() => {
4674
- setItems(props.items);
4675
- prevCountRef.current = props.items;
4676
- // eslint-disable-next-line react-hooks/exhaustive-deps
4677
- }, [isEqual(props.items, prevCountRef.current)]);
4678
- useEffect(() => {
4679
- if (textInput) {
4680
- textInput.addEventListener('keydown', handleKeyDown);
4681
- textInput.addEventListener('blur', handleTextInputOnBlur);
4682
- }
4683
- document.addEventListener('keydown', handleDocumentKeyDown);
4684
- return () => {
4685
- if (textInput) {
4686
- textInput.removeEventListener('keydown', handleKeyDown);
4687
- textInput.removeEventListener('blur', handleTextInputOnBlur);
4688
- }
4689
- document.removeEventListener('keydown', handleDocumentKeyDown);
4690
- };
4691
- // eslint-disable-next-line react-hooks/exhaustive-deps
4692
- }, [textInput, document]);
4693
- /* istanbul ignore next */
4694
- const handleTextInputOnBlur = e => {
4695
- if (e.relatedTarget === null) {
4696
- setIsOpen(false);
4697
- } else if (e.relatedTarget && !isAutoCompletion) {
4698
- const dropDownEl = e.relatedTarget;
4699
- if (dropDownEl) {
4700
- if (!dropDownEl.id.startsWith(`${PREFIX}-${label}`)) {
4701
- setIsOpen(false);
4702
- }
4703
- }
4704
- }
4705
- };
4706
- const updateDropDownData = item => {
4707
- onChange(item.value);
4708
- setSelectedOption(item.value);
4709
- setInputText(item.label);
4710
- if (isAutoCompletion) {
4711
- const selectedItems = props.items.filter(filterItem => {
4712
- return filterItem.label === item.label;
4705
+ const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4706
+ const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
4707
+ const InputValue = data && data !== undefined ? data : '';
4708
+ const clonedSchema = JSON.parse(JSON.stringify(schema));
4709
+ const StepValue = clonedSchema.multipleOf ? clonedSchema.multipleOf : 0.01;
4710
+ const MinValue = clonedSchema.minimum ? clonedSchema.minimum : '';
4711
+ const MaxValue = clonedSchema.exclusiveMaximum ? clonedSchema.exclusiveMaximum : '';
4712
+ const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
4713
+ const width = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : '100%';
4714
+ const errorsFormInput = checkFieldValidity(props);
4715
+ return jsx(GoAInput, Object.assign({
4716
+ type: "number",
4717
+ error: errorsFormInput.length > 0,
4718
+ disabled: !enabled,
4719
+ readonly: readOnly,
4720
+ value: InputValue,
4721
+ placeholder: placeholder,
4722
+ step: StepValue,
4723
+ min: MinValue,
4724
+ max: MaxValue,
4725
+ width: width,
4726
+ name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4727
+ testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4728
+ onKeyPress: (name, value, key) => {
4729
+ onKeyPressNumericControl({
4730
+ name,
4731
+ value,
4732
+ key,
4733
+ controlProps: props
4734
+ });
4735
+ },
4736
+ onBlur: (name, value) => {
4737
+ onBlurForNumericControl({
4738
+ name,
4739
+ value,
4740
+ controlProps: props
4741
+ });
4742
+ },
4743
+ onChange: (name, value) => {
4744
+ onChangeForNumericControl({
4745
+ name,
4746
+ value,
4747
+ controlProps: props
4713
4748
  });
4714
- setItems(selectedItems);
4715
- }
4716
- setIsOpen(false);
4717
- };
4718
- const setInputTextFocus = () => {
4719
- const inputEl = document.getElementById(`${id}-input`);
4720
- if (inputEl) {
4721
- //The 'focused' property is part of the GoAInput component that is used to
4722
- //set focus on the input field. We need to set it back to false once we set focus on the input field. Doing with just .focus() doesnt work.
4723
- inputEl.focused = true;
4724
- inputEl.focus();
4725
- inputEl.focused = false;
4726
- }
4727
- };
4728
- const setElementFocus = (e, element, preventDefault) => {
4729
- if (element) {
4730
- element.focus();
4731
- if (preventDefault) {
4732
- e.preventDefault();
4733
- }
4734
- }
4735
- };
4736
- /* istanbul ignore next */
4737
- const handleDocumentKeyDown = e => {
4738
- if (e.key === ESCAPE_KEY || e.key === TAB_KEY) {
4739
- setIsOpen(false);
4740
- }
4741
- };
4742
- /* istanbul ignore next */
4743
- const handleKeyDown = e => {
4744
- var _a, _b, _c;
4745
- if (e.key === ENTER_KEY || e.key === SPACE_KEY) {
4746
- setIsOpen(previousIsOpen => !previousIsOpen);
4747
- const el = document.getElementById(`${PREFIX}-${label}-${(_a = items.at(0)) === null || _a === void 0 ? void 0 : _a.value}`);
4748
- setInputTextFocus();
4749
- setElementFocus(e, el, false);
4750
- } else if (e.key === ARROW_UP_KEY) {
4751
- setIsOpen(true);
4752
- const val = `${PREFIX}-${label}-${(_b = items.at(1)) === null || _b === void 0 ? void 0 : _b.value}`;
4753
- const el = document.getElementById(val);
4754
- setElementFocus(e, el, false);
4755
- } else if (e.key === ARROW_DOWN_KEY) {
4756
- setIsOpen(true);
4757
- const firstItem = props.items.at(0);
4758
- let index = 0;
4759
- if ((firstItem === null || firstItem === void 0 ? void 0 : firstItem.label.trim()) === '') {
4760
- index = 1;
4761
- }
4762
- let el = document.getElementById(`${PREFIX}-${label}-${(_c = props.items.at(index)) === null || _c === void 0 ? void 0 : _c.value}`);
4763
- if (el === null && !isAutoCompletion) {
4764
- const elements = document.querySelectorAll(`[id='${PREFIX}-dropDownList-${label}']`);
4765
- const element = elements.item(0).children.item(1);
4766
- el = document.getElementById(`${PREFIX}-${label}-${element.innerText}`);
4767
- } else if (el === null && isAutoCompletion) {
4768
- const elements = document.querySelectorAll(`[id=${PREFIX}-dropDownList-${label}]`);
4769
- const element = elements[0].children[0];
4770
- el = document.getElementById(`${PREFIX}-${label}-${element.innerText}`);
4771
- }
4772
- setElementFocus(e, el, true);
4773
- } else if (e.key === ESCAPE_KEY || e.key === TAB_KEY) {
4774
- setIsOpen(false);
4775
- } else {
4776
- if (isValidKey(e.key)) {
4777
- setIsOpen(true);
4778
- }
4779
- }
4780
- };
4781
- const handDropDownItemOnKeyDown = (e, item) => {
4782
- var _a, _b, _c, _d;
4783
- if (e.key === ENTER_KEY || e.key === SPACE_KEY) {
4784
- updateDropDownData(item);
4785
- setInputTextFocus();
4786
- }
4787
- if (e.key === ESCAPE_KEY) {
4788
- setIsOpen(false);
4789
- setInputTextFocus();
4790
4749
  }
4791
- let index = items.findIndex(val => {
4792
- return val.label === e.currentTarget.innerText;
4793
- });
4794
- //Prevent jumping to the next control/DOM element if
4795
- //we are on the last item in the drop down list
4796
- if (e.key === ARROW_DOWN_KEY) {
4797
- if (item.label === ((_a = items.at(-1)) === null || _a === void 0 ? void 0 : _a.label)) {
4798
- e.preventDefault();
4799
- }
4800
- if (index === -1 && item.label.trim() === '') {
4801
- index = 0;
4802
- }
4803
- const el = document.getElementById(`${PREFIX}-${label}-${(_b = items.at(index + 1)) === null || _b === void 0 ? void 0 : _b.value}`);
4804
- if (el) {
4805
- setElementFocus(e, el, true);
4806
- return;
4807
- }
4750
+ }, (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps));
4751
+ };
4752
+ const GoANumberControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
4753
+ input: GoANumberInput
4754
+ }));
4755
+ const GoANumberControlTester = rankWith(2, isNumberControl);
4756
+ const GoAInputNumberControl = withJsonFormsControlProps(GoANumberControl);
4757
+
4758
+ const GoAInputInteger = props => {
4759
+ var _a, _b, _c, _d, _e, _f, _g;
4760
+ // eslint-disable-next-line
4761
+ const {
4762
+ data,
4763
+ config,
4764
+ id,
4765
+ enabled,
4766
+ uischema,
4767
+ isValid,
4768
+ path,
4769
+ handleChange,
4770
+ schema,
4771
+ label
4772
+ } = props;
4773
+ const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4774
+ const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
4775
+ const InputValue = data && data !== undefined ? data : '';
4776
+ const clonedSchema = JSON.parse(JSON.stringify(schema));
4777
+ const StepValue = clonedSchema.multipleOf ? clonedSchema.multipleOf : 0;
4778
+ const MinValue = clonedSchema.minimum ? clonedSchema.minimum : '';
4779
+ const MaxValue = clonedSchema.exclusiveMaximum ? clonedSchema.exclusiveMaximum : '';
4780
+ const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
4781
+ const width = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : '100%';
4782
+ const errorsFormInput = checkFieldValidity(props);
4783
+ return jsx(GoAInput, Object.assign({
4784
+ type: "number",
4785
+ error: errorsFormInput.length > 0,
4786
+ width: width,
4787
+ disabled: !enabled,
4788
+ readonly: readOnly,
4789
+ value: InputValue,
4790
+ step: StepValue,
4791
+ min: MinValue,
4792
+ max: MaxValue,
4793
+ placeholder: placeholder,
4794
+ name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4795
+ testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4796
+ onKeyPress: (name, value, key) => {
4797
+ onKeyPressNumericControl({
4798
+ name,
4799
+ value,
4800
+ key,
4801
+ controlProps: props
4802
+ });
4803
+ },
4804
+ onBlur: (name, value) => {
4805
+ onBlurForNumericControl({
4806
+ name,
4807
+ value,
4808
+ controlProps: props
4809
+ });
4810
+ },
4811
+ onChange: (name, value) => {
4812
+ onChangeForNumericControl({
4813
+ name,
4814
+ value,
4815
+ controlProps: props
4816
+ });
4808
4817
  }
4809
- if (e.key === ARROW_UP_KEY) {
4810
- if (index <= 0) {
4811
- e.preventDefault();
4812
- return;
4813
- }
4814
- const el = document.getElementById(`${PREFIX}-${label}-${(_c = items.at(index - 1)) === null || _c === void 0 ? void 0 : _c.value}`);
4815
- if (el) {
4816
- el.focus();
4817
- }
4818
+ }, (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps));
4819
+ };
4820
+ const GoAIntegerControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
4821
+ input: GoAInputInteger
4822
+ }));
4823
+ const GoAIntegerControlTester = rankWith(2, isIntegerControl);
4824
+ const GoAInputIntegerControl = withJsonFormsControlProps(GoAIntegerControl);
4825
+
4826
+ const GoADateTimeInput = props => {
4827
+ var _a, _b, _c, _d, _e, _f, _g;
4828
+ // eslint-disable-next-line
4829
+ const {
4830
+ data,
4831
+ config,
4832
+ id,
4833
+ enabled,
4834
+ uischema,
4835
+ isValid,
4836
+ path,
4837
+ errors,
4838
+ handleChange,
4839
+ schema,
4840
+ label
4841
+ } = props;
4842
+ const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4843
+ const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
4844
+ const width = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : '100%';
4845
+ return jsx(GoAInputDateTime, Object.assign({
4846
+ error: checkFieldValidity(props).length > 0,
4847
+ width: width,
4848
+ name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4849
+ value: data ? new Date(data).toISOString() : '',
4850
+ testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4851
+ disabled: !enabled,
4852
+ readonly: readOnly,
4853
+ onChange: (name, value) => {
4854
+ onChangeForDateTimeControl({
4855
+ name,
4856
+ value,
4857
+ controlProps: props
4858
+ });
4859
+ },
4860
+ onKeyPress: (name, value, key) => {
4861
+ onKeyPressForDateControl({
4862
+ name,
4863
+ value,
4864
+ key,
4865
+ controlProps: props
4866
+ });
4867
+ },
4868
+ onBlur: (name, value) => {
4869
+ onBlurForDateControl({
4870
+ name,
4871
+ value,
4872
+ controlProps: props
4873
+ });
4818
4874
  }
4819
- if (e.key === TAB_KEY) {
4820
- const val = `${PREFIX}-${label}-${(_d = items.at(index - 1)) === null || _d === void 0 ? void 0 : _d.value}`;
4821
- const el = document.getElementById(val);
4822
- if (el) {
4823
- setIsOpen(false);
4824
- }
4875
+ }, (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps));
4876
+ };
4877
+ const GoADateTimeControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
4878
+ input: GoADateTimeInput
4879
+ }));
4880
+ const GoADateTimeControlTester = rankWith(2, isDateTimeControl);
4881
+ const GoAInputDateTimeControl = withJsonFormsControlProps(GoADateTimeControl);
4882
+
4883
+ const GoATimeInput = props => {
4884
+ var _a, _b, _c, _d, _e, _f, _g;
4885
+ // eslint-disable-next-line
4886
+ const {
4887
+ data,
4888
+ config,
4889
+ id,
4890
+ enabled,
4891
+ uischema,
4892
+ isValid,
4893
+ path,
4894
+ handleChange,
4895
+ schema,
4896
+ label
4897
+ } = props;
4898
+ const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4899
+ (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
4900
+ const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
4901
+ const errorsFormInput = checkFieldValidity(props);
4902
+ const width = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.readOnly) !== null && _f !== void 0 ? _f : '100%';
4903
+ return jsx(GoAInputTime, Object.assign({
4904
+ error: errorsFormInput.length > 0,
4905
+ name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4906
+ value: data,
4907
+ step: 1,
4908
+ width: width,
4909
+ disabled: !enabled,
4910
+ readonly: readOnly,
4911
+ testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4912
+ onBlur: (name, value) => {
4913
+ onBlurForTimeControl({
4914
+ name,
4915
+ value,
4916
+ controlProps: props
4917
+ });
4918
+ },
4919
+ // Dont use handleChange in the onChange event, use the keyPress or onBlur.
4920
+ // If you use it onChange along with keyPress event it will cause a
4921
+ // side effect that causes the validation to render when it shouldnt.
4922
+ onChange: (name, value) => {},
4923
+ onKeyPress: (name, value, key) => {
4924
+ onKeyPressForTimeControl({
4925
+ name,
4926
+ value,
4927
+ key,
4928
+ controlProps: props
4929
+ });
4825
4930
  }
4826
- };
4827
- return jsxs("div", {
4828
- "data-testid": id,
4829
- children: [jsx(GoADropdownTextbox, {
4830
- isOpen: isOpen,
4831
- onClick: e => {
4832
- setIsOpen(previousIsOpen => !previousIsOpen);
4833
- },
4834
- children: jsx(GoAInput, {
4835
- disabled: !enabled,
4836
- name: `dropdown-${label}`,
4837
- width: "100%",
4838
- value: inputText,
4839
- testId: `${id}-input`,
4840
- id: `${id}-input`,
4841
- readonly: !isAutoCompletion,
4842
- onChange: (name, value) => {
4843
- if (isAutoCompletion) {
4844
- setInputText(value);
4845
- const selectedItems = props.items.filter(item => {
4846
- return item.label.includes(value);
4847
- });
4848
- setItems(selectedItems);
4849
- }
4850
- },
4851
- onTrailingIconClick: () => {},
4852
- trailingIcon: trailingIcon
4853
- })
4854
- }), jsx(GoADropdownListContainerWrapper, {
4855
- isOpen: isOpen,
4856
- id: `${PREFIX}-dropDownListContainerWrapper-${label}`,
4857
- children: jsx(GoADropdownListContainer, {
4858
- id: `${PREFIX}-dropDownList-${label}`,
4859
- optionListMaxHeight: optionListMaxHeight,
4860
- children: items.map(item => {
4861
- return jsx(GoADropdownListOption, {
4862
- id: `${PREFIX}-option-${label}-${item.value}`,
4863
- isSelected: item.value === selected || item.value === selectedOption,
4864
- children: jsx("div", {
4865
- tabIndex: 0,
4866
- className: "dropDownListItem",
4867
- "data-testid": `${id}-${item.label}-option`,
4868
- id: `${PREFIX}-${label}-${item.value}`,
4869
- onKeyDown: e => {
4870
- handDropDownItemOnKeyDown(e, item);
4871
- },
4872
- onClick: e => {
4873
- updateDropDownData(item);
4874
- },
4875
- children: item.label
4876
- }, `${PREFIX}-${label}-${item.value}`)
4877
- }, `${PREFIX}-option-${label}-${item.value}`);
4878
- })
4879
- }, `${PREFIX}-dropDownList-${label}`)
4880
- }, `${PREFIX}-dropDownListContainerWrapper-${label}`)]
4881
- }, id);
4931
+ }, (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps));
4882
4932
  };
4933
+ const GoATimeControl = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
4934
+ input: GoATimeInput
4935
+ }));
4936
+ const GoATimeControlTester = rankWith(4, isTimeControl);
4937
+ const GoAInputTimeControl = withJsonFormsControlProps(GoATimeControl);
4883
4938
 
4884
4939
  function fetchRegisterConfigFromOptions(options) {
4885
4940
  if (!(options === null || options === void 0 ? void 0 : options.url) && !(options === null || options === void 0 ? void 0 : options.urn)) return undefined;
@@ -5859,13 +5914,15 @@ const stepperReducer = (state, action) => {
5859
5914
  {
5860
5915
  const {
5861
5916
  id,
5917
+ ajv,
5862
5918
  errors
5863
5919
  } = action.payload;
5864
- if (state.isOnReview) {
5865
- return Object.assign({}, state);
5866
- }
5920
+ /*
5921
+ ctx.core.errors only includes required errors when the fields are touched. In this case, we still ajv to figure out the required errors at the very beginning.
5922
+ */
5923
+ const incompletePaths = getIncompletePaths(ajv, state.categories[id].scopes);
5867
5924
  const errorsInCategory = errors.filter(e => categories[id].scopes.map(s => '/' + toDataPath(s)).includes(e.instancePath));
5868
- state.categories[id].isCompleted = errorsInCategory.filter(e => e.keyword === 'required').length === 0;
5925
+ state.categories[id].isCompleted = (incompletePaths === null || incompletePaths === void 0 ? void 0 : incompletePaths.length) === 0;
5869
5926
  state.categories[id].isValid = errorsInCategory.length === 0;
5870
5927
  return Object.assign({}, state);
5871
5928
  }
@@ -5945,7 +6002,12 @@ const JsonFormsStepperContextProvider = ({
5945
6002
  children,
5946
6003
  StepperProps
5947
6004
  }) => {
6005
+ var _a;
5948
6006
  const ctx = useJsonForms();
6007
+ const {
6008
+ schema,
6009
+ ajv
6010
+ } = StepperProps;
5949
6011
  const [stepperState, dispatch] = useReducer(stepperReducer, createStepperContextInitData(StepperProps));
5950
6012
  const stepperDispatch = (StepperProps === null || StepperProps === void 0 ? void 0 : StepperProps.customDispatch) || dispatch;
5951
6013
  const context = useMemo(() => {
@@ -5969,13 +6031,15 @@ const JsonFormsStepperContextProvider = ({
5969
6031
  return stepperState.categories[id];
5970
6032
  },
5971
6033
  goToPage: (id, updateCategoryId) => {
5972
- var _a, _b, _c;
6034
+ var _a, _b, _c, _d;
6035
+ ajv.validate(schema, ((_a = ctx.core) === null || _a === void 0 ? void 0 : _a.data) || {});
5973
6036
  if (updateCategoryId !== undefined) {
5974
6037
  stepperDispatch({
5975
6038
  type: 'update/category',
5976
6039
  payload: {
5977
- errors: ((_a = ctx.core) === null || _a === void 0 ? void 0 : _a.errors) || [],
5978
- id: updateCategoryId
6040
+ errors: (_b = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _b === void 0 ? void 0 : _b.errors,
6041
+ id: updateCategoryId,
6042
+ ajv
5979
6043
  }
5980
6044
  });
5981
6045
  }
@@ -5983,15 +6047,16 @@ const JsonFormsStepperContextProvider = ({
5983
6047
  stepperDispatch({
5984
6048
  type: 'update/category',
5985
6049
  payload: {
5986
- errors: ((_b = ctx.core) === null || _b === void 0 ? void 0 : _b.errors) || [],
5987
- id: stepperState.activeId
6050
+ errors: (_c = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _c === void 0 ? void 0 : _c.errors,
6051
+ id: stepperState.activeId,
6052
+ ajv
5988
6053
  }
5989
6054
  });
5990
6055
  }
5991
6056
  stepperDispatch({
5992
6057
  type: 'validate/form',
5993
6058
  payload: {
5994
- errors: (_c = ctx.core) === null || _c === void 0 ? void 0 : _c.errors
6059
+ errors: (_d = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _d === void 0 ? void 0 : _d.errors
5995
6060
  }
5996
6061
  });
5997
6062
  stepperDispatch({
@@ -6002,7 +6067,7 @@ const JsonFormsStepperContextProvider = ({
6002
6067
  });
6003
6068
  }
6004
6069
  };
6005
- }, [ctx === null || ctx === void 0 ? void 0 : ctx.core, stepperDispatch, stepperState]);
6070
+ }, [stepperDispatch, stepperState, (_a = ctx.core) === null || _a === void 0 ? void 0 : _a.errors]);
6006
6071
  useEffect(() => {
6007
6072
  if ((context === null || context === void 0 ? void 0 : context.isProvided) === true) {
6008
6073
  stepperDispatch({
@@ -6012,7 +6077,7 @@ const JsonFormsStepperContextProvider = ({
6012
6077
  }
6013
6078
  });
6014
6079
  }
6015
- }, [StepperProps.uischema]);
6080
+ }, [JSON.stringify(StepperProps.uischema), JSON.stringify(StepperProps.schema)]);
6016
6081
  return jsx(JsonFormsStepperContext.Provider, {
6017
6082
  value: context,
6018
6083
  children: children
@@ -6035,7 +6100,7 @@ const FormStepper = props => {
6035
6100
  });
6036
6101
  };
6037
6102
  const FormStepperView = props => {
6038
- var _a, _b, _c;
6103
+ var _a;
6039
6104
  const {
6040
6105
  uischema,
6041
6106
  data,
@@ -6074,17 +6139,15 @@ const FormStepperView = props => {
6074
6139
  const onCloseModal = () => {
6075
6140
  setIsOpen(false);
6076
6141
  };
6077
- return jsxs("div", {
6142
+ return jsx("div", {
6078
6143
  "data-testid": "form-stepper-test-wrapper",
6079
- children: [jsx("div", {
6080
- children: ((_a = categories[activeId]) === null || _a === void 0 ? void 0 : _a.isCompleted) && ((_b = categories[activeId]) === null || _b === void 0 ? void 0 : _b.isVisited)
6081
- }), jsx(Visible, {
6144
+ children: jsx(Visible, {
6082
6145
  visible: visible,
6083
6146
  children: jsxs("div", {
6084
6147
  id: `${path || `goa`}-form-stepper`,
6085
6148
  className: "formStepper",
6086
6149
  children: [jsxs(GoAFormStepper, {
6087
- testId: `form-stepper-headers-${(_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.testId}` || 'form-stepper-test',
6150
+ testId: `form-stepper-headers-${(_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.testId}` || 'form-stepper-test',
6088
6151
  onChange: step => {
6089
6152
  goToPage(step - 1);
6090
6153
  },
@@ -6092,7 +6155,7 @@ const FormStepperView = props => {
6092
6155
  return jsx(GoAFormStep, {
6093
6156
  "data-testid": `stepper-tab-${index}`,
6094
6157
  text: `${c.label}`,
6095
- status: c.isValid ? 'complete' : 'incomplete'
6158
+ status: c.isCompleted && c.isValid ? 'complete' : 'incomplete'
6096
6159
  }, `stepper-tab-${index}`);
6097
6160
  }), jsx(GoAFormStep, {
6098
6161
  text: "Review"
@@ -6187,7 +6250,7 @@ const FormStepperView = props => {
6187
6250
  }), "(i.e. no actual form is being submitted)"]
6188
6251
  })]
6189
6252
  })
6190
- })]
6253
+ })
6191
6254
  });
6192
6255
  };
6193
6256
  const FormStepperControl = withAjvProps(withTranslateProps(withJsonFormsLayoutProps(FormStepper)));
@@ -8381,6 +8444,7 @@ const AddressLookUpControl = props => {
8381
8444
  };
8382
8445
  const [address, setAddress] = useState(data || defaultAddress);
8383
8446
  const [searchTerm, setSearchTerm] = useState('');
8447
+ const [saveSearchTerm, setSaveSearchTerm] = useState(false);
8384
8448
  const [suggestions, setSuggestions] = useState([]);
8385
8449
  const [loading, setLoading] = useState(false);
8386
8450
  const [errors, setErrors] = useState({});
@@ -8421,6 +8485,12 @@ const AddressLookUpControl = props => {
8421
8485
  showLabel: false
8422
8486
  }));
8423
8487
  };
8488
+ useEffect(() => {
8489
+ if (saveSearchTerm) {
8490
+ handleInputChange('addressLine1', searchTerm);
8491
+ setSaveSearchTerm(false);
8492
+ }
8493
+ }, [saveSearchTerm]); // eslint-disable-line react-hooks/exhaustive-deps
8424
8494
  useEffect(() => {
8425
8495
  const fetchSuggestions = () => __awaiter(void 0, void 0, void 0, function* () {
8426
8496
  if (searchTerm.length > 2 && dropdownSelected === false) {
@@ -8441,10 +8511,10 @@ const AddressLookUpControl = props => {
8441
8511
  }
8442
8512
  });
8443
8513
  fetchSuggestions();
8444
- }, [searchTerm, dropdownSelected]); // eslint-disable-line react-hooks/exhaustive-deps
8514
+ }, [searchTerm]); // eslint-disable-line react-hooks/exhaustive-deps
8445
8515
  const handleDropdownChange = value => {
8446
8516
  setSearchTerm(value);
8447
- handleInputChange('addressLine1', value);
8517
+ setSaveSearchTerm(true);
8448
8518
  };
8449
8519
  const handleSuggestionClick = suggestion => {
8450
8520
  const suggestAddress = mapSuggestionToAddress(suggestion);