@cruk/cruk-react-components 6.2.3 → 7.1.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.
Files changed (240) hide show
  1. package/README.md +185 -7
  2. package/lib/index.css +4248 -0
  3. package/lib/index.css.map +1 -0
  4. package/lib/node_modules/tslib/tslib.es6.js +1 -1
  5. package/lib/node_modules/tslib/tslib.es6.js.map +1 -1
  6. package/lib/src/components/AddressLookup/index.d.ts +8 -9
  7. package/lib/src/components/AddressLookup/index.js +1 -1
  8. package/lib/src/components/AddressLookup/index.js.map +1 -1
  9. package/lib/src/components/AllThemesWrapper.d.ts +3 -3
  10. package/lib/src/components/Avatar/index.d.ts +10 -8
  11. package/lib/src/components/Avatar/index.js +1 -1
  12. package/lib/src/components/Avatar/index.js.map +1 -1
  13. package/lib/src/components/Badge/index.d.ts +12 -16
  14. package/lib/src/components/Badge/index.js +1 -1
  15. package/lib/src/components/Badge/index.js.map +1 -1
  16. package/lib/src/components/Box/index.d.ts +7 -7
  17. package/lib/src/components/Box/index.js +1 -1
  18. package/lib/src/components/Box/index.js.map +1 -1
  19. package/lib/src/components/Button/index.d.ts +7 -16
  20. package/lib/src/components/Button/index.js +1 -1
  21. package/lib/src/components/Button/index.js.map +1 -1
  22. package/lib/src/components/Carousel/Dots.js +1 -1
  23. package/lib/src/components/Carousel/Dots.js.map +1 -1
  24. package/lib/src/components/Carousel/index.d.ts +23 -13
  25. package/lib/src/components/Carousel/index.js +1 -1
  26. package/lib/src/components/Carousel/index.js.map +1 -1
  27. package/lib/src/components/Checkbox/index.d.ts +7 -8
  28. package/lib/src/components/Checkbox/index.js +1 -1
  29. package/lib/src/components/Checkbox/index.js.map +1 -1
  30. package/lib/src/components/Collapse/index.d.ts +2 -2
  31. package/lib/src/components/Collapse/index.js +1 -1
  32. package/lib/src/components/Collapse/index.js.map +1 -1
  33. package/lib/src/components/DateField/index.d.ts +5 -6
  34. package/lib/src/components/DateField/index.js +1 -1
  35. package/lib/src/components/DateField/index.js.map +1 -1
  36. package/lib/src/components/ErrorText/index.d.ts +7 -6
  37. package/lib/src/components/ErrorText/index.js +1 -1
  38. package/lib/src/components/ErrorText/index.js.map +1 -1
  39. package/lib/src/components/Footer/index.d.ts +8 -6
  40. package/lib/src/components/Footer/index.js +1 -1
  41. package/lib/src/components/Footer/index.js.map +1 -1
  42. package/lib/src/components/Header/index.d.ts +19 -18
  43. package/lib/src/components/Header/index.js +1 -1
  44. package/lib/src/components/Header/index.js.map +1 -1
  45. package/lib/src/components/Heading/index.d.ts +5 -17
  46. package/lib/src/components/Heading/index.js +1 -1
  47. package/lib/src/components/Heading/index.js.map +1 -1
  48. package/lib/src/components/IconFa/index.d.ts +9 -9
  49. package/lib/src/components/IconFa/index.js +1 -1
  50. package/lib/src/components/IconFa/index.js.map +1 -1
  51. package/lib/src/components/InfoBox/index.d.ts +13 -16
  52. package/lib/src/components/InfoBox/index.js +1 -1
  53. package/lib/src/components/InfoBox/index.js.map +1 -1
  54. package/lib/src/components/LabelWrapper/index.js +1 -1
  55. package/lib/src/components/LabelWrapper/index.js.map +1 -1
  56. package/lib/src/components/LegendWrapper/index.js +1 -1
  57. package/lib/src/components/LegendWrapper/index.js.map +1 -1
  58. package/lib/src/components/Link/index.d.ts +6 -10
  59. package/lib/src/components/Link/index.js +1 -1
  60. package/lib/src/components/Link/index.js.map +1 -1
  61. package/lib/src/components/Loader/index.js +1 -1
  62. package/lib/src/components/Loader/index.js.map +1 -1
  63. package/lib/src/components/Modal/TestModalWithContent.d.ts +3 -1
  64. package/lib/src/components/Modal/TestModalWithState.d.ts +3 -1
  65. package/lib/src/components/Modal/index.d.ts +14 -17
  66. package/lib/src/components/Modal/index.js +1 -1
  67. package/lib/src/components/Modal/index.js.map +1 -1
  68. package/lib/src/components/Pagination/index.js +1 -1
  69. package/lib/src/components/Pagination/index.js.map +1 -1
  70. package/lib/src/components/PopOver/index.d.ts +1 -1
  71. package/lib/src/components/PopOver/index.js +1 -1
  72. package/lib/src/components/PopOver/index.js.map +1 -1
  73. package/lib/src/components/ProgressBar/index.d.ts +1 -1
  74. package/lib/src/components/ProgressBar/index.js +1 -1
  75. package/lib/src/components/ProgressBar/index.js.map +1 -1
  76. package/lib/src/components/Radio/index.js +1 -1
  77. package/lib/src/components/Radio/index.js.map +1 -1
  78. package/lib/src/components/RadioConsent/index.d.ts +8 -9
  79. package/lib/src/components/RadioConsent/index.js +1 -1
  80. package/lib/src/components/RadioConsent/index.js.map +1 -1
  81. package/lib/src/components/Select/index.js +1 -1
  82. package/lib/src/components/Select/index.js.map +1 -1
  83. package/lib/src/components/Step/index.d.ts +7 -8
  84. package/lib/src/components/Step/index.js +1 -1
  85. package/lib/src/components/Step/index.js.map +1 -1
  86. package/lib/src/components/Text/index.d.ts +7 -27
  87. package/lib/src/components/Text/index.js +1 -1
  88. package/lib/src/components/Text/index.js.map +1 -1
  89. package/lib/src/components/TextAreaField/index.d.ts +5 -6
  90. package/lib/src/components/TextAreaField/index.js +1 -1
  91. package/lib/src/components/TextAreaField/index.js.map +1 -1
  92. package/lib/src/components/TextField/index.d.ts +3 -1
  93. package/lib/src/components/TextField/index.js +1 -1
  94. package/lib/src/components/TextField/index.js.map +1 -1
  95. package/lib/src/components/Totaliser/index.d.ts +5 -6
  96. package/lib/src/components/Totaliser/index.js +1 -1
  97. package/lib/src/components/Totaliser/index.js.map +1 -1
  98. package/lib/src/components/UserBlock/index.d.ts +3 -1
  99. package/lib/src/components/UserBlock/index.js +1 -1
  100. package/lib/src/components/UserBlock/index.js.map +1 -1
  101. package/lib/src/components/index.d.ts +34 -10
  102. package/lib/src/components/index.js +1 -1
  103. package/lib/src/types.d.ts +45 -172
  104. package/lib/src/types.js +2 -0
  105. package/lib/src/types.js.map +1 -0
  106. package/lib/src/utils/Helper.d.ts +3 -0
  107. package/lib/src/utils/Helper.js +1 -1
  108. package/lib/src/utils/Helper.js.map +1 -1
  109. package/lib/src/utils/themeUtils.d.ts +4 -3
  110. package/lib/src/utils/themeUtils.js +1 -1
  111. package/lib/src/utils/themeUtils.js.map +1 -1
  112. package/package.json +11 -9
  113. package/lib/src/components/AddressLookup/styles.d.ts +0 -17
  114. package/lib/src/components/AddressLookup/styles.js +0 -2
  115. package/lib/src/components/AddressLookup/styles.js.map +0 -1
  116. package/lib/src/components/Avatar/styles.d.ts +0 -6
  117. package/lib/src/components/Avatar/styles.js +0 -2
  118. package/lib/src/components/Avatar/styles.js.map +0 -1
  119. package/lib/src/components/Badge/styles.d.ts +0 -10
  120. package/lib/src/components/Badge/styles.js +0 -2
  121. package/lib/src/components/Badge/styles.js.map +0 -1
  122. package/lib/src/components/Box/styles.d.ts +0 -9
  123. package/lib/src/components/Box/styles.js +0 -2
  124. package/lib/src/components/Box/styles.js.map +0 -1
  125. package/lib/src/components/Button/styles.d.ts +0 -13
  126. package/lib/src/components/Button/styles.js +0 -2
  127. package/lib/src/components/Button/styles.js.map +0 -1
  128. package/lib/src/components/Carousel/styles.d.ts +0 -30
  129. package/lib/src/components/Carousel/styles.js +0 -2
  130. package/lib/src/components/Carousel/styles.js.map +0 -1
  131. package/lib/src/components/Checkbox/styles.d.ts +0 -17
  132. package/lib/src/components/Checkbox/styles.js +0 -2
  133. package/lib/src/components/Checkbox/styles.js.map +0 -1
  134. package/lib/src/components/Collapse/styles.d.ts +0 -26
  135. package/lib/src/components/Collapse/styles.js +0 -2
  136. package/lib/src/components/Collapse/styles.js.map +0 -1
  137. package/lib/src/components/DateField/styles.d.ts +0 -25
  138. package/lib/src/components/DateField/styles.js +0 -2
  139. package/lib/src/components/DateField/styles.js.map +0 -1
  140. package/lib/src/components/Divider.d.ts +0 -5
  141. package/lib/src/components/Divider.js +0 -2
  142. package/lib/src/components/Divider.js.map +0 -1
  143. package/lib/src/components/ErrorText/styles.d.ts +0 -16
  144. package/lib/src/components/ErrorText/styles.js +0 -2
  145. package/lib/src/components/ErrorText/styles.js.map +0 -1
  146. package/lib/src/components/Flex.d.ts +0 -8
  147. package/lib/src/components/Flex.js +0 -2
  148. package/lib/src/components/Flex.js.map +0 -1
  149. package/lib/src/components/Fontface.d.ts +0 -4
  150. package/lib/src/components/Fontface.js +0 -2
  151. package/lib/src/components/Fontface.js.map +0 -1
  152. package/lib/src/components/Footer/styles.d.ts +0 -16
  153. package/lib/src/components/Footer/styles.js +0 -2
  154. package/lib/src/components/Footer/styles.js.map +0 -1
  155. package/lib/src/components/GlobalStyle.d.ts +0 -2
  156. package/lib/src/components/GlobalStyle.js +0 -2
  157. package/lib/src/components/GlobalStyle.js.map +0 -1
  158. package/lib/src/components/GlobalStyleNoFontFace.d.ts +0 -2
  159. package/lib/src/components/GlobalStyleNoFontFace.js +0 -2
  160. package/lib/src/components/GlobalStyleNoFontFace.js.map +0 -1
  161. package/lib/src/components/Header/styles.d.ts +0 -33
  162. package/lib/src/components/Header/styles.js +0 -2
  163. package/lib/src/components/Header/styles.js.map +0 -1
  164. package/lib/src/components/Heading/styles.d.ts +0 -17
  165. package/lib/src/components/Heading/styles.js +0 -2
  166. package/lib/src/components/Heading/styles.js.map +0 -1
  167. package/lib/src/components/IconFa/styles.d.ts +0 -7
  168. package/lib/src/components/IconFa/styles.js +0 -2
  169. package/lib/src/components/IconFa/styles.js.map +0 -1
  170. package/lib/src/components/InfoBox/styles.d.ts +0 -13
  171. package/lib/src/components/InfoBox/styles.js +0 -2
  172. package/lib/src/components/InfoBox/styles.js.map +0 -1
  173. package/lib/src/components/LabelWrapper/styles.d.ts +0 -16
  174. package/lib/src/components/LabelWrapper/styles.js +0 -2
  175. package/lib/src/components/LabelWrapper/styles.js.map +0 -1
  176. package/lib/src/components/LegendWrapper/styles.d.ts +0 -15
  177. package/lib/src/components/LegendWrapper/styles.js +0 -2
  178. package/lib/src/components/LegendWrapper/styles.js.map +0 -1
  179. package/lib/src/components/Link/styles.d.ts +0 -20
  180. package/lib/src/components/Link/styles.js +0 -2
  181. package/lib/src/components/Link/styles.js.map +0 -1
  182. package/lib/src/components/Loader/styles.d.ts +0 -7
  183. package/lib/src/components/Loader/styles.js +0 -2
  184. package/lib/src/components/Loader/styles.js.map +0 -1
  185. package/lib/src/components/Modal/styles.d.ts +0 -32
  186. package/lib/src/components/Modal/styles.js +0 -2
  187. package/lib/src/components/Modal/styles.js.map +0 -1
  188. package/lib/src/components/Pagination/styles.d.ts +0 -12
  189. package/lib/src/components/Pagination/styles.js +0 -2
  190. package/lib/src/components/Pagination/styles.js.map +0 -1
  191. package/lib/src/components/PopOver/styles.d.ts +0 -11
  192. package/lib/src/components/PopOver/styles.js +0 -2
  193. package/lib/src/components/PopOver/styles.js.map +0 -1
  194. package/lib/src/components/ProgressBar/styles.d.ts +0 -32
  195. package/lib/src/components/ProgressBar/styles.js +0 -2
  196. package/lib/src/components/ProgressBar/styles.js.map +0 -1
  197. package/lib/src/components/Radio/styles.d.ts +0 -21
  198. package/lib/src/components/Radio/styles.js +0 -2
  199. package/lib/src/components/Radio/styles.js.map +0 -1
  200. package/lib/src/components/RadioConsent/styles.d.ts +0 -10
  201. package/lib/src/components/RadioConsent/styles.js +0 -2
  202. package/lib/src/components/RadioConsent/styles.js.map +0 -1
  203. package/lib/src/components/Select/styles.d.ts +0 -9
  204. package/lib/src/components/Select/styles.js +0 -2
  205. package/lib/src/components/Select/styles.js.map +0 -1
  206. package/lib/src/components/Spacing/index.d.ts +0 -68
  207. package/lib/src/components/Spacing/index.js +0 -2
  208. package/lib/src/components/Spacing/index.js.map +0 -1
  209. package/lib/src/components/Step/styles.d.ts +0 -16
  210. package/lib/src/components/Step/styles.js +0 -2
  211. package/lib/src/components/Step/styles.js.map +0 -1
  212. package/lib/src/components/Text/styles.d.ts +0 -15
  213. package/lib/src/components/Text/styles.js +0 -2
  214. package/lib/src/components/Text/styles.js.map +0 -1
  215. package/lib/src/components/TextAreaField/styles.d.ts +0 -10
  216. package/lib/src/components/TextAreaField/styles.js +0 -2
  217. package/lib/src/components/TextAreaField/styles.js.map +0 -1
  218. package/lib/src/components/TextField/styles.d.ts +0 -18
  219. package/lib/src/components/TextField/styles.js +0 -2
  220. package/lib/src/components/TextField/styles.js.map +0 -1
  221. package/lib/src/components/ThemeCheatSheet.d.ts +0 -7
  222. package/lib/src/components/Totaliser/styles.d.ts +0 -27
  223. package/lib/src/components/Totaliser/styles.js +0 -2
  224. package/lib/src/components/Totaliser/styles.js.map +0 -1
  225. package/lib/src/components/UserBlock/styles.d.ts +0 -9
  226. package/lib/src/components/UserBlock/styles.js +0 -2
  227. package/lib/src/components/UserBlock/styles.js.map +0 -1
  228. package/lib/src/themes/bowelbabe.d.ts +0 -14
  229. package/lib/src/themes/bowelbabe.js +0 -2
  230. package/lib/src/themes/bowelbabe.js.map +0 -1
  231. package/lib/src/themes/cruk.d.ts +0 -14
  232. package/lib/src/themes/cruk.js +0 -2
  233. package/lib/src/themes/cruk.js.map +0 -1
  234. package/lib/src/themes/rfl.d.ts +0 -14
  235. package/lib/src/themes/rfl.js +0 -2
  236. package/lib/src/themes/rfl.js.map +0 -1
  237. package/lib/src/themes/su2c.d.ts +0 -14
  238. package/lib/src/themes/su2c.js +0 -2
  239. package/lib/src/themes/su2c.js.map +0 -1
  240. package/lib/vite.config.d.ts +0 -2
@@ -1,13 +1,14 @@
1
- import React, { type HTMLAttributes } from "react";
2
- import { type SpacingProps } from "../Spacing";
3
- export type ErrorTextProps = SpacingProps & HTMLAttributes<HTMLElement> & {
4
- as?: React.ElementType;
5
- };
1
+ import React, { type Ref, type HTMLAttributes } from "react";
2
+ import { type SpacingProps, type TextProps, type ColourProps } from "../../types";
6
3
  /**
7
4
  *
8
5
  * To be used in forms for inline validation. Applies styling and accessibility attribute so that it will be read by screen readers.
9
6
  *
10
7
  * Please be aware that some input components already have this component built in and can be passed an "errorMessage" prop
11
8
  */
12
- export declare function ErrorText({ children, as, ...props }: ErrorTextProps): React.JSX.Element;
9
+ export declare function ErrorText({ textColor, backgroundColor, margin, marginTop, marginRight, marginBottom, marginLeft, marginVertical, marginHorizontal, padding, paddingTop, paddingRight, paddingBottom, paddingLeft, paddingVertical, paddingHorizontal, textSize, textAlign, textWeight, textFontFamily, wordBreak, overflowWrap, as, children, ref, ...htmlAttributes }: SpacingProps & TextProps & ColourProps & HTMLAttributes<HTMLElement> & {
10
+ children?: React.ReactNode;
11
+ as?: "span" | "div" | "p";
12
+ ref?: Ref<HTMLSpanElement | HTMLDivElement | HTMLParagraphElement>;
13
+ }): React.JSX.Element;
13
14
  export default ErrorText;
@@ -1,2 +1,2 @@
1
- import{__rest as e,__assign as o}from"../../../node_modules/tslib/tslib.es6.js";import r from"react";import{useTheme as t}from"styled-components";import{faTriangleExclamation as s}from"../../../node_modules/@fortawesome/free-solid-svg-icons/index.js";import{crukTheme as m}from"../../themes/cruk.js";import{StyledErrorText as n}from"./styles.js";import{IconFa as i}from"../IconFa/index.js";import{Box as a}from"../Box/index.js";function l(l){var d=l.children,f=l.as,p=void 0===f?"span":f,c=e(l,["children","as"]),u=t(),x=o(o({},m),u),h="string"==typeof d&&d.length;return r.createElement(n,o({forwardedAs:p},c,{theme:x,role:"alert"}),h?r.createElement(a,{as:"span",marginRight:"xxs"},r.createElement(i,{faIcon:s,size:"1em"})):null,d)}export{l as ErrorText,l as default};
1
+ import{__rest as t,__assign as a}from"../../../node_modules/tslib/tslib.es6.js";import r from"react";import{faTriangleExclamation as e}from"../../../node_modules/@fortawesome/free-solid-svg-icons/index.js";import{IconFa as o}from"../IconFa/index.js";import{Box as n}from"../Box/index.js";import{removeEmpty as i}from"../../utils/Helper.js";function d(d){var l=d.textColor,p=d.backgroundColor,g=d.margin,m=d.marginTop,s=d.marginRight,c=d.marginBottom,f=d.marginLeft,x=d.marginVertical,h=d.marginHorizontal,u=d.padding,z=d.paddingTop,v=d.paddingRight,w=d.paddingBottom,b=d.paddingLeft,j=d.paddingVertical,B=d.paddingHorizontal,E=d.textSize,F=d.textAlign,k=d.textWeight,H=d.textFontFamily,R=d.wordBreak,y=d.overflowWrap,C=d.as,L=d.children,T=d.ref,V=t(d,["textColor","backgroundColor","margin","marginTop","marginRight","marginBottom","marginLeft","marginVertical","marginHorizontal","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingVertical","paddingHorizontal","textSize","textAlign","textWeight","textFontFamily","wordBreak","overflowWrap","as","children","ref"]),W=i({"data-color":l,"data-bg-color":p,"data-text-size":E,"data-text-align":F,"data-text-weight":k,"data-text-font-family":H,"data-word-break":R,"data-overflow-wrap":y,"data-margin":g,"data-margin-top":m,"data-margin-right":s,"data-margin-bottom":c,"data-margin-left":f,"data-margin-vertical":x,"data-margin-horizontal":h,"data-padding":u,"data-padding-top":z,"data-padding-right":v,"data-padding-bottom":w,"data-padding-left":b,"data-padding-vertical":j,"data-padding-horizontal":B}),N="string"==typeof L&&L.length,A=r.createElement(r.Fragment,null,N?r.createElement(n,{as:"span",marginRight:"xxs"},r.createElement(o,{faIcon:e,size:"1em"})):null,L);return r.createElement(r.Fragment,null,C&&"span"!==C?null:r.createElement("span",a({className:["component-error-text","text-props","spacing-props","color-props"].join(" "),ref:T},V,W,{role:"alert"}),A),"div"===C?r.createElement("div",a({className:["component-error-text","text-props","spacing-props","color-props"].join(" "),ref:T},V,W,{role:"alert"}),A):null,"p"===C?r.createElement("p",a({className:["component-error-text","text-props","spacing-props","color-props"].join(" "),ref:T},V,W,{role:"alert"}),A):null)}export{d as ErrorText,d as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/ErrorText/index.tsx"],"sourcesContent":["import React, { type HTMLAttributes } from \"react\";\nimport { useTheme } from \"styled-components\";\n\nimport { faTriangleExclamation } from \"@fortawesome/free-solid-svg-icons\";\nimport { crukTheme as defaultTheme } from \"../../themes/cruk\";\nimport { type SpacingProps } from \"../Spacing\";\nimport { StyledErrorText } from \"./styles\";\nimport { IconFa } from \"../IconFa\";\nimport { Box } from \"../Box\";\n\nexport type ErrorTextProps = SpacingProps &\n HTMLAttributes<HTMLElement> & {\n as?: React.ElementType;\n };\n\n/**\n *\n * To be used in forms for inline validation. Applies styling and accessibility attribute so that it will be read by screen readers.\n *\n * Please be aware that some input components already have this component built in and can be passed an \"errorMessage\" prop\n */\nexport function ErrorText({ children, as = \"span\", ...props }: ErrorTextProps) {\n const foundTheme = useTheme();\n const theme = {\n ...defaultTheme,\n ...foundTheme,\n };\n\n const shouldShowIcon = typeof children === \"string\" && children.length;\n return (\n <StyledErrorText forwardedAs={as} {...props} theme={theme} role=\"alert\">\n {shouldShowIcon ? (\n <Box as=\"span\" marginRight=\"xxs\">\n <IconFa faIcon={faTriangleExclamation} size=\"1em\" />\n </Box>\n ) : null}\n {children}\n </StyledErrorText>\n );\n}\n\nexport default ErrorText;\n"],"names":["ErrorText","_a","children","_b","as","props","__rest","foundTheme","useTheme","theme","__assign","defaultTheme","shouldShowIcon","length","React","createElement","StyledErrorText","forwardedAs","role","Box","marginRight","IconFa","faIcon","faTriangleExclamation","size"],"mappings":"4aAqBM,SAAUA,EAAUC,GAAE,IAAAC,EAAQD,EAAAC,SAAEC,EAAAF,EAAAG,GAAAA,OAAE,IAAAD,EAAG,OAAMA,EAAKE,EAAKC,EAAAL,EAAjC,mBAClBM,EAAaC,IACbC,EAAKC,EAAAA,EAAA,CAAA,EACNC,GACAJ,GAGCK,EAAqC,iBAAbV,GAAyBA,EAASW,OAChE,OACEC,EAAAC,cAACC,EAAeN,EAAA,CAACO,YAAab,GAAQC,EAAK,CAAEI,MAAOA,EAAOS,KAAK,UAC7DN,EACCE,EAAAC,cAACI,EAAG,CAACf,GAAG,OAAOgB,YAAY,OACzBN,EAAAC,cAACM,EAAM,CAACC,OAAQC,EAAuBC,KAAK,SAE5C,KACHtB,EAGP"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/ErrorText/index.tsx"],"sourcesContent":["import React, { type Ref, type HTMLAttributes } from \"react\";\nimport { faTriangleExclamation } from \"@fortawesome/free-solid-svg-icons\";\n\nimport { IconFa } from \"../IconFa\";\nimport { Box } from \"../Box\";\n\nimport { removeEmpty } from \"../../utils/Helper\";\n\nimport {\n type SpacingProps,\n type TextProps,\n type ColourProps,\n} from \"../../types\";\n\n/**\n *\n * To be used in forms for inline validation. Applies styling and accessibility attribute so that it will be read by screen readers.\n *\n * Please be aware that some input components already have this component built in and can be passed an \"errorMessage\" prop\n */\nexport function ErrorText({\n textColor,\n backgroundColor,\n margin,\n marginTop,\n marginRight,\n marginBottom,\n marginLeft,\n marginVertical,\n marginHorizontal,\n padding,\n paddingTop,\n paddingRight,\n paddingBottom,\n paddingLeft,\n paddingVertical,\n paddingHorizontal,\n textSize,\n textAlign,\n textWeight,\n textFontFamily,\n wordBreak,\n overflowWrap,\n as,\n children,\n ref,\n ...htmlAttributes\n}: SpacingProps &\n TextProps &\n ColourProps &\n HTMLAttributes<HTMLElement> & {\n children?: React.ReactNode;\n as?: \"span\" | \"div\" | \"p\";\n ref?: Ref<HTMLSpanElement | HTMLDivElement | HTMLParagraphElement>;\n }) {\n const convertedProps = {\n \"data-color\": textColor,\n \"data-bg-color\": backgroundColor,\n \"data-text-size\": textSize,\n \"data-text-align\": textAlign,\n \"data-text-weight\": textWeight,\n \"data-text-font-family\": textFontFamily,\n \"data-word-break\": wordBreak,\n \"data-overflow-wrap\": overflowWrap,\n \"data-margin\": margin,\n \"data-margin-top\": marginTop,\n \"data-margin-right\": marginRight,\n \"data-margin-bottom\": marginBottom,\n \"data-margin-left\": marginLeft,\n \"data-margin-vertical\": marginVertical,\n \"data-margin-horizontal\": marginHorizontal,\n \"data-padding\": padding,\n \"data-padding-top\": paddingTop,\n \"data-padding-right\": paddingRight,\n \"data-padding-bottom\": paddingBottom,\n \"data-padding-left\": paddingLeft,\n \"data-padding-vertical\": paddingVertical,\n \"data-padding-horizontal\": paddingHorizontal,\n };\n\n const convertedPropsFiltered = removeEmpty(convertedProps);\n\n const shouldShowIcon = typeof children === \"string\" && children.length;\n\n const innerContent = (\n <>\n {shouldShowIcon ? (\n <Box as=\"span\" marginRight=\"xxs\">\n <IconFa faIcon={faTriangleExclamation} size=\"1em\" />\n </Box>\n ) : null}\n {children}\n </>\n );\n return (\n <>\n {!as || as === \"span\" ? (\n <span\n className={[\n \"component-error-text\",\n \"text-props\",\n \"spacing-props\",\n \"color-props\",\n ].join(\" \")}\n ref={ref as Ref<HTMLSpanElement>}\n {...htmlAttributes}\n {...convertedPropsFiltered}\n role=\"alert\"\n >\n {innerContent}\n </span>\n ) : null}\n {as === \"div\" ? (\n <div\n className={[\n \"component-error-text\",\n \"text-props\",\n \"spacing-props\",\n \"color-props\",\n ].join(\" \")}\n ref={ref as Ref<HTMLDivElement>}\n {...htmlAttributes}\n {...convertedPropsFiltered}\n role=\"alert\"\n >\n {innerContent}\n </div>\n ) : null}\n {as === \"p\" ? (\n <p\n className={[\n \"component-error-text\",\n \"text-props\",\n \"spacing-props\",\n \"color-props\",\n ].join(\" \")}\n ref={ref as Ref<HTMLParagraphElement>}\n {...htmlAttributes}\n {...convertedPropsFiltered}\n role=\"alert\"\n >\n {innerContent}\n </p>\n ) : null}\n </>\n );\n}\n\nexport default ErrorText;\n"],"names":["ErrorText","_a","textColor","backgroundColor","margin","marginTop","marginRight","marginBottom","marginLeft","marginVertical","marginHorizontal","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingVertical","paddingHorizontal","textSize","textAlign","textWeight","textFontFamily","wordBreak","overflowWrap","as","children","ref","htmlAttributes","__rest","convertedPropsFiltered","removeEmpty","shouldShowIcon","length","innerContent","React","createElement","Fragment","Box","IconFa","faIcon","faTriangleExclamation","size","__assign","className","join","role"],"mappings":"oVAoBM,SAAUA,EAAUC,GACxB,IAAAC,EAASD,EAAAC,UACTC,EAAeF,EAAAE,gBACfC,EAAMH,EAAAG,OACNC,cACAC,EAAWL,EAAAK,YACXC,EAAYN,EAAAM,aACZC,EAAUP,EAAAO,WACVC,EAAcR,EAAAQ,eACdC,qBACAC,EAAOV,EAAAU,QACPC,EAAUX,EAAAW,WACVC,EAAYZ,EAAAY,aACZC,EAAab,EAAAa,cACbC,EAAWd,EAAAc,YACXC,EAAef,EAAAe,gBACfC,sBACAC,EAAQjB,EAAAiB,SACRC,EAASlB,EAAAkB,UACTC,EAAUnB,EAAAmB,WACVC,EAAcpB,EAAAoB,eACdC,cACAC,EAAYtB,EAAAsB,aACZC,EAAEvB,EAAAuB,GACFC,EAAQxB,EAAAwB,SACRC,EAAGzB,EAAAyB,IACAC,EAAcC,EAAA3B,EA1BO,oVA4DlB4B,EAAyBC,EAzBR,CACrB,aAAc5B,EACd,gBAAiBC,EACjB,iBAAkBe,EAClB,kBAAmBC,EACnB,mBAAoBC,EACpB,wBAAyBC,EACzB,kBAAmBC,EACnB,qBAAsBC,EACtB,cAAenB,EACf,kBAAmBC,EACnB,oBAAqBC,EACrB,qBAAsBC,EACtB,mBAAoBC,EACpB,uBAAwBC,EACxB,yBAA0BC,EAC1B,eAAgBC,EAChB,mBAAoBC,EACpB,qBAAsBC,EACtB,sBAAuBC,EACvB,oBAAqBC,EACrB,wBAAyBC,EACzB,0BAA2BC,IAKvBc,EAAqC,iBAAbN,GAAyBA,EAASO,OAE1DC,EACJC,EAAAC,cAAAD,EAAAE,SAAA,KACGL,EACCG,EAAAC,cAACE,EAAG,CAACb,GAAG,OAAOlB,YAAY,OACzB4B,EAAAC,cAACG,EAAM,CAACC,OAAQC,EAAuBC,KAAK,SAE5C,KACHhB,GAGL,OACES,EAAAC,cAAAD,EAAAE,SAAA,KACIZ,GAAa,SAAPA,EAeJ,KAdFU,EAAAC,cAAA,OAAAO,EAAA,CACEC,UAAW,CACT,uBACA,aACA,gBACA,eACAC,KAAK,KACPlB,IAAKA,GACDC,EACAE,EAAsB,CAC1BgB,KAAK,UAEJZ,GAGG,QAAPT,EACCU,EAAAC,cAAA,MAAAO,EAAA,CACEC,UAAW,CACT,uBACA,aACA,gBACA,eACAC,KAAK,KACPlB,IAAKA,GACDC,EACAE,EAAsB,CAC1BgB,KAAK,UAEJZ,GAED,KACI,MAAPT,EACCU,EAAAC,cAAA,IAAAO,EAAA,CACEC,UAAW,CACT,uBACA,aACA,gBACA,eACAC,KAAK,KACPlB,IAAKA,GACDC,EACAE,EAAsB,CAC1BgB,KAAK,UAEJZ,GAED,KAGV"}
@@ -1,11 +1,13 @@
1
1
  import React, { type ReactNode, type HTMLAttributes } from "react";
2
- export type FooterProps = HTMLAttributes<HTMLElement> & {
3
- /** used to customise text in middle section, it could also be react element, this is not to be confused with the component children which is primarily for the links in the footer */
4
- middleSection?: ReactNode;
5
- children?: ReactNode;
6
- };
2
+ import { type ThemeNameType } from "../../types";
7
3
  /**
8
4
  * There should be only one footer component at the bottom of the body of each page. Links can be passed as children
9
5
  * */
10
- export declare function Footer({ children, middleSection }: FooterProps): React.JSX.Element;
6
+ export declare function Footer({ children, themeName, footerText, }: HTMLAttributes<HTMLElement> & {
7
+ /** used to customise text in middle section, it could also be react element, this is not to be confused with the component children which is primarily for the links in the footer */
8
+ middleSection?: ReactNode;
9
+ children?: ReactNode;
10
+ themeName?: ThemeNameType;
11
+ footerText?: string;
12
+ }): React.JSX.Element;
11
13
  export default Footer;
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"../../../node_modules/tslib/tslib.es6.js";import t from"react";import{useTheme as n,ThemeProvider as l}from"styled-components";import{crukTheme as r}from"../../themes/cruk.js";import{Text as o}from"../Text/index.js";import{StyledFooter as a,FooterContentWrapper as m,FooterSectionLogo as i,StyledRegulatorLogo as s,FooterSectionLinks as c,StyledNav as E,StyledUL as f,StyledLI as u,FooterSection as p,FooterSectionAddress as d,StyledAddress as g}from"./styles.js";function x(x){var h=x.children,S=x.middleSection,y=t.Children.toArray(h),z=n(),C=e(e({},r),z);return t.createElement(l,{theme:C},t.createElement(a,null,t.createElement(m,null,t.createElement(i,null,t.createElement(s,{width:130,height:40,alt:C.siteConfig.footerLogoAlt||"",src:C.siteConfig.footerLogoSrc||""})),t.createElement(c,null,t.createElement(E,{"aria-label":"footer links"},t.createElement(f,null,y.length?y.map(function(e,n){var l="footerLink".concat(n);return t.createElement(u,{key:l},e)}):null))),t.createElement(p,null,S?"string"==typeof S?t.createElement(o,{textSize:"s"},S):t.createElement(t.Fragment,null,S):t.createElement(o,{textSize:"s"},C.siteConfig.footerCopyText)),t.createElement(d,null,t.createElement(g,null,t.createElement(o,{as:"span",textSize:"s"},"2 Redman Place"),t.createElement(o,{as:"span",textSize:"s"},"London"),t.createElement(o,{as:"span",textSize:"s"},"E20 1JQ"))))))}export{x as Footer,x as default};
1
+ import e from"react";import{Text as a}from"../Text/index.js";function t(t){var n=t.children,r=t.themeName,s=void 0===r?"cruk":r,o=t.footerText,c=e.Children.toArray(n);return e.createElement("footer",{className:"component-footer"},e.createElement("div",{className:"footer-bar"}),e.createElement("div",{className:"footer-wrapper"},e.createElement("div",{className:"footer-section"},e.createElement("nav",{className:"footer-nav","aria-label":"footer links"},e.createElement("ul",{className:"footer-ul"},c.length?c.map(function(a,t){var n="footerLink".concat(t);return e.createElement("li",{key:n,className:"footer-li"},a)}):null))),e.createElement("div",{className:"footer-section"},e.createElement("img",{className:"footer-regulator-logo",width:130,height:40,alt:"Registered with Fundraising Regulator",src:"https://rcl.assets.cancerresearchuk.org/images/logos/fundreg.png"})),e.createElement("div",{className:"footer-section"},o?e.createElement(a,{textSize:"m"},o):e.createElement(e.Fragment,null,e.createElement(a,{textSize:"m",as:"span"},function(e){switch(e){case"su2c":return"Stand Up To Cancer and Stand Up To Cancer Brand Marks are registered trademarks of the Entertainment Industry Foundation. Cancer Research UK is a registered charity in England and Wales (1089464), Scotland(SC041666), the Isle of Man (1103) and Jersey (247). A company limited by guarantee. Registered company in England and Wales (4325234) and the Isle of Man (5713F). Registered address: 2 Redman Place, London, E20 1JQ. Donations will be made to Cancer Research UK in support of the Stand Up To Cancer campaign.";case"bowelbabe":return"The Bowelbabe Fund for Cancer Research UK, raises money to fund clinical trials, research and cancer information and awareness, as well as other initiatives to combat cancer and support those affected by cancer. The Bowelbabe Fund is a restricted fund within Cancer Research UK. Cancer Research UK is a registered charity in England and Wales (1089464), Scotland (SC041666), the Isle of Man (1103) and Jersey (247) and is registered with the Fundraising Regulator.";default:return"Cancer Research UK is a registered charity in England and Wales (1089464), Scotland (SC041666), the Isle of Man (1103) and Jersey (247). A company limited by guarantee. Registered company in England and Wales(4325234) and the Isle of Man (5713F)."}}(s)," Registered address:"),e.createElement("address",{className:"footer-address"},e.createElement(a,{textSize:"m",as:"span"}," ","2 Redman Place, London, E20 1JQ"))))))}export{t as Footer,t as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/Footer/index.tsx"],"sourcesContent":["import React, { type ReactNode, type HTMLAttributes } from \"react\";\nimport { useTheme, ThemeProvider } from \"styled-components\";\n\nimport { crukTheme as defaultTheme } from \"../../themes/cruk\";\nimport { Text } from \"../Text\";\n\nimport {\n StyledFooter,\n FooterContentWrapper,\n FooterSectionLogo,\n FooterSection,\n FooterSectionAddress,\n StyledAddress,\n StyledRegulatorLogo,\n FooterSectionLinks,\n StyledNav,\n StyledUL,\n StyledLI,\n} from \"./styles\";\n\nexport type FooterProps = HTMLAttributes<HTMLElement> & {\n /** used to customise text in middle section, it could also be react element, this is not to be confused with the component children which is primarily for the links in the footer */\n middleSection?: ReactNode;\n children?: ReactNode;\n};\n\n/**\n * There should be only one footer component at the bottom of the body of each page. Links can be passed as children\n * */\nexport function Footer({ children, middleSection }: FooterProps) {\n const childArray = React.Children.toArray(children);\n\n const foundTheme = useTheme();\n const theme = {\n ...defaultTheme,\n ...foundTheme,\n };\n\n return (\n <ThemeProvider theme={theme}>\n <StyledFooter>\n <FooterContentWrapper>\n <FooterSectionLogo>\n <StyledRegulatorLogo\n width={130}\n height={40}\n alt={theme.siteConfig.footerLogoAlt || \"\"}\n src={theme.siteConfig.footerLogoSrc || \"\"}\n />\n </FooterSectionLogo>\n <FooterSectionLinks>\n <StyledNav aria-label=\"footer links\">\n <StyledUL>\n {childArray.length\n ? childArray.map((child, index) => {\n const footerLinkKey = `footerLink${index}`;\n return <StyledLI key={footerLinkKey}>{child}</StyledLI>;\n })\n : null}\n </StyledUL>\n </StyledNav>\n </FooterSectionLinks>\n\n <FooterSection>\n {middleSection ? (\n typeof middleSection === \"string\" ? (\n <Text textSize=\"s\">{middleSection}</Text>\n ) : (\n <>{middleSection}</>\n )\n ) : (\n <Text textSize=\"s\">{theme.siteConfig.footerCopyText}</Text>\n )}\n </FooterSection>\n\n <FooterSectionAddress>\n <StyledAddress>\n <Text as=\"span\" textSize=\"s\">\n 2 Redman Place\n </Text>\n <Text as=\"span\" textSize=\"s\">\n London\n </Text>\n <Text as=\"span\" textSize=\"s\">\n E20 1JQ\n </Text>\n </StyledAddress>\n </FooterSectionAddress>\n </FooterContentWrapper>\n </StyledFooter>\n </ThemeProvider>\n );\n}\n\nexport default Footer;\n"],"names":["Footer","_a","children","middleSection","childArray","React","Children","toArray","foundTheme","useTheme","theme","__assign","defaultTheme","createElement","ThemeProvider","StyledFooter","FooterContentWrapper","FooterSectionLogo","StyledRegulatorLogo","width","height","alt","siteConfig","footerLogoAlt","src","footerLogoSrc","FooterSectionLinks","StyledNav","StyledUL","length","map","child","index","footerLinkKey","concat","StyledLI","key","FooterSection","Text","textSize","Fragment","footerCopyText","FooterSectionAddress","StyledAddress","as"],"mappings":"0eA6BM,SAAUA,EAAOC,OAAEC,EAAQD,EAAAC,SAAEC,EAAaF,EAAAE,cACxCC,EAAaC,EAAMC,SAASC,QAAQL,GAEpCM,EAAaC,IACbC,EAAKC,EAAAA,EAAA,CAAA,EACNC,GACAJ,GAGL,OACEH,EAAAQ,cAACC,EAAa,CAACJ,MAAOA,GACpBL,EAAAQ,cAACE,EAAY,KACXV,EAAAQ,cAACG,EAAoB,KACnBX,EAAAQ,cAACI,EAAiB,KAChBZ,EAAAQ,cAACK,EAAmB,CAClBC,MAAO,IACPC,OAAQ,GACRC,IAAKX,EAAMY,WAAWC,eAAiB,GACvCC,IAAKd,EAAMY,WAAWG,eAAiB,MAG3CpB,EAAAQ,cAACa,EAAkB,KACjBrB,EAAAQ,cAACc,gBAAqB,gBACpBtB,EAAAQ,cAACe,EAAQ,KACNxB,EAAWyB,OACRzB,EAAW0B,IAAI,SAACC,EAAOC,GACrB,IAAMC,EAAgB,aAAAC,OAAaF,GACnC,OAAO3B,EAAAQ,cAACsB,EAAQ,CAACC,IAAKH,GAAgBF,EACxC,GACA,QAKV1B,EAAAQ,cAACwB,EAAa,KACXlC,EAC0B,iBAAlBA,EACLE,EAAAQ,cAACyB,EAAI,CAACC,SAAS,KAAKpC,GAEpBE,EAAAQ,cAAAR,EAAAmC,SAAA,KAAGrC,GAGLE,EAAAQ,cAACyB,GAAKC,SAAS,KAAK7B,EAAMY,WAAWmB,iBAIzCpC,EAAAQ,cAAC6B,EAAoB,KACnBrC,EAAAQ,cAAC8B,EAAa,KACZtC,EAAAQ,cAACyB,GAAKM,GAAG,OAAOL,SAAS,KAAG,kBAG5BlC,EAAAQ,cAACyB,GAAKM,GAAG,OAAOL,SAAS,KAAG,UAG5BlC,EAAAQ,cAACyB,EAAI,CAACM,GAAG,OAAOL,SAAS,KAAG,eAS1C"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/Footer/index.tsx"],"sourcesContent":["import React, { type ReactNode, type HTMLAttributes } from \"react\";\nimport { Text } from \"../Text\";\n\nimport { type ThemeNameType } from \"../../types\";\n\nconst footerTextCruk =\n \"Cancer Research UK is a registered charity in England and Wales (1089464), Scotland (SC041666), the Isle of Man (1103) and Jersey (247). A company limited by guarantee. Registered company in England and Wales(4325234) and the Isle of Man (5713F).\";\nconst footerTextSu2c =\n \"Stand Up To Cancer and Stand Up To Cancer Brand Marks are registered trademarks of the Entertainment Industry Foundation. Cancer Research UK is a registered charity in England and Wales (1089464), Scotland(SC041666), the Isle of Man (1103) and Jersey (247). A company limited by guarantee. Registered company in England and Wales (4325234) and the Isle of Man (5713F). Registered address: 2 Redman Place, London, E20 1JQ. Donations will be made to Cancer Research UK in support of the Stand Up To Cancer campaign.\";\nconst footerTextBowelBabe =\n \"The Bowelbabe Fund for Cancer Research UK, raises money to fund clinical trials, research and cancer information and awareness, as well as other initiatives to combat cancer and support those affected by cancer. The Bowelbabe Fund is a restricted fund within Cancer Research UK. Cancer Research UK is a registered charity in England and Wales (1089464), Scotland (SC041666), the Isle of Man (1103) and Jersey (247) and is registered with the Fundraising Regulator.\";\n\nfunction footerTextForTheme(themeName: string): string {\n switch (themeName) {\n case \"su2c\":\n return footerTextSu2c;\n case \"bowelbabe\":\n return footerTextBowelBabe;\n default:\n return footerTextCruk;\n }\n}\n\n/**\n * There should be only one footer component at the bottom of the body of each page. Links can be passed as children\n * */\nexport function Footer({\n children,\n themeName = \"cruk\",\n footerText,\n}: HTMLAttributes<HTMLElement> & {\n /** used to customise text in middle section, it could also be react element, this is not to be confused with the component children which is primarily for the links in the footer */\n middleSection?: ReactNode;\n children?: ReactNode;\n themeName?: ThemeNameType;\n footerText?: string;\n}) {\n const childArray = React.Children.toArray(children);\n\n return (\n <footer className=\"component-footer\">\n <div className=\"footer-bar\" />\n <div className=\"footer-wrapper\">\n <div className=\"footer-section\">\n <nav className=\"footer-nav\" aria-label=\"footer links\">\n <ul className=\"footer-ul\">\n {childArray.length\n ? childArray.map((child, index) => {\n const footerLinkKey = `footerLink${index}`;\n return (\n <li key={footerLinkKey} className=\"footer-li\">\n {child}\n </li>\n );\n })\n : null}\n </ul>\n </nav>\n </div>\n <div className=\"footer-section\">\n <img\n className=\"footer-regulator-logo\"\n width={130}\n height={40}\n alt=\"Registered with Fundraising Regulator\"\n src=\"https://rcl.assets.cancerresearchuk.org/images/logos/fundreg.png\"\n />\n </div>\n <div className=\"footer-section\">\n {footerText ? (\n <Text textSize=\"m\">{footerText}</Text>\n ) : (\n <>\n <Text textSize=\"m\" as=\"span\">\n {footerTextForTheme(themeName)} Registered address:\n </Text>\n <address className=\"footer-address\">\n <Text textSize=\"m\" as=\"span\">\n {\" \"}\n 2 Redman Place, London, E20 1JQ\n </Text>\n </address>\n </>\n )}\n </div>\n </div>\n </footer>\n );\n}\n\nexport default Footer;\n"],"names":["Footer","_a","children","_b","themeName","footerText","childArray","React","Children","toArray","createElement","className","length","map","child","index","footerLinkKey","concat","key","width","height","alt","src","Text","textSize","Fragment","as","footerTextForTheme"],"mappings":"6DA0BM,SAAUA,EAAOC,OACrBC,EAAQD,EAAAC,SACRC,EAAAF,EAAAG,UAAAA,aAAY,OAAMD,EAClBE,EAAUJ,EAAAI,WAQJC,EAAaC,EAAMC,SAASC,QAAQP,GAE1C,OACEK,EAAAG,cAAA,SAAA,CAAQC,UAAU,oBAChBJ,EAAAG,cAAA,MAAA,CAAKC,UAAU,eACfJ,EAAAG,cAAA,MAAA,CAAKC,UAAU,kBACbJ,EAAAG,cAAA,MAAA,CAAKC,UAAU,kBACbJ,EAAAG,cAAA,MAAA,CAAKC,UAAU,aAAY,aAAY,gBACrCJ,EAAAG,cAAA,KAAA,CAAIC,UAAU,aACXL,EAAWM,OACRN,EAAWO,IAAI,SAACC,EAAOC,GACrB,IAAMC,EAAgB,aAAAC,OAAaF,GACnC,OACER,EAAAG,cAAA,KAAA,CAAIQ,IAAKF,EAAeL,UAAU,aAC/BG,EAGP,GACA,QAIVP,EAAAG,cAAA,MAAA,CAAKC,UAAU,kBACbJ,EAAAG,cAAA,MAAA,CACEC,UAAU,wBACVQ,MAAO,IACPC,OAAQ,GACRC,IAAI,wCACJC,IAAI,sEAGRf,EAAAG,cAAA,MAAA,CAAKC,UAAU,kBACZN,EACCE,EAAAG,cAACa,GAAKC,SAAS,KAAKnB,GAEpBE,EAAAG,cAAAH,EAAAkB,SAAA,KACElB,EAAAG,cAACa,GAAKC,SAAS,IAAIE,GAAG,QA7DpC,SAA4BtB,GAC1B,OAAQA,GACN,IAAK,OACH,MAPJ,ogBAQE,IAAK,YACH,MAPJ,mdAQE,QACE,MAbJ,yPAeF,CAqDiBuB,CAAmBvB,GACf,wBACPG,EAAAG,cAAA,UAAA,CAASC,UAAU,kBACjBJ,EAAAG,cAACa,GAAKC,SAAS,IAAIE,GAAG,QACnB,IAEI,uCAQvB"}
@@ -1,21 +1,5 @@
1
1
  import React, { type HTMLAttributes, type ReactNode } from "react";
2
- export type HeaderProps = HTMLAttributes<HTMLElement> & {
3
- /** flag which make header fixed to the top even when scrolling */
4
- isSticky?: boolean;
5
- /** text in the middle of the header */
6
- siteSlogan?: string;
7
- /** text to explain the content of the icon for a11y usually a description of where the link will take you */
8
- logoAltText?: string;
9
- /** header logo image url */
10
- logoImageSrc?: string;
11
- /** title of the header image component, this is mainly for the tooltip text on hover */
12
- logoLinkTitle?: string;
13
- /** the url of the logo link */
14
- logoLinkUrl?: string;
15
- /** instead of the contents of the header being centered to max width as defined in theme it is 100% width fo viewport */
16
- fullWidth?: boolean;
17
- children?: ReactNode;
18
- };
2
+ import { type ThemeNameType } from "../../types";
19
3
  /**
20
4
  * There should be only one header component near or at the top of the body of each page.
21
5
  *
@@ -33,5 +17,22 @@ export type HeaderProps = HTMLAttributes<HTMLElement> & {
33
17
  * There is a hidden skip link in the header which will only reveals itself on the first tab and to screen readers. This link helps users skip to the main page content, however this will only work with there is an element with an id of 'main' which the developer should create for every page.
34
18
  *
35
19
  */
36
- export declare function Header({ isSticky, siteSlogan, logoAltText, logoImageSrc, logoLinkTitle, logoLinkUrl, fullWidth, children, }: HeaderProps): React.JSX.Element;
20
+ export declare function Header({ themeName, isSticky, siteSlogan, logoAltText, logoImageSrc, logoLinkTitle, logoLinkUrl, fullWidth, children, }: HTMLAttributes<HTMLElement> & {
21
+ themeName: ThemeNameType;
22
+ /** flag which make header fixed to the top even when scrolling */
23
+ isSticky?: boolean;
24
+ /** text in the middle of the header */
25
+ siteSlogan?: string;
26
+ /** text to explain the content of the icon for a11y usually a description of where the link will take you */
27
+ logoAltText?: string;
28
+ /** header logo image url */
29
+ logoImageSrc?: string;
30
+ /** title of the header image component, this is mainly for the tooltip text on hover */
31
+ logoLinkTitle?: string;
32
+ /** the url of the logo link */
33
+ logoLinkUrl?: string;
34
+ /** instead of the contents of the header being centered to max width as defined in theme it is 100% width fo viewport */
35
+ fullWidth?: boolean;
36
+ children?: ReactNode;
37
+ }): React.JSX.Element;
37
38
  export default Header;
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"../../../node_modules/tslib/tslib.es6.js";import t,{useState as l}from"react";import{useTheme as o,ThemeProvider as n}from"styled-components";import i from"../../hooks/useScrollPosition.js";import{crukTheme as r}from"../../themes/cruk.js";import{StyledHeader as m,HeaderStickyPlaceHolder as s,HeaderStickyContainer as c,SkipToMain as a,HeaderMainContent as u,StyledLink as f,LogoWrapper as d,Logo as g,Tagline as E,ChildWrapper as S,ChildInner as h}from"./styles.js";function k(k){var p=k.isSticky,y=k.siteSlogan,$=k.logoAltText,j=k.logoImageSrc,C=k.logoLinkTitle,b=k.logoLinkUrl,v=k.fullWidth,w=k.children,x=l(!1),A=x[0],L=x[1],P="undefined"!=typeof window,T=o(),U=e(e({},r),T);return i(function(e){var t=e.currPos,l=!!P&&t.y>240;l!==A&&L(l)},[A],null,!0,50),t.createElement(n,{theme:U},t.createElement(m,null,t.createElement(s,null,t.createElement(c,{"data-testid":"header-sticky-container",$isSmall:A,$isSticky:p},t.createElement(a,{href:"#main"},"Skip to main content"),t.createElement(u,{$fullWidth:v},t.createElement(f,{href:null!=b?b:U.siteConfig.logoUrl,title:null!=C?C:"Home"},t.createElement(d,{$isSmall:A,$isSticky:p},t.createElement(g,{height:80,src:null!=j?j:U.siteConfig.logoSrc,alt:null!=$?$:U.siteConfig.logoAlt}))),y?t.createElement(E,{$isSmall:A,$isSticky:p},y):null,t.createElement(S,null,t.createElement(h,null,w)))))))}export{k as Header,k as default};
1
+ import e,{useState as a}from"react";import t from"../../hooks/useScrollPosition.js";function l(l){var r=l.themeName,s=l.isSticky,c=l.siteSlogan,n=l.logoAltText,o=l.logoImageSrc,i=l.logoLinkTitle,m=l.logoLinkUrl,d=l.fullWidth,g=l.children,h=a(!1),u=h[0],p=h[1],f="undefined"!=typeof window;t(function(e){var a=e.currPos,t=!!f&&a.y>240;t!==u&&p(t)},[u],null,!0,50);var k=function(e){switch(e){case"su2c":return"https://rcl.assets.cancerresearchuk.org/images/logos/su2c-160.png";case"bowelbabe":return"https://rcl.assets.cancerresearchuk.org/images/logos/bowelbabe-logo-160.png";case"rfl":return"https://rcl.assets.cancerresearchuk.org/images/logos/rfl.svg";default:return"https://rcl.assets.cancerresearchuk.org/images/logos/cruk.svg"}}(r);return e.createElement("header",{className:"component-header","data-is-sticky":s||!1,"data-is-small":u||!1,"data-full-width":d||!1},e.createElement("div",{className:"header-sticky-placeholder"},e.createElement("div",{className:"header-sticky-container","data-testid":"header-sticky-container"},e.createElement("a",{className:"skip-to-main",href:"#main"},"Skip to main content"),e.createElement("div",{className:"header-main-content","data-$full-width":d},e.createElement("a",{className:"header-logo-link",href:null!=m?m:"/",title:null!=i?i:"Home"},e.createElement("div",{className:"logo-wrapper"},e.createElement("img",{className:"logo",width:160,height:80,src:null!=o?o:k,alt:null!=n?n:"Cancer Research UK Giving Pages"}))),c?e.createElement("p",{className:"tagline"},c):null,e.createElement("div",{className:"child-wrapper"},e.createElement("div",{className:"child-inner"},g))))))}export{l as Header,l as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/Header/index.tsx"],"sourcesContent":["import React, { useState, type HTMLAttributes, type ReactNode } from \"react\";\nimport { useTheme, ThemeProvider } from \"styled-components\";\n\nimport { useScrollPosition } from \"../../hooks/useScrollPosition\";\nimport { crukTheme as defaultTheme } from \"../../themes/cruk\";\n\nimport {\n StyledHeader,\n HeaderStickyContainer,\n HeaderStickyPlaceHolder,\n HeaderMainContent,\n SkipToMain,\n StyledLink,\n Logo,\n LogoWrapper,\n Tagline,\n ChildWrapper,\n ChildInner,\n} from \"./styles\";\n\nconst HEADER_SCROLL_THRESHOLD = 240;\n\nexport type HeaderProps = HTMLAttributes<HTMLElement> & {\n /** flag which make header fixed to the top even when scrolling */\n isSticky?: boolean;\n /** text in the middle of the header */\n siteSlogan?: string;\n /** text to explain the content of the icon for a11y usually a description of where the link will take you */\n logoAltText?: string;\n /** header logo image url */\n logoImageSrc?: string;\n /** title of the header image component, this is mainly for the tooltip text on hover */\n logoLinkTitle?: string;\n /** the url of the logo link */\n logoLinkUrl?: string;\n /** instead of the contents of the header being centered to max width as defined in theme it is 100% width fo viewport */\n fullWidth?: boolean;\n\n children?: ReactNode;\n};\n\n/**\n * There should be only one header component near or at the top of the body of each page.\n *\n * ### Logos\n * It is recommended that logo images are at least 80px high if they are not SVGs and that the logo is still clearly legible when reduced to 40px high for mobile.\n * It is also recommended that the logo width doesn't exceed 350px. If you need a wide logo that is shorter than 80px to keep the aspect ratio please make sure that the logo is centered with transparent space at the top and bottom and still 80px high.\n *\n * ### Site Slogan Text (optional)\n * This is a single line of text and the character limit depends on the theme, logo and children width. This is only visible on desktop at the top of the page\n *\n * ### Right section (optional)\n * This has been kept quite open you can place any child elements in here but ideally it is narrow and its height is 50px or smaller.\n *\n * ### Accessability\n * There is a hidden skip link in the header which will only reveals itself on the first tab and to screen readers. This link helps users skip to the main page content, however this will only work with there is an element with an id of 'main' which the developer should create for every page.\n *\n */\nexport function Header({\n isSticky,\n siteSlogan,\n logoAltText,\n logoImageSrc,\n logoLinkTitle,\n logoLinkUrl,\n fullWidth,\n children,\n}: HeaderProps) {\n const [isSmall, setIsSmall] = useState(false);\n const isBrowser = typeof window !== `undefined`;\n const foundTheme = useTheme();\n const theme = {\n ...defaultTheme,\n ...foundTheme,\n };\n\n useScrollPosition(\n ({\n currPos,\n }: {\n prevPos: { x: number; y: number };\n currPos: { x: number; y: number };\n }) => {\n const shouldShrink = isBrowser\n ? currPos.y > HEADER_SCROLL_THRESHOLD\n : false;\n if (shouldShrink !== isSmall) {\n setIsSmall(shouldShrink);\n }\n },\n [isSmall],\n null,\n true,\n 50,\n );\n\n return (\n <ThemeProvider theme={theme}>\n <StyledHeader>\n <HeaderStickyPlaceHolder>\n <HeaderStickyContainer\n data-testid=\"header-sticky-container\"\n $isSmall={isSmall}\n $isSticky={isSticky}\n >\n <SkipToMain href=\"#main\">Skip to main content</SkipToMain>\n <HeaderMainContent $fullWidth={fullWidth}>\n <StyledLink\n href={logoLinkUrl ?? theme.siteConfig.logoUrl}\n title={logoLinkTitle ?? \"Home\"}\n >\n <LogoWrapper $isSmall={isSmall} $isSticky={isSticky}>\n <Logo\n height={80}\n src={logoImageSrc ?? theme.siteConfig.logoSrc}\n alt={logoAltText ?? theme.siteConfig.logoAlt}\n />\n </LogoWrapper>\n </StyledLink>\n {siteSlogan ? (\n <Tagline $isSmall={isSmall} $isSticky={isSticky}>\n {siteSlogan}\n </Tagline>\n ) : null}\n <ChildWrapper>\n <ChildInner>{children}</ChildInner>\n </ChildWrapper>\n </HeaderMainContent>\n </HeaderStickyContainer>\n </HeaderStickyPlaceHolder>\n </StyledHeader>\n </ThemeProvider>\n );\n}\n\nexport default Header;\n"],"names":["Header","_a","isSticky","siteSlogan","logoAltText","logoImageSrc","logoLinkTitle","logoLinkUrl","fullWidth","children","_b","useState","isSmall","setIsSmall","isBrowser","window","foundTheme","useTheme","theme","__assign","defaultTheme","useScrollPosition","currPos","shouldShrink","y","React","createElement","ThemeProvider","StyledHeader","HeaderStickyPlaceHolder","HeaderStickyContainer","$isSmall","SkipToMain","href","HeaderMainContent","StyledLink","siteConfig","logoUrl","title","LogoWrapper","$isSticky","Logo","height","src","logoSrc","alt","logoAlt","Tagline","ChildWrapper","ChildInner"],"mappings":"6eA0DM,SAAUA,EAAOC,OACrBC,EAAQD,EAAAC,SACRC,EAAUF,EAAAE,WACVC,EAAWH,EAAAG,YACXC,EAAYJ,EAAAI,aACZC,EAAaL,EAAAK,cACbC,EAAWN,EAAAM,YACXC,EAASP,EAAAO,UACTC,EAAQR,EAAAQ,SAEFC,EAAwBC,GAAS,GAAhCC,EAAOF,EAAA,GAAEG,EAAUH,EAAA,GACpBI,EAA8B,oBAAXC,OACnBC,EAAaC,IACbC,EAAKC,EAAAA,EAAA,CAAA,EACNC,GACAJ,GAuBL,OApBAK,EACE,SAACpB,GACC,IAAAqB,EAAOrB,EAAAqB,QAKDC,IAAeT,GACjBQ,EAAQE,EAhEc,IAkEtBD,IAAiBX,GACnBC,EAAWU,EAEf,EACA,CAACX,GACD,MACA,EACA,IAIAa,EAAAC,cAACC,EAAa,CAACT,MAAOA,GACpBO,EAAAC,cAACE,EAAY,KACXH,EAAAC,cAACG,EAAuB,KACtBJ,EAAAC,cAACI,EAAqB,CAAA,cACR,0BAAyBC,SAC3BnB,YACCV,GAEXuB,EAAAC,cAACM,EAAU,CAACC,KAAK,SAAO,wBACxBR,EAAAC,cAACQ,cAA8B1B,GAC7BiB,EAAAC,cAACS,EAAU,CACTF,KAAM1B,QAAAA,EAAeW,EAAMkB,WAAWC,QACtCC,MAAOhC,QAAAA,EAAiB,QAExBmB,EAAAC,cAACa,EAAW,CAAAR,SAAWnB,EAAO4B,UAAatC,GACzCuB,EAAAC,cAACe,EAAI,CACHC,OAAQ,GACRC,IAAKtC,QAAAA,EAAgBa,EAAMkB,WAAWQ,QACtCC,IAAKzC,QAAAA,EAAec,EAAMkB,WAAWU,YAI1C3C,EACCsB,EAAAC,cAACqB,EAAO,CAAAhB,SAAWnB,EAAO4B,UAAatC,GACpCC,GAED,KACJsB,EAAAC,cAACsB,EAAY,KACXvB,EAAAC,cAACuB,EAAU,KAAExC,QAQ7B"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/Header/index.tsx"],"sourcesContent":["import React, { useState, type HTMLAttributes, type ReactNode } from \"react\";\n\nimport { useScrollPosition } from \"../../hooks/useScrollPosition\";\n\nimport { type ThemeNameType } from \"../../types\";\n\nconst HEADER_SCROLL_THRESHOLD = 240;\n\nconst crukLogoUrl =\n \"https://rcl.assets.cancerresearchuk.org/images/logos/cruk.svg\";\nconst rflLogoUrl =\n \"https://rcl.assets.cancerresearchuk.org/images/logos/rfl.svg\";\nconst su2cLogoUrl =\n \"https://rcl.assets.cancerresearchuk.org/images/logos/su2c-160.png\";\nconst bowelbabeLogoUrl =\n \"https://rcl.assets.cancerresearchuk.org/images/logos/bowelbabe-logo-160.png\";\n\nfunction getLogoFromThemeName(themeName: ThemeNameType) {\n switch (themeName) {\n case \"su2c\":\n return su2cLogoUrl;\n case \"bowelbabe\":\n return bowelbabeLogoUrl;\n case \"rfl\":\n return rflLogoUrl;\n default:\n return crukLogoUrl;\n }\n}\n\n/**\n * There should be only one header component near or at the top of the body of each page.\n *\n * ### Logos\n * It is recommended that logo images are at least 80px high if they are not SVGs and that the logo is still clearly legible when reduced to 40px high for mobile.\n * It is also recommended that the logo width doesn't exceed 350px. If you need a wide logo that is shorter than 80px to keep the aspect ratio please make sure that the logo is centered with transparent space at the top and bottom and still 80px high.\n *\n * ### Site Slogan Text (optional)\n * This is a single line of text and the character limit depends on the theme, logo and children width. This is only visible on desktop at the top of the page\n *\n * ### Right section (optional)\n * This has been kept quite open you can place any child elements in here but ideally it is narrow and its height is 50px or smaller.\n *\n * ### Accessability\n * There is a hidden skip link in the header which will only reveals itself on the first tab and to screen readers. This link helps users skip to the main page content, however this will only work with there is an element with an id of 'main' which the developer should create for every page.\n *\n */\nexport function Header({\n themeName,\n isSticky,\n siteSlogan,\n logoAltText,\n logoImageSrc,\n logoLinkTitle,\n logoLinkUrl,\n fullWidth,\n children,\n}: HTMLAttributes<HTMLElement> & {\n themeName: ThemeNameType;\n /** flag which make header fixed to the top even when scrolling */\n isSticky?: boolean;\n /** text in the middle of the header */\n siteSlogan?: string;\n /** text to explain the content of the icon for a11y usually a description of where the link will take you */\n logoAltText?: string;\n /** header logo image url */\n logoImageSrc?: string;\n /** title of the header image component, this is mainly for the tooltip text on hover */\n logoLinkTitle?: string;\n /** the url of the logo link */\n logoLinkUrl?: string;\n /** instead of the contents of the header being centered to max width as defined in theme it is 100% width fo viewport */\n fullWidth?: boolean;\n\n children?: ReactNode;\n}) {\n const [isSmall, setIsSmall] = useState(false);\n const isBrowser = typeof window !== `undefined`;\n\n useScrollPosition(\n ({\n currPos,\n }: {\n prevPos: { x: number; y: number };\n currPos: { x: number; y: number };\n }) => {\n const shouldShrink = isBrowser\n ? currPos.y > HEADER_SCROLL_THRESHOLD\n : false;\n if (shouldShrink !== isSmall) {\n setIsSmall(shouldShrink);\n }\n },\n [isSmall],\n null,\n true,\n 50,\n );\n\n const logoUrl = getLogoFromThemeName(themeName);\n\n return (\n <header\n className=\"component-header\"\n data-is-sticky={isSticky || false}\n data-is-small={isSmall || false}\n data-full-width={fullWidth || false}\n >\n <div className=\"header-sticky-placeholder\">\n <div\n className=\"header-sticky-container\"\n data-testid=\"header-sticky-container\"\n >\n <a className=\"skip-to-main\" href=\"#main\">\n Skip to main content\n </a>\n <div className=\"header-main-content\" data-$full-width={fullWidth}>\n <a\n className=\"header-logo-link\"\n href={logoLinkUrl ?? \"/\"}\n title={logoLinkTitle ?? \"Home\"}\n >\n <div className=\"logo-wrapper\">\n <img\n className=\"logo\"\n width={160}\n height={80}\n src={logoImageSrc ?? logoUrl}\n alt={logoAltText ?? \"Cancer Research UK Giving Pages\"}\n />\n </div>\n </a>\n {siteSlogan ? <p className=\"tagline\">{siteSlogan}</p> : null}\n <div className=\"child-wrapper\">\n <div className=\"child-inner\">{children}</div>\n </div>\n </div>\n </div>\n </div>\n </header>\n );\n}\n\nexport default Header;\n"],"names":["Header","_a","themeName","isSticky","siteSlogan","logoAltText","logoImageSrc","logoLinkTitle","logoLinkUrl","fullWidth","children","_b","useState","isSmall","setIsSmall","isBrowser","window","useScrollPosition","currPos","shouldShrink","y","logoUrl","getLogoFromThemeName","React","createElement","className","href","title","width","height","src","alt"],"mappings":"oFA+CM,SAAUA,EAAOC,OACrBC,EAASD,EAAAC,UACTC,EAAQF,EAAAE,SACRC,EAAUH,EAAAG,WACVC,EAAWJ,EAAAI,YACXC,iBACAC,EAAaN,EAAAM,cACbC,EAAWP,EAAAO,YACXC,EAASR,EAAAQ,UACTC,EAAQT,EAAAS,SAoBFC,EAAwBC,GAAS,GAAhCC,EAAOF,EAAA,GAAEG,EAAUH,EAAA,GACpBI,EAA8B,oBAAXC,OAEzBC,EACE,SAAChB,GACC,IAAAiB,EAAOjB,EAAAiB,QAKDC,IAAeJ,GACjBG,EAAQE,EAjFc,IAmFtBD,IAAiBN,GACnBC,EAAWK,EAEf,EACA,CAACN,GACD,MACA,EACA,IAGF,IAAMQ,EAlFR,SAA8BnB,GAC5B,OAAQA,GACN,IAAK,OACH,MAPJ,oEAQE,IAAK,YACH,MAPJ,8EAQE,IAAK,MACH,MAbJ,+DAcE,QACE,MAjBJ,gEAmBF,CAuEkBoB,CAAqBpB,GAErC,OACEqB,EAAAC,cAAA,SAAA,CACEC,UAAU,oCACMtB,IAAY,EAAK,gBAClBU,IAAW,EAAK,kBACdJ,IAAa,GAE9Bc,EAAAC,cAAA,MAAA,CAAKC,UAAU,6BACbF,EAAAC,cAAA,MAAA,CACEC,UAAU,0BAAyB,cACvB,2BAEZF,EAAAC,cAAA,IAAA,CAAGC,UAAU,eAAeC,KAAK,SAAO,wBAGxCH,EAAAC,cAAA,MAAA,CAAKC,UAAU,sBAAqB,mBAAmBhB,GACrDc,EAAAC,cAAA,IAAA,CACEC,UAAU,mBACVC,KAAMlB,QAAAA,EAAe,IACrBmB,MAAOpB,QAAAA,EAAiB,QAExBgB,EAAAC,cAAA,MAAA,CAAKC,UAAU,gBACbF,EAAAC,cAAA,MAAA,CACEC,UAAU,OACVG,MAAO,IACPC,OAAQ,GACRC,IAAKxB,QAAAA,EAAgBe,EACrBU,IAAK1B,QAAAA,EAAe,sCAIzBD,EAAamB,EAAAC,cAAA,IAAA,CAAGC,UAAU,WAAWrB,GAAkB,KACxDmB,EAAAC,cAAA,MAAA,CAAKC,UAAU,iBACbF,EAAAC,cAAA,MAAA,CAAKC,UAAU,eAAef,OAO5C"}
@@ -1,25 +1,13 @@
1
- import React, { type HTMLAttributes, type ElementType } from "react";
2
- import { type SpacingProps } from "../Spacing";
3
- import { type FontSizeType, type WordBreakType, type OverflowWrapType } from "../../types";
4
- export type HeadingProps = SpacingProps & HTMLAttributes<HTMLElement> & {
1
+ import React, { type HTMLAttributes } from "react";
2
+ import { type SpacingProps, type TextProps, type ColourProps } from "../../types";
3
+ export type HeadingProps = SpacingProps & TextProps & ColourProps & HTMLAttributes<HTMLElement> & {
5
4
  h1?: boolean;
6
5
  h2?: boolean;
7
6
  h3?: boolean;
8
7
  h4?: boolean;
9
8
  h5?: boolean;
10
9
  h6?: boolean;
11
- /** font size FontSizeType t-shirt sizes */
12
- textSize?: FontSizeType;
13
- /** horizontal alignment of text */
14
- textAlign?: "left" | "right" | "center";
15
- /** color of text */
16
- textColor?: string;
17
- /** word-break behavior */
18
- wordBreak?: WordBreakType;
19
- /** overflow-wrap behavior */
20
- overflowWrap?: OverflowWrapType;
21
- /** styled-component polymorphic feature so you take the styling of a header and cast the component to be a "span" for example */
22
- as?: ElementType;
10
+ as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span" | "legend";
23
11
  };
24
12
  /**
25
13
  *
@@ -28,5 +16,5 @@ Markup headings semantically using the appropriate <h#> level HTML element and
28
16
  use the corresponding heading class (h1, h2, h3, ....). Write all headings in sentence case. Heading differs from the Text component by using a different font-family and it changes the font size according to the screen width breakpoints.
29
17
  *
30
18
  */
31
- export declare function Heading({ textSize, textAlign, textColor, wordBreak, overflowWrap, h1, h2, h3, h4, h5, h6, ...props }: HeadingProps): React.JSX.Element;
19
+ export declare function Heading({ textColor, backgroundColor, textSize, textAlign, textWeight, textFontFamily, wordBreak, overflowWrap, margin, marginTop, marginRight, marginBottom, marginLeft, marginVertical, marginHorizontal, padding, paddingTop, paddingRight, paddingBottom, paddingLeft, paddingVertical, paddingHorizontal, h1, h2, h3, h4, h5, h6, as, ...htmlProps }: HeadingProps): React.JSX.Element;
32
20
  export default Heading;
@@ -1,2 +1,2 @@
1
- import{__rest as e,__assign as t}from"../../../node_modules/tslib/tslib.es6.js";import r from"react";import{useTheme as o}from"styled-components";import{crukTheme as l}from"../../themes/cruk.js";import{spacingPropsToSpacingPropsInternal as $}from"../Spacing/index.js";import{H1 as a,H2 as i,H3 as m,H4 as x,H5 as n,H6 as h}from"./styles.js";function p(p){var w=p.textSize,f=p.textAlign,d=p.textColor,s=p.wordBreak,c=p.overflowWrap,g=p.h1,k=p.h2,v=p.h3,S=p.h4,z=p.h5,A=p.h6,B=e(p,["textSize","textAlign","textColor","wordBreak","overflowWrap","h1","h2","h3","h4","h5","h6"]),C=o(),W=t(t({},l),C),E=$(B);return g?r.createElement(a,t({},E,{theme:W,$textSize:w,$textAlign:f,$textColor:d,$wordBreak:s,$overflowWrap:c})):k?r.createElement(i,t({},E,{theme:W,$textSize:w,$textAlign:f,$textColor:d,$wordBreak:s,$overflowWrap:c})):v?r.createElement(m,t({},E,{theme:W,$textSize:w,$textAlign:f,$textColor:d,$wordBreak:s,$overflowWrap:c})):S?r.createElement(x,t({},E,{theme:W,$textSize:w,$textAlign:f,$textColor:d,$wordBreak:s,$overflowWrap:c})):z?r.createElement(n,t({},E,{theme:W,$textSize:w,$textAlign:f,$textColor:d,$wordBreak:s,$overflowWrap:c})):A?r.createElement(h,t({},E,{theme:W,$textSize:w,$textAlign:f,$textColor:d,$wordBreak:s,$overflowWrap:c})):r.createElement(i,t({},E,{theme:W,$textSize:w,$textAlign:f,$textColor:d,$wordBreak:s,$overflowWrap:c}))}export{p as Heading,p as default};
1
+ import{__rest as a,__assign as t}from"../../../node_modules/tslib/tslib.es6.js";import e from"react";function n(n){var o=n.textColor,p=n.backgroundColor,r=n.textSize,i=n.textAlign,d=n.textWeight,l=n.textFontFamily,g=n.wordBreak,s=n.overflowWrap,c=n.margin,m=n.marginTop,h=n.marginRight,x=n.marginBottom,u=n.marginLeft,f=n.marginVertical,j=n.marginHorizontal,E=n.padding,z=n.paddingTop,N=n.paddingRight,b=n.paddingBottom,w=n.paddingLeft,v=n.paddingVertical,B=n.paddingHorizontal,k=n.h1,F=n.h2,C=n.h3,H=n.h4,L=n.h5,R=n.h6,T=n.as,V=a(n,["textColor","backgroundColor","textSize","textAlign","textWeight","textFontFamily","wordBreak","overflowWrap","margin","marginTop","marginRight","marginBottom","marginLeft","marginVertical","marginHorizontal","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingVertical","paddingHorizontal","h1","h2","h3","h4","h5","h6","as"]),W=k?"h1":F?"h2":C?"h3":H?"h4":L?"h5":R?"h6":"h2",y=T||W,A={"data-color":o,"data-bg-color":p,"data-text-size":r,"data-text-align":i,"data-text-weight":d,"data-text-font-family":l,"data-word-break":g,"data-overflow-wrap":s,"data-margin":c,"data-margin-top":m,"data-margin-right":h,"data-margin-bottom":x,"data-margin-left":u,"data-margin-vertical":f,"data-margin-horizontal":j,"data-padding":E,"data-padding-top":z,"data-padding-right":N,"data-padding-bottom":b,"data-padding-left":w,"data-padding-vertical":v,"data-padding-horizontal":B};return e.createElement(e.Fragment,null,"h1"===y?e.createElement("h1",t({className:["component-heading","color-props","spacing-props","text-props"].join(" "),"data-appearance":W},A,V)):null,"h2"===y?e.createElement("h2",t({className:["component-heading","color-props","spacing-props","text-props"].join(" "),"data-appearance":W},A,V)):null,"h3"===y?e.createElement("h3",t({className:["component-heading","color-props","spacing-props","text-props"].join(" "),"data-appearance":W},A,V)):null,"h4"===y?e.createElement("h4",t({className:["component-heading","color-props","spacing-props","text-props"].join(" "),"data-appearance":W},A,V)):null,"h5"===y?e.createElement("h5",t({className:["component-heading","color-props","spacing-props","text-props"].join(" "),"data-appearance":W},A,V)):null,"h6"===y?e.createElement("h6",t({className:["component-heading","color-props","spacing-props","text-props"].join(" "),"data-appearance":W},A,V)):null,"p"===y?e.createElement("p",t({className:["component-heading","color-props","spacing-props","text-props"].join(" ")},A,V)):null,"span"===y?e.createElement("span",t({className:["component-heading","color-props","spacing-props","text-props"].join(" ")},A,V)):null,"legend"===y?e.createElement("legend",t({className:["component-heading","color-props","spacing-props","text-props"].join(" ")},A,V)):null)}export{n as Heading,n as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/Heading/index.tsx"],"sourcesContent":["import React, { type HTMLAttributes, type ElementType } from \"react\";\nimport { useTheme } from \"styled-components\";\n\nimport { crukTheme as defaultTheme } from \"../../themes/cruk\";\nimport {\n spacingPropsToSpacingPropsInternal,\n type SpacingProps,\n} from \"../Spacing\";\n\nimport {\n type FontSizeType,\n type WordBreakType,\n type OverflowWrapType,\n} from \"../../types\";\nimport { H1, H2, H3, H4, H5, H6 } from \"./styles\";\n\nexport type HeadingProps = SpacingProps &\n HTMLAttributes<HTMLElement> & {\n h1?: boolean;\n h2?: boolean;\n h3?: boolean;\n h4?: boolean;\n h5?: boolean;\n h6?: boolean;\n /** font size FontSizeType t-shirt sizes */\n textSize?: FontSizeType;\n /** horizontal alignment of text */\n textAlign?: \"left\" | \"right\" | \"center\";\n /** color of text */\n textColor?: string;\n /** word-break behavior */\n wordBreak?: WordBreakType;\n /** overflow-wrap behavior */\n overflowWrap?: OverflowWrapType;\n /** styled-component polymorphic feature so you take the styling of a header and cast the component to be a \"span\" for example */\n as?: ElementType;\n };\n\n/**\n * \n * Use headings consistently to create a clear hierarchy throughout your service.\nMarkup headings semantically using the appropriate <h#> level HTML element and\nuse the corresponding heading class (h1, h2, h3, ....). Write all headings in sentence case. Heading differs from the Text component by using a different font-family and it changes the font size according to the screen width breakpoints.\n * \n */\nexport function Heading({\n textSize,\n textAlign,\n textColor,\n wordBreak,\n overflowWrap,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n ...props\n}: HeadingProps) {\n const foundTheme = useTheme();\n const theme = {\n ...defaultTheme,\n ...foundTheme,\n };\n\n const propsConvertedToInternalSpacingProps =\n spacingPropsToSpacingPropsInternal(props);\n\n if (h1)\n return (\n <H1\n {...propsConvertedToInternalSpacingProps}\n theme={theme}\n $textSize={textSize}\n $textAlign={textAlign}\n $textColor={textColor}\n $wordBreak={wordBreak}\n $overflowWrap={overflowWrap}\n />\n );\n if (h2)\n return (\n <H2\n {...propsConvertedToInternalSpacingProps}\n theme={theme}\n $textSize={textSize}\n $textAlign={textAlign}\n $textColor={textColor}\n $wordBreak={wordBreak}\n $overflowWrap={overflowWrap}\n />\n );\n if (h3)\n return (\n <H3\n {...propsConvertedToInternalSpacingProps}\n theme={theme}\n $textSize={textSize}\n $textAlign={textAlign}\n $textColor={textColor}\n $wordBreak={wordBreak}\n $overflowWrap={overflowWrap}\n />\n );\n if (h4)\n return (\n <H4\n {...propsConvertedToInternalSpacingProps}\n theme={theme}\n $textSize={textSize}\n $textAlign={textAlign}\n $textColor={textColor}\n $wordBreak={wordBreak}\n $overflowWrap={overflowWrap}\n />\n );\n if (h5)\n return (\n <H5\n {...propsConvertedToInternalSpacingProps}\n theme={theme}\n $textSize={textSize}\n $textAlign={textAlign}\n $textColor={textColor}\n $wordBreak={wordBreak}\n $overflowWrap={overflowWrap}\n />\n );\n if (h6)\n return (\n <H6\n {...propsConvertedToInternalSpacingProps}\n theme={theme}\n $textSize={textSize}\n $textAlign={textAlign}\n $textColor={textColor}\n $wordBreak={wordBreak}\n $overflowWrap={overflowWrap}\n />\n );\n return (\n <H2\n {...propsConvertedToInternalSpacingProps}\n theme={theme}\n $textSize={textSize}\n $textAlign={textAlign}\n $textColor={textColor}\n $wordBreak={wordBreak}\n $overflowWrap={overflowWrap}\n />\n );\n}\n\nexport default Heading;\n"],"names":["Heading","_a","textSize","textAlign","textColor","wordBreak","overflowWrap","h1","h2","h3","h4","h5","h6","props","__rest","foundTheme","useTheme","theme","__assign","defaultTheme","propsConvertedToInternalSpacingProps","spacingPropsToSpacingPropsInternal","React","H1","$textSize","$textAlign","$wordBreak","$overflowWrap","H2","H3","H4","H5","H6"],"mappings":"qVA6CM,SAAUA,EAAQC,GACtB,IAAAC,EAAQD,EAAAC,SACRC,EAASF,EAAAE,UACTC,EAASH,EAAAG,UACTC,cACAC,EAAYL,EAAAK,aACZC,EAAEN,EAAAM,GACFC,EAAEP,EAAAO,GACFC,EAAER,EAAAQ,GACFC,OACAC,EAAEV,EAAAU,GACFC,EAAEX,EAAAW,GACCC,EAAKC,EAAAb,EAZc,+FAchBc,EAAaC,IACbC,EAAKC,EAAAA,EAAA,CAAA,EACNC,GACAJ,GAGCK,EACJC,EAAmCR,GAErC,OAAIN,EAEAe,gBAACC,EAAEL,EAAA,CAAA,EACGE,EAAoC,CACxCH,MAAOA,EAAKO,UACDtB,EAAQuB,WACPtB,aACAC,EAASsB,WACTrB,EAASsB,cACNrB,KAGjBE,EAEAc,gBAACM,EAAEV,EAAA,CAAA,EACGE,EAAoC,CACxCH,MAAOA,EAAKO,UACDtB,EAAQuB,WACPtB,aACAC,EAASsB,WACTrB,EAASsB,cACNrB,KAGjBG,EAEAa,gBAACO,EAAEX,EAAA,CAAA,EACGE,EAAoC,CACxCH,MAAOA,EAAKO,UACDtB,EAAQuB,WACPtB,aACAC,EAASsB,WACTrB,EAASsB,cACNrB,KAGjBI,EAEAY,gBAACQ,EAAEZ,EAAA,CAAA,EACGE,EAAoC,CACxCH,MAAOA,EAAKO,UACDtB,EAAQuB,WACPtB,aACAC,EAASsB,WACTrB,EAASsB,cACNrB,KAGjBK,EAEAW,gBAACS,EAAEb,EAAA,CAAA,EACGE,EAAoC,CACxCH,MAAOA,EAAKO,UACDtB,EAAQuB,WACPtB,aACAC,EAASsB,WACTrB,EAASsB,cACNrB,KAGjBM,EAEAU,gBAACU,EAAEd,EAAA,CAAA,EACGE,EAAoC,CACxCH,MAAOA,EAAKO,UACDtB,EAAQuB,WACPtB,aACAC,EAASsB,WACTrB,EAASsB,cACNrB,KAInBgB,gBAACM,EAAEV,EAAA,CAAA,EACGE,EAAoC,CACxCH,MAAOA,EAAKO,UACDtB,EAAQuB,WACPtB,aACAC,EAASsB,WACTrB,EAASsB,cACNrB,IAGrB"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/Heading/index.tsx"],"sourcesContent":["import React, { type HTMLAttributes } from \"react\";\n\nimport {\n type SpacingProps,\n type TextProps,\n type ColourProps,\n} from \"../../types\";\n\nexport type HeadingProps = SpacingProps &\n TextProps &\n ColourProps &\n HTMLAttributes<HTMLElement> & {\n h1?: boolean;\n h2?: boolean;\n h3?: boolean;\n h4?: boolean;\n h5?: boolean;\n h6?: boolean;\n as?: \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\" | \"p\" | \"span\" | \"legend\";\n };\n\n/**\n * \n * Use headings consistently to create a clear hierarchy throughout your service.\nMarkup headings semantically using the appropriate <h#> level HTML element and\nuse the corresponding heading class (h1, h2, h3, ....). Write all headings in sentence case. Heading differs from the Text component by using a different font-family and it changes the font size according to the screen width breakpoints.\n * \n */\nexport function Heading({\n textColor,\n backgroundColor,\n textSize,\n textAlign,\n textWeight,\n textFontFamily,\n wordBreak,\n overflowWrap,\n margin,\n marginTop,\n marginRight,\n marginBottom,\n marginLeft,\n marginVertical,\n marginHorizontal,\n padding,\n paddingTop,\n paddingRight,\n paddingBottom,\n paddingLeft,\n paddingVertical,\n paddingHorizontal,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n as,\n ...htmlProps\n}: HeadingProps) {\n const calculatedHTag = h1\n ? \"h1\"\n : h2\n ? \"h2\"\n : h3\n ? \"h3\"\n : h4\n ? \"h4\"\n : h5\n ? \"h5\"\n : h6\n ? \"h6\"\n : \"h2\";\n // as can be explicitly set or inferred from h1-h6 props\n const calculatedAs = as ? as : calculatedHTag;\n\n const convertedProps = {\n \"data-color\": textColor,\n \"data-bg-color\": backgroundColor,\n \"data-text-size\": textSize,\n \"data-text-align\": textAlign,\n \"data-text-weight\": textWeight,\n \"data-text-font-family\": textFontFamily,\n \"data-word-break\": wordBreak,\n \"data-overflow-wrap\": overflowWrap,\n \"data-margin\": margin,\n \"data-margin-top\": marginTop,\n \"data-margin-right\": marginRight,\n \"data-margin-bottom\": marginBottom,\n \"data-margin-left\": marginLeft,\n \"data-margin-vertical\": marginVertical,\n \"data-margin-horizontal\": marginHorizontal,\n \"data-padding\": padding,\n \"data-padding-top\": paddingTop,\n \"data-padding-right\": paddingRight,\n \"data-padding-bottom\": paddingBottom,\n \"data-padding-left\": paddingLeft,\n \"data-padding-vertical\": paddingVertical,\n \"data-padding-horizontal\": paddingHorizontal,\n };\n\n return (\n <>\n {calculatedAs === \"h1\" ? (\n <h1\n className={[\n \"component-heading\",\n \"color-props\",\n \"spacing-props\",\n \"text-props\",\n ].join(\" \")}\n data-appearance={calculatedHTag}\n {...convertedProps}\n {...htmlProps}\n />\n ) : null}\n\n {calculatedAs === \"h2\" ? (\n <h2\n className={[\n \"component-heading\",\n \"color-props\",\n \"spacing-props\",\n \"text-props\",\n ].join(\" \")}\n data-appearance={calculatedHTag}\n {...convertedProps}\n {...htmlProps}\n />\n ) : null}\n\n {calculatedAs === \"h3\" ? (\n <h3\n className={[\n \"component-heading\",\n \"color-props\",\n \"spacing-props\",\n \"text-props\",\n ].join(\" \")}\n data-appearance={calculatedHTag}\n {...convertedProps}\n {...htmlProps}\n />\n ) : null}\n\n {calculatedAs === \"h4\" ? (\n <h4\n className={[\n \"component-heading\",\n \"color-props\",\n \"spacing-props\",\n \"text-props\",\n ].join(\" \")}\n data-appearance={calculatedHTag}\n {...convertedProps}\n {...htmlProps}\n />\n ) : null}\n\n {calculatedAs === \"h5\" ? (\n <h5\n className={[\n \"component-heading\",\n \"color-props\",\n \"spacing-props\",\n \"text-props\",\n ].join(\" \")}\n data-appearance={calculatedHTag}\n {...convertedProps}\n {...htmlProps}\n />\n ) : null}\n\n {calculatedAs === \"h6\" ? (\n <h6\n className={[\n \"component-heading\",\n \"color-props\",\n \"spacing-props\",\n \"text-props\",\n ].join(\" \")}\n data-appearance={calculatedHTag}\n {...convertedProps}\n {...htmlProps}\n />\n ) : null}\n\n {calculatedAs === \"p\" ? (\n <p\n className={[\n \"component-heading\",\n \"color-props\",\n \"spacing-props\",\n \"text-props\",\n ].join(\" \")}\n {...convertedProps}\n {...htmlProps}\n />\n ) : null}\n\n {calculatedAs === \"span\" ? (\n <span\n className={[\n \"component-heading\",\n \"color-props\",\n \"spacing-props\",\n \"text-props\",\n ].join(\" \")}\n {...convertedProps}\n {...htmlProps}\n />\n ) : null}\n {calculatedAs === \"legend\" ? (\n <legend\n className={[\n \"component-heading\",\n \"color-props\",\n \"spacing-props\",\n \"text-props\",\n ].join(\" \")}\n {...convertedProps}\n {...htmlProps}\n />\n ) : null}\n </>\n );\n}\n\nexport default Heading;\n"],"names":["Heading","_a","textColor","backgroundColor","textSize","textAlign","textWeight","textFontFamily","wordBreak","overflowWrap","margin","marginTop","marginRight","marginBottom","marginLeft","marginVertical","marginHorizontal","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingVertical","paddingHorizontal","h1","h2","h3","h4","h5","h6","as","htmlProps","__rest","calculatedHTag","calculatedAs","convertedProps","React","createElement","Fragment","__assign","className","join"],"mappings":"qGA4BM,SAAUA,EAAQC,GACtB,IAAAC,EAASD,EAAAC,UACTC,EAAeF,EAAAE,gBACfC,EAAQH,EAAAG,SACRC,EAASJ,EAAAI,UACTC,EAAUL,EAAAK,WACVC,EAAcN,EAAAM,eACdC,EAASP,EAAAO,UACTC,EAAYR,EAAAQ,aACZC,EAAMT,EAAAS,OACNC,EAASV,EAAAU,UACTC,EAAWX,EAAAW,YACXC,EAAYZ,EAAAY,aACZC,EAAUb,EAAAa,WACVC,EAAcd,EAAAc,eACdC,EAAgBf,EAAAe,iBAChBC,EAAOhB,EAAAgB,QACPC,EAAUjB,EAAAiB,WACVC,EAAYlB,EAAAkB,aACZC,EAAanB,EAAAmB,cACbC,EAAWpB,EAAAoB,YACXC,EAAerB,EAAAqB,gBACfC,EAAiBtB,EAAAsB,kBACjBC,EAAEvB,EAAAuB,GACFC,EAAExB,EAAAwB,GACFC,EAAEzB,EAAAyB,GACFC,EAAE1B,EAAA0B,GACFC,EAAE3B,EAAA2B,GACFC,EAAE5B,EAAA4B,GACFC,EAAE7B,EAAA6B,GACCC,EAASC,EAAA/B,EA9BU,iWAgChBgC,EAAiBT,EACnB,KACAC,EACE,KACAC,EACE,KACAC,EACE,KACAC,EACE,KACAC,EACE,KACA,KAERK,EAAeJ,GAAUG,EAEzBE,EAAiB,CACrB,aAAcjC,EACd,gBAAiBC,EACjB,iBAAkBC,EAClB,kBAAmBC,EACnB,mBAAoBC,EACpB,wBAAyBC,EACzB,kBAAmBC,EACnB,qBAAsBC,EACtB,cAAeC,EACf,kBAAmBC,EACnB,oBAAqBC,EACrB,qBAAsBC,EACtB,mBAAoBC,EACpB,uBAAwBC,EACxB,yBAA0BC,EAC1B,eAAgBC,EAChB,mBAAoBC,EACpB,qBAAsBC,EACtB,sBAAuBC,EACvB,oBAAqBC,EACrB,wBAAyBC,EACzB,0BAA2BC,GAG7B,OACEa,EAAAC,cAAAD,EAAAE,SAAA,KACoB,OAAjBJ,EACCE,EAAAC,cAAA,KAAAE,EAAA,CACEC,UAAW,CACT,oBACA,cACA,gBACA,cACAC,KAAK,uBACUR,GACbE,EACAJ,IAEJ,KAEc,OAAjBG,EACCE,EAAAC,cAAA,KAAAE,EAAA,CACEC,UAAW,CACT,oBACA,cACA,gBACA,cACAC,KAAK,uBACUR,GACbE,EACAJ,IAEJ,KAEc,OAAjBG,EACCE,EAAAC,cAAA,KAAAE,EAAA,CACEC,UAAW,CACT,oBACA,cACA,gBACA,cACAC,KAAK,uBACUR,GACbE,EACAJ,IAEJ,KAEc,OAAjBG,EACCE,EAAAC,cAAA,KAAAE,EAAA,CACEC,UAAW,CACT,oBACA,cACA,gBACA,cACAC,KAAK,uBACUR,GACbE,EACAJ,IAEJ,KAEc,OAAjBG,EACCE,EAAAC,cAAA,KAAAE,EAAA,CACEC,UAAW,CACT,oBACA,cACA,gBACA,cACAC,KAAK,uBACUR,GACbE,EACAJ,IAEJ,KAEc,OAAjBG,EACCE,EAAAC,cAAA,KAAAE,EAAA,CACEC,UAAW,CACT,oBACA,cACA,gBACA,cACAC,KAAK,uBACUR,GACbE,EACAJ,IAEJ,KAEc,MAAjBG,EACCE,EAAAC,cAAA,IAAAE,EAAA,CACEC,UAAW,CACT,oBACA,cACA,gBACA,cACAC,KAAK,MACHN,EACAJ,IAEJ,KAEc,SAAjBG,EACCE,EAAAC,cAAA,OAAAE,EAAA,CACEC,UAAW,CACT,oBACA,cACA,gBACA,cACAC,KAAK,MACHN,EACAJ,IAEJ,KACc,WAAjBG,EACCE,EAAAC,cAAA,SAAAE,EAAA,CACEC,UAAW,CACT,oBACA,cACA,gBACA,cACAC,KAAK,MACHN,EACAJ,IAEJ,KAGV"}
@@ -1,17 +1,17 @@
1
1
  import React from "react";
2
2
  import { type IconDefinition } from "@fortawesome/fontawesome-common-types";
3
- export type IconFaProps = {
4
- /** imported icon definition from "@fortawesome/free-solid-svg-icons" or "@fortawesome/free-brands-svg-icons" */
5
- faIcon: IconDefinition;
6
- /** color of icon, inherits current text colour by default */
7
- color?: string;
8
- /** size of ion 1.1em by default */
9
- size?: string;
10
- };
3
+ import { type spaces, type colours } from "src/types";
11
4
  /**
12
5
  * The IconFa component (Icon Font Awesome) displays an icon glyph as an `<svg>` element.
13
6
  *
14
7
  * This is an svg icon wrapper where a font awesome icon definition can be passed in a long with colour and size
15
8
  * */
16
- export declare function IconFa({ faIcon, color, size }: IconFaProps): React.JSX.Element;
9
+ export declare function IconFa({ faIcon, size, color, }: {
10
+ /** imported icon definition from "@fortawesome/free-solid-svg-icons" or "@fortawesome/free-brands-svg-icons" */
11
+ faIcon: IconDefinition;
12
+ /** size of ion 1.1em by default */
13
+ size?: (typeof spaces)[number] | "full" | string;
14
+ /** color of icon */
15
+ color?: string | (typeof colours)[number];
16
+ }): React.JSX.Element;
17
17
  export default IconFa;
@@ -1,2 +1,2 @@
1
- import{__assign as e}from"../../../node_modules/tslib/tslib.es6.js";import o from"react";import{useTheme as t}from"styled-components";import{crukTheme as r}from"../../themes/cruk.js";import{StyledIcon as m}from"./styles.js";import{themeColorOrString as s,themeSizeOrString as i}from"../../utils/themeUtils.js";function c(c){var n=c.faIcon,l=c.color,a=c.size,p=void 0===a?"1rem":a,f=t(),d=e(e({},r),f),u=n.icon,h=u[0],j=u[1],v=u[4];return o.createElement(m,{theme:d,role:"presentation",viewBox:"0 0 ".concat(h," ").concat(j),$size:i(p,d),$color:s(l,d)},v&&o.createElement("path",{d:v}))}export{c as IconFa,c as default};
1
+ import e from"react";import{themeSpacingSizeOrString as t,themeColorOrString as o}from"../../utils/themeUtils.js";function c(c){var r=c.faIcon,a=c.size,n=c.color,i=r.icon,s=i[0],l=i[1],m=i[4],f=o(n),p=t(a||"xs");return e.createElement("svg",{className:"component-icon-fa",role:"presentation",viewBox:"0 0 ".concat(s," ").concat(l),style:{color:f,height:p,width:p}},m&&e.createElement("path",{d:m}))}export{c as IconFa,c as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/IconFa/index.tsx"],"sourcesContent":["import React from \"react\";\nimport { useTheme } from \"styled-components\";\nimport { type IconDefinition } from \"@fortawesome/fontawesome-common-types\";\nimport { crukTheme as defaultTheme } from \"../../themes/cruk\";\n\nimport { StyledIcon } from \"./styles\";\nimport { themeColorOrString, themeSizeOrString } from \"../../utils/themeUtils\";\n\nexport type IconFaProps = {\n /** imported icon definition from \"@fortawesome/free-solid-svg-icons\" or \"@fortawesome/free-brands-svg-icons\" */\n faIcon: IconDefinition;\n /** color of icon, inherits current text colour by default */\n color?: string;\n /** size of ion 1.1em by default */\n size?: string;\n};\n\n/**\n * The IconFa component (Icon Font Awesome) displays an icon glyph as an `<svg>` element.\n *\n * This is an svg icon wrapper where a font awesome icon definition can be passed in a long with colour and size\n * */\nexport function IconFa({ faIcon, color, size = \"1rem\" }: IconFaProps) {\n const foundTheme = useTheme();\n const theme = {\n ...defaultTheme,\n ...foundTheme,\n };\n const [width, height, , , svgPathData] = faIcon.icon;\n\n return (\n <StyledIcon\n theme={theme}\n role=\"presentation\"\n viewBox={`0 0 ${width} ${height}`}\n $size={themeSizeOrString(size, theme)}\n $color={themeColorOrString(color, theme)}\n >\n {svgPathData && <path d={svgPathData as string} />}\n </StyledIcon>\n );\n}\n\nexport default IconFa;\n"],"names":["IconFa","_a","faIcon","color","_b","size","foundTheme","useTheme","theme","__assign","defaultTheme","_c","icon","width","height","svgPathData","React","createElement","StyledIcon","role","viewBox","concat","$size","themeSizeOrString","$color","themeColorOrString","d"],"mappings":"sTAsBM,SAAUA,EAAOC,OAAEC,EAAMD,EAAAC,OAAEC,EAAKF,EAAAE,MAAEC,SAAAC,OAAI,IAAAD,EAAG,OAAMA,EAC7CE,EAAaC,IACbC,EAAKC,EAAAA,EAAA,CAAA,EACNC,GACAJ,GAECK,EAAmCT,EAAOU,KAAzCC,EAAKF,EAAA,GAAEG,EAAMH,EAAA,GAAMI,OAE1B,OACEC,EAAAC,cAACC,GACCV,MAAOA,EACPW,KAAK,eACLC,QAAS,OAAAC,OAAOR,EAAK,KAAAQ,OAAIP,GAAQQ,MAC1BC,EAAkBlB,EAAMG,GAAMgB,OAC7BC,EAAmBtB,EAAOK,IAEjCO,GAAeC,wBAAMU,EAAGX,IAG/B"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/IconFa/index.tsx"],"sourcesContent":["import React from \"react\";\nimport { type IconDefinition } from \"@fortawesome/fontawesome-common-types\";\n\nimport {\n themeColorOrString,\n themeSpacingSizeOrString,\n} from \"../../utils/themeUtils\";\n\nimport { type spaces, type colours } from \"src/types\";\n\n/**\n * The IconFa component (Icon Font Awesome) displays an icon glyph as an `<svg>` element.\n *\n * This is an svg icon wrapper where a font awesome icon definition can be passed in a long with colour and size\n * */\nexport function IconFa({\n faIcon,\n size,\n color,\n}: {\n /** imported icon definition from \"@fortawesome/free-solid-svg-icons\" or \"@fortawesome/free-brands-svg-icons\" */\n faIcon: IconDefinition;\n /** size of ion 1.1em by default */\n size?: (typeof spaces)[number] | \"full\" | string;\n /** color of icon */\n color?: string | (typeof colours)[number];\n}) {\n const [width, height, , , svgPathData] = faIcon.icon;\n\n const themeColorOrStringValue = themeColorOrString(color);\n const themeSizeValueOrString = themeSpacingSizeOrString(size || \"xs\");\n\n return (\n <svg\n className={\"component-icon-fa\"}\n role=\"presentation\"\n viewBox={`0 0 ${width} ${height}`}\n style={{\n color: themeColorOrStringValue,\n height: themeSizeValueOrString,\n width: themeSizeValueOrString,\n }}\n >\n {svgPathData && <path d={svgPathData as string} />}\n </svg>\n );\n}\n\nexport default IconFa;\n"],"names":["IconFa","_a","faIcon","size","color","_b","icon","width","height","svgPathData","themeColorOrStringValue","themeColorOrString","themeSizeValueOrString","themeSpacingSizeOrString","React","createElement","className","role","viewBox","concat","style","d"],"mappings":"kHAeM,SAAUA,EAAOC,GACrB,IAAAC,WACAC,EAAIF,EAAAE,KACJC,EAAKH,EAAAG,MASCC,EAAmCH,EAAOI,KAAzCC,EAAKF,EAAA,GAAEG,EAAMH,EAAA,GAAMI,OAEpBC,EAA0BC,EAAmBP,GAC7CQ,EAAyBC,EAAyBV,GAAQ,MAEhE,OACEW,EAAAC,cAAA,MAAA,CACEC,UAAW,oBACXC,KAAK,eACLC,QAAS,cAAOX,EAAK,KAAAY,OAAIX,GACzBY,MAAO,CACLhB,MAAOM,EACPF,OAAQI,EACRL,MAAOK,IAGRH,GAAeK,EAAAC,cAAA,OAAA,CAAMM,EAAGZ,IAG/B"}
@@ -1,28 +1,25 @@
1
- import React, { type HTMLAttributes, type Ref, type ReactNode, type ElementType } from "react";
2
- import { type SpacingProps } from "../Spacing";
3
- export type InfoBoxProps = SpacingProps & HTMLAttributes<HTMLElement> & {
1
+ import React, { type HTMLAttributes, type Ref, type ReactNode } from "react";
2
+ import { type ColourVariableType, type SpacingProps } from "../../types";
3
+ /**
4
+ * Box is used to wrap other components to add margin and padding. The values will be in the t-shirt sizes specified in the theme sizes.
5
+
6
+ The more specific the the target the higher priority the css will have. For example `margin` will be overridden by the `marginVertical` or `marginHorizontal` props. `marginTop`, `marginBottom`, `marginLeft`, `marginRight` will override the the `marginVertical` and `marginHorizontal` props.
7
+ */
8
+ export declare const InfoBox: ({ children, titleText, titleTextColor, descriptionText, descriptionTextColor, icon, backgroundColor, ref, ...spacingAndHTMLElementProps }: SpacingProps & HTMLAttributes<HTMLElement> & {
4
9
  /** background color of wrapping element, this will add default padding */
5
- backgroundColor?: string;
10
+ backgroundColor?: ColourVariableType;
6
11
  /** Title text */
7
12
  titleText: string;
8
13
  /** Title text colour */
9
- titleTextColor?: string;
14
+ titleTextColor?: ColourVariableType;
10
15
  /** Description text */
11
16
  descriptionText: string;
12
17
  /** Description text colour */
13
- descriptionTextColor?: string;
18
+ descriptionTextColor?: ColourVariableType;
14
19
  /** Space for extra element underneath description */
15
20
  children?: ReactNode;
16
21
  /** Icon in left column usually 2em squared */
17
22
  icon?: ReactNode;
18
- ref?: Ref<HTMLElement>;
19
- /** styled-component polymorphic feature so you take the styling of a box and cast the component to be a "span" for example */
20
- as?: ElementType;
21
- };
22
- /**
23
- * Box is used to wrap other components to add margin and padding. The values will be in the t-shirt sizes specified in the theme sizes.
24
-
25
- The more specific the the target the higher priority the css will have. For example `margin` will be overridden by the `marginVertical` or `marginHorizontal` props. `marginTop`, `marginBottom`, `marginLeft`, `marginRight` will override the the `marginVertical` and `marginHorizontal` props.
26
- */
27
- export declare const InfoBox: ({ children, titleText, titleTextColor, descriptionText, descriptionTextColor, icon, ref, ...spacingAndHTMLElementProps }: InfoBoxProps) => React.JSX.Element;
23
+ ref?: Ref<HTMLDivElement>;
24
+ }) => React.JSX.Element;
28
25
  export default InfoBox;
@@ -1,2 +1,2 @@
1
- import{__rest as e,__assign as t}from"../../../node_modules/tslib/tslib.es6.js";import o from"react";import{useTheme as r}from"styled-components";import{crukTheme as i}from"../../themes/cruk.js";import{Box as n}from"../Box/index.js";import{Text as m}from"../Text/index.js";import{Heading as l}from"../Heading/index.js";import{StyledInfoBox as s}from"./styles.js";var a=function(a){var c=a.children,x=a.titleText,d=a.titleTextColor,p=a.descriptionText,f=a.descriptionTextColor,g=a.icon,C=a.ref,T=e(a,["children","titleText","titleTextColor","descriptionText","descriptionTextColor","icon","ref"]),u=r(),h=t(t({},i),u),j=T.backgroundColor||h.tokenColors.grey_200;return o.createElement(s,t({theme:h},T,{backgroundColor:j,margin:T.margin||"none",ref:C}),g&&o.createElement(n,{marginRight:"s"},g),o.createElement("div",null,x&&o.createElement(l,{as:"p",margin:"none",h4:!0,marginBottom:"xxs",textColor:d||h.colors.textDark},x),p&&o.createElement(m,{textColor:f||h.colors.textDark,marginBottom:"none"},p),c))};export{a as InfoBox,a as default};
1
+ import{__rest as e,__assign as t}from"../../../node_modules/tslib/tslib.es6.js";import o from"react";import{Box as r}from"../Box/index.js";import{Text as i}from"../Text/index.js";import{Heading as n}from"../Heading/index.js";var l=function(l){var a=l.children,m=l.titleText,c=l.titleTextColor,d=l.descriptionText,s=l.descriptionTextColor,x=l.icon,p=l.backgroundColor,f=l.ref,g=e(l,["children","titleText","titleTextColor","descriptionText","descriptionTextColor","icon","backgroundColor","ref"]);return o.createElement("div",t({className:["component-info-box","spacing-props","color-props"].join(" ")},g,{"data-bg-color":p||"background-mid",ref:f}),x&&o.createElement(r,{marginRight:"s"},x),o.createElement("div",null,m&&o.createElement(n,{as:"p",margin:"none",h4:!0,marginBottom:"xxs",textColor:c||"text-dark"},m),d&&o.createElement(i,{textColor:s||"text-dark",marginBottom:"none"},d),a))};export{l as InfoBox,l as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/InfoBox/index.tsx"],"sourcesContent":["import React, {\n type HTMLAttributes,\n type Ref,\n type ReactNode,\n type ElementType,\n} from \"react\";\nimport { useTheme } from \"styled-components\";\n\nimport { crukTheme as defaultTheme } from \"../../themes/cruk\";\nimport { Box } from \"../Box\";\nimport { Text } from \"../Text\";\nimport { Heading } from \"../Heading\";\n\nimport { type SpacingProps } from \"../Spacing\";\nimport { StyledInfoBox } from \"./styles\";\n\nexport type InfoBoxProps = SpacingProps &\n HTMLAttributes<HTMLElement> & {\n /** background color of wrapping element, this will add default padding */\n backgroundColor?: string;\n /** Title text */\n titleText: string;\n /** Title text colour */\n titleTextColor?: string;\n /** Description text */\n descriptionText: string;\n /** Description text colour */\n descriptionTextColor?: string;\n /** Space for extra element underneath description */\n children?: ReactNode;\n /** Icon in left column usually 2em squared */\n icon?: ReactNode;\n ref?: Ref<HTMLElement>;\n /** styled-component polymorphic feature so you take the styling of a box and cast the component to be a \"span\" for example */\n as?: ElementType;\n };\n\n/**\n * Box is used to wrap other components to add margin and padding. The values will be in the t-shirt sizes specified in the theme sizes.\n \n The more specific the the target the higher priority the css will have. For example `margin` will be overridden by the `marginVertical` or `marginHorizontal` props. `marginTop`, `marginBottom`, `marginLeft`, `marginRight` will override the the `marginVertical` and `marginHorizontal` props.\n */\nexport const InfoBox = ({\n children,\n titleText,\n titleTextColor,\n descriptionText,\n descriptionTextColor,\n icon,\n ref,\n ...spacingAndHTMLElementProps\n}: InfoBoxProps) => {\n const foundTheme = useTheme();\n const theme = {\n ...defaultTheme,\n ...foundTheme,\n };\n\n const backgroundColorOrDefault =\n spacingAndHTMLElementProps.backgroundColor || theme.tokenColors.grey_200;\n\n return (\n <StyledInfoBox\n theme={theme}\n {...spacingAndHTMLElementProps}\n backgroundColor={backgroundColorOrDefault}\n margin={spacingAndHTMLElementProps.margin || \"none\"}\n ref={ref}\n >\n {icon && <Box marginRight=\"s\">{icon}</Box>}\n <div>\n {titleText && (\n <Heading\n as=\"p\"\n margin=\"none\"\n h4\n marginBottom=\"xxs\"\n textColor={titleTextColor || theme.colors.textDark}\n >\n {titleText}\n </Heading>\n )}\n {descriptionText && (\n <Text\n textColor={descriptionTextColor || theme.colors.textDark}\n marginBottom=\"none\"\n >\n {descriptionText}\n </Text>\n )}\n {children}\n </div>\n </StyledInfoBox>\n );\n};\n\nexport default InfoBox;\n"],"names":["InfoBox","_a","children","titleText","titleTextColor","descriptionText","descriptionTextColor","icon","ref","spacingAndHTMLElementProps","__rest","foundTheme","useTheme","theme","__assign","defaultTheme","backgroundColorOrDefault","backgroundColor","tokenColors","grey_200","React","createElement","StyledInfoBox","margin","Box","marginRight","Heading","as","h4","marginBottom","textColor","colors","textDark","Text"],"mappings":"2WA0CO,IAAMA,EAAU,SAACC,GACtB,IAAAC,EAAQD,EAAAC,SACRC,EAASF,EAAAE,UACTC,EAAcH,EAAAG,eACdC,EAAeJ,EAAAI,gBACfC,EAAoBL,EAAAK,qBACpBC,EAAIN,EAAAM,KACJC,QACGC,EAA0BC,EAAAT,EARP,CAAA,WAAA,YAAA,iBAAA,kBAAA,uBAAA,OAAA,QAUhBU,EAAaC,IACbC,EAAKC,EAAAA,EAAA,CAAA,EACNC,GACAJ,GAGCK,EACJP,EAA2BQ,iBAAmBJ,EAAMK,YAAYC,SAElE,OACEC,EAAAC,cAACC,EAAaR,EAAA,CACZD,MAAOA,GACHJ,EAA0B,CAC9BQ,gBAAiBD,EACjBO,OAAQd,EAA2Bc,QAAU,OAC7Cf,IAAKA,IAEJD,GAAQa,gBAACI,EAAG,CAACC,YAAY,KAAKlB,GAC/Ba,EAAAC,cAAA,MAAA,KACGlB,GACCiB,EAAAC,cAACK,EAAO,CACNC,GAAG,IACHJ,OAAO,OACPK,IAAE,EACFC,aAAa,MACbC,UAAW1B,GAAkBS,EAAMkB,OAAOC,UAEzC7B,GAGJE,GACCe,EAAAC,cAACY,GACCH,UAAWxB,GAAwBO,EAAMkB,OAAOC,SAChDH,aAAa,QAEZxB,GAGJH,GAIT"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/InfoBox/index.tsx"],"sourcesContent":["import React, { type HTMLAttributes, type Ref, type ReactNode } from \"react\";\n\nimport { Box } from \"../Box\";\nimport { Text } from \"../Text\";\nimport { Heading } from \"../Heading\";\n\nimport { type ColourVariableType, type SpacingProps } from \"../../types\";\n\n/**\n * Box is used to wrap other components to add margin and padding. The values will be in the t-shirt sizes specified in the theme sizes.\n \n The more specific the the target the higher priority the css will have. For example `margin` will be overridden by the `marginVertical` or `marginHorizontal` props. `marginTop`, `marginBottom`, `marginLeft`, `marginRight` will override the the `marginVertical` and `marginHorizontal` props.\n */\nexport const InfoBox = ({\n children,\n titleText,\n titleTextColor,\n descriptionText,\n descriptionTextColor,\n icon,\n backgroundColor,\n ref,\n ...spacingAndHTMLElementProps\n}: SpacingProps &\n HTMLAttributes<HTMLElement> & {\n /** background color of wrapping element, this will add default padding */\n backgroundColor?: ColourVariableType;\n /** Title text */\n titleText: string;\n /** Title text colour */\n titleTextColor?: ColourVariableType;\n /** Description text */\n descriptionText: string;\n /** Description text colour */\n descriptionTextColor?: ColourVariableType;\n /** Space for extra element underneath description */\n children?: ReactNode;\n /** Icon in left column usually 2em squared */\n icon?: ReactNode;\n ref?: Ref<HTMLDivElement>;\n }) => {\n return (\n <div\n className={[\"component-info-box\", \"spacing-props\", \"color-props\"].join(\n \" \",\n )}\n {...spacingAndHTMLElementProps}\n data-bg-color={backgroundColor || \"background-mid\"}\n ref={ref}\n >\n {icon && <Box marginRight=\"s\">{icon}</Box>}\n <div>\n {titleText && (\n <Heading\n as=\"p\"\n margin=\"none\"\n h4\n marginBottom=\"xxs\"\n textColor={titleTextColor || \"text-dark\"}\n >\n {titleText}\n </Heading>\n )}\n {descriptionText && (\n <Text\n textColor={descriptionTextColor || \"text-dark\"}\n marginBottom=\"none\"\n >\n {descriptionText}\n </Text>\n )}\n {children}\n </div>\n </div>\n );\n};\n\nexport default InfoBox;\n"],"names":["InfoBox","_a","children","titleText","titleTextColor","descriptionText","descriptionTextColor","icon","backgroundColor","ref","spacingAndHTMLElementProps","__rest","React","createElement","__assign","className","join","Box","marginRight","Heading","as","margin","h4","marginBottom","textColor","Text"],"mappings":"iOAaO,IAAMA,EAAU,SAACC,GACtB,IAAAC,EAAQD,EAAAC,SACRC,EAASF,EAAAE,UACTC,EAAcH,EAAAG,eACdC,EAAeJ,EAAAI,gBACfC,EAAoBL,EAAAK,qBACpBC,EAAIN,EAAAM,KACJC,EAAeP,EAAAO,gBACfC,EAAGR,EAAAQ,IACAC,EAA0BC,EAAAV,EATP,CAAA,WAAA,YAAA,iBAAA,kBAAA,uBAAA,OAAA,kBAAA,QA4BtB,OACEW,EAAAC,cAAA,MAAAC,EAAA,CACEC,UAAW,CAAC,qBAAsB,gBAAiB,eAAeC,KAChE,MAEEN,EAA0B,CAAA,gBACfF,GAAmB,iBAClCC,IAAKA,IAEJF,GAAQK,gBAACK,EAAG,CAACC,YAAY,KAAKX,GAC/BK,EAAAC,cAAA,MAAA,KACGV,GACCS,EAAAC,cAACM,EAAO,CACNC,GAAG,IACHC,OAAO,OACPC,IAAE,EACFC,aAAa,MACbC,UAAWpB,GAAkB,aAE5BD,GAGJE,GACCO,EAAAC,cAACY,EAAI,CACHD,UAAWlB,GAAwB,YACnCiB,aAAa,QAEZlB,GAGJH,GAIT"}
@@ -1,2 +1,2 @@
1
- import{__rest as e,__assign as t}from"../../../node_modules/tslib/tslib.es6.js";import r from"react";import{useTheme as n,ThemeProvider as l}from"styled-components";import{crukTheme as i}from"../../themes/cruk.js";import{HintText as o,Label as m,LabelText as a,RequiredIndicationText as d}from"./styles.js";function s(s){var c=s.label,u=s.hintText,h=s.required,p=void 0!==h&&h,f=s.hideRequiredIndicationInLabel,b=void 0!==f&&f,E=s.children,q=e(s,["label","hintText","required","hideRequiredIndicationInLabel","children"]),x=n(),y=t(t({},i),x),I=u&&("string"==typeof u&&u.length||"number"==typeof u)?r.createElement(o,null,u):u;return r.createElement(l,{theme:y},c?r.createElement(m,t({},q),r.createElement(a,{$hasHintText:!!u},c,!p&&!b&&r.createElement(d,null," (optional)")),I,E):r.createElement(r.Fragment,null,E))}export{s as LabelWrapper,s as default};
1
+ import{__rest as e,__assign as t}from"../../../node_modules/tslib/tslib.es6.js";import n from"react";function a(a){var l=a.label,i=a.hintText,r=a.required,m=void 0!==r&&r,o=a.hideRequiredIndicationInLabel,c=void 0!==o&&o,d=a.children,s=e(a,["label","hintText","required","hideRequiredIndicationInLabel","children"]),u=i&&("string"==typeof i&&i.length||"number"==typeof i)?n.createElement("span",{className:"hint-text"},i):i;return n.createElement(n.Fragment,null,l?n.createElement("label",t({className:"label-component"},s),n.createElement("span",{className:"label-text","data-hintext":!!i},l,!m&&!c&&n.createElement("span",{className:"required-indication-text"}," (optional)")),u,d):n.createElement(n.Fragment,null,d))}export{a as LabelWrapper,a as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/LabelWrapper/index.tsx"],"sourcesContent":["import React, { type LabelHTMLAttributes, type ReactNode } from \"react\";\nimport { useTheme, ThemeProvider } from \"styled-components\";\n\nimport { crukTheme as defaultTheme } from \"../../themes/cruk\";\n\nimport { LabelText, Label, RequiredIndicationText, HintText } from \"./styles\";\n\ntype LabelWrapperProps = LabelHTMLAttributes<HTMLLabelElement> & {\n /** label text */\n label: string;\n /** hint text or react element in it's place */\n hintText?: ReactNode;\n /** if field is required, when not required (optional) appears in label */\n required?: boolean;\n /** flag to stop (optional) appearing in label, useful for compound form components like DateInput */\n hideRequiredIndicationInLabel?: boolean;\n children?: ReactNode;\n};\n\nexport function LabelWrapper({\n label,\n hintText,\n required = false,\n hideRequiredIndicationInLabel = false,\n children,\n ...otherHTMLLabelProps\n}: LabelWrapperProps) {\n const foundTheme = useTheme();\n const theme = {\n ...defaultTheme,\n ...foundTheme,\n };\n\n const hintTextElement =\n !!hintText &&\n ((typeof hintText === \"string\" && hintText.length) ||\n typeof hintText === \"number\") ? (\n <HintText>{hintText}</HintText>\n ) : (\n hintText\n );\n\n return (\n <ThemeProvider theme={theme}>\n {label ? (\n <Label {...otherHTMLLabelProps}>\n <LabelText $hasHintText={!!hintText}>\n {label}\n {!required && !hideRequiredIndicationInLabel && (\n <RequiredIndicationText>{` (optional)`}</RequiredIndicationText>\n )}\n </LabelText>\n {hintTextElement}\n {children}\n </Label>\n ) : (\n <>{children}</>\n )}\n </ThemeProvider>\n );\n}\n\nexport default LabelWrapper;\n"],"names":["LabelWrapper","_a","label","hintText","_b","required","_c","hideRequiredIndicationInLabel","children","otherHTMLLabelProps","__rest","foundTheme","useTheme","theme","__assign","defaultTheme","hintTextElement","length","React","createElement","HintText","ThemeProvider","Label","LabelText","$hasHintText","RequiredIndicationText","Fragment"],"mappings":"mTAmBM,SAAUA,EAAaC,GAC3B,IAAAC,EAAKD,EAAAC,MACLC,EAAQF,EAAAE,SACRC,EAAAH,EAAAI,SAAAA,OAAQ,IAAAD,GAAQA,EAChBE,kCAAAC,OAA6B,IAAAD,GAAQA,EACrCE,EAAQP,EAAAO,SACLC,EAAmBC,EAAAT,EANK,CAAA,QAAA,WAAA,WAAA,gCAAA,aAQrBU,EAAaC,IACbC,EAAKC,EAAAA,EAAA,CAAA,EACNC,GACAJ,GAGCK,EACFb,IACoB,iBAAbA,GAAyBA,EAASc,QACrB,iBAAbd,GACPe,EAAAC,cAACC,OAAUjB,GAAoB,EAKnC,OACEe,EAAAC,cAACE,EAAa,CAACR,MAAOA,GACnBX,EACCgB,EAAAC,cAACG,OAAUb,GACTS,EAAAC,cAACI,EAAS,CAAAC,eAAiBrB,GACxBD,GACCG,IAAaE,GACbW,EAAAC,cAACM,EAAsB,KAAE,gBAG5BT,EACAR,GAGHU,EAAAC,cAAAD,EAAAQ,SAAA,KAAGlB,GAIX"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/LabelWrapper/index.tsx"],"sourcesContent":["import React, { type LabelHTMLAttributes, type ReactNode } from \"react\";\n\ntype LabelWrapperProps = LabelHTMLAttributes<HTMLLabelElement> & {\n /** label text */\n label: string;\n /** hint text or react element in it's place */\n hintText?: ReactNode;\n /** if field is required, when not required (optional) appears in label */\n required?: boolean;\n /** flag to stop (optional) appearing in label, useful for compound form components like DateInput */\n hideRequiredIndicationInLabel?: boolean;\n children?: ReactNode;\n};\n\nexport function LabelWrapper({\n label,\n hintText,\n required = false,\n hideRequiredIndicationInLabel = false,\n children,\n ...otherHTMLLabelProps\n}: LabelWrapperProps) {\n const hintTextElement =\n !!hintText &&\n ((typeof hintText === \"string\" && hintText.length) ||\n typeof hintText === \"number\") ? (\n <span className=\"hint-text\">{hintText}</span>\n ) : (\n hintText\n );\n\n return (\n <>\n {label ? (\n <label className=\"label-component\" {...otherHTMLLabelProps}>\n <span className=\"label-text\" data-hintext={!!hintText}>\n {label}\n {!required && !hideRequiredIndicationInLabel && (\n <span className=\"required-indication-text\">{` (optional)`}</span>\n )}\n </span>\n {hintTextElement}\n {children}\n </label>\n ) : (\n <>{children}</>\n )}\n </>\n );\n}\n\nexport default LabelWrapper;\n"],"names":["LabelWrapper","_a","label","hintText","_b","required","_c","hideRequiredIndicationInLabel","children","otherHTMLLabelProps","__rest","hintTextElement","length","React","createElement","className","Fragment","__assign"],"mappings":"qGAcM,SAAUA,EAAaC,GAC3B,IAAAC,EAAKD,EAAAC,MACLC,EAAQF,EAAAE,SACRC,EAAAH,EAAAI,SAAAA,OAAQ,IAAAD,GAAQA,EAChBE,kCAAAC,OAA6B,IAAAD,GAAQA,EACrCE,EAAQP,EAAAO,SACLC,EAAmBC,EAAAT,EANK,CAAA,QAAA,WAAA,WAAA,gCAAA,aAQrBU,EACFR,IACoB,iBAAbA,GAAyBA,EAASS,QACrB,iBAAbT,GACPU,EAAAC,cAAA,OAAA,CAAMC,UAAU,aAAaZ,GAAgB,EAKjD,OACEU,EAAAC,cAAAD,EAAAG,SAAA,KACGd,EACCW,EAAAC,cAAA,QAAAG,EAAA,CAAOF,UAAU,mBAAsBN,GACrCI,EAAAC,cAAA,OAAA,CAAMC,UAAU,aAAY,iBAAiBZ,GAC1CD,GACCG,IAAaE,GACbM,EAAAC,cAAA,OAAA,CAAMC,UAAU,4BAA4B,gBAG/CJ,EACAH,GAGHK,EAAAC,cAAAD,EAAAG,SAAA,KAAGR,GAIX"}
@@ -1,2 +1,2 @@
1
- import{__rest as e,__assign as r}from"../../../node_modules/tslib/tslib.es6.js";import t from"react";import{useTheme as n,ThemeProvider as o}from"styled-components";import{crukTheme as s}from"../../themes/cruk.js";import{ErrorText as m}from"../ErrorText/index.js";import{HintText as l,StyledFieldset as a,LegendSpan as i}from"./styles.js";function c(c){var p=c.children,d=c.legendText,h=c.required,x=c.errorMessage,E=c.hasError,f=c.hintText,u=e(c,["children","legendText","required","errorMessage","hasError","hintText"]),T=n(),g=r(r({},s),T),j=!f||"string"!=typeof f&&"number"!=typeof f?f:t.createElement(l,null,f);return t.createElement(o,{theme:g},t.createElement(a,{$hasError:E||!!x||!1,$hasHintText:!!f},d&&t.createElement("legend",r({},u),t.createElement(i,{$hasHintText:!!f},d," ",!h&&t.createElement("span",null,"(optional)")),j),p,!!x&&t.createElement(m,{marginTop:"xxs"},x)))}export{c as LegendWrapper,c as default};
1
+ import{__rest as e,__assign as t}from"../../../node_modules/tslib/tslib.es6.js";import r from"react";import{ErrorText as a}from"../ErrorText/index.js";function n(n){var s=n.children,i=n.legendText,o=n.required,l=n.errorMessage,m=n.hasError,d=n.hintText,c=e(n,["children","legendText","required","errorMessage","hasError","hintText"]);return r.createElement("fieldset",{className:"component-legend-wrapper","data-has-error":m||!!l||!1,"data-has-hint-text":!!d},i&&r.createElement("legend",t({},c),r.createElement("span",{className:"legend-span","data-has-hint-text":!!d},i," ",!o&&r.createElement("span",{className:"required-indication-text"},"(optional)")),!d||"string"!=typeof d&&"number"!=typeof d?d:r.createElement("span",{className:"hint-text"},d)),s,!!l&&r.createElement(a,{marginTop:"xxs"},l))}export{n as LegendWrapper,n as default};
2
2
  //# sourceMappingURL=index.js.map