@cruk/cruk-react-components 3.1.0 → 3.1.1

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.
@@ -27,6 +27,8 @@ declare const _default: {
27
27
  isValid: boolean;
28
28
  isValidVisible: boolean;
29
29
  isInvalidVisible: boolean;
30
+ apiKey: string;
31
+ onAddressSelected: (address: unknown) => void;
30
32
  };
31
33
  tags: string[];
32
34
  };
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StoryObj } from "@storybook/react";
3
2
  import Badge, { BadgeProps } from ".";
4
3
  declare const _default: {
@@ -13,7 +13,7 @@ declare const _default: {
13
13
  isIconButton?: boolean | undefined;
14
14
  ref?: React.Ref<HTMLElement> | undefined;
15
15
  children?: React.ReactNode;
16
- }, "as" | "size" | "css" | keyof React.ButtonHTMLAttributes<HTMLElement> | "appearance" | "full" | "href" | "isIconButton"> & React.RefAttributes<HTMLElement>>;
16
+ }, "css" | "as" | "size" | keyof React.ButtonHTMLAttributes<HTMLElement> | "appearance" | "full" | "href" | "isIconButton"> & React.RefAttributes<HTMLElement>>;
17
17
  args: {
18
18
  appearance: string;
19
19
  disabled: boolean;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StoryObj } from "@storybook/react";
3
2
  import Collapse, { CollapseProps } from ".";
4
3
  declare const _default: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StoryObj } from "@storybook/react";
3
2
  import DateField, { DateFieldProps } from ".";
4
3
  declare const _default: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StoryObj } from "@storybook/react";
3
2
  import Footer, { FooterProps } from ".";
4
3
  declare const _default: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StoryObj } from "@storybook/react";
3
2
  import Header, { HeaderProps } from ".";
4
3
  declare const _default: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StoryObj } from "@storybook/react";
3
2
  import Heading, { HeadingProps } from ".";
4
3
  declare const _default: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StoryObj } from "@storybook/react";
3
2
  import Icon, { IconProps } from ".";
4
3
  declare const _default: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StoryObj } from "@storybook/react";
3
2
  import { IconFa } from "..";
4
3
  import { IconFaProps } from ".";
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StoryObj } from "@storybook/react";
3
2
  import LegendWrapper, { LegendWrapperProps } from ".";
4
3
  declare const _default: {
@@ -9,7 +9,7 @@ declare const _default: {
9
9
  ref?: React.Ref<HTMLElement> | undefined;
10
10
  as?: React.ElementType | undefined;
11
11
  children?: React.ReactNode;
12
- }, "children" | "slot" | "style" | "title" | "hidden" | "tabIndex" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "textSize" | "textAlign" | "textColor" | "as" | "wordBreak" | "overflowWrap" | "type" | "referrerPolicy" | keyof import("../Spacing").SpacingProps | "appearance" | "href" | "download" | "hrefLang" | "media" | "ping" | "rel" | "target" | "textWeight" | "textHoverColor"> & React.RefAttributes<HTMLElement>>;
12
+ }, "slot" | "style" | "title" | "type" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | keyof import("../Spacing").SpacingProps | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "as" | "textSize" | "textAlign" | "textColor" | "wordBreak" | "overflowWrap" | "referrerPolicy" | "appearance" | "href" | "download" | "hrefLang" | "media" | "ping" | "rel" | "target" | "textWeight" | "textHoverColor"> & React.RefAttributes<HTMLElement>>;
13
13
  args: {
14
14
  appearance: undefined;
15
15
  href: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StoryObj } from "@storybook/react";
3
2
  import Loader from ".";
4
3
  declare const _default: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StoryObj } from "@storybook/react";
3
2
  import Modal, { ModalProps } from ".";
4
3
  declare const _default: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StoryObj } from "@storybook/react";
3
2
  import Pagination, { PaginationProps } from ".";
4
3
  declare const _default: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StoryObj } from "@storybook/react";
3
2
  import PopOver, { PopOverProps } from ".";
4
3
  declare const _default: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StoryObj } from "@storybook/react";
3
2
  import ProgressBar, { ProgressBarProps } from ".";
4
3
  declare const _default: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StoryObj } from "@storybook/react";
3
2
  import Totaliser, { TotaliserProps } from ".";
4
3
  declare const _default: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StoryObj } from "@storybook/react";
3
2
  import UserBlock, { UserBlockProps } from ".";
4
3
  declare const _default: {
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  declare const Docs: () => JSX.Element;
3
2
  export default Docs;
@@ -1,2 +1,2 @@
1
- import{__rest as e,__assign as t}from"../../../_virtual/_tslib.js";import n,{forwardRef as r,useState as o,useRef as s,useCallback as a,useEffect as i}from"react";import{useTheme as l}from"styled-components";import{faChevronRight as c}from"../../../node_modules/@fortawesome/free-solid-svg-icons/index.mjs.js";import{useKey as d}from"../../hooks/useKey.js";import u from"../../utils/debounce.js";import{removeCommasFromObjectStringValues as m}from"../../utils/Helper.js";import{Text as f}from"../Text/index.js";import p from"../TextField/index.js";import h from"../IconFa/index.js";import g from"../../themes/cruk.js";import{ScreenReaderOnly as v,ListWrapper as y,List as E,ListItem as w}from"./styles.js";var b=r((function(r,b){var j=r.apiKey,x=r.countries,I=r.errorMessage,T=r.hasError,V=r.isValid,k=r.isValidVisible,A=r.isInvalidVisible,C=r.label,K=r.hintText,D=r.onAddressError,F=void 0===D?function(e){}:D,S=r.onAddressSelected,_=r.onChange,M=r.onBlur,B=e(r,["apiKey","countries","errorMessage","hasError","isValid","isValidVisible","isInvalidVisible","label","hintText","onAddressError","onAddressSelected","onChange","onBlur"]),H=o([]),L=H[0],O=H[1],U=o(-1),q=U[0],R=U[1],W=s(null),z=l(),G=t(t({},g),z),J=function(){R(-1),O([])},N=a(u(500,(function(e){return P(e)})),[]),P=function(e,t){if(void 0===t&&(t=""),0===e.length)return O([]);var n="".concat("https://api.addressy.com/Capture/Interactive/Find/v1.1/json3.ws","?Key=").concat(j,"&Text=").concat(e,"&Container=").concat(t);return void 0!==x&&(n="".concat(n,"&Countries=").concat(x.join(","))),fetch(n).then((function(e){if(!e.ok)throw new Error("Something went wrong please try again");return e.json()})).then((function(e){if(e.Items[0].Error)throw new Error("Something went wrong please try again");return O(e.Items||[]),null})).catch((function(e){return F(e)})),null},Q=function(e){fetch("".concat("https://api.addressy.com/Capture/Interactive/Retrieve/v1/json3.ws","?Key=").concat(j,"&Id=").concat(e)).then((function(e){if(!e.ok)throw new Error("Something went wrong please try again");return e.json()})).then((function(e){J();var t=e.Items[0],n=m(t);return S(n),null})).catch((function(e){return F(e)}))},X=function(e){return"Address"===e.Type?Q(e.Id):(P(e.Text,e.Id),null)},Y=function(e){W.current&&e.target instanceof HTMLElement&&!W.current.contains(e.target)&&J()};return i((function(){return document.addEventListener("mousedown",Y),function(){document.removeEventListener("mousedown",Y)}})),d((function(){J()}),{detectKeys:["Escape","Tab"]},[]),n.createElement(n.Fragment,null,n.createElement(p,t({"aria-activedescendant":L.length?"addressOptions-".concat(q):"","aria-owns":"found_addresses","aria-autocomplete":"both","aria-expanded":L.length?"true":"false",autoComplete:"off",hasError:T||!!I,errorMessage:I,hintText:null!=K?K:"Start typing your address or postcode",isValid:V,isValidVisible:k,isInvalidVisible:A,label:null!=C?C:"Home address",ref:b,required:!0,role:"combobox",type:"search"},B,{onKeyDown:function(e){"Enter"===e.key&&L[q]?(e.preventDefault(),"Address"===L[q].Type&&Q(L[q].Id),P(L[q].Text,L[q].Id),R(-1)):"ArrowUp"===e.key?(e.preventDefault(),q<=-1&&R(L.length-1),R(q-1)):"ArrowDown"===e.key?(e.preventDefault(),q+1>=L.length&&R(0),R(q+1)):R(-1)},onChange:function(e){N(e.target.value),_&&_(e)},onBlur:function(e){var t=!!L.length;M&&!t&&M(e)}})),!!L.length&&n.createElement(n.Fragment,null,n.createElement(v,{role:"status","aria-live":"assertive"},!!L.length&&"We have found ".concat(L.length," result").concat(1!==L.length?"s":""," matching your search. Use up and down arrow keys to navigate")),n.createElement(y,{ref:W},n.createElement(E,{"aria-label":"found addresses",id:"found_addresses",role:"listbox",theme:G},L.map((function(e,t){return n.createElement(w,{tabIndex:0,id:"addressOptions-".concat(t),isActive:t===q,key:e.Id,onClick:function(){X(e)},onKeyDown:function(t){"Enter"===t.key&&X(e)},role:"option","data-hj-suppress":!0,theme:G},n.createElement(f,{as:"span","data-hj-suppress":!0},e.Text," ",e.Description),"Address"!==e.Type&&n.createElement(n.Fragment,null,n.createElement(v,null,"press enter for these addresses"),n.createElement(h,{faIcon:c})))}))))))}));export{b as default};
1
+ import{__rest as e,__assign as t}from"../../../_virtual/_tslib.js";import n,{forwardRef as r,useState as o,useRef as s,useCallback as a,useEffect as i}from"react";import{useTheme as l}from"styled-components";import{faChevronRight as c}from"../../../node_modules/@fortawesome/free-solid-svg-icons/index.mjs.js";import{useKey as d}from"../../hooks/useKey.js";import u from"../../utils/debounce.js";import{removeCommasFromObjectStringValues as m}from"../../utils/Helper.js";import{Text as f}from"../Text/index.js";import p from"../TextField/index.js";import h from"../IconFa/index.js";import g from"../../themes/cruk.js";import{ScreenReaderOnly as v,ListWrapper as y,List as E,ListItem as w}from"./styles.js";var b=r((function(r,b){var j=r.apiKey,x=r.countries,I=r.errorMessage,T=r.hasError,V=r.isValid,k=r.isValidVisible,A=r.isInvalidVisible,C=r.label,K=r.hintText,D=r.onAddressError,F=void 0===D?function(e){}:D,S=r.onAddressSelected,_=r.onChange,M=r.onBlur,B=e(r,["apiKey","countries","errorMessage","hasError","isValid","isValidVisible","isInvalidVisible","label","hintText","onAddressError","onAddressSelected","onChange","onBlur"]),H=o([]),L=H[0],O=H[1],U=o(-1),q=U[0],R=U[1],W=s(null),z=l(),G=t(t({},g),z),J=function(){R(-1),O([])},N=a(u(500,(function(e){return P(e)})),[]),P=function(e,t){if(void 0===t&&(t=""),0===e.length)return O([]);var n="".concat("https://api.addressy.com/Capture/Interactive/Find/v1.1/json3.ws","?Key=").concat(j,"&Text=").concat(e,"&Container=").concat(t);return void 0!==x&&(n="".concat(n,"&Countries=").concat(x.join(","))),fetch(n).then((function(e){if(!e.ok)throw new Error("Something went wrong please try again");return e.json()})).then((function(e){if(e.Items[0].Error)throw new Error("Something went wrong please try again");return O(e.Items||[]),null})).catch((function(e){return F(e)})),null},Q=function(e){fetch("".concat("https://api.addressy.com/Capture/Interactive/Retrieve/v1/json3.ws","?Key=").concat(j,"&Id=").concat(e)).then((function(e){if(!e.ok)throw new Error("Something went wrong please try again");return e.json()})).then((function(e){var t=e.Items[0],n=m(t);return S(n),J(),null})).catch((function(e){return F(e)}))},X=function(e){return"Address"===e.Type?Q(e.Id):(P(e.Text,e.Id),null)},Y=function(e){W.current&&e.target instanceof HTMLElement&&!W.current.contains(e.target)&&J()};return i((function(){return document.addEventListener("mousedown",Y),function(){document.removeEventListener("mousedown",Y)}})),d((function(){J()}),{detectKeys:["Escape","Tab"]},[]),n.createElement(n.Fragment,null,n.createElement(p,t({"aria-activedescendant":L.length?"addressOptions-".concat(q):"","aria-owns":"found_addresses","aria-autocomplete":"both","aria-expanded":L.length?"true":"false",autoComplete:"off",hasError:T||!!I,errorMessage:I,hintText:null!=K?K:"Start typing your address or postcode",isValid:V,isValidVisible:k,isInvalidVisible:A,label:null!=C?C:"Home address",ref:b,required:!0,role:"combobox",type:"search"},B,{onKeyDown:function(e){"Enter"===e.key&&L[q]?(e.preventDefault(),"Address"===L[q].Type&&Q(L[q].Id),P(L[q].Text,L[q].Id),R(-1)):"ArrowUp"===e.key?(e.preventDefault(),q<=-1&&R(L.length-1),R(q-1)):"ArrowDown"===e.key?(e.preventDefault(),q+1>=L.length&&R(0),R(q+1)):R(-1)},onChange:function(e){N(e.target.value),_&&_(e)},onBlur:function(e){var t=!!L.length;M&&!t&&M(e)}})),!!L.length&&n.createElement(n.Fragment,null,n.createElement(v,{role:"status","aria-live":"assertive"},!!L.length&&"We have found ".concat(L.length," result").concat(1!==L.length?"s":""," matching your search. Use up and down arrow keys to navigate")),n.createElement(y,{ref:W},n.createElement(E,{"aria-label":"found addresses",id:"found_addresses",role:"listbox",theme:G},L.map((function(e,t){return n.createElement(w,{tabIndex:0,id:"addressOptions-".concat(t),isActive:t===q,key:e.Id,onClick:function(){X(e)},onKeyDown:function(t){"Enter"===t.key&&X(e)},role:"option","data-hj-suppress":!0,theme:G},n.createElement(f,{as:"span","data-hj-suppress":!0},e.Text," ",e.Description),"Address"!==e.Type&&n.createElement(n.Fragment,null,n.createElement(v,null,"press enter for these addresses"),n.createElement(h,{faIcon:c})))}))))))}));export{b as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import{__assign as r}from"../../_virtual/_tslib.js";var t="undefined"!=typeof window,e=function(r,t){var e=r/t*100;return e===Number.POSITIVE_INFINITY||Number.isNaN(e)?0:Math.floor(e<1?Math.ceil(e):Math.floor(e))},n=function(r){if(!r)return"";var t=r.toString().split(".");return"".concat(t[0].replace(/\B(?=(\d{3})+(?!\d))/g,",")).concat(t[1]?".".concat(t[1]):"")},o=function(r){var t=Number.parseFloat((Math.round(100*r)/100).toString()).toFixed(2);return Number.isNaN(parseFloat(t))||Number.isNaN(r)?"0":n(t)},a=function(t){return Object.entries(t).reduce((function(t,e){var n,o=e[0],a=e[1].replace(/,/g,"");return r(r({},t),((n={})[o]=a,n))}),{})};export{e as calculatePercentRounded,o as formatMoneyWithCommas,t as isBrowser,n as numberWithCommas,a as removeCommasFromObjectStringValues};
1
+ import{__assign as r}from"../../_virtual/_tslib.js";var t="undefined"!=typeof window,e=function(r,t){var e=r/t*100;return e===Number.POSITIVE_INFINITY||Number.isNaN(e)?0:Math.floor(e<1?Math.ceil(e):Math.floor(e))},n=function(r){if(!r)return"";var t=r.toString().split(".");return"".concat(t[0].replace(/\B(?=(\d{3})+(?!\d))/g,",")).concat(t[1]?".".concat(t[1]):"")},o=function(r){var t=Number.parseFloat((Math.round(100*r)/100).toString()).toFixed(2);return Number.isNaN(parseFloat(t))||Number.isNaN(r)?"0":n(t)},a=function(t){return Object.entries(t).reduce((function(t,e){var n,o=e[0],a=e[1],i="string"==typeof a?a.replace(/,/g,""):a;return r(r({},t),((n={})[o]=i,n))}),{})};export{e as calculatePercentRounded,o as formatMoneyWithCommas,t as isBrowser,n as numberWithCommas,a as removeCommasFromObjectStringValues};
2
2
  //# sourceMappingURL=Helper.js.map
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ReactNode } from "@mdx-js/react/lib";
3
2
  type MdxProviderProps = {
4
3
  children?: ReactNode;
@@ -4,4 +4,4 @@ export declare const formatMoney: (value: number) => string;
4
4
  export declare const numberWithCommas: (n?: number | string) => string;
5
5
  export declare const formatMoneyWithCommas: (value: number) => string;
6
6
  export declare const camelize: (str: string) => string;
7
- export declare const removeCommasFromObjectStringValues: <T>(object: T extends Record<string, string> ? T : never) => T;
7
+ export declare const removeCommasFromObjectStringValues: <T>(object: T) => T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cruk/cruk-react-components",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "React components implementing CRUK, SU2C & Bowelbabe designs",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {