@hmlr/govuk-react-components-library 1.2.2 → 1.2.3
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/.prettierignore +2 -0
- package/README.md +1 -1
- package/assets/uml-diagram.svg +4 -4
- package/dist/PDFViewerCanvas.cjs.js +1 -1
- package/dist/PDFViewerCanvas.cjs.js.map +1 -1
- package/dist/PDFViewerCanvas.esm.js +1 -1
- package/dist/PDFViewerCanvas.esm.js.map +1 -1
- package/dist/index.cjs.css +127 -134
- package/dist/index.cjs.js +52 -27
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.css +127 -134
- package/dist/index.esm.js +52 -27
- package/dist/index.esm.js.map +1 -1
- package/package.json +74 -58
- package/scripts/generateStories.mjs +19 -1
- package/bundle-analysis-main.html +0 -4949
- package/bundle-analysis-pdfvc.html +0 -4949
package/dist/index.esm.js
CHANGED
|
@@ -229,7 +229,7 @@ const Button = (props) => {
|
|
|
229
229
|
iconHtml = (jsx("svg", { className: "govuk-button__start-icon", xmlns: "http://www.w3.org/2000/svg", width: "17.5", height: "19", viewBox: "0 0 33 40", "aria-hidden": "true", focusable: "false", children: jsx("path", { fill: "currentColor", d: "M0 0h13l20 20-20 20H0l20-20z" }) }));
|
|
230
230
|
}
|
|
231
231
|
const commonAttributes = {
|
|
232
|
-
className: `govuk-button ${className || ""}
|
|
232
|
+
className: `govuk-button ${className || ""} ${isStartButton ? "govuk-button--start" : ""}`,
|
|
233
233
|
// ref: buttonRef,
|
|
234
234
|
};
|
|
235
235
|
if (preventDoubleClick) {
|
|
@@ -613,28 +613,36 @@ const defaultProps$1 = {
|
|
|
613
613
|
name: "",
|
|
614
614
|
};
|
|
615
615
|
const Textarea = React__default.forwardRef((props = defaultProps$1, ref) => {
|
|
616
|
-
const { className, "aria-describedby": describedBy, errorMessage, formGroup, hint, label, id, ...attributes } = props;
|
|
616
|
+
const { className, "aria-describedby": describedBy, errorMessage, formGroup, hint, label, id, name, ...attributes } = props;
|
|
617
|
+
// Mirrors govuk-frontend's Nunjucks macro, which defaults id to name when
|
|
618
|
+
// id isn't given - without this the textarea has no id, so its <label for>
|
|
619
|
+
// (and hint/error aria-describedby) can never associate with it.
|
|
620
|
+
const resolvedId = id || name;
|
|
617
621
|
let describedByValue = describedBy || "";
|
|
618
622
|
let hintComponent = null;
|
|
619
623
|
let errorMessageComponent = null;
|
|
620
624
|
if (hint) {
|
|
621
|
-
const hintId = `${
|
|
625
|
+
const hintId = `${resolvedId}-hint`;
|
|
622
626
|
describedByValue += ` ${hintId}`;
|
|
623
627
|
hintComponent = jsx(Hint, { ...hint, id: hintId });
|
|
624
628
|
}
|
|
625
629
|
if (errorMessage) {
|
|
626
|
-
const errorId =
|
|
630
|
+
const errorId = resolvedId ? `${resolvedId}-error` : "";
|
|
627
631
|
describedByValue += ` ${errorId}`;
|
|
628
632
|
errorMessageComponent = jsx(ErrorMessage, { ...errorMessage, id: errorId });
|
|
629
633
|
}
|
|
630
|
-
return (jsxs("div", { className: `govuk-form-group${errorMessage ? " govuk-form-group--error" : ""} ${formGroup?.className || ""}`, children: [jsx(Label, { ...label, htmlFor:
|
|
634
|
+
return (jsxs("div", { className: `govuk-form-group${errorMessage ? " govuk-form-group--error" : ""} ${formGroup?.className || ""}`, children: [jsx(Label, { ...label, htmlFor: resolvedId }), hintComponent, errorMessageComponent, jsx("textarea", { name: name, ...attributes, id: resolvedId, ref: ref, className: `govuk-textarea${errorMessage ? " govuk-textarea--error" : ""} ${className || ""}`, "aria-describedby": describedByValue?.trim() || undefined })] }));
|
|
631
635
|
});
|
|
632
636
|
Textarea.displayName = "Textarea";
|
|
633
637
|
|
|
634
638
|
const CharacterCount = (props) => {
|
|
635
|
-
const { id, className, maxlength, threshold, maxwords, errorMessage, countMessage, ...attributes } = props;
|
|
636
|
-
|
|
637
|
-
|
|
639
|
+
const { id, name, className, maxlength, threshold, maxwords, errorMessage, countMessage, ...attributes } = props;
|
|
640
|
+
// Mirrors govuk-frontend's Nunjucks macro, which defaults id to name when
|
|
641
|
+
// id isn't given - without this the count message's id (referenced by the
|
|
642
|
+
// textarea's aria-describedby) would render as literally "undefined-info".
|
|
643
|
+
const resolvedId = id || name;
|
|
644
|
+
const characterCountInfoId = `${resolvedId}-info`;
|
|
645
|
+
return (jsxs("div", { className: "govuk-character-count", "data-module": "govuk-character-count", "data-maxlength": maxlength, "data-threshold": threshold, "data-maxwords": maxwords, children: [jsx(Textarea, { id: resolvedId, name: name, ...attributes, errorMessage: errorMessage, className: `govuk-js-character-count ${className || ""}${errorMessage ? " govuk-textarea--error" : ""}`, "aria-describedby": characterCountInfoId }), jsxs(Hint, { id: characterCountInfoId, className: `govuk-hint govuk-character-count__message ${countMessage?.className || ""}`, "aria-live": "polite", children: ["You have ", maxlength || maxwords, " ", maxwords ? "words" : "characters", " ", "remaining"] })] }));
|
|
638
646
|
};
|
|
639
647
|
CharacterCount.displayName = "CharacterCount";
|
|
640
648
|
|
|
@@ -682,21 +690,25 @@ const defaultProps = {
|
|
|
682
690
|
};
|
|
683
691
|
const Input = React__default.forwardRef((props = defaultProps, ref) => {
|
|
684
692
|
const { className, "aria-describedby": describedBy, errorMessage, formGroup, hint, label, name, id, prefix, suffix, ...attributes } = props;
|
|
693
|
+
// Mirrors govuk-frontend's Nunjucks macro, which defaults id to name when
|
|
694
|
+
// id isn't given - without this the input has no id, so its <label for>
|
|
695
|
+
// (and hint/error aria-describedby) can never associate with it.
|
|
696
|
+
const resolvedId = id || name;
|
|
685
697
|
let describedByValue = describedBy || "";
|
|
686
698
|
let hintComponent = null;
|
|
687
699
|
let errorMessageComponent = null;
|
|
688
700
|
if (hint) {
|
|
689
|
-
const hintId = `${
|
|
701
|
+
const hintId = `${resolvedId}-hint`;
|
|
690
702
|
describedByValue += ` ${hintId}`;
|
|
691
703
|
hintComponent = jsx(Hint, { ...hint, id: hintId });
|
|
692
704
|
}
|
|
693
705
|
if (errorMessage) {
|
|
694
|
-
const errorId =
|
|
706
|
+
const errorId = resolvedId ? `${resolvedId}-error` : "";
|
|
695
707
|
describedByValue += ` ${errorId}`;
|
|
696
708
|
errorMessageComponent = jsx(ErrorMessage, { ...errorMessage, id: errorId });
|
|
697
709
|
}
|
|
698
|
-
const input = (jsx("input", { ref: ref, id:
|
|
699
|
-
return (jsxs("div", { className: `govuk-form-group ${formGroup?.className || ""} ${errorMessage ? "govuk-form-group--error" : ""}`, children: [jsx(Label, { ...label, htmlFor:
|
|
710
|
+
const input = (jsx("input", { ref: ref, id: resolvedId, className: `govuk-input ${className || ""} ${errorMessage ? " govuk-input--error" : ""}`, name: name || resolvedId, "aria-describedby": describedByValue || undefined, ...attributes }));
|
|
711
|
+
return (jsxs("div", { className: `govuk-form-group ${formGroup?.className || ""} ${errorMessage ? "govuk-form-group--error" : ""}`, children: [jsx(Label, { ...label, htmlFor: resolvedId }), hintComponent, errorMessageComponent, prefix || suffix ? (jsxs("div", { className: "govuk-input__wrapper", children: [prefix ? (jsx("div", { "aria-hidden": "true", ...prefix,
|
|
700
712
|
className: `govuk-input__prefix ${prefix.className ? prefix.className : ""}` })) : null, input, suffix ? (jsx("div", { "aria-hidden": "true", ...suffix,
|
|
701
713
|
className: `govuk-input__suffix ${suffix.className ? suffix.className : ""}` })) : null] })) : (input)] }));
|
|
702
714
|
});
|
|
@@ -877,21 +889,25 @@ function ConfigureOverallExitThisPage($scope) {
|
|
|
877
889
|
}
|
|
878
890
|
|
|
879
891
|
const FileUpload = (props) => {
|
|
880
|
-
const { className, errorMessage, formGroup, hint, label, "aria-describedby": describedBy, id, ...attributes } = props;
|
|
892
|
+
const { className, errorMessage, formGroup, hint, label, "aria-describedby": describedBy, id, name, ...attributes } = props;
|
|
893
|
+
// Mirrors govuk-frontend's Nunjucks macro, which defaults id to name when
|
|
894
|
+
// id isn't given - without this the input has no id, so its <label for>
|
|
895
|
+
// (and hint/error aria-describedby) can never associate with it.
|
|
896
|
+
const resolvedId = id || name;
|
|
881
897
|
let hintComponent;
|
|
882
898
|
let errorMessageComponent;
|
|
883
899
|
let describedByValue = describedBy || "";
|
|
884
900
|
if (hint) {
|
|
885
|
-
const hintId = `${
|
|
901
|
+
const hintId = `${resolvedId}-hint`;
|
|
886
902
|
describedByValue += ` ${hintId}`;
|
|
887
|
-
hintComponent = jsx(Hint, { ...
|
|
903
|
+
hintComponent = jsx(Hint, { ...hint, id: hintId });
|
|
888
904
|
}
|
|
889
905
|
if (errorMessage) {
|
|
890
|
-
const errorId = `${
|
|
906
|
+
const errorId = `${resolvedId}-error`;
|
|
891
907
|
describedByValue += ` ${errorId}`;
|
|
892
908
|
errorMessageComponent = jsx(ErrorMessage, { ...errorMessage, id: errorId });
|
|
893
909
|
}
|
|
894
|
-
return (jsxs("div", { className: `govuk-form-group${errorMessage ? " govuk-form-group--error" : ""} ${formGroup?.className || ""}`, children: [jsx(Label, { ...label, htmlFor:
|
|
910
|
+
return (jsxs("div", { className: `govuk-form-group${errorMessage ? " govuk-form-group--error" : ""} ${formGroup?.className || ""}`, children: [jsx(Label, { ...label, htmlFor: resolvedId }), hintComponent, errorMessageComponent, jsx("input", { name: name, ...attributes, id: resolvedId, className: `govuk-file-upload ${className || ""}${errorMessage ? " govuk-file-upload--error" : ""}`, type: "file", "aria-describedby": describedByValue || undefined })] }));
|
|
895
911
|
};
|
|
896
912
|
FileUpload.displayName = "FileUpload";
|
|
897
913
|
|
|
@@ -1052,7 +1068,7 @@ const Pagination = ({ previous, next, items, className, }) => {
|
|
|
1052
1068
|
// Block layout is used when there are no numbered page items — govuk renders
|
|
1053
1069
|
// the nav with an extra class and the link title with --decorated modifier.
|
|
1054
1070
|
const isBlockLayout = !items || items.length === 0;
|
|
1055
|
-
return (jsxs("nav", { className: `govuk-pagination${isBlockLayout ? " govuk-pagination--block" : ""}${className ? ` ${className}` : ""}`, role: "navigation", "aria-label": "Pagination", children: [previous && (jsx("div", { className: "govuk-pagination__prev", children: jsx(NavigationButton, { type: "previous", ...previous }) })), items && items.length > 0 && (jsx("ul", { className: "govuk-pagination__list", children: items.map((item, index) => item.ellipsis ? (jsx("li", { className: "govuk-pagination__item govuk-pagination__item--
|
|
1071
|
+
return (jsxs("nav", { className: `govuk-pagination${isBlockLayout ? " govuk-pagination--block" : ""}${className ? ` ${className}` : ""}`, role: "navigation", "aria-label": "Pagination", children: [previous && (jsx("div", { className: "govuk-pagination__prev", children: jsx(NavigationButton, { type: "previous", ...previous }) })), items && items.length > 0 && (jsx("ul", { className: "govuk-pagination__list", children: items.map((item, index) => item.ellipsis ? (jsx("li", { className: "govuk-pagination__item govuk-pagination__item--ellipsis", children: DOTS }, index)) : (jsx("li", { className: `govuk-pagination__item${item.current ? " govuk-pagination__item--current" : ""}`, children: jsx("a", { className: "govuk-link govuk-pagination__link", href: item.href ?? "#", "aria-label": `Page ${item.number}`, ...(item.current ? { "aria-current": "page" } : {}), children: item.number }) }, index))) })), next && (jsx("div", { className: "govuk-pagination__next", children: jsx(NavigationButton, { type: "next", ...next }) }))] }));
|
|
1056
1072
|
};
|
|
1057
1073
|
|
|
1058
1074
|
const Panel = (props) => {
|
|
@@ -1063,16 +1079,21 @@ const Panel = (props) => {
|
|
|
1063
1079
|
|
|
1064
1080
|
const PasswordInput = React__default.forwardRef((props, ref) => {
|
|
1065
1081
|
const { className, "aria-describedby": describedBy, errorMessage, formGroup, hint, label, name, id, autoComplete = "current-password", showPasswordText = "Show", hidePasswordText = "Hide", showPasswordAriaLabelText = "Show password", hidePasswordAriaLabelText = "Hide password", passwordShownAnnouncementText, passwordHiddenAnnouncementText, ...attributes } = props;
|
|
1082
|
+
// Mirrors govuk-frontend's Nunjucks macro, which defaults id to name
|
|
1083
|
+
// when id isn't given - without this the input has no id, so its
|
|
1084
|
+
// <label for> (and hint/error aria-describedby) can never associate
|
|
1085
|
+
// with it.
|
|
1086
|
+
const resolvedId = id || name;
|
|
1066
1087
|
let describedByValue = describedBy || "";
|
|
1067
1088
|
let hintComponent = null;
|
|
1068
1089
|
let errorMessageComponent = null;
|
|
1069
1090
|
if (hint) {
|
|
1070
|
-
const hintId = `${
|
|
1091
|
+
const hintId = `${resolvedId}-hint`;
|
|
1071
1092
|
describedByValue += ` ${hintId}`;
|
|
1072
1093
|
hintComponent = jsx(Hint, { ...hint, id: hintId });
|
|
1073
1094
|
}
|
|
1074
1095
|
if (errorMessage) {
|
|
1075
|
-
const errorId =
|
|
1096
|
+
const errorId = resolvedId ? `${resolvedId}-error` : "";
|
|
1076
1097
|
describedByValue += ` ${errorId}`;
|
|
1077
1098
|
errorMessageComponent = jsx(ErrorMessage, { ...errorMessage, id: errorId });
|
|
1078
1099
|
}
|
|
@@ -1095,8 +1116,8 @@ const PasswordInput = React__default.forwardRef((props, ref) => {
|
|
|
1095
1116
|
i18nProps["data-i18n.password-hidden-announcement"] =
|
|
1096
1117
|
passwordHiddenAnnouncementText;
|
|
1097
1118
|
// Label handles isPageHeading internally — no extra wrapper needed here
|
|
1098
|
-
const labelEl = jsx(Label, { ...label, htmlFor:
|
|
1099
|
-
return (jsxs("div", { className: `govuk-form-group${formGroup?.className ? ` ${formGroup.className}` : ""}${errorMessage ? " govuk-form-group--error" : ""} govuk-password-input`, "data-module": "govuk-password-input", ...i18nProps, children: [labelEl, hintComponent, errorMessageComponent, jsxs("div", { className: "govuk-input__wrapper govuk-password-input__wrapper", children: [jsx("input", { ref: ref, id:
|
|
1119
|
+
const labelEl = jsx(Label, { ...label, htmlFor: resolvedId });
|
|
1120
|
+
return (jsxs("div", { className: `govuk-form-group${formGroup?.className ? ` ${formGroup.className}` : ""}${errorMessage ? " govuk-form-group--error" : ""} govuk-password-input`, "data-module": "govuk-password-input", ...i18nProps, children: [labelEl, hintComponent, errorMessageComponent, jsxs("div", { className: "govuk-input__wrapper govuk-password-input__wrapper", children: [jsx("input", { ref: ref, id: resolvedId, className: `govuk-input govuk-password-input__input govuk-js-password-input-input${className ? ` ${className}` : ""}${errorMessage ? " govuk-input--error" : ""}`, name: name || resolvedId, type: "password", spellCheck: false, autoComplete: autoComplete, autoCapitalize: "none", "aria-describedby": describedByValue.trim() || undefined, ...attributes }), jsx("button", { type: "button", className: "govuk-button govuk-button--secondary govuk-password-input__toggle govuk-js-password-input-toggle", "data-module": "govuk-button", "aria-controls": resolvedId, "aria-label": showPasswordAriaLabelText, hidden: true, children: showPasswordText })] })] }));
|
|
1100
1121
|
});
|
|
1101
1122
|
PasswordInput.displayName = "PasswordInput";
|
|
1102
1123
|
|
|
@@ -1472,17 +1493,21 @@ function ConfigureOverallRadios($scope) {
|
|
|
1472
1493
|
}
|
|
1473
1494
|
|
|
1474
1495
|
const Select = (props) => {
|
|
1475
|
-
const { className, "aria-describedby": describedBy, errorMessage, formGroup, hint, id, items, label, ...attributes } = props;
|
|
1496
|
+
const { className, "aria-describedby": describedBy, errorMessage, formGroup, hint, id, name, items, label, ...attributes } = props;
|
|
1497
|
+
// Mirrors govuk-frontend's Nunjucks macro, which defaults id to name when
|
|
1498
|
+
// id isn't given - without this the select has no id, so its <label for>
|
|
1499
|
+
// (and hint/error aria-describedby) can never associate with it.
|
|
1500
|
+
const resolvedId = id || name;
|
|
1476
1501
|
let describedByValue = describedBy || "";
|
|
1477
1502
|
let hintComponent;
|
|
1478
1503
|
let errorMessageComponent;
|
|
1479
1504
|
if (hint) {
|
|
1480
|
-
const hintId = `${
|
|
1505
|
+
const hintId = `${resolvedId}-hint`;
|
|
1481
1506
|
describedByValue += ` ${hintId}`;
|
|
1482
1507
|
hintComponent = jsx(Hint, { ...hint, id: hintId });
|
|
1483
1508
|
}
|
|
1484
1509
|
if (errorMessage) {
|
|
1485
|
-
const errorId =
|
|
1510
|
+
const errorId = resolvedId ? `${resolvedId}-error` : "";
|
|
1486
1511
|
describedByValue += ` ${errorId}`;
|
|
1487
1512
|
errorMessageComponent = jsx(ErrorMessage, { ...errorMessage, id: errorId });
|
|
1488
1513
|
}
|
|
@@ -1494,12 +1519,12 @@ const Select = (props) => {
|
|
|
1494
1519
|
return (createElement("option", { ...optionAttributes, key: reactListKey || index }, children));
|
|
1495
1520
|
})
|
|
1496
1521
|
: null;
|
|
1497
|
-
return (jsxs("div", { className: `govuk-form-group${errorMessage ? " govuk-form-group--error" : ""} ${formGroup?.className || ""}`, children: [jsx(Label, { ...label, htmlFor:
|
|
1522
|
+
return (jsxs("div", { className: `govuk-form-group${errorMessage ? " govuk-form-group--error" : ""} ${formGroup?.className || ""}`, children: [jsx(Label, { ...label, htmlFor: resolvedId }), hintComponent, errorMessageComponent, jsx("select", { className: `govuk-select ${className || ""}${errorMessage ? " govuk-select--error" : ""}`, id: resolvedId, name: name, "aria-describedby": describedByValue || undefined, ...attributes, children: options })] }));
|
|
1498
1523
|
};
|
|
1499
1524
|
|
|
1500
1525
|
const ServiceNavigation = (props) => {
|
|
1501
1526
|
const { className, containerClassName = "govuk-width-container", menuButtonLabel = "Show or hide menu", navigation, navigationClassName, navigationLabel = "Menu", serviceName, serviceUrlHref, serviceUrlTo, ...attributes } = props;
|
|
1502
|
-
return (jsx("section", { "aria-label": "Service information", className: `govuk-service-navigation ${className || ""}`, "data-module": "govuk-service-navigation", ...attributes, children: jsx("div", { className: `govuk-width-container ${containerClassName}`, children: jsxs("div", { className: "govuk-service-navigation__container", children: [serviceName ? (jsx("span", { className: "govuk-service-navigation__service-name", children: jsx(LinkWithRef, { href: serviceUrlHref, to: serviceUrlTo, className: "govuk-
|
|
1527
|
+
return (jsx("section", { "aria-label": "Service information", className: `govuk-service-navigation ${className || ""}`, "data-module": "govuk-service-navigation", ...attributes, children: jsx("div", { className: `govuk-width-container ${containerClassName}`, children: jsxs("div", { className: "govuk-service-navigation__container", children: [serviceName ? (jsx("span", { className: "govuk-service-navigation__service-name", children: jsx(LinkWithRef, { href: serviceUrlHref, to: serviceUrlTo, className: "govuk-service-navigation__link", children: serviceName }) })) : null, navigation ? (jsxs("nav", { "aria-label": navigationLabel, className: `govuk-service-navigation__wrapper ${navigationClassName || ""}`, children: [jsx("button", { type: "button", className: "govuk-service-navigation__toggle govuk-js-service-navigation-toggle", "aria-controls": "navigation", "aria-label": menuButtonLabel, hidden: true, children: "Menu" }), jsx("ul", { className: "govuk-service-navigation__list", id: "navigation", children: navigation.map((item, index) => {
|
|
1503
1528
|
const { active: itemActive, className: itemClassName, children: itemChildren, reactListKey, ...itemAttributes } = item;
|
|
1504
1529
|
return itemChildren ? (jsx("li", { className: `govuk-service-navigation__item${itemActive
|
|
1505
1530
|
? " govuk-service-navigation__item--active"
|