@uktrade/react-component-library 0.13.0 → 0.14.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.
@@ -15,7 +15,8 @@ interface CheckboxGroupProps {
15
15
  name: string;
16
16
  legendAs?: LegendAs;
17
17
  legendSize?: LegendSize;
18
+ checkboxSize?: "small" | "default";
18
19
  }
19
- export declare const CheckboxGroup: ({ legend, hint, error, options, name, legendAs, legendSize, }: CheckboxGroupProps) => import("react/jsx-runtime").JSX.Element;
20
+ export declare const CheckboxGroup: ({ legend, hint, error, options, name, legendAs, legendSize, checkboxSize }: CheckboxGroupProps) => import("react/jsx-runtime").JSX.Element;
20
21
  export {};
21
22
  //# 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;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,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;CAC3B;AAED,eAAO,MAAM,aAAa,GAAI,+DAQ3B,kBAAkB,4CA0DpB,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;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;CACtC;AAED,eAAO,MAAM,aAAa,GAAI,4EAS3B,kBAAkB,4CA+DpB,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", }) => {
5
+ export const CheckboxGroup = ({ legend, hint, error, options, name, legendAs = "h4", legendSize = "m", checkboxSize = "default" }) => {
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);
@@ -10,5 +10,7 @@ export const CheckboxGroup = ({ legend, hint, error, options, name, legendAs = "
10
10
  "govuk-form-group--error": hasError,
11
11
  }), children: _jsxs("fieldset", { className: "govuk-fieldset", "aria-describedby": errorId, children: [_jsx("legend", { className: clsx("govuk-fieldset__legend", {
12
12
  [`govuk-fieldset__legend--${legendSize}`]: legendSize !== "m",
13
- }), 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: "govuk-checkboxes", "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 }), _jsx("label", { className: "govuk-label govuk-checkboxes__label", htmlFor: opt.id, children: opt.label })] }, opt.id))) })] }) }));
13
+ }), 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", {
14
+ "govuk-checkboxes--small": checkboxSize === "small",
15
+ }), "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 }), _jsx("label", { className: "govuk-label govuk-checkboxes__label", htmlFor: opt.id, children: opt.label })] }, opt.id))) })] }) }));
14
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uktrade/react-component-library",
3
- "version": "0.13.0",
3
+ "version": "0.14.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",
@@ -22,6 +22,7 @@ interface CheckboxGroupProps {
22
22
  name: string;
23
23
  legendAs?: LegendAs;
24
24
  legendSize?: LegendSize;
25
+ checkboxSize?: "small" | "default";
25
26
  }
26
27
 
27
28
  export const CheckboxGroup = ({
@@ -32,6 +33,7 @@ export const CheckboxGroup = ({
32
33
  name,
33
34
  legendAs = "h4",
34
35
  legendSize = "m",
36
+ checkboxSize = "default"
35
37
  }: CheckboxGroupProps) => {
36
38
  const hasError = Boolean(error);
37
39
  const errorId = hasError ? `${name}-error` : undefined;
@@ -67,7 +69,12 @@ export const CheckboxGroup = ({
67
69
  </p>
68
70
  )}
69
71
 
70
- <div className="govuk-checkboxes" data-module="govuk-checkboxes">
72
+ <div
73
+ className={clsx("govuk-checkboxes", {
74
+ "govuk-checkboxes--small": checkboxSize === "small",
75
+ })}
76
+ data-module="govuk-checkboxes"
77
+ >
71
78
  {options.map((opt) => (
72
79
  <div key={opt.id} className="govuk-checkboxes__item">
73
80
  <input