@transferwise/components 46.162.2 → 46.164.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/Chips/Chip/Chip.js +11 -4
- package/build/Chips/Chip/Chip.js.map +1 -1
- package/build/Chips/Chip/Chip.mjs +11 -4
- package/build/Chips/Chip/Chip.mjs.map +1 -1
- package/build/FlowNavigation/FlowNavigation.js +4 -2
- package/build/FlowNavigation/FlowNavigation.js.map +1 -1
- package/build/FlowNavigation/FlowNavigation.mjs +4 -2
- package/build/FlowNavigation/FlowNavigation.mjs.map +1 -1
- package/build/FlowNavigation/helpers.js +24 -0
- package/build/FlowNavigation/helpers.js.map +1 -0
- package/build/FlowNavigation/helpers.mjs +21 -0
- package/build/FlowNavigation/helpers.mjs.map +1 -0
- package/build/Typeahead/Typeahead.js +17 -4
- package/build/Typeahead/Typeahead.js.map +1 -1
- package/build/Typeahead/Typeahead.mjs +17 -4
- package/build/Typeahead/Typeahead.mjs.map +1 -1
- package/build/Typeahead/TypeaheadInput/TypeaheadInput.js +2 -0
- package/build/Typeahead/TypeaheadInput/TypeaheadInput.js.map +1 -1
- package/build/Typeahead/TypeaheadInput/TypeaheadInput.mjs +2 -0
- package/build/Typeahead/TypeaheadInput/TypeaheadInput.mjs.map +1 -1
- package/build/i18n/cs.json +1 -0
- package/build/i18n/cs.json.js +1 -0
- package/build/i18n/cs.json.js.map +1 -1
- package/build/i18n/cs.json.mjs +1 -0
- package/build/i18n/cs.json.mjs.map +1 -1
- package/build/i18n/de.json +1 -0
- package/build/i18n/de.json.js +1 -0
- package/build/i18n/de.json.js.map +1 -1
- package/build/i18n/de.json.mjs +1 -0
- package/build/i18n/de.json.mjs.map +1 -1
- package/build/i18n/es.json +1 -0
- package/build/i18n/es.json.js +1 -0
- package/build/i18n/es.json.js.map +1 -1
- package/build/i18n/es.json.mjs +1 -0
- package/build/i18n/es.json.mjs.map +1 -1
- package/build/i18n/fr.json +1 -0
- package/build/i18n/fr.json.js +1 -0
- package/build/i18n/fr.json.js.map +1 -1
- package/build/i18n/fr.json.mjs +1 -0
- package/build/i18n/fr.json.mjs.map +1 -1
- package/build/i18n/hu.json +1 -0
- package/build/i18n/hu.json.js +1 -0
- package/build/i18n/hu.json.js.map +1 -1
- package/build/i18n/hu.json.mjs +1 -0
- package/build/i18n/hu.json.mjs.map +1 -1
- package/build/i18n/id.json +1 -0
- package/build/i18n/id.json.js +1 -0
- package/build/i18n/id.json.js.map +1 -1
- package/build/i18n/id.json.mjs +1 -0
- package/build/i18n/id.json.mjs.map +1 -1
- package/build/i18n/it.json +1 -0
- package/build/i18n/it.json.js +1 -0
- package/build/i18n/it.json.js.map +1 -1
- package/build/i18n/it.json.mjs +1 -0
- package/build/i18n/it.json.mjs.map +1 -1
- package/build/i18n/ja.json +1 -0
- package/build/i18n/ja.json.js +1 -0
- package/build/i18n/ja.json.js.map +1 -1
- package/build/i18n/ja.json.mjs +1 -0
- package/build/i18n/ja.json.mjs.map +1 -1
- package/build/i18n/nl.json +1 -0
- package/build/i18n/nl.json.js +1 -0
- package/build/i18n/nl.json.js.map +1 -1
- package/build/i18n/nl.json.mjs +1 -0
- package/build/i18n/nl.json.mjs.map +1 -1
- package/build/i18n/pl.json +1 -0
- package/build/i18n/pl.json.js +1 -0
- package/build/i18n/pl.json.js.map +1 -1
- package/build/i18n/pl.json.mjs +1 -0
- package/build/i18n/pl.json.mjs.map +1 -1
- package/build/i18n/pt.json +1 -0
- package/build/i18n/pt.json.js +1 -0
- package/build/i18n/pt.json.js.map +1 -1
- package/build/i18n/pt.json.mjs +1 -0
- package/build/i18n/pt.json.mjs.map +1 -1
- package/build/i18n/ro.json +1 -0
- package/build/i18n/ro.json.js +1 -0
- package/build/i18n/ro.json.js.map +1 -1
- package/build/i18n/ro.json.mjs +1 -0
- package/build/i18n/ro.json.mjs.map +1 -1
- package/build/i18n/ru.json +1 -0
- package/build/i18n/ru.json.js +1 -0
- package/build/i18n/ru.json.js.map +1 -1
- package/build/i18n/ru.json.mjs +1 -0
- package/build/i18n/ru.json.mjs.map +1 -1
- package/build/i18n/th.json +1 -0
- package/build/i18n/th.json.js +1 -0
- package/build/i18n/th.json.js.map +1 -1
- package/build/i18n/th.json.mjs +1 -0
- package/build/i18n/th.json.mjs.map +1 -1
- package/build/i18n/tr.json +1 -0
- package/build/i18n/tr.json.js +1 -0
- package/build/i18n/tr.json.js.map +1 -1
- package/build/i18n/tr.json.mjs +1 -0
- package/build/i18n/tr.json.mjs.map +1 -1
- package/build/i18n/uk.json +1 -0
- package/build/i18n/uk.json.js +1 -0
- package/build/i18n/uk.json.js.map +1 -1
- package/build/i18n/uk.json.mjs +1 -0
- package/build/i18n/uk.json.mjs.map +1 -1
- package/build/i18n/zh-HK.json +1 -0
- package/build/i18n/zh-HK.json.js +1 -0
- package/build/i18n/zh-HK.json.js.map +1 -1
- package/build/i18n/zh-HK.json.mjs +1 -0
- package/build/i18n/zh-HK.json.mjs.map +1 -1
- package/build/main.css +3 -0
- package/build/styles/Typeahead/Typeahead.css +3 -0
- package/build/styles/main.css +3 -0
- package/build/types/Body/Body.d.ts +2 -2
- package/build/types/Chips/Chip/Chip.d.ts +3 -1
- package/build/types/Chips/Chip/Chip.d.ts.map +1 -1
- package/build/types/FlowNavigation/FlowNavigation.d.ts +6 -2
- package/build/types/FlowNavigation/FlowNavigation.d.ts.map +1 -1
- package/build/types/FlowNavigation/helpers.d.ts +5 -0
- package/build/types/FlowNavigation/helpers.d.ts.map +1 -0
- package/build/types/FlowNavigation/index.d.ts +1 -0
- package/build/types/FlowNavigation/index.d.ts.map +1 -1
- package/build/types/FlowNavigation/types.d.ts +15 -0
- package/build/types/FlowNavigation/types.d.ts.map +1 -0
- package/build/types/IconButton/IconButton.d.ts +1 -1
- package/build/types/MoneyInput/MoneyInput.d.ts +1 -1
- package/build/types/MoneyInput/MoneyInput.d.ts.map +1 -1
- package/build/types/Title/Title.d.ts +2 -2
- package/build/types/Typeahead/Typeahead.d.ts +2 -0
- package/build/types/Typeahead/Typeahead.d.ts.map +1 -1
- package/build/types/Typeahead/TypeaheadInput/TypeaheadInput.d.ts +1 -1
- package/build/types/Typeahead/TypeaheadInput/TypeaheadInput.d.ts.map +1 -1
- package/build/types/Upload/Steps/UploadImageStep/UploadImageStep.d.ts +1 -1
- package/build/types/UploadInput/UploadItem/UploadItemLink.d.ts +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/Chips/Chip/Chip.test.tsx +34 -0
- package/src/Chips/Chip/Chip.tsx +11 -3
- package/src/FlowNavigation/FlowNavigation.test.tsx +45 -0
- package/src/FlowNavigation/FlowNavigation.tsx +14 -3
- package/src/FlowNavigation/_stories/FlowNavigation.CriticalBanner.docs.mdx +66 -0
- package/src/FlowNavigation/_stories/FlowNavigation.story.tsx +49 -0
- package/src/FlowNavigation/helpers.ts +28 -0
- package/src/FlowNavigation/index.ts +1 -0
- package/src/FlowNavigation/types.ts +16 -0
- package/src/Prompt/CriticalBanner/_stories/CriticalBanner.story.tsx +2 -0
- package/src/Snackbar/Snackbar.test.tsx +190 -0
- package/src/Typeahead/Typeahead.css +3 -0
- package/src/Typeahead/Typeahead.less +4 -0
- package/src/Typeahead/Typeahead.test.tsx +73 -0
- package/src/Typeahead/Typeahead.tsx +18 -3
- package/src/Typeahead/TypeaheadInput/TypeaheadInput.tsx +6 -1
- package/src/Typeahead/_stories/Typeahead.story.tsx +1 -0
- package/src/Typeahead/_stories/Typeahead.test.story.tsx +41 -0
- package/src/i18n/cs.json +1 -0
- package/src/i18n/de.json +1 -0
- package/src/i18n/es.json +1 -0
- package/src/i18n/fr.json +1 -0
- package/src/i18n/hu.json +1 -0
- package/src/i18n/id.json +1 -0
- package/src/i18n/it.json +1 -0
- package/src/i18n/ja.json +1 -0
- package/src/i18n/nl.json +1 -0
- package/src/i18n/pl.json +1 -0
- package/src/i18n/pt.json +1 -0
- package/src/i18n/ro.json +1 -0
- package/src/i18n/ru.json +1 -0
- package/src/i18n/th.json +1 -0
- package/src/i18n/tr.json +1 -0
- package/src/i18n/uk.json +1 -0
- package/src/i18n/zh-HK.json +1 -0
- package/src/index.ts +1 -1
- package/src/main.css +3 -0
package/build/Chips/Chip/Chip.js
CHANGED
|
@@ -34,6 +34,7 @@ const Chip = ({
|
|
|
34
34
|
onRemove,
|
|
35
35
|
onClick,
|
|
36
36
|
onKeyPress,
|
|
37
|
+
disabled = false,
|
|
37
38
|
className = undefined,
|
|
38
39
|
'aria-label': ariaLabel,
|
|
39
40
|
'aria-checked': ariaChecked,
|
|
@@ -41,8 +42,10 @@ const Chip = ({
|
|
|
41
42
|
closeButton
|
|
42
43
|
}) => {
|
|
43
44
|
const isActionable = onClick || onKeyPress;
|
|
45
|
+
const isInteractive = isActionable && !disabled;
|
|
44
46
|
const defaultRole = isActionable ? 'button' : undefined;
|
|
45
|
-
const
|
|
47
|
+
const chipRole = role ?? defaultRole;
|
|
48
|
+
const tabIndex = isInteractive ? 0 : -1;
|
|
46
49
|
const closeButtonReference = React.useRef(null);
|
|
47
50
|
const previousCloseButtonShown = React.useRef(undefined);
|
|
48
51
|
React.useEffect(() => {
|
|
@@ -52,12 +55,15 @@ const Chip = ({
|
|
|
52
55
|
previousCloseButtonShown.current = closeButtonReference.current != null;
|
|
53
56
|
}, [onRemove]);
|
|
54
57
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
55
|
-
role:
|
|
58
|
+
role: chipRole,
|
|
56
59
|
tabIndex: tabIndex,
|
|
57
60
|
"aria-label": ariaLabel,
|
|
58
61
|
"aria-checked": ariaChecked,
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
"aria-disabled": chipRole && disabled ? true : undefined,
|
|
63
|
+
className: clsx.clsx('np-chip', 'd-flex', 'align-items-center', 'justify-content-between', onRemove ? 'np-chip--removable' : '', {
|
|
64
|
+
disabled
|
|
65
|
+
}, className),
|
|
66
|
+
...(isInteractive && {
|
|
61
67
|
onClick,
|
|
62
68
|
onKeyPress
|
|
63
69
|
}),
|
|
@@ -71,6 +77,7 @@ const Chip = ({
|
|
|
71
77
|
"aria-label": closeButton?.['aria-label'],
|
|
72
78
|
size: "sm",
|
|
73
79
|
filled: true,
|
|
80
|
+
isDisabled: disabled,
|
|
74
81
|
onClick: onRemove
|
|
75
82
|
}) : null]
|
|
76
83
|
}, value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.js","sources":["../../../src/Chips/Chip/Chip.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef } from 'react';\n\nimport Body from '../../Body';\nimport { AriaLabelProperty, CommonProps, Typography } from '../../common';\nimport { CloseButton } from '../../common/CloseButton/CloseButton';\n\nexport type ChipValue = string | number;\n\nexport type ChipProps<T extends ChipValue = ChipValue> = {\n value?: T;\n label: string;\n onRemove?: () => void;\n onClick?: () => void;\n onKeyPress?: () => void;\n closeButton?: AriaLabelProperty;\n 'aria-checked'?: boolean;\n role?: string;\n} & AriaLabelProperty &\n CommonProps;\n\nconst Chip = <T extends ChipValue = ChipValue>({\n label,\n value,\n onRemove,\n onClick,\n onKeyPress,\n className = undefined,\n 'aria-label': ariaLabel,\n 'aria-checked': ariaChecked,\n role,\n closeButton,\n}: ChipProps<T>) => {\n const isActionable = onClick || onKeyPress;\n const defaultRole = isActionable ? 'button' : undefined;\n const tabIndex =
|
|
1
|
+
{"version":3,"file":"Chip.js","sources":["../../../src/Chips/Chip/Chip.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef } from 'react';\n\nimport Body from '../../Body';\nimport { AriaLabelProperty, CommonProps, Typography } from '../../common';\nimport { CloseButton } from '../../common/CloseButton/CloseButton';\n\nexport type ChipValue = string | number;\n\nexport type ChipProps<T extends ChipValue = ChipValue> = {\n value?: T;\n label: string;\n onRemove?: () => void;\n onClick?: () => void;\n onKeyPress?: () => void;\n /** @default false */\n disabled?: boolean;\n closeButton?: AriaLabelProperty;\n 'aria-checked'?: boolean;\n role?: string;\n} & AriaLabelProperty &\n CommonProps;\n\nconst Chip = <T extends ChipValue = ChipValue>({\n label,\n value,\n onRemove,\n onClick,\n onKeyPress,\n disabled = false,\n className = undefined,\n 'aria-label': ariaLabel,\n 'aria-checked': ariaChecked,\n role,\n closeButton,\n}: ChipProps<T>) => {\n const isActionable = onClick || onKeyPress;\n const isInteractive = isActionable && !disabled;\n const defaultRole = isActionable ? 'button' : undefined;\n const chipRole = role ?? defaultRole;\n const tabIndex = isInteractive ? 0 : -1;\n\n const closeButtonReference = useRef<HTMLButtonElement>(null);\n const previousCloseButtonShown = useRef<boolean | undefined>(undefined);\n useEffect(() => {\n if (closeButtonReference.current != null && previousCloseButtonShown.current === false) {\n closeButtonReference.current?.focus();\n }\n previousCloseButtonShown.current = closeButtonReference.current != null;\n }, [onRemove]);\n\n return (\n <div\n key={value}\n role={chipRole}\n tabIndex={tabIndex}\n aria-label={ariaLabel}\n aria-checked={ariaChecked}\n aria-disabled={chipRole && disabled ? true : undefined}\n className={clsx(\n 'np-chip',\n 'd-flex',\n 'align-items-center',\n 'justify-content-between',\n onRemove ? 'np-chip--removable' : '',\n { disabled },\n className,\n )}\n {...(isInteractive && { onClick, onKeyPress })}\n >\n <Body aria-hidden={!!onRemove} type={Typography.BODY_DEFAULT_BOLD}>\n {label}\n </Body>\n {onRemove ? (\n <CloseButton\n ref={closeButtonReference}\n className=\"btn-unstyled\"\n aria-label={closeButton?.['aria-label']}\n size=\"sm\"\n filled\n isDisabled={disabled}\n onClick={onRemove}\n />\n ) : null}\n </div>\n );\n};\n\nexport default Chip;\n"],"names":["Chip","label","value","onRemove","onClick","onKeyPress","disabled","className","undefined","ariaLabel","ariaChecked","role","closeButton","isActionable","isInteractive","defaultRole","chipRole","tabIndex","closeButtonReference","useRef","previousCloseButtonShown","useEffect","current","focus","_jsxs","clsx","children","_jsx","Body","type","Typography","BODY_DEFAULT_BOLD","CloseButton","ref","size","filled","isDisabled"],"mappings":";;;;;;;;;;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Q,IAAIV,QAAQ,GAAG,IAAI,GAAGE,SAAU;AACvDD,IAAAA,SAAS,EAAEkB,SAAI,CACb,SAAS,EACT,QAAQ,EACR,oBAAoB,EACpB,yBAAyB,EACzBtB,QAAQ,GAAG,oBAAoB,GAAG,EAAE,EACpC;AAAEG,MAAAA;KAAU,EACZC,SAAS,CACT;AAAA,IAAA,IACGO,aAAa,IAAI;MAAEV,OAAO;AAAEC,MAAAA;KAAY,CAAA;IAAAqB,QAAA,EAAA,cAE7CC,cAAA,CAACC,YAAI,EAAA;MAAC,aAAA,EAAa,CAAC,CAACzB,QAAS;MAAC0B,IAAI,EAAEC,qBAAU,CAACC,iBAAkB;AAAAL,MAAAA,QAAA,EAC/DzB;AAAK,KACF,CACN,EAACE,QAAQ,gBACPwB,cAAA,CAACK,uBAAW,EAAA;AACVC,MAAAA,GAAG,EAAEf,oBAAqB;AAC1BX,MAAAA,SAAS,EAAC,cAAc;MACxB,YAAA,EAAYK,WAAW,GAAG,YAAY,CAAE;AACxCsB,MAAAA,IAAI,EAAC,IAAI;MACTC,MAAM,EAAA,IAAA;AACNC,MAAAA,UAAU,EAAE9B,QAAS;AACrBF,MAAAA,OAAO,EAAED;KAAS,CAClB,GACA,IAAI;AAAA,GAAA,EA9BHD,KA+BF,CAAC;AAEV;;"}
|
|
@@ -30,6 +30,7 @@ const Chip = ({
|
|
|
30
30
|
onRemove,
|
|
31
31
|
onClick,
|
|
32
32
|
onKeyPress,
|
|
33
|
+
disabled = false,
|
|
33
34
|
className = undefined,
|
|
34
35
|
'aria-label': ariaLabel,
|
|
35
36
|
'aria-checked': ariaChecked,
|
|
@@ -37,8 +38,10 @@ const Chip = ({
|
|
|
37
38
|
closeButton
|
|
38
39
|
}) => {
|
|
39
40
|
const isActionable = onClick || onKeyPress;
|
|
41
|
+
const isInteractive = isActionable && !disabled;
|
|
40
42
|
const defaultRole = isActionable ? 'button' : undefined;
|
|
41
|
-
const
|
|
43
|
+
const chipRole = role ?? defaultRole;
|
|
44
|
+
const tabIndex = isInteractive ? 0 : -1;
|
|
42
45
|
const closeButtonReference = useRef(null);
|
|
43
46
|
const previousCloseButtonShown = useRef(undefined);
|
|
44
47
|
useEffect(() => {
|
|
@@ -48,12 +51,15 @@ const Chip = ({
|
|
|
48
51
|
previousCloseButtonShown.current = closeButtonReference.current != null;
|
|
49
52
|
}, [onRemove]);
|
|
50
53
|
return /*#__PURE__*/jsxs("div", {
|
|
51
|
-
role:
|
|
54
|
+
role: chipRole,
|
|
52
55
|
tabIndex: tabIndex,
|
|
53
56
|
"aria-label": ariaLabel,
|
|
54
57
|
"aria-checked": ariaChecked,
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
"aria-disabled": chipRole && disabled ? true : undefined,
|
|
59
|
+
className: clsx('np-chip', 'd-flex', 'align-items-center', 'justify-content-between', onRemove ? 'np-chip--removable' : '', {
|
|
60
|
+
disabled
|
|
61
|
+
}, className),
|
|
62
|
+
...(isInteractive && {
|
|
57
63
|
onClick,
|
|
58
64
|
onKeyPress
|
|
59
65
|
}),
|
|
@@ -67,6 +73,7 @@ const Chip = ({
|
|
|
67
73
|
"aria-label": closeButton?.['aria-label'],
|
|
68
74
|
size: "sm",
|
|
69
75
|
filled: true,
|
|
76
|
+
isDisabled: disabled,
|
|
70
77
|
onClick: onRemove
|
|
71
78
|
}) : null]
|
|
72
79
|
}, value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.mjs","sources":["../../../src/Chips/Chip/Chip.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef } from 'react';\n\nimport Body from '../../Body';\nimport { AriaLabelProperty, CommonProps, Typography } from '../../common';\nimport { CloseButton } from '../../common/CloseButton/CloseButton';\n\nexport type ChipValue = string | number;\n\nexport type ChipProps<T extends ChipValue = ChipValue> = {\n value?: T;\n label: string;\n onRemove?: () => void;\n onClick?: () => void;\n onKeyPress?: () => void;\n closeButton?: AriaLabelProperty;\n 'aria-checked'?: boolean;\n role?: string;\n} & AriaLabelProperty &\n CommonProps;\n\nconst Chip = <T extends ChipValue = ChipValue>({\n label,\n value,\n onRemove,\n onClick,\n onKeyPress,\n className = undefined,\n 'aria-label': ariaLabel,\n 'aria-checked': ariaChecked,\n role,\n closeButton,\n}: ChipProps<T>) => {\n const isActionable = onClick || onKeyPress;\n const defaultRole = isActionable ? 'button' : undefined;\n const tabIndex =
|
|
1
|
+
{"version":3,"file":"Chip.mjs","sources":["../../../src/Chips/Chip/Chip.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef } from 'react';\n\nimport Body from '../../Body';\nimport { AriaLabelProperty, CommonProps, Typography } from '../../common';\nimport { CloseButton } from '../../common/CloseButton/CloseButton';\n\nexport type ChipValue = string | number;\n\nexport type ChipProps<T extends ChipValue = ChipValue> = {\n value?: T;\n label: string;\n onRemove?: () => void;\n onClick?: () => void;\n onKeyPress?: () => void;\n /** @default false */\n disabled?: boolean;\n closeButton?: AriaLabelProperty;\n 'aria-checked'?: boolean;\n role?: string;\n} & AriaLabelProperty &\n CommonProps;\n\nconst Chip = <T extends ChipValue = ChipValue>({\n label,\n value,\n onRemove,\n onClick,\n onKeyPress,\n disabled = false,\n className = undefined,\n 'aria-label': ariaLabel,\n 'aria-checked': ariaChecked,\n role,\n closeButton,\n}: ChipProps<T>) => {\n const isActionable = onClick || onKeyPress;\n const isInteractive = isActionable && !disabled;\n const defaultRole = isActionable ? 'button' : undefined;\n const chipRole = role ?? defaultRole;\n const tabIndex = isInteractive ? 0 : -1;\n\n const closeButtonReference = useRef<HTMLButtonElement>(null);\n const previousCloseButtonShown = useRef<boolean | undefined>(undefined);\n useEffect(() => {\n if (closeButtonReference.current != null && previousCloseButtonShown.current === false) {\n closeButtonReference.current?.focus();\n }\n previousCloseButtonShown.current = closeButtonReference.current != null;\n }, [onRemove]);\n\n return (\n <div\n key={value}\n role={chipRole}\n tabIndex={tabIndex}\n aria-label={ariaLabel}\n aria-checked={ariaChecked}\n aria-disabled={chipRole && disabled ? true : undefined}\n className={clsx(\n 'np-chip',\n 'd-flex',\n 'align-items-center',\n 'justify-content-between',\n onRemove ? 'np-chip--removable' : '',\n { disabled },\n className,\n )}\n {...(isInteractive && { onClick, onKeyPress })}\n >\n <Body aria-hidden={!!onRemove} type={Typography.BODY_DEFAULT_BOLD}>\n {label}\n </Body>\n {onRemove ? (\n <CloseButton\n ref={closeButtonReference}\n className=\"btn-unstyled\"\n aria-label={closeButton?.['aria-label']}\n size=\"sm\"\n filled\n isDisabled={disabled}\n onClick={onRemove}\n />\n ) : null}\n </div>\n );\n};\n\nexport default Chip;\n"],"names":["Chip","label","value","onRemove","onClick","onKeyPress","disabled","className","undefined","ariaLabel","ariaChecked","role","closeButton","isActionable","isInteractive","defaultRole","chipRole","tabIndex","closeButtonReference","useRef","previousCloseButtonShown","useEffect","current","focus","_jsxs","clsx","children","_jsx","Body","type","Typography","BODY_DEFAULT_BOLD","CloseButton","ref","size","filled","isDisabled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAMA,IAAI,GAAGA,CAAkC;EAC7CC,KAAK;EACLC,KAAK;EACLC,QAAQ;EACRC,OAAO;EACPC,UAAU;AACVC,EAAAA,QAAQ,GAAG,KAAK;AAChBC,EAAAA,SAAS,GAAGC,SAAS;AACrB,EAAA,YAAY,EAAEC,SAAS;AACvB,EAAA,cAAc,EAAEC,WAAW;EAC3BC,IAAI;AACJC,EAAAA;AAAW,CACE,KAAI;AACjB,EAAA,MAAMC,YAAY,GAAGT,OAAO,IAAIC,UAAU;AAC1C,EAAA,MAAMS,aAAa,GAAGD,YAAY,IAAI,CAACP,QAAQ;AAC/C,EAAA,MAAMS,WAAW,GAAGF,YAAY,GAAG,QAAQ,GAAGL,SAAS;AACvD,EAAA,MAAMQ,QAAQ,GAAGL,IAAI,IAAII,WAAW;AACpC,EAAA,MAAME,QAAQ,GAAGH,aAAa,GAAG,CAAC,GAAG,EAAE;AAEvC,EAAA,MAAMI,oBAAo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AAE;AACxCsB,MAAAA,IAAI,EAAC,IAAI;MACTC,MAAM,EAAA,IAAA;AACNC,MAAAA,UAAU,EAAE9B,QAAS;AACrBF,MAAAA,OAAO,EAAED;KAAS,CAClB,GACA,IAAI;AAAA,GAAA,EA9BHD,KA+BF,CAAC;AAEV;;"}
|
|
@@ -48,6 +48,7 @@ require('../Primitives/PrimitiveButton/PrimitiveButton.js');
|
|
|
48
48
|
require('../Primitives/PrimitiveAnchor/PrimitiveAnchor.js');
|
|
49
49
|
require('../Link/Link.messages.js');
|
|
50
50
|
var CriticalBanner = require('../Prompt/CriticalBanner/CriticalBanner.js');
|
|
51
|
+
var helpers = require('./helpers.js');
|
|
51
52
|
|
|
52
53
|
const defaultLogo = /*#__PURE__*/jsxRuntime.jsx(Logo.default, {});
|
|
53
54
|
const FlowNavigation = ({
|
|
@@ -66,6 +67,7 @@ const FlowNavigation = ({
|
|
|
66
67
|
const screenLg = useScreenSize.useScreenSize(neptuneTokens.Breakpoint.LARGE);
|
|
67
68
|
const hasSteps = steps && steps.length > 0;
|
|
68
69
|
const displayGoBack = onGoBack != null && activeStep > 0;
|
|
70
|
+
const resolvedBannerData = banner ? helpers.isCriticalBannerData(banner) ? helpers.mapCriticalBannerDataToBannerProps(banner) : banner : null;
|
|
69
71
|
const closeButton = onClose != null && /*#__PURE__*/jsxRuntime.jsx(CloseButton.CloseButton, {
|
|
70
72
|
size: "lg",
|
|
71
73
|
onClick: onClose
|
|
@@ -109,8 +111,8 @@ const FlowNavigation = ({
|
|
|
109
111
|
layout: !screenLg ? layouts.Layout.VERTICAL : layouts.Layout.HORIZONTAL
|
|
110
112
|
});
|
|
111
113
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
112
|
-
children: [
|
|
113
|
-
...
|
|
114
|
+
children: [resolvedBannerData && /*#__PURE__*/jsxRuntime.jsx(CriticalBanner.CriticalBanner, {
|
|
115
|
+
...resolvedBannerData
|
|
114
116
|
}), /*#__PURE__*/jsxRuntime.jsx(Container.default, {
|
|
115
117
|
size: "fluid",
|
|
116
118
|
className: clsx.clsx('np-flow-navigation', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlowNavigation.js","sources":["../../src/FlowNavigation/FlowNavigation.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\nimport { Breakpoint } from '@transferwise/neptune-tokens';\n\nimport { Layout } from '../common';\nimport { CloseButton } from '../common/CloseButton';\nimport FlowHeader from '../common/FlowHeader/FlowHeader';\nimport Logo from '../Logo';\nimport Stepper, { type Step } from '../Stepper/Stepper';\nimport Container from '../Container';\n\nimport { useScreenSize } from '../common/hooks/useScreenSize';\nimport messages from './FlowNavigation.messages';\nimport AnimatedLabel from './AnimatedLabel';\nimport IconButton from '../IconButton';\nimport { ArrowLeft } from '@transferwise/icons';\nimport { CriticalBanner, CriticalBannerProps } from '../Prompt';\n\nconst defaultLogo = <Logo />;\n\nexport interface FlowNavigationProps {\n /** @default 0 */\n activeStep?: number;\n avatar?: React.ReactNode;\n /** @default <Logo /> */\n logo?: React.ReactNode;\n /** @default false */\n done?: boolean;\n /** Called when the close button is clicked. If not provided the close button won't show */\n onClose?: (() => void) | React.MouseEventHandler<HTMLButtonElement>;\n /** Called when the back button is clicked. If not provided the back button won't show. The back button only shows on small screens */\n onGoBack?: () => void;\n /** Steps to be displayed in stepper. If not provided, the stepper won't show. */\n steps?: readonly Step[];\n
|
|
1
|
+
{"version":3,"file":"FlowNavigation.js","sources":["../../src/FlowNavigation/FlowNavigation.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\nimport { Breakpoint } from '@transferwise/neptune-tokens';\n\nimport { Layout } from '../common';\nimport { CloseButton } from '../common/CloseButton';\nimport FlowHeader from '../common/FlowHeader/FlowHeader';\nimport Logo from '../Logo';\nimport Stepper, { type Step } from '../Stepper/Stepper';\nimport Container from '../Container';\n\nimport { useScreenSize } from '../common/hooks/useScreenSize';\nimport messages from './FlowNavigation.messages';\nimport AnimatedLabel from './AnimatedLabel';\nimport IconButton from '../IconButton';\nimport { ArrowLeft } from '@transferwise/icons';\nimport { CriticalBanner, CriticalBannerProps } from '../Prompt';\nimport { isCriticalBannerData, mapCriticalBannerDataToBannerProps } from './helpers';\nimport { CriticalBannerLegacyData } from './types';\n\nconst defaultLogo = <Logo />;\n\nexport interface FlowNavigationProps {\n /** @default 0 */\n activeStep?: number;\n avatar?: React.ReactNode;\n /** @default <Logo /> */\n logo?: React.ReactNode;\n /** @default false */\n done?: boolean;\n /** Called when the close button is clicked. If not provided the close button won't show */\n onClose?: (() => void) | React.MouseEventHandler<HTMLButtonElement>;\n /** Called when the back button is clicked. If not provided the back button won't show. The back button only shows on small screens */\n onGoBack?: () => void;\n /** Steps to be displayed in stepper. If not provided, the stepper won't show. */\n steps?: readonly Step[];\n /**\n * Optional critical banner data, to be displayed above the flow navigation.\n * Accepts either the internal `CriticalBannerProps` shape, or the legacy backend `CriticalBannerData` shape — the latter is mapped to `CriticalBannerProps` internally.\n */\n banner?: CriticalBannerLegacyData | CriticalBannerProps | null;\n /**\n * Controls whether the bottom border is displayed.\n * @default true\n */\n showBottomBorder?: boolean;\n}\n\nconst FlowNavigation = ({\n activeStep = 0,\n avatar,\n logo = defaultLogo,\n done = false,\n onClose,\n onGoBack,\n steps,\n banner = null,\n showBottomBorder = true,\n}: FlowNavigationProps) => {\n const intl = useIntl();\n const screenSm = useScreenSize(Breakpoint.SMALL);\n const screenLg = useScreenSize(Breakpoint.LARGE);\n\n const hasSteps = steps && steps.length > 0;\n const displayGoBack = onGoBack != null && activeStep > 0;\n\n const resolvedBannerData: CriticalBannerProps | null = banner\n ? isCriticalBannerData(banner)\n ? mapCriticalBannerDataToBannerProps(banner)\n : banner\n : null;\n\n const closeButton = onClose != null && <CloseButton size=\"lg\" onClick={onClose} />;\n const newAvatar = done ? null : avatar;\n\n const flowHeaderContent = (\n <FlowHeader\n className={clsx(\n 'np-flow-navigation__content',\n screenSm == null\n ? 'np-flow-navigation--hidden'\n : {\n 'np-flow-navigation--xs-max': !screenSm,\n // Size switches on parent container which may or may not have the same size as the window.\n 'np-flow-navigation--sm': screenSm,\n 'np-flow-navigation--lg': screenLg,\n },\n )}\n leftContent={\n <>\n {!screenSm && displayGoBack ? (\n <IconButton\n size={40}\n priority=\"tertiary\"\n type=\"default\"\n aria-label={intl.formatMessage(messages.back)}\n onClick={onGoBack}\n >\n <ArrowLeft />\n </IconButton>\n ) : (\n <div className=\"np-flow-header__left\">{logo}</div>\n )}\n {!screenSm && !done && hasSteps && (\n <AnimatedLabel className=\"m-x-1\" steps={steps} activeLabel={activeStep} />\n )}\n </>\n }\n rightContent={\n <div className=\"np-flow-header__right d-flex align-items-center justify-content-end order-2--lg\">\n {newAvatar}\n {newAvatar && closeButton && <span className=\"m-x-1\" />}\n {closeButton}\n </div>\n }\n bottomContent={\n !done && hasSteps ? (\n <Stepper\n activeStep={activeStep}\n steps={steps}\n className={clsx('np-flow-navigation__stepper')}\n />\n ) : null\n }\n layout={!screenLg ? Layout.VERTICAL : Layout.HORIZONTAL}\n />\n );\n\n return (\n <>\n {resolvedBannerData && <CriticalBanner {...resolvedBannerData} />}\n <Container\n size=\"fluid\"\n className={clsx('np-flow-navigation', {\n 'np-flow-navigation--border-bottom': showBottomBorder,\n 'np-flow-navigation--no-steps': !hasSteps || done,\n })}\n >\n {flowHeaderContent}\n </Container>\n </>\n );\n};\n\nexport default FlowNavigation;\n"],"names":["defaultLogo","_jsx","Logo","FlowNavigation","activeStep","avatar","logo","done","onClose","onGoBack","steps","banner","showBottomBorder","intl","useIntl","screenSm","useScreenSize","Breakpoint","SMALL","screenLg","LARGE","hasSteps","length","displayGoBack","resolvedBannerData","isCriticalBannerData","mapCriticalBannerDataToBannerProps","closeButton","CloseButton","size","onClick","newAvatar","flowHeaderContent","FlowHeader","className","clsx","leftContent","_jsxs","_Fragment","children","IconButton","priority","type","formatMessage","messages","back","ArrowLeft","AnimatedLabel","activeLabel","rightContent","bottomContent","Stepper","layout","Layout","VERTICAL","HORIZONTAL","CriticalBanner","Container"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAMA,WAAW,gBAAGC,cAAA,CAACC,YAAI,KAAG;AA4B5B,MAAMC,cAAc,GAAGA,CAAC;AACtBC,EAAAA,UAAU,GAAG,CAAC;EACdC,MAAM;AACNC,EAAAA,IAAI,GAAGN,WAAW;AAClBO,EAAAA,IAAI,GAAG,KAAK;EACZC,OAAO;EACPC,QAAQ;EACRC,KAAK;AACLC,EAAAA,MAAM,GAAG,IAAI;AACbC,EAAAA,gBAAgB,GAAG;AAAI,CACH,KAAI;AACxB,EAAA,MAAMC,IAAI,GAAGC,iBAAO,EAAE;AACtB,EAAA,MAAMC,QAAQ,GAAGC,2BAAa,CAACC,wBAAU,CAACC,KAAK,CAAC;AAChD,EAAA,MAAMC,QAAQ,GAAGH,2BAAa,CAACC,wBAAU,CAACG,KAAK,CAAC;EAEhD,MAAMC,QAAQ,GAAGX,KAAK,IAAIA,KAAK,CAACY,MAAM,GAAG,CAAC;EAC1C,MAAMC,aAAa,GAAGd,QAAQ,IAAI,IAAI,IAAIL,UAAU,GAAG,CAAC;AAExD,EAAA,MAAMoB,kBAAkB,GAA+Bb,MAAM,GACzDc,4BAAoB,CAACd,MAAM,CAAC,GAC1Be,0CAAkC,CAACf,MAAM,CAAC,GAC1CA,MAAM,GACR,IAAI;EAER,MAAMgB,WAAW,GAAGnB,OAAO,IAAI,IAAI,iBAAIP,cAAA,CAAC2B,uBAAW,EAAA;AAACC,IAAAA,IAAI,EAAC,IAAI;AAACC,IAAAA,OAAO,EAAEtB;AAAQ,IAAG;AAClF,EAAA,MAAMuB,SAAS,GAAGxB,IAAI,GAAG,IAAI,GAAGF,MAAM;AAEtC,EAAA,MAAM2B,iBAAiB,gBACrB/B,cAAA,CAACgC,kBAAU,EAAA;IACTC,SAAS,EAAEC,S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Q,gBACfpB,cAAA,CAACkD,eAAO,EAAA;AACN/C,MAAAA,UAAU,EAAEA,UAAW;AACvBM,MAAAA,KAAK,EAAEA,KAAM;MACbwB,SAAS,EAAEC,SAAI,CAAC,6BAA6B;KAAE,CAC/C,GACA,IACL;IACDiB,MAAM,EAAE,CAACjC,QAAQ,GAAGkC,cAAM,CAACC,QAAQ,GAAGD,cAAM,CAACE;AAAW,GAAA,CAE3D;EAED,oBACElB,eAAA,CAAAC,mBAAA,EAAA;AAAAC,IAAAA,QAAA,EAAA,CACGf,kBAAkB,iBAAIvB,cAAA,CAACuD,6BAAc,EAAA;MAAA,GAAKhC;AAAkB,KAAC,CAAG,eACjEvB,cAAA,CAACwD,iBAAS,EAAA;AACR5B,MAAAA,IAAI,EAAC,OAAO;AACZK,MAAAA,SAAS,EAAEC,SAAI,CAAC,oBAAoB,EAAE;AACpC,QAAA,mCAAmC,EAAEvB,gBAAgB;QACrD,8BAA8B,EAAE,CAACS,QAAQ,IAAId;AAC9C,OAAA,CAAE;AAAAgC,MAAAA,QAAA,EAEFP;AAAiB,KACT,CACb;AAAA,GAAA,CAAG;AAEP;;"}
|
|
@@ -44,6 +44,7 @@ import '../Primitives/PrimitiveButton/PrimitiveButton.mjs';
|
|
|
44
44
|
import '../Primitives/PrimitiveAnchor/PrimitiveAnchor.mjs';
|
|
45
45
|
import '../Link/Link.messages.mjs';
|
|
46
46
|
import { CriticalBanner } from '../Prompt/CriticalBanner/CriticalBanner.mjs';
|
|
47
|
+
import { isCriticalBannerData, mapCriticalBannerDataToBannerProps } from './helpers.mjs';
|
|
47
48
|
|
|
48
49
|
const defaultLogo = /*#__PURE__*/jsx(Logo, {});
|
|
49
50
|
const FlowNavigation = ({
|
|
@@ -62,6 +63,7 @@ const FlowNavigation = ({
|
|
|
62
63
|
const screenLg = useScreenSize(Breakpoint.LARGE);
|
|
63
64
|
const hasSteps = steps && steps.length > 0;
|
|
64
65
|
const displayGoBack = onGoBack != null && activeStep > 0;
|
|
66
|
+
const resolvedBannerData = banner ? isCriticalBannerData(banner) ? mapCriticalBannerDataToBannerProps(banner) : banner : null;
|
|
65
67
|
const closeButton = onClose != null && /*#__PURE__*/jsx(CloseButton, {
|
|
66
68
|
size: "lg",
|
|
67
69
|
onClick: onClose
|
|
@@ -105,8 +107,8 @@ const FlowNavigation = ({
|
|
|
105
107
|
layout: !screenLg ? Layout.VERTICAL : Layout.HORIZONTAL
|
|
106
108
|
});
|
|
107
109
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
108
|
-
children: [
|
|
109
|
-
...
|
|
110
|
+
children: [resolvedBannerData && /*#__PURE__*/jsx(CriticalBanner, {
|
|
111
|
+
...resolvedBannerData
|
|
110
112
|
}), /*#__PURE__*/jsx(Container, {
|
|
111
113
|
size: "fluid",
|
|
112
114
|
className: clsx('np-flow-navigation', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlowNavigation.mjs","sources":["../../src/FlowNavigation/FlowNavigation.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\nimport { Breakpoint } from '@transferwise/neptune-tokens';\n\nimport { Layout } from '../common';\nimport { CloseButton } from '../common/CloseButton';\nimport FlowHeader from '../common/FlowHeader/FlowHeader';\nimport Logo from '../Logo';\nimport Stepper, { type Step } from '../Stepper/Stepper';\nimport Container from '../Container';\n\nimport { useScreenSize } from '../common/hooks/useScreenSize';\nimport messages from './FlowNavigation.messages';\nimport AnimatedLabel from './AnimatedLabel';\nimport IconButton from '../IconButton';\nimport { ArrowLeft } from '@transferwise/icons';\nimport { CriticalBanner, CriticalBannerProps } from '../Prompt';\n\nconst defaultLogo = <Logo />;\n\nexport interface FlowNavigationProps {\n /** @default 0 */\n activeStep?: number;\n avatar?: React.ReactNode;\n /** @default <Logo /> */\n logo?: React.ReactNode;\n /** @default false */\n done?: boolean;\n /** Called when the close button is clicked. If not provided the close button won't show */\n onClose?: (() => void) | React.MouseEventHandler<HTMLButtonElement>;\n /** Called when the back button is clicked. If not provided the back button won't show. The back button only shows on small screens */\n onGoBack?: () => void;\n /** Steps to be displayed in stepper. If not provided, the stepper won't show. */\n steps?: readonly Step[];\n
|
|
1
|
+
{"version":3,"file":"FlowNavigation.mjs","sources":["../../src/FlowNavigation/FlowNavigation.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\nimport { Breakpoint } from '@transferwise/neptune-tokens';\n\nimport { Layout } from '../common';\nimport { CloseButton } from '../common/CloseButton';\nimport FlowHeader from '../common/FlowHeader/FlowHeader';\nimport Logo from '../Logo';\nimport Stepper, { type Step } from '../Stepper/Stepper';\nimport Container from '../Container';\n\nimport { useScreenSize } from '../common/hooks/useScreenSize';\nimport messages from './FlowNavigation.messages';\nimport AnimatedLabel from './AnimatedLabel';\nimport IconButton from '../IconButton';\nimport { ArrowLeft } from '@transferwise/icons';\nimport { CriticalBanner, CriticalBannerProps } from '../Prompt';\nimport { isCriticalBannerData, mapCriticalBannerDataToBannerProps } from './helpers';\nimport { CriticalBannerLegacyData } from './types';\n\nconst defaultLogo = <Logo />;\n\nexport interface FlowNavigationProps {\n /** @default 0 */\n activeStep?: number;\n avatar?: React.ReactNode;\n /** @default <Logo /> */\n logo?: React.ReactNode;\n /** @default false */\n done?: boolean;\n /** Called when the close button is clicked. If not provided the close button won't show */\n onClose?: (() => void) | React.MouseEventHandler<HTMLButtonElement>;\n /** Called when the back button is clicked. If not provided the back button won't show. The back button only shows on small screens */\n onGoBack?: () => void;\n /** Steps to be displayed in stepper. If not provided, the stepper won't show. */\n steps?: readonly Step[];\n /**\n * Optional critical banner data, to be displayed above the flow navigation.\n * Accepts either the internal `CriticalBannerProps` shape, or the legacy backend `CriticalBannerData` shape — the latter is mapped to `CriticalBannerProps` internally.\n */\n banner?: CriticalBannerLegacyData | CriticalBannerProps | null;\n /**\n * Controls whether the bottom border is displayed.\n * @default true\n */\n showBottomBorder?: boolean;\n}\n\nconst FlowNavigation = ({\n activeStep = 0,\n avatar,\n logo = defaultLogo,\n done = false,\n onClose,\n onGoBack,\n steps,\n banner = null,\n showBottomBorder = true,\n}: FlowNavigationProps) => {\n const intl = useIntl();\n const screenSm = useScreenSize(Breakpoint.SMALL);\n const screenLg = useScreenSize(Breakpoint.LARGE);\n\n const hasSteps = steps && steps.length > 0;\n const displayGoBack = onGoBack != null && activeStep > 0;\n\n const resolvedBannerData: CriticalBannerProps | null = banner\n ? isCriticalBannerData(banner)\n ? mapCriticalBannerDataToBannerProps(banner)\n : banner\n : null;\n\n const closeButton = onClose != null && <CloseButton size=\"lg\" onClick={onClose} />;\n const newAvatar = done ? null : avatar;\n\n const flowHeaderContent = (\n <FlowHeader\n className={clsx(\n 'np-flow-navigation__content',\n screenSm == null\n ? 'np-flow-navigation--hidden'\n : {\n 'np-flow-navigation--xs-max': !screenSm,\n // Size switches on parent container which may or may not have the same size as the window.\n 'np-flow-navigation--sm': screenSm,\n 'np-flow-navigation--lg': screenLg,\n },\n )}\n leftContent={\n <>\n {!screenSm && displayGoBack ? (\n <IconButton\n size={40}\n priority=\"tertiary\"\n type=\"default\"\n aria-label={intl.formatMessage(messages.back)}\n onClick={onGoBack}\n >\n <ArrowLeft />\n </IconButton>\n ) : (\n <div className=\"np-flow-header__left\">{logo}</div>\n )}\n {!screenSm && !done && hasSteps && (\n <AnimatedLabel className=\"m-x-1\" steps={steps} activeLabel={activeStep} />\n )}\n </>\n }\n rightContent={\n <div className=\"np-flow-header__right d-flex align-items-center justify-content-end order-2--lg\">\n {newAvatar}\n {newAvatar && closeButton && <span className=\"m-x-1\" />}\n {closeButton}\n </div>\n }\n bottomContent={\n !done && hasSteps ? (\n <Stepper\n activeStep={activeStep}\n steps={steps}\n className={clsx('np-flow-navigation__stepper')}\n />\n ) : null\n }\n layout={!screenLg ? Layout.VERTICAL : Layout.HORIZONTAL}\n />\n );\n\n return (\n <>\n {resolvedBannerData && <CriticalBanner {...resolvedBannerData} />}\n <Container\n size=\"fluid\"\n className={clsx('np-flow-navigation', {\n 'np-flow-navigation--border-bottom': showBottomBorder,\n 'np-flow-navigation--no-steps': !hasSteps || done,\n })}\n >\n {flowHeaderContent}\n </Container>\n </>\n );\n};\n\nexport default FlowNavigation;\n"],"names":["defaultLogo","_jsx","Logo","FlowNavigation","activeStep","avatar","logo","done","onClose","onGoBack","steps","banner","showBottomBorder","intl","useIntl","screenSm","useScreenSize","Breakpoint","SMALL","screenLg","LARGE","hasSteps","length","displayGoBack","resolvedBannerData","isCriticalBannerData","mapCriticalBannerDataToBannerProps","closeButton","CloseButton","size","onClick","newAvatar","flowHeaderContent","FlowHeader","className","clsx","leftContent","_jsxs","_Fragment","children","IconButton","priority","type","formatMessage","messages","back","ArrowLeft","AnimatedLabel","activeLabel","rightContent","bottomContent","Stepper","layout","Layout","VERTICAL","HORIZONTAL","CriticalBanner","Container"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAMA,WAAW,gBAAGC,GAAA,CAACC,IAAI,KAAG;AA4B5B,MAAMC,cAAc,GAAGA,CAAC;AACtBC,EAAAA,UAAU,GAAG,CAAC;EACdC,MAAM;AACNC,EAAAA,IAAI,GAAGN,WAAW;AAClBO,EAAAA,IAAI,GAAG,KAAK;EACZC,OAAO;EACPC,QAAQ;EACRC,KAAK;AACLC,EAAAA,MAAM,GAAG,IAAI;AACbC,EAAAA,gBAAgB,GAAG;AAAI,CACH,KAAI;AACxB,EAAA,MAAMC,IAAI,GAAGC,OAAO,EAAE;AACtB,EAAA,MAAMC,QAAQ,GAAGC,aAAa,CAACC,UAAU,CAACC,KAAK,CAAC;AAChD,EAAA,MAAMC,QAAQ,GAAGH,aAAa,CAACC,UAAU,CAACG,KAAK,CAAC;EAEhD,MAAMC,QAAQ,GAAGX,KAAK,IAAIA,KAAK,CAACY,MAAM,GAAG,CAAC;EAC1C,MAAMC,aAAa,GAAGd,QAAQ,IAAI,IAAI,IAAIL,UAAU,GAAG,CAAC;AAExD,EAAA,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E: 'negative',
|
|
5
|
+
WARNING: 'warning',
|
|
6
|
+
NEUTRAL: 'neutral'
|
|
7
|
+
};
|
|
8
|
+
const isCriticalBannerData = banner => 'style' in banner;
|
|
9
|
+
const mapCriticalBannerDataToBannerProps = data => ({
|
|
10
|
+
id: data.id,
|
|
11
|
+
title: data.title,
|
|
12
|
+
description: data.subtitle,
|
|
13
|
+
// subtitle → description
|
|
14
|
+
sentiment: sentimentMap[data.style],
|
|
15
|
+
action: data.action ? {
|
|
16
|
+
label: data.action.label,
|
|
17
|
+
href: data.action.href
|
|
18
|
+
} : undefined,
|
|
19
|
+
expanded: !data.collapsed // collapsed → expanded (inverted)
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
exports.isCriticalBannerData = isCriticalBannerData;
|
|
23
|
+
exports.mapCriticalBannerDataToBannerProps = mapCriticalBannerDataToBannerProps;
|
|
24
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../src/FlowNavigation/helpers.ts"],"sourcesContent":["import { CriticalBannerProps } from '../Prompt';\nimport { CriticalBannerLegacyData } from './types';\n\nconst sentimentMap: Record<CriticalBannerLegacyData['style'], CriticalBannerProps['sentiment']> = {\n NEGATIVE: 'negative',\n WARNING: 'warning',\n NEUTRAL: 'neutral',\n};\n\nexport const isCriticalBannerData = (\n banner: CriticalBannerLegacyData | CriticalBannerProps,\n): banner is CriticalBannerLegacyData => 'style' in banner;\n\nexport const mapCriticalBannerDataToBannerProps = (\n data: CriticalBannerLegacyData,\n): CriticalBannerProps => ({\n id: data.id,\n title: data.title,\n description: data.subtitle, // subtitle → description\n sentiment: sentimentMap[data.style],\n action: data.action\n ? {\n label: data.action.label,\n href: data.action.href,\n }\n : undefined,\n expanded: !data.collapsed, // collapsed → expanded (inverted)\n});\n"],"names":["sentimentMap","NEGATIVE","WARNING","NEUTRAL","isCriticalBannerData","banner","mapCriticalBannerDataToBannerProps","data","id","title","description","subtitle","sentiment","style","action","label","href","undefined","expanded","collapsed"],"mappings":";;AAGA,MAAMA,YAAY,GAAgF;AAChGC,EAAAA,QAAQ,EAAE,UAAU;AACpBC,EAAAA,OAAO,EAAE,SAAS;AAClBC,EAAAA,OAAO,EAAE;CACV;MAEYC,oBAAoB,GAC/BC,MAAsD,IACf,OAAO,IAAIA;AAE7C,MAAMC,kCAAkC,GAC7CC,IAA8B,KACL;EACzBC,EAAE,EAAED,IAAI,CAACC,EAAE;EACXC,KAAK,EAAEF,IAAI,CAACE,KAAK;EACjBC,WAAW,EAAEH,IAAI,CAACI,QAAQ;AAAE;AAC5BC,EAAAA,SAAS,EAAEZ,YAAY,CAACO,IAAI,CAACM,KAAK,CAAC;AACnCC,EAAAA,MAAM,EAAEP,IAAI,CAACO,MAAM,GACf;AACEC,IAAAA,KAAK,EAAER,IAAI,CAACO,MAAM,CAACC,KAAK;AACxBC,IAAAA,IAAI,EAAET,IAAI,CAACO,MAAM,CAACE;AACnB,GAAA,GACDC,SAAS;AACbC,EAAAA,QAAQ,EAAE,CAACX,IAAI,CAACY,SAAS;AAC1B,CAAA;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const sentimentMap = {
|
|
2
|
+
NEGATIVE: 'negative',
|
|
3
|
+
WARNING: 'warning',
|
|
4
|
+
NEUTRAL: 'neutral'
|
|
5
|
+
};
|
|
6
|
+
const isCriticalBannerData = banner => 'style' in banner;
|
|
7
|
+
const mapCriticalBannerDataToBannerProps = data => ({
|
|
8
|
+
id: data.id,
|
|
9
|
+
title: data.title,
|
|
10
|
+
description: data.subtitle,
|
|
11
|
+
// subtitle → description
|
|
12
|
+
sentiment: sentimentMap[data.style],
|
|
13
|
+
action: data.action ? {
|
|
14
|
+
label: data.action.label,
|
|
15
|
+
href: data.action.href
|
|
16
|
+
} : undefined,
|
|
17
|
+
expanded: !data.collapsed // collapsed → expanded (inverted)
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export { isCriticalBannerData, mapCriticalBannerDataToBannerProps };
|
|
21
|
+
//# sourceMappingURL=helpers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.mjs","sources":["../../src/FlowNavigation/helpers.ts"],"sourcesContent":["import { CriticalBannerProps } from '../Prompt';\nimport { CriticalBannerLegacyData } from './types';\n\nconst sentimentMap: Record<CriticalBannerLegacyData['style'], CriticalBannerProps['sentiment']> = {\n NEGATIVE: 'negative',\n WARNING: 'warning',\n NEUTRAL: 'neutral',\n};\n\nexport const isCriticalBannerData = (\n banner: CriticalBannerLegacyData | CriticalBannerProps,\n): banner is CriticalBannerLegacyData => 'style' in banner;\n\nexport const mapCriticalBannerDataToBannerProps = (\n data: CriticalBannerLegacyData,\n): CriticalBannerProps => ({\n id: data.id,\n title: data.title,\n description: data.subtitle, // subtitle → description\n sentiment: sentimentMap[data.style],\n action: data.action\n ? {\n label: data.action.label,\n href: data.action.href,\n }\n : undefined,\n expanded: !data.collapsed, // collapsed → expanded (inverted)\n});\n"],"names":["sentimentMap","NEGATIVE","WARNING","NEUTRAL","isCriticalBannerData","banner","mapCriticalBannerDataToBannerProps","data","id","title","description","subtitle","sentiment","style","action","label","href","undefined","expanded","collapsed"],"mappings":"AAGA,MAAMA,YAAY,GAAgF;AAChGC,EAAAA,QAAQ,EAAE,UAAU;AACpBC,EAAAA,OAAO,EAAE,SAAS;AAClBC,EAAAA,OAAO,EAAE;CACV;MAEYC,oBAAoB,GAC/BC,MAAsD,IACf,OAAO,IAAIA;AAE7C,MAAMC,kCAAkC,GAC7CC,IAA8B,KACL;EACzBC,EAAE,EAAED,IAAI,CAACC,EAAE;EACXC,KAAK,EAAEF,IAAI,CAACE,KAAK;EACjBC,WAAW,EAAEH,IAAI,CAACI,QAAQ;AAAE;AAC5BC,EAAAA,SAAS,EAAEZ,YAAY,CAACO,IAAI,CAACM,KAAK,CAAC;AACnCC,EAAAA,MAAM,EAAEP,IAAI,CAACO,MAAM,GACf;AACEC,IAAAA,KAAK,EAAER,IAAI,CAACO,MAAM,CAACC,KAAK;AACxBC,IAAAA,IAAI,EAAET,IAAI,CAACO,MAAM,CAACE;AACnB,GAAA,GACDC,SAAS;AACbC,EAAAA,QAAQ,EAAE,CAACX,IAAI,CAACY,SAAS;AAC1B,CAAA;;"}
|
|
@@ -67,6 +67,7 @@ class Typeahead extends React.Component {
|
|
|
67
67
|
autoFocus: false,
|
|
68
68
|
chipSeparators: [],
|
|
69
69
|
clearable: true,
|
|
70
|
+
disabled: false,
|
|
70
71
|
initialValue: [],
|
|
71
72
|
inputAutoComplete: 'new-password',
|
|
72
73
|
minQueryLength: DEFAULT_MIN_QUERY_LENGTH,
|
|
@@ -117,6 +118,11 @@ class Typeahead extends React.Component {
|
|
|
117
118
|
});
|
|
118
119
|
}
|
|
119
120
|
}
|
|
121
|
+
componentDidUpdate(previousProps) {
|
|
122
|
+
if (this.props.disabled && !previousProps.disabled) {
|
|
123
|
+
this.hideMenu();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
120
126
|
componentWillUnmount() {
|
|
121
127
|
this.handleSearchDebounced.cancel();
|
|
122
128
|
}
|
|
@@ -372,6 +378,9 @@ class Typeahead extends React.Component {
|
|
|
372
378
|
}
|
|
373
379
|
};
|
|
374
380
|
renderChip = (option, idx) => {
|
|
381
|
+
const {
|
|
382
|
+
disabled
|
|
383
|
+
} = this.props;
|
|
375
384
|
const valid = this.props.validateChip?.(option);
|
|
376
385
|
return /*#__PURE__*/jsxRuntime.jsx(Chip.default, {
|
|
377
386
|
label: option.label,
|
|
@@ -379,7 +388,8 @@ class Typeahead extends React.Component {
|
|
|
379
388
|
'has-error': !valid,
|
|
380
389
|
'np-chip--valid': valid
|
|
381
390
|
}),
|
|
382
|
-
|
|
391
|
+
disabled: disabled,
|
|
392
|
+
onRemove: disabled ? undefined : () => this.removeChip(option)
|
|
383
393
|
}, idx);
|
|
384
394
|
};
|
|
385
395
|
renderMenu = ({
|
|
@@ -437,6 +447,7 @@ class Typeahead extends React.Component {
|
|
|
437
447
|
addon,
|
|
438
448
|
name,
|
|
439
449
|
clearable,
|
|
450
|
+
disabled,
|
|
440
451
|
allowNew,
|
|
441
452
|
footer,
|
|
442
453
|
showSuggestions,
|
|
@@ -456,8 +467,8 @@ class Typeahead extends React.Component {
|
|
|
456
467
|
optionsShown,
|
|
457
468
|
keyboardFocusedOptionIndex
|
|
458
469
|
} = this.state;
|
|
459
|
-
const clearButton = clearable && (query || selected.length > 0);
|
|
460
|
-
const dropdownOpen = optionsShown && showSuggestions && query.length >= minQueryLength;
|
|
470
|
+
const clearButton = !disabled && clearable && (query || selected.length > 0);
|
|
471
|
+
const dropdownOpen = !disabled && optionsShown && showSuggestions && query.length >= minQueryLength;
|
|
461
472
|
const menu = this.renderMenu({
|
|
462
473
|
footer,
|
|
463
474
|
options,
|
|
@@ -503,13 +514,15 @@ class Typeahead extends React.Component {
|
|
|
503
514
|
}),
|
|
504
515
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
505
516
|
className: clsx.clsx(`input-group input-group-${size}`, {
|
|
506
|
-
'input-group--has-error': hasError
|
|
517
|
+
'input-group--has-error': hasError,
|
|
518
|
+
disabled
|
|
507
519
|
}),
|
|
508
520
|
children: [addon && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
509
521
|
className: "input-group-addon input-group-addon--search",
|
|
510
522
|
children: addon
|
|
511
523
|
}), /*#__PURE__*/jsxRuntime.jsx(TypeaheadInput.default, {
|
|
512
524
|
autoFocus,
|
|
525
|
+
disabled,
|
|
513
526
|
multiple,
|
|
514
527
|
dropdownOpen,
|
|
515
528
|
placeholder,
|