Skip to content

Commit

Permalink
chore: esm import fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Apr 26, 2024
1 parent a772f77 commit 58cab48
Show file tree
Hide file tree
Showing 19 changed files with 284 additions and 386 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/utils/ImageUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {base64UriValidationRegex} from '../regexes';
import {base64UriValidationRegex} from '../regexes'

export const calculateAspectRatio = (width: number, height: number): number => {
return width / height
Expand Down
36 changes: 18 additions & 18 deletions packages/core/src/utils/TypeUtils.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
export const isBoolean = (value: unknown): boolean => {
if (typeof value === 'boolean') {
return true
} else if (typeof value === 'string') {
const lowercaseValue = value.toLowerCase()
return lowercaseValue === 'true' || lowercaseValue === 'false'
} else {
return false
}
if (typeof value === 'boolean') {
return true
} else if (typeof value === 'string') {
const lowercaseValue = value.toLowerCase()
return lowercaseValue === 'true' || lowercaseValue === 'false'
} else {
return false
}
}

export const parseToBoolean = (value: unknown): boolean | null => {
if (typeof value === 'boolean') {
return value
} else if (typeof value === 'string') {
const lowercaseValue = value.toLowerCase()
if (lowercaseValue === 'true') {
return true
} else if (lowercaseValue === 'false') {
return false
}
if (typeof value === 'boolean') {
return value
} else if (typeof value === 'string') {
const lowercaseValue = value.toLowerCase()
if (lowercaseValue === 'true') {
return true
} else if (lowercaseValue === 'false') {
return false
}
}

return null
return null
}
2 changes: 1 addition & 1 deletion packages/ssi-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@sphereon/ui-components.core": "workspace:*",
"@tanstack/react-table": "^8.9.3",
"react-json-tree": "^0.18.0",
"react-loader-spinner": "^5.4.5",
"react-loader-spinner": "^6.1.6",
"react-select": "^5.8.0",
"react-toastify": "^9.1.3",
"uint8arrays": "^3.1.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Props = {
}

const ImageIcon: FC<Props> = (props: Props): ReactElement => {
const {width = 38, height = 30, color = fontColors.dark, style} = props
const {width = 38, height = 30, color = fontColors.dark, style} = props

return (
<div style={{...style, width, height, display: 'flex'}}>
Expand Down
15 changes: 4 additions & 11 deletions packages/ssi-react/src/components/fields/ComboBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@ type InlineOption = {
}

const ComboBox = <T extends ComboBoxOption>(props: Props<T>): ReactElement => {
const {
onChange,
noOptionsMessage,
placeholder,
defaultValue,
inlineOption,
options = []
} = props
const {onChange, noOptionsMessage, placeholder, defaultValue, inlineOption, options = []} = props
const [value, setValue] = React.useState<T | undefined>(props.value)

const creatableProps = inlineOption
Expand All @@ -46,8 +39,8 @@ const ComboBox = <T extends ComboBoxOption>(props: Props<T>): ReactElement => {
: {}

const onValueChange = async (newValue: any): Promise<void> => {
setValue(newValue)
await onChange?.(newValue)
setValue(newValue)
await onChange?.(newValue)
}

return (
Expand All @@ -68,7 +61,7 @@ const ComboBox = <T extends ComboBoxOption>(props: Props<T>): ReactElement => {
}),
menu: (provided: CSSObjectWithLabel) => ({
...provided,
maxWidth: 455
maxWidth: 455,
}),
option: (provided: CSSObjectWithLabel, state) => ({
...provided,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, {FC} from 'react'

import {elementColors} from '@sphereon/ui-components.core'
// @ts-ignore
import {Oval} from "react-loader-spinner";
import {Oval} from 'react-loader-spinner'

interface Props {
size?: string | number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
CredentialIssuanceWizardViewEvidenceContainerStyled as EvidenceContainer,
CredentialIssuanceWizardViewEvidenceContentContainerStyled as EvidenceContentContainer,
CredentialIssuanceWizardViewEvidenceTitleContainerStyled as EvidenceTitleContainer,
SSITextH2SemiBoldStyled as EvidenceTitle,
SSITextH2SemiBoldStyled as EvidenceTitle,
CredentialIssuanceWizardViewEvidenceTitleOptionalStyled as EvidenceTitleOptional,
SSITextH2Styled as EvidenceDescription,
CredentialIssuanceWizardViewEvidenceFilesContainerStyled as EvidenceFilesContainer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@ export type CredentialMiniCardViewProps = {
}

const CredentialMiniCardView: FC<CredentialMiniCardViewProps> = (props: CredentialMiniCardViewProps): ReactElement => {
const {
backgroundColor = credentialCardColors.default,
backgroundImage,
logo,
logoColor,
style
} = props
const {backgroundColor = credentialCardColors.default, backgroundImage, logo, logoColor, style} = props

return (
<Container style={{...style, backgroundColor}}>
Expand Down
110 changes: 47 additions & 63 deletions packages/ssi-react/src/components/views/CredentialViewItem/index.tsx
Original file line number Diff line number Diff line change
@@ -1,76 +1,60 @@
import {CSSProperties, FC, ReactElement} from 'react'
import {
CredentialStatus,
Localization,
toLocalDateString,
toLocalDateTimeString
} from '@sphereon/ui-components.core'
import {CredentialStatus, Localization, toLocalDateString, toLocalDateTimeString} from '@sphereon/ui-components.core'
import SSIStatusLabel from '../../labels/SSIStatusLabel/index.js'
import CredentialMiniCardView, {CredentialMiniCardViewProps} from '../CredentialMiniCardView/index.js';
import CredentialMiniCardView, {CredentialMiniCardViewProps} from '../CredentialMiniCardView/index.js'
import {
CredentialViewItemContainerStyled as Container,
CredentialViewItemDetailsContainerStyled as DetailsContainer,
SSIFlexDirectionRowViewStyled as ContentRowContainer,
CredentialViewItemTitleCaptionStyled as TitleCaption,
SSITextH4Styled as IssuerCaption,
CredentialViewItemStatusContainerStyled as StatusContainer,
SSITextH5Styled as IssueDateCaption,
CredentialViewItemExpirationDateCaptionStyled as ExpirationDateCaption,
} from '../../../styles/index.js';
CredentialViewItemContainerStyled as Container,
CredentialViewItemDetailsContainerStyled as DetailsContainer,
SSIFlexDirectionRowViewStyled as ContentRowContainer,
CredentialViewItemTitleCaptionStyled as TitleCaption,
SSITextH4Styled as IssuerCaption,
CredentialViewItemStatusContainerStyled as StatusContainer,
SSITextH5Styled as IssueDateCaption,
CredentialViewItemExpirationDateCaptionStyled as ExpirationDateCaption,
} from '../../../styles/index.js'

type Props = {
credentialTitle: string
credentialStatus: CredentialStatus
issuerName: string
issueDate: number
expirationDate?: number
showTime?: boolean
showCard?: boolean
credentialBranding?: CredentialMiniCardViewProps
style?: CSSProperties
credentialTitle: string
credentialStatus: CredentialStatus
issuerName: string
issueDate: number
expirationDate?: number
showTime?: boolean
showCard?: boolean
credentialBranding?: CredentialMiniCardViewProps
style?: CSSProperties
}

const CredentialViewItem: FC<Props> = (props: Props): ReactElement => {
const {
credentialStatus,
credentialTitle,
issuerName,
showTime = false,
showCard = true,
credentialBranding,
style
} = props
const {credentialStatus, credentialTitle, issuerName, showTime = false, showCard = true, credentialBranding, style} = props

const issueDate = showTime ? toLocalDateTimeString(props.issueDate) : toLocalDateString(props.issueDate)
const expirationDate = props.expirationDate
? `${Localization.translate('credentials_view_item_expires_on')} ${showTime
? toLocalDateTimeString(props.expirationDate)
: toLocalDateString(props.expirationDate)
}`
: Localization.translate('credential_status_never_expires_date_label')
const issueDate = showTime ? toLocalDateTimeString(props.issueDate) : toLocalDateString(props.issueDate)
const expirationDate = props.expirationDate
? `${Localization.translate('credentials_view_item_expires_on')} ${
showTime ? toLocalDateTimeString(props.expirationDate) : toLocalDateString(props.expirationDate)
}`
: Localization.translate('credential_status_never_expires_date_label')

return (
<Container style={{...style}}>
{ showCard &&
<CredentialMiniCardView {...credentialBranding}/>
}
<DetailsContainer>
<ContentRowContainer>
<div>
<TitleCaption>{credentialTitle}</TitleCaption>
<IssuerCaption>{issuerName}</IssuerCaption>
</div>
<StatusContainer>
<SSIStatusLabel status={credentialStatus}/>
</StatusContainer>
</ContentRowContainer>
<ContentRowContainer>
<IssueDateCaption>{issueDate}</IssueDateCaption>
<ExpirationDateCaption>{expirationDate}</ExpirationDateCaption>
</ContentRowContainer>
</DetailsContainer>
</Container>
)
return (
<Container style={{...style}}>
{showCard && <CredentialMiniCardView {...credentialBranding} />}
<DetailsContainer>
<ContentRowContainer>
<div>
<TitleCaption>{credentialTitle}</TitleCaption>
<IssuerCaption>{issuerName}</IssuerCaption>
</div>
<StatusContainer>
<SSIStatusLabel status={credentialStatus} />
</StatusContainer>
</ContentRowContainer>
<ContentRowContainer>
<IssueDateCaption>{issueDate}</IssueDateCaption>
<ExpirationDateCaption>{expirationDate}</ExpirationDateCaption>
</ContentRowContainer>
</DetailsContainer>
</Container>
)
}

export default CredentialViewItem
Loading

0 comments on commit 58cab48

Please sign in to comment.