@abgov/jsonforms-components 1.40.0 → 1.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import React, { createContext, useContext, useReducer, useMemo, useEffect, useState, useRef, useCallback } from 'react';
|
|
3
|
-
import { GoAFormItem, GoAInput, GoATextArea, GoACallout, GoAInputDate, GoAInputDateTime, GoAInputTime, GoARadioGroup, GoARadioItem, GoACheckbox, GoAGrid, GoAFormStepper, GoAFormStep, GoAPages, GoAButton, GoAModal, GoAButtonGroup, GoAIconButton, GoAFileUploadInput, GoACircularProgress, GoAContainer, GoATable, GoADropdown, GoADropdownItem, GoADetails
|
|
3
|
+
import { GoAFormItem, GoAInput, GoATextArea, GoACallout, GoAInputDate, GoAInputDateTime, GoAInputTime, GoARadioGroup, GoARadioItem, GoACheckbox, GoAGrid, GoAFormStepper, GoAFormStep, GoAPages, GoAButton, GoAModal, GoAButtonGroup, GoAIconButton, GoAFileUploadInput, GoACircularProgress, GoAContainer, GoATable, GoADropdown, GoADropdownItem, GoADetails } from '@abgov/react-components';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
import axios from 'axios';
|
|
6
6
|
import get$1 from 'lodash/get';
|
|
@@ -4419,7 +4419,7 @@ const TAB_KEY = 'Tab';
|
|
|
4419
4419
|
let _$7 = t => t,
|
|
4420
4420
|
_t$7,
|
|
4421
4421
|
_t2$4,
|
|
4422
|
-
_t3$
|
|
4422
|
+
_t3$4,
|
|
4423
4423
|
_t4$2;
|
|
4424
4424
|
styled.div(_t$7 || (_t$7 = _$7`
|
|
4425
4425
|
text-overflow: ellipsis;
|
|
@@ -4442,7 +4442,7 @@ const GoADropdownListContainerWrapper = styled.div(_t2$4 || (_t2$4 = _$7`
|
|
|
4442
4442
|
position: relative;
|
|
4443
4443
|
display: ${0};
|
|
4444
4444
|
`), p => !(p === null || p === void 0 ? void 0 : p.isOpen) && 'none');
|
|
4445
|
-
const GoADropdownListContainer = styled.div(_t3$
|
|
4445
|
+
const GoADropdownListContainer = styled.div(_t3$4 || (_t3$4 = _$7`
|
|
4446
4446
|
border: solid 1px var(--goa-color-greyscale-200);
|
|
4447
4447
|
border-radius: var(--goa-space-2xs);
|
|
4448
4448
|
background: var(--goa-color-greyscale-white);
|
|
@@ -5094,7 +5094,7 @@ const LayoutRenderer = ({
|
|
|
5094
5094
|
let _$5 = t => t,
|
|
5095
5095
|
_t$5,
|
|
5096
5096
|
_t2$3,
|
|
5097
|
-
_t3$
|
|
5097
|
+
_t3$3,
|
|
5098
5098
|
_t4$1,
|
|
5099
5099
|
_t5$1,
|
|
5100
5100
|
_t6$1,
|
|
@@ -5120,7 +5120,7 @@ const ReviewItemSection = styled.div(_t2$3 || (_t2$3 = _$5`
|
|
|
5120
5120
|
border: 1px solid #dcdcdc;
|
|
5121
5121
|
border-radius: 5px;
|
|
5122
5122
|
`));
|
|
5123
|
-
const ReviewItemHeader = styled.div(_t3$
|
|
5123
|
+
const ReviewItemHeader = styled.div(_t3$3 || (_t3$3 = _$5`
|
|
5124
5124
|
display: flex;
|
|
5125
5125
|
align-items: center;
|
|
5126
5126
|
justify-content: space-between;
|
|
@@ -5904,7 +5904,7 @@ const DeleteFileModal = ({
|
|
|
5904
5904
|
let _$3 = t => t,
|
|
5905
5905
|
_t$3,
|
|
5906
5906
|
_t2$2,
|
|
5907
|
-
_t3$
|
|
5907
|
+
_t3$2;
|
|
5908
5908
|
const DELAY_UPLOAD_TIMEOUT_MS = 5;
|
|
5909
5909
|
const DELAY_DELETE_TIMEOUT_MS = 5;
|
|
5910
5910
|
const FileUploaderReview = props => {
|
|
@@ -6075,7 +6075,7 @@ const AttachmentBorder = styled.div(_t2$2 || (_t2$2 = _$3`
|
|
|
6075
6075
|
width: fit-content;
|
|
6076
6076
|
margin-top: var(--goa-space-2xs);
|
|
6077
6077
|
`));
|
|
6078
|
-
const FileUploaderStyle = styled.div(_t3$
|
|
6078
|
+
const FileUploaderStyle = styled.div(_t3$2 || (_t3$2 = _$3`
|
|
6079
6079
|
.label {
|
|
6080
6080
|
display: block;
|
|
6081
6081
|
font-weight: var(--goa-font-weight-bold);
|
|
@@ -6269,7 +6269,7 @@ $$8({ target: 'Object', stat: true }, {
|
|
|
6269
6269
|
let _$2 = t => t,
|
|
6270
6270
|
_t$2,
|
|
6271
6271
|
_t2$1,
|
|
6272
|
-
_t3,
|
|
6272
|
+
_t3$1,
|
|
6273
6273
|
_t4,
|
|
6274
6274
|
_t5,
|
|
6275
6275
|
_t6,
|
|
@@ -6288,7 +6288,7 @@ const NonEmptyCellStyle = styled.div(_t2$1 || (_t2$1 = _$2`
|
|
|
6288
6288
|
background-color: #000:
|
|
6289
6289
|
}
|
|
6290
6290
|
`));
|
|
6291
|
-
const ToolBarHeader = styled.div(_t3 || (_t3 = _$2`
|
|
6291
|
+
const ToolBarHeader = styled.div(_t3$1 || (_t3$1 = _$2`
|
|
6292
6292
|
margin-bottom: var(--goa-space-l);
|
|
6293
6293
|
`));
|
|
6294
6294
|
const ObjectArrayTitle = styled.h2(_t4 || (_t4 = _$2`
|
|
@@ -7412,7 +7412,8 @@ const GoAListWithDetailsTester = rankWith(3, and(uiTypeIs('ListWithDetail')));
|
|
|
7412
7412
|
|
|
7413
7413
|
let _$1 = t => t,
|
|
7414
7414
|
_t$1,
|
|
7415
|
-
_t2
|
|
7415
|
+
_t2,
|
|
7416
|
+
_t3;
|
|
7416
7417
|
const SearchBox = styled.div(_t$1 || (_t$1 = _$1`
|
|
7417
7418
|
position: relative;
|
|
7418
7419
|
|
|
@@ -7448,6 +7449,20 @@ const LabelDiv = styled.div(_t2 || (_t2 = _$1`
|
|
|
7448
7449
|
font-size: var(--fs-sl);
|
|
7449
7450
|
padding-bottom: 1.5rem;
|
|
7450
7451
|
`));
|
|
7452
|
+
const ListItem = styled.li(_t3 || (_t3 = _$1`
|
|
7453
|
+
background-color: ${0};
|
|
7454
|
+
color: ${0};
|
|
7455
|
+
font-weight: ${0};
|
|
7456
|
+
`), ({
|
|
7457
|
+
selectedIndex,
|
|
7458
|
+
index
|
|
7459
|
+
}) => selectedIndex === index ? 'var(--color-primary)' : '', ({
|
|
7460
|
+
selectedIndex,
|
|
7461
|
+
index
|
|
7462
|
+
}) => selectedIndex === index ? 'var(--color-white) !important' : '', ({
|
|
7463
|
+
selectedIndex,
|
|
7464
|
+
index
|
|
7465
|
+
}) => selectedIndex === index ? 'var(--fw-bold)' : '');
|
|
7451
7466
|
|
|
7452
7467
|
const AddressInputs = ({
|
|
7453
7468
|
address,
|
|
@@ -7626,7 +7641,7 @@ const fetchAddressSuggestions = (formUrl, searchTerm, isAlbertaAddress) => __awa
|
|
|
7626
7641
|
const response = yield axios.get(formUrl, {
|
|
7627
7642
|
params
|
|
7628
7643
|
});
|
|
7629
|
-
return response.data.Items
|
|
7644
|
+
return response.data.Items;
|
|
7630
7645
|
} catch (error) {
|
|
7631
7646
|
console.error('Error fetching address suggestions:', error);
|
|
7632
7647
|
return [];
|
|
@@ -7904,6 +7919,8 @@ const AddressLookUpControl = props => {
|
|
|
7904
7919
|
setAddress(updatedAddress);
|
|
7905
7920
|
handleChange(path, updatedAddress);
|
|
7906
7921
|
};
|
|
7922
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
7923
|
+
const dropdownRef = useRef(null);
|
|
7907
7924
|
const handleInputChange = (field, value) => {
|
|
7908
7925
|
var _a, _b;
|
|
7909
7926
|
let newAddress;
|
|
@@ -7935,14 +7952,15 @@ const AddressLookUpControl = props => {
|
|
|
7935
7952
|
if (searchTerm.length > 2) {
|
|
7936
7953
|
setLoading(true);
|
|
7937
7954
|
setOpen(true);
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7955
|
+
yield fetchAddressSuggestions(formUrl, searchTerm, isAlbertaAddress).then(response => {
|
|
7956
|
+
const suggestions = filterSuggestionsWithoutAddressCount(response);
|
|
7957
|
+
if (isAlbertaAddress) {
|
|
7958
|
+
setSuggestions(filterAlbertaAddresses(suggestions));
|
|
7959
|
+
} else {
|
|
7960
|
+
setSuggestions(suggestions);
|
|
7961
|
+
}
|
|
7962
|
+
setLoading(false);
|
|
7963
|
+
});
|
|
7946
7964
|
} else {
|
|
7947
7965
|
setSuggestions([]);
|
|
7948
7966
|
setOpen(false);
|
|
@@ -7961,14 +7979,62 @@ const AddressLookUpControl = props => {
|
|
|
7961
7979
|
setSuggestions([]);
|
|
7962
7980
|
setErrors({});
|
|
7963
7981
|
};
|
|
7982
|
+
/* istanbul ignore next */
|
|
7964
7983
|
const handleRequiredFieldBlur = name => {
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
err[name] = name === 'municipality' ?
|
|
7984
|
+
const err = Object.assign({}, errors);
|
|
7985
|
+
if ((data === null || data === void 0 ? void 0 : data["city"]) === undefined || (data === null || data === void 0 ? void 0 : data["city"]) === "") {
|
|
7986
|
+
err[name] = name === 'municipality' ? 'city is required' : "";
|
|
7987
|
+
setErrors(err);
|
|
7988
|
+
}
|
|
7989
|
+
if (!(data === null || data === void 0 ? void 0 : data[name]) || data[name] === '' || (data === null || data === void 0 ? void 0 : data[name]) === undefined) {
|
|
7990
|
+
err[name] = name === 'municipality' ? 'city is required' : `${name} is required`;
|
|
7991
|
+
setErrors(err);
|
|
7992
|
+
}
|
|
7993
|
+
if (!(data === null || data === void 0 ? void 0 : data[name])) {
|
|
7994
|
+
err[name] = name === 'addressLine1' ? `${name} is required` : ``;
|
|
7968
7995
|
setErrors(err);
|
|
7969
7996
|
} else {
|
|
7970
7997
|
delete errors[name];
|
|
7971
7998
|
}
|
|
7999
|
+
setTimeout(() => {
|
|
8000
|
+
setSuggestions([]);
|
|
8001
|
+
setOpen(false);
|
|
8002
|
+
}, 100);
|
|
8003
|
+
};
|
|
8004
|
+
useEffect(() => {
|
|
8005
|
+
if (dropdownRef.current) {
|
|
8006
|
+
const selectedItem = dropdownRef.current.children[selectedIndex];
|
|
8007
|
+
if (selectedItem) {
|
|
8008
|
+
selectedItem.scrollIntoView({
|
|
8009
|
+
block: 'nearest',
|
|
8010
|
+
behavior: 'smooth'
|
|
8011
|
+
});
|
|
8012
|
+
}
|
|
8013
|
+
}
|
|
8014
|
+
}, [selectedIndex, open]);
|
|
8015
|
+
/* istanbul ignore next */
|
|
8016
|
+
const handleKeyDown = (e, value, key) => {
|
|
8017
|
+
var _a;
|
|
8018
|
+
if (key === 'ArrowDown') {
|
|
8019
|
+
setSelectedIndex(prevIndex => prevIndex < suggestions.length - 1 ? prevIndex + 1 : 0);
|
|
8020
|
+
handleDropdownChange(value);
|
|
8021
|
+
} else if (key === 'ArrowUp') {
|
|
8022
|
+
setSelectedIndex(prevIndex => prevIndex > 0 ? prevIndex - 1 : suggestions.length - 1);
|
|
8023
|
+
handleDropdownChange(value);
|
|
8024
|
+
} else if (key === 'Enter') {
|
|
8025
|
+
handleDropdownChange(value);
|
|
8026
|
+
setLoading(false);
|
|
8027
|
+
if (selectedIndex >= 0) {
|
|
8028
|
+
(_a = document.getElementById("goaInput")) === null || _a === void 0 ? void 0 : _a.blur();
|
|
8029
|
+
const suggestion = suggestions[selectedIndex];
|
|
8030
|
+
if (suggestion) {
|
|
8031
|
+
setTimeout(() => {
|
|
8032
|
+
handleSuggestionClick(suggestion);
|
|
8033
|
+
setOpen(false);
|
|
8034
|
+
}, 100);
|
|
8035
|
+
}
|
|
8036
|
+
}
|
|
8037
|
+
}
|
|
7972
8038
|
};
|
|
7973
8039
|
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;
|
|
7974
8040
|
return jsxs("div", {
|
|
@@ -7979,6 +8045,7 @@ const AddressLookUpControl = props => {
|
|
|
7979
8045
|
children: jsxs(SearchBox, {
|
|
7980
8046
|
children: [jsx(GoAInput, {
|
|
7981
8047
|
leadingIcon: autocompletion && enabled ? 'search' : undefined,
|
|
8048
|
+
id: "goaInput",
|
|
7982
8049
|
name: "addressLine1",
|
|
7983
8050
|
testId: "address-form-address1",
|
|
7984
8051
|
readonly: readOnly,
|
|
@@ -7986,17 +8053,31 @@ const AddressLookUpControl = props => {
|
|
|
7986
8053
|
ariaLabel: 'address-form-address1',
|
|
7987
8054
|
placeholder: "Start typing the first line of your address, required.",
|
|
7988
8055
|
value: (address === null || address === void 0 ? void 0 : address.addressLine1) || '',
|
|
7989
|
-
onChange: (
|
|
8056
|
+
onChange: (e, value) => {
|
|
8057
|
+
handleDropdownChange(value);
|
|
8058
|
+
},
|
|
7990
8059
|
onBlur: name => handleRequiredFieldBlur(name),
|
|
7991
|
-
width: "100%"
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
|
|
8060
|
+
width: "100%",
|
|
8061
|
+
onKeyPress: (e, value, key) => {
|
|
8062
|
+
if (open) {
|
|
8063
|
+
handleKeyDown(e, value, key);
|
|
8064
|
+
}
|
|
8065
|
+
}
|
|
8066
|
+
}), loading && autocompletion && jsx(GoACircularProgress, {
|
|
8067
|
+
variant: "inline",
|
|
8068
|
+
size: "small",
|
|
8069
|
+
visible: true
|
|
8070
|
+
}), suggestions && autocompletion && jsx("ul", {
|
|
8071
|
+
ref: dropdownRef,
|
|
7996
8072
|
className: "suggestions",
|
|
7997
8073
|
tabIndex: 0,
|
|
7998
|
-
children: suggestions && autocompletion && open && suggestions.map((suggestion, index) => jsx(
|
|
7999
|
-
|
|
8074
|
+
children: suggestions && autocompletion && open && suggestions.map((suggestion, index) => jsx(ListItem, {
|
|
8075
|
+
"data-index": index,
|
|
8076
|
+
onClick: () => {
|
|
8077
|
+
handleSuggestionClick(suggestion);
|
|
8078
|
+
},
|
|
8079
|
+
selectedIndex: selectedIndex,
|
|
8080
|
+
index: index,
|
|
8000
8081
|
children: `${suggestion.Text} ${suggestion.Description}`
|
|
8001
8082
|
}, index))
|
|
8002
8083
|
})]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "1.40.
|
|
3
|
+
"version": "1.40.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Government of Alberta - React renderers for JSON Forms based on the design system.",
|
|
6
6
|
"repository": "https://github.com/GovAlta/adsp-monorepo",
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
interface ListItemProps {
|
|
3
|
+
selectedIndex: number;
|
|
4
|
+
index: number;
|
|
5
|
+
}
|
|
2
6
|
export declare const SearchBox: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
3
7
|
export declare const LabelDiv: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
8
|
+
export declare const ListItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, ListItemProps>> & string;
|
|
9
|
+
export {};
|