northants-design-system 1.0.1 → 1.1.0-alpha.0
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 +2998 -496
- package/build/index.js.map +1 -1
- package/build/index.mjs.js +2998 -497
- package/build/index.mjs.js.map +1 -1
- package/build/library/components/FormButton/FormButton.d.ts +2 -2
- package/build/library/components/Input/Input.test.d.ts +1 -0
- package/build/library/components/Input/Input.types.d.ts +4 -0
- package/build/library/components/Panel/Panel.d.ts +7 -0
- package/build/library/components/Panel/Panel.test.d.ts +1 -0
- package/build/library/components/Panel/Panel.types.d.ts +11 -0
- package/build/library/components/RadioCheckboxInput/RadioCheckboxInput.types.d.ts +4 -0
- package/build/library/components/Textarea/Textarea.d.ts +8 -0
- package/build/library/components/Textarea/Textarea.test.d.ts +1 -0
- package/build/library/components/Textarea/Textarea.types.d.ts +45 -0
- package/build/library/slices/StreamingVideo/StreamingVideo.d.ts +8 -0
- package/build/library/slices/StreamingVideo/StreamingVideo.test.d.ts +1 -0
- package/build/library/slices/StreamingVideo/StreamingVideo.types.d.ts +34 -0
- package/build/library/structure/PageStructures.d.ts +2 -1
- package/build/library/structure/RateThisPage/RateThisPage.d.ts +22 -0
- package/build/library/structure/RateThisPage/RateThisPage.test.d.ts +1 -0
- package/build/library/structure/RateThisPage/RateThisPage.types.d.ts +26 -0
- package/package.json +3 -1
package/build/index.js
CHANGED
|
@@ -128,6 +128,7 @@ const StyledInput = styled__default.default.input`
|
|
|
128
128
|
border-width: ${(props) => (props.$isErrored ? '3px' : '2px')};
|
|
129
129
|
border-radius: ${(props) => props.theme.theme_vars.border_radius};
|
|
130
130
|
display: block;
|
|
131
|
+
width: ${(props) => (props.$isFullWidth ? '100%' : 'auto')};
|
|
131
132
|
|
|
132
133
|
&:focus {
|
|
133
134
|
outline: none;
|
|
@@ -135,7 +136,7 @@ const StyledInput = styled__default.default.input`
|
|
|
135
136
|
transition: box-shadow 0.3s ease 0s;
|
|
136
137
|
}
|
|
137
138
|
`;
|
|
138
|
-
const ErrorText$
|
|
139
|
+
const ErrorText$2 = styled__default.default.p`
|
|
139
140
|
${(props) => props.theme.fontStyles}
|
|
140
141
|
color: ${(props) => props.theme.theme_vars.colours.negative};
|
|
141
142
|
font-weight: bold;
|
|
@@ -2097,7 +2098,7 @@ function normalizeArrowKey(event) {
|
|
|
2097
2098
|
*/
|
|
2098
2099
|
|
|
2099
2100
|
|
|
2100
|
-
function isPlainObject$
|
|
2101
|
+
function isPlainObject$4(obj) {
|
|
2101
2102
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
2102
2103
|
}
|
|
2103
2104
|
/**
|
|
@@ -3375,7 +3376,7 @@ const Downshift = /*#__PURE__*/(() => {
|
|
|
3375
3376
|
return '';
|
|
3376
3377
|
}
|
|
3377
3378
|
|
|
3378
|
-
if (process.env.NODE_ENV !== 'production' && isPlainObject$
|
|
3379
|
+
if (process.env.NODE_ENV !== 'production' && isPlainObject$4(i) && !i.hasOwnProperty('toString')) {
|
|
3379
3380
|
// eslint-disable-next-line no-console
|
|
3380
3381
|
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);
|
|
3381
3382
|
}
|
|
@@ -3847,7 +3848,7 @@ var Autocomplete = function (_a) {
|
|
|
3847
3848
|
var getInputProps = _a.getInputProps, getItemProps = _a.getItemProps, getLabelProps = _a.getLabelProps, getMenuProps = _a.getMenuProps, isOpen = _a.isOpen, inputValue = _a.inputValue, getRootProps = _a.getRootProps;
|
|
3848
3849
|
return (React__default.default.createElement("div", null,
|
|
3849
3850
|
React__default.default.createElement(AutocompleteLabel, __assign$2({}, getLabelProps(), { "$hasHiddenLabel": hasHiddenLabel }), labelText ? labelText : placeholder),
|
|
3850
|
-
isErrored && errorText && (React__default.default.createElement(React__default.default.Fragment, null, hasLightBackground ? (React__default.default.createElement(ErrorText$
|
|
3851
|
+
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)))),
|
|
3851
3852
|
React__default.default.createElement("div", __assign$2({}, getRootProps(undefined, { suppressRefError: true })),
|
|
3852
3853
|
React__default.default.createElement(AutocompleteTextInput, __assign$2({}, getInputProps({
|
|
3853
3854
|
name: name,
|
|
@@ -3876,7 +3877,7 @@ var Autocomplete = function (_a) {
|
|
|
3876
3877
|
})));
|
|
3877
3878
|
};
|
|
3878
3879
|
|
|
3879
|
-
const Container$
|
|
3880
|
+
const Container$18 = styled__default.default.div`
|
|
3880
3881
|
display: block;
|
|
3881
3882
|
`;
|
|
3882
3883
|
|
|
@@ -3961,7 +3962,7 @@ var BackToTop = function (_a) {
|
|
|
3961
3962
|
React.useEffect(function () {
|
|
3962
3963
|
window.addEventListener('scroll', toggleVisible);
|
|
3963
3964
|
});
|
|
3964
|
-
return (React__default.default.createElement(Container$
|
|
3965
|
+
return (React__default.default.createElement(Container$18, { "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" },
|
|
3965
3966
|
React__default.default.createElement(ChevronIcon, { colourFill: themeContext.theme_vars.colours.white, direction: "up" })))));
|
|
3966
3967
|
};
|
|
3967
3968
|
|
|
@@ -6159,7 +6160,7 @@ const H4 = styled__default.default.h4`
|
|
|
6159
6160
|
/**
|
|
6160
6161
|
* A heading of different levels
|
|
6161
6162
|
*/
|
|
6162
|
-
var Heading = function (_a) {
|
|
6163
|
+
var Heading$1 = function (_a) {
|
|
6163
6164
|
var _b = _a.level, level = _b === void 0 ? 2 : _b, text = _a.text, props = __rest(_a, ["level", "text"]);
|
|
6164
6165
|
if (level === 1)
|
|
6165
6166
|
return React__default.default.createElement(H1, __assign$2({}, props), text);
|
|
@@ -6216,10 +6217,10 @@ var HeadingWithIcon = function (_a) {
|
|
|
6216
6217
|
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;
|
|
6217
6218
|
return (React__default.default.createElement(HeadingWrapper, { "data-testid": "HeadingWithIcon", "$hasHover": hasHover },
|
|
6218
6219
|
React__default.default.createElement(DynamicIcon, { icon: icon, level: level }),
|
|
6219
|
-
React__default.default.createElement(Heading, { text: text, level: level })));
|
|
6220
|
+
React__default.default.createElement(Heading$1, { text: text, level: level })));
|
|
6220
6221
|
};
|
|
6221
6222
|
|
|
6222
|
-
const Container$
|
|
6223
|
+
const Container$17 = styled__default.default.div`
|
|
6223
6224
|
display: flex;
|
|
6224
6225
|
width: 100%;
|
|
6225
6226
|
min-height: 400px;
|
|
@@ -6243,7 +6244,7 @@ var Map$1 = function (_a) {
|
|
|
6243
6244
|
setMap(new window.google.maps.Map(ref.current, { center: center, zoom: zoom }));
|
|
6244
6245
|
}
|
|
6245
6246
|
}, [ref, map]);
|
|
6246
|
-
return (React__default.default.createElement(Container$
|
|
6247
|
+
return (React__default.default.createElement(Container$17, { "data-testid": "Map" },
|
|
6247
6248
|
React__default.default.createElement("div", { ref: ref }),
|
|
6248
6249
|
React__default.default.Children.map(children, function (child) {
|
|
6249
6250
|
if (React__default.default.isValidElement(child)) {
|
|
@@ -6300,7 +6301,7 @@ var MapMarker = function (options) {
|
|
|
6300
6301
|
return null;
|
|
6301
6302
|
};
|
|
6302
6303
|
|
|
6303
|
-
const Container$
|
|
6304
|
+
const Container$16 = styled__default.default.div`
|
|
6304
6305
|
${(props) => props.theme.fontStyles};
|
|
6305
6306
|
display: block;
|
|
6306
6307
|
border-top: 1px solid ${(props) => props.theme.theme_vars.colours.grey};
|
|
@@ -7078,7 +7079,7 @@ var Pagination = function (_a) {
|
|
|
7078
7079
|
}
|
|
7079
7080
|
};
|
|
7080
7081
|
if (numbers.length > 1) {
|
|
7081
|
-
return (React__default.default.createElement(Container$
|
|
7082
|
+
return (React__default.default.createElement(Container$16, { "data-testid": "Pagination", role: "navigation", "aria-label": "Pagination" },
|
|
7082
7083
|
currentPage > 1 && (React__default.default.createElement(Previous, { onClick: function () { return buttonClick(currentPage - 1); }, title: "Go back a page" }, "Previous")),
|
|
7083
7084
|
React__default.default.createElement(NumbersContainer, null, numbers.map(function (v, i) { return (React__default.default.createElement(NumberContainer, { key: i },
|
|
7084
7085
|
v === '...' && React__default.default.createElement(Ellipsis, null, "..."),
|
|
@@ -7090,7 +7091,7 @@ var Pagination = function (_a) {
|
|
|
7090
7091
|
return null;
|
|
7091
7092
|
};
|
|
7092
7093
|
|
|
7093
|
-
const Container$
|
|
7094
|
+
const Container$15 = styled__default.default.div`
|
|
7094
7095
|
${(props) => props.theme.fontStyles};
|
|
7095
7096
|
margin-bottom: 30px;
|
|
7096
7097
|
`;
|
|
@@ -7114,7 +7115,7 @@ const hideLabel$1 = (props) => {
|
|
|
7114
7115
|
}
|
|
7115
7116
|
};
|
|
7116
7117
|
|
|
7117
|
-
const Legend$
|
|
7118
|
+
const Legend$3 = styled__default.default.legend`
|
|
7118
7119
|
color: #0b0c0c;
|
|
7119
7120
|
-webkit-box-sizing: border-box;
|
|
7120
7121
|
box-sizing: border-box;
|
|
@@ -7132,7 +7133,7 @@ const hideHint = (props) => {
|
|
|
7132
7133
|
}
|
|
7133
7134
|
};
|
|
7134
7135
|
|
|
7135
|
-
const Hint = styled__default.default.div`
|
|
7136
|
+
const Hint$1 = styled__default.default.div`
|
|
7136
7137
|
font-size: ${(props) => props.theme.theme_vars.fontSizes.small};
|
|
7137
7138
|
display: block;
|
|
7138
7139
|
margin-bottom: 15px;
|
|
@@ -7261,16 +7262,16 @@ var CheckboxListFilter = function (_a) {
|
|
|
7261
7262
|
handleParams('news', [{ key: NewsArticleFilterFields.articleType.queryParamKey, value: articleTypes }], ['page']);
|
|
7262
7263
|
};
|
|
7263
7264
|
var backupLabel = Math.random().toString(36).substring(7);
|
|
7264
|
-
return (React__default.default.createElement(Container$
|
|
7265
|
+
return (React__default.default.createElement(Container$15, { "data-testid": "CheckboxListFilter" },
|
|
7265
7266
|
React__default.default.createElement(Fieldset$2, { "aria-describedby": hintId },
|
|
7266
|
-
React__default.default.createElement(Legend$
|
|
7267
|
-
React__default.default.createElement(Hint, { id: hintId, "$hintHidden": hintHidden, "data-testid": "CheckboxListFilterHint" }, hint),
|
|
7267
|
+
React__default.default.createElement(Legend$3, { "$labelHidden": labelHidden, "data-testid": "CheckboxListFilterLegend" }, label),
|
|
7268
|
+
React__default.default.createElement(Hint$1, { id: hintId, "$hintHidden": hintHidden, "data-testid": "CheckboxListFilterHint" }, hint),
|
|
7268
7269
|
React__default.default.createElement(Checkboxes, null, checkboxState.map(function (option, i) { return (React__default.default.createElement(Checkbox, { key: i },
|
|
7269
7270
|
React__default.default.createElement(CheckboxInput, { id: option.value, name: labelHidden ? backupLabel : label, type: "checkbox", onChange: optionChecked, value: option.value, checked: option.checked }),
|
|
7270
7271
|
React__default.default.createElement(CheckboxLabel, { "$isChecked": option.checked, htmlFor: option.value }, option.title))); })))));
|
|
7271
7272
|
};
|
|
7272
7273
|
|
|
7273
|
-
const Container$
|
|
7274
|
+
const Container$14 = styled__default.default.div`
|
|
7274
7275
|
${(props) => props.theme.fontStyles};
|
|
7275
7276
|
`;
|
|
7276
7277
|
|
|
@@ -7280,7 +7281,7 @@ const hideLabel = (props) => {
|
|
|
7280
7281
|
}
|
|
7281
7282
|
};
|
|
7282
7283
|
|
|
7283
|
-
const Label$
|
|
7284
|
+
const Label$5 = styled__default.default.label`
|
|
7284
7285
|
display: block;
|
|
7285
7286
|
margin-bottom: 5px;
|
|
7286
7287
|
${hideLabel}
|
|
@@ -7315,8 +7316,8 @@ const Option = styled__default.default.option`
|
|
|
7315
7316
|
|
|
7316
7317
|
var DropDownSelect = function (_a) {
|
|
7317
7318
|
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;
|
|
7318
|
-
return (React__default.default.createElement(Container$
|
|
7319
|
-
React__default.default.createElement(Label$
|
|
7319
|
+
return (React__default.default.createElement(Container$14, null,
|
|
7320
|
+
React__default.default.createElement(Label$5, { htmlFor: id, "$hideLabel": hideLabel }, label),
|
|
7320
7321
|
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)); }))));
|
|
7321
7322
|
};
|
|
7322
7323
|
|
|
@@ -7430,7 +7431,7 @@ const PromotedLink$1 = styled__default.default.a`
|
|
|
7430
7431
|
${oneColStyles}
|
|
7431
7432
|
`;
|
|
7432
7433
|
|
|
7433
|
-
const Container$
|
|
7434
|
+
const Container$13 = styled__default.default.div`
|
|
7434
7435
|
box-sizing: border-box;
|
|
7435
7436
|
display: flex;
|
|
7436
7437
|
flex-wrap: wrap;
|
|
@@ -7453,7 +7454,7 @@ const Container$12 = styled__default.default.div`
|
|
|
7453
7454
|
|
|
7454
7455
|
var Row$1 = function (_a) {
|
|
7455
7456
|
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;
|
|
7456
|
-
return (React__default.default.createElement(Container$
|
|
7457
|
+
return (React__default.default.createElement(Container$13, { "data-testid": "Row", "$hasBorder": hasBorder, "$hasWrap": hasWrap, as: isList ? 'ul' : 'div' }, children));
|
|
7457
7458
|
};
|
|
7458
7459
|
|
|
7459
7460
|
const calculateWidth = (size) => {
|
|
@@ -7503,7 +7504,7 @@ const widths = (props) => {
|
|
|
7503
7504
|
`;
|
|
7504
7505
|
};
|
|
7505
7506
|
|
|
7506
|
-
const Container$
|
|
7507
|
+
const Container$12 = styled__default.default.div`
|
|
7507
7508
|
box-sizing: border-box;
|
|
7508
7509
|
display: block;
|
|
7509
7510
|
padding: ${(props) => (props.$hasPadding ? props.theme.theme_vars.spacingSizes.small : `0`)};
|
|
@@ -7514,7 +7515,7 @@ const Container$11 = styled__default.default.div`
|
|
|
7514
7515
|
|
|
7515
7516
|
var Column = function (_a) {
|
|
7516
7517
|
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;
|
|
7517
|
-
return (React__default.default.createElement(Container$
|
|
7518
|
+
return (React__default.default.createElement(Container$12, { "data-testid": "Column", "$small": small, "$medium": medium, "$large": large, "$hasPadding": hasPadding, "$hasBorder": hasBorder, as: isList ? 'li' : 'div', className: classes }, children));
|
|
7518
7519
|
};
|
|
7519
7520
|
|
|
7520
7521
|
var PromotedLinks = function (_a) {
|
|
@@ -7530,7 +7531,7 @@ var PromotedLinks = function (_a) {
|
|
|
7530
7531
|
}
|
|
7531
7532
|
};
|
|
7532
7533
|
|
|
7533
|
-
const Container$
|
|
7534
|
+
const Container$11 = styled__default.default.div`
|
|
7534
7535
|
display: block;
|
|
7535
7536
|
`;
|
|
7536
7537
|
|
|
@@ -7566,7 +7567,7 @@ const Cookies = styled__default.default.button`
|
|
|
7566
7567
|
}
|
|
7567
7568
|
`;
|
|
7568
7569
|
|
|
7569
|
-
const Container
|
|
7570
|
+
const Container$10 = styled__default.default.div`
|
|
7570
7571
|
${props => props.theme.fontStyles}
|
|
7571
7572
|
background-color: ${props => props.theme.theme_vars.colours.grey_light};
|
|
7572
7573
|
padding: ${props => props.theme.theme_vars.spacingSizes.medium} 0;
|
|
@@ -7678,74 +7679,80 @@ const ButtonsContainer = styled__default.default.div`
|
|
|
7678
7679
|
`;
|
|
7679
7680
|
|
|
7680
7681
|
const StyledButton = styled__default.default.button`
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7682
|
+
font-weight: 700;
|
|
7683
|
+
border: none;
|
|
7684
|
+
cursor: pointer;
|
|
7685
|
+
display: inline-block;
|
|
7686
|
+
line-height: 1;
|
|
7687
|
+
font-family: ${(props) => props.theme.theme_vars.fontstack};
|
|
7688
|
+
border-radius: ${(props) => props.theme.theme_vars.border_radius};
|
|
7689
|
+
text-decoration: none;
|
|
7689
7690
|
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7691
|
+
&:disabled {
|
|
7692
|
+
background-color: ${(props) => props.theme.theme_vars.colours.grey} !important;
|
|
7693
|
+
color: ${(props) => props.theme.theme_vars.colours.black} !important;
|
|
7694
|
+
cursor: not-allowed !important;
|
|
7695
|
+
}
|
|
7693
7696
|
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
&:focus {
|
|
7698
|
-
outline: none;
|
|
7699
|
-
color: ${props => props.theme.theme_vars.colours.black} !important;
|
|
7700
|
-
background-color: ${props => props.theme.theme_vars.colours.focus};
|
|
7701
|
-
box-shadow: 0px -3px 0px 0px ${props => props.theme.theme_vars.colours.black} inset;
|
|
7702
|
-
-webkit-box-shadow: 0px -3px 0px 0px ${props => props.theme.theme_vars.colours.black} inset;
|
|
7703
|
-
-moz-box-shadow: 0px -3px 0px 0px ${props => props.theme.theme_vars.colours.black} inset;
|
|
7704
|
-
}
|
|
7705
|
-
&:active {
|
|
7706
|
-
transform: translateY(2px);
|
|
7707
|
-
color: ${props => props.theme.theme_vars.colours.black} !important;
|
|
7708
|
-
background-color: ${props => props.theme.theme_vars.colours.focus};
|
|
7709
|
-
box-shadow: 0px -1px 0px 0px ${props => props.theme.theme_vars.colours.black} inset;
|
|
7710
|
-
-webkit-box-shadow: 0px -1px 0px 0px ${props => props.theme.theme_vars.colours.black} inset;
|
|
7711
|
-
-moz-box-shadow: 0px -1px 0px 0px ${props => props.theme.theme_vars.colours.black} inset;
|
|
7712
|
-
}
|
|
7713
|
-
}
|
|
7714
|
-
&.button--secondary {
|
|
7715
|
-
color: ${props => props.theme.theme_vars.colours.action};
|
|
7716
|
-
background-color: transparent;
|
|
7717
|
-
border: 2px solid ${props => props.theme.theme_vars.colours.action};
|
|
7697
|
+
&.button--primary {
|
|
7698
|
+
color: white;
|
|
7699
|
+
background-color: ${(props) => props.theme.theme_vars.colours.action};
|
|
7718
7700
|
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7701
|
+
&:hover {
|
|
7702
|
+
background-color: ${(props) => props.theme.theme_vars.colours.action_dark};
|
|
7703
|
+
}
|
|
7704
|
+
&:focus {
|
|
7705
|
+
outline: none;
|
|
7706
|
+
color: ${(props) => props.theme.theme_vars.colours.black} !important;
|
|
7707
|
+
background-color: ${(props) => props.theme.theme_vars.colours.focus};
|
|
7708
|
+
box-shadow: 0px -3px 0px 0px ${(props) => props.theme.theme_vars.colours.black} inset;
|
|
7709
|
+
-webkit-box-shadow: 0px -3px 0px 0px ${(props) => props.theme.theme_vars.colours.black} inset;
|
|
7710
|
+
-moz-box-shadow: 0px -3px 0px 0px ${(props) => props.theme.theme_vars.colours.black} inset;
|
|
7727
7711
|
}
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7712
|
+
&:active {
|
|
7713
|
+
transform: translateY(2px);
|
|
7714
|
+
color: ${(props) => props.theme.theme_vars.colours.black} !important;
|
|
7715
|
+
background-color: ${(props) => props.theme.theme_vars.colours.focus};
|
|
7716
|
+
box-shadow: 0px -1px 0px 0px ${(props) => props.theme.theme_vars.colours.black} inset;
|
|
7717
|
+
-webkit-box-shadow: 0px -1px 0px 0px ${(props) => props.theme.theme_vars.colours.black} inset;
|
|
7718
|
+
-moz-box-shadow: 0px -1px 0px 0px ${(props) => props.theme.theme_vars.colours.black} inset;
|
|
7731
7719
|
}
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7720
|
+
}
|
|
7721
|
+
&.button--secondary {
|
|
7722
|
+
color: ${(props) => props.theme.theme_vars.colours.action};
|
|
7723
|
+
background-color: transparent;
|
|
7724
|
+
border: 2px solid ${(props) => props.theme.theme_vars.colours.action};
|
|
7725
|
+
|
|
7726
|
+
&:hover {
|
|
7727
|
+
background-color: ${(props) => props.theme.theme_vars.colours.action}1A;
|
|
7735
7728
|
}
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7729
|
+
&:focus {
|
|
7730
|
+
outline: none;
|
|
7731
|
+
border: 2px solid ${(props) => props.theme.theme_vars.colours.focus};
|
|
7732
|
+
background-color: ${(props) => props.theme.theme_vars.colours.action}1A;
|
|
7739
7733
|
}
|
|
7734
|
+
}
|
|
7735
|
+
&.button--small {
|
|
7736
|
+
font-size: 12px;
|
|
7737
|
+
padding: 10px 16px;
|
|
7738
|
+
}
|
|
7739
|
+
&.button--medium {
|
|
7740
|
+
font-size: 14px;
|
|
7741
|
+
padding: 11px 20px;
|
|
7742
|
+
}
|
|
7743
|
+
&.button--large {
|
|
7744
|
+
font-size: 16px;
|
|
7745
|
+
padding: 12px 24px;
|
|
7746
|
+
}
|
|
7740
7747
|
`;
|
|
7741
7748
|
|
|
7742
7749
|
/**
|
|
7743
7750
|
* Primary UI component for user interaction
|
|
7744
7751
|
*/
|
|
7745
7752
|
var FormButton = function (_a) {
|
|
7746
|
-
var _b = _a.primary, primary = _b === void 0 ? true : _b, _c = _a.size, size = _c === void 0 ? 'medium' : _c, text = _a.text; _a.type; _a.isDisabled
|
|
7753
|
+
var _b = _a.primary, primary = _b === void 0 ? true : _b, _c = _a.size, size = _c === void 0 ? 'medium' : _c, text = _a.text; _a.type; var _e = _a.isDisabled, isDisabled = _e === void 0 ? false : _e, props = __rest(_a, ["primary", "size", "text", "type", "isDisabled"]);
|
|
7747
7754
|
var mode = primary ? 'button--primary' : 'button--secondary';
|
|
7748
|
-
return (React__default.default.createElement(StyledButton, __assign$2({ className: ["button--".concat(size), mode].join(' ') }, props), text));
|
|
7755
|
+
return (React__default.default.createElement(StyledButton, __assign$2({ className: ["button--".concat(size), mode].join(' '), disabled: isDisabled }, props), text));
|
|
7749
7756
|
};
|
|
7750
7757
|
|
|
7751
7758
|
const cookieName = 'fn-cookie';
|
|
@@ -7904,18 +7911,18 @@ var CookieBanner = function (_a) {
|
|
|
7904
7911
|
hideCookiesAcceptedConfirmationBanner();
|
|
7905
7912
|
};
|
|
7906
7913
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
7907
|
-
showCookieBanner && (React__default.default.createElement(Container
|
|
7914
|
+
showCookieBanner && (React__default.default.createElement(Container$10, { "data-testid": "CookieBanner" },
|
|
7908
7915
|
React__default.default.createElement(CookieMessage, null,
|
|
7909
7916
|
React__default.default.createElement(CookieHeading, null, title),
|
|
7910
7917
|
React__default.default.createElement(CookieParagraph, null, paragraph),
|
|
7911
7918
|
React__default.default.createElement(ButtonsContainer, null,
|
|
7912
7919
|
React__default.default.createElement(FormButton, { primary: true, text: acceptButtonText, isDisabled: true, onClick: acceptCookies }),
|
|
7913
7920
|
React__default.default.createElement(FormButton, { primary: true, text: rejectButtonText, isDisabled: true, onClick: rejectCookies }))))),
|
|
7914
|
-
showCookiesRejectedBanner && (React__default.default.createElement(Container
|
|
7921
|
+
showCookiesRejectedBanner && (React__default.default.createElement(Container$10, { "data-testid": "CookieBannerRejected", id: "CookieBannerRejected" },
|
|
7915
7922
|
React__default.default.createElement(CookieMessage, { isInline: true },
|
|
7916
7923
|
React__default.default.createElement(CookieParagraph, null, rejectConfirmationText),
|
|
7917
7924
|
React__default.default.createElement(CookieHide, { onClick: hideCookiesConfirmationBanner, "aria-controls": "CookieBannerRejected", "aria-hidden": "false" }, "Hide")))),
|
|
7918
|
-
showCookiesAcceptedBanner && (React__default.default.createElement(Container
|
|
7925
|
+
showCookiesAcceptedBanner && (React__default.default.createElement(Container$10, { "data-testid": "CookieBannerAccepted", id: "CookieBannerAccepted" },
|
|
7919
7926
|
React__default.default.createElement(CookieMessage, { isInline: true },
|
|
7920
7927
|
React__default.default.createElement(CookieParagraph, null, acceptConfirmationText),
|
|
7921
7928
|
React__default.default.createElement(CookieHide, { onClick: hideCookiesConfirmationBanner, "aria-controls": "CookieBannerAccepted", "aria-hidden": "false" }, "Hide"))))));
|
|
@@ -7937,7 +7944,7 @@ var StaticMap = function (_a) {
|
|
|
7937
7944
|
return "&markers=size:".concat(size, "%7Ccolor:").concat(colour).concat(label, "%7C").concat(mapMarker.lat, ",").concat(mapMarker.lng);
|
|
7938
7945
|
})
|
|
7939
7946
|
.join('');
|
|
7940
|
-
return (React__default.default.createElement(Container$
|
|
7947
|
+
return (React__default.default.createElement(Container$11, { "data-testid": "StaticMap" },
|
|
7941
7948
|
React__default.default.createElement(Message, null,
|
|
7942
7949
|
React__default.default.createElement("span", null,
|
|
7943
7950
|
"To interact with the map, you need to ",
|
|
@@ -7952,13 +7959,13 @@ var StaticMap = function (_a) {
|
|
|
7952
7959
|
var TextInput = function (_a) {
|
|
7953
7960
|
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;
|
|
7954
7961
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
7955
|
-
isErrored && errorText && React__default.default.createElement(ErrorText$
|
|
7962
|
+
isErrored && errorText && React__default.default.createElement(ErrorText$2, null, errorText),
|
|
7956
7963
|
React__default.default.createElement(StyledTextInput, { type: "text", id: id, name: name, defaultValue: value, "$size": size, placeholder: placeholder, "$isErrored": isErrored, "$isLarge": isLarge })));
|
|
7957
7964
|
};
|
|
7958
7965
|
|
|
7959
7966
|
// Accordion
|
|
7960
7967
|
|
|
7961
|
-
const Container
|
|
7968
|
+
const Container$$ = styled__default.default.div`
|
|
7962
7969
|
${(props) => props.theme.fontStyles}
|
|
7963
7970
|
margin-bottom: 20px;
|
|
7964
7971
|
border-bottom: 1px solid ${(props) => props.theme.theme_vars.colours.grey};
|
|
@@ -8233,7 +8240,7 @@ var Accordion$1 = function (_a) {
|
|
|
8233
8240
|
setAccordionStates(newStatus);
|
|
8234
8241
|
};
|
|
8235
8242
|
var accordionId = "accordion".concat(React.useId());
|
|
8236
|
-
return (React__default.default.createElement(Container
|
|
8243
|
+
return (React__default.default.createElement(Container$$, { "data-testid": "Accordion", id: accordionId },
|
|
8237
8244
|
showControls && sections.length > 1 && (React__default.default.createElement(AccordionControls$1, null,
|
|
8238
8245
|
React__default.default.createElement(OpenAllButton, { onClick: toggleAll, type: "button", "aria-expanded": !openAll },
|
|
8239
8246
|
openAll ? 'Open all' : 'Close all',
|
|
@@ -8284,7 +8291,7 @@ var BlockQuote = function (_a) {
|
|
|
8284
8291
|
citation && React__default.default.createElement(Citation, null, citation)));
|
|
8285
8292
|
};
|
|
8286
8293
|
|
|
8287
|
-
const Container$
|
|
8294
|
+
const Container$_ = styled__default.default.div`
|
|
8288
8295
|
margin-bottom: 30px;
|
|
8289
8296
|
display: block;
|
|
8290
8297
|
|
|
@@ -8299,11 +8306,11 @@ const Container$Z = styled__default.default.div`
|
|
|
8299
8306
|
*/
|
|
8300
8307
|
var CallToAction = function (_a) {
|
|
8301
8308
|
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"]);
|
|
8302
|
-
return (React__default.default.createElement(Container$
|
|
8309
|
+
return (React__default.default.createElement(Container$_, null,
|
|
8303
8310
|
React__default.default.createElement(Button$4, { primary: primary, size: "large", text: text, url: url, isExternal: isExternal, isDisabled: isDisabled })));
|
|
8304
8311
|
};
|
|
8305
8312
|
|
|
8306
|
-
const Container$
|
|
8313
|
+
const Container$Z = styled__default.default.div`
|
|
8307
8314
|
display: block;
|
|
8308
8315
|
${(props) => props.theme.fontStyles}
|
|
8309
8316
|
`;
|
|
@@ -8388,7 +8395,7 @@ const BackButton = styled__default.default.a`
|
|
|
8388
8395
|
}
|
|
8389
8396
|
`;
|
|
8390
8397
|
|
|
8391
|
-
const ErrorText = styled__default.default.p`
|
|
8398
|
+
const ErrorText$1 = styled__default.default.p`
|
|
8392
8399
|
${(props) => props.theme.fontStyles}
|
|
8393
8400
|
color: ${(props) => props.theme.theme_vars.colours.negative};
|
|
8394
8401
|
font-weight: bold;
|
|
@@ -8479,9 +8486,9 @@ var CouncilTaxAlphabeticalDirectory = function (_a) {
|
|
|
8479
8486
|
});
|
|
8480
8487
|
return letterData;
|
|
8481
8488
|
});
|
|
8482
|
-
return (React__default.default.createElement(Container$
|
|
8489
|
+
return (React__default.default.createElement(Container$Z, { "data-testid": "AlphabeticalDirectory", ref: directoryRef },
|
|
8483
8490
|
React__default.default.createElement(React__default.default.Fragment, null,
|
|
8484
|
-
parishes.length === 0 && (React__default.default.createElement(ErrorText, null, "There was an issue fetching the parish data. Please try again later.")),
|
|
8491
|
+
parishes.length === 0 && (React__default.default.createElement(ErrorText$1, null, "There was an issue fetching the parish data. Please try again later.")),
|
|
8485
8492
|
parish === null ? (React__default.default.createElement(React__default.default.Fragment, null, sortedData.map(function (letter, i) { return (React__default.default.createElement(Row, { key: i },
|
|
8486
8493
|
React__default.default.createElement(Row$1, null,
|
|
8487
8494
|
React__default.default.createElement(Column, { small: "full", medium: "one-quarter", large: "one-quarter" },
|
|
@@ -8505,9 +8512,9 @@ var CouncilTaxAlphabeticalDirectory = function (_a) {
|
|
|
8505
8512
|
React__default.default.createElement("td", null, Number(parish.values[band]).toLocaleString('en-GB', { style: 'currency', currency: 'GBP' })))); })))))))));
|
|
8506
8513
|
};
|
|
8507
8514
|
|
|
8508
|
-
const Container$
|
|
8515
|
+
const Container$Y = styled__default.default.div``;
|
|
8509
8516
|
|
|
8510
|
-
const Container$
|
|
8517
|
+
const Container$X = styled__default.default.div`
|
|
8511
8518
|
display: flex;
|
|
8512
8519
|
flex-direction: column;
|
|
8513
8520
|
justify-content: flex-start;
|
|
@@ -8520,7 +8527,7 @@ const Container$W = styled__default.default.div`
|
|
|
8520
8527
|
: props.theme.theme_vars.colours.white};
|
|
8521
8528
|
`;
|
|
8522
8529
|
|
|
8523
|
-
const Content$
|
|
8530
|
+
const Content$7 = styled__default.default.div`
|
|
8524
8531
|
padding: ${(props) => props.theme.theme_vars.spacingSizes.medium};
|
|
8525
8532
|
flex-grow: 1;
|
|
8526
8533
|
|
|
@@ -13225,9 +13232,9 @@ var escapeStringRegexp$1 = string => {
|
|
|
13225
13232
|
.replace(/-/g, '\\x2d');
|
|
13226
13233
|
};
|
|
13227
13234
|
|
|
13228
|
-
var isPlainObject$
|
|
13235
|
+
var isPlainObject$3 = {};
|
|
13229
13236
|
|
|
13230
|
-
Object.defineProperty(isPlainObject$
|
|
13237
|
+
Object.defineProperty(isPlainObject$3, '__esModule', { value: true });
|
|
13231
13238
|
|
|
13232
13239
|
/*!
|
|
13233
13240
|
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
@@ -13236,14 +13243,14 @@ Object.defineProperty(isPlainObject$2, '__esModule', { value: true });
|
|
|
13236
13243
|
* Released under the MIT License.
|
|
13237
13244
|
*/
|
|
13238
13245
|
|
|
13239
|
-
function isObject(o) {
|
|
13246
|
+
function isObject$1(o) {
|
|
13240
13247
|
return Object.prototype.toString.call(o) === '[object Object]';
|
|
13241
13248
|
}
|
|
13242
13249
|
|
|
13243
|
-
function isPlainObject$
|
|
13250
|
+
function isPlainObject$2(o) {
|
|
13244
13251
|
var ctor,prot;
|
|
13245
13252
|
|
|
13246
|
-
if (isObject(o) === false) return false;
|
|
13253
|
+
if (isObject$1(o) === false) return false;
|
|
13247
13254
|
|
|
13248
13255
|
// If has modified constructor
|
|
13249
13256
|
ctor = o.constructor;
|
|
@@ -13251,7 +13258,7 @@ function isPlainObject$1(o) {
|
|
|
13251
13258
|
|
|
13252
13259
|
// If has modified prototype
|
|
13253
13260
|
prot = ctor.prototype;
|
|
13254
|
-
if (isObject(prot) === false) return false;
|
|
13261
|
+
if (isObject$1(prot) === false) return false;
|
|
13255
13262
|
|
|
13256
13263
|
// If constructor does not have an Object-specific method
|
|
13257
13264
|
if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
|
@@ -13262,7 +13269,7 @@ function isPlainObject$1(o) {
|
|
|
13262
13269
|
return true;
|
|
13263
13270
|
}
|
|
13264
13271
|
|
|
13265
|
-
isPlainObject$
|
|
13272
|
+
isPlainObject$3.isPlainObject = isPlainObject$2;
|
|
13266
13273
|
|
|
13267
13274
|
var isMergeableObject = function isMergeableObject(value) {
|
|
13268
13275
|
return isNonNullObject(value)
|
|
@@ -19119,7 +19126,7 @@ function markDirtyUp(node) {
|
|
|
19119
19126
|
}
|
|
19120
19127
|
}
|
|
19121
19128
|
|
|
19122
|
-
let Container$
|
|
19129
|
+
let Container$W = class Container extends Node$1 {
|
|
19123
19130
|
append(...children) {
|
|
19124
19131
|
for (let child of children) {
|
|
19125
19132
|
let nodes = this.normalize(child, this.last);
|
|
@@ -19490,27 +19497,27 @@ let Container$V = class Container extends Node$1 {
|
|
|
19490
19497
|
}
|
|
19491
19498
|
};
|
|
19492
19499
|
|
|
19493
|
-
Container$
|
|
19500
|
+
Container$W.registerParse = dependant => {
|
|
19494
19501
|
parse$4 = dependant;
|
|
19495
19502
|
};
|
|
19496
19503
|
|
|
19497
|
-
Container$
|
|
19504
|
+
Container$W.registerRule = dependant => {
|
|
19498
19505
|
Rule$4 = dependant;
|
|
19499
19506
|
};
|
|
19500
19507
|
|
|
19501
|
-
Container$
|
|
19508
|
+
Container$W.registerAtRule = dependant => {
|
|
19502
19509
|
AtRule$4 = dependant;
|
|
19503
19510
|
};
|
|
19504
19511
|
|
|
19505
|
-
Container$
|
|
19512
|
+
Container$W.registerRoot = dependant => {
|
|
19506
19513
|
Root$6 = dependant;
|
|
19507
19514
|
};
|
|
19508
19515
|
|
|
19509
|
-
var container = Container$
|
|
19510
|
-
Container$
|
|
19516
|
+
var container = Container$W;
|
|
19517
|
+
Container$W.default = Container$W;
|
|
19511
19518
|
|
|
19512
19519
|
/* c8 ignore start */
|
|
19513
|
-
Container$
|
|
19520
|
+
Container$W.rebuild = node => {
|
|
19514
19521
|
if (node.type === 'atrule') {
|
|
19515
19522
|
Object.setPrototypeOf(node, AtRule$4.prototype);
|
|
19516
19523
|
} else if (node.type === 'rule') {
|
|
@@ -19527,16 +19534,16 @@ Container$V.rebuild = node => {
|
|
|
19527
19534
|
|
|
19528
19535
|
if (node.nodes) {
|
|
19529
19536
|
node.nodes.forEach(child => {
|
|
19530
|
-
Container$
|
|
19537
|
+
Container$W.rebuild(child);
|
|
19531
19538
|
});
|
|
19532
19539
|
}
|
|
19533
19540
|
};
|
|
19534
19541
|
|
|
19535
|
-
let Container$
|
|
19542
|
+
let Container$V = container;
|
|
19536
19543
|
|
|
19537
19544
|
let LazyResult$4, Processor$3;
|
|
19538
19545
|
|
|
19539
|
-
let Document$3 = class Document extends Container$
|
|
19546
|
+
let Document$3 = class Document extends Container$V {
|
|
19540
19547
|
constructor(defaults) {
|
|
19541
19548
|
// type needs to be passed to super, otherwise child roots won't be normalized correctly
|
|
19542
19549
|
super({ type: 'document', ...defaults });
|
|
@@ -19654,9 +19661,9 @@ let Result$4 = class Result {
|
|
|
19654
19661
|
var result = Result$4;
|
|
19655
19662
|
Result$4.default = Result$4;
|
|
19656
19663
|
|
|
19657
|
-
let Container$
|
|
19664
|
+
let Container$U = container;
|
|
19658
19665
|
|
|
19659
|
-
let AtRule$3 = class AtRule extends Container$
|
|
19666
|
+
let AtRule$3 = class AtRule extends Container$U {
|
|
19660
19667
|
constructor(defaults) {
|
|
19661
19668
|
super(defaults);
|
|
19662
19669
|
this.type = 'atrule';
|
|
@@ -19676,13 +19683,13 @@ let AtRule$3 = class AtRule extends Container$T {
|
|
|
19676
19683
|
var atRule = AtRule$3;
|
|
19677
19684
|
AtRule$3.default = AtRule$3;
|
|
19678
19685
|
|
|
19679
|
-
Container$
|
|
19686
|
+
Container$U.registerAtRule(AtRule$3);
|
|
19680
19687
|
|
|
19681
|
-
let Container$
|
|
19688
|
+
let Container$T = container;
|
|
19682
19689
|
|
|
19683
19690
|
let LazyResult$3, Processor$2;
|
|
19684
19691
|
|
|
19685
|
-
let Root$5 = class Root extends Container$
|
|
19692
|
+
let Root$5 = class Root extends Container$T {
|
|
19686
19693
|
constructor(defaults) {
|
|
19687
19694
|
super(defaults);
|
|
19688
19695
|
this.type = 'root';
|
|
@@ -19736,7 +19743,7 @@ Root$5.registerProcessor = dependant => {
|
|
|
19736
19743
|
var root = Root$5;
|
|
19737
19744
|
Root$5.default = Root$5;
|
|
19738
19745
|
|
|
19739
|
-
Container$
|
|
19746
|
+
Container$T.registerRoot(Root$5);
|
|
19740
19747
|
|
|
19741
19748
|
let list$2 = {
|
|
19742
19749
|
comma(string) {
|
|
@@ -19795,10 +19802,10 @@ let list$2 = {
|
|
|
19795
19802
|
var list_1 = list$2;
|
|
19796
19803
|
list$2.default = list$2;
|
|
19797
19804
|
|
|
19798
|
-
let Container$
|
|
19805
|
+
let Container$S = container;
|
|
19799
19806
|
let list$1 = list_1;
|
|
19800
19807
|
|
|
19801
|
-
let Rule$3 = class Rule extends Container$
|
|
19808
|
+
let Rule$3 = class Rule extends Container$S {
|
|
19802
19809
|
constructor(defaults) {
|
|
19803
19810
|
super(defaults);
|
|
19804
19811
|
this.type = 'rule';
|
|
@@ -19819,7 +19826,7 @@ let Rule$3 = class Rule extends Container$R {
|
|
|
19819
19826
|
var rule = Rule$3;
|
|
19820
19827
|
Rule$3.default = Rule$3;
|
|
19821
19828
|
|
|
19822
|
-
Container$
|
|
19829
|
+
Container$S.registerRule(Rule$3);
|
|
19823
19830
|
|
|
19824
19831
|
let Declaration$2 = declaration;
|
|
19825
19832
|
let tokenizer = tokenize;
|
|
@@ -20430,7 +20437,7 @@ let Parser$1 = class Parser {
|
|
|
20430
20437
|
|
|
20431
20438
|
var parser = Parser$1;
|
|
20432
20439
|
|
|
20433
|
-
let Container$
|
|
20440
|
+
let Container$R = container;
|
|
20434
20441
|
let Parser = parser;
|
|
20435
20442
|
let Input$3 = input;
|
|
20436
20443
|
|
|
@@ -20469,12 +20476,12 @@ function parse$3(css, opts) {
|
|
|
20469
20476
|
var parse_1 = parse$3;
|
|
20470
20477
|
parse$3.default = parse$3;
|
|
20471
20478
|
|
|
20472
|
-
Container$
|
|
20479
|
+
Container$R.registerParse(parse$3);
|
|
20473
20480
|
|
|
20474
20481
|
let { isClean, my } = symbols;
|
|
20475
20482
|
let MapGenerator$1 = mapGenerator;
|
|
20476
20483
|
let stringify$2 = stringify_1;
|
|
20477
|
-
let Container$
|
|
20484
|
+
let Container$Q = container;
|
|
20478
20485
|
let Document$2 = document$1;
|
|
20479
20486
|
let warnOnce$1 = warnOnce$2;
|
|
20480
20487
|
let Result$3 = result;
|
|
@@ -20609,7 +20616,7 @@ let LazyResult$2 = class LazyResult {
|
|
|
20609
20616
|
|
|
20610
20617
|
if (root && !root[my]) {
|
|
20611
20618
|
/* c8 ignore next 2 */
|
|
20612
|
-
Container$
|
|
20619
|
+
Container$Q.rebuild(root);
|
|
20613
20620
|
}
|
|
20614
20621
|
}
|
|
20615
20622
|
|
|
@@ -21276,7 +21283,7 @@ fromJSON$1.default = fromJSON$1;
|
|
|
21276
21283
|
let CssSyntaxError = cssSyntaxError;
|
|
21277
21284
|
let Declaration = declaration;
|
|
21278
21285
|
let LazyResult = lazyResult;
|
|
21279
|
-
let Container$
|
|
21286
|
+
let Container$P = container;
|
|
21280
21287
|
let Processor = processor;
|
|
21281
21288
|
let stringify = stringify_1;
|
|
21282
21289
|
let fromJSON = fromJSON_1;
|
|
@@ -21356,7 +21363,7 @@ postcss.document = defaults => new Document(defaults);
|
|
|
21356
21363
|
|
|
21357
21364
|
postcss.CssSyntaxError = CssSyntaxError;
|
|
21358
21365
|
postcss.Declaration = Declaration;
|
|
21359
|
-
postcss.Container = Container$
|
|
21366
|
+
postcss.Container = Container$P;
|
|
21360
21367
|
postcss.Processor = Processor;
|
|
21361
21368
|
postcss.Document = Document;
|
|
21362
21369
|
postcss.Comment = Comment;
|
|
@@ -21375,7 +21382,7 @@ postcss.default = postcss;
|
|
|
21375
21382
|
|
|
21376
21383
|
const htmlparser = lib$7;
|
|
21377
21384
|
const escapeStringRegexp = escapeStringRegexp$1;
|
|
21378
|
-
const { isPlainObject } = isPlainObject$
|
|
21385
|
+
const { isPlainObject: isPlainObject$1 } = isPlainObject$3;
|
|
21379
21386
|
const deepmerge = cjs;
|
|
21380
21387
|
const parseSrcset = parseSrcsetExports;
|
|
21381
21388
|
const { parse: postcssParse } = postcss_1;
|
|
@@ -21411,7 +21418,7 @@ function filter(a, cb) {
|
|
|
21411
21418
|
return n;
|
|
21412
21419
|
}
|
|
21413
21420
|
|
|
21414
|
-
function isEmptyObject(obj) {
|
|
21421
|
+
function isEmptyObject$1(obj) {
|
|
21415
21422
|
for (const key in obj) {
|
|
21416
21423
|
if (has(obj, key)) {
|
|
21417
21424
|
return false;
|
|
@@ -21634,7 +21641,7 @@ function sanitizeHtml(html, options, _recursing) {
|
|
|
21634
21641
|
}
|
|
21635
21642
|
}
|
|
21636
21643
|
|
|
21637
|
-
if (!tagAllowed(name) || (options.disallowedTagsMode === 'recursiveEscape' && !isEmptyObject(skipMap)) || (options.nestingLimit != null && depth >= options.nestingLimit)) {
|
|
21644
|
+
if (!tagAllowed(name) || (options.disallowedTagsMode === 'recursiveEscape' && !isEmptyObject$1(skipMap)) || (options.nestingLimit != null && depth >= options.nestingLimit)) {
|
|
21638
21645
|
skip = true;
|
|
21639
21646
|
skipMap[depth] = true;
|
|
21640
21647
|
if (options.disallowedTagsMode === 'discard') {
|
|
@@ -21687,7 +21694,7 @@ function sanitizeHtml(html, options, _recursing) {
|
|
|
21687
21694
|
passedAllowedAttributesMapCheck = true;
|
|
21688
21695
|
} else if (allowedAttributesMap && allowedAttributesMap[name]) {
|
|
21689
21696
|
for (const o of allowedAttributesMap[name]) {
|
|
21690
|
-
if (isPlainObject(o) && o.name && (o.name === a)) {
|
|
21697
|
+
if (isPlainObject$1(o) && o.name && (o.name === a)) {
|
|
21691
21698
|
passedAllowedAttributesMapCheck = true;
|
|
21692
21699
|
let newValue = '';
|
|
21693
21700
|
if (o.multiple === true) {
|
|
@@ -22291,12 +22298,12 @@ var sanitizeHtml$1 = /*@__PURE__*/getDefaultExportFromCjs(sanitizeHtml_1);
|
|
|
22291
22298
|
var Card = function (_a) {
|
|
22292
22299
|
var header = _a.header, content = _a.content, footerLink = _a.footerLink, imageLarge = _a.imageLarge, imageSmall = _a.imageSmall, imageAltText = _a.imageAltText;
|
|
22293
22300
|
var showContent = content || header;
|
|
22294
|
-
return (React__default.default.createElement(Container$
|
|
22301
|
+
return (React__default.default.createElement(Container$X, { "data-testid": "Card" },
|
|
22295
22302
|
imageLarge && imageSmall && (React__default.default.createElement(React__default.default.Fragment, null, footerLink ? (React__default.default.createElement(ImageLink$1, { href: footerLink.url },
|
|
22296
22303
|
React__default.default.createElement(Image$4, { src: imageLarge, alt: imageAltText, srcSet: "".concat(imageSmall, " 400w, ").concat(imageLarge, " 800w"), sizes: "(max-width: 550px) 400px, 800px", loading: "lazy" }))) : (React__default.default.createElement(Image$4, { src: imageLarge, alt: imageAltText, srcSet: "".concat(imageSmall, " 400w, ").concat(imageLarge, " 800w"), sizes: "(max-width: 550px) 400px, 800px", loading: "lazy" })))),
|
|
22297
|
-
showContent && (React__default.default.createElement(Content$
|
|
22304
|
+
showContent && (React__default.default.createElement(Content$7, null,
|
|
22298
22305
|
header && (React__default.default.createElement(Header$1, null,
|
|
22299
|
-
React__default.default.createElement(Heading, { text: header, level: 3 }))),
|
|
22306
|
+
React__default.default.createElement(Heading$1, { text: header, level: 3 }))),
|
|
22300
22307
|
React__default.default.createElement("div", { dangerouslySetInnerHTML: { __html: sanitizeHtml$1(content) } }))),
|
|
22301
22308
|
footerLink && (React__default.default.createElement(Footer$1, null,
|
|
22302
22309
|
React__default.default.createElement(FooterLink$1, { href: footerLink.url }, footerLink.title)))));
|
|
@@ -22307,12 +22314,12 @@ var Card = function (_a) {
|
|
|
22307
22314
|
*/
|
|
22308
22315
|
var Cards = function (_a) {
|
|
22309
22316
|
var cards = _a.cards;
|
|
22310
|
-
return (React__default.default.createElement(Container$
|
|
22317
|
+
return (React__default.default.createElement(Container$Y, { "data-testid": "Cards" },
|
|
22311
22318
|
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 },
|
|
22312
22319
|
React__default.default.createElement(Card, __assign$2({}, card)))); }))));
|
|
22313
22320
|
};
|
|
22314
22321
|
|
|
22315
|
-
const Container$
|
|
22322
|
+
const Container$O = styled__default.default.div`
|
|
22316
22323
|
margin: 25px 0;
|
|
22317
22324
|
`;
|
|
22318
22325
|
|
|
@@ -22430,7 +22437,7 @@ var FileDownload = function (_a) {
|
|
|
22430
22437
|
|
|
22431
22438
|
var DownloadableFiles = function (_a) {
|
|
22432
22439
|
var files = _a.files;
|
|
22433
|
-
return (React__default.default.createElement(Container$
|
|
22440
|
+
return (React__default.default.createElement(Container$O, { "data-testid": "DownloadableFiles" }, files.length > 0 ?
|
|
22434
22441
|
files.map(function (file) { return React__default.default.createElement(FileDownload, __assign$2({ key: file.title }, file)); })
|
|
22435
22442
|
:
|
|
22436
22443
|
React__default.default.createElement("i", null, "No file to show")));
|
|
@@ -22531,7 +22538,7 @@ const AccessibleMapLink = styled__default.default(MapLink$1)`
|
|
|
22531
22538
|
${(props) => props.theme.visuallyHidden};
|
|
22532
22539
|
`;
|
|
22533
22540
|
|
|
22534
|
-
const Container$
|
|
22541
|
+
const Container$N = styled__default.default.div`
|
|
22535
22542
|
border: solid 4px;
|
|
22536
22543
|
border-radius: ${(props) => props.theme.theme_vars.border_radius};
|
|
22537
22544
|
border-color: ${(props) =>
|
|
@@ -22585,9 +22592,9 @@ const InnerContainer$2 = styled__default.default.div`
|
|
|
22585
22592
|
*/
|
|
22586
22593
|
var AlertBannerService = function (_a) {
|
|
22587
22594
|
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;
|
|
22588
|
-
return (React__default.default.createElement(Container$
|
|
22595
|
+
return (React__default.default.createElement(Container$N, { "$alertType": alertType, "data-testid": "AlertBannerService", "$hasTopSpacing": hasTopSpacing },
|
|
22589
22596
|
React__default.default.createElement(InnerContainer$2, { "data-testid": "AlertBannerServiceInner" },
|
|
22590
|
-
(title === null || title === void 0 ? void 0 : title.trim()) && React__default.default.createElement(Heading, { text: title }),
|
|
22597
|
+
(title === null || title === void 0 ? void 0 : title.trim()) && React__default.default.createElement(Heading$1, { text: title }),
|
|
22591
22598
|
children)));
|
|
22592
22599
|
};
|
|
22593
22600
|
|
|
@@ -22615,7 +22622,7 @@ var GoogleMap = function (_a) {
|
|
|
22615
22622
|
}, []);
|
|
22616
22623
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
22617
22624
|
React__default.default.createElement(ProtectiveContainer, null,
|
|
22618
|
-
title && React__default.default.createElement(Heading, { level: 3, text: title }),
|
|
22625
|
+
title && React__default.default.createElement(Heading$1, { level: 3, text: title }),
|
|
22619
22626
|
description && (React__default.default.createElement(MapDescription, { dangerouslySetInnerHTML: {
|
|
22620
22627
|
__html: sanitizeHtml$1(description),
|
|
22621
22628
|
} })),
|
|
@@ -22638,7 +22645,7 @@ var GoogleMap = function (_a) {
|
|
|
22638
22645
|
React__default.default.createElement(MapLink$1, { href: link_url }, link_title ? link_title : 'Google Maps link')))));
|
|
22639
22646
|
};
|
|
22640
22647
|
|
|
22641
|
-
const Container$
|
|
22648
|
+
const Container$M = styled__default.default.figure`
|
|
22642
22649
|
display: block;
|
|
22643
22650
|
background: ${(props) =>
|
|
22644
22651
|
props.theme.cardinal_name === 'north'
|
|
@@ -23303,7 +23310,7 @@ var LazyImage = /*@__PURE__*/getDefaultExportFromCjs(lib$1);
|
|
|
23303
23310
|
*/
|
|
23304
23311
|
var Image$2 = function (_a) {
|
|
23305
23312
|
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;
|
|
23306
|
-
return (React__default.default.createElement(Container$
|
|
23313
|
+
return (React__default.default.createElement(Container$M, { "data-testid": "Image", "$wrapText": wrapText },
|
|
23307
23314
|
React__default.default.createElement(ImageContainer$4, { "data-testid": "ImageContainer", "$ratio": ratio },
|
|
23308
23315
|
React__default.default.createElement(LazyImage, { placeholder: imageSmall, src: imageLarge, visibilitySensorProps: {
|
|
23309
23316
|
partialVisibility: true,
|
|
@@ -23311,7 +23318,7 @@ var Image$2 = function (_a) {
|
|
|
23311
23318
|
(caption === null || caption === void 0 ? void 0 : caption.trim()) && React__default.default.createElement(Caption, null, caption)));
|
|
23312
23319
|
};
|
|
23313
23320
|
|
|
23314
|
-
const Container$
|
|
23321
|
+
const Container$L = styled__default.default.div`
|
|
23315
23322
|
display: block;
|
|
23316
23323
|
`;
|
|
23317
23324
|
|
|
@@ -23321,7 +23328,7 @@ const HeadingContainer = styled__default.default.div`
|
|
|
23321
23328
|
}
|
|
23322
23329
|
`;
|
|
23323
23330
|
|
|
23324
|
-
const Content$
|
|
23331
|
+
const Content$6 = styled__default.default.div`
|
|
23325
23332
|
@media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.m}) {
|
|
23326
23333
|
margin: ${(props) => props.theme.theme_vars.spacingSizes.medium} 0;
|
|
23327
23334
|
}
|
|
@@ -23332,20 +23339,20 @@ const Content$5 = styled__default.default.div`
|
|
|
23332
23339
|
*/
|
|
23333
23340
|
var ImageAndText = function (_a) {
|
|
23334
23341
|
var heading = _a.heading, textContent = _a.textContent, image = _a.image;
|
|
23335
|
-
return (React__default.default.createElement(Container$
|
|
23342
|
+
return (React__default.default.createElement(Container$L, { "data-testid": "ImageAndText" },
|
|
23336
23343
|
React__default.default.createElement(Row$1, null,
|
|
23337
23344
|
heading && (React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
23338
23345
|
React__default.default.createElement(HeadingContainer, null,
|
|
23339
|
-
React__default.default.createElement(Heading, { text: heading, level: 3 })))),
|
|
23346
|
+
React__default.default.createElement(Heading$1, { text: heading, level: 3 })))),
|
|
23340
23347
|
image ? (React__default.default.createElement(React__default.default.Fragment, null,
|
|
23341
23348
|
React__default.default.createElement(Column, { small: "full", medium: "one-third", large: "one-third" },
|
|
23342
23349
|
React__default.default.createElement(Image$2, __assign$2({}, image))),
|
|
23343
23350
|
React__default.default.createElement(Column, { small: "full", medium: "two-thirds", large: "two-thirds" },
|
|
23344
|
-
React__default.default.createElement(Content$
|
|
23345
|
-
React__default.default.createElement(Content$
|
|
23351
|
+
React__default.default.createElement(Content$6, { dangerouslySetInnerHTML: { __html: sanitizeHtml$1(textContent) } })))) : (React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
23352
|
+
React__default.default.createElement(Content$6, { dangerouslySetInnerHTML: { __html: sanitizeHtml$1(textContent) } }))))));
|
|
23346
23353
|
};
|
|
23347
23354
|
|
|
23348
|
-
const Container$
|
|
23355
|
+
const Container$K = styled__default.default.div`
|
|
23349
23356
|
display: block;
|
|
23350
23357
|
`;
|
|
23351
23358
|
|
|
@@ -23354,7 +23361,7 @@ const Container$J = styled__default.default.div`
|
|
|
23354
23361
|
*/
|
|
23355
23362
|
var InquestSchedule = function (_a) {
|
|
23356
23363
|
var caseAppointments = _a.caseAppointments, title = _a.title, _b = _a.error, error = _b === void 0 ? false : _b;
|
|
23357
|
-
return (React__default.default.createElement(Container$
|
|
23364
|
+
return (React__default.default.createElement(Container$K, { "data-testid": "InquestSchedule" },
|
|
23358
23365
|
React__default.default.createElement("div", { className: "table-container" },
|
|
23359
23366
|
React__default.default.createElement("table", null,
|
|
23360
23367
|
React__default.default.createElement("caption", null, title),
|
|
@@ -23382,7 +23389,7 @@ var InquestSchedule = function (_a) {
|
|
|
23382
23389
|
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."))))))))));
|
|
23383
23390
|
};
|
|
23384
23391
|
|
|
23385
|
-
const Container$
|
|
23392
|
+
const Container$J = styled__default.default.div`
|
|
23386
23393
|
${(props) => props.theme.fontStyles};
|
|
23387
23394
|
overflow: hidden;
|
|
23388
23395
|
margin: 40px auto 5px auto;
|
|
@@ -23437,7 +23444,7 @@ const Wrapper$4 = styled__default.default.div`
|
|
|
23437
23444
|
}
|
|
23438
23445
|
`;
|
|
23439
23446
|
|
|
23440
|
-
const Content$
|
|
23447
|
+
const Content$5 = styled__default.default.div``;
|
|
23441
23448
|
|
|
23442
23449
|
const CTA = styled__default.default.a`
|
|
23443
23450
|
margin-top: 10px;
|
|
@@ -23462,13 +23469,13 @@ const CTA = styled__default.default.a`
|
|
|
23462
23469
|
*/
|
|
23463
23470
|
var PromoBanner = function (_a) {
|
|
23464
23471
|
var title = _a.title, image1440x810 = _a.image1440x810, image144x81 = _a.image144x81, ctaText = _a.ctaText, ctaUrl = _a.ctaUrl, children = _a.children;
|
|
23465
|
-
return (React__default.default.createElement(Container$
|
|
23472
|
+
return (React__default.default.createElement(Container$J, null,
|
|
23466
23473
|
React__default.default.createElement(LazyImage, { src: image1440x810, placeholder: image144x81, visibilitySensorProps: {
|
|
23467
23474
|
partialVisibility: true,
|
|
23468
23475
|
} }, function (src) { return React__default.default.createElement(ImageLink, { "$img": src, href: ctaUrl, title: ctaText }); }),
|
|
23469
23476
|
React__default.default.createElement(Wrapper$4, null,
|
|
23470
|
-
React__default.default.createElement(Heading, { text: title }),
|
|
23471
|
-
React__default.default.createElement(Content$
|
|
23477
|
+
React__default.default.createElement(Heading$1, { text: title }),
|
|
23478
|
+
React__default.default.createElement(Content$5, null, children),
|
|
23472
23479
|
React__default.default.createElement(CTA, { href: ctaUrl }, ctaText))));
|
|
23473
23480
|
};
|
|
23474
23481
|
|
|
@@ -23581,7 +23588,7 @@ const PromoText = styled__default.default.div`
|
|
|
23581
23588
|
/**
|
|
23582
23589
|
* The headline of the tile
|
|
23583
23590
|
*/
|
|
23584
|
-
const PromoHeadline = styled__default.default(Heading)`
|
|
23591
|
+
const PromoHeadline = styled__default.default(Heading$1)`
|
|
23585
23592
|
margin-top: 5px;
|
|
23586
23593
|
`;
|
|
23587
23594
|
|
|
@@ -23673,7 +23680,7 @@ var Promotions = function (_a) {
|
|
|
23673
23680
|
numberOfPromos > 1 && React__default.default.createElement(PromoBlock, { promos: promos.slice(1, numberOfPromos) })));
|
|
23674
23681
|
};
|
|
23675
23682
|
|
|
23676
|
-
const Container$
|
|
23683
|
+
const Container$I = styled__default.default.div`
|
|
23677
23684
|
padding: 0;
|
|
23678
23685
|
margin: ${(props) => props.theme.theme_vars.spacingSizes.medium} 0;
|
|
23679
23686
|
${(props) => props.theme.fontStyles}
|
|
@@ -23723,7 +23730,7 @@ const Inner = styled__default.default.div`
|
|
|
23723
23730
|
}
|
|
23724
23731
|
`;
|
|
23725
23732
|
|
|
23726
|
-
const Container$
|
|
23733
|
+
const Container$H = styled__default.default.div`
|
|
23727
23734
|
display: block;
|
|
23728
23735
|
|
|
23729
23736
|
input[type='text'] {
|
|
@@ -23734,7 +23741,7 @@ const Container$G = styled__default.default.div`
|
|
|
23734
23741
|
}
|
|
23735
23742
|
`;
|
|
23736
23743
|
|
|
23737
|
-
const Label$
|
|
23744
|
+
const Label$4 = styled__default.default.label`
|
|
23738
23745
|
font-weight: bold;
|
|
23739
23746
|
font-family: ${(props) => props.theme.theme_vars.fontstack};
|
|
23740
23747
|
${(props) =>
|
|
@@ -23796,10 +23803,10 @@ const SubmitButton = styled__default.default.input`
|
|
|
23796
23803
|
* If value is set then treat as controlled component
|
|
23797
23804
|
*/
|
|
23798
23805
|
var Input = function (_a) {
|
|
23799
|
-
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;
|
|
23806
|
+
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;
|
|
23800
23807
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
23801
|
-
errorText && React__default.default.createElement(ErrorText$
|
|
23802
|
-
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 }))));
|
|
23808
|
+
errorText && React__default.default.createElement(ErrorText$2, null, errorText),
|
|
23809
|
+
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 }))));
|
|
23803
23810
|
};
|
|
23804
23811
|
|
|
23805
23812
|
var CustomSearch = function (_a) {
|
|
@@ -23807,10 +23814,10 @@ var CustomSearch = function (_a) {
|
|
|
23807
23814
|
if (!id) {
|
|
23808
23815
|
id = React.useId();
|
|
23809
23816
|
}
|
|
23810
|
-
return (React__default.default.createElement(Container$
|
|
23817
|
+
return (React__default.default.createElement(Container$H, { "data-testid": "CustomSearch" },
|
|
23811
23818
|
React__default.default.createElement("form", { method: method, action: path, "aria-label": label },
|
|
23812
23819
|
React__default.default.createElement("div", { role: "search" },
|
|
23813
|
-
React__default.default.createElement(Label$
|
|
23820
|
+
React__default.default.createElement(Label$4, { htmlFor: id, "$hasHiddenLabel": hasHiddenLabel }, label),
|
|
23814
23821
|
React__default.default.createElement(InputWrapper$1, null,
|
|
23815
23822
|
React__default.default.createElement(Input, { name: fieldName, placeholder: placeholder, id: id }),
|
|
23816
23823
|
React__default.default.createElement(SubmitButton, { type: "submit", value: searchText }))))));
|
|
@@ -23821,7 +23828,7 @@ var SearchBox = function (_a) {
|
|
|
23821
23828
|
var searchInner = (React__default.default.createElement(Inner, null,
|
|
23822
23829
|
React__default.default.createElement(Row$1, null,
|
|
23823
23830
|
title && (React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
23824
|
-
React__default.default.createElement(Heading, { text: title, level: 2 }))),
|
|
23831
|
+
React__default.default.createElement(Heading$1, { text: title, level: 2 }))),
|
|
23825
23832
|
React__default.default.createElement(Column, { small: "full", medium: "full", large: searchBoxLink ? 'two-thirds' : 'full' },
|
|
23826
23833
|
React__default.default.createElement(CustomSearch, __assign$2({}, customSearch))),
|
|
23827
23834
|
searchBoxLink && (React__default.default.createElement(Column, { small: "full", medium: "full", large: "one-third" },
|
|
@@ -23830,8 +23837,8 @@ var SearchBox = function (_a) {
|
|
|
23830
23837
|
return (React__default.default.createElement(React__default.default.Fragment, null, imageLarge && imageSmall ? (React__default.default.createElement(React__default.default.Fragment, null,
|
|
23831
23838
|
React__default.default.createElement(LazyImage, { src: imageLarge, placeholder: imageSmall, visibilitySensorProps: {
|
|
23832
23839
|
partialVisibility: true,
|
|
23833
|
-
} }, function (src) { return (React__default.default.createElement(Container$
|
|
23834
|
-
imageAltText && React__default.default.createElement("span", { role: "img", "aria-label": imageAltText }))) : (React__default.default.createElement(Container$
|
|
23840
|
+
} }, function (src) { return (React__default.default.createElement(Container$I, { "$image": src, "data-testid": "SearchBox" }, searchInner)); }),
|
|
23841
|
+
imageAltText && React__default.default.createElement("span", { role: "img", "aria-label": imageAltText }))) : (React__default.default.createElement(Container$I, { "data-testid": "SearchBox" }, searchInner))));
|
|
23835
23842
|
};
|
|
23836
23843
|
|
|
23837
23844
|
var VideoProvider;
|
|
@@ -23940,7 +23947,7 @@ const Title$6 = styled__default.default.div`
|
|
|
23940
23947
|
max-width: 960px;
|
|
23941
23948
|
}
|
|
23942
23949
|
`;
|
|
23943
|
-
const Content$
|
|
23950
|
+
const Content$4 = styled__default.default.div``;
|
|
23944
23951
|
|
|
23945
23952
|
/**
|
|
23946
23953
|
* Display text as a highlight or warning with a title
|
|
@@ -23949,7 +23956,7 @@ var WarningText = function (_a) {
|
|
|
23949
23956
|
var title = _a.title, _b = _a.isWarning, isWarning = _b === void 0 ? false : _b, children = _a.children;
|
|
23950
23957
|
return (React__default.default.createElement(WarningText$1, { "$isWarning": isWarning, "data-testid": "WarningText" },
|
|
23951
23958
|
React__default.default.createElement(Title$6, { "$isWarning": isWarning }, title),
|
|
23952
|
-
React__default.default.createElement(Content$
|
|
23959
|
+
React__default.default.createElement(Content$4, null, children)));
|
|
23953
23960
|
};
|
|
23954
23961
|
|
|
23955
23962
|
var WarningTextDisclaimer = function () {
|
|
@@ -24023,7 +24030,7 @@ var AccessibleLink = function (_a) {
|
|
|
24023
24030
|
})));
|
|
24024
24031
|
};
|
|
24025
24032
|
|
|
24026
|
-
const Container$
|
|
24033
|
+
const Container$G = styled__default.default.div`
|
|
24027
24034
|
padding: ${(props) => props.theme.theme_vars.spacingSizes.medium} 0;
|
|
24028
24035
|
background: ${(props) =>
|
|
24029
24036
|
props.$alertType === 'alert'
|
|
@@ -24154,7 +24161,7 @@ const handleContainerPadding = (noBackground, noPadding) => {
|
|
|
24154
24161
|
}
|
|
24155
24162
|
};
|
|
24156
24163
|
|
|
24157
|
-
const Container$
|
|
24164
|
+
const Container$F = styled__default.default.div`
|
|
24158
24165
|
background: ${(props) =>
|
|
24159
24166
|
props.$noBackground
|
|
24160
24167
|
? 'transparent'
|
|
@@ -24196,7 +24203,7 @@ const MaxWidth = styled__default.default.div`
|
|
|
24196
24203
|
*/
|
|
24197
24204
|
var MaxWidthContainer = function (_a) {
|
|
24198
24205
|
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"]);
|
|
24199
|
-
return (React__default.default.createElement(Container$
|
|
24206
|
+
return (React__default.default.createElement(Container$F, { "$noBackground": noBackground, "$noPadding": noPadding },
|
|
24200
24207
|
React__default.default.createElement(MaxWidth, __assign$2({ className: classes, "$overflowVisible": overflowVisible }, props), children)));
|
|
24201
24208
|
};
|
|
24202
24209
|
|
|
@@ -24267,7 +24274,7 @@ var AlertBanner = function (_a) {
|
|
|
24267
24274
|
setShowAlert(false);
|
|
24268
24275
|
};
|
|
24269
24276
|
return (showAlert &&
|
|
24270
|
-
notServer && (React__default.default.createElement(Container$
|
|
24277
|
+
notServer && (React__default.default.createElement(Container$G, { "$alertType": alertType, "data-testid": "AlertBanner" },
|
|
24271
24278
|
React__default.default.createElement(MaxWidthContainer, { noBackground: true },
|
|
24272
24279
|
React__default.default.createElement(InnerContainer$1, null,
|
|
24273
24280
|
React__default.default.createElement(BannerContentContainer, null,
|
|
@@ -24281,7 +24288,7 @@ var AlertBanner = function (_a) {
|
|
|
24281
24288
|
"Dismiss"))))));
|
|
24282
24289
|
};
|
|
24283
24290
|
|
|
24284
|
-
const Container$
|
|
24291
|
+
const Container$E = styled__default.default.a`
|
|
24285
24292
|
display: inline-block;
|
|
24286
24293
|
position: relative;
|
|
24287
24294
|
margin-top: 15px;
|
|
@@ -24340,10 +24347,10 @@ const Container$D = styled__default.default.a`
|
|
|
24340
24347
|
*/
|
|
24341
24348
|
var BackLink = function (_a) {
|
|
24342
24349
|
var link = _a.link, _b = _a.useHistory, useHistory = _b === void 0 ? false : _b;
|
|
24343
|
-
return (React__default.default.createElement(React__default.default.Fragment, null, useHistory ? (React__default.default.createElement(Container$
|
|
24350
|
+
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"))));
|
|
24344
24351
|
};
|
|
24345
24352
|
|
|
24346
|
-
const Container$
|
|
24353
|
+
const Container$D = styled__default.default.div`
|
|
24347
24354
|
padding-top: 20px;
|
|
24348
24355
|
border-bottom: 1px solid ${(props) => props.theme.theme_vars.colours.grey}80;
|
|
24349
24356
|
margin-bottom: ${(props) => (props.$hasMargin ? props.theme.theme_vars.spacingSizes.large : 0)};
|
|
@@ -24410,14 +24417,14 @@ const BreadcrumbLink$1 = styled__default.default.a`
|
|
|
24410
24417
|
|
|
24411
24418
|
var Breadcrumbs = function (_a) {
|
|
24412
24419
|
var breadcrumbsArray = _a.breadcrumbsArray, _b = _a.hasMargin, hasMargin = _b === void 0 ? false : _b;
|
|
24413
|
-
return (React__default.default.createElement(Container$
|
|
24420
|
+
return (React__default.default.createElement(Container$D, { "$hasMargin": hasMargin, "data-testid": "Breadcrumbs" },
|
|
24414
24421
|
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,
|
|
24415
24422
|
React__default.default.createElement(BreadcrumbLink$1, { href: crumb.url, title: crumb.title }, crumb.title),
|
|
24416
24423
|
React__default.default.createElement(IconWrapper$4, null,
|
|
24417
24424
|
React__default.default.createElement(ChevronIcon, { direction: 'right', colourFill: "#C6C6C6" }))))); }))));
|
|
24418
24425
|
};
|
|
24419
24426
|
|
|
24420
|
-
const Container$
|
|
24427
|
+
const Container$C = styled__default.default.div`
|
|
24421
24428
|
display: block;
|
|
24422
24429
|
margin-bottom: ${(props) => props.theme.theme_vars.spacingSizes.large};
|
|
24423
24430
|
padding-bottom: ${(props) => props.theme.theme_vars.spacingSizes.large};
|
|
@@ -24465,12 +24472,12 @@ const CurrentPage = styled__default.default.span`
|
|
|
24465
24472
|
|
|
24466
24473
|
var Contents$1 = function (_a) {
|
|
24467
24474
|
var contents = _a.contents, _b = _a.currentPath, currentPath = _b === void 0 ? undefined : _b, _c = _a.title, title = _c === void 0 ? 'Contents' : _c;
|
|
24468
|
-
return (React__default.default.createElement(Container$
|
|
24469
|
-
React__default.default.createElement(Heading, { text: title, level: 2 }),
|
|
24475
|
+
return (React__default.default.createElement(Container$C, { "data-testid": "Contents" },
|
|
24476
|
+
React__default.default.createElement(Heading$1, { text: title, level: 2 }),
|
|
24470
24477
|
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)))); }))));
|
|
24471
24478
|
};
|
|
24472
24479
|
|
|
24473
|
-
const Container$
|
|
24480
|
+
const Container$B = styled__default.default.div`
|
|
24474
24481
|
display: block;
|
|
24475
24482
|
border-top: 1px solid ${(props) => props.theme.theme_vars.colours.grey}80;
|
|
24476
24483
|
margin: ${(props) => props.theme.theme_vars.spacingSizes.medium} 0;
|
|
@@ -24520,7 +24527,7 @@ var ContentsNavigation = function (_a) {
|
|
|
24520
24527
|
};
|
|
24521
24528
|
var nextPage = currentPage() < contents.length - 1 ? contents[currentPage() + 1] : undefined;
|
|
24522
24529
|
var previousPage = currentPage() !== 0 ? contents[currentPage() - 1] : undefined;
|
|
24523
|
-
return (React__default.default.createElement(Container$
|
|
24530
|
+
return (React__default.default.createElement(Container$B, { "data-testid": "ContentsNavigation" },
|
|
24524
24531
|
previousPage && (React__default.default.createElement(NavigationLink, { href: previousPage.url },
|
|
24525
24532
|
React__default.default.createElement(Arrow, null, "\u2190"),
|
|
24526
24533
|
React__default.default.createElement(LinkText, null,
|
|
@@ -24577,7 +24584,7 @@ var DisplayDate = function (_a) {
|
|
|
24577
24584
|
postText));
|
|
24578
24585
|
};
|
|
24579
24586
|
|
|
24580
|
-
const Container$
|
|
24587
|
+
const Container$A = styled__default.default.footer`
|
|
24581
24588
|
background-color: ${(props) => props.theme.theme_vars.colours.black};
|
|
24582
24589
|
padding: 25px 0;
|
|
24583
24590
|
`;
|
|
@@ -24752,7 +24759,7 @@ var ServiceIcon = function (_a) {
|
|
|
24752
24759
|
var Footer = function (_a) {
|
|
24753
24760
|
var _b = _a.footerLinksArray, footerLinksArray = _b === void 0 ? null : _b, _c = _a.year, year = _c === void 0 ? new Date().getFullYear() : _c;
|
|
24754
24761
|
var themeContext = React.useContext(styled.ThemeContext);
|
|
24755
|
-
return (React__default.default.createElement(Container$
|
|
24762
|
+
return (React__default.default.createElement(Container$A, { "data-testid": "Footer" },
|
|
24756
24763
|
React__default.default.createElement(StyledMaxWidthContainer$3, { noBackground: true },
|
|
24757
24764
|
React__default.default.createElement(FooterAlignment, null,
|
|
24758
24765
|
React__default.default.createElement("div", null,
|
|
@@ -24785,7 +24792,7 @@ var Footer = function (_a) {
|
|
|
24785
24792
|
: '' }, 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)))))));
|
|
24786
24793
|
};
|
|
24787
24794
|
|
|
24788
|
-
const Container$
|
|
24795
|
+
const Container$z = styled__default.default.div`
|
|
24789
24796
|
background: ${(props) => (props.$hasBackground ? props.theme.theme_vars.colours.grey_light : 'transparent')};
|
|
24790
24797
|
padding: ${(props) => (props.$hasPadding ? '50px 0 20px' : '0')};
|
|
24791
24798
|
`;
|
|
@@ -24795,7 +24802,7 @@ const Container$y = styled__default.default.div`
|
|
|
24795
24802
|
*/
|
|
24796
24803
|
var FullWidthContainer = function (_a) {
|
|
24797
24804
|
var children = _a.children, _b = _a.hasBackground, hasBackground = _b === void 0 ? false : _b, _c = _a.hasPadding, hasPadding = _c === void 0 ? false : _c;
|
|
24798
|
-
return (React__default.default.createElement(Container$
|
|
24805
|
+
return (React__default.default.createElement(Container$z, { "$hasBackground": hasBackground, "$hasPadding": hasPadding, "data-testid": "FullWidthContainer" }, children));
|
|
24799
24806
|
};
|
|
24800
24807
|
|
|
24801
24808
|
/**
|
|
@@ -24827,7 +24834,7 @@ const headerThemeStyles = (props) => {
|
|
|
24827
24834
|
}
|
|
24828
24835
|
};
|
|
24829
24836
|
|
|
24830
|
-
const Container$
|
|
24837
|
+
const Container$y = styled__default.default.header`
|
|
24831
24838
|
font-family: ${(props) => props.theme.theme_vars.fontstack};
|
|
24832
24839
|
padding: 3px 0;
|
|
24833
24840
|
${headerThemeStyles}
|
|
@@ -24992,7 +24999,7 @@ var NorthColouredLogo = function () {
|
|
|
24992
24999
|
React__default.default.createElement("path", { fill: "#fff", d: "M0 0H974V327H0z" })))));
|
|
24993
25000
|
};
|
|
24994
25001
|
|
|
24995
|
-
const Container$
|
|
25002
|
+
const Container$x = styled__default.default.div`
|
|
24996
25003
|
${(props) => props.theme.fontStyles}
|
|
24997
25004
|
width: calc(100% - ${(props) => (props.$isLarge ? '5rem' : '3rem')});
|
|
24998
25005
|
`;
|
|
@@ -25141,7 +25148,7 @@ var Searchbar = function (_a) {
|
|
|
25141
25148
|
/**
|
|
25142
25149
|
* Render the component
|
|
25143
25150
|
*/
|
|
25144
|
-
return (React__default.default.createElement(Container$
|
|
25151
|
+
return (React__default.default.createElement(Container$x, { "data-testid": "Searchbar", "$isLarge": isLarge },
|
|
25145
25152
|
React__default.default.createElement("form", { onSubmit: handleSubmit },
|
|
25146
25153
|
React__default.default.createElement("div", { role: "search" },
|
|
25147
25154
|
React__default.default.createElement(InputWrapper, null,
|
|
@@ -25196,7 +25203,7 @@ var Header = function (_a) {
|
|
|
25196
25203
|
}
|
|
25197
25204
|
};
|
|
25198
25205
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
25199
|
-
React__default.default.createElement(Container$
|
|
25206
|
+
React__default.default.createElement(Container$y, __assign$2({}, props, { "data-testid": "Header" }),
|
|
25200
25207
|
React__default.default.createElement(StyledMaxWidthContainer$2, { noBackground: true },
|
|
25201
25208
|
React__default.default.createElement(LogoWrapper, null,
|
|
25202
25209
|
React__default.default.createElement(HomeLink, { href: homeLink, title: "Home", id: "logo" }, themeLogos(themeContext.cardinal_name, themeContext.is_memorial))),
|
|
@@ -25216,7 +25223,7 @@ var Header = function (_a) {
|
|
|
25216
25223
|
* Hero image container with optional dark gradient for non-box mode
|
|
25217
25224
|
* Optimised for an image in 16:5 ratio on all but small width screens
|
|
25218
25225
|
*/
|
|
25219
|
-
const Container$
|
|
25226
|
+
const Container$w = styled__default.default.div`
|
|
25220
25227
|
background-image: ${(props) =>
|
|
25221
25228
|
!props.$backgroundBox ? `linear-gradient(to bottom left, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75)),` : ``}
|
|
25222
25229
|
url('${(props) => props.$image}');
|
|
@@ -25297,7 +25304,7 @@ const Overlay = styled__default.default.div`
|
|
|
25297
25304
|
}
|
|
25298
25305
|
`;
|
|
25299
25306
|
|
|
25300
|
-
const Headline = styled__default.default(Heading)`
|
|
25307
|
+
const Headline = styled__default.default(Heading$1)`
|
|
25301
25308
|
margin: 0;
|
|
25302
25309
|
color: ${(props) =>
|
|
25303
25310
|
props.$backgroundBox ? props.theme.theme_vars.colours.black : props.theme.theme_vars.colours.white};
|
|
@@ -25316,7 +25323,7 @@ const Headline = styled__default.default(Heading)`
|
|
|
25316
25323
|
}
|
|
25317
25324
|
`;
|
|
25318
25325
|
|
|
25319
|
-
const Content$
|
|
25326
|
+
const Content$3 = styled__default.default.div`
|
|
25320
25327
|
margin-top: 10px;
|
|
25321
25328
|
p,
|
|
25322
25329
|
div {
|
|
@@ -25380,12 +25387,12 @@ var HeroImage = function (_a) {
|
|
|
25380
25387
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
25381
25388
|
React__default.default.createElement(LazyImage, { src: imageLarge, placeholder: imageSmall, visibilitySensorProps: {
|
|
25382
25389
|
partialVisibility: true,
|
|
25383
|
-
} }, function (src) { return (React__default.default.createElement(Container$
|
|
25390
|
+
} }, function (src) { return (React__default.default.createElement(Container$w, { "$image": src, "$backgroundBox": backgroundBox, "data-testid": "HeroImage" },
|
|
25384
25391
|
React__default.default.createElement(InnerContainer, null,
|
|
25385
25392
|
React__default.default.createElement(Overlay, { "$backgroundBox": backgroundBox, "data-testid": "HeroImageOverlay" },
|
|
25386
25393
|
breadcrumb && (React__default.default.createElement(BreadcrumbLink, { href: breadcrumb.url, "$backgroundBox": backgroundBox }, breadcrumb.title)),
|
|
25387
25394
|
headline && React__default.default.createElement(Headline, { level: 1, text: headline, "$backgroundBox": backgroundBox }),
|
|
25388
|
-
content && React__default.default.createElement(Content$
|
|
25395
|
+
content && React__default.default.createElement(Content$3, { dangerouslySetInnerHTML: { __html: sanitizeHtml$1(content) } }),
|
|
25389
25396
|
customSearch && (React__default.default.createElement(Search, null,
|
|
25390
25397
|
React__default.default.createElement(CustomSearch, __assign$2({}, customSearch)))),
|
|
25391
25398
|
callToActionURL && backgroundBox && (React__default.default.createElement(CallToAction, { url: callToActionURL, text: callToActionText, primary: callToActionIsPrimary })),
|
|
@@ -25403,7 +25410,7 @@ const Wrapper$3 = styled__default.default.header`
|
|
|
25403
25410
|
: props.theme.theme_vars.colours.white};
|
|
25404
25411
|
`;
|
|
25405
25412
|
|
|
25406
|
-
const Container$
|
|
25413
|
+
const Container$v = styled__default.default.div`
|
|
25407
25414
|
font-family: ${(props) => props.theme.theme_vars.fontstack};
|
|
25408
25415
|
overflow: hidden;
|
|
25409
25416
|
background: ${(props) => props.theme.theme_vars.colours.action}5A;
|
|
@@ -25547,7 +25554,7 @@ var HomeHero = function (_a) {
|
|
|
25547
25554
|
React__default.default.createElement(Wrapper$3, null,
|
|
25548
25555
|
React__default.default.createElement(LazyImage, { src: random !== 999 && imagesArray[random].image1440x810 ? imagesArray[random].image1440x810 : '', placeholder: random !== 999 && imagesArray[random].image144x81 ? imagesArray[random].image144x81 : '', visibilitySensorProps: {
|
|
25549
25556
|
partialVisibility: true,
|
|
25550
|
-
} }, function (src) { return (React__default.default.createElement(Container$
|
|
25557
|
+
} }, function (src) { return (React__default.default.createElement(Container$v, { className: random !== 999 ? 'loaded' : 'loading', "$image": src, title: random !== 999 && imagesArray[random].imageAltText ? imagesArray[random].imageAltText : '' },
|
|
25551
25558
|
React__default.default.createElement(StyledMaxWidthContainer$1, null,
|
|
25552
25559
|
React__default.default.createElement(MainBox, null,
|
|
25553
25560
|
topline && React__default.default.createElement(Topline, null, topline),
|
|
@@ -25571,7 +25578,7 @@ const Wrapper$2 = styled__default.default.section`
|
|
|
25571
25578
|
padding-bottom: 0px;
|
|
25572
25579
|
`;
|
|
25573
25580
|
|
|
25574
|
-
const Container$
|
|
25581
|
+
const Container$u = styled__default.default.div`
|
|
25575
25582
|
font-family: ${(props) => props.theme.theme_vars.fontstack};
|
|
25576
25583
|
display: flex;
|
|
25577
25584
|
flex-wrap: wrap;
|
|
@@ -25711,7 +25718,7 @@ var MemorialHero = function (_a) {
|
|
|
25711
25718
|
React__default.default.createElement(HiddenH1, null,
|
|
25712
25719
|
themeContext.full_name,
|
|
25713
25720
|
" Council"),
|
|
25714
|
-
React__default.default.createElement(Container$
|
|
25721
|
+
React__default.default.createElement(Container$u, null,
|
|
25715
25722
|
React__default.default.createElement(Left, null,
|
|
25716
25723
|
children,
|
|
25717
25724
|
React__default.default.createElement(styled.ThemeProvider, { theme: theme }, councilServices)),
|
|
@@ -25741,7 +25748,7 @@ var NewsArticleDate = function (_a) {
|
|
|
25741
25748
|
const imageHeightMobile = 150;
|
|
25742
25749
|
const imageHeightDesktop = 200;
|
|
25743
25750
|
|
|
25744
|
-
const Container$
|
|
25751
|
+
const Container$t = styled__default.default.div`
|
|
25745
25752
|
${(props) => props.theme.fontStyles};
|
|
25746
25753
|
padding: 15px 0;
|
|
25747
25754
|
|
|
@@ -25879,8 +25886,8 @@ var NewsArticleFeaturedBlock = function (_a) {
|
|
|
25879
25886
|
var articles = _a.articles, _b = _a.withoutTitle, withoutTitle = _b === void 0 ? false : _b, _c = _a.viewAllLink, viewAllLink = _c === void 0 ? '/' : _c;
|
|
25880
25887
|
if (articles && articles.length > 0) {
|
|
25881
25888
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
25882
|
-
!withoutTitle && React__default.default.createElement(Heading, { text: "News articles and press releases" }),
|
|
25883
|
-
React__default.default.createElement(Container$
|
|
25889
|
+
!withoutTitle && React__default.default.createElement(Heading$1, { text: "News articles and press releases" }),
|
|
25890
|
+
React__default.default.createElement(Container$t, null,
|
|
25884
25891
|
React__default.default.createElement(Row$1, { isList: true }, articles.map(function (article) { return (React__default.default.createElement(Column, { isList: true, small: "full", medium: "one-half", large: "one-third", key: article.id },
|
|
25885
25892
|
React__default.default.createElement(ArticleContainer$1, { href: article.url },
|
|
25886
25893
|
React__default.default.createElement(Row$1, null,
|
|
@@ -25901,7 +25908,7 @@ var NewsArticleFeaturedBlock = function (_a) {
|
|
|
25901
25908
|
}
|
|
25902
25909
|
};
|
|
25903
25910
|
|
|
25904
|
-
const Container$
|
|
25911
|
+
const Container$s = styled__default.default.div`
|
|
25905
25912
|
/* margin-top: 50px; */
|
|
25906
25913
|
/* border: 1px solid red; */
|
|
25907
25914
|
|
|
@@ -26002,7 +26009,7 @@ const FilterHeading = styled__default.default.h2`
|
|
|
26002
26009
|
// display: block;
|
|
26003
26010
|
// overflow: hidden;
|
|
26004
26011
|
|
|
26005
|
-
const Container$
|
|
26012
|
+
const Container$r = styled__default.default.a`
|
|
26006
26013
|
${props => props.theme.linkStyles}
|
|
26007
26014
|
color: ${props => props.theme.theme_vars.colours.negative} !important;
|
|
26008
26015
|
font-weight: normal;
|
|
@@ -26031,7 +26038,7 @@ var RemoveAllFilters = function (_a) {
|
|
|
26031
26038
|
e.preventDefault();
|
|
26032
26039
|
removeParams(__spreadArray(__spreadArray([], NewsArticleFilterFields.removeFiltersList, true), ['page'], false));
|
|
26033
26040
|
};
|
|
26034
|
-
return (React__default.default.createElement(Container$
|
|
26041
|
+
return (React__default.default.createElement(Container$r, { "data-testid": "RemoveAllFilters", href: "#", onClick: removeAllFilters },
|
|
26035
26042
|
"Clear ",
|
|
26036
26043
|
searchValue.length > 0 && 'search term and ',
|
|
26037
26044
|
"filters",
|
|
@@ -26078,7 +26085,7 @@ var NewsArticleFilterAccordion = function (_a) {
|
|
|
26078
26085
|
section.isExpanded = false;
|
|
26079
26086
|
}
|
|
26080
26087
|
});
|
|
26081
|
-
return (React__default.default.createElement(Container$
|
|
26088
|
+
return (React__default.default.createElement(Container$s, { "data-testid": "NewsArticleFilterAccordion" },
|
|
26082
26089
|
React__default.default.createElement(ShowFiltersButton, { onClick: showFullscreenFilters, "aria-expanded": !!isFullScreen, "aria-controls": "PageFilters" },
|
|
26083
26090
|
"Show Search and filters",
|
|
26084
26091
|
count > 0 && " (".concat(count, ")")),
|
|
@@ -26141,7 +26148,7 @@ var NewsArticleImage = function (_a) {
|
|
|
26141
26148
|
imageCaption && React__default.default.createElement(Small, { itemprop: "copyrightHolder" }, imageCaption))); })));
|
|
26142
26149
|
};
|
|
26143
26150
|
|
|
26144
|
-
const Container$
|
|
26151
|
+
const Container$q = styled__default.default.div`
|
|
26145
26152
|
${(props) => props.theme.fontStyles};
|
|
26146
26153
|
`;
|
|
26147
26154
|
|
|
@@ -26262,7 +26269,7 @@ var NewsArticleList = function (_a) {
|
|
|
26262
26269
|
var results = _a.results;
|
|
26263
26270
|
var extractLength = 140;
|
|
26264
26271
|
if (results && results.length > 0) {
|
|
26265
|
-
return (React__default.default.createElement(Container$
|
|
26272
|
+
return (React__default.default.createElement(Container$q, { "data-testid": "NewsArticleList" },
|
|
26266
26273
|
React__default.default.createElement(Row$1, { isList: true }, results.map(function (article) { return (React__default.default.createElement(Column, { isList: true, small: "full", medium: "full", large: "full", key: article.id },
|
|
26267
26274
|
React__default.default.createElement(ArticleContainer, { href: article.url, title: article.title },
|
|
26268
26275
|
article.image720x405 && (React__default.default.createElement(LazyImage, { src: article.image720x405, placeholder: article.image72x41, visibilitySensorProps: {
|
|
@@ -26277,12 +26284,12 @@ var NewsArticleList = function (_a) {
|
|
|
26277
26284
|
React__default.default.createElement(NewsArticleDate, { text: article.date.toString(), format: "X" })))))); }))));
|
|
26278
26285
|
}
|
|
26279
26286
|
else {
|
|
26280
|
-
return (React__default.default.createElement(Container$
|
|
26287
|
+
return (React__default.default.createElement(Container$q, { "data-testid": "NewsArticleList" },
|
|
26281
26288
|
React__default.default.createElement(ResultInfo$3, null, "No results found")));
|
|
26282
26289
|
}
|
|
26283
26290
|
};
|
|
26284
26291
|
|
|
26285
|
-
const Container$
|
|
26292
|
+
const Container$p = styled__default.default.div`
|
|
26286
26293
|
${props => props.theme.fontStyles};
|
|
26287
26294
|
padding-bottom: 20px;
|
|
26288
26295
|
border-bottom: 1px solid ${props => props.theme.theme_vars.colours.grey};
|
|
@@ -26356,7 +26363,7 @@ const Preposition = styled__default.default.div`
|
|
|
26356
26363
|
font-size: 80%;
|
|
26357
26364
|
`;
|
|
26358
26365
|
|
|
26359
|
-
const Container$
|
|
26366
|
+
const Container$o = styled__default.default.span`
|
|
26360
26367
|
margin: 0 5px;
|
|
26361
26368
|
display: inline-block;
|
|
26362
26369
|
position: relative;
|
|
@@ -26417,7 +26424,7 @@ var RemovableTag = function (_a) {
|
|
|
26417
26424
|
var index = _a.index, preposition = _a.preposition, label = _a.label; _a.value; _a.param; var clickHandler = _a.clickHandler;
|
|
26418
26425
|
return (React__default.default.createElement(Wrapper$1, { "data-testid": "RemovableTag" },
|
|
26419
26426
|
index > 0 && preposition && React__default.default.createElement(Preposition, null, preposition),
|
|
26420
|
-
React__default.default.createElement(Container$
|
|
26427
|
+
React__default.default.createElement(Container$o, null,
|
|
26421
26428
|
React__default.default.createElement(Text, null, label),
|
|
26422
26429
|
React__default.default.createElement(Button$2, { "aria-label": "Remove filter ".concat(label), onClick: clickHandler }, "x"))));
|
|
26423
26430
|
};
|
|
@@ -26437,7 +26444,7 @@ var NewsArticleListHeader = function (_a) {
|
|
|
26437
26444
|
var removeFilterValue = function (param, value) {
|
|
26438
26445
|
removeValueFromParam(param, value);
|
|
26439
26446
|
};
|
|
26440
|
-
return (React__default.default.createElement(Container$
|
|
26447
|
+
return (React__default.default.createElement(Container$p, { "data-testid": "NewsArticleListHeader" },
|
|
26441
26448
|
React__default.default.createElement(LeftCol, null,
|
|
26442
26449
|
totalResults,
|
|
26443
26450
|
" article",
|
|
@@ -26491,7 +26498,7 @@ var NewsArticleOldBanner = function (_a) {
|
|
|
26491
26498
|
React__default.default.createElement("strong", null, "1 year old")));
|
|
26492
26499
|
};
|
|
26493
26500
|
|
|
26494
|
-
const Container$
|
|
26501
|
+
const Container$n = styled__default.default.main`
|
|
26495
26502
|
padding-top: 30px;
|
|
26496
26503
|
|
|
26497
26504
|
a {
|
|
@@ -26608,10 +26615,10 @@ const Container$m = styled__default.default.main`
|
|
|
26608
26615
|
*/
|
|
26609
26616
|
var PageMain = function (_a) {
|
|
26610
26617
|
var children = _a.children, classes = _a.classes, _b = _a.fullWidthText, fullWidthText = _b === void 0 ? false : _b, props = __rest(_a, ["children", "classes", "fullWidthText"]);
|
|
26611
|
-
return (React__default.default.createElement(Container$
|
|
26618
|
+
return (React__default.default.createElement(Container$n, __assign$2({ id: "main", className: classes, "$fullWidthText": fullWidthText }, props, { "data-testid": "PageMain" }), children));
|
|
26612
26619
|
};
|
|
26613
26620
|
|
|
26614
|
-
const Container$
|
|
26621
|
+
const Container$m = styled__default.default.aside`
|
|
26615
26622
|
padding-top: 30px;
|
|
26616
26623
|
`;
|
|
26617
26624
|
|
|
@@ -26620,10 +26627,10 @@ const Container$l = styled__default.default.aside`
|
|
|
26620
26627
|
*/
|
|
26621
26628
|
var PageSidebar = function (_a) {
|
|
26622
26629
|
var children = _a.children;
|
|
26623
|
-
return (React__default.default.createElement(Container$
|
|
26630
|
+
return (React__default.default.createElement(Container$m, { className: "sidebar" }, children));
|
|
26624
26631
|
};
|
|
26625
26632
|
|
|
26626
|
-
const Container$
|
|
26633
|
+
const Container$l = styled__default.default.div`
|
|
26627
26634
|
padding-top: 30px;
|
|
26628
26635
|
|
|
26629
26636
|
h1 {
|
|
@@ -26636,10 +26643,10 @@ const Container$k = styled__default.default.div`
|
|
|
26636
26643
|
*/
|
|
26637
26644
|
var PageTitle = function (_a) {
|
|
26638
26645
|
var children = _a.children, classes = _a.classes, props = __rest(_a, ["children", "classes"]);
|
|
26639
|
-
return (React__default.default.createElement(Container$
|
|
26646
|
+
return (React__default.default.createElement(Container$l, __assign$2({ "data-testid": "title", className: classes }, props), children));
|
|
26640
26647
|
};
|
|
26641
26648
|
|
|
26642
|
-
const Container$
|
|
26649
|
+
const Container$k = styled__default.default.div`
|
|
26643
26650
|
@media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.m}) {
|
|
26644
26651
|
display: flex;
|
|
26645
26652
|
flex-wrap: wrap;
|
|
@@ -26681,7 +26688,7 @@ const Container$j = styled__default.default.div`
|
|
|
26681
26688
|
*/
|
|
26682
26689
|
var PageWithSidebarContainer = function (_a) {
|
|
26683
26690
|
var _b = _a.sidebarLeft, sidebarLeft = _b === void 0 ? false : _b, children = _a.children;
|
|
26684
|
-
return React__default.default.createElement(Container$
|
|
26691
|
+
return React__default.default.createElement(Container$k, { "$sidebarLeft": sidebarLeft }, children);
|
|
26685
26692
|
};
|
|
26686
26693
|
|
|
26687
26694
|
const backgroundDecider = props => {
|
|
@@ -26700,14 +26707,14 @@ const backgroundDecider = props => {
|
|
|
26700
26707
|
};
|
|
26701
26708
|
|
|
26702
26709
|
|
|
26703
|
-
const Container$
|
|
26710
|
+
const Container$j = styled__default.default.div`
|
|
26704
26711
|
${backgroundDecider};
|
|
26705
26712
|
padding-top: 1.5em;
|
|
26706
26713
|
`;
|
|
26707
26714
|
|
|
26708
26715
|
var PageWrapper = function (_a) {
|
|
26709
26716
|
var colour = _a.colour, children = _a.children;
|
|
26710
|
-
return (React__default.default.createElement(Container$
|
|
26717
|
+
return (React__default.default.createElement(Container$j, { "data-testid": "PageWrapper", colour: colour }, children));
|
|
26711
26718
|
};
|
|
26712
26719
|
|
|
26713
26720
|
const Wrapper = styled__default.default.div`
|
|
@@ -26773,110 +26780,2741 @@ var PhaseBanner = function (_a) {
|
|
|
26773
26780
|
React__default.default.createElement(PhaseText, null, "This site is new and we are improving it every day."))));
|
|
26774
26781
|
};
|
|
26775
26782
|
|
|
26776
|
-
|
|
26777
|
-
${(props) => props.theme.fontStyles};
|
|
26778
|
-
`;
|
|
26779
|
-
|
|
26780
|
-
const ResultInfo$2 = styled__default.default.div`
|
|
26781
|
-
font-weight: bold;
|
|
26782
|
-
margin: ${(props) => props.theme.theme_vars.spacingSizes.large} 0;
|
|
26783
|
-
`;
|
|
26784
|
-
|
|
26785
|
-
const Result = styled__default.default.div`
|
|
26786
|
-
margin-bottom: ${(props) => props.theme.theme_vars.spacingSizes.x_large};
|
|
26783
|
+
var isCheckBoxInput = (element) => element.type === 'checkbox';
|
|
26787
26784
|
|
|
26788
|
-
|
|
26789
|
-
margin-top: 0;
|
|
26790
|
-
}
|
|
26791
|
-
`;
|
|
26785
|
+
var isDateObject = (value) => value instanceof Date;
|
|
26792
26786
|
|
|
26793
|
-
|
|
26794
|
-
${(props) => props.theme.linkStyles};
|
|
26795
|
-
font-size: 1.2em;
|
|
26796
|
-
display: block;
|
|
26797
|
-
margin-bottom: 5px;
|
|
26798
|
-
`;
|
|
26787
|
+
var isNullOrUndefined = (value) => value == null;
|
|
26799
26788
|
|
|
26800
|
-
const
|
|
26801
|
-
|
|
26802
|
-
|
|
26803
|
-
|
|
26804
|
-
|
|
26805
|
-
props.theme.cardinal_name === 'west'
|
|
26806
|
-
? props.theme.theme_vars.colours.grey_darke
|
|
26807
|
-
: props.theme.theme_vars.colours.grey_darkest};
|
|
26808
|
-
margin-bottom: 3px !important;
|
|
26789
|
+
const isObjectType = (value) => typeof value === 'object';
|
|
26790
|
+
var isObject = (value) => !isNullOrUndefined(value) &&
|
|
26791
|
+
!Array.isArray(value) &&
|
|
26792
|
+
isObjectType(value) &&
|
|
26793
|
+
!isDateObject(value);
|
|
26809
26794
|
|
|
26810
|
-
|
|
26811
|
-
|
|
26812
|
-
|
|
26813
|
-
|
|
26814
|
-
|
|
26815
|
-
`;
|
|
26795
|
+
var getEventValue = (event) => isObject(event) && event.target
|
|
26796
|
+
? isCheckBoxInput(event.target)
|
|
26797
|
+
? event.target.checked
|
|
26798
|
+
: event.target.value
|
|
26799
|
+
: event;
|
|
26816
26800
|
|
|
26817
|
-
|
|
26818
|
-
margin-bottom: ${(props) => props.theme.theme_vars.spacingSizes.small};
|
|
26819
|
-
`;
|
|
26801
|
+
var getNodeParentName = (name) => name.substring(0, name.search(/\.\d+(\.|$)/)) || name;
|
|
26820
26802
|
|
|
26821
|
-
|
|
26822
|
-
font-size: 14px;
|
|
26823
|
-
font-size: 0.8rem;
|
|
26824
|
-
line-height: 1.3;
|
|
26803
|
+
var isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));
|
|
26825
26804
|
|
|
26826
|
-
|
|
26827
|
-
|
|
26828
|
-
|
|
26805
|
+
var isPlainObject = (tempObject) => {
|
|
26806
|
+
const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
|
|
26807
|
+
return (isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
|
|
26808
|
+
};
|
|
26829
26809
|
|
|
26830
|
-
|
|
26831
|
-
|
|
26832
|
-
|
|
26833
|
-
font-size: 0.8rem;
|
|
26834
|
-
line-height: 1.3;
|
|
26810
|
+
var isWeb = typeof window !== 'undefined' &&
|
|
26811
|
+
typeof window.HTMLElement !== 'undefined' &&
|
|
26812
|
+
typeof document !== 'undefined';
|
|
26835
26813
|
|
|
26836
|
-
|
|
26837
|
-
|
|
26814
|
+
function cloneObject(data) {
|
|
26815
|
+
let copy;
|
|
26816
|
+
const isArray = Array.isArray(data);
|
|
26817
|
+
if (data instanceof Date) {
|
|
26818
|
+
copy = new Date(data);
|
|
26838
26819
|
}
|
|
26839
|
-
|
|
26840
|
-
|
|
26841
|
-
@media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.s}) {
|
|
26842
|
-
font-size: 16px;
|
|
26843
|
-
font-size: 1rem;
|
|
26844
|
-
line-height: 1.4;
|
|
26845
|
-
|
|
26846
|
-
ul {
|
|
26847
|
-
font-size: 16px;
|
|
26848
|
-
font-size: 1rem;
|
|
26849
|
-
line-height: 1.4;
|
|
26820
|
+
else if (data instanceof Set) {
|
|
26821
|
+
copy = new Set(data);
|
|
26850
26822
|
}
|
|
26851
|
-
|
|
26852
|
-
|
|
26823
|
+
else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) &&
|
|
26824
|
+
(isArray || isObject(data))) {
|
|
26825
|
+
copy = isArray ? [] : {};
|
|
26826
|
+
if (!isArray && !isPlainObject(data)) {
|
|
26827
|
+
copy = data;
|
|
26828
|
+
}
|
|
26829
|
+
else {
|
|
26830
|
+
for (const key in data) {
|
|
26831
|
+
if (data.hasOwnProperty(key)) {
|
|
26832
|
+
copy[key] = cloneObject(data[key]);
|
|
26833
|
+
}
|
|
26834
|
+
}
|
|
26835
|
+
}
|
|
26836
|
+
}
|
|
26837
|
+
else {
|
|
26838
|
+
return data;
|
|
26839
|
+
}
|
|
26840
|
+
return copy;
|
|
26841
|
+
}
|
|
26853
26842
|
|
|
26854
|
-
|
|
26843
|
+
var compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];
|
|
26855
26844
|
|
|
26856
|
-
|
|
26857
|
-
margin: 0 !important;
|
|
26858
|
-
padding-left: 10px;
|
|
26859
|
-
margin-bottom: 20px !important;
|
|
26860
|
-
list-style-type: none;
|
|
26845
|
+
var isUndefined = (val) => val === undefined;
|
|
26861
26846
|
|
|
26862
|
-
|
|
26863
|
-
|
|
26847
|
+
var get = (object, path, defaultValue) => {
|
|
26848
|
+
if (!path || !isObject(object)) {
|
|
26849
|
+
return defaultValue;
|
|
26864
26850
|
}
|
|
26865
|
-
|
|
26866
|
-
|
|
26867
|
-
|
|
26868
|
-
|
|
26851
|
+
const result = compact(path.split(/[,[\].]+?/)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], object);
|
|
26852
|
+
return isUndefined(result) || result === object
|
|
26853
|
+
? isUndefined(object[path])
|
|
26854
|
+
? defaultValue
|
|
26855
|
+
: object[path]
|
|
26856
|
+
: result;
|
|
26857
|
+
};
|
|
26869
26858
|
|
|
26870
|
-
|
|
26871
|
-
content: none !important;
|
|
26872
|
-
}
|
|
26873
|
-
`;
|
|
26859
|
+
var isBoolean = (value) => typeof value === 'boolean';
|
|
26874
26860
|
|
|
26861
|
+
const EVENTS = {
|
|
26862
|
+
BLUR: 'blur',
|
|
26863
|
+
FOCUS_OUT: 'focusout',
|
|
26864
|
+
CHANGE: 'change',
|
|
26865
|
+
};
|
|
26866
|
+
const VALIDATION_MODE = {
|
|
26867
|
+
onBlur: 'onBlur',
|
|
26868
|
+
onChange: 'onChange',
|
|
26869
|
+
onSubmit: 'onSubmit',
|
|
26870
|
+
onTouched: 'onTouched',
|
|
26871
|
+
all: 'all',
|
|
26872
|
+
};
|
|
26873
|
+
const INPUT_VALIDATION_RULES = {
|
|
26874
|
+
max: 'max',
|
|
26875
|
+
min: 'min',
|
|
26876
|
+
maxLength: 'maxLength',
|
|
26877
|
+
minLength: 'minLength',
|
|
26878
|
+
pattern: 'pattern',
|
|
26879
|
+
required: 'required',
|
|
26880
|
+
validate: 'validate',
|
|
26881
|
+
};
|
|
26875
26882
|
|
|
26876
|
-
const
|
|
26877
|
-
|
|
26883
|
+
const HookFormContext = React__default.default.createContext(null);
|
|
26884
|
+
/**
|
|
26885
|
+
* 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}.
|
|
26886
|
+
*
|
|
26887
|
+
* @remarks
|
|
26888
|
+
* [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
|
|
26889
|
+
*
|
|
26890
|
+
* @returns return all useForm methods
|
|
26891
|
+
*
|
|
26892
|
+
* @example
|
|
26893
|
+
* ```tsx
|
|
26894
|
+
* function App() {
|
|
26895
|
+
* const methods = useForm();
|
|
26896
|
+
* const onSubmit = data => console.log(data);
|
|
26897
|
+
*
|
|
26898
|
+
* return (
|
|
26899
|
+
* <FormProvider {...methods} >
|
|
26900
|
+
* <form onSubmit={methods.handleSubmit(onSubmit)}>
|
|
26901
|
+
* <NestedInput />
|
|
26902
|
+
* <input type="submit" />
|
|
26903
|
+
* </form>
|
|
26904
|
+
* </FormProvider>
|
|
26905
|
+
* );
|
|
26906
|
+
* }
|
|
26907
|
+
*
|
|
26908
|
+
* function NestedInput() {
|
|
26909
|
+
* const { register } = useFormContext(); // retrieve all hook methods
|
|
26910
|
+
* return <input {...register("test")} />;
|
|
26911
|
+
* }
|
|
26912
|
+
* ```
|
|
26913
|
+
*/
|
|
26914
|
+
const useFormContext = () => React__default.default.useContext(HookFormContext);
|
|
26878
26915
|
|
|
26879
|
-
|
|
26916
|
+
var getProxyFormState = (formState, control, localProxyFormState, isRoot = true) => {
|
|
26917
|
+
const result = {
|
|
26918
|
+
defaultValues: control._defaultValues,
|
|
26919
|
+
};
|
|
26920
|
+
for (const key in formState) {
|
|
26921
|
+
Object.defineProperty(result, key, {
|
|
26922
|
+
get: () => {
|
|
26923
|
+
const _key = key;
|
|
26924
|
+
if (control._proxyFormState[_key] !== VALIDATION_MODE.all) {
|
|
26925
|
+
control._proxyFormState[_key] = !isRoot || VALIDATION_MODE.all;
|
|
26926
|
+
}
|
|
26927
|
+
localProxyFormState && (localProxyFormState[_key] = true);
|
|
26928
|
+
return formState[_key];
|
|
26929
|
+
},
|
|
26930
|
+
});
|
|
26931
|
+
}
|
|
26932
|
+
return result;
|
|
26933
|
+
};
|
|
26934
|
+
|
|
26935
|
+
var isEmptyObject = (value) => isObject(value) && !Object.keys(value).length;
|
|
26936
|
+
|
|
26937
|
+
var shouldRenderFormState = (formStateData, _proxyFormState, updateFormState, isRoot) => {
|
|
26938
|
+
updateFormState(formStateData);
|
|
26939
|
+
const { name, ...formState } = formStateData;
|
|
26940
|
+
return (isEmptyObject(formState) ||
|
|
26941
|
+
Object.keys(formState).length >= Object.keys(_proxyFormState).length ||
|
|
26942
|
+
Object.keys(formState).find((key) => _proxyFormState[key] ===
|
|
26943
|
+
(!isRoot || VALIDATION_MODE.all)));
|
|
26944
|
+
};
|
|
26945
|
+
|
|
26946
|
+
var convertToArrayPayload = (value) => (Array.isArray(value) ? value : [value]);
|
|
26947
|
+
|
|
26948
|
+
var shouldSubscribeByName = (name, signalName, exact) => !name ||
|
|
26949
|
+
!signalName ||
|
|
26950
|
+
name === signalName ||
|
|
26951
|
+
convertToArrayPayload(name).some((currentName) => currentName &&
|
|
26952
|
+
(exact
|
|
26953
|
+
? currentName === signalName
|
|
26954
|
+
: currentName.startsWith(signalName) ||
|
|
26955
|
+
signalName.startsWith(currentName)));
|
|
26956
|
+
|
|
26957
|
+
function useSubscribe(props) {
|
|
26958
|
+
const _props = React__default.default.useRef(props);
|
|
26959
|
+
_props.current = props;
|
|
26960
|
+
React__default.default.useEffect(() => {
|
|
26961
|
+
const subscription = !props.disabled &&
|
|
26962
|
+
_props.current.subject &&
|
|
26963
|
+
_props.current.subject.subscribe({
|
|
26964
|
+
next: _props.current.next,
|
|
26965
|
+
});
|
|
26966
|
+
return () => {
|
|
26967
|
+
subscription && subscription.unsubscribe();
|
|
26968
|
+
};
|
|
26969
|
+
}, [props.disabled]);
|
|
26970
|
+
}
|
|
26971
|
+
|
|
26972
|
+
/**
|
|
26973
|
+
* 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.
|
|
26974
|
+
*
|
|
26975
|
+
* @remarks
|
|
26976
|
+
* [API](https://react-hook-form.com/docs/useformstate) • [Demo](https://codesandbox.io/s/useformstate-75xly)
|
|
26977
|
+
*
|
|
26978
|
+
* @param props - include options on specify fields to subscribe. {@link UseFormStateReturn}
|
|
26979
|
+
*
|
|
26980
|
+
* @example
|
|
26981
|
+
* ```tsx
|
|
26982
|
+
* function App() {
|
|
26983
|
+
* const { register, handleSubmit, control } = useForm({
|
|
26984
|
+
* defaultValues: {
|
|
26985
|
+
* firstName: "firstName"
|
|
26986
|
+
* }});
|
|
26987
|
+
* const { dirtyFields } = useFormState({
|
|
26988
|
+
* control
|
|
26989
|
+
* });
|
|
26990
|
+
* const onSubmit = (data) => console.log(data);
|
|
26991
|
+
*
|
|
26992
|
+
* return (
|
|
26993
|
+
* <form onSubmit={handleSubmit(onSubmit)}>
|
|
26994
|
+
* <input {...register("firstName")} placeholder="First Name" />
|
|
26995
|
+
* {dirtyFields.firstName && <p>Field is dirty.</p>}
|
|
26996
|
+
* <input type="submit" />
|
|
26997
|
+
* </form>
|
|
26998
|
+
* );
|
|
26999
|
+
* }
|
|
27000
|
+
* ```
|
|
27001
|
+
*/
|
|
27002
|
+
function useFormState(props) {
|
|
27003
|
+
const methods = useFormContext();
|
|
27004
|
+
const { control = methods.control, disabled, name, exact } = props || {};
|
|
27005
|
+
const [formState, updateFormState] = React__default.default.useState(control._formState);
|
|
27006
|
+
const _mounted = React__default.default.useRef(true);
|
|
27007
|
+
const _localProxyFormState = React__default.default.useRef({
|
|
27008
|
+
isDirty: false,
|
|
27009
|
+
isLoading: false,
|
|
27010
|
+
dirtyFields: false,
|
|
27011
|
+
touchedFields: false,
|
|
27012
|
+
isValidating: false,
|
|
27013
|
+
isValid: false,
|
|
27014
|
+
errors: false,
|
|
27015
|
+
});
|
|
27016
|
+
const _name = React__default.default.useRef(name);
|
|
27017
|
+
_name.current = name;
|
|
27018
|
+
useSubscribe({
|
|
27019
|
+
disabled,
|
|
27020
|
+
next: (value) => _mounted.current &&
|
|
27021
|
+
shouldSubscribeByName(_name.current, value.name, exact) &&
|
|
27022
|
+
shouldRenderFormState(value, _localProxyFormState.current, control._updateFormState) &&
|
|
27023
|
+
updateFormState({
|
|
27024
|
+
...control._formState,
|
|
27025
|
+
...value,
|
|
27026
|
+
}),
|
|
27027
|
+
subject: control._subjects.state,
|
|
27028
|
+
});
|
|
27029
|
+
React__default.default.useEffect(() => {
|
|
27030
|
+
_mounted.current = true;
|
|
27031
|
+
_localProxyFormState.current.isValid && control._updateValid(true);
|
|
27032
|
+
return () => {
|
|
27033
|
+
_mounted.current = false;
|
|
27034
|
+
};
|
|
27035
|
+
}, [control]);
|
|
27036
|
+
return getProxyFormState(formState, control, _localProxyFormState.current, false);
|
|
27037
|
+
}
|
|
27038
|
+
|
|
27039
|
+
var isString = (value) => typeof value === 'string';
|
|
27040
|
+
|
|
27041
|
+
var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) => {
|
|
27042
|
+
if (isString(names)) {
|
|
27043
|
+
isGlobal && _names.watch.add(names);
|
|
27044
|
+
return get(formValues, names, defaultValue);
|
|
27045
|
+
}
|
|
27046
|
+
if (Array.isArray(names)) {
|
|
27047
|
+
return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName), get(formValues, fieldName)));
|
|
27048
|
+
}
|
|
27049
|
+
isGlobal && (_names.watchAll = true);
|
|
27050
|
+
return formValues;
|
|
27051
|
+
};
|
|
27052
|
+
|
|
27053
|
+
/**
|
|
27054
|
+
* Custom hook to subscribe to field change and isolate re-rendering at the component level.
|
|
27055
|
+
*
|
|
27056
|
+
* @remarks
|
|
27057
|
+
*
|
|
27058
|
+
* [API](https://react-hook-form.com/docs/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)
|
|
27059
|
+
*
|
|
27060
|
+
* @example
|
|
27061
|
+
* ```tsx
|
|
27062
|
+
* const { control } = useForm();
|
|
27063
|
+
* const values = useWatch({
|
|
27064
|
+
* name: "fieldName"
|
|
27065
|
+
* control,
|
|
27066
|
+
* })
|
|
27067
|
+
* ```
|
|
27068
|
+
*/
|
|
27069
|
+
function useWatch(props) {
|
|
27070
|
+
const methods = useFormContext();
|
|
27071
|
+
const { control = methods.control, name, defaultValue, disabled, exact, } = props || {};
|
|
27072
|
+
const _name = React__default.default.useRef(name);
|
|
27073
|
+
_name.current = name;
|
|
27074
|
+
useSubscribe({
|
|
27075
|
+
disabled,
|
|
27076
|
+
subject: control._subjects.values,
|
|
27077
|
+
next: (formState) => {
|
|
27078
|
+
if (shouldSubscribeByName(_name.current, formState.name, exact)) {
|
|
27079
|
+
updateValue(cloneObject(generateWatchOutput(_name.current, control._names, formState.values || control._formValues, false, defaultValue)));
|
|
27080
|
+
}
|
|
27081
|
+
},
|
|
27082
|
+
});
|
|
27083
|
+
const [value, updateValue] = React__default.default.useState(control._getWatch(name, defaultValue));
|
|
27084
|
+
React__default.default.useEffect(() => control._removeUnmounted());
|
|
27085
|
+
return value;
|
|
27086
|
+
}
|
|
27087
|
+
|
|
27088
|
+
var isKey = (value) => /^\w*$/.test(value);
|
|
27089
|
+
|
|
27090
|
+
var stringToPath = (input) => compact(input.replace(/["|']|\]/g, '').split(/\.|\[/));
|
|
27091
|
+
|
|
27092
|
+
var set = (object, path, value) => {
|
|
27093
|
+
let index = -1;
|
|
27094
|
+
const tempPath = isKey(path) ? [path] : stringToPath(path);
|
|
27095
|
+
const length = tempPath.length;
|
|
27096
|
+
const lastIndex = length - 1;
|
|
27097
|
+
while (++index < length) {
|
|
27098
|
+
const key = tempPath[index];
|
|
27099
|
+
let newValue = value;
|
|
27100
|
+
if (index !== lastIndex) {
|
|
27101
|
+
const objValue = object[key];
|
|
27102
|
+
newValue =
|
|
27103
|
+
isObject(objValue) || Array.isArray(objValue)
|
|
27104
|
+
? objValue
|
|
27105
|
+
: !isNaN(+tempPath[index + 1])
|
|
27106
|
+
? []
|
|
27107
|
+
: {};
|
|
27108
|
+
}
|
|
27109
|
+
object[key] = newValue;
|
|
27110
|
+
object = object[key];
|
|
27111
|
+
}
|
|
27112
|
+
return object;
|
|
27113
|
+
};
|
|
27114
|
+
|
|
27115
|
+
/**
|
|
27116
|
+
* 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.
|
|
27117
|
+
*
|
|
27118
|
+
* @remarks
|
|
27119
|
+
* [API](https://react-hook-form.com/docs/usecontroller) • [Demo](https://codesandbox.io/s/usecontroller-0o8px)
|
|
27120
|
+
*
|
|
27121
|
+
* @param props - the path name to the form field value, and validation rules.
|
|
27122
|
+
*
|
|
27123
|
+
* @returns field properties, field and form state. {@link UseControllerReturn}
|
|
27124
|
+
*
|
|
27125
|
+
* @example
|
|
27126
|
+
* ```tsx
|
|
27127
|
+
* function Input(props) {
|
|
27128
|
+
* const { field, fieldState, formState } = useController(props);
|
|
27129
|
+
* return (
|
|
27130
|
+
* <div>
|
|
27131
|
+
* <input {...field} placeholder={props.name} />
|
|
27132
|
+
* <p>{fieldState.isTouched && "Touched"}</p>
|
|
27133
|
+
* <p>{formState.isSubmitted ? "submitted" : ""}</p>
|
|
27134
|
+
* </div>
|
|
27135
|
+
* );
|
|
27136
|
+
* }
|
|
27137
|
+
* ```
|
|
27138
|
+
*/
|
|
27139
|
+
function useController(props) {
|
|
27140
|
+
const methods = useFormContext();
|
|
27141
|
+
const { name, disabled, control = methods.control, shouldUnregister } = props;
|
|
27142
|
+
const isArrayField = isNameInFieldArray(control._names.array, name);
|
|
27143
|
+
const value = useWatch({
|
|
27144
|
+
control,
|
|
27145
|
+
name,
|
|
27146
|
+
defaultValue: get(control._formValues, name, get(control._defaultValues, name, props.defaultValue)),
|
|
27147
|
+
exact: true,
|
|
27148
|
+
});
|
|
27149
|
+
const formState = useFormState({
|
|
27150
|
+
control,
|
|
27151
|
+
name,
|
|
27152
|
+
});
|
|
27153
|
+
const _registerProps = React__default.default.useRef(control.register(name, {
|
|
27154
|
+
...props.rules,
|
|
27155
|
+
value,
|
|
27156
|
+
...(isBoolean(props.disabled) ? { disabled: props.disabled } : {}),
|
|
27157
|
+
}));
|
|
27158
|
+
React__default.default.useEffect(() => {
|
|
27159
|
+
const _shouldUnregisterField = control._options.shouldUnregister || shouldUnregister;
|
|
27160
|
+
const updateMounted = (name, value) => {
|
|
27161
|
+
const field = get(control._fields, name);
|
|
27162
|
+
if (field) {
|
|
27163
|
+
field._f.mount = value;
|
|
27164
|
+
}
|
|
27165
|
+
};
|
|
27166
|
+
updateMounted(name, true);
|
|
27167
|
+
if (_shouldUnregisterField) {
|
|
27168
|
+
const value = cloneObject(get(control._options.defaultValues, name));
|
|
27169
|
+
set(control._defaultValues, name, value);
|
|
27170
|
+
if (isUndefined(get(control._formValues, name))) {
|
|
27171
|
+
set(control._formValues, name, value);
|
|
27172
|
+
}
|
|
27173
|
+
}
|
|
27174
|
+
return () => {
|
|
27175
|
+
(isArrayField
|
|
27176
|
+
? _shouldUnregisterField && !control._state.action
|
|
27177
|
+
: _shouldUnregisterField)
|
|
27178
|
+
? control.unregister(name)
|
|
27179
|
+
: updateMounted(name, false);
|
|
27180
|
+
};
|
|
27181
|
+
}, [name, control, isArrayField, shouldUnregister]);
|
|
27182
|
+
React__default.default.useEffect(() => {
|
|
27183
|
+
if (get(control._fields, name)) {
|
|
27184
|
+
control._updateDisabledField({
|
|
27185
|
+
disabled,
|
|
27186
|
+
fields: control._fields,
|
|
27187
|
+
name,
|
|
27188
|
+
value: get(control._fields, name)._f.value,
|
|
27189
|
+
});
|
|
27190
|
+
}
|
|
27191
|
+
}, [disabled, name, control]);
|
|
27192
|
+
return {
|
|
27193
|
+
field: {
|
|
27194
|
+
name,
|
|
27195
|
+
value,
|
|
27196
|
+
...(isBoolean(disabled) || isBoolean(formState.disabled)
|
|
27197
|
+
? { disabled: formState.disabled || disabled }
|
|
27198
|
+
: {}),
|
|
27199
|
+
onChange: React__default.default.useCallback((event) => _registerProps.current.onChange({
|
|
27200
|
+
target: {
|
|
27201
|
+
value: getEventValue(event),
|
|
27202
|
+
name: name,
|
|
27203
|
+
},
|
|
27204
|
+
type: EVENTS.CHANGE,
|
|
27205
|
+
}), [name]),
|
|
27206
|
+
onBlur: React__default.default.useCallback(() => _registerProps.current.onBlur({
|
|
27207
|
+
target: {
|
|
27208
|
+
value: get(control._formValues, name),
|
|
27209
|
+
name: name,
|
|
27210
|
+
},
|
|
27211
|
+
type: EVENTS.BLUR,
|
|
27212
|
+
}), [name, control]),
|
|
27213
|
+
ref: (elm) => {
|
|
27214
|
+
const field = get(control._fields, name);
|
|
27215
|
+
if (field && elm) {
|
|
27216
|
+
field._f.ref = {
|
|
27217
|
+
focus: () => elm.focus(),
|
|
27218
|
+
select: () => elm.select(),
|
|
27219
|
+
setCustomValidity: (message) => elm.setCustomValidity(message),
|
|
27220
|
+
reportValidity: () => elm.reportValidity(),
|
|
27221
|
+
};
|
|
27222
|
+
}
|
|
27223
|
+
},
|
|
27224
|
+
},
|
|
27225
|
+
formState,
|
|
27226
|
+
fieldState: Object.defineProperties({}, {
|
|
27227
|
+
invalid: {
|
|
27228
|
+
enumerable: true,
|
|
27229
|
+
get: () => !!get(formState.errors, name),
|
|
27230
|
+
},
|
|
27231
|
+
isDirty: {
|
|
27232
|
+
enumerable: true,
|
|
27233
|
+
get: () => !!get(formState.dirtyFields, name),
|
|
27234
|
+
},
|
|
27235
|
+
isTouched: {
|
|
27236
|
+
enumerable: true,
|
|
27237
|
+
get: () => !!get(formState.touchedFields, name),
|
|
27238
|
+
},
|
|
27239
|
+
error: {
|
|
27240
|
+
enumerable: true,
|
|
27241
|
+
get: () => get(formState.errors, name),
|
|
27242
|
+
},
|
|
27243
|
+
}),
|
|
27244
|
+
};
|
|
27245
|
+
}
|
|
27246
|
+
|
|
27247
|
+
/**
|
|
27248
|
+
* Component based on `useController` hook to work with controlled component.
|
|
27249
|
+
*
|
|
27250
|
+
* @remarks
|
|
27251
|
+
* [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)
|
|
27252
|
+
*
|
|
27253
|
+
* @param props - the path name to the form field value, and validation rules.
|
|
27254
|
+
*
|
|
27255
|
+
* @returns provide field handler functions, field and form state.
|
|
27256
|
+
*
|
|
27257
|
+
* @example
|
|
27258
|
+
* ```tsx
|
|
27259
|
+
* function App() {
|
|
27260
|
+
* const { control } = useForm<FormValues>({
|
|
27261
|
+
* defaultValues: {
|
|
27262
|
+
* test: ""
|
|
27263
|
+
* }
|
|
27264
|
+
* });
|
|
27265
|
+
*
|
|
27266
|
+
* return (
|
|
27267
|
+
* <form>
|
|
27268
|
+
* <Controller
|
|
27269
|
+
* control={control}
|
|
27270
|
+
* name="test"
|
|
27271
|
+
* render={({ field: { onChange, onBlur, value, ref }, formState, fieldState }) => (
|
|
27272
|
+
* <>
|
|
27273
|
+
* <input
|
|
27274
|
+
* onChange={onChange} // send value to hook form
|
|
27275
|
+
* onBlur={onBlur} // notify when input is touched
|
|
27276
|
+
* value={value} // return updated value
|
|
27277
|
+
* ref={ref} // set ref for focus management
|
|
27278
|
+
* />
|
|
27279
|
+
* <p>{formState.isSubmitted ? "submitted" : ""}</p>
|
|
27280
|
+
* <p>{fieldState.isTouched ? "touched" : ""}</p>
|
|
27281
|
+
* </>
|
|
27282
|
+
* )}
|
|
27283
|
+
* />
|
|
27284
|
+
* </form>
|
|
27285
|
+
* );
|
|
27286
|
+
* }
|
|
27287
|
+
* ```
|
|
27288
|
+
*/
|
|
27289
|
+
const Controller = (props) => props.render(useController(props));
|
|
27290
|
+
|
|
27291
|
+
var appendErrors = (name, validateAllFieldCriteria, errors, type, message) => validateAllFieldCriteria
|
|
27292
|
+
? {
|
|
27293
|
+
...errors[name],
|
|
27294
|
+
types: {
|
|
27295
|
+
...(errors[name] && errors[name].types ? errors[name].types : {}),
|
|
27296
|
+
[type]: message || true,
|
|
27297
|
+
},
|
|
27298
|
+
}
|
|
27299
|
+
: {};
|
|
27300
|
+
|
|
27301
|
+
var getValidationModes = (mode) => ({
|
|
27302
|
+
isOnSubmit: !mode || mode === VALIDATION_MODE.onSubmit,
|
|
27303
|
+
isOnBlur: mode === VALIDATION_MODE.onBlur,
|
|
27304
|
+
isOnChange: mode === VALIDATION_MODE.onChange,
|
|
27305
|
+
isOnAll: mode === VALIDATION_MODE.all,
|
|
27306
|
+
isOnTouch: mode === VALIDATION_MODE.onTouched,
|
|
27307
|
+
});
|
|
27308
|
+
|
|
27309
|
+
var isWatched = (name, _names, isBlurEvent) => !isBlurEvent &&
|
|
27310
|
+
(_names.watchAll ||
|
|
27311
|
+
_names.watch.has(name) ||
|
|
27312
|
+
[..._names.watch].some((watchName) => name.startsWith(watchName) &&
|
|
27313
|
+
/^\.\w+/.test(name.slice(watchName.length))));
|
|
27314
|
+
|
|
27315
|
+
const iterateFieldsByAction = (fields, action, fieldsNames, abortEarly) => {
|
|
27316
|
+
for (const key of fieldsNames || Object.keys(fields)) {
|
|
27317
|
+
const field = get(fields, key);
|
|
27318
|
+
if (field) {
|
|
27319
|
+
const { _f, ...currentField } = field;
|
|
27320
|
+
if (_f) {
|
|
27321
|
+
if (_f.refs && _f.refs[0] && action(_f.refs[0], key) && !abortEarly) {
|
|
27322
|
+
break;
|
|
27323
|
+
}
|
|
27324
|
+
else if (_f.ref && action(_f.ref, _f.name) && !abortEarly) {
|
|
27325
|
+
break;
|
|
27326
|
+
}
|
|
27327
|
+
else {
|
|
27328
|
+
iterateFieldsByAction(currentField, action);
|
|
27329
|
+
}
|
|
27330
|
+
}
|
|
27331
|
+
else if (isObject(currentField)) {
|
|
27332
|
+
iterateFieldsByAction(currentField, action);
|
|
27333
|
+
}
|
|
27334
|
+
}
|
|
27335
|
+
}
|
|
27336
|
+
};
|
|
27337
|
+
|
|
27338
|
+
var updateFieldArrayRootError = (errors, error, name) => {
|
|
27339
|
+
const fieldArrayErrors = compact(get(errors, name));
|
|
27340
|
+
set(fieldArrayErrors, 'root', error[name]);
|
|
27341
|
+
set(errors, name, fieldArrayErrors);
|
|
27342
|
+
return errors;
|
|
27343
|
+
};
|
|
27344
|
+
|
|
27345
|
+
var isFileInput = (element) => element.type === 'file';
|
|
27346
|
+
|
|
27347
|
+
var isFunction = (value) => typeof value === 'function';
|
|
27348
|
+
|
|
27349
|
+
var isHTMLElement = (value) => {
|
|
27350
|
+
if (!isWeb) {
|
|
27351
|
+
return false;
|
|
27352
|
+
}
|
|
27353
|
+
const owner = value ? value.ownerDocument : 0;
|
|
27354
|
+
return (value instanceof
|
|
27355
|
+
(owner && owner.defaultView ? owner.defaultView.HTMLElement : HTMLElement));
|
|
27356
|
+
};
|
|
27357
|
+
|
|
27358
|
+
var isMessage = (value) => isString(value);
|
|
27359
|
+
|
|
27360
|
+
var isRadioInput = (element) => element.type === 'radio';
|
|
27361
|
+
|
|
27362
|
+
var isRegex = (value) => value instanceof RegExp;
|
|
27363
|
+
|
|
27364
|
+
const defaultResult = {
|
|
27365
|
+
value: false,
|
|
27366
|
+
isValid: false,
|
|
27367
|
+
};
|
|
27368
|
+
const validResult = { value: true, isValid: true };
|
|
27369
|
+
var getCheckboxValue = (options) => {
|
|
27370
|
+
if (Array.isArray(options)) {
|
|
27371
|
+
if (options.length > 1) {
|
|
27372
|
+
const values = options
|
|
27373
|
+
.filter((option) => option && option.checked && !option.disabled)
|
|
27374
|
+
.map((option) => option.value);
|
|
27375
|
+
return { value: values, isValid: !!values.length };
|
|
27376
|
+
}
|
|
27377
|
+
return options[0].checked && !options[0].disabled
|
|
27378
|
+
? // @ts-expect-error expected to work in the browser
|
|
27379
|
+
options[0].attributes && !isUndefined(options[0].attributes.value)
|
|
27380
|
+
? isUndefined(options[0].value) || options[0].value === ''
|
|
27381
|
+
? validResult
|
|
27382
|
+
: { value: options[0].value, isValid: true }
|
|
27383
|
+
: validResult
|
|
27384
|
+
: defaultResult;
|
|
27385
|
+
}
|
|
27386
|
+
return defaultResult;
|
|
27387
|
+
};
|
|
27388
|
+
|
|
27389
|
+
const defaultReturn = {
|
|
27390
|
+
isValid: false,
|
|
27391
|
+
value: null,
|
|
27392
|
+
};
|
|
27393
|
+
var getRadioValue = (options) => Array.isArray(options)
|
|
27394
|
+
? options.reduce((previous, option) => option && option.checked && !option.disabled
|
|
27395
|
+
? {
|
|
27396
|
+
isValid: true,
|
|
27397
|
+
value: option.value,
|
|
27398
|
+
}
|
|
27399
|
+
: previous, defaultReturn)
|
|
27400
|
+
: defaultReturn;
|
|
27401
|
+
|
|
27402
|
+
function getValidateError(result, ref, type = 'validate') {
|
|
27403
|
+
if (isMessage(result) ||
|
|
27404
|
+
(Array.isArray(result) && result.every(isMessage)) ||
|
|
27405
|
+
(isBoolean(result) && !result)) {
|
|
27406
|
+
return {
|
|
27407
|
+
type,
|
|
27408
|
+
message: isMessage(result) ? result : '',
|
|
27409
|
+
ref,
|
|
27410
|
+
};
|
|
27411
|
+
}
|
|
27412
|
+
}
|
|
27413
|
+
|
|
27414
|
+
var getValueAndMessage = (validationData) => isObject(validationData) && !isRegex(validationData)
|
|
27415
|
+
? validationData
|
|
27416
|
+
: {
|
|
27417
|
+
value: validationData,
|
|
27418
|
+
message: '',
|
|
27419
|
+
};
|
|
27420
|
+
|
|
27421
|
+
var validateField = async (field, formValues, validateAllFieldCriteria, shouldUseNativeValidation, isFieldArray) => {
|
|
27422
|
+
const { ref, refs, required, maxLength, minLength, min, max, pattern, validate, name, valueAsNumber, mount, disabled, } = field._f;
|
|
27423
|
+
const inputValue = get(formValues, name);
|
|
27424
|
+
if (!mount || disabled) {
|
|
27425
|
+
return {};
|
|
27426
|
+
}
|
|
27427
|
+
const inputRef = refs ? refs[0] : ref;
|
|
27428
|
+
const setCustomValidity = (message) => {
|
|
27429
|
+
if (shouldUseNativeValidation && inputRef.reportValidity) {
|
|
27430
|
+
inputRef.setCustomValidity(isBoolean(message) ? '' : message || '');
|
|
27431
|
+
inputRef.reportValidity();
|
|
27432
|
+
}
|
|
27433
|
+
};
|
|
27434
|
+
const error = {};
|
|
27435
|
+
const isRadio = isRadioInput(ref);
|
|
27436
|
+
const isCheckBox = isCheckBoxInput(ref);
|
|
27437
|
+
const isRadioOrCheckbox = isRadio || isCheckBox;
|
|
27438
|
+
const isEmpty = ((valueAsNumber || isFileInput(ref)) &&
|
|
27439
|
+
isUndefined(ref.value) &&
|
|
27440
|
+
isUndefined(inputValue)) ||
|
|
27441
|
+
(isHTMLElement(ref) && ref.value === '') ||
|
|
27442
|
+
inputValue === '' ||
|
|
27443
|
+
(Array.isArray(inputValue) && !inputValue.length);
|
|
27444
|
+
const appendErrorsCurry = appendErrors.bind(null, name, validateAllFieldCriteria, error);
|
|
27445
|
+
const getMinMaxMessage = (exceedMax, maxLengthMessage, minLengthMessage, maxType = INPUT_VALIDATION_RULES.maxLength, minType = INPUT_VALIDATION_RULES.minLength) => {
|
|
27446
|
+
const message = exceedMax ? maxLengthMessage : minLengthMessage;
|
|
27447
|
+
error[name] = {
|
|
27448
|
+
type: exceedMax ? maxType : minType,
|
|
27449
|
+
message,
|
|
27450
|
+
ref,
|
|
27451
|
+
...appendErrorsCurry(exceedMax ? maxType : minType, message),
|
|
27452
|
+
};
|
|
27453
|
+
};
|
|
27454
|
+
if (isFieldArray
|
|
27455
|
+
? !Array.isArray(inputValue) || !inputValue.length
|
|
27456
|
+
: required &&
|
|
27457
|
+
((!isRadioOrCheckbox && (isEmpty || isNullOrUndefined(inputValue))) ||
|
|
27458
|
+
(isBoolean(inputValue) && !inputValue) ||
|
|
27459
|
+
(isCheckBox && !getCheckboxValue(refs).isValid) ||
|
|
27460
|
+
(isRadio && !getRadioValue(refs).isValid))) {
|
|
27461
|
+
const { value, message } = isMessage(required)
|
|
27462
|
+
? { value: !!required, message: required }
|
|
27463
|
+
: getValueAndMessage(required);
|
|
27464
|
+
if (value) {
|
|
27465
|
+
error[name] = {
|
|
27466
|
+
type: INPUT_VALIDATION_RULES.required,
|
|
27467
|
+
message,
|
|
27468
|
+
ref: inputRef,
|
|
27469
|
+
...appendErrorsCurry(INPUT_VALIDATION_RULES.required, message),
|
|
27470
|
+
};
|
|
27471
|
+
if (!validateAllFieldCriteria) {
|
|
27472
|
+
setCustomValidity(message);
|
|
27473
|
+
return error;
|
|
27474
|
+
}
|
|
27475
|
+
}
|
|
27476
|
+
}
|
|
27477
|
+
if (!isEmpty && (!isNullOrUndefined(min) || !isNullOrUndefined(max))) {
|
|
27478
|
+
let exceedMax;
|
|
27479
|
+
let exceedMin;
|
|
27480
|
+
const maxOutput = getValueAndMessage(max);
|
|
27481
|
+
const minOutput = getValueAndMessage(min);
|
|
27482
|
+
if (!isNullOrUndefined(inputValue) && !isNaN(inputValue)) {
|
|
27483
|
+
const valueNumber = ref.valueAsNumber ||
|
|
27484
|
+
(inputValue ? +inputValue : inputValue);
|
|
27485
|
+
if (!isNullOrUndefined(maxOutput.value)) {
|
|
27486
|
+
exceedMax = valueNumber > maxOutput.value;
|
|
27487
|
+
}
|
|
27488
|
+
if (!isNullOrUndefined(minOutput.value)) {
|
|
27489
|
+
exceedMin = valueNumber < minOutput.value;
|
|
27490
|
+
}
|
|
27491
|
+
}
|
|
27492
|
+
else {
|
|
27493
|
+
const valueDate = ref.valueAsDate || new Date(inputValue);
|
|
27494
|
+
const convertTimeToDate = (time) => new Date(new Date().toDateString() + ' ' + time);
|
|
27495
|
+
const isTime = ref.type == 'time';
|
|
27496
|
+
const isWeek = ref.type == 'week';
|
|
27497
|
+
if (isString(maxOutput.value) && inputValue) {
|
|
27498
|
+
exceedMax = isTime
|
|
27499
|
+
? convertTimeToDate(inputValue) > convertTimeToDate(maxOutput.value)
|
|
27500
|
+
: isWeek
|
|
27501
|
+
? inputValue > maxOutput.value
|
|
27502
|
+
: valueDate > new Date(maxOutput.value);
|
|
27503
|
+
}
|
|
27504
|
+
if (isString(minOutput.value) && inputValue) {
|
|
27505
|
+
exceedMin = isTime
|
|
27506
|
+
? convertTimeToDate(inputValue) < convertTimeToDate(minOutput.value)
|
|
27507
|
+
: isWeek
|
|
27508
|
+
? inputValue < minOutput.value
|
|
27509
|
+
: valueDate < new Date(minOutput.value);
|
|
27510
|
+
}
|
|
27511
|
+
}
|
|
27512
|
+
if (exceedMax || exceedMin) {
|
|
27513
|
+
getMinMaxMessage(!!exceedMax, maxOutput.message, minOutput.message, INPUT_VALIDATION_RULES.max, INPUT_VALIDATION_RULES.min);
|
|
27514
|
+
if (!validateAllFieldCriteria) {
|
|
27515
|
+
setCustomValidity(error[name].message);
|
|
27516
|
+
return error;
|
|
27517
|
+
}
|
|
27518
|
+
}
|
|
27519
|
+
}
|
|
27520
|
+
if ((maxLength || minLength) &&
|
|
27521
|
+
!isEmpty &&
|
|
27522
|
+
(isString(inputValue) || (isFieldArray && Array.isArray(inputValue)))) {
|
|
27523
|
+
const maxLengthOutput = getValueAndMessage(maxLength);
|
|
27524
|
+
const minLengthOutput = getValueAndMessage(minLength);
|
|
27525
|
+
const exceedMax = !isNullOrUndefined(maxLengthOutput.value) &&
|
|
27526
|
+
inputValue.length > +maxLengthOutput.value;
|
|
27527
|
+
const exceedMin = !isNullOrUndefined(minLengthOutput.value) &&
|
|
27528
|
+
inputValue.length < +minLengthOutput.value;
|
|
27529
|
+
if (exceedMax || exceedMin) {
|
|
27530
|
+
getMinMaxMessage(exceedMax, maxLengthOutput.message, minLengthOutput.message);
|
|
27531
|
+
if (!validateAllFieldCriteria) {
|
|
27532
|
+
setCustomValidity(error[name].message);
|
|
27533
|
+
return error;
|
|
27534
|
+
}
|
|
27535
|
+
}
|
|
27536
|
+
}
|
|
27537
|
+
if (pattern && !isEmpty && isString(inputValue)) {
|
|
27538
|
+
const { value: patternValue, message } = getValueAndMessage(pattern);
|
|
27539
|
+
if (isRegex(patternValue) && !inputValue.match(patternValue)) {
|
|
27540
|
+
error[name] = {
|
|
27541
|
+
type: INPUT_VALIDATION_RULES.pattern,
|
|
27542
|
+
message,
|
|
27543
|
+
ref,
|
|
27544
|
+
...appendErrorsCurry(INPUT_VALIDATION_RULES.pattern, message),
|
|
27545
|
+
};
|
|
27546
|
+
if (!validateAllFieldCriteria) {
|
|
27547
|
+
setCustomValidity(message);
|
|
27548
|
+
return error;
|
|
27549
|
+
}
|
|
27550
|
+
}
|
|
27551
|
+
}
|
|
27552
|
+
if (validate) {
|
|
27553
|
+
if (isFunction(validate)) {
|
|
27554
|
+
const result = await validate(inputValue, formValues);
|
|
27555
|
+
const validateError = getValidateError(result, inputRef);
|
|
27556
|
+
if (validateError) {
|
|
27557
|
+
error[name] = {
|
|
27558
|
+
...validateError,
|
|
27559
|
+
...appendErrorsCurry(INPUT_VALIDATION_RULES.validate, validateError.message),
|
|
27560
|
+
};
|
|
27561
|
+
if (!validateAllFieldCriteria) {
|
|
27562
|
+
setCustomValidity(validateError.message);
|
|
27563
|
+
return error;
|
|
27564
|
+
}
|
|
27565
|
+
}
|
|
27566
|
+
}
|
|
27567
|
+
else if (isObject(validate)) {
|
|
27568
|
+
let validationResult = {};
|
|
27569
|
+
for (const key in validate) {
|
|
27570
|
+
if (!isEmptyObject(validationResult) && !validateAllFieldCriteria) {
|
|
27571
|
+
break;
|
|
27572
|
+
}
|
|
27573
|
+
const validateError = getValidateError(await validate[key](inputValue, formValues), inputRef, key);
|
|
27574
|
+
if (validateError) {
|
|
27575
|
+
validationResult = {
|
|
27576
|
+
...validateError,
|
|
27577
|
+
...appendErrorsCurry(key, validateError.message),
|
|
27578
|
+
};
|
|
27579
|
+
setCustomValidity(validateError.message);
|
|
27580
|
+
if (validateAllFieldCriteria) {
|
|
27581
|
+
error[name] = validationResult;
|
|
27582
|
+
}
|
|
27583
|
+
}
|
|
27584
|
+
}
|
|
27585
|
+
if (!isEmptyObject(validationResult)) {
|
|
27586
|
+
error[name] = {
|
|
27587
|
+
ref: inputRef,
|
|
27588
|
+
...validationResult,
|
|
27589
|
+
};
|
|
27590
|
+
if (!validateAllFieldCriteria) {
|
|
27591
|
+
return error;
|
|
27592
|
+
}
|
|
27593
|
+
}
|
|
27594
|
+
}
|
|
27595
|
+
}
|
|
27596
|
+
setCustomValidity(true);
|
|
27597
|
+
return error;
|
|
27598
|
+
};
|
|
27599
|
+
|
|
27600
|
+
function baseGet(object, updatePath) {
|
|
27601
|
+
const length = updatePath.slice(0, -1).length;
|
|
27602
|
+
let index = 0;
|
|
27603
|
+
while (index < length) {
|
|
27604
|
+
object = isUndefined(object) ? index++ : object[updatePath[index++]];
|
|
27605
|
+
}
|
|
27606
|
+
return object;
|
|
27607
|
+
}
|
|
27608
|
+
function isEmptyArray(obj) {
|
|
27609
|
+
for (const key in obj) {
|
|
27610
|
+
if (obj.hasOwnProperty(key) && !isUndefined(obj[key])) {
|
|
27611
|
+
return false;
|
|
27612
|
+
}
|
|
27613
|
+
}
|
|
27614
|
+
return true;
|
|
27615
|
+
}
|
|
27616
|
+
function unset(object, path) {
|
|
27617
|
+
const paths = Array.isArray(path)
|
|
27618
|
+
? path
|
|
27619
|
+
: isKey(path)
|
|
27620
|
+
? [path]
|
|
27621
|
+
: stringToPath(path);
|
|
27622
|
+
const childObject = paths.length === 1 ? object : baseGet(object, paths);
|
|
27623
|
+
const index = paths.length - 1;
|
|
27624
|
+
const key = paths[index];
|
|
27625
|
+
if (childObject) {
|
|
27626
|
+
delete childObject[key];
|
|
27627
|
+
}
|
|
27628
|
+
if (index !== 0 &&
|
|
27629
|
+
((isObject(childObject) && isEmptyObject(childObject)) ||
|
|
27630
|
+
(Array.isArray(childObject) && isEmptyArray(childObject)))) {
|
|
27631
|
+
unset(object, paths.slice(0, -1));
|
|
27632
|
+
}
|
|
27633
|
+
return object;
|
|
27634
|
+
}
|
|
27635
|
+
|
|
27636
|
+
var createSubject = () => {
|
|
27637
|
+
let _observers = [];
|
|
27638
|
+
const next = (value) => {
|
|
27639
|
+
for (const observer of _observers) {
|
|
27640
|
+
observer.next && observer.next(value);
|
|
27641
|
+
}
|
|
27642
|
+
};
|
|
27643
|
+
const subscribe = (observer) => {
|
|
27644
|
+
_observers.push(observer);
|
|
27645
|
+
return {
|
|
27646
|
+
unsubscribe: () => {
|
|
27647
|
+
_observers = _observers.filter((o) => o !== observer);
|
|
27648
|
+
},
|
|
27649
|
+
};
|
|
27650
|
+
};
|
|
27651
|
+
const unsubscribe = () => {
|
|
27652
|
+
_observers = [];
|
|
27653
|
+
};
|
|
27654
|
+
return {
|
|
27655
|
+
get observers() {
|
|
27656
|
+
return _observers;
|
|
27657
|
+
},
|
|
27658
|
+
next,
|
|
27659
|
+
subscribe,
|
|
27660
|
+
unsubscribe,
|
|
27661
|
+
};
|
|
27662
|
+
};
|
|
27663
|
+
|
|
27664
|
+
var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
|
|
27665
|
+
|
|
27666
|
+
function deepEqual(object1, object2) {
|
|
27667
|
+
if (isPrimitive(object1) || isPrimitive(object2)) {
|
|
27668
|
+
return object1 === object2;
|
|
27669
|
+
}
|
|
27670
|
+
if (isDateObject(object1) && isDateObject(object2)) {
|
|
27671
|
+
return object1.getTime() === object2.getTime();
|
|
27672
|
+
}
|
|
27673
|
+
const keys1 = Object.keys(object1);
|
|
27674
|
+
const keys2 = Object.keys(object2);
|
|
27675
|
+
if (keys1.length !== keys2.length) {
|
|
27676
|
+
return false;
|
|
27677
|
+
}
|
|
27678
|
+
for (const key of keys1) {
|
|
27679
|
+
const val1 = object1[key];
|
|
27680
|
+
if (!keys2.includes(key)) {
|
|
27681
|
+
return false;
|
|
27682
|
+
}
|
|
27683
|
+
if (key !== 'ref') {
|
|
27684
|
+
const val2 = object2[key];
|
|
27685
|
+
if ((isDateObject(val1) && isDateObject(val2)) ||
|
|
27686
|
+
(isObject(val1) && isObject(val2)) ||
|
|
27687
|
+
(Array.isArray(val1) && Array.isArray(val2))
|
|
27688
|
+
? !deepEqual(val1, val2)
|
|
27689
|
+
: val1 !== val2) {
|
|
27690
|
+
return false;
|
|
27691
|
+
}
|
|
27692
|
+
}
|
|
27693
|
+
}
|
|
27694
|
+
return true;
|
|
27695
|
+
}
|
|
27696
|
+
|
|
27697
|
+
var isMultipleSelect = (element) => element.type === `select-multiple`;
|
|
27698
|
+
|
|
27699
|
+
var isRadioOrCheckbox = (ref) => isRadioInput(ref) || isCheckBoxInput(ref);
|
|
27700
|
+
|
|
27701
|
+
var live = (ref) => isHTMLElement(ref) && ref.isConnected;
|
|
27702
|
+
|
|
27703
|
+
var objectHasFunction = (data) => {
|
|
27704
|
+
for (const key in data) {
|
|
27705
|
+
if (isFunction(data[key])) {
|
|
27706
|
+
return true;
|
|
27707
|
+
}
|
|
27708
|
+
}
|
|
27709
|
+
return false;
|
|
27710
|
+
};
|
|
27711
|
+
|
|
27712
|
+
function markFieldsDirty(data, fields = {}) {
|
|
27713
|
+
const isParentNodeArray = Array.isArray(data);
|
|
27714
|
+
if (isObject(data) || isParentNodeArray) {
|
|
27715
|
+
for (const key in data) {
|
|
27716
|
+
if (Array.isArray(data[key]) ||
|
|
27717
|
+
(isObject(data[key]) && !objectHasFunction(data[key]))) {
|
|
27718
|
+
fields[key] = Array.isArray(data[key]) ? [] : {};
|
|
27719
|
+
markFieldsDirty(data[key], fields[key]);
|
|
27720
|
+
}
|
|
27721
|
+
else if (!isNullOrUndefined(data[key])) {
|
|
27722
|
+
fields[key] = true;
|
|
27723
|
+
}
|
|
27724
|
+
}
|
|
27725
|
+
}
|
|
27726
|
+
return fields;
|
|
27727
|
+
}
|
|
27728
|
+
function getDirtyFieldsFromDefaultValues(data, formValues, dirtyFieldsFromValues) {
|
|
27729
|
+
const isParentNodeArray = Array.isArray(data);
|
|
27730
|
+
if (isObject(data) || isParentNodeArray) {
|
|
27731
|
+
for (const key in data) {
|
|
27732
|
+
if (Array.isArray(data[key]) ||
|
|
27733
|
+
(isObject(data[key]) && !objectHasFunction(data[key]))) {
|
|
27734
|
+
if (isUndefined(formValues) ||
|
|
27735
|
+
isPrimitive(dirtyFieldsFromValues[key])) {
|
|
27736
|
+
dirtyFieldsFromValues[key] = Array.isArray(data[key])
|
|
27737
|
+
? markFieldsDirty(data[key], [])
|
|
27738
|
+
: { ...markFieldsDirty(data[key]) };
|
|
27739
|
+
}
|
|
27740
|
+
else {
|
|
27741
|
+
getDirtyFieldsFromDefaultValues(data[key], isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);
|
|
27742
|
+
}
|
|
27743
|
+
}
|
|
27744
|
+
else {
|
|
27745
|
+
dirtyFieldsFromValues[key] = !deepEqual(data[key], formValues[key]);
|
|
27746
|
+
}
|
|
27747
|
+
}
|
|
27748
|
+
}
|
|
27749
|
+
return dirtyFieldsFromValues;
|
|
27750
|
+
}
|
|
27751
|
+
var getDirtyFields = (defaultValues, formValues) => getDirtyFieldsFromDefaultValues(defaultValues, formValues, markFieldsDirty(formValues));
|
|
27752
|
+
|
|
27753
|
+
var getFieldValueAs = (value, { valueAsNumber, valueAsDate, setValueAs }) => isUndefined(value)
|
|
27754
|
+
? value
|
|
27755
|
+
: valueAsNumber
|
|
27756
|
+
? value === ''
|
|
27757
|
+
? NaN
|
|
27758
|
+
: value
|
|
27759
|
+
? +value
|
|
27760
|
+
: value
|
|
27761
|
+
: valueAsDate && isString(value)
|
|
27762
|
+
? new Date(value)
|
|
27763
|
+
: setValueAs
|
|
27764
|
+
? setValueAs(value)
|
|
27765
|
+
: value;
|
|
27766
|
+
|
|
27767
|
+
function getFieldValue(_f) {
|
|
27768
|
+
const ref = _f.ref;
|
|
27769
|
+
if (_f.refs ? _f.refs.every((ref) => ref.disabled) : ref.disabled) {
|
|
27770
|
+
return;
|
|
27771
|
+
}
|
|
27772
|
+
if (isFileInput(ref)) {
|
|
27773
|
+
return ref.files;
|
|
27774
|
+
}
|
|
27775
|
+
if (isRadioInput(ref)) {
|
|
27776
|
+
return getRadioValue(_f.refs).value;
|
|
27777
|
+
}
|
|
27778
|
+
if (isMultipleSelect(ref)) {
|
|
27779
|
+
return [...ref.selectedOptions].map(({ value }) => value);
|
|
27780
|
+
}
|
|
27781
|
+
if (isCheckBoxInput(ref)) {
|
|
27782
|
+
return getCheckboxValue(_f.refs).value;
|
|
27783
|
+
}
|
|
27784
|
+
return getFieldValueAs(isUndefined(ref.value) ? _f.ref.value : ref.value, _f);
|
|
27785
|
+
}
|
|
27786
|
+
|
|
27787
|
+
var getResolverOptions = (fieldsNames, _fields, criteriaMode, shouldUseNativeValidation) => {
|
|
27788
|
+
const fields = {};
|
|
27789
|
+
for (const name of fieldsNames) {
|
|
27790
|
+
const field = get(_fields, name);
|
|
27791
|
+
field && set(fields, name, field._f);
|
|
27792
|
+
}
|
|
27793
|
+
return {
|
|
27794
|
+
criteriaMode,
|
|
27795
|
+
names: [...fieldsNames],
|
|
27796
|
+
fields,
|
|
27797
|
+
shouldUseNativeValidation,
|
|
27798
|
+
};
|
|
27799
|
+
};
|
|
27800
|
+
|
|
27801
|
+
var getRuleValue = (rule) => isUndefined(rule)
|
|
27802
|
+
? rule
|
|
27803
|
+
: isRegex(rule)
|
|
27804
|
+
? rule.source
|
|
27805
|
+
: isObject(rule)
|
|
27806
|
+
? isRegex(rule.value)
|
|
27807
|
+
? rule.value.source
|
|
27808
|
+
: rule.value
|
|
27809
|
+
: rule;
|
|
27810
|
+
|
|
27811
|
+
var hasValidation = (options) => options.mount &&
|
|
27812
|
+
(options.required ||
|
|
27813
|
+
options.min ||
|
|
27814
|
+
options.max ||
|
|
27815
|
+
options.maxLength ||
|
|
27816
|
+
options.minLength ||
|
|
27817
|
+
options.pattern ||
|
|
27818
|
+
options.validate);
|
|
27819
|
+
|
|
27820
|
+
function schemaErrorLookup(errors, _fields, name) {
|
|
27821
|
+
const error = get(errors, name);
|
|
27822
|
+
if (error || isKey(name)) {
|
|
27823
|
+
return {
|
|
27824
|
+
error,
|
|
27825
|
+
name,
|
|
27826
|
+
};
|
|
27827
|
+
}
|
|
27828
|
+
const names = name.split('.');
|
|
27829
|
+
while (names.length) {
|
|
27830
|
+
const fieldName = names.join('.');
|
|
27831
|
+
const field = get(_fields, fieldName);
|
|
27832
|
+
const foundError = get(errors, fieldName);
|
|
27833
|
+
if (field && !Array.isArray(field) && name !== fieldName) {
|
|
27834
|
+
return { name };
|
|
27835
|
+
}
|
|
27836
|
+
if (foundError && foundError.type) {
|
|
27837
|
+
return {
|
|
27838
|
+
name: fieldName,
|
|
27839
|
+
error: foundError,
|
|
27840
|
+
};
|
|
27841
|
+
}
|
|
27842
|
+
names.pop();
|
|
27843
|
+
}
|
|
27844
|
+
return {
|
|
27845
|
+
name,
|
|
27846
|
+
};
|
|
27847
|
+
}
|
|
27848
|
+
|
|
27849
|
+
var skipValidation = (isBlurEvent, isTouched, isSubmitted, reValidateMode, mode) => {
|
|
27850
|
+
if (mode.isOnAll) {
|
|
27851
|
+
return false;
|
|
27852
|
+
}
|
|
27853
|
+
else if (!isSubmitted && mode.isOnTouch) {
|
|
27854
|
+
return !(isTouched || isBlurEvent);
|
|
27855
|
+
}
|
|
27856
|
+
else if (isSubmitted ? reValidateMode.isOnBlur : mode.isOnBlur) {
|
|
27857
|
+
return !isBlurEvent;
|
|
27858
|
+
}
|
|
27859
|
+
else if (isSubmitted ? reValidateMode.isOnChange : mode.isOnChange) {
|
|
27860
|
+
return isBlurEvent;
|
|
27861
|
+
}
|
|
27862
|
+
return true;
|
|
27863
|
+
};
|
|
27864
|
+
|
|
27865
|
+
var unsetEmptyArray = (ref, name) => !compact(get(ref, name)).length && unset(ref, name);
|
|
27866
|
+
|
|
27867
|
+
const defaultOptions = {
|
|
27868
|
+
mode: VALIDATION_MODE.onSubmit,
|
|
27869
|
+
reValidateMode: VALIDATION_MODE.onChange,
|
|
27870
|
+
shouldFocusError: true,
|
|
27871
|
+
};
|
|
27872
|
+
function createFormControl(props = {}, flushRootRender) {
|
|
27873
|
+
let _options = {
|
|
27874
|
+
...defaultOptions,
|
|
27875
|
+
...props,
|
|
27876
|
+
};
|
|
27877
|
+
let _formState = {
|
|
27878
|
+
submitCount: 0,
|
|
27879
|
+
isDirty: false,
|
|
27880
|
+
isLoading: isFunction(_options.defaultValues),
|
|
27881
|
+
isValidating: false,
|
|
27882
|
+
isSubmitted: false,
|
|
27883
|
+
isSubmitting: false,
|
|
27884
|
+
isSubmitSuccessful: false,
|
|
27885
|
+
isValid: false,
|
|
27886
|
+
touchedFields: {},
|
|
27887
|
+
dirtyFields: {},
|
|
27888
|
+
errors: _options.errors || {},
|
|
27889
|
+
disabled: false,
|
|
27890
|
+
};
|
|
27891
|
+
let _fields = {};
|
|
27892
|
+
let _defaultValues = isObject(_options.defaultValues) || isObject(_options.values)
|
|
27893
|
+
? cloneObject(_options.defaultValues || _options.values) || {}
|
|
27894
|
+
: {};
|
|
27895
|
+
let _formValues = _options.shouldUnregister
|
|
27896
|
+
? {}
|
|
27897
|
+
: cloneObject(_defaultValues);
|
|
27898
|
+
let _state = {
|
|
27899
|
+
action: false,
|
|
27900
|
+
mount: false,
|
|
27901
|
+
watch: false,
|
|
27902
|
+
};
|
|
27903
|
+
let _names = {
|
|
27904
|
+
mount: new Set(),
|
|
27905
|
+
unMount: new Set(),
|
|
27906
|
+
array: new Set(),
|
|
27907
|
+
watch: new Set(),
|
|
27908
|
+
};
|
|
27909
|
+
let delayErrorCallback;
|
|
27910
|
+
let timer = 0;
|
|
27911
|
+
const _proxyFormState = {
|
|
27912
|
+
isDirty: false,
|
|
27913
|
+
dirtyFields: false,
|
|
27914
|
+
touchedFields: false,
|
|
27915
|
+
isValidating: false,
|
|
27916
|
+
isValid: false,
|
|
27917
|
+
errors: false,
|
|
27918
|
+
};
|
|
27919
|
+
const _subjects = {
|
|
27920
|
+
values: createSubject(),
|
|
27921
|
+
array: createSubject(),
|
|
27922
|
+
state: createSubject(),
|
|
27923
|
+
};
|
|
27924
|
+
const shouldCaptureDirtyFields = props.resetOptions && props.resetOptions.keepDirtyValues;
|
|
27925
|
+
const validationModeBeforeSubmit = getValidationModes(_options.mode);
|
|
27926
|
+
const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);
|
|
27927
|
+
const shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;
|
|
27928
|
+
const debounce = (callback) => (wait) => {
|
|
27929
|
+
clearTimeout(timer);
|
|
27930
|
+
timer = setTimeout(callback, wait);
|
|
27931
|
+
};
|
|
27932
|
+
const _updateValid = async (shouldUpdateValid) => {
|
|
27933
|
+
if (_proxyFormState.isValid || shouldUpdateValid) {
|
|
27934
|
+
const isValid = _options.resolver
|
|
27935
|
+
? isEmptyObject((await _executeSchema()).errors)
|
|
27936
|
+
: await executeBuiltInValidation(_fields, true);
|
|
27937
|
+
if (isValid !== _formState.isValid) {
|
|
27938
|
+
_subjects.state.next({
|
|
27939
|
+
isValid,
|
|
27940
|
+
});
|
|
27941
|
+
}
|
|
27942
|
+
}
|
|
27943
|
+
};
|
|
27944
|
+
const _updateIsValidating = (value) => _proxyFormState.isValidating &&
|
|
27945
|
+
_subjects.state.next({
|
|
27946
|
+
isValidating: value,
|
|
27947
|
+
});
|
|
27948
|
+
const _updateFieldArray = (name, values = [], method, args, shouldSetValues = true, shouldUpdateFieldsAndState = true) => {
|
|
27949
|
+
if (args && method) {
|
|
27950
|
+
_state.action = true;
|
|
27951
|
+
if (shouldUpdateFieldsAndState && Array.isArray(get(_fields, name))) {
|
|
27952
|
+
const fieldValues = method(get(_fields, name), args.argA, args.argB);
|
|
27953
|
+
shouldSetValues && set(_fields, name, fieldValues);
|
|
27954
|
+
}
|
|
27955
|
+
if (shouldUpdateFieldsAndState &&
|
|
27956
|
+
Array.isArray(get(_formState.errors, name))) {
|
|
27957
|
+
const errors = method(get(_formState.errors, name), args.argA, args.argB);
|
|
27958
|
+
shouldSetValues && set(_formState.errors, name, errors);
|
|
27959
|
+
unsetEmptyArray(_formState.errors, name);
|
|
27960
|
+
}
|
|
27961
|
+
if (_proxyFormState.touchedFields &&
|
|
27962
|
+
shouldUpdateFieldsAndState &&
|
|
27963
|
+
Array.isArray(get(_formState.touchedFields, name))) {
|
|
27964
|
+
const touchedFields = method(get(_formState.touchedFields, name), args.argA, args.argB);
|
|
27965
|
+
shouldSetValues && set(_formState.touchedFields, name, touchedFields);
|
|
27966
|
+
}
|
|
27967
|
+
if (_proxyFormState.dirtyFields) {
|
|
27968
|
+
_formState.dirtyFields = getDirtyFields(_defaultValues, _formValues);
|
|
27969
|
+
}
|
|
27970
|
+
_subjects.state.next({
|
|
27971
|
+
name,
|
|
27972
|
+
isDirty: _getDirty(name, values),
|
|
27973
|
+
dirtyFields: _formState.dirtyFields,
|
|
27974
|
+
errors: _formState.errors,
|
|
27975
|
+
isValid: _formState.isValid,
|
|
27976
|
+
});
|
|
27977
|
+
}
|
|
27978
|
+
else {
|
|
27979
|
+
set(_formValues, name, values);
|
|
27980
|
+
}
|
|
27981
|
+
};
|
|
27982
|
+
const updateErrors = (name, error) => {
|
|
27983
|
+
set(_formState.errors, name, error);
|
|
27984
|
+
_subjects.state.next({
|
|
27985
|
+
errors: _formState.errors,
|
|
27986
|
+
});
|
|
27987
|
+
};
|
|
27988
|
+
const _setErrors = (errors) => {
|
|
27989
|
+
_formState.errors = errors;
|
|
27990
|
+
_subjects.state.next({
|
|
27991
|
+
errors: _formState.errors,
|
|
27992
|
+
isValid: false,
|
|
27993
|
+
});
|
|
27994
|
+
};
|
|
27995
|
+
const updateValidAndValue = (name, shouldSkipSetValueAs, value, ref) => {
|
|
27996
|
+
const field = get(_fields, name);
|
|
27997
|
+
if (field) {
|
|
27998
|
+
const defaultValue = get(_formValues, name, isUndefined(value) ? get(_defaultValues, name) : value);
|
|
27999
|
+
isUndefined(defaultValue) ||
|
|
28000
|
+
(ref && ref.defaultChecked) ||
|
|
28001
|
+
shouldSkipSetValueAs
|
|
28002
|
+
? set(_formValues, name, shouldSkipSetValueAs ? defaultValue : getFieldValue(field._f))
|
|
28003
|
+
: setFieldValue(name, defaultValue);
|
|
28004
|
+
_state.mount && _updateValid();
|
|
28005
|
+
}
|
|
28006
|
+
};
|
|
28007
|
+
const updateTouchAndDirty = (name, fieldValue, isBlurEvent, shouldDirty, shouldRender) => {
|
|
28008
|
+
let shouldUpdateField = false;
|
|
28009
|
+
let isPreviousDirty = false;
|
|
28010
|
+
const output = {
|
|
28011
|
+
name,
|
|
28012
|
+
};
|
|
28013
|
+
const disabledField = !!(get(_fields, name) && get(_fields, name)._f.disabled);
|
|
28014
|
+
if (!isBlurEvent || shouldDirty) {
|
|
28015
|
+
if (_proxyFormState.isDirty) {
|
|
28016
|
+
isPreviousDirty = _formState.isDirty;
|
|
28017
|
+
_formState.isDirty = output.isDirty = _getDirty();
|
|
28018
|
+
shouldUpdateField = isPreviousDirty !== output.isDirty;
|
|
28019
|
+
}
|
|
28020
|
+
const isCurrentFieldPristine = disabledField || deepEqual(get(_defaultValues, name), fieldValue);
|
|
28021
|
+
isPreviousDirty = !!(!disabledField && get(_formState.dirtyFields, name));
|
|
28022
|
+
isCurrentFieldPristine || disabledField
|
|
28023
|
+
? unset(_formState.dirtyFields, name)
|
|
28024
|
+
: set(_formState.dirtyFields, name, true);
|
|
28025
|
+
output.dirtyFields = _formState.dirtyFields;
|
|
28026
|
+
shouldUpdateField =
|
|
28027
|
+
shouldUpdateField ||
|
|
28028
|
+
(_proxyFormState.dirtyFields &&
|
|
28029
|
+
isPreviousDirty !== !isCurrentFieldPristine);
|
|
28030
|
+
}
|
|
28031
|
+
if (isBlurEvent) {
|
|
28032
|
+
const isPreviousFieldTouched = get(_formState.touchedFields, name);
|
|
28033
|
+
if (!isPreviousFieldTouched) {
|
|
28034
|
+
set(_formState.touchedFields, name, isBlurEvent);
|
|
28035
|
+
output.touchedFields = _formState.touchedFields;
|
|
28036
|
+
shouldUpdateField =
|
|
28037
|
+
shouldUpdateField ||
|
|
28038
|
+
(_proxyFormState.touchedFields &&
|
|
28039
|
+
isPreviousFieldTouched !== isBlurEvent);
|
|
28040
|
+
}
|
|
28041
|
+
}
|
|
28042
|
+
shouldUpdateField && shouldRender && _subjects.state.next(output);
|
|
28043
|
+
return shouldUpdateField ? output : {};
|
|
28044
|
+
};
|
|
28045
|
+
const shouldRenderByError = (name, isValid, error, fieldState) => {
|
|
28046
|
+
const previousFieldError = get(_formState.errors, name);
|
|
28047
|
+
const shouldUpdateValid = _proxyFormState.isValid &&
|
|
28048
|
+
isBoolean(isValid) &&
|
|
28049
|
+
_formState.isValid !== isValid;
|
|
28050
|
+
if (props.delayError && error) {
|
|
28051
|
+
delayErrorCallback = debounce(() => updateErrors(name, error));
|
|
28052
|
+
delayErrorCallback(props.delayError);
|
|
28053
|
+
}
|
|
28054
|
+
else {
|
|
28055
|
+
clearTimeout(timer);
|
|
28056
|
+
delayErrorCallback = null;
|
|
28057
|
+
error
|
|
28058
|
+
? set(_formState.errors, name, error)
|
|
28059
|
+
: unset(_formState.errors, name);
|
|
28060
|
+
}
|
|
28061
|
+
if ((error ? !deepEqual(previousFieldError, error) : previousFieldError) ||
|
|
28062
|
+
!isEmptyObject(fieldState) ||
|
|
28063
|
+
shouldUpdateValid) {
|
|
28064
|
+
const updatedFormState = {
|
|
28065
|
+
...fieldState,
|
|
28066
|
+
...(shouldUpdateValid && isBoolean(isValid) ? { isValid } : {}),
|
|
28067
|
+
errors: _formState.errors,
|
|
28068
|
+
name,
|
|
28069
|
+
};
|
|
28070
|
+
_formState = {
|
|
28071
|
+
..._formState,
|
|
28072
|
+
...updatedFormState,
|
|
28073
|
+
};
|
|
28074
|
+
_subjects.state.next(updatedFormState);
|
|
28075
|
+
}
|
|
28076
|
+
_updateIsValidating(false);
|
|
28077
|
+
};
|
|
28078
|
+
const _executeSchema = async (name) => _options.resolver(_formValues, _options.context, getResolverOptions(name || _names.mount, _fields, _options.criteriaMode, _options.shouldUseNativeValidation));
|
|
28079
|
+
const executeSchemaAndUpdateState = async (names) => {
|
|
28080
|
+
const { errors } = await _executeSchema(names);
|
|
28081
|
+
if (names) {
|
|
28082
|
+
for (const name of names) {
|
|
28083
|
+
const error = get(errors, name);
|
|
28084
|
+
error
|
|
28085
|
+
? set(_formState.errors, name, error)
|
|
28086
|
+
: unset(_formState.errors, name);
|
|
28087
|
+
}
|
|
28088
|
+
}
|
|
28089
|
+
else {
|
|
28090
|
+
_formState.errors = errors;
|
|
28091
|
+
}
|
|
28092
|
+
return errors;
|
|
28093
|
+
};
|
|
28094
|
+
const executeBuiltInValidation = async (fields, shouldOnlyCheckValid, context = {
|
|
28095
|
+
valid: true,
|
|
28096
|
+
}) => {
|
|
28097
|
+
for (const name in fields) {
|
|
28098
|
+
const field = fields[name];
|
|
28099
|
+
if (field) {
|
|
28100
|
+
const { _f, ...fieldValue } = field;
|
|
28101
|
+
if (_f) {
|
|
28102
|
+
const isFieldArrayRoot = _names.array.has(_f.name);
|
|
28103
|
+
const fieldError = await validateField(field, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation && !shouldOnlyCheckValid, isFieldArrayRoot);
|
|
28104
|
+
if (fieldError[_f.name]) {
|
|
28105
|
+
context.valid = false;
|
|
28106
|
+
if (shouldOnlyCheckValid) {
|
|
28107
|
+
break;
|
|
28108
|
+
}
|
|
28109
|
+
}
|
|
28110
|
+
!shouldOnlyCheckValid &&
|
|
28111
|
+
(get(fieldError, _f.name)
|
|
28112
|
+
? isFieldArrayRoot
|
|
28113
|
+
? updateFieldArrayRootError(_formState.errors, fieldError, _f.name)
|
|
28114
|
+
: set(_formState.errors, _f.name, fieldError[_f.name])
|
|
28115
|
+
: unset(_formState.errors, _f.name));
|
|
28116
|
+
}
|
|
28117
|
+
fieldValue &&
|
|
28118
|
+
(await executeBuiltInValidation(fieldValue, shouldOnlyCheckValid, context));
|
|
28119
|
+
}
|
|
28120
|
+
}
|
|
28121
|
+
return context.valid;
|
|
28122
|
+
};
|
|
28123
|
+
const _removeUnmounted = () => {
|
|
28124
|
+
for (const name of _names.unMount) {
|
|
28125
|
+
const field = get(_fields, name);
|
|
28126
|
+
field &&
|
|
28127
|
+
(field._f.refs
|
|
28128
|
+
? field._f.refs.every((ref) => !live(ref))
|
|
28129
|
+
: !live(field._f.ref)) &&
|
|
28130
|
+
unregister(name);
|
|
28131
|
+
}
|
|
28132
|
+
_names.unMount = new Set();
|
|
28133
|
+
};
|
|
28134
|
+
const _getDirty = (name, data) => (name && data && set(_formValues, name, data),
|
|
28135
|
+
!deepEqual(getValues(), _defaultValues));
|
|
28136
|
+
const _getWatch = (names, defaultValue, isGlobal) => generateWatchOutput(names, _names, {
|
|
28137
|
+
...(_state.mount
|
|
28138
|
+
? _formValues
|
|
28139
|
+
: isUndefined(defaultValue)
|
|
28140
|
+
? _defaultValues
|
|
28141
|
+
: isString(names)
|
|
28142
|
+
? { [names]: defaultValue }
|
|
28143
|
+
: defaultValue),
|
|
28144
|
+
}, isGlobal, defaultValue);
|
|
28145
|
+
const _getFieldArray = (name) => compact(get(_state.mount ? _formValues : _defaultValues, name, props.shouldUnregister ? get(_defaultValues, name, []) : []));
|
|
28146
|
+
const setFieldValue = (name, value, options = {}) => {
|
|
28147
|
+
const field = get(_fields, name);
|
|
28148
|
+
let fieldValue = value;
|
|
28149
|
+
if (field) {
|
|
28150
|
+
const fieldReference = field._f;
|
|
28151
|
+
if (fieldReference) {
|
|
28152
|
+
!fieldReference.disabled &&
|
|
28153
|
+
set(_formValues, name, getFieldValueAs(value, fieldReference));
|
|
28154
|
+
fieldValue =
|
|
28155
|
+
isHTMLElement(fieldReference.ref) && isNullOrUndefined(value)
|
|
28156
|
+
? ''
|
|
28157
|
+
: value;
|
|
28158
|
+
if (isMultipleSelect(fieldReference.ref)) {
|
|
28159
|
+
[...fieldReference.ref.options].forEach((optionRef) => (optionRef.selected = fieldValue.includes(optionRef.value)));
|
|
28160
|
+
}
|
|
28161
|
+
else if (fieldReference.refs) {
|
|
28162
|
+
if (isCheckBoxInput(fieldReference.ref)) {
|
|
28163
|
+
fieldReference.refs.length > 1
|
|
28164
|
+
? fieldReference.refs.forEach((checkboxRef) => (!checkboxRef.defaultChecked || !checkboxRef.disabled) &&
|
|
28165
|
+
(checkboxRef.checked = Array.isArray(fieldValue)
|
|
28166
|
+
? !!fieldValue.find((data) => data === checkboxRef.value)
|
|
28167
|
+
: fieldValue === checkboxRef.value))
|
|
28168
|
+
: fieldReference.refs[0] &&
|
|
28169
|
+
(fieldReference.refs[0].checked = !!fieldValue);
|
|
28170
|
+
}
|
|
28171
|
+
else {
|
|
28172
|
+
fieldReference.refs.forEach((radioRef) => (radioRef.checked = radioRef.value === fieldValue));
|
|
28173
|
+
}
|
|
28174
|
+
}
|
|
28175
|
+
else if (isFileInput(fieldReference.ref)) {
|
|
28176
|
+
fieldReference.ref.value = '';
|
|
28177
|
+
}
|
|
28178
|
+
else {
|
|
28179
|
+
fieldReference.ref.value = fieldValue;
|
|
28180
|
+
if (!fieldReference.ref.type) {
|
|
28181
|
+
_subjects.values.next({
|
|
28182
|
+
name,
|
|
28183
|
+
values: { ..._formValues },
|
|
28184
|
+
});
|
|
28185
|
+
}
|
|
28186
|
+
}
|
|
28187
|
+
}
|
|
28188
|
+
}
|
|
28189
|
+
(options.shouldDirty || options.shouldTouch) &&
|
|
28190
|
+
updateTouchAndDirty(name, fieldValue, options.shouldTouch, options.shouldDirty, true);
|
|
28191
|
+
options.shouldValidate && trigger(name);
|
|
28192
|
+
};
|
|
28193
|
+
const setValues = (name, value, options) => {
|
|
28194
|
+
for (const fieldKey in value) {
|
|
28195
|
+
const fieldValue = value[fieldKey];
|
|
28196
|
+
const fieldName = `${name}.${fieldKey}`;
|
|
28197
|
+
const field = get(_fields, fieldName);
|
|
28198
|
+
(_names.array.has(name) ||
|
|
28199
|
+
!isPrimitive(fieldValue) ||
|
|
28200
|
+
(field && !field._f)) &&
|
|
28201
|
+
!isDateObject(fieldValue)
|
|
28202
|
+
? setValues(fieldName, fieldValue, options)
|
|
28203
|
+
: setFieldValue(fieldName, fieldValue, options);
|
|
28204
|
+
}
|
|
28205
|
+
};
|
|
28206
|
+
const setValue = (name, value, options = {}) => {
|
|
28207
|
+
const field = get(_fields, name);
|
|
28208
|
+
const isFieldArray = _names.array.has(name);
|
|
28209
|
+
const cloneValue = cloneObject(value);
|
|
28210
|
+
set(_formValues, name, cloneValue);
|
|
28211
|
+
if (isFieldArray) {
|
|
28212
|
+
_subjects.array.next({
|
|
28213
|
+
name,
|
|
28214
|
+
values: { ..._formValues },
|
|
28215
|
+
});
|
|
28216
|
+
if ((_proxyFormState.isDirty || _proxyFormState.dirtyFields) &&
|
|
28217
|
+
options.shouldDirty) {
|
|
28218
|
+
_subjects.state.next({
|
|
28219
|
+
name,
|
|
28220
|
+
dirtyFields: getDirtyFields(_defaultValues, _formValues),
|
|
28221
|
+
isDirty: _getDirty(name, cloneValue),
|
|
28222
|
+
});
|
|
28223
|
+
}
|
|
28224
|
+
}
|
|
28225
|
+
else {
|
|
28226
|
+
field && !field._f && !isNullOrUndefined(cloneValue)
|
|
28227
|
+
? setValues(name, cloneValue, options)
|
|
28228
|
+
: setFieldValue(name, cloneValue, options);
|
|
28229
|
+
}
|
|
28230
|
+
isWatched(name, _names) && _subjects.state.next({ ..._formState });
|
|
28231
|
+
_subjects.values.next({
|
|
28232
|
+
name,
|
|
28233
|
+
values: { ..._formValues },
|
|
28234
|
+
});
|
|
28235
|
+
!_state.mount && flushRootRender();
|
|
28236
|
+
};
|
|
28237
|
+
const onChange = async (event) => {
|
|
28238
|
+
const target = event.target;
|
|
28239
|
+
let name = target.name;
|
|
28240
|
+
let isFieldValueUpdated = true;
|
|
28241
|
+
const field = get(_fields, name);
|
|
28242
|
+
const getCurrentFieldValue = () => target.type ? getFieldValue(field._f) : getEventValue(event);
|
|
28243
|
+
const _updateIsFieldValueUpdated = (fieldValue) => {
|
|
28244
|
+
isFieldValueUpdated =
|
|
28245
|
+
Number.isNaN(fieldValue) ||
|
|
28246
|
+
fieldValue === get(_formValues, name, fieldValue);
|
|
28247
|
+
};
|
|
28248
|
+
if (field) {
|
|
28249
|
+
let error;
|
|
28250
|
+
let isValid;
|
|
28251
|
+
const fieldValue = getCurrentFieldValue();
|
|
28252
|
+
const isBlurEvent = event.type === EVENTS.BLUR || event.type === EVENTS.FOCUS_OUT;
|
|
28253
|
+
const shouldSkipValidation = (!hasValidation(field._f) &&
|
|
28254
|
+
!_options.resolver &&
|
|
28255
|
+
!get(_formState.errors, name) &&
|
|
28256
|
+
!field._f.deps) ||
|
|
28257
|
+
skipValidation(isBlurEvent, get(_formState.touchedFields, name), _formState.isSubmitted, validationModeAfterSubmit, validationModeBeforeSubmit);
|
|
28258
|
+
const watched = isWatched(name, _names, isBlurEvent);
|
|
28259
|
+
set(_formValues, name, fieldValue);
|
|
28260
|
+
if (isBlurEvent) {
|
|
28261
|
+
field._f.onBlur && field._f.onBlur(event);
|
|
28262
|
+
delayErrorCallback && delayErrorCallback(0);
|
|
28263
|
+
}
|
|
28264
|
+
else if (field._f.onChange) {
|
|
28265
|
+
field._f.onChange(event);
|
|
28266
|
+
}
|
|
28267
|
+
const fieldState = updateTouchAndDirty(name, fieldValue, isBlurEvent, false);
|
|
28268
|
+
const shouldRender = !isEmptyObject(fieldState) || watched;
|
|
28269
|
+
!isBlurEvent &&
|
|
28270
|
+
_subjects.values.next({
|
|
28271
|
+
name,
|
|
28272
|
+
type: event.type,
|
|
28273
|
+
values: { ..._formValues },
|
|
28274
|
+
});
|
|
28275
|
+
if (shouldSkipValidation) {
|
|
28276
|
+
_proxyFormState.isValid && _updateValid();
|
|
28277
|
+
return (shouldRender &&
|
|
28278
|
+
_subjects.state.next({ name, ...(watched ? {} : fieldState) }));
|
|
28279
|
+
}
|
|
28280
|
+
!isBlurEvent && watched && _subjects.state.next({ ..._formState });
|
|
28281
|
+
_updateIsValidating(true);
|
|
28282
|
+
if (_options.resolver) {
|
|
28283
|
+
const { errors } = await _executeSchema([name]);
|
|
28284
|
+
_updateIsFieldValueUpdated(fieldValue);
|
|
28285
|
+
if (isFieldValueUpdated) {
|
|
28286
|
+
const previousErrorLookupResult = schemaErrorLookup(_formState.errors, _fields, name);
|
|
28287
|
+
const errorLookupResult = schemaErrorLookup(errors, _fields, previousErrorLookupResult.name || name);
|
|
28288
|
+
error = errorLookupResult.error;
|
|
28289
|
+
name = errorLookupResult.name;
|
|
28290
|
+
isValid = isEmptyObject(errors);
|
|
28291
|
+
}
|
|
28292
|
+
}
|
|
28293
|
+
else {
|
|
28294
|
+
error = (await validateField(field, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation))[name];
|
|
28295
|
+
_updateIsFieldValueUpdated(fieldValue);
|
|
28296
|
+
if (isFieldValueUpdated) {
|
|
28297
|
+
if (error) {
|
|
28298
|
+
isValid = false;
|
|
28299
|
+
}
|
|
28300
|
+
else if (_proxyFormState.isValid) {
|
|
28301
|
+
isValid = await executeBuiltInValidation(_fields, true);
|
|
28302
|
+
}
|
|
28303
|
+
}
|
|
28304
|
+
}
|
|
28305
|
+
if (isFieldValueUpdated) {
|
|
28306
|
+
field._f.deps &&
|
|
28307
|
+
trigger(field._f.deps);
|
|
28308
|
+
shouldRenderByError(name, isValid, error, fieldState);
|
|
28309
|
+
}
|
|
28310
|
+
}
|
|
28311
|
+
};
|
|
28312
|
+
const _focusInput = (ref, key) => {
|
|
28313
|
+
if (get(_formState.errors, key) && ref.focus) {
|
|
28314
|
+
ref.focus();
|
|
28315
|
+
return 1;
|
|
28316
|
+
}
|
|
28317
|
+
return;
|
|
28318
|
+
};
|
|
28319
|
+
const trigger = async (name, options = {}) => {
|
|
28320
|
+
let isValid;
|
|
28321
|
+
let validationResult;
|
|
28322
|
+
const fieldNames = convertToArrayPayload(name);
|
|
28323
|
+
_updateIsValidating(true);
|
|
28324
|
+
if (_options.resolver) {
|
|
28325
|
+
const errors = await executeSchemaAndUpdateState(isUndefined(name) ? name : fieldNames);
|
|
28326
|
+
isValid = isEmptyObject(errors);
|
|
28327
|
+
validationResult = name
|
|
28328
|
+
? !fieldNames.some((name) => get(errors, name))
|
|
28329
|
+
: isValid;
|
|
28330
|
+
}
|
|
28331
|
+
else if (name) {
|
|
28332
|
+
validationResult = (await Promise.all(fieldNames.map(async (fieldName) => {
|
|
28333
|
+
const field = get(_fields, fieldName);
|
|
28334
|
+
return await executeBuiltInValidation(field && field._f ? { [fieldName]: field } : field);
|
|
28335
|
+
}))).every(Boolean);
|
|
28336
|
+
!(!validationResult && !_formState.isValid) && _updateValid();
|
|
28337
|
+
}
|
|
28338
|
+
else {
|
|
28339
|
+
validationResult = isValid = await executeBuiltInValidation(_fields);
|
|
28340
|
+
}
|
|
28341
|
+
_subjects.state.next({
|
|
28342
|
+
...(!isString(name) ||
|
|
28343
|
+
(_proxyFormState.isValid && isValid !== _formState.isValid)
|
|
28344
|
+
? {}
|
|
28345
|
+
: { name }),
|
|
28346
|
+
...(_options.resolver || !name ? { isValid } : {}),
|
|
28347
|
+
errors: _formState.errors,
|
|
28348
|
+
isValidating: false,
|
|
28349
|
+
});
|
|
28350
|
+
options.shouldFocus &&
|
|
28351
|
+
!validationResult &&
|
|
28352
|
+
iterateFieldsByAction(_fields, _focusInput, name ? fieldNames : _names.mount);
|
|
28353
|
+
return validationResult;
|
|
28354
|
+
};
|
|
28355
|
+
const getValues = (fieldNames) => {
|
|
28356
|
+
const values = {
|
|
28357
|
+
..._defaultValues,
|
|
28358
|
+
...(_state.mount ? _formValues : {}),
|
|
28359
|
+
};
|
|
28360
|
+
return isUndefined(fieldNames)
|
|
28361
|
+
? values
|
|
28362
|
+
: isString(fieldNames)
|
|
28363
|
+
? get(values, fieldNames)
|
|
28364
|
+
: fieldNames.map((name) => get(values, name));
|
|
28365
|
+
};
|
|
28366
|
+
const getFieldState = (name, formState) => ({
|
|
28367
|
+
invalid: !!get((formState || _formState).errors, name),
|
|
28368
|
+
isDirty: !!get((formState || _formState).dirtyFields, name),
|
|
28369
|
+
isTouched: !!get((formState || _formState).touchedFields, name),
|
|
28370
|
+
error: get((formState || _formState).errors, name),
|
|
28371
|
+
});
|
|
28372
|
+
const clearErrors = (name) => {
|
|
28373
|
+
name &&
|
|
28374
|
+
convertToArrayPayload(name).forEach((inputName) => unset(_formState.errors, inputName));
|
|
28375
|
+
_subjects.state.next({
|
|
28376
|
+
errors: name ? _formState.errors : {},
|
|
28377
|
+
});
|
|
28378
|
+
};
|
|
28379
|
+
const setError = (name, error, options) => {
|
|
28380
|
+
const ref = (get(_fields, name, { _f: {} })._f || {}).ref;
|
|
28381
|
+
set(_formState.errors, name, {
|
|
28382
|
+
...error,
|
|
28383
|
+
ref,
|
|
28384
|
+
});
|
|
28385
|
+
_subjects.state.next({
|
|
28386
|
+
name,
|
|
28387
|
+
errors: _formState.errors,
|
|
28388
|
+
isValid: false,
|
|
28389
|
+
});
|
|
28390
|
+
options && options.shouldFocus && ref && ref.focus && ref.focus();
|
|
28391
|
+
};
|
|
28392
|
+
const watch = (name, defaultValue) => isFunction(name)
|
|
28393
|
+
? _subjects.values.subscribe({
|
|
28394
|
+
next: (payload) => name(_getWatch(undefined, defaultValue), payload),
|
|
28395
|
+
})
|
|
28396
|
+
: _getWatch(name, defaultValue, true);
|
|
28397
|
+
const unregister = (name, options = {}) => {
|
|
28398
|
+
for (const fieldName of name ? convertToArrayPayload(name) : _names.mount) {
|
|
28399
|
+
_names.mount.delete(fieldName);
|
|
28400
|
+
_names.array.delete(fieldName);
|
|
28401
|
+
if (!options.keepValue) {
|
|
28402
|
+
unset(_fields, fieldName);
|
|
28403
|
+
unset(_formValues, fieldName);
|
|
28404
|
+
}
|
|
28405
|
+
!options.keepError && unset(_formState.errors, fieldName);
|
|
28406
|
+
!options.keepDirty && unset(_formState.dirtyFields, fieldName);
|
|
28407
|
+
!options.keepTouched && unset(_formState.touchedFields, fieldName);
|
|
28408
|
+
!_options.shouldUnregister &&
|
|
28409
|
+
!options.keepDefaultValue &&
|
|
28410
|
+
unset(_defaultValues, fieldName);
|
|
28411
|
+
}
|
|
28412
|
+
_subjects.values.next({
|
|
28413
|
+
values: { ..._formValues },
|
|
28414
|
+
});
|
|
28415
|
+
_subjects.state.next({
|
|
28416
|
+
..._formState,
|
|
28417
|
+
...(!options.keepDirty ? {} : { isDirty: _getDirty() }),
|
|
28418
|
+
});
|
|
28419
|
+
!options.keepIsValid && _updateValid();
|
|
28420
|
+
};
|
|
28421
|
+
const _updateDisabledField = ({ disabled, name, field, fields, value, }) => {
|
|
28422
|
+
if (isBoolean(disabled)) {
|
|
28423
|
+
const inputValue = disabled
|
|
28424
|
+
? undefined
|
|
28425
|
+
: isUndefined(value)
|
|
28426
|
+
? getFieldValue(field ? field._f : get(fields, name)._f)
|
|
28427
|
+
: value;
|
|
28428
|
+
set(_formValues, name, inputValue);
|
|
28429
|
+
updateTouchAndDirty(name, inputValue, false, false, true);
|
|
28430
|
+
}
|
|
28431
|
+
};
|
|
28432
|
+
const register = (name, options = {}) => {
|
|
28433
|
+
let field = get(_fields, name);
|
|
28434
|
+
const disabledIsDefined = isBoolean(options.disabled);
|
|
28435
|
+
set(_fields, name, {
|
|
28436
|
+
...(field || {}),
|
|
28437
|
+
_f: {
|
|
28438
|
+
...(field && field._f ? field._f : { ref: { name } }),
|
|
28439
|
+
name,
|
|
28440
|
+
mount: true,
|
|
28441
|
+
...options,
|
|
28442
|
+
},
|
|
28443
|
+
});
|
|
28444
|
+
_names.mount.add(name);
|
|
28445
|
+
if (field) {
|
|
28446
|
+
_updateDisabledField({
|
|
28447
|
+
field,
|
|
28448
|
+
disabled: options.disabled,
|
|
28449
|
+
name,
|
|
28450
|
+
value: options.value,
|
|
28451
|
+
});
|
|
28452
|
+
}
|
|
28453
|
+
else {
|
|
28454
|
+
updateValidAndValue(name, true, options.value);
|
|
28455
|
+
}
|
|
28456
|
+
return {
|
|
28457
|
+
...(disabledIsDefined ? { disabled: options.disabled } : {}),
|
|
28458
|
+
...(_options.progressive
|
|
28459
|
+
? {
|
|
28460
|
+
required: !!options.required,
|
|
28461
|
+
min: getRuleValue(options.min),
|
|
28462
|
+
max: getRuleValue(options.max),
|
|
28463
|
+
minLength: getRuleValue(options.minLength),
|
|
28464
|
+
maxLength: getRuleValue(options.maxLength),
|
|
28465
|
+
pattern: getRuleValue(options.pattern),
|
|
28466
|
+
}
|
|
28467
|
+
: {}),
|
|
28468
|
+
name,
|
|
28469
|
+
onChange,
|
|
28470
|
+
onBlur: onChange,
|
|
28471
|
+
ref: (ref) => {
|
|
28472
|
+
if (ref) {
|
|
28473
|
+
register(name, options);
|
|
28474
|
+
field = get(_fields, name);
|
|
28475
|
+
const fieldRef = isUndefined(ref.value)
|
|
28476
|
+
? ref.querySelectorAll
|
|
28477
|
+
? ref.querySelectorAll('input,select,textarea')[0] || ref
|
|
28478
|
+
: ref
|
|
28479
|
+
: ref;
|
|
28480
|
+
const radioOrCheckbox = isRadioOrCheckbox(fieldRef);
|
|
28481
|
+
const refs = field._f.refs || [];
|
|
28482
|
+
if (radioOrCheckbox
|
|
28483
|
+
? refs.find((option) => option === fieldRef)
|
|
28484
|
+
: fieldRef === field._f.ref) {
|
|
28485
|
+
return;
|
|
28486
|
+
}
|
|
28487
|
+
set(_fields, name, {
|
|
28488
|
+
_f: {
|
|
28489
|
+
...field._f,
|
|
28490
|
+
...(radioOrCheckbox
|
|
28491
|
+
? {
|
|
28492
|
+
refs: [
|
|
28493
|
+
...refs.filter(live),
|
|
28494
|
+
fieldRef,
|
|
28495
|
+
...(Array.isArray(get(_defaultValues, name)) ? [{}] : []),
|
|
28496
|
+
],
|
|
28497
|
+
ref: { type: fieldRef.type, name },
|
|
28498
|
+
}
|
|
28499
|
+
: { ref: fieldRef }),
|
|
28500
|
+
},
|
|
28501
|
+
});
|
|
28502
|
+
updateValidAndValue(name, false, undefined, fieldRef);
|
|
28503
|
+
}
|
|
28504
|
+
else {
|
|
28505
|
+
field = get(_fields, name, {});
|
|
28506
|
+
if (field._f) {
|
|
28507
|
+
field._f.mount = false;
|
|
28508
|
+
}
|
|
28509
|
+
(_options.shouldUnregister || options.shouldUnregister) &&
|
|
28510
|
+
!(isNameInFieldArray(_names.array, name) && _state.action) &&
|
|
28511
|
+
_names.unMount.add(name);
|
|
28512
|
+
}
|
|
28513
|
+
},
|
|
28514
|
+
};
|
|
28515
|
+
};
|
|
28516
|
+
const _focusError = () => _options.shouldFocusError &&
|
|
28517
|
+
iterateFieldsByAction(_fields, _focusInput, _names.mount);
|
|
28518
|
+
const _disableForm = (disabled) => {
|
|
28519
|
+
if (isBoolean(disabled)) {
|
|
28520
|
+
_subjects.state.next({ disabled });
|
|
28521
|
+
iterateFieldsByAction(_fields, (ref, name) => {
|
|
28522
|
+
let requiredDisabledState = disabled;
|
|
28523
|
+
const currentField = get(_fields, name);
|
|
28524
|
+
if (currentField && isBoolean(currentField._f.disabled)) {
|
|
28525
|
+
requiredDisabledState || (requiredDisabledState = currentField._f.disabled);
|
|
28526
|
+
}
|
|
28527
|
+
ref.disabled = requiredDisabledState;
|
|
28528
|
+
}, 0, false);
|
|
28529
|
+
}
|
|
28530
|
+
};
|
|
28531
|
+
const handleSubmit = (onValid, onInvalid) => async (e) => {
|
|
28532
|
+
if (e) {
|
|
28533
|
+
e.preventDefault && e.preventDefault();
|
|
28534
|
+
e.persist && e.persist();
|
|
28535
|
+
}
|
|
28536
|
+
let fieldValues = cloneObject(_formValues);
|
|
28537
|
+
_subjects.state.next({
|
|
28538
|
+
isSubmitting: true,
|
|
28539
|
+
});
|
|
28540
|
+
if (_options.resolver) {
|
|
28541
|
+
const { errors, values } = await _executeSchema();
|
|
28542
|
+
_formState.errors = errors;
|
|
28543
|
+
fieldValues = values;
|
|
28544
|
+
}
|
|
28545
|
+
else {
|
|
28546
|
+
await executeBuiltInValidation(_fields);
|
|
28547
|
+
}
|
|
28548
|
+
unset(_formState.errors, 'root');
|
|
28549
|
+
if (isEmptyObject(_formState.errors)) {
|
|
28550
|
+
_subjects.state.next({
|
|
28551
|
+
errors: {},
|
|
28552
|
+
});
|
|
28553
|
+
await onValid(fieldValues, e);
|
|
28554
|
+
}
|
|
28555
|
+
else {
|
|
28556
|
+
if (onInvalid) {
|
|
28557
|
+
await onInvalid({ ..._formState.errors }, e);
|
|
28558
|
+
}
|
|
28559
|
+
_focusError();
|
|
28560
|
+
setTimeout(_focusError);
|
|
28561
|
+
}
|
|
28562
|
+
_subjects.state.next({
|
|
28563
|
+
isSubmitted: true,
|
|
28564
|
+
isSubmitting: false,
|
|
28565
|
+
isSubmitSuccessful: isEmptyObject(_formState.errors),
|
|
28566
|
+
submitCount: _formState.submitCount + 1,
|
|
28567
|
+
errors: _formState.errors,
|
|
28568
|
+
});
|
|
28569
|
+
};
|
|
28570
|
+
const resetField = (name, options = {}) => {
|
|
28571
|
+
if (get(_fields, name)) {
|
|
28572
|
+
if (isUndefined(options.defaultValue)) {
|
|
28573
|
+
setValue(name, get(_defaultValues, name));
|
|
28574
|
+
}
|
|
28575
|
+
else {
|
|
28576
|
+
setValue(name, options.defaultValue);
|
|
28577
|
+
set(_defaultValues, name, options.defaultValue);
|
|
28578
|
+
}
|
|
28579
|
+
if (!options.keepTouched) {
|
|
28580
|
+
unset(_formState.touchedFields, name);
|
|
28581
|
+
}
|
|
28582
|
+
if (!options.keepDirty) {
|
|
28583
|
+
unset(_formState.dirtyFields, name);
|
|
28584
|
+
_formState.isDirty = options.defaultValue
|
|
28585
|
+
? _getDirty(name, get(_defaultValues, name))
|
|
28586
|
+
: _getDirty();
|
|
28587
|
+
}
|
|
28588
|
+
if (!options.keepError) {
|
|
28589
|
+
unset(_formState.errors, name);
|
|
28590
|
+
_proxyFormState.isValid && _updateValid();
|
|
28591
|
+
}
|
|
28592
|
+
_subjects.state.next({ ..._formState });
|
|
28593
|
+
}
|
|
28594
|
+
};
|
|
28595
|
+
const _reset = (formValues, keepStateOptions = {}) => {
|
|
28596
|
+
const updatedValues = formValues ? cloneObject(formValues) : _defaultValues;
|
|
28597
|
+
const cloneUpdatedValues = cloneObject(updatedValues);
|
|
28598
|
+
const values = formValues && !isEmptyObject(formValues)
|
|
28599
|
+
? cloneUpdatedValues
|
|
28600
|
+
: _defaultValues;
|
|
28601
|
+
if (!keepStateOptions.keepDefaultValues) {
|
|
28602
|
+
_defaultValues = updatedValues;
|
|
28603
|
+
}
|
|
28604
|
+
if (!keepStateOptions.keepValues) {
|
|
28605
|
+
if (keepStateOptions.keepDirtyValues || shouldCaptureDirtyFields) {
|
|
28606
|
+
for (const fieldName of _names.mount) {
|
|
28607
|
+
get(_formState.dirtyFields, fieldName)
|
|
28608
|
+
? set(values, fieldName, get(_formValues, fieldName))
|
|
28609
|
+
: setValue(fieldName, get(values, fieldName));
|
|
28610
|
+
}
|
|
28611
|
+
}
|
|
28612
|
+
else {
|
|
28613
|
+
if (isWeb && isUndefined(formValues)) {
|
|
28614
|
+
for (const name of _names.mount) {
|
|
28615
|
+
const field = get(_fields, name);
|
|
28616
|
+
if (field && field._f) {
|
|
28617
|
+
const fieldReference = Array.isArray(field._f.refs)
|
|
28618
|
+
? field._f.refs[0]
|
|
28619
|
+
: field._f.ref;
|
|
28620
|
+
if (isHTMLElement(fieldReference)) {
|
|
28621
|
+
const form = fieldReference.closest('form');
|
|
28622
|
+
if (form) {
|
|
28623
|
+
form.reset();
|
|
28624
|
+
break;
|
|
28625
|
+
}
|
|
28626
|
+
}
|
|
28627
|
+
}
|
|
28628
|
+
}
|
|
28629
|
+
}
|
|
28630
|
+
_fields = {};
|
|
28631
|
+
}
|
|
28632
|
+
_formValues = props.shouldUnregister
|
|
28633
|
+
? keepStateOptions.keepDefaultValues
|
|
28634
|
+
? cloneObject(_defaultValues)
|
|
28635
|
+
: {}
|
|
28636
|
+
: cloneObject(values);
|
|
28637
|
+
_subjects.array.next({
|
|
28638
|
+
values: { ...values },
|
|
28639
|
+
});
|
|
28640
|
+
_subjects.values.next({
|
|
28641
|
+
values: { ...values },
|
|
28642
|
+
});
|
|
28643
|
+
}
|
|
28644
|
+
_names = {
|
|
28645
|
+
mount: new Set(),
|
|
28646
|
+
unMount: new Set(),
|
|
28647
|
+
array: new Set(),
|
|
28648
|
+
watch: new Set(),
|
|
28649
|
+
watchAll: false,
|
|
28650
|
+
focus: '',
|
|
28651
|
+
};
|
|
28652
|
+
!_state.mount && flushRootRender();
|
|
28653
|
+
_state.mount = !_proxyFormState.isValid || !!keepStateOptions.keepIsValid;
|
|
28654
|
+
_state.watch = !!props.shouldUnregister;
|
|
28655
|
+
_subjects.state.next({
|
|
28656
|
+
submitCount: keepStateOptions.keepSubmitCount
|
|
28657
|
+
? _formState.submitCount
|
|
28658
|
+
: 0,
|
|
28659
|
+
isDirty: keepStateOptions.keepDirty
|
|
28660
|
+
? _formState.isDirty
|
|
28661
|
+
: !!(keepStateOptions.keepDefaultValues &&
|
|
28662
|
+
!deepEqual(formValues, _defaultValues)),
|
|
28663
|
+
isSubmitted: keepStateOptions.keepIsSubmitted
|
|
28664
|
+
? _formState.isSubmitted
|
|
28665
|
+
: false,
|
|
28666
|
+
dirtyFields: keepStateOptions.keepDirtyValues
|
|
28667
|
+
? _formState.dirtyFields
|
|
28668
|
+
: keepStateOptions.keepDefaultValues && formValues
|
|
28669
|
+
? getDirtyFields(_defaultValues, formValues)
|
|
28670
|
+
: {},
|
|
28671
|
+
touchedFields: keepStateOptions.keepTouched
|
|
28672
|
+
? _formState.touchedFields
|
|
28673
|
+
: {},
|
|
28674
|
+
errors: keepStateOptions.keepErrors ? _formState.errors : {},
|
|
28675
|
+
isSubmitSuccessful: keepStateOptions.keepIsSubmitSuccessful
|
|
28676
|
+
? _formState.isSubmitSuccessful
|
|
28677
|
+
: false,
|
|
28678
|
+
isSubmitting: false,
|
|
28679
|
+
});
|
|
28680
|
+
};
|
|
28681
|
+
const reset = (formValues, keepStateOptions) => _reset(isFunction(formValues)
|
|
28682
|
+
? formValues(_formValues)
|
|
28683
|
+
: formValues, keepStateOptions);
|
|
28684
|
+
const setFocus = (name, options = {}) => {
|
|
28685
|
+
const field = get(_fields, name);
|
|
28686
|
+
const fieldReference = field && field._f;
|
|
28687
|
+
if (fieldReference) {
|
|
28688
|
+
const fieldRef = fieldReference.refs
|
|
28689
|
+
? fieldReference.refs[0]
|
|
28690
|
+
: fieldReference.ref;
|
|
28691
|
+
if (fieldRef.focus) {
|
|
28692
|
+
fieldRef.focus();
|
|
28693
|
+
options.shouldSelect && fieldRef.select();
|
|
28694
|
+
}
|
|
28695
|
+
}
|
|
28696
|
+
};
|
|
28697
|
+
const _updateFormState = (updatedFormState) => {
|
|
28698
|
+
_formState = {
|
|
28699
|
+
..._formState,
|
|
28700
|
+
...updatedFormState,
|
|
28701
|
+
};
|
|
28702
|
+
};
|
|
28703
|
+
const _resetDefaultValues = () => isFunction(_options.defaultValues) &&
|
|
28704
|
+
_options.defaultValues().then((values) => {
|
|
28705
|
+
reset(values, _options.resetOptions);
|
|
28706
|
+
_subjects.state.next({
|
|
28707
|
+
isLoading: false,
|
|
28708
|
+
});
|
|
28709
|
+
});
|
|
28710
|
+
return {
|
|
28711
|
+
control: {
|
|
28712
|
+
register,
|
|
28713
|
+
unregister,
|
|
28714
|
+
getFieldState,
|
|
28715
|
+
handleSubmit,
|
|
28716
|
+
setError,
|
|
28717
|
+
_executeSchema,
|
|
28718
|
+
_getWatch,
|
|
28719
|
+
_getDirty,
|
|
28720
|
+
_updateValid,
|
|
28721
|
+
_removeUnmounted,
|
|
28722
|
+
_updateFieldArray,
|
|
28723
|
+
_updateDisabledField,
|
|
28724
|
+
_getFieldArray,
|
|
28725
|
+
_reset,
|
|
28726
|
+
_resetDefaultValues,
|
|
28727
|
+
_updateFormState,
|
|
28728
|
+
_disableForm,
|
|
28729
|
+
_subjects,
|
|
28730
|
+
_proxyFormState,
|
|
28731
|
+
_setErrors,
|
|
28732
|
+
get _fields() {
|
|
28733
|
+
return _fields;
|
|
28734
|
+
},
|
|
28735
|
+
get _formValues() {
|
|
28736
|
+
return _formValues;
|
|
28737
|
+
},
|
|
28738
|
+
get _state() {
|
|
28739
|
+
return _state;
|
|
28740
|
+
},
|
|
28741
|
+
set _state(value) {
|
|
28742
|
+
_state = value;
|
|
28743
|
+
},
|
|
28744
|
+
get _defaultValues() {
|
|
28745
|
+
return _defaultValues;
|
|
28746
|
+
},
|
|
28747
|
+
get _names() {
|
|
28748
|
+
return _names;
|
|
28749
|
+
},
|
|
28750
|
+
set _names(value) {
|
|
28751
|
+
_names = value;
|
|
28752
|
+
},
|
|
28753
|
+
get _formState() {
|
|
28754
|
+
return _formState;
|
|
28755
|
+
},
|
|
28756
|
+
set _formState(value) {
|
|
28757
|
+
_formState = value;
|
|
28758
|
+
},
|
|
28759
|
+
get _options() {
|
|
28760
|
+
return _options;
|
|
28761
|
+
},
|
|
28762
|
+
set _options(value) {
|
|
28763
|
+
_options = {
|
|
28764
|
+
..._options,
|
|
28765
|
+
...value,
|
|
28766
|
+
};
|
|
28767
|
+
},
|
|
28768
|
+
},
|
|
28769
|
+
trigger,
|
|
28770
|
+
register,
|
|
28771
|
+
handleSubmit,
|
|
28772
|
+
watch,
|
|
28773
|
+
setValue,
|
|
28774
|
+
getValues,
|
|
28775
|
+
reset,
|
|
28776
|
+
resetField,
|
|
28777
|
+
clearErrors,
|
|
28778
|
+
unregister,
|
|
28779
|
+
setError,
|
|
28780
|
+
setFocus,
|
|
28781
|
+
getFieldState,
|
|
28782
|
+
};
|
|
28783
|
+
}
|
|
28784
|
+
|
|
28785
|
+
/**
|
|
28786
|
+
* Custom hook to manage the entire form.
|
|
28787
|
+
*
|
|
28788
|
+
* @remarks
|
|
28789
|
+
* [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)
|
|
28790
|
+
*
|
|
28791
|
+
* @param props - form configuration and validation parameters.
|
|
28792
|
+
*
|
|
28793
|
+
* @returns methods - individual functions to manage the form state. {@link UseFormReturn}
|
|
28794
|
+
*
|
|
28795
|
+
* @example
|
|
28796
|
+
* ```tsx
|
|
28797
|
+
* function App() {
|
|
28798
|
+
* const { register, handleSubmit, watch, formState: { errors } } = useForm();
|
|
28799
|
+
* const onSubmit = data => console.log(data);
|
|
28800
|
+
*
|
|
28801
|
+
* console.log(watch("example"));
|
|
28802
|
+
*
|
|
28803
|
+
* return (
|
|
28804
|
+
* <form onSubmit={handleSubmit(onSubmit)}>
|
|
28805
|
+
* <input defaultValue="test" {...register("example")} />
|
|
28806
|
+
* <input {...register("exampleRequired", { required: true })} />
|
|
28807
|
+
* {errors.exampleRequired && <span>This field is required</span>}
|
|
28808
|
+
* <button>Submit</button>
|
|
28809
|
+
* </form>
|
|
28810
|
+
* );
|
|
28811
|
+
* }
|
|
28812
|
+
* ```
|
|
28813
|
+
*/
|
|
28814
|
+
function useForm(props = {}) {
|
|
28815
|
+
const _formControl = React__default.default.useRef();
|
|
28816
|
+
const _values = React__default.default.useRef();
|
|
28817
|
+
const [formState, updateFormState] = React__default.default.useState({
|
|
28818
|
+
isDirty: false,
|
|
28819
|
+
isValidating: false,
|
|
28820
|
+
isLoading: isFunction(props.defaultValues),
|
|
28821
|
+
isSubmitted: false,
|
|
28822
|
+
isSubmitting: false,
|
|
28823
|
+
isSubmitSuccessful: false,
|
|
28824
|
+
isValid: false,
|
|
28825
|
+
submitCount: 0,
|
|
28826
|
+
dirtyFields: {},
|
|
28827
|
+
touchedFields: {},
|
|
28828
|
+
errors: props.errors || {},
|
|
28829
|
+
disabled: false,
|
|
28830
|
+
defaultValues: isFunction(props.defaultValues)
|
|
28831
|
+
? undefined
|
|
28832
|
+
: props.defaultValues,
|
|
28833
|
+
});
|
|
28834
|
+
if (!_formControl.current) {
|
|
28835
|
+
_formControl.current = {
|
|
28836
|
+
...createFormControl(props, () => updateFormState((formState) => ({ ...formState }))),
|
|
28837
|
+
formState,
|
|
28838
|
+
};
|
|
28839
|
+
}
|
|
28840
|
+
const control = _formControl.current.control;
|
|
28841
|
+
control._options = props;
|
|
28842
|
+
useSubscribe({
|
|
28843
|
+
subject: control._subjects.state,
|
|
28844
|
+
next: (value) => {
|
|
28845
|
+
if (shouldRenderFormState(value, control._proxyFormState, control._updateFormState, true)) {
|
|
28846
|
+
updateFormState({ ...control._formState });
|
|
28847
|
+
}
|
|
28848
|
+
},
|
|
28849
|
+
});
|
|
28850
|
+
React__default.default.useEffect(() => control._disableForm(props.disabled), [control, props.disabled]);
|
|
28851
|
+
React__default.default.useEffect(() => {
|
|
28852
|
+
if (control._proxyFormState.isDirty) {
|
|
28853
|
+
const isDirty = control._getDirty();
|
|
28854
|
+
if (isDirty !== formState.isDirty) {
|
|
28855
|
+
control._subjects.state.next({
|
|
28856
|
+
isDirty,
|
|
28857
|
+
});
|
|
28858
|
+
}
|
|
28859
|
+
}
|
|
28860
|
+
}, [control, formState.isDirty]);
|
|
28861
|
+
React__default.default.useEffect(() => {
|
|
28862
|
+
if (props.values && !deepEqual(props.values, _values.current)) {
|
|
28863
|
+
control._reset(props.values, control._options.resetOptions);
|
|
28864
|
+
_values.current = props.values;
|
|
28865
|
+
updateFormState((state) => ({ ...state }));
|
|
28866
|
+
}
|
|
28867
|
+
else {
|
|
28868
|
+
control._resetDefaultValues();
|
|
28869
|
+
}
|
|
28870
|
+
}, [props.values, control]);
|
|
28871
|
+
React__default.default.useEffect(() => {
|
|
28872
|
+
if (props.errors) {
|
|
28873
|
+
control._setErrors(props.errors);
|
|
28874
|
+
}
|
|
28875
|
+
}, [props.errors, control]);
|
|
28876
|
+
React__default.default.useEffect(() => {
|
|
28877
|
+
if (!control._state.mount) {
|
|
28878
|
+
control._updateValid();
|
|
28879
|
+
control._state.mount = true;
|
|
28880
|
+
}
|
|
28881
|
+
if (control._state.watch) {
|
|
28882
|
+
control._state.watch = false;
|
|
28883
|
+
control._subjects.state.next({ ...control._formState });
|
|
28884
|
+
}
|
|
28885
|
+
control._removeUnmounted();
|
|
28886
|
+
});
|
|
28887
|
+
_formControl.current.formState = getProxyFormState(formState, control);
|
|
28888
|
+
return _formControl.current;
|
|
28889
|
+
}
|
|
28890
|
+
|
|
28891
|
+
const FormContainer$1 = styled__default.default(Container$n)`
|
|
28892
|
+
display: block;
|
|
28893
|
+
.grecaptcha-badge {
|
|
28894
|
+
visibility: hidden;
|
|
28895
|
+
}
|
|
28896
|
+
`;
|
|
28897
|
+
|
|
28898
|
+
const Legend$2 = styled__default.default.legend`
|
|
28899
|
+
margin-bottom: 5px;
|
|
28900
|
+
font-weight: bold;
|
|
28901
|
+
`;
|
|
28902
|
+
|
|
28903
|
+
const Label$3 = styled__default.default.label`
|
|
28904
|
+
margin-bottom: 5px;
|
|
28905
|
+
font-weight: bold;
|
|
28906
|
+
`;
|
|
28907
|
+
|
|
28908
|
+
const Hint = styled__default.default.p``;
|
|
28909
|
+
|
|
28910
|
+
const FormErrorText = styled__default.default(ErrorText$2)``;
|
|
28911
|
+
|
|
28912
|
+
const Hidden = styled__default.default.span`
|
|
28913
|
+
${VisuallyHidden$3}
|
|
28914
|
+
`;
|
|
28915
|
+
|
|
28916
|
+
const Terms = styled__default.default.p`
|
|
28917
|
+
font-size: ${(props) => props.theme.theme_vars.fontSizes.extra_small};
|
|
28918
|
+
`;
|
|
28919
|
+
|
|
28920
|
+
const QuestionContainer = styled__default.default.div`
|
|
28921
|
+
border: 2px solid ${(props) => props.theme.theme_vars.colours.grey_light};
|
|
28922
|
+
padding: ${(props) => props.theme.theme_vars.spacingSizes.small};
|
|
28923
|
+
border-radius: ${(props) => props.theme.theme_vars.border_radius};
|
|
28924
|
+
display: flex;
|
|
28925
|
+
flex-direction: column;
|
|
28926
|
+
flex-grow: 1;
|
|
28927
|
+
height: 100%;
|
|
28928
|
+
`;
|
|
28929
|
+
|
|
28930
|
+
const QuestionTitle = styled__default.default.p`
|
|
28931
|
+
font-weight: bold;
|
|
28932
|
+
`;
|
|
28933
|
+
|
|
28934
|
+
const QuestionButton = styled__default.default.div`
|
|
28935
|
+
flex-grow: 1;
|
|
28936
|
+
display: flex;
|
|
28937
|
+
flex-direction: row;
|
|
28938
|
+
align-items: flex-end;
|
|
28939
|
+
justify-content: center;
|
|
28940
|
+
`;
|
|
28941
|
+
|
|
28942
|
+
const StyledTextarea = styled__default.default.textarea`
|
|
28943
|
+
${(props) => props.theme.fontStyles}
|
|
28944
|
+
margin-top: 0 !important;
|
|
28945
|
+
margin-bottom: 25px;
|
|
28946
|
+
padding: 5px;
|
|
28947
|
+
border: solid
|
|
28948
|
+
${(props) => (props.$isErrored ? props.theme.theme_vars.colours.negative : props.theme.theme_vars.colours.black)};
|
|
28949
|
+
border-width: ${(props) => (props.$isErrored ? '3px' : '2px')};
|
|
28950
|
+
border-radius: ${(props) => props.theme.theme_vars.border_radius};
|
|
28951
|
+
display: block;
|
|
28952
|
+
width: ${(props) => (props.$isFullWidth ? '100%' : 'auto')};
|
|
28953
|
+
|
|
28954
|
+
&:focus {
|
|
28955
|
+
outline: none;
|
|
28956
|
+
box-shadow: ${(props) => props.theme.theme_vars.colours.focus} 0 0 0 3px;
|
|
28957
|
+
transition: box-shadow 0.3s ease 0s;
|
|
28958
|
+
}
|
|
28959
|
+
`;
|
|
28960
|
+
const ErrorText = styled__default.default.p`
|
|
28961
|
+
${(props) => props.theme.fontStyles}
|
|
28962
|
+
color: ${(props) => props.theme.theme_vars.colours.negative};
|
|
28963
|
+
font-weight: bold;
|
|
28964
|
+
margin-bottom: 5px;
|
|
28965
|
+
font-size: 14px;
|
|
28966
|
+
font-size: 0.8rem;
|
|
28967
|
+
line-height: 1.1;
|
|
28968
|
+
|
|
28969
|
+
@media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.m}) {
|
|
28970
|
+
font-size: 18px;
|
|
28971
|
+
font-size: 1rem;
|
|
28972
|
+
line-height: 1.25;
|
|
28973
|
+
}
|
|
28974
|
+
`;
|
|
28975
|
+
|
|
28976
|
+
/**
|
|
28977
|
+
* Primary UI component for user interaction
|
|
28978
|
+
* If value is set then treat as controlled component
|
|
28979
|
+
*/
|
|
28980
|
+
var Textarea = function (_a) {
|
|
28981
|
+
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;
|
|
28982
|
+
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
28983
|
+
errorText && React__default.default.createElement(ErrorText, null, errorText),
|
|
28984
|
+
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 }))));
|
|
28985
|
+
};
|
|
28986
|
+
|
|
28987
|
+
const Container$i = styled__default.default.div`
|
|
28988
|
+
display: block;
|
|
28989
|
+
border-left: ${(props) =>
|
|
28990
|
+
props.$isErrored
|
|
28991
|
+
? `${props.theme.theme_vars.border_width} solid ${props.theme.theme_vars.colours.negative}`
|
|
28992
|
+
: 'none'};
|
|
28993
|
+
padding-left: ${(props) => (props.$isErrored ? ` ${props.theme.theme_vars.spacingSizes.extra_small}` : '0')};
|
|
28994
|
+
padding-bottom: 10px;
|
|
28995
|
+
`;
|
|
28996
|
+
|
|
28997
|
+
const Category$2 = styled__default.default.div`
|
|
28998
|
+
font-size: ${(props) => props.theme.theme_vars.fontSizes.small};
|
|
28999
|
+
display: block;
|
|
29000
|
+
position: relative;
|
|
29001
|
+
min-height: 40px;
|
|
29002
|
+
|
|
29003
|
+
padding-left: 40px;
|
|
29004
|
+
clear: left;
|
|
29005
|
+
`;
|
|
29006
|
+
|
|
29007
|
+
const CategoryInput = styled__default.default.input`
|
|
29008
|
+
cursor: pointer;
|
|
29009
|
+
position: absolute;
|
|
29010
|
+
z-index: 1;
|
|
29011
|
+
top: -2px;
|
|
29012
|
+
left: -2px;
|
|
29013
|
+
width: 44px;
|
|
29014
|
+
height: 44px;
|
|
29015
|
+
margin: 0;
|
|
29016
|
+
opacity: 0;
|
|
29017
|
+
|
|
29018
|
+
&:focus + label:before {
|
|
29019
|
+
box-shadow: 0 0 0 3px ${(props) => props.theme.theme_vars.colours.focus};
|
|
29020
|
+
}
|
|
29021
|
+
`;
|
|
29022
|
+
|
|
29023
|
+
/**
|
|
29024
|
+
* If single selection then use styles for radio button, otherwise checkbox styles
|
|
29025
|
+
*/
|
|
29026
|
+
const checkedMarker = (props) => {
|
|
29027
|
+
if (props.$singleSelection) {
|
|
29028
|
+
return styled.css`
|
|
29029
|
+
top: 10px;
|
|
29030
|
+
left: 10px;
|
|
29031
|
+
width: 0;
|
|
29032
|
+
height: 0;
|
|
29033
|
+
border: 10px solid currentcolor;
|
|
29034
|
+
border-radius: 50%;
|
|
29035
|
+
background: currentcolor;
|
|
29036
|
+
`;
|
|
29037
|
+
} else {
|
|
29038
|
+
return styled.css`
|
|
29039
|
+
top: 11px;
|
|
29040
|
+
left: 9px;
|
|
29041
|
+
width: 23px;
|
|
29042
|
+
height: 12px;
|
|
29043
|
+
-webkit-transform: rotate(-45deg);
|
|
29044
|
+
-ms-transform: rotate(-45deg);
|
|
29045
|
+
transform: rotate(-45deg);
|
|
29046
|
+
border: solid;
|
|
29047
|
+
border-width: 0 0 5px 5px;
|
|
29048
|
+
border-top-color: transparent;
|
|
29049
|
+
background: transparent;
|
|
29050
|
+
`;
|
|
29051
|
+
}
|
|
29052
|
+
};
|
|
29053
|
+
|
|
29054
|
+
const CategoryInputLabel = styled__default.default.label`
|
|
29055
|
+
display: inline-block;
|
|
29056
|
+
margin-bottom: 0;
|
|
29057
|
+
padding: 8px 15px 5px;
|
|
29058
|
+
cursor: pointer;
|
|
29059
|
+
-ms-touch-action: manipulation;
|
|
29060
|
+
touch-action: manipulation;
|
|
29061
|
+
color: #0b0c0c;
|
|
29062
|
+
display: block;
|
|
29063
|
+
margin-bottom: 5px;
|
|
29064
|
+
|
|
29065
|
+
&:before {
|
|
29066
|
+
content: '';
|
|
29067
|
+
-webkit-box-sizing: border-box;
|
|
29068
|
+
box-sizing: border-box;
|
|
29069
|
+
position: absolute;
|
|
29070
|
+
top: 0;
|
|
29071
|
+
left: 0;
|
|
29072
|
+
width: 40px;
|
|
29073
|
+
height: 40px;
|
|
29074
|
+
border: 2px solid currentColor;
|
|
29075
|
+
background: transparent;
|
|
29076
|
+
border-radius: ${(props) => (props.$singleSelection ? '100%' : 0)};
|
|
29077
|
+
}
|
|
29078
|
+
|
|
29079
|
+
&:after {
|
|
29080
|
+
content: '';
|
|
29081
|
+
-webkit-box-sizing: border-box;
|
|
29082
|
+
box-sizing: border-box;
|
|
29083
|
+
position: absolute;
|
|
29084
|
+
opacity: ${(props) => (props.$isChecked ? 1 : 0)};
|
|
29085
|
+
${checkedMarker}
|
|
29086
|
+
}
|
|
29087
|
+
`;
|
|
29088
|
+
|
|
29089
|
+
var RadioCheckboxInput = function (_a) {
|
|
29090
|
+
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;
|
|
29091
|
+
var id = React.useId();
|
|
29092
|
+
return (React__default.default.createElement(Container$i, { "data-testid": "RadioCheckboxInput", "$isErrored": isErrored },
|
|
29093
|
+
React__default.default.createElement(Category$2, null,
|
|
29094
|
+
React__default.default.createElement(CategoryInput, { type: singleSelection ? 'radio' : 'checkbox', value: value, id: id, name: name, onClick: onChange, defaultChecked: checked }),
|
|
29095
|
+
React__default.default.createElement(CategoryInputLabel, { "$isChecked": checked, htmlFor: id, "$singleSelection": singleSelection }, label))));
|
|
29096
|
+
};
|
|
29097
|
+
|
|
29098
|
+
function L(r) {
|
|
29099
|
+
const [o, c] = React.useState(r ? "loading" : "idle");
|
|
29100
|
+
return React.useEffect(
|
|
29101
|
+
() => {
|
|
29102
|
+
if (!r) {
|
|
29103
|
+
c("idle");
|
|
29104
|
+
return;
|
|
29105
|
+
}
|
|
29106
|
+
let e = document.querySelector(`script[src="${r}"]`);
|
|
29107
|
+
if (e)
|
|
29108
|
+
c(e.getAttribute("data-status"));
|
|
29109
|
+
else {
|
|
29110
|
+
e = document.createElement("script"), e.src = r, e.async = !0, e.defer = !0, e.setAttribute("data-status", "loading"), document.body.appendChild(e);
|
|
29111
|
+
const a = (i) => {
|
|
29112
|
+
e.setAttribute(
|
|
29113
|
+
"data-status",
|
|
29114
|
+
i.type === "load" ? "ready" : "error"
|
|
29115
|
+
);
|
|
29116
|
+
};
|
|
29117
|
+
e.addEventListener("load", a), e.addEventListener("error", a);
|
|
29118
|
+
}
|
|
29119
|
+
const n = (a) => {
|
|
29120
|
+
c(a.type === "load" ? "ready" : "error");
|
|
29121
|
+
};
|
|
29122
|
+
return e.addEventListener("load", n), e.addEventListener("error", n), () => {
|
|
29123
|
+
e && (e.removeEventListener("load", n), e.removeEventListener("error", n));
|
|
29124
|
+
};
|
|
29125
|
+
},
|
|
29126
|
+
[r]
|
|
29127
|
+
// Only re-run effect if script src changes
|
|
29128
|
+
), o;
|
|
29129
|
+
}
|
|
29130
|
+
const b = "https://www.google.com/recaptcha/api.js?render=explicit";
|
|
29131
|
+
let l;
|
|
29132
|
+
function R({
|
|
29133
|
+
containerId: r,
|
|
29134
|
+
sitekey: o,
|
|
29135
|
+
size: c,
|
|
29136
|
+
theme: e,
|
|
29137
|
+
badge: n,
|
|
29138
|
+
successCallback: a,
|
|
29139
|
+
expiredCallback: i,
|
|
29140
|
+
errorCallback: h
|
|
29141
|
+
}) {
|
|
29142
|
+
var w;
|
|
29143
|
+
L(b);
|
|
29144
|
+
const [s, f] = React.useState(!!((w = window == null ? void 0 : window.grecaptcha) != null && w.render)), [t, v] = React.useState(null);
|
|
29145
|
+
React.useEffect(() => (l = window.setInterval(() => {
|
|
29146
|
+
var d;
|
|
29147
|
+
(d = window == null ? void 0 : window.grecaptcha) != null && d.render && f(!0);
|
|
29148
|
+
}, 500), () => {
|
|
29149
|
+
clearInterval(l);
|
|
29150
|
+
}), []), React.useEffect(() => {
|
|
29151
|
+
if (s && window.grecaptcha && t === null) {
|
|
29152
|
+
clearInterval(l);
|
|
29153
|
+
const d = window.grecaptcha.render(r, {
|
|
29154
|
+
sitekey: o,
|
|
29155
|
+
size: c,
|
|
29156
|
+
theme: e,
|
|
29157
|
+
badge: n,
|
|
29158
|
+
callback: a,
|
|
29159
|
+
"expired-callback": i,
|
|
29160
|
+
"error-callback": h
|
|
29161
|
+
});
|
|
29162
|
+
v(d);
|
|
29163
|
+
}
|
|
29164
|
+
}, [s, a, t, r]);
|
|
29165
|
+
const m = React.useCallback(() => {
|
|
29166
|
+
t !== null && window.grecaptcha && window.grecaptcha.execute(t);
|
|
29167
|
+
}, [t]), E = React.useCallback(() => {
|
|
29168
|
+
t !== null && window.grecaptcha && window.grecaptcha.reset(t);
|
|
29169
|
+
}, [t]);
|
|
29170
|
+
return {
|
|
29171
|
+
execute: m,
|
|
29172
|
+
recaptchaLoaded: s,
|
|
29173
|
+
recaptchaWidget: t,
|
|
29174
|
+
reset: E
|
|
29175
|
+
};
|
|
29176
|
+
}
|
|
29177
|
+
|
|
29178
|
+
const Spinner = styled__default.default.div`
|
|
29179
|
+
display: inline-block;
|
|
29180
|
+
width: 80px;
|
|
29181
|
+
height: 80px;
|
|
29182
|
+
|
|
29183
|
+
&:after {
|
|
29184
|
+
content: " ";
|
|
29185
|
+
display: block;
|
|
29186
|
+
width: 50px;
|
|
29187
|
+
height: 50px;
|
|
29188
|
+
margin: 8px;
|
|
29189
|
+
border-radius: 50%;
|
|
29190
|
+
border: 6px solid ${props => props.theme.theme_vars.colours.action};
|
|
29191
|
+
border-color: ${props => props.theme.theme_vars.colours.action} transparent ${props => props.theme.theme_vars.colours.action} transparent;
|
|
29192
|
+
animation: lds-dual-ring 1.2s linear infinite;
|
|
29193
|
+
}
|
|
29194
|
+
|
|
29195
|
+
@keyframes lds-dual-ring {
|
|
29196
|
+
0% {
|
|
29197
|
+
transform: rotate(0deg);
|
|
29198
|
+
}
|
|
29199
|
+
100% {
|
|
29200
|
+
transform: rotate(360deg);
|
|
29201
|
+
}
|
|
29202
|
+
}
|
|
29203
|
+
|
|
29204
|
+
`;
|
|
29205
|
+
|
|
29206
|
+
var LoadingSpinner = function () {
|
|
29207
|
+
return React__default.default.createElement(Spinner, null);
|
|
29208
|
+
};
|
|
29209
|
+
|
|
29210
|
+
const Container$h = styled__default.default.div`
|
|
29211
|
+
display: block;
|
|
29212
|
+
background-color: ${(props) => props.theme.theme_vars.colours.positive};
|
|
29213
|
+
padding: ${(props) => props.theme.theme_vars.spacingSizes.small};
|
|
29214
|
+
display: flex;
|
|
29215
|
+
justify-content: center;
|
|
29216
|
+
|
|
29217
|
+
@media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.m}) {
|
|
29218
|
+
padding: ${(props) => props.theme.theme_vars.spacingSizes.large};
|
|
29219
|
+
}
|
|
29220
|
+
`;
|
|
29221
|
+
|
|
29222
|
+
const Heading = styled__default.default.h2`
|
|
29223
|
+
${(props) => props.theme.fontStyles}
|
|
29224
|
+
${(props) => props.theme.theme_vars.h2}
|
|
29225
|
+
font-size: ${(props) => props.theme.theme_vars.fontSizes.medium};
|
|
29226
|
+
color: ${(props) => props.theme.theme_vars.colours.white};
|
|
29227
|
+
text-align: center;
|
|
29228
|
+
`;
|
|
29229
|
+
|
|
29230
|
+
const Content$2 = styled__default.default.div`
|
|
29231
|
+
${(props) => props.theme.fontStyles}
|
|
29232
|
+
color: ${(props) => props.theme.theme_vars.colours.white};
|
|
29233
|
+
display: flex;
|
|
29234
|
+
justify-content: center;
|
|
29235
|
+
text-align: center;
|
|
29236
|
+
`;
|
|
29237
|
+
|
|
29238
|
+
/**
|
|
29239
|
+
* A panel to show success messages
|
|
29240
|
+
*/
|
|
29241
|
+
var Panel = function (_a) {
|
|
29242
|
+
var heading = _a.heading, children = _a.children;
|
|
29243
|
+
return (React__default.default.createElement(Container$h, { "data-testid": "Panel" },
|
|
29244
|
+
React__default.default.createElement(Heading, null, heading),
|
|
29245
|
+
children && React__default.default.createElement(Content$2, null, children)));
|
|
29246
|
+
};
|
|
29247
|
+
|
|
29248
|
+
var ratingValues = ['1', '2', '3', '4', '5'];
|
|
29249
|
+
var HelpfulEnum;
|
|
29250
|
+
(function (HelpfulEnum) {
|
|
29251
|
+
HelpfulEnum["yes"] = "Yes";
|
|
29252
|
+
HelpfulEnum["no"] = "No";
|
|
29253
|
+
})(HelpfulEnum || (HelpfulEnum = {}));
|
|
29254
|
+
/**
|
|
29255
|
+
* A form that allows visitors to rate the website page.
|
|
29256
|
+
* If the user answers No to 'Is this information helpful?' then they are presented with more questions.
|
|
29257
|
+
* The form is protected by Google recaptcha and needs a recaptcha sitekey to work.
|
|
29258
|
+
*/
|
|
29259
|
+
var RateThisPage = function (_a) {
|
|
29260
|
+
var _b;
|
|
29261
|
+
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;
|
|
29262
|
+
var _e = useForm({
|
|
29263
|
+
defaultValues: {
|
|
29264
|
+
HowCanWeImprove: '',
|
|
29265
|
+
Email: '',
|
|
29266
|
+
BarriersOrIssues: '',
|
|
29267
|
+
},
|
|
29268
|
+
}), handleSubmit = _e.handleSubmit, control = _e.control, errors = _e.formState.errors, watch = _e.watch, register = _e.register, setValue = _e.setValue;
|
|
29269
|
+
var watchIsHelpful = watch('IsHelpful');
|
|
29270
|
+
var _f = React.useState(false), showQuestion = _f[0], setShowQuestion = _f[1];
|
|
29271
|
+
var _g = React.useState(false), showFullForm = _g[0], setShowFullForm = _g[1];
|
|
29272
|
+
var _h = React.useState(false), showSubmit = _h[0], setShowSubmit = _h[1];
|
|
29273
|
+
var recaptchaKey = (_b = process.env.NEXT_PUBLIC_RECAPTCHA_KEY) !== null && _b !== void 0 ? _b : '';
|
|
29274
|
+
var recaptchaContainerId = 'recaptchaContainer';
|
|
29275
|
+
/**
|
|
29276
|
+
* called when captcha succeeds
|
|
29277
|
+
*/
|
|
29278
|
+
var successCallback = function (response) {
|
|
29279
|
+
setValue('ReCaptcha', response);
|
|
29280
|
+
setIsLoading(false);
|
|
29281
|
+
handleSubmit(function (data) { return onSubmit(data); })();
|
|
29282
|
+
};
|
|
29283
|
+
var errorCallback = function () {
|
|
29284
|
+
setIsLoading(false);
|
|
29285
|
+
};
|
|
29286
|
+
var _j = R({
|
|
29287
|
+
containerId: recaptchaContainerId,
|
|
29288
|
+
successCallback: successCallback,
|
|
29289
|
+
errorCallback: errorCallback,
|
|
29290
|
+
sitekey: recaptchaKey,
|
|
29291
|
+
size: 'invisible',
|
|
29292
|
+
}), recaptchaLoaded = _j.recaptchaLoaded, execute = _j.execute, reset = _j.reset;
|
|
29293
|
+
React.useEffect(function () {
|
|
29294
|
+
if (watchIsHelpful && String(watchIsHelpful) === 'No') {
|
|
29295
|
+
setShowQuestion(true);
|
|
29296
|
+
setShowSubmit(false);
|
|
29297
|
+
}
|
|
29298
|
+
else if (watchIsHelpful && String(watchIsHelpful) === 'Yes') {
|
|
29299
|
+
setShowQuestion(false);
|
|
29300
|
+
setShowSubmit(true);
|
|
29301
|
+
setShowFullForm(false);
|
|
29302
|
+
}
|
|
29303
|
+
else {
|
|
29304
|
+
setShowQuestion(false);
|
|
29305
|
+
setShowFullForm(false);
|
|
29306
|
+
setShowSubmit(false);
|
|
29307
|
+
}
|
|
29308
|
+
}, [watchIsHelpful]);
|
|
29309
|
+
var executeCaptcha = function (e) {
|
|
29310
|
+
e.preventDefault();
|
|
29311
|
+
reset();
|
|
29312
|
+
execute();
|
|
29313
|
+
setIsLoading(true);
|
|
29314
|
+
};
|
|
29315
|
+
var handleQuestionButton = function (e) {
|
|
29316
|
+
e.preventDefault();
|
|
29317
|
+
setShowQuestion(false);
|
|
29318
|
+
setShowFullForm(true);
|
|
29319
|
+
setShowSubmit(true);
|
|
29320
|
+
};
|
|
29321
|
+
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 },
|
|
29322
|
+
React__default.default.createElement(Row$1, null,
|
|
29323
|
+
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
29324
|
+
React__default.default.createElement("fieldset", { "aria-describedby": errors.IsHelpful ? 'IsHelpfulError' : 'IsHelpfulLegend' },
|
|
29325
|
+
React__default.default.createElement(Legend$2, { id: "IsHelpfulLegend" }, "Is this information helpful?"),
|
|
29326
|
+
React__default.default.createElement(Controller, { name: "IsHelpful", control: control, rules: { required: true }, render: function (_a) {
|
|
29327
|
+
var _b = _a.field, onChange = _b.onChange, value = _b.value;
|
|
29328
|
+
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
29329
|
+
errors.IsHelpful && (React__default.default.createElement(FormErrorText, { id: "IsHelpfulError" },
|
|
29330
|
+
React__default.default.createElement(Hidden, null, "Error:"),
|
|
29331
|
+
" The field is this information helpful is required.")),
|
|
29332
|
+
Object.entries(HelpfulEnum).map(function (_a) {
|
|
29333
|
+
var key = _a[0], enumValue = _a[1];
|
|
29334
|
+
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 }));
|
|
29335
|
+
})));
|
|
29336
|
+
} }))),
|
|
29337
|
+
showQuestion && (React__default.default.createElement(React__default.default.Fragment, null,
|
|
29338
|
+
React__default.default.createElement(Column, { small: "full", medium: "full", large: "one-half" },
|
|
29339
|
+
React__default.default.createElement(QuestionContainer, null,
|
|
29340
|
+
React__default.default.createElement(QuestionTitle, null, "Service"),
|
|
29341
|
+
React__default.default.createElement("p", null, "You may have comments about the quality of the service that's been provided."),
|
|
29342
|
+
React__default.default.createElement("ul", null,
|
|
29343
|
+
React__default.default.createElement("li", null, "I have waited too long for something to happen"),
|
|
29344
|
+
React__default.default.createElement("li", null, "I'm struggling to contact the service"),
|
|
29345
|
+
React__default.default.createElement("li", null, "I don't think I have been treated fairly"),
|
|
29346
|
+
React__default.default.createElement("li", null, "I feel as if I have been misled")),
|
|
29347
|
+
React__default.default.createElement(QuestionButton, null,
|
|
29348
|
+
React__default.default.createElement(Button$4, { url: complaintsFormLink }, "I have a comment or complaint about this service")))),
|
|
29349
|
+
React__default.default.createElement(Column, { small: "full", medium: "full", large: "one-half" },
|
|
29350
|
+
React__default.default.createElement(QuestionContainer, null,
|
|
29351
|
+
React__default.default.createElement(QuestionTitle, null, "Content"),
|
|
29352
|
+
React__default.default.createElement("p", null, "You may have comments about the content on the webpage."),
|
|
29353
|
+
React__default.default.createElement("p", null, "Your feedback will help us improve our website and the content we include."),
|
|
29354
|
+
React__default.default.createElement("ul", null,
|
|
29355
|
+
React__default.default.createElement("li", null, "The information on this page is difficult to understand"),
|
|
29356
|
+
React__default.default.createElement("li", null, "This page isn't giving me the information I need"),
|
|
29357
|
+
React__default.default.createElement("li", null, "This page contains information that is wrong or out of date"),
|
|
29358
|
+
React__default.default.createElement("li", null, "This page could have been written or presented better")),
|
|
29359
|
+
React__default.default.createElement(QuestionButton, null,
|
|
29360
|
+
React__default.default.createElement(FormButton, { text: "I have feedback about the information on this page", type: "button", size: "medium", onClick: handleQuestionButton })))))),
|
|
29361
|
+
showFullForm && (React__default.default.createElement(React__default.default.Fragment, null,
|
|
29362
|
+
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
29363
|
+
React__default.default.createElement("fieldset", { "aria-describedby": "HowEasyToFindLegend" },
|
|
29364
|
+
React__default.default.createElement(Legend$2, { id: "HowEasyToFindLegend" }, "How easy was it to find what you were looking for?"),
|
|
29365
|
+
React__default.default.createElement(Hint, null, "1 being very easy and 5 being extremely difficult."),
|
|
29366
|
+
React__default.default.createElement(Controller, { name: "HowEasyToFind", control: control, rules: { pattern: /^[1-5]+$/i }, render: function (_a) {
|
|
29367
|
+
var _b = _a.field, onChange = _b.onChange, value = _b.value;
|
|
29368
|
+
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 })); })));
|
|
29369
|
+
} }))),
|
|
29370
|
+
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
29371
|
+
React__default.default.createElement("fieldset", { "aria-describedby": "HowEasyToUnderstandLegend" },
|
|
29372
|
+
React__default.default.createElement(Legend$2, { id: "HowEasyToUnderstandLegend" }, "How easy was this content to understand?"),
|
|
29373
|
+
React__default.default.createElement(Hint, null, "1 being very easy and 5 being extremely difficult."),
|
|
29374
|
+
React__default.default.createElement(Controller, { name: "HowEasyToUnderstand", control: control, rules: { pattern: /^[1-5]+$/i }, render: function (_a) {
|
|
29375
|
+
var _b = _a.field, onChange = _b.onChange, value = _b.value;
|
|
29376
|
+
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 })); })));
|
|
29377
|
+
} }))),
|
|
29378
|
+
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
29379
|
+
React__default.default.createElement(Label$3, { htmlFor: "BarriersOrIssues" }, "Did you come across any barriers or issues with this webpage?"),
|
|
29380
|
+
React__default.default.createElement(Controller, { name: "BarriersOrIssues", control: control, rules: { max: 500 }, render: function (_a) {
|
|
29381
|
+
var _b = _a.field, onChange = _b.onChange, value = _b.value;
|
|
29382
|
+
return (React__default.default.createElement(Textarea, { id: "BarriersOrIssues", name: "BarriersOrIssues", value: value, placeholder: "", onChange: onChange, isErrored: errors.BarriersOrIssues ? true : false, isFullWidth: true }));
|
|
29383
|
+
} })),
|
|
29384
|
+
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
29385
|
+
React__default.default.createElement(Label$3, { htmlFor: "HowCanWeImprove" }, "How could this page be improved?"),
|
|
29386
|
+
React__default.default.createElement(Controller, { name: "HowCanWeImprove", control: control, rules: { max: 500 }, render: function (_a) {
|
|
29387
|
+
var _b = _a.field, onChange = _b.onChange, value = _b.value;
|
|
29388
|
+
return (React__default.default.createElement(Textarea, { id: "HowCanWeImprove", name: "HowCanWeImprove", value: value, placeholder: "", onChange: onChange, isErrored: errors.HowCanWeImprove ? true : false, isFullWidth: true }));
|
|
29389
|
+
} })),
|
|
29390
|
+
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
29391
|
+
React__default.default.createElement(Label$3, { htmlFor: "Email" }, "Please leave your email below if you are happy for us to contact you further (optional)"),
|
|
29392
|
+
React__default.default.createElement(Controller, { name: "Email", control: control, rules: {
|
|
29393
|
+
max: 150,
|
|
29394
|
+
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,}))$/,
|
|
29395
|
+
}, render: function (_a) {
|
|
29396
|
+
var _b = _a.field, onChange = _b.onChange; _b.onBlur; var value = _b.value; _b.ref;
|
|
29397
|
+
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 }));
|
|
29398
|
+
} })))),
|
|
29399
|
+
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
29400
|
+
React__default.default.createElement("div", { id: recaptchaContainerId, className: "g-recaptcha" }),
|
|
29401
|
+
React__default.default.createElement("input", __assign$2({ type: "hidden" }, register('ReCaptcha'))),
|
|
29402
|
+
React__default.default.createElement(Terms, null,
|
|
29403
|
+
"This site is protected by reCAPTCHA and the Google",
|
|
29404
|
+
' ',
|
|
29405
|
+
React__default.default.createElement("a", { href: "https://policies.google.com/privacy" }, "Privacy Policy"),
|
|
29406
|
+
" and",
|
|
29407
|
+
' ',
|
|
29408
|
+
React__default.default.createElement("a", { href: "https://policies.google.com/terms" }, "Terms of Service"),
|
|
29409
|
+
" apply.")),
|
|
29410
|
+
showSubmit && (React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
29411
|
+
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 }))))))))));
|
|
29412
|
+
};
|
|
29413
|
+
|
|
29414
|
+
const Container$g = styled__default.default.div`
|
|
29415
|
+
${(props) => props.theme.fontStyles};
|
|
29416
|
+
`;
|
|
29417
|
+
|
|
29418
|
+
const ResultInfo$2 = styled__default.default.div`
|
|
29419
|
+
font-weight: bold;
|
|
29420
|
+
margin: ${(props) => props.theme.theme_vars.spacingSizes.large} 0;
|
|
29421
|
+
`;
|
|
29422
|
+
|
|
29423
|
+
const Result = styled__default.default.div`
|
|
29424
|
+
margin-bottom: ${(props) => props.theme.theme_vars.spacingSizes.x_large};
|
|
29425
|
+
|
|
29426
|
+
&:first-of-type {
|
|
29427
|
+
margin-top: 0;
|
|
29428
|
+
}
|
|
29429
|
+
`;
|
|
29430
|
+
|
|
29431
|
+
const Title$3 = styled__default.default.a`
|
|
29432
|
+
${(props) => props.theme.linkStyles};
|
|
29433
|
+
font-size: 1.2em;
|
|
29434
|
+
display: block;
|
|
29435
|
+
margin-bottom: 5px;
|
|
29436
|
+
`;
|
|
29437
|
+
|
|
29438
|
+
const ServiceArea = styled__default.default.p`
|
|
29439
|
+
font-size: 14px;
|
|
29440
|
+
font-size: 0.8rem;
|
|
29441
|
+
line-height: 1.3;
|
|
29442
|
+
color: ${(props) =>
|
|
29443
|
+
props.theme.cardinal_name === 'west'
|
|
29444
|
+
? props.theme.theme_vars.colours.grey_darke
|
|
29445
|
+
: props.theme.theme_vars.colours.grey_darkest};
|
|
29446
|
+
margin-bottom: 3px !important;
|
|
29447
|
+
|
|
29448
|
+
@media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.s}) {
|
|
29449
|
+
font-size: 16px;
|
|
29450
|
+
font-size: 1rem;
|
|
29451
|
+
line-height: 1.4;
|
|
29452
|
+
}
|
|
29453
|
+
`;
|
|
29454
|
+
|
|
29455
|
+
const Summary$2 = styled__default.default.p`
|
|
29456
|
+
margin-bottom: ${(props) => props.theme.theme_vars.spacingSizes.small};
|
|
29457
|
+
`;
|
|
29458
|
+
|
|
29459
|
+
const SignpostContainer = styled__default.default.div`
|
|
29460
|
+
font-size: 14px;
|
|
29461
|
+
font-size: 0.8rem;
|
|
29462
|
+
line-height: 1.3;
|
|
29463
|
+
|
|
29464
|
+
p {
|
|
29465
|
+
margin-bottom: 10px !important;
|
|
29466
|
+
}
|
|
29467
|
+
|
|
29468
|
+
ul {
|
|
29469
|
+
margin-top: 8px !important;
|
|
29470
|
+
font-size: 14px;
|
|
29471
|
+
font-size: 0.8rem;
|
|
29472
|
+
line-height: 1.3;
|
|
29473
|
+
|
|
29474
|
+
li {
|
|
29475
|
+
margin-bottom: 5px;
|
|
29476
|
+
}
|
|
29477
|
+
}
|
|
29478
|
+
|
|
29479
|
+
@media screen and (min-width: ${(props) => props.theme.theme_vars.breakpoints.s}) {
|
|
29480
|
+
font-size: 16px;
|
|
29481
|
+
font-size: 1rem;
|
|
29482
|
+
line-height: 1.4;
|
|
29483
|
+
|
|
29484
|
+
ul {
|
|
29485
|
+
font-size: 16px;
|
|
29486
|
+
font-size: 1rem;
|
|
29487
|
+
line-height: 1.4;
|
|
29488
|
+
}
|
|
29489
|
+
}
|
|
29490
|
+
`;
|
|
29491
|
+
|
|
29492
|
+
const SignpostList = styled__default.default.ul`
|
|
29493
|
+
|
|
29494
|
+
${props => props.theme.fontStyles}
|
|
29495
|
+
margin: 0 !important;
|
|
29496
|
+
padding-left: 10px;
|
|
29497
|
+
margin-bottom: 20px !important;
|
|
29498
|
+
list-style-type: none;
|
|
29499
|
+
|
|
29500
|
+
li:last-of-type {
|
|
29501
|
+
margin-bottom: 0;
|
|
29502
|
+
}
|
|
29503
|
+
`;
|
|
29504
|
+
const SignpostListItem = styled__default.default.li`
|
|
29505
|
+
margin-bottom: 10px;
|
|
29506
|
+
padding-left: 0 !important;
|
|
29507
|
+
|
|
29508
|
+
&:before {
|
|
29509
|
+
content: none !important;
|
|
29510
|
+
}
|
|
29511
|
+
`;
|
|
29512
|
+
|
|
29513
|
+
|
|
29514
|
+
const SignpostLink = styled__default.default.a`
|
|
29515
|
+
${props => props.theme.linkStyles}
|
|
29516
|
+
|
|
29517
|
+
svg {
|
|
26880
29518
|
fill: ${props => props.theme.theme_vars.colours.action};
|
|
26881
29519
|
}
|
|
26882
29520
|
|
|
@@ -26930,11 +29568,11 @@ var SearchResultsList = function (_a) {
|
|
|
26930
29568
|
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;
|
|
26931
29569
|
var themeContext = React.useContext(styled.ThemeContext);
|
|
26932
29570
|
if (totalResults === 0) {
|
|
26933
|
-
return (React__default.default.createElement(Container$
|
|
29571
|
+
return (React__default.default.createElement(Container$g, { "data-testid": "SearchResultsList" },
|
|
26934
29572
|
React__default.default.createElement(ResultInfo$2, null, "No results found")));
|
|
26935
29573
|
}
|
|
26936
29574
|
else {
|
|
26937
|
-
return (React__default.default.createElement(Container$
|
|
29575
|
+
return (React__default.default.createElement(Container$g, { "data-testid": "SearchResultsList" },
|
|
26938
29576
|
React__default.default.createElement(ResultInfo$2, null,
|
|
26939
29577
|
pageNumber > 1 && 'Page ' + pageNumber + ' of ',
|
|
26940
29578
|
totalResults,
|
|
@@ -26951,9 +29589,9 @@ var SearchResultsList = function (_a) {
|
|
|
26951
29589
|
}
|
|
26952
29590
|
};
|
|
26953
29591
|
|
|
26954
|
-
const Container$
|
|
29592
|
+
const Container$f = styled__default.default.div``;
|
|
26955
29593
|
|
|
26956
|
-
const SectionTitle$1 = styled__default.default(Heading)`
|
|
29594
|
+
const SectionTitle$1 = styled__default.default(Heading$1)`
|
|
26957
29595
|
background: ${(props) =>
|
|
26958
29596
|
props.theme.cardinal_name === 'north'
|
|
26959
29597
|
? props.theme.theme_vars.colours.grey
|
|
@@ -27043,7 +29681,7 @@ styled__default.default.img`
|
|
|
27043
29681
|
*/
|
|
27044
29682
|
var SectionLinks = function (_a) {
|
|
27045
29683
|
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;
|
|
27046
|
-
return (React__default.default.createElement(Container$
|
|
29684
|
+
return (React__default.default.createElement(Container$f, { id: sectionSlug, "data-testid": "SectionLinks" },
|
|
27047
29685
|
displayTitle ? React__default.default.createElement(SectionTitle$1, { text: sectionTitle }) : React__default.default.createElement("br", null),
|
|
27048
29686
|
React__default.default.createElement(Row$1, { isList: true }, pageLinksArray.map(function (link, i) {
|
|
27049
29687
|
var _a;
|
|
@@ -27057,7 +29695,7 @@ var SectionLinks = function (_a) {
|
|
|
27057
29695
|
}))));
|
|
27058
29696
|
};
|
|
27059
29697
|
|
|
27060
|
-
const Container$
|
|
29698
|
+
const Container$e = styled__default.default.aside`
|
|
27061
29699
|
padding-top: 20px;
|
|
27062
29700
|
display: block;
|
|
27063
29701
|
|
|
@@ -27141,7 +29779,7 @@ const InlineLink = styled__default.default.a`
|
|
|
27141
29779
|
|
|
27142
29780
|
var SectionLinksMobileContents = function (_a) {
|
|
27143
29781
|
var sectionLinksArray = _a.sectionLinksArray;
|
|
27144
|
-
return (React__default.default.createElement(Container$
|
|
29782
|
+
return (React__default.default.createElement(Container$e, null,
|
|
27145
29783
|
React__default.default.createElement(Contents, null,
|
|
27146
29784
|
React__default.default.createElement(ContentsTitle, null, "Contents"),
|
|
27147
29785
|
React__default.default.createElement(ContentsList, null, sectionLinksArray.map(function (link) {
|
|
@@ -27150,7 +29788,7 @@ var SectionLinksMobileContents = function (_a) {
|
|
|
27150
29788
|
})))));
|
|
27151
29789
|
};
|
|
27152
29790
|
|
|
27153
|
-
const Container$
|
|
29791
|
+
const Container$d = styled__default.default.div`
|
|
27154
29792
|
${(props) => props.theme.fontStyles}
|
|
27155
29793
|
background-color: ${(props) => props.theme.theme_vars.colours.action_light};
|
|
27156
29794
|
border-radius: ${(props) => props.theme.theme_vars.border_radius};
|
|
@@ -27301,7 +29939,7 @@ const ListItemLink = styled__default.default.a`
|
|
|
27301
29939
|
var SectionLinksSidebar = function (_a) {
|
|
27302
29940
|
var Title = _a.Title, Sections = _a.Sections;
|
|
27303
29941
|
var _b = React.useState(false), open = _b[0], setOpen = _b[1];
|
|
27304
|
-
return (React__default.default.createElement(Container$
|
|
29942
|
+
return (React__default.default.createElement(Container$d, { "data-testid": "SectionLinksSidebar" },
|
|
27305
29943
|
React__default.default.createElement(MobileTitleButton, { onClick: function () { return (open ? setOpen(false) : setOpen(true)); } },
|
|
27306
29944
|
Title,
|
|
27307
29945
|
React__default.default.createElement(IconWrapper$2, null,
|
|
@@ -27313,7 +29951,7 @@ var SectionLinksSidebar = function (_a) {
|
|
|
27313
29951
|
React__default.default.createElement(ListItemLink, { href: link.url }, link.title))); })))); }))));
|
|
27314
29952
|
};
|
|
27315
29953
|
|
|
27316
|
-
const Container$
|
|
29954
|
+
const Container$c = styled__default.default.div`
|
|
27317
29955
|
position: relative;
|
|
27318
29956
|
`;
|
|
27319
29957
|
|
|
@@ -27465,7 +30103,7 @@ var ServiceLinksBoxed = function (_a) {
|
|
|
27465
30103
|
var _a;
|
|
27466
30104
|
return (_a = refs.current[index]) !== null && _a !== void 0 ? _a : React__default.default.createRef();
|
|
27467
30105
|
});
|
|
27468
|
-
return (React__default.default.createElement(Container$
|
|
30106
|
+
return (React__default.default.createElement(Container$c, { "data-testid": "ServiceLinksBoxed" },
|
|
27469
30107
|
React__default.default.createElement(Row$1, null, serviceLinksArray.map(function (serviceLink, index) {
|
|
27470
30108
|
var _a;
|
|
27471
30109
|
return (React__default.default.createElement(Column, { small: "full", medium: "one-half", large: "one-third", key: index },
|
|
@@ -27502,7 +30140,7 @@ const containerMaxHeight = (props) => {
|
|
|
27502
30140
|
}
|
|
27503
30141
|
};
|
|
27504
30142
|
|
|
27505
|
-
const Container$
|
|
30143
|
+
const Container$b = styled__default.default.div`
|
|
27506
30144
|
${(props) => props.theme.fontStyles}
|
|
27507
30145
|
${containerMaxHeight}
|
|
27508
30146
|
|
|
@@ -27875,7 +30513,7 @@ const Link = styled__default.default.a`
|
|
|
27875
30513
|
}
|
|
27876
30514
|
`;
|
|
27877
30515
|
|
|
27878
|
-
const Title = styled__default.default(Heading)`
|
|
30516
|
+
const Title = styled__default.default(Heading$1)`
|
|
27879
30517
|
${(props) => props.theme.linkStyles}
|
|
27880
30518
|
|
|
27881
30519
|
padding: 15px 0;
|
|
@@ -27917,9 +30555,9 @@ var ServicesLinksList = function (_a) {
|
|
|
27917
30555
|
}
|
|
27918
30556
|
}, [currentOrder]);
|
|
27919
30557
|
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
27920
|
-
React__default.default.createElement(Container$
|
|
30558
|
+
React__default.default.createElement(Container$b, { id: serviceId, className: open && 'open', "$hideHeader": hideHeader, "$isBoxed": isBoxed },
|
|
27921
30559
|
!hideHeader && (React__default.default.createElement(HomeTitle, { "data-testid": "servicesLinksListHeader" },
|
|
27922
|
-
React__default.default.createElement(Heading, { text: "Council services" }),
|
|
30560
|
+
React__default.default.createElement(Heading$1, { text: "Council services" }),
|
|
27923
30561
|
React__default.default.createElement(ReorderControl, null,
|
|
27924
30562
|
"Order services by",
|
|
27925
30563
|
React__default.default.createElement("br", null),
|
|
@@ -27946,7 +30584,7 @@ var ServicesLinksList = function (_a) {
|
|
|
27946
30584
|
" services")))));
|
|
27947
30585
|
};
|
|
27948
30586
|
|
|
27949
|
-
const Container$
|
|
30587
|
+
const Container$a = styled__default.default.div`
|
|
27950
30588
|
${props => props.theme.fontStyles}
|
|
27951
30589
|
max-width: 500px;
|
|
27952
30590
|
border-radius: ${props => props.theme.theme_vars.border_radius};
|
|
@@ -27993,7 +30631,7 @@ const SingleButtonContainer = styled__default.default.div`
|
|
|
27993
30631
|
}
|
|
27994
30632
|
`;
|
|
27995
30633
|
|
|
27996
|
-
const Container$
|
|
30634
|
+
const Container$9 = styled__default.default.div`
|
|
27997
30635
|
strong {
|
|
27998
30636
|
font-weight: bold;
|
|
27999
30637
|
}
|
|
@@ -28134,7 +30772,7 @@ var HintText = function (_a) {
|
|
|
28134
30772
|
return (React__default.default.createElement(HintText$1, null, text));
|
|
28135
30773
|
};
|
|
28136
30774
|
|
|
28137
|
-
const Container$
|
|
30775
|
+
const Container$8 = styled__default.default.div`
|
|
28138
30776
|
display: flex;
|
|
28139
30777
|
-webkit-flex-direction: row;
|
|
28140
30778
|
-moz-flex-direction: row;
|
|
@@ -28171,45 +30809,13 @@ const ErrorSummary = styled__default.default.div`
|
|
|
28171
30809
|
*/
|
|
28172
30810
|
var FormWithLine = function (_a) {
|
|
28173
30811
|
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;
|
|
28174
|
-
return (React__default.default.createElement(Container$
|
|
30812
|
+
return (React__default.default.createElement(Container$8, null,
|
|
28175
30813
|
React__default.default.createElement(Line, { "$lineColour": lineColour, "$hideLine": hideLine, "$isError": isError }),
|
|
28176
30814
|
React__default.default.createElement(Form, { onSubmit: onSubmit, "$hideLine": hideLine, role: formRole, method: formMethod, url: formURL, "data-testid": "FormWithLine" },
|
|
28177
30815
|
errorSummary && React__default.default.createElement(ErrorSummary, null, errorSummary),
|
|
28178
30816
|
children)));
|
|
28179
30817
|
};
|
|
28180
30818
|
|
|
28181
|
-
const Spinner = styled__default.default.div`
|
|
28182
|
-
display: inline-block;
|
|
28183
|
-
width: 80px;
|
|
28184
|
-
height: 80px;
|
|
28185
|
-
|
|
28186
|
-
&:after {
|
|
28187
|
-
content: " ";
|
|
28188
|
-
display: block;
|
|
28189
|
-
width: 50px;
|
|
28190
|
-
height: 50px;
|
|
28191
|
-
margin: 8px;
|
|
28192
|
-
border-radius: 50%;
|
|
28193
|
-
border: 6px solid ${props => props.theme.theme_vars.colours.action};
|
|
28194
|
-
border-color: ${props => props.theme.theme_vars.colours.action} transparent ${props => props.theme.theme_vars.colours.action} transparent;
|
|
28195
|
-
animation: lds-dual-ring 1.2s linear infinite;
|
|
28196
|
-
}
|
|
28197
|
-
|
|
28198
|
-
@keyframes lds-dual-ring {
|
|
28199
|
-
0% {
|
|
28200
|
-
transform: rotate(0deg);
|
|
28201
|
-
}
|
|
28202
|
-
100% {
|
|
28203
|
-
transform: rotate(360deg);
|
|
28204
|
-
}
|
|
28205
|
-
}
|
|
28206
|
-
|
|
28207
|
-
`;
|
|
28208
|
-
|
|
28209
|
-
var LoadingSpinner = function () {
|
|
28210
|
-
return React__default.default.createElement(Spinner, null);
|
|
28211
|
-
};
|
|
28212
|
-
|
|
28213
30819
|
var _a;
|
|
28214
30820
|
var PostcodeSearchApiUrl = (_a = process.env.NEXT_PUBLIC_POSTCODE_SEARCH_API_URL) !== null && _a !== void 0 ? _a : '';
|
|
28215
30821
|
|
|
@@ -28327,7 +30933,7 @@ var PostCodeSearch = function (_a) {
|
|
|
28327
30933
|
setCurrentPostcode(currentPostcode + ' (' + singleAddress.title + ')');
|
|
28328
30934
|
}
|
|
28329
30935
|
}
|
|
28330
|
-
return (React__default.default.createElement(Container$
|
|
30936
|
+
return (React__default.default.createElement(Container$9, { "data-testid": "PostCodeSearch" },
|
|
28331
30937
|
React__default.default.createElement(DropDownButton, { onClick: function () { return setOpen(open ? false : true); } },
|
|
28332
30938
|
React__default.default.createElement(IconWrapper, null,
|
|
28333
30939
|
React__default.default.createElement(ChevronIcon, { direction: open ? 'down' : 'right', colourFill: themeContext.theme_vars.colours.black })),
|
|
@@ -28402,7 +31008,7 @@ var SignpostLinks = function (_a) {
|
|
|
28402
31008
|
var themeContext = React.useContext(styled.ThemeContext);
|
|
28403
31009
|
var councilLink = otherCouncilLink ? otherCouncilLink : themeContext.theme_vars.other_council_link;
|
|
28404
31010
|
return (React__default.default.createElement(React__default.default.Fragment, null, signpostLinksArray.length > 1 ?
|
|
28405
|
-
React__default.default.createElement(Container$
|
|
31011
|
+
React__default.default.createElement(Container$a, null,
|
|
28406
31012
|
React__default.default.createElement(Paragraph, null, TopLineText),
|
|
28407
31013
|
React__default.default.createElement(SignpostLinksList, { signpostLinksArray: signpostLinksArray }),
|
|
28408
31014
|
React__default.default.createElement(PostCodeSearch, { otherCouncilLink: councilLink, signPostLinks: signpostLinksArray }),
|
|
@@ -28502,7 +31108,7 @@ const summaryStyles = (props) => {
|
|
|
28502
31108
|
}
|
|
28503
31109
|
};
|
|
28504
31110
|
|
|
28505
|
-
const Container$
|
|
31111
|
+
const Container$7 = styled__default.default.div`
|
|
28506
31112
|
padding: ${(props) => (props.$hasPadding ? '30px 20px' : '0')};
|
|
28507
31113
|
font-size: 1.2em;
|
|
28508
31114
|
margin-bottom: 15px;
|
|
@@ -28519,7 +31125,7 @@ const Container$8 = styled__default.default.div`
|
|
|
28519
31125
|
|
|
28520
31126
|
var Summary = function (_a) {
|
|
28521
31127
|
var children = _a.children, _b = _a.hasBackground, hasBackground = _b === void 0 ? true : _b, _c = _a.hasPadding, hasPadding = _c === void 0 ? true : _c;
|
|
28522
|
-
return (React__default.default.createElement(Container$
|
|
31128
|
+
return (React__default.default.createElement(Container$7, { "data-testid": "Summary", "$hasBackground": hasBackground, "$hasPadding": hasPadding }, children));
|
|
28523
31129
|
};
|
|
28524
31130
|
|
|
28525
31131
|
var breakpointsVals$4 = {
|
|
@@ -28911,7 +31517,7 @@ var templateObject_1$1, templateObject_2;
|
|
|
28911
31517
|
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"])));
|
|
28912
31518
|
var templateObject_1;
|
|
28913
31519
|
|
|
28914
|
-
const Container$
|
|
31520
|
+
const Container$6 = styled__default.default.div`
|
|
28915
31521
|
display: block;
|
|
28916
31522
|
|
|
28917
31523
|
.striped-column {
|
|
@@ -29028,7 +31634,7 @@ const ServiceImage$1 = styled__default.default.img`
|
|
|
29028
31634
|
left: 0;
|
|
29029
31635
|
`;
|
|
29030
31636
|
|
|
29031
|
-
const Container$
|
|
31637
|
+
const Container$5 = styled__default.default.div`
|
|
29032
31638
|
display: flex;
|
|
29033
31639
|
|
|
29034
31640
|
.striped-contacts {
|
|
@@ -29131,7 +31737,7 @@ var PhoneIcon = function (_a) {
|
|
|
29131
31737
|
var ServiceContact = function (_a) {
|
|
29132
31738
|
var website = _a.website, email = _a.email, contacts = _a.contacts;
|
|
29133
31739
|
var themeContext = React.useContext(styled.ThemeContext);
|
|
29134
|
-
return (React__default.default.createElement(Container$
|
|
31740
|
+
return (React__default.default.createElement(Container$5, { "data-testid": "ServiceContact" },
|
|
29135
31741
|
React__default.default.createElement(Row$1, { hasWrap: false },
|
|
29136
31742
|
website && (React__default.default.createElement(Column, { small: "full", medium: "full", large: "auto", classes: "striped-contacts" },
|
|
29137
31743
|
React__default.default.createElement(IconContainer$1, null,
|
|
@@ -29362,7 +31968,7 @@ var transformAge = function (age, ageInMonths) {
|
|
|
29362
31968
|
return "".concat(age, " years");
|
|
29363
31969
|
};
|
|
29364
31970
|
|
|
29365
|
-
const Container$
|
|
31971
|
+
const Container$4 = styled__default.default.div`
|
|
29366
31972
|
display: block;
|
|
29367
31973
|
`;
|
|
29368
31974
|
|
|
@@ -29376,7 +31982,7 @@ var DirectoryMap = function (_a) {
|
|
|
29376
31982
|
lat: parseFloat(latLong[0]),
|
|
29377
31983
|
lng: parseFloat(latLong[1]),
|
|
29378
31984
|
};
|
|
29379
|
-
return (React__default.default.createElement(Container$
|
|
31985
|
+
return (React__default.default.createElement(Container$4, { "data-testid": "DirectoryMap" }, cookiesAccepted ? (React__default.default.createElement(React__default.default.Fragment, null,
|
|
29380
31986
|
React__default.default.createElement(reactWrapper.Wrapper, { apiKey: apiKey },
|
|
29381
31987
|
React__default.default.createElement(Map$1, { center: center, zoom: (_c = mapProps.zoom) !== null && _c !== void 0 ? _c : 14 }, mapProps.mapMarkers.map(function (marker, index) {
|
|
29382
31988
|
var _a;
|
|
@@ -29477,7 +32083,7 @@ var DirectoryAddToShortList = function (_a) {
|
|
|
29477
32083
|
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")));
|
|
29478
32084
|
};
|
|
29479
32085
|
|
|
29480
|
-
const Container$
|
|
32086
|
+
const Container$3 = styled__default.default.div`
|
|
29481
32087
|
display: flex;
|
|
29482
32088
|
overflow: hidden;
|
|
29483
32089
|
|
|
@@ -29517,7 +32123,7 @@ const WebLink = styled__default.default.a`
|
|
|
29517
32123
|
|
|
29518
32124
|
var ServiceSocialLinks = function (_a) {
|
|
29519
32125
|
var profiles = _a.profiles;
|
|
29520
|
-
return (React__default.default.createElement(Container$
|
|
32126
|
+
return (React__default.default.createElement(Container$3, { "data-testid": "ServiceSocialLinks" },
|
|
29521
32127
|
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" },
|
|
29522
32128
|
React__default.default.createElement(IconContainer, null, getIcon(profile)),
|
|
29523
32129
|
React__default.default.createElement(Content, null,
|
|
@@ -29549,13 +32155,13 @@ var DirectoryService = function (_a) {
|
|
|
29549
32155
|
React.useEffect(function () {
|
|
29550
32156
|
setNotServer(true);
|
|
29551
32157
|
}, []);
|
|
29552
|
-
return (React__default.default.createElement(Container$
|
|
32158
|
+
return (React__default.default.createElement(Container$6, { "data-testid": "DirectoryService" },
|
|
29553
32159
|
React__default.default.createElement(Row$1, null,
|
|
29554
32160
|
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
29555
32161
|
React__default.default.createElement(Row$1, null,
|
|
29556
32162
|
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
29557
32163
|
React__default.default.createElement(ServiceHeader$1, null,
|
|
29558
|
-
React__default.default.createElement(Heading, { level: 1, text: name }),
|
|
32164
|
+
React__default.default.createElement(Heading$1, { level: 1, text: name }),
|
|
29559
32165
|
(organization === null || organization === void 0 ? void 0 : organization.logo) && (React__default.default.createElement(ServiceImageOuter, null,
|
|
29560
32166
|
React__default.default.createElement(ServiceImageContainer$1, null,
|
|
29561
32167
|
React__default.default.createElement(ServiceImage$1, { src: organization.logo, alt: name + ' logo', loading: "lazy" })))))),
|
|
@@ -29575,7 +32181,7 @@ var DirectoryService = function (_a) {
|
|
|
29575
32181
|
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) {
|
|
29576
32182
|
return location.is_visitable != false;
|
|
29577
32183
|
}).map(function (location) { return (React__default.default.createElement("div", { key: location.id },
|
|
29578
|
-
React__default.default.createElement(Heading, { level: 2, text: location.name }),
|
|
32184
|
+
React__default.default.createElement(Heading$1, { level: 2, text: location.name }),
|
|
29579
32185
|
location.physical_addresses.map(function (address) { return (React__default.default.createElement(PhysicalAddress, { key: address.id },
|
|
29580
32186
|
React__default.default.createElement("p", { key: address.id, dangerouslySetInnerHTML: {
|
|
29581
32187
|
__html: Object.values(address)
|
|
@@ -29584,7 +32190,7 @@ var DirectoryService = function (_a) {
|
|
|
29584
32190
|
} }),
|
|
29585
32191
|
React__default.default.createElement(Button$4, { url: "https://google.com/maps/dir//".concat(location.latitude, ",").concat(location.longitude), text: "Get directions" }))); }),
|
|
29586
32192
|
(location === null || location === void 0 ? void 0 : location.accessibility_for_disabilities.length) > 0 && (React__default.default.createElement(React__default.default.Fragment, null,
|
|
29587
|
-
React__default.default.createElement(Heading, { level: 3, text: "Other facilities on site" }),
|
|
32193
|
+
React__default.default.createElement(Heading$1, { level: 3, text: "Other facilities on site" }),
|
|
29588
32194
|
React__default.default.createElement("ul", null, location.accessibility_for_disabilities.map(function (accessibility) { return (React__default.default.createElement("li", { key: accessibility.id }, accessibility.accessibility)); })))))); })),
|
|
29589
32195
|
React__default.default.createElement(Column, { small: "full", medium: "full", large: "two-thirds" }, service_at_locations.filter(function (location) {
|
|
29590
32196
|
return location.is_visitable != false;
|
|
@@ -29613,16 +32219,16 @@ var DirectoryService = function (_a) {
|
|
|
29613
32219
|
} })),
|
|
29614
32220
|
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"))))))),
|
|
29615
32221
|
(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" },
|
|
29616
|
-
React__default.default.createElement(Heading, { level: 2, text: "How to contact this service" }),
|
|
32222
|
+
React__default.default.createElement(Heading$1, { level: 2, text: "How to contact this service" }),
|
|
29617
32223
|
React__default.default.createElement(ServiceContact, { email: email, website: url, contacts: contacts }))),
|
|
29618
32224
|
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full", classes: "striped-column" },
|
|
29619
|
-
React__default.default.createElement(Heading, { level: 2, text: "Description" }),
|
|
32225
|
+
React__default.default.createElement(Heading$1, { level: 2, text: "Description" }),
|
|
29620
32226
|
React__default.default.createElement("div", null,
|
|
29621
32227
|
React__default.default.createElement(React__default.default.Fragment, null, descriptionElement)),
|
|
29622
32228
|
React__default.default.createElement(SummaryList, { terms: transformDescriptionDetails(accreditations, fees, service_areas, languages, eligibilitys, ageInMonths), hasMargin: false }),
|
|
29623
32229
|
React__default.default.createElement(SummaryList, { terms: transformTaxonomies(service_taxonomys, taxonomiesToShow), hasMargin: false })),
|
|
29624
32230
|
regular_schedules.length > 0 && (React__default.default.createElement(Column, { small: "full", medium: "full", large: "full", classes: "striped-column" },
|
|
29625
|
-
React__default.default.createElement(Heading, { level: 2, text: "Service hours" }),
|
|
32231
|
+
React__default.default.createElement(Heading$1, { level: 2, text: "Service hours" }),
|
|
29626
32232
|
React__default.default.createElement("div", { className: "table-container" },
|
|
29627
32233
|
React__default.default.createElement("table", null,
|
|
29628
32234
|
React__default.default.createElement("thead", null,
|
|
@@ -29635,10 +32241,10 @@ var DirectoryService = function (_a) {
|
|
|
29635
32241
|
React__default.default.createElement("td", null, schedule.opens_at),
|
|
29636
32242
|
React__default.default.createElement("td", null, schedule.closes_at))); })))))),
|
|
29637
32243
|
(uploads === null || uploads === void 0 ? void 0 : uploads.length) > 0 && (React__default.default.createElement(Column, { small: "full", medium: "full", large: "full", classes: "striped-column" },
|
|
29638
|
-
React__default.default.createElement(Heading, { level: 2, text: "Some resources that can help" }),
|
|
32244
|
+
React__default.default.createElement(Heading$1, { level: 2, text: "Some resources that can help" }),
|
|
29639
32245
|
React__default.default.createElement(DownloadableFiles, { files: uploads }))),
|
|
29640
32246
|
(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" },
|
|
29641
|
-
React__default.default.createElement(Heading, { level: 2, text: "Follow this service" }),
|
|
32247
|
+
React__default.default.createElement(Heading$1, { level: 2, text: "Follow this service" }),
|
|
29642
32248
|
React__default.default.createElement(ServiceSocialLinks, { profiles: service_social_profiles }))),
|
|
29643
32249
|
service_at_locations.filter(function (location) {
|
|
29644
32250
|
return location.is_visitable == false;
|
|
@@ -29648,7 +32254,7 @@ var DirectoryService = function (_a) {
|
|
|
29648
32254
|
})
|
|
29649
32255
|
.map(function (location) { return (React__default.default.createElement(Row$1, { key: location.id },
|
|
29650
32256
|
React__default.default.createElement(Column, { small: "full", medium: "one-half", large: "one-third", key: location.id },
|
|
29651
|
-
React__default.default.createElement(Heading, { level: 2, text: location.name }),
|
|
32257
|
+
React__default.default.createElement(Heading$1, { level: 2, text: location.name }),
|
|
29652
32258
|
location.physical_addresses.map(function (address) { return (React__default.default.createElement(PhysicalAddress, { key: address.id },
|
|
29653
32259
|
React__default.default.createElement("p", { key: address.id, dangerouslySetInnerHTML: {
|
|
29654
32260
|
__html: Object.values(address)
|
|
@@ -29656,11 +32262,11 @@ var DirectoryService = function (_a) {
|
|
|
29656
32262
|
.join(' <br />'),
|
|
29657
32263
|
} }))); }),
|
|
29658
32264
|
(location === null || location === void 0 ? void 0 : location.accessibility_for_disabilities.length) > 0 && (React__default.default.createElement(React__default.default.Fragment, null,
|
|
29659
|
-
React__default.default.createElement(Heading, { level: 3, text: "Other facilities on site" }),
|
|
32265
|
+
React__default.default.createElement(Heading$1, { level: 3, text: "Other facilities on site" }),
|
|
29660
32266
|
React__default.default.createElement("ul", null, location.accessibility_for_disabilities.map(function (accessibility) { return (React__default.default.createElement("li", { key: accessibility.id }, accessibility.accessibility)); }))))))); }))))));
|
|
29661
32267
|
};
|
|
29662
32268
|
|
|
29663
|
-
const Container$
|
|
32269
|
+
const Container$2 = styled__default.default.div`
|
|
29664
32270
|
display: block;
|
|
29665
32271
|
|
|
29666
32272
|
input {
|
|
@@ -29839,7 +32445,7 @@ const AccordionIcon = styled__default.default.span`
|
|
|
29839
32445
|
}
|
|
29840
32446
|
`;
|
|
29841
32447
|
|
|
29842
|
-
const Category$
|
|
32448
|
+
const Category$1 = styled__default.default.div``;
|
|
29843
32449
|
|
|
29844
32450
|
styled__default.default.div`
|
|
29845
32451
|
font-weight: bold;
|
|
@@ -30021,111 +32627,6 @@ var PinIcon = function (_a) {
|
|
|
30021
32627
|
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 })));
|
|
30022
32628
|
};
|
|
30023
32629
|
|
|
30024
|
-
const Container$2 = styled__default.default.div`
|
|
30025
|
-
display: block;
|
|
30026
|
-
`;
|
|
30027
|
-
|
|
30028
|
-
const Category$1 = styled__default.default.div`
|
|
30029
|
-
font-size: ${(props) => props.theme.theme_vars.fontSizes.small};
|
|
30030
|
-
display: block;
|
|
30031
|
-
position: relative;
|
|
30032
|
-
min-height: 40px;
|
|
30033
|
-
margin-bottom: 10px;
|
|
30034
|
-
padding-left: 40px;
|
|
30035
|
-
clear: left;
|
|
30036
|
-
`;
|
|
30037
|
-
|
|
30038
|
-
const CategoryInput = styled__default.default.input`
|
|
30039
|
-
cursor: pointer;
|
|
30040
|
-
position: absolute;
|
|
30041
|
-
z-index: 1;
|
|
30042
|
-
top: -2px;
|
|
30043
|
-
left: -2px;
|
|
30044
|
-
width: 44px;
|
|
30045
|
-
height: 44px;
|
|
30046
|
-
margin: 0;
|
|
30047
|
-
opacity: 0;
|
|
30048
|
-
|
|
30049
|
-
&:focus + label:before {
|
|
30050
|
-
box-shadow: 0 0 0 3px ${(props) => props.theme.theme_vars.colours.focus};
|
|
30051
|
-
}
|
|
30052
|
-
`;
|
|
30053
|
-
|
|
30054
|
-
/**
|
|
30055
|
-
* If single selection then use styles for radio button, otherwise checkbox styles
|
|
30056
|
-
*/
|
|
30057
|
-
const checkedMarker = (props) => {
|
|
30058
|
-
if (props.$singleSelection) {
|
|
30059
|
-
return styled.css`
|
|
30060
|
-
top: 10px;
|
|
30061
|
-
left: 10px;
|
|
30062
|
-
width: 0;
|
|
30063
|
-
height: 0;
|
|
30064
|
-
border: 10px solid currentcolor;
|
|
30065
|
-
border-radius: 50%;
|
|
30066
|
-
background: currentcolor;
|
|
30067
|
-
`;
|
|
30068
|
-
} else {
|
|
30069
|
-
return styled.css`
|
|
30070
|
-
top: 11px;
|
|
30071
|
-
left: 9px;
|
|
30072
|
-
width: 23px;
|
|
30073
|
-
height: 12px;
|
|
30074
|
-
-webkit-transform: rotate(-45deg);
|
|
30075
|
-
-ms-transform: rotate(-45deg);
|
|
30076
|
-
transform: rotate(-45deg);
|
|
30077
|
-
border: solid;
|
|
30078
|
-
border-width: 0 0 5px 5px;
|
|
30079
|
-
border-top-color: transparent;
|
|
30080
|
-
background: transparent;
|
|
30081
|
-
`;
|
|
30082
|
-
}
|
|
30083
|
-
};
|
|
30084
|
-
|
|
30085
|
-
const CategoryInputLabel = styled__default.default.label`
|
|
30086
|
-
display: inline-block;
|
|
30087
|
-
margin-bottom: 0;
|
|
30088
|
-
padding: 8px 15px 5px;
|
|
30089
|
-
cursor: pointer;
|
|
30090
|
-
-ms-touch-action: manipulation;
|
|
30091
|
-
touch-action: manipulation;
|
|
30092
|
-
color: #0b0c0c;
|
|
30093
|
-
display: block;
|
|
30094
|
-
margin-bottom: 5px;
|
|
30095
|
-
|
|
30096
|
-
&:before {
|
|
30097
|
-
content: '';
|
|
30098
|
-
-webkit-box-sizing: border-box;
|
|
30099
|
-
box-sizing: border-box;
|
|
30100
|
-
position: absolute;
|
|
30101
|
-
top: 0;
|
|
30102
|
-
left: 0;
|
|
30103
|
-
width: 40px;
|
|
30104
|
-
height: 40px;
|
|
30105
|
-
border: 2px solid currentColor;
|
|
30106
|
-
background: transparent;
|
|
30107
|
-
border-radius: ${(props) => (props.$singleSelection ? '100%' : 0)};
|
|
30108
|
-
}
|
|
30109
|
-
|
|
30110
|
-
&:after {
|
|
30111
|
-
content: '';
|
|
30112
|
-
-webkit-box-sizing: border-box;
|
|
30113
|
-
box-sizing: border-box;
|
|
30114
|
-
position: absolute;
|
|
30115
|
-
opacity: ${(props) => (props.$isChecked ? 1 : 0)};
|
|
30116
|
-
${checkedMarker}
|
|
30117
|
-
}
|
|
30118
|
-
`;
|
|
30119
|
-
|
|
30120
|
-
var RadioCheckboxInput = function (_a) {
|
|
30121
|
-
var singleSelection = _a.singleSelection, value = _a.value, name = _a.name, onChange = _a.onChange, checked = _a.checked, label = _a.label;
|
|
30122
|
-
var id = React.useId();
|
|
30123
|
-
return (React__default.default.createElement(Container$2, { "data-testid": "RadioCheckboxInput" },
|
|
30124
|
-
React__default.default.createElement(Category$1, null,
|
|
30125
|
-
React__default.default.createElement(CategoryInput, { type: singleSelection ? 'radio' : 'checkbox', value: value, id: id, name: name, onClick: onChange, defaultChecked: checked }),
|
|
30126
|
-
React__default.default.createElement(CategoryInputLabel, { "$isChecked": checked, htmlFor: id, "$singleSelection": singleSelection }, label))));
|
|
30127
|
-
};
|
|
30128
|
-
|
|
30129
32630
|
var DirectoryServiceList = function (_a) {
|
|
30130
32631
|
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;
|
|
30131
32632
|
var _s = useLocalStorage("".concat(directoryPath.replace(/\//g, ''), "-accordion"), []), accordions = _s[0], setAccordions = _s[1];
|
|
@@ -30247,7 +32748,7 @@ var DirectoryServiceList = function (_a) {
|
|
|
30247
32748
|
});
|
|
30248
32749
|
}));
|
|
30249
32750
|
};
|
|
30250
|
-
return (React__default.default.createElement(Container$
|
|
32751
|
+
return (React__default.default.createElement(Container$2, { "data-testid": "DirectoryServiceList" },
|
|
30251
32752
|
React__default.default.createElement(Row$1, null,
|
|
30252
32753
|
React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
30253
32754
|
React__default.default.createElement(SearchHeader$1, null,
|
|
@@ -30309,7 +32810,7 @@ var DirectoryServiceList = function (_a) {
|
|
|
30309
32810
|
React__default.default.createElement(Accordion, { "$isOpen": accordions[categoryIndex + 1] },
|
|
30310
32811
|
React__default.default.createElement(ClearFilter$1, null,
|
|
30311
32812
|
React__default.default.createElement(TextLink$1, { onClick: function (e) { return clearCategory(categoryIndex); } }, "Clear filter")),
|
|
30312
|
-
category.options.map(function (taxonomy) { return (React__default.default.createElement(Category$
|
|
32813
|
+
category.options.map(function (taxonomy) { return (React__default.default.createElement(Category$1, { key: taxonomy.id },
|
|
30313
32814
|
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); } }))); }))))); })))))),
|
|
30314
32815
|
React__default.default.createElement(Column, { small: "full", medium: "two-thirds", large: "two-thirds" },
|
|
30315
32816
|
React__default.default.createElement(Row$1, null, isError ? (React__default.default.createElement(Column, { small: "full", medium: "full", large: "full" },
|
|
@@ -32129,7 +34630,7 @@ exports.GDS_theme = GDS_theme;
|
|
|
32129
34630
|
exports.GlobalStyleReset = GlobalStyleReset;
|
|
32130
34631
|
exports.GoogleMap = GoogleMap;
|
|
32131
34632
|
exports.Header = Header;
|
|
32132
|
-
exports.Heading = Heading;
|
|
34633
|
+
exports.Heading = Heading$1;
|
|
32133
34634
|
exports.HeadingWithIcon = HeadingWithIcon;
|
|
32134
34635
|
exports.HeroImage = HeroImage;
|
|
32135
34636
|
exports.HomeHero = HomeHero;
|
|
@@ -32158,6 +34659,7 @@ exports.PromoBanner = PromoBanner;
|
|
|
32158
34659
|
exports.PromoBlock = PromoBlock;
|
|
32159
34660
|
exports.PromotedLinks = PromotedLinks;
|
|
32160
34661
|
exports.Promotions = Promotions;
|
|
34662
|
+
exports.RateThisPage = RateThisPage;
|
|
32161
34663
|
exports.SearchBox = SearchBox;
|
|
32162
34664
|
exports.SearchResultsList = SearchResultsList;
|
|
32163
34665
|
exports.Searchbar = Searchbar;
|