@hmlr/govuk-react-components-library 1.0.3 → 1.1.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/.stylelintrc.json +1 -1
- package/README.md +215 -1
- package/assets/uml-diagram.svg +731 -572
- package/bundle-analysis-main.html +3 -1
- package/bundle-analysis-pdfvc.html +1 -1
- package/dist/PDFViewerCanvas.cjs.css +4 -4
- package/dist/PDFViewerCanvas.esm.css +4 -4
- package/dist/index.cjs.css +7 -7
- package/dist/index.cjs.js +93 -31
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +104 -10
- package/dist/index.esm.css +7 -7
- package/dist/index.esm.js +93 -37
- package/dist/index.esm.js.map +1 -1
- package/dist/types/components/ExitThisPage/ExitThisPage.config.d.ts +1 -0
- package/dist/types/components/ExitThisPage/ExitThisPage.d.ts +4 -0
- package/dist/types/components/ExitThisPage/ExitThisPage.types.d.ts +17 -0
- package/dist/types/components/ExitThisPage/index.d.ts +2 -0
- package/dist/types/components/Pagination/Pagination.types.d.ts +23 -13
- package/dist/types/components/Pagination/index.d.ts +2 -0
- package/dist/types/components/PasswordInput/PasswordInput.config.d.ts +1 -0
- package/dist/types/components/PasswordInput/PasswordInput.d.ts +4 -0
- package/dist/types/components/PasswordInput/PasswordInput.types.d.ts +49 -0
- package/dist/types/components/PasswordInput/index.d.ts +2 -0
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/utils/WithReference.types.d.ts +7 -2
- package/package.json +63 -59
- package/scripts/generateStories.mjs +433 -0
- package/dist/types/JestSetup.d.ts +0 -1
package/dist/index.esm.css
CHANGED
|
@@ -11864,8 +11864,8 @@ textarea.form-control-lg {
|
|
|
11864
11864
|
}
|
|
11865
11865
|
|
|
11866
11866
|
.card-link :hover {
|
|
11867
|
-
border-color: #fd0;
|
|
11868
11867
|
color: #003078;
|
|
11868
|
+
border-color: #fd0;
|
|
11869
11869
|
}
|
|
11870
11870
|
|
|
11871
11871
|
.card-header {
|
|
@@ -11873,13 +11873,13 @@ textarea.form-control-lg {
|
|
|
11873
11873
|
color: #005ea5;
|
|
11874
11874
|
}
|
|
11875
11875
|
.card-header:hover {
|
|
11876
|
-
background-color: #005ea5;
|
|
11877
11876
|
color: #f8f8f8;
|
|
11877
|
+
background-color: #005ea5;
|
|
11878
11878
|
transition-duration: 0.3s;
|
|
11879
11879
|
}
|
|
11880
11880
|
.card-header:active {
|
|
11881
|
-
border-bottom: #000 groove;
|
|
11882
11881
|
background-color: gold;
|
|
11882
|
+
border-bottom: #000 groove;
|
|
11883
11883
|
transition: ease-in-out;
|
|
11884
11884
|
}
|
|
11885
11885
|
|
|
@@ -11950,24 +11950,24 @@ textarea.form-control-lg {
|
|
|
11950
11950
|
.loading-wheel-2 {
|
|
11951
11951
|
width: 1em;
|
|
11952
11952
|
height: 1em;
|
|
11953
|
-
border-radius: 50%;
|
|
11954
11953
|
margin: 40px;
|
|
11955
|
-
animation: loading-frames 1.1s infinite ease;
|
|
11956
11954
|
font-size: 8px;
|
|
11957
11955
|
text-indent: -9999em;
|
|
11956
|
+
border-radius: 50%;
|
|
11958
11957
|
transform: translateZ(0);
|
|
11958
|
+
animation: loading-frames 1.1s infinite ease;
|
|
11959
11959
|
}
|
|
11960
11960
|
|
|
11961
11961
|
.loading-wheel {
|
|
11962
11962
|
width: 1em;
|
|
11963
11963
|
height: 1em;
|
|
11964
|
-
border-radius: 50%;
|
|
11965
11964
|
margin: 40px;
|
|
11966
11965
|
margin-left: 25px;
|
|
11967
|
-
animation: loading-frames 1.1s infinite ease;
|
|
11968
11966
|
font-size: 8px;
|
|
11969
11967
|
text-indent: -9999em;
|
|
11968
|
+
border-radius: 50%;
|
|
11970
11969
|
transform: translateZ(0);
|
|
11970
|
+
animation: loading-frames 1.1s infinite ease;
|
|
11971
11971
|
}
|
|
11972
11972
|
|
|
11973
11973
|
.head-space {
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { Accordion as Accordion$1, createAll, Button as Button$1, Checkboxes as Checkboxes$1, ErrorSummary as ErrorSummary$1, Header as Header$1, Radios as Radios$1, SkipLink as SkipLink$1, Tabs as Tabs$1 } from 'govuk-frontend';
|
|
2
|
+
import { Accordion as Accordion$1, createAll, Button as Button$1, Checkboxes as Checkboxes$1, ErrorSummary as ErrorSummary$1, ExitThisPage as ExitThisPage$1, Header as Header$1, PasswordInput as PasswordInput$1, Radios as Radios$1, SkipLink as SkipLink$1, Tabs as Tabs$1 } from 'govuk-frontend';
|
|
3
3
|
import { Link, useLocation } from 'react-router-dom';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import React__default, { useContext, useMemo, createElement, Component, useState, useRef, useEffect } from 'react';
|
|
@@ -72,10 +72,10 @@ function ExtractAccordionConfigFromAttributes(remainingAttributes) {
|
|
|
72
72
|
return accordionConfig;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
const Accordion = ({ headingLevel: HeadingLevel = "h2", items, className, id, ...attributes }) => {
|
|
75
|
+
const Accordion = ({ headingLevel: HeadingLevel = "h2", items = [], className, id, ...attributes }) => {
|
|
76
76
|
const remainingAttributes = { ...attributes };
|
|
77
77
|
ExtractAccordionConfigFromAttributes(remainingAttributes);
|
|
78
|
-
return (jsx("div", { ...remainingAttributes, id: id, className: `govuk-accordion ${className || ""}`, "data-module": "govuk-accordion", children: items.filter(Boolean).map((item, index) => (jsxs("div", { className: `govuk-accordion__section ${item.expanded ? "govuk-accordion__section--expanded" : ""}`, children: [jsxs("div", { className: "govuk-accordion__section-header", children: [jsx(HeadingLevel, { className: "govuk-accordion__section-heading", children: jsx("span", { className: "govuk-accordion__section-button", id: `${id}-heading-${index + 1}`, children: item.heading
|
|
78
|
+
return (jsx("div", { ...remainingAttributes, id: id, className: `govuk-accordion ${className || ""}`, "data-module": "govuk-accordion", children: items.filter(Boolean).map((item, index) => (jsxs("div", { className: `govuk-accordion__section ${item.expanded ? "govuk-accordion__section--expanded" : ""}`, children: [jsxs("div", { className: "govuk-accordion__section-header", children: [jsx(HeadingLevel, { className: "govuk-accordion__section-heading", children: jsx("span", { className: "govuk-accordion__section-button", id: `${id}-heading-${index + 1}`, children: item.heading?.children }) }), item.summary && (jsx("div", { className: "govuk-accordion__section-summary govuk-body", id: `${id}-summary-${index + 1}`, children: item.summary.children }))] }), jsx("div", { id: `${id}-content-${index + 1}`, className: "govuk-accordion__section-content", "aria-labelledby": `${id}-heading-${index + 1}`, children: item.content?.children })] }, item.reactListKey || index))) }));
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
const LinkWithRef = ({ children, to, href, forwardedRef = null, ...attributes }) => {
|
|
@@ -540,7 +540,7 @@ const CardTitle = /*#__PURE__*/React.forwardRef(({
|
|
|
540
540
|
});
|
|
541
541
|
CardTitle.displayName = 'CardTitle';
|
|
542
542
|
|
|
543
|
-
const Card = /*#__PURE__*/React.forwardRef(({
|
|
543
|
+
const Card$1 = /*#__PURE__*/React.forwardRef(({
|
|
544
544
|
bsPrefix,
|
|
545
545
|
className,
|
|
546
546
|
bg,
|
|
@@ -562,8 +562,8 @@ const Card = /*#__PURE__*/React.forwardRef(({
|
|
|
562
562
|
}) : children
|
|
563
563
|
});
|
|
564
564
|
});
|
|
565
|
-
Card.displayName = 'Card';
|
|
566
|
-
var Card
|
|
565
|
+
Card$1.displayName = 'Card';
|
|
566
|
+
var Card = Object.assign(Card$1, {
|
|
567
567
|
Img: CardImg,
|
|
568
568
|
Title: CardTitle,
|
|
569
569
|
Subtitle: CardSubtitle,
|
|
@@ -577,7 +577,7 @@ var Card$1 = Object.assign(Card, {
|
|
|
577
577
|
|
|
578
578
|
const CardColumn = (props) => {
|
|
579
579
|
const { body, header, link } = props;
|
|
580
|
-
return (jsx("div", { className: "col", children: jsxs(Card
|
|
580
|
+
return (jsx("div", { className: "col", children: jsxs(Card, { className: "card-styles", children: [jsx(Link, { to: link, children: jsx(Card.Header, { className: "card-header govuk-!-font-size-27 govuk-!-font-weight-bold", children: header }) }), jsx(Card.Body, { className: "govuk-!-font-size-19", children: body })] }) }));
|
|
581
581
|
};
|
|
582
582
|
|
|
583
583
|
const CardLayout = (props) => {
|
|
@@ -811,6 +811,24 @@ function ConfigureOverallErrorSummary($scope, config) {
|
|
|
811
811
|
createAll(ErrorSummary$1, config, $scope);
|
|
812
812
|
}
|
|
813
813
|
|
|
814
|
+
const ExitThisPage = ({ children = "Exit this page", className, redirectUrl = "https://www.bbc.co.uk/weather", activatedText, timedOutText, pressTwoMoreTimesText, pressOneMoreTimeText, ...attributes }) => {
|
|
815
|
+
const i18nProps = {};
|
|
816
|
+
if (activatedText)
|
|
817
|
+
i18nProps["data-i18n.activated"] = activatedText;
|
|
818
|
+
if (timedOutText)
|
|
819
|
+
i18nProps["data-i18n.timed-out"] = timedOutText;
|
|
820
|
+
if (pressTwoMoreTimesText)
|
|
821
|
+
i18nProps["data-i18n.press-two-more-times"] = pressTwoMoreTimesText;
|
|
822
|
+
if (pressOneMoreTimeText)
|
|
823
|
+
i18nProps["data-i18n.press-one-more-time"] = pressOneMoreTimeText;
|
|
824
|
+
return (jsx("div", { ...attributes, ...i18nProps, className: `govuk-exit-this-page${className ? ` ${className}` : ""}`, "data-module": "govuk-exit-this-page", children: jsxs("a", { href: redirectUrl, role: "button", draggable: false, className: "govuk-button govuk-button--warning govuk-exit-this-page__button govuk-js-exit-this-page-button", "data-module": "govuk-button", rel: "nofollow noreferrer", children: [jsx("span", { className: "govuk-visually-hidden", children: "Emergency" }), " ", children] }) }));
|
|
825
|
+
};
|
|
826
|
+
ExitThisPage.displayName = "ExitThisPage";
|
|
827
|
+
|
|
828
|
+
function ConfigureOverallExitThisPage($scope) {
|
|
829
|
+
createAll(ExitThisPage$1, {}, $scope);
|
|
830
|
+
}
|
|
831
|
+
|
|
814
832
|
const FileUpload = (props) => {
|
|
815
833
|
const { className, errorMessage, formGroup, hint, label, "aria-describedby": describedBy, id, ...attributes } = props;
|
|
816
834
|
let hintComponent;
|
|
@@ -935,6 +953,17 @@ const NotificationBanner = (props) => {
|
|
|
935
953
|
return (jsxs("div", { className: `govuk-notification-banner ${typeClass} ${className || ""}`, role: roleAttribute, "aria-labelledby": titleId, "data-module": "govuk-notification-banner", ...(disableAutoFocus ? { "data-disable-auto-focus": "true" } : {}), ...attributes, children: [jsx("div", { className: "govuk-notification-banner__header", children: jsx(HeadingLevel, { className: "govuk-notification-banner__title", id: titleId, children: title }) }), jsx("div", { className: "govuk-notification-banner__content", children: typeof children === "string" ? (jsx("p", { className: "govuk-notification-banner__heading", children: children })) : (children) })] }));
|
|
936
954
|
};
|
|
937
955
|
|
|
956
|
+
const SvgIcon = ({ type, ...props }) => (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 15, height: 13, "aria-hidden": "true", ...props, children: jsx("path", { d: type === "next"
|
|
957
|
+
? "M8.107-.008L6.693 1.406 10.986 5.7H-2v2h12.896L6.71 11.676l1.378 1.449 6.744-6.406L8.107-.008z"
|
|
958
|
+
: "M6.594-.008-.133 6.72l6.744 6.406 1.377-1.449-4.185-3.977h12.896v-2H3.715l4.293-4.293L6.594-.008z" }) }));
|
|
959
|
+
|
|
960
|
+
const NavigationButton = ({ href, type, children, labelText, }) => {
|
|
961
|
+
const defaultText = type === "next" ? "Next" : "Previous";
|
|
962
|
+
const typeClass = type === "next" ? "next" : "prev";
|
|
963
|
+
const icon = (jsx(SvgIcon, { type: type, className: `govuk-pagination__icon govuk-pagination__icon--${typeClass}`, focusable: "false", "aria-hidden": "true" }));
|
|
964
|
+
return (jsxs("a", { className: "govuk-link govuk-pagination__link", href: href, rel: type, children: [type === "previous" && icon, jsxs("span", { className: "govuk-pagination__link-title", children: [children ?? defaultText, jsx("span", { className: "govuk-visually-hidden", children: " page" })] }), type === "next" && icon, labelText && (jsxs(Fragment, { children: [jsx("span", { className: "govuk-visually-hidden", children: ":" }), jsx("span", { className: "govuk-pagination__link-label", children: labelText })] }))] }));
|
|
965
|
+
};
|
|
966
|
+
|
|
938
967
|
const DOTS = "...";
|
|
939
968
|
const UsePagination = ({ totalCount, pageSize, siblingCount = 1, currentPage, }) => {
|
|
940
969
|
const range = (start, end) => {
|
|
@@ -970,29 +999,13 @@ const UsePagination = ({ totalCount, pageSize, siblingCount = 1, currentPage, })
|
|
|
970
999
|
return paginationRange;
|
|
971
1000
|
};
|
|
972
1001
|
|
|
973
|
-
const
|
|
974
|
-
|
|
975
|
-
: "M6.594-.008-.133 6.72l6.744 6.406 1.377-1.449-4.185-3.977h12.896v-2H3.715l4.293-4.293L6.594-.008z" }) }));
|
|
976
|
-
|
|
977
|
-
const NavigationButton = ({ isDisabled, onClick, children, name, type, }) => {
|
|
978
|
-
const typeClass = type === "next" ? type : "prev";
|
|
979
|
-
const Icon = (jsx(SvgIcon, { type: type, className: `govuk-pagination__icon govuk-pagination__icon--${typeClass}`, focusable: "false" }));
|
|
980
|
-
return isDisabled ? (jsxs("div", { rel: type, children: [type === "previous" && Icon, jsx("span", { className: "govuk-pagination__link-title", children: name }), type === "next" && Icon, children && (jsxs(Fragment, { children: [type === "previous" && jsx(Fragment, { children: "\u00A0" }), jsx("span", { className: "govuk-visually-hidden", children: ":" }), children, type === "next" && jsx(Fragment, { children: " \u00A0" })] }))] })) : (jsxs("a", { className: "govuk-link govuk-pagination__link", href: "#", rel: type, onClick: onClick, children: [type === "previous" && Icon, jsx("span", { className: "govuk-pagination__link-title", children: name }), type === "next" && Icon, children && (jsxs(Fragment, { children: [type === "previous" && jsx(Fragment, { children: "\u00A0\u00A0" }), jsx("span", { className: "govuk-visually-hidden", children: ":" }), children, type === "next" && jsx(Fragment, { children: "\u00A0\u00A0" })] }))] }));
|
|
981
|
-
};
|
|
982
|
-
|
|
983
|
-
const Pagination = ({ onPageChange, totalCount, siblingCount = 1, currentPage, pageSize, className, previousName = "Previous", nextName = "Next", previousChildren, nextChildren, }) => {
|
|
984
|
-
const paginationRange = UsePagination({
|
|
985
|
-
currentPage,
|
|
986
|
-
totalCount,
|
|
987
|
-
siblingCount,
|
|
988
|
-
pageSize,
|
|
989
|
-
});
|
|
990
|
-
if (!paginationRange || paginationRange.length < 2)
|
|
1002
|
+
const Pagination = ({ previous, next, items, className, }) => {
|
|
1003
|
+
if (!previous && !next && (!items || items.length === 0))
|
|
991
1004
|
return null;
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
const
|
|
995
|
-
return (jsxs(
|
|
1005
|
+
// Block layout is used when there are no numbered page items — govuk renders
|
|
1006
|
+
// the nav with an extra class and the link title with --decorated modifier.
|
|
1007
|
+
const isBlockLayout = !items || items.length === 0;
|
|
1008
|
+
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--ellipses", 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 }) }))] }));
|
|
996
1009
|
};
|
|
997
1010
|
|
|
998
1011
|
const Panel = (props) => {
|
|
@@ -1001,6 +1014,49 @@ const Panel = (props) => {
|
|
|
1001
1014
|
return (jsxs("div", { className: `govuk-panel govuk-panel--confirmation ${className || ""}`, ...attributes, children: [jsx(HeadingLevel, { className: "govuk-panel__title", children: titleChildren }), innerHtml] }));
|
|
1002
1015
|
};
|
|
1003
1016
|
|
|
1017
|
+
const PasswordInput = React__default.forwardRef((props, ref) => {
|
|
1018
|
+
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;
|
|
1019
|
+
let describedByValue = describedBy || "";
|
|
1020
|
+
let hintComponent = null;
|
|
1021
|
+
let errorMessageComponent = null;
|
|
1022
|
+
if (hint) {
|
|
1023
|
+
const hintId = `${id}-hint`;
|
|
1024
|
+
describedByValue += ` ${hintId}`;
|
|
1025
|
+
hintComponent = jsx(Hint, { ...hint, id: hintId });
|
|
1026
|
+
}
|
|
1027
|
+
if (errorMessage) {
|
|
1028
|
+
const errorId = id ? `${id}-error` : "";
|
|
1029
|
+
describedByValue += ` ${errorId}`;
|
|
1030
|
+
errorMessageComponent = jsx(ErrorMessage, { ...errorMessage, id: errorId });
|
|
1031
|
+
}
|
|
1032
|
+
// Build i18n data attributes for the govuk-frontend JS module
|
|
1033
|
+
const i18nProps = {};
|
|
1034
|
+
if (showPasswordText)
|
|
1035
|
+
i18nProps["data-i18n.show-password"] = showPasswordText;
|
|
1036
|
+
if (hidePasswordText)
|
|
1037
|
+
i18nProps["data-i18n.hide-password"] = hidePasswordText;
|
|
1038
|
+
if (showPasswordAriaLabelText)
|
|
1039
|
+
i18nProps["data-i18n.show-password-aria-label"] =
|
|
1040
|
+
showPasswordAriaLabelText;
|
|
1041
|
+
if (hidePasswordAriaLabelText)
|
|
1042
|
+
i18nProps["data-i18n.hide-password-aria-label"] =
|
|
1043
|
+
hidePasswordAriaLabelText;
|
|
1044
|
+
if (passwordShownAnnouncementText)
|
|
1045
|
+
i18nProps["data-i18n.password-shown-announcement"] =
|
|
1046
|
+
passwordShownAnnouncementText;
|
|
1047
|
+
if (passwordHiddenAnnouncementText)
|
|
1048
|
+
i18nProps["data-i18n.password-hidden-announcement"] =
|
|
1049
|
+
passwordHiddenAnnouncementText;
|
|
1050
|
+
// Label handles isPageHeading internally — no extra wrapper needed here
|
|
1051
|
+
const labelEl = jsx(Label, { ...label, htmlFor: id });
|
|
1052
|
+
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: id, className: `govuk-input govuk-password-input__input govuk-js-password-input-input${className ? ` ${className}` : ""}${errorMessage ? " govuk-input--error" : ""}`, name: name || id, 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": id, "aria-label": showPasswordAriaLabelText, hidden: true, children: showPasswordText })] })] }));
|
|
1053
|
+
});
|
|
1054
|
+
PasswordInput.displayName = "PasswordInput";
|
|
1055
|
+
|
|
1056
|
+
function ConfigureOverallPasswordInput($scope) {
|
|
1057
|
+
createAll(PasswordInput$1, {}, $scope);
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1004
1060
|
function Slugify(str) {
|
|
1005
1061
|
str = str.replace(/^\s+|\s+$/g, ""); // trim leading/trailing white space
|
|
1006
1062
|
str = str.toLowerCase(); // convert string to lowercase
|
|
@@ -1168,7 +1224,7 @@ const PDFViewer = (props) => {
|
|
|
1168
1224
|
// 1) Let ResolvePDFSource handle base64/data/blob inputs synchronously.
|
|
1169
1225
|
try {
|
|
1170
1226
|
const resolved = ResolvePDFSource(src);
|
|
1171
|
-
if (resolved
|
|
1227
|
+
if (resolved?.source) {
|
|
1172
1228
|
sourceToUse = resolved.source;
|
|
1173
1229
|
if (resolved.isBase64Source) {
|
|
1174
1230
|
// ResolvePDFSource created an object URL for us (data/blob/base64)
|
|
@@ -1195,11 +1251,7 @@ const PDFViewer = (props) => {
|
|
|
1195
1251
|
signal: controller.signal,
|
|
1196
1252
|
credentials: "omit",
|
|
1197
1253
|
});
|
|
1198
|
-
if (
|
|
1199
|
-
console.warn(`PDFViewer: fetch returned ${resp.status} ${resp.statusText} for ${src}`);
|
|
1200
|
-
// fallback: keep using original src
|
|
1201
|
-
}
|
|
1202
|
-
else {
|
|
1254
|
+
if (resp.ok) {
|
|
1203
1255
|
const blob = await resp.blob();
|
|
1204
1256
|
if (blob && blob.size > 0) {
|
|
1205
1257
|
const obj = URL.createObjectURL(blob);
|
|
@@ -1211,9 +1263,13 @@ const PDFViewer = (props) => {
|
|
|
1211
1263
|
console.warn("PDFViewer: fetched blob is empty - falling back to original src");
|
|
1212
1264
|
}
|
|
1213
1265
|
}
|
|
1266
|
+
else {
|
|
1267
|
+
console.warn(`PDFViewer: fetch returned ${resp.status} ${resp.statusText} for ${src}`);
|
|
1268
|
+
// fallback: keep using original src
|
|
1269
|
+
}
|
|
1214
1270
|
}
|
|
1215
1271
|
catch (err) {
|
|
1216
|
-
if (err
|
|
1272
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
1217
1273
|
// aborted, nothing to do
|
|
1218
1274
|
if (!mounted)
|
|
1219
1275
|
return;
|
|
@@ -1526,5 +1582,5 @@ const WarningText = ({ children = "Warning message", className, ...attributes })
|
|
|
1526
1582
|
return (jsxs("div", { className: `govuk-warning-text ${className || ""}`, ...attributes, children: [jsx("span", { className: "govuk-warning-text__icon", "aria-hidden": "true", children: "!" }), jsxs("strong", { className: "govuk-warning-text__text", children: [jsx("span", { className: "govuk-visually-hidden", children: "Warning" }), children] })] }));
|
|
1527
1583
|
};
|
|
1528
1584
|
|
|
1529
|
-
export { Accordion, ActionLink, BackLink, Boolean$1 as Boolean, Breadcrumbs, Button, CardColumn, CardLayout, CharacterCount, Checkboxes as Checkbox, ConfigureOverallAccordion, ConfigureOverallButton, ConfigureOverallCheckboxes, ConfigureOverallErrorSummary, ConfigureOverallHeader, ConfigureOverallRadios, ConfigureOverallSkipLink, ConfigureOverallTabs, CookieBanner, DataNavigation, DateInput, Details, DifferenceNavigation, ErrorBoundary, ErrorMessage, ErrorSummary, ExtractAccordionConfigFromAttributes, Fieldset, FileUpload, Footer, Header, Hint, Input, InsetText, Label, Landing, LinkWithRef, Loading, Main, NotFoundPage, NotificationBanner, PDFViewer, PDFViewerBackend, Pagination, Panel, PhaseBanner, ProblemWithService, Radios, Select, ServiceNavigation, SkipLink, SummaryList, Table, Tabs, Tag, TaskList, Textarea, WarningInfo, WarningText };
|
|
1585
|
+
export { Accordion, ActionLink, BackLink, Boolean$1 as Boolean, Breadcrumbs, Button, CardColumn, CardLayout, CharacterCount, Checkboxes as Checkbox, ConfigureOverallAccordion, ConfigureOverallButton, ConfigureOverallCheckboxes, ConfigureOverallErrorSummary, ConfigureOverallExitThisPage, ConfigureOverallHeader, ConfigureOverallPasswordInput, ConfigureOverallRadios, ConfigureOverallSkipLink, ConfigureOverallTabs, CookieBanner, DOTS, DataNavigation, DateInput, Details, DifferenceNavigation, ErrorBoundary, ErrorMessage, ErrorSummary, ExitThisPage, ExtractAccordionConfigFromAttributes, Fieldset, FileUpload, Footer, Header, Hint, Input, InsetText, Label, Landing, LinkWithRef, Loading, Main, NotFoundPage, NotificationBanner, PDFViewer, PDFViewerBackend, Pagination, Panel, PasswordInput, PhaseBanner, ProblemWithService, Radios, Select, ServiceNavigation, SkipLink, SummaryList, Table, Tabs, Tag, TaskList, Textarea, UsePagination, WarningInfo, WarningText };
|
|
1530
1586
|
//# sourceMappingURL=index.esm.js.map
|