@sphereon/ui-components.ssi-react 0.3.1-next.23 → 0.3.1-next.37

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.
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import SSILogo from '../../assets/logos/SSILogo';
3
3
  import { ContactViewItemContactDetailsContainerStyled as ContactDetailsContainer, SSITextH3Styled as ContactNameCaption, SSITextH4Styled as ContactRolesCaption, ContactViewItemContactUriCaptionStyled as ContactUriCaption, ContactViewItemContainerStyled as Container, ContactViewItemLogoContainerStyled as LogoContainer, ContactViewItemNewStatusContainerStyled as StatusContainer, } from '../../../styles';
4
- import { fontColors } from "@sphereon/ui-components.core";
4
+ import { fontColors } from '@sphereon/ui-components.core';
5
5
  const ContactViewItem = (props) => {
6
6
  const { name, uri, roles, logo } = props;
7
7
  return (_jsxs(Container, { children: [_jsx(StatusContainer, {}), _jsx(LogoContainer, { children: _jsx(SSILogo, { logo: logo, color: fontColors.dark }) }), _jsxs("div", { children: [_jsxs(ContactDetailsContainer, { children: [_jsx(ContactNameCaption, { children: name }), _jsx(ContactRolesCaption, { children: roles.join(', ') })] }), _jsx(ContactUriCaption, { children: uri })] })] }));
@@ -1,4 +1,4 @@
1
- import { CSSProperties, FC } from 'react';
1
+ import { CSSProperties, ReactElement } from 'react';
2
2
  import { JsonFormsCellRendererRegistryEntry, JsonFormsRendererRegistryEntry, JsonSchema, Middleware, UISchemaElement, ValidationMode } from '@jsonforms/core';
3
3
  import { JSONFormState } from '../../../types';
4
4
  import Ajv from 'ajv';
@@ -16,5 +16,5 @@ type Props<DataType = Record<any, any>> = {
16
16
  readonly?: boolean;
17
17
  config?: any;
18
18
  };
19
- declare const FormView: FC<Props>;
19
+ declare const FormView: (props: Props) => ReactElement;
20
20
  export default FormView;
@@ -1,12 +1,57 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
2
3
  import { JsonForms } from '@jsonforms/react';
3
4
  import { materialCells } from '@jsonforms/material-renderers';
4
5
  import { jsonFormsMaterialRenderers } from '../../../renders/jsonFormsRenders';
6
+ import { formatDateToISO } from '../../../helpers';
7
+ const initializeDefaultValues = (schema, currentData = {}) => {
8
+ const result = { ...currentData };
9
+ if (!schema.properties) {
10
+ return result;
11
+ }
12
+ Object.entries(schema.properties).forEach(([key, property]) => {
13
+ if (typeof property === 'object') {
14
+ if (property.const && (!(key in result) || !result[key])) {
15
+ result[key] = property.const;
16
+ }
17
+ if (property.default && (!(key in result) || !result[key])) {
18
+ if (property.format?.startsWith('date') || property.format?.startsWith('time')) {
19
+ result[key] = formatDateToISO(property.default, property.format);
20
+ }
21
+ else {
22
+ result[key] = property.default;
23
+ }
24
+ }
25
+ if (property.properties) {
26
+ if (!result[key]) {
27
+ result[key] = {};
28
+ }
29
+ result[key] = initializeDefaultValues(property, result[key]);
30
+ }
31
+ }
32
+ });
33
+ return result;
34
+ };
5
35
  const FormView = (props) => {
6
36
  const { data, schema, uiSchema, validationMode = 'ValidateAndShow', renderers = jsonFormsMaterialRenderers, cells = materialCells, style, middleware, ajv, onFormStateChange, readonly = false, config, } = props;
37
+ const [formData, setFormData] = useState(data ?? {});
38
+ useEffect(() => {
39
+ const initializedData = initializeDefaultValues(schema, formData);
40
+ setFormData(initializedData);
41
+ }, [schema]);
7
42
  const onFormStateChanged = (state) => {
8
- void onFormStateChange?.(state);
43
+ const updatedData = initializeDefaultValues(schema, state.data);
44
+ if (JSON.stringify(updatedData) !== JSON.stringify(state.data)) {
45
+ setFormData(updatedData);
46
+ void onFormStateChange?.({
47
+ ...state,
48
+ data: updatedData,
49
+ });
50
+ }
51
+ else {
52
+ void onFormStateChange?.(state);
53
+ }
9
54
  };
10
- return (_jsx("div", { style: style, children: _jsx(JsonForms, { schema: schema, uischema: uiSchema, data: data, renderers: renderers, cells: cells, onChange: onFormStateChanged, validationMode: validationMode, middleware: middleware, ajv: ajv, readonly: readonly, config: config }) }));
55
+ return (_jsx("div", { style: style, children: _jsx(JsonForms, { schema: schema, uischema: uiSchema, data: formData, renderers: renderers, cells: cells, onChange: onFormStateChanged, validationMode: validationMode, middleware: middleware, ajv: ajv, readonly: readonly, config: config }) }));
11
56
  };
12
57
  export default FormView;
@@ -17,9 +17,8 @@ const SSICredentialCardView = (props) => {
17
17
  };
18
18
  return (_jsx(Container, { style: { backgroundColor }, children: _jsx(BackgroundImage, { style: {
19
19
  ...(backgroundImage?.uri && { background: `url(${backgroundImage.uri})`, backgroundSize: 'cover' }),
20
- }, children: _jsxs(AlphaContainer, { children: [header && (_jsxs(HeaderContainer, { children: [(!backgroundImage || logo) && (_jsx(LogoContainer, { children: _jsx(SSILogo, { logo: logo, color: textColor }) })), credentialTitle && (_jsxs(TitleContainer, { children: [_jsx(CredentialTitleText, { style: { color: textColor }, children: credentialTitle }), credentialSubtitle && _jsx(CredentialSubtitleText, { style: { color: textColor }, children: credentialSubtitle })] }))] })), body && (_jsx(ContentMainContainer, { children: _jsxs(ContentSubContainer, { children: [issuerName && (_jsx(IssueNameContainer, { children: _jsx(H4Text, { style: { color: textColor }, children: issuerName }) })), properties && _jsx(PropertiesContainer, { children: getPropertyElementsFrom(properties) })] }) })), footer && (_jsxs(FooterContainer, { children: [showExpirationDate &&
21
- _jsx(ExpirationDateText, { style: { color: textColor }, children: expirationDate
22
- ? `${Localization.translate('credential_card_expires_message')} ${toLocalDateString(expirationDate)}`
23
- : Localization.translate('credential_status_never_expires_date_label') }), credentialStatus && (_jsx(StatusContainer, { children: credentialStatus && _jsx(SSIStatusLabel, { status: credentialStatus, color: textColor }) }))] }))] }) }) }));
20
+ }, children: _jsxs(AlphaContainer, { children: [header && (_jsxs(HeaderContainer, { children: [(!backgroundImage || logo) && (_jsx(LogoContainer, { children: _jsx(SSILogo, { logo: logo, color: textColor }) })), credentialTitle && (_jsxs(TitleContainer, { children: [_jsx(CredentialTitleText, { style: { color: textColor }, children: credentialTitle }), credentialSubtitle && _jsx(CredentialSubtitleText, { style: { color: textColor }, children: credentialSubtitle })] }))] })), body && (_jsx(ContentMainContainer, { children: _jsxs(ContentSubContainer, { children: [issuerName && (_jsx(IssueNameContainer, { children: _jsx(H4Text, { style: { color: textColor }, children: issuerName }) })), properties && _jsx(PropertiesContainer, { children: getPropertyElementsFrom(properties) })] }) })), footer && (_jsxs(FooterContainer, { children: [showExpirationDate && (_jsx(ExpirationDateText, { style: { color: textColor }, children: expirationDate
21
+ ? `${Localization.translate('credential_card_expires_message')} ${toLocalDateString(expirationDate)}`
22
+ : Localization.translate('credential_status_never_expires_date_label') })), credentialStatus && (_jsx(StatusContainer, { children: credentialStatus && _jsx(SSIStatusLabel, { status: credentialStatus, color: textColor }) }))] }))] }) }) }));
24
23
  };
25
24
  export default SSICredentialCardView;
@@ -0,0 +1,3 @@
1
+ export type DateFormat = 'date-time' | 'date' | 'time' | undefined;
2
+ export declare const formatDate: (dateString?: string, format?: DateFormat) => string;
3
+ export declare const formatDateToISO: (dateString?: string, format?: DateFormat) => string;
@@ -0,0 +1,45 @@
1
+ export const formatDate = (dateString, format = 'date-time') => {
2
+ const userDateTimeOpts = Intl.DateTimeFormat().resolvedOptions();
3
+ if (!dateString) {
4
+ return '';
5
+ }
6
+ const date = dateString === 'now' ? new Date() : new Date(dateString);
7
+ if (isNaN(date.getTime())) {
8
+ console.error('Invalid date:', dateString);
9
+ return 'Invalid date';
10
+ }
11
+ const formatOptions = {
12
+ timeZone: userDateTimeOpts.timeZone,
13
+ };
14
+ if (format === 'date-time') {
15
+ formatOptions.dateStyle = 'short';
16
+ formatOptions.timeStyle = 'short';
17
+ }
18
+ else if (format === 'date') {
19
+ formatOptions.dateStyle = 'short';
20
+ }
21
+ else if (format === 'time') {
22
+ formatOptions.timeStyle = 'short';
23
+ }
24
+ return new Intl.DateTimeFormat(userDateTimeOpts.locale, formatOptions).format(date);
25
+ };
26
+ export const formatDateToISO = (dateString, format = 'date-time') => {
27
+ if (!dateString) {
28
+ return '';
29
+ }
30
+ const date = dateString === 'now' ? new Date() : new Date(dateString);
31
+ if (isNaN(date.getTime())) {
32
+ console.error('Invalid date:', dateString);
33
+ return 'Invalid date';
34
+ }
35
+ const isoString = date.toISOString();
36
+ if (format === 'date-time') {
37
+ return isoString.slice(0, 19).replace('T', ' ');
38
+ }
39
+ else if (format === 'date') {
40
+ return isoString.slice(0, 10);
41
+ }
42
+ else {
43
+ return isoString.slice(11, 19);
44
+ }
45
+ };
@@ -1 +1,2 @@
1
+ export * from './DateHelper';
1
2
  export * from './toastHelper';
@@ -1 +1,2 @@
1
+ export * from './DateHelper';
1
2
  export * from './toastHelper';
package/dist/index.d.ts CHANGED
@@ -52,4 +52,4 @@ export * from './styles/fonts';
52
52
  export * from './types';
53
53
  export * from './helpers';
54
54
  export * from './utils';
55
- export { SSICredentialCardView, CredentialMiniCardView, CredentialMiniCardViewProps, SSIStatusLabel, SSICheckmarkBadge, SSIExclamationMarkBadge, SSIPlaceholderLogo, SSILogo, SSIAddIcon, SSIFilterIcon, SSIArrowDownIcon, SSITypeLabel, IconButton, PrimaryButton, SecondaryButton, DropDownList, SSITableView, SSITableViewHeader, SSITabView, SSITabViewHeader, SSIProfileIcon, SSIToastContainer, SSICheckbox, SSIActivityIndicator, SSIHoverText, StepMarker, ProgressStepIndicator, PaginationControls, PaginationControlsProps, Row, DocumentIcon, CrossIcon, ImageIcon, MeatBallsIcon, PencilIcon, ViewIcon, CopyIcon, DeleteIcon, FileSelection, ComboBox, DragAndDropBox, PersonPlaceholder, PassportPhotoControl, passportPhotoControlTester, CredentialIssuanceWizardView, CredentialViewItem, JSONDataView, TextInputField, WarningImage, FormView, InformationRequestView, ContactViewItem };
55
+ export { SSICredentialCardView, CredentialMiniCardView, CredentialMiniCardViewProps, SSIStatusLabel, SSICheckmarkBadge, SSIExclamationMarkBadge, SSIPlaceholderLogo, SSILogo, SSIAddIcon, SSIFilterIcon, SSIArrowDownIcon, SSITypeLabel, IconButton, PrimaryButton, SecondaryButton, DropDownList, SSITableView, SSITableViewHeader, SSITabView, SSITabViewHeader, SSIProfileIcon, SSIToastContainer, SSICheckbox, SSIActivityIndicator, SSIHoverText, StepMarker, ProgressStepIndicator, PaginationControls, PaginationControlsProps, Row, DocumentIcon, CrossIcon, ImageIcon, MeatBallsIcon, PencilIcon, ViewIcon, CopyIcon, DeleteIcon, FileSelection, ComboBox, DragAndDropBox, PersonPlaceholder, PassportPhotoControl, passportPhotoControlTester, CredentialIssuanceWizardView, CredentialViewItem, JSONDataView, TextInputField, WarningImage, FormView, InformationRequestView, ContactViewItem, };
package/dist/index.js CHANGED
@@ -51,4 +51,4 @@ export * from './styles/fonts';
51
51
  export * from './types';
52
52
  export * from './helpers';
53
53
  export * from './utils';
54
- export { SSICredentialCardView, CredentialMiniCardView, SSIStatusLabel, SSICheckmarkBadge, SSIExclamationMarkBadge, SSIPlaceholderLogo, SSILogo, SSIAddIcon, SSIFilterIcon, SSIArrowDownIcon, SSITypeLabel, IconButton, PrimaryButton, SecondaryButton, DropDownList, SSITableView, SSITableViewHeader, SSITabView, SSITabViewHeader, SSIProfileIcon, SSIToastContainer, SSICheckbox, SSIActivityIndicator, SSIHoverText, StepMarker, ProgressStepIndicator, PaginationControls, PaginationControlsProps, DocumentIcon, CrossIcon, ImageIcon, MeatBallsIcon, PencilIcon, ViewIcon, CopyIcon, DeleteIcon, FileSelection, ComboBox, DragAndDropBox, PersonPlaceholder, PassportPhotoControl, passportPhotoControlTester, CredentialIssuanceWizardView, CredentialViewItem, JSONDataView, TextInputField, WarningImage, FormView, InformationRequestView, ContactViewItem };
54
+ export { SSICredentialCardView, CredentialMiniCardView, SSIStatusLabel, SSICheckmarkBadge, SSIExclamationMarkBadge, SSIPlaceholderLogo, SSILogo, SSIAddIcon, SSIFilterIcon, SSIArrowDownIcon, SSITypeLabel, IconButton, PrimaryButton, SecondaryButton, DropDownList, SSITableView, SSITableViewHeader, SSITabView, SSITabViewHeader, SSIProfileIcon, SSIToastContainer, SSICheckbox, SSIActivityIndicator, SSIHoverText, StepMarker, ProgressStepIndicator, PaginationControls, PaginationControlsProps, DocumentIcon, CrossIcon, ImageIcon, MeatBallsIcon, PencilIcon, ViewIcon, CopyIcon, DeleteIcon, FileSelection, ComboBox, DragAndDropBox, PersonPlaceholder, PassportPhotoControl, passportPhotoControlTester, CredentialIssuanceWizardView, CredentialViewItem, JSONDataView, TextInputField, WarningImage, FormView, InformationRequestView, ContactViewItem, };
@@ -19,5 +19,5 @@ export const ContactViewItemContactDetailsContainerStyled = styled.div `
19
19
  margin-bottom: 6px;
20
20
  `;
21
21
  export const ContactViewItemContactUriCaptionStyled = styled(SSITextH5Styled) `
22
- color: #4F4F4F;
22
+ color: #4f4f4f;
23
23
  `;
@@ -7,6 +7,16 @@ export const DropDownListItemContainerStyled = styled(SSIFlexDirectionRowViewSty
7
7
  align-items: center;
8
8
  background-color: ${backgroundColors.primaryLight};
9
9
  padding: 10px 16px;
10
+ cursor: pointer;
11
+ transition: background-color 0.2s ease;
12
+
13
+ &:hover {
14
+ background-color: ${backgroundColors.lightGrey};
15
+ }
16
+
17
+ &:active {
18
+ background-color: ${backgroundColors.secondaryLight};
19
+ }
10
20
  `;
11
21
  export const DropDownListItemCaptionContainerStyled = styled(SSITextH2Styled) `
12
22
  flex: 1;
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.3.1-next.23+ef3d35e",
4
+ "version": "0.3.1-next.37+971d5d7",
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,8 +40,8 @@
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/ssi-sdk.data-store": "0.29.1-next.47",
44
- "@sphereon/ui-components.core": "0.3.1-next.23+ef3d35e",
43
+ "@sphereon/ssi-sdk.data-store": "0.30.2-next.273",
44
+ "@sphereon/ui-components.core": "0.3.1-next.37+971d5d7",
45
45
  "@tanstack/react-table": "^8.9.3",
46
46
  "react-json-tree": "^0.18.0",
47
47
  "react-loader-spinner": "5.4.5",
@@ -59,5 +59,5 @@
59
59
  "peerDependencies": {
60
60
  "react": ">= 18"
61
61
  },
62
- "gitHead": "ef3d35e9e76df912ca20db6708930f80226f49a6"
62
+ "gitHead": "971d5d76d6ade8f3eced3a278c3ba6dec57c1d6c"
63
63
  }