northants-design-system 1.0.3 → 1.1.0-alpha.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/build/index.js +3011 -509
- package/build/index.js.map +1 -1
- package/build/index.mjs.js +3011 -510
- package/build/index.mjs.js.map +1 -1
- package/build/library/components/FormButton/FormButton.d.ts +3 -3
- package/build/library/components/Input/Input.types.d.ts +4 -0
- package/build/library/components/RadioCheckboxInput/RadioCheckboxInput.types.d.ts +4 -0
- package/build/library/structure/PageStructures.d.ts +2 -1
- package/package.json +3 -1
package/build/index.js
CHANGED
|
@@ -126,6 +126,7 @@ const StyledInput = styled__default.default.input`
|
|
|
126
126
|
border-width: ${(props) => (props.$isErrored ? '3px' : '2px')};
|
|
127
127
|
border-radius: ${(props) => props.theme.theme_vars.border_radius};
|
|
128
128
|
display: block;
|
|
129
|
+
width: ${(props) => (props.$isFullWidth ? '100%' : 'auto')};
|
|
129
130
|
|
|
130
131
|
&:focus {
|
|
131
132
|
outline: none;
|
|
@@ -133,7 +134,7 @@ const StyledInput = styled__default.default.input`
|
|
|
133
134
|
transition: box-shadow 0.3s ease 0s;
|
|
134
135
|
}
|
|
135
136
|
`;
|
|
136
|
-
const ErrorText$
|
|
137
|
+
const ErrorText$2 = styled__default.default.p`
|
|
137
138
|
${(props) => props.theme.fontStyles}
|
|
138
139
|
color: ${(props) => props.theme.theme_vars.colours.negative};
|
|
139
140
|
font-weight: bold;
|
|
@@ -2095,7 +2096,7 @@ function normalizeArrowKey(event) {
|
|
|
2095
2096
|
*/
|
|
2096
2097
|
|
|
2097
2098
|
|
|
2098
|
-
function isPlainObject$
|
|
2099
|
+
function isPlainObject$4(obj) {
|
|
2099
2100
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
2100
2101
|
}
|
|
2101
2102
|
/**
|
|
@@ -3373,7 +3374,7 @@ const Downshift = /*#__PURE__*/(() => {
|
|
|
3373
3374
|
return '';
|
|
3374
3375
|
}
|
|
3375
3376
|
|
|
3376
|
-
if (process.env.NODE_ENV !== 'production' && isPlainObject$
|
|
3377
|
+
if (process.env.NODE_ENV !== 'production' && isPlainObject$4(i) && !i.hasOwnProperty('toString')) {
|
|
3377
3378
|
// eslint-disable-next-line no-console
|
|
3378
3379
|
console.warn('downshift: An object was passed to the default implementation of `itemToString`. You should probably provide your own `itemToString` implementation. Please refer to the `itemToString` API documentation.', 'The object that was passed:', i);
|
|
3379
3380
|
}
|
|
@@ -3845,7 +3846,7 @@ var Autocomplete = function (_a) {
|
|
|
3845
3846
|
var getInputProps = _a.getInputProps, getItemProps = _a.getItemProps, getLabelProps = _a.getLabelProps, getMenuProps = _a.getMenuProps, isOpen = _a.isOpen, inputValue = _a.inputValue, getRootProps = _a.getRootProps;
|
|
3846
3847
|
return (React__default.default.createElement("div", null,
|
|
3847
3848
|
React__default.default.createElement(AutocompleteLabel, __assign$2({}, getLabelProps(), { "$hasHiddenLabel": hasHiddenLabel }), labelText ? labelText : placeholder),
|
|
3848
|
-
isErrored && errorText && (React__default.default.createElement(React__default.default.Fragment, null, hasLightBackground ? (React__default.default.createElement(ErrorText$
|
|
3849
|
+
isErrored && errorText && (React__default.default.createElement(React__default.default.Fragment, null, hasLightBackground ? (React__default.default.createElement(ErrorText$2, null, errorText)) : (React__default.default.createElement(LightErrorText, null, errorText)))),
|
|
3849
3850
|
React__default.default.createElement("div", __assign$2({}, getRootProps(undefined, { suppressRefError: true })),
|
|
3850
3851
|
React__default.default.createElement(AutocompleteTextInput, __assign$2({}, getInputProps({
|
|
3851
3852
|
name: name,
|
|
@@ -3874,7 +3875,7 @@ var Autocomplete = function (_a) {
|
|
|
3874
3875
|
})));
|
|
3875
3876
|
};
|
|
3876
3877
|
|
|
3877
|
-
const Container$
|
|
3878
|
+
const Container$19 = styled__default.default.div`
|
|
3878
3879
|
display: block;
|
|
3879
3880
|
`;
|
|
3880
3881
|
|
|
@@ -3959,7 +3960,7 @@ var BackToTop = function (_a) {
|
|
|
3959
3960
|
React.useEffect(function () {
|
|
3960
3961
|
window.addEventListener('scroll', toggleVisible);
|
|
3961
3962
|
});
|
|
3962
|
-
return (React__default.default.createElement(Container$
|
|
3963
|
+
return (React__default.default.createElement(Container$19, { "data-testid": "BackToTop" }, isActive && (React__default.default.createElement(BackToTopButton, { onClick: scrollToTop, "$visible": visible, "data-testid": "BackToTopButton", type: "button", "aria-label": "Go to the top of the page" },
|
|
3963
3964
|
React__default.default.createElement(ChevronIcon, { colourFill: themeContext.theme_vars.colours.white, direction: "up" })))));
|
|
3964
3965
|
};
|
|
3965
3966
|
|
|
@@ -6157,7 +6158,7 @@ const H4 = styled__default.default.h4`
|
|
|
6157
6158
|
/**
|
|
6158
6159
|
* A heading of different levels
|
|
6159
6160
|
*/
|
|
6160
|
-
var Heading = function (_a) {
|
|
6161
|
+
var Heading$1 = function (_a) {
|
|
6161
6162
|
var _b = _a.level, level = _b === void 0 ? 2 : _b, text = _a.text, props = __rest(_a, ["level", "text"]);
|
|
6162
6163
|
if (level === 1)
|
|
6163
6164
|
return React__default.default.createElement(H1, __assign$2({}, props), text);
|
|
@@ -6214,10 +6215,10 @@ var HeadingWithIcon = function (_a) {
|
|
|
6214
6215
|
var _b = _a.level, level = _b === void 0 ? 2 : _b, text = _a.text, icon = _a.icon, _c = _a.hasHover, hasHover = _c === void 0 ? false : _c;
|
|
6215
6216
|
return (React__default.default.createElement(HeadingWrapper, { "data-testid": "HeadingWithIcon", "$hasHover": hasHover },
|
|
6216
6217
|
React__default.default.createElement(DynamicIcon, { icon: icon, level: level }),
|
|
6217
|
-
React__default.default.createElement(Heading, { text: text, level: level })));
|
|
6218
|
+
React__default.default.createElement(Heading$1, { text: text, level: level })));
|
|
6218
6219
|
};
|
|
6219
6220
|
|
|
6220
|
-
const Container$
|
|
6221
|
+
const Container$18 = styled__default.default.div`
|
|
6221
6222
|
display: flex;
|
|
6222
6223
|
width: 100%;
|
|
6223
6224
|
min-height: 400px;
|
|
@@ -6241,7 +6242,7 @@ var Map$1 = function (_a) {
|
|
|
6241
6242
|
setMap(new window.google.maps.Map(ref.current, { center: center, zoom: zoom }));
|
|
6242
6243
|
}
|
|
6243
6244
|
}, [ref, map]);
|
|
6244
|
-
return (React__default.default.createElement(Container$
|
|
6245
|
+
return (React__default.default.createElement(Container$18, { "data-testid": "Map" },
|
|
6245
6246
|
React__default.default.createElement("div", { ref: ref }),
|
|
6246
6247
|
React__default.default.Children.map(children, function (child) {
|
|
6247
6248
|
if (React__default.default.isValidElement(child)) {
|
|
@@ -6298,7 +6299,7 @@ var MapMarker = function (options) {
|
|
|
6298
6299
|
return null;
|
|
6299
6300
|
};
|
|
6300
6301
|
|
|
6301
|
-
const Container$
|
|
6302
|
+
const Container$17 = styled__default.default.div`
|
|
6302
6303
|
${(props) => props.theme.fontStyles};
|
|
6303
6304
|
display: block;
|
|
6304
6305
|
border-top: 1px solid ${(props) => props.theme.theme_vars.colours.grey};
|
|
@@ -7076,7 +7077,7 @@ var Pagination = function (_a) {
|
|
|
7076
7077
|
}
|
|
7077
7078
|
};
|
|
7078
7079
|
if (numbers.length > 1) {
|
|
7079
|
-
return (React__default.default.createElement(Container$
|
|
7080
|
+
return (React__default.default.createElement(Container$17, { "data-testid": "Pagination", role: "navigation", "aria-label": "Pagination" },
|
|
7080
7081
|
currentPage > 1 && (React__default.default.createElement(Previous, { onClick: function () { return buttonClick(currentPage - 1); }, title: "Go back a page" }, "Previous")),
|
|
7081
7082
|
React__default.default.createElement(NumbersContainer, null, numbers.map(function (v, i) { return (React__default.default.createElement(NumberContainer, { key: i },
|
|
7082
7083
|
v === '...' && React__default.default.createElement(Ellipsis, null, "..."),
|
|
@@ -7088,7 +7089,7 @@ var Pagination = function (_a) {
|
|
|
7088
7089
|
return null;
|
|
7089
7090
|
};
|
|
7090
7091
|
|
|
7091
|
-
const Container$
|
|
7092
|
+
const Container$16 = styled__default.default.div`
|
|
7092
7093
|
${(props) => props.theme.fontStyles};
|
|
7093
7094
|
margin-bottom: 30px;
|
|
7094
7095
|
`;
|
|
@@ -7112,7 +7113,7 @@ const hideLabel$1 = (props) => {
|
|
|
7112
7113
|
}
|
|
7113
7114
|
};
|
|
7114
7115
|
|
|
7115
|
-
const Legend$
|
|
7116
|
+
const Legend$3 = styled__default.default.legend`
|
|
7116
7117
|
color: #0b0c0c;
|
|
7117
7118
|
-webkit-box-sizing: border-box;
|
|
7118
7119
|
box-sizing: border-box;
|
|
@@ -7130,7 +7131,7 @@ const hideHint = (props) => {
|
|
|
7130
7131
|
}
|
|
7131
7132
|
};
|
|
7132
7133
|
|
|
7133
|
-
const Hint = styled__default.default.div`
|
|
7134
|
+
const Hint$1 = styled__default.default.div`
|
|
7134
7135
|
font-size: ${(props) => props.theme.theme_vars.fontSizes.small};
|
|
7135
7136
|
display: block;
|
|
7136
7137
|
margin-bottom: 15px;
|
|
@@ -7259,16 +7260,16 @@ var CheckboxListFilter = function (_a) {
|
|
|
7259
7260
|
handleParams('news', [{ key: NewsArticleFilterFields.articleType.queryParamKey, value: articleTypes }], ['page']);
|
|
7260
7261
|
};
|
|
7261
7262
|
var backupLabel = Math.random().toString(36).substring(7);
|
|
7262
|
-
return (React__default.default.createElement(Container$
|
|
7263
|
+
return (React__default.default.createElement(Container$16, { "data-testid": "CheckboxListFilter" },
|
|
7263
7264
|
React__default.default.createElement(Fieldset$2, { "aria-describedby": hintId },
|
|
7264
|
-
React__default.default.createElement(Legend$
|
|
7265
|
-
React__default.default.createElement(Hint, { id: hintId, "$hintHidden": hintHidden, "data-testid": "CheckboxListFilterHint" }, hint),
|
|
7265
|
+
React__default.default.createElement(Legend$3, { "$labelHidden": labelHidden, "data-testid": "CheckboxListFilterLegend" }, label),
|
|
7266
|
+
React__default.default.createElement(Hint$1, { id: hintId, "$hintHidden": hintHidden, "data-testid": "CheckboxListFilterHint" }, hint),
|
|
7266
7267
|
React__default.default.createElement(Checkboxes, null, checkboxState.map(function (option, i) { return (React__default.default.createElement(Checkbox, { key: i },
|
|
7267
7268
|
React__default.default.createElement(CheckboxInput, { id: option.value, name: labelHidden ? backupLabel : label, type: "checkbox", onChange: optionChecked, value: option.value, checked: option.checked }),
|
|
7268
7269
|
React__default.default.createElement(CheckboxLabel, { "$isChecked": option.checked, htmlFor: option.value }, option.title))); })))));
|
|
7269
7270
|
};
|
|
7270
7271
|
|
|
7271
|
-
const Container$
|
|
7272
|
+
const Container$15 = styled__default.default.div`
|
|
7272
7273
|
${(props) => props.theme.fontStyles};
|
|
7273
7274
|
`;
|
|
7274
7275
|
|
|
@@ -7278,7 +7279,7 @@ const hideLabel = (props) => {
|
|
|
7278
7279
|
}
|
|
7279
7280
|
};
|
|
7280
7281
|
|
|
7281
|
-
const Label$
|
|
7282
|
+
const Label$5 = styled__default.default.label`
|
|
7282
7283
|
display: block;
|
|
7283
7284
|
margin-bottom: 5px;
|
|
7284
7285
|
${hideLabel}
|
|
@@ -7313,8 +7314,8 @@ const Option = styled__default.default.option`
|
|
|
7313
7314
|
|
|
7314
7315
|
var DropDownSelect = function (_a) {
|
|
7315
7316
|
var id = _a.id, label = _a.label, options = _a.options, onChange = _a.onChange, selected = _a.selected, _b = _a.hideLabel, hideLabel = _b === void 0 ? false : _b;
|
|
7316
|
-
return (React__default.default.createElement(Container$
|
|
7317
|
-
React__default.default.createElement(Label$
|
|
7317
|
+
return (React__default.default.createElement(Container$15, null,
|
|
7318
|
+
React__default.default.createElement(Label$5, { htmlFor: id, "$hideLabel": hideLabel }, label),
|
|
7318
7319
|
React__default.default.createElement(Select, { id: id, name: id, onChange: onChange && onChange, defaultValue: selected && selected }, options.map(function (option, i) { return (React__default.default.createElement(Option, { key: i, value: option.value }, option.title)); }))));
|
|
7319
7320
|
};
|
|
7320
7321
|
|
|
@@ -7428,7 +7429,7 @@ const PromotedLink$1 = styled__default.default.a`
|
|
|
7428
7429
|
${oneColStyles}
|
|
7429
7430
|
`;
|
|
7430
7431
|
|
|
7431
|
-
const Container$
|
|
7432
|
+
const Container$14 = styled__default.default.div`
|
|
7432
7433
|
box-sizing: border-box;
|
|
7433
7434
|
display: flex;
|
|
7434
7435
|
flex-wrap: wrap;
|
|
@@ -7451,7 +7452,7 @@ const Container$13 = styled__default.default.div`
|
|
|
7451
7452
|
|
|
7452
7453
|
var Row$1 = function (_a) {
|
|
7453
7454
|
var _b = _a.hasBorder, hasBorder = _b === void 0 ? false : _b, _c = _a.isList, isList = _c === void 0 ? false : _c, _d = _a.hasWrap, hasWrap = _d === void 0 ? true : _d, children = _a.children;
|
|
7454
|
-
return (React__default.default.createElement(Container$
|
|
7455
|
+
return (React__default.default.createElement(Container$14, { "data-testid": "Row", "$hasBorder": hasBorder, "$hasWrap": hasWrap, as: isList ? 'ul' : 'div' }, children));
|
|
7455
7456
|
};
|
|
7456
7457
|
|
|
7457
7458
|
const calculateWidth = (size) => {
|
|
@@ -7501,7 +7502,7 @@ const widths = (props) => {
|
|
|
7501
7502
|
`;
|
|
7502
7503
|
};
|
|
7503
7504
|
|
|
7504
|
-
const Container$
|
|
7505
|
+
const Container$13 = styled__default.default.div`
|
|
7505
7506
|
box-sizing: border-box;
|
|
7506
7507
|
display: block;
|
|
7507
7508
|
padding: ${(props) => (props.$hasPadding ? props.theme.theme_vars.spacingSizes.small : `0`)};
|
|
@@ -7512,7 +7513,7 @@ const Container$12 = styled__default.default.div`
|
|
|
7512
7513
|
|
|
7513
7514
|
var Column = function (_a) {
|
|
7514
7515
|
var _b = _a.small, small = _b === void 0 ? 'full' : _b, _c = _a.medium, medium = _c === void 0 ? 'one-half' : _c, _d = _a.large, large = _d === void 0 ? 'one-third' : _d, _e = _a.hasPadding, hasPadding = _e === void 0 ? true : _e, _f = _a.hasBorder, hasBorder = _f === void 0 ? false : _f, _g = _a.isList, isList = _g === void 0 ? false : _g, classes = _a.classes, children = _a.children;
|
|
7515
|
-
return (React__default.default.createElement(Container$
|
|
7516
|
+
return (React__default.default.createElement(Container$13, { "data-testid": "Column", "$small": small, "$medium": medium, "$large": large, "$hasPadding": hasPadding, "$hasBorder": hasBorder, as: isList ? 'li' : 'div', className: classes }, children));
|
|
7516
7517
|
};
|
|
7517
7518
|
|
|
7518
7519
|
var PromotedLinks = function (_a) {
|
|
@@ -7528,7 +7529,7 @@ var PromotedLinks = function (_a) {
|
|
|
7528
7529
|
}
|
|
7529
7530
|
};
|
|
7530
7531
|
|
|
7531
|
-
const Container$
|
|
7532
|
+
const Container$12 = styled__default.default.div`
|
|
7532
7533
|
display: block;
|
|
7533
7534
|
`;
|
|
7534
7535
|
|
|
@@ -7564,7 +7565,7 @@ const Cookies = styled__default.default.button`
|
|
|
7564
7565
|
}
|
|
7565
7566
|
`;
|
|
7566
7567
|
|
|
7567
|
-
const Container$
|
|
7568
|
+
const Container$11 = styled__default.default.div`
|
|
7568
7569
|
${props => props.theme.fontStyles}
|
|
7569
7570
|
background-color: ${props => props.theme.theme_vars.colours.grey_light};
|
|
7570
7571
|
padding: ${props => props.theme.theme_vars.spacingSizes.medium} 0;
|
|
@@ -7676,74 +7677,80 @@ const ButtonsContainer = styled__default.default.div`
|
|
|
7676
7677
|
`;
|
|
7677
7678
|
|
|
7678
7679
|
const StyledButton = styled__default.default.button`
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
|
|
7686
|
-
|
|
7680
|
+
font-weight: 700;
|
|
7681
|
+
border: none;
|
|
7682
|
+
cursor: pointer;
|
|
7683
|
+
display: inline-block;
|
|
7684
|
+
line-height: 1;
|
|
7685
|
+
font-family: ${(props) => props.theme.theme_vars.fontstack};
|
|
7686
|
+
border-radius: ${(props) => props.theme.theme_vars.border_radius};
|
|
7687
|
+
text-decoration: none;
|
|
7687
7688
|
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
|
|
7689
|
+
&:disabled {
|
|
7690
|
+
background-color: ${(props) => props.theme.theme_vars.colours.grey} !important;
|
|
7691
|
+
color: ${(props) => props.theme.theme_vars.colours.black} !important;
|
|
7692
|
+
cursor: not-allowed !important;
|
|
7693
|
+
}
|
|
7691
7694
|
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
&:focus {
|
|
7696
|
-
outline: none;
|
|
7697
|
-
color: ${props => props.theme.theme_vars.colours.black} !important;
|
|
7698
|
-
background-color: ${props => props.theme.theme_vars.colours.focus};
|
|
7699
|
-
box-shadow: 0px -3px 0px 0px ${props => props.theme.theme_vars.colours.black} inset;
|
|
7700
|
-
-webkit-box-shadow: 0px -3px 0px 0px ${props => props.theme.theme_vars.colours.black} inset;
|
|
7701
|
-
-moz-box-shadow: 0px -3px 0px 0px ${props => props.theme.theme_vars.colours.black} inset;
|
|
7702
|
-
}
|
|
7703
|
-
&:active {
|
|
7704
|
-
transform: translateY(2px);
|
|
7705
|
-
color: ${props => props.theme.theme_vars.colours.black} !important;
|
|
7706
|
-
background-color: ${props => props.theme.theme_vars.colours.focus};
|
|
7707
|
-
box-shadow: 0px -1px 0px 0px ${props => props.theme.theme_vars.colours.black} inset;
|
|
7708
|
-
-webkit-box-shadow: 0px -1px 0px 0px ${props => props.theme.theme_vars.colours.black} inset;
|
|
7709
|
-
-moz-box-shadow: 0px -1px 0px 0px ${props => props.theme.theme_vars.colours.black} inset;
|
|
7710
|
-
}
|
|
7711
|
-
}
|
|
7712
|
-
&.button--secondary {
|
|
7713
|
-
color: ${props => props.theme.theme_vars.colours.action};
|
|
7714
|
-
background-color: transparent;
|
|
7715
|
-
border: 2px solid ${props => props.theme.theme_vars.colours.action};
|
|
7695
|
+
&.button--primary {
|
|
7696
|
+
color: white;
|
|
7697
|
+
background-color: ${(props) => props.theme.theme_vars.colours.action};
|
|
7716
7698
|
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7699
|
+
&:hover {
|
|
7700
|
+
background-color: ${(props) => props.theme.theme_vars.colours.action_dark};
|
|
7701
|
+
}
|
|
7702
|
+
&:focus {
|
|
7703
|
+
outline: none;
|
|
7704
|
+
color: ${(props) => props.theme.theme_vars.colours.black} !important;
|
|
7705
|
+
background-color: ${(props) => props.theme.theme_vars.colours.focus};
|
|
7706
|
+
box-shadow: 0px -3px 0px 0px ${(props) => props.theme.theme_vars.colours.black} inset;
|
|
7707
|
+
-webkit-box-shadow: 0px -3px 0px 0px ${(props) => props.theme.theme_vars.colours.black} inset;
|
|
7708
|
+
-moz-box-shadow: 0px -3px 0px 0px ${(props) => props.theme.theme_vars.colours.black} inset;
|
|
7725
7709
|
}
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7710
|
+
&:active {
|
|
7711
|
+
transform: translateY(2px);
|
|
7712
|
+
color: ${(props) => props.theme.theme_vars.colours.black} !important;
|
|
7713
|
+
background-color: ${(props) => props.theme.theme_vars.colours.focus};
|
|
7714
|
+
box-shadow: 0px -1px 0px 0px ${(props) => props.theme.theme_vars.colours.black} inset;
|
|
7715
|
+
-webkit-box-shadow: 0px -1px 0px 0px ${(props) => props.theme.theme_vars.colours.black} inset;
|
|
7716
|
+
-moz-box-shadow: 0px -1px 0px 0px ${(props) => props.theme.theme_vars.colours.black} inset;
|
|
7729
7717
|
}
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7718
|
+
}
|
|
7719
|
+
&.button--secondary {
|
|
7720
|
+
color: ${(props) => props.theme.theme_vars.colours.action};
|
|
7721
|
+
background-color: transparent;
|
|
7722
|
+
border: 2px solid ${(props) => props.theme.theme_vars.colours.action};
|
|
7723
|
+
|
|
7724
|
+
&:hover {
|
|
7725
|
+
background-color: ${(props) => props.theme.theme_vars.colours.action}1A;
|
|
7733
7726
|
}
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7727
|
+
&:focus {
|
|
7728
|
+
outline: none;
|
|
7729
|
+
border: 2px solid ${(props) => props.theme.theme_vars.colours.focus};
|
|
7730
|
+
background-color: ${(props) => props.theme.theme_vars.colours.action}1A;
|
|
7737
7731
|
}
|
|
7732
|
+
}
|
|
7733
|
+
&.button--small {
|
|
7734
|
+
font-size: 12px;
|
|
7735
|
+
padding: 10px 16px;
|
|
7736
|
+
}
|
|
7737
|
+
&.button--medium {
|
|
7738
|
+
font-size: 14px;
|
|
7739
|
+
padding: 11px 20px;
|
|
7740
|
+
}
|
|
7741
|
+
&.button--large {
|
|
7742
|
+
font-size: 16px;
|
|
7743
|
+
padding: 12px 24px;
|
|
7744
|
+
}
|
|
7738
7745
|
`;
|
|
7739
7746
|
|
|
7740
7747
|
/**
|
|
7741
7748
|
* Primary UI component for user interaction
|
|
7742
7749
|
*/
|
|
7743
7750
|
var FormButton = function (_a) {
|
|
7744
|
-
var _b = _a.primary, primary = _b === void 0 ? true : _b, _c = _a.size, size = _c === void 0 ? 'medium' : _c, text = _a.text
|
|
7751
|
+
var _b = _a.primary, primary = _b === void 0 ? true : _b, _c = _a.size, size = _c === void 0 ? 'medium' : _c, text = _a.text, _d = _a.type, type = _d === void 0 ? 'submit' : _d, _e = _a.isDisabled, isDisabled = _e === void 0 ? false : _e, props = __rest(_a, ["primary", "size", "text", "type", "isDisabled"]);
|
|
7745
7752
|
var mode = primary ? 'button--primary' : 'button--secondary';
|
|
7746
|
-
return (React__default.default.createElement(StyledButton, __assign$2({ className: ["button--".concat(size), mode].join(' ') }, props), text));
|
|
7753
|
+
return (React__default.default.createElement(StyledButton, __assign$2({ className: ["button--".concat(size), mode].join(' '), disabled: isDisabled, type: type }, props), text));
|
|
7747
7754
|
};
|
|
7748
7755
|
|
|
7749
7756
|
const cookieName = 'fn-cookie';
|
|
@@ -7902,18 +7909,18 @@ var CookieBanner = function (_a) {
|
|
|
7902
7909
|
hideCookiesAcceptedConfirmationBanner();
|
|
7903
7910
|
};
|
|
7904
7911
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
7905
|
-
showCookieBanner && (React__default.default.createElement(Container$
|
|
7912
|
+
showCookieBanner && (React__default.default.createElement(Container$11, { "data-testid": "CookieBanner" },
|
|
7906
7913
|
React__default.default.createElement(CookieMessage, null,
|
|
7907
7914
|
React__default.default.createElement(CookieHeading, null, title),
|
|
7908
7915
|
React__default.default.createElement(CookieParagraph, null, paragraph),
|
|
7909
7916
|
React__default.default.createElement(ButtonsContainer, null,
|
|
7910
|
-
React__default.default.createElement(FormButton, { primary: true, text: acceptButtonText, isDisabled:
|
|
7911
|
-
React__default.default.createElement(FormButton, { primary: true, text: rejectButtonText, isDisabled:
|
|
7912
|
-
showCookiesRejectedBanner && (React__default.default.createElement(Container$
|
|
7917
|
+
React__default.default.createElement(FormButton, { primary: true, text: acceptButtonText, isDisabled: false, type: "button", onClick: acceptCookies }),
|
|
7918
|
+
React__default.default.createElement(FormButton, { primary: true, text: rejectButtonText, isDisabled: false, type: "button", onClick: rejectCookies }))))),
|
|
7919
|
+
showCookiesRejectedBanner && (React__default.default.createElement(Container$11, { "data-testid": "CookieBannerRejected", id: "CookieBannerRejected" },
|
|
7913
7920
|
React__default.default.createElement(CookieMessage, { isInline: true },
|
|
7914
7921
|
React__default.default.createElement(CookieParagraph, null, rejectConfirmationText),
|
|
7915
7922
|
React__default.default.createElement(CookieHide, { onClick: hideCookiesConfirmationBanner, "aria-controls": "CookieBannerRejected", "aria-hidden": "false" }, "Hide")))),
|
|
7916
|
-
showCookiesAcceptedBanner && (React__default.default.createElement(Container$
|
|
7923
|
+
showCookiesAcceptedBanner && (React__default.default.createElement(Container$11, { "data-testid": "CookieBannerAccepted", id: "CookieBannerAccepted" },
|
|
7917
7924
|
React__default.default.createElement(CookieMessage, { isInline: true },
|
|
7918
7925
|
React__default.default.createElement(CookieParagraph, null, acceptConfirmationText),
|
|
7919
7926
|
React__default.default.createElement(CookieHide, { onClick: hideCookiesConfirmationBanner, "aria-controls": "CookieBannerAccepted", "aria-hidden": "false" }, "Hide"))))));
|
|
@@ -7935,7 +7942,7 @@ var StaticMap = function (_a) {
|
|
|
7935
7942
|
return "&markers=size:".concat(size, "%7Ccolor:").concat(colour).concat(label, "%7C").concat(mapMarker.lat, ",").concat(mapMarker.lng);
|
|
7936
7943
|
})
|
|
7937
7944
|
.join('');
|
|
7938
|
-
return (React__default.default.createElement(Container$
|
|
7945
|
+
return (React__default.default.createElement(Container$12, { "data-testid": "StaticMap" },
|
|
7939
7946
|
React__default.default.createElement(Message, null,
|
|
7940
7947
|
React__default.default.createElement("span", null,
|
|
7941
7948
|
"To interact with the map, you need to ",
|
|
@@ -7950,13 +7957,13 @@ var StaticMap = function (_a) {
|
|
|
7950
7957
|
var TextInput = function (_a) {
|
|
7951
7958
|
var id = _a.id, name = _a.name, _b = _a.value, value = _b === void 0 ? '' : _b, size = _a.size, _c = _a.placeholder, placeholder = _c === void 0 ? '' : _c, _d = _a.isLarge, isLarge = _d === void 0 ? false : _d, _e = _a.isErrored, isErrored = _e === void 0 ? false : _e, _f = _a.errorText, errorText = _f === void 0 ? '' : _f;
|
|
7952
7959
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
7953
|
-
isErrored && errorText && React__default.default.createElement(ErrorText$
|
|
7960
|
+
isErrored && errorText && React__default.default.createElement(ErrorText$2, null, errorText),
|
|
7954
7961
|
React__default.default.createElement(StyledTextInput, { type: "text", id: id, name: name, defaultValue: value, "$size": size, placeholder: placeholder, "$isErrored": isErrored, "$isLarge": isLarge })));
|
|
7955
7962
|
};
|
|
7956
7963
|
|
|
7957
7964
|
// Accordion
|
|
7958
7965
|
|
|
7959
|
-
const Container
|
|
7966
|
+
const Container$10 = styled__default.default.div`
|
|
7960
7967
|
${(props) => props.theme.fontStyles}
|
|
7961
7968
|
margin-bottom: 20px;
|
|
7962
7969
|
border-bottom: 1px solid ${(props) => props.theme.theme_vars.colours.grey};
|
|
@@ -8231,7 +8238,7 @@ var Accordion$1 = function (_a) {
|
|
|
8231
8238
|
setAccordionStates(newStatus);
|
|
8232
8239
|
};
|
|
8233
8240
|
var accordionId = "accordion".concat(React.useId());
|
|
8234
|
-
return (React__default.default.createElement(Container
|
|
8241
|
+
return (React__default.default.createElement(Container$10, { "data-testid": "Accordion", id: accordionId },
|
|
8235
8242
|
showControls && sections.length > 1 && (React__default.default.createElement(AccordionControls$1, null,
|
|
8236
8243
|
React__default.default.createElement(OpenAllButton, { onClick: toggleAll, type: "button", "aria-expanded": !openAll },
|
|
8237
8244
|
openAll ? 'Open all' : 'Close all',
|
|
@@ -8282,7 +8289,7 @@ var BlockQuote = function (_a) {
|
|
|
8282
8289
|
citation && React__default.default.createElement(Citation, null, citation)));
|
|
8283
8290
|
};
|
|
8284
8291
|
|
|
8285
|
-
const Container
|
|
8292
|
+
const Container$$ = styled__default.default.div`
|
|
8286
8293
|
margin-bottom: 30px;
|
|
8287
8294
|
display: block;
|
|
8288
8295
|
|
|
@@ -8297,11 +8304,11 @@ const Container$_ = styled__default.default.div`
|
|
|
8297
8304
|
*/
|
|
8298
8305
|
var CallToAction = function (_a) {
|
|
8299
8306
|
var primary = _a.primary; _a.size; var text = _a.text, url = _a.url, isExternal = _a.isExternal, isDisabled = _a.isDisabled; __rest(_a, ["primary", "size", "text", "url", "isExternal", "isDisabled"]);
|
|
8300
|
-
return (React__default.default.createElement(Container
|
|
8307
|
+
return (React__default.default.createElement(Container$$, null,
|
|
8301
8308
|
React__default.default.createElement(Button$4, { primary: primary, size: "large", text: text, url: url, isExternal: isExternal, isDisabled: isDisabled })));
|
|
8302
8309
|
};
|
|
8303
8310
|
|
|
8304
|
-
const Container$
|
|
8311
|
+
const Container$_ = styled__default.default.div`
|
|
8305
8312
|
display: block;
|
|
8306
8313
|
${(props) => props.theme.fontStyles}
|
|
8307
8314
|
`;
|
|
@@ -8386,7 +8393,7 @@ const BackButton = styled__default.default.a`
|
|
|
8386
8393
|
}
|
|
8387
8394
|
`;
|
|
8388
8395
|
|
|
8389
|
-
const ErrorText = styled__default.default.p`
|
|
8396
|
+
const ErrorText$1 = styled__default.default.p`
|
|
8390
8397
|
${(props) => props.theme.fontStyles}
|
|
8391
8398
|
color: ${(props) => props.theme.theme_vars.colours.negative};
|
|
8392
8399
|
font-weight: bold;
|
|
@@ -8477,9 +8484,9 @@ var CouncilTaxAlphabeticalDirectory = function (_a) {
|
|
|
8477
8484
|
});
|
|
8478
8485
|
return letterData;
|
|
8479
8486
|
});
|
|
8480
|
-
return (React__default.default.createElement(Container$
|
|
8487
|
+
return (React__default.default.createElement(Container$_, { "data-testid": "AlphabeticalDirectory", ref: directoryRef },
|
|
8481
8488
|
React__default.default.createElement(React__default.default.Fragment, null,
|
|
8482
|
-
parishes.length === 0 && (React__default.default.createElement(ErrorText, null, "There was an issue fetching the parish data. Please try again later.")),
|
|
8489
|
+
parishes.length === 0 && (React__default.default.createElement(ErrorText$1, null, "There was an issue fetching the parish data. Please try again later.")),
|
|
8483
8490
|
parish === null ? (React__default.default.createElement(React__default.default.Fragment, null, sortedData.map(function (letter, i) { return (React__default.default.createElement(Row, { key: i },
|
|
8484
8491
|
React__default.default.createElement(Row$1, null,
|
|
8485
8492
|
React__default.default.createElement(Column, { small: "full", medium: "one-quarter", large: "one-quarter" },
|
|
@@ -8503,9 +8510,9 @@ var CouncilTaxAlphabeticalDirectory = function (_a) {
|
|
|
8503
8510
|
React__default.default.createElement("td", null, Number(parish.values[band]).toLocaleString('en-GB', { style: 'currency', currency: 'GBP' })))); })))))))));
|
|
8504
8511
|
};
|
|
8505
8512
|
|
|
8506
|
-
const Container$
|
|
8513
|
+
const Container$Z = styled__default.default.div``;
|
|
8507
8514
|
|
|
8508
|
-
const Container$
|
|
8515
|
+
const Container$Y = styled__default.default.div`
|
|
8509
8516
|
display: flex;
|
|
8510
8517
|
flex-direction: column;
|
|
8511
8518
|
justify-content: flex-start;
|
|
@@ -8518,7 +8525,7 @@ const Container$X = styled__default.default.div`
|
|
|
8518
8525
|
: props.theme.theme_vars.colours.white};
|
|
8519
8526
|
`;
|
|
8520
8527
|
|
|
8521
|
-
const Content$
|
|
8528
|
+
const Content$7 = styled__default.default.div`
|
|
8522
8529
|
padding: ${(props) => props.theme.theme_vars.spacingSizes.medium};
|
|
8523
8530
|
flex-grow: 1;
|
|
8524
8531
|
|
|
@@ -13223,9 +13230,9 @@ var escapeStringRegexp$1 = string => {
|
|
|
13223
13230
|
.replace(/-/g, '\\x2d');
|
|
13224
13231
|
};
|
|
13225
13232
|
|
|
13226
|
-
var isPlainObject$
|
|
13233
|
+
var isPlainObject$3 = {};
|
|
13227
13234
|
|
|
13228
|
-
Object.defineProperty(isPlainObject$
|
|
13235
|
+
Object.defineProperty(isPlainObject$3, '__esModule', { value: true });
|
|
13229
13236
|
|
|
13230
13237
|
/*!
|
|
13231
13238
|
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
@@ -13234,14 +13241,14 @@ Object.defineProperty(isPlainObject$2, '__esModule', { value: true });
|
|
|
13234
13241
|
* Released under the MIT License.
|
|
13235
13242
|
*/
|
|
13236
13243
|
|
|
13237
|
-
function isObject(o) {
|
|
13244
|
+
function isObject$1(o) {
|
|
13238
13245
|
return Object.prototype.toString.call(o) === '[object Object]';
|
|
13239
13246
|
}
|
|
13240
13247
|
|
|
13241
|
-
function isPlainObject$
|
|
13248
|
+
function isPlainObject$2(o) {
|
|
13242
13249
|
var ctor,prot;
|
|
13243
13250
|
|
|
13244
|
-
if (isObject(o) === false) return false;
|
|
13251
|
+
if (isObject$1(o) === false) return false;
|
|
13245
13252
|
|
|
13246
13253
|
// If has modified constructor
|
|
13247
13254
|
ctor = o.constructor;
|
|
@@ -13249,7 +13256,7 @@ function isPlainObject$1(o) {
|
|
|
13249
13256
|
|
|
13250
13257
|
// If has modified prototype
|
|
13251
13258
|
prot = ctor.prototype;
|
|
13252
|
-
if (isObject(prot) === false) return false;
|
|
13259
|
+
if (isObject$1(prot) === false) return false;
|
|
13253
13260
|
|
|
13254
13261
|
// If constructor does not have an Object-specific method
|
|
13255
13262
|
if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
|
@@ -13260,7 +13267,7 @@ function isPlainObject$1(o) {
|
|
|
13260
13267
|
return true;
|
|
13261
13268
|
}
|
|
13262
13269
|
|
|
13263
|
-
isPlainObject$
|
|
13270
|
+
isPlainObject$3.isPlainObject = isPlainObject$2;
|
|
13264
13271
|
|
|
13265
13272
|
var isMergeableObject = function isMergeableObject(value) {
|
|
13266
13273
|
return isNonNullObject(value)
|
|
@@ -19117,7 +19124,7 @@ function markDirtyUp(node) {
|
|
|
19117
19124
|
}
|
|
19118
19125
|
}
|
|
19119
19126
|
|
|
19120
|
-
let Container$
|
|
19127
|
+
let Container$X = class Container extends Node$1 {
|
|
19121
19128
|
append(...children) {
|
|
19122
19129
|
for (let child of children) {
|
|
19123
19130
|
let nodes = this.normalize(child, this.last);
|
|
@@ -19488,27 +19495,27 @@ let Container$W = class Container extends Node$1 {
|
|
|
19488
19495
|
}
|
|
19489
19496
|
};
|
|
19490
19497
|
|
|
19491
|
-
Container$
|
|
19498
|
+
Container$X.registerParse = dependant => {
|
|
19492
19499
|
parse$4 = dependant;
|
|
19493
19500
|
};
|
|
19494
19501
|
|
|
19495
|
-
Container$
|
|
19502
|
+
Container$X.registerRule = dependant => {
|
|
19496
19503
|
Rule$4 = dependant;
|
|
19497
19504
|
};
|
|
19498
19505
|
|
|
19499
|
-
Container$
|
|
19506
|
+
Container$X.registerAtRule = dependant => {
|
|
19500
19507
|
AtRule$4 = dependant;
|
|
19501
19508
|
};
|
|
19502
19509
|
|
|
19503
|
-
Container$
|
|
19510
|
+
Container$X.registerRoot = dependant => {
|
|
19504
19511
|
Root$6 = dependant;
|
|
19505
19512
|
};
|
|
19506
19513
|
|
|
19507
|
-
var container = Container$
|
|
19508
|
-
Container$
|
|
19514
|
+
var container = Container$X;
|
|
19515
|
+
Container$X.default = Container$X;
|
|
19509
19516
|
|
|
19510
19517
|
/* c8 ignore start */
|
|
19511
|
-
Container$
|
|
19518
|
+
Container$X.rebuild = node => {
|
|
19512
19519
|
if (node.type === 'atrule') {
|
|
19513
19520
|
Object.setPrototypeOf(node, AtRule$4.prototype);
|
|
19514
19521
|
} else if (node.type === 'rule') {
|
|
@@ -19525,16 +19532,16 @@ Container$W.rebuild = node => {
|
|
|
19525
19532
|
|
|
19526
19533
|
if (node.nodes) {
|
|
19527
19534
|
node.nodes.forEach(child => {
|
|
19528
|
-
Container$
|
|
19535
|
+
Container$X.rebuild(child);
|
|
19529
19536
|
});
|
|
19530
19537
|
}
|
|
19531
19538
|
};
|
|
19532
19539
|
|
|
19533
|
-
let Container$
|
|
19540
|
+
let Container$W = container;
|
|
19534
19541
|
|
|
19535
19542
|
let LazyResult$4, Processor$3;
|
|
19536
19543
|
|
|
19537
|
-
let Document$3 = class Document extends Container$
|
|
19544
|
+
let Document$3 = class Document extends Container$W {
|
|
19538
19545
|
constructor(defaults) {
|
|
19539
19546
|
// type needs to be passed to super, otherwise child roots won't be normalized correctly
|
|
19540
19547
|
super({ type: 'document', ...defaults });
|
|
@@ -19652,9 +19659,9 @@ let Result$4 = class Result {
|
|
|
19652
19659
|
var result = Result$4;
|
|
19653
19660
|
Result$4.default = Result$4;
|
|
19654
19661
|
|
|
19655
|
-
let Container$
|
|
19662
|
+
let Container$V = container;
|
|
19656
19663
|
|
|
19657
|
-
let AtRule$3 = class AtRule extends Container$
|
|
19664
|
+
let AtRule$3 = class AtRule extends Container$V {
|
|
19658
19665
|
constructor(defaults) {
|
|
19659
19666
|
super(defaults);
|
|
19660
19667
|
this.type = 'atrule';
|
|
@@ -19674,13 +19681,13 @@ let AtRule$3 = class AtRule extends Container$U {
|
|
|
19674
19681
|
var atRule = AtRule$3;
|
|
19675
19682
|
AtRule$3.default = AtRule$3;
|
|
19676
19683
|
|
|
19677
|
-
Container$
|
|
19684
|
+
Container$V.registerAtRule(AtRule$3);
|
|
19678
19685
|
|
|
19679
|
-
let Container$
|
|
19686
|
+
let Container$U = container;
|
|
19680
19687
|
|
|
19681
19688
|
let LazyResult$3, Processor$2;
|
|
19682
19689
|
|
|
19683
|
-
let Root$5 = class Root extends Container$
|
|
19690
|
+
let Root$5 = class Root extends Container$U {
|
|
19684
19691
|
constructor(defaults) {
|
|
19685
19692
|
super(defaults);
|
|
19686
19693
|
this.type = 'root';
|
|
@@ -19734,7 +19741,7 @@ Root$5.registerProcessor = dependant => {
|
|
|
19734
19741
|
var root = Root$5;
|
|
19735
19742
|
Root$5.default = Root$5;
|
|
19736
19743
|
|
|
19737
|
-
Container$
|
|
19744
|
+
Container$U.registerRoot(Root$5);
|
|
19738
19745
|
|
|
19739
19746
|
let list$2 = {
|
|
19740
19747
|
comma(string) {
|
|
@@ -19793,10 +19800,10 @@ let list$2 = {
|
|
|
19793
19800
|
var list_1 = list$2;
|
|
19794
19801
|
list$2.default = list$2;
|
|
19795
19802
|
|
|
19796
|
-
let Container$
|
|
19803
|
+
let Container$T = container;
|
|
19797
19804
|
let list$1 = list_1;
|
|
19798
19805
|
|
|
19799
|
-
let Rule$3 = class Rule extends Container$
|
|
19806
|
+
let Rule$3 = class Rule extends Container$T {
|
|
19800
19807
|
constructor(defaults) {
|
|
19801
19808
|
super(defaults);
|
|
19802
19809
|
this.type = 'rule';
|
|
@@ -19817,7 +19824,7 @@ let Rule$3 = class Rule extends Container$S {
|
|
|
19817
19824
|
var rule = Rule$3;
|
|
19818
19825
|
Rule$3.default = Rule$3;
|
|
19819
19826
|
|
|
19820
|
-
Container$
|
|
19827
|
+
Container$T.registerRule(Rule$3);
|
|
19821
19828
|
|
|
19822
19829
|
let Declaration$2 = declaration;
|
|
19823
19830
|
let tokenizer = tokenize;
|
|
@@ -20428,7 +20435,7 @@ let Parser$1 = class Parser {
|
|
|
20428
20435
|
|
|
20429
20436
|
var parser = Parser$1;
|
|
20430
20437
|
|
|
20431
|
-
let Container$
|
|
20438
|
+
let Container$S = container;
|
|
20432
20439
|
let Parser = parser;
|
|
20433
20440
|
let Input$3 = input;
|
|
20434
20441
|
|
|
@@ -20467,12 +20474,12 @@ function parse$3(css, opts) {
|
|
|
20467
20474
|
var parse_1 = parse$3;
|
|
20468
20475
|
parse$3.default = parse$3;
|
|
20469
20476
|
|
|
20470
|
-
Container$
|
|
20477
|
+
Container$S.registerParse(parse$3);
|
|
20471
20478
|
|
|
20472
20479
|
let { isClean, my } = symbols;
|
|
20473
20480
|
let MapGenerator$1 = mapGenerator;
|
|
20474
20481
|
let stringify$2 = stringify_1;
|
|
20475
|
-
let Container$
|
|
20482
|
+
let Container$R = container;
|
|
20476
20483
|
let Document$2 = document$1;
|
|
20477
20484
|
let warnOnce$1 = warnOnce$2;
|
|
20478
20485
|
let Result$3 = result;
|
|
@@ -20607,7 +20614,7 @@ let LazyResult$2 = class LazyResult {
|
|
|
20607
20614
|
|
|
20608
20615
|
if (root && !root[my]) {
|
|
20609
20616
|
/* c8 ignore next 2 */
|
|
20610
|
-
Container$
|
|
20617
|
+
Container$R.rebuild(root);
|
|
20611
20618
|
}
|
|
20612
20619
|
}
|
|
20613
20620
|
|
|
@@ -21274,7 +21281,7 @@ fromJSON$1.default = fromJSON$1;
|
|
|
21274
21281
|
let CssSyntaxError = cssSyntaxError;
|
|
21275
21282
|
let Declaration = declaration;
|
|
21276
21283
|
let LazyResult = lazyResult;
|
|
21277
|
-
let Container$
|
|
21284
|
+
let Container$Q = container;
|
|
21278
21285
|
let Processor = processor;
|
|
21279
21286
|
let stringify = stringify_1;
|
|
21280
21287
|
let fromJSON = fromJSON_1;
|
|
@@ -21354,7 +21361,7 @@ postcss.document = defaults => new Document(defaults);
|
|
|
21354
21361
|
|
|
21355
21362
|
postcss.CssSyntaxError = CssSyntaxError;
|
|
21356
21363
|
postcss.Declaration = Declaration;
|
|
21357
|
-
postcss.Container = Container$
|
|
21364
|
+
postcss.Container = Container$Q;
|
|
21358
21365
|
postcss.Processor = Processor;
|
|
21359
21366
|
postcss.Document = Document;
|
|
21360
21367
|
postcss.Comment = Comment;
|
|
@@ -21373,7 +21380,7 @@ postcss.default = postcss;
|
|
|
21373
21380
|
|
|
21374
21381
|
const htmlparser = lib$6;
|
|
21375
21382
|
const escapeStringRegexp = escapeStringRegexp$1;
|
|
21376
|
-
const { isPlainObject } = isPlainObject$
|
|
21383
|
+
const { isPlainObject: isPlainObject$1 } = isPlainObject$3;
|
|
21377
21384
|
const deepmerge = cjs;
|
|
21378
21385
|
const parseSrcset = parseSrcsetExports;
|
|
21379
21386
|
const { parse: postcssParse } = postcss_1;
|
|
@@ -21409,7 +21416,7 @@ function filter(a, cb) {
|
|
|
21409
21416
|
return n;
|
|
21410
21417
|
}
|
|
21411
21418
|
|
|
21412
|
-
function isEmptyObject(obj) {
|
|
21419
|
+
function isEmptyObject$1(obj) {
|
|
21413
21420
|
for (const key in obj) {
|
|
21414
21421
|
if (has(obj, key)) {
|
|
21415
21422
|
return false;
|
|
@@ -21632,7 +21639,7 @@ function sanitizeHtml(html, options, _recursing) {
|
|
|
21632
21639
|
}
|
|
21633
21640
|
}
|
|
21634
21641
|
|
|
21635
|
-
if (!tagAllowed(name) || (options.disallowedTagsMode === 'recursiveEscape' && !isEmptyObject(skipMap)) || (options.nestingLimit != null && depth >= options.nestingLimit)) {
|
|
21642
|
+
if (!tagAllowed(name) || (options.disallowedTagsMode === 'recursiveEscape' && !isEmptyObject$1(skipMap)) || (options.nestingLimit != null && depth >= options.nestingLimit)) {
|
|
21636
21643
|
skip = true;
|
|
21637
21644
|
skipMap[depth] = true;
|
|
21638
21645
|
if (options.disallowedTagsMode === 'discard') {
|
|
@@ -21685,7 +21692,7 @@ function sanitizeHtml(html, options, _recursing) {
|
|
|
21685
21692
|
passedAllowedAttributesMapCheck = true;
|
|
21686
21693
|
} else if (allowedAttributesMap && allowedAttributesMap[name]) {
|
|
21687
21694
|
for (const o of allowedAttributesMap[name]) {
|
|
21688
|
-
if (isPlainObject(o) && o.name && (o.name === a)) {
|
|
21695
|
+
if (isPlainObject$1(o) && o.name && (o.name === a)) {
|
|
21689
21696
|
passedAllowedAttributesMapCheck = true;
|
|
21690
21697
|
let newValue = '';
|
|
21691
21698
|
if (o.multiple === true) {
|
|
@@ -22289,12 +22296,12 @@ var sanitizeHtml$1 = /*@__PURE__*/getDefaultExportFromCjs(sanitizeHtml_1);
|
|
|
22289
22296
|
var Card = function (_a) {
|
|
22290
22297
|
var header = _a.header, content = _a.content, footerLink = _a.footerLink, imageLarge = _a.imageLarge, imageSmall = _a.imageSmall, imageAltText = _a.imageAltText;
|
|
22291
22298
|
var showContent = content || header;
|
|
22292
|
-
return (React__default.default.createElement(Container$
|
|
22299
|
+
return (React__default.default.createElement(Container$Y, { "data-testid": "Card" },
|
|
22293
22300
|
imageLarge && imageSmall && (React__default.default.createElement(React__default.default.Fragment, null, footerLink ? (React__default.default.createElement(ImageLink$1, { href: footerLink.url },
|
|
22294
22301
|
React__default.default.createElement(Image$3, { src: imageLarge, alt: imageAltText, srcSet: "".concat(imageSmall, " 400w, ").concat(imageLarge, " 800w"), sizes: "(max-width: 550px) 400px, 800px", loading: "lazy" }))) : (React__default.default.createElement(Image$3, { src: imageLarge, alt: imageAltText, srcSet: "".concat(imageSmall, " 400w, ").concat(imageLarge, " 800w"), sizes: "(max-width: 550px) 400px, 800px", loading: "lazy" })))),
|
|
22295
|
-
showContent && (React__default.default.createElement(Content$
|
|
22302
|
+
showContent && (React__default.default.createElement(Content$7, null,
|
|
22296
22303
|
header && (React__default.default.createElement(Header$1, null,
|
|
22297
|
-
React__default.default.createElement(Heading, { text: header, level: 3 }))),
|
|
22304
|
+
React__default.default.createElement(Heading$1, { text: header, level: 3 }))),
|
|
22298
22305
|
React__default.default.createElement("div", { dangerouslySetInnerHTML: { __html: sanitizeHtml$1(content) } }))),
|
|
22299
22306
|
footerLink && (React__default.default.createElement(Footer$1, null,
|
|
22300
22307
|
React__default.default.createElement(FooterLink$1, { href: footerLink.url }, footerLink.title)))));
|
|
@@ -22305,12 +22312,12 @@ var Card = function (_a) {
|
|
|
22305
22312
|
*/
|
|
22306
22313
|
var Cards = function (_a) {
|
|
22307
22314
|
var cards = _a.cards;
|
|
22308
|
-
return (React__default.default.createElement(Container$
|
|
22315
|
+
return (React__default.default.createElement(Container$Z, { "data-testid": "Cards" },
|
|
22309
22316
|
React__default.default.createElement(Row$1, null, cards.map(function (card, index) { return (React__default.default.createElement(Column, { small: "full", medium: "one-half", large: "one-third", key: index },
|
|
22310
22317
|
React__default.default.createElement(Card, __assign$2({}, card)))); }))));
|
|
22311
22318
|
};
|
|
22312
22319
|
|
|
22313
|
-
const Container$
|
|
22320
|
+
const Container$P = styled__default.default.div`
|
|
22314
22321
|
margin: 25px 0;
|
|
22315
22322
|
`;
|
|
22316
22323
|
|
|
@@ -22428,7 +22435,7 @@ var FileDownload = function (_a) {
|
|
|
22428
22435
|
|
|
22429
22436
|
var DownloadableFiles = function (_a) {
|
|
22430
22437
|
var files = _a.files;
|
|
22431
|
-
return (React__default.default.createElement(Container$
|
|
22438
|
+
return (React__default.default.createElement(Container$P, { "data-testid": "DownloadableFiles" }, files.length > 0 ?
|
|
22432
22439
|
files.map(function (file) { return React__default.default.createElement(FileDownload, __assign$2({ key: file.title }, file)); })
|
|
22433
22440
|
:
|
|
22434
22441
|
React__default.default.createElement("i", null, "No file to show")));
|
|
@@ -22529,7 +22536,7 @@ const AccessibleMapLink = styled__default.default(MapLink$1)`
|
|
|
22529
22536
|
${(props) => props.theme.visuallyHidden};
|
|
22530
22537
|
`;
|
|
22531
22538
|
|
|
22532
|
-
const Container$
|
|
22539
|
+
const Container$O = styled__default.default.div`
|
|
22533
22540
|
border: solid 4px;
|
|
22534
22541
|
border-radius: ${(props) => props.theme.theme_vars.border_radius};
|
|
22535
22542
|
border-color: ${(props) =>
|
|
@@ -22583,9 +22590,9 @@ const InnerContainer$2 = styled__default.default.div`
|
|
|
22583
22590
|
*/
|
|
22584
22591
|
var AlertBannerService = function (_a) {
|
|
22585
22592
|
var title = _a.title, _b = _a.hasTopSpacing, hasTopSpacing = _b === void 0 ? false : _b, _c = _a.alertType, alertType = _c === void 0 ? 'alert' : _c, children = _a.children;
|
|
22586
|
-
return (React__default.default.createElement(Container$
|
|
22593
|
+
return (React__default.default.createElement(Container$O, { "$alertType": alertType, "data-testid": "AlertBannerService", "$hasTopSpacing": hasTopSpacing },
|
|
22587
22594
|
React__default.default.createElement(InnerContainer$2, { "data-testid": "AlertBannerServiceInner" },
|
|
22588
|
-
(title === null || title === void 0 ? void 0 : title.trim()) && React__default.default.createElement(Heading, { text: title }),
|
|
22595
|
+
(title === null || title === void 0 ? void 0 : title.trim()) && React__default.default.createElement(Heading$1, { text: title }),
|
|
22589
22596
|
children)));
|
|
22590
22597
|
};
|
|
22591
22598
|
|
|
@@ -22613,7 +22620,7 @@ var GoogleMap = function (_a) {
|
|
|
22613
22620
|
}, []);
|
|
22614
22621
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
22615
22622
|
React__default.default.createElement(ProtectiveContainer, null,
|
|
22616
|
-
title && React__default.default.createElement(Heading, { level: 3, text: title }),
|
|
22623
|
+
title && React__default.default.createElement(Heading$1, { level: 3, text: title }),
|
|
22617
22624
|
description && (React__default.default.createElement(MapDescription, { dangerouslySetInnerHTML: {
|
|
22618
22625
|
__html: sanitizeHtml$1(description),
|
|
22619
22626
|
} })),
|
|
@@ -22636,7 +22643,7 @@ var GoogleMap = function (_a) {
|
|
|
22636
22643
|
React__default.default.createElement(MapLink$1, { href: link_url }, link_title ? link_title : 'Google Maps link')))));
|
|
22637
22644
|
};
|
|
22638
22645
|
|
|
22639
|
-
const Container$
|
|
22646
|
+
const Container$N = styled__default.default.figure`
|
|
22640
22647
|
display: block;
|
|
22641
22648
|
background: ${(props) =>
|
|
22642
22649
|
props.theme.cardinal_name === 'north'
|
|
@@ -22693,7 +22700,7 @@ const imageRatio = (props) => {
|
|
|
22693
22700
|
}
|
|
22694
22701
|
};
|
|
22695
22702
|
|
|
22696
|
-
const Container$
|
|
22703
|
+
const Container$M = styled__default.default.div`
|
|
22697
22704
|
display: block;
|
|
22698
22705
|
position: ${(props) => (props.$ratio === 'auto' ? 'absolute' : 'relative')};
|
|
22699
22706
|
${imageRatio}
|
|
@@ -22711,7 +22718,7 @@ const Image$2 = styled__default.default.img`
|
|
|
22711
22718
|
|
|
22712
22719
|
var ResponsiveImage = function (_a) {
|
|
22713
22720
|
var imageSmall = _a.imageSmall, imageLarge = _a.imageLarge, imageAltText = _a.imageAltText, _b = _a.smallWidth, smallWidth = _b === void 0 ? '400' : _b, _c = _a.largeWidth, largeWidth = _c === void 0 ? '1200' : _c, ratio = _a.ratio, _d = _a.objectFit, objectFit = _d === void 0 ? 'cover' : _d;
|
|
22714
|
-
return (React__default.default.createElement(Container$
|
|
22721
|
+
return (React__default.default.createElement(Container$M, { "data-testid": "ResponsiveImage", "$ratio": ratio },
|
|
22715
22722
|
React__default.default.createElement(Image$2, { alt: imageAltText, loading: "lazy", srcSet: "".concat(imageSmall, " ").concat(smallWidth, "w, ").concat(imageLarge, " ").concat(largeWidth, "w"), sizes: "(max-width: 550px) 550px, ".concat(largeWidth, "px"), src: imageLarge, "$objectFit": objectFit })));
|
|
22716
22723
|
};
|
|
22717
22724
|
|
|
@@ -22721,12 +22728,12 @@ var ResponsiveImage = function (_a) {
|
|
|
22721
22728
|
*/
|
|
22722
22729
|
var Image$1 = function (_a) {
|
|
22723
22730
|
var imageSmall = _a.imageSmall, imageLarge = _a.imageLarge, imageAltText = _a.imageAltText, _b = _a.ratio, ratio = _b === void 0 ? '4by3' : _b, caption = _a.caption, wrapText = _a.wrapText;
|
|
22724
|
-
return (React__default.default.createElement(Container$
|
|
22731
|
+
return (React__default.default.createElement(Container$N, { "data-testid": "Image", "$wrapText": wrapText },
|
|
22725
22732
|
React__default.default.createElement(ResponsiveImage, { imageSmall: imageSmall, imageLarge: imageLarge, imageAltText: imageAltText, ratio: ratio, smallWidth: "400", largeWidth: "1200" }),
|
|
22726
22733
|
(caption === null || caption === void 0 ? void 0 : caption.trim()) && React__default.default.createElement(Caption, null, caption)));
|
|
22727
22734
|
};
|
|
22728
22735
|
|
|
22729
|
-
const Container$
|
|
22736
|
+
const Container$L = styled__default.default.div`
|
|
22730
22737
|
display: block;
|
|
22731
22738
|
`;
|
|
22732
22739
|
|
|
@@ -22736,7 +22743,7 @@ const HeadingContainer = styled__default.default.div`
|
|
|
22736
22743
|
}
|
|
22737
22744
|
`;
|
|
22738
22745
|
|
|
22739
|
-
const Content$
|
|
22746
|
+
const Content$6 = styled__default.default.div`
|
|
22740
22747
|
@media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.m}) {
|
|
22741
22748
|
margin: ${(props) => props.theme.theme_vars.spacingSizes.medium} 0;
|
|
22742
22749
|
}
|
|
@@ -22747,20 +22754,20 @@ const Content$5 = styled__default.default.div`
|
|
|
22747
22754
|
*/
|
|
22748
22755
|
var ImageAndText = function (_a) {
|
|
22749
22756
|
var heading = _a.heading, textContent = _a.textContent, image = _a.image;
|
|
22750
|
-
return (React__default.default.createElement(Container$
|
|
22757
|
+
return (React__default.default.createElement(Container$L, { "data-testid": "ImageAndText" },
|
|
22751
22758
|
React__default.default.createElement(Row$1, null,
|
|
22752
22759
|
heading && (React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
22753
22760
|
React__default.default.createElement(HeadingContainer, null,
|
|
22754
|
-
React__default.default.createElement(Heading, { text: heading, level: 3 })))),
|
|
22761
|
+
React__default.default.createElement(Heading$1, { text: heading, level: 3 })))),
|
|
22755
22762
|
image ? (React__default.default.createElement(React__default.default.Fragment, null,
|
|
22756
22763
|
React__default.default.createElement(Column, { small: "full", medium: "one-third", large: "one-third" },
|
|
22757
22764
|
React__default.default.createElement(Image$1, __assign$2({}, image))),
|
|
22758
22765
|
React__default.default.createElement(Column, { small: "full", medium: "two-thirds", large: "two-thirds" },
|
|
22759
|
-
React__default.default.createElement(Content$
|
|
22760
|
-
React__default.default.createElement(Content$
|
|
22766
|
+
React__default.default.createElement(Content$6, { dangerouslySetInnerHTML: { __html: sanitizeHtml$1(textContent) } })))) : (React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
22767
|
+
React__default.default.createElement(Content$6, { dangerouslySetInnerHTML: { __html: sanitizeHtml$1(textContent) } }))))));
|
|
22761
22768
|
};
|
|
22762
22769
|
|
|
22763
|
-
const Container$
|
|
22770
|
+
const Container$K = styled__default.default.div`
|
|
22764
22771
|
display: block;
|
|
22765
22772
|
`;
|
|
22766
22773
|
|
|
@@ -22769,7 +22776,7 @@ const Container$J = styled__default.default.div`
|
|
|
22769
22776
|
*/
|
|
22770
22777
|
var InquestSchedule = function (_a) {
|
|
22771
22778
|
var caseAppointments = _a.caseAppointments, title = _a.title, _b = _a.error, error = _b === void 0 ? false : _b;
|
|
22772
|
-
return (React__default.default.createElement(Container$
|
|
22779
|
+
return (React__default.default.createElement(Container$K, { "data-testid": "InquestSchedule" },
|
|
22773
22780
|
React__default.default.createElement("div", { className: "table-container" },
|
|
22774
22781
|
React__default.default.createElement("table", null,
|
|
22775
22782
|
React__default.default.createElement("caption", null, title),
|
|
@@ -22797,7 +22804,7 @@ var InquestSchedule = function (_a) {
|
|
|
22797
22804
|
error ? (React__default.default.createElement("p", null, " The information is currently unavailable.")) : (React__default.default.createElement("p", null, "There are no inquests scheduled for next month."))))))))));
|
|
22798
22805
|
};
|
|
22799
22806
|
|
|
22800
|
-
const Container$
|
|
22807
|
+
const Container$J = styled__default.default.div`
|
|
22801
22808
|
${(props) => props.theme.fontStyles};
|
|
22802
22809
|
overflow: hidden;
|
|
22803
22810
|
margin: 40px auto 5px auto;
|
|
@@ -22849,7 +22856,7 @@ const Wrapper$4 = styled__default.default.div`
|
|
|
22849
22856
|
}
|
|
22850
22857
|
`;
|
|
22851
22858
|
|
|
22852
|
-
const Content$
|
|
22859
|
+
const Content$5 = styled__default.default.div``;
|
|
22853
22860
|
|
|
22854
22861
|
const CTA = styled__default.default.a`
|
|
22855
22862
|
margin-top: 10px;
|
|
@@ -22874,12 +22881,12 @@ const CTA = styled__default.default.a`
|
|
|
22874
22881
|
*/
|
|
22875
22882
|
var PromoBanner = function (_a) {
|
|
22876
22883
|
var title = _a.title, image1440x810 = _a.image1440x810, image144x81 = _a.image144x81, ctaText = _a.ctaText, ctaUrl = _a.ctaUrl, children = _a.children;
|
|
22877
|
-
return (React__default.default.createElement(Container$
|
|
22884
|
+
return (React__default.default.createElement(Container$J, null,
|
|
22878
22885
|
React__default.default.createElement(ImageLink, { href: ctaUrl, title: ctaText },
|
|
22879
22886
|
React__default.default.createElement(ResponsiveImage, { imageSmall: image144x81, imageLarge: image1440x810, imageAltText: ctaText, smallWidth: "144", largeWidth: "1440", ratio: "16by9", objectFit: "cover" })),
|
|
22880
22887
|
React__default.default.createElement(Wrapper$4, null,
|
|
22881
|
-
React__default.default.createElement(Heading, { text: title }),
|
|
22882
|
-
React__default.default.createElement(Content$
|
|
22888
|
+
React__default.default.createElement(Heading$1, { text: title }),
|
|
22889
|
+
React__default.default.createElement(Content$5, null, children),
|
|
22883
22890
|
React__default.default.createElement(CTA, { href: ctaUrl }, ctaText))));
|
|
22884
22891
|
};
|
|
22885
22892
|
|
|
@@ -22992,7 +22999,7 @@ const PromoText = styled__default.default.div`
|
|
|
22992
22999
|
/**
|
|
22993
23000
|
* The headline of the tile
|
|
22994
23001
|
*/
|
|
22995
|
-
const PromoHeadline = styled__default.default(Heading)`
|
|
23002
|
+
const PromoHeadline = styled__default.default(Heading$1)`
|
|
22996
23003
|
margin-top: 5px;
|
|
22997
23004
|
`;
|
|
22998
23005
|
|
|
@@ -23085,7 +23092,7 @@ var Promotions = function (_a) {
|
|
|
23085
23092
|
numberOfPromos > 1 && React__default.default.createElement(PromoBlock, { promos: promos.slice(1, numberOfPromos) })));
|
|
23086
23093
|
};
|
|
23087
23094
|
|
|
23088
|
-
const Container$
|
|
23095
|
+
const Container$I = styled__default.default.div`
|
|
23089
23096
|
padding: 0;
|
|
23090
23097
|
margin: ${(props) => props.theme.theme_vars.spacingSizes.medium} 0;
|
|
23091
23098
|
position: relative;
|
|
@@ -23136,7 +23143,7 @@ const Inner = styled__default.default.div`
|
|
|
23136
23143
|
}
|
|
23137
23144
|
`;
|
|
23138
23145
|
|
|
23139
|
-
const Container$
|
|
23146
|
+
const Container$H = styled__default.default.div`
|
|
23140
23147
|
display: block;
|
|
23141
23148
|
|
|
23142
23149
|
input[type='text'] {
|
|
@@ -23147,7 +23154,7 @@ const Container$G = styled__default.default.div`
|
|
|
23147
23154
|
}
|
|
23148
23155
|
`;
|
|
23149
23156
|
|
|
23150
|
-
const Label$
|
|
23157
|
+
const Label$4 = styled__default.default.label`
|
|
23151
23158
|
font-weight: bold;
|
|
23152
23159
|
font-family: ${(props) => props.theme.theme_vars.fontstack};
|
|
23153
23160
|
${(props) =>
|
|
@@ -23209,10 +23216,10 @@ const SubmitButton = styled__default.default.input`
|
|
|
23209
23216
|
* If value is set then treat as controlled component
|
|
23210
23217
|
*/
|
|
23211
23218
|
var Input = function (_a) {
|
|
23212
|
-
var _b = _a.type, type = _b === void 0 ? 'text' : _b, _c = _a.placeholder, placeholder = _c === void 0 ? '' : _c, _d = _a.isErrored, isErrored = _d === void 0 ? false : _d, errorText = _a.errorText, name = _a.name, maxLength = _a.maxLength, defaultValue = _a.defaultValue, onChange = _a.onChange, id = _a.id, value = _a.value;
|
|
23219
|
+
var _b = _a.type, type = _b === void 0 ? 'text' : _b, _c = _a.placeholder, placeholder = _c === void 0 ? '' : _c, _d = _a.isErrored, isErrored = _d === void 0 ? false : _d, errorText = _a.errorText, name = _a.name, maxLength = _a.maxLength, defaultValue = _a.defaultValue, onChange = _a.onChange, id = _a.id, value = _a.value, _e = _a.isFullWidth, isFullWidth = _e === void 0 ? false : _e;
|
|
23213
23220
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
23214
|
-
errorText && React__default.default.createElement(ErrorText$
|
|
23215
|
-
typeof value !== 'undefined' ? (React__default.default.createElement(StyledInput, { onChange: onChange, type: type, placeholder: placeholder, name: name, "$isErrored": isErrored, maxLength: maxLength, value: value, id: id })) : (React__default.default.createElement(StyledInput, { onChange: onChange, type: type, placeholder: placeholder, name: name, "$isErrored": isErrored, maxLength: maxLength, defaultValue: defaultValue, id: id }))));
|
|
23221
|
+
errorText && React__default.default.createElement(ErrorText$2, null, errorText),
|
|
23222
|
+
typeof value !== 'undefined' ? (React__default.default.createElement(StyledInput, { onChange: onChange, type: type, placeholder: placeholder, name: name, "$isErrored": isErrored, maxLength: maxLength, value: value, id: id, "$isFullWidth": isFullWidth })) : (React__default.default.createElement(StyledInput, { onChange: onChange, type: type, placeholder: placeholder, name: name, "$isErrored": isErrored, maxLength: maxLength, defaultValue: defaultValue, id: id, "$isFullWidth": isFullWidth }))));
|
|
23216
23223
|
};
|
|
23217
23224
|
|
|
23218
23225
|
var CustomSearch = function (_a) {
|
|
@@ -23220,10 +23227,10 @@ var CustomSearch = function (_a) {
|
|
|
23220
23227
|
if (!id) {
|
|
23221
23228
|
id = React.useId();
|
|
23222
23229
|
}
|
|
23223
|
-
return (React__default.default.createElement(Container$
|
|
23230
|
+
return (React__default.default.createElement(Container$H, { "data-testid": "CustomSearch" },
|
|
23224
23231
|
React__default.default.createElement("form", { method: method, action: path, "aria-label": label },
|
|
23225
23232
|
React__default.default.createElement("div", { role: "search" },
|
|
23226
|
-
React__default.default.createElement(Label$
|
|
23233
|
+
React__default.default.createElement(Label$4, { htmlFor: id, "$hasHiddenLabel": hasHiddenLabel }, label),
|
|
23227
23234
|
React__default.default.createElement(InputWrapper$1, null,
|
|
23228
23235
|
React__default.default.createElement(Input, { name: fieldName, placeholder: placeholder, id: id }),
|
|
23229
23236
|
React__default.default.createElement(SubmitButton, { type: "submit", value: searchText }))))));
|
|
@@ -23234,13 +23241,13 @@ var SearchBox = function (_a) {
|
|
|
23234
23241
|
var searchInner = (React__default.default.createElement(Inner, null,
|
|
23235
23242
|
React__default.default.createElement(Row$1, null,
|
|
23236
23243
|
title && (React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
23237
|
-
React__default.default.createElement(Heading, { text: title, level: 2 }))),
|
|
23244
|
+
React__default.default.createElement(Heading$1, { text: title, level: 2 }))),
|
|
23238
23245
|
React__default.default.createElement(Column, { small: "full", medium: "full", large: searchBoxLink ? 'two-thirds' : 'full' },
|
|
23239
23246
|
React__default.default.createElement(CustomSearch, __assign$2({}, customSearch))),
|
|
23240
23247
|
searchBoxLink && (React__default.default.createElement(Column, { small: "full", medium: "full", large: "one-third" },
|
|
23241
23248
|
React__default.default.createElement(LinkContainer, null,
|
|
23242
23249
|
React__default.default.createElement(Button$4, { text: searchBoxLink.title, url: searchBoxLink.url, primary: searchBoxLinkIsPrimary })))))));
|
|
23243
|
-
return (React__default.default.createElement(Container$
|
|
23250
|
+
return (React__default.default.createElement(Container$I, { "data-testid": "SearchBox", "$hasImage": imageSmall && imageLarge },
|
|
23244
23251
|
imageSmall && imageLarge && (React__default.default.createElement(ResponsiveImage, { imageSmall: imageSmall, imageLarge: imageLarge, imageAltText: imageAltText, smallWidth: "400", largeWidth: "1200", ratio: "auto", objectFit: "cover" })),
|
|
23245
23252
|
searchInner));
|
|
23246
23253
|
};
|
|
@@ -23351,7 +23358,7 @@ const Title$6 = styled__default.default.div`
|
|
|
23351
23358
|
max-width: 960px;
|
|
23352
23359
|
}
|
|
23353
23360
|
`;
|
|
23354
|
-
const Content$
|
|
23361
|
+
const Content$4 = styled__default.default.div``;
|
|
23355
23362
|
|
|
23356
23363
|
/**
|
|
23357
23364
|
* Display text as a highlight or warning with a title
|
|
@@ -23360,7 +23367,7 @@ var WarningText = function (_a) {
|
|
|
23360
23367
|
var title = _a.title, _b = _a.isWarning, isWarning = _b === void 0 ? false : _b, children = _a.children;
|
|
23361
23368
|
return (React__default.default.createElement(WarningText$1, { "$isWarning": isWarning, "data-testid": "WarningText" },
|
|
23362
23369
|
React__default.default.createElement(Title$6, { "$isWarning": isWarning }, title),
|
|
23363
|
-
React__default.default.createElement(Content$
|
|
23370
|
+
React__default.default.createElement(Content$4, null, children)));
|
|
23364
23371
|
};
|
|
23365
23372
|
|
|
23366
23373
|
var WarningTextDisclaimer = function () {
|
|
@@ -23434,7 +23441,7 @@ var AccessibleLink = function (_a) {
|
|
|
23434
23441
|
})));
|
|
23435
23442
|
};
|
|
23436
23443
|
|
|
23437
|
-
const Container$
|
|
23444
|
+
const Container$G = styled__default.default.div`
|
|
23438
23445
|
padding: ${(props) => props.theme.theme_vars.spacingSizes.medium} 0;
|
|
23439
23446
|
background: ${(props) =>
|
|
23440
23447
|
props.$alertType === 'alert'
|
|
@@ -23565,7 +23572,7 @@ const handleContainerPadding = (noBackground, noPadding) => {
|
|
|
23565
23572
|
}
|
|
23566
23573
|
};
|
|
23567
23574
|
|
|
23568
|
-
const Container$
|
|
23575
|
+
const Container$F = styled__default.default.div`
|
|
23569
23576
|
background: ${(props) =>
|
|
23570
23577
|
props.$noBackground
|
|
23571
23578
|
? 'transparent'
|
|
@@ -23607,7 +23614,7 @@ const MaxWidth = styled__default.default.div`
|
|
|
23607
23614
|
*/
|
|
23608
23615
|
var MaxWidthContainer = function (_a) {
|
|
23609
23616
|
var children = _a.children, classes = _a.classes, _b = _a.noBackground, noBackground = _b === void 0 ? false : _b, _c = _a.noPadding, noPadding = _c === void 0 ? false : _c, _d = _a.overflowVisible, overflowVisible = _d === void 0 ? false : _d, props = __rest(_a, ["children", "classes", "noBackground", "noPadding", "overflowVisible"]);
|
|
23610
|
-
return (React__default.default.createElement(Container$
|
|
23617
|
+
return (React__default.default.createElement(Container$F, { "$noBackground": noBackground, "$noPadding": noPadding },
|
|
23611
23618
|
React__default.default.createElement(MaxWidth, __assign$2({ className: classes, "$overflowVisible": overflowVisible }, props), children)));
|
|
23612
23619
|
};
|
|
23613
23620
|
|
|
@@ -23678,7 +23685,7 @@ var AlertBanner = function (_a) {
|
|
|
23678
23685
|
setShowAlert(false);
|
|
23679
23686
|
};
|
|
23680
23687
|
return (showAlert &&
|
|
23681
|
-
notServer && (React__default.default.createElement(Container$
|
|
23688
|
+
notServer && (React__default.default.createElement(Container$G, { "$alertType": alertType, "data-testid": "AlertBanner" },
|
|
23682
23689
|
React__default.default.createElement(MaxWidthContainer, { noBackground: true },
|
|
23683
23690
|
React__default.default.createElement(InnerContainer$1, null,
|
|
23684
23691
|
React__default.default.createElement(BannerContentContainer, null,
|
|
@@ -23692,7 +23699,7 @@ var AlertBanner = function (_a) {
|
|
|
23692
23699
|
"Dismiss"))))));
|
|
23693
23700
|
};
|
|
23694
23701
|
|
|
23695
|
-
const Container$
|
|
23702
|
+
const Container$E = styled__default.default.a`
|
|
23696
23703
|
display: inline-block;
|
|
23697
23704
|
position: relative;
|
|
23698
23705
|
margin-top: 15px;
|
|
@@ -23751,10 +23758,10 @@ const Container$D = styled__default.default.a`
|
|
|
23751
23758
|
*/
|
|
23752
23759
|
var BackLink = function (_a) {
|
|
23753
23760
|
var link = _a.link, _b = _a.useHistory, useHistory = _b === void 0 ? false : _b;
|
|
23754
|
-
return (React__default.default.createElement(React__default.default.Fragment, null, useHistory ? (React__default.default.createElement(Container$
|
|
23761
|
+
return (React__default.default.createElement(React__default.default.Fragment, null, useHistory ? (React__default.default.createElement(Container$E, { onClick: function () { return history.back(); }, "data-testid": "BackLink", as: "button" }, "Back")) : (React__default.default.createElement(Container$E, { href: link, "data-testid": "BackLink" }, "Back"))));
|
|
23755
23762
|
};
|
|
23756
23763
|
|
|
23757
|
-
const Container$
|
|
23764
|
+
const Container$D = styled__default.default.div`
|
|
23758
23765
|
padding-top: 15px;
|
|
23759
23766
|
border-bottom: 1px solid ${(props) => props.theme.theme_vars.colours.grey}80;
|
|
23760
23767
|
margin-bottom: ${(props) => (props.$hasMargin ? props.theme.theme_vars.spacingSizes.large : 0)};
|
|
@@ -23822,14 +23829,14 @@ const BreadcrumbLink$1 = styled__default.default.a`
|
|
|
23822
23829
|
|
|
23823
23830
|
var Breadcrumbs = function (_a) {
|
|
23824
23831
|
var breadcrumbsArray = _a.breadcrumbsArray, _b = _a.hasMargin, hasMargin = _b === void 0 ? false : _b;
|
|
23825
|
-
return (React__default.default.createElement(Container$
|
|
23832
|
+
return (React__default.default.createElement(Container$D, { "$hasMargin": hasMargin, "data-testid": "Breadcrumbs" },
|
|
23826
23833
|
React__default.default.createElement(List$2, { as: breadcrumbsArray.length === 1 ? 'div' : 'ol' }, breadcrumbsArray.map(function (crumb) { return (React__default.default.createElement(Crumb, { key: crumb.title, as: breadcrumbsArray.length === 1 ? 'span' : 'li' }, React__default.default.createElement(React__default.default.Fragment, null,
|
|
23827
23834
|
React__default.default.createElement(BreadcrumbLink$1, { href: crumb.url, title: crumb.title }, crumb.title),
|
|
23828
23835
|
React__default.default.createElement(IconWrapper$4, null,
|
|
23829
23836
|
React__default.default.createElement(ChevronIcon, { direction: 'right', colourFill: "#C6C6C6" }))))); }))));
|
|
23830
23837
|
};
|
|
23831
23838
|
|
|
23832
|
-
const Container$
|
|
23839
|
+
const Container$C = styled__default.default.div`
|
|
23833
23840
|
display: block;
|
|
23834
23841
|
margin-bottom: ${(props) => props.theme.theme_vars.spacingSizes.large};
|
|
23835
23842
|
padding-bottom: ${(props) => props.theme.theme_vars.spacingSizes.large};
|
|
@@ -23877,12 +23884,12 @@ const CurrentPage = styled__default.default.span`
|
|
|
23877
23884
|
|
|
23878
23885
|
var Contents$1 = function (_a) {
|
|
23879
23886
|
var contents = _a.contents, _b = _a.currentPath, currentPath = _b === void 0 ? undefined : _b, _c = _a.title, title = _c === void 0 ? 'Contents' : _c;
|
|
23880
|
-
return (React__default.default.createElement(Container$
|
|
23881
|
-
React__default.default.createElement(Heading, { text: title, level: 2 }),
|
|
23887
|
+
return (React__default.default.createElement(Container$C, { "data-testid": "Contents" },
|
|
23888
|
+
React__default.default.createElement(Heading$1, { text: title, level: 2 }),
|
|
23882
23889
|
React__default.default.createElement(List$1, null, contents.map(function (content, index) { return (React__default.default.createElement(ListItem$1, { key: index }, content.url === currentPath ? (React__default.default.createElement(CurrentPage, null, content.title)) : (React__default.default.createElement(Link$2, { href: content.url, "$active": content.url === currentPath }, content.title)))); }))));
|
|
23883
23890
|
};
|
|
23884
23891
|
|
|
23885
|
-
const Container$
|
|
23892
|
+
const Container$B = styled__default.default.div`
|
|
23886
23893
|
display: block;
|
|
23887
23894
|
border-top: 1px solid ${(props) => props.theme.theme_vars.colours.grey}80;
|
|
23888
23895
|
margin: ${(props) => props.theme.theme_vars.spacingSizes.medium} 0;
|
|
@@ -23932,7 +23939,7 @@ var ContentsNavigation = function (_a) {
|
|
|
23932
23939
|
};
|
|
23933
23940
|
var nextPage = currentPage() < contents.length - 1 ? contents[currentPage() + 1] : undefined;
|
|
23934
23941
|
var previousPage = currentPage() !== 0 ? contents[currentPage() - 1] : undefined;
|
|
23935
|
-
return (React__default.default.createElement(Container$
|
|
23942
|
+
return (React__default.default.createElement(Container$B, { "data-testid": "ContentsNavigation" },
|
|
23936
23943
|
previousPage && (React__default.default.createElement(NavigationLink, { href: previousPage.url },
|
|
23937
23944
|
React__default.default.createElement(Arrow, null, "\u2190"),
|
|
23938
23945
|
React__default.default.createElement(LinkText, null,
|
|
@@ -23989,7 +23996,7 @@ var DisplayDate = function (_a) {
|
|
|
23989
23996
|
postText));
|
|
23990
23997
|
};
|
|
23991
23998
|
|
|
23992
|
-
const Container$
|
|
23999
|
+
const Container$A = styled__default.default.footer`
|
|
23993
24000
|
background-color: ${(props) => props.theme.theme_vars.colours.black};
|
|
23994
24001
|
padding: 25px 0;
|
|
23995
24002
|
`;
|
|
@@ -24174,7 +24181,7 @@ var ServiceIcon = function (_a) {
|
|
|
24174
24181
|
var Footer = function (_a) {
|
|
24175
24182
|
var _b = _a.footerLinksArray, footerLinksArray = _b === void 0 ? null : _b, _c = _a.year, year = _c === void 0 ? new Date().getFullYear() : _c;
|
|
24176
24183
|
var themeContext = React.useContext(styled.ThemeContext);
|
|
24177
|
-
return (React__default.default.createElement(Container$
|
|
24184
|
+
return (React__default.default.createElement(Container$A, { "data-testid": "Footer" },
|
|
24178
24185
|
React__default.default.createElement(StyledMaxWidthContainer$3, { noBackground: true },
|
|
24179
24186
|
React__default.default.createElement(FooterAlignment, null,
|
|
24180
24187
|
React__default.default.createElement("div", null,
|
|
@@ -24207,7 +24214,7 @@ var Footer = function (_a) {
|
|
|
24207
24214
|
: '' }, themeContext.cardinal_name === 'north' ? (React__default.default.createElement(NorthWhiteLogo, null)) : themeContext.cardinal_name === 'west' ? (React__default.default.createElement(WestWhiteLogo, null)) : (React__default.default.createElement(GDSLogo, null)))))));
|
|
24208
24215
|
};
|
|
24209
24216
|
|
|
24210
|
-
const Container$
|
|
24217
|
+
const Container$z = styled__default.default.div`
|
|
24211
24218
|
background: ${(props) => (props.$hasBackground ? props.theme.theme_vars.colours.grey_light : 'transparent')};
|
|
24212
24219
|
padding: ${(props) => (props.$hasPadding ? '50px 0 20px' : '0')};
|
|
24213
24220
|
`;
|
|
@@ -24217,7 +24224,7 @@ const Container$y = styled__default.default.div`
|
|
|
24217
24224
|
*/
|
|
24218
24225
|
var FullWidthContainer = function (_a) {
|
|
24219
24226
|
var children = _a.children, _b = _a.hasBackground, hasBackground = _b === void 0 ? false : _b, _c = _a.hasPadding, hasPadding = _c === void 0 ? false : _c;
|
|
24220
|
-
return (React__default.default.createElement(Container$
|
|
24227
|
+
return (React__default.default.createElement(Container$z, { "$hasBackground": hasBackground, "$hasPadding": hasPadding, "data-testid": "FullWidthContainer" }, children));
|
|
24221
24228
|
};
|
|
24222
24229
|
|
|
24223
24230
|
/**
|
|
@@ -24249,7 +24256,7 @@ const headerThemeStyles = (props) => {
|
|
|
24249
24256
|
}
|
|
24250
24257
|
};
|
|
24251
24258
|
|
|
24252
|
-
const Container$
|
|
24259
|
+
const Container$y = styled__default.default.header`
|
|
24253
24260
|
font-family: ${(props) => props.theme.theme_vars.fontstack};
|
|
24254
24261
|
padding: 3px 0;
|
|
24255
24262
|
${headerThemeStyles}
|
|
@@ -24414,7 +24421,7 @@ var NorthColouredLogo = function () {
|
|
|
24414
24421
|
React__default.default.createElement("path", { fill: "#fff", d: "M0 0H974V327H0z" })))));
|
|
24415
24422
|
};
|
|
24416
24423
|
|
|
24417
|
-
const Container$
|
|
24424
|
+
const Container$x = styled__default.default.div`
|
|
24418
24425
|
${(props) => props.theme.fontStyles}
|
|
24419
24426
|
width: calc(100% - ${(props) => (props.$isLarge ? '5rem' : '3rem')});
|
|
24420
24427
|
`;
|
|
@@ -24568,7 +24575,7 @@ var Searchbar = function (_a) {
|
|
|
24568
24575
|
/**
|
|
24569
24576
|
* Render the component
|
|
24570
24577
|
*/
|
|
24571
|
-
return (React__default.default.createElement(Container$
|
|
24578
|
+
return (React__default.default.createElement(Container$x, { "data-testid": "Searchbar", "$isLarge": isLarge },
|
|
24572
24579
|
React__default.default.createElement("form", { onSubmit: handleSubmit },
|
|
24573
24580
|
React__default.default.createElement("div", { role: "search" },
|
|
24574
24581
|
React__default.default.createElement(InputWrapper, null,
|
|
@@ -24623,7 +24630,7 @@ var Header = function (_a) {
|
|
|
24623
24630
|
}
|
|
24624
24631
|
};
|
|
24625
24632
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
24626
|
-
React__default.default.createElement(Container$
|
|
24633
|
+
React__default.default.createElement(Container$y, __assign$2({}, props, { "data-testid": "Header" }),
|
|
24627
24634
|
React__default.default.createElement(StyledMaxWidthContainer$2, { noBackground: true },
|
|
24628
24635
|
React__default.default.createElement(LogoWrapper, null,
|
|
24629
24636
|
React__default.default.createElement(HomeLink, { href: homeLink, title: "Home", id: "logo" }, themeLogos(themeContext.cardinal_name, themeContext.is_memorial))),
|
|
@@ -24643,7 +24650,7 @@ var Header = function (_a) {
|
|
|
24643
24650
|
* Hero image container with optional dark gradient for non-box mode
|
|
24644
24651
|
* Optimised for an image in 16:5 ratio on all but small width screens
|
|
24645
24652
|
*/
|
|
24646
|
-
const Container$
|
|
24653
|
+
const Container$w = styled__default.default.div`
|
|
24647
24654
|
padding-bottom: 10px;
|
|
24648
24655
|
display: flex;
|
|
24649
24656
|
justify-content: center;
|
|
@@ -24742,7 +24749,7 @@ const Overlay = styled__default.default.div`
|
|
|
24742
24749
|
}
|
|
24743
24750
|
`;
|
|
24744
24751
|
|
|
24745
|
-
const Headline = styled__default.default(Heading)`
|
|
24752
|
+
const Headline = styled__default.default(Heading$1)`
|
|
24746
24753
|
margin: 0;
|
|
24747
24754
|
color: ${(props) =>
|
|
24748
24755
|
props.$backgroundBox ? props.theme.theme_vars.colours.black : props.theme.theme_vars.colours.white};
|
|
@@ -24761,7 +24768,7 @@ const Headline = styled__default.default(Heading)`
|
|
|
24761
24768
|
}
|
|
24762
24769
|
`;
|
|
24763
24770
|
|
|
24764
|
-
const Content$
|
|
24771
|
+
const Content$3 = styled__default.default.div`
|
|
24765
24772
|
margin-top: 10px;
|
|
24766
24773
|
p,
|
|
24767
24774
|
div {
|
|
@@ -24822,14 +24829,14 @@ const Search = styled__default.default.div`
|
|
|
24822
24829
|
*/
|
|
24823
24830
|
var HeroImage = function (_a) {
|
|
24824
24831
|
var headline = _a.headline, content = _a.content, callToActionText = _a.callToActionText, callToActionURL = _a.callToActionURL, _b = _a.callToActionIsPrimary, callToActionIsPrimary = _b === void 0 ? true : _b, _c = _a.backgroundBox, backgroundBox = _c === void 0 ? true : _c, imageLarge = _a.imageLarge, imageSmall = _a.imageSmall, imageAltText = _a.imageAltText, breadcrumb = _a.breadcrumb, customSearch = _a.customSearch;
|
|
24825
|
-
return (React__default.default.createElement(Container$
|
|
24832
|
+
return (React__default.default.createElement(Container$w, { "data-testid": "HeroImage" },
|
|
24826
24833
|
React__default.default.createElement(ImageContainer$3, { "$backgroundBox": backgroundBox },
|
|
24827
24834
|
React__default.default.createElement(ResponsiveImage, { imageSmall: imageSmall, imageLarge: imageLarge, imageAltText: imageAltText, smallWidth: "144", largeWidth: "1440", ratio: "auto", objectFit: "cover" })),
|
|
24828
24835
|
React__default.default.createElement(InnerContainer, null,
|
|
24829
24836
|
React__default.default.createElement(Overlay, { "$backgroundBox": backgroundBox, "data-testid": "HeroImageOverlay" },
|
|
24830
24837
|
breadcrumb && (React__default.default.createElement(BreadcrumbLink, { href: breadcrumb.url, "$backgroundBox": backgroundBox }, breadcrumb.title)),
|
|
24831
24838
|
headline && React__default.default.createElement(Headline, { level: 1, text: headline, "$backgroundBox": backgroundBox }),
|
|
24832
|
-
content && React__default.default.createElement(Content$
|
|
24839
|
+
content && React__default.default.createElement(Content$3, { dangerouslySetInnerHTML: { __html: sanitizeHtml$1(content) } }),
|
|
24833
24840
|
customSearch && (React__default.default.createElement(Search, null,
|
|
24834
24841
|
React__default.default.createElement(CustomSearch, __assign$2({}, customSearch)))),
|
|
24835
24842
|
callToActionURL && backgroundBox && (React__default.default.createElement(CallToAction, { url: callToActionURL, text: callToActionText, primary: callToActionIsPrimary })),
|
|
@@ -24846,7 +24853,7 @@ const Wrapper$3 = styled__default.default.header`
|
|
|
24846
24853
|
: props.theme.theme_vars.colours.white};
|
|
24847
24854
|
`;
|
|
24848
24855
|
|
|
24849
|
-
const Container$
|
|
24856
|
+
const Container$v = styled__default.default.div`
|
|
24850
24857
|
font-family: ${(props) => props.theme.theme_vars.fontstack};
|
|
24851
24858
|
overflow: hidden;
|
|
24852
24859
|
background: ${(props) => props.theme.theme_vars.colours.action}5A;
|
|
@@ -24982,7 +24989,7 @@ var HomeHero = function (_a) {
|
|
|
24982
24989
|
}, []);
|
|
24983
24990
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
24984
24991
|
React__default.default.createElement(Wrapper$3, null,
|
|
24985
|
-
React__default.default.createElement(Container$
|
|
24992
|
+
React__default.default.createElement(Container$v, { className: random !== 999 ? 'loaded' : 'loading' },
|
|
24986
24993
|
random !== 999 && (React__default.default.createElement(ResponsiveImage, { imageSmall: (_b = imagesArray[random].image144x81) !== null && _b !== void 0 ? _b : '', imageLarge: (_c = imagesArray[random].image1440x810) !== null && _c !== void 0 ? _c : '', imageAltText: (_d = imagesArray[random].imageAltText) !== null && _d !== void 0 ? _d : '', smallWidth: "144", largeWidth: "1440", ratio: "auto", objectFit: "cover" })),
|
|
24987
24994
|
React__default.default.createElement(StyledMaxWidthContainer$1, null,
|
|
24988
24995
|
React__default.default.createElement(MainBox, null,
|
|
@@ -25007,7 +25014,7 @@ const Wrapper$2 = styled__default.default.section`
|
|
|
25007
25014
|
padding-bottom: 0px;
|
|
25008
25015
|
`;
|
|
25009
25016
|
|
|
25010
|
-
const Container$
|
|
25017
|
+
const Container$u = styled__default.default.div`
|
|
25011
25018
|
font-family: ${(props) => props.theme.theme_vars.fontstack};
|
|
25012
25019
|
display: flex;
|
|
25013
25020
|
flex-wrap: wrap;
|
|
@@ -25138,7 +25145,7 @@ var MemorialHero = function (_a) {
|
|
|
25138
25145
|
React__default.default.createElement(HiddenH1, null,
|
|
25139
25146
|
themeContext.full_name,
|
|
25140
25147
|
" Council"),
|
|
25141
|
-
React__default.default.createElement(Container$
|
|
25148
|
+
React__default.default.createElement(Container$u, null,
|
|
25142
25149
|
React__default.default.createElement(Left, null,
|
|
25143
25150
|
children,
|
|
25144
25151
|
React__default.default.createElement(styled.ThemeProvider, { theme: theme }, councilServices)),
|
|
@@ -25167,7 +25174,7 @@ var NewsArticleDate = function (_a) {
|
|
|
25167
25174
|
const imageHeightMobile = 150;
|
|
25168
25175
|
const imageHeightDesktop = 200;
|
|
25169
25176
|
|
|
25170
|
-
const Container$
|
|
25177
|
+
const Container$t = styled__default.default.div`
|
|
25171
25178
|
${(props) => props.theme.fontStyles};
|
|
25172
25179
|
padding: 15px 0;
|
|
25173
25180
|
|
|
@@ -25305,8 +25312,8 @@ var NewsArticleFeaturedBlock = function (_a) {
|
|
|
25305
25312
|
var articles = _a.articles, _b = _a.withoutTitle, withoutTitle = _b === void 0 ? false : _b, _c = _a.viewAllLink, viewAllLink = _c === void 0 ? '/' : _c;
|
|
25306
25313
|
if (articles && articles.length > 0) {
|
|
25307
25314
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
25308
|
-
!withoutTitle && React__default.default.createElement(Heading, { text: "News articles and press releases" }),
|
|
25309
|
-
React__default.default.createElement(Container$
|
|
25315
|
+
!withoutTitle && React__default.default.createElement(Heading$1, { text: "News articles and press releases" }),
|
|
25316
|
+
React__default.default.createElement(Container$t, null,
|
|
25310
25317
|
React__default.default.createElement(Row$1, { isList: true }, articles.map(function (article) {
|
|
25311
25318
|
var _a;
|
|
25312
25319
|
return (React__default.default.createElement(Column, { isList: true, small: "full", medium: "one-half", large: "one-third", key: article.id },
|
|
@@ -25328,7 +25335,7 @@ var NewsArticleFeaturedBlock = function (_a) {
|
|
|
25328
25335
|
}
|
|
25329
25336
|
};
|
|
25330
25337
|
|
|
25331
|
-
const Container$
|
|
25338
|
+
const Container$s = styled__default.default.div`
|
|
25332
25339
|
/* margin-top: 50px; */
|
|
25333
25340
|
/* border: 1px solid red; */
|
|
25334
25341
|
|
|
@@ -25429,7 +25436,7 @@ const FilterHeading = styled__default.default.h2`
|
|
|
25429
25436
|
// display: block;
|
|
25430
25437
|
// overflow: hidden;
|
|
25431
25438
|
|
|
25432
|
-
const Container$
|
|
25439
|
+
const Container$r = styled__default.default.a`
|
|
25433
25440
|
${props => props.theme.linkStyles}
|
|
25434
25441
|
color: ${props => props.theme.theme_vars.colours.negative} !important;
|
|
25435
25442
|
font-weight: normal;
|
|
@@ -25458,7 +25465,7 @@ var RemoveAllFilters = function (_a) {
|
|
|
25458
25465
|
e.preventDefault();
|
|
25459
25466
|
removeParams(__spreadArray(__spreadArray([], NewsArticleFilterFields.removeFiltersList, true), ['page'], false));
|
|
25460
25467
|
};
|
|
25461
|
-
return (React__default.default.createElement(Container$
|
|
25468
|
+
return (React__default.default.createElement(Container$r, { "data-testid": "RemoveAllFilters", href: "#", onClick: removeAllFilters },
|
|
25462
25469
|
"Clear ",
|
|
25463
25470
|
searchValue.length > 0 && 'search term and ',
|
|
25464
25471
|
"filters",
|
|
@@ -25505,7 +25512,7 @@ var NewsArticleFilterAccordion = function (_a) {
|
|
|
25505
25512
|
section.isExpanded = false;
|
|
25506
25513
|
}
|
|
25507
25514
|
});
|
|
25508
|
-
return (React__default.default.createElement(Container$
|
|
25515
|
+
return (React__default.default.createElement(Container$s, { "data-testid": "NewsArticleFilterAccordion" },
|
|
25509
25516
|
React__default.default.createElement(ShowFiltersButton, { onClick: showFullscreenFilters, "aria-expanded": !!isFullScreen, "aria-controls": "PageFilters" },
|
|
25510
25517
|
"Show Search and filters",
|
|
25511
25518
|
count > 0 && " (".concat(count, ")")),
|
|
@@ -25565,7 +25572,7 @@ var NewsArticleImage = function (_a) {
|
|
|
25565
25572
|
imageCaption && React__default.default.createElement(Small, { itemprop: "copyrightHolder" }, imageCaption)));
|
|
25566
25573
|
};
|
|
25567
25574
|
|
|
25568
|
-
const Container$
|
|
25575
|
+
const Container$q = styled__default.default.div`
|
|
25569
25576
|
${(props) => props.theme.fontStyles};
|
|
25570
25577
|
`;
|
|
25571
25578
|
|
|
@@ -25684,7 +25691,7 @@ var NewsArticleList = function (_a) {
|
|
|
25684
25691
|
var results = _a.results;
|
|
25685
25692
|
var extractLength = 140;
|
|
25686
25693
|
if (results && results.length > 0) {
|
|
25687
|
-
return (React__default.default.createElement(Container$
|
|
25694
|
+
return (React__default.default.createElement(Container$q, { "data-testid": "NewsArticleList" },
|
|
25688
25695
|
React__default.default.createElement(Row$1, { isList: true }, results.map(function (article) {
|
|
25689
25696
|
var _a;
|
|
25690
25697
|
return (React__default.default.createElement(Column, { isList: true, small: "full", medium: "full", large: "full", key: article.id },
|
|
@@ -25701,12 +25708,12 @@ var NewsArticleList = function (_a) {
|
|
|
25701
25708
|
}))));
|
|
25702
25709
|
}
|
|
25703
25710
|
else {
|
|
25704
|
-
return (React__default.default.createElement(Container$
|
|
25711
|
+
return (React__default.default.createElement(Container$q, { "data-testid": "NewsArticleList" },
|
|
25705
25712
|
React__default.default.createElement(ResultInfo$3, null, "No results found")));
|
|
25706
25713
|
}
|
|
25707
25714
|
};
|
|
25708
25715
|
|
|
25709
|
-
const Container$
|
|
25716
|
+
const Container$p = styled__default.default.div`
|
|
25710
25717
|
${props => props.theme.fontStyles};
|
|
25711
25718
|
padding-bottom: 20px;
|
|
25712
25719
|
border-bottom: 1px solid ${props => props.theme.theme_vars.colours.grey};
|
|
@@ -25780,7 +25787,7 @@ const Preposition = styled__default.default.div`
|
|
|
25780
25787
|
font-size: 80%;
|
|
25781
25788
|
`;
|
|
25782
25789
|
|
|
25783
|
-
const Container$
|
|
25790
|
+
const Container$o = styled__default.default.span`
|
|
25784
25791
|
margin: 0 5px;
|
|
25785
25792
|
display: inline-block;
|
|
25786
25793
|
position: relative;
|
|
@@ -25841,7 +25848,7 @@ var RemovableTag = function (_a) {
|
|
|
25841
25848
|
var index = _a.index, preposition = _a.preposition, label = _a.label; _a.value; _a.param; var clickHandler = _a.clickHandler;
|
|
25842
25849
|
return (React__default.default.createElement(Wrapper$1, { "data-testid": "RemovableTag" },
|
|
25843
25850
|
index > 0 && preposition && React__default.default.createElement(Preposition, null, preposition),
|
|
25844
|
-
React__default.default.createElement(Container$
|
|
25851
|
+
React__default.default.createElement(Container$o, null,
|
|
25845
25852
|
React__default.default.createElement(Text, null, label),
|
|
25846
25853
|
React__default.default.createElement(Button$2, { "aria-label": "Remove filter ".concat(label), onClick: clickHandler }, "x"))));
|
|
25847
25854
|
};
|
|
@@ -25861,7 +25868,7 @@ var NewsArticleListHeader = function (_a) {
|
|
|
25861
25868
|
var removeFilterValue = function (param, value) {
|
|
25862
25869
|
removeValueFromParam(param, value);
|
|
25863
25870
|
};
|
|
25864
|
-
return (React__default.default.createElement(Container$
|
|
25871
|
+
return (React__default.default.createElement(Container$p, { "data-testid": "NewsArticleListHeader" },
|
|
25865
25872
|
React__default.default.createElement(LeftCol, null,
|
|
25866
25873
|
totalResults,
|
|
25867
25874
|
" article",
|
|
@@ -25915,7 +25922,7 @@ var NewsArticleOldBanner = function (_a) {
|
|
|
25915
25922
|
React__default.default.createElement("strong", null, "1 year old")));
|
|
25916
25923
|
};
|
|
25917
25924
|
|
|
25918
|
-
const Container$
|
|
25925
|
+
const Container$n = styled__default.default.main`
|
|
25919
25926
|
padding-top: 30px;
|
|
25920
25927
|
|
|
25921
25928
|
a {
|
|
@@ -26032,10 +26039,10 @@ const Container$m = styled__default.default.main`
|
|
|
26032
26039
|
*/
|
|
26033
26040
|
var PageMain = function (_a) {
|
|
26034
26041
|
var children = _a.children, classes = _a.classes, _b = _a.fullWidthText, fullWidthText = _b === void 0 ? false : _b, props = __rest(_a, ["children", "classes", "fullWidthText"]);
|
|
26035
|
-
return (React__default.default.createElement(Container$
|
|
26042
|
+
return (React__default.default.createElement(Container$n, __assign$2({ id: "main", className: classes, "$fullWidthText": fullWidthText }, props, { "data-testid": "PageMain" }), children));
|
|
26036
26043
|
};
|
|
26037
26044
|
|
|
26038
|
-
const Container$
|
|
26045
|
+
const Container$m = styled__default.default.aside`
|
|
26039
26046
|
padding-top: 30px;
|
|
26040
26047
|
`;
|
|
26041
26048
|
|
|
@@ -26044,10 +26051,10 @@ const Container$l = styled__default.default.aside`
|
|
|
26044
26051
|
*/
|
|
26045
26052
|
var PageSidebar = function (_a) {
|
|
26046
26053
|
var children = _a.children;
|
|
26047
|
-
return (React__default.default.createElement(Container$
|
|
26054
|
+
return (React__default.default.createElement(Container$m, { className: "sidebar" }, children));
|
|
26048
26055
|
};
|
|
26049
26056
|
|
|
26050
|
-
const Container$
|
|
26057
|
+
const Container$l = styled__default.default.div`
|
|
26051
26058
|
padding-top: 30px;
|
|
26052
26059
|
|
|
26053
26060
|
h1 {
|
|
@@ -26060,10 +26067,10 @@ const Container$k = styled__default.default.div`
|
|
|
26060
26067
|
*/
|
|
26061
26068
|
var PageTitle = function (_a) {
|
|
26062
26069
|
var children = _a.children, classes = _a.classes, props = __rest(_a, ["children", "classes"]);
|
|
26063
|
-
return (React__default.default.createElement(Container$
|
|
26070
|
+
return (React__default.default.createElement(Container$l, __assign$2({ "data-testid": "title", className: classes }, props), children));
|
|
26064
26071
|
};
|
|
26065
26072
|
|
|
26066
|
-
const Container$
|
|
26073
|
+
const Container$k = styled__default.default.div`
|
|
26067
26074
|
@media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.m}) {
|
|
26068
26075
|
display: flex;
|
|
26069
26076
|
flex-wrap: wrap;
|
|
@@ -26105,7 +26112,7 @@ const Container$j = styled__default.default.div`
|
|
|
26105
26112
|
*/
|
|
26106
26113
|
var PageWithSidebarContainer = function (_a) {
|
|
26107
26114
|
var _b = _a.sidebarLeft, sidebarLeft = _b === void 0 ? false : _b, children = _a.children;
|
|
26108
|
-
return React__default.default.createElement(Container$
|
|
26115
|
+
return React__default.default.createElement(Container$k, { "$sidebarLeft": sidebarLeft }, children);
|
|
26109
26116
|
};
|
|
26110
26117
|
|
|
26111
26118
|
const backgroundDecider = props => {
|
|
@@ -26124,14 +26131,14 @@ const backgroundDecider = props => {
|
|
|
26124
26131
|
};
|
|
26125
26132
|
|
|
26126
26133
|
|
|
26127
|
-
const Container$
|
|
26134
|
+
const Container$j = styled__default.default.div`
|
|
26128
26135
|
${backgroundDecider};
|
|
26129
26136
|
padding-top: 1.5em;
|
|
26130
26137
|
`;
|
|
26131
26138
|
|
|
26132
26139
|
var PageWrapper = function (_a) {
|
|
26133
26140
|
var colour = _a.colour, children = _a.children;
|
|
26134
|
-
return (React__default.default.createElement(Container$
|
|
26141
|
+
return (React__default.default.createElement(Container$j, { "data-testid": "PageWrapper", colour: colour }, children));
|
|
26135
26142
|
};
|
|
26136
26143
|
|
|
26137
26144
|
const Wrapper = styled__default.default.div`
|
|
@@ -26197,119 +26204,2750 @@ var PhaseBanner = function (_a) {
|
|
|
26197
26204
|
React__default.default.createElement(PhaseText, null, "This site is new and we are improving it every day."))));
|
|
26198
26205
|
};
|
|
26199
26206
|
|
|
26200
|
-
|
|
26201
|
-
${(props) => props.theme.fontStyles};
|
|
26202
|
-
`;
|
|
26203
|
-
|
|
26204
|
-
const ResultInfo$2 = styled__default.default.div`
|
|
26205
|
-
font-weight: bold;
|
|
26206
|
-
margin: ${(props) => props.theme.theme_vars.spacingSizes.large} 0;
|
|
26207
|
-
`;
|
|
26208
|
-
|
|
26209
|
-
const Result = styled__default.default.div`
|
|
26210
|
-
margin-bottom: ${(props) => props.theme.theme_vars.spacingSizes.x_large};
|
|
26207
|
+
var isCheckBoxInput = (element) => element.type === 'checkbox';
|
|
26211
26208
|
|
|
26212
|
-
|
|
26213
|
-
margin-top: 0;
|
|
26214
|
-
}
|
|
26215
|
-
`;
|
|
26209
|
+
var isDateObject = (value) => value instanceof Date;
|
|
26216
26210
|
|
|
26217
|
-
|
|
26218
|
-
${(props) => props.theme.linkStyles};
|
|
26219
|
-
font-size: 1.2em;
|
|
26220
|
-
display: block;
|
|
26221
|
-
margin-bottom: 5px;
|
|
26222
|
-
`;
|
|
26211
|
+
var isNullOrUndefined = (value) => value == null;
|
|
26223
26212
|
|
|
26224
|
-
const
|
|
26225
|
-
|
|
26226
|
-
|
|
26227
|
-
|
|
26228
|
-
|
|
26229
|
-
props.theme.cardinal_name === 'west'
|
|
26230
|
-
? props.theme.theme_vars.colours.grey_darke
|
|
26231
|
-
: props.theme.theme_vars.colours.grey_darkest};
|
|
26232
|
-
margin-bottom: 3px !important;
|
|
26213
|
+
const isObjectType = (value) => typeof value === 'object';
|
|
26214
|
+
var isObject = (value) => !isNullOrUndefined(value) &&
|
|
26215
|
+
!Array.isArray(value) &&
|
|
26216
|
+
isObjectType(value) &&
|
|
26217
|
+
!isDateObject(value);
|
|
26233
26218
|
|
|
26234
|
-
|
|
26235
|
-
|
|
26236
|
-
|
|
26237
|
-
|
|
26238
|
-
|
|
26239
|
-
`;
|
|
26219
|
+
var getEventValue = (event) => isObject(event) && event.target
|
|
26220
|
+
? isCheckBoxInput(event.target)
|
|
26221
|
+
? event.target.checked
|
|
26222
|
+
: event.target.value
|
|
26223
|
+
: event;
|
|
26240
26224
|
|
|
26241
|
-
|
|
26242
|
-
margin-bottom: ${(props) => props.theme.theme_vars.spacingSizes.small};
|
|
26243
|
-
`;
|
|
26225
|
+
var getNodeParentName = (name) => name.substring(0, name.search(/\.\d+(\.|$)/)) || name;
|
|
26244
26226
|
|
|
26245
|
-
|
|
26246
|
-
font-size: 14px;
|
|
26247
|
-
font-size: 0.8rem;
|
|
26248
|
-
line-height: 1.3;
|
|
26227
|
+
var isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));
|
|
26249
26228
|
|
|
26250
|
-
|
|
26251
|
-
|
|
26252
|
-
|
|
26229
|
+
var isPlainObject = (tempObject) => {
|
|
26230
|
+
const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
|
|
26231
|
+
return (isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
|
|
26232
|
+
};
|
|
26253
26233
|
|
|
26254
|
-
|
|
26255
|
-
|
|
26256
|
-
|
|
26257
|
-
font-size: 0.8rem;
|
|
26258
|
-
line-height: 1.3;
|
|
26234
|
+
var isWeb = typeof window !== 'undefined' &&
|
|
26235
|
+
typeof window.HTMLElement !== 'undefined' &&
|
|
26236
|
+
typeof document !== 'undefined';
|
|
26259
26237
|
|
|
26260
|
-
|
|
26261
|
-
|
|
26238
|
+
function cloneObject(data) {
|
|
26239
|
+
let copy;
|
|
26240
|
+
const isArray = Array.isArray(data);
|
|
26241
|
+
if (data instanceof Date) {
|
|
26242
|
+
copy = new Date(data);
|
|
26262
26243
|
}
|
|
26263
|
-
|
|
26264
|
-
|
|
26265
|
-
@media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.s}) {
|
|
26266
|
-
font-size: 16px;
|
|
26267
|
-
font-size: 1rem;
|
|
26268
|
-
line-height: 1.4;
|
|
26269
|
-
|
|
26270
|
-
ul {
|
|
26271
|
-
font-size: 16px;
|
|
26272
|
-
font-size: 1rem;
|
|
26273
|
-
line-height: 1.4;
|
|
26244
|
+
else if (data instanceof Set) {
|
|
26245
|
+
copy = new Set(data);
|
|
26274
26246
|
}
|
|
26275
|
-
|
|
26276
|
-
|
|
26277
|
-
|
|
26278
|
-
|
|
26279
|
-
|
|
26280
|
-
|
|
26281
|
-
|
|
26282
|
-
|
|
26283
|
-
|
|
26284
|
-
|
|
26285
|
-
|
|
26286
|
-
|
|
26287
|
-
|
|
26247
|
+
else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) &&
|
|
26248
|
+
(isArray || isObject(data))) {
|
|
26249
|
+
copy = isArray ? [] : {};
|
|
26250
|
+
if (!isArray && !isPlainObject(data)) {
|
|
26251
|
+
copy = data;
|
|
26252
|
+
}
|
|
26253
|
+
else {
|
|
26254
|
+
for (const key in data) {
|
|
26255
|
+
if (data.hasOwnProperty(key)) {
|
|
26256
|
+
copy[key] = cloneObject(data[key]);
|
|
26257
|
+
}
|
|
26258
|
+
}
|
|
26259
|
+
}
|
|
26288
26260
|
}
|
|
26289
|
-
|
|
26290
|
-
|
|
26291
|
-
margin-bottom: 10px;
|
|
26292
|
-
padding-left: 0 !important;
|
|
26293
|
-
|
|
26294
|
-
&:before {
|
|
26295
|
-
content: none !important;
|
|
26261
|
+
else {
|
|
26262
|
+
return data;
|
|
26296
26263
|
}
|
|
26297
|
-
|
|
26264
|
+
return copy;
|
|
26265
|
+
}
|
|
26298
26266
|
|
|
26267
|
+
var compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];
|
|
26299
26268
|
|
|
26300
|
-
|
|
26301
|
-
${props => props.theme.linkStyles}
|
|
26269
|
+
var isUndefined = (val) => val === undefined;
|
|
26302
26270
|
|
|
26303
|
-
|
|
26304
|
-
|
|
26271
|
+
var get = (object, path, defaultValue) => {
|
|
26272
|
+
if (!path || !isObject(object)) {
|
|
26273
|
+
return defaultValue;
|
|
26305
26274
|
}
|
|
26275
|
+
const result = compact(path.split(/[,[\].]+?/)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], object);
|
|
26276
|
+
return isUndefined(result) || result === object
|
|
26277
|
+
? isUndefined(object[path])
|
|
26278
|
+
? defaultValue
|
|
26279
|
+
: object[path]
|
|
26280
|
+
: result;
|
|
26281
|
+
};
|
|
26306
26282
|
|
|
26307
|
-
|
|
26308
|
-
|
|
26309
|
-
|
|
26310
|
-
|
|
26311
|
-
|
|
26312
|
-
|
|
26283
|
+
var isBoolean = (value) => typeof value === 'boolean';
|
|
26284
|
+
|
|
26285
|
+
const EVENTS = {
|
|
26286
|
+
BLUR: 'blur',
|
|
26287
|
+
FOCUS_OUT: 'focusout',
|
|
26288
|
+
CHANGE: 'change',
|
|
26289
|
+
};
|
|
26290
|
+
const VALIDATION_MODE = {
|
|
26291
|
+
onBlur: 'onBlur',
|
|
26292
|
+
onChange: 'onChange',
|
|
26293
|
+
onSubmit: 'onSubmit',
|
|
26294
|
+
onTouched: 'onTouched',
|
|
26295
|
+
all: 'all',
|
|
26296
|
+
};
|
|
26297
|
+
const INPUT_VALIDATION_RULES = {
|
|
26298
|
+
max: 'max',
|
|
26299
|
+
min: 'min',
|
|
26300
|
+
maxLength: 'maxLength',
|
|
26301
|
+
minLength: 'minLength',
|
|
26302
|
+
pattern: 'pattern',
|
|
26303
|
+
required: 'required',
|
|
26304
|
+
validate: 'validate',
|
|
26305
|
+
};
|
|
26306
|
+
|
|
26307
|
+
const HookFormContext = React__default.default.createContext(null);
|
|
26308
|
+
/**
|
|
26309
|
+
* This custom hook allows you to access the form context. useFormContext is intended to be used in deeply nested structures, where it would become inconvenient to pass the context as a prop. To be used with {@link FormProvider}.
|
|
26310
|
+
*
|
|
26311
|
+
* @remarks
|
|
26312
|
+
* [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
|
|
26313
|
+
*
|
|
26314
|
+
* @returns return all useForm methods
|
|
26315
|
+
*
|
|
26316
|
+
* @example
|
|
26317
|
+
* ```tsx
|
|
26318
|
+
* function App() {
|
|
26319
|
+
* const methods = useForm();
|
|
26320
|
+
* const onSubmit = data => console.log(data);
|
|
26321
|
+
*
|
|
26322
|
+
* return (
|
|
26323
|
+
* <FormProvider {...methods} >
|
|
26324
|
+
* <form onSubmit={methods.handleSubmit(onSubmit)}>
|
|
26325
|
+
* <NestedInput />
|
|
26326
|
+
* <input type="submit" />
|
|
26327
|
+
* </form>
|
|
26328
|
+
* </FormProvider>
|
|
26329
|
+
* );
|
|
26330
|
+
* }
|
|
26331
|
+
*
|
|
26332
|
+
* function NestedInput() {
|
|
26333
|
+
* const { register } = useFormContext(); // retrieve all hook methods
|
|
26334
|
+
* return <input {...register("test")} />;
|
|
26335
|
+
* }
|
|
26336
|
+
* ```
|
|
26337
|
+
*/
|
|
26338
|
+
const useFormContext = () => React__default.default.useContext(HookFormContext);
|
|
26339
|
+
|
|
26340
|
+
var getProxyFormState = (formState, control, localProxyFormState, isRoot = true) => {
|
|
26341
|
+
const result = {
|
|
26342
|
+
defaultValues: control._defaultValues,
|
|
26343
|
+
};
|
|
26344
|
+
for (const key in formState) {
|
|
26345
|
+
Object.defineProperty(result, key, {
|
|
26346
|
+
get: () => {
|
|
26347
|
+
const _key = key;
|
|
26348
|
+
if (control._proxyFormState[_key] !== VALIDATION_MODE.all) {
|
|
26349
|
+
control._proxyFormState[_key] = !isRoot || VALIDATION_MODE.all;
|
|
26350
|
+
}
|
|
26351
|
+
localProxyFormState && (localProxyFormState[_key] = true);
|
|
26352
|
+
return formState[_key];
|
|
26353
|
+
},
|
|
26354
|
+
});
|
|
26355
|
+
}
|
|
26356
|
+
return result;
|
|
26357
|
+
};
|
|
26358
|
+
|
|
26359
|
+
var isEmptyObject = (value) => isObject(value) && !Object.keys(value).length;
|
|
26360
|
+
|
|
26361
|
+
var shouldRenderFormState = (formStateData, _proxyFormState, updateFormState, isRoot) => {
|
|
26362
|
+
updateFormState(formStateData);
|
|
26363
|
+
const { name, ...formState } = formStateData;
|
|
26364
|
+
return (isEmptyObject(formState) ||
|
|
26365
|
+
Object.keys(formState).length >= Object.keys(_proxyFormState).length ||
|
|
26366
|
+
Object.keys(formState).find((key) => _proxyFormState[key] ===
|
|
26367
|
+
(!isRoot || VALIDATION_MODE.all)));
|
|
26368
|
+
};
|
|
26369
|
+
|
|
26370
|
+
var convertToArrayPayload = (value) => (Array.isArray(value) ? value : [value]);
|
|
26371
|
+
|
|
26372
|
+
var shouldSubscribeByName = (name, signalName, exact) => !name ||
|
|
26373
|
+
!signalName ||
|
|
26374
|
+
name === signalName ||
|
|
26375
|
+
convertToArrayPayload(name).some((currentName) => currentName &&
|
|
26376
|
+
(exact
|
|
26377
|
+
? currentName === signalName
|
|
26378
|
+
: currentName.startsWith(signalName) ||
|
|
26379
|
+
signalName.startsWith(currentName)));
|
|
26380
|
+
|
|
26381
|
+
function useSubscribe(props) {
|
|
26382
|
+
const _props = React__default.default.useRef(props);
|
|
26383
|
+
_props.current = props;
|
|
26384
|
+
React__default.default.useEffect(() => {
|
|
26385
|
+
const subscription = !props.disabled &&
|
|
26386
|
+
_props.current.subject &&
|
|
26387
|
+
_props.current.subject.subscribe({
|
|
26388
|
+
next: _props.current.next,
|
|
26389
|
+
});
|
|
26390
|
+
return () => {
|
|
26391
|
+
subscription && subscription.unsubscribe();
|
|
26392
|
+
};
|
|
26393
|
+
}, [props.disabled]);
|
|
26394
|
+
}
|
|
26395
|
+
|
|
26396
|
+
/**
|
|
26397
|
+
* This custom hook allows you to subscribe to each form state, and isolate the re-render at the custom hook level. It has its scope in terms of form state subscription, so it would not affect other useFormState and useForm. Using this hook can reduce the re-render impact on large and complex form application.
|
|
26398
|
+
*
|
|
26399
|
+
* @remarks
|
|
26400
|
+
* [API](https://react-hook-form.com/docs/useformstate) • [Demo](https://codesandbox.io/s/useformstate-75xly)
|
|
26401
|
+
*
|
|
26402
|
+
* @param props - include options on specify fields to subscribe. {@link UseFormStateReturn}
|
|
26403
|
+
*
|
|
26404
|
+
* @example
|
|
26405
|
+
* ```tsx
|
|
26406
|
+
* function App() {
|
|
26407
|
+
* const { register, handleSubmit, control } = useForm({
|
|
26408
|
+
* defaultValues: {
|
|
26409
|
+
* firstName: "firstName"
|
|
26410
|
+
* }});
|
|
26411
|
+
* const { dirtyFields } = useFormState({
|
|
26412
|
+
* control
|
|
26413
|
+
* });
|
|
26414
|
+
* const onSubmit = (data) => console.log(data);
|
|
26415
|
+
*
|
|
26416
|
+
* return (
|
|
26417
|
+
* <form onSubmit={handleSubmit(onSubmit)}>
|
|
26418
|
+
* <input {...register("firstName")} placeholder="First Name" />
|
|
26419
|
+
* {dirtyFields.firstName && <p>Field is dirty.</p>}
|
|
26420
|
+
* <input type="submit" />
|
|
26421
|
+
* </form>
|
|
26422
|
+
* );
|
|
26423
|
+
* }
|
|
26424
|
+
* ```
|
|
26425
|
+
*/
|
|
26426
|
+
function useFormState(props) {
|
|
26427
|
+
const methods = useFormContext();
|
|
26428
|
+
const { control = methods.control, disabled, name, exact } = props || {};
|
|
26429
|
+
const [formState, updateFormState] = React__default.default.useState(control._formState);
|
|
26430
|
+
const _mounted = React__default.default.useRef(true);
|
|
26431
|
+
const _localProxyFormState = React__default.default.useRef({
|
|
26432
|
+
isDirty: false,
|
|
26433
|
+
isLoading: false,
|
|
26434
|
+
dirtyFields: false,
|
|
26435
|
+
touchedFields: false,
|
|
26436
|
+
isValidating: false,
|
|
26437
|
+
isValid: false,
|
|
26438
|
+
errors: false,
|
|
26439
|
+
});
|
|
26440
|
+
const _name = React__default.default.useRef(name);
|
|
26441
|
+
_name.current = name;
|
|
26442
|
+
useSubscribe({
|
|
26443
|
+
disabled,
|
|
26444
|
+
next: (value) => _mounted.current &&
|
|
26445
|
+
shouldSubscribeByName(_name.current, value.name, exact) &&
|
|
26446
|
+
shouldRenderFormState(value, _localProxyFormState.current, control._updateFormState) &&
|
|
26447
|
+
updateFormState({
|
|
26448
|
+
...control._formState,
|
|
26449
|
+
...value,
|
|
26450
|
+
}),
|
|
26451
|
+
subject: control._subjects.state,
|
|
26452
|
+
});
|
|
26453
|
+
React__default.default.useEffect(() => {
|
|
26454
|
+
_mounted.current = true;
|
|
26455
|
+
_localProxyFormState.current.isValid && control._updateValid(true);
|
|
26456
|
+
return () => {
|
|
26457
|
+
_mounted.current = false;
|
|
26458
|
+
};
|
|
26459
|
+
}, [control]);
|
|
26460
|
+
return getProxyFormState(formState, control, _localProxyFormState.current, false);
|
|
26461
|
+
}
|
|
26462
|
+
|
|
26463
|
+
var isString = (value) => typeof value === 'string';
|
|
26464
|
+
|
|
26465
|
+
var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) => {
|
|
26466
|
+
if (isString(names)) {
|
|
26467
|
+
isGlobal && _names.watch.add(names);
|
|
26468
|
+
return get(formValues, names, defaultValue);
|
|
26469
|
+
}
|
|
26470
|
+
if (Array.isArray(names)) {
|
|
26471
|
+
return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName), get(formValues, fieldName)));
|
|
26472
|
+
}
|
|
26473
|
+
isGlobal && (_names.watchAll = true);
|
|
26474
|
+
return formValues;
|
|
26475
|
+
};
|
|
26476
|
+
|
|
26477
|
+
/**
|
|
26478
|
+
* Custom hook to subscribe to field change and isolate re-rendering at the component level.
|
|
26479
|
+
*
|
|
26480
|
+
* @remarks
|
|
26481
|
+
*
|
|
26482
|
+
* [API](https://react-hook-form.com/docs/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)
|
|
26483
|
+
*
|
|
26484
|
+
* @example
|
|
26485
|
+
* ```tsx
|
|
26486
|
+
* const { control } = useForm();
|
|
26487
|
+
* const values = useWatch({
|
|
26488
|
+
* name: "fieldName"
|
|
26489
|
+
* control,
|
|
26490
|
+
* })
|
|
26491
|
+
* ```
|
|
26492
|
+
*/
|
|
26493
|
+
function useWatch(props) {
|
|
26494
|
+
const methods = useFormContext();
|
|
26495
|
+
const { control = methods.control, name, defaultValue, disabled, exact, } = props || {};
|
|
26496
|
+
const _name = React__default.default.useRef(name);
|
|
26497
|
+
_name.current = name;
|
|
26498
|
+
useSubscribe({
|
|
26499
|
+
disabled,
|
|
26500
|
+
subject: control._subjects.values,
|
|
26501
|
+
next: (formState) => {
|
|
26502
|
+
if (shouldSubscribeByName(_name.current, formState.name, exact)) {
|
|
26503
|
+
updateValue(cloneObject(generateWatchOutput(_name.current, control._names, formState.values || control._formValues, false, defaultValue)));
|
|
26504
|
+
}
|
|
26505
|
+
},
|
|
26506
|
+
});
|
|
26507
|
+
const [value, updateValue] = React__default.default.useState(control._getWatch(name, defaultValue));
|
|
26508
|
+
React__default.default.useEffect(() => control._removeUnmounted());
|
|
26509
|
+
return value;
|
|
26510
|
+
}
|
|
26511
|
+
|
|
26512
|
+
var isKey = (value) => /^\w*$/.test(value);
|
|
26513
|
+
|
|
26514
|
+
var stringToPath = (input) => compact(input.replace(/["|']|\]/g, '').split(/\.|\[/));
|
|
26515
|
+
|
|
26516
|
+
var set = (object, path, value) => {
|
|
26517
|
+
let index = -1;
|
|
26518
|
+
const tempPath = isKey(path) ? [path] : stringToPath(path);
|
|
26519
|
+
const length = tempPath.length;
|
|
26520
|
+
const lastIndex = length - 1;
|
|
26521
|
+
while (++index < length) {
|
|
26522
|
+
const key = tempPath[index];
|
|
26523
|
+
let newValue = value;
|
|
26524
|
+
if (index !== lastIndex) {
|
|
26525
|
+
const objValue = object[key];
|
|
26526
|
+
newValue =
|
|
26527
|
+
isObject(objValue) || Array.isArray(objValue)
|
|
26528
|
+
? objValue
|
|
26529
|
+
: !isNaN(+tempPath[index + 1])
|
|
26530
|
+
? []
|
|
26531
|
+
: {};
|
|
26532
|
+
}
|
|
26533
|
+
object[key] = newValue;
|
|
26534
|
+
object = object[key];
|
|
26535
|
+
}
|
|
26536
|
+
return object;
|
|
26537
|
+
};
|
|
26538
|
+
|
|
26539
|
+
/**
|
|
26540
|
+
* Custom hook to work with controlled component, this function provide you with both form and field level state. Re-render is isolated at the hook level.
|
|
26541
|
+
*
|
|
26542
|
+
* @remarks
|
|
26543
|
+
* [API](https://react-hook-form.com/docs/usecontroller) • [Demo](https://codesandbox.io/s/usecontroller-0o8px)
|
|
26544
|
+
*
|
|
26545
|
+
* @param props - the path name to the form field value, and validation rules.
|
|
26546
|
+
*
|
|
26547
|
+
* @returns field properties, field and form state. {@link UseControllerReturn}
|
|
26548
|
+
*
|
|
26549
|
+
* @example
|
|
26550
|
+
* ```tsx
|
|
26551
|
+
* function Input(props) {
|
|
26552
|
+
* const { field, fieldState, formState } = useController(props);
|
|
26553
|
+
* return (
|
|
26554
|
+
* <div>
|
|
26555
|
+
* <input {...field} placeholder={props.name} />
|
|
26556
|
+
* <p>{fieldState.isTouched && "Touched"}</p>
|
|
26557
|
+
* <p>{formState.isSubmitted ? "submitted" : ""}</p>
|
|
26558
|
+
* </div>
|
|
26559
|
+
* );
|
|
26560
|
+
* }
|
|
26561
|
+
* ```
|
|
26562
|
+
*/
|
|
26563
|
+
function useController(props) {
|
|
26564
|
+
const methods = useFormContext();
|
|
26565
|
+
const { name, disabled, control = methods.control, shouldUnregister } = props;
|
|
26566
|
+
const isArrayField = isNameInFieldArray(control._names.array, name);
|
|
26567
|
+
const value = useWatch({
|
|
26568
|
+
control,
|
|
26569
|
+
name,
|
|
26570
|
+
defaultValue: get(control._formValues, name, get(control._defaultValues, name, props.defaultValue)),
|
|
26571
|
+
exact: true,
|
|
26572
|
+
});
|
|
26573
|
+
const formState = useFormState({
|
|
26574
|
+
control,
|
|
26575
|
+
name,
|
|
26576
|
+
});
|
|
26577
|
+
const _registerProps = React__default.default.useRef(control.register(name, {
|
|
26578
|
+
...props.rules,
|
|
26579
|
+
value,
|
|
26580
|
+
...(isBoolean(props.disabled) ? { disabled: props.disabled } : {}),
|
|
26581
|
+
}));
|
|
26582
|
+
React__default.default.useEffect(() => {
|
|
26583
|
+
const _shouldUnregisterField = control._options.shouldUnregister || shouldUnregister;
|
|
26584
|
+
const updateMounted = (name, value) => {
|
|
26585
|
+
const field = get(control._fields, name);
|
|
26586
|
+
if (field) {
|
|
26587
|
+
field._f.mount = value;
|
|
26588
|
+
}
|
|
26589
|
+
};
|
|
26590
|
+
updateMounted(name, true);
|
|
26591
|
+
if (_shouldUnregisterField) {
|
|
26592
|
+
const value = cloneObject(get(control._options.defaultValues, name));
|
|
26593
|
+
set(control._defaultValues, name, value);
|
|
26594
|
+
if (isUndefined(get(control._formValues, name))) {
|
|
26595
|
+
set(control._formValues, name, value);
|
|
26596
|
+
}
|
|
26597
|
+
}
|
|
26598
|
+
return () => {
|
|
26599
|
+
(isArrayField
|
|
26600
|
+
? _shouldUnregisterField && !control._state.action
|
|
26601
|
+
: _shouldUnregisterField)
|
|
26602
|
+
? control.unregister(name)
|
|
26603
|
+
: updateMounted(name, false);
|
|
26604
|
+
};
|
|
26605
|
+
}, [name, control, isArrayField, shouldUnregister]);
|
|
26606
|
+
React__default.default.useEffect(() => {
|
|
26607
|
+
if (get(control._fields, name)) {
|
|
26608
|
+
control._updateDisabledField({
|
|
26609
|
+
disabled,
|
|
26610
|
+
fields: control._fields,
|
|
26611
|
+
name,
|
|
26612
|
+
value: get(control._fields, name)._f.value,
|
|
26613
|
+
});
|
|
26614
|
+
}
|
|
26615
|
+
}, [disabled, name, control]);
|
|
26616
|
+
return {
|
|
26617
|
+
field: {
|
|
26618
|
+
name,
|
|
26619
|
+
value,
|
|
26620
|
+
...(isBoolean(disabled) || isBoolean(formState.disabled)
|
|
26621
|
+
? { disabled: formState.disabled || disabled }
|
|
26622
|
+
: {}),
|
|
26623
|
+
onChange: React__default.default.useCallback((event) => _registerProps.current.onChange({
|
|
26624
|
+
target: {
|
|
26625
|
+
value: getEventValue(event),
|
|
26626
|
+
name: name,
|
|
26627
|
+
},
|
|
26628
|
+
type: EVENTS.CHANGE,
|
|
26629
|
+
}), [name]),
|
|
26630
|
+
onBlur: React__default.default.useCallback(() => _registerProps.current.onBlur({
|
|
26631
|
+
target: {
|
|
26632
|
+
value: get(control._formValues, name),
|
|
26633
|
+
name: name,
|
|
26634
|
+
},
|
|
26635
|
+
type: EVENTS.BLUR,
|
|
26636
|
+
}), [name, control]),
|
|
26637
|
+
ref: (elm) => {
|
|
26638
|
+
const field = get(control._fields, name);
|
|
26639
|
+
if (field && elm) {
|
|
26640
|
+
field._f.ref = {
|
|
26641
|
+
focus: () => elm.focus(),
|
|
26642
|
+
select: () => elm.select(),
|
|
26643
|
+
setCustomValidity: (message) => elm.setCustomValidity(message),
|
|
26644
|
+
reportValidity: () => elm.reportValidity(),
|
|
26645
|
+
};
|
|
26646
|
+
}
|
|
26647
|
+
},
|
|
26648
|
+
},
|
|
26649
|
+
formState,
|
|
26650
|
+
fieldState: Object.defineProperties({}, {
|
|
26651
|
+
invalid: {
|
|
26652
|
+
enumerable: true,
|
|
26653
|
+
get: () => !!get(formState.errors, name),
|
|
26654
|
+
},
|
|
26655
|
+
isDirty: {
|
|
26656
|
+
enumerable: true,
|
|
26657
|
+
get: () => !!get(formState.dirtyFields, name),
|
|
26658
|
+
},
|
|
26659
|
+
isTouched: {
|
|
26660
|
+
enumerable: true,
|
|
26661
|
+
get: () => !!get(formState.touchedFields, name),
|
|
26662
|
+
},
|
|
26663
|
+
error: {
|
|
26664
|
+
enumerable: true,
|
|
26665
|
+
get: () => get(formState.errors, name),
|
|
26666
|
+
},
|
|
26667
|
+
}),
|
|
26668
|
+
};
|
|
26669
|
+
}
|
|
26670
|
+
|
|
26671
|
+
/**
|
|
26672
|
+
* Component based on `useController` hook to work with controlled component.
|
|
26673
|
+
*
|
|
26674
|
+
* @remarks
|
|
26675
|
+
* [API](https://react-hook-form.com/docs/usecontroller/controller) • [Demo](https://codesandbox.io/s/react-hook-form-v6-controller-ts-jwyzw) • [Video](https://www.youtube.com/watch?v=N2UNk_UCVyA)
|
|
26676
|
+
*
|
|
26677
|
+
* @param props - the path name to the form field value, and validation rules.
|
|
26678
|
+
*
|
|
26679
|
+
* @returns provide field handler functions, field and form state.
|
|
26680
|
+
*
|
|
26681
|
+
* @example
|
|
26682
|
+
* ```tsx
|
|
26683
|
+
* function App() {
|
|
26684
|
+
* const { control } = useForm<FormValues>({
|
|
26685
|
+
* defaultValues: {
|
|
26686
|
+
* test: ""
|
|
26687
|
+
* }
|
|
26688
|
+
* });
|
|
26689
|
+
*
|
|
26690
|
+
* return (
|
|
26691
|
+
* <form>
|
|
26692
|
+
* <Controller
|
|
26693
|
+
* control={control}
|
|
26694
|
+
* name="test"
|
|
26695
|
+
* render={({ field: { onChange, onBlur, value, ref }, formState, fieldState }) => (
|
|
26696
|
+
* <>
|
|
26697
|
+
* <input
|
|
26698
|
+
* onChange={onChange} // send value to hook form
|
|
26699
|
+
* onBlur={onBlur} // notify when input is touched
|
|
26700
|
+
* value={value} // return updated value
|
|
26701
|
+
* ref={ref} // set ref for focus management
|
|
26702
|
+
* />
|
|
26703
|
+
* <p>{formState.isSubmitted ? "submitted" : ""}</p>
|
|
26704
|
+
* <p>{fieldState.isTouched ? "touched" : ""}</p>
|
|
26705
|
+
* </>
|
|
26706
|
+
* )}
|
|
26707
|
+
* />
|
|
26708
|
+
* </form>
|
|
26709
|
+
* );
|
|
26710
|
+
* }
|
|
26711
|
+
* ```
|
|
26712
|
+
*/
|
|
26713
|
+
const Controller = (props) => props.render(useController(props));
|
|
26714
|
+
|
|
26715
|
+
var appendErrors = (name, validateAllFieldCriteria, errors, type, message) => validateAllFieldCriteria
|
|
26716
|
+
? {
|
|
26717
|
+
...errors[name],
|
|
26718
|
+
types: {
|
|
26719
|
+
...(errors[name] && errors[name].types ? errors[name].types : {}),
|
|
26720
|
+
[type]: message || true,
|
|
26721
|
+
},
|
|
26722
|
+
}
|
|
26723
|
+
: {};
|
|
26724
|
+
|
|
26725
|
+
var getValidationModes = (mode) => ({
|
|
26726
|
+
isOnSubmit: !mode || mode === VALIDATION_MODE.onSubmit,
|
|
26727
|
+
isOnBlur: mode === VALIDATION_MODE.onBlur,
|
|
26728
|
+
isOnChange: mode === VALIDATION_MODE.onChange,
|
|
26729
|
+
isOnAll: mode === VALIDATION_MODE.all,
|
|
26730
|
+
isOnTouch: mode === VALIDATION_MODE.onTouched,
|
|
26731
|
+
});
|
|
26732
|
+
|
|
26733
|
+
var isWatched = (name, _names, isBlurEvent) => !isBlurEvent &&
|
|
26734
|
+
(_names.watchAll ||
|
|
26735
|
+
_names.watch.has(name) ||
|
|
26736
|
+
[..._names.watch].some((watchName) => name.startsWith(watchName) &&
|
|
26737
|
+
/^\.\w+/.test(name.slice(watchName.length))));
|
|
26738
|
+
|
|
26739
|
+
const iterateFieldsByAction = (fields, action, fieldsNames, abortEarly) => {
|
|
26740
|
+
for (const key of fieldsNames || Object.keys(fields)) {
|
|
26741
|
+
const field = get(fields, key);
|
|
26742
|
+
if (field) {
|
|
26743
|
+
const { _f, ...currentField } = field;
|
|
26744
|
+
if (_f) {
|
|
26745
|
+
if (_f.refs && _f.refs[0] && action(_f.refs[0], key) && !abortEarly) {
|
|
26746
|
+
break;
|
|
26747
|
+
}
|
|
26748
|
+
else if (_f.ref && action(_f.ref, _f.name) && !abortEarly) {
|
|
26749
|
+
break;
|
|
26750
|
+
}
|
|
26751
|
+
else {
|
|
26752
|
+
iterateFieldsByAction(currentField, action);
|
|
26753
|
+
}
|
|
26754
|
+
}
|
|
26755
|
+
else if (isObject(currentField)) {
|
|
26756
|
+
iterateFieldsByAction(currentField, action);
|
|
26757
|
+
}
|
|
26758
|
+
}
|
|
26759
|
+
}
|
|
26760
|
+
};
|
|
26761
|
+
|
|
26762
|
+
var updateFieldArrayRootError = (errors, error, name) => {
|
|
26763
|
+
const fieldArrayErrors = compact(get(errors, name));
|
|
26764
|
+
set(fieldArrayErrors, 'root', error[name]);
|
|
26765
|
+
set(errors, name, fieldArrayErrors);
|
|
26766
|
+
return errors;
|
|
26767
|
+
};
|
|
26768
|
+
|
|
26769
|
+
var isFileInput = (element) => element.type === 'file';
|
|
26770
|
+
|
|
26771
|
+
var isFunction = (value) => typeof value === 'function';
|
|
26772
|
+
|
|
26773
|
+
var isHTMLElement = (value) => {
|
|
26774
|
+
if (!isWeb) {
|
|
26775
|
+
return false;
|
|
26776
|
+
}
|
|
26777
|
+
const owner = value ? value.ownerDocument : 0;
|
|
26778
|
+
return (value instanceof
|
|
26779
|
+
(owner && owner.defaultView ? owner.defaultView.HTMLElement : HTMLElement));
|
|
26780
|
+
};
|
|
26781
|
+
|
|
26782
|
+
var isMessage = (value) => isString(value);
|
|
26783
|
+
|
|
26784
|
+
var isRadioInput = (element) => element.type === 'radio';
|
|
26785
|
+
|
|
26786
|
+
var isRegex = (value) => value instanceof RegExp;
|
|
26787
|
+
|
|
26788
|
+
const defaultResult = {
|
|
26789
|
+
value: false,
|
|
26790
|
+
isValid: false,
|
|
26791
|
+
};
|
|
26792
|
+
const validResult = { value: true, isValid: true };
|
|
26793
|
+
var getCheckboxValue = (options) => {
|
|
26794
|
+
if (Array.isArray(options)) {
|
|
26795
|
+
if (options.length > 1) {
|
|
26796
|
+
const values = options
|
|
26797
|
+
.filter((option) => option && option.checked && !option.disabled)
|
|
26798
|
+
.map((option) => option.value);
|
|
26799
|
+
return { value: values, isValid: !!values.length };
|
|
26800
|
+
}
|
|
26801
|
+
return options[0].checked && !options[0].disabled
|
|
26802
|
+
? // @ts-expect-error expected to work in the browser
|
|
26803
|
+
options[0].attributes && !isUndefined(options[0].attributes.value)
|
|
26804
|
+
? isUndefined(options[0].value) || options[0].value === ''
|
|
26805
|
+
? validResult
|
|
26806
|
+
: { value: options[0].value, isValid: true }
|
|
26807
|
+
: validResult
|
|
26808
|
+
: defaultResult;
|
|
26809
|
+
}
|
|
26810
|
+
return defaultResult;
|
|
26811
|
+
};
|
|
26812
|
+
|
|
26813
|
+
const defaultReturn = {
|
|
26814
|
+
isValid: false,
|
|
26815
|
+
value: null,
|
|
26816
|
+
};
|
|
26817
|
+
var getRadioValue = (options) => Array.isArray(options)
|
|
26818
|
+
? options.reduce((previous, option) => option && option.checked && !option.disabled
|
|
26819
|
+
? {
|
|
26820
|
+
isValid: true,
|
|
26821
|
+
value: option.value,
|
|
26822
|
+
}
|
|
26823
|
+
: previous, defaultReturn)
|
|
26824
|
+
: defaultReturn;
|
|
26825
|
+
|
|
26826
|
+
function getValidateError(result, ref, type = 'validate') {
|
|
26827
|
+
if (isMessage(result) ||
|
|
26828
|
+
(Array.isArray(result) && result.every(isMessage)) ||
|
|
26829
|
+
(isBoolean(result) && !result)) {
|
|
26830
|
+
return {
|
|
26831
|
+
type,
|
|
26832
|
+
message: isMessage(result) ? result : '',
|
|
26833
|
+
ref,
|
|
26834
|
+
};
|
|
26835
|
+
}
|
|
26836
|
+
}
|
|
26837
|
+
|
|
26838
|
+
var getValueAndMessage = (validationData) => isObject(validationData) && !isRegex(validationData)
|
|
26839
|
+
? validationData
|
|
26840
|
+
: {
|
|
26841
|
+
value: validationData,
|
|
26842
|
+
message: '',
|
|
26843
|
+
};
|
|
26844
|
+
|
|
26845
|
+
var validateField = async (field, formValues, validateAllFieldCriteria, shouldUseNativeValidation, isFieldArray) => {
|
|
26846
|
+
const { ref, refs, required, maxLength, minLength, min, max, pattern, validate, name, valueAsNumber, mount, disabled, } = field._f;
|
|
26847
|
+
const inputValue = get(formValues, name);
|
|
26848
|
+
if (!mount || disabled) {
|
|
26849
|
+
return {};
|
|
26850
|
+
}
|
|
26851
|
+
const inputRef = refs ? refs[0] : ref;
|
|
26852
|
+
const setCustomValidity = (message) => {
|
|
26853
|
+
if (shouldUseNativeValidation && inputRef.reportValidity) {
|
|
26854
|
+
inputRef.setCustomValidity(isBoolean(message) ? '' : message || '');
|
|
26855
|
+
inputRef.reportValidity();
|
|
26856
|
+
}
|
|
26857
|
+
};
|
|
26858
|
+
const error = {};
|
|
26859
|
+
const isRadio = isRadioInput(ref);
|
|
26860
|
+
const isCheckBox = isCheckBoxInput(ref);
|
|
26861
|
+
const isRadioOrCheckbox = isRadio || isCheckBox;
|
|
26862
|
+
const isEmpty = ((valueAsNumber || isFileInput(ref)) &&
|
|
26863
|
+
isUndefined(ref.value) &&
|
|
26864
|
+
isUndefined(inputValue)) ||
|
|
26865
|
+
(isHTMLElement(ref) && ref.value === '') ||
|
|
26866
|
+
inputValue === '' ||
|
|
26867
|
+
(Array.isArray(inputValue) && !inputValue.length);
|
|
26868
|
+
const appendErrorsCurry = appendErrors.bind(null, name, validateAllFieldCriteria, error);
|
|
26869
|
+
const getMinMaxMessage = (exceedMax, maxLengthMessage, minLengthMessage, maxType = INPUT_VALIDATION_RULES.maxLength, minType = INPUT_VALIDATION_RULES.minLength) => {
|
|
26870
|
+
const message = exceedMax ? maxLengthMessage : minLengthMessage;
|
|
26871
|
+
error[name] = {
|
|
26872
|
+
type: exceedMax ? maxType : minType,
|
|
26873
|
+
message,
|
|
26874
|
+
ref,
|
|
26875
|
+
...appendErrorsCurry(exceedMax ? maxType : minType, message),
|
|
26876
|
+
};
|
|
26877
|
+
};
|
|
26878
|
+
if (isFieldArray
|
|
26879
|
+
? !Array.isArray(inputValue) || !inputValue.length
|
|
26880
|
+
: required &&
|
|
26881
|
+
((!isRadioOrCheckbox && (isEmpty || isNullOrUndefined(inputValue))) ||
|
|
26882
|
+
(isBoolean(inputValue) && !inputValue) ||
|
|
26883
|
+
(isCheckBox && !getCheckboxValue(refs).isValid) ||
|
|
26884
|
+
(isRadio && !getRadioValue(refs).isValid))) {
|
|
26885
|
+
const { value, message } = isMessage(required)
|
|
26886
|
+
? { value: !!required, message: required }
|
|
26887
|
+
: getValueAndMessage(required);
|
|
26888
|
+
if (value) {
|
|
26889
|
+
error[name] = {
|
|
26890
|
+
type: INPUT_VALIDATION_RULES.required,
|
|
26891
|
+
message,
|
|
26892
|
+
ref: inputRef,
|
|
26893
|
+
...appendErrorsCurry(INPUT_VALIDATION_RULES.required, message),
|
|
26894
|
+
};
|
|
26895
|
+
if (!validateAllFieldCriteria) {
|
|
26896
|
+
setCustomValidity(message);
|
|
26897
|
+
return error;
|
|
26898
|
+
}
|
|
26899
|
+
}
|
|
26900
|
+
}
|
|
26901
|
+
if (!isEmpty && (!isNullOrUndefined(min) || !isNullOrUndefined(max))) {
|
|
26902
|
+
let exceedMax;
|
|
26903
|
+
let exceedMin;
|
|
26904
|
+
const maxOutput = getValueAndMessage(max);
|
|
26905
|
+
const minOutput = getValueAndMessage(min);
|
|
26906
|
+
if (!isNullOrUndefined(inputValue) && !isNaN(inputValue)) {
|
|
26907
|
+
const valueNumber = ref.valueAsNumber ||
|
|
26908
|
+
(inputValue ? +inputValue : inputValue);
|
|
26909
|
+
if (!isNullOrUndefined(maxOutput.value)) {
|
|
26910
|
+
exceedMax = valueNumber > maxOutput.value;
|
|
26911
|
+
}
|
|
26912
|
+
if (!isNullOrUndefined(minOutput.value)) {
|
|
26913
|
+
exceedMin = valueNumber < minOutput.value;
|
|
26914
|
+
}
|
|
26915
|
+
}
|
|
26916
|
+
else {
|
|
26917
|
+
const valueDate = ref.valueAsDate || new Date(inputValue);
|
|
26918
|
+
const convertTimeToDate = (time) => new Date(new Date().toDateString() + ' ' + time);
|
|
26919
|
+
const isTime = ref.type == 'time';
|
|
26920
|
+
const isWeek = ref.type == 'week';
|
|
26921
|
+
if (isString(maxOutput.value) && inputValue) {
|
|
26922
|
+
exceedMax = isTime
|
|
26923
|
+
? convertTimeToDate(inputValue) > convertTimeToDate(maxOutput.value)
|
|
26924
|
+
: isWeek
|
|
26925
|
+
? inputValue > maxOutput.value
|
|
26926
|
+
: valueDate > new Date(maxOutput.value);
|
|
26927
|
+
}
|
|
26928
|
+
if (isString(minOutput.value) && inputValue) {
|
|
26929
|
+
exceedMin = isTime
|
|
26930
|
+
? convertTimeToDate(inputValue) < convertTimeToDate(minOutput.value)
|
|
26931
|
+
: isWeek
|
|
26932
|
+
? inputValue < minOutput.value
|
|
26933
|
+
: valueDate < new Date(minOutput.value);
|
|
26934
|
+
}
|
|
26935
|
+
}
|
|
26936
|
+
if (exceedMax || exceedMin) {
|
|
26937
|
+
getMinMaxMessage(!!exceedMax, maxOutput.message, minOutput.message, INPUT_VALIDATION_RULES.max, INPUT_VALIDATION_RULES.min);
|
|
26938
|
+
if (!validateAllFieldCriteria) {
|
|
26939
|
+
setCustomValidity(error[name].message);
|
|
26940
|
+
return error;
|
|
26941
|
+
}
|
|
26942
|
+
}
|
|
26943
|
+
}
|
|
26944
|
+
if ((maxLength || minLength) &&
|
|
26945
|
+
!isEmpty &&
|
|
26946
|
+
(isString(inputValue) || (isFieldArray && Array.isArray(inputValue)))) {
|
|
26947
|
+
const maxLengthOutput = getValueAndMessage(maxLength);
|
|
26948
|
+
const minLengthOutput = getValueAndMessage(minLength);
|
|
26949
|
+
const exceedMax = !isNullOrUndefined(maxLengthOutput.value) &&
|
|
26950
|
+
inputValue.length > +maxLengthOutput.value;
|
|
26951
|
+
const exceedMin = !isNullOrUndefined(minLengthOutput.value) &&
|
|
26952
|
+
inputValue.length < +minLengthOutput.value;
|
|
26953
|
+
if (exceedMax || exceedMin) {
|
|
26954
|
+
getMinMaxMessage(exceedMax, maxLengthOutput.message, minLengthOutput.message);
|
|
26955
|
+
if (!validateAllFieldCriteria) {
|
|
26956
|
+
setCustomValidity(error[name].message);
|
|
26957
|
+
return error;
|
|
26958
|
+
}
|
|
26959
|
+
}
|
|
26960
|
+
}
|
|
26961
|
+
if (pattern && !isEmpty && isString(inputValue)) {
|
|
26962
|
+
const { value: patternValue, message } = getValueAndMessage(pattern);
|
|
26963
|
+
if (isRegex(patternValue) && !inputValue.match(patternValue)) {
|
|
26964
|
+
error[name] = {
|
|
26965
|
+
type: INPUT_VALIDATION_RULES.pattern,
|
|
26966
|
+
message,
|
|
26967
|
+
ref,
|
|
26968
|
+
...appendErrorsCurry(INPUT_VALIDATION_RULES.pattern, message),
|
|
26969
|
+
};
|
|
26970
|
+
if (!validateAllFieldCriteria) {
|
|
26971
|
+
setCustomValidity(message);
|
|
26972
|
+
return error;
|
|
26973
|
+
}
|
|
26974
|
+
}
|
|
26975
|
+
}
|
|
26976
|
+
if (validate) {
|
|
26977
|
+
if (isFunction(validate)) {
|
|
26978
|
+
const result = await validate(inputValue, formValues);
|
|
26979
|
+
const validateError = getValidateError(result, inputRef);
|
|
26980
|
+
if (validateError) {
|
|
26981
|
+
error[name] = {
|
|
26982
|
+
...validateError,
|
|
26983
|
+
...appendErrorsCurry(INPUT_VALIDATION_RULES.validate, validateError.message),
|
|
26984
|
+
};
|
|
26985
|
+
if (!validateAllFieldCriteria) {
|
|
26986
|
+
setCustomValidity(validateError.message);
|
|
26987
|
+
return error;
|
|
26988
|
+
}
|
|
26989
|
+
}
|
|
26990
|
+
}
|
|
26991
|
+
else if (isObject(validate)) {
|
|
26992
|
+
let validationResult = {};
|
|
26993
|
+
for (const key in validate) {
|
|
26994
|
+
if (!isEmptyObject(validationResult) && !validateAllFieldCriteria) {
|
|
26995
|
+
break;
|
|
26996
|
+
}
|
|
26997
|
+
const validateError = getValidateError(await validate[key](inputValue, formValues), inputRef, key);
|
|
26998
|
+
if (validateError) {
|
|
26999
|
+
validationResult = {
|
|
27000
|
+
...validateError,
|
|
27001
|
+
...appendErrorsCurry(key, validateError.message),
|
|
27002
|
+
};
|
|
27003
|
+
setCustomValidity(validateError.message);
|
|
27004
|
+
if (validateAllFieldCriteria) {
|
|
27005
|
+
error[name] = validationResult;
|
|
27006
|
+
}
|
|
27007
|
+
}
|
|
27008
|
+
}
|
|
27009
|
+
if (!isEmptyObject(validationResult)) {
|
|
27010
|
+
error[name] = {
|
|
27011
|
+
ref: inputRef,
|
|
27012
|
+
...validationResult,
|
|
27013
|
+
};
|
|
27014
|
+
if (!validateAllFieldCriteria) {
|
|
27015
|
+
return error;
|
|
27016
|
+
}
|
|
27017
|
+
}
|
|
27018
|
+
}
|
|
27019
|
+
}
|
|
27020
|
+
setCustomValidity(true);
|
|
27021
|
+
return error;
|
|
27022
|
+
};
|
|
27023
|
+
|
|
27024
|
+
function baseGet(object, updatePath) {
|
|
27025
|
+
const length = updatePath.slice(0, -1).length;
|
|
27026
|
+
let index = 0;
|
|
27027
|
+
while (index < length) {
|
|
27028
|
+
object = isUndefined(object) ? index++ : object[updatePath[index++]];
|
|
27029
|
+
}
|
|
27030
|
+
return object;
|
|
27031
|
+
}
|
|
27032
|
+
function isEmptyArray(obj) {
|
|
27033
|
+
for (const key in obj) {
|
|
27034
|
+
if (obj.hasOwnProperty(key) && !isUndefined(obj[key])) {
|
|
27035
|
+
return false;
|
|
27036
|
+
}
|
|
27037
|
+
}
|
|
27038
|
+
return true;
|
|
27039
|
+
}
|
|
27040
|
+
function unset(object, path) {
|
|
27041
|
+
const paths = Array.isArray(path)
|
|
27042
|
+
? path
|
|
27043
|
+
: isKey(path)
|
|
27044
|
+
? [path]
|
|
27045
|
+
: stringToPath(path);
|
|
27046
|
+
const childObject = paths.length === 1 ? object : baseGet(object, paths);
|
|
27047
|
+
const index = paths.length - 1;
|
|
27048
|
+
const key = paths[index];
|
|
27049
|
+
if (childObject) {
|
|
27050
|
+
delete childObject[key];
|
|
27051
|
+
}
|
|
27052
|
+
if (index !== 0 &&
|
|
27053
|
+
((isObject(childObject) && isEmptyObject(childObject)) ||
|
|
27054
|
+
(Array.isArray(childObject) && isEmptyArray(childObject)))) {
|
|
27055
|
+
unset(object, paths.slice(0, -1));
|
|
27056
|
+
}
|
|
27057
|
+
return object;
|
|
27058
|
+
}
|
|
27059
|
+
|
|
27060
|
+
var createSubject = () => {
|
|
27061
|
+
let _observers = [];
|
|
27062
|
+
const next = (value) => {
|
|
27063
|
+
for (const observer of _observers) {
|
|
27064
|
+
observer.next && observer.next(value);
|
|
27065
|
+
}
|
|
27066
|
+
};
|
|
27067
|
+
const subscribe = (observer) => {
|
|
27068
|
+
_observers.push(observer);
|
|
27069
|
+
return {
|
|
27070
|
+
unsubscribe: () => {
|
|
27071
|
+
_observers = _observers.filter((o) => o !== observer);
|
|
27072
|
+
},
|
|
27073
|
+
};
|
|
27074
|
+
};
|
|
27075
|
+
const unsubscribe = () => {
|
|
27076
|
+
_observers = [];
|
|
27077
|
+
};
|
|
27078
|
+
return {
|
|
27079
|
+
get observers() {
|
|
27080
|
+
return _observers;
|
|
27081
|
+
},
|
|
27082
|
+
next,
|
|
27083
|
+
subscribe,
|
|
27084
|
+
unsubscribe,
|
|
27085
|
+
};
|
|
27086
|
+
};
|
|
27087
|
+
|
|
27088
|
+
var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
|
|
27089
|
+
|
|
27090
|
+
function deepEqual(object1, object2) {
|
|
27091
|
+
if (isPrimitive(object1) || isPrimitive(object2)) {
|
|
27092
|
+
return object1 === object2;
|
|
27093
|
+
}
|
|
27094
|
+
if (isDateObject(object1) && isDateObject(object2)) {
|
|
27095
|
+
return object1.getTime() === object2.getTime();
|
|
27096
|
+
}
|
|
27097
|
+
const keys1 = Object.keys(object1);
|
|
27098
|
+
const keys2 = Object.keys(object2);
|
|
27099
|
+
if (keys1.length !== keys2.length) {
|
|
27100
|
+
return false;
|
|
27101
|
+
}
|
|
27102
|
+
for (const key of keys1) {
|
|
27103
|
+
const val1 = object1[key];
|
|
27104
|
+
if (!keys2.includes(key)) {
|
|
27105
|
+
return false;
|
|
27106
|
+
}
|
|
27107
|
+
if (key !== 'ref') {
|
|
27108
|
+
const val2 = object2[key];
|
|
27109
|
+
if ((isDateObject(val1) && isDateObject(val2)) ||
|
|
27110
|
+
(isObject(val1) && isObject(val2)) ||
|
|
27111
|
+
(Array.isArray(val1) && Array.isArray(val2))
|
|
27112
|
+
? !deepEqual(val1, val2)
|
|
27113
|
+
: val1 !== val2) {
|
|
27114
|
+
return false;
|
|
27115
|
+
}
|
|
27116
|
+
}
|
|
27117
|
+
}
|
|
27118
|
+
return true;
|
|
27119
|
+
}
|
|
27120
|
+
|
|
27121
|
+
var isMultipleSelect = (element) => element.type === `select-multiple`;
|
|
27122
|
+
|
|
27123
|
+
var isRadioOrCheckbox = (ref) => isRadioInput(ref) || isCheckBoxInput(ref);
|
|
27124
|
+
|
|
27125
|
+
var live = (ref) => isHTMLElement(ref) && ref.isConnected;
|
|
27126
|
+
|
|
27127
|
+
var objectHasFunction = (data) => {
|
|
27128
|
+
for (const key in data) {
|
|
27129
|
+
if (isFunction(data[key])) {
|
|
27130
|
+
return true;
|
|
27131
|
+
}
|
|
27132
|
+
}
|
|
27133
|
+
return false;
|
|
27134
|
+
};
|
|
27135
|
+
|
|
27136
|
+
function markFieldsDirty(data, fields = {}) {
|
|
27137
|
+
const isParentNodeArray = Array.isArray(data);
|
|
27138
|
+
if (isObject(data) || isParentNodeArray) {
|
|
27139
|
+
for (const key in data) {
|
|
27140
|
+
if (Array.isArray(data[key]) ||
|
|
27141
|
+
(isObject(data[key]) && !objectHasFunction(data[key]))) {
|
|
27142
|
+
fields[key] = Array.isArray(data[key]) ? [] : {};
|
|
27143
|
+
markFieldsDirty(data[key], fields[key]);
|
|
27144
|
+
}
|
|
27145
|
+
else if (!isNullOrUndefined(data[key])) {
|
|
27146
|
+
fields[key] = true;
|
|
27147
|
+
}
|
|
27148
|
+
}
|
|
27149
|
+
}
|
|
27150
|
+
return fields;
|
|
27151
|
+
}
|
|
27152
|
+
function getDirtyFieldsFromDefaultValues(data, formValues, dirtyFieldsFromValues) {
|
|
27153
|
+
const isParentNodeArray = Array.isArray(data);
|
|
27154
|
+
if (isObject(data) || isParentNodeArray) {
|
|
27155
|
+
for (const key in data) {
|
|
27156
|
+
if (Array.isArray(data[key]) ||
|
|
27157
|
+
(isObject(data[key]) && !objectHasFunction(data[key]))) {
|
|
27158
|
+
if (isUndefined(formValues) ||
|
|
27159
|
+
isPrimitive(dirtyFieldsFromValues[key])) {
|
|
27160
|
+
dirtyFieldsFromValues[key] = Array.isArray(data[key])
|
|
27161
|
+
? markFieldsDirty(data[key], [])
|
|
27162
|
+
: { ...markFieldsDirty(data[key]) };
|
|
27163
|
+
}
|
|
27164
|
+
else {
|
|
27165
|
+
getDirtyFieldsFromDefaultValues(data[key], isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);
|
|
27166
|
+
}
|
|
27167
|
+
}
|
|
27168
|
+
else {
|
|
27169
|
+
dirtyFieldsFromValues[key] = !deepEqual(data[key], formValues[key]);
|
|
27170
|
+
}
|
|
27171
|
+
}
|
|
27172
|
+
}
|
|
27173
|
+
return dirtyFieldsFromValues;
|
|
27174
|
+
}
|
|
27175
|
+
var getDirtyFields = (defaultValues, formValues) => getDirtyFieldsFromDefaultValues(defaultValues, formValues, markFieldsDirty(formValues));
|
|
27176
|
+
|
|
27177
|
+
var getFieldValueAs = (value, { valueAsNumber, valueAsDate, setValueAs }) => isUndefined(value)
|
|
27178
|
+
? value
|
|
27179
|
+
: valueAsNumber
|
|
27180
|
+
? value === ''
|
|
27181
|
+
? NaN
|
|
27182
|
+
: value
|
|
27183
|
+
? +value
|
|
27184
|
+
: value
|
|
27185
|
+
: valueAsDate && isString(value)
|
|
27186
|
+
? new Date(value)
|
|
27187
|
+
: setValueAs
|
|
27188
|
+
? setValueAs(value)
|
|
27189
|
+
: value;
|
|
27190
|
+
|
|
27191
|
+
function getFieldValue(_f) {
|
|
27192
|
+
const ref = _f.ref;
|
|
27193
|
+
if (_f.refs ? _f.refs.every((ref) => ref.disabled) : ref.disabled) {
|
|
27194
|
+
return;
|
|
27195
|
+
}
|
|
27196
|
+
if (isFileInput(ref)) {
|
|
27197
|
+
return ref.files;
|
|
27198
|
+
}
|
|
27199
|
+
if (isRadioInput(ref)) {
|
|
27200
|
+
return getRadioValue(_f.refs).value;
|
|
27201
|
+
}
|
|
27202
|
+
if (isMultipleSelect(ref)) {
|
|
27203
|
+
return [...ref.selectedOptions].map(({ value }) => value);
|
|
27204
|
+
}
|
|
27205
|
+
if (isCheckBoxInput(ref)) {
|
|
27206
|
+
return getCheckboxValue(_f.refs).value;
|
|
27207
|
+
}
|
|
27208
|
+
return getFieldValueAs(isUndefined(ref.value) ? _f.ref.value : ref.value, _f);
|
|
27209
|
+
}
|
|
27210
|
+
|
|
27211
|
+
var getResolverOptions = (fieldsNames, _fields, criteriaMode, shouldUseNativeValidation) => {
|
|
27212
|
+
const fields = {};
|
|
27213
|
+
for (const name of fieldsNames) {
|
|
27214
|
+
const field = get(_fields, name);
|
|
27215
|
+
field && set(fields, name, field._f);
|
|
27216
|
+
}
|
|
27217
|
+
return {
|
|
27218
|
+
criteriaMode,
|
|
27219
|
+
names: [...fieldsNames],
|
|
27220
|
+
fields,
|
|
27221
|
+
shouldUseNativeValidation,
|
|
27222
|
+
};
|
|
27223
|
+
};
|
|
27224
|
+
|
|
27225
|
+
var getRuleValue = (rule) => isUndefined(rule)
|
|
27226
|
+
? rule
|
|
27227
|
+
: isRegex(rule)
|
|
27228
|
+
? rule.source
|
|
27229
|
+
: isObject(rule)
|
|
27230
|
+
? isRegex(rule.value)
|
|
27231
|
+
? rule.value.source
|
|
27232
|
+
: rule.value
|
|
27233
|
+
: rule;
|
|
27234
|
+
|
|
27235
|
+
var hasValidation = (options) => options.mount &&
|
|
27236
|
+
(options.required ||
|
|
27237
|
+
options.min ||
|
|
27238
|
+
options.max ||
|
|
27239
|
+
options.maxLength ||
|
|
27240
|
+
options.minLength ||
|
|
27241
|
+
options.pattern ||
|
|
27242
|
+
options.validate);
|
|
27243
|
+
|
|
27244
|
+
function schemaErrorLookup(errors, _fields, name) {
|
|
27245
|
+
const error = get(errors, name);
|
|
27246
|
+
if (error || isKey(name)) {
|
|
27247
|
+
return {
|
|
27248
|
+
error,
|
|
27249
|
+
name,
|
|
27250
|
+
};
|
|
27251
|
+
}
|
|
27252
|
+
const names = name.split('.');
|
|
27253
|
+
while (names.length) {
|
|
27254
|
+
const fieldName = names.join('.');
|
|
27255
|
+
const field = get(_fields, fieldName);
|
|
27256
|
+
const foundError = get(errors, fieldName);
|
|
27257
|
+
if (field && !Array.isArray(field) && name !== fieldName) {
|
|
27258
|
+
return { name };
|
|
27259
|
+
}
|
|
27260
|
+
if (foundError && foundError.type) {
|
|
27261
|
+
return {
|
|
27262
|
+
name: fieldName,
|
|
27263
|
+
error: foundError,
|
|
27264
|
+
};
|
|
27265
|
+
}
|
|
27266
|
+
names.pop();
|
|
27267
|
+
}
|
|
27268
|
+
return {
|
|
27269
|
+
name,
|
|
27270
|
+
};
|
|
27271
|
+
}
|
|
27272
|
+
|
|
27273
|
+
var skipValidation = (isBlurEvent, isTouched, isSubmitted, reValidateMode, mode) => {
|
|
27274
|
+
if (mode.isOnAll) {
|
|
27275
|
+
return false;
|
|
27276
|
+
}
|
|
27277
|
+
else if (!isSubmitted && mode.isOnTouch) {
|
|
27278
|
+
return !(isTouched || isBlurEvent);
|
|
27279
|
+
}
|
|
27280
|
+
else if (isSubmitted ? reValidateMode.isOnBlur : mode.isOnBlur) {
|
|
27281
|
+
return !isBlurEvent;
|
|
27282
|
+
}
|
|
27283
|
+
else if (isSubmitted ? reValidateMode.isOnChange : mode.isOnChange) {
|
|
27284
|
+
return isBlurEvent;
|
|
27285
|
+
}
|
|
27286
|
+
return true;
|
|
27287
|
+
};
|
|
27288
|
+
|
|
27289
|
+
var unsetEmptyArray = (ref, name) => !compact(get(ref, name)).length && unset(ref, name);
|
|
27290
|
+
|
|
27291
|
+
const defaultOptions = {
|
|
27292
|
+
mode: VALIDATION_MODE.onSubmit,
|
|
27293
|
+
reValidateMode: VALIDATION_MODE.onChange,
|
|
27294
|
+
shouldFocusError: true,
|
|
27295
|
+
};
|
|
27296
|
+
function createFormControl(props = {}, flushRootRender) {
|
|
27297
|
+
let _options = {
|
|
27298
|
+
...defaultOptions,
|
|
27299
|
+
...props,
|
|
27300
|
+
};
|
|
27301
|
+
let _formState = {
|
|
27302
|
+
submitCount: 0,
|
|
27303
|
+
isDirty: false,
|
|
27304
|
+
isLoading: isFunction(_options.defaultValues),
|
|
27305
|
+
isValidating: false,
|
|
27306
|
+
isSubmitted: false,
|
|
27307
|
+
isSubmitting: false,
|
|
27308
|
+
isSubmitSuccessful: false,
|
|
27309
|
+
isValid: false,
|
|
27310
|
+
touchedFields: {},
|
|
27311
|
+
dirtyFields: {},
|
|
27312
|
+
errors: _options.errors || {},
|
|
27313
|
+
disabled: false,
|
|
27314
|
+
};
|
|
27315
|
+
let _fields = {};
|
|
27316
|
+
let _defaultValues = isObject(_options.defaultValues) || isObject(_options.values)
|
|
27317
|
+
? cloneObject(_options.defaultValues || _options.values) || {}
|
|
27318
|
+
: {};
|
|
27319
|
+
let _formValues = _options.shouldUnregister
|
|
27320
|
+
? {}
|
|
27321
|
+
: cloneObject(_defaultValues);
|
|
27322
|
+
let _state = {
|
|
27323
|
+
action: false,
|
|
27324
|
+
mount: false,
|
|
27325
|
+
watch: false,
|
|
27326
|
+
};
|
|
27327
|
+
let _names = {
|
|
27328
|
+
mount: new Set(),
|
|
27329
|
+
unMount: new Set(),
|
|
27330
|
+
array: new Set(),
|
|
27331
|
+
watch: new Set(),
|
|
27332
|
+
};
|
|
27333
|
+
let delayErrorCallback;
|
|
27334
|
+
let timer = 0;
|
|
27335
|
+
const _proxyFormState = {
|
|
27336
|
+
isDirty: false,
|
|
27337
|
+
dirtyFields: false,
|
|
27338
|
+
touchedFields: false,
|
|
27339
|
+
isValidating: false,
|
|
27340
|
+
isValid: false,
|
|
27341
|
+
errors: false,
|
|
27342
|
+
};
|
|
27343
|
+
const _subjects = {
|
|
27344
|
+
values: createSubject(),
|
|
27345
|
+
array: createSubject(),
|
|
27346
|
+
state: createSubject(),
|
|
27347
|
+
};
|
|
27348
|
+
const shouldCaptureDirtyFields = props.resetOptions && props.resetOptions.keepDirtyValues;
|
|
27349
|
+
const validationModeBeforeSubmit = getValidationModes(_options.mode);
|
|
27350
|
+
const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
|
|
27351
|
+
const shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;
|
|
27352
|
+
const debounce = (callback) => (wait) => {
|
|
27353
|
+
clearTimeout(timer);
|
|
27354
|
+
timer = setTimeout(callback, wait);
|
|
27355
|
+
};
|
|
27356
|
+
const _updateValid = async (shouldUpdateValid) => {
|
|
27357
|
+
if (_proxyFormState.isValid || shouldUpdateValid) {
|
|
27358
|
+
const isValid = _options.resolver
|
|
27359
|
+
? isEmptyObject((await _executeSchema()).errors)
|
|
27360
|
+
: await executeBuiltInValidation(_fields, true);
|
|
27361
|
+
if (isValid !== _formState.isValid) {
|
|
27362
|
+
_subjects.state.next({
|
|
27363
|
+
isValid,
|
|
27364
|
+
});
|
|
27365
|
+
}
|
|
27366
|
+
}
|
|
27367
|
+
};
|
|
27368
|
+
const _updateIsValidating = (value) => _proxyFormState.isValidating &&
|
|
27369
|
+
_subjects.state.next({
|
|
27370
|
+
isValidating: value,
|
|
27371
|
+
});
|
|
27372
|
+
const _updateFieldArray = (name, values = [], method, args, shouldSetValues = true, shouldUpdateFieldsAndState = true) => {
|
|
27373
|
+
if (args && method) {
|
|
27374
|
+
_state.action = true;
|
|
27375
|
+
if (shouldUpdateFieldsAndState && Array.isArray(get(_fields, name))) {
|
|
27376
|
+
const fieldValues = method(get(_fields, name), args.argA, args.argB);
|
|
27377
|
+
shouldSetValues && set(_fields, name, fieldValues);
|
|
27378
|
+
}
|
|
27379
|
+
if (shouldUpdateFieldsAndState &&
|
|
27380
|
+
Array.isArray(get(_formState.errors, name))) {
|
|
27381
|
+
const errors = method(get(_formState.errors, name), args.argA, args.argB);
|
|
27382
|
+
shouldSetValues && set(_formState.errors, name, errors);
|
|
27383
|
+
unsetEmptyArray(_formState.errors, name);
|
|
27384
|
+
}
|
|
27385
|
+
if (_proxyFormState.touchedFields &&
|
|
27386
|
+
shouldUpdateFieldsAndState &&
|
|
27387
|
+
Array.isArray(get(_formState.touchedFields, name))) {
|
|
27388
|
+
const touchedFields = method(get(_formState.touchedFields, name), args.argA, args.argB);
|
|
27389
|
+
shouldSetValues && set(_formState.touchedFields, name, touchedFields);
|
|
27390
|
+
}
|
|
27391
|
+
if (_proxyFormState.dirtyFields) {
|
|
27392
|
+
_formState.dirtyFields = getDirtyFields(_defaultValues, _formValues);
|
|
27393
|
+
}
|
|
27394
|
+
_subjects.state.next({
|
|
27395
|
+
name,
|
|
27396
|
+
isDirty: _getDirty(name, values),
|
|
27397
|
+
dirtyFields: _formState.dirtyFields,
|
|
27398
|
+
errors: _formState.errors,
|
|
27399
|
+
isValid: _formState.isValid,
|
|
27400
|
+
});
|
|
27401
|
+
}
|
|
27402
|
+
else {
|
|
27403
|
+
set(_formValues, name, values);
|
|
27404
|
+
}
|
|
27405
|
+
};
|
|
27406
|
+
const updateErrors = (name, error) => {
|
|
27407
|
+
set(_formState.errors, name, error);
|
|
27408
|
+
_subjects.state.next({
|
|
27409
|
+
errors: _formState.errors,
|
|
27410
|
+
});
|
|
27411
|
+
};
|
|
27412
|
+
const _setErrors = (errors) => {
|
|
27413
|
+
_formState.errors = errors;
|
|
27414
|
+
_subjects.state.next({
|
|
27415
|
+
errors: _formState.errors,
|
|
27416
|
+
isValid: false,
|
|
27417
|
+
});
|
|
27418
|
+
};
|
|
27419
|
+
const updateValidAndValue = (name, shouldSkipSetValueAs, value, ref) => {
|
|
27420
|
+
const field = get(_fields, name);
|
|
27421
|
+
if (field) {
|
|
27422
|
+
const defaultValue = get(_formValues, name, isUndefined(value) ? get(_defaultValues, name) : value);
|
|
27423
|
+
isUndefined(defaultValue) ||
|
|
27424
|
+
(ref && ref.defaultChecked) ||
|
|
27425
|
+
shouldSkipSetValueAs
|
|
27426
|
+
? set(_formValues, name, shouldSkipSetValueAs ? defaultValue : getFieldValue(field._f))
|
|
27427
|
+
: setFieldValue(name, defaultValue);
|
|
27428
|
+
_state.mount && _updateValid();
|
|
27429
|
+
}
|
|
27430
|
+
};
|
|
27431
|
+
const updateTouchAndDirty = (name, fieldValue, isBlurEvent, shouldDirty, shouldRender) => {
|
|
27432
|
+
let shouldUpdateField = false;
|
|
27433
|
+
let isPreviousDirty = false;
|
|
27434
|
+
const output = {
|
|
27435
|
+
name,
|
|
27436
|
+
};
|
|
27437
|
+
const disabledField = !!(get(_fields, name) && get(_fields, name)._f.disabled);
|
|
27438
|
+
if (!isBlurEvent || shouldDirty) {
|
|
27439
|
+
if (_proxyFormState.isDirty) {
|
|
27440
|
+
isPreviousDirty = _formState.isDirty;
|
|
27441
|
+
_formState.isDirty = output.isDirty = _getDirty();
|
|
27442
|
+
shouldUpdateField = isPreviousDirty !== output.isDirty;
|
|
27443
|
+
}
|
|
27444
|
+
const isCurrentFieldPristine = disabledField || deepEqual(get(_defaultValues, name), fieldValue);
|
|
27445
|
+
isPreviousDirty = !!(!disabledField && get(_formState.dirtyFields, name));
|
|
27446
|
+
isCurrentFieldPristine || disabledField
|
|
27447
|
+
? unset(_formState.dirtyFields, name)
|
|
27448
|
+
: set(_formState.dirtyFields, name, true);
|
|
27449
|
+
output.dirtyFields = _formState.dirtyFields;
|
|
27450
|
+
shouldUpdateField =
|
|
27451
|
+
shouldUpdateField ||
|
|
27452
|
+
(_proxyFormState.dirtyFields &&
|
|
27453
|
+
isPreviousDirty !== !isCurrentFieldPristine);
|
|
27454
|
+
}
|
|
27455
|
+
if (isBlurEvent) {
|
|
27456
|
+
const isPreviousFieldTouched = get(_formState.touchedFields, name);
|
|
27457
|
+
if (!isPreviousFieldTouched) {
|
|
27458
|
+
set(_formState.touchedFields, name, isBlurEvent);
|
|
27459
|
+
output.touchedFields = _formState.touchedFields;
|
|
27460
|
+
shouldUpdateField =
|
|
27461
|
+
shouldUpdateField ||
|
|
27462
|
+
(_proxyFormState.touchedFields &&
|
|
27463
|
+
isPreviousFieldTouched !== isBlurEvent);
|
|
27464
|
+
}
|
|
27465
|
+
}
|
|
27466
|
+
shouldUpdateField && shouldRender && _subjects.state.next(output);
|
|
27467
|
+
return shouldUpdateField ? output : {};
|
|
27468
|
+
};
|
|
27469
|
+
const shouldRenderByError = (name, isValid, error, fieldState) => {
|
|
27470
|
+
const previousFieldError = get(_formState.errors, name);
|
|
27471
|
+
const shouldUpdateValid = _proxyFormState.isValid &&
|
|
27472
|
+
isBoolean(isValid) &&
|
|
27473
|
+
_formState.isValid !== isValid;
|
|
27474
|
+
if (props.delayError && error) {
|
|
27475
|
+
delayErrorCallback = debounce(() => updateErrors(name, error));
|
|
27476
|
+
delayErrorCallback(props.delayError);
|
|
27477
|
+
}
|
|
27478
|
+
else {
|
|
27479
|
+
clearTimeout(timer);
|
|
27480
|
+
delayErrorCallback = null;
|
|
27481
|
+
error
|
|
27482
|
+
? set(_formState.errors, name, error)
|
|
27483
|
+
: unset(_formState.errors, name);
|
|
27484
|
+
}
|
|
27485
|
+
if ((error ? !deepEqual(previousFieldError, error) : previousFieldError) ||
|
|
27486
|
+
!isEmptyObject(fieldState) ||
|
|
27487
|
+
shouldUpdateValid) {
|
|
27488
|
+
const updatedFormState = {
|
|
27489
|
+
...fieldState,
|
|
27490
|
+
...(shouldUpdateValid && isBoolean(isValid) ? { isValid } : {}),
|
|
27491
|
+
errors: _formState.errors,
|
|
27492
|
+
name,
|
|
27493
|
+
};
|
|
27494
|
+
_formState = {
|
|
27495
|
+
..._formState,
|
|
27496
|
+
...updatedFormState,
|
|
27497
|
+
};
|
|
27498
|
+
_subjects.state.next(updatedFormState);
|
|
27499
|
+
}
|
|
27500
|
+
_updateIsValidating(false);
|
|
27501
|
+
};
|
|
27502
|
+
const _executeSchema = async (name) => _options.resolver(_formValues, _options.context, getResolverOptions(name || _names.mount, _fields, _options.criteriaMode, _options.shouldUseNativeValidation));
|
|
27503
|
+
const executeSchemaAndUpdateState = async (names) => {
|
|
27504
|
+
const { errors } = await _executeSchema(names);
|
|
27505
|
+
if (names) {
|
|
27506
|
+
for (const name of names) {
|
|
27507
|
+
const error = get(errors, name);
|
|
27508
|
+
error
|
|
27509
|
+
? set(_formState.errors, name, error)
|
|
27510
|
+
: unset(_formState.errors, name);
|
|
27511
|
+
}
|
|
27512
|
+
}
|
|
27513
|
+
else {
|
|
27514
|
+
_formState.errors = errors;
|
|
27515
|
+
}
|
|
27516
|
+
return errors;
|
|
27517
|
+
};
|
|
27518
|
+
const executeBuiltInValidation = async (fields, shouldOnlyCheckValid, context = {
|
|
27519
|
+
valid: true,
|
|
27520
|
+
}) => {
|
|
27521
|
+
for (const name in fields) {
|
|
27522
|
+
const field = fields[name];
|
|
27523
|
+
if (field) {
|
|
27524
|
+
const { _f, ...fieldValue } = field;
|
|
27525
|
+
if (_f) {
|
|
27526
|
+
const isFieldArrayRoot = _names.array.has(_f.name);
|
|
27527
|
+
const fieldError = await validateField(field, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation && !shouldOnlyCheckValid, isFieldArrayRoot);
|
|
27528
|
+
if (fieldError[_f.name]) {
|
|
27529
|
+
context.valid = false;
|
|
27530
|
+
if (shouldOnlyCheckValid) {
|
|
27531
|
+
break;
|
|
27532
|
+
}
|
|
27533
|
+
}
|
|
27534
|
+
!shouldOnlyCheckValid &&
|
|
27535
|
+
(get(fieldError, _f.name)
|
|
27536
|
+
? isFieldArrayRoot
|
|
27537
|
+
? updateFieldArrayRootError(_formState.errors, fieldError, _f.name)
|
|
27538
|
+
: set(_formState.errors, _f.name, fieldError[_f.name])
|
|
27539
|
+
: unset(_formState.errors, _f.name));
|
|
27540
|
+
}
|
|
27541
|
+
fieldValue &&
|
|
27542
|
+
(await executeBuiltInValidation(fieldValue, shouldOnlyCheckValid, context));
|
|
27543
|
+
}
|
|
27544
|
+
}
|
|
27545
|
+
return context.valid;
|
|
27546
|
+
};
|
|
27547
|
+
const _removeUnmounted = () => {
|
|
27548
|
+
for (const name of _names.unMount) {
|
|
27549
|
+
const field = get(_fields, name);
|
|
27550
|
+
field &&
|
|
27551
|
+
(field._f.refs
|
|
27552
|
+
? field._f.refs.every((ref) => !live(ref))
|
|
27553
|
+
: !live(field._f.ref)) &&
|
|
27554
|
+
unregister(name);
|
|
27555
|
+
}
|
|
27556
|
+
_names.unMount = new Set();
|
|
27557
|
+
};
|
|
27558
|
+
const _getDirty = (name, data) => (name && data && set(_formValues, name, data),
|
|
27559
|
+
!deepEqual(getValues(), _defaultValues));
|
|
27560
|
+
const _getWatch = (names, defaultValue, isGlobal) => generateWatchOutput(names, _names, {
|
|
27561
|
+
...(_state.mount
|
|
27562
|
+
? _formValues
|
|
27563
|
+
: isUndefined(defaultValue)
|
|
27564
|
+
? _defaultValues
|
|
27565
|
+
: isString(names)
|
|
27566
|
+
? { [names]: defaultValue }
|
|
27567
|
+
: defaultValue),
|
|
27568
|
+
}, isGlobal, defaultValue);
|
|
27569
|
+
const _getFieldArray = (name) => compact(get(_state.mount ? _formValues : _defaultValues, name, props.shouldUnregister ? get(_defaultValues, name, []) : []));
|
|
27570
|
+
const setFieldValue = (name, value, options = {}) => {
|
|
27571
|
+
const field = get(_fields, name);
|
|
27572
|
+
let fieldValue = value;
|
|
27573
|
+
if (field) {
|
|
27574
|
+
const fieldReference = field._f;
|
|
27575
|
+
if (fieldReference) {
|
|
27576
|
+
!fieldReference.disabled &&
|
|
27577
|
+
set(_formValues, name, getFieldValueAs(value, fieldReference));
|
|
27578
|
+
fieldValue =
|
|
27579
|
+
isHTMLElement(fieldReference.ref) && isNullOrUndefined(value)
|
|
27580
|
+
? ''
|
|
27581
|
+
: value;
|
|
27582
|
+
if (isMultipleSelect(fieldReference.ref)) {
|
|
27583
|
+
[...fieldReference.ref.options].forEach((optionRef) => (optionRef.selected = fieldValue.includes(optionRef.value)));
|
|
27584
|
+
}
|
|
27585
|
+
else if (fieldReference.refs) {
|
|
27586
|
+
if (isCheckBoxInput(fieldReference.ref)) {
|
|
27587
|
+
fieldReference.refs.length > 1
|
|
27588
|
+
? fieldReference.refs.forEach((checkboxRef) => (!checkboxRef.defaultChecked || !checkboxRef.disabled) &&
|
|
27589
|
+
(checkboxRef.checked = Array.isArray(fieldValue)
|
|
27590
|
+
? !!fieldValue.find((data) => data === checkboxRef.value)
|
|
27591
|
+
: fieldValue === checkboxRef.value))
|
|
27592
|
+
: fieldReference.refs[0] &&
|
|
27593
|
+
(fieldReference.refs[0].checked = !!fieldValue);
|
|
27594
|
+
}
|
|
27595
|
+
else {
|
|
27596
|
+
fieldReference.refs.forEach((radioRef) => (radioRef.checked = radioRef.value === fieldValue));
|
|
27597
|
+
}
|
|
27598
|
+
}
|
|
27599
|
+
else if (isFileInput(fieldReference.ref)) {
|
|
27600
|
+
fieldReference.ref.value = '';
|
|
27601
|
+
}
|
|
27602
|
+
else {
|
|
27603
|
+
fieldReference.ref.value = fieldValue;
|
|
27604
|
+
if (!fieldReference.ref.type) {
|
|
27605
|
+
_subjects.values.next({
|
|
27606
|
+
name,
|
|
27607
|
+
values: { ..._formValues },
|
|
27608
|
+
});
|
|
27609
|
+
}
|
|
27610
|
+
}
|
|
27611
|
+
}
|
|
27612
|
+
}
|
|
27613
|
+
(options.shouldDirty || options.shouldTouch) &&
|
|
27614
|
+
updateTouchAndDirty(name, fieldValue, options.shouldTouch, options.shouldDirty, true);
|
|
27615
|
+
options.shouldValidate && trigger(name);
|
|
27616
|
+
};
|
|
27617
|
+
const setValues = (name, value, options) => {
|
|
27618
|
+
for (const fieldKey in value) {
|
|
27619
|
+
const fieldValue = value[fieldKey];
|
|
27620
|
+
const fieldName = `${name}.${fieldKey}`;
|
|
27621
|
+
const field = get(_fields, fieldName);
|
|
27622
|
+
(_names.array.has(name) ||
|
|
27623
|
+
!isPrimitive(fieldValue) ||
|
|
27624
|
+
(field && !field._f)) &&
|
|
27625
|
+
!isDateObject(fieldValue)
|
|
27626
|
+
? setValues(fieldName, fieldValue, options)
|
|
27627
|
+
: setFieldValue(fieldName, fieldValue, options);
|
|
27628
|
+
}
|
|
27629
|
+
};
|
|
27630
|
+
const setValue = (name, value, options = {}) => {
|
|
27631
|
+
const field = get(_fields, name);
|
|
27632
|
+
const isFieldArray = _names.array.has(name);
|
|
27633
|
+
const cloneValue = cloneObject(value);
|
|
27634
|
+
set(_formValues, name, cloneValue);
|
|
27635
|
+
if (isFieldArray) {
|
|
27636
|
+
_subjects.array.next({
|
|
27637
|
+
name,
|
|
27638
|
+
values: { ..._formValues },
|
|
27639
|
+
});
|
|
27640
|
+
if ((_proxyFormState.isDirty || _proxyFormState.dirtyFields) &&
|
|
27641
|
+
options.shouldDirty) {
|
|
27642
|
+
_subjects.state.next({
|
|
27643
|
+
name,
|
|
27644
|
+
dirtyFields: getDirtyFields(_defaultValues, _formValues),
|
|
27645
|
+
isDirty: _getDirty(name, cloneValue),
|
|
27646
|
+
});
|
|
27647
|
+
}
|
|
27648
|
+
}
|
|
27649
|
+
else {
|
|
27650
|
+
field && !field._f && !isNullOrUndefined(cloneValue)
|
|
27651
|
+
? setValues(name, cloneValue, options)
|
|
27652
|
+
: setFieldValue(name, cloneValue, options);
|
|
27653
|
+
}
|
|
27654
|
+
isWatched(name, _names) && _subjects.state.next({ ..._formState });
|
|
27655
|
+
_subjects.values.next({
|
|
27656
|
+
name,
|
|
27657
|
+
values: { ..._formValues },
|
|
27658
|
+
});
|
|
27659
|
+
!_state.mount && flushRootRender();
|
|
27660
|
+
};
|
|
27661
|
+
const onChange = async (event) => {
|
|
27662
|
+
const target = event.target;
|
|
27663
|
+
let name = target.name;
|
|
27664
|
+
let isFieldValueUpdated = true;
|
|
27665
|
+
const field = get(_fields, name);
|
|
27666
|
+
const getCurrentFieldValue = () => target.type ? getFieldValue(field._f) : getEventValue(event);
|
|
27667
|
+
const _updateIsFieldValueUpdated = (fieldValue) => {
|
|
27668
|
+
isFieldValueUpdated =
|
|
27669
|
+
Number.isNaN(fieldValue) ||
|
|
27670
|
+
fieldValue === get(_formValues, name, fieldValue);
|
|
27671
|
+
};
|
|
27672
|
+
if (field) {
|
|
27673
|
+
let error;
|
|
27674
|
+
let isValid;
|
|
27675
|
+
const fieldValue = getCurrentFieldValue();
|
|
27676
|
+
const isBlurEvent = event.type === EVENTS.BLUR || event.type === EVENTS.FOCUS_OUT;
|
|
27677
|
+
const shouldSkipValidation = (!hasValidation(field._f) &&
|
|
27678
|
+
!_options.resolver &&
|
|
27679
|
+
!get(_formState.errors, name) &&
|
|
27680
|
+
!field._f.deps) ||
|
|
27681
|
+
skipValidation(isBlurEvent, get(_formState.touchedFields, name), _formState.isSubmitted, validationModeAfterSubmit, validationModeBeforeSubmit);
|
|
27682
|
+
const watched = isWatched(name, _names, isBlurEvent);
|
|
27683
|
+
set(_formValues, name, fieldValue);
|
|
27684
|
+
if (isBlurEvent) {
|
|
27685
|
+
field._f.onBlur && field._f.onBlur(event);
|
|
27686
|
+
delayErrorCallback && delayErrorCallback(0);
|
|
27687
|
+
}
|
|
27688
|
+
else if (field._f.onChange) {
|
|
27689
|
+
field._f.onChange(event);
|
|
27690
|
+
}
|
|
27691
|
+
const fieldState = updateTouchAndDirty(name, fieldValue, isBlurEvent, false);
|
|
27692
|
+
const shouldRender = !isEmptyObject(fieldState) || watched;
|
|
27693
|
+
!isBlurEvent &&
|
|
27694
|
+
_subjects.values.next({
|
|
27695
|
+
name,
|
|
27696
|
+
type: event.type,
|
|
27697
|
+
values: { ..._formValues },
|
|
27698
|
+
});
|
|
27699
|
+
if (shouldSkipValidation) {
|
|
27700
|
+
_proxyFormState.isValid && _updateValid();
|
|
27701
|
+
return (shouldRender &&
|
|
27702
|
+
_subjects.state.next({ name, ...(watched ? {} : fieldState) }));
|
|
27703
|
+
}
|
|
27704
|
+
!isBlurEvent && watched && _subjects.state.next({ ..._formState });
|
|
27705
|
+
_updateIsValidating(true);
|
|
27706
|
+
if (_options.resolver) {
|
|
27707
|
+
const { errors } = await _executeSchema([name]);
|
|
27708
|
+
_updateIsFieldValueUpdated(fieldValue);
|
|
27709
|
+
if (isFieldValueUpdated) {
|
|
27710
|
+
const previousErrorLookupResult = schemaErrorLookup(_formState.errors, _fields, name);
|
|
27711
|
+
const errorLookupResult = schemaErrorLookup(errors, _fields, previousErrorLookupResult.name || name);
|
|
27712
|
+
error = errorLookupResult.error;
|
|
27713
|
+
name = errorLookupResult.name;
|
|
27714
|
+
isValid = isEmptyObject(errors);
|
|
27715
|
+
}
|
|
27716
|
+
}
|
|
27717
|
+
else {
|
|
27718
|
+
error = (await validateField(field, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation))[name];
|
|
27719
|
+
_updateIsFieldValueUpdated(fieldValue);
|
|
27720
|
+
if (isFieldValueUpdated) {
|
|
27721
|
+
if (error) {
|
|
27722
|
+
isValid = false;
|
|
27723
|
+
}
|
|
27724
|
+
else if (_proxyFormState.isValid) {
|
|
27725
|
+
isValid = await executeBuiltInValidation(_fields, true);
|
|
27726
|
+
}
|
|
27727
|
+
}
|
|
27728
|
+
}
|
|
27729
|
+
if (isFieldValueUpdated) {
|
|
27730
|
+
field._f.deps &&
|
|
27731
|
+
trigger(field._f.deps);
|
|
27732
|
+
shouldRenderByError(name, isValid, error, fieldState);
|
|
27733
|
+
}
|
|
27734
|
+
}
|
|
27735
|
+
};
|
|
27736
|
+
const _focusInput = (ref, key) => {
|
|
27737
|
+
if (get(_formState.errors, key) && ref.focus) {
|
|
27738
|
+
ref.focus();
|
|
27739
|
+
return 1;
|
|
27740
|
+
}
|
|
27741
|
+
return;
|
|
27742
|
+
};
|
|
27743
|
+
const trigger = async (name, options = {}) => {
|
|
27744
|
+
let isValid;
|
|
27745
|
+
let validationResult;
|
|
27746
|
+
const fieldNames = convertToArrayPayload(name);
|
|
27747
|
+
_updateIsValidating(true);
|
|
27748
|
+
if (_options.resolver) {
|
|
27749
|
+
const errors = await executeSchemaAndUpdateState(isUndefined(name) ? name : fieldNames);
|
|
27750
|
+
isValid = isEmptyObject(errors);
|
|
27751
|
+
validationResult = name
|
|
27752
|
+
? !fieldNames.some((name) => get(errors, name))
|
|
27753
|
+
: isValid;
|
|
27754
|
+
}
|
|
27755
|
+
else if (name) {
|
|
27756
|
+
validationResult = (await Promise.all(fieldNames.map(async (fieldName) => {
|
|
27757
|
+
const field = get(_fields, fieldName);
|
|
27758
|
+
return await executeBuiltInValidation(field && field._f ? { [fieldName]: field } : field);
|
|
27759
|
+
}))).every(Boolean);
|
|
27760
|
+
!(!validationResult && !_formState.isValid) && _updateValid();
|
|
27761
|
+
}
|
|
27762
|
+
else {
|
|
27763
|
+
validationResult = isValid = await executeBuiltInValidation(_fields);
|
|
27764
|
+
}
|
|
27765
|
+
_subjects.state.next({
|
|
27766
|
+
...(!isString(name) ||
|
|
27767
|
+
(_proxyFormState.isValid && isValid !== _formState.isValid)
|
|
27768
|
+
? {}
|
|
27769
|
+
: { name }),
|
|
27770
|
+
...(_options.resolver || !name ? { isValid } : {}),
|
|
27771
|
+
errors: _formState.errors,
|
|
27772
|
+
isValidating: false,
|
|
27773
|
+
});
|
|
27774
|
+
options.shouldFocus &&
|
|
27775
|
+
!validationResult &&
|
|
27776
|
+
iterateFieldsByAction(_fields, _focusInput, name ? fieldNames : _names.mount);
|
|
27777
|
+
return validationResult;
|
|
27778
|
+
};
|
|
27779
|
+
const getValues = (fieldNames) => {
|
|
27780
|
+
const values = {
|
|
27781
|
+
..._defaultValues,
|
|
27782
|
+
...(_state.mount ? _formValues : {}),
|
|
27783
|
+
};
|
|
27784
|
+
return isUndefined(fieldNames)
|
|
27785
|
+
? values
|
|
27786
|
+
: isString(fieldNames)
|
|
27787
|
+
? get(values, fieldNames)
|
|
27788
|
+
: fieldNames.map((name) => get(values, name));
|
|
27789
|
+
};
|
|
27790
|
+
const getFieldState = (name, formState) => ({
|
|
27791
|
+
invalid: !!get((formState || _formState).errors, name),
|
|
27792
|
+
isDirty: !!get((formState || _formState).dirtyFields, name),
|
|
27793
|
+
isTouched: !!get((formState || _formState).touchedFields, name),
|
|
27794
|
+
error: get((formState || _formState).errors, name),
|
|
27795
|
+
});
|
|
27796
|
+
const clearErrors = (name) => {
|
|
27797
|
+
name &&
|
|
27798
|
+
convertToArrayPayload(name).forEach((inputName) => unset(_formState.errors, inputName));
|
|
27799
|
+
_subjects.state.next({
|
|
27800
|
+
errors: name ? _formState.errors : {},
|
|
27801
|
+
});
|
|
27802
|
+
};
|
|
27803
|
+
const setError = (name, error, options) => {
|
|
27804
|
+
const ref = (get(_fields, name, { _f: {} })._f || {}).ref;
|
|
27805
|
+
set(_formState.errors, name, {
|
|
27806
|
+
...error,
|
|
27807
|
+
ref,
|
|
27808
|
+
});
|
|
27809
|
+
_subjects.state.next({
|
|
27810
|
+
name,
|
|
27811
|
+
errors: _formState.errors,
|
|
27812
|
+
isValid: false,
|
|
27813
|
+
});
|
|
27814
|
+
options && options.shouldFocus && ref && ref.focus && ref.focus();
|
|
27815
|
+
};
|
|
27816
|
+
const watch = (name, defaultValue) => isFunction(name)
|
|
27817
|
+
? _subjects.values.subscribe({
|
|
27818
|
+
next: (payload) => name(_getWatch(undefined, defaultValue), payload),
|
|
27819
|
+
})
|
|
27820
|
+
: _getWatch(name, defaultValue, true);
|
|
27821
|
+
const unregister = (name, options = {}) => {
|
|
27822
|
+
for (const fieldName of name ? convertToArrayPayload(name) : _names.mount) {
|
|
27823
|
+
_names.mount.delete(fieldName);
|
|
27824
|
+
_names.array.delete(fieldName);
|
|
27825
|
+
if (!options.keepValue) {
|
|
27826
|
+
unset(_fields, fieldName);
|
|
27827
|
+
unset(_formValues, fieldName);
|
|
27828
|
+
}
|
|
27829
|
+
!options.keepError && unset(_formState.errors, fieldName);
|
|
27830
|
+
!options.keepDirty && unset(_formState.dirtyFields, fieldName);
|
|
27831
|
+
!options.keepTouched && unset(_formState.touchedFields, fieldName);
|
|
27832
|
+
!_options.shouldUnregister &&
|
|
27833
|
+
!options.keepDefaultValue &&
|
|
27834
|
+
unset(_defaultValues, fieldName);
|
|
27835
|
+
}
|
|
27836
|
+
_subjects.values.next({
|
|
27837
|
+
values: { ..._formValues },
|
|
27838
|
+
});
|
|
27839
|
+
_subjects.state.next({
|
|
27840
|
+
..._formState,
|
|
27841
|
+
...(!options.keepDirty ? {} : { isDirty: _getDirty() }),
|
|
27842
|
+
});
|
|
27843
|
+
!options.keepIsValid && _updateValid();
|
|
27844
|
+
};
|
|
27845
|
+
const _updateDisabledField = ({ disabled, name, field, fields, value, }) => {
|
|
27846
|
+
if (isBoolean(disabled)) {
|
|
27847
|
+
const inputValue = disabled
|
|
27848
|
+
? undefined
|
|
27849
|
+
: isUndefined(value)
|
|
27850
|
+
? getFieldValue(field ? field._f : get(fields, name)._f)
|
|
27851
|
+
: value;
|
|
27852
|
+
set(_formValues, name, inputValue);
|
|
27853
|
+
updateTouchAndDirty(name, inputValue, false, false, true);
|
|
27854
|
+
}
|
|
27855
|
+
};
|
|
27856
|
+
const register = (name, options = {}) => {
|
|
27857
|
+
let field = get(_fields, name);
|
|
27858
|
+
const disabledIsDefined = isBoolean(options.disabled);
|
|
27859
|
+
set(_fields, name, {
|
|
27860
|
+
...(field || {}),
|
|
27861
|
+
_f: {
|
|
27862
|
+
...(field && field._f ? field._f : { ref: { name } }),
|
|
27863
|
+
name,
|
|
27864
|
+
mount: true,
|
|
27865
|
+
...options,
|
|
27866
|
+
},
|
|
27867
|
+
});
|
|
27868
|
+
_names.mount.add(name);
|
|
27869
|
+
if (field) {
|
|
27870
|
+
_updateDisabledField({
|
|
27871
|
+
field,
|
|
27872
|
+
disabled: options.disabled,
|
|
27873
|
+
name,
|
|
27874
|
+
value: options.value,
|
|
27875
|
+
});
|
|
27876
|
+
}
|
|
27877
|
+
else {
|
|
27878
|
+
updateValidAndValue(name, true, options.value);
|
|
27879
|
+
}
|
|
27880
|
+
return {
|
|
27881
|
+
...(disabledIsDefined ? { disabled: options.disabled } : {}),
|
|
27882
|
+
...(_options.progressive
|
|
27883
|
+
? {
|
|
27884
|
+
required: !!options.required,
|
|
27885
|
+
min: getRuleValue(options.min),
|
|
27886
|
+
max: getRuleValue(options.max),
|
|
27887
|
+
minLength: getRuleValue(options.minLength),
|
|
27888
|
+
maxLength: getRuleValue(options.maxLength),
|
|
27889
|
+
pattern: getRuleValue(options.pattern),
|
|
27890
|
+
}
|
|
27891
|
+
: {}),
|
|
27892
|
+
name,
|
|
27893
|
+
onChange,
|
|
27894
|
+
onBlur: onChange,
|
|
27895
|
+
ref: (ref) => {
|
|
27896
|
+
if (ref) {
|
|
27897
|
+
register(name, options);
|
|
27898
|
+
field = get(_fields, name);
|
|
27899
|
+
const fieldRef = isUndefined(ref.value)
|
|
27900
|
+
? ref.querySelectorAll
|
|
27901
|
+
? ref.querySelectorAll('input,select,textarea')[0] || ref
|
|
27902
|
+
: ref
|
|
27903
|
+
: ref;
|
|
27904
|
+
const radioOrCheckbox = isRadioOrCheckbox(fieldRef);
|
|
27905
|
+
const refs = field._f.refs || [];
|
|
27906
|
+
if (radioOrCheckbox
|
|
27907
|
+
? refs.find((option) => option === fieldRef)
|
|
27908
|
+
: fieldRef === field._f.ref) {
|
|
27909
|
+
return;
|
|
27910
|
+
}
|
|
27911
|
+
set(_fields, name, {
|
|
27912
|
+
_f: {
|
|
27913
|
+
...field._f,
|
|
27914
|
+
...(radioOrCheckbox
|
|
27915
|
+
? {
|
|
27916
|
+
refs: [
|
|
27917
|
+
...refs.filter(live),
|
|
27918
|
+
fieldRef,
|
|
27919
|
+
...(Array.isArray(get(_defaultValues, name)) ? [{}] : []),
|
|
27920
|
+
],
|
|
27921
|
+
ref: { type: fieldRef.type, name },
|
|
27922
|
+
}
|
|
27923
|
+
: { ref: fieldRef }),
|
|
27924
|
+
},
|
|
27925
|
+
});
|
|
27926
|
+
updateValidAndValue(name, false, undefined, fieldRef);
|
|
27927
|
+
}
|
|
27928
|
+
else {
|
|
27929
|
+
field = get(_fields, name, {});
|
|
27930
|
+
if (field._f) {
|
|
27931
|
+
field._f.mount = false;
|
|
27932
|
+
}
|
|
27933
|
+
(_options.shouldUnregister || options.shouldUnregister) &&
|
|
27934
|
+
!(isNameInFieldArray(_names.array, name) && _state.action) &&
|
|
27935
|
+
_names.unMount.add(name);
|
|
27936
|
+
}
|
|
27937
|
+
},
|
|
27938
|
+
};
|
|
27939
|
+
};
|
|
27940
|
+
const _focusError = () => _options.shouldFocusError &&
|
|
27941
|
+
iterateFieldsByAction(_fields, _focusInput, _names.mount);
|
|
27942
|
+
const _disableForm = (disabled) => {
|
|
27943
|
+
if (isBoolean(disabled)) {
|
|
27944
|
+
_subjects.state.next({ disabled });
|
|
27945
|
+
iterateFieldsByAction(_fields, (ref, name) => {
|
|
27946
|
+
let requiredDisabledState = disabled;
|
|
27947
|
+
const currentField = get(_fields, name);
|
|
27948
|
+
if (currentField && isBoolean(currentField._f.disabled)) {
|
|
27949
|
+
requiredDisabledState || (requiredDisabledState = currentField._f.disabled);
|
|
27950
|
+
}
|
|
27951
|
+
ref.disabled = requiredDisabledState;
|
|
27952
|
+
}, 0, false);
|
|
27953
|
+
}
|
|
27954
|
+
};
|
|
27955
|
+
const handleSubmit = (onValid, onInvalid) => async (e) => {
|
|
27956
|
+
if (e) {
|
|
27957
|
+
e.preventDefault && e.preventDefault();
|
|
27958
|
+
e.persist && e.persist();
|
|
27959
|
+
}
|
|
27960
|
+
let fieldValues = cloneObject(_formValues);
|
|
27961
|
+
_subjects.state.next({
|
|
27962
|
+
isSubmitting: true,
|
|
27963
|
+
});
|
|
27964
|
+
if (_options.resolver) {
|
|
27965
|
+
const { errors, values } = await _executeSchema();
|
|
27966
|
+
_formState.errors = errors;
|
|
27967
|
+
fieldValues = values;
|
|
27968
|
+
}
|
|
27969
|
+
else {
|
|
27970
|
+
await executeBuiltInValidation(_fields);
|
|
27971
|
+
}
|
|
27972
|
+
unset(_formState.errors, 'root');
|
|
27973
|
+
if (isEmptyObject(_formState.errors)) {
|
|
27974
|
+
_subjects.state.next({
|
|
27975
|
+
errors: {},
|
|
27976
|
+
});
|
|
27977
|
+
await onValid(fieldValues, e);
|
|
27978
|
+
}
|
|
27979
|
+
else {
|
|
27980
|
+
if (onInvalid) {
|
|
27981
|
+
await onInvalid({ ..._formState.errors }, e);
|
|
27982
|
+
}
|
|
27983
|
+
_focusError();
|
|
27984
|
+
setTimeout(_focusError);
|
|
27985
|
+
}
|
|
27986
|
+
_subjects.state.next({
|
|
27987
|
+
isSubmitted: true,
|
|
27988
|
+
isSubmitting: false,
|
|
27989
|
+
isSubmitSuccessful: isEmptyObject(_formState.errors),
|
|
27990
|
+
submitCount: _formState.submitCount + 1,
|
|
27991
|
+
errors: _formState.errors,
|
|
27992
|
+
});
|
|
27993
|
+
};
|
|
27994
|
+
const resetField = (name, options = {}) => {
|
|
27995
|
+
if (get(_fields, name)) {
|
|
27996
|
+
if (isUndefined(options.defaultValue)) {
|
|
27997
|
+
setValue(name, get(_defaultValues, name));
|
|
27998
|
+
}
|
|
27999
|
+
else {
|
|
28000
|
+
setValue(name, options.defaultValue);
|
|
28001
|
+
set(_defaultValues, name, options.defaultValue);
|
|
28002
|
+
}
|
|
28003
|
+
if (!options.keepTouched) {
|
|
28004
|
+
unset(_formState.touchedFields, name);
|
|
28005
|
+
}
|
|
28006
|
+
if (!options.keepDirty) {
|
|
28007
|
+
unset(_formState.dirtyFields, name);
|
|
28008
|
+
_formState.isDirty = options.defaultValue
|
|
28009
|
+
? _getDirty(name, get(_defaultValues, name))
|
|
28010
|
+
: _getDirty();
|
|
28011
|
+
}
|
|
28012
|
+
if (!options.keepError) {
|
|
28013
|
+
unset(_formState.errors, name);
|
|
28014
|
+
_proxyFormState.isValid && _updateValid();
|
|
28015
|
+
}
|
|
28016
|
+
_subjects.state.next({ ..._formState });
|
|
28017
|
+
}
|
|
28018
|
+
};
|
|
28019
|
+
const _reset = (formValues, keepStateOptions = {}) => {
|
|
28020
|
+
const updatedValues = formValues ? cloneObject(formValues) : _defaultValues;
|
|
28021
|
+
const cloneUpdatedValues = cloneObject(updatedValues);
|
|
28022
|
+
const values = formValues && !isEmptyObject(formValues)
|
|
28023
|
+
? cloneUpdatedValues
|
|
28024
|
+
: _defaultValues;
|
|
28025
|
+
if (!keepStateOptions.keepDefaultValues) {
|
|
28026
|
+
_defaultValues = updatedValues;
|
|
28027
|
+
}
|
|
28028
|
+
if (!keepStateOptions.keepValues) {
|
|
28029
|
+
if (keepStateOptions.keepDirtyValues || shouldCaptureDirtyFields) {
|
|
28030
|
+
for (const fieldName of _names.mount) {
|
|
28031
|
+
get(_formState.dirtyFields, fieldName)
|
|
28032
|
+
? set(values, fieldName, get(_formValues, fieldName))
|
|
28033
|
+
: setValue(fieldName, get(values, fieldName));
|
|
28034
|
+
}
|
|
28035
|
+
}
|
|
28036
|
+
else {
|
|
28037
|
+
if (isWeb && isUndefined(formValues)) {
|
|
28038
|
+
for (const name of _names.mount) {
|
|
28039
|
+
const field = get(_fields, name);
|
|
28040
|
+
if (field && field._f) {
|
|
28041
|
+
const fieldReference = Array.isArray(field._f.refs)
|
|
28042
|
+
? field._f.refs[0]
|
|
28043
|
+
: field._f.ref;
|
|
28044
|
+
if (isHTMLElement(fieldReference)) {
|
|
28045
|
+
const form = fieldReference.closest('form');
|
|
28046
|
+
if (form) {
|
|
28047
|
+
form.reset();
|
|
28048
|
+
break;
|
|
28049
|
+
}
|
|
28050
|
+
}
|
|
28051
|
+
}
|
|
28052
|
+
}
|
|
28053
|
+
}
|
|
28054
|
+
_fields = {};
|
|
28055
|
+
}
|
|
28056
|
+
_formValues = props.shouldUnregister
|
|
28057
|
+
? keepStateOptions.keepDefaultValues
|
|
28058
|
+
? cloneObject(_defaultValues)
|
|
28059
|
+
: {}
|
|
28060
|
+
: cloneObject(values);
|
|
28061
|
+
_subjects.array.next({
|
|
28062
|
+
values: { ...values },
|
|
28063
|
+
});
|
|
28064
|
+
_subjects.values.next({
|
|
28065
|
+
values: { ...values },
|
|
28066
|
+
});
|
|
28067
|
+
}
|
|
28068
|
+
_names = {
|
|
28069
|
+
mount: new Set(),
|
|
28070
|
+
unMount: new Set(),
|
|
28071
|
+
array: new Set(),
|
|
28072
|
+
watch: new Set(),
|
|
28073
|
+
watchAll: false,
|
|
28074
|
+
focus: '',
|
|
28075
|
+
};
|
|
28076
|
+
!_state.mount && flushRootRender();
|
|
28077
|
+
_state.mount = !_proxyFormState.isValid || !!keepStateOptions.keepIsValid;
|
|
28078
|
+
_state.watch = !!props.shouldUnregister;
|
|
28079
|
+
_subjects.state.next({
|
|
28080
|
+
submitCount: keepStateOptions.keepSubmitCount
|
|
28081
|
+
? _formState.submitCount
|
|
28082
|
+
: 0,
|
|
28083
|
+
isDirty: keepStateOptions.keepDirty
|
|
28084
|
+
? _formState.isDirty
|
|
28085
|
+
: !!(keepStateOptions.keepDefaultValues &&
|
|
28086
|
+
!deepEqual(formValues, _defaultValues)),
|
|
28087
|
+
isSubmitted: keepStateOptions.keepIsSubmitted
|
|
28088
|
+
? _formState.isSubmitted
|
|
28089
|
+
: false,
|
|
28090
|
+
dirtyFields: keepStateOptions.keepDirtyValues
|
|
28091
|
+
? _formState.dirtyFields
|
|
28092
|
+
: keepStateOptions.keepDefaultValues && formValues
|
|
28093
|
+
? getDirtyFields(_defaultValues, formValues)
|
|
28094
|
+
: {},
|
|
28095
|
+
touchedFields: keepStateOptions.keepTouched
|
|
28096
|
+
? _formState.touchedFields
|
|
28097
|
+
: {},
|
|
28098
|
+
errors: keepStateOptions.keepErrors ? _formState.errors : {},
|
|
28099
|
+
isSubmitSuccessful: keepStateOptions.keepIsSubmitSuccessful
|
|
28100
|
+
? _formState.isSubmitSuccessful
|
|
28101
|
+
: false,
|
|
28102
|
+
isSubmitting: false,
|
|
28103
|
+
});
|
|
28104
|
+
};
|
|
28105
|
+
const reset = (formValues, keepStateOptions) => _reset(isFunction(formValues)
|
|
28106
|
+
? formValues(_formValues)
|
|
28107
|
+
: formValues, keepStateOptions);
|
|
28108
|
+
const setFocus = (name, options = {}) => {
|
|
28109
|
+
const field = get(_fields, name);
|
|
28110
|
+
const fieldReference = field && field._f;
|
|
28111
|
+
if (fieldReference) {
|
|
28112
|
+
const fieldRef = fieldReference.refs
|
|
28113
|
+
? fieldReference.refs[0]
|
|
28114
|
+
: fieldReference.ref;
|
|
28115
|
+
if (fieldRef.focus) {
|
|
28116
|
+
fieldRef.focus();
|
|
28117
|
+
options.shouldSelect && fieldRef.select();
|
|
28118
|
+
}
|
|
28119
|
+
}
|
|
28120
|
+
};
|
|
28121
|
+
const _updateFormState = (updatedFormState) => {
|
|
28122
|
+
_formState = {
|
|
28123
|
+
..._formState,
|
|
28124
|
+
...updatedFormState,
|
|
28125
|
+
};
|
|
28126
|
+
};
|
|
28127
|
+
const _resetDefaultValues = () => isFunction(_options.defaultValues) &&
|
|
28128
|
+
_options.defaultValues().then((values) => {
|
|
28129
|
+
reset(values, _options.resetOptions);
|
|
28130
|
+
_subjects.state.next({
|
|
28131
|
+
isLoading: false,
|
|
28132
|
+
});
|
|
28133
|
+
});
|
|
28134
|
+
return {
|
|
28135
|
+
control: {
|
|
28136
|
+
register,
|
|
28137
|
+
unregister,
|
|
28138
|
+
getFieldState,
|
|
28139
|
+
handleSubmit,
|
|
28140
|
+
setError,
|
|
28141
|
+
_executeSchema,
|
|
28142
|
+
_getWatch,
|
|
28143
|
+
_getDirty,
|
|
28144
|
+
_updateValid,
|
|
28145
|
+
_removeUnmounted,
|
|
28146
|
+
_updateFieldArray,
|
|
28147
|
+
_updateDisabledField,
|
|
28148
|
+
_getFieldArray,
|
|
28149
|
+
_reset,
|
|
28150
|
+
_resetDefaultValues,
|
|
28151
|
+
_updateFormState,
|
|
28152
|
+
_disableForm,
|
|
28153
|
+
_subjects,
|
|
28154
|
+
_proxyFormState,
|
|
28155
|
+
_setErrors,
|
|
28156
|
+
get _fields() {
|
|
28157
|
+
return _fields;
|
|
28158
|
+
},
|
|
28159
|
+
get _formValues() {
|
|
28160
|
+
return _formValues;
|
|
28161
|
+
},
|
|
28162
|
+
get _state() {
|
|
28163
|
+
return _state;
|
|
28164
|
+
},
|
|
28165
|
+
set _state(value) {
|
|
28166
|
+
_state = value;
|
|
28167
|
+
},
|
|
28168
|
+
get _defaultValues() {
|
|
28169
|
+
return _defaultValues;
|
|
28170
|
+
},
|
|
28171
|
+
get _names() {
|
|
28172
|
+
return _names;
|
|
28173
|
+
},
|
|
28174
|
+
set _names(value) {
|
|
28175
|
+
_names = value;
|
|
28176
|
+
},
|
|
28177
|
+
get _formState() {
|
|
28178
|
+
return _formState;
|
|
28179
|
+
},
|
|
28180
|
+
set _formState(value) {
|
|
28181
|
+
_formState = value;
|
|
28182
|
+
},
|
|
28183
|
+
get _options() {
|
|
28184
|
+
return _options;
|
|
28185
|
+
},
|
|
28186
|
+
set _options(value) {
|
|
28187
|
+
_options = {
|
|
28188
|
+
..._options,
|
|
28189
|
+
...value,
|
|
28190
|
+
};
|
|
28191
|
+
},
|
|
28192
|
+
},
|
|
28193
|
+
trigger,
|
|
28194
|
+
register,
|
|
28195
|
+
handleSubmit,
|
|
28196
|
+
watch,
|
|
28197
|
+
setValue,
|
|
28198
|
+
getValues,
|
|
28199
|
+
reset,
|
|
28200
|
+
resetField,
|
|
28201
|
+
clearErrors,
|
|
28202
|
+
unregister,
|
|
28203
|
+
setError,
|
|
28204
|
+
setFocus,
|
|
28205
|
+
getFieldState,
|
|
28206
|
+
};
|
|
28207
|
+
}
|
|
28208
|
+
|
|
28209
|
+
/**
|
|
28210
|
+
* Custom hook to manage the entire form.
|
|
28211
|
+
*
|
|
28212
|
+
* @remarks
|
|
28213
|
+
* [API](https://react-hook-form.com/docs/useform) • [Demo](https://codesandbox.io/s/react-hook-form-get-started-ts-5ksmm) • [Video](https://www.youtube.com/watch?v=RkXv4AXXC_4)
|
|
28214
|
+
*
|
|
28215
|
+
* @param props - form configuration and validation parameters.
|
|
28216
|
+
*
|
|
28217
|
+
* @returns methods - individual functions to manage the form state. {@link UseFormReturn}
|
|
28218
|
+
*
|
|
28219
|
+
* @example
|
|
28220
|
+
* ```tsx
|
|
28221
|
+
* function App() {
|
|
28222
|
+
* const { register, handleSubmit, watch, formState: { errors } } = useForm();
|
|
28223
|
+
* const onSubmit = data => console.log(data);
|
|
28224
|
+
*
|
|
28225
|
+
* console.log(watch("example"));
|
|
28226
|
+
*
|
|
28227
|
+
* return (
|
|
28228
|
+
* <form onSubmit={handleSubmit(onSubmit)}>
|
|
28229
|
+
* <input defaultValue="test" {...register("example")} />
|
|
28230
|
+
* <input {...register("exampleRequired", { required: true })} />
|
|
28231
|
+
* {errors.exampleRequired && <span>This field is required</span>}
|
|
28232
|
+
* <button>Submit</button>
|
|
28233
|
+
* </form>
|
|
28234
|
+
* );
|
|
28235
|
+
* }
|
|
28236
|
+
* ```
|
|
28237
|
+
*/
|
|
28238
|
+
function useForm(props = {}) {
|
|
28239
|
+
const _formControl = React__default.default.useRef();
|
|
28240
|
+
const _values = React__default.default.useRef();
|
|
28241
|
+
const [formState, updateFormState] = React__default.default.useState({
|
|
28242
|
+
isDirty: false,
|
|
28243
|
+
isValidating: false,
|
|
28244
|
+
isLoading: isFunction(props.defaultValues),
|
|
28245
|
+
isSubmitted: false,
|
|
28246
|
+
isSubmitting: false,
|
|
28247
|
+
isSubmitSuccessful: false,
|
|
28248
|
+
isValid: false,
|
|
28249
|
+
submitCount: 0,
|
|
28250
|
+
dirtyFields: {},
|
|
28251
|
+
touchedFields: {},
|
|
28252
|
+
errors: props.errors || {},
|
|
28253
|
+
disabled: false,
|
|
28254
|
+
defaultValues: isFunction(props.defaultValues)
|
|
28255
|
+
? undefined
|
|
28256
|
+
: props.defaultValues,
|
|
28257
|
+
});
|
|
28258
|
+
if (!_formControl.current) {
|
|
28259
|
+
_formControl.current = {
|
|
28260
|
+
...createFormControl(props, () => updateFormState((formState) => ({ ...formState }))),
|
|
28261
|
+
formState,
|
|
28262
|
+
};
|
|
28263
|
+
}
|
|
28264
|
+
const control = _formControl.current.control;
|
|
28265
|
+
control._options = props;
|
|
28266
|
+
useSubscribe({
|
|
28267
|
+
subject: control._subjects.state,
|
|
28268
|
+
next: (value) => {
|
|
28269
|
+
if (shouldRenderFormState(value, control._proxyFormState, control._updateFormState, true)) {
|
|
28270
|
+
updateFormState({ ...control._formState });
|
|
28271
|
+
}
|
|
28272
|
+
},
|
|
28273
|
+
});
|
|
28274
|
+
React__default.default.useEffect(() => control._disableForm(props.disabled), [control, props.disabled]);
|
|
28275
|
+
React__default.default.useEffect(() => {
|
|
28276
|
+
if (control._proxyFormState.isDirty) {
|
|
28277
|
+
const isDirty = control._getDirty();
|
|
28278
|
+
if (isDirty !== formState.isDirty) {
|
|
28279
|
+
control._subjects.state.next({
|
|
28280
|
+
isDirty,
|
|
28281
|
+
});
|
|
28282
|
+
}
|
|
28283
|
+
}
|
|
28284
|
+
}, [control, formState.isDirty]);
|
|
28285
|
+
React__default.default.useEffect(() => {
|
|
28286
|
+
if (props.values && !deepEqual(props.values, _values.current)) {
|
|
28287
|
+
control._reset(props.values, control._options.resetOptions);
|
|
28288
|
+
_values.current = props.values;
|
|
28289
|
+
updateFormState((state) => ({ ...state }));
|
|
28290
|
+
}
|
|
28291
|
+
else {
|
|
28292
|
+
control._resetDefaultValues();
|
|
28293
|
+
}
|
|
28294
|
+
}, [props.values, control]);
|
|
28295
|
+
React__default.default.useEffect(() => {
|
|
28296
|
+
if (props.errors) {
|
|
28297
|
+
control._setErrors(props.errors);
|
|
28298
|
+
}
|
|
28299
|
+
}, [props.errors, control]);
|
|
28300
|
+
React__default.default.useEffect(() => {
|
|
28301
|
+
if (!control._state.mount) {
|
|
28302
|
+
control._updateValid();
|
|
28303
|
+
control._state.mount = true;
|
|
28304
|
+
}
|
|
28305
|
+
if (control._state.watch) {
|
|
28306
|
+
control._state.watch = false;
|
|
28307
|
+
control._subjects.state.next({ ...control._formState });
|
|
28308
|
+
}
|
|
28309
|
+
control._removeUnmounted();
|
|
28310
|
+
});
|
|
28311
|
+
_formControl.current.formState = getProxyFormState(formState, control);
|
|
28312
|
+
return _formControl.current;
|
|
28313
|
+
}
|
|
28314
|
+
|
|
28315
|
+
const FormContainer$1 = styled__default.default(Container$n)`
|
|
28316
|
+
display: block;
|
|
28317
|
+
.grecaptcha-badge {
|
|
28318
|
+
visibility: hidden;
|
|
28319
|
+
}
|
|
28320
|
+
`;
|
|
28321
|
+
|
|
28322
|
+
const Legend$2 = styled__default.default.legend`
|
|
28323
|
+
margin-bottom: 5px;
|
|
28324
|
+
font-weight: bold;
|
|
28325
|
+
`;
|
|
28326
|
+
|
|
28327
|
+
const Label$3 = styled__default.default.label`
|
|
28328
|
+
margin-bottom: 5px;
|
|
28329
|
+
font-weight: bold;
|
|
28330
|
+
`;
|
|
28331
|
+
|
|
28332
|
+
const Hint = styled__default.default.p``;
|
|
28333
|
+
|
|
28334
|
+
const FormErrorText = styled__default.default(ErrorText$2)``;
|
|
28335
|
+
|
|
28336
|
+
const Hidden = styled__default.default.span`
|
|
28337
|
+
${VisuallyHidden$3}
|
|
28338
|
+
`;
|
|
28339
|
+
|
|
28340
|
+
const Terms = styled__default.default.p`
|
|
28341
|
+
font-size: ${(props) => props.theme.theme_vars.fontSizes.extra_small};
|
|
28342
|
+
`;
|
|
28343
|
+
|
|
28344
|
+
const QuestionContainer = styled__default.default.div`
|
|
28345
|
+
border: 2px solid ${(props) => props.theme.theme_vars.colours.grey_light};
|
|
28346
|
+
padding: ${(props) => props.theme.theme_vars.spacingSizes.small};
|
|
28347
|
+
border-radius: ${(props) => props.theme.theme_vars.border_radius};
|
|
28348
|
+
display: flex;
|
|
28349
|
+
flex-direction: column;
|
|
28350
|
+
flex-grow: 1;
|
|
28351
|
+
height: 100%;
|
|
28352
|
+
`;
|
|
28353
|
+
|
|
28354
|
+
const QuestionTitle = styled__default.default.p`
|
|
28355
|
+
font-weight: bold;
|
|
28356
|
+
`;
|
|
28357
|
+
|
|
28358
|
+
const QuestionButton = styled__default.default.div`
|
|
28359
|
+
flex-grow: 1;
|
|
28360
|
+
display: flex;
|
|
28361
|
+
flex-direction: row;
|
|
28362
|
+
align-items: flex-end;
|
|
28363
|
+
justify-content: center;
|
|
28364
|
+
`;
|
|
28365
|
+
|
|
28366
|
+
const StyledTextarea = styled__default.default.textarea`
|
|
28367
|
+
${(props) => props.theme.fontStyles}
|
|
28368
|
+
margin-top: 0 !important;
|
|
28369
|
+
margin-bottom: 25px;
|
|
28370
|
+
padding: 5px;
|
|
28371
|
+
border: solid
|
|
28372
|
+
${(props) => (props.$isErrored ? props.theme.theme_vars.colours.negative : props.theme.theme_vars.colours.black)};
|
|
28373
|
+
border-width: ${(props) => (props.$isErrored ? '3px' : '2px')};
|
|
28374
|
+
border-radius: ${(props) => props.theme.theme_vars.border_radius};
|
|
28375
|
+
display: block;
|
|
28376
|
+
width: ${(props) => (props.$isFullWidth ? '100%' : 'auto')};
|
|
28377
|
+
|
|
28378
|
+
&:focus {
|
|
28379
|
+
outline: none;
|
|
28380
|
+
box-shadow: ${(props) => props.theme.theme_vars.colours.focus} 0 0 0 3px;
|
|
28381
|
+
transition: box-shadow 0.3s ease 0s;
|
|
28382
|
+
}
|
|
28383
|
+
`;
|
|
28384
|
+
const ErrorText = styled__default.default.p`
|
|
28385
|
+
${(props) => props.theme.fontStyles}
|
|
28386
|
+
color: ${(props) => props.theme.theme_vars.colours.negative};
|
|
28387
|
+
font-weight: bold;
|
|
28388
|
+
margin-bottom: 5px;
|
|
28389
|
+
font-size: 14px;
|
|
28390
|
+
font-size: 0.8rem;
|
|
28391
|
+
line-height: 1.1;
|
|
28392
|
+
|
|
28393
|
+
@media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.m}) {
|
|
28394
|
+
font-size: 18px;
|
|
28395
|
+
font-size: 1rem;
|
|
28396
|
+
line-height: 1.25;
|
|
28397
|
+
}
|
|
28398
|
+
`;
|
|
28399
|
+
|
|
28400
|
+
/**
|
|
28401
|
+
* Primary UI component for user interaction
|
|
28402
|
+
* If value is set then treat as controlled component
|
|
28403
|
+
*/
|
|
28404
|
+
var Textarea = function (_a) {
|
|
28405
|
+
var _b = _a.placeholder, placeholder = _b === void 0 ? '' : _b, _c = _a.isErrored, isErrored = _c === void 0 ? false : _c, errorText = _a.errorText, name = _a.name, maxLength = _a.maxLength, defaultValue = _a.defaultValue, onChange = _a.onChange, id = _a.id, value = _a.value, _d = _a.isFullWidth, isFullWidth = _d === void 0 ? false : _d;
|
|
28406
|
+
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
28407
|
+
errorText && React__default.default.createElement(ErrorText, null, errorText),
|
|
28408
|
+
typeof value !== 'undefined' ? (React__default.default.createElement(StyledTextarea, { onChange: onChange, placeholder: placeholder, name: name, "$isErrored": isErrored, maxLength: maxLength, value: value, id: id, "$isFullWidth": isFullWidth })) : (React__default.default.createElement(StyledTextarea, { onChange: onChange, placeholder: placeholder, name: name, "$isErrored": isErrored, maxLength: maxLength, defaultValue: defaultValue, id: id, "$isFullWidth": isFullWidth }))));
|
|
28409
|
+
};
|
|
28410
|
+
|
|
28411
|
+
const Container$i = styled__default.default.div`
|
|
28412
|
+
display: block;
|
|
28413
|
+
border-left: ${(props) =>
|
|
28414
|
+
props.$isErrored
|
|
28415
|
+
? `${props.theme.theme_vars.border_width} solid ${props.theme.theme_vars.colours.negative}`
|
|
28416
|
+
: 'none'};
|
|
28417
|
+
padding-left: ${(props) => (props.$isErrored ? ` ${props.theme.theme_vars.spacingSizes.extra_small}` : '0')};
|
|
28418
|
+
padding-bottom: 10px;
|
|
28419
|
+
`;
|
|
28420
|
+
|
|
28421
|
+
const Category$2 = styled__default.default.div`
|
|
28422
|
+
font-size: ${(props) => props.theme.theme_vars.fontSizes.small};
|
|
28423
|
+
display: block;
|
|
28424
|
+
position: relative;
|
|
28425
|
+
min-height: 40px;
|
|
28426
|
+
|
|
28427
|
+
padding-left: 40px;
|
|
28428
|
+
clear: left;
|
|
28429
|
+
`;
|
|
28430
|
+
|
|
28431
|
+
const CategoryInput = styled__default.default.input`
|
|
28432
|
+
cursor: pointer;
|
|
28433
|
+
position: absolute;
|
|
28434
|
+
z-index: 1;
|
|
28435
|
+
top: -2px;
|
|
28436
|
+
left: -2px;
|
|
28437
|
+
width: 44px;
|
|
28438
|
+
height: 44px;
|
|
28439
|
+
margin: 0;
|
|
28440
|
+
opacity: 0;
|
|
28441
|
+
|
|
28442
|
+
&:focus + label:before {
|
|
28443
|
+
box-shadow: 0 0 0 3px ${(props) => props.theme.theme_vars.colours.focus};
|
|
28444
|
+
}
|
|
28445
|
+
`;
|
|
28446
|
+
|
|
28447
|
+
/**
|
|
28448
|
+
* If single selection then use styles for radio button, otherwise checkbox styles
|
|
28449
|
+
*/
|
|
28450
|
+
const checkedMarker = (props) => {
|
|
28451
|
+
if (props.$singleSelection) {
|
|
28452
|
+
return styled.css`
|
|
28453
|
+
top: 10px;
|
|
28454
|
+
left: 10px;
|
|
28455
|
+
width: 0;
|
|
28456
|
+
height: 0;
|
|
28457
|
+
border: 10px solid currentcolor;
|
|
28458
|
+
border-radius: 50%;
|
|
28459
|
+
background: currentcolor;
|
|
28460
|
+
`;
|
|
28461
|
+
} else {
|
|
28462
|
+
return styled.css`
|
|
28463
|
+
top: 11px;
|
|
28464
|
+
left: 9px;
|
|
28465
|
+
width: 23px;
|
|
28466
|
+
height: 12px;
|
|
28467
|
+
-webkit-transform: rotate(-45deg);
|
|
28468
|
+
-ms-transform: rotate(-45deg);
|
|
28469
|
+
transform: rotate(-45deg);
|
|
28470
|
+
border: solid;
|
|
28471
|
+
border-width: 0 0 5px 5px;
|
|
28472
|
+
border-top-color: transparent;
|
|
28473
|
+
background: transparent;
|
|
28474
|
+
`;
|
|
28475
|
+
}
|
|
28476
|
+
};
|
|
28477
|
+
|
|
28478
|
+
const CategoryInputLabel = styled__default.default.label`
|
|
28479
|
+
display: inline-block;
|
|
28480
|
+
margin-bottom: 0;
|
|
28481
|
+
padding: 8px 15px 5px;
|
|
28482
|
+
cursor: pointer;
|
|
28483
|
+
-ms-touch-action: manipulation;
|
|
28484
|
+
touch-action: manipulation;
|
|
28485
|
+
color: #0b0c0c;
|
|
28486
|
+
display: block;
|
|
28487
|
+
margin-bottom: 5px;
|
|
28488
|
+
|
|
28489
|
+
&:before {
|
|
28490
|
+
content: '';
|
|
28491
|
+
-webkit-box-sizing: border-box;
|
|
28492
|
+
box-sizing: border-box;
|
|
28493
|
+
position: absolute;
|
|
28494
|
+
top: 0;
|
|
28495
|
+
left: 0;
|
|
28496
|
+
width: 40px;
|
|
28497
|
+
height: 40px;
|
|
28498
|
+
border: 2px solid currentColor;
|
|
28499
|
+
background: transparent;
|
|
28500
|
+
border-radius: ${(props) => (props.$singleSelection ? '100%' : 0)};
|
|
28501
|
+
}
|
|
28502
|
+
|
|
28503
|
+
&:after {
|
|
28504
|
+
content: '';
|
|
28505
|
+
-webkit-box-sizing: border-box;
|
|
28506
|
+
box-sizing: border-box;
|
|
28507
|
+
position: absolute;
|
|
28508
|
+
opacity: ${(props) => (props.$isChecked ? 1 : 0)};
|
|
28509
|
+
${checkedMarker}
|
|
28510
|
+
}
|
|
28511
|
+
`;
|
|
28512
|
+
|
|
28513
|
+
var RadioCheckboxInput = function (_a) {
|
|
28514
|
+
var singleSelection = _a.singleSelection, value = _a.value, name = _a.name, onChange = _a.onChange, checked = _a.checked, label = _a.label, _b = _a.isErrored, isErrored = _b === void 0 ? false : _b;
|
|
28515
|
+
var id = React.useId();
|
|
28516
|
+
return (React__default.default.createElement(Container$i, { "data-testid": "RadioCheckboxInput", "$isErrored": isErrored },
|
|
28517
|
+
React__default.default.createElement(Category$2, null,
|
|
28518
|
+
React__default.default.createElement(CategoryInput, { type: singleSelection ? 'radio' : 'checkbox', value: value, id: id, name: name, onClick: onChange, defaultChecked: checked }),
|
|
28519
|
+
React__default.default.createElement(CategoryInputLabel, { "$isChecked": checked, htmlFor: id, "$singleSelection": singleSelection }, label))));
|
|
28520
|
+
};
|
|
28521
|
+
|
|
28522
|
+
function L(r) {
|
|
28523
|
+
const [o, c] = React.useState(r ? "loading" : "idle");
|
|
28524
|
+
return React.useEffect(
|
|
28525
|
+
() => {
|
|
28526
|
+
if (!r) {
|
|
28527
|
+
c("idle");
|
|
28528
|
+
return;
|
|
28529
|
+
}
|
|
28530
|
+
let e = document.querySelector(`script[src="${r}"]`);
|
|
28531
|
+
if (e)
|
|
28532
|
+
c(e.getAttribute("data-status"));
|
|
28533
|
+
else {
|
|
28534
|
+
e = document.createElement("script"), e.src = r, e.async = !0, e.defer = !0, e.setAttribute("data-status", "loading"), document.body.appendChild(e);
|
|
28535
|
+
const a = (i) => {
|
|
28536
|
+
e.setAttribute(
|
|
28537
|
+
"data-status",
|
|
28538
|
+
i.type === "load" ? "ready" : "error"
|
|
28539
|
+
);
|
|
28540
|
+
};
|
|
28541
|
+
e.addEventListener("load", a), e.addEventListener("error", a);
|
|
28542
|
+
}
|
|
28543
|
+
const n = (a) => {
|
|
28544
|
+
c(a.type === "load" ? "ready" : "error");
|
|
28545
|
+
};
|
|
28546
|
+
return e.addEventListener("load", n), e.addEventListener("error", n), () => {
|
|
28547
|
+
e && (e.removeEventListener("load", n), e.removeEventListener("error", n));
|
|
28548
|
+
};
|
|
28549
|
+
},
|
|
28550
|
+
[r]
|
|
28551
|
+
// Only re-run effect if script src changes
|
|
28552
|
+
), o;
|
|
28553
|
+
}
|
|
28554
|
+
const b = "https://www.google.com/recaptcha/api.js?render=explicit";
|
|
28555
|
+
let l;
|
|
28556
|
+
function R({
|
|
28557
|
+
containerId: r,
|
|
28558
|
+
sitekey: o,
|
|
28559
|
+
size: c,
|
|
28560
|
+
theme: e,
|
|
28561
|
+
badge: n,
|
|
28562
|
+
successCallback: a,
|
|
28563
|
+
expiredCallback: i,
|
|
28564
|
+
errorCallback: h
|
|
28565
|
+
}) {
|
|
28566
|
+
var w;
|
|
28567
|
+
L(b);
|
|
28568
|
+
const [s, f] = React.useState(!!((w = window == null ? void 0 : window.grecaptcha) != null && w.render)), [t, v] = React.useState(null);
|
|
28569
|
+
React.useEffect(() => (l = window.setInterval(() => {
|
|
28570
|
+
var d;
|
|
28571
|
+
(d = window == null ? void 0 : window.grecaptcha) != null && d.render && f(!0);
|
|
28572
|
+
}, 500), () => {
|
|
28573
|
+
clearInterval(l);
|
|
28574
|
+
}), []), React.useEffect(() => {
|
|
28575
|
+
if (s && window.grecaptcha && t === null) {
|
|
28576
|
+
clearInterval(l);
|
|
28577
|
+
const d = window.grecaptcha.render(r, {
|
|
28578
|
+
sitekey: o,
|
|
28579
|
+
size: c,
|
|
28580
|
+
theme: e,
|
|
28581
|
+
badge: n,
|
|
28582
|
+
callback: a,
|
|
28583
|
+
"expired-callback": i,
|
|
28584
|
+
"error-callback": h
|
|
28585
|
+
});
|
|
28586
|
+
v(d);
|
|
28587
|
+
}
|
|
28588
|
+
}, [s, a, t, r]);
|
|
28589
|
+
const m = React.useCallback(() => {
|
|
28590
|
+
t !== null && window.grecaptcha && window.grecaptcha.execute(t);
|
|
28591
|
+
}, [t]), E = React.useCallback(() => {
|
|
28592
|
+
t !== null && window.grecaptcha && window.grecaptcha.reset(t);
|
|
28593
|
+
}, [t]);
|
|
28594
|
+
return {
|
|
28595
|
+
execute: m,
|
|
28596
|
+
recaptchaLoaded: s,
|
|
28597
|
+
recaptchaWidget: t,
|
|
28598
|
+
reset: E
|
|
28599
|
+
};
|
|
28600
|
+
}
|
|
28601
|
+
|
|
28602
|
+
const Spinner = styled__default.default.div`
|
|
28603
|
+
display: inline-block;
|
|
28604
|
+
width: 80px;
|
|
28605
|
+
height: 80px;
|
|
28606
|
+
|
|
28607
|
+
&:after {
|
|
28608
|
+
content: " ";
|
|
28609
|
+
display: block;
|
|
28610
|
+
width: 50px;
|
|
28611
|
+
height: 50px;
|
|
28612
|
+
margin: 8px;
|
|
28613
|
+
border-radius: 50%;
|
|
28614
|
+
border: 6px solid ${props => props.theme.theme_vars.colours.action};
|
|
28615
|
+
border-color: ${props => props.theme.theme_vars.colours.action} transparent ${props => props.theme.theme_vars.colours.action} transparent;
|
|
28616
|
+
animation: lds-dual-ring 1.2s linear infinite;
|
|
28617
|
+
}
|
|
28618
|
+
|
|
28619
|
+
@keyframes lds-dual-ring {
|
|
28620
|
+
0% {
|
|
28621
|
+
transform: rotate(0deg);
|
|
28622
|
+
}
|
|
28623
|
+
100% {
|
|
28624
|
+
transform: rotate(360deg);
|
|
28625
|
+
}
|
|
28626
|
+
}
|
|
28627
|
+
|
|
28628
|
+
`;
|
|
28629
|
+
|
|
28630
|
+
var LoadingSpinner = function () {
|
|
28631
|
+
return React__default.default.createElement(Spinner, null);
|
|
28632
|
+
};
|
|
28633
|
+
|
|
28634
|
+
const Container$h = styled__default.default.div`
|
|
28635
|
+
display: block;
|
|
28636
|
+
background-color: ${(props) => props.theme.theme_vars.colours.positive};
|
|
28637
|
+
padding: ${(props) => props.theme.theme_vars.spacingSizes.small};
|
|
28638
|
+
display: flex;
|
|
28639
|
+
justify-content: center;
|
|
28640
|
+
|
|
28641
|
+
@media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.m}) {
|
|
28642
|
+
padding: ${(props) => props.theme.theme_vars.spacingSizes.large};
|
|
28643
|
+
}
|
|
28644
|
+
`;
|
|
28645
|
+
|
|
28646
|
+
const Heading = styled__default.default.h2`
|
|
28647
|
+
${(props) => props.theme.fontStyles}
|
|
28648
|
+
${(props) => props.theme.theme_vars.h2}
|
|
28649
|
+
font-size: ${(props) => props.theme.theme_vars.fontSizes.medium};
|
|
28650
|
+
color: ${(props) => props.theme.theme_vars.colours.white};
|
|
28651
|
+
text-align: center;
|
|
28652
|
+
`;
|
|
28653
|
+
|
|
28654
|
+
const Content$2 = styled__default.default.div`
|
|
28655
|
+
${(props) => props.theme.fontStyles}
|
|
28656
|
+
color: ${(props) => props.theme.theme_vars.colours.white};
|
|
28657
|
+
display: flex;
|
|
28658
|
+
justify-content: center;
|
|
28659
|
+
text-align: center;
|
|
28660
|
+
`;
|
|
28661
|
+
|
|
28662
|
+
/**
|
|
28663
|
+
* A panel to show success messages
|
|
28664
|
+
*/
|
|
28665
|
+
var Panel = function (_a) {
|
|
28666
|
+
var heading = _a.heading, children = _a.children;
|
|
28667
|
+
return (React__default.default.createElement(Container$h, { "data-testid": "Panel" },
|
|
28668
|
+
React__default.default.createElement(Heading, null, heading),
|
|
28669
|
+
children && React__default.default.createElement(Content$2, null, children)));
|
|
28670
|
+
};
|
|
28671
|
+
|
|
28672
|
+
var ratingValues = ['1', '2', '3', '4', '5'];
|
|
28673
|
+
var HelpfulEnum;
|
|
28674
|
+
(function (HelpfulEnum) {
|
|
28675
|
+
HelpfulEnum["yes"] = "Yes";
|
|
28676
|
+
HelpfulEnum["no"] = "No";
|
|
28677
|
+
})(HelpfulEnum || (HelpfulEnum = {}));
|
|
28678
|
+
/**
|
|
28679
|
+
* A form that allows visitors to rate the website page.
|
|
28680
|
+
* If the user answers No to 'Is this information helpful?' then they are presented with more questions.
|
|
28681
|
+
* The form is protected by Google recaptcha and needs a recaptcha sitekey to work.
|
|
28682
|
+
*/
|
|
28683
|
+
var RateThisPage = function (_a) {
|
|
28684
|
+
var _b;
|
|
28685
|
+
var onSubmit = _a.onSubmit, complaintsFormLink = _a.complaintsFormLink, _c = _a.isLoading, isLoading = _c === void 0 ? false : _c, setIsLoading = _a.setIsLoading, _d = _a.isSuccessful, isSuccessful = _d === void 0 ? false : _d;
|
|
28686
|
+
var _e = useForm({
|
|
28687
|
+
defaultValues: {
|
|
28688
|
+
HowCanWeImprove: '',
|
|
28689
|
+
Email: '',
|
|
28690
|
+
BarriersOrIssues: '',
|
|
28691
|
+
},
|
|
28692
|
+
}), handleSubmit = _e.handleSubmit, control = _e.control, errors = _e.formState.errors, watch = _e.watch, register = _e.register, setValue = _e.setValue;
|
|
28693
|
+
var watchIsHelpful = watch('IsHelpful');
|
|
28694
|
+
var _f = React.useState(false), showQuestion = _f[0], setShowQuestion = _f[1];
|
|
28695
|
+
var _g = React.useState(false), showFullForm = _g[0], setShowFullForm = _g[1];
|
|
28696
|
+
var _h = React.useState(true), showSubmit = _h[0], setShowSubmit = _h[1];
|
|
28697
|
+
var recaptchaKey = (_b = process.env.NEXT_PUBLIC_RECAPTCHA_KEY) !== null && _b !== void 0 ? _b : '';
|
|
28698
|
+
var recaptchaContainerId = 'recaptchaContainer';
|
|
28699
|
+
/**
|
|
28700
|
+
* called when captcha succeeds
|
|
28701
|
+
*/
|
|
28702
|
+
var successCallback = function (response) {
|
|
28703
|
+
setValue('ReCaptcha', response);
|
|
28704
|
+
setIsLoading(false);
|
|
28705
|
+
handleSubmit(function (data) { return onSubmit(data); })();
|
|
28706
|
+
};
|
|
28707
|
+
var errorCallback = function () {
|
|
28708
|
+
setIsLoading(false);
|
|
28709
|
+
};
|
|
28710
|
+
var _j = R({
|
|
28711
|
+
containerId: recaptchaContainerId,
|
|
28712
|
+
successCallback: successCallback,
|
|
28713
|
+
errorCallback: errorCallback,
|
|
28714
|
+
sitekey: recaptchaKey,
|
|
28715
|
+
size: 'invisible',
|
|
28716
|
+
}), recaptchaLoaded = _j.recaptchaLoaded, execute = _j.execute, reset = _j.reset;
|
|
28717
|
+
React.useEffect(function () {
|
|
28718
|
+
if (watchIsHelpful && String(watchIsHelpful) === 'No') {
|
|
28719
|
+
setShowQuestion(true);
|
|
28720
|
+
setShowSubmit(false);
|
|
28721
|
+
}
|
|
28722
|
+
else if (watchIsHelpful && String(watchIsHelpful) === 'Yes') {
|
|
28723
|
+
setShowQuestion(false);
|
|
28724
|
+
setShowSubmit(true);
|
|
28725
|
+
setShowFullForm(false);
|
|
28726
|
+
}
|
|
28727
|
+
else {
|
|
28728
|
+
setShowQuestion(false);
|
|
28729
|
+
setShowFullForm(false);
|
|
28730
|
+
setShowSubmit(true);
|
|
28731
|
+
}
|
|
28732
|
+
}, [watchIsHelpful]);
|
|
28733
|
+
var executeCaptcha = function (e) {
|
|
28734
|
+
e.preventDefault();
|
|
28735
|
+
reset();
|
|
28736
|
+
execute();
|
|
28737
|
+
setIsLoading(true);
|
|
28738
|
+
};
|
|
28739
|
+
var handleQuestionButton = function (e) {
|
|
28740
|
+
e.preventDefault();
|
|
28741
|
+
setShowQuestion(false);
|
|
28742
|
+
setShowFullForm(true);
|
|
28743
|
+
setShowSubmit(true);
|
|
28744
|
+
};
|
|
28745
|
+
return (React__default.default.createElement(FormContainer$1, { as: "section", "data-testid": "RateThisPage", "aria-label": "Rate This Page" }, isSuccessful ? (React__default.default.createElement(Panel, { heading: "Thank you for your feedback." })) : (React__default.default.createElement("form", { onSubmit: executeCaptcha },
|
|
28746
|
+
React__default.default.createElement(Row$1, null,
|
|
28747
|
+
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
28748
|
+
React__default.default.createElement("fieldset", { "aria-describedby": errors.IsHelpful ? 'IsHelpfulError' : 'IsHelpfulLegend' },
|
|
28749
|
+
React__default.default.createElement(Legend$2, { id: "IsHelpfulLegend" }, "Is this information helpful?"),
|
|
28750
|
+
React__default.default.createElement(Controller, { name: "IsHelpful", control: control, rules: { required: true }, render: function (_a) {
|
|
28751
|
+
var _b = _a.field, onChange = _b.onChange, value = _b.value;
|
|
28752
|
+
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
28753
|
+
errors.IsHelpful && (React__default.default.createElement(FormErrorText, { id: "IsHelpfulError" },
|
|
28754
|
+
React__default.default.createElement(Hidden, null, "Error:"),
|
|
28755
|
+
" The field is this information helpful is required.")),
|
|
28756
|
+
Object.entries(HelpfulEnum).map(function (_a) {
|
|
28757
|
+
var key = _a[0], enumValue = _a[1];
|
|
28758
|
+
return (React__default.default.createElement(RadioCheckboxInput, { key: key, value: enumValue, label: HelpfulEnum[key], checked: String(value) == enumValue, name: "IsHelpful", singleSelection: true, onChange: onChange, isErrored: errors.IsHelpful ? true : false }));
|
|
28759
|
+
})));
|
|
28760
|
+
} }))),
|
|
28761
|
+
showQuestion && (React__default.default.createElement(React__default.default.Fragment, null,
|
|
28762
|
+
React__default.default.createElement(Column, { small: "full", medium: "full", large: "one-half" },
|
|
28763
|
+
React__default.default.createElement(QuestionContainer, null,
|
|
28764
|
+
React__default.default.createElement(QuestionTitle, null, "Service"),
|
|
28765
|
+
React__default.default.createElement("p", null, "You may have comments about the quality of the service that's been provided."),
|
|
28766
|
+
React__default.default.createElement("ul", null,
|
|
28767
|
+
React__default.default.createElement("li", null, "I have waited too long for something to happen"),
|
|
28768
|
+
React__default.default.createElement("li", null, "I'm struggling to contact the service"),
|
|
28769
|
+
React__default.default.createElement("li", null, "I don't think I have been treated fairly"),
|
|
28770
|
+
React__default.default.createElement("li", null, "I feel as if I have been misled")),
|
|
28771
|
+
React__default.default.createElement(QuestionButton, null,
|
|
28772
|
+
React__default.default.createElement(Button$4, { url: complaintsFormLink }, "I have a comment or complaint about this service")))),
|
|
28773
|
+
React__default.default.createElement(Column, { small: "full", medium: "full", large: "one-half" },
|
|
28774
|
+
React__default.default.createElement(QuestionContainer, null,
|
|
28775
|
+
React__default.default.createElement(QuestionTitle, null, "Content"),
|
|
28776
|
+
React__default.default.createElement("p", null, "You may have comments about the content on the webpage."),
|
|
28777
|
+
React__default.default.createElement("p", null, "Your feedback will help us improve our website and the content we include."),
|
|
28778
|
+
React__default.default.createElement("ul", null,
|
|
28779
|
+
React__default.default.createElement("li", null, "The information on this page is difficult to understand"),
|
|
28780
|
+
React__default.default.createElement("li", null, "This page isn't giving me the information I need"),
|
|
28781
|
+
React__default.default.createElement("li", null, "This page contains information that is wrong or out of date"),
|
|
28782
|
+
React__default.default.createElement("li", null, "This page could have been written or presented better")),
|
|
28783
|
+
React__default.default.createElement(QuestionButton, null,
|
|
28784
|
+
React__default.default.createElement(FormButton, { text: "I have feedback about the information on this page", type: "button", size: "medium", onClick: handleQuestionButton })))))),
|
|
28785
|
+
showFullForm && (React__default.default.createElement(React__default.default.Fragment, null,
|
|
28786
|
+
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
28787
|
+
React__default.default.createElement("fieldset", { "aria-describedby": "HowEasyToFindLegend" },
|
|
28788
|
+
React__default.default.createElement(Legend$2, { id: "HowEasyToFindLegend" }, "How easy was it to find what you were looking for?"),
|
|
28789
|
+
React__default.default.createElement(Hint, null, "1 being very easy and 5 being extremely difficult."),
|
|
28790
|
+
React__default.default.createElement(Controller, { name: "HowEasyToFind", control: control, rules: { pattern: /^[1-5]+$/i }, render: function (_a) {
|
|
28791
|
+
var _b = _a.field, onChange = _b.onChange, value = _b.value;
|
|
28792
|
+
return (React__default.default.createElement(React__default.default.Fragment, null, ratingValues.map(function (ratingValue, index) { return (React__default.default.createElement(RadioCheckboxInput, { key: index, value: ratingValue, label: ratingValue, checked: String(value) == ratingValue, name: "HowEasyToFind", singleSelection: true, onChange: onChange })); })));
|
|
28793
|
+
} }))),
|
|
28794
|
+
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
28795
|
+
React__default.default.createElement("fieldset", { "aria-describedby": "HowEasyToUnderstandLegend" },
|
|
28796
|
+
React__default.default.createElement(Legend$2, { id: "HowEasyToUnderstandLegend" }, "How easy was this content to understand?"),
|
|
28797
|
+
React__default.default.createElement(Hint, null, "1 being very easy and 5 being extremely difficult."),
|
|
28798
|
+
React__default.default.createElement(Controller, { name: "HowEasyToUnderstand", control: control, rules: { pattern: /^[1-5]+$/i }, render: function (_a) {
|
|
28799
|
+
var _b = _a.field, onChange = _b.onChange, value = _b.value;
|
|
28800
|
+
return (React__default.default.createElement(React__default.default.Fragment, null, ratingValues.map(function (ratingValue, index) { return (React__default.default.createElement(RadioCheckboxInput, { key: index, value: ratingValue, label: ratingValue, checked: String(value) == ratingValue, name: "HowEasyToUnderstand", singleSelection: true, onChange: onChange })); })));
|
|
28801
|
+
} }))),
|
|
28802
|
+
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
28803
|
+
React__default.default.createElement(Label$3, { htmlFor: "BarriersOrIssues" }, "Did you come across any barriers or issues with this webpage?"),
|
|
28804
|
+
React__default.default.createElement(Controller, { name: "BarriersOrIssues", control: control, rules: { max: 500 }, render: function (_a) {
|
|
28805
|
+
var _b = _a.field, onChange = _b.onChange, value = _b.value;
|
|
28806
|
+
return (React__default.default.createElement(Textarea, { id: "BarriersOrIssues", name: "BarriersOrIssues", value: value, placeholder: "", onChange: onChange, isErrored: errors.BarriersOrIssues ? true : false, isFullWidth: true }));
|
|
28807
|
+
} })),
|
|
28808
|
+
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
28809
|
+
React__default.default.createElement(Label$3, { htmlFor: "HowCanWeImprove" }, "How could this page be improved?"),
|
|
28810
|
+
React__default.default.createElement(Controller, { name: "HowCanWeImprove", control: control, rules: { max: 500 }, render: function (_a) {
|
|
28811
|
+
var _b = _a.field, onChange = _b.onChange, value = _b.value;
|
|
28812
|
+
return (React__default.default.createElement(Textarea, { id: "HowCanWeImprove", name: "HowCanWeImprove", value: value, placeholder: "", onChange: onChange, isErrored: errors.HowCanWeImprove ? true : false, isFullWidth: true }));
|
|
28813
|
+
} })),
|
|
28814
|
+
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
28815
|
+
React__default.default.createElement(Label$3, { htmlFor: "Email" }, "Please leave your email below if you are happy for us to contact you further (optional)"),
|
|
28816
|
+
React__default.default.createElement(Controller, { name: "Email", control: control, rules: {
|
|
28817
|
+
max: 150,
|
|
28818
|
+
pattern: /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
|
|
28819
|
+
}, render: function (_a) {
|
|
28820
|
+
var _b = _a.field, onChange = _b.onChange; _b.onBlur; var value = _b.value; _b.ref;
|
|
28821
|
+
return (React__default.default.createElement(Input, { id: "Email", name: "Email", value: value, placeholder: "", onChange: onChange, isErrored: errors.Email ? true : false, errorText: errors.Email && errors.Email.type === 'pattern' ? 'Invalid email address' : null, isFullWidth: true }));
|
|
28822
|
+
} })))),
|
|
28823
|
+
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
28824
|
+
React__default.default.createElement("div", { id: recaptchaContainerId, className: "g-recaptcha" }),
|
|
28825
|
+
React__default.default.createElement("input", __assign$2({ type: "hidden" }, register('ReCaptcha'))),
|
|
28826
|
+
React__default.default.createElement(Terms, null,
|
|
28827
|
+
"This site is protected by reCAPTCHA and the Google",
|
|
28828
|
+
' ',
|
|
28829
|
+
React__default.default.createElement("a", { href: "https://policies.google.com/privacy" }, "Privacy Policy"),
|
|
28830
|
+
" and",
|
|
28831
|
+
' ',
|
|
28832
|
+
React__default.default.createElement("a", { href: "https://policies.google.com/terms" }, "Terms of Service"),
|
|
28833
|
+
" apply.")),
|
|
28834
|
+
showSubmit && (React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
28835
|
+
React__default.default.createElement(React__default.default.Fragment, null, isLoading ? (React__default.default.createElement(LoadingSpinner, null)) : (React__default.default.createElement(FormButton, { text: "Submit", type: "submit", size: "large", isDisabled: !recaptchaLoaded }))))))))));
|
|
28836
|
+
};
|
|
28837
|
+
|
|
28838
|
+
const Container$g = styled__default.default.div`
|
|
28839
|
+
${(props) => props.theme.fontStyles};
|
|
28840
|
+
`;
|
|
28841
|
+
|
|
28842
|
+
const ResultInfo$2 = styled__default.default.div`
|
|
28843
|
+
font-weight: bold;
|
|
28844
|
+
margin: ${(props) => props.theme.theme_vars.spacingSizes.large} 0;
|
|
28845
|
+
`;
|
|
28846
|
+
|
|
28847
|
+
const Result = styled__default.default.div`
|
|
28848
|
+
margin-bottom: ${(props) => props.theme.theme_vars.spacingSizes.x_large};
|
|
28849
|
+
|
|
28850
|
+
&:first-of-type {
|
|
28851
|
+
margin-top: 0;
|
|
28852
|
+
}
|
|
28853
|
+
`;
|
|
28854
|
+
|
|
28855
|
+
const Title$3 = styled__default.default.a`
|
|
28856
|
+
${(props) => props.theme.linkStyles};
|
|
28857
|
+
font-size: 1.2em;
|
|
28858
|
+
display: block;
|
|
28859
|
+
margin-bottom: 5px;
|
|
28860
|
+
`;
|
|
28861
|
+
|
|
28862
|
+
const ServiceArea = styled__default.default.p`
|
|
28863
|
+
font-size: 14px;
|
|
28864
|
+
font-size: 0.8rem;
|
|
28865
|
+
line-height: 1.3;
|
|
28866
|
+
color: ${(props) =>
|
|
28867
|
+
props.theme.cardinal_name === 'west'
|
|
28868
|
+
? props.theme.theme_vars.colours.grey_darke
|
|
28869
|
+
: props.theme.theme_vars.colours.grey_darkest};
|
|
28870
|
+
margin-bottom: 3px !important;
|
|
28871
|
+
|
|
28872
|
+
@media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.s}) {
|
|
28873
|
+
font-size: 16px;
|
|
28874
|
+
font-size: 1rem;
|
|
28875
|
+
line-height: 1.4;
|
|
28876
|
+
}
|
|
28877
|
+
`;
|
|
28878
|
+
|
|
28879
|
+
const Summary$2 = styled__default.default.p`
|
|
28880
|
+
margin-bottom: ${(props) => props.theme.theme_vars.spacingSizes.small};
|
|
28881
|
+
`;
|
|
28882
|
+
|
|
28883
|
+
const SignpostContainer = styled__default.default.div`
|
|
28884
|
+
font-size: 14px;
|
|
28885
|
+
font-size: 0.8rem;
|
|
28886
|
+
line-height: 1.3;
|
|
28887
|
+
|
|
28888
|
+
p {
|
|
28889
|
+
margin-bottom: 10px !important;
|
|
28890
|
+
}
|
|
28891
|
+
|
|
28892
|
+
ul {
|
|
28893
|
+
margin-top: 8px !important;
|
|
28894
|
+
font-size: 14px;
|
|
28895
|
+
font-size: 0.8rem;
|
|
28896
|
+
line-height: 1.3;
|
|
28897
|
+
|
|
28898
|
+
li {
|
|
28899
|
+
margin-bottom: 5px;
|
|
28900
|
+
}
|
|
28901
|
+
}
|
|
28902
|
+
|
|
28903
|
+
@media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.s}) {
|
|
28904
|
+
font-size: 16px;
|
|
28905
|
+
font-size: 1rem;
|
|
28906
|
+
line-height: 1.4;
|
|
28907
|
+
|
|
28908
|
+
ul {
|
|
28909
|
+
font-size: 16px;
|
|
28910
|
+
font-size: 1rem;
|
|
28911
|
+
line-height: 1.4;
|
|
28912
|
+
}
|
|
28913
|
+
}
|
|
28914
|
+
`;
|
|
28915
|
+
|
|
28916
|
+
const SignpostList = styled__default.default.ul`
|
|
28917
|
+
|
|
28918
|
+
${props => props.theme.fontStyles}
|
|
28919
|
+
margin: 0 !important;
|
|
28920
|
+
padding-left: 10px;
|
|
28921
|
+
margin-bottom: 20px !important;
|
|
28922
|
+
list-style-type: none;
|
|
28923
|
+
|
|
28924
|
+
li:last-of-type {
|
|
28925
|
+
margin-bottom: 0;
|
|
28926
|
+
}
|
|
28927
|
+
`;
|
|
28928
|
+
const SignpostListItem = styled__default.default.li`
|
|
28929
|
+
margin-bottom: 10px;
|
|
28930
|
+
padding-left: 0 !important;
|
|
28931
|
+
|
|
28932
|
+
&:before {
|
|
28933
|
+
content: none !important;
|
|
28934
|
+
}
|
|
28935
|
+
`;
|
|
28936
|
+
|
|
28937
|
+
|
|
28938
|
+
const SignpostLink = styled__default.default.a`
|
|
28939
|
+
${props => props.theme.linkStyles}
|
|
28940
|
+
|
|
28941
|
+
svg {
|
|
28942
|
+
fill: ${props => props.theme.theme_vars.colours.action};
|
|
28943
|
+
}
|
|
28944
|
+
|
|
28945
|
+
&:hover{
|
|
28946
|
+
${props => props.theme.linkStylesHover}
|
|
28947
|
+
svg {
|
|
28948
|
+
fill: ${props => props.theme.theme_vars.colours.action_darl};
|
|
28949
|
+
}
|
|
28950
|
+
}
|
|
26313
28951
|
&:focus{
|
|
26314
28952
|
${props => props.theme.linkStylesFocus}
|
|
26315
28953
|
svg {
|
|
@@ -26354,11 +28992,11 @@ var SearchResultsList = function (_a) {
|
|
|
26354
28992
|
var searchTerm = _a.searchTerm, results = _a.results, _b = _a.totalResults, totalResults = _b === void 0 ? 0 : _b, _c = _a.pageNumber, pageNumber = _c === void 0 ? 0 : _c;
|
|
26355
28993
|
var themeContext = React.useContext(styled.ThemeContext);
|
|
26356
28994
|
if (totalResults === 0) {
|
|
26357
|
-
return (React__default.default.createElement(Container$
|
|
28995
|
+
return (React__default.default.createElement(Container$g, { "data-testid": "SearchResultsList" },
|
|
26358
28996
|
React__default.default.createElement(ResultInfo$2, null, "No results found")));
|
|
26359
28997
|
}
|
|
26360
28998
|
else {
|
|
26361
|
-
return (React__default.default.createElement(Container$
|
|
28999
|
+
return (React__default.default.createElement(Container$g, { "data-testid": "SearchResultsList" },
|
|
26362
29000
|
React__default.default.createElement(ResultInfo$2, null,
|
|
26363
29001
|
pageNumber > 1 && 'Page ' + pageNumber + ' of ',
|
|
26364
29002
|
totalResults,
|
|
@@ -26375,9 +29013,9 @@ var SearchResultsList = function (_a) {
|
|
|
26375
29013
|
}
|
|
26376
29014
|
};
|
|
26377
29015
|
|
|
26378
|
-
const Container$
|
|
29016
|
+
const Container$f = styled__default.default.div``;
|
|
26379
29017
|
|
|
26380
|
-
const SectionTitle$1 = styled__default.default(Heading)`
|
|
29018
|
+
const SectionTitle$1 = styled__default.default(Heading$1)`
|
|
26381
29019
|
background: ${(props) =>
|
|
26382
29020
|
props.theme.cardinal_name === 'north'
|
|
26383
29021
|
? props.theme.theme_vars.colours.grey
|
|
@@ -26475,7 +29113,7 @@ styled__default.default.img`
|
|
|
26475
29113
|
*/
|
|
26476
29114
|
var SectionLinks = function (_a) {
|
|
26477
29115
|
var sectionTitle = _a.sectionTitle, _b = _a.displayTitle, displayTitle = _b === void 0 ? true : _b, sectionSlug = _a.sectionSlug, pageLinksArray = _a.pageLinksArray, _c = _a.hasImages, hasImages = _c === void 0 ? false : _c;
|
|
26478
|
-
return (React__default.default.createElement(Container$
|
|
29116
|
+
return (React__default.default.createElement(Container$f, { id: sectionSlug, "data-testid": "SectionLinks" },
|
|
26479
29117
|
displayTitle ? React__default.default.createElement(SectionTitle$1, { text: sectionTitle }) : React__default.default.createElement("br", null),
|
|
26480
29118
|
React__default.default.createElement(Row$1, { isList: true }, pageLinksArray.map(function (link, i) {
|
|
26481
29119
|
var _a;
|
|
@@ -26487,7 +29125,7 @@ var SectionLinks = function (_a) {
|
|
|
26487
29125
|
}))));
|
|
26488
29126
|
};
|
|
26489
29127
|
|
|
26490
|
-
const Container$
|
|
29128
|
+
const Container$e = styled__default.default.aside`
|
|
26491
29129
|
padding-top: 20px;
|
|
26492
29130
|
display: block;
|
|
26493
29131
|
|
|
@@ -26571,7 +29209,7 @@ const InlineLink = styled__default.default.a`
|
|
|
26571
29209
|
|
|
26572
29210
|
var SectionLinksMobileContents = function (_a) {
|
|
26573
29211
|
var sectionLinksArray = _a.sectionLinksArray;
|
|
26574
|
-
return (React__default.default.createElement(Container$
|
|
29212
|
+
return (React__default.default.createElement(Container$e, null,
|
|
26575
29213
|
React__default.default.createElement(Contents, null,
|
|
26576
29214
|
React__default.default.createElement(ContentsTitle, null, "Contents"),
|
|
26577
29215
|
React__default.default.createElement(ContentsList, null, sectionLinksArray.map(function (link) {
|
|
@@ -26580,7 +29218,7 @@ var SectionLinksMobileContents = function (_a) {
|
|
|
26580
29218
|
})))));
|
|
26581
29219
|
};
|
|
26582
29220
|
|
|
26583
|
-
const Container$
|
|
29221
|
+
const Container$d = styled__default.default.div`
|
|
26584
29222
|
${(props) => props.theme.fontStyles}
|
|
26585
29223
|
background-color: ${(props) => props.theme.theme_vars.colours.action_light};
|
|
26586
29224
|
border-radius: ${(props) => props.theme.theme_vars.border_radius};
|
|
@@ -26731,7 +29369,7 @@ const ListItemLink = styled__default.default.a`
|
|
|
26731
29369
|
var SectionLinksSidebar = function (_a) {
|
|
26732
29370
|
var Title = _a.Title, Sections = _a.Sections;
|
|
26733
29371
|
var _b = React.useState(false), open = _b[0], setOpen = _b[1];
|
|
26734
|
-
return (React__default.default.createElement(Container$
|
|
29372
|
+
return (React__default.default.createElement(Container$d, { "data-testid": "SectionLinksSidebar" },
|
|
26735
29373
|
React__default.default.createElement(MobileTitleButton, { onClick: function () { return (open ? setOpen(false) : setOpen(true)); } },
|
|
26736
29374
|
Title,
|
|
26737
29375
|
React__default.default.createElement(IconWrapper$2, null,
|
|
@@ -26743,7 +29381,7 @@ var SectionLinksSidebar = function (_a) {
|
|
|
26743
29381
|
React__default.default.createElement(ListItemLink, { href: link.url }, link.title))); })))); }))));
|
|
26744
29382
|
};
|
|
26745
29383
|
|
|
26746
|
-
const Container$
|
|
29384
|
+
const Container$c = styled__default.default.div`
|
|
26747
29385
|
position: relative;
|
|
26748
29386
|
`;
|
|
26749
29387
|
|
|
@@ -26895,7 +29533,7 @@ var ServiceLinksBoxed = function (_a) {
|
|
|
26895
29533
|
var _a;
|
|
26896
29534
|
return (_a = refs.current[index]) !== null && _a !== void 0 ? _a : React__default.default.createRef();
|
|
26897
29535
|
});
|
|
26898
|
-
return (React__default.default.createElement(Container$
|
|
29536
|
+
return (React__default.default.createElement(Container$c, { "data-testid": "ServiceLinksBoxed" },
|
|
26899
29537
|
React__default.default.createElement(Row$1, null, serviceLinksArray.map(function (serviceLink, index) {
|
|
26900
29538
|
var _a;
|
|
26901
29539
|
return (React__default.default.createElement(Column, { small: "full", medium: "one-half", large: "one-third", key: index },
|
|
@@ -26932,7 +29570,7 @@ const containerMaxHeight = (props) => {
|
|
|
26932
29570
|
}
|
|
26933
29571
|
};
|
|
26934
29572
|
|
|
26935
|
-
const Container$
|
|
29573
|
+
const Container$b = styled__default.default.div`
|
|
26936
29574
|
${(props) => props.theme.fontStyles}
|
|
26937
29575
|
${containerMaxHeight}
|
|
26938
29576
|
|
|
@@ -27305,7 +29943,7 @@ const Link = styled__default.default.a`
|
|
|
27305
29943
|
}
|
|
27306
29944
|
`;
|
|
27307
29945
|
|
|
27308
|
-
const Title = styled__default.default(Heading)`
|
|
29946
|
+
const Title = styled__default.default(Heading$1)`
|
|
27309
29947
|
${(props) => props.theme.linkStyles}
|
|
27310
29948
|
|
|
27311
29949
|
padding: 15px 0;
|
|
@@ -27347,9 +29985,9 @@ var ServicesLinksList = function (_a) {
|
|
|
27347
29985
|
}
|
|
27348
29986
|
}, [currentOrder]);
|
|
27349
29987
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
27350
|
-
React__default.default.createElement(Container$
|
|
29988
|
+
React__default.default.createElement(Container$b, { id: serviceId, className: open && 'open', "$hideHeader": hideHeader, "$isBoxed": isBoxed },
|
|
27351
29989
|
!hideHeader && (React__default.default.createElement(HomeTitle, { "data-testid": "servicesLinksListHeader" },
|
|
27352
|
-
React__default.default.createElement(Heading, { text: "Council services" }),
|
|
29990
|
+
React__default.default.createElement(Heading$1, { text: "Council services" }),
|
|
27353
29991
|
React__default.default.createElement(ReorderControl, null,
|
|
27354
29992
|
"Order services by",
|
|
27355
29993
|
React__default.default.createElement("br", null),
|
|
@@ -27376,7 +30014,7 @@ var ServicesLinksList = function (_a) {
|
|
|
27376
30014
|
" services")))));
|
|
27377
30015
|
};
|
|
27378
30016
|
|
|
27379
|
-
const Container$
|
|
30017
|
+
const Container$a = styled__default.default.div`
|
|
27380
30018
|
${props => props.theme.fontStyles}
|
|
27381
30019
|
max-width: 500px;
|
|
27382
30020
|
border-radius: ${props => props.theme.theme_vars.border_radius};
|
|
@@ -27423,7 +30061,7 @@ const SingleButtonContainer = styled__default.default.div`
|
|
|
27423
30061
|
}
|
|
27424
30062
|
`;
|
|
27425
30063
|
|
|
27426
|
-
const Container$
|
|
30064
|
+
const Container$9 = styled__default.default.div`
|
|
27427
30065
|
strong {
|
|
27428
30066
|
font-weight: bold;
|
|
27429
30067
|
}
|
|
@@ -27564,7 +30202,7 @@ var HintText = function (_a) {
|
|
|
27564
30202
|
return (React__default.default.createElement(HintText$1, null, text));
|
|
27565
30203
|
};
|
|
27566
30204
|
|
|
27567
|
-
const Container$
|
|
30205
|
+
const Container$8 = styled__default.default.div`
|
|
27568
30206
|
display: flex;
|
|
27569
30207
|
-webkit-flex-direction: row;
|
|
27570
30208
|
-moz-flex-direction: row;
|
|
@@ -27601,45 +30239,13 @@ const ErrorSummary = styled__default.default.div`
|
|
|
27601
30239
|
*/
|
|
27602
30240
|
var FormWithLine = function (_a) {
|
|
27603
30241
|
var _b = _a.lineColour, lineColour = _b === void 0 ? '#C6C6C6' : _b, _c = _a.hideLine, hideLine = _c === void 0 ? false : _c, formRole = _a.formRole, formMethod = _a.formMethod, formURL = _a.formURL, _d = _a.isError, isError = _d === void 0 ? false : _d, errorSummary = _a.errorSummary, onSubmit = _a.onSubmit, children = _a.children;
|
|
27604
|
-
return (React__default.default.createElement(Container$
|
|
30242
|
+
return (React__default.default.createElement(Container$8, null,
|
|
27605
30243
|
React__default.default.createElement(Line, { "$lineColour": lineColour, "$hideLine": hideLine, "$isError": isError }),
|
|
27606
30244
|
React__default.default.createElement(Form, { onSubmit: onSubmit, "$hideLine": hideLine, role: formRole, method: formMethod, url: formURL, "data-testid": "FormWithLine" },
|
|
27607
30245
|
errorSummary && React__default.default.createElement(ErrorSummary, null, errorSummary),
|
|
27608
30246
|
children)));
|
|
27609
30247
|
};
|
|
27610
30248
|
|
|
27611
|
-
const Spinner = styled__default.default.div`
|
|
27612
|
-
display: inline-block;
|
|
27613
|
-
width: 80px;
|
|
27614
|
-
height: 80px;
|
|
27615
|
-
|
|
27616
|
-
&:after {
|
|
27617
|
-
content: " ";
|
|
27618
|
-
display: block;
|
|
27619
|
-
width: 50px;
|
|
27620
|
-
height: 50px;
|
|
27621
|
-
margin: 8px;
|
|
27622
|
-
border-radius: 50%;
|
|
27623
|
-
border: 6px solid ${props => props.theme.theme_vars.colours.action};
|
|
27624
|
-
border-color: ${props => props.theme.theme_vars.colours.action} transparent ${props => props.theme.theme_vars.colours.action} transparent;
|
|
27625
|
-
animation: lds-dual-ring 1.2s linear infinite;
|
|
27626
|
-
}
|
|
27627
|
-
|
|
27628
|
-
@keyframes lds-dual-ring {
|
|
27629
|
-
0% {
|
|
27630
|
-
transform: rotate(0deg);
|
|
27631
|
-
}
|
|
27632
|
-
100% {
|
|
27633
|
-
transform: rotate(360deg);
|
|
27634
|
-
}
|
|
27635
|
-
}
|
|
27636
|
-
|
|
27637
|
-
`;
|
|
27638
|
-
|
|
27639
|
-
var LoadingSpinner = function () {
|
|
27640
|
-
return React__default.default.createElement(Spinner, null);
|
|
27641
|
-
};
|
|
27642
|
-
|
|
27643
30249
|
var _a;
|
|
27644
30250
|
var PostcodeSearchApiUrl = (_a = process.env.NEXT_PUBLIC_POSTCODE_SEARCH_API_URL) !== null && _a !== void 0 ? _a : '';
|
|
27645
30251
|
|
|
@@ -27757,7 +30363,7 @@ var PostCodeSearch = function (_a) {
|
|
|
27757
30363
|
setCurrentPostcode(currentPostcode + ' (' + singleAddress.title + ')');
|
|
27758
30364
|
}
|
|
27759
30365
|
}
|
|
27760
|
-
return (React__default.default.createElement(Container$
|
|
30366
|
+
return (React__default.default.createElement(Container$9, { "data-testid": "PostCodeSearch" },
|
|
27761
30367
|
React__default.default.createElement(DropDownButton, { onClick: function () { return setOpen(open ? false : true); } },
|
|
27762
30368
|
React__default.default.createElement(IconWrapper, null,
|
|
27763
30369
|
React__default.default.createElement(ChevronIcon, { direction: open ? 'down' : 'right', colourFill: themeContext.theme_vars.colours.black })),
|
|
@@ -27832,7 +30438,7 @@ var SignpostLinks = function (_a) {
|
|
|
27832
30438
|
var themeContext = React.useContext(styled.ThemeContext);
|
|
27833
30439
|
var councilLink = otherCouncilLink ? otherCouncilLink : themeContext.theme_vars.other_council_link;
|
|
27834
30440
|
return (React__default.default.createElement(React__default.default.Fragment, null, signpostLinksArray.length > 1 ?
|
|
27835
|
-
React__default.default.createElement(Container$
|
|
30441
|
+
React__default.default.createElement(Container$a, null,
|
|
27836
30442
|
React__default.default.createElement(Paragraph, null, TopLineText),
|
|
27837
30443
|
React__default.default.createElement(SignpostLinksList, { signpostLinksArray: signpostLinksArray }),
|
|
27838
30444
|
React__default.default.createElement(PostCodeSearch, { otherCouncilLink: councilLink, signPostLinks: signpostLinksArray }),
|
|
@@ -27932,7 +30538,7 @@ const summaryStyles = (props) => {
|
|
|
27932
30538
|
}
|
|
27933
30539
|
};
|
|
27934
30540
|
|
|
27935
|
-
const Container$
|
|
30541
|
+
const Container$7 = styled__default.default.div`
|
|
27936
30542
|
padding: ${(props) => (props.$hasPadding ? '30px 20px' : '0')};
|
|
27937
30543
|
font-size: 1.2em;
|
|
27938
30544
|
margin-bottom: 15px;
|
|
@@ -27949,7 +30555,7 @@ const Container$8 = styled__default.default.div`
|
|
|
27949
30555
|
|
|
27950
30556
|
var Summary = function (_a) {
|
|
27951
30557
|
var children = _a.children, _b = _a.hasBackground, hasBackground = _b === void 0 ? true : _b, _c = _a.hasPadding, hasPadding = _c === void 0 ? true : _c;
|
|
27952
|
-
return (React__default.default.createElement(Container$
|
|
30558
|
+
return (React__default.default.createElement(Container$7, { "data-testid": "Summary", "$hasBackground": hasBackground, "$hasPadding": hasPadding }, children));
|
|
27953
30559
|
};
|
|
27954
30560
|
|
|
27955
30561
|
var breakpointsVals$4 = {
|
|
@@ -28341,7 +30947,7 @@ var templateObject_1$1, templateObject_2;
|
|
|
28341
30947
|
var GlobalStyleReset = styled.createGlobalStyle(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n html {\n box-sizing: border-box;\n }\n *,\n *:before,\n *:after {\n box-sizing: inherit;\n }\n\n html,\n body,\n div,\n span,\n applet,\n object,\n iframe,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n p,\n blockquote,\n pre,\n a,\n abbr,\n acronym,\n address,\n big,\n cite,\n code,\n del,\n dfn,\n em,\n img,\n ins,\n kbd,\n q,\n s,\n samp,\n small,\n strike,\n strong,\n sub,\n sup,\n tt,\n var,\n b,\n u,\n i,\n center,\n dl,\n dt,\n dd,\n ol,\n ul,\n li,\n fieldset,\n form,\n label,\n legend,\n table,\n caption,\n tbody,\n tfoot,\n thead,\n tr,\n th,\n td,\n article,\n aside,\n canvas,\n details,\n embed,\n figure,\n figcaption,\n footer,\n header,\n hgroup,\n menu,\n nav,\n output,\n ruby,\n section,\n summary,\n time,\n mark,\n audio,\n video {\n margin: 0;\n padding: 0;\n border: 0;\n font-size: 100%;\n font: inherit;\n vertical-align: baseline;\n }\n /* HTML5 display-role reset for older browsers */\n article,\n aside,\n details,\n figcaption,\n figure,\n footer,\n header,\n hgroup,\n menu,\n nav,\n section {\n display: block;\n }\n body {\n line-height: 1;\n }\n ol {\n list-style: decimal outside;\n margin: 1rem 0rem 1rem 1.25rem;\n }\n ul {\n list-style: disc outside;\n margin: 1rem 0rem 1rem 1.25rem;\n }\n li {\n position: relative;\n left: 1.25rem;\n padding-right: 1.25rem;\n }\n blockquote,\n q {\n quotes: none;\n }\n blockquote:before,\n blockquote:after,\n q:before,\n q:after {\n content: '';\n content: none;\n }\n table {\n border-collapse: collapse;\n border-spacing: 0;\n }\n .table-container li {\n left: 0;\n }\n table tr td {\n vertical-align: top;\n }\n"], ["\n html {\n box-sizing: border-box;\n }\n *,\n *:before,\n *:after {\n box-sizing: inherit;\n }\n\n html,\n body,\n div,\n span,\n applet,\n object,\n iframe,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n p,\n blockquote,\n pre,\n a,\n abbr,\n acronym,\n address,\n big,\n cite,\n code,\n del,\n dfn,\n em,\n img,\n ins,\n kbd,\n q,\n s,\n samp,\n small,\n strike,\n strong,\n sub,\n sup,\n tt,\n var,\n b,\n u,\n i,\n center,\n dl,\n dt,\n dd,\n ol,\n ul,\n li,\n fieldset,\n form,\n label,\n legend,\n table,\n caption,\n tbody,\n tfoot,\n thead,\n tr,\n th,\n td,\n article,\n aside,\n canvas,\n details,\n embed,\n figure,\n figcaption,\n footer,\n header,\n hgroup,\n menu,\n nav,\n output,\n ruby,\n section,\n summary,\n time,\n mark,\n audio,\n video {\n margin: 0;\n padding: 0;\n border: 0;\n font-size: 100%;\n font: inherit;\n vertical-align: baseline;\n }\n /* HTML5 display-role reset for older browsers */\n article,\n aside,\n details,\n figcaption,\n figure,\n footer,\n header,\n hgroup,\n menu,\n nav,\n section {\n display: block;\n }\n body {\n line-height: 1;\n }\n ol {\n list-style: decimal outside;\n margin: 1rem 0rem 1rem 1.25rem;\n }\n ul {\n list-style: disc outside;\n margin: 1rem 0rem 1rem 1.25rem;\n }\n li {\n position: relative;\n left: 1.25rem;\n padding-right: 1.25rem;\n }\n blockquote,\n q {\n quotes: none;\n }\n blockquote:before,\n blockquote:after,\n q:before,\n q:after {\n content: '';\n content: none;\n }\n table {\n border-collapse: collapse;\n border-spacing: 0;\n }\n .table-container li {\n left: 0;\n }\n table tr td {\n vertical-align: top;\n }\n"])));
|
|
28342
30948
|
var templateObject_1;
|
|
28343
30949
|
|
|
28344
|
-
const Container$
|
|
30950
|
+
const Container$6 = styled__default.default.div`
|
|
28345
30951
|
display: block;
|
|
28346
30952
|
|
|
28347
30953
|
.striped-column {
|
|
@@ -28458,7 +31064,7 @@ const ServiceImage$1 = styled__default.default.img`
|
|
|
28458
31064
|
left: 0;
|
|
28459
31065
|
`;
|
|
28460
31066
|
|
|
28461
|
-
const Container$
|
|
31067
|
+
const Container$5 = styled__default.default.div`
|
|
28462
31068
|
display: flex;
|
|
28463
31069
|
|
|
28464
31070
|
.striped-contacts {
|
|
@@ -28561,7 +31167,7 @@ var PhoneIcon = function (_a) {
|
|
|
28561
31167
|
var ServiceContact = function (_a) {
|
|
28562
31168
|
var website = _a.website, email = _a.email, contacts = _a.contacts;
|
|
28563
31169
|
var themeContext = React.useContext(styled.ThemeContext);
|
|
28564
|
-
return (React__default.default.createElement(Container$
|
|
31170
|
+
return (React__default.default.createElement(Container$5, { "data-testid": "ServiceContact" },
|
|
28565
31171
|
React__default.default.createElement(Row$1, { hasWrap: false },
|
|
28566
31172
|
website && (React__default.default.createElement(Column, { small: "full", medium: "full", large: "auto", classes: "striped-contacts" },
|
|
28567
31173
|
React__default.default.createElement(IconContainer$1, null,
|
|
@@ -28792,7 +31398,7 @@ var transformAge = function (age, ageInMonths) {
|
|
|
28792
31398
|
return "".concat(age, " years");
|
|
28793
31399
|
};
|
|
28794
31400
|
|
|
28795
|
-
const Container$
|
|
31401
|
+
const Container$4 = styled__default.default.div`
|
|
28796
31402
|
display: block;
|
|
28797
31403
|
`;
|
|
28798
31404
|
|
|
@@ -28806,7 +31412,7 @@ var DirectoryMap = function (_a) {
|
|
|
28806
31412
|
lat: parseFloat(latLong[0]),
|
|
28807
31413
|
lng: parseFloat(latLong[1]),
|
|
28808
31414
|
};
|
|
28809
|
-
return (React__default.default.createElement(Container$
|
|
31415
|
+
return (React__default.default.createElement(Container$4, { "data-testid": "DirectoryMap" }, cookiesAccepted ? (React__default.default.createElement(React__default.default.Fragment, null,
|
|
28810
31416
|
React__default.default.createElement(reactWrapper.Wrapper, { apiKey: apiKey },
|
|
28811
31417
|
React__default.default.createElement(Map$1, { center: center, zoom: (_c = mapProps.zoom) !== null && _c !== void 0 ? _c : 14 }, mapProps.mapMarkers.map(function (marker, index) {
|
|
28812
31418
|
var _a;
|
|
@@ -28907,7 +31513,7 @@ var DirectoryAddToShortList = function (_a) {
|
|
|
28907
31513
|
favourite ? React__default.default.createElement(React__default.default.Fragment, null, "Remove from shortlist") : React__default.default.createElement(React__default.default.Fragment, null, "Add to shortlist")));
|
|
28908
31514
|
};
|
|
28909
31515
|
|
|
28910
|
-
const Container$
|
|
31516
|
+
const Container$3 = styled__default.default.div`
|
|
28911
31517
|
display: flex;
|
|
28912
31518
|
overflow: hidden;
|
|
28913
31519
|
|
|
@@ -28947,7 +31553,7 @@ const WebLink = styled__default.default.a`
|
|
|
28947
31553
|
|
|
28948
31554
|
var ServiceSocialLinks = function (_a) {
|
|
28949
31555
|
var profiles = _a.profiles;
|
|
28950
|
-
return (React__default.default.createElement(Container$
|
|
31556
|
+
return (React__default.default.createElement(Container$3, { "data-testid": "ServiceSocialLinks" },
|
|
28951
31557
|
React__default.default.createElement(Row$1, null, profiles === null || profiles === void 0 ? void 0 : profiles.map(function (profile) { return (React__default.default.createElement(Column, { key: profile.id, small: "full", medium: "one-half", large: "one-third", classes: "striped-socials" },
|
|
28952
31558
|
React__default.default.createElement(IconContainer, null, getIcon(profile)),
|
|
28953
31559
|
React__default.default.createElement(Content, null,
|
|
@@ -28979,13 +31585,13 @@ var DirectoryService = function (_a) {
|
|
|
28979
31585
|
React.useEffect(function () {
|
|
28980
31586
|
setNotServer(true);
|
|
28981
31587
|
}, []);
|
|
28982
|
-
return (React__default.default.createElement(Container$
|
|
31588
|
+
return (React__default.default.createElement(Container$6, { "data-testid": "DirectoryService" },
|
|
28983
31589
|
React__default.default.createElement(Row$1, null,
|
|
28984
31590
|
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
28985
31591
|
React__default.default.createElement(Row$1, null,
|
|
28986
31592
|
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
28987
31593
|
React__default.default.createElement(ServiceHeader$1, null,
|
|
28988
|
-
React__default.default.createElement(Heading, { level: 1, text: name }),
|
|
31594
|
+
React__default.default.createElement(Heading$1, { level: 1, text: name }),
|
|
28989
31595
|
(organization === null || organization === void 0 ? void 0 : organization.logo) && (React__default.default.createElement(ServiceImageOuter, null,
|
|
28990
31596
|
React__default.default.createElement(ServiceImageContainer$1, null,
|
|
28991
31597
|
React__default.default.createElement(ServiceImage$1, { src: organization.logo, alt: name + ' logo', loading: "lazy" })))))),
|
|
@@ -29005,7 +31611,7 @@ var DirectoryService = function (_a) {
|
|
|
29005
31611
|
React__default.default.createElement(Column, { small: "full", medium: "full", large: "one-third" }, service_at_locations === null || service_at_locations === void 0 ? void 0 : service_at_locations.filter(function (location) {
|
|
29006
31612
|
return location.is_visitable != false;
|
|
29007
31613
|
}).map(function (location) { return (React__default.default.createElement("div", { key: location.id },
|
|
29008
|
-
React__default.default.createElement(Heading, { level: 2, text: location.name }),
|
|
31614
|
+
React__default.default.createElement(Heading$1, { level: 2, text: location.name }),
|
|
29009
31615
|
location.physical_addresses.map(function (address) { return (React__default.default.createElement(PhysicalAddress, { key: address.id },
|
|
29010
31616
|
React__default.default.createElement("p", { key: address.id, dangerouslySetInnerHTML: {
|
|
29011
31617
|
__html: Object.values(address)
|
|
@@ -29014,7 +31620,7 @@ var DirectoryService = function (_a) {
|
|
|
29014
31620
|
} }),
|
|
29015
31621
|
React__default.default.createElement(Button$4, { url: "https://google.com/maps/dir//".concat(location.latitude, ",").concat(location.longitude), text: "Get directions" }))); }),
|
|
29016
31622
|
(location === null || location === void 0 ? void 0 : location.accessibility_for_disabilities.length) > 0 && (React__default.default.createElement(React__default.default.Fragment, null,
|
|
29017
|
-
React__default.default.createElement(Heading, { level: 3, text: "Other facilities on site" }),
|
|
31623
|
+
React__default.default.createElement(Heading$1, { level: 3, text: "Other facilities on site" }),
|
|
29018
31624
|
React__default.default.createElement("ul", null, location.accessibility_for_disabilities.map(function (accessibility) { return (React__default.default.createElement("li", { key: accessibility.id }, accessibility.accessibility)); })))))); })),
|
|
29019
31625
|
React__default.default.createElement(Column, { small: "full", medium: "full", large: "two-thirds" }, service_at_locations.filter(function (location) {
|
|
29020
31626
|
return location.is_visitable != false;
|
|
@@ -29043,16 +31649,16 @@ var DirectoryService = function (_a) {
|
|
|
29043
31649
|
} })),
|
|
29044
31650
|
React__default.default.createElement(MapLink, { href: "https://www.google.com/maps/search/?api=1&query=".concat(service_at_locations[0].latitude, "%2C").concat(service_at_locations[0].longitude) }, "View in Google Maps"))))))),
|
|
29045
31651
|
(email || url || (contacts === null || contacts === void 0 ? void 0 : contacts.length) > 0) && (React__default.default.createElement(Column, { small: "full", medium: "full", large: "full", classes: "striped-column" },
|
|
29046
|
-
React__default.default.createElement(Heading, { level: 2, text: "How to contact this service" }),
|
|
31652
|
+
React__default.default.createElement(Heading$1, { level: 2, text: "How to contact this service" }),
|
|
29047
31653
|
React__default.default.createElement(ServiceContact, { email: email, website: url, contacts: contacts }))),
|
|
29048
31654
|
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full", classes: "striped-column" },
|
|
29049
|
-
React__default.default.createElement(Heading, { level: 2, text: "Description" }),
|
|
31655
|
+
React__default.default.createElement(Heading$1, { level: 2, text: "Description" }),
|
|
29050
31656
|
React__default.default.createElement("div", null,
|
|
29051
31657
|
React__default.default.createElement(React__default.default.Fragment, null, descriptionElement)),
|
|
29052
31658
|
React__default.default.createElement(SummaryList, { terms: transformDescriptionDetails(accreditations, fees, service_areas, languages, eligibilitys, ageInMonths), hasMargin: false }),
|
|
29053
31659
|
React__default.default.createElement(SummaryList, { terms: transformTaxonomies(service_taxonomys, taxonomiesToShow), hasMargin: false })),
|
|
29054
31660
|
regular_schedules.length > 0 && (React__default.default.createElement(Column, { small: "full", medium: "full", large: "full", classes: "striped-column" },
|
|
29055
|
-
React__default.default.createElement(Heading, { level: 2, text: "Service hours" }),
|
|
31661
|
+
React__default.default.createElement(Heading$1, { level: 2, text: "Service hours" }),
|
|
29056
31662
|
React__default.default.createElement("div", { className: "table-container" },
|
|
29057
31663
|
React__default.default.createElement("table", null,
|
|
29058
31664
|
React__default.default.createElement("thead", null,
|
|
@@ -29065,10 +31671,10 @@ var DirectoryService = function (_a) {
|
|
|
29065
31671
|
React__default.default.createElement("td", null, schedule.opens_at),
|
|
29066
31672
|
React__default.default.createElement("td", null, schedule.closes_at))); })))))),
|
|
29067
31673
|
(uploads === null || uploads === void 0 ? void 0 : uploads.length) > 0 && (React__default.default.createElement(Column, { small: "full", medium: "full", large: "full", classes: "striped-column" },
|
|
29068
|
-
React__default.default.createElement(Heading, { level: 2, text: "Some resources that can help" }),
|
|
31674
|
+
React__default.default.createElement(Heading$1, { level: 2, text: "Some resources that can help" }),
|
|
29069
31675
|
React__default.default.createElement(DownloadableFiles, { files: uploads }))),
|
|
29070
31676
|
(service_social_profiles === null || service_social_profiles === void 0 ? void 0 : service_social_profiles.length) > 0 && (React__default.default.createElement(Column, { small: "full", medium: "full", large: "full", classes: "striped-column" },
|
|
29071
|
-
React__default.default.createElement(Heading, { level: 2, text: "Follow this service" }),
|
|
31677
|
+
React__default.default.createElement(Heading$1, { level: 2, text: "Follow this service" }),
|
|
29072
31678
|
React__default.default.createElement(ServiceSocialLinks, { profiles: service_social_profiles }))),
|
|
29073
31679
|
service_at_locations.filter(function (location) {
|
|
29074
31680
|
return location.is_visitable == false;
|
|
@@ -29078,7 +31684,7 @@ var DirectoryService = function (_a) {
|
|
|
29078
31684
|
})
|
|
29079
31685
|
.map(function (location) { return (React__default.default.createElement(Row$1, { key: location.id },
|
|
29080
31686
|
React__default.default.createElement(Column, { small: "full", medium: "one-half", large: "one-third", key: location.id },
|
|
29081
|
-
React__default.default.createElement(Heading, { level: 2, text: location.name }),
|
|
31687
|
+
React__default.default.createElement(Heading$1, { level: 2, text: location.name }),
|
|
29082
31688
|
location.physical_addresses.map(function (address) { return (React__default.default.createElement(PhysicalAddress, { key: address.id },
|
|
29083
31689
|
React__default.default.createElement("p", { key: address.id, dangerouslySetInnerHTML: {
|
|
29084
31690
|
__html: Object.values(address)
|
|
@@ -29086,11 +31692,11 @@ var DirectoryService = function (_a) {
|
|
|
29086
31692
|
.join(' <br />'),
|
|
29087
31693
|
} }))); }),
|
|
29088
31694
|
(location === null || location === void 0 ? void 0 : location.accessibility_for_disabilities.length) > 0 && (React__default.default.createElement(React__default.default.Fragment, null,
|
|
29089
|
-
React__default.default.createElement(Heading, { level: 3, text: "Other facilities on site" }),
|
|
31695
|
+
React__default.default.createElement(Heading$1, { level: 3, text: "Other facilities on site" }),
|
|
29090
31696
|
React__default.default.createElement("ul", null, location.accessibility_for_disabilities.map(function (accessibility) { return (React__default.default.createElement("li", { key: accessibility.id }, accessibility.accessibility)); }))))))); }))))));
|
|
29091
31697
|
};
|
|
29092
31698
|
|
|
29093
|
-
const Container$
|
|
31699
|
+
const Container$2 = styled__default.default.div`
|
|
29094
31700
|
display: block;
|
|
29095
31701
|
|
|
29096
31702
|
input {
|
|
@@ -29281,7 +31887,7 @@ const AccordionIcon = styled__default.default.span`
|
|
|
29281
31887
|
}
|
|
29282
31888
|
`;
|
|
29283
31889
|
|
|
29284
|
-
const Category$
|
|
31890
|
+
const Category$1 = styled__default.default.div``;
|
|
29285
31891
|
|
|
29286
31892
|
styled__default.default.div`
|
|
29287
31893
|
font-weight: bold;
|
|
@@ -29463,111 +32069,6 @@ var PinIcon = function (_a) {
|
|
|
29463
32069
|
React__default.default.createElement("path", { d: "M19.7,5.6c-0.1,0-0.5,0.1-0.9,0.1c-3.3,0.4-6.5,2-8.9,4.4c-2.6,2.6-4.2,5.9-4.6,9.6c-0.1,1,0,3.1,0.1,4.1c0.3,2.1,1.1,4.2,2.3,6.6c0.9,1.6,1.6,2.9,4.2,7c0.9,1.4,1.9,3.1,2.6,4.2c2.3,3.9,4.1,7.9,5.4,11.9c0.2,0.6,0.3,0.8,0.6,0.9c0.5,0.2,1.1,0.1,1.4-0.3c0.1-0.1,0.2-0.5,0.4-0.9c1.1-3.3,2.5-6.5,4.2-9.5c1.2-2.2,2-3.6,4.4-7.4c1.7-2.7,2.3-3.6,2.9-4.8c1.6-2.9,2.5-5.3,2.9-7.8c0.2-1,0.2-3.1,0.1-4.1c-0.2-1.5-0.5-3-1-4.2c-2.1-5.2-6.8-8.9-12.4-9.8C22.9,5.6,20.2,5.5,19.7,5.6z", fill: colourFill })));
|
|
29464
32070
|
};
|
|
29465
32071
|
|
|
29466
|
-
const Container$2 = styled__default.default.div`
|
|
29467
|
-
display: block;
|
|
29468
|
-
`;
|
|
29469
|
-
|
|
29470
|
-
const Category$1 = styled__default.default.div`
|
|
29471
|
-
font-size: ${(props) => props.theme.theme_vars.fontSizes.small};
|
|
29472
|
-
display: block;
|
|
29473
|
-
position: relative;
|
|
29474
|
-
min-height: 40px;
|
|
29475
|
-
margin-bottom: 10px;
|
|
29476
|
-
padding-left: 40px;
|
|
29477
|
-
clear: left;
|
|
29478
|
-
`;
|
|
29479
|
-
|
|
29480
|
-
const CategoryInput = styled__default.default.input`
|
|
29481
|
-
cursor: pointer;
|
|
29482
|
-
position: absolute;
|
|
29483
|
-
z-index: 1;
|
|
29484
|
-
top: -2px;
|
|
29485
|
-
left: -2px;
|
|
29486
|
-
width: 44px;
|
|
29487
|
-
height: 44px;
|
|
29488
|
-
margin: 0;
|
|
29489
|
-
opacity: 0;
|
|
29490
|
-
|
|
29491
|
-
&:focus + label:before {
|
|
29492
|
-
box-shadow: 0 0 0 3px ${(props) => props.theme.theme_vars.colours.focus};
|
|
29493
|
-
}
|
|
29494
|
-
`;
|
|
29495
|
-
|
|
29496
|
-
/**
|
|
29497
|
-
* If single selection then use styles for radio button, otherwise checkbox styles
|
|
29498
|
-
*/
|
|
29499
|
-
const checkedMarker = (props) => {
|
|
29500
|
-
if (props.$singleSelection) {
|
|
29501
|
-
return styled.css`
|
|
29502
|
-
top: 10px;
|
|
29503
|
-
left: 10px;
|
|
29504
|
-
width: 0;
|
|
29505
|
-
height: 0;
|
|
29506
|
-
border: 10px solid currentcolor;
|
|
29507
|
-
border-radius: 50%;
|
|
29508
|
-
background: currentcolor;
|
|
29509
|
-
`;
|
|
29510
|
-
} else {
|
|
29511
|
-
return styled.css`
|
|
29512
|
-
top: 11px;
|
|
29513
|
-
left: 9px;
|
|
29514
|
-
width: 23px;
|
|
29515
|
-
height: 12px;
|
|
29516
|
-
-webkit-transform: rotate(-45deg);
|
|
29517
|
-
-ms-transform: rotate(-45deg);
|
|
29518
|
-
transform: rotate(-45deg);
|
|
29519
|
-
border: solid;
|
|
29520
|
-
border-width: 0 0 5px 5px;
|
|
29521
|
-
border-top-color: transparent;
|
|
29522
|
-
background: transparent;
|
|
29523
|
-
`;
|
|
29524
|
-
}
|
|
29525
|
-
};
|
|
29526
|
-
|
|
29527
|
-
const CategoryInputLabel = styled__default.default.label`
|
|
29528
|
-
display: inline-block;
|
|
29529
|
-
margin-bottom: 0;
|
|
29530
|
-
padding: 8px 15px 5px;
|
|
29531
|
-
cursor: pointer;
|
|
29532
|
-
-ms-touch-action: manipulation;
|
|
29533
|
-
touch-action: manipulation;
|
|
29534
|
-
color: #0b0c0c;
|
|
29535
|
-
display: block;
|
|
29536
|
-
margin-bottom: 5px;
|
|
29537
|
-
|
|
29538
|
-
&:before {
|
|
29539
|
-
content: '';
|
|
29540
|
-
-webkit-box-sizing: border-box;
|
|
29541
|
-
box-sizing: border-box;
|
|
29542
|
-
position: absolute;
|
|
29543
|
-
top: 0;
|
|
29544
|
-
left: 0;
|
|
29545
|
-
width: 40px;
|
|
29546
|
-
height: 40px;
|
|
29547
|
-
border: 2px solid currentColor;
|
|
29548
|
-
background: transparent;
|
|
29549
|
-
border-radius: ${(props) => (props.$singleSelection ? '100%' : 0)};
|
|
29550
|
-
}
|
|
29551
|
-
|
|
29552
|
-
&:after {
|
|
29553
|
-
content: '';
|
|
29554
|
-
-webkit-box-sizing: border-box;
|
|
29555
|
-
box-sizing: border-box;
|
|
29556
|
-
position: absolute;
|
|
29557
|
-
opacity: ${(props) => (props.$isChecked ? 1 : 0)};
|
|
29558
|
-
${checkedMarker}
|
|
29559
|
-
}
|
|
29560
|
-
`;
|
|
29561
|
-
|
|
29562
|
-
var RadioCheckboxInput = function (_a) {
|
|
29563
|
-
var singleSelection = _a.singleSelection, value = _a.value, name = _a.name, onChange = _a.onChange, checked = _a.checked, label = _a.label;
|
|
29564
|
-
var id = React.useId();
|
|
29565
|
-
return (React__default.default.createElement(Container$2, { "data-testid": "RadioCheckboxInput" },
|
|
29566
|
-
React__default.default.createElement(Category$1, null,
|
|
29567
|
-
React__default.default.createElement(CategoryInput, { type: singleSelection ? 'radio' : 'checkbox', value: value, id: id, name: name, onClick: onChange, defaultChecked: checked }),
|
|
29568
|
-
React__default.default.createElement(CategoryInputLabel, { "$isChecked": checked, htmlFor: id, "$singleSelection": singleSelection }, label))));
|
|
29569
|
-
};
|
|
29570
|
-
|
|
29571
32072
|
var DirectoryServiceList = function (_a) {
|
|
29572
32073
|
var directoryPath = _a.directoryPath, shortListPath = _a.shortListPath, services = _a.services, _b = _a.search, search = _b === void 0 ? '' : _b, setSearch = _a.setSearch, _c = _a.postcode, postcode = _c === void 0 ? '' : _c, setPostcode = _a.setPostcode, _d = _a.totalResults, totalResults = _d === void 0 ? 0 : _d, _e = _a.pageNumber, pageNumber = _e === void 0 ? 1 : _e, setPageNumber = _a.setPageNumber, _f = _a.perPage, perPage = _f === void 0 ? 5 : _f, _g = _a.extractLength, extractLength = _g === void 0 ? 300 : _g, _h = _a.categories, categories = _h === void 0 ? [] : _h, setCategories = _a.setCategories, _j = _a.minimumAge, minimumAge = _j === void 0 ? undefined : _j, setMinimumAge = _a.setMinimumAge, _k = _a.maximumAge, maximumAge = _k === void 0 ? undefined : _k, setMaximumAge = _a.setMaximumAge, _l = _a.mapCenter, mapCenter = _l === void 0 ? '52.23555414368587,-0.8957390701320571' : _l, _m = _a.mapZoom, mapZoom = _m === void 0 ? 9 : _m, _o = _a.isLoading, isLoading = _o === void 0 ? false : _o, _p = _a.ageInMonths, ageInMonths = _p === void 0 ? false : _p, _q = _a.hasDocuments, hasDocuments = _q === void 0 ? false : _q, _r = _a.isError, isError = _r === void 0 ? false : _r;
|
|
29573
32074
|
var _s = useLocalStorage("".concat(directoryPath.replace(/\//g, ''), "-accordion"), []), accordions = _s[0], setAccordions = _s[1];
|
|
@@ -29691,7 +32192,7 @@ var DirectoryServiceList = function (_a) {
|
|
|
29691
32192
|
});
|
|
29692
32193
|
}));
|
|
29693
32194
|
};
|
|
29694
|
-
return (React__default.default.createElement(Container$
|
|
32195
|
+
return (React__default.default.createElement(Container$2, { "data-testid": "DirectoryServiceList" },
|
|
29695
32196
|
React__default.default.createElement(Row$1, null,
|
|
29696
32197
|
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
29697
32198
|
React__default.default.createElement(SearchHeader$1, null,
|
|
@@ -29755,7 +32256,7 @@ var DirectoryServiceList = function (_a) {
|
|
|
29755
32256
|
React__default.default.createElement(Accordion, { "$isOpen": accordions[categoryIndex + 1] },
|
|
29756
32257
|
React__default.default.createElement(ClearFilter$1, null,
|
|
29757
32258
|
React__default.default.createElement(TextLink$1, { onClick: function (e) { return clearCategory(categoryIndex); } }, "Clear filter")),
|
|
29758
|
-
category.options.map(function (taxonomy) { return (React__default.default.createElement(Category$
|
|
32259
|
+
category.options.map(function (taxonomy) { return (React__default.default.createElement(Category$1, { key: taxonomy.id },
|
|
29759
32260
|
React__default.default.createElement(RadioCheckboxInput, { name: taxonomy.vocabulary, value: taxonomy.id, label: taxonomy.name, singleSelection: category.singleSelection, checked: taxonomy.checked, onChange: function (e) { return optionChecked(e, categoryIndex, category.singleSelection); } }))); }))))); })))))),
|
|
29760
32261
|
React__default.default.createElement(Column, { small: "full", medium: "two-thirds", large: "two-thirds" },
|
|
29761
32262
|
React__default.default.createElement(Row$1, null, isError ? (React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
@@ -31575,7 +34076,7 @@ exports.GDS_theme = GDS_theme;
|
|
|
31575
34076
|
exports.GlobalStyleReset = GlobalStyleReset;
|
|
31576
34077
|
exports.GoogleMap = GoogleMap;
|
|
31577
34078
|
exports.Header = Header;
|
|
31578
|
-
exports.Heading = Heading;
|
|
34079
|
+
exports.Heading = Heading$1;
|
|
31579
34080
|
exports.HeadingWithIcon = HeadingWithIcon;
|
|
31580
34081
|
exports.HeroImage = HeroImage;
|
|
31581
34082
|
exports.HomeHero = HomeHero;
|
|
@@ -31604,6 +34105,7 @@ exports.PromoBanner = PromoBanner;
|
|
|
31604
34105
|
exports.PromoBlock = PromoBlock;
|
|
31605
34106
|
exports.PromotedLinks = PromotedLinks;
|
|
31606
34107
|
exports.Promotions = Promotions;
|
|
34108
|
+
exports.RateThisPage = RateThisPage;
|
|
31607
34109
|
exports.SearchBox = SearchBox;
|
|
31608
34110
|
exports.SearchResultsList = SearchResultsList;
|
|
31609
34111
|
exports.Searchbar = Searchbar;
|