@abgov/jsonforms-components 1.41.2 → 1.41.4

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.
Files changed (2) hide show
  1. package/index.esm.js +31 -15
  2. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -4425,6 +4425,8 @@ const ARROW_DOWN_KEY = 'ArrowDown';
4425
4425
  const ARROW_UP_KEY = 'ArrowUp';
4426
4426
  const TAB_KEY = 'Tab';
4427
4427
  const SPACE_KEY = ' ';
4428
+ const ALT_KEY = 'Alt';
4429
+ const SHIFT_KEY = 'Shift';
4428
4430
 
4429
4431
  let _$7 = t => t,
4430
4432
  _t$7,
@@ -4466,6 +4468,8 @@ const GoADropdownListContainer = styled.div(_t3$4 || (_t3$4 = _$7`
4466
4468
  &:hover {
4467
4469
  background-color: var(--goa-color-interactive-hover) !important;
4468
4470
  color: #fff !important;
4471
+ /* Fix to override scrollbar color in Firefox */
4472
+ scrollbar-color: #a8a8a8 var(--goa-color-greyscale-100) !important;
4469
4473
  }
4470
4474
  `), p => p.optionListMaxHeight || '272px');
4471
4475
  const GoADropdownListOption = styled.div(_t4$2 || (_t4$2 = _$7`
@@ -4503,7 +4507,7 @@ const GoADropdownListOption = styled.div(_t4$2 || (_t4$2 = _$7`
4503
4507
  `), 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');
4504
4508
 
4505
4509
  const isValidKey = keyCode => {
4506
- if (keyCode === 'Shift' || keyCode === 'Alt') return false;
4510
+ if (keyCode === SHIFT_KEY || keyCode === ALT_KEY) return false;
4507
4511
  const regex = new RegExp(/^[a-zA-Z0-9!%$@.#?\-_]+$/);
4508
4512
  return regex.test(keyCode);
4509
4513
  };
@@ -4535,18 +4539,20 @@ const Dropdown = props => {
4535
4539
  useEffect(() => {
4536
4540
  if (textInput) {
4537
4541
  textInput.addEventListener('click', inputTextOnClick);
4538
- textInput.addEventListener('keydown', handleKeyDown, false);
4539
- textInput.addEventListener('blur', handleTextInputOnBlur, false);
4542
+ textInput.addEventListener('keydown', handleKeyDown);
4543
+ textInput.addEventListener('blur', handleTextInputOnBlur);
4540
4544
  }
4545
+ document.addEventListener('keydown', handleDocumentKeyDown);
4541
4546
  return () => {
4542
4547
  if (textInput) {
4543
4548
  textInput.removeEventListener('click', inputTextOnClick);
4544
4549
  textInput.removeEventListener('keydown', handleKeyDown);
4545
4550
  textInput.removeEventListener('blur', handleTextInputOnBlur);
4546
4551
  }
4552
+ document.removeEventListener('keydown', handleDocumentKeyDown);
4547
4553
  };
4548
4554
  // eslint-disable-next-line react-hooks/exhaustive-deps
4549
- }, [textInput]);
4555
+ }, [textInput, document]);
4550
4556
  /* istanbul ignore next */
4551
4557
  const handleTextInputOnBlur = e => {
4552
4558
  if (e.relatedTarget === null) {
@@ -4575,6 +4581,16 @@ const Dropdown = props => {
4575
4581
  }
4576
4582
  setIsOpen(false);
4577
4583
  };
4584
+ const setInputTextFocus = () => {
4585
+ const inputEl = document.getElementById(`${id}-input`);
4586
+ if (inputEl) {
4587
+ //The 'focused' property is part of the GoAInput component that is used to
4588
+ //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.
4589
+ inputEl.focused = true;
4590
+ inputEl.focus();
4591
+ inputEl.focused = false;
4592
+ }
4593
+ };
4578
4594
  const setElementFocus = (e, element, preventDefault) => {
4579
4595
  if (element) {
4580
4596
  element.focus();
@@ -4584,11 +4600,18 @@ const Dropdown = props => {
4584
4600
  }
4585
4601
  };
4586
4602
  /* istanbul ignore next */
4603
+ const handleDocumentKeyDown = e => {
4604
+ if (e.key === ESCAPE_KEY || e.key === TAB_KEY) {
4605
+ setIsOpen(false);
4606
+ }
4607
+ };
4608
+ /* istanbul ignore next */
4587
4609
  const handleKeyDown = e => {
4588
4610
  var _a, _b, _c;
4589
4611
  if (e.key === ENTER_KEY || e.key === SPACE_KEY) {
4590
4612
  setIsOpen(previousIsOpen => !previousIsOpen);
4591
4613
  const el = document.getElementById(`${PREFIX}-${label}-${(_a = items.at(0)) === null || _a === void 0 ? void 0 : _a.value}`);
4614
+ setInputTextFocus();
4592
4615
  setElementFocus(e, el, false);
4593
4616
  } else if (e.key === ARROW_UP_KEY) {
4594
4617
  setIsOpen(true);
@@ -4625,14 +4648,7 @@ const Dropdown = props => {
4625
4648
  var _a, _b, _c, _d;
4626
4649
  if (e.key === ENTER_KEY || e.key === SPACE_KEY) {
4627
4650
  updateDropDownData(item);
4628
- const inputEl = document.getElementById(`${id}-input`);
4629
- if (inputEl) {
4630
- //The 'focused' property is part of the GoAInput component that is used to
4631
- //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.
4632
- inputEl.focused = true;
4633
- inputEl.focus();
4634
- inputEl.focused = false;
4635
- }
4651
+ setInputTextFocus();
4636
4652
  }
4637
4653
  if (e.key === ESCAPE_KEY) {
4638
4654
  setIsOpen(false);
@@ -8165,7 +8181,7 @@ const AddressViews = ({
8165
8181
  gap: "s",
8166
8182
  children: [jsx(GoAFormItem, {
8167
8183
  error: ((_a = data === null || data === void 0 ? void 0 : data.addressLine1) === null || _a === void 0 ? void 0 : _a.length) === 0 ? 'addressLine1 is required' : '',
8168
- label: `${isAlbertaAddress ? 'Alberta p' : 'P'}ostal address`,
8184
+ label: `${isAlbertaAddress ? 'Alberta p' : 'Canada p'}ostal address`,
8169
8185
  children: jsx("p", {
8170
8186
  children: data === null || data === void 0 ? void 0 : data.addressLine1
8171
8187
  })
@@ -8182,7 +8198,7 @@ const AddressViews = ({
8182
8198
  error: ((_b = data === null || data === void 0 ? void 0 : data.municipality) === null || _b === void 0 ? void 0 : _b.length) === 0 ? 'city is required' : '',
8183
8199
  label: "City",
8184
8200
  children: jsx("p", {
8185
- children: data === null || data === void 0 ? void 0 : data.city
8201
+ children: data === null || data === void 0 ? void 0 : data.municipality
8186
8202
  })
8187
8203
  }), jsx(GoAFormItem, {
8188
8204
  error: ((_c = data === null || data === void 0 ? void 0 : data.postalCode) === null || _c === void 0 ? void 0 : _c.length) === 0 ? 'postalCode is required' : '',
@@ -8201,7 +8217,7 @@ const AddressViews = ({
8201
8217
  children: "Alberta"
8202
8218
  }), !isAlbertaAddress && jsx("div", {
8203
8219
  "data-testid": "address-form-province-view",
8204
- children: (_d = provinces.find(p => p.value === (data === null || data === void 0 ? void 0 : data.province))) === null || _d === void 0 ? void 0 : _d.label
8220
+ children: (_d = provinces.find(p => p.value === (data === null || data === void 0 ? void 0 : data.subdivisionCode))) === null || _d === void 0 ? void 0 : _d.label
8205
8221
  })]
8206
8222
  }), jsx(GoAFormItem, {
8207
8223
  label: "Country",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.41.2",
3
+ "version": "1.41.4",
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",