@transferwise/components 46.87.2 → 46.88.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.
- package/build/avatarLayout/AvatarLayout.js +9 -2
- package/build/avatarLayout/AvatarLayout.js.map +1 -1
- package/build/avatarLayout/AvatarLayout.mjs +9 -2
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/button/Button.js +92 -79
- package/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs +93 -80
- package/build/button/Button.mjs.map +1 -1
- package/build/button/Button.resolver.js +74 -0
- package/build/button/Button.resolver.js.map +1 -0
- package/build/button/Button.resolver.mjs +72 -0
- package/build/button/Button.resolver.mjs.map +1 -0
- package/build/button/LegacyButton.js +114 -0
- package/build/button/LegacyButton.js.map +1 -0
- package/build/button/LegacyButton.mjs +112 -0
- package/build/button/LegacyButton.mjs.map +1 -0
- package/build/circularButton/CircularButton.js.map +1 -1
- package/build/circularButton/CircularButton.mjs.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.js +2 -2
- package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
- package/build/header/Header.js +2 -2
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs +1 -1
- package/build/index.js +2 -2
- package/build/index.mjs +1 -1
- package/build/link/Link.js +8 -3
- package/build/link/Link.js.map +1 -1
- package/build/link/Link.mjs +8 -3
- package/build/link/Link.mjs.map +1 -1
- package/build/main.css +247 -0
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +2 -4
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +2 -4
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +3 -5
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +3 -5
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
- package/build/select/Select.js +2 -2
- package/build/select/Select.js.map +1 -1
- package/build/select/Select.mjs +1 -1
- package/build/styles/avatarLayout/AvatarLayout.css +11 -0
- package/build/styles/button/Button.css +228 -15
- package/build/styles/button/Button.vars.css +46 -0
- package/build/styles/button/LegacyButton.css +23 -0
- package/build/styles/main.css +247 -0
- package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
- package/build/types/button/Button.d.ts +4 -23
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/button/Button.resolver.d.ts +11 -0
- package/build/types/button/Button.resolver.d.ts.map +1 -0
- package/build/types/button/Button.types.d.ts +70 -0
- package/build/types/button/Button.types.d.ts.map +1 -0
- package/build/types/button/LegacyButton.d.ts +44 -0
- package/build/types/button/LegacyButton.d.ts.map +1 -0
- package/build/types/button/index.d.ts +3 -2
- package/build/types/button/index.d.ts.map +1 -1
- package/build/types/circularButton/CircularButton.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/link/Link.d.ts +2 -2
- package/build/types/link/Link.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +6 -2
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
- package/build/types/test-utils/story-config.d.ts +1 -1
- package/build/types/test-utils/story-config.d.ts.map +1 -1
- package/build/upload/steps/completeStep/completeStep.js +2 -2
- package/build/upload/steps/completeStep/completeStep.js.map +1 -1
- package/build/upload/steps/completeStep/completeStep.mjs +1 -1
- package/build/upload/steps/processingStep/processingStep.js +2 -2
- package/build/upload/steps/processingStep/processingStep.js.map +1 -1
- package/build/upload/steps/processingStep/processingStep.mjs +1 -1
- package/build/uploadInput/UploadInput.js +3 -3
- package/build/uploadInput/UploadInput.js.map +1 -1
- package/build/uploadInput/UploadInput.mjs +1 -1
- package/package.json +3 -3
- package/src/alert/Alert.tests.story.tsx +1 -1
- package/src/avatar/Avatar.story.tsx +1 -1
- package/src/avatarLayout/AvatarLayout.css +11 -0
- package/src/avatarLayout/AvatarLayout.less +18 -1
- package/src/avatarLayout/AvatarLayout.tsx +10 -2
- package/src/avatarWrapper/AvatarWrapper.story.tsx +1 -1
- package/src/badge/Badge.story.tsx +1 -1
- package/src/button/Button.accessibility.docs.mdx +103 -0
- package/src/button/Button.css +228 -15
- package/src/button/Button.less +242 -14
- package/src/button/Button.resolver.tsx +73 -0
- package/src/button/Button.spec.tsx +329 -213
- package/src/button/Button.story.tsx +782 -134
- package/src/button/Button.tests.story.tsx +27 -0
- package/src/button/Button.tsx +109 -132
- package/src/button/Button.types.ts +92 -0
- package/src/button/Button.vars.css +46 -0
- package/src/button/Button.vars.less +59 -0
- package/src/button/LegacyButton.css +23 -0
- package/src/button/LegacyButton.less +24 -0
- package/src/button/LegacyButton.spec.tsx +147 -0
- package/src/button/LegacyButton.story.tsx +228 -0
- package/src/button/LegacyButton.tsx +177 -0
- package/src/button/index.ts +6 -2
- package/src/card/Card.story.tsx +6 -1
- package/src/circularButton/CircularButton.tsx +1 -0
- package/src/field/Field.story.tsx +1 -1
- package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -2
- package/src/index.ts +1 -1
- package/src/inputs/SelectInput.story.tsx +1 -1
- package/src/label/Label.story.tsx +1 -1
- package/src/link/Link.tsx +15 -6
- package/src/main.css +247 -0
- package/src/main.less +1 -0
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +2 -8
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +7 -2
- package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +1 -3
- package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +4 -12
- package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +16 -13
- package/src/select/Select.story.tsx +4 -1
- package/src/test-utils/Parameters.d.ts +9 -1
- package/src/test-utils/story-config.ts +10 -1
- package/src/button/__snapshots__/Button.spec.tsx.snap +0 -309
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completeStep.js","sources":["../../../../src/upload/steps/completeStep/completeStep.tsx"],"sourcesContent":["import { Document as DocumentIcon } from '@transferwise/icons';\n\nimport { Typography } from '../../..';\nimport Body from '../../../body';\nimport Button from '../../../button';\nimport Title from '../../../title';\n\nexport interface CompleteStepProps {\n csButtonText: string;\n csSuccessText: string;\n fileName: string;\n isComplete: boolean;\n isImage: boolean;\n uploadedImage?: string;\n onClear: React.MouseEventHandler<HTMLButtonElement>;\n}\n\nexport default function CompleteStep({\n csButtonText,\n csSuccessText,\n fileName,\n isComplete,\n isImage,\n onClear,\n uploadedImage,\n}: CompleteStepProps) {\n return (\n <div className=\"droppable-complete-card droppable-card\" aria-hidden={!isComplete}>\n <div className=\"droppable-card-content\">\n <div\n className=\"droppable-card-content d-flex flex-column align-items-center\"\n aria-live=\"polite\"\n >\n {isImage && uploadedImage ? (\n <img src={uploadedImage} alt=\"OK\" className=\"thumbnail \" />\n ) : (\n <DocumentIcon />\n )}\n\n {fileName && (\n <Body as=\"p\" className=\"m-b-0\">\n {fileName}\n </Body>\n )}\n {csSuccessText && (\n <Title className=\"caption m-t-1\" type={Typography.TITLE_BODY}>\n {csSuccessText}\n </Title>\n )}\n </div>\n {csButtonText && (\n <Button className=\"m-t-1\" onClick={onClear}>\n {csButtonText}\n </Button>\n )}\n </div>\n </div>\n );\n}\n"],"names":["CompleteStep","csButtonText","csSuccessText","fileName","isComplete","isImage","onClear","uploadedImage","_jsx","className","children","_jsxs","src","alt","DocumentIcon","Body","as","Title","type","Typography","TITLE_BODY","Button","onClick"],"mappings":";;;;;;;;;AAiBc,SAAUA,YAAYA,CAAC;EACnCC,YAAY;EACZC,aAAa;EACbC,QAAQ;EACRC,UAAU;EACVC,OAAO;EACPC,OAAO;AACPC,EAAAA,aAAAA;AACkB,CAAA,EAAA;AAClB,EAAA,oBACEC,cAAA,CAAA,KAAA,EAAA;AAAKC,IAAAA,SAAS,EAAC,wCAAwC;AAAC,IAAA,aAAA,EAAa,CAACL,UAAW;AAAAM,IAAAA,QAAA,eAC/EC,eAAA,CAAA,KAAA,EAAA;AAAKF,MAAAA,SAAS,EAAC,wBAAwB;AAAAC,MAAAA,QAAA,gBACrCC,eAAA,CAAA,KAAA,EAAA;AACEF,QAAAA,SAAS,EAAC,8DAA8D;AACxE,QAAA,WAAA,EAAU,QAAQ;AAAAC,QAAAA,QAAA,EAEjBL,CAAAA,OAAO,IAAIE,aAAa,gBACvBC,cAAA,CAAA,KAAA,EAAA;AAAKI,UAAAA,GAAG,EAAEL,aAAc;AAACM,UAAAA,GAAG,EAAC,IAAI;AAACJ,UAAAA,SAAS,EAAC,YAAA;AAAY,SAAA,CAAG,gBAE3DD,cAAA,CAACM,cAAY,EAAA,EAAA,CACd,EAEAX,QAAQ,iBACPK,cAAA,CAACO,IAAI,EAAA;AAACC,UAAAA,EAAE,EAAC,GAAG;AAACP,UAAAA,SAAS,EAAC,OAAO;AAAAC,UAAAA,QAAA,EAC3BP,QAAAA;AAAQ,SACL,CACP,EACAD,aAAa,iBACZM,cAAA,CAACS,KAAK,EAAA;AAACR,UAAAA,SAAS,EAAC,eAAe;UAACS,IAAI,EAAEC,qBAAU,CAACC,UAAW;AAAAV,UAAAA,QAAA,EAC1DR,aAAAA;AAAa,SACT,CACR,CAAA;AAAA,OACE,CACL,EAACD,YAAY,iBACXO,cAAA,CAACa,
|
|
1
|
+
{"version":3,"file":"completeStep.js","sources":["../../../../src/upload/steps/completeStep/completeStep.tsx"],"sourcesContent":["import { Document as DocumentIcon } from '@transferwise/icons';\n\nimport { Typography } from '../../..';\nimport Body from '../../../body';\nimport Button from '../../../button';\nimport Title from '../../../title';\n\nexport interface CompleteStepProps {\n csButtonText: string;\n csSuccessText: string;\n fileName: string;\n isComplete: boolean;\n isImage: boolean;\n uploadedImage?: string;\n onClear: React.MouseEventHandler<HTMLButtonElement>;\n}\n\nexport default function CompleteStep({\n csButtonText,\n csSuccessText,\n fileName,\n isComplete,\n isImage,\n onClear,\n uploadedImage,\n}: CompleteStepProps) {\n return (\n <div className=\"droppable-complete-card droppable-card\" aria-hidden={!isComplete}>\n <div className=\"droppable-card-content\">\n <div\n className=\"droppable-card-content d-flex flex-column align-items-center\"\n aria-live=\"polite\"\n >\n {isImage && uploadedImage ? (\n <img src={uploadedImage} alt=\"OK\" className=\"thumbnail \" />\n ) : (\n <DocumentIcon />\n )}\n\n {fileName && (\n <Body as=\"p\" className=\"m-b-0\">\n {fileName}\n </Body>\n )}\n {csSuccessText && (\n <Title className=\"caption m-t-1\" type={Typography.TITLE_BODY}>\n {csSuccessText}\n </Title>\n )}\n </div>\n {csButtonText && (\n <Button className=\"m-t-1\" onClick={onClear}>\n {csButtonText}\n </Button>\n )}\n </div>\n </div>\n );\n}\n"],"names":["CompleteStep","csButtonText","csSuccessText","fileName","isComplete","isImage","onClear","uploadedImage","_jsx","className","children","_jsxs","src","alt","DocumentIcon","Body","as","Title","type","Typography","TITLE_BODY","Button","onClick"],"mappings":";;;;;;;;;AAiBc,SAAUA,YAAYA,CAAC;EACnCC,YAAY;EACZC,aAAa;EACbC,QAAQ;EACRC,UAAU;EACVC,OAAO;EACPC,OAAO;AACPC,EAAAA,aAAAA;AACkB,CAAA,EAAA;AAClB,EAAA,oBACEC,cAAA,CAAA,KAAA,EAAA;AAAKC,IAAAA,SAAS,EAAC,wCAAwC;AAAC,IAAA,aAAA,EAAa,CAACL,UAAW;AAAAM,IAAAA,QAAA,eAC/EC,eAAA,CAAA,KAAA,EAAA;AAAKF,MAAAA,SAAS,EAAC,wBAAwB;AAAAC,MAAAA,QAAA,gBACrCC,eAAA,CAAA,KAAA,EAAA;AACEF,QAAAA,SAAS,EAAC,8DAA8D;AACxE,QAAA,WAAA,EAAU,QAAQ;AAAAC,QAAAA,QAAA,EAEjBL,CAAAA,OAAO,IAAIE,aAAa,gBACvBC,cAAA,CAAA,KAAA,EAAA;AAAKI,UAAAA,GAAG,EAAEL,aAAc;AAACM,UAAAA,GAAG,EAAC,IAAI;AAACJ,UAAAA,SAAS,EAAC,YAAA;AAAY,SAAA,CAAG,gBAE3DD,cAAA,CAACM,cAAY,EAAA,EAAA,CACd,EAEAX,QAAQ,iBACPK,cAAA,CAACO,IAAI,EAAA;AAACC,UAAAA,EAAE,EAAC,GAAG;AAACP,UAAAA,SAAS,EAAC,OAAO;AAAAC,UAAAA,QAAA,EAC3BP,QAAAA;AAAQ,SACL,CACP,EACAD,aAAa,iBACZM,cAAA,CAACS,KAAK,EAAA;AAACR,UAAAA,SAAS,EAAC,eAAe;UAACS,IAAI,EAAEC,qBAAU,CAACC,UAAW;AAAAV,UAAAA,QAAA,EAC1DR,aAAAA;AAAa,SACT,CACR,CAAA;AAAA,OACE,CACL,EAACD,YAAY,iBACXO,cAAA,CAACa,eAAM,EAAA;AAACZ,QAAAA,SAAS,EAAC,OAAO;AAACa,QAAAA,OAAO,EAAEhB,OAAQ;AAAAI,QAAAA,QAAA,EACxCT,YAAAA;AAAY,OACP,CACT,CAAA;KACE,CAAA;AACP,GAAK,CAAC,CAAA;AAEV;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Document } from '@transferwise/icons';
|
|
2
2
|
import Body from '../../../body/Body.mjs';
|
|
3
|
-
import Button from '../../../button/Button.mjs';
|
|
3
|
+
import Button from '../../../button/Button.resolver.mjs';
|
|
4
4
|
import Title from '../../../title/Title.mjs';
|
|
5
5
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
6
6
|
import { Typography } from '../../../common/propsValues/typography.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var Button_resolver = require('../../../button/Button.resolver.js');
|
|
4
4
|
require('../../../common/theme.js');
|
|
5
5
|
require('../../../common/direction.js');
|
|
6
6
|
require('../../../common/propsValues/control.js');
|
|
@@ -59,7 +59,7 @@ function ProcessingStep({
|
|
|
59
59
|
type: typography.Typography.TITLE_BODY,
|
|
60
60
|
"aria-live": "polite",
|
|
61
61
|
children: psProcessingText
|
|
62
|
-
}), psButtonText && /*#__PURE__*/jsxRuntime.jsx(
|
|
62
|
+
}), psButtonText && /*#__PURE__*/jsxRuntime.jsx(Button_resolver, {
|
|
63
63
|
disabled: psButtonDisabled,
|
|
64
64
|
onClick: onClear,
|
|
65
65
|
children: psButtonText
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processingStep.js","sources":["../../../../src/upload/steps/processingStep/processingStep.tsx"],"sourcesContent":["import Button from '../../../button';\nimport { Status, Typography } from '../../../common';\nimport ProcessIndicator, { ProcessIndicatorStatus } from '../../../processIndicator';\nimport Title from '../../../title';\n\nexport interface ProcessingStepProps {\n isComplete: boolean;\n isError: boolean;\n isSuccess: boolean;\n onAnimationCompleted: (status: ProcessIndicatorStatus) => void;\n onClear: React.MouseEventHandler<HTMLButtonElement>;\n psButtonText: string;\n psProcessingText: string;\n psButtonDisabled: boolean;\n}\n\nexport default function ProcessingStep({\n isComplete,\n isError,\n isSuccess,\n onAnimationCompleted,\n onClear,\n psButtonText,\n psProcessingText,\n psButtonDisabled,\n}: ProcessingStepProps) {\n let processStatus = Status.PROCESSING;\n if (isError) {\n processStatus = Status.FAILED;\n }\n if (isSuccess) {\n processStatus = Status.SUCCEEDED;\n }\n\n return (\n <div className=\"droppable-processing-card droppable-card\" aria-hidden={isComplete}>\n <div className=\"droppable-card-content\">\n <ProcessIndicator\n status={processStatus}\n onAnimationCompleted={(status) => onAnimationCompleted(status)}\n />\n <Title className=\"m-y-2\" type={Typography.TITLE_BODY} aria-live=\"polite\">\n {psProcessingText}\n </Title>\n {psButtonText && (\n <Button disabled={psButtonDisabled} onClick={onClear}>\n {psButtonText}\n </Button>\n )}\n </div>\n </div>\n );\n}\n"],"names":["ProcessingStep","isComplete","isError","isSuccess","onAnimationCompleted","onClear","psButtonText","psProcessingText","psButtonDisabled","processStatus","Status","PROCESSING","FAILED","SUCCEEDED","_jsx","className","children","_jsxs","ProcessIndicator","status","Title","type","Typography","TITLE_BODY","Button","disabled","onClick"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBwB,SAAAA,cAAcA,CAAC;EACrCC,UAAU;EACVC,OAAO;EACPC,SAAS;EACTC,oBAAoB;EACpBC,OAAO;EACPC,YAAY;EACZC,gBAAgB;AAChBC,EAAAA,gBAAAA;AACoB,CAAA,EAAA;AACpB,EAAA,IAAIC,aAAa,GAAGC,aAAM,CAACC,UAAU,CAAA;AACrC,EAAA,IAAIT,OAAO,EAAE;IACXO,aAAa,GAAGC,aAAM,CAACE,MAAM,CAAA;AAC/B,GAAA;AACA,EAAA,IAAIT,SAAS,EAAE;IACbM,aAAa,GAAGC,aAAM,CAACG,SAAS,CAAA;AAClC,GAAA;AAEA,EAAA,oBACEC,cAAA,CAAA,KAAA,EAAA;AAAKC,IAAAA,SAAS,EAAC,0CAA0C;AAAC,IAAA,aAAA,EAAad,UAAW;AAAAe,IAAAA,QAAA,eAChFC,eAAA,CAAA,KAAA,EAAA;AAAKF,MAAAA,SAAS,EAAC,wBAAwB;MAAAC,QAAA,EAAA,cACrCF,cAAA,CAACI,gBAAgB,EAAA;AACfC,QAAAA,MAAM,EAAEV,aAAc;AACtBL,QAAAA,oBAAoB,EAAGe,MAAM,IAAKf,oBAAoB,CAACe,MAAM,CAAA;AAAE,OAEjE,CAAA,eAAAL,cAAA,CAACM,KAAK,EAAA;AAACL,QAAAA,SAAS,EAAC,OAAO;QAACM,IAAI,EAAEC,qBAAU,CAACC,UAAW;AAAC,QAAA,WAAA,EAAU,QAAQ;AAAAP,QAAAA,QAAA,EACrET,gBAAAA;AAAgB,OACZ,CACP,EAACD,YAAY,iBACXQ,cAAA,CAACU,
|
|
1
|
+
{"version":3,"file":"processingStep.js","sources":["../../../../src/upload/steps/processingStep/processingStep.tsx"],"sourcesContent":["import Button from '../../../button';\nimport { Status, Typography } from '../../../common';\nimport ProcessIndicator, { ProcessIndicatorStatus } from '../../../processIndicator';\nimport Title from '../../../title';\n\nexport interface ProcessingStepProps {\n isComplete: boolean;\n isError: boolean;\n isSuccess: boolean;\n onAnimationCompleted: (status: ProcessIndicatorStatus) => void;\n onClear: React.MouseEventHandler<HTMLButtonElement>;\n psButtonText: string;\n psProcessingText: string;\n psButtonDisabled: boolean;\n}\n\nexport default function ProcessingStep({\n isComplete,\n isError,\n isSuccess,\n onAnimationCompleted,\n onClear,\n psButtonText,\n psProcessingText,\n psButtonDisabled,\n}: ProcessingStepProps) {\n let processStatus = Status.PROCESSING;\n if (isError) {\n processStatus = Status.FAILED;\n }\n if (isSuccess) {\n processStatus = Status.SUCCEEDED;\n }\n\n return (\n <div className=\"droppable-processing-card droppable-card\" aria-hidden={isComplete}>\n <div className=\"droppable-card-content\">\n <ProcessIndicator\n status={processStatus}\n onAnimationCompleted={(status) => onAnimationCompleted(status)}\n />\n <Title className=\"m-y-2\" type={Typography.TITLE_BODY} aria-live=\"polite\">\n {psProcessingText}\n </Title>\n {psButtonText && (\n <Button disabled={psButtonDisabled} onClick={onClear}>\n {psButtonText}\n </Button>\n )}\n </div>\n </div>\n );\n}\n"],"names":["ProcessingStep","isComplete","isError","isSuccess","onAnimationCompleted","onClear","psButtonText","psProcessingText","psButtonDisabled","processStatus","Status","PROCESSING","FAILED","SUCCEEDED","_jsx","className","children","_jsxs","ProcessIndicator","status","Title","type","Typography","TITLE_BODY","Button","disabled","onClick"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBwB,SAAAA,cAAcA,CAAC;EACrCC,UAAU;EACVC,OAAO;EACPC,SAAS;EACTC,oBAAoB;EACpBC,OAAO;EACPC,YAAY;EACZC,gBAAgB;AAChBC,EAAAA,gBAAAA;AACoB,CAAA,EAAA;AACpB,EAAA,IAAIC,aAAa,GAAGC,aAAM,CAACC,UAAU,CAAA;AACrC,EAAA,IAAIT,OAAO,EAAE;IACXO,aAAa,GAAGC,aAAM,CAACE,MAAM,CAAA;AAC/B,GAAA;AACA,EAAA,IAAIT,SAAS,EAAE;IACbM,aAAa,GAAGC,aAAM,CAACG,SAAS,CAAA;AAClC,GAAA;AAEA,EAAA,oBACEC,cAAA,CAAA,KAAA,EAAA;AAAKC,IAAAA,SAAS,EAAC,0CAA0C;AAAC,IAAA,aAAA,EAAad,UAAW;AAAAe,IAAAA,QAAA,eAChFC,eAAA,CAAA,KAAA,EAAA;AAAKF,MAAAA,SAAS,EAAC,wBAAwB;MAAAC,QAAA,EAAA,cACrCF,cAAA,CAACI,gBAAgB,EAAA;AACfC,QAAAA,MAAM,EAAEV,aAAc;AACtBL,QAAAA,oBAAoB,EAAGe,MAAM,IAAKf,oBAAoB,CAACe,MAAM,CAAA;AAAE,OAEjE,CAAA,eAAAL,cAAA,CAACM,KAAK,EAAA;AAACL,QAAAA,SAAS,EAAC,OAAO;QAACM,IAAI,EAAEC,qBAAU,CAACC,UAAW;AAAC,QAAA,WAAA,EAAU,QAAQ;AAAAP,QAAAA,QAAA,EACrET,gBAAAA;AAAgB,OACZ,CACP,EAACD,YAAY,iBACXQ,cAAA,CAACU,eAAM,EAAA;AAACC,QAAAA,QAAQ,EAAEjB,gBAAiB;AAACkB,QAAAA,OAAO,EAAErB,OAAQ;AAAAW,QAAAA,QAAA,EAClDV,YAAAA;AAAY,OACP,CACT,CAAA;KACE,CAAA;AACP,GAAK,CAAC,CAAA;AAEV;;;;"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var clsx = require('clsx');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var reactIntl = require('react-intl');
|
|
6
|
-
var
|
|
6
|
+
var Button_resolver = require('../button/Button.resolver.js');
|
|
7
7
|
require('../common/theme.js');
|
|
8
8
|
require('../common/direction.js');
|
|
9
9
|
var control = require('../common/propsValues/control.js');
|
|
@@ -294,13 +294,13 @@ const UploadInput = ({
|
|
|
294
294
|
body: deleteConfirm?.body !== undefined ? deleteConfirm.body : formatMessage(UploadInput_messages.deleteModalBody),
|
|
295
295
|
open: !!markedFileForDelete,
|
|
296
296
|
footer: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
297
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(
|
|
297
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Button_resolver, {
|
|
298
298
|
block: true,
|
|
299
299
|
onClick: () => {
|
|
300
300
|
setMarkedFileForDelete(null);
|
|
301
301
|
},
|
|
302
302
|
children: deleteConfirm?.cancelText || formatMessage(UploadInput_messages.deleteModalCancelButtonText)
|
|
303
|
-
}), /*#__PURE__*/jsxRuntime.jsx(
|
|
303
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Button_resolver, {
|
|
304
304
|
block: true,
|
|
305
305
|
priority: control.Priority.SECONDARY,
|
|
306
306
|
type: control.ControlType.NEGATIVE,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadInput.js","sources":["../../src/uploadInput/UploadInput.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef, useState } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport Button from '../button';\nimport { CommonProps, ControlType, Priority, Status } from '../common';\nimport { useInputAttributes } from '../inputs/contexts';\nimport Modal from '../modal';\nimport { isSizeValid } from '../upload/utils/isSizeValid';\nimport { isTypeValid } from '../upload/utils/isTypeValid';\n\nimport MESSAGES from './UploadInput.messages';\nimport { UploadedFile, UploadError, UploadResponse } from './types';\nimport UploadButton, { UploadButtonProps } from './uploadButton/UploadButton';\nimport { DEFAULT_SIZE_LIMIT, imageFileTypes } from './uploadButton/defaults';\nimport UploadItem, { UploadItemProps } from './uploadItem/UploadItem';\n\nexport type UploadInputProps = {\n /**\n * List of already existing, failed or in progress files\n */\n files?: readonly UploadedFile[];\n\n /**\n * The key of the file in the returned FormData object (default: file)\n */\n fileInputName?: string;\n\n /**\n * Callback that handles form submission\n *\n * @param formData\n */\n onUploadFile: (formData: FormData) => Promise<UploadResponse>;\n\n /**\n * Provide a callback if the file can be removed/deleted from the server\n * Your app is responsible for reloading the uploaded files list and updating the component to ensure that the file has in fact been deleted successfully\n *\n * @param id\n */\n onDeleteFile?: (id: string | number) => Promise<any>;\n\n /**\n * Provide a callback to trigger on validation error\n *\n * @param file\n */\n onValidationError?: (file: UploadedFile) => void;\n\n /**\n * Provide a callback to trigger on change whenever the files are updated\n *\n * @param files\n */\n onFilesChange?: (files: UploadedFile[]) => void;\n\n /**\n * Confirmation modal displayed on delete\n */\n deleteConfirm?: {\n /**\n * The title of the confirmation modal on delete\n */\n title?: string;\n\n /**\n * The body of the confirmation modal on delete\n */\n body?: React.ReactNode;\n\n /**\n * The confirm button text of the confirmation modal on delete\n */\n confirmText?: string;\n\n /**\n * The cancel button text of the confirmation modal on delete\n */\n cancelText?: string;\n };\n\n /**\n * Maximum number of files allowed, if provided, shows error below file item\n */\n maxFiles?: number;\n\n /**\n * Error message to show when the maximum number of files are uploaded already\n */\n maxFilesErrorMessage?: string;\n\n /**\n * Error message to show when files over a allowed size limit are uploaded\n */\n sizeLimitErrorMessage?: string;\n} & Pick<\n UploadButtonProps,\n 'disabled' | 'multiple' | 'fileTypes' | 'sizeLimit' | 'description' | 'id' | 'uploadButtonTitle'\n> & { onDownload?: UploadItemProps['onDownload'] } & CommonProps;\n\n/**\n * Interface representing a reference to an UploadItem component.\n * Provides a method to focus the UploadItem.\n */\ninterface UploadItemRef {\n /**\n * Focuses the UploadItem component.\n */\n focus: () => void;\n\n /**\n * Required id of the UploadItem component.\n */\n id: string | number;\n\n /**\n * Optional status of the UploadItem component.\n */\n status?: string;\n}\n\n/**\n * Generates a unique ID for a file based on its name, size, and the current timestamp\n */\nfunction generateFileId(file: File) {\n const { name, size } = file;\n const uploadTimeStamp = new Date().getTime();\n return `${name}_${size}_${uploadTimeStamp}`;\n}\n\n/**\n * The component allows users to upload files, manage the list of uploaded files,\n * and handle file validation and deletion.\n *\n * @param {UploadInputProps} props - The properties for the UploadInput component.\n *\n * @see {@link UploadInput} for further information.\n * @see {@link https://storybook.wise.design/?path=/docs/forms-uploadinput--docs|Storybook Wise Design}\n */\nconst UploadInput = ({\n files = [],\n fileInputName = 'file',\n className,\n deleteConfirm,\n disabled,\n multiple = false,\n fileTypes = imageFileTypes,\n sizeLimit = DEFAULT_SIZE_LIMIT,\n description,\n onUploadFile,\n onDeleteFile,\n onValidationError,\n onFilesChange,\n onDownload,\n maxFiles,\n maxFilesErrorMessage,\n id,\n sizeLimitErrorMessage,\n uploadButtonTitle,\n}: UploadInputProps) => {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n const [markedFileForDelete, setMarkedFileForDelete] = useState<UploadedFile | null>(null);\n const [mounted, setMounted] = useState(false);\n const { formatMessage } = useIntl();\n const uploadInputRef = useRef<HTMLInputElement | null>(null);\n let fileRefs: (HTMLDivElement | UploadItemRef | null)[] = [];\n\n const PROGRESS_STATUSES = new Set([Status.PENDING, Status.PROCESSING]);\n\n const [uploadedFiles, setUploadedFiles] = useState<readonly UploadedFile[]>(\n multiple || files.length === 0 ? files : [files[0]],\n );\n\n const uploadedFilesListReference = useRef(multiple || files.length === 0 ? files : [files[0]]);\n\n function updateFileList(updateFn: (list: readonly UploadedFile[]) => readonly UploadedFile[]) {\n setUploadedFiles(updateFn);\n uploadedFilesListReference.current = updateFn(uploadedFilesListReference.current);\n }\n\n function addFileToList(recentUploadedFile: UploadedFile) {\n updateFileList((list) => [...list, recentUploadedFile]);\n }\n\n function removeFileFromList(file: UploadedFile) {\n updateFileList((list) =>\n list.filter((fileInList) => file !== fileInList && file.id !== fileInList.id),\n );\n fileRefs = fileRefs.filter((ref) => ref && ref.id !== file.id);\n }\n\n function modifyFileInList(file: UploadedFile, updates: Partial<UploadedFile>) {\n updateFileList((list) =>\n list.map((fileInList) =>\n fileInList === file || fileInList.id === file.id ? { ...file, ...updates } : fileInList,\n ),\n );\n }\n\n const removeFile = async (file: UploadedFile) => {\n const { id, status } = file;\n fileRefs = fileRefs.filter((item) => item && item.id !== file.id);\n\n if (status === Status.FAILED) {\n removeFileFromList(file);\n return Promise.resolve();\n }\n\n if (onDeleteFile && id) {\n modifyFileInList(file, { status: Status.PROCESSING, error: undefined });\n\n return onDeleteFile(id)\n .then(() => {\n removeFileFromList(file);\n })\n .catch((error) => {\n modifyFileInList(file, { error: error as UploadError });\n });\n }\n };\n\n function handleFileUploadFailure(file: File, failureMessage: string) {\n const { name } = file;\n\n const failedUpload = {\n id: generateFileId(file),\n filename: name,\n status: Status.FAILED,\n error: failureMessage,\n };\n\n addFileToList(failedUpload);\n\n if (onValidationError) {\n onValidationError(failedUpload);\n }\n }\n\n function getNumberOfFilesUploaded() {\n const uploadInitiatedStatus = new Set([Status.SUCCEEDED, Status.PENDING]);\n const validFiles = uploadedFilesListReference.current.filter(\n (file) => file.status && uploadInitiatedStatus.has(file.status),\n );\n return validFiles.length;\n }\n\n function areMaximumFilesUploadedAlready() {\n if (!maxFiles) {\n return false;\n }\n\n const numberOfValidFiles = getNumberOfFilesUploaded();\n return numberOfValidFiles >= maxFiles;\n }\n\n const addFiles = (selectedFiles: FileList) => {\n for (let i = 0; i < selectedFiles.length; i += 1) {\n const file = selectedFiles.item(i);\n\n const formData = new FormData();\n\n if (file) {\n const allowedFileTypes = typeof fileTypes === 'string' ? fileTypes : fileTypes.join(',');\n\n if (!isTypeValid(file, allowedFileTypes)) {\n handleFileUploadFailure(file, formatMessage(MESSAGES.fileTypeNotSupported));\n continue;\n }\n\n if (!isSizeValid(file, sizeLimit * 1000)) {\n const failureMessage = sizeLimitErrorMessage || formatMessage(MESSAGES.fileIsTooLarge);\n handleFileUploadFailure(file, failureMessage);\n continue;\n }\n\n if (areMaximumFilesUploadedAlready()) {\n const failureMessage =\n maxFilesErrorMessage ||\n formatMessage(MESSAGES.maximumFilesAlreadyUploaded, { maxFilesAllowed: maxFiles });\n handleFileUploadFailure(file, failureMessage);\n continue;\n }\n\n const existingFile = uploadedFiles.find((f) => f.filename === file.name);\n if (existingFile) {\n removeFileFromList(existingFile);\n }\n\n formData.append(fileInputName, file);\n const pendingFile = {\n id: generateFileId(file),\n filename: file.name,\n status: Status.PENDING,\n };\n\n addFileToList(pendingFile);\n\n onUploadFile(formData)\n .then(({ id, url, error }: UploadResponse) => {\n modifyFileInList(pendingFile, { id, url, error, status: Status.SUCCEEDED });\n })\n .catch((error) => {\n modifyFileInList(pendingFile, { error: error as UploadError, status: Status.FAILED });\n });\n\n if (!multiple) {\n break;\n }\n }\n }\n };\n\n useEffect(() => {\n setMounted(true);\n }, []);\n\n useEffect(() => {\n if (onFilesChange && mounted) {\n onFilesChange([...uploadedFiles]);\n }\n }, [onFilesChange, uploadedFiles]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const [nextFocusable, setNextFocusable] = useState<HTMLDivElement | UploadItemRef | null>(\n uploadInputRef.current,\n );\n\n const handleFocus = (fileId: string | number) => {\n fileRefs = fileRefs.filter((ref) => {\n return ref && ref.id !== markedFileForDelete?.id;\n });\n\n const filesCount = fileRefs.length;\n let next: HTMLDivElement | UploadItemRef | null = uploadInputRef.current;\n\n if (filesCount > 1) {\n const currentFileIndex = fileRefs.findIndex((file) => file?.id === fileId);\n const currentFileId = fileRefs?.[currentFileIndex]?.id;\n const lastFileId = fileRefs?.[filesCount - 1]?.id;\n\n // if last file, select a previous one\n if (currentFileId === lastFileId) {\n next = fileRefs[filesCount - 2];\n } else {\n next = fileRefs[currentFileIndex + 1];\n }\n }\n setNextFocusable(next);\n };\n\n const handleRefocus = () => {\n if (nextFocusable && 'focus' in nextFocusable && typeof nextFocusable.focus === 'function') {\n setTimeout(() => {\n nextFocusable.focus();\n }, 0);\n }\n };\n\n return (\n <>\n <div\n role=\"group\"\n className={clsx('np-upload-input', className, { disabled })}\n {...inputAttributes}\n >\n <div\n className=\"np-upload-input__section\"\n aria-live=\"polite\"\n aria-relevant=\"all\"\n role=\"region\"\n >\n {uploadedFiles.map((file, index) => (\n <UploadItem\n key={file.id}\n ref={(el: UploadItemRef | null) => {\n if (\n el &&\n el.id !== markedFileForDelete?.id &&\n !fileRefs.some((ref) => ref && ref.id === el.id) &&\n el.status !== 'processing'\n ) {\n fileRefs.push(el);\n }\n }}\n file={file}\n singleFileUpload={!multiple}\n canDelete={\n (!!onDeleteFile || file.status === Status.FAILED) &&\n (!file.status || !PROGRESS_STATUSES.has(file.status))\n }\n onDelete={\n file.status === Status.FAILED\n ? async () => {\n await removeFile(file);\n handleRefocus();\n }\n : () => setMarkedFileForDelete(file)\n }\n onDownload={onDownload}\n onFocus={() => handleFocus(file.id)}\n />\n ))}\n </div>\n {(multiple || (!multiple && !uploadedFiles.length)) && (\n <div className=\"np-upload-input__section np-upload-input__section--uploader\">\n <UploadButton\n ref={uploadInputRef}\n id={id}\n uploadButtonTitle={uploadButtonTitle}\n disabled={areMaximumFilesUploadedAlready() || disabled}\n multiple={multiple}\n fileTypes={fileTypes}\n sizeLimit={sizeLimit}\n description={description}\n maxFiles={maxFiles}\n withEntries={Boolean(uploadedFiles.length)}\n onChange={addFiles}\n />\n </div>\n )}\n </div>\n <Modal\n title={\n deleteConfirm?.title !== undefined\n ? deleteConfirm.title\n : formatMessage(MESSAGES.deleteModalTitle)\n }\n body={\n deleteConfirm?.body !== undefined\n ? deleteConfirm.body\n : formatMessage(MESSAGES.deleteModalBody)\n }\n open={!!markedFileForDelete}\n footer={\n <>\n <Button\n block\n onClick={() => {\n setMarkedFileForDelete(null);\n }}\n >\n {deleteConfirm?.cancelText || formatMessage(MESSAGES.deleteModalCancelButtonText)}\n </Button>\n <Button\n block\n priority={Priority.SECONDARY}\n type={ControlType.NEGATIVE}\n tabIndex={markedFileForDelete ? 0 : -1}\n onClick={() => {\n if (markedFileForDelete) {\n void removeFile(markedFileForDelete);\n }\n setMarkedFileForDelete(null);\n }}\n >\n {deleteConfirm?.confirmText || formatMessage(MESSAGES.deleteModalConfirmButtonText)}\n </Button>\n </>\n }\n onUnmount={handleRefocus}\n onClose={() => {\n setMarkedFileForDelete(null);\n }}\n />\n </>\n );\n};\n\nexport default UploadInput;\n"],"names":["generateFileId","file","name","size","uploadTimeStamp","Date","getTime","UploadInput","files","fileInputName","className","deleteConfirm","disabled","multiple","fileTypes","imageFileTypes","sizeLimit","DEFAULT_SIZE_LIMIT","description","onUploadFile","onDeleteFile","onValidationError","onFilesChange","onDownload","maxFiles","maxFilesErrorMessage","id","sizeLimitErrorMessage","uploadButtonTitle","inputAttributes","useInputAttributes","nonLabelable","markedFileForDelete","setMarkedFileForDelete","useState","mounted","setMounted","formatMessage","useIntl","uploadInputRef","useRef","fileRefs","PROGRESS_STATUSES","Set","Status","PENDING","PROCESSING","uploadedFiles","setUploadedFiles","length","uploadedFilesListReference","updateFileList","updateFn","current","addFileToList","recentUploadedFile","list","removeFileFromList","filter","fileInList","ref","modifyFileInList","updates","map","removeFile","status","item","FAILED","Promise","resolve","error","undefined","then","catch","handleFileUploadFailure","failureMessage","failedUpload","filename","getNumberOfFilesUploaded","uploadInitiatedStatus","SUCCEEDED","validFiles","has","areMaximumFilesUploadedAlready","numberOfValidFiles","addFiles","selectedFiles","i","formData","FormData","allowedFileTypes","join","isTypeValid","MESSAGES","fileTypeNotSupported","isSizeValid","fileIsTooLarge","maximumFilesAlreadyUploaded","maxFilesAllowed","existingFile","find","f","append","pendingFile","url","useEffect","nextFocusable","setNextFocusable","handleFocus","fileId","filesCount","next","currentFileIndex","findIndex","currentFileId","lastFileId","handleRefocus","focus","setTimeout","_jsxs","_Fragment","children","role","clsx","_jsx","index","UploadItem","el","some","push","singleFileUpload","canDelete","onDelete","onFocus","UploadButton","withEntries","Boolean","onChange","Modal","title","deleteModalTitle","body","deleteModalBody","open","footer","Button","block","onClick","cancelText","deleteModalCancelButtonText","priority","Priority","SECONDARY","type","ControlType","NEGATIVE","tabIndex","confirmText","deleteModalConfirmButtonText","onUnmount","onClose"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6HA,SAASA,cAAcA,CAACC,IAAU,EAAA;EAChC,MAAM;IAAEC,IAAI;AAAEC,IAAAA,IAAAA;AAAM,GAAA,GAAGF,IAAI,CAAA;EAC3B,MAAMG,eAAe,GAAG,IAAIC,IAAI,EAAE,CAACC,OAAO,EAAE,CAAA;AAC5C,EAAA,OAAO,GAAGJ,IAAI,CAAA,CAAA,EAAIC,IAAI,CAAA,CAAA,EAAIC,eAAe,CAAE,CAAA,CAAA;AAC7C,CAAA;AAEA;;;;;;;;AAQG;AACGG,MAAAA,WAAW,GAAGA,CAAC;AACnBC,EAAAA,KAAK,GAAG,EAAE;AACVC,EAAAA,aAAa,GAAG,MAAM;EACtBC,SAAS;EACTC,aAAa;EACbC,QAAQ;AACRC,EAAAA,QAAQ,GAAG,KAAK;AAChBC,EAAAA,SAAS,GAAGC,uBAAc;AAC1BC,EAAAA,SAAS,GAAGC,2BAAkB;EAC9BC,WAAW;EACXC,YAAY;EACZC,YAAY;EACZC,iBAAiB;EACjBC,aAAa;EACbC,UAAU;EACVC,QAAQ;EACRC,oBAAoB;EACpBC,EAAE;EACFC,qBAAqB;AACrBC,EAAAA,iBAAAA;AACiB,CAAA,KAAI;EACrB,MAAMC,eAAe,GAAGC,2BAAkB,CAAC;AAAEC,IAAAA,YAAY,EAAE,IAAA;AAAM,GAAA,CAAC,CAAA;EAClE,MAAM,CAACC,mBAAmB,EAAEC,sBAAsB,CAAC,GAAGC,cAAQ,CAAsB,IAAI,CAAC,CAAA;EACzF,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGF,cAAQ,CAAC,KAAK,CAAC,CAAA;EAC7C,MAAM;AAAEG,IAAAA,aAAAA;GAAe,GAAGC,iBAAO,EAAE,CAAA;AACnC,EAAA,MAA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}
|
|
1
|
+
{"version":3,"file":"UploadInput.js","sources":["../../src/uploadInput/UploadInput.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef, useState } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport Button from '../button';\nimport { CommonProps, ControlType, Priority, Status } from '../common';\nimport { useInputAttributes } from '../inputs/contexts';\nimport Modal from '../modal';\nimport { isSizeValid } from '../upload/utils/isSizeValid';\nimport { isTypeValid } from '../upload/utils/isTypeValid';\n\nimport MESSAGES from './UploadInput.messages';\nimport { UploadedFile, UploadError, UploadResponse } from './types';\nimport UploadButton, { UploadButtonProps } from './uploadButton/UploadButton';\nimport { DEFAULT_SIZE_LIMIT, imageFileTypes } from './uploadButton/defaults';\nimport UploadItem, { UploadItemProps } from './uploadItem/UploadItem';\n\nexport type UploadInputProps = {\n /**\n * List of already existing, failed or in progress files\n */\n files?: readonly UploadedFile[];\n\n /**\n * The key of the file in the returned FormData object (default: file)\n */\n fileInputName?: string;\n\n /**\n * Callback that handles form submission\n *\n * @param formData\n */\n onUploadFile: (formData: FormData) => Promise<UploadResponse>;\n\n /**\n * Provide a callback if the file can be removed/deleted from the server\n * Your app is responsible for reloading the uploaded files list and updating the component to ensure that the file has in fact been deleted successfully\n *\n * @param id\n */\n onDeleteFile?: (id: string | number) => Promise<any>;\n\n /**\n * Provide a callback to trigger on validation error\n *\n * @param file\n */\n onValidationError?: (file: UploadedFile) => void;\n\n /**\n * Provide a callback to trigger on change whenever the files are updated\n *\n * @param files\n */\n onFilesChange?: (files: UploadedFile[]) => void;\n\n /**\n * Confirmation modal displayed on delete\n */\n deleteConfirm?: {\n /**\n * The title of the confirmation modal on delete\n */\n title?: string;\n\n /**\n * The body of the confirmation modal on delete\n */\n body?: React.ReactNode;\n\n /**\n * The confirm button text of the confirmation modal on delete\n */\n confirmText?: string;\n\n /**\n * The cancel button text of the confirmation modal on delete\n */\n cancelText?: string;\n };\n\n /**\n * Maximum number of files allowed, if provided, shows error below file item\n */\n maxFiles?: number;\n\n /**\n * Error message to show when the maximum number of files are uploaded already\n */\n maxFilesErrorMessage?: string;\n\n /**\n * Error message to show when files over a allowed size limit are uploaded\n */\n sizeLimitErrorMessage?: string;\n} & Pick<\n UploadButtonProps,\n 'disabled' | 'multiple' | 'fileTypes' | 'sizeLimit' | 'description' | 'id' | 'uploadButtonTitle'\n> & { onDownload?: UploadItemProps['onDownload'] } & CommonProps;\n\n/**\n * Interface representing a reference to an UploadItem component.\n * Provides a method to focus the UploadItem.\n */\ninterface UploadItemRef {\n /**\n * Focuses the UploadItem component.\n */\n focus: () => void;\n\n /**\n * Required id of the UploadItem component.\n */\n id: string | number;\n\n /**\n * Optional status of the UploadItem component.\n */\n status?: string;\n}\n\n/**\n * Generates a unique ID for a file based on its name, size, and the current timestamp\n */\nfunction generateFileId(file: File) {\n const { name, size } = file;\n const uploadTimeStamp = new Date().getTime();\n return `${name}_${size}_${uploadTimeStamp}`;\n}\n\n/**\n * The component allows users to upload files, manage the list of uploaded files,\n * and handle file validation and deletion.\n *\n * @param {UploadInputProps} props - The properties for the UploadInput component.\n *\n * @see {@link UploadInput} for further information.\n * @see {@link https://storybook.wise.design/?path=/docs/forms-uploadinput--docs|Storybook Wise Design}\n */\nconst UploadInput = ({\n files = [],\n fileInputName = 'file',\n className,\n deleteConfirm,\n disabled,\n multiple = false,\n fileTypes = imageFileTypes,\n sizeLimit = DEFAULT_SIZE_LIMIT,\n description,\n onUploadFile,\n onDeleteFile,\n onValidationError,\n onFilesChange,\n onDownload,\n maxFiles,\n maxFilesErrorMessage,\n id,\n sizeLimitErrorMessage,\n uploadButtonTitle,\n}: UploadInputProps) => {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n const [markedFileForDelete, setMarkedFileForDelete] = useState<UploadedFile | null>(null);\n const [mounted, setMounted] = useState(false);\n const { formatMessage } = useIntl();\n const uploadInputRef = useRef<HTMLInputElement | null>(null);\n let fileRefs: (HTMLDivElement | UploadItemRef | null)[] = [];\n\n const PROGRESS_STATUSES = new Set([Status.PENDING, Status.PROCESSING]);\n\n const [uploadedFiles, setUploadedFiles] = useState<readonly UploadedFile[]>(\n multiple || files.length === 0 ? files : [files[0]],\n );\n\n const uploadedFilesListReference = useRef(multiple || files.length === 0 ? files : [files[0]]);\n\n function updateFileList(updateFn: (list: readonly UploadedFile[]) => readonly UploadedFile[]) {\n setUploadedFiles(updateFn);\n uploadedFilesListReference.current = updateFn(uploadedFilesListReference.current);\n }\n\n function addFileToList(recentUploadedFile: UploadedFile) {\n updateFileList((list) => [...list, recentUploadedFile]);\n }\n\n function removeFileFromList(file: UploadedFile) {\n updateFileList((list) =>\n list.filter((fileInList) => file !== fileInList && file.id !== fileInList.id),\n );\n fileRefs = fileRefs.filter((ref) => ref && ref.id !== file.id);\n }\n\n function modifyFileInList(file: UploadedFile, updates: Partial<UploadedFile>) {\n updateFileList((list) =>\n list.map((fileInList) =>\n fileInList === file || fileInList.id === file.id ? { ...file, ...updates } : fileInList,\n ),\n );\n }\n\n const removeFile = async (file: UploadedFile) => {\n const { id, status } = file;\n fileRefs = fileRefs.filter((item) => item && item.id !== file.id);\n\n if (status === Status.FAILED) {\n removeFileFromList(file);\n return Promise.resolve();\n }\n\n if (onDeleteFile && id) {\n modifyFileInList(file, { status: Status.PROCESSING, error: undefined });\n\n return onDeleteFile(id)\n .then(() => {\n removeFileFromList(file);\n })\n .catch((error) => {\n modifyFileInList(file, { error: error as UploadError });\n });\n }\n };\n\n function handleFileUploadFailure(file: File, failureMessage: string) {\n const { name } = file;\n\n const failedUpload = {\n id: generateFileId(file),\n filename: name,\n status: Status.FAILED,\n error: failureMessage,\n };\n\n addFileToList(failedUpload);\n\n if (onValidationError) {\n onValidationError(failedUpload);\n }\n }\n\n function getNumberOfFilesUploaded() {\n const uploadInitiatedStatus = new Set([Status.SUCCEEDED, Status.PENDING]);\n const validFiles = uploadedFilesListReference.current.filter(\n (file) => file.status && uploadInitiatedStatus.has(file.status),\n );\n return validFiles.length;\n }\n\n function areMaximumFilesUploadedAlready() {\n if (!maxFiles) {\n return false;\n }\n\n const numberOfValidFiles = getNumberOfFilesUploaded();\n return numberOfValidFiles >= maxFiles;\n }\n\n const addFiles = (selectedFiles: FileList) => {\n for (let i = 0; i < selectedFiles.length; i += 1) {\n const file = selectedFiles.item(i);\n\n const formData = new FormData();\n\n if (file) {\n const allowedFileTypes = typeof fileTypes === 'string' ? fileTypes : fileTypes.join(',');\n\n if (!isTypeValid(file, allowedFileTypes)) {\n handleFileUploadFailure(file, formatMessage(MESSAGES.fileTypeNotSupported));\n continue;\n }\n\n if (!isSizeValid(file, sizeLimit * 1000)) {\n const failureMessage = sizeLimitErrorMessage || formatMessage(MESSAGES.fileIsTooLarge);\n handleFileUploadFailure(file, failureMessage);\n continue;\n }\n\n if (areMaximumFilesUploadedAlready()) {\n const failureMessage =\n maxFilesErrorMessage ||\n formatMessage(MESSAGES.maximumFilesAlreadyUploaded, { maxFilesAllowed: maxFiles });\n handleFileUploadFailure(file, failureMessage);\n continue;\n }\n\n const existingFile = uploadedFiles.find((f) => f.filename === file.name);\n if (existingFile) {\n removeFileFromList(existingFile);\n }\n\n formData.append(fileInputName, file);\n const pendingFile = {\n id: generateFileId(file),\n filename: file.name,\n status: Status.PENDING,\n };\n\n addFileToList(pendingFile);\n\n onUploadFile(formData)\n .then(({ id, url, error }: UploadResponse) => {\n modifyFileInList(pendingFile, { id, url, error, status: Status.SUCCEEDED });\n })\n .catch((error) => {\n modifyFileInList(pendingFile, { error: error as UploadError, status: Status.FAILED });\n });\n\n if (!multiple) {\n break;\n }\n }\n }\n };\n\n useEffect(() => {\n setMounted(true);\n }, []);\n\n useEffect(() => {\n if (onFilesChange && mounted) {\n onFilesChange([...uploadedFiles]);\n }\n }, [onFilesChange, uploadedFiles]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const [nextFocusable, setNextFocusable] = useState<HTMLDivElement | UploadItemRef | null>(\n uploadInputRef.current,\n );\n\n const handleFocus = (fileId: string | number) => {\n fileRefs = fileRefs.filter((ref) => {\n return ref && ref.id !== markedFileForDelete?.id;\n });\n\n const filesCount = fileRefs.length;\n let next: HTMLDivElement | UploadItemRef | null = uploadInputRef.current;\n\n if (filesCount > 1) {\n const currentFileIndex = fileRefs.findIndex((file) => file?.id === fileId);\n const currentFileId = fileRefs?.[currentFileIndex]?.id;\n const lastFileId = fileRefs?.[filesCount - 1]?.id;\n\n // if last file, select a previous one\n if (currentFileId === lastFileId) {\n next = fileRefs[filesCount - 2];\n } else {\n next = fileRefs[currentFileIndex + 1];\n }\n }\n setNextFocusable(next);\n };\n\n const handleRefocus = () => {\n if (nextFocusable && 'focus' in nextFocusable && typeof nextFocusable.focus === 'function') {\n setTimeout(() => {\n nextFocusable.focus();\n }, 0);\n }\n };\n\n return (\n <>\n <div\n role=\"group\"\n className={clsx('np-upload-input', className, { disabled })}\n {...inputAttributes}\n >\n <div\n className=\"np-upload-input__section\"\n aria-live=\"polite\"\n aria-relevant=\"all\"\n role=\"region\"\n >\n {uploadedFiles.map((file, index) => (\n <UploadItem\n key={file.id}\n ref={(el: UploadItemRef | null) => {\n if (\n el &&\n el.id !== markedFileForDelete?.id &&\n !fileRefs.some((ref) => ref && ref.id === el.id) &&\n el.status !== 'processing'\n ) {\n fileRefs.push(el);\n }\n }}\n file={file}\n singleFileUpload={!multiple}\n canDelete={\n (!!onDeleteFile || file.status === Status.FAILED) &&\n (!file.status || !PROGRESS_STATUSES.has(file.status))\n }\n onDelete={\n file.status === Status.FAILED\n ? async () => {\n await removeFile(file);\n handleRefocus();\n }\n : () => setMarkedFileForDelete(file)\n }\n onDownload={onDownload}\n onFocus={() => handleFocus(file.id)}\n />\n ))}\n </div>\n {(multiple || (!multiple && !uploadedFiles.length)) && (\n <div className=\"np-upload-input__section np-upload-input__section--uploader\">\n <UploadButton\n ref={uploadInputRef}\n id={id}\n uploadButtonTitle={uploadButtonTitle}\n disabled={areMaximumFilesUploadedAlready() || disabled}\n multiple={multiple}\n fileTypes={fileTypes}\n sizeLimit={sizeLimit}\n description={description}\n maxFiles={maxFiles}\n withEntries={Boolean(uploadedFiles.length)}\n onChange={addFiles}\n />\n </div>\n )}\n </div>\n <Modal\n title={\n deleteConfirm?.title !== undefined\n ? deleteConfirm.title\n : formatMessage(MESSAGES.deleteModalTitle)\n }\n body={\n deleteConfirm?.body !== undefined\n ? deleteConfirm.body\n : formatMessage(MESSAGES.deleteModalBody)\n }\n open={!!markedFileForDelete}\n footer={\n <>\n <Button\n block\n onClick={() => {\n setMarkedFileForDelete(null);\n }}\n >\n {deleteConfirm?.cancelText || formatMessage(MESSAGES.deleteModalCancelButtonText)}\n </Button>\n <Button\n block\n priority={Priority.SECONDARY}\n type={ControlType.NEGATIVE}\n tabIndex={markedFileForDelete ? 0 : -1}\n onClick={() => {\n if (markedFileForDelete) {\n void removeFile(markedFileForDelete);\n }\n setMarkedFileForDelete(null);\n }}\n >\n {deleteConfirm?.confirmText || formatMessage(MESSAGES.deleteModalConfirmButtonText)}\n </Button>\n </>\n }\n onUnmount={handleRefocus}\n onClose={() => {\n setMarkedFileForDelete(null);\n }}\n />\n </>\n );\n};\n\nexport default UploadInput;\n"],"names":["generateFileId","file","name","size","uploadTimeStamp","Date","getTime","UploadInput","files","fileInputName","className","deleteConfirm","disabled","multiple","fileTypes","imageFileTypes","sizeLimit","DEFAULT_SIZE_LIMIT","description","onUploadFile","onDeleteFile","onValidationError","onFilesChange","onDownload","maxFiles","maxFilesErrorMessage","id","sizeLimitErrorMessage","uploadButtonTitle","inputAttributes","useInputAttributes","nonLabelable","markedFileForDelete","setMarkedFileForDelete","useState","mounted","setMounted","formatMessage","useIntl","uploadInputRef","useRef","fileRefs","PROGRESS_STATUSES","Set","Status","PENDING","PROCESSING","uploadedFiles","setUploadedFiles","length","uploadedFilesListReference","updateFileList","updateFn","current","addFileToList","recentUploadedFile","list","removeFileFromList","filter","fileInList","ref","modifyFileInList","updates","map","removeFile","status","item","FAILED","Promise","resolve","error","undefined","then","catch","handleFileUploadFailure","failureMessage","failedUpload","filename","getNumberOfFilesUploaded","uploadInitiatedStatus","SUCCEEDED","validFiles","has","areMaximumFilesUploadedAlready","numberOfValidFiles","addFiles","selectedFiles","i","formData","FormData","allowedFileTypes","join","isTypeValid","MESSAGES","fileTypeNotSupported","isSizeValid","fileIsTooLarge","maximumFilesAlreadyUploaded","maxFilesAllowed","existingFile","find","f","append","pendingFile","url","useEffect","nextFocusable","setNextFocusable","handleFocus","fileId","filesCount","next","currentFileIndex","findIndex","currentFileId","lastFileId","handleRefocus","focus","setTimeout","_jsxs","_Fragment","children","role","clsx","_jsx","index","UploadItem","el","some","push","singleFileUpload","canDelete","onDelete","onFocus","UploadButton","withEntries","Boolean","onChange","Modal","title","deleteModalTitle","body","deleteModalBody","open","footer","Button","block","onClick","cancelText","deleteModalCancelButtonText","priority","Priority","SECONDARY","type","ControlType","NEGATIVE","tabIndex","confirmText","deleteModalConfirmButtonText","onUnmount","onClose"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6HA,SAASA,cAAcA,CAACC,IAAU,EAAA;EAChC,MAAM;IAAEC,IAAI;AAAEC,IAAAA,IAAAA;AAAM,GAAA,GAAGF,IAAI,CAAA;EAC3B,MAAMG,eAAe,GAAG,IAAIC,IAAI,EAAE,CAACC,OAAO,EAAE,CAAA;AAC5C,EAAA,OAAO,GAAGJ,IAAI,CAAA,CAAA,EAAIC,IAAI,CAAA,CAAA,EAAIC,eAAe,CAAE,CAAA,CAAA;AAC7C,CAAA;AAEA;;;;;;;;AAQG;AACGG,MAAAA,WAAW,GAAGA,CAAC;AACnBC,EAAAA,KAAK,GAAG,EAAE;AACVC,EAAAA,aAAa,GAAG,MAAM;EACtBC,SAAS;EACTC,aAAa;EACbC,QAAQ;AACRC,EAAAA,QAAQ,GAAG,KAAK;AAChBC,EAAAA,SAAS,GAAGC,uBAAc;AAC1BC,EAAAA,SAAS,GAAGC,2BAAkB;EAC9BC,WAAW;EACXC,YAAY;EACZC,YAAY;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C,CAAE;UACvCmH,OAAO,EAAEA,MAAK;AACZ,YAAA,IAAInH,mBAAmB,EAAE;cACvB,KAAKgC,UAAU,CAAChC,mBAAmB,CAAC,CAAA;AACtC,aAAA;YACAC,sBAAsB,CAAC,IAAI,CAAC,CAAA;WAC5B;UAAAwF,QAAA,EAED9G,aAAa,EAAEkJ,WAAW,IAAIxH,aAAa,CAACwD,oBAAQ,CAACiE,4BAA4B,CAAA;AAAC,SAC7E,CACV,CAAA;AAAA,OAAA,CACD;AACDC,MAAAA,SAAS,EAAE3C,aAAc;MACzB4C,OAAO,EAAEA,MAAK;QACZ/H,sBAAsB,CAAC,IAAI,CAAC,CAAA;AAC9B,OAAA;AAAE,KAEN,CAAA,CAAA;AAAA,GAAA,CAAG,CAAA;AAEP;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
import { useState, useRef, useEffect } from 'react';
|
|
3
3
|
import { useIntl } from 'react-intl';
|
|
4
|
-
import Button from '../button/Button.mjs';
|
|
4
|
+
import Button from '../button/Button.resolver.mjs';
|
|
5
5
|
import '../common/theme.mjs';
|
|
6
6
|
import '../common/direction.mjs';
|
|
7
7
|
import { Priority, ControlType } from '../common/propsValues/control.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "46.
|
|
3
|
+
"version": "46.88.1",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -91,9 +91,9 @@
|
|
|
91
91
|
"rollup": "^4.18.1",
|
|
92
92
|
"rollup-preserve-directives": "^1.1.1",
|
|
93
93
|
"storybook": "^8.2.2",
|
|
94
|
-
"@transferwise/
|
|
94
|
+
"@transferwise/neptune-css": "14.21.0",
|
|
95
95
|
"@wise/components-theming": "1.6.1",
|
|
96
|
-
"@transferwise/
|
|
96
|
+
"@transferwise/less-config": "3.1.0"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"@transferwise/icons": "^3.13.1",
|
|
@@ -11,10 +11,18 @@
|
|
|
11
11
|
-webkit-mask-image: radial-gradient(circle at bottom calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)) right calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)), transparent 0, transparent calc(var(--np-avatar-size) / 2 + 2px), black 0);
|
|
12
12
|
mask-image: radial-gradient(circle at bottom calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)) right calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)), transparent 0, transparent calc(var(--np-avatar-size) / 2 + 2px), black 0);
|
|
13
13
|
}
|
|
14
|
+
[dir="rtl"] .np-avatar-layout-diagonal-mask {
|
|
15
|
+
-webkit-mask-image: radial-gradient(circle at bottom calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)) left calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)), transparent 0, transparent calc(var(--np-avatar-size) / 2 + 2px), black 0);
|
|
16
|
+
mask-image: radial-gradient(circle at bottom calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)) left calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)), transparent 0, transparent calc(var(--np-avatar-size) / 2 + 2px), black 0);
|
|
17
|
+
}
|
|
14
18
|
.np-avatar-layout-diagonal-child {
|
|
15
19
|
margin-left: calc(var(--np-avatar-layout-size) - var(--np-avatar-size) * 2);
|
|
16
20
|
margin-top: calc(var(--np-avatar-layout-size) - var(--np-avatar-size));
|
|
17
21
|
}
|
|
22
|
+
[dir="rtl"] .np-avatar-layout-diagonal-child {
|
|
23
|
+
margin-left: 0;
|
|
24
|
+
margin-right: calc(var(--np-avatar-layout-size) - var(--np-avatar-size) * 2);
|
|
25
|
+
}
|
|
18
26
|
.np-avatar-layout-horizontal {
|
|
19
27
|
width: calc(var(--np-avatar-size) * var(--np-avatar-avatars-count) - (var(--np-avatar-offset) * (var(--np-avatar-avatars-count) - 1)));
|
|
20
28
|
width: calc(var(--np-avatar-size) * var(--np-avatar-avatars-count) - calc(var(--np-avatar-offset) * calc(var(--np-avatar-avatars-count) - 1)));
|
|
@@ -29,3 +37,6 @@
|
|
|
29
37
|
.np-avatar-layout-horizontal-child {
|
|
30
38
|
margin-left: calc(var(--np-avatar-offset) * -1);
|
|
31
39
|
}
|
|
40
|
+
[dir="rtl"] .np-avatar-layout-horizontal-child {
|
|
41
|
+
margin-right: calc(var(--np-avatar-offset) * -1);
|
|
42
|
+
}
|
|
@@ -13,11 +13,24 @@
|
|
|
13
13
|
transparent 0,
|
|
14
14
|
transparent calc(var(--np-avatar-size) / 2 + 2px),
|
|
15
15
|
black 0);
|
|
16
|
+
|
|
17
|
+
:dir(rtl) & {
|
|
18
|
+
mask-image:
|
|
19
|
+
radial-gradient(circle at bottom calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)) left calc(100% - var(--np-avatar-size) - var(--np-avatar-offset)),
|
|
20
|
+
transparent 0,
|
|
21
|
+
transparent calc(var(--np-avatar-size) / 2 + 2px),
|
|
22
|
+
black 0);
|
|
23
|
+
}
|
|
16
24
|
}
|
|
17
25
|
|
|
18
26
|
&-child {
|
|
19
27
|
margin-left: calc(var(--np-avatar-layout-size) - var(--np-avatar-size) * 2);
|
|
20
28
|
margin-top: calc(var(--np-avatar-layout-size) - var(--np-avatar-size));
|
|
29
|
+
|
|
30
|
+
:dir(rtl) & {
|
|
31
|
+
margin-left: 0;
|
|
32
|
+
margin-right: calc(var(--np-avatar-layout-size) - var(--np-avatar-size) * 2);
|
|
33
|
+
}
|
|
21
34
|
}
|
|
22
35
|
}
|
|
23
36
|
|
|
@@ -34,6 +47,10 @@
|
|
|
34
47
|
|
|
35
48
|
&-child {
|
|
36
49
|
margin-left: calc(var(--np-avatar-offset) * -1);
|
|
50
|
+
|
|
51
|
+
:dir(rtl) & {
|
|
52
|
+
margin-right: calc(var(--np-avatar-offset) * -1);
|
|
53
|
+
}
|
|
37
54
|
}
|
|
38
55
|
}
|
|
39
|
-
}
|
|
56
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
import AvatarView, { AvatarViewProps } from '../avatarView';
|
|
3
|
+
import { useDirection } from '../common/hooks';
|
|
3
4
|
|
|
4
5
|
type SingleAvatarType = { asset?: AvatarViewProps['children'] } & Omit<
|
|
5
6
|
AvatarViewProps,
|
|
@@ -24,6 +25,7 @@ export default function AvatarLayout({
|
|
|
24
25
|
}: Props) {
|
|
25
26
|
const orientation =
|
|
26
27
|
size === 16 && orientationProp === 'diagonal' ? 'horizontal' : orientationProp;
|
|
28
|
+
const { isRTL } = useDirection();
|
|
27
29
|
const isDiagonal = orientation === 'diagonal';
|
|
28
30
|
const avatarSize = isDiagonal ? DIAGONAL_LAYOUT_STYLE_CONFIG[size]?.avatarSize : size;
|
|
29
31
|
return avatars.length < 1 ? null : avatars.length === 1 ? (
|
|
@@ -47,8 +49,14 @@ export default function AvatarLayout({
|
|
|
47
49
|
// eslint-disable-next-line react/no-array-index-key
|
|
48
50
|
key={index}
|
|
49
51
|
className={clsx(
|
|
50
|
-
{
|
|
51
|
-
|
|
52
|
+
{
|
|
53
|
+
[`np-avatar-layout-${orientation}-child`]:
|
|
54
|
+
!isDiagonal && isRTL ? index !== avatars.length - 1 : index !== 0,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
[`np-avatar-layout-${orientation}-mask`]:
|
|
58
|
+
!isDiagonal && isRTL ? index !== 0 : index !== avatars.length - 1,
|
|
59
|
+
},
|
|
52
60
|
)}
|
|
53
61
|
>
|
|
54
62
|
<AvatarView
|
|
@@ -10,7 +10,7 @@ import AvatarWrapper from './AvatarWrapper';
|
|
|
10
10
|
export default {
|
|
11
11
|
tags: ['autodocs'],
|
|
12
12
|
component: AvatarWrapper,
|
|
13
|
-
title: 'Content/AvatarWrapper',
|
|
13
|
+
title: 'Content/AvatarWrapper (Deprecated)',
|
|
14
14
|
} satisfies Meta<typeof AvatarWrapper>;
|
|
15
15
|
|
|
16
16
|
type Story = StoryObj<typeof AvatarWrapper>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Meta, Canvas, Source } from '@storybook/blocks';
|
|
2
|
+
import { NavigationOption } from '..';
|
|
3
|
+
import { Bulb } from '@transferwise/icons';
|
|
4
|
+
import * as stories from './Button.story';
|
|
5
|
+
|
|
6
|
+
<Meta title="Actions/Button/Accessibility" />
|
|
7
|
+
|
|
8
|
+
# Accessibility
|
|
9
|
+
|
|
10
|
+
Given the `Button` is a widely used and highly sensitive component, there are some instances where care is required to ensure inclusive and accessible experience.
|
|
11
|
+
|
|
12
|
+
<NavigationOption
|
|
13
|
+
media={<Bulb size={24} />}
|
|
14
|
+
title="Design guidance"
|
|
15
|
+
content="Before you start, familiarise yourself with the dedicated accessibility documentation."
|
|
16
|
+
href="https://wise.design/components/button#accessibility"
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
<br />
|
|
20
|
+
<br />
|
|
21
|
+
|
|
22
|
+
## Anchors
|
|
23
|
+
|
|
24
|
+
While it's technically possible to make the `Button` component render as a link by using `as="a"` on its own, and there are use cases for it, this will not result in a semantic HTML anchor. For that to happen, you should set `href` instead – it will automatically render the component as a semantic anchor.
|
|
25
|
+
|
|
26
|
+
<Source dark code={`
|
|
27
|
+
// ⚠️ use with care
|
|
28
|
+
<Button v2 as="a">Inaccessible anchor</Button>
|
|
29
|
+
|
|
30
|
+
// ✅ semantic link
|
|
31
|
+
|
|
32
|
+
<Button v2 href="https://wise.com">
|
|
33
|
+
Accessible anchor
|
|
34
|
+
</Button>
|
|
35
|
+
<Button v2 href="https://wise.com" as="a">
|
|
36
|
+
Accessible anchor
|
|
37
|
+
</Button>
|
|
38
|
+
`}/>
|
|
39
|
+
|
|
40
|
+
It's also worth noting that HTML links without a valid `href` are not recognised by RTL via `getByRole('link')`.
|
|
41
|
+
|
|
42
|
+
**Additional resources:**
|
|
43
|
+
|
|
44
|
+
1. [Deque: Anchors must only be used as links with valid URLs or URL fragments](https://dequeuniversity.com/rules/axe-devtools/4.2/href-no-hash)
|
|
45
|
+
2. [whatwg HTML standard: 4.6.2 Links created by a and area elements](https://html.spec.whatwg.org/multipage/links.html#links-created-by-a-and-area-elements)
|
|
46
|
+
|
|
47
|
+
<br />
|
|
48
|
+
|
|
49
|
+
## Disabled anchors
|
|
50
|
+
|
|
51
|
+
Technically, there's no such thing as disabled HTML anchor and the `disabled` attribute is not recognised on the `<a />`. While the code shown below works in all major screen readers, should be overall considered a last resort and design teams should be encouraged to use it sporadically and consider alternative flows instead.
|
|
52
|
+
|
|
53
|
+
<Source
|
|
54
|
+
dark
|
|
55
|
+
code={`
|
|
56
|
+
// ⚠️ use with care
|
|
57
|
+
<Button v2 href="https://wise.com" disabled>Emulated disabled anchor</Button>
|
|
58
|
+
`}
|
|
59
|
+
/>
|
|
60
|
+
|
|
61
|
+
We're emulating this behaviour by applying a combination of the following:
|
|
62
|
+
|
|
63
|
+
1. removing `href` attribute to strip out the link's semantics.
|
|
64
|
+
2. adding `role="link"` to make it recognisable and discoverable by the assistive tech.
|
|
65
|
+
3. setting `aria-disabled="true"` to inform assistive tech of the component state.
|
|
66
|
+
|
|
67
|
+
**Additional resources:**
|
|
68
|
+
|
|
69
|
+
1. [Scott O'Hara: Disabling a link](https://www.scottohara.me/blog/2021/05/28/disabled-links.html)
|
|
70
|
+
2. [CSS-Tricks: How to Disable Links](https://css-tricks.com/how-to-disable-links/)
|
|
71
|
+
|
|
72
|
+
<br />
|
|
73
|
+
|
|
74
|
+
## Loading state
|
|
75
|
+
|
|
76
|
+
While it might be tempting to use the native, HTML `disabled` attribute for the `loading` state, it would result in a component that is completely invisible to the assistive tech – not focusable and not parsable – entirely inaccessible experience for users relying on such tools.
|
|
77
|
+
|
|
78
|
+
Instead, we're relying on ARIA attributes and roles to ensure the `Button` is focusable, correctly announced as "busy" and offering visual cue different to the disabled state.
|
|
79
|
+
|
|
80
|
+
<Source dark code={`
|
|
81
|
+
// ❌ do not use
|
|
82
|
+
<Button v2 loading disabled>Invisible</Button>
|
|
83
|
+
|
|
84
|
+
// ✅ semantic loading button
|
|
85
|
+
|
|
86
|
+
<Button v2 loading>
|
|
87
|
+
Proper loading state
|
|
88
|
+
</Button>
|
|
89
|
+
`}/>
|
|
90
|
+
|
|
91
|
+
`Button` instances rendered as HTML anchors, follow the strategy described in the [Disabled anchors](#disabled-anchors) section above.
|
|
92
|
+
|
|
93
|
+
<br />
|
|
94
|
+
|
|
95
|
+
## Working with addons (accessories)
|
|
96
|
+
|
|
97
|
+
One of the core requirements of accessible experience is that all users have equal access to the same content, no matter how they interact with our products.
|
|
98
|
+
|
|
99
|
+
This becomes troublesome for more complex instances of the `Button` such as those with contentful icons or avatars, e.g. those referring to particular currencies, people or action types.
|
|
100
|
+
|
|
101
|
+
Exposing separate ARIA labels for such addons would likely become problematic due to syntactic differences between different languages and so instead we recommend using simple `aria-label` attribute to describe given components complete content. Please note, that screen readers will use that text over the visible label
|
|
102
|
+
|
|
103
|
+
<Canvas of={stories.AccessibilityAddons} />
|