@transferwise/components 46.119.5 → 46.120.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/build/alert/Alert.js +1 -1
  2. package/build/alert/Alert.js.map +1 -1
  3. package/build/alert/Alert.mjs +1 -1
  4. package/build/alert/Alert.mjs.map +1 -1
  5. package/build/checkbox/Checkbox.js +1 -1
  6. package/build/checkbox/Checkbox.js.map +1 -1
  7. package/build/checkbox/Checkbox.mjs +1 -1
  8. package/build/checkbox/Checkbox.mjs.map +1 -1
  9. package/build/common/initials.js +17 -7
  10. package/build/common/initials.js.map +1 -1
  11. package/build/common/initials.mjs +17 -7
  12. package/build/common/initials.mjs.map +1 -1
  13. package/build/field/Field.js +8 -4
  14. package/build/field/Field.js.map +1 -1
  15. package/build/field/Field.mjs +8 -4
  16. package/build/field/Field.mjs.map +1 -1
  17. package/build/inlineAlert/InlineAlert.js +1 -7
  18. package/build/inlineAlert/InlineAlert.js.map +1 -1
  19. package/build/inlineAlert/InlineAlert.mjs +1 -7
  20. package/build/inlineAlert/InlineAlert.mjs.map +1 -1
  21. package/build/main.css +20 -1
  22. package/build/prompt/InlinePrompt/InlinePrompt.js +2 -0
  23. package/build/prompt/InlinePrompt/InlinePrompt.js.map +1 -1
  24. package/build/prompt/InlinePrompt/InlinePrompt.mjs +2 -0
  25. package/build/prompt/InlinePrompt/InlinePrompt.mjs.map +1 -1
  26. package/build/radioGroup/RadioGroup.js +1 -0
  27. package/build/radioGroup/RadioGroup.js.map +1 -1
  28. package/build/radioGroup/RadioGroup.mjs +1 -0
  29. package/build/radioGroup/RadioGroup.mjs.map +1 -1
  30. package/build/styles/field/Field.css +10 -1
  31. package/build/styles/main.css +20 -1
  32. package/build/styles/prompt/InlinePrompt/InlinePrompt.css +3 -0
  33. package/build/styles/radioGroup/RadioGroup.css +3 -0
  34. package/build/styles/typeahead/Typeahead.css +4 -0
  35. package/build/typeahead/Typeahead.js +20 -7
  36. package/build/typeahead/Typeahead.js.map +1 -1
  37. package/build/typeahead/Typeahead.mjs +20 -7
  38. package/build/typeahead/Typeahead.mjs.map +1 -1
  39. package/build/types/alert/Alert.d.ts +1 -1
  40. package/build/types/alert/Alert.d.ts.map +1 -1
  41. package/build/types/common/initials.d.ts.map +1 -1
  42. package/build/types/field/Field.d.ts +8 -4
  43. package/build/types/field/Field.d.ts.map +1 -1
  44. package/build/types/inlineAlert/InlineAlert.d.ts +1 -7
  45. package/build/types/inlineAlert/InlineAlert.d.ts.map +1 -1
  46. package/build/types/listItem/_stories/variants/helpers.d.ts +7 -4
  47. package/build/types/listItem/_stories/variants/helpers.d.ts.map +1 -1
  48. package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts +6 -1
  49. package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts.map +1 -1
  50. package/build/types/radioGroup/RadioGroup.d.ts.map +1 -1
  51. package/build/types/test-utils/index.d.ts +0 -1
  52. package/build/types/test-utils/index.d.ts.map +1 -1
  53. package/build/types/typeahead/Typeahead.d.ts +8 -4
  54. package/build/types/typeahead/Typeahead.d.ts.map +1 -1
  55. package/build/types/upload/Upload.d.ts +1 -1
  56. package/build/types/upload/steps/uploadImageStep/uploadImageStep.d.ts.map +1 -1
  57. package/build/upload/Upload.js.map +1 -1
  58. package/build/upload/Upload.mjs.map +1 -1
  59. package/build/upload/steps/uploadImageStep/uploadImageStep.js +5 -4
  60. package/build/upload/steps/uploadImageStep/uploadImageStep.js.map +1 -1
  61. package/build/upload/steps/uploadImageStep/uploadImageStep.mjs +5 -4
  62. package/build/upload/steps/uploadImageStep/uploadImageStep.mjs.map +1 -1
  63. package/package.json +9 -8
  64. package/src/DisabledComponents.story.tsx +1 -3
  65. package/src/actionButton/ActionButton.story.tsx +42 -45
  66. package/src/alert/Alert.spec.tsx +1 -1
  67. package/src/alert/Alert.tsx +2 -2
  68. package/src/avatar/Avatar.story.tsx +192 -188
  69. package/src/button/_stories/Button.tests.story.tsx +122 -119
  70. package/src/carousel/Carousel.story.tsx +4 -7
  71. package/src/checkbox/Checkbox.story.tsx +42 -21
  72. package/src/checkbox/Checkbox.tsx +1 -1
  73. package/src/checkbox/__snapshots__/Checkbox.spec.tsx.snap +1 -1
  74. package/src/circularButton/CircularButton.story.tsx +10 -2
  75. package/src/common/bottomSheet/BottomSheet.story.tsx +48 -14
  76. package/src/common/circle/Circle.story.tsx +62 -55
  77. package/src/common/initials.spec.tsx +31 -0
  78. package/src/common/initials.ts +19 -8
  79. package/src/criticalBanner/CriticalCommsBanner.story.tsx +30 -19
  80. package/src/dateInput/DateInput.tests.story.tsx +101 -74
  81. package/src/dateLookup/DateLookup.story.tsx +69 -59
  82. package/src/field/Field.css +10 -1
  83. package/src/field/Field.less +13 -2
  84. package/src/field/Field.spec.tsx +19 -3
  85. package/src/field/Field.story.tsx +18 -0
  86. package/src/field/Field.tsx +17 -5
  87. package/src/header/Header.story.tsx +5 -16
  88. package/src/header/Header.tests.story.tsx +95 -69
  89. package/src/info/Info.story.tsx +27 -11
  90. package/src/inlineAlert/InlineAlert.story.tsx +4 -0
  91. package/src/inlineAlert/InlineAlert.tsx +1 -7
  92. package/src/instructionsList/InstructionsList.story.tsx +0 -1
  93. package/src/listItem/_stories/ListItem.layout.test.story.tsx +1 -3
  94. package/src/listItem/_stories/variants/ListItem.brightGreen.test.story.tsx +77 -35
  95. package/src/listItem/_stories/variants/ListItem.dark.test.story.tsx +65 -29
  96. package/src/listItem/_stories/variants/ListItem.forestGreen.test.story.tsx +77 -35
  97. package/src/listItem/_stories/variants/ListItem.medium.test.story.tsx +38 -18
  98. package/src/listItem/_stories/variants/ListItem.neutral.test.story.tsx +0 -1
  99. package/src/listItem/_stories/variants/ListItem.personal.test.story.tsx +38 -18
  100. package/src/listItem/_stories/variants/ListItem.rtl.test.story.tsx +77 -29
  101. package/src/listItem/_stories/variants/ListItem.small.test.story.tsx +65 -18
  102. package/src/listItem/_stories/variants/helpers.tsx +136 -133
  103. package/src/main.css +20 -1
  104. package/src/main.less +1 -0
  105. package/src/modal/Modal.story.tsx +47 -8
  106. package/src/moneyInput/MoneyInput.story.tsx +2 -2
  107. package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.story.tsx +1 -0
  108. package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.tests.story.tsx +1 -0
  109. package/src/primitives/PrimitiveButton/stories/PrimitiveButton.story.tsx +1 -0
  110. package/src/primitives/PrimitiveButton/stories/PrimitiveButton.tests.story.tsx +1 -0
  111. package/src/prompt/InlinePrompt/InlinePrompt.css +3 -0
  112. package/src/prompt/InlinePrompt/InlinePrompt.less +5 -1
  113. package/src/prompt/InlinePrompt/InlinePrompt.spec.tsx +17 -0
  114. package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +35 -0
  115. package/src/prompt/InlinePrompt/InlinePrompt.tsx +7 -0
  116. package/src/provider/theme/ThemeProvider.story.tsx +1 -0
  117. package/src/radioGroup/RadioGroup.css +3 -0
  118. package/src/radioGroup/RadioGroup.less +3 -0
  119. package/src/radioGroup/RadioGroup.story.tsx +2 -0
  120. package/src/radioGroup/RadioGroup.test.story.tsx +62 -0
  121. package/src/radioGroup/RadioGroup.tsx +6 -1
  122. package/src/segmentedControl/SegmentedControl.story.tsx +71 -67
  123. package/src/snackbar/Snackbar.tests.story.tsx +116 -114
  124. package/src/statusIcon/StatusIcon.story.tsx +41 -38
  125. package/src/test-utils/index.tsx +0 -2
  126. package/src/tokens/tokens.story.tsx +1 -1
  127. package/src/tooltip/Tooltip.story.tsx +10 -2
  128. package/src/typeahead/Typeahead.css +4 -0
  129. package/src/typeahead/Typeahead.less +5 -1
  130. package/src/typeahead/Typeahead.spec.tsx +1 -1
  131. package/src/typeahead/Typeahead.story.tsx +151 -3
  132. package/src/typeahead/Typeahead.tsx +33 -9
  133. package/src/upload/Upload.story.tsx +1 -1
  134. package/src/upload/Upload.tests.story.tsx +36 -1
  135. package/src/upload/Upload.tsx +1 -1
  136. package/src/upload/steps/uploadImageStep/uploadImageStep.tsx +7 -3
  137. package/src/withId/withId.story.tsx +1 -1
  138. package/build/types/test-utils/story-config.d.ts +0 -64
  139. package/build/types/test-utils/story-config.d.ts.map +0 -1
  140. package/src/test-utils/story-config.ts +0 -95
package/build/main.css CHANGED
@@ -949,6 +949,9 @@
949
949
  .wds-inline-prompt:has(button):active {
950
950
  background-color: var(--color-sentiment-background-surface-active);
951
951
  }
952
+ .wds-inline-prompt--full-width {
953
+ width: 100%;
954
+ }
952
955
  .wds-inline-prompt--muted {
953
956
  opacity: 0.93;
954
957
  filter: grayscale(1);
@@ -3822,10 +3825,19 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3822
3825
  stroke-dasharray: calc(12px * 0.5) calc(12px * 0.5);
3823
3826
  stroke-dasharray: var(--wds-list-item-spotlight-strokeDashSize) var(--wds-list-item-spotlight-strokeDashSize);
3824
3827
  }
3825
- .np-field-control {
3828
+ .np-field-control,
3829
+ .np-field__prompt {
3826
3830
  margin-top: 4px;
3827
3831
  margin-top: var(--size-4);
3828
3832
  }
3833
+ .np-field .form-group--typeahead[class],
3834
+ .np-field .np-checkbox-label[class] {
3835
+ margin-bottom: 0;
3836
+ }
3837
+ .np-field:has(.wds-radio-group) .np-field__prompt {
3838
+ margin-top: 12px;
3839
+ margin-top: var(--size-12);
3840
+ }
3829
3841
  .np-input-group {
3830
3842
  display: inline-grid;
3831
3843
  width: 100%;
@@ -5394,6 +5406,9 @@ html:not([dir="rtl"]) .np-navigation-option {
5394
5406
  .np-CardGroup .np-Card.np-Card--promoCard {
5395
5407
  max-width: 100%;
5396
5408
  }
5409
+ .wds-radio-group .np-radio:last-child label {
5410
+ margin-bottom: 0;
5411
+ }
5397
5412
  .np-section {
5398
5413
  margin-top: 32px;
5399
5414
  margin-top: var(--size-32);
@@ -6920,6 +6935,10 @@ html:not([dir="rtl"]) .np-navigation-option {
6920
6935
  padding: 0;
6921
6936
  margin: 0;
6922
6937
  }
6938
+ .typeahead--prompt {
6939
+ margin-top: 4px;
6940
+ margin-top: var(--size-4);
6941
+ }
6923
6942
  .typeahead-sm.typeahead--multiple .typeahead__input-container {
6924
6943
  min-height: 32px;
6925
6944
  }
@@ -38,6 +38,7 @@ const InlinePrompt = ({
38
38
  children,
39
39
  media = null,
40
40
  mediaLabel,
41
+ width = 'auto',
41
42
  'data-testid': dataTestId,
42
43
  ...rest
43
44
  }) => {
@@ -75,6 +76,7 @@ const InlinePrompt = ({
75
76
  sentiment: surfaceSentiment,
76
77
  "data-testid": dataTestId,
77
78
  className: clsx.clsx('wds-inline-prompt', `wds-inline-prompt--${sentiment$1}`, {
79
+ 'wds-inline-prompt--full-width': width === 'full',
78
80
  'wds-inline-prompt--muted': muted,
79
81
  'wds-inline-prompt--loading': loading
80
82
  }, className),
@@ -1 +1 @@
1
- {"version":3,"file":"InlinePrompt.js","sources":["../../../src/prompt/InlinePrompt/InlinePrompt.tsx"],"sourcesContent":["import { Sentiment } from '../../common';\nimport { BackslashCircle, GiftBox } from '@transferwise/icons';\nimport ProcessIndicator from '../../processIndicator';\nimport StatusIcon from '../../statusIcon';\nimport { clsx } from 'clsx';\nimport Body from '../../body';\nimport SentimentSurface from '../../sentimentSurface';\n\nexport type InlinePromptProps = {\n /**\n * The sentiment determines the colour scheme\n */\n sentiment?:\n | `${Sentiment.POSITIVE | Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.WARNING}`\n | 'proposition';\n /**\n * Replaces the icon with a spinner while waiting for the short-lived action to finish.\n * @default false\n */\n loading?: boolean;\n /**\n * While prompts cannot be fully (visually and functionally) disabled, this prop should be enabled\n * they are associated with actually disabled component (e.g. a disabled list item or input).\n * @default false\n */\n muted?: boolean;\n /**\n * Icon override for `proposition` and `positive` sentiments. Unsupported for remaining ones.\n */\n media?: React.ReactNode;\n /**\n * Override for the sentiment's-derived, default, accessible name announced by the screen readers.\n * To be used primarily for `proposition` sentiment.\n */\n mediaLabel?: string;\n id?: string;\n className?: string;\n 'data-testid'?: string;\n children: React.ReactNode;\n};\n\n/**\n * Inline prompts appear alongside a specific component on the screen. They help the user stay\n * informed, fix something, or get more out of what they're doing. <br />\n *\n * **NB:** It should be used in favour of `InlineAlert` which will be soon deprecated.\n */\nexport const InlinePrompt = ({\n sentiment = Sentiment.POSITIVE,\n muted = false,\n loading = false,\n className,\n children,\n media = null,\n mediaLabel,\n 'data-testid': dataTestId,\n ...rest\n}: InlinePromptProps) => {\n const surfaceSentiment = sentiment === Sentiment.POSITIVE ? 'success' : sentiment;\n\n const renderMedia = () => {\n if (muted) {\n return <BackslashCircle size={16} data-testid=\"InlinePrompt_Muted\" title={mediaLabel} />;\n }\n if (loading) {\n return (\n <ProcessIndicator\n data-testid=\"InlinePrompt_ProcessIndicator\"\n size=\"xxs\"\n className=\"wds-inline-prompt-process-indicator\"\n />\n );\n }\n\n if (sentiment === 'positive' && media) {\n return media;\n }\n\n if (sentiment === 'proposition') {\n return media || <GiftBox title={mediaLabel} />;\n }\n\n return <StatusIcon size={16} sentiment={sentiment} iconLabel={mediaLabel} />;\n };\n\n return (\n <SentimentSurface\n sentiment={surfaceSentiment}\n data-testid={dataTestId}\n className={clsx(\n 'wds-inline-prompt',\n `wds-inline-prompt--${sentiment}`,\n {\n 'wds-inline-prompt--muted': muted,\n 'wds-inline-prompt--loading': loading,\n },\n className,\n )}\n {...rest}\n >\n <div className=\"wds-inline-prompt__media-wrapper\">{renderMedia()}</div>\n <Body>{children}</Body>\n </SentimentSurface>\n );\n};\n"],"names":["InlinePrompt","sentiment","Sentiment","POSITIVE","muted","loading","className","children","media","mediaLabel","dataTestId","rest","surfaceSentiment","renderMedia","_jsx","BackslashCircle","size","title","ProcessIndicator","GiftBox","StatusIcon","iconLabel","_jsxs","SentimentSurface","clsx","Body"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CO,MAAMA,YAAY,GAAGA,CAAC;aAC3BC,WAAS,GAAGC,mBAAS,CAACC,QAAQ;AAC9BC,EA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AmB,EACnB,CAAA,mBAAA,EAAsBvB,WAAS,EAAE,EACjC;AACE,MAAA,0BAA0B,EAAEG,KAAK;AACjC,MAAA,4BAA4B,EAAEC;KAC/B,EACDC,SAAS,CACT;AAAA,IAAA,GACEK,IAAI;AAAAJ,IAAAA,QAAA,gBAERO,cAAA,CAAA,KAAA,EAAA;AAAKR,MAAAA,SAAS,EAAC,kCAAkC;MAAAC,QAAA,EAAEM,WAAW;AAAE,KAAM,CACtE,eAAAC,cAAA,CAACW,YAAI,EAAA;AAAAlB,MAAAA,QAAA,EAAEA;AAAQ,KAAO,CACxB;AAAA,GAAkB,CAAC;AAEvB;;;;"}
1
+ {"version":3,"file":"InlinePrompt.js","sources":["../../../src/prompt/InlinePrompt/InlinePrompt.tsx"],"sourcesContent":["import { Sentiment } from '../../common';\nimport { BackslashCircle, GiftBox } from '@transferwise/icons';\nimport ProcessIndicator from '../../processIndicator';\nimport StatusIcon from '../../statusIcon';\nimport { clsx } from 'clsx';\nimport Body from '../../body';\nimport SentimentSurface from '../../sentimentSurface';\n\nexport type InlinePromptProps = {\n /**\n * The sentiment determines the colour scheme\n */\n sentiment?:\n | `${Sentiment.POSITIVE | Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.WARNING}`\n | 'proposition';\n /**\n * Replaces the icon with a spinner while waiting for the short-lived action to finish.\n * @default false\n */\n loading?: boolean;\n /**\n * While prompts cannot be fully (visually and functionally) disabled, this prop should be enabled\n * they are associated with actually disabled component (e.g. a disabled list item or input).\n * @default false\n */\n muted?: boolean;\n /**\n * Icon override for `proposition` and `positive` sentiments. Unsupported for remaining ones.\n */\n media?: React.ReactNode;\n /**\n * Override for the sentiment's-derived, default, accessible name announced by the screen readers.\n * To be used primarily for `proposition` sentiment.\n */\n mediaLabel?: string;\n /**\n * Defines the sizing strategy of the prompt component - either hugging the content or taking full width of the container.\n * @default auto\n */\n width?: 'auto' | 'full';\n id?: string;\n className?: string;\n 'data-testid'?: string;\n children: React.ReactNode;\n};\n\n/**\n * Inline prompts appear alongside a specific component on the screen. They help the user stay\n * informed, fix something, or get more out of what they're doing. <br />\n *\n * **NB:** It should be used in favour of `InlineAlert` which will be soon deprecated.\n */\nexport const InlinePrompt = ({\n sentiment = Sentiment.POSITIVE,\n muted = false,\n loading = false,\n className,\n children,\n media = null,\n mediaLabel,\n width = 'auto',\n 'data-testid': dataTestId,\n ...rest\n}: InlinePromptProps) => {\n const surfaceSentiment = sentiment === Sentiment.POSITIVE ? 'success' : sentiment;\n\n const renderMedia = () => {\n if (muted) {\n return <BackslashCircle size={16} data-testid=\"InlinePrompt_Muted\" title={mediaLabel} />;\n }\n if (loading) {\n return (\n <ProcessIndicator\n data-testid=\"InlinePrompt_ProcessIndicator\"\n size=\"xxs\"\n className=\"wds-inline-prompt-process-indicator\"\n />\n );\n }\n\n if (sentiment === 'positive' && media) {\n return media;\n }\n\n if (sentiment === 'proposition') {\n return media || <GiftBox title={mediaLabel} />;\n }\n\n return <StatusIcon size={16} sentiment={sentiment} iconLabel={mediaLabel} />;\n };\n\n return (\n <SentimentSurface\n sentiment={surfaceSentiment}\n data-testid={dataTestId}\n className={clsx(\n 'wds-inline-prompt',\n `wds-inline-prompt--${sentiment}`,\n {\n 'wds-inline-prompt--full-width': width === 'full',\n 'wds-inline-prompt--muted': muted,\n 'wds-inline-prompt--loading': loading,\n },\n className,\n )}\n {...rest}\n >\n <div className=\"wds-inline-prompt__media-wrapper\">{renderMedia()}</div>\n <Body>{children}</Body>\n </SentimentSurface>\n );\n};\n"],"names":["InlinePrompt","sentiment","Sentiment","POSITIVE","muted","loading","className","children","media","mediaLabel","width","dataTestId","rest","surfaceSentiment","renderMedia","_jsx","BackslashCircle","size","title","ProcessIndicator","GiftBox","StatusIcon","iconLabel","_jsxs","SentimentSurface","clsx","Body"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDO,MAAMA,YAAY,GAAGA,CAAC;aAC3BC,WAAS,GAAGC,mBAAS,CAACC,QAAQ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aF,UAAW;IACxBL,SAAS,EAAEmB,SAAI,CACb,mBAAmB,EACnB,CAAA,mBAAA,EAAsBxB,WAAS,EAAE,EACjC;MACE,+BAA+B,EAAES,KAAK,KAAK,MAAM;AACjD,MAAA,0BAA0B,EAAEN,KAAK;AACjC,MAAA,4BAA4B,EAAEC;KAC/B,EACDC,SAAS,CACT;AAAA,IAAA,GACEM,IAAI;AAAAL,IAAAA,QAAA,gBAERQ,cAAA,CAAA,KAAA,EAAA;AAAKT,MAAAA,SAAS,EAAC,kCAAkC;MAAAC,QAAA,EAAEO,WAAW;AAAE,KAAM,CACtE,eAAAC,cAAA,CAACW,YAAI,EAAA;AAAAnB,MAAAA,QAAA,EAAEA;AAAQ,KAAO,CACxB;AAAA,GAAkB,CAAC;AAEvB;;;;"}
@@ -36,6 +36,7 @@ const InlinePrompt = ({
36
36
  children,
37
37
  media = null,
38
38
  mediaLabel,
39
+ width = 'auto',
39
40
  'data-testid': dataTestId,
40
41
  ...rest
41
42
  }) => {
@@ -73,6 +74,7 @@ const InlinePrompt = ({
73
74
  sentiment: surfaceSentiment,
74
75
  "data-testid": dataTestId,
75
76
  className: clsx('wds-inline-prompt', `wds-inline-prompt--${sentiment}`, {
77
+ 'wds-inline-prompt--full-width': width === 'full',
76
78
  'wds-inline-prompt--muted': muted,
77
79
  'wds-inline-prompt--loading': loading
78
80
  }, className),
@@ -1 +1 @@
1
- {"version":3,"file":"InlinePrompt.mjs","sources":["../../../src/prompt/InlinePrompt/InlinePrompt.tsx"],"sourcesContent":["import { Sentiment } from '../../common';\nimport { BackslashCircle, GiftBox } from '@transferwise/icons';\nimport ProcessIndicator from '../../processIndicator';\nimport StatusIcon from '../../statusIcon';\nimport { clsx } from 'clsx';\nimport Body from '../../body';\nimport SentimentSurface from '../../sentimentSurface';\n\nexport type InlinePromptProps = {\n /**\n * The sentiment determines the colour scheme\n */\n sentiment?:\n | `${Sentiment.POSITIVE | Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.WARNING}`\n | 'proposition';\n /**\n * Replaces the icon with a spinner while waiting for the short-lived action to finish.\n * @default false\n */\n loading?: boolean;\n /**\n * While prompts cannot be fully (visually and functionally) disabled, this prop should be enabled\n * they are associated with actually disabled component (e.g. a disabled list item or input).\n * @default false\n */\n muted?: boolean;\n /**\n * Icon override for `proposition` and `positive` sentiments. Unsupported for remaining ones.\n */\n media?: React.ReactNode;\n /**\n * Override for the sentiment's-derived, default, accessible name announced by the screen readers.\n * To be used primarily for `proposition` sentiment.\n */\n mediaLabel?: string;\n id?: string;\n className?: string;\n 'data-testid'?: string;\n children: React.ReactNode;\n};\n\n/**\n * Inline prompts appear alongside a specific component on the screen. They help the user stay\n * informed, fix something, or get more out of what they're doing. <br />\n *\n * **NB:** It should be used in favour of `InlineAlert` which will be soon deprecated.\n */\nexport const InlinePrompt = ({\n sentiment = Sentiment.POSITIVE,\n muted = false,\n loading = false,\n className,\n children,\n media = null,\n mediaLabel,\n 'data-testid': dataTestId,\n ...rest\n}: InlinePromptProps) => {\n const surfaceSentiment = sentiment === Sentiment.POSITIVE ? 'success' : sentiment;\n\n const renderMedia = () => {\n if (muted) {\n return <BackslashCircle size={16} data-testid=\"InlinePrompt_Muted\" title={mediaLabel} />;\n }\n if (loading) {\n return (\n <ProcessIndicator\n data-testid=\"InlinePrompt_ProcessIndicator\"\n size=\"xxs\"\n className=\"wds-inline-prompt-process-indicator\"\n />\n );\n }\n\n if (sentiment === 'positive' && media) {\n return media;\n }\n\n if (sentiment === 'proposition') {\n return media || <GiftBox title={mediaLabel} />;\n }\n\n return <StatusIcon size={16} sentiment={sentiment} iconLabel={mediaLabel} />;\n };\n\n return (\n <SentimentSurface\n sentiment={surfaceSentiment}\n data-testid={dataTestId}\n className={clsx(\n 'wds-inline-prompt',\n `wds-inline-prompt--${sentiment}`,\n {\n 'wds-inline-prompt--muted': muted,\n 'wds-inline-prompt--loading': loading,\n },\n className,\n )}\n {...rest}\n >\n <div className=\"wds-inline-prompt__media-wrapper\">{renderMedia()}</div>\n <Body>{children}</Body>\n </SentimentSurface>\n );\n};\n"],"names":["InlinePrompt","sentiment","Sentiment","POSITIVE","muted","loading","className","children","media","mediaLabel","dataTestId","rest","surfaceSentiment","renderMedia","_jsx","BackslashCircle","size","title","ProcessIndicator","GiftBox","StatusIcon","iconLabel","_jsxs","SentimentSurface","clsx","Body"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CO,MAAMA,YAAY,GAAGA,CAAC;EAC3BC,SAAS,GAAGC,SAAS,CAACC,QAAQ;AAC9BC,EAAAA,KAAK,GAAG,KAAK;AACbC,EAAAA,OAAO,GAAG,KAAK;EACfC,SAAS;EACTC,QAAQ;AACRC,EAAAA,KAAK,GAAG,IAAI;EACZC,UAAU;AACV,EAAA,aAAa,EAAEC,UAAU;EACzB,GAAGC;AAAI,CACW,KAAI;EACtB,MAAMC,gBAAgB,GAAGX,SAAS,KAAKC,SAAS,CAACC,QAAQ,GAAG,SAAS,GAAGF,SAAS;EAEjF,MAAMY,WAAW,GAAGA,MAAK;AACvB,IAAA,IAAIT,KAAK,EAAE;MACT,oBAAOU,GAAA,CAACC,eAAe,EAAA;AAACC,QAAAA,IAAI,EAAE,EAAG;AAAC,QAAA,aAAA,EAAY,oBAAoB;AAACC,QAAAA,KAAK,EAAER;AAAW,QAAG;AAC1F,IAAA;AACA,IAAA,IAAIJ,OAAO,EAAE;MACX,oBACES,GAAA,CAACI,gBAAgB,EAAA;AACf,QAAA,aAAA,EAAY,+BAA+B;AAC3CF,QAAAA,IAAI,EAAC,KAAK;AACVV,QAAAA,SAAS,EAAC;AAAqC,OAAA,CAC/C;AAEN,IAAA;AAEA,IAAA,IAAIL,SAAS,KAAK,UAAU,IAAIO,KAAK,EAAE;AACrC,MAAA,OAAOA,KAAK;AACd,IAAA;IAEA,IAAIP,SAAS,KAAK,aAAa,EAAE;AAC/B,MAAA,OAAOO,KAAK,iBAAIM,GAAA,CAACK,OAAO,EAAA;AAACF,QAAAA,KAAK,EAAER;AAAW,OAAA,CAAG;AAChD,IAAA;IAEA,oBAAOK,GAAA,CAACM,UAAU,EAAA;AAACJ,MAAAA,IAAI,EAAE,EAAG;AAACf,MAAAA,SAAS,EAAEA,SAAU;AAACoB,MAAAA,SAAS,EAAEZ;AAAW,KAAA,CAAG;EAC9E,CAAC;EAED,oBACEa,IAAA,CAACC,gBAAgB,EAAA;AACftB,IAAAA,SAAS,EAAEW,gBAAiB;AAC5B,IAAA,aAAA,EAAaF,UAAW;IACxBJ,SAAS,EAAEkB,IAAI,CACb,mBAAmB,EACnB,CAAA,mBAAA,EAAsBvB,SAAS,EAAE,EACjC;AACE,MAAA,0BAA0B,EAAEG,KAAK;AACjC,MAAA,4BAA4B,EAAEC;KAC/B,EACDC,SAAS,CACT;AAAA,IAAA,GACEK,IAAI;AAAAJ,IAAAA,QAAA,gBAERO,GAAA,CAAA,KAAA,EAAA;AAAKR,MAAAA,SAAS,EAAC,kCAAkC;MAAAC,QAAA,EAAEM,WAAW;AAAE,KAAM,CACtE,eAAAC,GAAA,CAACW,IAAI,EAAA;AAAAlB,MAAAA,QAAA,EAAEA;AAAQ,KAAO,CACxB;AAAA,GAAkB,CAAC;AAEvB;;;;"}
1
+ {"version":3,"file":"InlinePrompt.mjs","sources":["../../../src/prompt/InlinePrompt/InlinePrompt.tsx"],"sourcesContent":["import { Sentiment } from '../../common';\nimport { BackslashCircle, GiftBox } from '@transferwise/icons';\nimport ProcessIndicator from '../../processIndicator';\nimport StatusIcon from '../../statusIcon';\nimport { clsx } from 'clsx';\nimport Body from '../../body';\nimport SentimentSurface from '../../sentimentSurface';\n\nexport type InlinePromptProps = {\n /**\n * The sentiment determines the colour scheme\n */\n sentiment?:\n | `${Sentiment.POSITIVE | Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.WARNING}`\n | 'proposition';\n /**\n * Replaces the icon with a spinner while waiting for the short-lived action to finish.\n * @default false\n */\n loading?: boolean;\n /**\n * While prompts cannot be fully (visually and functionally) disabled, this prop should be enabled\n * they are associated with actually disabled component (e.g. a disabled list item or input).\n * @default false\n */\n muted?: boolean;\n /**\n * Icon override for `proposition` and `positive` sentiments. Unsupported for remaining ones.\n */\n media?: React.ReactNode;\n /**\n * Override for the sentiment's-derived, default, accessible name announced by the screen readers.\n * To be used primarily for `proposition` sentiment.\n */\n mediaLabel?: string;\n /**\n * Defines the sizing strategy of the prompt component - either hugging the content or taking full width of the container.\n * @default auto\n */\n width?: 'auto' | 'full';\n id?: string;\n className?: string;\n 'data-testid'?: string;\n children: React.ReactNode;\n};\n\n/**\n * Inline prompts appear alongside a specific component on the screen. They help the user stay\n * informed, fix something, or get more out of what they're doing. <br />\n *\n * **NB:** It should be used in favour of `InlineAlert` which will be soon deprecated.\n */\nexport const InlinePrompt = ({\n sentiment = Sentiment.POSITIVE,\n muted = false,\n loading = false,\n className,\n children,\n media = null,\n mediaLabel,\n width = 'auto',\n 'data-testid': dataTestId,\n ...rest\n}: InlinePromptProps) => {\n const surfaceSentiment = sentiment === Sentiment.POSITIVE ? 'success' : sentiment;\n\n const renderMedia = () => {\n if (muted) {\n return <BackslashCircle size={16} data-testid=\"InlinePrompt_Muted\" title={mediaLabel} />;\n }\n if (loading) {\n return (\n <ProcessIndicator\n data-testid=\"InlinePrompt_ProcessIndicator\"\n size=\"xxs\"\n className=\"wds-inline-prompt-process-indicator\"\n />\n );\n }\n\n if (sentiment === 'positive' && media) {\n return media;\n }\n\n if (sentiment === 'proposition') {\n return media || <GiftBox title={mediaLabel} />;\n }\n\n return <StatusIcon size={16} sentiment={sentiment} iconLabel={mediaLabel} />;\n };\n\n return (\n <SentimentSurface\n sentiment={surfaceSentiment}\n data-testid={dataTestId}\n className={clsx(\n 'wds-inline-prompt',\n `wds-inline-prompt--${sentiment}`,\n {\n 'wds-inline-prompt--full-width': width === 'full',\n 'wds-inline-prompt--muted': muted,\n 'wds-inline-prompt--loading': loading,\n },\n className,\n )}\n {...rest}\n >\n <div className=\"wds-inline-prompt__media-wrapper\">{renderMedia()}</div>\n <Body>{children}</Body>\n </SentimentSurface>\n );\n};\n"],"names":["InlinePrompt","sentiment","Sentiment","POSITIVE","muted","loading","className","children","media","mediaLabel","width","dataTestId","rest","surfaceSentiment","renderMedia","_jsx","BackslashCircle","size","title","ProcessIndicator","GiftBox","StatusIcon","iconLabel","_jsxs","SentimentSurface","clsx","Body"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDO,MAAMA,YAAY,GAAGA,CAAC;EAC3BC,SAAS,GAAGC,SAAS,CAACC,QAAQ;AAC9BC,EAAAA,KAAK,GAAG,KAAK;AACbC,EAAAA,OAAO,GAAG,KAAK;EACfC,SAAS;EACTC,QAAQ;AACRC,EAAAA,KAAK,GAAG,IAAI;EACZC,UAAU;AACVC,EAAAA,KAAK,GAAG,MAAM;AACd,EAAA,aAAa,EAAEC,UAAU;EACzB,GAAGC;AAAI,CACW,KAAI;EACtB,MAAMC,gBAAgB,GAAGZ,SAAS,KAAKC,SAAS,CAACC,QAAQ,GAAG,SAAS,GAAGF,SAAS;EAEjF,MAAMa,WAAW,GAAGA,MAAK;AACvB,IAAA,IAAIV,KAAK,EAAE;MACT,oBAAOW,GAAA,CAACC,eAAe,EAAA;AAACC,QAAAA,IAAI,EAAE,EAAG;AAAC,QAAA,aAAA,EAAY,oBAAoB;AAACC,QAAAA,KAAK,EAAET;AAAW,QAAG;AAC1F,IAAA;AACA,IAAA,IAAIJ,OAAO,EAAE;MACX,oBACEU,GAAA,CAACI,gBAAgB,EAAA;AACf,QAAA,aAAA,EAAY,+BAA+B;AAC3CF,QAAAA,IAAI,EAAC,KAAK;AACVX,QAAAA,SAAS,EAAC;AAAqC,OAAA,CAC/C;AAEN,IAAA;AAEA,IAAA,IAAIL,SAAS,KAAK,UAAU,IAAIO,KAAK,EAAE;AACrC,MAAA,OAAOA,KAAK;AACd,IAAA;IAEA,IAAIP,SAAS,KAAK,aAAa,EAAE;AAC/B,MAAA,OAAOO,KAAK,iBAAIO,GAAA,CAACK,OAAO,EAAA;AAACF,QAAAA,KAAK,EAAET;AAAW,OAAA,CAAG;AAChD,IAAA;IAEA,oBAAOM,GAAA,CAACM,UAAU,EAAA;AAACJ,MAAAA,IAAI,EAAE,EAAG;AAAChB,MAAAA,SAAS,EAAEA,SAAU;AAACqB,MAAAA,SAAS,EAAEb;AAAW,KAAA,CAAG;EAC9E,CAAC;EAED,oBACEc,IAAA,CAACC,gBAAgB,EAAA;AACfvB,IAAAA,SAAS,EAAEY,gBAAiB;AAC5B,IAAA,aAAA,EAAaF,UAAW;IACxBL,SAAS,EAAEmB,IAAI,CACb,mBAAmB,EACnB,CAAA,mBAAA,EAAsBxB,SAAS,EAAE,EACjC;MACE,+BAA+B,EAAES,KAAK,KAAK,MAAM;AACjD,MAAA,0BAA0B,EAAEN,KAAK;AACjC,MAAA,4BAA4B,EAAEC;KAC/B,EACDC,SAAS,CACT;AAAA,IAAA,GACEM,IAAI;AAAAL,IAAAA,QAAA,gBAERQ,GAAA,CAAA,KAAA,EAAA;AAAKT,MAAAA,SAAS,EAAC,kCAAkC;MAAAC,QAAA,EAAEO,WAAW;AAAE,KAAM,CACtE,eAAAC,GAAA,CAACW,IAAI,EAAA;AAAAnB,MAAAA,QAAA,EAAEA;AAAQ,KAAO,CACxB;AAAA,GAAkB,CAAC;AAEvB;;;;"}
@@ -22,6 +22,7 @@ function RadioGroup({
22
22
  role: "radiogroup",
23
23
  ...inputAttributes,
24
24
  ...UNSAFE_inputAttributes,
25
+ className: "wds-radio-group",
25
26
  children: radios.map(({
26
27
  value = '',
27
28
  ...restProps
@@ -1 +1 @@
1
- {"version":3,"file":"RadioGroup.js","sources":["../../src/radioGroup/RadioGroup.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport Radio from '../radio';\nimport { RadioProps } from '../radio/Radio';\nimport { useInputAttributes, WithInputAttributesProps } from '../inputs/contexts';\n\nexport type RadioGroupRadio<T extends string | number = string> = Omit<\n RadioProps<T>,\n 'name' | 'checked' | 'onChange' | 'className'\n>;\n\nexport interface RadioGroupProps<T extends string | number = string> {\n name: string;\n radios: readonly RadioGroupRadio<T>[];\n selectedValue?: T; // TODO: `NoInfer<T>` from TypeScript 5.4\n onChange: NonNullable<RadioProps<T>['onChange']>;\n UNSAFE_inputAttributes?: WithInputAttributesProps['inputAttributes'];\n}\n\nexport default function RadioGroup<T extends string | number = never>({\n name,\n radios,\n selectedValue: controlledValue,\n onChange,\n UNSAFE_inputAttributes,\n}: RadioGroupProps<T>) {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n\n const [uncontrolledValue, setUncontrolledValue] = useState(controlledValue);\n\n return radios.length > 0 ? (\n <div role=\"radiogroup\" {...inputAttributes} {...UNSAFE_inputAttributes}>\n {radios.map(({ value = '' as T, ...restProps }, index) => (\n <Radio\n // eslint-disable-next-line react/no-array-index-key\n key={index}\n {...restProps}\n name={name}\n value={value}\n checked={value === uncontrolledValue}\n onChange={(nextValue) => {\n setUncontrolledValue(nextValue);\n onChange(nextValue);\n }}\n />\n ))}\n </div>\n ) : null;\n}\n"],"names":["RadioGroup","name","radios","selectedValue","controlledValue","onChange","UNSAFE_inputAttributes","inputAttributes","useInputAttributes","nonLabelable","uncontrolledValue","setUncontrolledValue","useState","length","_jsx","role","children","map","value","restProps","index","Radio","checked","nextValue"],"mappings":";;;;;;;;;AAmBc,SAAUA,UAAUA,CAAoC;EACpEC,IAAI;EACJC,MAAM;AACNC,EAAAA,aAAa,EAAEC,eAAe;EAC9BC,QAAQ;AACRC,EAAAA;AAAsB,CACH,EAAA;EACnB,MAAMC,eAAe,GAAGC,2BAAkB,CAAC;AAAEC,IAAAA,YAAY,EAAE;AAAI,GAAE,CAAC;EAElE,MAAM,CAACC,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGC,cAAQ,CAACR,eAAe,CAAC;AAE3E,EAAA,OAAOF,MAAM,CAACW,MAAM,GAAG,CAAC,gBACtBC,cAAA,CAAA,KAAA,EAAA;AAAKC,IAAAA,IAAI,EAAC,YAAY;AAAA,IAAA,GAAKR,eAAe;AAAA,IAAA,GAAMD,sBAAsB;AAAAU,IAAAA,QAAA,EACnEd,MAAM,CAACe,GAAG,CAAC,CAAC;AAAEC,MAAAA,KAAK,GAAG,EAAO;MAAE,GAAGC;AAAS,KAAE,EAAEC,KAAK,kBACnDN,cAAA,CAACO;AACC;AAAA,MAAA;AAAA,MAAA,GAEIF,SAAS;AACblB,MAAAA,IAAI,EAAEA,IAAK;AACXiB,MAAAA,KAAK,EAAEA,KAAM;MACbI,OAAO,EAAEJ,KAAK,KAAKR,iBAAkB;MACrCL,QAAQ,EAAGkB,SAAS,IAAI;QACtBZ,oBAAoB,CAACY,SAAS,CAAC;QAC/BlB,QAAQ,CAACkB,SAAS,CAAC;AACrB,MAAA;AAAE,KAAA,EARGH,KAQH,CAEL;GACE,CAAC,GACJ,IAAI;AACV;;;;"}
1
+ {"version":3,"file":"RadioGroup.js","sources":["../../src/radioGroup/RadioGroup.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport Radio from '../radio';\nimport { RadioProps } from '../radio/Radio';\nimport { useInputAttributes, WithInputAttributesProps } from '../inputs/contexts';\n\nexport type RadioGroupRadio<T extends string | number = string> = Omit<\n RadioProps<T>,\n 'name' | 'checked' | 'onChange' | 'className'\n>;\n\nexport interface RadioGroupProps<T extends string | number = string> {\n name: string;\n radios: readonly RadioGroupRadio<T>[];\n selectedValue?: T; // TODO: `NoInfer<T>` from TypeScript 5.4\n onChange: NonNullable<RadioProps<T>['onChange']>;\n UNSAFE_inputAttributes?: WithInputAttributesProps['inputAttributes'];\n}\n\nexport default function RadioGroup<T extends string | number = never>({\n name,\n radios,\n selectedValue: controlledValue,\n onChange,\n UNSAFE_inputAttributes,\n}: RadioGroupProps<T>) {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n\n const [uncontrolledValue, setUncontrolledValue] = useState(controlledValue);\n\n return radios.length > 0 ? (\n <div\n role=\"radiogroup\"\n {...inputAttributes}\n {...UNSAFE_inputAttributes}\n className=\"wds-radio-group\"\n >\n {radios.map(({ value = '' as T, ...restProps }, index) => (\n <Radio\n // eslint-disable-next-line react/no-array-index-key\n key={index}\n {...restProps}\n name={name}\n value={value}\n checked={value === uncontrolledValue}\n onChange={(nextValue) => {\n setUncontrolledValue(nextValue);\n onChange(nextValue);\n }}\n />\n ))}\n </div>\n ) : null;\n}\n"],"names":["RadioGroup","name","radios","selectedValue","controlledValue","onChange","UNSAFE_inputAttributes","inputAttributes","useInputAttributes","nonLabelable","uncontrolledValue","setUncontrolledValue","useState","length","_jsx","role","className","children","map","value","restProps","index","Radio","checked","nextValue"],"mappings":";;;;;;;;;AAmBc,SAAUA,UAAUA,CAAoC;EACpEC,IAAI;EACJC,MAAM;AACNC,EAAAA,aAAa,EAAEC,eAAe;EAC9BC,QAAQ;AACRC,EAAAA;AAAsB,CACH,EAAA;EACnB,MAAMC,eAAe,GAAGC,2BAAkB,CAAC;AAAEC,IAAAA,YAAY,EAAE;AAAI,GAAE,CAAC;EAElE,MAAM,CAACC,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGC,cAAQ,CAACR,eAAe,CAAC;AAE3E,EAAA,OAAOF,MAAM,CAACW,MAAM,GAAG,CAAC,gBACtBC,cAAA,CAAA,KAAA,EAAA;AACEC,IAAAA,IAAI,EAAC,YAAY;AAAA,IAAA,GACbR,eAAe;AAAA,IAAA,GACfD,sBAAsB;AAC1BU,IAAAA,SAAS,EAAC,iBAAiB;AAAAC,IAAAA,QAAA,EAE1Bf,MAAM,CAACgB,GAAG,CAAC,CAAC;AAAEC,MAAAA,KAAK,GAAG,EAAO;MAAE,GAAGC;AAAS,KAAE,EAAEC,KAAK,kBACnDP,cAAA,CAACQ;AACC;AAAA,MAAA;AAAA,MAAA,GAEIF,SAAS;AACbnB,MAAAA,IAAI,EAAEA,IAAK;AACXkB,MAAAA,KAAK,EAAEA,KAAM;MACbI,OAAO,EAAEJ,KAAK,KAAKT,iBAAkB;MACrCL,QAAQ,EAAGmB,SAAS,IAAI;QACtBb,oBAAoB,CAACa,SAAS,CAAC;QAC/BnB,QAAQ,CAACmB,SAAS,CAAC;AACrB,MAAA;AAAE,KAAA,EARGH,KAQH,CAEL;GACE,CAAC,GACJ,IAAI;AACV;;;;"}
@@ -18,6 +18,7 @@ function RadioGroup({
18
18
  role: "radiogroup",
19
19
  ...inputAttributes,
20
20
  ...UNSAFE_inputAttributes,
21
+ className: "wds-radio-group",
21
22
  children: radios.map(({
22
23
  value = '',
23
24
  ...restProps
@@ -1 +1 @@
1
- {"version":3,"file":"RadioGroup.mjs","sources":["../../src/radioGroup/RadioGroup.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport Radio from '../radio';\nimport { RadioProps } from '../radio/Radio';\nimport { useInputAttributes, WithInputAttributesProps } from '../inputs/contexts';\n\nexport type RadioGroupRadio<T extends string | number = string> = Omit<\n RadioProps<T>,\n 'name' | 'checked' | 'onChange' | 'className'\n>;\n\nexport interface RadioGroupProps<T extends string | number = string> {\n name: string;\n radios: readonly RadioGroupRadio<T>[];\n selectedValue?: T; // TODO: `NoInfer<T>` from TypeScript 5.4\n onChange: NonNullable<RadioProps<T>['onChange']>;\n UNSAFE_inputAttributes?: WithInputAttributesProps['inputAttributes'];\n}\n\nexport default function RadioGroup<T extends string | number = never>({\n name,\n radios,\n selectedValue: controlledValue,\n onChange,\n UNSAFE_inputAttributes,\n}: RadioGroupProps<T>) {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n\n const [uncontrolledValue, setUncontrolledValue] = useState(controlledValue);\n\n return radios.length > 0 ? (\n <div role=\"radiogroup\" {...inputAttributes} {...UNSAFE_inputAttributes}>\n {radios.map(({ value = '' as T, ...restProps }, index) => (\n <Radio\n // eslint-disable-next-line react/no-array-index-key\n key={index}\n {...restProps}\n name={name}\n value={value}\n checked={value === uncontrolledValue}\n onChange={(nextValue) => {\n setUncontrolledValue(nextValue);\n onChange(nextValue);\n }}\n />\n ))}\n </div>\n ) : null;\n}\n"],"names":["RadioGroup","name","radios","selectedValue","controlledValue","onChange","UNSAFE_inputAttributes","inputAttributes","useInputAttributes","nonLabelable","uncontrolledValue","setUncontrolledValue","useState","length","_jsx","role","children","map","value","restProps","index","Radio","checked","nextValue"],"mappings":";;;;;AAmBc,SAAUA,UAAUA,CAAoC;EACpEC,IAAI;EACJC,MAAM;AACNC,EAAAA,aAAa,EAAEC,eAAe;EAC9BC,QAAQ;AACRC,EAAAA;AAAsB,CACH,EAAA;EACnB,MAAMC,eAAe,GAAGC,kBAAkB,CAAC;AAAEC,IAAAA,YAAY,EAAE;AAAI,GAAE,CAAC;EAElE,MAAM,CAACC,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGC,QAAQ,CAACR,eAAe,CAAC;AAE3E,EAAA,OAAOF,MAAM,CAACW,MAAM,GAAG,CAAC,gBACtBC,GAAA,CAAA,KAAA,EAAA;AAAKC,IAAAA,IAAI,EAAC,YAAY;AAAA,IAAA,GAAKR,eAAe;AAAA,IAAA,GAAMD,sBAAsB;AAAAU,IAAAA,QAAA,EACnEd,MAAM,CAACe,GAAG,CAAC,CAAC;AAAEC,MAAAA,KAAK,GAAG,EAAO;MAAE,GAAGC;AAAS,KAAE,EAAEC,KAAK,kBACnDN,GAAA,CAACO;AACC;AAAA,MAAA;AAAA,MAAA,GAEIF,SAAS;AACblB,MAAAA,IAAI,EAAEA,IAAK;AACXiB,MAAAA,KAAK,EAAEA,KAAM;MACbI,OAAO,EAAEJ,KAAK,KAAKR,iBAAkB;MACrCL,QAAQ,EAAGkB,SAAS,IAAI;QACtBZ,oBAAoB,CAACY,SAAS,CAAC;QAC/BlB,QAAQ,CAACkB,SAAS,CAAC;AACrB,MAAA;AAAE,KAAA,EARGH,KAQH,CAEL;GACE,CAAC,GACJ,IAAI;AACV;;;;"}
1
+ {"version":3,"file":"RadioGroup.mjs","sources":["../../src/radioGroup/RadioGroup.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport Radio from '../radio';\nimport { RadioProps } from '../radio/Radio';\nimport { useInputAttributes, WithInputAttributesProps } from '../inputs/contexts';\n\nexport type RadioGroupRadio<T extends string | number = string> = Omit<\n RadioProps<T>,\n 'name' | 'checked' | 'onChange' | 'className'\n>;\n\nexport interface RadioGroupProps<T extends string | number = string> {\n name: string;\n radios: readonly RadioGroupRadio<T>[];\n selectedValue?: T; // TODO: `NoInfer<T>` from TypeScript 5.4\n onChange: NonNullable<RadioProps<T>['onChange']>;\n UNSAFE_inputAttributes?: WithInputAttributesProps['inputAttributes'];\n}\n\nexport default function RadioGroup<T extends string | number = never>({\n name,\n radios,\n selectedValue: controlledValue,\n onChange,\n UNSAFE_inputAttributes,\n}: RadioGroupProps<T>) {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n\n const [uncontrolledValue, setUncontrolledValue] = useState(controlledValue);\n\n return radios.length > 0 ? (\n <div\n role=\"radiogroup\"\n {...inputAttributes}\n {...UNSAFE_inputAttributes}\n className=\"wds-radio-group\"\n >\n {radios.map(({ value = '' as T, ...restProps }, index) => (\n <Radio\n // eslint-disable-next-line react/no-array-index-key\n key={index}\n {...restProps}\n name={name}\n value={value}\n checked={value === uncontrolledValue}\n onChange={(nextValue) => {\n setUncontrolledValue(nextValue);\n onChange(nextValue);\n }}\n />\n ))}\n </div>\n ) : null;\n}\n"],"names":["RadioGroup","name","radios","selectedValue","controlledValue","onChange","UNSAFE_inputAttributes","inputAttributes","useInputAttributes","nonLabelable","uncontrolledValue","setUncontrolledValue","useState","length","_jsx","role","className","children","map","value","restProps","index","Radio","checked","nextValue"],"mappings":";;;;;AAmBc,SAAUA,UAAUA,CAAoC;EACpEC,IAAI;EACJC,MAAM;AACNC,EAAAA,aAAa,EAAEC,eAAe;EAC9BC,QAAQ;AACRC,EAAAA;AAAsB,CACH,EAAA;EACnB,MAAMC,eAAe,GAAGC,kBAAkB,CAAC;AAAEC,IAAAA,YAAY,EAAE;AAAI,GAAE,CAAC;EAElE,MAAM,CAACC,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGC,QAAQ,CAACR,eAAe,CAAC;AAE3E,EAAA,OAAOF,MAAM,CAACW,MAAM,GAAG,CAAC,gBACtBC,GAAA,CAAA,KAAA,EAAA;AACEC,IAAAA,IAAI,EAAC,YAAY;AAAA,IAAA,GACbR,eAAe;AAAA,IAAA,GACfD,sBAAsB;AAC1BU,IAAAA,SAAS,EAAC,iBAAiB;AAAAC,IAAAA,QAAA,EAE1Bf,MAAM,CAACgB,GAAG,CAAC,CAAC;AAAEC,MAAAA,KAAK,GAAG,EAAO;MAAE,GAAGC;AAAS,KAAE,EAAEC,KAAK,kBACnDP,GAAA,CAACQ;AACC;AAAA,MAAA;AAAA,MAAA,GAEIF,SAAS;AACbnB,MAAAA,IAAI,EAAEA,IAAK;AACXkB,MAAAA,KAAK,EAAEA,KAAM;MACbI,OAAO,EAAEJ,KAAK,KAAKT,iBAAkB;MACrCL,QAAQ,EAAGmB,SAAS,IAAI;QACtBb,oBAAoB,CAACa,SAAS,CAAC;QAC/BnB,QAAQ,CAACmB,SAAS,CAAC;AACrB,MAAA;AAAE,KAAA,EARGH,KAQH,CAEL;GACE,CAAC,GACJ,IAAI;AACV;;;;"}
@@ -1,4 +1,13 @@
1
- .np-field-control {
1
+ .np-field-control,
2
+ .np-field__prompt {
2
3
  margin-top: 4px;
3
4
  margin-top: var(--size-4);
4
5
  }
6
+ .np-field .form-group--typeahead[class],
7
+ .np-field .np-checkbox-label[class] {
8
+ margin-bottom: 0;
9
+ }
10
+ .np-field:has(.wds-radio-group) .np-field__prompt {
11
+ margin-top: 12px;
12
+ margin-top: var(--size-12);
13
+ }
@@ -949,6 +949,9 @@
949
949
  .wds-inline-prompt:has(button):active {
950
950
  background-color: var(--color-sentiment-background-surface-active);
951
951
  }
952
+ .wds-inline-prompt--full-width {
953
+ width: 100%;
954
+ }
952
955
  .wds-inline-prompt--muted {
953
956
  opacity: 0.93;
954
957
  filter: grayscale(1);
@@ -3822,10 +3825,19 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3822
3825
  stroke-dasharray: calc(12px * 0.5) calc(12px * 0.5);
3823
3826
  stroke-dasharray: var(--wds-list-item-spotlight-strokeDashSize) var(--wds-list-item-spotlight-strokeDashSize);
3824
3827
  }
3825
- .np-field-control {
3828
+ .np-field-control,
3829
+ .np-field__prompt {
3826
3830
  margin-top: 4px;
3827
3831
  margin-top: var(--size-4);
3828
3832
  }
3833
+ .np-field .form-group--typeahead[class],
3834
+ .np-field .np-checkbox-label[class] {
3835
+ margin-bottom: 0;
3836
+ }
3837
+ .np-field:has(.wds-radio-group) .np-field__prompt {
3838
+ margin-top: 12px;
3839
+ margin-top: var(--size-12);
3840
+ }
3829
3841
  .np-input-group {
3830
3842
  display: inline-grid;
3831
3843
  width: 100%;
@@ -5394,6 +5406,9 @@ html:not([dir="rtl"]) .np-navigation-option {
5394
5406
  .np-CardGroup .np-Card.np-Card--promoCard {
5395
5407
  max-width: 100%;
5396
5408
  }
5409
+ .wds-radio-group .np-radio:last-child label {
5410
+ margin-bottom: 0;
5411
+ }
5397
5412
  .np-section {
5398
5413
  margin-top: 32px;
5399
5414
  margin-top: var(--size-32);
@@ -6920,6 +6935,10 @@ html:not([dir="rtl"]) .np-navigation-option {
6920
6935
  padding: 0;
6921
6936
  margin: 0;
6922
6937
  }
6938
+ .typeahead--prompt {
6939
+ margin-top: 4px;
6940
+ margin-top: var(--size-4);
6941
+ }
6923
6942
  .typeahead-sm.typeahead--multiple .typeahead__input-container {
6924
6943
  min-height: 32px;
6925
6944
  }
@@ -27,6 +27,9 @@
27
27
  .wds-inline-prompt:has(button):active {
28
28
  background-color: var(--color-sentiment-background-surface-active);
29
29
  }
30
+ .wds-inline-prompt--full-width {
31
+ width: 100%;
32
+ }
30
33
  .wds-inline-prompt--muted {
31
34
  opacity: 0.93;
32
35
  filter: grayscale(1);
@@ -0,0 +1,3 @@
1
+ .wds-radio-group .np-radio:last-child label {
2
+ margin-bottom: 0;
3
+ }
@@ -103,6 +103,10 @@
103
103
  padding: 0;
104
104
  margin: 0;
105
105
  }
106
+ .typeahead--prompt {
107
+ margin-top: 4px;
108
+ margin-top: var(--size-4);
109
+ }
106
110
  .typeahead-sm.typeahead--multiple .typeahead__input-container {
107
111
  min-height: 32px;
108
112
  }
@@ -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 InlineAlert = require('../inlineAlert/InlineAlert.js');
34
+ var InlinePrompt = require('../prompt/InlinePrompt/InlinePrompt.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,9 +427,20 @@ class Typeahead extends React.Component {
427
427
  showNewEntry,
428
428
  dropdownOpen
429
429
  });
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;
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;
433
444
  const hasWarning = displayAlert && alertType === sentiment.Sentiment.WARNING;
434
445
  const hasInfo = displayAlert && alertType === sentiment.Sentiment.NEUTRAL;
435
446
  return /*#__PURE__*/ /* eslint-disable-next-line jsx-a11y/click-events-have-key-events */jsxRuntime.jsx("div", {
@@ -444,7 +455,7 @@ class Typeahead extends React.Component {
444
455
  }),
445
456
  onClick: documentIosClick.stopPropagation,
446
457
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
447
- className: clsx.clsx('form-group', {
458
+ className: clsx.clsx('form-group', 'form-group--typeahead', {
448
459
  'has-error': hasError,
449
460
  'has-warning': hasWarning,
450
461
  'has-info': hasInfo
@@ -484,8 +495,10 @@ class Typeahead extends React.Component {
484
495
  children: /*#__PURE__*/jsxRuntime.jsx(icons.Cross, {})
485
496
  })
486
497
  })]
487
- }), displayAlert ? /*#__PURE__*/jsxRuntime.jsx(InlineAlert.default, {
488
- type: alert.type,
498
+ }), displayAlert ? /*#__PURE__*/jsxRuntime.jsx(InlinePrompt.InlinePrompt, {
499
+ sentiment: alertType,
500
+ className: "typeahead--prompt",
501
+ width: "full",
489
502
  children: alert.message
490
503
  }) : menu]
491
504
  })
@@ -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 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;AACpB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AAI,EAAEJ,KAAK,CAACI,IAAK;UAAAtB,QAAA,EAAEkB,KAAK,CAAC2B;SAAqB,CAAC,GAAGzB,IAAI;OAChF;AACP,KAAK,CAAC;AAEV,EAAA;;AAGF,wBAAe0B,oBAAU,CAACC,4BAAmB,CAAChK,SAAS,EAAE;AAAEiK,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 { 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 /**\n * @deprecated Please use [`Field`](?path=/docs/forms-field--docs) component and its `message` and `sentiment` props instead.\n * @deprecated `error`, `info` and `success` are deprecated as alert types and will be soon removed.\n */\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', 'form-group--typeahead', {\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\" width=\"full\">\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","width","message","injectIntl","withInputAttributes","nonLabelable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAMA,wBAAwB,GAAG,CAAC;AAClC,MAAMC,YAAY,GAAG,GAAG;AAk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C8E,WAAW,iBACVhC,cAAA,CAAA,KAAA,EAAA;AAAKE,YAAAA,SAAS,EAAC,mBAAmB;AAAAW,YAAAA,QAAA,eAChCb,cAAA,CAAA,QAAA,EAAA;AACEmC,cAAAA,IAAI,EAAC,QAAQ;AACbjC,cAAAA,SAAS,EAAC,cAAc;cACxB,YAAA,EAAY,IAAI,CAACjF,KAAK,EAAEuI,IAAI,EAAEC,aAAa,CAACC,0BAAQ,CAACC,UAAU,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;AAAC6D,UAAAA,KAAK,EAAC,MAAM;UAAAlD,QAAA,EAC3EkB,KAAK,CAACiC;SACK,CAAC,GAEf/B,IACD;OACE;AACP,KAAK,CAAC;AAEV,EAAA;;AAGF,wBAAegC,oBAAU,CAACC,4BAAmB,CAACtK,SAAS,EAAE;AAAEuK,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 InlineAlert from '../inlineAlert/InlineAlert.mjs';
30
+ import { InlinePrompt } from '../prompt/InlinePrompt/InlinePrompt.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,9 +417,20 @@ class Typeahead extends Component {
417
417
  showNewEntry,
418
418
  dropdownOpen
419
419
  });
420
- const alertType = alert?.type ?? Sentiment.NEUTRAL;
421
- const hasError = errorState || alert && alertType === Sentiment.ERROR;
422
- const displayAlert = !errorState && alert || alert && alertType === Sentiment.ERROR;
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;
423
434
  const hasWarning = displayAlert && alertType === Sentiment.WARNING;
424
435
  const hasInfo = displayAlert && alertType === Sentiment.NEUTRAL;
425
436
  return /*#__PURE__*/ /* eslint-disable-next-line jsx-a11y/click-events-have-key-events */jsx("div", {
@@ -434,7 +445,7 @@ class Typeahead extends Component {
434
445
  }),
435
446
  onClick: stopPropagation,
436
447
  children: /*#__PURE__*/jsxs("div", {
437
- className: clsx('form-group', {
448
+ className: clsx('form-group', 'form-group--typeahead', {
438
449
  'has-error': hasError,
439
450
  'has-warning': hasWarning,
440
451
  'has-info': hasInfo
@@ -474,8 +485,10 @@ class Typeahead extends Component {
474
485
  children: /*#__PURE__*/jsx(Cross, {})
475
486
  })
476
487
  })]
477
- }), displayAlert ? /*#__PURE__*/jsx(InlineAlert, {
478
- type: alert.type,
488
+ }), displayAlert ? /*#__PURE__*/jsx(InlinePrompt, {
489
+ sentiment: alertType,
490
+ className: "typeahead--prompt",
491
+ width: "full",
479
492
  children: alert.message
480
493
  }) : menu]
481
494
  })