@sphereon/ui-components.ssi-react 0.1.3-unstable.144 → 0.1.3-unstable.145

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.
@@ -9,7 +9,7 @@ const ComboBox = (props) => {
9
9
  isValidNewOption: () => true,
10
10
  onCreateOption: inlineOption.onCreate,
11
11
  createOptionPosition: 'last',
12
- formatCreateLabel: (inputValue) => `${inlineOption.caption}`,
12
+ formatCreateLabel: () => `${inlineOption.caption}`,
13
13
  }
14
14
  : {};
15
15
  return (_jsx(CreatableSelect, { styles: {
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { getFileSizeDisplay, Localization } from '@sphereon/ui-components.core';
2
3
  import ComboBox from '../ComboBox';
3
4
  import DocumentIcon from '../../assets/icons/DocumentIcon';
4
5
  import ImageIcon from '../../assets/icons/ImageIcon';
@@ -6,23 +7,9 @@ import CrossIcon from '../../assets/icons/CrossIcon';
6
7
  import { FileSelectionFieldContainerStyled as Container, FileSelectionFieldContentContainerStyled as ContentContainer, FileSelectionFieldRemoveContainerStyled as RemoveContainer, FileSelectionFieldRemoveButtonStyled as RemoveButton, FileSelectionFieldRemoveButtonCircleIconStyled as RemoveButtonCircleIcon, FileSelectionFieldIconContainerStyled as IconContainer, FileSelectionFieldFileDataContainerStyled as FileDataContainer, FileSelectionFieldFileNameCaptionStyled as FileNameCaption, FileSelectionFieldFileSizeCaptionStyled as FileSizeCaption, FileSelectionFieldPermissionSelectionContainerStyled as PermissionSelectionContainer } from '../../../styles';
7
8
  import { FileSelectionFieldType } from '../../../types';
8
9
  const filePermissions = [
9
- { label: 'Public', value: 'public' },
10
- { label: 'Private', value: 'private' },
10
+ { label: Localization.translate('file_permission_public_label'), value: 'public' },
11
+ { label: Localization.translate('file_permission_private_label'), value: 'private' },
11
12
  ];
12
- const getFileSizeDisplay = (bytes) => {
13
- if (bytes < 1024) {
14
- return `${bytes} B`;
15
- }
16
- else if (bytes <= 1024 * 1024) {
17
- return `${(bytes / 1024).toFixed(1)} KB`;
18
- }
19
- else if (bytes <= 1024 * 1024 * 1024) {
20
- return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
21
- }
22
- else {
23
- return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
24
- }
25
- };
26
13
  const FileSelection = (props) => {
27
14
  const { file, fileType = FileSelectionFieldType.FILE, permission, onPermissionChange, onRemove, style } = props;
28
15
  const onChange = async (selection) => {
@@ -2,24 +2,24 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { and, isObjectControl, optionIs, rankWith, } from '@jsonforms/core';
4
4
  import { withJsonFormsControlProps } from '@jsonforms/react';
5
- import { base64toFile, Localization } from '@sphereon/ui-components.core';
5
+ import { Localization, parseBase64Uri } from '@sphereon/ui-components.core';
6
6
  import DragAndDropBox from '../../DragAndDropBox';
7
7
  import PersonPlaceholder from '../../../assets/placeholders/PersonPlaceholder';
8
8
  import FileSelection from '../../FileSelection';
9
+ import { base64UriToFile } from '../../../../utils';
9
10
  import { PassportPhotoControlContainerStyled as Container, PassportPhotoControlDragAndDropBoxContainerStyled as DragAndDropBoxContainer, PassportPhotoControlPassportPhotoContainerStyled as PassportPhotoContainer, PassportPhotoControlPassportPhotoImageStyled as PassportPhotoImage } from '../../../../styles';
10
11
  import { FileSelectionFieldType } from '../../../../types';
11
12
  const PassportPhotoControl = (props) => {
12
13
  const { data, handleChange, path } = props;
13
- const [image, setImage] = useState(data && { file: base64toFile(data.base64, data.fileName, data.mimeType), base64: data.base64 });
14
+ const [image, setImage] = useState(data && { file: base64UriToFile(data.base64Uri, data.fileName, data.mimeType), base64Uri: data.base64Uri });
14
15
  const onAddImage = async (file) => {
15
16
  const reader = new FileReader();
16
17
  reader.onload = () => {
17
18
  const result = reader.result;
18
19
  if (typeof result === 'string') {
19
- const base64Parts = result.split(';base64,');
20
- const mimeType = base64Parts[0].replace("data:", "");
21
- setImage({ file, base64: result });
22
- handleChange(path, { fileName: file.name, mimeType, base64: result });
20
+ const parsedBase64Uri = parseBase64Uri(result);
21
+ setImage({ file, base64Uri: result });
22
+ handleChange(path, { fileName: file.name, mimeType: parsedBase64Uri.mimeType, base64Uri: result });
23
23
  }
24
24
  };
25
25
  reader.readAsDataURL(file);
@@ -29,7 +29,7 @@ const PassportPhotoControl = (props) => {
29
29
  handleChange(path, undefined);
30
30
  };
31
31
  return (_jsxs(Container, { children: [_jsxs(DragAndDropBoxContainer, { children: [_jsx(DragAndDropBox, { caption: Localization.translate('drag_and_drop_upload_image_caption'), description: Localization.translate('credential_attach_image_description'), onChangeFile: onAddImage }), _jsx(PassportPhotoContainer, { children: image
32
- ? _jsx(PassportPhotoImage, { src: image.base64, alt: Localization.translate('passport_photo_alt') })
32
+ ? _jsx(PassportPhotoImage, { src: image.base64Uri, alt: Localization.translate('passport_photo_alt') })
33
33
  : _jsx(PersonPlaceholder, {}) })] }), image &&
34
34
  _jsx(FileSelection, { file: image.file, fileType: FileSelectionFieldType.IMAGE, onRemove: onRemoveImage })] }));
35
35
  };
package/dist/index.d.ts CHANGED
@@ -40,4 +40,5 @@ import { Row } from '@tanstack/react-table';
40
40
  export * from './styles/fonts';
41
41
  export * from './types';
42
42
  export * from './helpers';
43
+ export * from './utils';
43
44
  export { SSICredentialCardView, CredentialMiniCardView, CredentialMiniCardViewProps, SSIStatusLabel, SSICheckmarkBadge, SSIExclamationMarkBadge, SSIPlaceholderLogo, SSILogo, SSIAddIcon, SSIFilterIcon, SSIArrowDownIcon, SSITypeLabel, SSIIconButton, SSIPrimaryButton, SSISecondaryButton, DropDownList, SSITableView, SSITableViewHeader, SSITabView, SSITabViewHeader, SSIProfileIcon, SSIToastContainer, SSICheckbox, SSIActivityIndicator, SSIHoverText, StepMarker, ProgressStepIndicator, PaginationControls, PaginationControlsProps, Row, DocumentIcon, CrossIcon, ImageIcon, FileSelection, ComboBox, DragAndDropBox, PersonPlaceholder, PassportPhotoControl, passportPhotoControlTester, CredentialIssuanceWizardView, };
package/dist/index.js CHANGED
@@ -38,4 +38,5 @@ import PaginationControlsProps from './components/views/SSITableView/PaginationC
38
38
  export * from './styles/fonts';
39
39
  export * from './types';
40
40
  export * from './helpers';
41
+ export * from './utils';
41
42
  export { SSICredentialCardView, CredentialMiniCardView, SSIStatusLabel, SSICheckmarkBadge, SSIExclamationMarkBadge, SSIPlaceholderLogo, SSILogo, SSIAddIcon, SSIFilterIcon, SSIArrowDownIcon, SSITypeLabel, SSIIconButton, SSIPrimaryButton, SSISecondaryButton, DropDownList, SSITableView, SSITableViewHeader, SSITabView, SSITabViewHeader, SSIProfileIcon, SSIToastContainer, SSICheckbox, SSIActivityIndicator, SSIHoverText, StepMarker, ProgressStepIndicator, PaginationControls, PaginationControlsProps, DocumentIcon, CrossIcon, ImageIcon, FileSelection, ComboBox, DragAndDropBox, PersonPlaceholder, PassportPhotoControl, passportPhotoControlTester, CredentialIssuanceWizardView, };
@@ -12,10 +12,10 @@ export declare enum FileSelectionFieldType {
12
12
  }
13
13
  export type PassportPhoto = {
14
14
  file: File;
15
- base64: string;
15
+ base64Uri: string;
16
16
  };
17
17
  export type PassportPhotoControlData = {
18
18
  fileName: string;
19
19
  mimeType: string;
20
- base64: string;
20
+ base64Uri: string;
21
21
  };
@@ -0,0 +1 @@
1
+ export declare const base64UriToFile: (base64Uri: string, filename: string, mimeType: string) => File;
@@ -0,0 +1,7 @@
1
+ import { fromString } from 'uint8arrays';
2
+ export const base64UriToFile = (base64Uri, filename, mimeType) => {
3
+ const base64 = base64Uri.split(',')[1];
4
+ const uint8Array = fromString(base64, 'base64');
5
+ const blob = new Blob([uint8Array]);
6
+ return new File([blob], filename, { type: mimeType });
7
+ };
@@ -0,0 +1 @@
1
+ export * from './FileUtils';
@@ -0,0 +1 @@
1
+ export * from './FileUtils';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sphereon/ui-components.ssi-react",
3
3
  "private": false,
4
- "version": "0.1.3-unstable.144+18cddf4",
4
+ "version": "0.1.3-unstable.145+66bd1c4",
5
5
  "description": "SSI UI components for React",
6
6
  "repository": "git@github.com:Sphereon-Opensource/UI-Components.git",
7
7
  "author": "Sphereon <dev@sphereon.com>",
@@ -40,12 +40,13 @@
40
40
  "@mui/styled-engine-sc": "^5.14.12",
41
41
  "@mui/system": "^5.15.12",
42
42
  "@mui/x-date-pickers": "^6.19.5",
43
- "@sphereon/ui-components.core": "0.1.3-unstable.144+18cddf4",
43
+ "@sphereon/ui-components.core": "0.1.3-unstable.145+66bd1c4",
44
44
  "@tanstack/react-table": "^8.9.3",
45
45
  "react-loader-spinner": "^5.4.5",
46
46
  "react-select": "^5.8.0",
47
47
  "react-toastify": "^9.1.3",
48
- "styled-components": "^5.3.3"
48
+ "styled-components": "^5.3.3",
49
+ "uint8arrays": "^3.1.1"
49
50
  },
50
51
  "devDependencies": {
51
52
  "@types/react": "~18.0.14",
@@ -57,5 +58,5 @@
57
58
  "peerDependencies": {
58
59
  "react": ">= 16.8.0"
59
60
  },
60
- "gitHead": "18cddf4c2d9265f91657a7c00d98674340ca5260"
61
+ "gitHead": "66bd1c46e40b7a5930b8f02404d2924d36954110"
61
62
  }