govuk-chakra 0.0.14 → 0.0.16
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 +6 -4
- package/dist/{Button-DAqN4KBn.mjs → Button-D2zPYhfj.mjs} +8 -8
- package/dist/{Button-DAqN4KBn.mjs.map → Button-D2zPYhfj.mjs.map} +1 -1
- package/dist/{Button-CXQWUUx_.js → Button-DBeoyc1e.js} +2 -2
- package/dist/{Button-CXQWUUx_.js.map → Button-DBeoyc1e.js.map} +1 -1
- package/dist/DonutChart-D3Sq34se.js +2 -0
- package/dist/{DonutChart-DXLy2EPU.js.map → DonutChart-D3Sq34se.js.map} +1 -1
- package/dist/{DonutChart-s0i7PCWM.mjs → DonutChart-XZvUd_OH.mjs} +53 -53
- package/dist/{DonutChart-s0i7PCWM.mjs.map → DonutChart-XZvUd_OH.mjs.map} +1 -1
- package/dist/chakra.cjs +1 -1
- package/dist/chakra.mjs +6 -6
- package/dist/charts.cjs +1 -1
- package/dist/charts.mjs +49 -49
- package/dist/editor.cjs +1 -1
- package/dist/editor.mjs +79 -79
- package/dist/{fieldFocusStyles-CR3WEdJM.js → fieldFocusStyles-SnxM1ENz.js} +2 -2
- package/dist/{fieldFocusStyles-CR3WEdJM.js.map → fieldFocusStyles-SnxM1ENz.js.map} +1 -1
- package/dist/{fieldFocusStyles-DSgAG3af.mjs → fieldFocusStyles-i7bGS_ct.mjs} +2 -2
- package/dist/{fieldFocusStyles-DSgAG3af.mjs.map → fieldFocusStyles-i7bGS_ct.mjs.map} +1 -1
- package/dist/{fonts-BhsM-8n2.js → fonts-CcuQpO84.js} +1 -1
- package/dist/{fonts-BhsM-8n2.js.map → fonts-CcuQpO84.js.map} +1 -1
- package/dist/{fonts-ov_EiRYw.mjs → fonts-CwkXY-dR.mjs} +1 -1
- package/dist/{fonts-ov_EiRYw.mjs.map → fonts-CwkXY-dR.mjs.map} +1 -1
- package/dist/govUKTheme-B6N8jc4i.js +2 -0
- package/dist/{govUkTheme-C4JEP9HJ.js.map → govUKTheme-B6N8jc4i.js.map} +1 -1
- package/dist/{govUkTheme-BXD0ZGIE.mjs → govUKTheme-CDTBLgqV.mjs} +219 -219
- package/dist/{govUkTheme-BXD0ZGIE.mjs.map → govUKTheme-CDTBLgqV.mjs.map} +1 -1
- package/dist/govuk-chakra-DIQtEMpV.js +2 -0
- package/dist/govuk-chakra-DIQtEMpV.js.map +1 -0
- package/dist/{govuk-chakra-CB5sulWP.mjs → govuk-chakra-G-0BpNPi.mjs} +1017 -956
- package/dist/govuk-chakra-G-0BpNPi.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +6 -6
- package/dist/provider-BSZ9Md7O.js +2 -0
- package/dist/provider-BSZ9Md7O.js.map +1 -0
- package/dist/provider-BiK0vyjw.mjs +13 -0
- package/dist/provider-BiK0vyjw.mjs.map +1 -0
- package/dist/provider.cjs +1 -1
- package/dist/provider.mjs +3 -3
- package/dist/{px-to-rem-B1V8yc0o.mjs → px-to-rem-Bun7yTT7.mjs} +1 -1
- package/dist/{px-to-rem-B1V8yc0o.mjs.map → px-to-rem-Bun7yTT7.mjs.map} +1 -1
- package/dist/{px-to-rem-CahZatpE.js → px-to-rem-kQOjVfEt.js} +1 -1
- package/dist/{px-to-rem-CahZatpE.js.map → px-to-rem-kQOjVfEt.js.map} +1 -1
- package/dist/theme.cjs +1 -1
- package/dist/theme.mjs +2 -2
- package/dist/types/components/GOVUKHeader/GOV.UKHeader.stories.d.ts +1 -0
- package/dist/types/components/PhaseBanner/PhaseBanner.d.ts +3 -4
- package/dist/types/components/Popover/Popover.recipe.d.ts +1 -1
- package/dist/types/components/Stat/Stat.d.ts +1 -1
- package/dist/types/components/SummaryList/SummaryList.d.ts +6 -6
- package/dist/types/components/Table/Table.d.ts +2 -2
- package/dist/types/provider.d.ts +1 -1
- package/dist/types/theme/govUKTheme.d.ts +2853 -0
- package/dist/types/theme/index.d.ts +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.mjs +2 -2
- package/package.json +1 -1
- package/dist/DonutChart-DXLy2EPU.js +0 -2
- package/dist/govUkTheme-C4JEP9HJ.js +0 -2
- package/dist/govuk-chakra-CB5sulWP.mjs.map +0 -1
- package/dist/govuk-chakra-DJckL8TR.js +0 -2
- package/dist/govuk-chakra-DJckL8TR.js.map +0 -1
- package/dist/provider-B4S-LLH2.js +0 -2
- package/dist/provider-B4S-LLH2.js.map +0 -1
- package/dist/provider-BwvwXCqG.mjs +0 -15
- package/dist/provider-BwvwXCqG.mjs.map +0 -1
- package/dist/types/theme/govUkTheme.d.ts +0 -1
package/README.md
CHANGED
|
@@ -14,6 +14,8 @@ Current Chakra version being used is: **3.34.0**.
|
|
|
14
14
|
## Links
|
|
15
15
|
|
|
16
16
|
- [**Live Demo**](https://gov-uk-gds-react-chakra.vercel.app 'Live demo')
|
|
17
|
+
- [**Sandbox Demo**](https://gov-uk-gds-react-chakra.vercel.app 'Live demo')
|
|
18
|
+
|
|
17
19
|
- [**The npm page**](https://www.npmjs.com/package/govuk-chakra)
|
|
18
20
|
- [**GOV.UK Design System Figma File in Community**](https://www.figma.com/community/file/1550623138170727031/gov-uk-design-system-2025)
|
|
19
21
|
- [**Chakra-UI Library**](https://www.chakra-ui.com/docs/components/concepts/overview)
|
|
@@ -23,7 +25,7 @@ Current Chakra version being used is: **3.34.0**.
|
|
|
23
25
|
|
|
24
26
|
- A Chakra-based design skin for React applications,
|
|
25
27
|
- A set of GOV.UK-flavoured components such as `GOVUKHeader`, `GOVUKFooter`, `CookieBanner`, `TaskList`, `SummaryList`, and form primitives
|
|
26
|
-
- A reusable Chakra system theme exported as `
|
|
28
|
+
- A reusable Chakra system theme exported as `govUKTheme`
|
|
27
29
|
- A package that can be published to a package registry and consumed as a library instead of only being run as a local app
|
|
28
30
|
|
|
29
31
|
## What This Project Is Not
|
|
@@ -212,7 +214,7 @@ export function ExamplePage() {
|
|
|
212
214
|
Chakra UI passthrough plus the shared GOV.UK provider and theme exports
|
|
213
215
|
|
|
214
216
|
- `govuk-chakra/theme`
|
|
215
|
-
Lightweight theme-only entry for `
|
|
217
|
+
Lightweight theme-only entry for `govUKTheme`
|
|
216
218
|
|
|
217
219
|
- `govuk-chakra/provider`
|
|
218
220
|
Lightweight provider entry for `GOVUKProvider`
|
|
@@ -237,11 +239,11 @@ If you want direct access to the Chakra system rather than the convenience provi
|
|
|
237
239
|
|
|
238
240
|
```tsx
|
|
239
241
|
import { ChakraProvider } from '@chakra-ui/react'
|
|
240
|
-
import {
|
|
242
|
+
import { govUKTheme } from 'govuk-chakra/theme'
|
|
241
243
|
|
|
242
244
|
export function AppRoot() {
|
|
243
245
|
return (
|
|
244
|
-
<ChakraProvider value={
|
|
246
|
+
<ChakraProvider value={govUKTheme}>
|
|
245
247
|
<App />
|
|
246
248
|
</ChakraProvider>
|
|
247
249
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { o as e } from "./px-to-rem-
|
|
1
|
+
import { o as e } from "./px-to-rem-Bun7yTT7.mjs";
|
|
2
2
|
import { Button as t } from "@chakra-ui/react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
import { forwardRef as i } from "react";
|
|
5
5
|
//#region src/components/Button/buttonVariants.ts
|
|
6
6
|
var a = {
|
|
7
7
|
outline: "none",
|
|
@@ -116,7 +116,7 @@ var a = {
|
|
|
116
116
|
_focus: a,
|
|
117
117
|
_focusVisible: a
|
|
118
118
|
}
|
|
119
|
-
}, s =
|
|
119
|
+
}, s = i(({ variant: i = "primary", children: a, startButton: s, ...c }, l) => /* @__PURE__ */ r(t, {
|
|
120
120
|
ref: l,
|
|
121
121
|
borderRadius: "0",
|
|
122
122
|
fontSize: "1.1875rem",
|
|
@@ -126,9 +126,9 @@ var a = {
|
|
|
126
126
|
fontFamily: "body",
|
|
127
127
|
fontWeight: s ? "bold" : "normal",
|
|
128
128
|
padding: `${e(8)} ${e(10)} ${e(7)}`,
|
|
129
|
-
...o[
|
|
129
|
+
...o[i],
|
|
130
130
|
...c,
|
|
131
|
-
children: [a, s && /* @__PURE__ */
|
|
131
|
+
children: [a, s && /* @__PURE__ */ n("svg", {
|
|
132
132
|
className: "govuk-button__start-icon",
|
|
133
133
|
xmlns: "http://www.w3.org/2000/svg",
|
|
134
134
|
width: "17.5",
|
|
@@ -136,7 +136,7 @@ var a = {
|
|
|
136
136
|
viewBox: "0 0 33 40",
|
|
137
137
|
"aria-hidden": "true",
|
|
138
138
|
focusable: "false",
|
|
139
|
-
children: /* @__PURE__ */
|
|
139
|
+
children: /* @__PURE__ */ n("path", {
|
|
140
140
|
fill: "currentColor",
|
|
141
141
|
d: "M0 0h13l20 20-20 20H0l20-20z"
|
|
142
142
|
})
|
|
@@ -146,4 +146,4 @@ s.displayName = "Button";
|
|
|
146
146
|
//#endregion
|
|
147
147
|
export { o as n, s as t };
|
|
148
148
|
|
|
149
|
-
//# sourceMappingURL=Button-
|
|
149
|
+
//# sourceMappingURL=Button-D2zPYhfj.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button-
|
|
1
|
+
{"version":3,"file":"Button-D2zPYhfj.mjs","names":[],"sources":["../src/components/Button/buttonVariants.ts","../src/components/Button/Button.tsx"],"sourcesContent":["import type { SystemStyleObject } from '@chakra-ui/react'\n\nexport type ButtonVariant = 'primary' | 'secondary' | 'plain' | 'error' | 'inverse' | 'link'\n\nexport const buttonFocusStyles: SystemStyleObject = {\n outline: 'none',\n bgColor: 'yellow.500',\n color: 'grey.950',\n}\n\nexport const buttonVariantStyles: Record<ButtonVariant, SystemStyleObject> = {\n primary: {\n bgColor: 'green.500',\n color: 'white',\n boxShadow: '0 2px 0 {colors.green.800}',\n _hover: {\n bgColor: 'green.700',\n color: 'white',\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n secondary: {\n color: 'grey.900',\n bgColor: 'grey.50',\n _dark: {\n color: 'grey.50',\n bgColor: 'grey.600',\n _hover: {\n bgColor: 'grey.600',\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n boxShadow: '0 2px 0 {colors.grey.200}',\n _hover: {\n bgColor: 'grey.100',\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n error: {\n bgColor: 'border.error',\n color: 'white',\n boxShadow: '0 2px 0 {colors.red.800}',\n _hover: {\n bgColor: 'red.700',\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n inverse: {\n bgColor: 'bg',\n color: 'blue.500',\n boxShadow: '0 2px 0 {colors.blue.700}',\n _dark: {\n bgColor: 'blue.900',\n color: 'blue.50',\n _hover: {\n color: 'blue.50',\n bgColor: 'blue.800',\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _hover: {\n color: 'blue.700',\n bgColor: 'blue.100',\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n plain: {\n bgColor: 'transparent',\n color: 'fg',\n _dark: {\n _hover: {\n color: 'grey.50',\n bgColor: 'grey.800',\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _hover: {\n color: 'grey.700',\n bgColor: 'grey.100',\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n link: {\n bgColor: 'transparent',\n color: 'blue.500',\n textDecoration: 'underline',\n boxShadow: 'none',\n _hover: {\n color: 'blue.700',\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n}\n","import { Button as ChakraButton, type ButtonProps as ChakraButtonProps } from '@chakra-ui/react'\n\nimport { forwardRef } from 'react'\nimport { pxToRem } from '@/utils'\nimport { buttonVariantStyles, type ButtonVariant } from './buttonVariants'\n\nexport interface ButtonProps extends Omit<ChakraButtonProps, 'variant'> {\n variant?: ButtonVariant\n startButton?: boolean\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n ({ variant = 'primary', children, startButton, ...props }, ref) => {\n return (\n <ChakraButton\n ref={ref}\n borderRadius=\"0\"\n fontSize=\"1.1875rem\"\n bg=\"green.500\"\n color=\"white\"\n boxShadow=\"0 2px 0 {colors.green.900}\"\n fontFamily=\"body\"\n fontWeight={startButton ? 'bold' : 'normal'}\n padding={`${pxToRem(8)} ${pxToRem(10)} ${pxToRem(7)}`}\n {...buttonVariantStyles[variant]}\n {...props}\n >\n {children}\n {startButton && (\n <svg\n className=\"govuk-button__start-icon\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"17.5\"\n height=\"19\"\n viewBox=\"0 0 33 40\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path fill=\"currentColor\" d=\"M0 0h13l20 20-20 20H0l20-20z\"></path>\n </svg>\n )}\n </ChakraButton>\n )\n }\n)\n\nButton.displayName = 'Button'\n"],"mappings":";;;;;AAIA,IAAa,IAAuC;CAClD,SAAS;CACT,SAAS;CACT,OAAO;CACR,EAEY,IAAgE;CAC3E,SAAS;EACP,SAAS;EACT,OAAO;EACP,WAAW;EACX,QAAQ;GACN,SAAS;GACT,OAAO;GACP,QAAQ;GACR,eAAe;GAChB;EACD,QAAQ;EACR,eAAe;EAChB;CACD,WAAW;EACT,OAAO;EACP,SAAS;EACT,OAAO;GACL,OAAO;GACP,SAAS;GACT,QAAQ;I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AD;EACE,WAAU;EACV,OAAM;EACN,OAAM;EACN,QAAO;EACP,SAAQ;EACR,eAAY;EACZ,WAAU;YAEV,kBAAC,QAAD;GAAM,MAAK;GAAe,GAAE;GAAsC,CAAA;EAC9D,CAAA,CAEK;GAGpB;AAED,EAAO,cAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require(`./iconBase-BVfFpyD6.js`);const e=require(`./px-to-rem-
|
|
2
|
-
//# sourceMappingURL=Button-
|
|
1
|
+
require(`./iconBase-BVfFpyD6.js`);const e=require(`./px-to-rem-kQOjVfEt.js`);let t=require(`@chakra-ui/react`),n=require(`react/jsx-runtime`),r=require(`react`);var i={outline:`none`,bgColor:`yellow.500`,color:`grey.950`},a={primary:{bgColor:`green.500`,color:`white`,boxShadow:`0 2px 0 {colors.green.800}`,_hover:{bgColor:`green.700`,color:`white`,_focus:i,_focusVisible:i},_focus:i,_focusVisible:i},secondary:{color:`grey.900`,bgColor:`grey.50`,_dark:{color:`grey.50`,bgColor:`grey.600`,_hover:{bgColor:`grey.600`,_focus:i,_focusVisible:i},_focus:i,_focusVisible:i},boxShadow:`0 2px 0 {colors.grey.200}`,_hover:{bgColor:`grey.100`,_focus:i,_focusVisible:i},_focus:i,_focusVisible:i},error:{bgColor:`border.error`,color:`white`,boxShadow:`0 2px 0 {colors.red.800}`,_hover:{bgColor:`red.700`,_focus:i,_focusVisible:i},_focus:i,_focusVisible:i},inverse:{bgColor:`bg`,color:`blue.500`,boxShadow:`0 2px 0 {colors.blue.700}`,_dark:{bgColor:`blue.900`,color:`blue.50`,_hover:{color:`blue.50`,bgColor:`blue.800`,_focus:i,_focusVisible:i},_focus:i,_focusVisible:i},_hover:{color:`blue.700`,bgColor:`blue.100`,_focus:i,_focusVisible:i},_focus:i,_focusVisible:i},plain:{bgColor:`transparent`,color:`fg`,_dark:{_hover:{color:`grey.50`,bgColor:`grey.800`,_focus:i,_focusVisible:i},_focus:i,_focusVisible:i},_hover:{color:`grey.700`,bgColor:`grey.100`,_focus:i,_focusVisible:i},_focus:i,_focusVisible:i},link:{bgColor:`transparent`,color:`blue.500`,textDecoration:`underline`,boxShadow:`none`,_hover:{color:`blue.700`,_focus:i,_focusVisible:i},_focus:i,_focusVisible:i}},o=(0,r.forwardRef)(({variant:r=`primary`,children:i,startButton:o,...s},c)=>(0,n.jsxs)(t.Button,{ref:c,borderRadius:`0`,fontSize:`1.1875rem`,bg:`green.500`,color:`white`,boxShadow:`0 2px 0 {colors.green.900}`,fontFamily:`body`,fontWeight:o?`bold`:`normal`,padding:`${e.o(8)} ${e.o(10)} ${e.o(7)}`,...a[r],...s,children:[i,o&&(0,n.jsx)(`svg`,{className:`govuk-button__start-icon`,xmlns:`http://www.w3.org/2000/svg`,width:`17.5`,height:`19`,viewBox:`0 0 33 40`,"aria-hidden":`true`,focusable:`false`,children:(0,n.jsx)(`path`,{fill:`currentColor`,d:`M0 0h13l20 20-20 20H0l20-20z`})})]}));o.displayName=`Button`,Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return o}});
|
|
2
|
+
//# sourceMappingURL=Button-DBeoyc1e.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button-
|
|
1
|
+
{"version":3,"file":"Button-DBeoyc1e.js","names":[],"sources":["../src/components/Button/buttonVariants.ts","../src/components/Button/Button.tsx"],"sourcesContent":["import type { SystemStyleObject } from '@chakra-ui/react'\n\nexport type ButtonVariant = 'primary' | 'secondary' | 'plain' | 'error' | 'inverse' | 'link'\n\nexport const buttonFocusStyles: SystemStyleObject = {\n outline: 'none',\n bgColor: 'yellow.500',\n color: 'grey.950',\n}\n\nexport const buttonVariantStyles: Record<ButtonVariant, SystemStyleObject> = {\n primary: {\n bgColor: 'green.500',\n color: 'white',\n boxShadow: '0 2px 0 {colors.green.800}',\n _hover: {\n bgColor: 'green.700',\n color: 'white',\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n secondary: {\n color: 'grey.900',\n bgColor: 'grey.50',\n _dark: {\n color: 'grey.50',\n bgColor: 'grey.600',\n _hover: {\n bgColor: 'grey.600',\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n boxShadow: '0 2px 0 {colors.grey.200}',\n _hover: {\n bgColor: 'grey.100',\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n error: {\n bgColor: 'border.error',\n color: 'white',\n boxShadow: '0 2px 0 {colors.red.800}',\n _hover: {\n bgColor: 'red.700',\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n inverse: {\n bgColor: 'bg',\n color: 'blue.500',\n boxShadow: '0 2px 0 {colors.blue.700}',\n _dark: {\n bgColor: 'blue.900',\n color: 'blue.50',\n _hover: {\n color: 'blue.50',\n bgColor: 'blue.800',\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _hover: {\n color: 'blue.700',\n bgColor: 'blue.100',\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n plain: {\n bgColor: 'transparent',\n color: 'fg',\n _dark: {\n _hover: {\n color: 'grey.50',\n bgColor: 'grey.800',\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _hover: {\n color: 'grey.700',\n bgColor: 'grey.100',\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n link: {\n bgColor: 'transparent',\n color: 'blue.500',\n textDecoration: 'underline',\n boxShadow: 'none',\n _hover: {\n color: 'blue.700',\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n _focus: buttonFocusStyles,\n _focusVisible: buttonFocusStyles,\n },\n}\n","import { Button as ChakraButton, type ButtonProps as ChakraButtonProps } from '@chakra-ui/react'\n\nimport { forwardRef } from 'react'\nimport { pxToRem } from '@/utils'\nimport { buttonVariantStyles, type ButtonVariant } from './buttonVariants'\n\nexport interface ButtonProps extends Omit<ChakraButtonProps, 'variant'> {\n variant?: ButtonVariant\n startButton?: boolean\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n ({ variant = 'primary', children, startButton, ...props }, ref) => {\n return (\n <ChakraButton\n ref={ref}\n borderRadius=\"0\"\n fontSize=\"1.1875rem\"\n bg=\"green.500\"\n color=\"white\"\n boxShadow=\"0 2px 0 {colors.green.900}\"\n fontFamily=\"body\"\n fontWeight={startButton ? 'bold' : 'normal'}\n padding={`${pxToRem(8)} ${pxToRem(10)} ${pxToRem(7)}`}\n {...buttonVariantStyles[variant]}\n {...props}\n >\n {children}\n {startButton && (\n <svg\n className=\"govuk-button__start-icon\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"17.5\"\n height=\"19\"\n viewBox=\"0 0 33 40\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path fill=\"currentColor\" d=\"M0 0h13l20 20-20 20H0l20-20z\"></path>\n </svg>\n )}\n </ChakraButton>\n )\n }\n)\n\nButton.displayName = 'Button'\n"],"mappings":"iKAIA,IAAa,EAAuC,CAClD,QAAS,OACT,QAAS,aACT,MAAO,WACR,CAEY,EAAgE,CAC3E,QAAS,CACP,QAAS,YACT,MAAO,QACP,UAAW,6BACX,OAAQ,CACN,QAAS,YACT,MAAO,QACP,OAAQ,EACR,cAAe,EAChB,CACD,OAAQ,EACR,cAAe,EAChB,CACD,UAAW,CACT,MAAO,WAC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,GAAG,CAAC,GAAG,EAAA,EAAQ,EAAE,GACnD,GAAI,EAAoB,GACxB,GAAI,WAXN,CAaG,EACA,IACC,EAAA,EAAA,KAAC,MAAD,CACE,UAAU,2BACV,MAAM,6BACN,MAAM,OACN,OAAO,KACP,QAAQ,YACR,cAAY,OACZ,UAAU,kBAEV,EAAA,EAAA,KAAC,OAAD,CAAM,KAAK,eAAe,EAAE,+BAAsC,CAAA,CAC9D,CAAA,CAEK,GAGpB,CAED,EAAO,YAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
require(`./iconBase-BVfFpyD6.js`);const e=require(`./fonts-CcuQpO84.js`),t=require(`./px-to-rem-kQOjVfEt.js`);let n=require(`@chakra-ui/react`),r=require(`react/jsx-runtime`),i=require(`react`),a=require(`recharts`),o=require(`@chakra-ui/charts`);var s=(0,i.forwardRef)(function({fontSize:e,fontWeight:i=400,...a},o){typeof e==`number`&&!(e in t.a)&&console.warn(`[GOV.UK Text] fontSize={${e}} is not a valid GOV.UK type scale point. Use one of: 16, 19, 24, 27, 36, 48, 80.`);let s=t.t(e);return s?(0,r.jsx)(n.Text,{ref:o,fontSize:{base:s.small.fontSize,md:s.large.fontSize},lineHeight:{base:s.small.lineHeight,md:s.large.lineHeight},fontWeight:i,fontFamily:`body`,...a}):(0,r.jsx)(n.Text,{ref:o,fontSize:e,...a})}),c=(0,i.createContext)(null);function l(){let e=(0,i.useContext)(c);if(!e)throw Error(`Chart components must be rendered inside Chart.Root`);return e}function u(e,t){if(!(!e||!t||typeof e.payload!=`object`||e.payload===null))return e.payload[t]}function d(e){return e==null?``:(0,i.isValidElement)(e)||typeof e==`string`||typeof e==`number`?e:typeof e==`boolean`||typeof e==`bigint`?String(e):Array.isArray(e)?e.join(`, `):String(e)}function f(e){return typeof e!=`string`||e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}function p({payload:e,label:t,labelFormatter:i,hideLabel:a,hideIndicator:o,hideSeriesLabel:c,showTotal:p,fitContent:m,nameKey:h,formatter:g,render:_}){let v=l(),y=e?.filter(e=>e.color!==`none`||e.type!==`none`);if(!y?.length)return null;let b=y,x=y[0],S=u(x,h)??t??x?.dataKey??`value`,C=d(i?.(String(S),b)??S),w=y.reduce((e,t)=>typeof t.value==`number`?e+t.value:e,0);return(0,r.jsxs)(n.Stack,{minW:m?void 0:`8rem`,gap:`1`,rounded:`l2`,bg:`bg.panel`,px:`2.5`,py:`1`,textStyle:`xs`,shadow:`md`,children:[a?null:(0,r.jsx)(s,{fontWeight:`medium`,children:C}),(0,r.jsx)(n.Box,{children:y.map((e,t)=>{let i=v.getSeries(e);if(_)return(0,r.jsx)(n.Box,{children:_(e)},t);let a=g?g(e.value,e.name):e.value?.toLocaleString(),[l,u]=Array.isArray(a)?a:[a,f(e.name)];return(0,r.jsxs)(n.Flex,{gap:`1.5`,wrap:`wrap`,align:`center`,children:[o?null:i?.color?(0,r.jsx)(n.Box,{boxSize:`2`,rounded:`full`,bg:v.color(i.color),borderWidth:`1px`,borderColor:`blackAlpha.200`,flexShrink:0}):(0,r.jsx)(n.Box,{boxSize:`2`,rounded:`full`,bg:`border.emphasized`,borderWidth:`1px`,borderColor:`blackAlpha.200`,flexShrink:0}),(0,r.jsxs)(n.HStack,{justify:`space-between`,flex:`1`,children:[c?null:(0,r.jsx)(s,{color:`fg.muted`,children:d(u)}),e.value==null?null:(0,r.jsx)(s,{fontFamily:`mono`,fontWeight:`medium`,fontVariantNumeric:`tabular-nums`,children:d(l)})]})]},t)})}),p?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.Separator,{mt:`1`}),(0,r.jsxs)(n.HStack,{gap:`1`,justify:`space-between`,pb:`1`,children:[(0,r.jsx)(n.Span,{color:`fg.muted`,children:`Total`}),(0,r.jsx)(s,{fontFamily:`mono`,fontWeight:`medium`,fontVariantNumeric:`tabular-nums`,children:g?(()=>{let e=g(w,``);return Array.isArray(e)?e[0]:e})():w.toLocaleString()})]})]}):null]})}function m({payload:e,verticalAlign:t=`bottom`,align:i=`center`,title:a,orientation:o,nameKey:c,spacing:p=`3`,interaction:m=`hover`,rootProps:h,itemProps:g,labelProps:_,indicatorProps:v}){let y=l(),b=e?.filter(e=>e.color!==`none`||e.type!==`none`);if(!b?.length)return null;let x=typeof p==`number`?`${p}px`:y.spacing(p);return(0,r.jsxs)(n.Stack,{gap:`1.5`,align:{left:`flex-start`,center:`center`,right:`flex-end`}[i],pt:t===`bottom`?`3`:void 0,pb:t===`top`?`3`:void 0,...h,children:[a?(0,r.jsx)(s,{fontWeight:`medium`,children:a}):null,(0,r.jsx)(n.Flex,{"data-orientation":o,gap:x,direction:{_horizontal:`row`,_vertical:`column`},align:{_horizontal:`center`,_vertical:`flex-start`},flexWrap:`wrap`,children:b.map((e,t)=>{let i=y.getSeries(e),a=i?.name==null?void 0:typeof i.name==`string`?i.name:String(i.name),o=f(u(e,c)??i?.label);return(0,r.jsxs)(n.HStack,{gap:`1.5`,style:{opacity:y.getSeriesOpacity(a,.6)},onClick:()=>{m===`click`&&a&&y.setHighlightedSeries(e=>e===a?null:a)},onMouseEnter:()=>{m===`hover`&&a&&y.setHighlightedSeries(a)},onMouseLeave:()=>{m===`hover`&&a&&y.setHighlightedSeries(null)},...g,children:[i?.icon?i.icon:(0,r.jsx)(n.Box,{boxSize:`2`,rounded:`full`,bg:i?.color?y.color(i.color):`border.emphasized`,borderWidth:`1px`,borderColor:`blackAlpha.200`,flexShrink:0,...v}),(0,r.jsx)(n.Span,{color:`fg.muted`,..._,children:d(o)})]},t)})})]})}function h(e){let{rootProps:t,itemProps:n,labelProps:i,indicatorProps:o,title:s,nameKey:c,interaction:l,spacing:u,payload:d,align:f,verticalAlign:p,layout:h,...g}=e;return(0,r.jsx)(a.Legend,{...g,align:f,verticalAlign:p,layout:h,content:(0,r.jsx)(m,{rootProps:t,itemProps:n,labelProps:i,indicatorProps:o,title:s,nameKey:c,interaction:l,spacing:u,payload:d,align:f,verticalAlign:p,layout:h})})}function g(e){return(0,r.jsx)(a.Tooltip,{...e,content:(0,r.jsx)(p,{...e})})}function _({fontFamily:n=`body`,fontSize:i=16,...a}){let s=t.t(i);if(!s)console.warn(`[GOV.UK Chart] fontSize={${i}} is not a valid GOV.UK type scale point. Use one of: 16, 19, 24, 27, 36, 48, 80.`);else return(0,r.jsx)(c.Provider,{value:a.chart,children:(0,r.jsx)(o.Chart.Root,{fontFamily:n,css:{"& svg.recharts-surface tspan":{fontSize:{base:s.small.fontSize,md:s.large.fontSize},lineHeight:{base:s.small.lineHeight,md:s.large.lineHeight},color:`fg`,fontFamily:e.t.body.value},"& .recharts-tooltip-wrapper":{background:`var(--govuk-colors-bg)`,borderRadius:`var(--govuk-radii-l2)`}},...a})})}var v=Object.assign(_,{...o.Chart,Root:_,Legend:h,LegendContent:m,Tooltip:g,TooltipContent:p});function y({chart:e,chartRootProps:t,...n}){return(0,r.jsx)(v.Root,{chart:e,...t,children:(0,r.jsx)(a.PieChart,{data:e.data,...n})})}var b=Object.assign(y,{Root:y});Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return b}});
|
|
2
|
+
//# sourceMappingURL=DonutChart-D3Sq34se.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DonutChart-DXLy2EPU.js","names":[],"sources":["../src/components/Text/Text.tsx","../src/components/Chart/Chart.tsx","../src/components/DonutChart/DonutChart.tsx"],"sourcesContent":["import { Text as ChakraText, type TextProps as ChakraTextProps } from '@chakra-ui/react'\nimport { forwardRef } from 'react'\nimport { getGovukTypeScale, govukTypeScale, type GovukTypeScalePoint } from '@/utils'\n\nexport interface TextProps extends Omit<ChakraTextProps, 'fontSize' | 'fontWeight'> {\n fontSize?: GovukTypeScalePoint | ChakraTextProps['fontSize']\n fontWeight?: ChakraTextProps['fontWeight']\n}\n\nexport const Text = forwardRef<HTMLParagraphElement, TextProps>(function Text(\n { fontSize, fontWeight = 400, ...props },\n ref\n) {\n if (typeof fontSize === 'number' && !(fontSize in govukTypeScale)) {\n console.warn(\n `[GOV.UK Text] fontSize={${fontSize}} is not a valid GOV.UK type scale point. Use one of: 16, 19, 24, 27, 36, 48, 80.`\n )\n }\n\n const scale = getGovukTypeScale(fontSize)\n\n if (scale) {\n return (\n <ChakraText\n ref={ref}\n fontSize={{ base: scale.small.fontSize, md: scale.large.fontSize }}\n lineHeight={{ base: scale.small.lineHeight, md: scale.large.lineHeight }}\n fontWeight={fontWeight}\n fontFamily=\"body\"\n {...props}\n />\n )\n }\n\n return <ChakraText ref={ref} fontSize={fontSize as ChakraTextProps['fontSize']} {...props} />\n})\n","import { Box, Flex, HStack, Separator, Span, Stack } from '@chakra-ui/react'\nimport { fonts } from '@/theme/fonts'\nimport {\n Chart as ChakraChart,\n type ChartLegendProps as ChakraChartLegendProps,\n type ChartTooltipProps as ChakraChartTooltipProps,\n type UseChartReturn,\n} from '@chakra-ui/charts'\nimport {\n createContext,\n isValidElement,\n useContext,\n type ComponentPropsWithoutRef,\n type ReactNode,\n} from 'react'\nimport { Legend as RechartsLegend, Tooltip as RechartsTooltip } from 'recharts'\nimport type { Payload } from 'recharts/types/component/DefaultTooltipContent'\nimport type { TooltipPayloadEntry } from 'recharts/types/state/tooltipSlice'\nimport { getGovukTypeScale } from '@/utils'\nimport { Text } from '../Text'\n\nexport interface ChartRootProps<T> extends Omit<\n ComponentPropsWithoutRef<typeof ChakraChart.Root>,\n 'chart'\n> {\n chart: UseChartReturn<T>\n}\n\nexport type ChartRechartsTooltipProps = Omit<\n ComponentPropsWithoutRef<typeof RechartsTooltip>,\n 'content'\n> &\n ChakraChartTooltipProps\n\nexport interface ChartLegendContentProps extends ChakraChartLegendProps {\n rootProps?: ComponentPropsWithoutRef<typeof Stack>\n itemProps?: ComponentPropsWithoutRef<typeof HStack>\n labelProps?: ComponentPropsWithoutRef<typeof Span>\n indicatorProps?: ComponentPropsWithoutRef<typeof Box>\n}\n\nexport type ChartRechartsLegendProps = Omit<\n ComponentPropsWithoutRef<typeof RechartsLegend>,\n 'content'\n> &\n ChartLegendContentProps\n\nconst ChartContext = createContext<UseChartReturn<unknown> | null>(null)\n\nfunction useGovukChartContext() {\n const chart = useContext(ChartContext)\n\n if (!chart) {\n throw new Error('Chart components must be rendered inside Chart.Root')\n }\n\n return chart\n}\n\nfunction getPayloadProp(item: TooltipPayloadEntry | undefined, key?: string) {\n if (!item || !key || typeof item.payload !== 'object' || item.payload === null) {\n return undefined\n }\n\n const payload = item.payload as Record<string, unknown>\n return payload[key]\n}\n\nfunction toRenderableValue(value: unknown): ReactNode {\n if (value == null) {\n return ''\n }\n\n if (isValidElement(value)) {\n return value\n }\n\n if (typeof value === 'string' || typeof value === 'number') {\n return value\n }\n\n if (typeof value === 'boolean' || typeof value === 'bigint') {\n return String(value)\n }\n\n if (Array.isArray(value)) {\n return value.join(', ')\n }\n\n return String(value)\n}\n\nfunction capitalizeLabel(value: unknown) {\n if (typeof value !== 'string' || value.length === 0) {\n return value\n }\n\n return value.charAt(0).toUpperCase() + value.slice(1)\n}\n\nfunction ChartTooltip({\n payload: payloadProp,\n label,\n labelFormatter,\n hideLabel,\n hideIndicator,\n hideSeriesLabel,\n showTotal,\n fitContent,\n nameKey,\n formatter,\n render,\n}: ChakraChartTooltipProps) {\n const chart = useGovukChartContext()\n const payload = payloadProp?.filter((item) => item.color !== 'none' || item.type !== 'none')\n\n if (!payload?.length) {\n return null\n }\n\n const callbackPayload = payload as Array<Payload<string | number, string>>\n const firstItem = payload[0]\n const rawLabel = getPayloadProp(firstItem, nameKey) ?? label ?? firstItem?.dataKey ?? 'value'\n const tooltipLabel = toRenderableValue(\n labelFormatter?.(String(rawLabel), callbackPayload) ?? rawLabel\n )\n const total = payload.reduce((sum, item) => {\n return typeof item.value === 'number' ? sum + item.value : sum\n }, 0)\n\n return (\n <Stack\n minW={fitContent ? undefined : '8rem'}\n gap=\"1\"\n rounded=\"l2\"\n bg=\"bg.panel\"\n px=\"2.5\"\n py=\"1\"\n textStyle=\"xs\"\n shadow=\"md\"\n >\n {!hideLabel ? <Text fontWeight=\"medium\">{tooltipLabel}</Text> : null}\n <Box>\n {payload.map((item, index) => {\n const config = chart.getSeries(item)\n\n if (render) {\n return <Box key={index}>{render(item as Payload<string, string>)}</Box>\n }\n\n const formatted = formatter\n ? formatter(item.value, item.name)\n : item.value?.toLocaleString()\n const [formattedValue, formattedName] = Array.isArray(formatted)\n ? formatted\n : [formatted, capitalizeLabel(item.name)]\n\n return (\n <Flex key={index} gap=\"1.5\" wrap=\"wrap\" align=\"center\">\n {!hideIndicator ? (\n config?.color ? (\n <Box\n boxSize=\"2\"\n rounded=\"full\"\n bg={chart.color(config.color)}\n borderWidth=\"1px\"\n borderColor=\"blackAlpha.200\"\n flexShrink={0}\n />\n ) : (\n <Box\n boxSize=\"2\"\n rounded=\"full\"\n bg=\"border.emphasized\"\n borderWidth=\"1px\"\n borderColor=\"blackAlpha.200\"\n flexShrink={0}\n />\n )\n ) : null}\n <HStack justify=\"space-between\" flex=\"1\">\n {!hideSeriesLabel ? (\n <Text color=\"fg.muted\">{toRenderableValue(formattedName)}</Text>\n ) : null}\n {item.value != null ? (\n <Text fontFamily=\"mono\" fontWeight=\"medium\" fontVariantNumeric=\"tabular-nums\">\n {toRenderableValue(formattedValue)}\n </Text>\n ) : null}\n </HStack>\n </Flex>\n )\n })}\n </Box>\n {showTotal ? (\n <>\n <Separator mt=\"1\" />\n <HStack gap=\"1\" justify=\"space-between\" pb=\"1\">\n <Span color=\"fg.muted\">Total</Span>\n <Text fontFamily=\"mono\" fontWeight=\"medium\" fontVariantNumeric=\"tabular-nums\">\n {formatter\n ? (() => {\n const formatted = formatter(total, '')\n return Array.isArray(formatted) ? formatted[0] : formatted\n })()\n : total.toLocaleString()}\n </Text>\n </HStack>\n </>\n ) : null}\n </Stack>\n )\n}\n\nfunction ChartLegendContent({\n payload,\n verticalAlign = 'bottom',\n align = 'center',\n title,\n orientation,\n nameKey,\n spacing = '3',\n interaction = 'hover',\n rootProps,\n itemProps,\n labelProps,\n indicatorProps,\n}: ChartLegendContentProps) {\n const chart = useGovukChartContext()\n const filteredPayload = payload?.filter((item) => item.color !== 'none' || item.type !== 'none')\n\n if (!filteredPayload?.length) {\n return null\n }\n\n const spacingValue = typeof spacing === 'number' ? `${spacing}px` : chart.spacing(spacing)\n const alignMap = {\n left: 'flex-start',\n center: 'center',\n right: 'flex-end',\n } as const\n\n return (\n <Stack\n gap=\"1.5\"\n align={alignMap[align]}\n pt={verticalAlign === 'bottom' ? '3' : undefined}\n pb={verticalAlign === 'top' ? '3' : undefined}\n {...rootProps}\n >\n {title ? <Text fontWeight=\"medium\">{title}</Text> : null}\n <Flex\n data-orientation={orientation}\n gap={spacingValue}\n direction={{ _horizontal: 'row', _vertical: 'column' }}\n align={{ _horizontal: 'center', _vertical: 'flex-start' }}\n flexWrap=\"wrap\"\n >\n {filteredPayload.map((item, index) => {\n const config = chart.getSeries(item)\n const seriesName =\n config?.name == null\n ? undefined\n : typeof config.name === 'string'\n ? config.name\n : String(config.name)\n const name = getPayloadProp(item as TooltipPayloadEntry, nameKey)\n const label = capitalizeLabel(name ?? config?.label)\n\n return (\n <HStack\n key={index}\n gap=\"1.5\"\n style={{ opacity: chart.getSeriesOpacity(seriesName, 0.6) }}\n onClick={() => {\n if (interaction === 'click' && seriesName) {\n chart.setHighlightedSeries((prev) => (prev === seriesName ? null : seriesName))\n }\n }}\n onMouseEnter={() => {\n if (interaction === 'hover' && seriesName) {\n chart.setHighlightedSeries(seriesName)\n }\n }}\n onMouseLeave={() => {\n if (interaction === 'hover' && seriesName) {\n chart.setHighlightedSeries(null)\n }\n }}\n {...itemProps}\n >\n {config?.icon ? (\n config.icon\n ) : (\n <Box\n boxSize=\"2\"\n rounded=\"full\"\n bg={config?.color ? chart.color(config.color) : 'border.emphasized'}\n borderWidth=\"1px\"\n borderColor=\"blackAlpha.200\"\n flexShrink={0}\n {...indicatorProps}\n />\n )}\n <Span color=\"fg.muted\" {...labelProps}>\n {toRenderableValue(label)}\n </Span>\n </HStack>\n )\n })}\n </Flex>\n </Stack>\n )\n}\n\nfunction ChartLegend(props: ChartRechartsLegendProps) {\n const {\n rootProps,\n itemProps,\n labelProps,\n indicatorProps,\n title,\n nameKey,\n interaction,\n spacing,\n payload,\n align,\n verticalAlign,\n layout,\n ...legendProps\n } = props\n\n return (\n <RechartsLegend\n {...legendProps}\n align={align}\n verticalAlign={verticalAlign}\n layout={layout}\n content={\n <ChartLegendContent\n rootProps={rootProps}\n itemProps={itemProps}\n labelProps={labelProps}\n indicatorProps={indicatorProps}\n title={title}\n nameKey={nameKey}\n interaction={interaction}\n spacing={spacing}\n payload={payload}\n align={align}\n verticalAlign={verticalAlign}\n layout={layout}\n />\n }\n />\n )\n}\n\nfunction ChartRechartsTooltip(props: ChartRechartsTooltipProps) {\n return <RechartsTooltip {...props} content={<ChartTooltip {...props} />} />\n}\n\nfunction ChartRoot<T>({ fontFamily = 'body', fontSize = 16, ...props }: ChartRootProps<T>) {\n const scale = getGovukTypeScale(fontSize)\n if (!scale) {\n console.warn(\n `[GOV.UK Chart] fontSize={${fontSize}} is not a valid GOV.UK type scale point. Use one of: 16, 19, 24, 27, 36, 48, 80.`\n )\n } else {\n return (\n <ChartContext.Provider value={props.chart as UseChartReturn<unknown>}>\n <ChakraChart.Root\n fontFamily={fontFamily}\n css={{\n '& svg.recharts-surface tspan': {\n fontSize: { base: scale.small.fontSize, md: scale.large.fontSize },\n lineHeight: { base: scale.small.lineHeight, md: scale.large.lineHeight },\n color: 'fg',\n fontFamily: fonts.body.value,\n },\n '& .recharts-tooltip-wrapper': {\n background: 'var(--govuk-colors-bg)',\n borderRadius: 'var(--govuk-radii-l2)',\n },\n }}\n {...props}\n />\n </ChartContext.Provider>\n )\n }\n}\n\nexport { ChartRoot }\n\nexport const Chart = Object.assign(ChartRoot, {\n ...ChakraChart,\n Root: ChartRoot,\n Legend: ChartLegend,\n LegendContent: ChartLegendContent,\n Tooltip: ChartRechartsTooltip,\n TooltipContent: ChartTooltip,\n})\n","import type { UseChartReturn } from '@chakra-ui/charts'\nimport { PieChart as ChakraDonutChart } from 'recharts'\nimport type { ComponentPropsWithoutRef } from 'react'\n\nimport { Chart, type ChartRootProps } from '@/components/Chart'\n\nexport interface DonutChartProps<T> extends Omit<\n ComponentPropsWithoutRef<typeof ChakraDonutChart>,\n 'data'\n> {\n chart: UseChartReturn<T>\n chartRootProps?: Omit<ChartRootProps<T>, 'chart' | 'children'>\n}\n\nfunction DonutChartRoot<T>({ chart, chartRootProps, ...props }: DonutChartProps<T>) {\n return (\n <Chart.Root chart={chart} {...chartRootProps}>\n <ChakraDonutChart data={chart.data} {...props} />\n </Chart.Root>\n )\n}\n\nexport { DonutChartRoot }\n\nexport const DonutChart = Object.assign(DonutChartRoot, {\n Root: DonutChartRoot,\n})\n"],"mappings":"uPASA,IAAa,GAAA,EAAA,EAAA,YAAmD,SAC9D,CAAE,WAAU,aAAa,IAAK,GAAG,GACjC,EACA,CACI,OAAO,GAAa,UAAY,EAAE,KAAY,EAAA,IAChD,QAAQ,KACN,2BAA2B,EAAS,mFACrC,CAGH,IAAM,EAAQ,EAAA,EAAkB,EAAS,CAezC,OAbI,GAEA,EAAA,EAAA,KAAC,EAAA,KAAD,CACO,MACL,SAAU,CAAE,KAAM,EAAM,MAAM,SAAU,GAAI,EAAM,MAAM,SAAU,CAClE,WAAY,CAAE,KAAM,EAAM,MAAM,WAAY,GAAI,EAAM,MAAM,WAAY,CAC5D,aACZ,WAAW,OACX,GAAI,EACJ,CAAA,EAIC,EAAA,EAAA,KAAC,EAAA,KAAD,CAAiB,MAAe,WAAyC,GAAI,EAAS,CAAA,EAC7F,CCYI,GAAA,EAAA,EAAA,eAA6D,KAAK,CAExE,SAAS,GAAuB,CAC9B,IAAM,GAAA,EAAA,EAAA,YAAmB,EAAa,CAEtC,GAAI,CAAC,EACH,MAAU,MAAM,sDAAsD,CAGxE,OAA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AI,CAAA,CAG7E,SAAS,EAAa,CAAE,aAAa,OAAQ,WAAW,GAAI,GAAG,GAA4B,CACzF,IAAM,EAAQ,EAAA,EAAkB,EAAS,CACzC,GAAI,CAAC,EACH,QAAQ,KACN,4BAA4B,EAAS,mFACtC,MAED,OACE,EAAA,EAAA,KAAC,EAAa,SAAd,CAAuB,MAAO,EAAM,gBAClC,EAAA,EAAA,KAAC,EAAA,MAAY,KAAb,CACc,aACZ,IAAK,CACH,+BAAgC,CAC9B,SAAU,CAAE,KAAM,EAAM,MAAM,SAAU,GAAI,EAAM,MAAM,SAAU,CAClE,WAAY,CAAE,KAAM,EAAM,MAAM,WAAY,GAAI,EAAM,MAAM,WAAY,CACxE,MAAO,KACP,WAAY,EAAA,EAAM,KAAK,MACxB,CACD,8BAA+B,CAC7B,WAAY,yBACZ,aAAc,wBACf,CACF,CACD,GAAI,EACJ,CAAA,CACoB,CAAA,CAO9B,IAAa,EAAQ,OAAO,OAAO,EAAW,CAC5C,GAAG,EAAA,MACH,KAAM,EACN,OAAQ,EACR,cAAe,EACf,QAAS,EACT,eAAgB,EACjB,CAAC,CCnYF,SAAS,EAAkB,CAAE,QAAO,iBAAgB,GAAG,GAA6B,CAClF,OACE,EAAA,EAAA,KAAC,EAAM,KAAP,CAAmB,QAAO,GAAI,YAC5B,EAAA,EAAA,KAAC,EAAA,SAAD,CAAkB,KAAM,EAAM,KAAM,GAAI,EAAS,CAAA,CACtC,CAAA,CAMjB,IAAa,EAAa,OAAO,OAAO,EAAgB,CACtD,KAAM,EACP,CAAC"}
|
|
1
|
+
{"version":3,"file":"DonutChart-D3Sq34se.js","names":[],"sources":["../src/components/Text/Text.tsx","../src/components/Chart/Chart.tsx","../src/components/DonutChart/DonutChart.tsx"],"sourcesContent":["import { Text as ChakraText, type TextProps as ChakraTextProps } from '@chakra-ui/react'\nimport { forwardRef } from 'react'\nimport { getGovukTypeScale, govukTypeScale, type GovukTypeScalePoint } from '@/utils'\n\nexport interface TextProps extends Omit<ChakraTextProps, 'fontSize' | 'fontWeight'> {\n fontSize?: GovukTypeScalePoint | ChakraTextProps['fontSize']\n fontWeight?: ChakraTextProps['fontWeight']\n}\n\nexport const Text = forwardRef<HTMLParagraphElement, TextProps>(function Text(\n { fontSize, fontWeight = 400, ...props },\n ref\n) {\n if (typeof fontSize === 'number' && !(fontSize in govukTypeScale)) {\n console.warn(\n `[GOV.UK Text] fontSize={${fontSize}} is not a valid GOV.UK type scale point. Use one of: 16, 19, 24, 27, 36, 48, 80.`\n )\n }\n\n const scale = getGovukTypeScale(fontSize)\n\n if (scale) {\n return (\n <ChakraText\n ref={ref}\n fontSize={{ base: scale.small.fontSize, md: scale.large.fontSize }}\n lineHeight={{ base: scale.small.lineHeight, md: scale.large.lineHeight }}\n fontWeight={fontWeight}\n fontFamily=\"body\"\n {...props}\n />\n )\n }\n\n return <ChakraText ref={ref} fontSize={fontSize as ChakraTextProps['fontSize']} {...props} />\n})\n","import { Box, Flex, HStack, Separator, Span, Stack } from '@chakra-ui/react'\nimport { fonts } from '@/theme/fonts'\nimport {\n Chart as ChakraChart,\n type ChartLegendProps as ChakraChartLegendProps,\n type ChartTooltipProps as ChakraChartTooltipProps,\n type UseChartReturn,\n} from '@chakra-ui/charts'\nimport {\n createContext,\n isValidElement,\n useContext,\n type ComponentPropsWithoutRef,\n type ReactNode,\n} from 'react'\nimport { Legend as RechartsLegend, Tooltip as RechartsTooltip } from 'recharts'\nimport type { Payload } from 'recharts/types/component/DefaultTooltipContent'\nimport type { TooltipPayloadEntry } from 'recharts/types/state/tooltipSlice'\nimport { getGovukTypeScale } from '@/utils'\nimport { Text } from '../Text'\n\nexport interface ChartRootProps<T> extends Omit<\n ComponentPropsWithoutRef<typeof ChakraChart.Root>,\n 'chart'\n> {\n chart: UseChartReturn<T>\n}\n\nexport type ChartRechartsTooltipProps = Omit<\n ComponentPropsWithoutRef<typeof RechartsTooltip>,\n 'content'\n> &\n ChakraChartTooltipProps\n\nexport interface ChartLegendContentProps extends ChakraChartLegendProps {\n rootProps?: ComponentPropsWithoutRef<typeof Stack>\n itemProps?: ComponentPropsWithoutRef<typeof HStack>\n labelProps?: ComponentPropsWithoutRef<typeof Span>\n indicatorProps?: ComponentPropsWithoutRef<typeof Box>\n}\n\nexport type ChartRechartsLegendProps = Omit<\n ComponentPropsWithoutRef<typeof RechartsLegend>,\n 'content'\n> &\n ChartLegendContentProps\n\nconst ChartContext = createContext<UseChartReturn<unknown> | null>(null)\n\nfunction useGovukChartContext() {\n const chart = useContext(ChartContext)\n\n if (!chart) {\n throw new Error('Chart components must be rendered inside Chart.Root')\n }\n\n return chart\n}\n\nfunction getPayloadProp(item: TooltipPayloadEntry | undefined, key?: string) {\n if (!item || !key || typeof item.payload !== 'object' || item.payload === null) {\n return undefined\n }\n\n const payload = item.payload as Record<string, unknown>\n return payload[key]\n}\n\nfunction toRenderableValue(value: unknown): ReactNode {\n if (value == null) {\n return ''\n }\n\n if (isValidElement(value)) {\n return value\n }\n\n if (typeof value === 'string' || typeof value === 'number') {\n return value\n }\n\n if (typeof value === 'boolean' || typeof value === 'bigint') {\n return String(value)\n }\n\n if (Array.isArray(value)) {\n return value.join(', ')\n }\n\n return String(value)\n}\n\nfunction capitalizeLabel(value: unknown) {\n if (typeof value !== 'string' || value.length === 0) {\n return value\n }\n\n return value.charAt(0).toUpperCase() + value.slice(1)\n}\n\nfunction ChartTooltip({\n payload: payloadProp,\n label,\n labelFormatter,\n hideLabel,\n hideIndicator,\n hideSeriesLabel,\n showTotal,\n fitContent,\n nameKey,\n formatter,\n render,\n}: ChakraChartTooltipProps) {\n const chart = useGovukChartContext()\n const payload = payloadProp?.filter((item) => item.color !== 'none' || item.type !== 'none')\n\n if (!payload?.length) {\n return null\n }\n\n const callbackPayload = payload as Array<Payload<string | number, string>>\n const firstItem = payload[0]\n const rawLabel = getPayloadProp(firstItem, nameKey) ?? label ?? firstItem?.dataKey ?? 'value'\n const tooltipLabel = toRenderableValue(\n labelFormatter?.(String(rawLabel), callbackPayload) ?? rawLabel\n )\n const total = payload.reduce((sum, item) => {\n return typeof item.value === 'number' ? sum + item.value : sum\n }, 0)\n\n return (\n <Stack\n minW={fitContent ? undefined : '8rem'}\n gap=\"1\"\n rounded=\"l2\"\n bg=\"bg.panel\"\n px=\"2.5\"\n py=\"1\"\n textStyle=\"xs\"\n shadow=\"md\"\n >\n {!hideLabel ? <Text fontWeight=\"medium\">{tooltipLabel}</Text> : null}\n <Box>\n {payload.map((item, index) => {\n const config = chart.getSeries(item)\n\n if (render) {\n return <Box key={index}>{render(item as Payload<string, string>)}</Box>\n }\n\n const formatted = formatter\n ? formatter(item.value, item.name)\n : item.value?.toLocaleString()\n const [formattedValue, formattedName] = Array.isArray(formatted)\n ? formatted\n : [formatted, capitalizeLabel(item.name)]\n\n return (\n <Flex key={index} gap=\"1.5\" wrap=\"wrap\" align=\"center\">\n {!hideIndicator ? (\n config?.color ? (\n <Box\n boxSize=\"2\"\n rounded=\"full\"\n bg={chart.color(config.color)}\n borderWidth=\"1px\"\n borderColor=\"blackAlpha.200\"\n flexShrink={0}\n />\n ) : (\n <Box\n boxSize=\"2\"\n rounded=\"full\"\n bg=\"border.emphasized\"\n borderWidth=\"1px\"\n borderColor=\"blackAlpha.200\"\n flexShrink={0}\n />\n )\n ) : null}\n <HStack justify=\"space-between\" flex=\"1\">\n {!hideSeriesLabel ? (\n <Text color=\"fg.muted\">{toRenderableValue(formattedName)}</Text>\n ) : null}\n {item.value != null ? (\n <Text fontFamily=\"mono\" fontWeight=\"medium\" fontVariantNumeric=\"tabular-nums\">\n {toRenderableValue(formattedValue)}\n </Text>\n ) : null}\n </HStack>\n </Flex>\n )\n })}\n </Box>\n {showTotal ? (\n <>\n <Separator mt=\"1\" />\n <HStack gap=\"1\" justify=\"space-between\" pb=\"1\">\n <Span color=\"fg.muted\">Total</Span>\n <Text fontFamily=\"mono\" fontWeight=\"medium\" fontVariantNumeric=\"tabular-nums\">\n {formatter\n ? (() => {\n const formatted = formatter(total, '')\n return Array.isArray(formatted) ? formatted[0] : formatted\n })()\n : total.toLocaleString()}\n </Text>\n </HStack>\n </>\n ) : null}\n </Stack>\n )\n}\n\nfunction ChartLegendContent({\n payload,\n verticalAlign = 'bottom',\n align = 'center',\n title,\n orientation,\n nameKey,\n spacing = '3',\n interaction = 'hover',\n rootProps,\n itemProps,\n labelProps,\n indicatorProps,\n}: ChartLegendContentProps) {\n const chart = useGovukChartContext()\n const filteredPayload = payload?.filter((item) => item.color !== 'none' || item.type !== 'none')\n\n if (!filteredPayload?.length) {\n return null\n }\n\n const spacingValue = typeof spacing === 'number' ? `${spacing}px` : chart.spacing(spacing)\n const alignMap = {\n left: 'flex-start',\n center: 'center',\n right: 'flex-end',\n } as const\n\n return (\n <Stack\n gap=\"1.5\"\n align={alignMap[align]}\n pt={verticalAlign === 'bottom' ? '3' : undefined}\n pb={verticalAlign === 'top' ? '3' : undefined}\n {...rootProps}\n >\n {title ? <Text fontWeight=\"medium\">{title}</Text> : null}\n <Flex\n data-orientation={orientation}\n gap={spacingValue}\n direction={{ _horizontal: 'row', _vertical: 'column' }}\n align={{ _horizontal: 'center', _vertical: 'flex-start' }}\n flexWrap=\"wrap\"\n >\n {filteredPayload.map((item, index) => {\n const config = chart.getSeries(item)\n const seriesName =\n config?.name == null\n ? undefined\n : typeof config.name === 'string'\n ? config.name\n : String(config.name)\n const name = getPayloadProp(item as TooltipPayloadEntry, nameKey)\n const label = capitalizeLabel(name ?? config?.label)\n\n return (\n <HStack\n key={index}\n gap=\"1.5\"\n style={{ opacity: chart.getSeriesOpacity(seriesName, 0.6) }}\n onClick={() => {\n if (interaction === 'click' && seriesName) {\n chart.setHighlightedSeries((prev) => (prev === seriesName ? null : seriesName))\n }\n }}\n onMouseEnter={() => {\n if (interaction === 'hover' && seriesName) {\n chart.setHighlightedSeries(seriesName)\n }\n }}\n onMouseLeave={() => {\n if (interaction === 'hover' && seriesName) {\n chart.setHighlightedSeries(null)\n }\n }}\n {...itemProps}\n >\n {config?.icon ? (\n config.icon\n ) : (\n <Box\n boxSize=\"2\"\n rounded=\"full\"\n bg={config?.color ? chart.color(config.color) : 'border.emphasized'}\n borderWidth=\"1px\"\n borderColor=\"blackAlpha.200\"\n flexShrink={0}\n {...indicatorProps}\n />\n )}\n <Span color=\"fg.muted\" {...labelProps}>\n {toRenderableValue(label)}\n </Span>\n </HStack>\n )\n })}\n </Flex>\n </Stack>\n )\n}\n\nfunction ChartLegend(props: ChartRechartsLegendProps) {\n const {\n rootProps,\n itemProps,\n labelProps,\n indicatorProps,\n title,\n nameKey,\n interaction,\n spacing,\n payload,\n align,\n verticalAlign,\n layout,\n ...legendProps\n } = props\n\n return (\n <RechartsLegend\n {...legendProps}\n align={align}\n verticalAlign={verticalAlign}\n layout={layout}\n content={\n <ChartLegendContent\n rootProps={rootProps}\n itemProps={itemProps}\n labelProps={labelProps}\n indicatorProps={indicatorProps}\n title={title}\n nameKey={nameKey}\n interaction={interaction}\n spacing={spacing}\n payload={payload}\n align={align}\n verticalAlign={verticalAlign}\n layout={layout}\n />\n }\n />\n )\n}\n\nfunction ChartRechartsTooltip(props: ChartRechartsTooltipProps) {\n return <RechartsTooltip {...props} content={<ChartTooltip {...props} />} />\n}\n\nfunction ChartRoot<T>({ fontFamily = 'body', fontSize = 16, ...props }: ChartRootProps<T>) {\n const scale = getGovukTypeScale(fontSize)\n if (!scale) {\n console.warn(\n `[GOV.UK Chart] fontSize={${fontSize}} is not a valid GOV.UK type scale point. Use one of: 16, 19, 24, 27, 36, 48, 80.`\n )\n } else {\n return (\n <ChartContext.Provider value={props.chart as UseChartReturn<unknown>}>\n <ChakraChart.Root\n fontFamily={fontFamily}\n css={{\n '& svg.recharts-surface tspan': {\n fontSize: { base: scale.small.fontSize, md: scale.large.fontSize },\n lineHeight: { base: scale.small.lineHeight, md: scale.large.lineHeight },\n color: 'fg',\n fontFamily: fonts.body.value,\n },\n '& .recharts-tooltip-wrapper': {\n background: 'var(--govuk-colors-bg)',\n borderRadius: 'var(--govuk-radii-l2)',\n },\n }}\n {...props}\n />\n </ChartContext.Provider>\n )\n }\n}\n\nexport { ChartRoot }\n\nexport const Chart = Object.assign(ChartRoot, {\n ...ChakraChart,\n Root: ChartRoot,\n Legend: ChartLegend,\n LegendContent: ChartLegendContent,\n Tooltip: ChartRechartsTooltip,\n TooltipContent: ChartTooltip,\n})\n","import type { UseChartReturn } from '@chakra-ui/charts'\nimport { PieChart as ChakraDonutChart } from 'recharts'\nimport type { ComponentPropsWithoutRef } from 'react'\n\nimport { Chart, type ChartRootProps } from '@/components/Chart'\n\nexport interface DonutChartProps<T> extends Omit<\n ComponentPropsWithoutRef<typeof ChakraDonutChart>,\n 'data'\n> {\n chart: UseChartReturn<T>\n chartRootProps?: Omit<ChartRootProps<T>, 'chart' | 'children'>\n}\n\nfunction DonutChartRoot<T>({ chart, chartRootProps, ...props }: DonutChartProps<T>) {\n return (\n <Chart.Root chart={chart} {...chartRootProps}>\n <ChakraDonutChart data={chart.data} {...props} />\n </Chart.Root>\n )\n}\n\nexport { DonutChartRoot }\n\nexport const DonutChart = Object.assign(DonutChartRoot, {\n Root: DonutChartRoot,\n})\n"],"mappings":"uPASA,IAAa,GAAA,EAAA,EAAA,YAAmD,SAC9D,CAAE,WAAU,aAAa,IAAK,GAAG,GACjC,EACA,CACI,OAAO,GAAa,UAAY,EAAE,KAAY,EAAA,IAChD,QAAQ,KACN,2BAA2B,EAAS,mFACrC,CAGH,IAAM,EAAQ,EAAA,EAAkB,EAAS,CAezC,OAbI,GAEA,EAAA,EAAA,KAAC,EAAA,KAAD,CACO,MACL,SAAU,CAAE,KAAM,EAAM,MAAM,SAAU,GAAI,EAAM,MAAM,SAAU,CAClE,WAAY,CAAE,KAAM,EAAM,MAAM,WAAY,GAAI,EAAM,MAAM,WAAY,CAC5D,aACZ,WAAW,OACX,GAAI,EACJ,CAAA,EAIC,EAAA,EAAA,KAAC,EAAA,KAAD,CAAiB,MAAe,WAAyC,GAAI,EAAS,CAAA,EAC7F,CCYI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onts-CwkXY-dR.mjs";
|
|
2
|
+
import { a as t, t as n } from "./px-to-rem-Bun7yTT7.mjs";
|
|
3
3
|
import { Box as r, Flex as i, HStack as a, Separator as o, Span as s, Stack as c, Text as l } from "@chakra-ui/react";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
5
|
+
import { createContext as p, forwardRef as m, isValidElement as h, useContext as g } from "react";
|
|
6
6
|
import { Legend as _, PieChart as v, Tooltip as y } from "recharts";
|
|
7
7
|
import { Chart as b } from "@chakra-ui/charts";
|
|
8
8
|
//#region src/components/Text/Text.tsx
|
|
9
|
-
var x =
|
|
9
|
+
var x = m(function({ fontSize: e, fontWeight: r = 400, ...i }, a) {
|
|
10
10
|
typeof e == "number" && !(e in t) && console.warn(`[GOV.UK Text] fontSize={${e}} is not a valid GOV.UK type scale point. Use one of: 16, 19, 24, 27, 36, 48, 80.`);
|
|
11
11
|
let o = n(e);
|
|
12
|
-
return o ? /* @__PURE__ */
|
|
12
|
+
return o ? /* @__PURE__ */ d(l, {
|
|
13
13
|
ref: a,
|
|
14
14
|
fontSize: {
|
|
15
15
|
base: o.small.fontSize,
|
|
@@ -22,14 +22,14 @@ var x = d(function({ fontSize: e, fontWeight: r = 400, ...i }, a) {
|
|
|
22
22
|
fontWeight: r,
|
|
23
23
|
fontFamily: "body",
|
|
24
24
|
...i
|
|
25
|
-
}) : /* @__PURE__ */
|
|
25
|
+
}) : /* @__PURE__ */ d(l, {
|
|
26
26
|
ref: a,
|
|
27
27
|
fontSize: e,
|
|
28
28
|
...i
|
|
29
29
|
});
|
|
30
|
-
}), S =
|
|
30
|
+
}), S = p(null);
|
|
31
31
|
function C() {
|
|
32
|
-
let e =
|
|
32
|
+
let e = g(S);
|
|
33
33
|
if (!e) throw Error("Chart components must be rendered inside Chart.Root");
|
|
34
34
|
return e;
|
|
35
35
|
}
|
|
@@ -37,17 +37,17 @@ function w(e, t) {
|
|
|
37
37
|
if (!(!e || !t || typeof e.payload != "object" || e.payload === null)) return e.payload[t];
|
|
38
38
|
}
|
|
39
39
|
function T(e) {
|
|
40
|
-
return e == null ? "" :
|
|
40
|
+
return e == null ? "" : h(e) || typeof e == "string" || typeof e == "number" ? e : typeof e == "boolean" || typeof e == "bigint" ? String(e) : Array.isArray(e) ? e.join(", ") : String(e);
|
|
41
41
|
}
|
|
42
42
|
function E(e) {
|
|
43
43
|
return typeof e != "string" || e.length === 0 ? e : e.charAt(0).toUpperCase() + e.slice(1);
|
|
44
44
|
}
|
|
45
|
-
function D({ payload: e, label: t, labelFormatter: n, hideLabel: l, hideIndicator:
|
|
45
|
+
function D({ payload: e, label: t, labelFormatter: n, hideLabel: l, hideIndicator: p, hideSeriesLabel: m, showTotal: h, fitContent: g, nameKey: _, formatter: v, render: y }) {
|
|
46
46
|
let b = C(), S = e?.filter((e) => e.color !== "none" || e.type !== "none");
|
|
47
47
|
if (!S?.length) return null;
|
|
48
48
|
let D = S, O = S[0], k = w(O, _) ?? t ?? O?.dataKey ?? "value", A = T(n?.(String(k), D) ?? k), j = S.reduce((e, t) => typeof t.value == "number" ? e + t.value : e, 0);
|
|
49
|
-
return /* @__PURE__ */
|
|
50
|
-
minW:
|
|
49
|
+
return /* @__PURE__ */ f(c, {
|
|
50
|
+
minW: g ? void 0 : "8rem",
|
|
51
51
|
gap: "1",
|
|
52
52
|
rounded: "l2",
|
|
53
53
|
bg: "bg.panel",
|
|
@@ -56,39 +56,39 @@ function D({ payload: e, label: t, labelFormatter: n, hideLabel: l, hideIndicato
|
|
|
56
56
|
textStyle: "xs",
|
|
57
57
|
shadow: "md",
|
|
58
58
|
children: [
|
|
59
|
-
l ? null : /* @__PURE__ */
|
|
59
|
+
l ? null : /* @__PURE__ */ d(x, {
|
|
60
60
|
fontWeight: "medium",
|
|
61
61
|
children: A
|
|
62
62
|
}),
|
|
63
|
-
/* @__PURE__ */
|
|
63
|
+
/* @__PURE__ */ d(r, { children: S.map((e, t) => {
|
|
64
64
|
let n = b.getSeries(e);
|
|
65
|
-
if (y) return /* @__PURE__ */
|
|
65
|
+
if (y) return /* @__PURE__ */ d(r, { children: y(e) }, t);
|
|
66
66
|
let o = v ? v(e.value, e.name) : e.value?.toLocaleString(), [s, c] = Array.isArray(o) ? o : [o, E(e.name)];
|
|
67
|
-
return /* @__PURE__ */
|
|
67
|
+
return /* @__PURE__ */ f(i, {
|
|
68
68
|
gap: "1.5",
|
|
69
69
|
wrap: "wrap",
|
|
70
70
|
align: "center",
|
|
71
|
-
children: [
|
|
71
|
+
children: [p ? null : n?.color ? /* @__PURE__ */ d(r, {
|
|
72
72
|
boxSize: "2",
|
|
73
73
|
rounded: "full",
|
|
74
74
|
bg: b.color(n.color),
|
|
75
75
|
borderWidth: "1px",
|
|
76
76
|
borderColor: "blackAlpha.200",
|
|
77
77
|
flexShrink: 0
|
|
78
|
-
}) : /* @__PURE__ */
|
|
78
|
+
}) : /* @__PURE__ */ d(r, {
|
|
79
79
|
boxSize: "2",
|
|
80
80
|
rounded: "full",
|
|
81
81
|
bg: "border.emphasized",
|
|
82
82
|
borderWidth: "1px",
|
|
83
83
|
borderColor: "blackAlpha.200",
|
|
84
84
|
flexShrink: 0
|
|
85
|
-
}), /* @__PURE__ */
|
|
85
|
+
}), /* @__PURE__ */ f(a, {
|
|
86
86
|
justify: "space-between",
|
|
87
87
|
flex: "1",
|
|
88
|
-
children: [
|
|
88
|
+
children: [m ? null : /* @__PURE__ */ d(x, {
|
|
89
89
|
color: "fg.muted",
|
|
90
90
|
children: T(c)
|
|
91
|
-
}), e.value == null ? null : /* @__PURE__ */
|
|
91
|
+
}), e.value == null ? null : /* @__PURE__ */ d(x, {
|
|
92
92
|
fontFamily: "mono",
|
|
93
93
|
fontWeight: "medium",
|
|
94
94
|
fontVariantNumeric: "tabular-nums",
|
|
@@ -97,14 +97,14 @@ function D({ payload: e, label: t, labelFormatter: n, hideLabel: l, hideIndicato
|
|
|
97
97
|
})]
|
|
98
98
|
}, t);
|
|
99
99
|
}) }),
|
|
100
|
-
|
|
100
|
+
h ? /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(o, { mt: "1" }), /* @__PURE__ */ f(a, {
|
|
101
101
|
gap: "1",
|
|
102
102
|
justify: "space-between",
|
|
103
103
|
pb: "1",
|
|
104
|
-
children: [/* @__PURE__ */
|
|
104
|
+
children: [/* @__PURE__ */ d(s, {
|
|
105
105
|
color: "fg.muted",
|
|
106
106
|
children: "Total"
|
|
107
|
-
}), /* @__PURE__ */
|
|
107
|
+
}), /* @__PURE__ */ d(x, {
|
|
108
108
|
fontFamily: "mono",
|
|
109
109
|
fontWeight: "medium",
|
|
110
110
|
fontVariantNumeric: "tabular-nums",
|
|
@@ -117,11 +117,11 @@ function D({ payload: e, label: t, labelFormatter: n, hideLabel: l, hideIndicato
|
|
|
117
117
|
]
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
|
-
function O({ payload: e, verticalAlign: t = "bottom", align: n = "center", title: o, orientation: l, nameKey: u, spacing:
|
|
120
|
+
function O({ payload: e, verticalAlign: t = "bottom", align: n = "center", title: o, orientation: l, nameKey: u, spacing: p = "3", interaction: m = "hover", rootProps: h, itemProps: g, labelProps: _, indicatorProps: v }) {
|
|
121
121
|
let y = C(), b = e?.filter((e) => e.color !== "none" || e.type !== "none");
|
|
122
122
|
if (!b?.length) return null;
|
|
123
|
-
let S = typeof
|
|
124
|
-
return /* @__PURE__ */
|
|
123
|
+
let S = typeof p == "number" ? `${p}px` : y.spacing(p);
|
|
124
|
+
return /* @__PURE__ */ f(c, {
|
|
125
125
|
gap: "1.5",
|
|
126
126
|
align: {
|
|
127
127
|
left: "flex-start",
|
|
@@ -130,11 +130,11 @@ function O({ payload: e, verticalAlign: t = "bottom", align: n = "center", title
|
|
|
130
130
|
}[n],
|
|
131
131
|
pt: t === "bottom" ? "3" : void 0,
|
|
132
132
|
pb: t === "top" ? "3" : void 0,
|
|
133
|
-
...
|
|
134
|
-
children: [o ? /* @__PURE__ */
|
|
133
|
+
...h,
|
|
134
|
+
children: [o ? /* @__PURE__ */ d(x, {
|
|
135
135
|
fontWeight: "medium",
|
|
136
136
|
children: o
|
|
137
|
-
}) : null, /* @__PURE__ */
|
|
137
|
+
}) : null, /* @__PURE__ */ d(i, {
|
|
138
138
|
"data-orientation": l,
|
|
139
139
|
gap: S,
|
|
140
140
|
direction: {
|
|
@@ -148,20 +148,20 @@ function O({ payload: e, verticalAlign: t = "bottom", align: n = "center", title
|
|
|
148
148
|
flexWrap: "wrap",
|
|
149
149
|
children: b.map((e, t) => {
|
|
150
150
|
let n = y.getSeries(e), i = n?.name == null ? void 0 : typeof n.name == "string" ? n.name : String(n.name), o = E(w(e, u) ?? n?.label);
|
|
151
|
-
return /* @__PURE__ */
|
|
151
|
+
return /* @__PURE__ */ f(a, {
|
|
152
152
|
gap: "1.5",
|
|
153
153
|
style: { opacity: y.getSeriesOpacity(i, .6) },
|
|
154
154
|
onClick: () => {
|
|
155
|
-
|
|
155
|
+
m === "click" && i && y.setHighlightedSeries((e) => e === i ? null : i);
|
|
156
156
|
},
|
|
157
157
|
onMouseEnter: () => {
|
|
158
|
-
|
|
158
|
+
m === "hover" && i && y.setHighlightedSeries(i);
|
|
159
159
|
},
|
|
160
160
|
onMouseLeave: () => {
|
|
161
|
-
|
|
161
|
+
m === "hover" && i && y.setHighlightedSeries(null);
|
|
162
162
|
},
|
|
163
|
-
...
|
|
164
|
-
children: [n?.icon ? n.icon : /* @__PURE__ */
|
|
163
|
+
...g,
|
|
164
|
+
children: [n?.icon ? n.icon : /* @__PURE__ */ d(r, {
|
|
165
165
|
boxSize: "2",
|
|
166
166
|
rounded: "full",
|
|
167
167
|
bg: n?.color ? y.color(n.color) : "border.emphasized",
|
|
@@ -169,7 +169,7 @@ function O({ payload: e, verticalAlign: t = "bottom", align: n = "center", title
|
|
|
169
169
|
borderColor: "blackAlpha.200",
|
|
170
170
|
flexShrink: 0,
|
|
171
171
|
...v
|
|
172
|
-
}), /* @__PURE__ */
|
|
172
|
+
}), /* @__PURE__ */ d(s, {
|
|
173
173
|
color: "fg.muted",
|
|
174
174
|
..._,
|
|
175
175
|
children: T(o)
|
|
@@ -180,13 +180,13 @@ function O({ payload: e, verticalAlign: t = "bottom", align: n = "center", title
|
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
182
|
function k(e) {
|
|
183
|
-
let { rootProps: t, itemProps: n, labelProps: r, indicatorProps: i, title: a, nameKey: o, interaction: s, spacing: c, payload: l, align: u, verticalAlign:
|
|
184
|
-
return /* @__PURE__ */
|
|
185
|
-
...
|
|
183
|
+
let { rootProps: t, itemProps: n, labelProps: r, indicatorProps: i, title: a, nameKey: o, interaction: s, spacing: c, payload: l, align: u, verticalAlign: f, layout: p, ...m } = e;
|
|
184
|
+
return /* @__PURE__ */ d(_, {
|
|
185
|
+
...m,
|
|
186
186
|
align: u,
|
|
187
|
-
verticalAlign:
|
|
188
|
-
layout:
|
|
189
|
-
content: /* @__PURE__ */
|
|
187
|
+
verticalAlign: f,
|
|
188
|
+
layout: p,
|
|
189
|
+
content: /* @__PURE__ */ d(O, {
|
|
190
190
|
rootProps: t,
|
|
191
191
|
itemProps: n,
|
|
192
192
|
labelProps: r,
|
|
@@ -197,23 +197,23 @@ function k(e) {
|
|
|
197
197
|
spacing: c,
|
|
198
198
|
payload: l,
|
|
199
199
|
align: u,
|
|
200
|
-
verticalAlign:
|
|
201
|
-
layout:
|
|
200
|
+
verticalAlign: f,
|
|
201
|
+
layout: p
|
|
202
202
|
})
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
205
|
function A(e) {
|
|
206
|
-
return /* @__PURE__ */
|
|
206
|
+
return /* @__PURE__ */ d(y, {
|
|
207
207
|
...e,
|
|
208
|
-
content: /* @__PURE__ */
|
|
208
|
+
content: /* @__PURE__ */ d(D, { ...e })
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
211
|
function j({ fontFamily: t = "body", fontSize: r = 16, ...i }) {
|
|
212
212
|
let a = n(r);
|
|
213
213
|
if (!a) console.warn(`[GOV.UK Chart] fontSize={${r}} is not a valid GOV.UK type scale point. Use one of: 16, 19, 24, 27, 36, 48, 80.`);
|
|
214
|
-
else return /* @__PURE__ */
|
|
214
|
+
else return /* @__PURE__ */ d(S.Provider, {
|
|
215
215
|
value: i.chart,
|
|
216
|
-
children: /* @__PURE__ */
|
|
216
|
+
children: /* @__PURE__ */ d(b.Root, {
|
|
217
217
|
fontFamily: t,
|
|
218
218
|
css: {
|
|
219
219
|
"& svg.recharts-surface tspan": {
|
|
@@ -248,10 +248,10 @@ var M = Object.assign(j, {
|
|
|
248
248
|
//#endregion
|
|
249
249
|
//#region src/components/DonutChart/DonutChart.tsx
|
|
250
250
|
function N({ chart: e, chartRootProps: t, ...n }) {
|
|
251
|
-
return /* @__PURE__ */
|
|
251
|
+
return /* @__PURE__ */ d(M.Root, {
|
|
252
252
|
chart: e,
|
|
253
253
|
...t,
|
|
254
|
-
children: /* @__PURE__ */
|
|
254
|
+
children: /* @__PURE__ */ d(v, {
|
|
255
255
|
data: e.data,
|
|
256
256
|
...n
|
|
257
257
|
})
|
|
@@ -261,4 +261,4 @@ var P = Object.assign(N, { Root: N });
|
|
|
261
261
|
//#endregion
|
|
262
262
|
export { M as n, x as r, P as t };
|
|
263
263
|
|
|
264
|
-
//# sourceMappingURL=DonutChart-
|
|
264
|
+
//# sourceMappingURL=DonutChart-XZvUd_OH.mjs.map
|