@uktrade/react-component-library 0.22.6 → 0.22.8

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.
@@ -9,11 +9,12 @@ export interface SummaryListProps extends React.HTMLAttributes<HTMLDListElement>
9
9
  export declare const SummaryList: ({ title, children, className, ...props }: SummaryListProps) => import("react/jsx-runtime").JSX.Element;
10
10
  export interface SummaryCardProps extends React.HTMLAttributes<HTMLDivElement> {
11
11
  title: string;
12
+ titleTag?: React.ReactNode;
12
13
  children?: React.ReactNode;
13
14
  actions?: SummaryListAction[];
14
15
  className?: string;
15
16
  titleBackground?: string;
16
17
  subSectionNode?: React.ReactNode;
17
18
  }
18
- export declare const SummaryCard: ({ title, children, actions, className, titleBackground, subSectionNode, ...props }: SummaryCardProps) => import("react/jsx-runtime").JSX.Element;
19
+ export declare const SummaryCard: ({ title, titleTag, children, actions, className, titleBackground, subSectionNode, ...props }: SummaryCardProps) => import("react/jsx-runtime").JSX.Element;
19
20
  //# sourceMappingURL=SummaryList.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SummaryList.d.ts","sourceRoot":"","sources":["../../../src/components/SummaryList/SummaryList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D,MAAM,WAAW,gBAAiB,SAAQ,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC;IAC9E,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,WAAW,GAAI,0CAA0C,gBAAgB,4CAOrF,CAAC;AAEF,MAAM,WAAW,gBAAiB,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC5E,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@ -4,4 +4,4 @@ import clsx from "clsx";
4
4
  import { SummaryListAction } from "../SummaryItem/SummaryItem";
5
5
  import styles from "./SummaryList.module.css";
6
6
  export const SummaryList = ({ title, children, className, ...props }) => (_jsxs(_Fragment, { children: [title && _jsx("h2", { className: "govuk-heading-l", children: title }), _jsx("dl", { className: clsx("govuk-summary-list", className), ...props, children: children })] }));
7
- export const SummaryCard = ({ title, children, actions, className, titleBackground, subSectionNode, ...props }) => (_jsx("div", { className: clsx(styles.root, className), children: _jsxs("div", { className: "govuk-summary-card govuk-body", ...props, children: [_jsxs("div", { className: "govuk-summary-card__title-wrapper", style: titleBackground ? { background: titleBackground } : undefined, children: [_jsx("h2", { className: "govuk-summary-card__title govuk-!-font-size-16", children: title }), actions && (_jsx("ul", { className: clsx("govuk-summary-card__actions", "govuk-!-font-size-16", styles.summaryCardTitleActions), children: actions.map((action) => (_jsx("li", { className: "govuk-summary-card__action", children: _jsx(SummaryListAction, { action: action }) }, action.text))) }))] }), subSectionNode && (_jsx("div", { children: subSectionNode })), _jsx("div", { className: clsx("govuk-summary-card__content", styles.govukSummaryCardContent), children: children })] }) }));
7
+ export const SummaryCard = ({ title, titleTag, children, actions, className, titleBackground, subSectionNode, ...props }) => (_jsx("div", { className: clsx(styles.root, className), children: _jsxs("div", { className: "govuk-summary-card govuk-body", ...props, children: [_jsxs("div", { className: "govuk-summary-card__title-wrapper", style: titleBackground ? { background: titleBackground } : undefined, children: [_jsxs("h2", { className: "govuk-summary-card__title govuk-!-font-size-16", children: [_jsx("span", { children: title }), titleTag && (_jsx("span", { className: styles.titleTag, children: titleTag }))] }), actions && (_jsx("ul", { className: clsx("govuk-summary-card__actions", "govuk-!-font-size-16", styles.summaryCardTitleActions), children: actions.map((action) => (_jsx("li", { className: "govuk-summary-card__action", children: _jsx(SummaryListAction, { action: action }) }, action.text))) }))] }), subSectionNode && (_jsx("div", { children: subSectionNode })), _jsx("div", { className: clsx("govuk-summary-card__content", styles.govukSummaryCardContent), children: children })] }) }));
@@ -11,4 +11,12 @@
11
11
  .summaryCardTitleActions {
12
12
  font-weight: 400;
13
13
  }
14
- }
14
+ }
15
+
16
+ .titleTag {
17
+ margin-left: 1rem;
18
+
19
+ strong {
20
+ font-size: 16px;
21
+ }
22
+ }
@@ -0,0 +1,21 @@
1
+ import type React from "react";
2
+ export type TableHeader = {
3
+ content: React.ReactNode;
4
+ className?: string;
5
+ };
6
+ export type TableCell = {
7
+ content: React.ReactNode;
8
+ className?: string;
9
+ isHeader?: boolean;
10
+ };
11
+ export type TableRow = {
12
+ cells: TableCell[];
13
+ };
14
+ export type TableProps = {
15
+ headers: TableHeader[];
16
+ rows: TableRow[];
17
+ caption?: string;
18
+ className?: string;
19
+ };
20
+ export declare const Table: ({ headers, rows, caption, className, }: TableProps) => React.JSX.Element;
21
+ //# sourceMappingURL=Table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../src/components/Table/Table.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,wCAKnB,UAAU,KAAG,KAAK,CAAC,GAAG,CAAC,OA6CzB,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import clsx from "clsx";
4
+ export const Table = ({ headers, rows, caption, className, }) => {
5
+ return (_jsxs("table", { className: clsx("govuk-table", className), children: [caption && _jsx("caption", { className: "govuk-table__caption", children: caption }), _jsx("thead", { className: "govuk-table__head", children: _jsx("tr", { className: "govuk-table__row", children: headers.map((header, index) => (_jsx("th", { scope: "col", className: clsx("govuk-table__header", header.className), children: header.content }, index))) }) }), _jsx("tbody", { className: "govuk-table__body", children: rows.map((row, rowIndex) => (_jsx("tr", { className: "govuk-table__row", children: row.cells.map((cell, cellIndex) => cell.isHeader ? (_jsx("th", { scope: "row", className: clsx("govuk-table__header", cell.className), children: cell.content }, cellIndex)) : (_jsx("td", { className: clsx("govuk-table__cell", cell.className), children: cell.content }, cellIndex))) }, rowIndex))) })] }));
6
+ };
package/dist/index.d.ts CHANGED
@@ -16,4 +16,5 @@ export * from "./components/NotificationBanner/NotificationBanner";
16
16
  export * from "./components/Details/Details";
17
17
  export * from "./components/Tooltip/Tooltip";
18
18
  export * from "./components/Tabs/Tabs";
19
+ export * from "./components/Table/Table";
19
20
  //# 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;AACpC,cAAc,oDAAoD,CAAC;AACnE,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,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;AACnE,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC"}
package/dist/index.js CHANGED
@@ -16,3 +16,4 @@ export * from "./components/NotificationBanner/NotificationBanner";
16
16
  export * from "./components/Details/Details";
17
17
  export * from "./components/Tooltip/Tooltip";
18
18
  export * from "./components/Tabs/Tabs";
19
+ export * from "./components/Table/Table";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uktrade/react-component-library",
3
- "version": "0.22.6",
3
+ "version": "0.22.8",
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",
@@ -11,4 +11,12 @@
11
11
  .summaryCardTitleActions {
12
12
  font-weight: 400;
13
13
  }
14
- }
14
+ }
15
+
16
+ .titleTag {
17
+ margin-left: 1rem;
18
+
19
+ strong {
20
+ font-size: 16px;
21
+ }
22
+ }
@@ -24,6 +24,7 @@ export const SummaryList = ({ title, children, className, ...props }: SummaryLis
24
24
 
25
25
  export interface SummaryCardProps extends React.HTMLAttributes<HTMLDivElement> {
26
26
  title: string;
27
+ titleTag?: React.ReactNode;
27
28
  children?: React.ReactNode;
28
29
  actions?: SummaryListAction[];
29
30
  className?: string;
@@ -33,6 +34,7 @@ export interface SummaryCardProps extends React.HTMLAttributes<HTMLDivElement> {
33
34
 
34
35
  export const SummaryCard = ({
35
36
  title,
37
+ titleTag,
36
38
  children,
37
39
  actions,
38
40
  className,
@@ -46,9 +48,15 @@ export const SummaryCard = ({
46
48
  className="govuk-summary-card__title-wrapper"
47
49
  style={titleBackground ? { background: titleBackground } : undefined}
48
50
  >
49
- <h2 className="govuk-summary-card__title govuk-!-font-size-16">
50
- {title}
51
- </h2>
51
+ <h2 className="govuk-summary-card__title govuk-!-font-size-16">
52
+ <span>{title}</span>
53
+
54
+ {titleTag && (
55
+ <span className={styles.titleTag}>
56
+ {titleTag}
57
+ </span>
58
+ )}
59
+ </h2>
52
60
 
53
61
  {actions && (
54
62
  <ul
@@ -0,0 +1,78 @@
1
+ "use client";
2
+
3
+ import clsx from "clsx";
4
+ import type React from "react";
5
+
6
+ export type TableHeader = {
7
+ content: React.ReactNode;
8
+ className?: string;
9
+ };
10
+
11
+ export type TableCell = {
12
+ content: React.ReactNode;
13
+ className?: string;
14
+ isHeader?: boolean;
15
+ };
16
+
17
+ export type TableRow = {
18
+ cells: TableCell[];
19
+ };
20
+
21
+ export type TableProps = {
22
+ headers: TableHeader[];
23
+ rows: TableRow[];
24
+ caption?: string;
25
+ className?: string;
26
+ };
27
+
28
+ export const Table = ({
29
+ headers,
30
+ rows,
31
+ caption,
32
+ className,
33
+ }: TableProps): React.JSX.Element => {
34
+ return (
35
+ <table className={clsx("govuk-table", className)}>
36
+ {caption && <caption className="govuk-table__caption">{caption}</caption>}
37
+
38
+ <thead className="govuk-table__head">
39
+ <tr className="govuk-table__row">
40
+ {headers.map((header, index) => (
41
+ <th
42
+ key={index}
43
+ scope="col"
44
+ className={clsx("govuk-table__header", header.className)}
45
+ >
46
+ {header.content}
47
+ </th>
48
+ ))}
49
+ </tr>
50
+ </thead>
51
+
52
+ <tbody className="govuk-table__body">
53
+ {rows.map((row, rowIndex) => (
54
+ <tr key={rowIndex} className="govuk-table__row">
55
+ {row.cells.map((cell, cellIndex) =>
56
+ cell.isHeader ? (
57
+ <th
58
+ key={cellIndex}
59
+ scope="row"
60
+ className={clsx("govuk-table__header", cell.className)}
61
+ >
62
+ {cell.content}
63
+ </th>
64
+ ) : (
65
+ <td
66
+ key={cellIndex}
67
+ className={clsx("govuk-table__cell", cell.className)}
68
+ >
69
+ {cell.content}
70
+ </td>
71
+ ),
72
+ )}
73
+ </tr>
74
+ ))}
75
+ </tbody>
76
+ </table>
77
+ );
78
+ };
package/src/index.ts CHANGED
@@ -16,3 +16,4 @@ export * from "./components/NotificationBanner/NotificationBanner";
16
16
  export * from "./components/Details/Details";
17
17
  export * from "./components/Tooltip/Tooltip";
18
18
  export * from "./components/Tabs/Tabs";
19
+ export * from "./components/Table/Table";