@uktrade/react-component-library 0.18.0 → 0.18.2
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/dist/components/Inputs/CheckBoxesInput/CheckBoxGroupInput.d.ts +1 -0
- package/dist/components/Inputs/CheckBoxesInput/CheckBoxGroupInput.d.ts.map +1 -1
- package/dist/components/Inputs/CheckBoxesInput/CheckBoxGroupInput.js +1 -1
- package/dist/components/NotificationBanner/NotificationBanner.d.ts +2 -1
- package/dist/components/NotificationBanner/NotificationBanner.d.ts.map +1 -1
- package/dist/components/NotificationBanner/NotificationBanner.js +2 -2
- package/package.json +1 -1
- package/src/components/Inputs/CheckBoxesInput/CheckBoxGroupInput.tsx +2 -0
- package/src/components/NotificationBanner/NotificationBanner.tsx +12 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckBoxGroupInput.d.ts","sourceRoot":"","sources":["../../../../src/components/Inputs/CheckBoxesInput/CheckBoxGroupInput.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1C,KAAK,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;AAEzC,UAAU,cAAc;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"CheckBoxGroupInput.d.ts","sourceRoot":"","sources":["../../../../src/components/Inputs/CheckBoxesInput/CheckBoxGroupInput.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1C,KAAK,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;AAEzC,UAAU,cAAc;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,UAAU,kBAAkB;IACxB,MAAM,EAAE,SAAS,CAAC;IAClB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,aAAa,GAAI,+FAW3B,kBAAkB,4CA8EpB,CAAC"}
|
|
@@ -19,5 +19,5 @@ export const CheckboxGroup = ({ legend, hint, error, options, name, values, lege
|
|
|
19
19
|
[`govuk-fieldset__legend--${legendSize}`]: legendSize !== "m",
|
|
20
20
|
}), children: legendHeading }), hint && _jsx("div", { className: "govuk-hint", children: hint }), hasError && (_jsxs("p", { id: errorId, className: "govuk-error-message", children: [_jsx("span", { className: "govuk-visually-hidden", children: "Error:" }), " ", error] })), _jsx("div", { className: clsx("govuk-checkboxes", {
|
|
21
21
|
"govuk-checkboxes--small": checkboxSize === "small",
|
|
22
|
-
}), "data-module": "govuk-checkboxes", children: options.map((opt) => (_jsxs("div", { className: "govuk-checkboxes__item", children: [_jsx("input", { className: "govuk-checkboxes__input", id: opt.id, name: name, type: "checkbox", value: opt.value, checked: values.includes(opt.value), onChange: handleChange }), _jsx("label", { className: "govuk-label govuk-checkboxes__label", htmlFor: opt.id, children: opt.label }), opt.hint && (_jsx("div", { className: "govuk-hint govuk-checkboxes__hint", children: opt.hint }))] }, opt.id))) })] }) }));
|
|
22
|
+
}), "data-module": "govuk-checkboxes", children: options.map((opt) => (_jsxs("div", { className: "govuk-checkboxes__item", children: [_jsx("input", { className: "govuk-checkboxes__input", id: opt.id, name: name, type: "checkbox", value: opt.value, checked: values.includes(opt.value), onChange: handleChange, "aria-label": opt.ariaLabel }), _jsx("label", { className: "govuk-label govuk-checkboxes__label", htmlFor: opt.id, children: opt.label }), opt.hint && (_jsx("div", { className: "govuk-hint govuk-checkboxes__hint", children: opt.hint }))] }, opt.id))) })] }) }));
|
|
23
23
|
};
|
|
@@ -5,7 +5,8 @@ type Props = {
|
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
variant?: "success";
|
|
7
7
|
className?: string;
|
|
8
|
+
onClose?: () => void;
|
|
8
9
|
};
|
|
9
|
-
export declare const NotificationBanner: ({ title, heading, children, variant, className, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const NotificationBanner: ({ title, heading, children, variant, className, onClose, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export {};
|
|
11
12
|
//# sourceMappingURL=NotificationBanner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationBanner.d.ts","sourceRoot":"","sources":["../../../src/components/NotificationBanner/NotificationBanner.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"NotificationBanner.d.ts","sourceRoot":"","sources":["../../../src/components/NotificationBanner/NotificationBanner.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,4DAOhC,KAAK,4CA0CP,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import clsx from "clsx";
|
|
4
|
-
export const NotificationBanner = ({ title, heading, children, variant, className, }) => {
|
|
4
|
+
export const NotificationBanner = ({ title, heading, children, variant, className, onClose, }) => {
|
|
5
5
|
const bannerClass = clsx("govuk-notification-banner", variant === "success" && "govuk-notification-banner--success", className);
|
|
6
|
-
return (_jsxs("div", { className: bannerClass, role: "alert", "aria-labelledby": "govuk-notification-banner-title", "data-module": "govuk-notification-banner", children: [_jsx("div", { className: "govuk-notification-banner__header", children: _jsx("h2", { className: "govuk-notification-banner__title", id: "govuk-notification-banner-title", children: title }) }), _jsxs("div", { className: "govuk-notification-banner__content", children: [heading && (_jsx("h3", { className: "govuk-notification-banner__heading", children: heading })), _jsx("p", { className: "govuk-body", children: children })] })] }));
|
|
6
|
+
return (_jsxs("div", { className: bannerClass, role: "alert", "aria-labelledby": "govuk-notification-banner-title", "data-module": "govuk-notification-banner", children: [_jsx("div", { className: "govuk-notification-banner__header", children: _jsx("h2", { className: "govuk-notification-banner__title", id: "govuk-notification-banner-title", children: title }) }), _jsxs("div", { className: "govuk-notification-banner__content", children: [heading && (_jsx("h3", { className: "govuk-notification-banner__heading", children: heading })), _jsx("p", { className: "govuk-body", children: children }), onClose && (_jsx("button", { className: "govuk-link govuk-body-s govuk-!-margin-0", style: { background: "none", border: "none", padding: 0, cursor: "pointer", color: "#1d70b8" }, onClick: onClose, "aria-label": "Close notification", children: "Close" }))] })] }));
|
|
7
7
|
};
|
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@ interface CheckboxOption {
|
|
|
13
13
|
label: ReactNode;
|
|
14
14
|
checked?: boolean;
|
|
15
15
|
hint?: string;
|
|
16
|
+
ariaLabel?: string
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
interface CheckboxGroupProps {
|
|
@@ -98,6 +99,7 @@ export const CheckboxGroup = ({
|
|
|
98
99
|
value={opt.value}
|
|
99
100
|
checked={values.includes(opt.value)}
|
|
100
101
|
onChange={handleChange}
|
|
102
|
+
aria-label={opt.ariaLabel}
|
|
101
103
|
/>
|
|
102
104
|
<label
|
|
103
105
|
className="govuk-label govuk-checkboxes__label"
|
|
@@ -9,6 +9,7 @@ type Props = {
|
|
|
9
9
|
children: ReactNode;
|
|
10
10
|
variant?: "success"; // only supported variant
|
|
11
11
|
className?: string;
|
|
12
|
+
onClose?: () => void;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
export const NotificationBanner = ({
|
|
@@ -17,6 +18,7 @@ export const NotificationBanner = ({
|
|
|
17
18
|
children,
|
|
18
19
|
variant,
|
|
19
20
|
className,
|
|
21
|
+
onClose,
|
|
20
22
|
}: Props) => {
|
|
21
23
|
const bannerClass = clsx(
|
|
22
24
|
"govuk-notification-banner",
|
|
@@ -46,6 +48,16 @@ export const NotificationBanner = ({
|
|
|
46
48
|
</h3>
|
|
47
49
|
)}
|
|
48
50
|
<p className="govuk-body">{children}</p>
|
|
51
|
+
{onClose && (
|
|
52
|
+
<button
|
|
53
|
+
className="govuk-link govuk-body-s govuk-!-margin-0"
|
|
54
|
+
style={{ background: "none", border: "none", padding: 0, cursor: "pointer", color: "#1d70b8" }}
|
|
55
|
+
onClick={onClose}
|
|
56
|
+
aria-label="Close notification"
|
|
57
|
+
>
|
|
58
|
+
Close
|
|
59
|
+
</button>
|
|
60
|
+
)}
|
|
49
61
|
</div>
|
|
50
62
|
</div>
|
|
51
63
|
);
|