@popsure/dirty-swan 0.57.9 → 0.58.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/cjs/index.js +65 -29
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/lib/components/multiDropzone/utils/index.d.ts +9 -2
  4. package/dist/esm/{TableSection-a26ba0c5.js → TableSection-ebace923.js} +1 -1
  5. package/dist/esm/{TableSection-a26ba0c5.js.map → TableSection-ebace923.js.map} +1 -1
  6. package/dist/esm/components/comparisonTable/components/TableInfoButton/index.js +1 -1
  7. package/dist/esm/components/comparisonTable/components/TableInfoButton/index.js.map +1 -1
  8. package/dist/esm/components/input/checkbox/index.js +5 -2
  9. package/dist/esm/components/input/checkbox/index.js.map +1 -1
  10. package/dist/esm/components/input/index.js +4 -2
  11. package/dist/esm/components/input/index.js.map +1 -1
  12. package/dist/esm/components/multiDropzone/UploadFileCell/index.js +6 -7
  13. package/dist/esm/components/multiDropzone/UploadFileCell/index.js.map +1 -1
  14. package/dist/esm/components/multiDropzone/index.js +51 -17
  15. package/dist/esm/components/multiDropzone/index.js.map +1 -1
  16. package/dist/esm/components/multiDropzone/index.stories.js +1 -0
  17. package/dist/esm/components/multiDropzone/index.stories.js.map +1 -1
  18. package/dist/esm/components/multiDropzone/index.test.js +1 -0
  19. package/dist/esm/components/multiDropzone/index.test.js.map +1 -1
  20. package/dist/esm/components/table/Table.js +1 -1
  21. package/dist/esm/components/table/Table.stories.js +1 -1
  22. package/dist/esm/components/table/Table.test.js +1 -1
  23. package/dist/esm/components/table/components/TableContents/TableContents.js +1 -1
  24. package/dist/esm/components/table/components/TableContents/TableContents.test.js +1 -1
  25. package/dist/esm/components/table/components/TableSection/TableSection.js +1 -1
  26. package/dist/esm/components/table/components/TableSection/TableSection.test.js +1 -1
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/lib/components/multiDropzone/utils/index.d.ts +9 -2
  29. package/package.json +1 -1
  30. package/src/lib/components/comparisonTable/components/TableInfoButton/index.tsx +2 -0
  31. package/src/lib/components/input/checkbox/index.tsx +8 -2
  32. package/src/lib/components/input/index.tsx +20 -13
  33. package/src/lib/components/multiDropzone/UploadFileCell/index.tsx +25 -19
  34. package/src/lib/components/multiDropzone/UploadFileCell/style.module.scss +11 -29
  35. package/src/lib/components/multiDropzone/index.tsx +17 -5
  36. package/src/lib/components/multiDropzone/style.module.scss +12 -9
  37. package/src/lib/components/multiDropzone/utils/index.test.ts +128 -45
  38. package/src/lib/components/multiDropzone/utils/index.ts +89 -36
@@ -13,6 +13,7 @@ import './UploadFileCell/index.js';
13
13
  import '../icon/icons/EyeVision.js';
14
14
  import '../icon/icons/File.js';
15
15
  import '../icon/icons/Trash2.js';
16
+ import '../button/index.js';
16
17
 
17
18
  var story = {
18
19
  title: 'JSX/MultiDropzone',
@@ -1 +1 @@
1
- {"version":3,"file":"index.stories.js","sources":["../../../../../src/lib/components/multiDropzone/index.stories.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { MultiDropzone, MultiDropzoneProps } from '.';\nimport { UploadedFile } from './types';\n\nconst story = {\n title: 'JSX/MultiDropzone',\n component: MultiDropzone,\n argTypes: {\n uploadedFiles: {\n description: 'List of files to be displayed on the component.',\n },\n uploading: {\n defaultValue: false,\n description: 'Property that allows to display component in an uploading state',\n },\n isCondensed: {\n defaultValue: false,\n description: 'Property that allows to display component in a smaller layout',\n },\n maxFiles: {\n description: 'Property that allows to display the maximum number of files allowed',\n table: {\n category: 'File Validation',\n },\n },\n maxSize: {\n description: 'Property that allows to display the maximum size of files allowed',\n table: {\n category: 'File Validation',\n },\n },\n accept: {\n description: 'Property that allows to define which file types are accepted',\n table: {\n category: 'File Validation',\n },\n },\n onRemoveFile: {\n description: 'Called when a file remove button is clicked',\n action: true,\n table: {\n category: 'Callbacks',\n },\n },\n onFileSelect: {\n description: 'Called when a file is uploaded',\n action: true,\n table: {\n category: 'Callbacks',\n },\n },\n textOverrides: {\n description: 'Properties that allow to localise component',\n },\n },\n args: {\n uploadedFiles: [{\n id: '123456789',\n name: 'my-code-doesnt-work-i-have-no-idea-why-my-code-works.jpg'\n }],\n uploading: false,\n isCondensed: false,\n textOverrides: {},\n maxFiles: 0\n },\n parameters: {\n componentSubtitle: 'MultiDropzone component allows upload of multiple documents / files.',\n },\n};\n\nexport const MultiDropzoneStory = ({\n onFileSelect,\n onRemoveFile,\n uploading,\n uploadedFiles = [],\n isCondensed,\n maxFiles,\n maxSize,\n textOverrides,\n}: MultiDropzoneProps) => {\n const [localFiles, setLocalFiles] = useState<UploadedFile[]>(uploadedFiles);\n\n const handleOnRemoveFile = (id: string) => {\n onRemoveFile?.(id);\n setLocalFiles((prevFiles) => prevFiles.filter((file) => file.id !== id));\n };\n\n const handleOnFileSelect = (files: File[]) => {\n const newFiles = files.map((newFile) => ({\n id: String(new Date().getTime()),\n name: newFile.name,\n progress: 100,\n }));\n setLocalFiles((prevFiles) => [...prevFiles, ...newFiles]);\n onFileSelect(files);\n };\n\n return (\n <MultiDropzone \n onFileSelect={handleOnFileSelect} \n onRemoveFile={handleOnRemoveFile} \n uploadedFiles={localFiles} \n uploading={uploading} \n isCondensed={isCondensed}\n maxFiles={maxFiles}\n maxSize={maxSize}\n textOverrides={textOverrides}\n />\n );\n};\n\nMultiDropzoneStory.storyName = \"MultiDropzone\";\n\nexport const UploadingState = () => (\n <MultiDropzone\n uploadedFiles={[\n {\n id: '123',\n progress: 72,\n name: 'test_file_name.pdf',\n previewUrl: 'http://getpopsure.com/test_file_name.pdf',\n },\n {\n id: '124',\n progress: 72,\n name: 'test_file_name.pdf',\n previewUrl: 'http://getpopsure.com/test_file_name.pdf',\n showLoadingSpinner: true,\n showProgressBar: false,\n },\n {\n id: '125',\n progress: 72,\n name: 'test_file_name.pdf',\n previewUrl: 'http://getpopsure.com/test_file_name.pdf',\n showLoadingSpinner: true,\n },\n {\n id: '456',\n progress: 100,\n name: 'test_file_name2.pdf',\n previewUrl: 'http://getpopsure.com/test_file_name2.pdf',\n },\n ]}\n onFileSelect={() => {}}\n uploading={true}\n onRemoveFile={() => {}}\n />\n);\n\n\nexport const CondensedView = () => (\n <MultiDropzone\n uploadedFiles={[\n {\n id: '123',\n progress: 100,\n name: 'test_file_name.pdf',\n previewUrl: 'http://getpopsure.com/test_file_name.pdf',\n },\n ]}\n onFileSelect={() => {}}\n uploading={false}\n onRemoveFile={() => {}}\n isCondensed\n />\n);\n\nexport const ErrorState = () => (\n <MultiDropzone\n uploadedFiles={[\n {\n id: '123',\n progress: 0,\n name: 'test_file_name.pdf',\n previewUrl: 'http://getpopsure.com/test_file_name.pdf',\n error: 'File is too big!',\n },\n ]}\n onFileSelect={() => {}}\n uploading={false}\n onRemoveFile={() => {}}\n />\n);\n\nexport const TooManyFilesErrorState = () => (\n <MultiDropzone\n maxFiles={2}\n isCondensed\n uploadedFiles={[\n {\n id: '123',\n progress: 100,\n name: 'test_file_name.pdf',\n previewUrl: 'http://getpopsure.com/test_file_name.pdf',\n },\n {\n id: '124',\n progress: 100,\n name: 'test_file_name.pdf',\n previewUrl: 'http://getpopsure.com/test_file_name.pdf',\n showLoadingSpinner: true,\n showProgressBar: false,\n },\n {\n id: '125',\n progress: 100,\n name: 'test_file_name.pdf',\n previewUrl: 'http://getpopsure.com/test_file_name.pdf',\n showLoadingSpinner: true,\n },\n ]}\n uploading={false}\n onFileSelect={() => {}}\n />\n);\n\nexport const AcceptingOnlyImages = () => (\n <MultiDropzone\n accept=\"image\"\n isCondensed\n uploadedFiles={[]}\n onFileSelect={() => {}}\n uploading={false}\n onRemoveFile={() => {}}\n />\n);\n\nexport const AcceptingOnlyDocuments = () => (\n <MultiDropzone\n accept=\"document\"\n isCondensed\n uploadedFiles={[]}\n onFileSelect={() => {}}\n uploading={false}\n onRemoveFile={() => {}}\n />\n);\n\nexport const AcceptingOnlyVideos = () => (\n <MultiDropzone\n accept=\"video\"\n isCondensed\n uploadedFiles={[]}\n onFileSelect={() => {}}\n uploading={false}\n onRemoveFile={() => {}}\n />\n);\n\nexport const LimitingFileSizeTo2MB = () => (\n <MultiDropzone\n isCondensed\n uploadedFiles={[]}\n onFileSelect={() => {}}\n uploading={false}\n onRemoveFile={() => {}}\n maxSize={2096000}\n />\n);\n\nexport const I18nSupport = () => (\n <MultiDropzone\n uploadedFiles={[]}\n onFileSelect={() => {}}\n uploading={false}\n onRemoveFile={() => {}}\n textOverrides={{\n instructionsText: 'Datei auswählen oder per Drag & Drop platzieren',\n supportsTextShort: 'Unterstützt werden',\n currentlyUploadingText:\n 'Bitte warten während die Datei hochgeladen wird...'\n }}\n />\n);\n\nexport default story;\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;IAIM,KAAK,GAAG;IACZ,KAAK,EAAE,mBAAmB;IAC1B,SAAS,EAAE,aAAa;IACxB,QAAQ,EAAE;QACR,aAAa,EAAE;YACb,WAAW,EAAE,iDAAiD;SAC/D;QACD,SAAS,EAAE;YACT,YAAY,EAAE,KAAK;YACnB,WAAW,EAAE,iEAAiE;SAC/E;QACD,WAAW,EAAE;YACX,YAAY,EAAE,KAAK;YACnB,WAAW,EAAE,+DAA+D;SAC7E;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,qEAAqE;YAClF,KAAK,EAAE;gBACL,QAAQ,EAAE,iBAAiB;aAC5B;SACF;QACD,OAAO,EAAE;YACP,WAAW,EAAE,mEAAmE;YAChF,KAAK,EAAE;gBACL,QAAQ,EAAE,iBAAiB;aAC5B;SACF;QACD,MAAM,EAAE;YACN,WAAW,EAAE,8DAA8D;YAC3E,KAAK,EAAE;gBACL,QAAQ,EAAE,iBAAiB;aAC5B;SACF;QACD,YAAY,EAAE;YACZ,WAAW,EAAE,6CAA6C;YAC1D,MAAM,EAAE,IAAI;YACZ,KAAK,EAAE;gBACL,QAAQ,EAAE,WAAW;aACtB;SACF;QACD,YAAY,EAAE;YACZ,WAAW,EAAE,gCAAgC;YAC7C,MAAM,EAAE,IAAI;YACZ,KAAK,EA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a,EAAE,EAAE,EACjB,YAAY,EAAE,eAAQ,EACtB,SAAS,EAAE,KAAK,EAChB,YAAY,EAAE,eAAQ,GACtB,KACF;IAEW,mBAAmB,GAAG,cAAM,QACvCA,IAAC,aAAa,IACZ,MAAM,EAAC,OAAO,EACd,WAAW,QACX,aAAa,EAAE,EAAE,EACjB,YAAY,EAAE,eAAQ,EACtB,SAAS,EAAE,KAAK,EAChB,YAAY,EAAE,eAAQ,GACtB,KACF;IAEW,qBAAqB,GAAG,cAAM,QACzCA,IAAC,aAAa,IACZ,WAAW,QACX,aAAa,EAAE,EAAE,EACjB,YAAY,EAAE,eAAQ,EACtB,SAAS,EAAE,KAAK,EAChB,YAAY,EAAE,eAAQ,EACtB,OAAO,EAAE,OAAO,GAChB,KACF;IAEW,WAAW,GAAG,cAAM,QAC/BA,IAAC,aAAa,IACZ,aAAa,EAAE,EAAE,EACjB,YAAY,EAAE,eAAQ,EACtB,SAAS,EAAE,KAAK,EAChB,YAAY,EAAE,eAAQ,EACtB,aAAa,EAAE;QACb,gBAAgB,EAAE,iDAAiD;QACnE,iBAAiB,EAAE,oBAAoB;QACvC,sBAAsB,EACpB,oDAAoD;KACvD,GACD;;;;;"}
1
+ {"version":3,"file":"index.stories.js","sources":["../../../../../src/lib/components/multiDropzone/index.stories.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { MultiDropzone, MultiDropzoneProps } from '.';\nimport { UploadedFile } from './types';\n\nconst story = {\n title: 'JSX/MultiDropzone',\n component: MultiDropzone,\n argTypes: {\n uploadedFiles: {\n description: 'List of files to be displayed on the component.',\n },\n uploading: {\n defaultValue: false,\n description: 'Property that allows to display component in an uploading state',\n },\n isCondensed: {\n defaultValue: false,\n description: 'Property that allows to display component in a smaller layout',\n },\n maxFiles: {\n description: 'Property that allows to display the maximum number of files allowed',\n table: {\n category: 'File Validation',\n },\n },\n maxSize: {\n description: 'Property that allows to display the maximum size of files allowed',\n table: {\n category: 'File Validation',\n },\n },\n accept: {\n description: 'Property that allows to define which file types are accepted',\n table: {\n category: 'File Validation',\n },\n },\n onRemoveFile: {\n description: 'Called when a file remove button is clicked',\n action: true,\n table: {\n category: 'Callbacks',\n },\n },\n onFileSelect: {\n description: 'Called when a file is uploaded',\n action: true,\n table: {\n category: 'Callbacks',\n },\n },\n textOverrides: {\n description: 'Properties that allow to localise component',\n },\n },\n args: {\n uploadedFiles: [{\n id: '123456789',\n name: 'my-code-doesnt-work-i-have-no-idea-why-my-code-works.jpg'\n }],\n uploading: false,\n isCondensed: false,\n textOverrides: {},\n maxFiles: 0\n },\n parameters: {\n componentSubtitle: 'MultiDropzone component allows upload of multiple documents / files.',\n },\n};\n\nexport const MultiDropzoneStory = ({\n onFileSelect,\n onRemoveFile,\n uploading,\n uploadedFiles = [],\n isCondensed,\n maxFiles,\n maxSize,\n textOverrides,\n}: MultiDropzoneProps) => {\n const [localFiles, setLocalFiles] = useState<UploadedFile[]>(uploadedFiles);\n\n const handleOnRemoveFile = (id: string) => {\n onRemoveFile?.(id);\n setLocalFiles((prevFiles) => prevFiles.filter((file) => file.id !== id));\n };\n\n const handleOnFileSelect = (files: File[]) => {\n const newFiles = files.map((newFile) => ({\n id: String(new Date().getTime()),\n name: newFile.name,\n progress: 100,\n }));\n setLocalFiles((prevFiles) => [...prevFiles, ...newFiles]);\n onFileSelect(files);\n };\n\n return (\n <MultiDropzone \n onFileSelect={handleOnFileSelect} \n onRemoveFile={handleOnRemoveFile} \n uploadedFiles={localFiles} \n uploading={uploading} \n isCondensed={isCondensed}\n maxFiles={maxFiles}\n maxSize={maxSize}\n textOverrides={textOverrides}\n />\n );\n};\n\nMultiDropzoneStory.storyName = \"MultiDropzone\";\n\nexport const UploadingState = () => (\n <MultiDropzone\n uploadedFiles={[\n {\n id: '123',\n progress: 72,\n name: 'test_file_name.pdf',\n previewUrl: 'http://getpopsure.com/test_file_name.pdf',\n },\n {\n id: '124',\n progress: 72,\n name: 'test_file_name.pdf',\n previewUrl: 'http://getpopsure.com/test_file_name.pdf',\n showLoadingSpinner: true,\n showProgressBar: false,\n },\n {\n id: '125',\n progress: 72,\n name: 'test_file_name.pdf',\n previewUrl: 'http://getpopsure.com/test_file_name.pdf',\n showLoadingSpinner: true,\n },\n {\n id: '456',\n progress: 100,\n name: 'test_file_name2.pdf',\n previewUrl: 'http://getpopsure.com/test_file_name2.pdf',\n },\n ]}\n onFileSelect={() => {}}\n uploading={true}\n onRemoveFile={() => {}}\n />\n);\n\n\nexport const CondensedView = () => (\n <MultiDropzone\n uploadedFiles={[\n {\n id: '123',\n progress: 100,\n name: 'test_file_name.pdf',\n previewUrl: 'http://getpopsure.com/test_file_name.pdf',\n },\n ]}\n onFileSelect={() => {}}\n uploading={false}\n onRemoveFile={() => {}}\n isCondensed\n />\n);\n\nexport const ErrorState = () => (\n <MultiDropzone\n uploadedFiles={[\n {\n id: '123',\n progress: 0,\n name: 'test_file_name.pdf',\n previewUrl: 'http://getpopsure.com/test_file_name.pdf',\n error: 'File is too big!',\n },\n ]}\n onFileSelect={() => {}}\n uploading={false}\n onRemoveFile={() => {}}\n />\n);\n\nexport const TooManyFilesErrorState = () => (\n <MultiDropzone\n maxFiles={2}\n isCondensed\n uploadedFiles={[\n {\n id: '123',\n progress: 100,\n name: 'test_file_name.pdf',\n previewUrl: 'http://getpopsure.com/test_file_name.pdf',\n },\n {\n id: '124',\n progress: 100,\n name: 'test_file_name.pdf',\n previewUrl: 'http://getpopsure.com/test_file_name.pdf',\n showLoadingSpinner: true,\n showProgressBar: false,\n },\n {\n id: '125',\n progress: 100,\n name: 'test_file_name.pdf',\n previewUrl: 'http://getpopsure.com/test_file_name.pdf',\n showLoadingSpinner: true,\n },\n ]}\n uploading={false}\n onFileSelect={() => {}}\n />\n);\n\nexport const AcceptingOnlyImages = () => (\n <MultiDropzone\n accept=\"image\"\n isCondensed\n uploadedFiles={[]}\n onFileSelect={() => {}}\n uploading={false}\n onRemoveFile={() => {}}\n />\n);\n\nexport const AcceptingOnlyDocuments = () => (\n <MultiDropzone\n accept=\"document\"\n isCondensed\n uploadedFiles={[]}\n onFileSelect={() => {}}\n uploading={false}\n onRemoveFile={() => {}}\n />\n);\n\nexport const AcceptingOnlyVideos = () => (\n <MultiDropzone\n accept=\"video\"\n isCondensed\n uploadedFiles={[]}\n onFileSelect={() => {}}\n uploading={false}\n onRemoveFile={() => {}}\n />\n);\n\nexport const LimitingFileSizeTo2MB = () => (\n <MultiDropzone\n isCondensed\n uploadedFiles={[]}\n onFileSelect={() => {}}\n uploading={false}\n onRemoveFile={() => {}}\n maxSize={2096000}\n />\n);\n\nexport const I18nSupport = () => (\n <MultiDropzone\n uploadedFiles={[]}\n onFileSelect={() => {}}\n uploading={false}\n onRemoveFile={() => {}}\n textOverrides={{\n instructionsText: 'Datei auswählen oder per Drag & Drop platzieren',\n supportsTextShort: 'Unterstützt werden',\n currentlyUploadingText:\n 'Bitte warten während die Datei hochgeladen wird...'\n }}\n />\n);\n\nexport default story;\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;IAIM,KAAK,GAAG;IACZ,KAAK,EAAE,mBAAmB;IAC1B,SAAS,EAAE,aAAa;IACxB,QAAQ,EAAE;QACR,aAAa,EAAE;YACb,WAAW,EAAE,iDAAiD;SAC/D;QACD,SAAS,EAAE;YACT,YAAY,EAAE,KAAK;YACnB,WAAW,EAAE,iEAAiE;SAC/E;QACD,WAAW,EAAE;YACX,YAAY,EAAE,KAAK;YACnB,WAAW,EAAE,+DAA+D;SAC7E;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,qEAAqE;YAClF,KAAK,EAAE;gBACL,QAAQ,EAAE,iBAAiB;aAC5B;SACF;QACD,OAAO,EAAE;YACP,WAAW,EAAE,mEAAmE;YAChF,KAAK,EAAE;gBACL,QAAQ,EAAE,iBAAiB;aAC5B;SACF;QACD,MAAM,EAAE;YACN,WAAW,EAAE,8DAA8D;YAC3E,KAAK,EAAE;gBACL,QAAQ,EAAE,iBAAiB;aAC5B;SACF;QACD,YAAY,EAAE;Y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AAE,EAAE,EACjB,YAAY,EAAE,eAAQ,EACtB,SAAS,EAAE,KAAK,EAChB,YAAY,EAAE,eAAQ,GACtB,KACF;IAEW,sBAAsB,GAAG,cAAM,QAC1CA,IAAC,aAAa,IACZ,MAAM,EAAC,UAAU,EACjB,WAAW,QACX,aAAa,EAAE,EAAE,EACjB,YAAY,EAAE,eAAQ,EACtB,SAAS,EAAE,KAAK,EAChB,YAAY,EAAE,eAAQ,GACtB,KACF;IAEW,mBAAmB,GAAG,cAAM,QACvCA,IAAC,aAAa,IACZ,MAAM,EAAC,OAAO,EACd,WAAW,QACX,aAAa,EAAE,EAAE,EACjB,YAAY,EAAE,eAAQ,EACtB,SAAS,EAAE,KAAK,EAChB,YAAY,EAAE,eAAQ,GACtB,KACF;IAEW,qBAAqB,GAAG,cAAM,QACzCA,IAAC,aAAa,IACZ,WAAW,QACX,aAAa,EAAE,EAAE,EACjB,YAAY,EAAE,eAAQ,EACtB,SAAS,EAAE,KAAK,EAChB,YAAY,EAAE,eAAQ,EACtB,OAAO,EAAE,OAAO,GAChB,KACF;IAEW,WAAW,GAAG,cAAM,QAC/BA,IAAC,aAAa,IACZ,aAAa,EAAE,EAAE,EACjB,YAAY,EAAE,eAAQ,EACtB,SAAS,EAAE,KAAK,EAChB,YAAY,EAAE,eAAQ,EACtB,aAAa,EAAE;QACb,gBAAgB,EAAE,iDAAiD;QACnE,iBAAiB,EAAE,oBAAoB;QACvC,sBAAsB,EACpB,oDAAoD;KACvD,GACD;;;;;"}
@@ -20,6 +20,7 @@ import './UploadFileCell/index.js';
20
20
  import '../icon/icons/EyeVision.js';
21
21
  import '../icon/icons/File.js';
22
22
  import '../icon/icons/Trash2.js';
23
+ import '../button/index.js';
23
24
 
24
25
  var mockOnFileSelect = jest.fn();
25
26
  var mockOnRemoveFile = jest.fn();
@@ -1 +1 @@
1
- {"version":3,"file":"index.test.js","sources":["../../../../../src/lib/components/multiDropzone/index.test.tsx"],"sourcesContent":["import { act, fireEvent, render } from '../../util/testUtils';\nimport '@testing-library/jest-dom';\n\nimport { MultiDropzone, MultiDropzoneProps } from '.';\n\nconst mockOnFileSelect = jest.fn();\nconst mockOnRemoveFile = jest.fn();\nconst file = new File(['DummyFile'], 'dummy.png', { type: 'image/png' });\n\nconst inputTestId = 'ds-drop-input';\nconst spinnerTestId = 'ds-filecell-spinner';\nconst progressbarTestId = 'ds-filecell-progressbar';\nconst uploadedFilesMock = {\n id: '123',\n name: 'File name',\n progress: 100,\n type: 'jpg',\n};\n\nconst setup = ({\n uploadedFiles = [],\n uploading = false,\n ...rest\n}: Partial<MultiDropzoneProps>) => {\n return render(\n <MultiDropzone\n {...rest}\n uploadedFiles={uploadedFiles}\n uploading={uploading}\n onFileSelect={mockOnFileSelect}\n onRemoveFile={mockOnRemoveFile}\n />\n );\n};\n\ndescribe('MultiDropzone component', () => {\n it('should call onFileSelect on files change', async () => {\n const { getByTestId, user } = setup({});\n const files = [file, file];\n\n await user.upload(getByTestId(inputTestId), files);\n\n expect(mockOnFileSelect).toHaveBeenCalledWith(files);\n });\n\n describe('Error states', () => {\n it('should show max files error message', () => {\n const screen = setup({\n maxFiles: 1,\n uploadedFiles: [\n uploadedFilesMock,\n {\n ...uploadedFilesMock,\n id: '222',\n },\n ],\n });\n\n expect(screen.getByText('You can upload maximum 1 files.')).toBeVisible();\n });\n\n it('should show max file size error message', async () => {\n const { getByTestId, getByText, user } = setup({ maxSize: 10 });\n const bigFile = file;\n Object.defineProperty(bigFile, 'size', { value: 1024 });\n\n await user.upload(getByTestId(inputTestId), [bigFile]);\n\n expect(\n getByText('File is too large. It must be less than 10 Bytes.')\n ).toBeInTheDocument();\n });\n\n it('should show wrong filetype error message', async () => {\n const { getByTestId, getByText } = setup({ accept: 'document' });\n const input = getByTestId(inputTestId);\n\n await act(async () => {\n // Keeping fireevent to emulate file change like drop\n // Using userevent.upload doesn't work since input has an accept/html validation\n fireEvent.change(input, { target: { files: [file] } });\n });\n\n expect(\n getByText('File type must be DOC, DOCX, PDF')\n ).toBeInTheDocument();\n });\n\n it('should remove wrong filetype error message', async () => {\n const { getByTestId, queryByText, user } = setup({\n accept: 'document',\n });\n const input = getByTestId(inputTestId);\n\n await act(async () => {\n // Keeping fireevent to emulate file change like drop\n // Using userevent.upload doesn't work since input has an accept/html validation\n fireEvent.change(input, { target: { files: [file] } });\n });\n\n await user.click(getByTestId('remove-button'));\n\n expect(\n queryByText('File type must be PDF')\n ).not.toBeInTheDocument();\n });\n });\n\n describe('Copy text', () => {\n it('should show uploader text', () => {\n const screen = setup({});\n\n expect(\n screen.getByText('Choose file or drag & drop')\n ).toBeInTheDocument();\n });\n\n it('should show uploader text translated', () => {\n const instructionsText = 'Drag drop file';\n const screen = setup({\n textOverrides: { instructionsText },\n });\n\n expect(screen.getByText(instructionsText)).toBeInTheDocument();\n });\n\n it('should show image accept file type label', () => {\n const screen = setup({ accept: 'image' });\n\n expect(\n screen.getByText('Supports images')\n ).toBeInTheDocument();\n });\n\n it('should show document accept file type label', () => {\n const screen = setup({ accept: 'document' });\n\n expect(screen.getByText('Supports documents')).toBeInTheDocument();\n });\n\n it('should custom document accept file type label', () => {\n const screen = setup({\n accept: {\n 'application/pdf': ['.pdf'],\n 'image/jpg': ['.jpg'],\n },\n });\n\n expect(screen.getByText('Supports images, videos and documents')).toBeInTheDocument();\n });\n\n it('should show disabled text if is uploading', () => {\n const screen = setup({ uploading: true });\n\n expect(\n screen.getByText('Please wait while uploading file...')\n ).toBeInTheDocument();\n });\n });\n\n describe('Uploaded files', () => {\n it('should show uploaded files', () => {\n const screen = setup({\n uploadedFiles: [uploadedFilesMock],\n });\n\n expect(screen.getByText(uploadedFilesMock.name)).toBeInTheDocument();\n });\n\n it('should call onRemoveFile with uploaded file id', () => {\n const screen = setup({\n uploadedFiles: [uploadedFilesMock],\n });\n\n screen.getByTestId('remove-button').click();\n\n expect(mockOnRemoveFile).toBeCalledWith(uploadedFilesMock.id);\n });\n\n it('should show uploaded file with uploading label', () => {\n const screen = setup({\n uploadedFiles: [{ ...uploadedFilesMock, progress: 50 }],\n });\n\n expect(screen.getByText('Uploading...')).toBeInTheDocument();\n });\n\n it('should show uploaded file with progress bar', () => {\n const screen = setup({\n uploadedFiles: [\n {\n ...uploadedFilesMock,\n progress: 50,\n },\n ],\n });\n\n expect(screen.getByTestId(progressbarTestId)).toBeInTheDocument();\n });\n\n it('should show uploaded file with no progress bar', () => {\n const screen = setup({\n uploadedFiles: [\n {\n ...uploadedFilesMock,\n progress: 50,\n showProgressBar: false,\n },\n ],\n });\n\n expect(screen.queryByTestId(progressbarTestId)).not.toBeInTheDocument();\n });\n\n it('should show uploaded file with loading spinner', () => {\n const screen = setup({\n uploadedFiles: [\n {\n ...uploadedFilesMock,\n progress: 50,\n showLoadingSpinner: true,\n },\n ],\n });\n\n expect(screen.getByTestId(spinnerTestId)).toBeInTheDocument();\n });\n\n it('should show uploaded file with no loading spinner', () => {\n const screen = setup({\n uploadedFiles: [\n {\n ...uploadedFilesMock,\n progress: 50,\n showLoadingSpinner: false,\n },\n ],\n });\n\n expect(screen.queryByTestId(spinnerTestId)).not.toBeInTheDocument();\n });\n });\n});\n"],"names":["render","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAM,gBAAgB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACnC,IAAM,gBAAgB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACnC,IAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;AAEzE,IAAM,WAAW,GAAG,eAAe,CAAC;AACpC,IAAM,aAAa,GAAG,qBAAqB,CAAC;AAC5C,IAAM,iBAAiB,GAAG,yBAAyB,CAAC;AACpD,IAAM,iBAAiB,GAAG;IACxB,EAAE,EAAE,KAAK;IACT,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,GAAG;IACb,IAAI,EAAE,KAAK;CACZ,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AAG,CAAC,iBAAiB,EAAE,CAAC;SACrE,CAAC,CAAC;KACJ,CAAC,CAAC;AACL,CAAC,CAAC"}
1
+ {"version":3,"file":"index.test.js","sources":["../../../../../src/lib/components/multiDropzone/index.test.tsx"],"sourcesContent":["import { act, fireEvent, render } from '../../util/testUtils';\nimport '@testing-library/jest-dom';\n\nimport { MultiDropzone, MultiDropzoneProps } from '.';\n\nconst mockOnFileSelect = jest.fn();\nconst mockOnRemoveFile = jest.fn();\nconst file = new File(['DummyFile'], 'dummy.png', { type: 'image/png' });\n\nconst inputTestId = 'ds-drop-input';\nconst spinnerTestId = 'ds-filecell-spinner';\nconst progressbarTestId = 'ds-filecell-progressbar';\nconst uploadedFilesMock = {\n id: '123',\n name: 'File name',\n progress: 100,\n type: 'jpg',\n};\n\nconst setup = ({\n uploadedFiles = [],\n uploading = false,\n ...rest\n}: Partial<MultiDropzoneProps>) => {\n return render(\n <MultiDropzone\n {...rest}\n uploadedFiles={uploadedFiles}\n uploading={uploading}\n onFileSelect={mockOnFileSelect}\n onRemoveFile={mockOnRemoveFile}\n />\n );\n};\n\ndescribe('MultiDropzone component', () => {\n it('should call onFileSelect on files change', async () => {\n const { getByTestId, user } = setup({});\n const files = [file, file];\n\n await user.upload(getByTestId(inputTestId), files);\n\n expect(mockOnFileSelect).toHaveBeenCalledWith(files);\n });\n\n describe('Error states', () => {\n it('should show max files error message', () => {\n const screen = setup({\n maxFiles: 1,\n uploadedFiles: [\n uploadedFilesMock,\n {\n ...uploadedFilesMock,\n id: '222',\n },\n ],\n });\n\n expect(screen.getByText('You can upload maximum 1 files.')).toBeVisible();\n });\n\n it('should show max file size error message', async () => {\n const { getByTestId, getByText, user } = setup({ maxSize: 10 });\n const bigFile = file;\n Object.defineProperty(bigFile, 'size', { value: 1024 });\n\n await user.upload(getByTestId(inputTestId), [bigFile]);\n\n expect(\n getByText('File is too large. It must be less than 10 Bytes.')\n ).toBeInTheDocument();\n });\n\n it('should show wrong filetype error message', async () => {\n const { getByTestId, getByText } = setup({ accept: 'document' });\n const input = getByTestId(inputTestId);\n\n await act(async () => {\n // Keeping fireevent to emulate file change like drop\n // Using userevent.upload doesn't work since input has an accept/html validation\n fireEvent.change(input, { target: { files: [file] } });\n });\n\n expect(\n getByText('File type must be DOC, DOCX, PDF')\n ).toBeInTheDocument();\n });\n\n it('should remove wrong filetype error message', async () => {\n const { getByTestId, queryByText, user } = setup({\n accept: 'document',\n });\n const input = getByTestId(inputTestId);\n\n await act(async () => {\n // Keeping fireevent to emulate file change like drop\n // Using userevent.upload doesn't work since input has an accept/html validation\n fireEvent.change(input, { target: { files: [file] } });\n });\n\n await user.click(getByTestId('remove-button'));\n\n expect(\n queryByText('File type must be PDF')\n ).not.toBeInTheDocument();\n });\n });\n\n describe('Copy text', () => {\n it('should show uploader text', () => {\n const screen = setup({});\n\n expect(\n screen.getByText('Choose file or drag & drop')\n ).toBeInTheDocument();\n });\n\n it('should show uploader text translated', () => {\n const instructionsText = 'Drag drop file';\n const screen = setup({\n textOverrides: { instructionsText },\n });\n\n expect(screen.getByText(instructionsText)).toBeInTheDocument();\n });\n\n it('should show image accept file type label', () => {\n const screen = setup({ accept: 'image' });\n\n expect(\n screen.getByText('Supports images')\n ).toBeInTheDocument();\n });\n\n it('should show document accept file type label', () => {\n const screen = setup({ accept: 'document' });\n\n expect(screen.getByText('Supports documents')).toBeInTheDocument();\n });\n\n it('should custom document accept file type label', () => {\n const screen = setup({\n accept: {\n 'application/pdf': ['.pdf'],\n 'image/jpg': ['.jpg'],\n },\n });\n\n expect(screen.getByText('Supports images, videos and documents')).toBeInTheDocument();\n });\n\n it('should show disabled text if is uploading', () => {\n const screen = setup({ uploading: true });\n\n expect(\n screen.getByText('Please wait while uploading file...')\n ).toBeInTheDocument();\n });\n });\n\n describe('Uploaded files', () => {\n it('should show uploaded files', () => {\n const screen = setup({\n uploadedFiles: [uploadedFilesMock],\n });\n\n expect(screen.getByText(uploadedFilesMock.name)).toBeInTheDocument();\n });\n\n it('should call onRemoveFile with uploaded file id', () => {\n const screen = setup({\n uploadedFiles: [uploadedFilesMock],\n });\n\n screen.getByTestId('remove-button').click();\n\n expect(mockOnRemoveFile).toBeCalledWith(uploadedFilesMock.id);\n });\n\n it('should show uploaded file with uploading label', () => {\n const screen = setup({\n uploadedFiles: [{ ...uploadedFilesMock, progress: 50 }],\n });\n\n expect(screen.getByText('Uploading...')).toBeInTheDocument();\n });\n\n it('should show uploaded file with progress bar', () => {\n const screen = setup({\n uploadedFiles: [\n {\n ...uploadedFilesMock,\n progress: 50,\n },\n ],\n });\n\n expect(screen.getByTestId(progressbarTestId)).toBeInTheDocument();\n });\n\n it('should show uploaded file with no progress bar', () => {\n const screen = setup({\n uploadedFiles: [\n {\n ...uploadedFilesMock,\n progress: 50,\n showProgressBar: false,\n },\n ],\n });\n\n expect(screen.queryByTestId(progressbarTestId)).not.toBeInTheDocument();\n });\n\n it('should show uploaded file with loading spinner', () => {\n const screen = setup({\n uploadedFiles: [\n {\n ...uploadedFilesMock,\n progress: 50,\n showLoadingSpinner: true,\n },\n ],\n });\n\n expect(screen.getByTestId(spinnerTestId)).toBeInTheDocument();\n });\n\n it('should show uploaded file with no loading spinner', () => {\n const screen = setup({\n uploadedFiles: [\n {\n ...uploadedFilesMock,\n progress: 50,\n showLoadingSpinner: false,\n },\n ],\n });\n\n expect(screen.queryByTestId(spinnerTestId)).not.toBeInTheDocument();\n });\n });\n});\n"],"names":["render","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAM,gBAAgB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACnC,IAAM,gBAAgB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACnC,IAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;AAEzE,IAAM,WAAW,GAAG,eAAe,CAAC;AACpC,IAAM,aAAa,GAAG,qBAA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;gBACnB,aAAa,EAAE;0CAER,iBAAiB,KACpB,QAAQ,EAAE,EAAE,EACZ,kBAAkB,EAAE,KAAK;iBAE5B;aACF,CAAC,CAAC;YAEH,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;SACrE,CAAC,CAAC;KACJ,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -7,7 +7,7 @@ import ChevronDownIcon from '../icon/icons/ChevronDown.js';
7
7
  import ChevronUpIcon from '../icon/icons/ChevronUp.js';
8
8
  import { Card } from '../cards/card/index.js';
9
9
  import { s as styleInject } from '../../style-inject.es-1f59c1d0.js';
10
- import { u as useMediaQuery, i as isBaseCell, T as TableSection } from '../../TableSection-a26ba0c5.js';
10
+ import { u as useMediaQuery, i as isBaseCell, T as TableSection } from '../../TableSection-ebace923.js';
11
11
  import { TableContents } from './components/TableContents/TableContents.js';
12
12
  import { c as classNames } from '../../index-6ea95111.js';
13
13
  import { u as useTableNavigation } from '../../useTableNavigation-f929fbc9.js';
@@ -35,7 +35,7 @@ import '../../index-dd80248b.js';
35
35
  import '../modal/regularModal/index.js';
36
36
  import '../icon/icons/ChevronDown.js';
37
37
  import '../icon/icons/ChevronUp.js';
38
- import '../../TableSection-a26ba0c5.js';
38
+ import '../../TableSection-ebace923.js';
39
39
  import './components/TableContents/TableContents.js';
40
40
  import './components/TableContents/Collapsible.js';
41
41
  import '../../useTableNavigation-f929fbc9.js';
@@ -35,7 +35,7 @@ import '../../index-dd80248b.js';
35
35
  import '../modal/regularModal/index.js';
36
36
  import '../icon/icons/ChevronDown.js';
37
37
  import '../icon/icons/ChevronUp.js';
38
- import '../../TableSection-a26ba0c5.js';
38
+ import '../../TableSection-ebace923.js';
39
39
  import './components/TableContents/TableContents.js';
40
40
  import './components/TableContents/Collapsible.js';
41
41
  import '../../useTableNavigation-f929fbc9.js';
@@ -1,7 +1,7 @@
1
1
  import { a as __assign, _ as __spreadArray } from '../../../../tslib.es6-a39f91fc.js';
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
3
  import { useState } from 'react';
4
- import { T as TableSection } from '../../../../TableSection-a26ba0c5.js';
4
+ import { T as TableSection } from '../../../../TableSection-ebace923.js';
5
5
  import ChevronDownIcon from '../../../icon/icons/ChevronDown.js';
6
6
  import ChevronUpIcon from '../../../icon/icons/ChevronUp.js';
7
7
  import { Card } from '../../../cards/card/index.js';
@@ -6,7 +6,7 @@ import 'react';
6
6
  import 'react-dom';
7
7
  import '../../../../_commonjsHelpers-4730bd53.js';
8
8
  import 'react-dom/test-utils';
9
- import '../../../../TableSection-a26ba0c5.js';
9
+ import '../../../../TableSection-ebace923.js';
10
10
  import '../../../../index-6ea95111.js';
11
11
  import '../../../../style-inject.es-1f59c1d0.js';
12
12
  import '../TableCell/TableCell.js';
@@ -1,7 +1,7 @@
1
1
  import '../../../../tslib.es6-a39f91fc.js';
2
2
  import 'react/jsx-runtime';
3
3
  import '../../../../index-6ea95111.js';
4
- export { T as TableSection } from '../../../../TableSection-a26ba0c5.js';
4
+ export { T as TableSection } from '../../../../TableSection-ebace923.js';
5
5
  import '../TableCell/TableCell.js';
6
6
  import 'react';
7
7
  import '../../../../style-inject.es-1f59c1d0.js';
@@ -1,7 +1,7 @@
1
1
  import { a as __assign } from '../../../../tslib.es6-a39f91fc.js';
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
  import { c as customRender, s as screen } from '../../../../customRender-be47569b.js';
4
- import { T as TableSection } from '../../../../TableSection-a26ba0c5.js';
4
+ import { T as TableSection } from '../../../../TableSection-ebace923.js';
5
5
  import 'react';
6
6
  import 'react-dom';
7
7
  import '../../../../_commonjsHelpers-4730bd53.js';
package/dist/esm/index.js CHANGED
@@ -31,7 +31,7 @@ export { a as Toaster, t as toast } from './index-4b19aafb.js';
31
31
  export { Accordion } from './components/accordion/index.js';
32
32
  export { Table } from './components/table/Table.js';
33
33
  import { useCallback, useEffect } from 'react';
34
- export { u as useMediaQuery } from './TableSection-a26ba0c5.js';
34
+ export { u as useMediaQuery } from './TableSection-ebace923.js';
35
35
  export { u as useOnClickOutside } from './Calendar-2d7e51b5.js';
36
36
  export { default as Svg1Icon } from './components/icon/icons/1.js';
37
37
  export { default as Svg2Icon } from './components/icon/icons/2.js';
@@ -1,5 +1,5 @@
1
- import { Accept, FileError } from "react-dropzone";
2
- import { AcceptType, TextOverrides, UploadStatus } from "../types";
1
+ import { Accept, FileError, FileRejection } from 'react-dropzone';
2
+ import { AcceptType, TextOverrides, UploadStatus } from '../types';
3
3
  export declare const getUploadStatus: (progress: number, error?: string) => UploadStatus;
4
4
  export declare const DOCUMENT_FILES_ACCEPT: Accept;
5
5
  export declare const IMAGE_FILES_ACCEPT: Accept;
@@ -11,3 +11,10 @@ export declare const getErrorMessage: ({ code, message }: FileError, { fileList,
11
11
  fileList?: string;
12
12
  maxSize?: number;
13
13
  }, textOverrides?: TextOverrides) => string;
14
+ export declare const getStatusMessage: ({ acceptedFiles, filesRejected, fileList, maxSize, textOverrides, }: {
15
+ acceptedFiles: File[];
16
+ filesRejected: FileRejection[];
17
+ fileList?: string;
18
+ maxSize?: number;
19
+ textOverrides?: TextOverrides;
20
+ }) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popsure/dirty-swan",
3
- "version": "0.57.9",
3
+ "version": "0.58.1",
4
4
  "author": "Vincent Audoire <vincent@getpopsure.com>",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -13,6 +13,8 @@ const TableInfoButton = ({
13
13
  type="button"
14
14
  data-testid="ds-table-info-button"
15
15
  onClick={onClick}
16
+ aria-label="View more information"
17
+ title="View more information"
16
18
  >
17
19
  <Info size={20} />
18
20
  </button>
@@ -31,7 +31,7 @@ export const Checkbox = <ValueType extends string>({
31
31
  inlineLayout = false,
32
32
  bordered = true,
33
33
  classNames: classNamesObj,
34
- fieldLegend = 'Select one or more options',
34
+ fieldLegend,
35
35
  }: CheckboxProps<ValueType> & {}) => {
36
36
  const hasNoneValue = Object.keys(options).includes('NONE');
37
37
 
@@ -73,6 +73,12 @@ export const Checkbox = <ValueType extends string>({
73
73
  return (label as CheckboxWithDescription).title !== undefined;
74
74
  };
75
75
 
76
+ const legend =
77
+ fieldLegend ??
78
+ (Object.keys(options).length > 1
79
+ ? 'Select one or more options'
80
+ : 'You may select this option');
81
+
76
82
  return (
77
83
  <fieldset
78
84
  className={classNames(
@@ -87,7 +93,7 @@ export const Checkbox = <ValueType extends string>({
87
93
  }
88
94
  )}
89
95
  >
90
- <legend className="sr-only">{fieldLegend}</legend>
96
+ <legend className="sr-only">{legend}</legend>
91
97
  {entries.map(([currentValue, label]) => {
92
98
  const checked = value?.includes(currentValue);
93
99
  const customIcon = (label as CheckboxWithDescription)?.icon;
@@ -5,15 +5,15 @@ import generateId from '../../util/generateId';
5
5
  import styles from './style.module.scss';
6
6
 
7
7
  // Something weird is going on with enterKeyHint that makes it a required field under certain circumstances. The & Omit<…> and & Pick<…> is a hacky way to go around that.
8
- export type InputProps = Omit<JSX.IntrinsicElements['input'], 'enterKeyHint'> &
9
- Partial<Pick<JSX.IntrinsicElements['input'], 'enterKeyHint'>> & {
10
- error?: string | boolean;
11
- prefix?: string;
12
- label?: string;
13
- id?: string;
14
- hideLabel?: boolean;
15
- labelInsideInput?: boolean;
16
- };
8
+ export type InputProps = Omit<JSX.IntrinsicElements['input'], 'enterKeyHint'> &
9
+ Partial<Pick<JSX.IntrinsicElements['input'], 'enterKeyHint'>> & {
10
+ error?: string | boolean;
11
+ prefix?: string;
12
+ label?: string;
13
+ id?: string;
14
+ hideLabel?: boolean;
15
+ labelInsideInput?: boolean;
16
+ };
17
17
 
18
18
  export const Input = React.forwardRef(
19
19
  (
@@ -54,16 +54,20 @@ export const Input = React.forwardRef(
54
54
  ref={ref}
55
55
  className={classnames(
56
56
  error ? 'p-input--error' : 'p-input',
57
- (!label || labelInsideInput) && placeholder && placeholder.length > 0
57
+ (!label || labelInsideInput) &&
58
+ placeholder &&
59
+ placeholder.length > 0
58
60
  ? styles.input
59
61
  : styles['input--no-placeholder'],
60
62
  {
61
- [styles['input--with-prefix']]: prefix,
62
- [styles['input--with-inside-label']]: labelInsideInput
63
+ [styles['input--with-prefix']]: prefix,
64
+ [styles['input--with-inside-label']]: labelInsideInput,
63
65
  }
64
66
  )}
65
67
  placeholder={label || labelInsideInput ? placeholder : ' '}
66
68
  disabled={disabled}
69
+ aria-invalid={!!error}
70
+ aria-errormessage={error ? `${uniqueId}-error` : undefined}
67
71
  {...props}
68
72
  />
69
73
  {prefix && (
@@ -91,7 +95,10 @@ export const Input = React.forwardRef(
91
95
  )}
92
96
  </div>
93
97
  {error && (
94
- <p className={`p-p--small tc-red-500 w100 ${styles.error}`}>
98
+ <p
99
+ id={`${uniqueId}-error`}
100
+ className={`p-p--small tc-red-500 w100 ${styles.error}`}
101
+ >
95
102
  {error}
96
103
  </p>
97
104
  )}
@@ -5,6 +5,7 @@ import styles from './style.module.scss';
5
5
  import { FileIcon, Trash2Icon, EyeVisionIcon } from '../../icon/icons';
6
6
  import { Color } from '../../../models/styles';
7
7
  import { UploadStatus, UploadedFile } from '../types';
8
+ import { Button } from '../../button';
8
9
 
9
10
  interface Props {
10
11
  uploadStatus: UploadStatus;
@@ -94,35 +95,40 @@ const UploadFileCell: React.FC<Props> = ({
94
95
  ) : (
95
96
  <>
96
97
  {isComplete && (
97
- <a
98
- className={styles['view-icon']}
98
+ <Button
99
+ as="a"
99
100
  href={previewUrl}
100
101
  target="_blank"
101
102
  rel="noopener noreferrer"
103
+ hideLabel
104
+ variant="filledWhite"
105
+ className={classnames('mr16', styles.button)}
106
+ leftIcon={
107
+ <EyeVisionIcon noMargin color={'grey-500'} size={24} />
108
+ }
102
109
  >
103
- <EyeVisionIcon
104
- color={'grey-500'}
105
- size={24}
106
- className={styles.icon}
107
- />
108
- </a>
110
+ Preview file
111
+ </Button>
109
112
  )}
110
113
 
111
114
  {onRemoveFile && (
112
- <button
113
- type="button"
115
+ <Button
114
116
  onClick={() => onRemoveFile(id)}
115
- className={classnames(styles['remove-icon'], {
116
- [styles.disabled]: uploading,
117
- })}
117
+ disabled={uploading}
118
118
  data-testid="remove-button"
119
+ className={styles.button}
120
+ leftIcon={
121
+ <Trash2Icon
122
+ color={hasError ? 'red-500' : 'grey-500'}
123
+ size={24}
124
+ noMargin
125
+ />
126
+ }
127
+ hideLabel
128
+ variant="filledWhite"
119
129
  >
120
- <Trash2Icon
121
- color={hasError ? 'red-500' : 'grey-500'}
122
- size={24}
123
- className={styles.icon}
124
- />
125
- </button>
130
+ Delete file
131
+ </Button>
126
132
  )}
127
133
  </>
128
134
  )}
@@ -27,10 +27,6 @@
27
27
  align-items: center;
28
28
  }
29
29
 
30
- .icon {
31
- margin: 0px;
32
- }
33
-
34
30
  .main-icon {
35
31
  margin-right: 16px;
36
32
  }
@@ -64,39 +60,25 @@
64
60
 
65
61
  .cell-right-section {
66
62
  display: flex;
67
- justify-content: flex-end;
68
- min-width: 32px;
69
- margin-left: 16px;
70
63
  }
71
64
 
72
65
  .cell-right-section-complete {
73
66
  min-width: 64px;
74
67
  }
75
68
 
76
- .view-icon,
77
- .remove-icon {
78
- cursor: pointer;
79
- background: none;
80
- border: none;
81
- padding: 0;
82
- margin: 0;
83
- color: inherit;
84
- text-align: inherit;
85
- outline: none;
86
- box-shadow: none;
87
- appearance: none;
88
- -webkit-appearance: none;
89
- -moz-appearance: none;
90
- }
69
+ .button {
70
+ width: 32px;
91
71
 
92
- .remove-icon {
93
- margin-left: 16px;
94
- }
72
+ div span span {
73
+ min-width: 24px !important;
74
+ height: 24px !important;
75
+ }
95
76
 
96
- .disabled {
97
- pointer-events: none;
98
- cursor: default;
99
- opacity: 0.3;
77
+ &:focus-visible {
78
+ outline: 2px solid $ds-grey-900;
79
+ border-radius: 2px;
80
+ outline-offset: 2px;
81
+ }
100
82
  }
101
83
 
102
84
  @keyframes appear-down {
@@ -10,6 +10,7 @@ import {
10
10
  formatAcceptFileList,
11
11
  getErrorMessage,
12
12
  getFormattedAcceptObject,
13
+ getStatusMessage,
13
14
  getUploadStatus,
14
15
  } from './utils';
15
16
 
@@ -48,6 +49,7 @@ const MultiDropzone = ({
48
49
  textOverrides,
49
50
  }: MultiDropzoneProps) => {
50
51
  const [errors, setErrors] = useState<ErrorMessage[]>([]);
52
+ const [statusMessage, setStatusMessage] = useState('');
51
53
  const formattedAccept = getFormattedAcceptObject(accept);
52
54
  const fileList = formatAcceptFileList(formattedAccept);
53
55
  const placeholder = getPlaceholder(textOverrides, accept, maxSize);
@@ -60,6 +62,15 @@ const MultiDropzone = ({
60
62
  (acceptedFiles: File[], filesRejected: FileRejection[]) => {
61
63
  onFileSelect(acceptedFiles);
62
64
 
65
+ const messageForScreenReader = getStatusMessage({
66
+ acceptedFiles,
67
+ filesRejected,
68
+ fileList,
69
+ maxSize,
70
+ textOverrides,
71
+ });
72
+ setStatusMessage(messageForScreenReader);
73
+
63
74
  setErrors((previousErrors) => [
64
75
  ...previousErrors,
65
76
  ...filesRejected.map(({ errors }) => ({
@@ -93,10 +104,10 @@ const MultiDropzone = ({
93
104
  )}
94
105
  {...getRootProps()}
95
106
  >
96
- <input
97
- data-testid="ds-drop-input"
98
- {...getInputProps()}
99
- />
107
+ <div className="sr-only" aria-live="polite" aria-atomic="true">
108
+ {statusMessage}
109
+ </div>
110
+ <input data-testid="ds-drop-input" {...getInputProps()} />
100
111
  <UploadCloudIcon
101
112
  className={isCondensed ? styles.img : ''}
102
113
  size={isCondensed ? 24 : 64}
@@ -151,7 +162,8 @@ const MultiDropzone = ({
151
162
 
152
163
  <AnimateHeight duration={300} height={isOverMaxFiles ? 'auto' : 0}>
153
164
  <p className="tc-red-500 mt16">
154
- {textOverrides?.tooManyFilesError || `You can upload maximum ${maxFiles} files.`}
165
+ {textOverrides?.tooManyFilesError ||
166
+ `You can upload maximum ${maxFiles} files.`}
155
167
  </p>
156
168
  </AnimateHeight>
157
169
  </div>
@@ -1,4 +1,5 @@
1
1
  @use '../../scss/public/grid' as *;
2
+ @use "../../scss/public/colors" as *;
2
3
 
3
4
  .container {
4
5
  background-color: transparent;
@@ -10,6 +11,17 @@
10
11
  background-color: white;
11
12
 
12
13
  transition: all 0.6s ease-in-out;
14
+
15
+ &:focus-visible {
16
+ outline: 2px solid $ds-grey-900;
17
+ border-radius: 2px;
18
+ outline-offset: 2px;
19
+ }
20
+
21
+ &:hover {
22
+ background-color: var(--ds-primary-100);
23
+ transition: 0.5s ease;
24
+ }
13
25
  }
14
26
 
15
27
  .img {
@@ -22,15 +34,6 @@
22
34
  display: inline-flex;
23
35
  }
24
36
 
25
- .dropzoneContainer:focus {
26
- outline: none;
27
- }
28
-
29
- .dropzoneContainer:hover {
30
- background-color: var(--ds-primary-100);
31
- transition: 0.5s ease;
32
- }
33
-
34
37
  .dropzoneContainerDisabled {
35
38
  pointer-events: none;
36
39
  opacity: 0.4;