@uktrade/react-component-library 0.15.0 → 0.17.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/Readme.md CHANGED
@@ -54,3 +54,13 @@ npm run docs:start
54
54
  ```
55
55
 
56
56
  This opens a Vite dev server with the playground for testing components.
57
+
58
+ ### Publishing a new version
59
+
60
+ To publish a new version to NPM [@uktrade/react-component-library](https://www.npmjs.com/package/@uktrade/react-component-library):
61
+
62
+ 1. **Update the version** in `package.json` following semantic versioning (don’t forget to sync the lockfile as well).
63
+ 2. **Commit your changes** on a feature or working branch.
64
+ 3. **Open a pull request** and **merge it into `main`**.
65
+ 4. **Create a new GitHub Release** from the `main` branch and tag it with the same version (for example, `v0.10.1`).
66
+ 5. Once the release is published, the [GitHub Actions workflow](./.github/workflows/release.yml) will automatically build and publish the package to NPM.
@@ -6,6 +6,7 @@ interface CheckboxOption {
6
6
  value: string;
7
7
  label: ReactNode;
8
8
  checked?: boolean;
9
+ hint?: string;
9
10
  }
10
11
  interface CheckboxGroupProps {
11
12
  legend: ReactNode;
@@ -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;CACrB;AAED,UAAU,kBAAkB;IACxB,MAAM,EAAE,SAAS,CAAC;IAClB,IAAI,CAAC,EAA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AE,MAAM,EAAE,KAAK,IAAI,CAAC;CACzC;AAED,eAAO,MAAM,aAAa,GAAI,uFAU3B,kBAAkB,4CA6EpB,CAAC"}
@@ -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, defaultChecked: opt.checked, onChange: handleChange }), _jsx("label", { className: "govuk-label govuk-checkboxes__label", htmlFor: opt.id, children: opt.label })] }, 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, defaultChecked: opt.checked, 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
  };
@@ -0,0 +1,11 @@
1
+ import type { ReactNode } from "react";
2
+ type Props = {
3
+ title: string;
4
+ heading?: string;
5
+ children: ReactNode;
6
+ variant?: "success";
7
+ className?: string;
8
+ };
9
+ export declare const NotificationBanner: ({ title, heading, children, variant, className, }: Props) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
11
+ //# sourceMappingURL=NotificationBanner.d.ts.map
@@ -0,0 +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;CACpB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,mDAMhC,KAAK,4CAgCP,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import clsx from "clsx";
4
+ export const NotificationBanner = ({ title, heading, children, variant, className, }) => {
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 })] })] }));
7
+ };
package/dist/index.d.ts CHANGED
@@ -12,4 +12,5 @@ export * from "./components/LoadingSpinner/LoadingSpinner";
12
12
  export * from "./components/ApiBoundary/ApiBoundary";
13
13
  export * from "./components/ApiQuery";
14
14
  export * from "./components/Inputs";
15
+ export * from "./components/NotificationBanner/NotificationBanner";
15
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wCAAwC,CAAC;AACvD,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4CAA4C,CAAC;AAC3D,cAAc,sCAAsC,CAAC;AACrD,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wCAAwC,CAAC;AACvD,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4CAA4C,CAAC;AAC3D,cAAc,sCAAsC,CAAC;AACrD,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oDAAoD,CAAC"}
package/dist/index.js CHANGED
@@ -12,3 +12,4 @@ export * from "./components/LoadingSpinner/LoadingSpinner";
12
12
  export * from "./components/ApiBoundary/ApiBoundary";
13
13
  export * from "./components/ApiQuery";
14
14
  export * from "./components/Inputs";
15
+ export * from "./components/NotificationBanner/NotificationBanner";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uktrade/react-component-library",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "description": "A collection of reusable React components following GOV.UK design patterns.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -12,7 +12,7 @@
12
12
  "build": "tsc -p tsconfig.build.json && npm run copy:css",
13
13
  "copy:css": "rsync -av --include='*/' --include='*.css' --exclude='*' src/ dist/",
14
14
  "docs:build": "tsc -p docs/playground/tsconfig.docs.json",
15
- "docs:start": "npx vite@latest docs/playground open",
15
+ "docs:start": "npx vite@latest docs/playground --open",
16
16
  "docs:vulnerability": "npx vite@latest --version && npm audit --audit-level=high",
17
17
  "lint": "eslint .",
18
18
  "lint:fix": "eslint . --fix",
@@ -12,6 +12,7 @@ interface CheckboxOption {
12
12
  value: string;
13
13
  label: ReactNode;
14
14
  checked?: boolean;
15
+ hint?: string;
15
16
  }
16
17
 
17
18
  interface CheckboxGroupProps {
@@ -102,6 +103,11 @@ export const CheckboxGroup = ({
102
103
  >
103
104
  {opt.label}
104
105
  </label>
106
+ {opt.hint && (
107
+ <div className="govuk-hint govuk-checkboxes__hint">
108
+ {opt.hint}
109
+ </div>
110
+ )}
105
111
  </div>
106
112
  ))}
107
113
  </div>
@@ -0,0 +1,52 @@
1
+ "use client";
2
+
3
+ import clsx from "clsx";
4
+ import type { ReactNode } from "react";
5
+
6
+ type Props = {
7
+ title: string;
8
+ heading?: string;
9
+ children: ReactNode;
10
+ variant?: "success"; // only supported variant
11
+ className?: string;
12
+ };
13
+
14
+ export const NotificationBanner = ({
15
+ title,
16
+ heading,
17
+ children,
18
+ variant,
19
+ className,
20
+ }: Props) => {
21
+ const bannerClass = clsx(
22
+ "govuk-notification-banner",
23
+ variant === "success" && "govuk-notification-banner--success",
24
+ className
25
+ );
26
+
27
+ return (
28
+ <div
29
+ className={bannerClass}
30
+ role="alert"
31
+ aria-labelledby="govuk-notification-banner-title"
32
+ data-module="govuk-notification-banner"
33
+ >
34
+ <div className="govuk-notification-banner__header">
35
+ <h2
36
+ className="govuk-notification-banner__title"
37
+ id="govuk-notification-banner-title"
38
+ >
39
+ {title}
40
+ </h2>
41
+ </div>
42
+ <div className="govuk-notification-banner__content">
43
+ {heading && (
44
+ <h3 className="govuk-notification-banner__heading">
45
+ {heading}
46
+ </h3>
47
+ )}
48
+ <p className="govuk-body">{children}</p>
49
+ </div>
50
+ </div>
51
+ );
52
+ };
package/src/index.ts CHANGED
@@ -12,3 +12,4 @@ export * from "./components/LoadingSpinner/LoadingSpinner";
12
12
  export * from "./components/ApiBoundary/ApiBoundary";
13
13
  export * from "./components/ApiQuery";
14
14
  export * from "./components/Inputs";
15
+ export * from "./components/NotificationBanner/NotificationBanner";