@uktrade/react-component-library 0.17.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Inputs/CheckBoxesInput/CheckBoxGroupInput.d.ts +2 -1
- package/dist/components/Inputs/CheckBoxesInput/CheckBoxGroupInput.d.ts.map +1 -1
- package/dist/components/Inputs/CheckBoxesInput/CheckBoxGroupInput.js +2 -2
- 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 +3 -1
- package/src/components/NotificationBanner/NotificationBanner.tsx +12 -0
|
@@ -18,7 +18,8 @@ interface CheckboxGroupProps {
|
|
|
18
18
|
legendSize?: LegendSize;
|
|
19
19
|
checkboxSize?: "small" | "default";
|
|
20
20
|
onChange?: (values: string[]) => void;
|
|
21
|
+
values: string[];
|
|
21
22
|
}
|
|
22
|
-
export declare const CheckboxGroup: ({ legend, hint, error, options, name, legendAs, legendSize, checkboxSize, onChange, }: CheckboxGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare const CheckboxGroup: ({ legend, hint, error, options, name, values, legendAs, legendSize, checkboxSize, onChange, }: CheckboxGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
24
|
export {};
|
|
24
25
|
//# sourceMappingURL=CheckBoxGroupInput.d.ts.map
|
|
@@ -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;AA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C;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,4CA6EpB,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import { createElement } from "react";
|
|
5
|
-
export const CheckboxGroup = ({ legend, hint, error, options, name, legendAs = "h4", legendSize = "m", checkboxSize = "default", onChange, }) => {
|
|
5
|
+
export const CheckboxGroup = ({ legend, hint, error, options, name, values, legendAs = "h4", legendSize = "m", checkboxSize = "default", onChange, }) => {
|
|
6
6
|
const hasError = Boolean(error);
|
|
7
7
|
const errorId = hasError ? `${name}-error` : undefined;
|
|
8
8
|
const legendHeading = createElement(legendAs, { className: "govuk-fieldset__heading" }, legend);
|
|
@@ -19,5 +19,5 @@ export const CheckboxGroup = ({ legend, hint, error, options, name, legendAs = "
|
|
|
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,
|
|
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))) })] }) }));
|
|
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
|
@@ -25,6 +25,7 @@ interface CheckboxGroupProps {
|
|
|
25
25
|
legendSize?: LegendSize;
|
|
26
26
|
checkboxSize?: "small" | "default";
|
|
27
27
|
onChange?: (values: string[]) => void;
|
|
28
|
+
values: string[];
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
export const CheckboxGroup = ({
|
|
@@ -33,6 +34,7 @@ export const CheckboxGroup = ({
|
|
|
33
34
|
error,
|
|
34
35
|
options,
|
|
35
36
|
name,
|
|
37
|
+
values,
|
|
36
38
|
legendAs = "h4",
|
|
37
39
|
legendSize = "m",
|
|
38
40
|
checkboxSize = "default",
|
|
@@ -94,7 +96,7 @@ export const CheckboxGroup = ({
|
|
|
94
96
|
name={name}
|
|
95
97
|
type="checkbox"
|
|
96
98
|
value={opt.value}
|
|
97
|
-
|
|
99
|
+
checked={values.includes(opt.value)}
|
|
98
100
|
onChange={handleChange}
|
|
99
101
|
/>
|
|
100
102
|
<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
|
);
|