@transferwise/components 0.0.0-experimental-5540836 → 0.0.0-experimental-6db0914

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.
@@ -71,7 +71,7 @@ function Alert({
71
71
  }) {
72
72
  React.useEffect(() => {
73
73
  if (arrow !== undefined) {
74
- logActionRequired.logActionRequired("Alert component doesn't support 'arrow' anymore, use 'InlinePrompt' instead.");
74
+ logActionRequired.logActionRequired("Alert component doesn't support 'arrow' anymore, use 'InlineAlert' instead.");
75
75
  }
76
76
  }, [arrow]);
77
77
  React.useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.js","sources":["../../src/alert/Alert.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useState, useRef, useEffect } from 'react';\n\nimport Body from '../body/Body';\nimport {\n CloseButton,\n Sentiment,\n Size,\n Status,\n Typography,\n WDS_LIVE_REGION_DELAY_MS,\n} from '../common';\n\nimport StatusIcon from '../statusIcon';\nimport Title from '../title/Title';\nimport { logActionRequired } from '../utilities';\n\nimport InlineMarkdown from './inlineMarkdown';\nimport Button from '../button';\nimport Link from '../link';\n\nexport type AlertAction = {\n 'aria-label'?: string;\n href?: string;\n target?: string;\n text: React.ReactNode;\n onClick?: () => void;\n};\n\n/** @deprecated Use `\"top\" | \"bottom\"` instead. */\ntype AlertTypeDeprecated = `${Sentiment.SUCCESS | Sentiment.INFO | Sentiment.ERROR}`;\ntype AlertTypeResolved = `${\n | Sentiment.POSITIVE\n | Sentiment.NEUTRAL\n | Sentiment.WARNING\n | Sentiment.NEGATIVE\n // remove when all instances of Sentiment.PENDING have been updated to Status.PENDING\n | Sentiment.PENDING\n | Status.PENDING}`;\nexport type AlertType = AlertTypeResolved | AlertTypeDeprecated;\n\nexport enum AlertArrowPosition {\n TOP_LEFT = 'up-left',\n TOP = 'up-center',\n TOP_RIGHT = 'up-right',\n BOTTOM_LEFT = 'down-left',\n BOTTOM = 'down-center',\n BOTTOM_RIGHT = 'down-right',\n}\n\nexport interface AlertProps {\n /** An optional call to action to sit under the main body of the alert. If your label is short, use aria-label to provide more context */\n action?: AlertAction;\n className?: string;\n /** An optional icon. If not provided, we will default the icon to something appropriate for the type */\n icon?: React.ReactNode;\n /**\n * Override for [StatusIcon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)\n * announced by the screen readers\n * */\n statusIconLabel?: string;\n /** Title for the alert component */\n title?: string;\n /** The main body of the alert. Accepts plain text and bold words specified with **double stars */\n message?: string;\n /** The presence of the onDismiss handler will trigger the visibility of the close button */\n onDismiss?: React.MouseEventHandler<HTMLButtonElement>;\n /** The type dictates which icon and colour will be used */\n type?: AlertType;\n /** @deprecated Use `InlinePrompt` instead. */\n arrow?: `${AlertArrowPosition}`;\n /** @deprecated Use `message` instead. Be aware `message` only accepts plain text or text with **bold** markdown. */\n children?: React.ReactNode;\n /** @deprecated Use `onDismiss` instead. */\n dismissible?: boolean;\n /** @deprecated Alert component doesn't support `size` anymore, please remove this prop. */\n size?: `${Size}`;\n}\n\nfunction resolveType(type: AlertType): AlertTypeResolved {\n switch (type) {\n case 'success':\n return 'positive';\n case 'info':\n return 'neutral';\n case 'error':\n return 'negative';\n default:\n return type;\n }\n}\n\nexport default function Alert({\n action,\n className,\n icon,\n statusIconLabel,\n onDismiss,\n message,\n title,\n type = 'neutral',\n arrow,\n children,\n size,\n dismissible,\n}: AlertProps) {\n useEffect(() => {\n if (arrow !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'arrow' anymore, use 'InlinePrompt' instead.\",\n );\n }\n }, [arrow]);\n\n useEffect(() => {\n if (children !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'children' anymore, use 'message' instead.\",\n );\n }\n }, [children]);\n\n useEffect(() => {\n if (dismissible !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'dismissible' anymore, use 'onDismiss' instead.\",\n );\n }\n }, [dismissible]);\n\n useEffect(() => {\n if (size !== undefined) {\n logActionRequired(\"Alert component doesn't support 'size' anymore, please remove that prop.\");\n }\n }, [size]);\n\n const resolvedType = resolveType(type);\n useEffect(() => {\n if (resolvedType !== type) {\n logActionRequired(\n `Alert component has deprecated '${type}' value for the 'type' prop. Please use '${resolvedType}' instead.`,\n );\n }\n }, [resolvedType, type]);\n\n const [shouldFire, setShouldFire] = useState<boolean>();\n\n const [shouldAnnounce, setShouldAnnounce] = useState<boolean>(false);\n useEffect(() => {\n const timeoutId = setTimeout(() => {\n setShouldAnnounce(true);\n }, WDS_LIVE_REGION_DELAY_MS);\n\n return () => clearTimeout(timeoutId);\n }, []);\n\n const closeButtonReference = useRef<HTMLButtonElement>(null);\n\n /**\n * All focusable elements must be disabled until we announce the alert.\n * @see https://dequeuniversity.com/rules/axe/4.10/aria-hidden-focus?application=axeAPI\n */\n const accessibleTabIndex = shouldAnnounce ? undefined : -1;\n\n return (\n <div\n role={resolvedType === Sentiment.NEGATIVE ? 'alert' : 'status'}\n className=\"wds-alert__liveRegion\"\n >\n <div\n aria-hidden={shouldAnnounce ? undefined : 'true'}\n className={clsx(\n 'alert d-flex',\n `alert-${resolvedType}`,\n arrow != null && alertArrowClassNames(arrow),\n className,\n )}\n data-testid=\"alert\"\n onTouchStart={() => setShouldFire(true)}\n onTouchEnd={(event) => {\n if (\n shouldFire &&\n action?.href &&\n // Check if current event is triggered from closeButton\n event.target instanceof Node &&\n closeButtonReference.current &&\n !closeButtonReference.current.contains(event.target)\n ) {\n if (action.target === '_blank') {\n window.top?.open(action.href);\n } else {\n window.top?.location.assign(action.href);\n }\n }\n setShouldFire(false);\n }}\n onTouchMove={() => setShouldFire(false)}\n >\n <div className=\"alert__icon\">\n {icon || <StatusIcon size={32} sentiment={resolvedType} iconLabel={statusIconLabel} />}\n </div>\n <div className={clsx('alert__content', 'd-flex', 'flex-grow-1')}>\n <div className=\"alert__message\">\n <div>\n {title && (\n <Title className=\"m-b-1\" type={Typography.TITLE_BODY}>\n {title}\n </Title>\n )}\n <Body as=\"span\" className=\"d-block\" type={Typography.BODY_LARGE}>\n {children || <InlineMarkdown>{message}</InlineMarkdown>}\n </Body>\n </div>\n {action &&\n ('href' in action ? (\n <Link\n href={action.href}\n aria-label={action['aria-label']}\n target={action.target}\n type={Typography.LINK_LARGE}\n className=\"alert__action\"\n tabIndex={accessibleTabIndex}\n onClick={action.onClick}\n >\n {action.text}\n </Link>\n ) : (\n <Button\n v2\n size=\"sm\"\n sentiment=\"default\"\n aria-label={action['aria-label']}\n priority=\"secondary-neutral\"\n className=\"alert__action\"\n tabIndex={accessibleTabIndex}\n onClick={action.onClick}\n >\n {action.text}\n </Button>\n ))}\n </div>\n </div>\n {onDismiss && (\n <div className=\"alert__close\">\n <CloseButton\n ref={closeButtonReference}\n size=\"xs\"\n tabIndex={accessibleTabIndex}\n onClick={onDismiss}\n />\n </div>\n )}\n </div>\n </div>\n );\n}\n\nfunction alertArrowClassNames(arrow: `${AlertArrowPosition}`) {\n switch (arrow) {\n case 'down-center':\n return 'arrow arrow-bottom arrow-center';\n case 'down-left':\n return 'arrow arrow-bottom arrow-left';\n case 'down-right':\n return 'arrow arrow-bottom arrow-right';\n case 'up-center':\n return 'arrow arrow-center';\n case 'up-right':\n return 'arrow arrow-right';\n case 'up-left':\n default:\n return 'arrow';\n }\n}\n"],"names":["AlertArrowPosition","resolveType","type","Alert","action","className","icon","statusIconLabel","onDismiss","message","title","arrow","children","size","dismissible","useEffect","undefined","logActionRequired","resolvedType","shouldFire","setShouldFire","useState","shouldAnnounce","setShouldAnnounce","timeoutId","setTimeout","WDS_LIVE_REGION_DELAY_MS","clearTimeout","closeButtonReference","useRef","accessibleTabIndex","_jsx","role","Sentiment","NEGATIVE","_jsxs","clsx","alertArrowClassNames","onTouchStart","onTouchEnd","event","href","target","Node","current","contains","window","top","open","location","assign","onTouchMove","StatusIcon","sentiment","iconLabel","Title","Typography","TITLE_BODY","Body","as","BODY_LARGE","InlineMarkdown","Link","LINK_LARGE","tabIndex","onClick","text","Button","v2","priority","CloseButton","ref"],"mapp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port { useState, useRef, useEffect } from 'react';\n\nimport Body from '../body/Body';\nimport {\n CloseButton,\n Sentiment,\n Size,\n Status,\n Typography,\n WDS_LIVE_REGION_DELAY_MS,\n} from '../common';\n\nimport StatusIcon from '../statusIcon';\nimport Title from '../title/Title';\nimport { logActionRequired } from '../utilities';\n\nimport InlineMarkdown from './inlineMarkdown';\nimport Button from '../button';\nimport Link from '../link';\n\nexport type AlertAction = {\n 'aria-label'?: string;\n href?: string;\n target?: string;\n text: React.ReactNode;\n onClick?: () => void;\n};\n\n/** @deprecated Use `\"top\" | \"bottom\"` instead. */\ntype AlertTypeDeprecated = `${Sentiment.SUCCESS | Sentiment.INFO | Sentiment.ERROR}`;\ntype AlertTypeResolved = `${\n | Sentiment.POSITIVE\n | Sentiment.NEUTRAL\n | Sentiment.WARNING\n | Sentiment.NEGATIVE\n // remove when all instances of Sentiment.PENDING have been updated to Status.PENDING\n | Sentiment.PENDING\n | Status.PENDING}`;\nexport type AlertType = AlertTypeResolved | AlertTypeDeprecated;\n\nexport enum AlertArrowPosition {\n TOP_LEFT = 'up-left',\n TOP = 'up-center',\n TOP_RIGHT = 'up-right',\n BOTTOM_LEFT = 'down-left',\n BOTTOM = 'down-center',\n BOTTOM_RIGHT = 'down-right',\n}\n\nexport interface AlertProps {\n /** An optional call to action to sit under the main body of the alert. If your label is short, use aria-label to provide more context */\n action?: AlertAction;\n className?: string;\n /** An optional icon. If not provided, we will default the icon to something appropriate for the type */\n icon?: React.ReactNode;\n /**\n * Override for [StatusIcon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)\n * announced by the screen readers\n * */\n statusIconLabel?: string;\n /** Title for the alert component */\n title?: string;\n /** The main body of the alert. Accepts plain text and bold words specified with **double stars */\n message?: string;\n /** The presence of the onDismiss handler will trigger the visibility of the close button */\n onDismiss?: React.MouseEventHandler<HTMLButtonElement>;\n /** The type dictates which icon and colour will be used */\n type?: AlertType;\n /** @deprecated Use `InlineAlert` instead. */\n arrow?: `${AlertArrowPosition}`;\n /** @deprecated Use `message` instead. Be aware `message` only accepts plain text or text with **bold** markdown. */\n children?: React.ReactNode;\n /** @deprecated Use `onDismiss` instead. */\n dismissible?: boolean;\n /** @deprecated Alert component doesn't support `size` anymore, please remove this prop. */\n size?: `${Size}`;\n}\n\nfunction resolveType(type: AlertType): AlertTypeResolved {\n switch (type) {\n case 'success':\n return 'positive';\n case 'info':\n return 'neutral';\n case 'error':\n return 'negative';\n default:\n return type;\n }\n}\n\nexport default function Alert({\n action,\n className,\n icon,\n statusIconLabel,\n onDismiss,\n message,\n title,\n type = 'neutral',\n arrow,\n children,\n size,\n dismissible,\n}: AlertProps) {\n useEffect(() => {\n if (arrow !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'arrow' anymore, use 'InlineAlert' instead.\",\n );\n }\n }, [arrow]);\n\n useEffect(() => {\n if (children !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'children' anymore, use 'message' instead.\",\n );\n }\n }, [children]);\n\n useEffect(() => {\n if (dismissible !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'dismissible' anymore, use 'onDismiss' instead.\",\n );\n }\n }, [dismissible]);\n\n useEffect(() => {\n if (size !== undefined) {\n logActionRequired(\"Alert component doesn't support 'size' anymore, please remove that prop.\");\n }\n }, [size]);\n\n const resolvedType = resolveType(type);\n useEffect(() => {\n if (resolvedType !== type) {\n logActionRequired(\n `Alert component has deprecated '${type}' value for the 'type' prop. Please use '${resolvedType}' instead.`,\n );\n }\n }, [resolvedType, type]);\n\n const [shouldFire, setShouldFire] = useState<boolean>();\n\n const [shouldAnnounce, setShouldAnnounce] = useState<boolean>(false);\n useEffect(() => {\n const timeoutId = setTimeout(() => {\n setShouldAnnounce(true);\n }, WDS_LIVE_REGION_DELAY_MS);\n\n return () => clearTimeout(timeoutId);\n }, []);\n\n const closeButtonReference = useRef<HTMLButtonElement>(null);\n\n /**\n * All focusable elements must be disabled until we announce the alert.\n * @see https://dequeuniversity.com/rules/axe/4.10/aria-hidden-focus?application=axeAPI\n */\n const accessibleTabIndex = shouldAnnounce ? undefined : -1;\n\n return (\n <div\n role={resolvedType === Sentiment.NEGATIVE ? 'alert' : 'status'}\n className=\"wds-alert__liveRegion\"\n >\n <div\n aria-hidden={shouldAnnounce ? undefined : 'true'}\n className={clsx(\n 'alert d-flex',\n `alert-${resolvedType}`,\n arrow != null && alertArrowClassNames(arrow),\n className,\n )}\n data-testid=\"alert\"\n onTouchStart={() => setShouldFire(true)}\n onTouchEnd={(event) => {\n if (\n shouldFire &&\n action?.href &&\n // Check if current event is triggered from closeButton\n event.target instanceof Node &&\n closeButtonReference.current &&\n !closeButtonReference.current.contains(event.target)\n ) {\n if (action.target === '_blank') {\n window.top?.open(action.href);\n } else {\n window.top?.location.assign(action.href);\n }\n }\n setShouldFire(false);\n }}\n onTouchMove={() => setShouldFire(false)}\n >\n <div className=\"alert__icon\">\n {icon || <StatusIcon size={32} sentiment={resolvedType} iconLabel={statusIconLabel} />}\n </div>\n <div className={clsx('alert__content', 'd-flex', 'flex-grow-1')}>\n <div className=\"alert__message\">\n <div>\n {title && (\n <Title className=\"m-b-1\" type={Typography.TITLE_BODY}>\n {title}\n </Title>\n )}\n <Body as=\"span\" className=\"d-block\" type={Typography.BODY_LARGE}>\n {children || <InlineMarkdown>{message}</InlineMarkdown>}\n </Body>\n </div>\n {action &&\n ('href' in action ? (\n <Link\n href={action.href}\n aria-label={action['aria-label']}\n target={action.target}\n type={Typography.LINK_LARGE}\n className=\"alert__action\"\n tabIndex={accessibleTabIndex}\n onClick={action.onClick}\n >\n {action.text}\n </Link>\n ) : (\n <Button\n v2\n size=\"sm\"\n sentiment=\"default\"\n aria-label={action['aria-label']}\n priority=\"secondary-neutral\"\n className=\"alert__action\"\n tabIndex={accessibleTabIndex}\n onClick={action.onClick}\n >\n {action.text}\n </Button>\n ))}\n </div>\n </div>\n {onDismiss && (\n <div className=\"alert__close\">\n <CloseButton\n ref={closeButtonReference}\n size=\"xs\"\n tabIndex={accessibleTabIndex}\n onClick={onDismiss}\n />\n </div>\n )}\n </div>\n </div>\n );\n}\n\nfunction alertArrowClassNames(arrow: `${AlertArrowPosition}`) {\n switch (arrow) {\n case 'down-center':\n return 'arrow arrow-bottom arrow-center';\n case 'down-left':\n return 'arrow arrow-bottom arrow-left';\n case 'down-right':\n return 'arrow arrow-bottom arrow-right';\n case 'up-center':\n return 'arrow arrow-center';\n case 'up-right':\n return 'arrow arrow-right';\n case 'up-left':\n default:\n return 'arrow';\n }\n}\n"],"names":["AlertArrowPosition","resolveType","type","Alert","action","className","icon","statusIconLabel","onDismiss","message","title","arrow","children","size","dismissible","useEffect","undefined","logActionRequired","resolvedType","shouldFire","setShouldFire","useState","shouldAnnounce","setShouldAnnounce","timeoutId","setTimeout","WDS_LIVE_REGION_DELAY_MS","clearTimeout","closeButtonReference","useRef","accessibleTabIndex","_jsx","role","Sentiment","NEGATIVE","_jsxs","clsx","alertArrowClassNames","onTouchStart","onTouchEnd","event","href","target","Node","current","contains","window","top","open","location","assign","onTouchMove","StatusIcon","sentiment","iconLabel","Title","Typography","TITLE_BODY","Body","as","BODY_LARGE","InlineMarkdown","Link","LINK_LARGE","tabIndex","onClick","text","Button","v2","priority","CloseButton","ref"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCYA;AAAZ,CAAA,UAAYA,kBAAkB,EAAA;AAC5BA,EAAAA,kBAAA,CAAA,UAAA,CAAA,GAAA,SAAoB;AACpBA,EAAAA,kBAAA,CAAA,KAAA,CAAA,GAAA,WAAiB;AACjBA,EAAAA,kBAAA,CAAA,WAAA,CAAA,GAAA,UAAsB;AACtBA,EAAAA,kBAAA,CAAA,aAAA,CAAA,GAAA,WAAyB;AACzBA,EAAAA,kBAAA,CAAA,QAAA,CAAA,GAAA,aAAsB;AACtBA,EAAAA,kBAAA,CAAA,cAAA,CAAA,GAAA,YAA2B;AAC7B,CAAC,EAPWA,0BAAkB,KAAlBA,0BAAkB,GAAA,EAAA,CAAA,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AA,EAAA;AAAK1B,QAAAA,SAAS,EAAC,cAAc;QAAAO,QAAA,eAC3BmB,cAAA,CAACuC,uBAAW,EAAA;AACVC,UAAAA,GAAG,EAAE3C,oBAAqB;AAC1Bf,UAAAA,IAAI,EAAC,IAAI;AACTmD,UAAAA,QAAQ,EAAElC,kBAAmB;AAC7BmC,UAAAA,OAAO,EAAEzD;SAAU;AAEvB,OAAK,CACN;KACE;AACP,GAAK,CAAC;AAEV;AAEA,SAAS6B,oBAAoBA,CAAC1B,KAA8B,EAAA;AAC1D,EAAA,QAAQA,KAAK;AACX,IAAA,KAAK,aAAa;AAChB,MAAA,OAAO,iCAAiC;AAC1C,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,+BAA+B;AACxC,IAAA,KAAK,YAAY;AACf,MAAA,OAAO,gCAAgC;AACzC,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,oBAAoB;AAC7B,IAAA,KAAK,UAAU;AACb,MAAA,OAAO,mBAAmB;AAC5B,IAAA,KAAK,SAAS;AACd,IAAA;AACE,MAAA,OAAO,OAAO;AAClB;AACF;;;;"}
@@ -67,7 +67,7 @@ function Alert({
67
67
  }) {
68
68
  useEffect(() => {
69
69
  if (arrow !== undefined) {
70
- logActionRequired("Alert component doesn't support 'arrow' anymore, use 'InlinePrompt' instead.");
70
+ logActionRequired("Alert component doesn't support 'arrow' anymore, use 'InlineAlert' instead.");
71
71
  }
72
72
  }, [arrow]);
73
73
  useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.mjs","sources":["../../src/alert/Alert.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useState, useRef, useEffect } from 'react';\n\nimport Body from '../body/Body';\nimport {\n CloseButton,\n Sentiment,\n Size,\n Status,\n Typography,\n WDS_LIVE_REGION_DELAY_MS,\n} from '../common';\n\nimport StatusIcon from '../statusIcon';\nimport Title from '../title/Title';\nimport { logActionRequired } from '../utilities';\n\nimport InlineMarkdown from './inlineMarkdown';\nimport Button from '../button';\nimport Link from '../link';\n\nexport type AlertAction = {\n 'aria-label'?: string;\n href?: string;\n target?: string;\n text: React.ReactNode;\n onClick?: () => void;\n};\n\n/** @deprecated Use `\"top\" | \"bottom\"` instead. */\ntype AlertTypeDeprecated = `${Sentiment.SUCCESS | Sentiment.INFO | Sentiment.ERROR}`;\ntype AlertTypeResolved = `${\n | Sentiment.POSITIVE\n | Sentiment.NEUTRAL\n | Sentiment.WARNING\n | Sentiment.NEGATIVE\n // remove when all instances of Sentiment.PENDING have been updated to Status.PENDING\n | Sentiment.PENDING\n | Status.PENDING}`;\nexport type AlertType = AlertTypeResolved | AlertTypeDeprecated;\n\nexport enum AlertArrowPosition {\n TOP_LEFT = 'up-left',\n TOP = 'up-center',\n TOP_RIGHT = 'up-right',\n BOTTOM_LEFT = 'down-left',\n BOTTOM = 'down-center',\n BOTTOM_RIGHT = 'down-right',\n}\n\nexport interface AlertProps {\n /** An optional call to action to sit under the main body of the alert. If your label is short, use aria-label to provide more context */\n action?: AlertAction;\n className?: string;\n /** An optional icon. If not provided, we will default the icon to something appropriate for the type */\n icon?: React.ReactNode;\n /**\n * Override for [StatusIcon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)\n * announced by the screen readers\n * */\n statusIconLabel?: string;\n /** Title for the alert component */\n title?: string;\n /** The main body of the alert. Accepts plain text and bold words specified with **double stars */\n message?: string;\n /** The presence of the onDismiss handler will trigger the visibility of the close button */\n onDismiss?: React.MouseEventHandler<HTMLButtonElement>;\n /** The type dictates which icon and colour will be used */\n type?: AlertType;\n /** @deprecated Use `InlinePrompt` instead. */\n arrow?: `${AlertArrowPosition}`;\n /** @deprecated Use `message` instead. Be aware `message` only accepts plain text or text with **bold** markdown. */\n children?: React.ReactNode;\n /** @deprecated Use `onDismiss` instead. */\n dismissible?: boolean;\n /** @deprecated Alert component doesn't support `size` anymore, please remove this prop. */\n size?: `${Size}`;\n}\n\nfunction resolveType(type: AlertType): AlertTypeResolved {\n switch (type) {\n case 'success':\n return 'positive';\n case 'info':\n return 'neutral';\n case 'error':\n return 'negative';\n default:\n return type;\n }\n}\n\nexport default function Alert({\n action,\n className,\n icon,\n statusIconLabel,\n onDismiss,\n message,\n title,\n type = 'neutral',\n arrow,\n children,\n size,\n dismissible,\n}: AlertProps) {\n useEffect(() => {\n if (arrow !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'arrow' anymore, use 'InlinePrompt' instead.\",\n );\n }\n }, [arrow]);\n\n useEffect(() => {\n if (children !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'children' anymore, use 'message' instead.\",\n );\n }\n }, [children]);\n\n useEffect(() => {\n if (dismissible !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'dismissible' anymore, use 'onDismiss' instead.\",\n );\n }\n }, [dismissible]);\n\n useEffect(() => {\n if (size !== undefined) {\n logActionRequired(\"Alert component doesn't support 'size' anymore, please remove that prop.\");\n }\n }, [size]);\n\n const resolvedType = resolveType(type);\n useEffect(() => {\n if (resolvedType !== type) {\n logActionRequired(\n `Alert component has deprecated '${type}' value for the 'type' prop. Please use '${resolvedType}' instead.`,\n );\n }\n }, [resolvedType, type]);\n\n const [shouldFire, setShouldFire] = useState<boolean>();\n\n const [shouldAnnounce, setShouldAnnounce] = useState<boolean>(false);\n useEffect(() => {\n const timeoutId = setTimeout(() => {\n setShouldAnnounce(true);\n }, WDS_LIVE_REGION_DELAY_MS);\n\n return () => clearTimeout(timeoutId);\n }, []);\n\n const closeButtonReference = useRef<HTMLButtonElement>(null);\n\n /**\n * All focusable elements must be disabled until we announce the alert.\n * @see https://dequeuniversity.com/rules/axe/4.10/aria-hidden-focus?application=axeAPI\n */\n const accessibleTabIndex = shouldAnnounce ? undefined : -1;\n\n return (\n <div\n role={resolvedType === Sentiment.NEGATIVE ? 'alert' : 'status'}\n className=\"wds-alert__liveRegion\"\n >\n <div\n aria-hidden={shouldAnnounce ? undefined : 'true'}\n className={clsx(\n 'alert d-flex',\n `alert-${resolvedType}`,\n arrow != null && alertArrowClassNames(arrow),\n className,\n )}\n data-testid=\"alert\"\n onTouchStart={() => setShouldFire(true)}\n onTouchEnd={(event) => {\n if (\n shouldFire &&\n action?.href &&\n // Check if current event is triggered from closeButton\n event.target instanceof Node &&\n closeButtonReference.current &&\n !closeButtonReference.current.contains(event.target)\n ) {\n if (action.target === '_blank') {\n window.top?.open(action.href);\n } else {\n window.top?.location.assign(action.href);\n }\n }\n setShouldFire(false);\n }}\n onTouchMove={() => setShouldFire(false)}\n >\n <div className=\"alert__icon\">\n {icon || <StatusIcon size={32} sentiment={resolvedType} iconLabel={statusIconLabel} />}\n </div>\n <div className={clsx('alert__content', 'd-flex', 'flex-grow-1')}>\n <div className=\"alert__message\">\n <div>\n {title && (\n <Title className=\"m-b-1\" type={Typography.TITLE_BODY}>\n {title}\n </Title>\n )}\n <Body as=\"span\" className=\"d-block\" type={Typography.BODY_LARGE}>\n {children || <InlineMarkdown>{message}</InlineMarkdown>}\n </Body>\n </div>\n {action &&\n ('href' in action ? (\n <Link\n href={action.href}\n aria-label={action['aria-label']}\n target={action.target}\n type={Typography.LINK_LARGE}\n className=\"alert__action\"\n tabIndex={accessibleTabIndex}\n onClick={action.onClick}\n >\n {action.text}\n </Link>\n ) : (\n <Button\n v2\n size=\"sm\"\n sentiment=\"default\"\n aria-label={action['aria-label']}\n priority=\"secondary-neutral\"\n className=\"alert__action\"\n tabIndex={accessibleTabIndex}\n onClick={action.onClick}\n >\n {action.text}\n </Button>\n ))}\n </div>\n </div>\n {onDismiss && (\n <div className=\"alert__close\">\n <CloseButton\n ref={closeButtonReference}\n size=\"xs\"\n tabIndex={accessibleTabIndex}\n onClick={onDismiss}\n />\n </div>\n )}\n </div>\n </div>\n );\n}\n\nfunction alertArrowClassNames(arrow: `${AlertArrowPosition}`) {\n switch (arrow) {\n case 'down-center':\n return 'arrow arrow-bottom arrow-center';\n case 'down-left':\n return 'arrow arrow-bottom arrow-left';\n case 'down-right':\n return 'arrow arrow-bottom arrow-right';\n case 'up-center':\n return 'arrow arrow-center';\n case 'up-right':\n return 'arrow arrow-right';\n case 'up-left':\n default:\n return 'arrow';\n }\n}\n"],"names":["AlertArrowPosition","resolveType","type","Alert","action","className","icon","statusIconLabel","onDismiss","message","title","arrow","children","size","dismissible","useEffect","undefined","logActionRequired","resolvedType","shouldFire","setShouldFire","useState","shouldAnnounce","setShouldAnnounce","timeoutId","setTimeout","WDS_LIVE_REGION_DELAY_MS","clearTimeout","closeButtonReference","useRef","accessibleTabIndex","_jsx","role","Sentiment","NEGATIVE","_jsxs","clsx","alertArrowClassNames","onTouchStart","onTouchEnd","event","href","target","Node","current","contains","window","top","open","location","assign","onTouchMove","StatusIcon","sentiment","iconLabel","Title","Typography","TITLE_BODY","Body","as","BODY_LARGE","InlineMarkdown","Link","LINK_LARGE","tabIndex","onClick","text","Button","v2","priority","CloseButton","ref"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAyCYA;AAAZ,CAAA,UAAYA,kBAAkB,EAAA;AAC5BA,EAAAA,kBAAA,CAAA,UAAA,CAAA,GAAA,SAAoB;AACpBA,EAAAA,kBAAA,CAAA,KAAA,CAAA,GAAA,WAAiB;AACjBA,EAAAA,kBAAA,CAAA,WAAA,CAAA,GAAA,UAAsB;AACtBA,EAAAA,kBAAA,CAAA,aAAA,CAAA,GAAA,WAAyB;AACzBA,EAAAA,kBAAA,CAAA,QAAA,CAAA,GAAA,aAAsB;AACtBA,EAAAA,kBAAA,CAAA,cAAA,CAAA,GAAA,YAA2B;AAC7B,CAAC,EAPWA,kBAAkB,KAAlBA,kBAAkB,GAAA,EAAA,CAAA,CAAA;AAsC9B,SAASC,WAAWA,CAACC,IAAe,EAAA;AAClC,EAAA,QAAQA,IAAI;AACV,IAAA,KAAK,SAAS;AACZ,MAAA,OAAO,UAAU;AACnB,IAAA,KAAK,MAAM;AACT,MAAA,OAAO,SAAS;AAClB,IAAA,KAAK,OAAO;AACV,MAAA,OAAO,UAAU;AACnB,IAAA;AACE,MAA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vB,OAAK,CACN;KACE;AACP,GAAK,CAAC;AAEV;AAEA,SAAS6B,oBAAoBA,CAAC1B,KAA8B,EAAA;AAC1D,EAAA,QAAQA,KAAK;AACX,IAAA,KAAK,aAAa;AAChB,MAAA,OAAO,iCAAiC;AAC1C,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,+BAA+B;AACxC,IAAA,KAAK,YAAY;AACf,MAAA,OAAO,gCAAgC;AACzC,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,oBAAoB;AAC7B,IAAA,KAAK,UAAU;AACb,MAAA,OAAO,mBAAmB;AAC5B,IAAA,KAAK,SAAS;AACd,IAAA;AACE,MAAA,OAAO,OAAO;AAClB;AACF;;;;"}
1
+ {"version":3,"file":"Alert.mjs","sources":["../../src/alert/Alert.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useState, useRef, useEffect } from 'react';\n\nimport Body from '../body/Body';\nimport {\n CloseButton,\n Sentiment,\n Size,\n Status,\n Typography,\n WDS_LIVE_REGION_DELAY_MS,\n} from '../common';\n\nimport StatusIcon from '../statusIcon';\nimport Title from '../title/Title';\nimport { logActionRequired } from '../utilities';\n\nimport InlineMarkdown from './inlineMarkdown';\nimport Button from '../button';\nimport Link from '../link';\n\nexport type AlertAction = {\n 'aria-label'?: string;\n href?: string;\n target?: string;\n text: React.ReactNode;\n onClick?: () => void;\n};\n\n/** @deprecated Use `\"top\" | \"bottom\"` instead. */\ntype AlertTypeDeprecated = `${Sentiment.SUCCESS | Sentiment.INFO | Sentiment.ERROR}`;\ntype AlertTypeResolved = `${\n | Sentiment.POSITIVE\n | Sentiment.NEUTRAL\n | Sentiment.WARNING\n | Sentiment.NEGATIVE\n // remove when all instances of Sentiment.PENDING have been updated to Status.PENDING\n | Sentiment.PENDING\n | Status.PENDING}`;\nexport type AlertType = AlertTypeResolved | AlertTypeDeprecated;\n\nexport enum AlertArrowPosition {\n TOP_LEFT = 'up-left',\n TOP = 'up-center',\n TOP_RIGHT = 'up-right',\n BOTTOM_LEFT = 'down-left',\n BOTTOM = 'down-center',\n BOTTOM_RIGHT = 'down-right',\n}\n\nexport interface AlertProps {\n /** An optional call to action to sit under the main body of the alert. If your label is short, use aria-label to provide more context */\n action?: AlertAction;\n className?: string;\n /** An optional icon. If not provided, we will default the icon to something appropriate for the type */\n icon?: React.ReactNode;\n /**\n * Override for [StatusIcon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)\n * announced by the screen readers\n * */\n statusIconLabel?: string;\n /** Title for the alert component */\n title?: string;\n /** The main body of the alert. Accepts plain text and bold words specified with **double stars */\n message?: string;\n /** The presence of the onDismiss handler will trigger the visibility of the close button */\n onDismiss?: React.MouseEventHandler<HTMLButtonElement>;\n /** The type dictates which icon and colour will be used */\n type?: AlertType;\n /** @deprecated Use `InlineAlert` instead. */\n arrow?: `${AlertArrowPosition}`;\n /** @deprecated Use `message` instead. Be aware `message` only accepts plain text or text with **bold** markdown. */\n children?: React.ReactNode;\n /** @deprecated Use `onDismiss` instead. */\n dismissible?: boolean;\n /** @deprecated Alert component doesn't support `size` anymore, please remove this prop. */\n size?: `${Size}`;\n}\n\nfunction resolveType(type: AlertType): AlertTypeResolved {\n switch (type) {\n case 'success':\n return 'positive';\n case 'info':\n return 'neutral';\n case 'error':\n return 'negative';\n default:\n return type;\n }\n}\n\nexport default function Alert({\n action,\n className,\n icon,\n statusIconLabel,\n onDismiss,\n message,\n title,\n type = 'neutral',\n arrow,\n children,\n size,\n dismissible,\n}: AlertProps) {\n useEffect(() => {\n if (arrow !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'arrow' anymore, use 'InlineAlert' instead.\",\n );\n }\n }, [arrow]);\n\n useEffect(() => {\n if (children !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'children' anymore, use 'message' instead.\",\n );\n }\n }, [children]);\n\n useEffect(() => {\n if (dismissible !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'dismissible' anymore, use 'onDismiss' instead.\",\n );\n }\n }, [dismissible]);\n\n useEffect(() => {\n if (size !== undefined) {\n logActionRequired(\"Alert component doesn't support 'size' anymore, please remove that prop.\");\n }\n }, [size]);\n\n const resolvedType = resolveType(type);\n useEffect(() => {\n if (resolvedType !== type) {\n logActionRequired(\n `Alert component has deprecated '${type}' value for the 'type' prop. Please use '${resolvedType}' instead.`,\n );\n }\n }, [resolvedType, type]);\n\n const [shouldFire, setShouldFire] = useState<boolean>();\n\n const [shouldAnnounce, setShouldAnnounce] = useState<boolean>(false);\n useEffect(() => {\n const timeoutId = setTimeout(() => {\n setShouldAnnounce(true);\n }, WDS_LIVE_REGION_DELAY_MS);\n\n return () => clearTimeout(timeoutId);\n }, []);\n\n const closeButtonReference = useRef<HTMLButtonElement>(null);\n\n /**\n * All focusable elements must be disabled until we announce the alert.\n * @see https://dequeuniversity.com/rules/axe/4.10/aria-hidden-focus?application=axeAPI\n */\n const accessibleTabIndex = shouldAnnounce ? undefined : -1;\n\n return (\n <div\n role={resolvedType === Sentiment.NEGATIVE ? 'alert' : 'status'}\n className=\"wds-alert__liveRegion\"\n >\n <div\n aria-hidden={shouldAnnounce ? undefined : 'true'}\n className={clsx(\n 'alert d-flex',\n `alert-${resolvedType}`,\n arrow != null && alertArrowClassNames(arrow),\n className,\n )}\n data-testid=\"alert\"\n onTouchStart={() => setShouldFire(true)}\n onTouchEnd={(event) => {\n if (\n shouldFire &&\n action?.href &&\n // Check if current event is triggered from closeButton\n event.target instanceof Node &&\n closeButtonReference.current &&\n !closeButtonReference.current.contains(event.target)\n ) {\n if (action.target === '_blank') {\n window.top?.open(action.href);\n } else {\n window.top?.location.assign(action.href);\n }\n }\n setShouldFire(false);\n }}\n onTouchMove={() => setShouldFire(false)}\n >\n <div className=\"alert__icon\">\n {icon || <StatusIcon size={32} sentiment={resolvedType} iconLabel={statusIconLabel} />}\n </div>\n <div className={clsx('alert__content', 'd-flex', 'flex-grow-1')}>\n <div className=\"alert__message\">\n <div>\n {title && (\n <Title className=\"m-b-1\" type={Typography.TITLE_BODY}>\n {title}\n </Title>\n )}\n <Body as=\"span\" className=\"d-block\" type={Typography.BODY_LARGE}>\n {children || <InlineMarkdown>{message}</InlineMarkdown>}\n </Body>\n </div>\n {action &&\n ('href' in action ? (\n <Link\n href={action.href}\n aria-label={action['aria-label']}\n target={action.target}\n type={Typography.LINK_LARGE}\n className=\"alert__action\"\n tabIndex={accessibleTabIndex}\n onClick={action.onClick}\n >\n {action.text}\n </Link>\n ) : (\n <Button\n v2\n size=\"sm\"\n sentiment=\"default\"\n aria-label={action['aria-label']}\n priority=\"secondary-neutral\"\n className=\"alert__action\"\n tabIndex={accessibleTabIndex}\n onClick={action.onClick}\n >\n {action.text}\n </Button>\n ))}\n </div>\n </div>\n {onDismiss && (\n <div className=\"alert__close\">\n <CloseButton\n ref={closeButtonReference}\n size=\"xs\"\n tabIndex={accessibleTabIndex}\n onClick={onDismiss}\n />\n </div>\n )}\n </div>\n </div>\n );\n}\n\nfunction alertArrowClassNames(arrow: `${AlertArrowPosition}`) {\n switch (arrow) {\n case 'down-center':\n return 'arrow arrow-bottom arrow-center';\n case 'down-left':\n return 'arrow arrow-bottom arrow-left';\n case 'down-right':\n return 'arrow arrow-bottom arrow-right';\n case 'up-center':\n return 'arrow arrow-center';\n case 'up-right':\n return 'arrow arrow-right';\n case 'up-left':\n default:\n return 'arrow';\n }\n}\n"],"names":["AlertArrowPosition","resolveType","type","Alert","action","className","icon","statusIconLabel","onDismiss","message","title","arrow","children","size","dismissible","useEffect","undefined","logActionRequired","resolvedType","shouldFire","setShouldFire","useState","shouldAnnounce","setShouldAnnounce","timeoutId","setTimeout","WDS_LIVE_REGION_DELAY_MS","clearTimeout","closeButtonReference","useRef","accessibleTabIndex","_jsx","role","Sentiment","NEGATIVE","_jsxs","clsx","alertArrowClassNames","onTouchStart","onTouchEnd","event","href","target","Node","current","contains","window","top","open","location","assign","onTouchMove","StatusIcon","sentiment","iconLabel","Title","Typography","TITLE_BODY","Body","as","BODY_LARGE","InlineMarkdown","Link","LIN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-intl');
26
26
  require('../common/closeButton/CloseButton.messages.js');
27
27
  var jsxRuntime = require('react/jsx-runtime');
28
- var InlinePrompt = require('../prompt/InlinePrompt/InlinePrompt.js');
28
+ var InlineAlert = require('../inlineAlert/InlineAlert.js');
29
29
  var contexts = require('../inputs/contexts.js');
30
30
  var Label = require('../label/Label.js');
31
31
 
@@ -98,8 +98,8 @@ const Field = ({
98
98
  className: "np-field-control",
99
99
  children: children
100
100
  })]
101
- }) : children, message && /*#__PURE__*/jsxRuntime.jsx(InlinePrompt.InlinePrompt, {
102
- sentiment: sentiment$1,
101
+ }) : children, message && /*#__PURE__*/jsxRuntime.jsx(InlineAlert.default, {
102
+ type: sentiment$1,
103
103
  id: messageId,
104
104
  iconLabel: messageIconLabel,
105
105
  children: message
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","sources":["../../src/field/Field.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useId, useRef } from 'react';\n\nimport { Sentiment } from '../common';\nimport { InlinePrompt } from '../prompt/InlinePrompt/InlinePrompt';\nimport {\n FieldLabelContextProvider,\n InputDescribedByProvider,\n InputIdContextProvider,\n InputInvalidProvider,\n} from '../inputs/contexts';\nimport { Label } from '../label';\n\nexport type FieldProps = {\n /** `null` disables auto-generating the `id` attribute, falling back to nesting-based label association over setting `htmlFor` explicitly. */\n id?: string | null;\n /** Should be specified unless the wrapped control has its own labeling mechanism, e.g. `Checkbox`. */\n label?: React.ReactNode;\n required?: boolean;\n /** @deprecated use `description` prop instead */\n hint?: React.ReactNode;\n message?: React.ReactNode;\n /**\n * Override for the [InlinePrompt icon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)\n * announced by the screen readers\n * */\n messageIconLabel?: string;\n description?: React.ReactNode;\n /** @deprecated use `message` and `type={Sentiment.NEGATIVE}` prop instead */\n error?: React.ReactNode;\n sentiment?: `${Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.POSITIVE | Sentiment.WARNING}`;\n className?: string;\n children?: React.ReactNode;\n};\n\nexport const Field = ({\n id,\n label,\n required = true,\n message: propMessage,\n messageIconLabel,\n hint,\n description = hint,\n sentiment: propType = Sentiment.NEUTRAL,\n className,\n children,\n ...props\n}: FieldProps) => {\n const labelRef = useRef<HTMLLabelElement>(null);\n const sentiment = props.error ? Sentiment.NEGATIVE : propType;\n const message = propMessage || props.error;\n const hasError = sentiment === Sentiment.NEGATIVE;\n\n const labelId = useId();\n\n const fallbackInputId = useId();\n const inputId = id !== null ? (id ?? fallbackInputId) : undefined;\n\n const messageId = useId();\n const descriptionId = useId();\n\n /**\n * form control can have multiple messages to describe it,\n * e.g the description underneath the label and inline alert\n */\n function ariaDescribedbyByIds() {\n const messageIds = [];\n if (description) {\n messageIds.push(descriptionId);\n }\n if (message) {\n messageIds.push(messageId);\n }\n return messageIds.length > 0 ? messageIds.join(' ') : undefined;\n }\n\n return (\n <FieldLabelContextProvider value={{ id: labelId, ref: labelRef }}>\n <InputIdContextProvider value={inputId}>\n <InputDescribedByProvider value={ariaDescribedbyByIds()}>\n <InputInvalidProvider value={hasError}>\n <div\n className={clsx(\n 'np-field form-group d-block',\n {\n 'has-success': sentiment === Sentiment.POSITIVE,\n 'has-warning': sentiment === Sentiment.WARNING,\n 'has-error': hasError,\n 'has-info': sentiment === Sentiment.NEUTRAL,\n },\n className,\n )}\n >\n {label != null ? (\n <>\n <Label ref={labelRef} id={labelId} htmlFor={inputId}>\n {required ? label : <Label.Optional>{label}</Label.Optional>}\n </Label>\n <Label.Description id={descriptionId}>{description}</Label.Description>\n <div className=\"np-field-control\">{children}</div>\n </>\n ) : (\n children\n )}\n\n {message && (\n <InlinePrompt sentiment={sentiment} id={messageId} iconLabel={messageIconLabel}>\n {message}\n </InlinePrompt>\n )}\n </div>\n </InputInvalidProvider>\n </InputDescribedByProvider>\n </InputIdContextProvider>\n </FieldLabelContextProvider>\n );\n};\n"],"names":["Field","id","label","required","message","propMessage","messageIconLabel","hint","description","sentiment","propType","Sentiment","NEUTRAL","className","children","props","labelRef","useRef","error","NEGATIVE","hasError","labelId","useId","fallbackInputId","inputId","undefined","messageId","descriptionId","ariaDescribedbyByIds","messageIds","push","length","join","_jsx","FieldLabelContextProvider","value","ref","InputIdContextProvider","InputDescribedByProvider","InputInvalidProvider","_jsxs","clsx","POSITIVE","WARNING","_Fragment","Label","htmlFor","Optional","Description","InlinePrompt","iconLabel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCO,MAAMA,KAAK,GAAGA,CAAC;EACpBC,EAAE;EACFC,KAAK;AACLC,EAAAA,QAAQ,GAAG,IAAI;AACfC,EAAAA,OAAO,EAAEC,WAAW;EACpBC,gBAAgB;EAChBC,IAAI;AACJC,EAAAA,WAAW,GAAGD,IAAI;AAClBE,EAAAA,SAAS,EAAEC,QAAQ,GAAGC,mBAAS,CAACC,OAAO;EACvCC,SAAS;EACTC,QAAQ;EACR,GAAGC;AAAK,CACG,KAAI;AACf,EAAA,MAAMC,QAAQ,GAAGC,YAAM,CAAmB,IAAI,CAAC;EAC/C,MAAMR,WAAS,GAAGM,KAAK,CAACG,KAAK,GAAGP,mBAAS,CAACQ,QAAQ,GAAGT,QAAQ;AAC7D,EAAA,MAAMN,OAAO,GAAGC,WAAW,IAAIU,KAAK,CAACG,KAAK;AAC1C,EAAA,MAAME,QAAQ,GAAGX,WAAS,KAAKE,mBAAS,CAACQ,QAAQ;AAEjD,EAAA,MAAME,OAAO,GAAGC,WAAK,EAAE;AAEvB,EAAA,MAAMC,eAAe,GAAGD,WAAK,EAAE;EAC/B,MAAME,OAAO,GAAGvB,EAAE,KAAK,IAAI,GAAIA,EAAE,IAAIsB,eAAe,GAAIE,SAAS;AAEjE,EAAA,MAAMC,SAAS,GAAGJ,WAAK,EAAE;AACzB,EAAA,MAAMK,aAAa,GAAGL,WAAK,EAAE;AAE7B;;;AAGG;EACH,SAASM,oBAAoBA,GAAA;IAC3B,MAAMC,UAAU,GAAG,EAAE;AACrB,IAAA,IAAIrB,WAAW,E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AEtB,OAAQ;gBAAAV,QAAA,EACjDX,QAAQ,GAAGD,KAAK,gBAAG+B,cAAA,CAACY,WAAK,CAACE,QAAQ,EAAA;AAAAjC,kBAAAA,QAAA,EAAEZ;iBAAsB;AAAC,eACvD,CACP,eAAA+B,cAAA,CAACY,WAAK,CAACG,WAAW,EAAA;AAAC/C,gBAAAA,EAAE,EAAE0B,aAAc;AAAAb,gBAAAA,QAAA,EAAEN;eAA+B,CACtE,eAAAyB,cAAA,CAAA,KAAA,EAAA;AAAKpB,gBAAAA,SAAS,EAAC,kBAAkB;AAAAC,gBAAAA,QAAA,EAAEA;AAAQ,eAAM,CACnD;aAAA,CAAG,GAEHA,QACD,EAEAV,OAAO,iBACN6B,cAAA,CAACgB,yBAAY,EAAA;AAACxC,cAAAA,SAAS,EAAEA,WAAU;AAACR,cAAAA,EAAE,EAAEyB,SAAU;AAACwB,cAAAA,SAAS,EAAE5C,gBAAiB;AAAAQ,cAAAA,QAAA,EAC5EV;AAAO,aACI,CACf;WACE;SACe;OACE;KACJ;AAC1B,GAA2B,CAAC;AAEhC;;;;"}
1
+ {"version":3,"file":"Field.js","sources":["../../src/field/Field.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useId, useRef } from 'react';\n\nimport { Sentiment } from '../common';\nimport InlineAlert from '../inlineAlert/InlineAlert';\nimport {\n FieldLabelContextProvider,\n InputDescribedByProvider,\n InputIdContextProvider,\n InputInvalidProvider,\n} from '../inputs/contexts';\nimport { Label } from '../label';\n\nexport type FieldProps = {\n /** `null` disables auto-generating the `id` attribute, falling back to nesting-based label association over setting `htmlFor` explicitly. */\n id?: string | null;\n /** Should be specified unless the wrapped control has its own labeling mechanism, e.g. `Checkbox`. */\n label?: React.ReactNode;\n required?: boolean;\n /** @deprecated use `description` prop instead */\n hint?: React.ReactNode;\n message?: React.ReactNode;\n /**\n * Override for the [InlineAlert icon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)\n * announced by the screen readers\n * */\n messageIconLabel?: string;\n description?: React.ReactNode;\n /** @deprecated use `message` and `type={Sentiment.NEGATIVE}` prop instead */\n error?: React.ReactNode;\n sentiment?: `${Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.POSITIVE | Sentiment.WARNING}`;\n className?: string;\n children?: React.ReactNode;\n};\n\nexport const Field = ({\n id,\n label,\n required = true,\n message: propMessage,\n messageIconLabel,\n hint,\n description = hint,\n sentiment: propType = Sentiment.NEUTRAL,\n className,\n children,\n ...props\n}: FieldProps) => {\n const labelRef = useRef<HTMLLabelElement>(null);\n const sentiment = props.error ? Sentiment.NEGATIVE : propType;\n const message = propMessage || props.error;\n const hasError = sentiment === Sentiment.NEGATIVE;\n\n const labelId = useId();\n\n const fallbackInputId = useId();\n const inputId = id !== null ? (id ?? fallbackInputId) : undefined;\n\n const messageId = useId();\n const descriptionId = useId();\n\n /**\n * form control can have multiple messages to describe it,\n * e.g the description underneath the label and inline alert\n */\n function ariaDescribedbyByIds() {\n const messageIds = [];\n if (description) {\n messageIds.push(descriptionId);\n }\n if (message) {\n messageIds.push(messageId);\n }\n return messageIds.length > 0 ? messageIds.join(' ') : undefined;\n }\n\n return (\n <FieldLabelContextProvider value={{ id: labelId, ref: labelRef }}>\n <InputIdContextProvider value={inputId}>\n <InputDescribedByProvider value={ariaDescribedbyByIds()}>\n <InputInvalidProvider value={hasError}>\n <div\n className={clsx(\n 'np-field form-group d-block',\n {\n 'has-success': sentiment === Sentiment.POSITIVE,\n 'has-warning': sentiment === Sentiment.WARNING,\n 'has-error': hasError,\n 'has-info': sentiment === Sentiment.NEUTRAL,\n },\n className,\n )}\n >\n {label != null ? (\n <>\n <Label ref={labelRef} id={labelId} htmlFor={inputId}>\n {required ? label : <Label.Optional>{label}</Label.Optional>}\n </Label>\n <Label.Description id={descriptionId}>{description}</Label.Description>\n <div className=\"np-field-control\">{children}</div>\n </>\n ) : (\n children\n )}\n\n {message && (\n <InlineAlert type={sentiment} id={messageId} iconLabel={messageIconLabel}>\n {message}\n </InlineAlert>\n )}\n </div>\n </InputInvalidProvider>\n </InputDescribedByProvider>\n </InputIdContextProvider>\n </FieldLabelContextProvider>\n );\n};\n"],"names":["Field","id","label","required","message","propMessage","messageIconLabel","hint","description","sentiment","propType","Sentiment","NEUTRAL","className","children","props","labelRef","useRef","error","NEGATIVE","hasError","labelId","useId","fallbackInputId","inputId","undefined","messageId","descriptionId","ariaDescribedbyByIds","messageIds","push","length","join","_jsx","FieldLabelContextProvider","value","ref","InputIdContextProvider","InputDescribedByProvider","InputInvalidProvider","_jsxs","clsx","POSITIVE","WARNING","_Fragment","Label","htmlFor","Optional","Description","InlineAlert","type","iconLabel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCO,MAAMA,KAAK,GAAGA,CAAC;EACpBC,EAAE;EACFC,KAAK;AACLC,EAAAA,QAAQ,GAAG,IAAI;AACfC,EAAAA,OAAO,EAAEC,WAAW;EACpBC,gBAAgB;EAChBC,IAAI;AACJC,EAAAA,WAAW,GAAGD,IAAI;AAClBE,EAAAA,SAAS,EAAEC,QAAQ,GAAGC,mBAAS,CAACC,OAAO;EACvCC,SAAS;EACTC,QAAQ;EACR,GAAGC;AAAK,CACG,KAAI;AACf,EAAA,MAAMC,QAAQ,GAAGC,YAAM,CAAmB,IAAI,CAAC;EAC/C,MAAMR,WAAS,GAAGM,KAAK,CAACG,KAAK,GAAGP,mBAAS,CAACQ,QAAQ,GAAGT,QAAQ;AAC7D,EAAA,MAAMN,OAAO,GAAGC,WAAW,IAAIU,KAAK,CAACG,KAAK;AAC1C,EAAA,MAAME,QAAQ,GAAGX,WAAS,KAAKE,mBAAS,CAACQ,QAAQ;AAEjD,EAAA,MAAME,OAAO,GAAGC,WAAK,EAAE;AAEvB,EAAA,MAAMC,eAAe,GAAGD,WAAK,EAAE;EAC/B,MAAME,OAAO,GAAGvB,EAAE,KAAK,IAAI,GAAIA,EAAE,IAAIsB,eAAe,GAAIE,SAAS;AAEjE,EAAA,MAAMC,SAAS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,CAAAI,mBAAA,EAAA;cAAA9B,QAAA,EAAA,cACEmB,cAAA,CAACY,WAAK,EAAA;AAACT,gBAAAA,GAAG,EAAEpB,QAAS;AAACf,gBAAAA,EAAE,EAAEoB,OAAQ;AAACyB,gBAAAA,OAAO,EAAEtB,OAAQ;gBAAAV,QAAA,EACjDX,QAAQ,GAAGD,KAAK,gBAAG+B,cAAA,CAACY,WAAK,CAACE,QAAQ,EAAA;AAAAjC,kBAAAA,QAAA,EAAEZ;iBAAsB;AAAC,eACvD,CACP,eAAA+B,cAAA,CAACY,WAAK,CAACG,WAAW,EAAA;AAAC/C,gBAAAA,EAAE,EAAE0B,aAAc;AAAAb,gBAAAA,QAAA,EAAEN;eAA+B,CACtE,eAAAyB,cAAA,CAAA,KAAA,EAAA;AAAKpB,gBAAAA,SAAS,EAAC,kBAAkB;AAAAC,gBAAAA,QAAA,EAAEA;AAAQ,eAAM,CACnD;aAAA,CAAG,GAEHA,QACD,EAEAV,OAAO,iBACN6B,cAAA,CAACgB,mBAAW,EAAA;AAACC,cAAAA,IAAI,EAAEzC,WAAU;AAACR,cAAAA,EAAE,EAAEyB,SAAU;AAACyB,cAAAA,SAAS,EAAE7C,gBAAiB;AAAAQ,cAAAA,QAAA,EACtEV;AAAO,aACG,CACd;WACE;SACe;OACE;KACJ;AAC1B,GAA2B,CAAC;AAEhC;;;;"}
@@ -23,7 +23,7 @@ import '@transferwise/icons';
23
23
  import 'react-intl';
24
24
  import '../common/closeButton/CloseButton.messages.mjs';
25
25
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
26
- import { InlinePrompt } from '../prompt/InlinePrompt/InlinePrompt.mjs';
26
+ import InlineAlert from '../inlineAlert/InlineAlert.mjs';
27
27
  import { FieldLabelContextProvider, InputIdContextProvider, InputDescribedByProvider, InputInvalidProvider } from '../inputs/contexts.mjs';
28
28
  import { Label as LabelNamespace } from '../label/Label.mjs';
29
29
 
@@ -96,8 +96,8 @@ const Field = ({
96
96
  className: "np-field-control",
97
97
  children: children
98
98
  })]
99
- }) : children, message && /*#__PURE__*/jsx(InlinePrompt, {
100
- sentiment: sentiment,
99
+ }) : children, message && /*#__PURE__*/jsx(InlineAlert, {
100
+ type: sentiment,
101
101
  id: messageId,
102
102
  iconLabel: messageIconLabel,
103
103
  children: message
@@ -1 +1 @@
1
- {"version":3,"file":"Field.mjs","sources":["../../src/field/Field.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useId, useRef } from 'react';\n\nimport { Sentiment } from '../common';\nimport { InlinePrompt } from '../prompt/InlinePrompt/InlinePrompt';\nimport {\n FieldLabelContextProvider,\n InputDescribedByProvider,\n InputIdContextProvider,\n InputInvalidProvider,\n} from '../inputs/contexts';\nimport { Label } from '../label';\n\nexport type FieldProps = {\n /** `null` disables auto-generating the `id` attribute, falling back to nesting-based label association over setting `htmlFor` explicitly. */\n id?: string | null;\n /** Should be specified unless the wrapped control has its own labeling mechanism, e.g. `Checkbox`. */\n label?: React.ReactNode;\n required?: boolean;\n /** @deprecated use `description` prop instead */\n hint?: React.ReactNode;\n message?: React.ReactNode;\n /**\n * Override for the [InlinePrompt icon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)\n * announced by the screen readers\n * */\n messageIconLabel?: string;\n description?: React.ReactNode;\n /** @deprecated use `message` and `type={Sentiment.NEGATIVE}` prop instead */\n error?: React.ReactNode;\n sentiment?: `${Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.POSITIVE | Sentiment.WARNING}`;\n className?: string;\n children?: React.ReactNode;\n};\n\nexport const Field = ({\n id,\n label,\n required = true,\n message: propMessage,\n messageIconLabel,\n hint,\n description = hint,\n sentiment: propType = Sentiment.NEUTRAL,\n className,\n children,\n ...props\n}: FieldProps) => {\n const labelRef = useRef<HTMLLabelElement>(null);\n const sentiment = props.error ? Sentiment.NEGATIVE : propType;\n const message = propMessage || props.error;\n const hasError = sentiment === Sentiment.NEGATIVE;\n\n const labelId = useId();\n\n const fallbackInputId = useId();\n const inputId = id !== null ? (id ?? fallbackInputId) : undefined;\n\n const messageId = useId();\n const descriptionId = useId();\n\n /**\n * form control can have multiple messages to describe it,\n * e.g the description underneath the label and inline alert\n */\n function ariaDescribedbyByIds() {\n const messageIds = [];\n if (description) {\n messageIds.push(descriptionId);\n }\n if (message) {\n messageIds.push(messageId);\n }\n return messageIds.length > 0 ? messageIds.join(' ') : undefined;\n }\n\n return (\n <FieldLabelContextProvider value={{ id: labelId, ref: labelRef }}>\n <InputIdContextProvider value={inputId}>\n <InputDescribedByProvider value={ariaDescribedbyByIds()}>\n <InputInvalidProvider value={hasError}>\n <div\n className={clsx(\n 'np-field form-group d-block',\n {\n 'has-success': sentiment === Sentiment.POSITIVE,\n 'has-warning': sentiment === Sentiment.WARNING,\n 'has-error': hasError,\n 'has-info': sentiment === Sentiment.NEUTRAL,\n },\n className,\n )}\n >\n {label != null ? (\n <>\n <Label ref={labelRef} id={labelId} htmlFor={inputId}>\n {required ? label : <Label.Optional>{label}</Label.Optional>}\n </Label>\n <Label.Description id={descriptionId}>{description}</Label.Description>\n <div className=\"np-field-control\">{children}</div>\n </>\n ) : (\n children\n )}\n\n {message && (\n <InlinePrompt sentiment={sentiment} id={messageId} iconLabel={messageIconLabel}>\n {message}\n </InlinePrompt>\n )}\n </div>\n </InputInvalidProvider>\n </InputDescribedByProvider>\n </InputIdContextProvider>\n </FieldLabelContextProvider>\n );\n};\n"],"names":["Field","id","label","required","message","propMessage","messageIconLabel","hint","description","sentiment","propType","Sentiment","NEUTRAL","className","children","props","labelRef","useRef","error","NEGATIVE","hasError","labelId","useId","fallbackInputId","inputId","undefined","messageId","descriptionId","ariaDescribedbyByIds","messageIds","push","length","join","_jsx","FieldLabelContextProvider","value","ref","InputIdContextProvider","InputDescribedByProvider","InputInvalidProvider","_jsxs","clsx","POSITIVE","WARNING","_Fragment","Label","htmlFor","Optional","Description","InlinePrompt","iconLabel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCO,MAAMA,KAA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AA,EAAA;AAAKpB,gBAAAA,SAAS,EAAC,kBAAkB;AAAAC,gBAAAA,QAAA,EAAEA;AAAQ,eAAM,CACnD;aAAA,CAAG,GAEHA,QACD,EAEAV,OAAO,iBACN6B,GAAA,CAACgB,YAAY,EAAA;AAACxC,cAAAA,SAAS,EAAEA,SAAU;AAACR,cAAAA,EAAE,EAAEyB,SAAU;AAACwB,cAAAA,SAAS,EAAE5C,gBAAiB;AAAAQ,cAAAA,QAAA,EAC5EV;AAAO,aACI,CACf;WACE;SACe;OACE;KACJ;AAC1B,GAA2B,CAAC;AAEhC;;;;"}
1
+ {"version":3,"file":"Field.mjs","sources":["../../src/field/Field.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useId, useRef } from 'react';\n\nimport { Sentiment } from '../common';\nimport InlineAlert from '../inlineAlert/InlineAlert';\nimport {\n FieldLabelContextProvider,\n InputDescribedByProvider,\n InputIdContextProvider,\n InputInvalidProvider,\n} from '../inputs/contexts';\nimport { Label } from '../label';\n\nexport type FieldProps = {\n /** `null` disables auto-generating the `id` attribute, falling back to nesting-based label association over setting `htmlFor` explicitly. */\n id?: string | null;\n /** Should be specified unless the wrapped control has its own labeling mechanism, e.g. `Checkbox`. */\n label?: React.ReactNode;\n required?: boolean;\n /** @deprecated use `description` prop instead */\n hint?: React.ReactNode;\n message?: React.ReactNode;\n /**\n * Override for the [InlineAlert icon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)\n * announced by the screen readers\n * */\n messageIconLabel?: string;\n description?: React.ReactNode;\n /** @deprecated use `message` and `type={Sentiment.NEGATIVE}` prop instead */\n error?: React.ReactNode;\n sentiment?: `${Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.POSITIVE | Sentiment.WARNING}`;\n className?: string;\n children?: React.ReactNode;\n};\n\nexport const Field = ({\n id,\n label,\n required = true,\n message: propMessage,\n messageIconLabel,\n hint,\n description = hint,\n sentiment: propType = Sentiment.NEUTRAL,\n className,\n children,\n ...props\n}: FieldProps) => {\n const labelRef = useRef<HTMLLabelElement>(null);\n const sentiment = props.error ? Sentiment.NEGATIVE : propType;\n const message = propMessage || props.error;\n const hasError = sentiment === Sentiment.NEGATIVE;\n\n const labelId = useId();\n\n const fallbackInputId = useId();\n const inputId = id !== null ? (id ?? fallbackInputId) : undefined;\n\n const messageId = useId();\n const descriptionId = useId();\n\n /**\n * form control can have multiple messages to describe it,\n * e.g the description underneath the label and inline alert\n */\n function ariaDescribedbyByIds() {\n const messageIds = [];\n if (description) {\n messageIds.push(descriptionId);\n }\n if (message) {\n messageIds.push(messageId);\n }\n return messageIds.length > 0 ? messageIds.join(' ') : undefined;\n }\n\n return (\n <FieldLabelContextProvider value={{ id: labelId, ref: labelRef }}>\n <InputIdContextProvider value={inputId}>\n <InputDescribedByProvider value={ariaDescribedbyByIds()}>\n <InputInvalidProvider value={hasError}>\n <div\n className={clsx(\n 'np-field form-group d-block',\n {\n 'has-success': sentiment === Sentiment.POSITIVE,\n 'has-warning': sentiment === Sentiment.WARNING,\n 'has-error': hasError,\n 'has-info': sentiment === Sentiment.NEUTRAL,\n },\n className,\n )}\n >\n {label != null ? (\n <>\n <Label ref={labelRef} id={labelId} htmlFor={inputId}>\n {required ? label : <Label.Optional>{label}</Label.Optional>}\n </Label>\n <Label.Description id={descriptionId}>{description}</Label.Description>\n <div className=\"np-field-control\">{children}</div>\n </>\n ) : (\n children\n )}\n\n {message && (\n <InlineAlert type={sentiment} id={messageId} iconLabel={messageIconLabel}>\n {message}\n </InlineAlert>\n )}\n </div>\n </InputInvalidProvider>\n </InputDescribedByProvider>\n </InputIdContextProvider>\n </FieldLabelContextProvider>\n );\n};\n"],"names":["Field","id","label","required","message","propMessage","messageIconLabel","hint","description","sentiment","propType","Sentiment","NEUTRAL","className","children","props","labelRef","useRef","error","NEGATIVE","hasError","labelId","useId","fallbackInputId","inputId","undefined","messageId","descriptionId","ariaDescribedbyByIds","messageIds","push","length","join","_jsx","FieldLabelContextProvider","value","ref","InputIdContextProvider","InputDescribedByProvider","InputInvalidProvider","_jsxs","clsx","POSITIVE","WARNING","_Fragment","Label","htmlFor","Optional","Description","InlineAlert","type","iconLabel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCO,MAAMA,KAAK,GAAGA,CAAC;EACpBC,EAAE;EACFC,KAAK;AACLC,EAAAA,QAAQ,GAAG,IAAI;AACfC,EAAAA,OAAO,EAAEC,WAAW;EACpBC,gBAAgB;EAChBC,IAAI;AACJC,EAAAA,WAAW,GAAGD,IAAI;AAClBE,EAAAA,SAAS,EAAEC,QAAQ,GAAGC,SAAS,CAACC,OAAO;EACvCC,SAAS;EACTC,QAAQ;EACR,GAAGC;AAAK,CACG,KAAI;AACf,EAAA,MAAMC,QAAQ,GAAGC,MAAM,CAAmB,IAAI,CAAC;EAC/C,MAAMR,SAAS,GAAGM,KAAK,CAACG,KAAK,GAAGP,SAAS,CAACQ,QAAQ,GAAGT,QAAQ;AAC7D,EAAA,MAAMN,OAAO,GAAGC,WAAW,IAAIU,KAAK,CAACG,KAAK;AAC1C,EAAA,MAAME,QAAQ,GAAGX,SAAS,KAAKE,SAAS,CAACQ,QAAQ;AAEjD,EAAA,MAAME,OAAO,GAAGC,KAAK,EAAE;AAEvB,EAAA,MAAMC,eAAe,GAAGD,KAAK,EAAE;EAC/B,MAAME,OAAO,GAAGvB,EAAE,KAAK,IAAI,GAAIA,EAAE,IAAIsB,eAAe,GAAIE,SAAS;AAEjE,EAAA,MAAMC,SAAS,GAAGJ,KAAK,EAAE;AACzB,EAAA,MAAMK,aAAa,GAAGL,KAAK,EAAE;AAE7B;;;AAGG;EACH,SAASM,oBAAoBA,GAAA;IAC3B,MAAMC,UAAU,GAAG,EAAE;AACrB,IAAA,IAAIrB,WAAW,EAAE;AACfqB,MAAAA,UAAU,CAACC,IAAI,CAACH,aAAa,CAAC;AAChC,IAAA;AACA,IAAA,IAAIvB,OAAO,EAAE;AACXyB,MAAAA,UAAU,CAACC,IAAI,CAACJ,SAA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,eACvD,CACP,eAAA+B,GAAA,CAACY,cAAK,CAACG,WAAW,EAAA;AAAC/C,gBAAAA,EAAE,EAAE0B,aAAc;AAAAb,gBAAAA,QAAA,EAAEN;eAA+B,CACtE,eAAAyB,GAAA,CAAA,KAAA,EAAA;AAAKpB,gBAAAA,SAAS,EAAC,kBAAkB;AAAAC,gBAAAA,QAAA,EAAEA;AAAQ,eAAM,CACnD;aAAA,CAAG,GAEHA,QACD,EAEAV,OAAO,iBACN6B,GAAA,CAACgB,WAAW,EAAA;AAACC,cAAAA,IAAI,EAAEzC,SAAU;AAACR,cAAAA,EAAE,EAAEyB,SAAU;AAACyB,cAAAA,SAAS,EAAE7C,gBAAiB;AAAAQ,cAAAA,QAAA,EACtEV;AAAO,aACG,CACd;WACE;SACe;OACE;KACJ;AAC1B,GAA2B,CAAC;AAEhC;;;;"}
package/build/main.css CHANGED
@@ -6920,10 +6920,6 @@ html:not([dir="rtl"]) .np-navigation-option {
6920
6920
  padding: 0;
6921
6921
  margin: 0;
6922
6922
  }
6923
- .typeahead--prompt {
6924
- margin-top: 4px;
6925
- margin-top: var(--size-4);
6926
- }
6927
6923
  .typeahead-sm.typeahead--multiple .typeahead__input-container {
6928
6924
  min-height: 32px;
6929
6925
  }
@@ -6920,10 +6920,6 @@ html:not([dir="rtl"]) .np-navigation-option {
6920
6920
  padding: 0;
6921
6921
  margin: 0;
6922
6922
  }
6923
- .typeahead--prompt {
6924
- margin-top: 4px;
6925
- margin-top: var(--size-4);
6926
- }
6927
6923
  .typeahead-sm.typeahead--multiple .typeahead__input-container {
6928
6924
  min-height: 32px;
6929
6925
  }
@@ -103,10 +103,6 @@
103
103
  padding: 0;
104
104
  margin: 0;
105
105
  }
106
- .typeahead--prompt {
107
- margin-top: 4px;
108
- margin-top: var(--size-4);
109
- }
110
106
  .typeahead-sm.typeahead--multiple .typeahead__input-container {
111
107
  min-height: 32px;
112
108
  }
@@ -31,7 +31,7 @@ require('../common/propsValues/markdownNodeType.js');
31
31
  require('../common/fileType.js');
32
32
  require('../common/closeButton/CloseButton.messages.js');
33
33
  var jsxRuntime = require('react/jsx-runtime');
34
- var InlinePrompt = require('../prompt/InlinePrompt/InlinePrompt.js');
34
+ var InlineAlert = require('../inlineAlert/InlineAlert.js');
35
35
  var contexts = require('../inputs/contexts.js');
36
36
  var TypeaheadInput = require('./typeaheadInput/TypeaheadInput.js');
37
37
  var TypeaheadOption = require('./typeaheadOption/TypeaheadOption.js');
@@ -427,20 +427,9 @@ class Typeahead extends React.Component {
427
427
  showNewEntry,
428
428
  dropdownOpen
429
429
  });
430
- const alertType = (() => {
431
- if (!alert?.type || alert.type === sentiment.Sentiment.INFO) {
432
- return sentiment.Sentiment.NEUTRAL;
433
- }
434
- if (alert.type === sentiment.Sentiment.ERROR) {
435
- return sentiment.Sentiment.NEGATIVE;
436
- }
437
- if (alert.type === sentiment.Sentiment.SUCCESS) {
438
- return sentiment.Sentiment.POSITIVE;
439
- }
440
- return alert.type;
441
- })();
442
- const hasError = errorState || alert && alertType === sentiment.Sentiment.NEGATIVE;
443
- const displayAlert = !errorState && alert || alert && alertType === sentiment.Sentiment.NEGATIVE;
430
+ const alertType = alert?.type ?? sentiment.Sentiment.NEUTRAL;
431
+ const hasError = errorState || alert && alertType === sentiment.Sentiment.ERROR;
432
+ const displayAlert = !errorState && alert || alert && alertType === sentiment.Sentiment.ERROR;
444
433
  const hasWarning = displayAlert && alertType === sentiment.Sentiment.WARNING;
445
434
  const hasInfo = displayAlert && alertType === sentiment.Sentiment.NEUTRAL;
446
435
  return /*#__PURE__*/ /* eslint-disable-next-line jsx-a11y/click-events-have-key-events */jsxRuntime.jsx("div", {
@@ -495,9 +484,8 @@ class Typeahead extends React.Component {
495
484
  children: /*#__PURE__*/jsxRuntime.jsx(icons.Cross, {})
496
485
  })
497
486
  })]
498
- }), displayAlert ? /*#__PURE__*/jsxRuntime.jsx(InlinePrompt.InlinePrompt, {
499
- sentiment: alertType,
500
- className: "typeahead--prompt",
487
+ }), displayAlert ? /*#__PURE__*/jsxRuntime.jsx(InlineAlert.default, {
488
+ type: alert.type,
501
489
  children: alert.message
502
490
  }) : menu]
503
491
  })
@@ -1 +1 @@
1
- {"version":3,"file":"Typeahead.js","sources":["../../src/typeahead/Typeahead.tsx"],"sourcesContent":["import { Cross as CrossIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { DebouncedFunc } from 'lodash';\nimport clamp from 'lodash.clamp';\nimport debounce from 'lodash.debounce';\nimport React, { Component, ReactNode } from 'react';\nimport { injectIntl, WrappedComponentProps } from 'react-intl';\n\nimport Chip from '../chips/Chip';\nimport {\n Size,\n Sentiment,\n SizeMedium,\n SizeLarge,\n addClickClassToDocumentOnIos,\n removeClickClassFromDocumentOnIos,\n stopPropagation,\n} from '../common';\nimport { InlinePrompt, InlinePromptProps } from '../prompt';\nimport { withInputAttributes, WithInputAttributesProps } from '../inputs/contexts';\n\nimport TypeaheadInput from './typeaheadInput/TypeaheadInput';\nimport TypeaheadOption from './typeaheadOption/TypeaheadOption';\nimport messages from './Typeahead.messages';\n\nconst DEFAULT_MIN_QUERY_LENGTH = 3;\nconst SEARCH_DELAY = 200;\n\nexport type TypeaheadOption<T = string> = {\n label: string;\n note?: string;\n secondary?: string;\n value?: T;\n clearQueryOnSelect?: boolean;\n keepFocusOnSelect?: boolean;\n};\n\nexport interface TypeaheadProps<T> extends Partial<WrappedComponentProps> {\n id: string;\n name: string;\n addon?: ReactNode;\n alert?: {\n message: InlinePromptProps['children'];\n type?:\n | InlinePromptProps['sentiment']\n | `${Sentiment.ERROR}`\n | `${Sentiment.INFO}`\n | `${Sentiment.SUCCESS}`;\n };\n allowNew?: boolean;\n autoFillOnBlur?: boolean;\n autoFocus?: boolean;\n chipSeparators?: readonly string[];\n clearable?: boolean;\n footer?: ReactNode;\n initialValue?: readonly TypeaheadOption<T>[];\n inputAutoComplete?: string;\n maxHeight?: number;\n minQueryLength?: number;\n placeholder?: string;\n multiple?: boolean;\n options: readonly TypeaheadOption<T>[];\n searchDelay?: number;\n showSuggestions?: boolean;\n showNewEntry?: boolean;\n size?: SizeMedium | SizeLarge;\n\n onBlur?: () => void;\n onChange: (options: TypeaheadOption<T>[]) => void;\n onFocus?: () => void;\n onInputChange?: (query: string) => void;\n onSearch?: (query: string) => void;\n validateChip?: (chip: TypeaheadOption<T>) => boolean;\n}\n\ntype TypeaheadPropsWithInputAttributes<T> = TypeaheadProps<T> &\n Partial<WithInputAttributesProps> &\n WrappedComponentProps;\n\ntype TypeaheadState<T> = {\n selected: readonly TypeaheadOption<T>[];\n keyboardFocusedOptionIndex: number | null;\n errorState: boolean;\n query: string;\n optionsShown: boolean;\n isFocused: boolean;\n};\n\nclass Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, TypeaheadState<T>> {\n declare props: TypeaheadPropsWithInputAttributes<T> &\n Required<Pick<TypeaheadPropsWithInputAttributes<T>, keyof typeof Typeahead.defaultProps>>;\n\n static defaultProps = {\n allowNew: false,\n autoFillOnBlur: true,\n autoFocus: false,\n chipSeparators: [],\n clearable: true,\n initialValue: [],\n inputAutoComplete: 'new-password',\n minQueryLength: DEFAULT_MIN_QUERY_LENGTH,\n multiple: false,\n searchDelay: SEARCH_DELAY,\n showSuggestions: true,\n showNewEntry: true,\n size: Size.MEDIUM,\n validateChip: () => true,\n } satisfies Partial<TypeaheadProps<unknown>>;\n optionRefs: (React.RefObject<HTMLLIElement> | null)[];\n\n constructor(props: TypeaheadPropsWithInputAttributes<T>) {\n super(props);\n const { searchDelay, initialValue, multiple } = this.props;\n this.handleSearchDebounced = debounce(this.handleSearch, searchDelay);\n const initialQuery = !multiple && initialValue.length > 0 ? initialValue[0].label : '';\n this.state = {\n selected: initialValue,\n errorState: false,\n query: initialQuery,\n keyboardFocusedOptionIndex: null,\n optionsShown: false,\n isFocused: false,\n };\n this.optionRefs = [] as (React.RefObject<HTMLLIElement> | null)[];\n }\n\n handleSearchDebounced: DebouncedFunc<Typeahead<T>['handleSearch']>;\n\n UNSAFE_componentWillReceiveProps(nextProps: TypeaheadPropsWithInputAttributes<T>) {\n if (nextProps.multiple !== this.props.multiple) {\n this.setState((previousState) => {\n const { selected } = previousState;\n if (!nextProps.multiple && selected.length > 0) {\n return {\n query: selected[0].label,\n selected: [selected[0]],\n };\n }\n return {\n selected: previousState.selected,\n query: '',\n };\n });\n }\n }\n\n componentWillUnmount() {\n this.handleSearchDebounced.cancel();\n }\n\n handleOnFocus = () => {\n this.showMenu();\n this.props.onFocus?.();\n };\n\n onOptionSelected = (event: React.MouseEvent, item: TypeaheadOption<T>) => {\n event.preventDefault();\n this.selectItem(item);\n };\n\n handleOnChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n const { optionsShown, selected } = this.state;\n const { multiple, onInputChange } = this.props;\n\n if (!optionsShown) {\n this.showMenu();\n }\n\n const query = event.target.value;\n\n if (!multiple && selected.length > 0) {\n this.updateSelectedValue([]);\n }\n\n this.setState({ query }, () => {\n this.handleSearchDebounced(query);\n if (onInputChange) {\n onInputChange(query);\n }\n });\n };\n\n handleOnPaste: React.ClipboardEventHandler<HTMLInputElement> = (event) => {\n const { allowNew, multiple, chipSeparators } = this.props;\n const { selected } = this.state;\n\n if (allowNew && multiple && chipSeparators.length > 0) {\n event.preventDefault();\n const value = event.clipboardData.getData('text');\n if (value) {\n const regex = new RegExp(chipSeparators.join('|'));\n const pastedChips = value\n .split(regex)\n .map((label) => ({ label: label.trim() }))\n .filter((chip) => chip.label);\n\n this.updateSelectedValue([...selected, ...pastedChips]);\n }\n }\n };\n\n handleOnKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {\n const { showSuggestions, allowNew, multiple, chipSeparators, options } = this.props;\n const { keyboardFocusedOptionIndex, query, selected } = this.state;\n const chipsMode = !showSuggestions && allowNew && multiple;\n\n if (chipsMode && ['Enter', 'Tab', ...chipSeparators].includes(event.key) && query.trim()) {\n event.preventDefault();\n this.selectItem({ label: query });\n } else {\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n this.moveFocusedOption(1);\n break;\n case 'ArrowUp':\n event.preventDefault();\n this.moveFocusedOption(-1);\n break;\n case 'Enter':\n event.preventDefault();\n if (keyboardFocusedOptionIndex != null && options[keyboardFocusedOptionIndex]) {\n this.selectItem(options[keyboardFocusedOptionIndex]);\n } else if (allowNew && query.trim()) {\n this.selectItem({ label: query });\n }\n break;\n case 'Backspace':\n if (multiple && !query && selected.length > 0) {\n this.updateSelectedValue(selected.slice(0, -1));\n }\n break;\n default:\n break;\n }\n }\n };\n moveFocusedOption(offset: number) {\n this.setState((previousState) => {\n const { keyboardFocusedOptionIndex } = previousState;\n const { options } = this.props;\n let index = 0;\n if (keyboardFocusedOptionIndex !== null) {\n index = clamp(keyboardFocusedOptionIndex + offset, 0, options.length - 1);\n }\n const optionRef = this.optionRefs[index];\n if (optionRef?.current) {\n optionRef.current.focus(); // Set focus on the option element\n }\n return {\n keyboardFocusedOptionIndex: index,\n };\n });\n }\n\n selectItem = (item: TypeaheadOption<T>) => {\n const { multiple } = this.props;\n let selected = [...this.state.selected];\n let query;\n if (multiple) {\n selected.push(item);\n query = '';\n } else {\n selected = [item];\n query = item.label;\n }\n\n this.updateSelectedValue(selected);\n\n if (!item.keepFocusOnSelect) {\n this.hideMenu();\n }\n\n if (item.clearQueryOnSelect) {\n query = '';\n }\n\n this.setState({\n query,\n });\n };\n\n handleSearch = (query: string) => {\n const { onSearch } = this.props;\n if (onSearch) {\n onSearch(query);\n }\n\n this.setState((previousState) => ({\n keyboardFocusedOptionIndex: previousState.keyboardFocusedOptionIndex === null ? null : 0,\n }));\n };\n\n handleDocumentClick = () => {\n if (this.state.optionsShown) {\n this.hideMenu();\n const { allowNew, onBlur, autoFillOnBlur } = this.props;\n const { query } = this.state;\n this.setState({\n isFocused: false,\n });\n if (allowNew && autoFillOnBlur && query.trim()) {\n this.selectItem({ label: query });\n }\n\n if (onBlur) {\n onBlur();\n }\n }\n };\n\n showMenu = () => {\n this.setState(\n {\n isFocused: true,\n optionsShown: true,\n },\n () => {\n addClickClassToDocumentOnIos();\n document.addEventListener('click', this.handleDocumentClick, false);\n },\n );\n };\n\n hideMenu = () => {\n this.setState(\n {\n optionsShown: false,\n keyboardFocusedOptionIndex: null,\n },\n () => {\n removeClickClassFromDocumentOnIos();\n document.removeEventListener('click', this.handleDocumentClick, false);\n },\n );\n };\n\n updateSelectedValue = (selected: readonly TypeaheadOption<T>[]) => {\n const { onChange, validateChip } = this.props;\n\n const errorState = selected.some((chip) => !validateChip(chip));\n this.setState({ selected, errorState }, () => {\n onChange([...selected]);\n });\n };\n\n clear = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n if (this.state.selected.length > 0) {\n this.updateSelectedValue([]);\n }\n\n this.setState({\n query: '',\n });\n };\n\n removeChip = (option: TypeaheadOption<T>) => {\n const { selected } = this.state;\n\n if (selected.length > 0) {\n this.updateSelectedValue([...selected.filter((selectedOption) => selectedOption !== option)]);\n }\n };\n\n renderChip = (option: TypeaheadOption<T>, idx: number): ReactNode => {\n const valid = this.props.validateChip?.(option);\n\n return (\n <Chip\n key={idx}\n label={option.label}\n className={clsx('m-t-1', {\n 'has-error': !valid,\n 'np-chip--valid': valid,\n })}\n onRemove={() => this.removeChip(option)}\n />\n );\n };\n\n renderMenu = ({\n footer,\n options,\n id,\n keyboardFocusedOptionIndex,\n query,\n allowNew,\n showNewEntry,\n dropdownOpen,\n }: Pick<\n TypeaheadPropsWithInputAttributes<T>,\n 'footer' | 'options' | 'id' | 'allowNew' | 'showNewEntry'\n > &\n Pick<TypeaheadState<T>, 'keyboardFocusedOptionIndex' | 'query'> & {\n dropdownOpen: boolean;\n }) => {\n const optionsToRender = [...options];\n if (\n allowNew &&\n query.trim() &&\n options.every((option) => option.label.trim().toUpperCase() !== query.trim().toUpperCase()) &&\n showNewEntry\n ) {\n optionsToRender.push({\n label: query,\n });\n }\n return (\n <div\n className={clsx('dropdown btn-group btn-block', { open: dropdownOpen })}\n id={`menu-${id}`}\n >\n {(!!optionsToRender.length || footer) && (\n <ul className=\"dropdown-menu\" role=\"menu\">\n {optionsToRender.map((option, idx) => {\n const ref = React.createRef<HTMLLIElement>();\n this.optionRefs[idx] = ref;\n return (\n <TypeaheadOption\n key={`${option.label}${idx.toString()}`}\n ref={ref}\n query={query}\n option={option}\n selected={keyboardFocusedOptionIndex === idx}\n id={String(option.label.replace(/\\s+/g, '-'))}\n onClick={(event) => {\n this.onOptionSelected(event, option);\n }}\n />\n );\n })}\n {footer}\n </ul>\n )}\n </div>\n );\n };\n\n render() {\n const {\n inputAttributes,\n id: idProp,\n placeholder,\n multiple,\n size,\n addon,\n name,\n clearable,\n allowNew,\n footer,\n showSuggestions,\n showNewEntry,\n options,\n minQueryLength,\n autoFocus,\n maxHeight,\n alert,\n inputAutoComplete,\n } = this.props;\n const id = idProp ?? inputAttributes?.id;\n\n const { errorState, query, selected, optionsShown, keyboardFocusedOptionIndex } = this.state;\n\n const clearButton = clearable && (query || selected.length > 0);\n\n const dropdownOpen = optionsShown && showSuggestions && query.length >= minQueryLength;\n\n const menu = this.renderMenu({\n footer,\n options,\n id,\n keyboardFocusedOptionIndex,\n query,\n allowNew,\n showNewEntry,\n dropdownOpen,\n });\n\n const alertType = (() => {\n if (!alert?.type || alert.type === Sentiment.INFO) {\n return Sentiment.NEUTRAL;\n }\n if (alert.type === Sentiment.ERROR) {\n return Sentiment.NEGATIVE;\n }\n if (alert.type === Sentiment.SUCCESS) {\n return Sentiment.POSITIVE;\n }\n return alert.type;\n })();\n const hasError = errorState || (alert && alertType === Sentiment.NEGATIVE);\n const displayAlert = (!errorState && alert) || (alert && alertType === Sentiment.NEGATIVE);\n const hasWarning = displayAlert && alertType === Sentiment.WARNING;\n const hasInfo = displayAlert && alertType === Sentiment.NEUTRAL;\n return (\n /* eslint-disable-next-line jsx-a11y/click-events-have-key-events */\n <div\n role=\"group\"\n {...inputAttributes}\n id={id}\n className={clsx('typeahead', `typeahead-${size}`, {\n 'typeahead--has-value': selected.length > 0,\n 'typeahead--empty': selected.length === 0,\n 'typeahead--multiple': multiple,\n open: dropdownOpen,\n })}\n onClick={stopPropagation}\n >\n <div\n className={clsx('form-group', {\n 'has-error': hasError,\n 'has-warning': hasWarning,\n 'has-info': hasInfo,\n })}\n >\n <div\n className={clsx(`input-group input-group-${size}`, {\n 'input-group--has-error': hasError,\n })}\n >\n {addon && <span className=\"input-group-addon input-group-addon--search\">{addon}</span>}\n\n <TypeaheadInput\n {...{\n autoFocus,\n multiple,\n dropdownOpen,\n placeholder,\n selected,\n maxHeight,\n }}\n id={id}\n name={name}\n value={query}\n typeaheadId={id}\n renderChip={this.renderChip}\n autoComplete={inputAutoComplete}\n ariaActivedescendant={\n keyboardFocusedOptionIndex !== null && options[keyboardFocusedOptionIndex]\n ? `option-${options[keyboardFocusedOptionIndex].label.replace(/\\s+/g, '-')}`\n : undefined\n }\n onChange={this.handleOnChange}\n onKeyDown={this.handleOnKeyDown}\n onFocus={this.handleOnFocus}\n onPaste={this.handleOnPaste}\n />\n\n {clearButton && (\n <div className=\"input-group-addon\">\n <button\n type=\"button\"\n className=\"btn-unstyled\"\n aria-label={this.props?.intl?.formatMessage(messages.clearLabel)}\n onClick={this.clear}\n >\n <CrossIcon />\n </button>\n </div>\n )}\n </div>\n {displayAlert ? (\n <InlinePrompt sentiment={alertType} className=\"typeahead--prompt\">\n {alert.message}\n </InlinePrompt>\n ) : (\n menu\n )}\n </div>\n </div>\n );\n }\n}\n\nexport default injectIntl(withInputAttributes(Typeahead, { nonLabelable: true })) as <T>(\n props: TypeaheadProps<T>,\n) => React.ReactElement;\n"],"names":["DEFAULT_MIN_QUERY_LENGTH","SEARCH_DELAY","Typeahead","Component","defaultProps","allowNew","autoFillOnBlur","autoFocus","chipSeparators","clearable","initialValue","inputAutoComplete","minQueryLength","multiple","searchDelay","showSuggestions","showNewEntry","size","Size","MEDIUM","validateChip","optionRefs","constructor","props","handleSearchDebounced","debounce","handleSearch","initialQuery","length","label","state","selected","errorState","query","keyboardFocusedOptionIndex","optionsShown","isFocused","UNSAFE_componentWillReceiveProps","nextProps","setState","previousState","componentWillUnmount","cancel","handleOnFocus","showMenu","onFocus","onOptionSelected","event","item","preventDefault","selectItem","handleOnChange","onInputChange","target","value","updateSelectedValue","handleOnPaste","clipboardData","getData","regex","RegExp","join","pastedChips","split","map","trim","filter","chip","handleOnKeyDown","options","chipsMode","includes","key","moveFocusedOption","slice","offset","index","clamp","optionRef","current","focus","push","keepFocusOnSelect","hideMenu","clearQueryOnSelect","onSearch","handleDocumentClick","onBlur","addClickClassToDocumentOnIos","document","addEventListener","removeClickClassFromDocumentOnIos","removeEventListener","onChange","some","clear","removeChip","option","selectedOption","renderChip","idx","valid","_jsx","Chip","className","clsx","onRemove","renderMenu","footer","id","dropdownOpen","optionsToRender","every","toUpperCase","open","children","_jsxs","role","ref","React","createRef","TypeaheadOption","String","replace","onClick","toString","render","inputAttributes","idProp","placeholder","addon","name","maxHeight","alert","clearButton","menu","alertType","type","Sentiment","INFO","NEUTRAL","ERROR","NEGATIVE","SUCCESS","POSITIVE","hasError","displayAlert","hasWarning","WARNING","hasInfo","stopPropagation","TypeaheadInput","typeaheadId","autoComplete","ariaActivedescendant","undefined","onKeyDown","onPaste","intl","formatMessage","messages","clearLabel","CrossIcon","InlinePrompt","sentiment","message","injectIntl","withInputAttributes","nonLabelable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAMA,wBAAwB,GAAG,CAAC;AAClC,MAAMC,YAAY,GAAG,GAAG;AA8DxB,MAAMC,SAAa,SAAQC,eAAkE,CAAA;AAI3F,EAAA,OAAOC,YAAY,GAAG;AACpBC,IAAAA,QAAQ,EAAE,KAAK;AACfC,IAAAA,cAAc,EAAE,IAAI;AACpBC,IAAAA,SAAS,EAAE,KAAK;AAChBC,IAAAA,cAAc,EAAE,EAAE;AAClBC,IAAAA,SAAS,EAAE,IAAI;AACfC,IAAAA,YAAY,EAAE,EAAE;AAChBC,I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U,CAAE;cACjErC,OAAO,EAAE,IAAI,CAAC7B,KAAM;AAAAoB,cAAAA,QAAA,eAEpBb,cAAA,CAAC4D,WAAS,EAAA,EAAA;aACJ;AACV,WAAK,CACN;AAAA,SACE,CACL,EAAChB,YAAY,gBACX5C,cAAA,CAAC6D,yBAAY,EAAA;AAACC,UAAAA,SAAS,EAAE5B,SAAU;AAAChC,UAAAA,SAAS,EAAC,mBAAmB;UAAAW,QAAA,EAC9DkB,KAAK,CAACgC;SACK,CAAC,GAEf9B,IACD;OACE;AACP,KAAK,CAAC;AAEV,EAAA;;AAGF,wBAAe+B,oBAAU,CAACC,4BAAmB,CAACrK,SAAS,EAAE;AAAEsK,EAAAA,YAAY,EAAE;AAAI,CAAE,CAAC,CAEzD;;;;"}
1
+ {"version":3,"file":"Typeahead.js","sources":["../../src/typeahead/Typeahead.tsx"],"sourcesContent":["import { Cross as CrossIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { DebouncedFunc } from 'lodash';\nimport clamp from 'lodash.clamp';\nimport debounce from 'lodash.debounce';\nimport React, { Component, ReactNode } from 'react';\nimport { injectIntl, WrappedComponentProps } from 'react-intl';\n\nimport Chip from '../chips/Chip';\nimport {\n Size,\n Sentiment,\n SizeMedium,\n SizeLarge,\n addClickClassToDocumentOnIos,\n removeClickClassFromDocumentOnIos,\n stopPropagation,\n} from '../common';\nimport InlineAlert from '../inlineAlert';\nimport { InlineAlertProps } from '../inlineAlert/InlineAlert';\nimport { withInputAttributes, WithInputAttributesProps } from '../inputs/contexts';\n\nimport TypeaheadInput from './typeaheadInput/TypeaheadInput';\nimport TypeaheadOption from './typeaheadOption/TypeaheadOption';\nimport messages from './Typeahead.messages';\n\nconst DEFAULT_MIN_QUERY_LENGTH = 3;\nconst SEARCH_DELAY = 200;\n\nexport type TypeaheadOption<T = string> = {\n label: string;\n note?: string;\n secondary?: string;\n value?: T;\n clearQueryOnSelect?: boolean;\n keepFocusOnSelect?: boolean;\n};\n\nexport interface TypeaheadProps<T> extends Partial<WrappedComponentProps> {\n id: string;\n name: string;\n addon?: ReactNode;\n alert?: {\n message: InlineAlertProps['children'];\n type?: InlineAlertProps['type'];\n };\n allowNew?: boolean;\n autoFillOnBlur?: boolean;\n autoFocus?: boolean;\n chipSeparators?: readonly string[];\n clearable?: boolean;\n footer?: ReactNode;\n initialValue?: readonly TypeaheadOption<T>[];\n inputAutoComplete?: string;\n maxHeight?: number;\n minQueryLength?: number;\n placeholder?: string;\n multiple?: boolean;\n options: readonly TypeaheadOption<T>[];\n searchDelay?: number;\n showSuggestions?: boolean;\n showNewEntry?: boolean;\n size?: SizeMedium | SizeLarge;\n\n onBlur?: () => void;\n onChange: (options: TypeaheadOption<T>[]) => void;\n onFocus?: () => void;\n onInputChange?: (query: string) => void;\n onSearch?: (query: string) => void;\n validateChip?: (chip: TypeaheadOption<T>) => boolean;\n}\n\ntype TypeaheadPropsWithInputAttributes<T> = TypeaheadProps<T> &\n Partial<WithInputAttributesProps> &\n WrappedComponentProps;\n\ntype TypeaheadState<T> = {\n selected: readonly TypeaheadOption<T>[];\n keyboardFocusedOptionIndex: number | null;\n errorState: boolean;\n query: string;\n optionsShown: boolean;\n isFocused: boolean;\n};\n\nclass Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, TypeaheadState<T>> {\n declare props: TypeaheadPropsWithInputAttributes<T> &\n Required<Pick<TypeaheadPropsWithInputAttributes<T>, keyof typeof Typeahead.defaultProps>>;\n\n static defaultProps = {\n allowNew: false,\n autoFillOnBlur: true,\n autoFocus: false,\n chipSeparators: [],\n clearable: true,\n initialValue: [],\n inputAutoComplete: 'new-password',\n minQueryLength: DEFAULT_MIN_QUERY_LENGTH,\n multiple: false,\n searchDelay: SEARCH_DELAY,\n showSuggestions: true,\n showNewEntry: true,\n size: Size.MEDIUM,\n validateChip: () => true,\n } satisfies Partial<TypeaheadProps<unknown>>;\n optionRefs: (React.RefObject<HTMLLIElement> | null)[];\n\n constructor(props: TypeaheadPropsWithInputAttributes<T>) {\n super(props);\n const { searchDelay, initialValue, multiple } = this.props;\n this.handleSearchDebounced = debounce(this.handleSearch, searchDelay);\n const initialQuery = !multiple && initialValue.length > 0 ? initialValue[0].label : '';\n this.state = {\n selected: initialValue,\n errorState: false,\n query: initialQuery,\n keyboardFocusedOptionIndex: null,\n optionsShown: false,\n isFocused: false,\n };\n this.optionRefs = [] as (React.RefObject<HTMLLIElement> | null)[];\n }\n\n handleSearchDebounced: DebouncedFunc<Typeahead<T>['handleSearch']>;\n\n UNSAFE_componentWillReceiveProps(nextProps: TypeaheadPropsWithInputAttributes<T>) {\n if (nextProps.multiple !== this.props.multiple) {\n this.setState((previousState) => {\n const { selected } = previousState;\n if (!nextProps.multiple && selected.length > 0) {\n return {\n query: selected[0].label,\n selected: [selected[0]],\n };\n }\n return {\n selected: previousState.selected,\n query: '',\n };\n });\n }\n }\n\n componentWillUnmount() {\n this.handleSearchDebounced.cancel();\n }\n\n handleOnFocus = () => {\n this.showMenu();\n this.props.onFocus?.();\n };\n\n onOptionSelected = (event: React.MouseEvent, item: TypeaheadOption<T>) => {\n event.preventDefault();\n this.selectItem(item);\n };\n\n handleOnChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n const { optionsShown, selected } = this.state;\n const { multiple, onInputChange } = this.props;\n\n if (!optionsShown) {\n this.showMenu();\n }\n\n const query = event.target.value;\n\n if (!multiple && selected.length > 0) {\n this.updateSelectedValue([]);\n }\n\n this.setState({ query }, () => {\n this.handleSearchDebounced(query);\n if (onInputChange) {\n onInputChange(query);\n }\n });\n };\n\n handleOnPaste: React.ClipboardEventHandler<HTMLInputElement> = (event) => {\n const { allowNew, multiple, chipSeparators } = this.props;\n const { selected } = this.state;\n\n if (allowNew && multiple && chipSeparators.length > 0) {\n event.preventDefault();\n const value = event.clipboardData.getData('text');\n if (value) {\n const regex = new RegExp(chipSeparators.join('|'));\n const pastedChips = value\n .split(regex)\n .map((label) => ({ label: label.trim() }))\n .filter((chip) => chip.label);\n\n this.updateSelectedValue([...selected, ...pastedChips]);\n }\n }\n };\n\n handleOnKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {\n const { showSuggestions, allowNew, multiple, chipSeparators, options } = this.props;\n const { keyboardFocusedOptionIndex, query, selected } = this.state;\n const chipsMode = !showSuggestions && allowNew && multiple;\n\n if (chipsMode && ['Enter', 'Tab', ...chipSeparators].includes(event.key) && query.trim()) {\n event.preventDefault();\n this.selectItem({ label: query });\n } else {\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n this.moveFocusedOption(1);\n break;\n case 'ArrowUp':\n event.preventDefault();\n this.moveFocusedOption(-1);\n break;\n case 'Enter':\n event.preventDefault();\n if (keyboardFocusedOptionIndex != null && options[keyboardFocusedOptionIndex]) {\n this.selectItem(options[keyboardFocusedOptionIndex]);\n } else if (allowNew && query.trim()) {\n this.selectItem({ label: query });\n }\n break;\n case 'Backspace':\n if (multiple && !query && selected.length > 0) {\n this.updateSelectedValue(selected.slice(0, -1));\n }\n break;\n default:\n break;\n }\n }\n };\n moveFocusedOption(offset: number) {\n this.setState((previousState) => {\n const { keyboardFocusedOptionIndex } = previousState;\n const { options } = this.props;\n let index = 0;\n if (keyboardFocusedOptionIndex !== null) {\n index = clamp(keyboardFocusedOptionIndex + offset, 0, options.length - 1);\n }\n const optionRef = this.optionRefs[index];\n if (optionRef?.current) {\n optionRef.current.focus(); // Set focus on the option element\n }\n return {\n keyboardFocusedOptionIndex: index,\n };\n });\n }\n\n selectItem = (item: TypeaheadOption<T>) => {\n const { multiple } = this.props;\n let selected = [...this.state.selected];\n let query;\n if (multiple) {\n selected.push(item);\n query = '';\n } else {\n selected = [item];\n query = item.label;\n }\n\n this.updateSelectedValue(selected);\n\n if (!item.keepFocusOnSelect) {\n this.hideMenu();\n }\n\n if (item.clearQueryOnSelect) {\n query = '';\n }\n\n this.setState({\n query,\n });\n };\n\n handleSearch = (query: string) => {\n const { onSearch } = this.props;\n if (onSearch) {\n onSearch(query);\n }\n\n this.setState((previousState) => ({\n keyboardFocusedOptionIndex: previousState.keyboardFocusedOptionIndex === null ? null : 0,\n }));\n };\n\n handleDocumentClick = () => {\n if (this.state.optionsShown) {\n this.hideMenu();\n const { allowNew, onBlur, autoFillOnBlur } = this.props;\n const { query } = this.state;\n this.setState({\n isFocused: false,\n });\n if (allowNew && autoFillOnBlur && query.trim()) {\n this.selectItem({ label: query });\n }\n\n if (onBlur) {\n onBlur();\n }\n }\n };\n\n showMenu = () => {\n this.setState(\n {\n isFocused: true,\n optionsShown: true,\n },\n () => {\n addClickClassToDocumentOnIos();\n document.addEventListener('click', this.handleDocumentClick, false);\n },\n );\n };\n\n hideMenu = () => {\n this.setState(\n {\n optionsShown: false,\n keyboardFocusedOptionIndex: null,\n },\n () => {\n removeClickClassFromDocumentOnIos();\n document.removeEventListener('click', this.handleDocumentClick, false);\n },\n );\n };\n\n updateSelectedValue = (selected: readonly TypeaheadOption<T>[]) => {\n const { onChange, validateChip } = this.props;\n\n const errorState = selected.some((chip) => !validateChip(chip));\n this.setState({ selected, errorState }, () => {\n onChange([...selected]);\n });\n };\n\n clear = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n if (this.state.selected.length > 0) {\n this.updateSelectedValue([]);\n }\n\n this.setState({\n query: '',\n });\n };\n\n removeChip = (option: TypeaheadOption<T>) => {\n const { selected } = this.state;\n\n if (selected.length > 0) {\n this.updateSelectedValue([...selected.filter((selectedOption) => selectedOption !== option)]);\n }\n };\n\n renderChip = (option: TypeaheadOption<T>, idx: number): ReactNode => {\n const valid = this.props.validateChip?.(option);\n\n return (\n <Chip\n key={idx}\n label={option.label}\n className={clsx('m-t-1', {\n 'has-error': !valid,\n 'np-chip--valid': valid,\n })}\n onRemove={() => this.removeChip(option)}\n />\n );\n };\n\n renderMenu = ({\n footer,\n options,\n id,\n keyboardFocusedOptionIndex,\n query,\n allowNew,\n showNewEntry,\n dropdownOpen,\n }: Pick<\n TypeaheadPropsWithInputAttributes<T>,\n 'footer' | 'options' | 'id' | 'allowNew' | 'showNewEntry'\n > &\n Pick<TypeaheadState<T>, 'keyboardFocusedOptionIndex' | 'query'> & {\n dropdownOpen: boolean;\n }) => {\n const optionsToRender = [...options];\n if (\n allowNew &&\n query.trim() &&\n options.every((option) => option.label.trim().toUpperCase() !== query.trim().toUpperCase()) &&\n showNewEntry\n ) {\n optionsToRender.push({\n label: query,\n });\n }\n return (\n <div\n className={clsx('dropdown btn-group btn-block', { open: dropdownOpen })}\n id={`menu-${id}`}\n >\n {(!!optionsToRender.length || footer) && (\n <ul className=\"dropdown-menu\" role=\"menu\">\n {optionsToRender.map((option, idx) => {\n const ref = React.createRef<HTMLLIElement>();\n this.optionRefs[idx] = ref;\n return (\n <TypeaheadOption\n key={`${option.label}${idx.toString()}`}\n ref={ref}\n query={query}\n option={option}\n selected={keyboardFocusedOptionIndex === idx}\n id={String(option.label.replace(/\\s+/g, '-'))}\n onClick={(event) => {\n this.onOptionSelected(event, option);\n }}\n />\n );\n })}\n {footer}\n </ul>\n )}\n </div>\n );\n };\n\n render() {\n const {\n inputAttributes,\n id: idProp,\n placeholder,\n multiple,\n size,\n addon,\n name,\n clearable,\n allowNew,\n footer,\n showSuggestions,\n showNewEntry,\n options,\n minQueryLength,\n autoFocus,\n maxHeight,\n alert,\n inputAutoComplete,\n } = this.props;\n const id = idProp ?? inputAttributes?.id;\n\n const { errorState, query, selected, optionsShown, keyboardFocusedOptionIndex } = this.state;\n\n const clearButton = clearable && (query || selected.length > 0);\n\n const dropdownOpen = optionsShown && showSuggestions && query.length >= minQueryLength;\n\n const menu = this.renderMenu({\n footer,\n options,\n id,\n keyboardFocusedOptionIndex,\n query,\n allowNew,\n showNewEntry,\n dropdownOpen,\n });\n\n const alertType = alert?.type ?? Sentiment.NEUTRAL;\n const hasError = errorState || (alert && alertType === Sentiment.ERROR);\n const displayAlert = (!errorState && alert) || (alert && alertType === Sentiment.ERROR);\n const hasWarning = displayAlert && alertType === Sentiment.WARNING;\n const hasInfo = displayAlert && alertType === Sentiment.NEUTRAL;\n return (\n /* eslint-disable-next-line jsx-a11y/click-events-have-key-events */\n <div\n role=\"group\"\n {...inputAttributes}\n id={id}\n className={clsx('typeahead', `typeahead-${size}`, {\n 'typeahead--has-value': selected.length > 0,\n 'typeahead--empty': selected.length === 0,\n 'typeahead--multiple': multiple,\n open: dropdownOpen,\n })}\n onClick={stopPropagation}\n >\n <div\n className={clsx('form-group', {\n 'has-error': hasError,\n 'has-warning': hasWarning,\n 'has-info': hasInfo,\n })}\n >\n <div\n className={clsx(`input-group input-group-${size}`, {\n 'input-group--has-error': hasError,\n })}\n >\n {addon && <span className=\"input-group-addon input-group-addon--search\">{addon}</span>}\n\n <TypeaheadInput\n {...{\n autoFocus,\n multiple,\n dropdownOpen,\n placeholder,\n selected,\n maxHeight,\n }}\n id={id}\n name={name}\n value={query}\n typeaheadId={id}\n renderChip={this.renderChip}\n autoComplete={inputAutoComplete}\n ariaActivedescendant={\n keyboardFocusedOptionIndex !== null && options[keyboardFocusedOptionIndex]\n ? `option-${options[keyboardFocusedOptionIndex].label.replace(/\\s+/g, '-')}`\n : undefined\n }\n onChange={this.handleOnChange}\n onKeyDown={this.handleOnKeyDown}\n onFocus={this.handleOnFocus}\n onPaste={this.handleOnPaste}\n />\n\n {clearButton && (\n <div className=\"input-group-addon\">\n <button\n type=\"button\"\n className=\"btn-unstyled\"\n aria-label={this.props?.intl?.formatMessage(messages.clearLabel)}\n onClick={this.clear}\n >\n <CrossIcon />\n </button>\n </div>\n )}\n </div>\n {displayAlert ? <InlineAlert type={alert.type}>{alert.message}</InlineAlert> : menu}\n </div>\n </div>\n );\n }\n}\n\nexport default injectIntl(withInputAttributes(Typeahead, { nonLabelable: true })) as <T>(\n props: TypeaheadProps<T>,\n) => React.ReactElement;\n"],"names":["DEFAULT_MIN_QUERY_LENGTH","SEARCH_DELAY","Typeahead","Component","defaultProps","allowNew","autoFillOnBlur","autoFocus","chipSeparators","clearable","initialValue","inputAutoComplete","minQueryLength","multiple","searchDelay","showSuggestions","showNewEntry","size","Size","MEDIUM","validateChip","optionRefs","constructor","props","handleSearchDebounced","debounce","handleSearch","initialQuery","length","label","state","selected","errorState","query","keyboardFocusedOptionIndex","optionsShown","isFocused","UNSAFE_componentWillReceiveProps","nextProps","setState","previousState","componentWillUnmount","cancel","handleOnFocus","showMenu","onFocus","onOptionSelected","event","item","preventDefault","selectItem","handleOnChange","onInputChange","target","value","updateSelectedValue","handleOnPaste","clipboardData","getData","regex","RegExp","join","pastedChips","split","map","trim","filter","chip","handleOnKeyDown","options","chipsMode","includes","key","moveFocusedOption","slice","offset","index","clamp","optionRef","current","focus","push","keepFocusOnSelect","hideMenu","clearQueryOnSelect","onSearch","handleDocumentClick","onBlur","addClickClassToDocumentOnIos","document","addEventListener","removeClickClassFromDocumentOnIos","removeEventListener","onChange","some","clear","removeChip","option","selectedOption","renderChip","idx","valid","_jsx","Chip","className","clsx","onRemove","renderMenu","footer","id","dropdownOpen","optionsToRender","every","toUpperCase","open","children","_jsxs","role","ref","React","createRef","TypeaheadOption","String","replace","onClick","toString","render","inputAttributes","idProp","placeholder","addon","name","maxHeight","alert","clearButton","menu","alertType","type","Sentiment","NEUTRAL","hasError","ERROR","displayAlert","hasWarning","WARNING","hasInfo","stopPropagation","TypeaheadInput","typeaheadId","autoComplete","ariaActivedescendant","undefined","onKeyDown","onPaste","intl","formatMessage","messages","clearLabel","CrossIcon","InlineAlert","message","injectIntl","withInputAttributes","nonLabelable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAMA,wBAAwB,GAAG,CAAC;AAClC,MAAMC,YAAY,GAAG,GAAG;AA0DxB,MAAMC,SAAa,SAAQC,eAAkE,CAAA;AAI3F,EAAA,OAAOC,YAAY,GAAG;AACpBC,IAAAA,QAAQ,EAAE,KAAK;AACfC,IAAAA,cAAc,EAAE,IAAI;AACpBC,IAAAA,SAAS,EAAE,KAAK;AAChBC,IAAAA,cA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AK,CAAC;AAEV,EAAA;;AAGF,wBAAe0B,oBAAU,CAACC,4BAAmB,CAAChK,SAAS,EAAE;AAAEiK,EAAAA,YAAY,EAAE;AAAI,CAAE,CAAC,CAEzD;;;;"}
@@ -27,7 +27,7 @@ import '../common/propsValues/markdownNodeType.mjs';
27
27
  import '../common/fileType.mjs';
28
28
  import '../common/closeButton/CloseButton.messages.mjs';
29
29
  import { jsx, jsxs } from 'react/jsx-runtime';
30
- import { InlinePrompt } from '../prompt/InlinePrompt/InlinePrompt.mjs';
30
+ import InlineAlert from '../inlineAlert/InlineAlert.mjs';
31
31
  import { withInputAttributes } from '../inputs/contexts.mjs';
32
32
  import TypeaheadInput from './typeaheadInput/TypeaheadInput.mjs';
33
33
  import Option from './typeaheadOption/TypeaheadOption.mjs';
@@ -417,20 +417,9 @@ class Typeahead extends Component {
417
417
  showNewEntry,
418
418
  dropdownOpen
419
419
  });
420
- const alertType = (() => {
421
- if (!alert?.type || alert.type === Sentiment.INFO) {
422
- return Sentiment.NEUTRAL;
423
- }
424
- if (alert.type === Sentiment.ERROR) {
425
- return Sentiment.NEGATIVE;
426
- }
427
- if (alert.type === Sentiment.SUCCESS) {
428
- return Sentiment.POSITIVE;
429
- }
430
- return alert.type;
431
- })();
432
- const hasError = errorState || alert && alertType === Sentiment.NEGATIVE;
433
- const displayAlert = !errorState && alert || alert && alertType === Sentiment.NEGATIVE;
420
+ const alertType = alert?.type ?? Sentiment.NEUTRAL;
421
+ const hasError = errorState || alert && alertType === Sentiment.ERROR;
422
+ const displayAlert = !errorState && alert || alert && alertType === Sentiment.ERROR;
434
423
  const hasWarning = displayAlert && alertType === Sentiment.WARNING;
435
424
  const hasInfo = displayAlert && alertType === Sentiment.NEUTRAL;
436
425
  return /*#__PURE__*/ /* eslint-disable-next-line jsx-a11y/click-events-have-key-events */jsx("div", {
@@ -485,9 +474,8 @@ class Typeahead extends Component {
485
474
  children: /*#__PURE__*/jsx(Cross, {})
486
475
  })
487
476
  })]
488
- }), displayAlert ? /*#__PURE__*/jsx(InlinePrompt, {
489
- sentiment: alertType,
490
- className: "typeahead--prompt",
477
+ }), displayAlert ? /*#__PURE__*/jsx(InlineAlert, {
478
+ type: alert.type,
491
479
  children: alert.message
492
480
  }) : menu]
493
481
  })
@@ -1 +1 @@
1
- {"version":3,"file":"Typeahead.mjs","sources":["../../src/typeahead/Typeahead.tsx"],"sourcesContent":["import { Cross as CrossIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { DebouncedFunc } from 'lodash';\nimport clamp from 'lodash.clamp';\nimport debounce from 'lodash.debounce';\nimport React, { Component, ReactNode } from 'react';\nimport { injectIntl, WrappedComponentProps } from 'react-intl';\n\nimport Chip from '../chips/Chip';\nimport {\n Size,\n Sentiment,\n SizeMedium,\n SizeLarge,\n addClickClassToDocumentOnIos,\n removeClickClassFromDocumentOnIos,\n stopPropagation,\n} from '../common';\nimport { InlinePrompt, InlinePromptProps } from '../prompt';\nimport { withInputAttributes, WithInputAttributesProps } from '../inputs/contexts';\n\nimport TypeaheadInput from './typeaheadInput/TypeaheadInput';\nimport TypeaheadOption from './typeaheadOption/TypeaheadOption';\nimport messages from './Typeahead.messages';\n\nconst DEFAULT_MIN_QUERY_LENGTH = 3;\nconst SEARCH_DELAY = 200;\n\nexport type TypeaheadOption<T = string> = {\n label: string;\n note?: string;\n secondary?: string;\n value?: T;\n clearQueryOnSelect?: boolean;\n keepFocusOnSelect?: boolean;\n};\n\nexport interface TypeaheadProps<T> extends Partial<WrappedComponentProps> {\n id: string;\n name: string;\n addon?: ReactNode;\n alert?: {\n message: InlinePromptProps['children'];\n type?:\n | InlinePromptProps['sentiment']\n | `${Sentiment.ERROR}`\n | `${Sentiment.INFO}`\n | `${Sentiment.SUCCESS}`;\n };\n allowNew?: boolean;\n autoFillOnBlur?: boolean;\n autoFocus?: boolean;\n chipSeparators?: readonly string[];\n clearable?: boolean;\n footer?: ReactNode;\n initialValue?: readonly TypeaheadOption<T>[];\n inputAutoComplete?: string;\n maxHeight?: number;\n minQueryLength?: number;\n placeholder?: string;\n multiple?: boolean;\n options: readonly TypeaheadOption<T>[];\n searchDelay?: number;\n showSuggestions?: boolean;\n showNewEntry?: boolean;\n size?: SizeMedium | SizeLarge;\n\n onBlur?: () => void;\n onChange: (options: TypeaheadOption<T>[]) => void;\n onFocus?: () => void;\n onInputChange?: (query: string) => void;\n onSearch?: (query: string) => void;\n validateChip?: (chip: TypeaheadOption<T>) => boolean;\n}\n\ntype TypeaheadPropsWithInputAttributes<T> = TypeaheadProps<T> &\n Partial<WithInputAttributesProps> &\n WrappedComponentProps;\n\ntype TypeaheadState<T> = {\n selected: readonly TypeaheadOption<T>[];\n keyboardFocusedOptionIndex: number | null;\n errorState: boolean;\n query: string;\n optionsShown: boolean;\n isFocused: boolean;\n};\n\nclass Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, TypeaheadState<T>> {\n declare props: TypeaheadPropsWithInputAttributes<T> &\n Required<Pick<TypeaheadPropsWithInputAttributes<T>, keyof typeof Typeahead.defaultProps>>;\n\n static defaultProps = {\n allowNew: false,\n autoFillOnBlur: true,\n autoFocus: false,\n chipSeparators: [],\n clearable: true,\n initialValue: [],\n inputAutoComplete: 'new-password',\n minQueryLength: DEFAULT_MIN_QUERY_LENGTH,\n multiple: false,\n searchDelay: SEARCH_DELAY,\n showSuggestions: true,\n showNewEntry: true,\n size: Size.MEDIUM,\n validateChip: () => true,\n } satisfies Partial<TypeaheadProps<unknown>>;\n optionRefs: (React.RefObject<HTMLLIElement> | null)[];\n\n constructor(props: TypeaheadPropsWithInputAttributes<T>) {\n super(props);\n const { searchDelay, initialValue, multiple } = this.props;\n this.handleSearchDebounced = debounce(this.handleSearch, searchDelay);\n const initialQuery = !multiple && initialValue.length > 0 ? initialValue[0].label : '';\n this.state = {\n selected: initialValue,\n errorState: false,\n query: initialQuery,\n keyboardFocusedOptionIndex: null,\n optionsShown: false,\n isFocused: false,\n };\n this.optionRefs = [] as (React.RefObject<HTMLLIElement> | null)[];\n }\n\n handleSearchDebounced: DebouncedFunc<Typeahead<T>['handleSearch']>;\n\n UNSAFE_componentWillReceiveProps(nextProps: TypeaheadPropsWithInputAttributes<T>) {\n if (nextProps.multiple !== this.props.multiple) {\n this.setState((previousState) => {\n const { selected } = previousState;\n if (!nextProps.multiple && selected.length > 0) {\n return {\n query: selected[0].label,\n selected: [selected[0]],\n };\n }\n return {\n selected: previousState.selected,\n query: '',\n };\n });\n }\n }\n\n componentWillUnmount() {\n this.handleSearchDebounced.cancel();\n }\n\n handleOnFocus = () => {\n this.showMenu();\n this.props.onFocus?.();\n };\n\n onOptionSelected = (event: React.MouseEvent, item: TypeaheadOption<T>) => {\n event.preventDefault();\n this.selectItem(item);\n };\n\n handleOnChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n const { optionsShown, selected } = this.state;\n const { multiple, onInputChange } = this.props;\n\n if (!optionsShown) {\n this.showMenu();\n }\n\n const query = event.target.value;\n\n if (!multiple && selected.length > 0) {\n this.updateSelectedValue([]);\n }\n\n this.setState({ query }, () => {\n this.handleSearchDebounced(query);\n if (onInputChange) {\n onInputChange(query);\n }\n });\n };\n\n handleOnPaste: React.ClipboardEventHandler<HTMLInputElement> = (event) => {\n const { allowNew, multiple, chipSeparators } = this.props;\n const { selected } = this.state;\n\n if (allowNew && multiple && chipSeparators.length > 0) {\n event.preventDefault();\n const value = event.clipboardData.getData('text');\n if (value) {\n const regex = new RegExp(chipSeparators.join('|'));\n const pastedChips = value\n .split(regex)\n .map((label) => ({ label: label.trim() }))\n .filter((chip) => chip.label);\n\n this.updateSelectedValue([...selected, ...pastedChips]);\n }\n }\n };\n\n handleOnKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {\n const { showSuggestions, allowNew, multiple, chipSeparators, options } = this.props;\n const { keyboardFocusedOptionIndex, query, selected } = this.state;\n const chipsMode = !showSuggestions && allowNew && multiple;\n\n if (chipsMode && ['Enter', 'Tab', ...chipSeparators].includes(event.key) && query.trim()) {\n event.preventDefault();\n this.selectItem({ label: query });\n } else {\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n this.moveFocusedOption(1);\n break;\n case 'ArrowUp':\n event.preventDefault();\n this.moveFocusedOption(-1);\n break;\n case 'Enter':\n event.preventDefault();\n if (keyboardFocusedOptionIndex != null && options[keyboardFocusedOptionIndex]) {\n this.selectItem(options[keyboardFocusedOptionIndex]);\n } else if (allowNew && query.trim()) {\n this.selectItem({ label: query });\n }\n break;\n case 'Backspace':\n if (multiple && !query && selected.length > 0) {\n this.updateSelectedValue(selected.slice(0, -1));\n }\n break;\n default:\n break;\n }\n }\n };\n moveFocusedOption(offset: number) {\n this.setState((previousState) => {\n const { keyboardFocusedOptionIndex } = previousState;\n const { options } = this.props;\n let index = 0;\n if (keyboardFocusedOptionIndex !== null) {\n index = clamp(keyboardFocusedOptionIndex + offset, 0, options.length - 1);\n }\n const optionRef = this.optionRefs[index];\n if (optionRef?.current) {\n optionRef.current.focus(); // Set focus on the option element\n }\n return {\n keyboardFocusedOptionIndex: index,\n };\n });\n }\n\n selectItem = (item: TypeaheadOption<T>) => {\n const { multiple } = this.props;\n let selected = [...this.state.selected];\n let query;\n if (multiple) {\n selected.push(item);\n query = '';\n } else {\n selected = [item];\n query = item.label;\n }\n\n this.updateSelectedValue(selected);\n\n if (!item.keepFocusOnSelect) {\n this.hideMenu();\n }\n\n if (item.clearQueryOnSelect) {\n query = '';\n }\n\n this.setState({\n query,\n });\n };\n\n handleSearch = (query: string) => {\n const { onSearch } = this.props;\n if (onSearch) {\n onSearch(query);\n }\n\n this.setState((previousState) => ({\n keyboardFocusedOptionIndex: previousState.keyboardFocusedOptionIndex === null ? null : 0,\n }));\n };\n\n handleDocumentClick = () => {\n if (this.state.optionsShown) {\n this.hideMenu();\n const { allowNew, onBlur, autoFillOnBlur } = this.props;\n const { query } = this.state;\n this.setState({\n isFocused: false,\n });\n if (allowNew && autoFillOnBlur && query.trim()) {\n this.selectItem({ label: query });\n }\n\n if (onBlur) {\n onBlur();\n }\n }\n };\n\n showMenu = () => {\n this.setState(\n {\n isFocused: true,\n optionsShown: true,\n },\n () => {\n addClickClassToDocumentOnIos();\n document.addEventListener('click', this.handleDocumentClick, false);\n },\n );\n };\n\n hideMenu = () => {\n this.setState(\n {\n optionsShown: false,\n keyboardFocusedOptionIndex: null,\n },\n () => {\n removeClickClassFromDocumentOnIos();\n document.removeEventListener('click', this.handleDocumentClick, false);\n },\n );\n };\n\n updateSelectedValue = (selected: readonly TypeaheadOption<T>[]) => {\n const { onChange, validateChip } = this.props;\n\n const errorState = selected.some((chip) => !validateChip(chip));\n this.setState({ selected, errorState }, () => {\n onChange([...selected]);\n });\n };\n\n clear = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n if (this.state.selected.length > 0) {\n this.updateSelectedValue([]);\n }\n\n this.setState({\n query: '',\n });\n };\n\n removeChip = (option: TypeaheadOption<T>) => {\n const { selected } = this.state;\n\n if (selected.length > 0) {\n this.updateSelectedValue([...selected.filter((selectedOption) => selectedOption !== option)]);\n }\n };\n\n renderChip = (option: TypeaheadOption<T>, idx: number): ReactNode => {\n const valid = this.props.validateChip?.(option);\n\n return (\n <Chip\n key={idx}\n label={option.label}\n className={clsx('m-t-1', {\n 'has-error': !valid,\n 'np-chip--valid': valid,\n })}\n onRemove={() => this.removeChip(option)}\n />\n );\n };\n\n renderMenu = ({\n footer,\n options,\n id,\n keyboardFocusedOptionIndex,\n query,\n allowNew,\n showNewEntry,\n dropdownOpen,\n }: Pick<\n TypeaheadPropsWithInputAttributes<T>,\n 'footer' | 'options' | 'id' | 'allowNew' | 'showNewEntry'\n > &\n Pick<TypeaheadState<T>, 'keyboardFocusedOptionIndex' | 'query'> & {\n dropdownOpen: boolean;\n }) => {\n const optionsToRender = [...options];\n if (\n allowNew &&\n query.trim() &&\n options.every((option) => option.label.trim().toUpperCase() !== query.trim().toUpperCase()) &&\n showNewEntry\n ) {\n optionsToRender.push({\n label: query,\n });\n }\n return (\n <div\n className={clsx('dropdown btn-group btn-block', { open: dropdownOpen })}\n id={`menu-${id}`}\n >\n {(!!optionsToRender.length || footer) && (\n <ul className=\"dropdown-menu\" role=\"menu\">\n {optionsToRender.map((option, idx) => {\n const ref = React.createRef<HTMLLIElement>();\n this.optionRefs[idx] = ref;\n return (\n <TypeaheadOption\n key={`${option.label}${idx.toString()}`}\n ref={ref}\n query={query}\n option={option}\n selected={keyboardFocusedOptionIndex === idx}\n id={String(option.label.replace(/\\s+/g, '-'))}\n onClick={(event) => {\n this.onOptionSelected(event, option);\n }}\n />\n );\n })}\n {footer}\n </ul>\n )}\n </div>\n );\n };\n\n render() {\n const {\n inputAttributes,\n id: idProp,\n placeholder,\n multiple,\n size,\n addon,\n name,\n clearable,\n allowNew,\n footer,\n showSuggestions,\n showNewEntry,\n options,\n minQueryLength,\n autoFocus,\n maxHeight,\n alert,\n inputAutoComplete,\n } = this.props;\n const id = idProp ?? inputAttributes?.id;\n\n const { errorState, query, selected, optionsShown, keyboardFocusedOptionIndex } = this.state;\n\n const clearButton = clearable && (query || selected.length > 0);\n\n const dropdownOpen = optionsShown && showSuggestions && query.length >= minQueryLength;\n\n const menu = this.renderMenu({\n footer,\n options,\n id,\n keyboardFocusedOptionIndex,\n query,\n allowNew,\n showNewEntry,\n dropdownOpen,\n });\n\n const alertType = (() => {\n if (!alert?.type || alert.type === Sentiment.INFO) {\n return Sentiment.NEUTRAL;\n }\n if (alert.type === Sentiment.ERROR) {\n return Sentiment.NEGATIVE;\n }\n if (alert.type === Sentiment.SUCCESS) {\n return Sentiment.POSITIVE;\n }\n return alert.type;\n })();\n const hasError = errorState || (alert && alertType === Sentiment.NEGATIVE);\n const displayAlert = (!errorState && alert) || (alert && alertType === Sentiment.NEGATIVE);\n const hasWarning = displayAlert && alertType === Sentiment.WARNING;\n const hasInfo = displayAlert && alertType === Sentiment.NEUTRAL;\n return (\n /* eslint-disable-next-line jsx-a11y/click-events-have-key-events */\n <div\n role=\"group\"\n {...inputAttributes}\n id={id}\n className={clsx('typeahead', `typeahead-${size}`, {\n 'typeahead--has-value': selected.length > 0,\n 'typeahead--empty': selected.length === 0,\n 'typeahead--multiple': multiple,\n open: dropdownOpen,\n })}\n onClick={stopPropagation}\n >\n <div\n className={clsx('form-group', {\n 'has-error': hasError,\n 'has-warning': hasWarning,\n 'has-info': hasInfo,\n })}\n >\n <div\n className={clsx(`input-group input-group-${size}`, {\n 'input-group--has-error': hasError,\n })}\n >\n {addon && <span className=\"input-group-addon input-group-addon--search\">{addon}</span>}\n\n <TypeaheadInput\n {...{\n autoFocus,\n multiple,\n dropdownOpen,\n placeholder,\n selected,\n maxHeight,\n }}\n id={id}\n name={name}\n value={query}\n typeaheadId={id}\n renderChip={this.renderChip}\n autoComplete={inputAutoComplete}\n ariaActivedescendant={\n keyboardFocusedOptionIndex !== null && options[keyboardFocusedOptionIndex]\n ? `option-${options[keyboardFocusedOptionIndex].label.replace(/\\s+/g, '-')}`\n : undefined\n }\n onChange={this.handleOnChange}\n onKeyDown={this.handleOnKeyDown}\n onFocus={this.handleOnFocus}\n onPaste={this.handleOnPaste}\n />\n\n {clearButton && (\n <div className=\"input-group-addon\">\n <button\n type=\"button\"\n className=\"btn-unstyled\"\n aria-label={this.props?.intl?.formatMessage(messages.clearLabel)}\n onClick={this.clear}\n >\n <CrossIcon />\n </button>\n </div>\n )}\n </div>\n {displayAlert ? (\n <InlinePrompt sentiment={alertType} className=\"typeahead--prompt\">\n {alert.message}\n </InlinePrompt>\n ) : (\n menu\n )}\n </div>\n </div>\n );\n }\n}\n\nexport default injectIntl(withInputAttributes(Typeahead, { nonLabelable: true })) as <T>(\n props: TypeaheadProps<T>,\n) => React.ReactElement;\n"],"names":["DEFAULT_MIN_QUERY_LENGTH","SEARCH_DELAY","Typeahead","Component","defaultProps","allowNew","autoFillOnBlur","autoFocus","chipSeparators","clearable","initialValue","inputAutoComplete","minQueryLength","multiple","searchDelay","showSuggestions","showNewEntry","size","Size","MEDIUM","validateChip","optionRefs","constructor","props","handleSearchDebounced","debounce","handleSearch","initialQuery","length","label","state","selected","errorState","query","keyboardFocusedOptionIndex","optionsShown","isFocused","UNSAFE_componentWillReceiveProps","nextProps","setState","previousState","componentWillUnmount","cancel","handleOnFocus","showMenu","onFocus","onOptionSelected","event","item","preventDefault","selectItem","handleOnChange","onInputChange","target","value","updateSelectedValue","handleOnPaste","clipboardData","getData","regex","RegExp","join","pastedChips","split","map","trim","filter","chip","handleOnKeyDown","options","chipsMode","includes","key","moveFocusedOption","slice","offset","index","clamp","optionRef","current","focus","push","keepFocusOnSelect","hideMenu","clearQueryOnSelect","onSearch","handleDocumentClick","onBlur","addClickClassToDocumentOnIos","document","addEventListener","removeClickClassFromDocumentOnIos","removeEventListener","onChange","some","clear","removeChip","option","selectedOption","renderChip","idx","valid","_jsx","Chip","className","clsx","onRemove","renderMenu","footer","id","dropdownOpen","optionsToRender","every","toUpperCase","open","children","_jsxs","role","ref","React","createRef","TypeaheadOption","String","replace","onClick","toString","render","inputAttributes","idProp","placeholder","addon","name","maxHeight","alert","clearButton","menu","alertType","type","Sentiment","INFO","NEUTRAL","ERROR","NEGATIVE","SUCCESS","POSITIVE","hasError","displayAlert","hasWarning","WARNING","hasInfo","stopPropagation","TypeaheadInput","typeaheadId","autoComplete","ariaActivedescendant","undefined","onKeyDown","onPaste","intl","formatMessage","messages","clearLabel","CrossIcon","InlinePrompt","sentiment","message","injectIntl","withInputAttributes","nonLabelable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAMA,wBAAwB,GAAG,CAAC;AAClC,MAAMC,YAAY,GAAG,GAAG;AA8DxB,MAAMC,SAAa,SAAQC,SAAkE,CAAA;AAI3F,EAAA,OAAOC,YAAY,GAAG;AACpBC,IAAAA,QAAQ,EAAE,KAAK;AACfC,IAAAA,cAAc,EAAE,IAAI;AACpBC,IAAAA,SAAS,EAAE,KAAK;AAChBC,IAAAA,cAAc,EAAE,EAAE;AAClBC,IAAA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AI,EAAEC,aAAa,CAACC,QAAQ,CAACC,UAAU,CAAE;cACjErC,OAAO,EAAE,IAAI,CAAC7B,KAAM;AAAAoB,cAAAA,QAAA,eAEpBb,GAAA,CAAC4D,KAAS,EAAA,EAAA;aACJ;AACV,WAAK,CACN;AAAA,SACE,CACL,EAAChB,YAAY,gBACX5C,GAAA,CAAC6D,YAAY,EAAA;AAACC,UAAAA,SAAS,EAAE5B,SAAU;AAAChC,UAAAA,SAAS,EAAC,mBAAmB;UAAAW,QAAA,EAC9DkB,KAAK,CAACgC;SACK,CAAC,GAEf9B,IACD;OACE;AACP,KAAK,CAAC;AAEV,EAAA;;AAGF,wBAAe+B,UAAU,CAACC,mBAAmB,CAACrK,SAAS,EAAE;AAAEsK,EAAAA,YAAY,EAAE;AAAI,CAAE,CAAC,CAEzD;;;;"}
1
+ {"version":3,"file":"Typeahead.mjs","sources":["../../src/typeahead/Typeahead.tsx"],"sourcesContent":["import { Cross as CrossIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { DebouncedFunc } from 'lodash';\nimport clamp from 'lodash.clamp';\nimport debounce from 'lodash.debounce';\nimport React, { Component, ReactNode } from 'react';\nimport { injectIntl, WrappedComponentProps } from 'react-intl';\n\nimport Chip from '../chips/Chip';\nimport {\n Size,\n Sentiment,\n SizeMedium,\n SizeLarge,\n addClickClassToDocumentOnIos,\n removeClickClassFromDocumentOnIos,\n stopPropagation,\n} from '../common';\nimport InlineAlert from '../inlineAlert';\nimport { InlineAlertProps } from '../inlineAlert/InlineAlert';\nimport { withInputAttributes, WithInputAttributesProps } from '../inputs/contexts';\n\nimport TypeaheadInput from './typeaheadInput/TypeaheadInput';\nimport TypeaheadOption from './typeaheadOption/TypeaheadOption';\nimport messages from './Typeahead.messages';\n\nconst DEFAULT_MIN_QUERY_LENGTH = 3;\nconst SEARCH_DELAY = 200;\n\nexport type TypeaheadOption<T = string> = {\n label: string;\n note?: string;\n secondary?: string;\n value?: T;\n clearQueryOnSelect?: boolean;\n keepFocusOnSelect?: boolean;\n};\n\nexport interface TypeaheadProps<T> extends Partial<WrappedComponentProps> {\n id: string;\n name: string;\n addon?: ReactNode;\n alert?: {\n message: InlineAlertProps['children'];\n type?: InlineAlertProps['type'];\n };\n allowNew?: boolean;\n autoFillOnBlur?: boolean;\n autoFocus?: boolean;\n chipSeparators?: readonly string[];\n clearable?: boolean;\n footer?: ReactNode;\n initialValue?: readonly TypeaheadOption<T>[];\n inputAutoComplete?: string;\n maxHeight?: number;\n minQueryLength?: number;\n placeholder?: string;\n multiple?: boolean;\n options: readonly TypeaheadOption<T>[];\n searchDelay?: number;\n showSuggestions?: boolean;\n showNewEntry?: boolean;\n size?: SizeMedium | SizeLarge;\n\n onBlur?: () => void;\n onChange: (options: TypeaheadOption<T>[]) => void;\n onFocus?: () => void;\n onInputChange?: (query: string) => void;\n onSearch?: (query: string) => void;\n validateChip?: (chip: TypeaheadOption<T>) => boolean;\n}\n\ntype TypeaheadPropsWithInputAttributes<T> = TypeaheadProps<T> &\n Partial<WithInputAttributesProps> &\n WrappedComponentProps;\n\ntype TypeaheadState<T> = {\n selected: readonly TypeaheadOption<T>[];\n keyboardFocusedOptionIndex: number | null;\n errorState: boolean;\n query: string;\n optionsShown: boolean;\n isFocused: boolean;\n};\n\nclass Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, TypeaheadState<T>> {\n declare props: TypeaheadPropsWithInputAttributes<T> &\n Required<Pick<TypeaheadPropsWithInputAttributes<T>, keyof typeof Typeahead.defaultProps>>;\n\n static defaultProps = {\n allowNew: false,\n autoFillOnBlur: true,\n autoFocus: false,\n chipSeparators: [],\n clearable: true,\n initialValue: [],\n inputAutoComplete: 'new-password',\n minQueryLength: DEFAULT_MIN_QUERY_LENGTH,\n multiple: false,\n searchDelay: SEARCH_DELAY,\n showSuggestions: true,\n showNewEntry: true,\n size: Size.MEDIUM,\n validateChip: () => true,\n } satisfies Partial<TypeaheadProps<unknown>>;\n optionRefs: (React.RefObject<HTMLLIElement> | null)[];\n\n constructor(props: TypeaheadPropsWithInputAttributes<T>) {\n super(props);\n const { searchDelay, initialValue, multiple } = this.props;\n this.handleSearchDebounced = debounce(this.handleSearch, searchDelay);\n const initialQuery = !multiple && initialValue.length > 0 ? initialValue[0].label : '';\n this.state = {\n selected: initialValue,\n errorState: false,\n query: initialQuery,\n keyboardFocusedOptionIndex: null,\n optionsShown: false,\n isFocused: false,\n };\n this.optionRefs = [] as (React.RefObject<HTMLLIElement> | null)[];\n }\n\n handleSearchDebounced: DebouncedFunc<Typeahead<T>['handleSearch']>;\n\n UNSAFE_componentWillReceiveProps(nextProps: TypeaheadPropsWithInputAttributes<T>) {\n if (nextProps.multiple !== this.props.multiple) {\n this.setState((previousState) => {\n const { selected } = previousState;\n if (!nextProps.multiple && selected.length > 0) {\n return {\n query: selected[0].label,\n selected: [selected[0]],\n };\n }\n return {\n selected: previousState.selected,\n query: '',\n };\n });\n }\n }\n\n componentWillUnmount() {\n this.handleSearchDebounced.cancel();\n }\n\n handleOnFocus = () => {\n this.showMenu();\n this.props.onFocus?.();\n };\n\n onOptionSelected = (event: React.MouseEvent, item: TypeaheadOption<T>) => {\n event.preventDefault();\n this.selectItem(item);\n };\n\n handleOnChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n const { optionsShown, selected } = this.state;\n const { multiple, onInputChange } = this.props;\n\n if (!optionsShown) {\n this.showMenu();\n }\n\n const query = event.target.value;\n\n if (!multiple && selected.length > 0) {\n this.updateSelectedValue([]);\n }\n\n this.setState({ query }, () => {\n this.handleSearchDebounced(query);\n if (onInputChange) {\n onInputChange(query);\n }\n });\n };\n\n handleOnPaste: React.ClipboardEventHandler<HTMLInputElement> = (event) => {\n const { allowNew, multiple, chipSeparators } = this.props;\n const { selected } = this.state;\n\n if (allowNew && multiple && chipSeparators.length > 0) {\n event.preventDefault();\n const value = event.clipboardData.getData('text');\n if (value) {\n const regex = new RegExp(chipSeparators.join('|'));\n const pastedChips = value\n .split(regex)\n .map((label) => ({ label: label.trim() }))\n .filter((chip) => chip.label);\n\n this.updateSelectedValue([...selected, ...pastedChips]);\n }\n }\n };\n\n handleOnKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {\n const { showSuggestions, allowNew, multiple, chipSeparators, options } = this.props;\n const { keyboardFocusedOptionIndex, query, selected } = this.state;\n const chipsMode = !showSuggestions && allowNew && multiple;\n\n if (chipsMode && ['Enter', 'Tab', ...chipSeparators].includes(event.key) && query.trim()) {\n event.preventDefault();\n this.selectItem({ label: query });\n } else {\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n this.moveFocusedOption(1);\n break;\n case 'ArrowUp':\n event.preventDefault();\n this.moveFocusedOption(-1);\n break;\n case 'Enter':\n event.preventDefault();\n if (keyboardFocusedOptionIndex != null && options[keyboardFocusedOptionIndex]) {\n this.selectItem(options[keyboardFocusedOptionIndex]);\n } else if (allowNew && query.trim()) {\n this.selectItem({ label: query });\n }\n break;\n case 'Backspace':\n if (multiple && !query && selected.length > 0) {\n this.updateSelectedValue(selected.slice(0, -1));\n }\n break;\n default:\n break;\n }\n }\n };\n moveFocusedOption(offset: number) {\n this.setState((previousState) => {\n const { keyboardFocusedOptionIndex } = previousState;\n const { options } = this.props;\n let index = 0;\n if (keyboardFocusedOptionIndex !== null) {\n index = clamp(keyboardFocusedOptionIndex + offset, 0, options.length - 1);\n }\n const optionRef = this.optionRefs[index];\n if (optionRef?.current) {\n optionRef.current.focus(); // Set focus on the option element\n }\n return {\n keyboardFocusedOptionIndex: index,\n };\n });\n }\n\n selectItem = (item: TypeaheadOption<T>) => {\n const { multiple } = this.props;\n let selected = [...this.state.selected];\n let query;\n if (multiple) {\n selected.push(item);\n query = '';\n } else {\n selected = [item];\n query = item.label;\n }\n\n this.updateSelectedValue(selected);\n\n if (!item.keepFocusOnSelect) {\n this.hideMenu();\n }\n\n if (item.clearQueryOnSelect) {\n query = '';\n }\n\n this.setState({\n query,\n });\n };\n\n handleSearch = (query: string) => {\n const { onSearch } = this.props;\n if (onSearch) {\n onSearch(query);\n }\n\n this.setState((previousState) => ({\n keyboardFocusedOptionIndex: previousState.keyboardFocusedOptionIndex === null ? null : 0,\n }));\n };\n\n handleDocumentClick = () => {\n if (this.state.optionsShown) {\n this.hideMenu();\n const { allowNew, onBlur, autoFillOnBlur } = this.props;\n const { query } = this.state;\n this.setState({\n isFocused: false,\n });\n if (allowNew && autoFillOnBlur && query.trim()) {\n this.selectItem({ label: query });\n }\n\n if (onBlur) {\n onBlur();\n }\n }\n };\n\n showMenu = () => {\n this.setState(\n {\n isFocused: true,\n optionsShown: true,\n },\n () => {\n addClickClassToDocumentOnIos();\n document.addEventListener('click', this.handleDocumentClick, false);\n },\n );\n };\n\n hideMenu = () => {\n this.setState(\n {\n optionsShown: false,\n keyboardFocusedOptionIndex: null,\n },\n () => {\n removeClickClassFromDocumentOnIos();\n document.removeEventListener('click', this.handleDocumentClick, false);\n },\n );\n };\n\n updateSelectedValue = (selected: readonly TypeaheadOption<T>[]) => {\n const { onChange, validateChip } = this.props;\n\n const errorState = selected.some((chip) => !validateChip(chip));\n this.setState({ selected, errorState }, () => {\n onChange([...selected]);\n });\n };\n\n clear = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n if (this.state.selected.length > 0) {\n this.updateSelectedValue([]);\n }\n\n this.setState({\n query: '',\n });\n };\n\n removeChip = (option: TypeaheadOption<T>) => {\n const { selected } = this.state;\n\n if (selected.length > 0) {\n this.updateSelectedValue([...selected.filter((selectedOption) => selectedOption !== option)]);\n }\n };\n\n renderChip = (option: TypeaheadOption<T>, idx: number): ReactNode => {\n const valid = this.props.validateChip?.(option);\n\n return (\n <Chip\n key={idx}\n label={option.label}\n className={clsx('m-t-1', {\n 'has-error': !valid,\n 'np-chip--valid': valid,\n })}\n onRemove={() => this.removeChip(option)}\n />\n );\n };\n\n renderMenu = ({\n footer,\n options,\n id,\n keyboardFocusedOptionIndex,\n query,\n allowNew,\n showNewEntry,\n dropdownOpen,\n }: Pick<\n TypeaheadPropsWithInputAttributes<T>,\n 'footer' | 'options' | 'id' | 'allowNew' | 'showNewEntry'\n > &\n Pick<TypeaheadState<T>, 'keyboardFocusedOptionIndex' | 'query'> & {\n dropdownOpen: boolean;\n }) => {\n const optionsToRender = [...options];\n if (\n allowNew &&\n query.trim() &&\n options.every((option) => option.label.trim().toUpperCase() !== query.trim().toUpperCase()) &&\n showNewEntry\n ) {\n optionsToRender.push({\n label: query,\n });\n }\n return (\n <div\n className={clsx('dropdown btn-group btn-block', { open: dropdownOpen })}\n id={`menu-${id}`}\n >\n {(!!optionsToRender.length || footer) && (\n <ul className=\"dropdown-menu\" role=\"menu\">\n {optionsToRender.map((option, idx) => {\n const ref = React.createRef<HTMLLIElement>();\n this.optionRefs[idx] = ref;\n return (\n <TypeaheadOption\n key={`${option.label}${idx.toString()}`}\n ref={ref}\n query={query}\n option={option}\n selected={keyboardFocusedOptionIndex === idx}\n id={String(option.label.replace(/\\s+/g, '-'))}\n onClick={(event) => {\n this.onOptionSelected(event, option);\n }}\n />\n );\n })}\n {footer}\n </ul>\n )}\n </div>\n );\n };\n\n render() {\n const {\n inputAttributes,\n id: idProp,\n placeholder,\n multiple,\n size,\n addon,\n name,\n clearable,\n allowNew,\n footer,\n showSuggestions,\n showNewEntry,\n options,\n minQueryLength,\n autoFocus,\n maxHeight,\n alert,\n inputAutoComplete,\n } = this.props;\n const id = idProp ?? inputAttributes?.id;\n\n const { errorState, query, selected, optionsShown, keyboardFocusedOptionIndex } = this.state;\n\n const clearButton = clearable && (query || selected.length > 0);\n\n const dropdownOpen = optionsShown && showSuggestions && query.length >= minQueryLength;\n\n const menu = this.renderMenu({\n footer,\n options,\n id,\n keyboardFocusedOptionIndex,\n query,\n allowNew,\n showNewEntry,\n dropdownOpen,\n });\n\n const alertType = alert?.type ?? Sentiment.NEUTRAL;\n const hasError = errorState || (alert && alertType === Sentiment.ERROR);\n const displayAlert = (!errorState && alert) || (alert && alertType === Sentiment.ERROR);\n const hasWarning = displayAlert && alertType === Sentiment.WARNING;\n const hasInfo = displayAlert && alertType === Sentiment.NEUTRAL;\n return (\n /* eslint-disable-next-line jsx-a11y/click-events-have-key-events */\n <div\n role=\"group\"\n {...inputAttributes}\n id={id}\n className={clsx('typeahead', `typeahead-${size}`, {\n 'typeahead--has-value': selected.length > 0,\n 'typeahead--empty': selected.length === 0,\n 'typeahead--multiple': multiple,\n open: dropdownOpen,\n })}\n onClick={stopPropagation}\n >\n <div\n className={clsx('form-group', {\n 'has-error': hasError,\n 'has-warning': hasWarning,\n 'has-info': hasInfo,\n })}\n >\n <div\n className={clsx(`input-group input-group-${size}`, {\n 'input-group--has-error': hasError,\n })}\n >\n {addon && <span className=\"input-group-addon input-group-addon--search\">{addon}</span>}\n\n <TypeaheadInput\n {...{\n autoFocus,\n multiple,\n dropdownOpen,\n placeholder,\n selected,\n maxHeight,\n }}\n id={id}\n name={name}\n value={query}\n typeaheadId={id}\n renderChip={this.renderChip}\n autoComplete={inputAutoComplete}\n ariaActivedescendant={\n keyboardFocusedOptionIndex !== null && options[keyboardFocusedOptionIndex]\n ? `option-${options[keyboardFocusedOptionIndex].label.replace(/\\s+/g, '-')}`\n : undefined\n }\n onChange={this.handleOnChange}\n onKeyDown={this.handleOnKeyDown}\n onFocus={this.handleOnFocus}\n onPaste={this.handleOnPaste}\n />\n\n {clearButton && (\n <div className=\"input-group-addon\">\n <button\n type=\"button\"\n className=\"btn-unstyled\"\n aria-label={this.props?.intl?.formatMessage(messages.clearLabel)}\n onClick={this.clear}\n >\n <CrossIcon />\n </button>\n </div>\n )}\n </div>\n {displayAlert ? <InlineAlert type={alert.type}>{alert.message}</InlineAlert> : menu}\n </div>\n </div>\n );\n }\n}\n\nexport default injectIntl(withInputAttributes(Typeahead, { nonLabelable: true })) as <T>(\n props: TypeaheadProps<T>,\n) => React.ReactElement;\n"],"names":["DEFAULT_MIN_QUERY_LENGTH","SEARCH_DELAY","Typeahead","Component","defaultProps","allowNew","autoFillOnBlur","autoFocus","chipSeparators","clearable","initialValue","inputAutoComplete","minQueryLength","multiple","searchDelay","showSuggestions","showNewEntry","size","Size","MEDIUM","validateChip","optionRefs","constructor","props","handleSearchDebounced","debounce","handleSearch","initialQuery","length","label","state","selected","errorState","query","keyboardFocusedOptionIndex","optionsShown","isFocused","UNSAFE_componentWillReceiveProps","nextProps","setState","previousState","componentWillUnmount","cancel","handleOnFocus","showMenu","onFocus","onOptionSelected","event","item","preventDefault","selectItem","handleOnChange","onInputChange","target","value","updateSelectedValue","handleOnPaste","clipboardData","getData","regex","RegExp","join","pastedChips","split","map","trim","filter","chip","handleOnKeyDown","options","chipsMode","includes","key","moveFocusedOption","slice","offset","index","clamp","optionRef","current","focus","push","keepFocusOnSelect","hideMenu","clearQueryOnSelect","onSearch","handleDocumentClick","onBlur","addClickClassToDocumentOnIos","document","addEventListener","removeClickClassFromDocumentOnIos","removeEventListener","onChange","some","clear","removeChip","option","selectedOption","renderChip","idx","valid","_jsx","Chip","className","clsx","onRemove","renderMenu","footer","id","dropdownOpen","optionsToRender","every","toUpperCase","open","children","_jsxs","role","ref","React","createRef","TypeaheadOption","String","replace","onClick","toString","render","inputAttributes","idProp","placeholder","addon","name","maxHeight","alert","clearButton","menu","alertType","type","Sentiment","NEUTRAL","hasError","ERROR","displayAlert","hasWarning","WARNING","hasInfo","stopPropagation","TypeaheadInput","typeaheadId","autoComplete","ariaActivedescendant","undefined","onKeyDown","onPaste","intl","formatMessage","messages","clearLabel","CrossIcon","InlineAlert","message","injectIntl","withInputAttributes","nonLabelable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAMA,wBAAwB,GAAG,CAAC;AAClC,MAAMC,YAAY,GAAG,GAAG;AA0DxB,MAAMC,SAAa,SAAQC,SAAkE,CAAA;AAI3F,EAAA,OAAOC,YAAY,GAAG;AACpBC,IAAAA,QAAQ,EAAE,KAAK;AACfC,IAAAA,cAAc,EAAE,IAAI;AACpBC,IAAAA,SAAS,E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AChF;AACP,KAAK,CAAC;AAEV,EAAA;;AAGF,wBAAe0B,UAAU,CAACC,mBAAmB,CAAChK,SAAS,EAAE;AAAEiK,EAAAA,YAAY,EAAE;AAAI,CAAE,CAAC,CAEzD;;;;"}
@@ -37,7 +37,7 @@ export interface AlertProps {
37
37
  onDismiss?: React.MouseEventHandler<HTMLButtonElement>;
38
38
  /** The type dictates which icon and colour will be used */
39
39
  type?: AlertType;
40
- /** @deprecated Use `InlinePrompt` instead. */
40
+ /** @deprecated Use `InlineAlert` instead. */
41
41
  arrow?: `${AlertArrowPosition}`;
42
42
  /** @deprecated Use `message` instead. Be aware `message` only accepts plain text or text with **bold** markdown. */
43
43
  children?: React.ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../../src/alert/Alert.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,SAAS,EACT,IAAI,EACJ,MAAM,EAGP,MAAM,WAAW,CAAC;AAUnB,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,kDAAkD;AAClD,KAAK,mBAAmB,GAAG,GAAG,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,IAAI,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC;AACrF,KAAK,iBAAiB,GAAG,GACrB,SAAS,CAAC,QAAQ,GAClB,SAAS,CAAC,OAAO,GACjB,SAAS,CAAC,OAAO,GACjB,SAAS,CAAC,QAAQ,GAElB,SAAS,CAAC,OAAO,GACjB,MAAM,CAAC,OAAO,EAAE,CAAC;AACrB,MAAM,MAAM,SAAS,GAAG,iBAAiB,GAAG,mBAAmB,CAAC;AAEhE,oBAAY,kBAAkB;IAC5B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oHAAoH;IACpH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,2CAA2C;IAC3C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2FAA2F;IAC3F,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC;CAClB;AAeD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,MAAM,EACN,SAAS,EACT,IAAI,EACJ,eAAe,EACf,SAAS,EACT,OAAO,EACP,KAAK,EACL,IAAgB,EAChB,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,WAAW,GACZ,EAAE,UAAU,+BAsJZ"}
@@ -9,7 +9,7 @@ export type FieldProps = {
9
9
  hint?: React.ReactNode;
10
10
  message?: React.ReactNode;
11
11
  /**
12
- * Override for the [InlinePrompt icon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)
12
+ * Override for the [InlineAlert icon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)
13
13
  * announced by the screen readers
14
14
  * */
15
15
  messageIconLabel?: string;
@@ -1,7 +1,7 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  import { WrappedComponentProps } from 'react-intl';
3
- import { Sentiment, SizeMedium, SizeLarge } from '../common';
4
- import { InlinePromptProps } from '../prompt';
3
+ import { SizeMedium, SizeLarge } from '../common';
4
+ import { InlineAlertProps } from '../inlineAlert/InlineAlert';
5
5
  export type TypeaheadOption<T = string> = {
6
6
  label: string;
7
7
  note?: string;
@@ -15,8 +15,8 @@ export interface TypeaheadProps<T> extends Partial<WrappedComponentProps> {
15
15
  name: string;
16
16
  addon?: ReactNode;
17
17
  alert?: {
18
- message: InlinePromptProps['children'];
19
- type?: InlinePromptProps['sentiment'] | `${Sentiment.ERROR}` | `${Sentiment.INFO}` | `${Sentiment.SUCCESS}`;
18
+ message: InlineAlertProps['children'];
19
+ type?: InlineAlertProps['type'];
20
20
  };
21
21
  allowNew?: boolean;
22
22
  autoFillOnBlur?: boolean;
@@ -1 +1 @@
1
- {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rB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IAE9B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC;IAClD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC;CACtD;wBAqeoF,CAAC,CAAC,EACrF,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,KACrB,KAAK,CAAC,YAAY;AAFvB,wBAEwB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "0.0.0-experimental-5540836",
3
+ "version": "0.0.0-experimental-6db0914",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -85,15 +85,15 @@
85
85
  "storybook-addon-tag-badges": "^3.0.4",
86
86
  "storybook-addon-test-codegen": "^3.0.1",
87
87
  "@transferwise/less-config": "3.1.2",
88
+ "@wise/components-theming": "0.0.0-experimental-6db0914",
88
89
  "@transferwise/neptune-css": "14.26.0",
89
- "@wise/components-theming": "0.0.0-experimental-5540836",
90
90
  "@wise/wds-configs": "0.0.0"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "@transferwise/icons": "^3 || ^4",
94
94
  "@transferwise/neptune-css": "^14.26",
95
95
  "@wise/art": "^2.25.0",
96
- "@wise/components-theming": "0.0.0-experimental-5540836",
96
+ "@wise/components-theming": "0.0.0-experimental-6db0914",
97
97
  "framer-motion": "^12.23.26",
98
98
  "react": ">=18",
99
99
  "react-dom": ">=18",
@@ -108,7 +108,7 @@
108
108
  "@react-aria/overlays": "^3.31.0",
109
109
  "@react-spring/web": "~10.0.3",
110
110
  "@transferwise/formatting": "^2.13.4",
111
- "@transferwise/neptune-validation": "0.0.0-experimental-5540836",
111
+ "@transferwise/neptune-validation": "0.0.0-experimental-6db0914",
112
112
  "clsx": "^2.1.1",
113
113
  "commonmark": "^0.31.2",
114
114
  "core-js": "^3.47.0",
@@ -93,7 +93,7 @@ describe('Alert', () => {
93
93
  expect(component).toHaveClass('arrow-bottom');
94
94
  expect(mockedWarn).toHaveBeenCalledWith(
95
95
  expect.stringContaining(
96
- "Alert component doesn't support 'arrow' anymore, use 'InlinePrompt' instead.",
96
+ "Alert component doesn't support 'arrow' anymore, use 'InlineAlert' instead.",
97
97
  ),
98
98
  );
99
99
  });
@@ -67,7 +67,7 @@ export interface AlertProps {
67
67
  onDismiss?: React.MouseEventHandler<HTMLButtonElement>;
68
68
  /** The type dictates which icon and colour will be used */
69
69
  type?: AlertType;
70
- /** @deprecated Use `InlinePrompt` instead. */
70
+ /** @deprecated Use `InlineAlert` instead. */
71
71
  arrow?: `${AlertArrowPosition}`;
72
72
  /** @deprecated Use `message` instead. Be aware `message` only accepts plain text or text with **bold** markdown. */
73
73
  children?: React.ReactNode;
@@ -107,7 +107,7 @@ export default function Alert({
107
107
  useEffect(() => {
108
108
  if (arrow !== undefined) {
109
109
  logActionRequired(
110
- "Alert component doesn't support 'arrow' anymore, use 'InlinePrompt' instead.",
110
+ "Alert component doesn't support 'arrow' anymore, use 'InlineAlert' instead.",
111
111
  );
112
112
  }
113
113
  }, [arrow]);
@@ -71,7 +71,7 @@ describe('Field', () => {
71
71
  expect(screen.getByLabelText(/Phone number/)).toHaveAttribute('aria-describedby');
72
72
  });
73
73
 
74
- it("should allow for InlinePrompt's StatusIcon override via `messageIconLabel` prop", () => {
74
+ it("should allow for InlineAlert's StatusIcon override via `messageIconLabel` prop", () => {
75
75
  const customIconLabel = 'My custom icon label';
76
76
 
77
77
  render(
@@ -86,8 +86,8 @@ describe('Field', () => {
86
86
  </Field>,
87
87
  );
88
88
 
89
- expect(screen.queryByLabelText('Error:')).not.toBeInTheDocument();
90
- expect(screen.getByLabelText(customIconLabel)).toBeInTheDocument();
89
+ expect(screen.queryByRole('graphics-symbol', { name: 'Error.' })).not.toBeInTheDocument();
90
+ expect(screen.getByRole('graphics-symbol', { name: customIconLabel })).toBeInTheDocument();
91
91
  });
92
92
 
93
93
  it('should show or hide (Optional) suffix depending on required prop', () => {
@@ -2,7 +2,7 @@ import { clsx } from 'clsx';
2
2
  import { useId, useRef } from 'react';
3
3
 
4
4
  import { Sentiment } from '../common';
5
- import { InlinePrompt } from '../prompt/InlinePrompt/InlinePrompt';
5
+ import InlineAlert from '../inlineAlert/InlineAlert';
6
6
  import {
7
7
  FieldLabelContextProvider,
8
8
  InputDescribedByProvider,
@@ -21,7 +21,7 @@ export type FieldProps = {
21
21
  hint?: React.ReactNode;
22
22
  message?: React.ReactNode;
23
23
  /**
24
- * Override for the [InlinePrompt icon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)
24
+ * Override for the [InlineAlert icon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)
25
25
  * announced by the screen readers
26
26
  * */
27
27
  messageIconLabel?: string;
@@ -104,9 +104,9 @@ export const Field = ({
104
104
  )}
105
105
 
106
106
  {message && (
107
- <InlinePrompt sentiment={sentiment} id={messageId} iconLabel={messageIconLabel}>
107
+ <InlineAlert type={sentiment} id={messageId} iconLabel={messageIconLabel}>
108
108
  {message}
109
- </InlinePrompt>
109
+ </InlineAlert>
110
110
  )}
111
111
  </div>
112
112
  </InputInvalidProvider>
package/src/main.css CHANGED
@@ -6920,10 +6920,6 @@ html:not([dir="rtl"]) .np-navigation-option {
6920
6920
  padding: 0;
6921
6921
  margin: 0;
6922
6922
  }
6923
- .typeahead--prompt {
6924
- margin-top: 4px;
6925
- margin-top: var(--size-4);
6926
- }
6927
6923
  .typeahead-sm.typeahead--multiple .typeahead__input-container {
6928
6924
  min-height: 32px;
6929
6925
  }
@@ -103,10 +103,6 @@
103
103
  padding: 0;
104
104
  margin: 0;
105
105
  }
106
- .typeahead--prompt {
107
- margin-top: 4px;
108
- margin-top: var(--size-4);
109
- }
110
106
  .typeahead-sm.typeahead--multiple .typeahead__input-container {
111
107
  min-height: 32px;
112
108
  }
@@ -1,7 +1,5 @@
1
- @import (reference)
2
- "../../node_modules/@transferwise/neptune-css/src/variables/legacy-variables.less";
3
- @import (reference)
4
- "../../node_modules/@transferwise/neptune-css/src/less/mixins/_logical-properties.less";
1
+ @import (reference) "../../node_modules/@transferwise/neptune-css/src/variables/legacy-variables.less";
2
+ @import (reference) "../../node_modules/@transferwise/neptune-css/src/less/mixins/_logical-properties.less";
5
3
 
6
4
  @animation-timing-function: ease-in-out;
7
5
  @animation-duration: 0.03s;
@@ -124,10 +122,6 @@
124
122
  }
125
123
  }
126
124
 
127
- &--prompt {
128
- margin-top: var(--size-4);
129
- }
130
-
131
125
  // SIZES
132
126
  &-sm {
133
127
  &.typeahead--multiple {
@@ -213,7 +207,7 @@
213
207
  }
214
208
 
215
209
  .np-theme-personal & {
216
- .input-group:not(.disabled, :disabled, .input-group--has-error):focus-within .tw-icon-search {
210
+ .input-group:not(.disabled,:disabled,.input-group--has-error):focus-within .tw-icon-search {
217
211
  color: var(--color-interactive-primary);
218
212
  }
219
213
  .tw-icon-search {
@@ -1,18 +1,15 @@
1
1
  import { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
  import { Search as SearchIcon } from '@transferwise/icons';
3
3
  import { userEvent, within, fn } from 'storybook/test';
4
- import { useState } from 'react';
5
4
 
6
- import { Sentiment, Size } from '../common';
5
+ import Typeahead, { type TypeaheadOption } from './Typeahead';
6
+ import { Size } from '../common';
7
+ import { useState } from 'react';
7
8
  import { Input } from '../inputs/Input';
8
9
  import { Field } from '../field/Field';
9
10
  import Button from '../button';
10
11
  import Modal from '../modal';
11
- import { InlinePromptProps } from '../prompt';
12
- import Typeahead, { type TypeaheadOption } from './Typeahead';
13
12
 
14
- // needed for SB to display correct name in the docs
15
- (Typeahead as React.FC).displayName = 'Typeahead';
16
13
  type Story = StoryObj<typeof Typeahead>;
17
14
 
18
15
  /**
@@ -40,7 +37,6 @@ const meta: Meta<typeof Typeahead> = {
40
37
  searchDelay: 200,
41
38
  showSuggestions: true,
42
39
  showNewEntry: true,
43
- alert: undefined,
44
40
  size: Size.MEDIUM,
45
41
  initialValue: [],
46
42
  id: 'myTypeahead',
@@ -58,17 +54,6 @@ const meta: Meta<typeof Typeahead> = {
58
54
  control: 'inline-radio',
59
55
  options: [Size.MEDIUM, Size.LARGE],
60
56
  },
61
- alert: {
62
- description:
63
- 'Displays an [InlinePrompt](?path=/docs/prompts-inlineprompt--docs) below the input when provided. <blockquote class="m-0">**⚠️ `error`, `info` and `success` are deprecated as alert types and will be soon removed.**</blockquote>',
64
- control: 'object',
65
- table: {
66
- type: {
67
- summary:
68
- '{ message: ReactNode; type?: "negative" | "neutral" | "positive" | "warning" | "proposition" }',
69
- },
70
- },
71
- },
72
57
  },
73
58
  };
74
59
  export default meta;
@@ -252,14 +237,6 @@ export const Search: Story = {
252
237
  };
253
238
 
254
239
  export const AutoFocusInModal: Story = {
255
- parameters: {
256
- docs: {
257
- story: {
258
- inline: false,
259
- iframeHeight: 500,
260
- },
261
- },
262
- },
263
240
  render: function Render() {
264
241
  const [open, setOpen] = useState<boolean>(true);
265
242
  return (
@@ -302,57 +279,3 @@ export const AutoFocusInModal: Story = {
302
279
  );
303
280
  },
304
281
  };
305
-
306
- export const WithPrompt: Story = {
307
- args: {
308
- autoFillOnBlur: undefined,
309
- chipSeparators: undefined,
310
- clearable: undefined,
311
- initialValue: undefined,
312
- inputAutoComplete: undefined,
313
- minQueryLength: undefined,
314
- onBlur: undefined,
315
- onFocus: undefined,
316
- onInputChange: undefined,
317
- onSearch: undefined,
318
- placeholder: undefined,
319
- searchDelay: undefined,
320
- showSuggestions: undefined,
321
- showNewEntry: undefined,
322
- size: undefined,
323
- },
324
- render: function Render(args) {
325
- const options = [{ label: 'Option 1' }];
326
-
327
- const alertTypes: InlinePromptProps['sentiment'][] = [
328
- Sentiment.NEGATIVE,
329
- Sentiment.WARNING,
330
- Sentiment.NEUTRAL,
331
- Sentiment.POSITIVE,
332
- 'proposition',
333
- ];
334
-
335
- return (
336
- <>
337
- {alertTypes.map((sentiment) => (
338
- <Typeahead
339
- key={sentiment}
340
- {...args}
341
- id={`typeahead-${sentiment}`}
342
- name={`typeahead-${sentiment}`}
343
- options={options}
344
- alert={{
345
- message: `This is a ${sentiment} message`,
346
- type: sentiment,
347
- }}
348
- />
349
- ))}
350
- </>
351
- );
352
- },
353
- decorators: (Story) => (
354
- <div className="d-flex flex-column">
355
- <Story />
356
- </div>
357
- ),
358
- };
@@ -16,7 +16,8 @@ import {
16
16
  removeClickClassFromDocumentOnIos,
17
17
  stopPropagation,
18
18
  } from '../common';
19
- import { InlinePrompt, InlinePromptProps } from '../prompt';
19
+ import InlineAlert from '../inlineAlert';
20
+ import { InlineAlertProps } from '../inlineAlert/InlineAlert';
20
21
  import { withInputAttributes, WithInputAttributesProps } from '../inputs/contexts';
21
22
 
22
23
  import TypeaheadInput from './typeaheadInput/TypeaheadInput';
@@ -40,12 +41,8 @@ export interface TypeaheadProps<T> extends Partial<WrappedComponentProps> {
40
41
  name: string;
41
42
  addon?: ReactNode;
42
43
  alert?: {
43
- message: InlinePromptProps['children'];
44
- type?:
45
- | InlinePromptProps['sentiment']
46
- | `${Sentiment.ERROR}`
47
- | `${Sentiment.INFO}`
48
- | `${Sentiment.SUCCESS}`;
44
+ message: InlineAlertProps['children'];
45
+ type?: InlineAlertProps['type'];
49
46
  };
50
47
  allowNew?: boolean;
51
48
  autoFillOnBlur?: boolean;
@@ -477,20 +474,9 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
477
474
  dropdownOpen,
478
475
  });
479
476
 
480
- const alertType = (() => {
481
- if (!alert?.type || alert.type === Sentiment.INFO) {
482
- return Sentiment.NEUTRAL;
483
- }
484
- if (alert.type === Sentiment.ERROR) {
485
- return Sentiment.NEGATIVE;
486
- }
487
- if (alert.type === Sentiment.SUCCESS) {
488
- return Sentiment.POSITIVE;
489
- }
490
- return alert.type;
491
- })();
492
- const hasError = errorState || (alert && alertType === Sentiment.NEGATIVE);
493
- const displayAlert = (!errorState && alert) || (alert && alertType === Sentiment.NEGATIVE);
477
+ const alertType = alert?.type ?? Sentiment.NEUTRAL;
478
+ const hasError = errorState || (alert && alertType === Sentiment.ERROR);
479
+ const displayAlert = (!errorState && alert) || (alert && alertType === Sentiment.ERROR);
494
480
  const hasWarning = displayAlert && alertType === Sentiment.WARNING;
495
481
  const hasInfo = displayAlert && alertType === Sentiment.NEUTRAL;
496
482
  return (
@@ -560,13 +546,7 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
560
546
  </div>
561
547
  )}
562
548
  </div>
563
- {displayAlert ? (
564
- <InlinePrompt sentiment={alertType} className="typeahead--prompt">
565
- {alert.message}
566
- </InlinePrompt>
567
- ) : (
568
- menu
569
- )}
549
+ {displayAlert ? <InlineAlert type={alert.type}>{alert.message}</InlineAlert> : menu}
570
550
  </div>
571
551
  </div>
572
552
  );