@sphereon/ui-components.ssi-react 0.1.3-unstable.99 → 0.2.1-unstable.2
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/dist/@config/toasts/index.d.ts +2 -3
- package/dist/components/assets/icons/{BitterballenIcon → CrossIcon}/index.d.ts +2 -2
- package/dist/components/assets/icons/CrossIcon/index.js +7 -0
- package/dist/components/assets/icons/DeleteIcon/index.d.ts +2 -1
- package/dist/components/assets/icons/DeleteIcon/index.js +2 -2
- package/dist/components/assets/icons/DocumentIcon/index.d.ts +9 -0
- package/dist/components/assets/icons/DocumentIcon/index.js +7 -0
- package/dist/components/assets/icons/ImageIcon/index.d.ts +9 -0
- package/dist/components/assets/icons/ImageIcon/index.js +7 -0
- package/dist/components/assets/icons/MeatBallsIcon/index.d.ts +9 -0
- package/dist/components/assets/icons/MeatBallsIcon/index.js +7 -0
- package/dist/components/assets/icons/SSIAddIcon/index.js +1 -1
- package/dist/components/assets/icons/SSIArrowDownIcon/index.js +1 -1
- package/dist/components/assets/icons/SSIFilterIcon/index.js +1 -1
- package/dist/components/assets/images/WarningImage/index.d.ts +8 -0
- package/dist/components/assets/images/WarningImage/index.js +6 -0
- package/dist/components/assets/placeholders/PersonPlaceholder/index.d.ts +9 -0
- package/dist/components/assets/placeholders/PersonPlaceholder/index.js +7 -0
- package/dist/components/buttons/SSIIconButton/index.d.ts +4 -3
- package/dist/components/buttons/SSIIconButton/index.js +8 -8
- package/dist/components/buttons/SSIPrimaryButton/index.js +1 -1
- package/dist/components/buttons/SSISecondaryButton/index.js +1 -1
- package/dist/components/fields/ComboBox/index.d.ts +21 -0
- package/dist/components/fields/ComboBox/index.js +51 -0
- package/dist/components/fields/DragAndDropBox/index.d.ts +8 -0
- package/dist/components/fields/DragAndDropBox/index.js +30 -0
- package/dist/components/fields/FileSelection/index.d.ts +12 -0
- package/dist/components/fields/FileSelection/index.js +33 -0
- package/dist/components/fields/JSONForms/PassportPhotoControl/index.d.ts +5 -0
- package/dist/components/fields/JSONForms/PassportPhotoControl/index.js +37 -0
- package/dist/components/fields/SSICheckbox/index.d.ts +2 -1
- package/dist/components/fields/SSICheckbox/index.js +2 -2
- package/dist/components/fields/TextInputField/index.d.ts +12 -0
- package/dist/components/fields/TextInputField/index.js +21 -0
- package/dist/components/lists/DropDownList/index.d.ts +10 -0
- package/dist/components/lists/DropDownList/index.js +34 -0
- package/dist/components/lists/DropDownListItem/index.d.ts +13 -0
- package/dist/components/lists/DropDownListItem/index.js +23 -0
- package/dist/components/views/CredentialIssuanceWizardView/index.d.ts +10 -0
- package/dist/components/views/CredentialIssuanceWizardView/index.js +43 -0
- package/dist/components/views/CredentialIssuanceWizardView/styles.css +87 -0
- package/dist/components/views/CredentialMiniCardView/index.js +1 -1
- package/dist/components/views/CredentialViewItem/index.d.ts +16 -0
- package/dist/components/views/CredentialViewItem/index.js +17 -0
- package/dist/components/views/JSONDataView/index.d.ts +8 -0
- package/dist/components/views/JSONDataView/index.js +85 -0
- package/dist/components/views/SSITabView/SSITabViewHeader/index.js +1 -1
- package/dist/components/views/SSITableView/PaginationControls/index.d.ts +8 -0
- package/dist/components/views/SSITableView/PaginationControls/index.js +9 -0
- package/dist/components/views/SSITableView/SSITableViewHeader/index.d.ts +1 -0
- package/dist/components/views/SSITableView/SSITableViewHeader/index.js +7 -5
- package/dist/components/views/SSITableView/index.d.ts +5 -2
- package/dist/components/views/SSITableView/index.js +76 -45
- package/dist/index.d.ts +18 -2
- package/dist/index.js +18 -2
- package/dist/renders/jsonFormsRenders.d.ts +2 -0
- package/dist/renders/jsonFormsRenders.js +6 -0
- package/dist/styles/components/components/CredentialIssuanceWizardView/index.d.ts +9 -0
- package/dist/styles/components/components/CredentialIssuanceWizardView/index.js +55 -0
- package/dist/styles/components/components/CredentialViewItem/index.d.ts +5 -0
- package/dist/styles/components/components/CredentialViewItem/index.js +28 -0
- package/dist/styles/components/components/DragAndDropBox/index.d.ts +4 -0
- package/dist/styles/components/components/DragAndDropBox/index.js +25 -0
- package/dist/styles/components/components/DropDownList/index.d.ts +3 -0
- package/dist/styles/components/components/DropDownList/index.js +21 -0
- package/dist/styles/components/components/DropDownListItem/index.d.ts +3 -0
- package/dist/styles/components/components/DropDownListItem/index.js +21 -0
- package/dist/styles/components/components/FileSelectionField/index.d.ts +10 -0
- package/dist/styles/components/components/FileSelectionField/index.js +64 -0
- package/dist/styles/components/components/JSONDataView/index.d.ts +7 -0
- package/dist/styles/components/components/JSONDataView/index.js +47 -0
- package/dist/styles/components/components/Pagination/index.d.ts +5 -0
- package/dist/styles/components/components/Pagination/index.js +71 -0
- package/dist/styles/components/components/PassportPhotoControl/index.d.ts +4 -0
- package/dist/styles/components/components/PassportPhotoControl/index.js +27 -0
- package/dist/styles/components/components/ProgressStepIndicator/index.js +1 -0
- package/dist/styles/components/components/SSICheckbox/index.js +2 -2
- package/dist/styles/components/components/SSICredentialCardView/index.js +1 -0
- package/dist/styles/components/components/SSIIconButton/index.js +4 -2
- package/dist/styles/components/components/SSIStatusLabel/index.js +1 -0
- package/dist/styles/components/components/SSITabView/index.js +1 -1
- package/dist/styles/components/components/SSITabViewHeader/index.d.ts +1 -0
- package/dist/styles/components/components/SSITabViewHeader/index.js +5 -0
- package/dist/styles/components/components/SSITableView/index.d.ts +5 -1
- package/dist/styles/components/components/SSITableView/index.js +21 -3
- package/dist/styles/components/components/SSITableViewHeader/index.d.ts +1 -0
- package/dist/styles/components/components/SSITableViewHeader/index.js +8 -0
- package/dist/styles/components/components/SSIToast/index.js +2 -2
- package/dist/styles/components/components/TextInputField/index.d.ts +2 -0
- package/dist/styles/components/components/TextInputField/index.js +27 -0
- package/dist/styles/components/components/buttons/index.d.ts +1 -0
- package/dist/styles/components/components/buttons/index.js +4 -0
- package/dist/styles/components/components/index.d.ts +11 -2
- package/dist/styles/components/components/index.js +11 -2
- package/dist/styles/css/index.d.ts +2 -0
- package/dist/styles/css/index.js +14 -0
- package/dist/styles/fonts/index.d.ts +1 -1
- package/dist/styles/fonts/index.js +23 -13
- package/dist/styles/typography.js +6 -0
- package/dist/types/button/index.d.ts +2 -1
- package/dist/types/field/index.d.ts +21 -0
- package/dist/types/field/index.js +10 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/table/index.d.ts +24 -14
- package/dist/types/table/index.js +3 -0
- package/dist/types/view/index.d.ts +14 -0
- package/dist/types/view/index.js +1 -0
- package/dist/utils/FileUtils.d.ts +1 -0
- package/dist/utils/FileUtils.js +7 -0
- package/dist/utils/ImageUtils.d.ts +2 -0
- package/dist/utils/ImageUtils.js +12 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/package.json +25 -8
- package/dist/components/assets/icons/BitterballenIcon/index.js +0 -7
- package/dist/components/buttons/RowActionMenuButton/index.d.ts +0 -13
- package/dist/components/buttons/RowActionMenuButton/index.js +0 -28
- package/dist/components/lists/SSIDropDownList/index.d.ts +0 -7
- package/dist/components/lists/SSIDropDownList/index.js +0 -11
- package/dist/styles/components/components/RowActionMenuButton/index.d.ts +0 -4
- package/dist/styles/components/components/RowActionMenuButton/index.js +0 -27
- package/dist/styles/components/components/SSIDropDownList/index.d.ts +0 -2
- package/dist/styles/components/components/SSIDropDownList/index.js +0 -12
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useEffect } from 'react';
|
|
3
|
+
import { borderColors } from '@sphereon/ui-components.core';
|
|
4
|
+
import DropDownListItem from '../DropDownListItem';
|
|
5
|
+
import SSIIconButton from '../../buttons/SSIIconButton';
|
|
6
|
+
import { DropDownListContainerStyled as Container, DropDownContainerStyled as DropDownContainer, DropDownListButtonStyled as ListButton, } from '../../../styles/components';
|
|
7
|
+
const DropDownList = (props) => {
|
|
8
|
+
const { icon, buttons, showBorder = false } = props;
|
|
9
|
+
const [showActionsMenu, setShowActionsMenu] = useState(false);
|
|
10
|
+
const dropdownRef = useRef(null);
|
|
11
|
+
const onMore = (event) => {
|
|
12
|
+
setShowActionsMenu(!showActionsMenu);
|
|
13
|
+
event.stopPropagation();
|
|
14
|
+
};
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const onClickOutside = (event) => {
|
|
17
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
18
|
+
setShowActionsMenu(false);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
document.addEventListener('mousedown', onClickOutside);
|
|
22
|
+
return () => {
|
|
23
|
+
document.removeEventListener('mousedown', onClickOutside);
|
|
24
|
+
};
|
|
25
|
+
}, [showActionsMenu]);
|
|
26
|
+
const getItems = () => {
|
|
27
|
+
return buttons.map((item, index) => {
|
|
28
|
+
const showBorder = buttons.length > 1 && index !== buttons.length - 1;
|
|
29
|
+
return (_jsx(DropDownListItem, { showBorder: showBorder, label: item.caption, onClick: item.onClick, icon: item.icon, fontColor: item.fontColor }, index));
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
return (_jsxs(Container, { ref: dropdownRef, children: [_jsx(ListButton, { children: _jsx(SSIIconButton, { icon: icon, onClick: onMore }) }), showActionsMenu && (_jsx(DropDownContainer, { style: { ...(showBorder && { borderWidth: 2, borderColor: borderColors.lightGrey, borderStyle: 'solid' }) }, children: getItems() }))] }));
|
|
33
|
+
};
|
|
34
|
+
export default DropDownList;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ButtonIcon } from '@sphereon/ui-components.core';
|
|
3
|
+
type Props = {
|
|
4
|
+
label: string;
|
|
5
|
+
onClick: (args?: any) => Promise<void>;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
icon?: ButtonIcon;
|
|
8
|
+
fontColor?: string;
|
|
9
|
+
showBorder?: boolean;
|
|
10
|
+
borderColor?: string;
|
|
11
|
+
};
|
|
12
|
+
declare const DropDownListItem: FC<Props>;
|
|
13
|
+
export default DropDownListItem;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DropDownListItemContainerStyled as Container, DropDownListItemIconContainerStyled as IconContainer, DropDownListItemCaptionContainerStyled as ListItemCaption, } from '../../../styles/components';
|
|
3
|
+
import DeleteIcon from '../../assets/icons/DeleteIcon';
|
|
4
|
+
import { borderColors, ButtonIcon, fontColors } from '@sphereon/ui-components.core';
|
|
5
|
+
const DropDownListItem = (props) => {
|
|
6
|
+
const { disabled, label, icon, showBorder = false, fontColor = fontColors.dark, borderColor = borderColors.light, onClick } = props;
|
|
7
|
+
const getIcon = (icon) => {
|
|
8
|
+
switch (icon) {
|
|
9
|
+
case ButtonIcon.DELETE:
|
|
10
|
+
return _jsx(DeleteIcon, { color: fontColors.dark });
|
|
11
|
+
default:
|
|
12
|
+
return _jsx("div", {});
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const onContainerClick = async (event) => {
|
|
16
|
+
event.stopPropagation();
|
|
17
|
+
if (onClick) {
|
|
18
|
+
await onClick();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
return (_jsxs(Container, { onClick: onContainerClick, style: { ...(showBorder && { borderBottomWidth: 2, borderBottomColor: borderColor }) }, children: [_jsx(ListItemCaption, { children: label }), icon && _jsx(IconContainer, { children: getIcon(icon) })] }));
|
|
22
|
+
};
|
|
23
|
+
export default DropDownListItem;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { CredentialFormData, CredentialFormSelectionType } from '../../../types';
|
|
3
|
+
type Props = {
|
|
4
|
+
credentialTypes: Array<CredentialFormSelectionType>;
|
|
5
|
+
onSelectCredentialTypeChange?: (credentialType: CredentialFormSelectionType) => Promise<void>;
|
|
6
|
+
onCredentialFormDataChange?: (credentialFormData: CredentialFormData) => Promise<void>;
|
|
7
|
+
credentialData?: Record<any, any>;
|
|
8
|
+
};
|
|
9
|
+
declare const CredentialIssuanceWizardView: FC<Props>;
|
|
10
|
+
export default CredentialIssuanceWizardView;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Autocomplete, TextField } from '@mui/material';
|
|
4
|
+
import { materialCells } from '@jsonforms/material-renderers';
|
|
5
|
+
import { JsonForms } from '@jsonforms/react';
|
|
6
|
+
import { Localization } from '@sphereon/ui-components.core';
|
|
7
|
+
import FileSelection from '../../fields/FileSelection';
|
|
8
|
+
import DragAndDropBox from '../../fields/DragAndDropBox';
|
|
9
|
+
import { jsonFormsMaterialRenderers } from '../../../renders/jsonFormsRenders';
|
|
10
|
+
import { CredentialIssuanceWizardViewContainerStyled as Container, CredentialIssuanceWizardViewCredentialTypeContainerStyled as CredentialTypeContainer, CredentialIssuanceWizardViewCredentialTypeTitleStyled as CredentialTypeTitle, CredentialIssuanceWizardViewFormContainerStyled as FormContainer, CredentialIssuanceWizardViewEvidenceContainerStyled as EvidenceContainer, CredentialIssuanceWizardViewEvidenceContentContainerStyled as EvidenceContentContainer, CredentialIssuanceWizardViewEvidenceTitleContainerStyled as EvidenceTitleContainer, SSITextH2SemiBoldStyled as EvidenceTitle, CredentialIssuanceWizardViewEvidenceTitleOptionalStyled as EvidenceTitleOptional, SSITextH2Styled as EvidenceDescription, CredentialIssuanceWizardViewEvidenceFilesContainerStyled as EvidenceFilesContainer } from '../../../styles';
|
|
11
|
+
const CredentialIssuanceWizardView = (props) => {
|
|
12
|
+
const { credentialData, credentialTypes, onSelectCredentialTypeChange, onCredentialFormDataChange } = props;
|
|
13
|
+
const [selectedCredentialType, setSelectedCredentialType] = useState(null);
|
|
14
|
+
const [credentialInput, setCredentialInput] = useState(null);
|
|
15
|
+
const [evidence, setEvidence] = useState([]);
|
|
16
|
+
const onCredentialTypeChange = (event, value) => {
|
|
17
|
+
setCredentialInput(null);
|
|
18
|
+
setEvidence([]);
|
|
19
|
+
setSelectedCredentialType(value);
|
|
20
|
+
onSelectCredentialTypeChange?.(value);
|
|
21
|
+
};
|
|
22
|
+
const onCredentialFormInputChange = (state) => {
|
|
23
|
+
setCredentialInput(state);
|
|
24
|
+
onCredentialFormDataChange?.({ ...state, evidence });
|
|
25
|
+
};
|
|
26
|
+
const onAddEvidence = async (file) => {
|
|
27
|
+
const evidenceFiles = [...evidence, file];
|
|
28
|
+
setEvidence(evidenceFiles);
|
|
29
|
+
onCredentialFormDataChange?.({ ...credentialInput, evidence: evidenceFiles });
|
|
30
|
+
};
|
|
31
|
+
const onRemoveEvidence = async (index) => {
|
|
32
|
+
evidence.splice(index, 1);
|
|
33
|
+
const evidenceFiles = [...evidence];
|
|
34
|
+
setEvidence(evidenceFiles);
|
|
35
|
+
onCredentialFormDataChange?.({ ...credentialInput, evidence: evidenceFiles });
|
|
36
|
+
};
|
|
37
|
+
const getEvidenceElements = () => {
|
|
38
|
+
return evidence.map((file, index) => _jsx(FileSelection, { file: file, onRemove: async () => onRemoveEvidence(index) }, index));
|
|
39
|
+
};
|
|
40
|
+
return (_jsxs(Container, { children: [_jsxs(CredentialTypeContainer, { children: [_jsx(CredentialTypeTitle, { children: Localization.translate('credential_issuance_wizard_title') }), _jsx(Autocomplete, { options: credentialTypes, sx: { flexGrow: 1 }, renderInput: (params) => _jsx(TextField, { ...params, label: Localization.translate('credential_issuance_wizard_credential_type_label') }), onChange: onCredentialTypeChange })] }), selectedCredentialType &&
|
|
41
|
+
_jsxs(_Fragment, { children: [_jsx(FormContainer, { children: _jsx(JsonForms, { schema: selectedCredentialType.schema, uischema: selectedCredentialType.uiSchema, data: credentialData, renderers: jsonFormsMaterialRenderers, cells: materialCells, onChange: onCredentialFormInputChange }) }), _jsx(EvidenceContainer, { children: _jsxs(EvidenceContentContainer, { children: [_jsxs("div", { children: [_jsxs(EvidenceTitleContainer, { children: [_jsx(EvidenceTitle, { children: Localization.translate('credential_issuance_wizard_evidence_title') }), _jsx(EvidenceTitleOptional, { children: Localization.translate('credential_issuance_wizard_evidence_optional_title') })] }), _jsx(EvidenceDescription, { children: Localization.translate('credential_issuance_wizard_evidence_description') })] }), _jsxs(EvidenceFilesContainer, { children: [_jsx(DragAndDropBox, { caption: Localization.translate('drag_and_drop_upload_evidence_caption'), description: Localization.translate('credential_attach_evidence_description'), onChangeFile: onAddEvidence }), getEvidenceElements()] })] }) })] })] }));
|
|
42
|
+
};
|
|
43
|
+
export default CredentialIssuanceWizardView;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
.MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline {
|
|
2
|
+
border-color: #7276F7 !important;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.MuiOutlinedInput-root:hover .MuiOutlinedInput-notchedOutline {
|
|
6
|
+
border-color: #7276F7 !important;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.MuiInputLabel-root.MuiFormLabel-root {
|
|
10
|
+
color: #303030 !important;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.MuiTypography-h6 {
|
|
14
|
+
color: #303030 !important;
|
|
15
|
+
font-size: 16px !important;
|
|
16
|
+
font-style: normal !important;
|
|
17
|
+
font-weight: 600 !important;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.MuiGrid-container {
|
|
21
|
+
padding: 0 !important;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.MuiFormControl-root {
|
|
25
|
+
padding: 0 !important;
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.MuiCardContent-root {
|
|
30
|
+
padding: 0 !important;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.MuiCardHeader-root {
|
|
34
|
+
padding: 0 !important;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.MuiPaper-root {
|
|
38
|
+
margin: 0 !important;
|
|
39
|
+
background-color: #FBFBFB !important;
|
|
40
|
+
box-shadow: none !important;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.MuiCardHeader-title {
|
|
44
|
+
font-family: Poppins, serif !important;
|
|
45
|
+
font-size: 16px !important;
|
|
46
|
+
font-style: normal !important;
|
|
47
|
+
font-weight: 400 !important;
|
|
48
|
+
margin-bottom: 10px !important;
|
|
49
|
+
color: #303030 !important;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.MuiGrid-root.MuiGrid-container.MuiGrid-direction-xs-column {
|
|
53
|
+
gap: 24px !important;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.MuiFormLabel-root.MuiInputLabel-root {
|
|
57
|
+
font-family: 'Poppins', sans-serif !important;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.MuiInputBase-root.MuiOutlinedInput-root .MuiInputBase-input {
|
|
61
|
+
font-family: 'Poppins', sans-serif !important;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.MuiInputBase-root.MuiOutlinedInput-root {
|
|
65
|
+
font-family: 'Poppins', sans-serif !important;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.MuiTypography-root {
|
|
69
|
+
font-family: 'Poppins', sans-serif !important;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.MuiDateCalendar-root {
|
|
73
|
+
background-color: #ECE6F0 !important;
|
|
74
|
+
border-radius: 16px !important;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.MuiPaper-root.MuiPaper-elevation.MuiPaper-rounded.MuiPaper-elevation8.MuiPickersPopper-paper {
|
|
78
|
+
border-radius: 16px !important;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.MuiButtonBase-root.MuiPickersDay-root.Mui-selected.MuiPickersDay-dayWithMargin {
|
|
82
|
+
background-color: #7276F7 !important;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.MuiButtonBase-root.MuiPickersDay-root.MuiPickersDay-dayWithMargin:hover {
|
|
86
|
+
background-color: #B7B8D9 !important;
|
|
87
|
+
}
|
|
@@ -6,6 +6,6 @@ const CredentialMiniCardView = (props) => {
|
|
|
6
6
|
const { backgroundColor = credentialCardColors.default, backgroundImage, logo, logoColor, style } = props;
|
|
7
7
|
return (_jsx(Container, { style: { ...style, backgroundColor }, children: _jsx(BackgroundImage, { style: {
|
|
8
8
|
...(backgroundImage?.uri && { background: `url(${backgroundImage.uri})`, backgroundSize: 'cover' }),
|
|
9
|
-
}, children: (!backgroundImage || logo) && _jsx(SSILogo, { logo: logo, color: logoColor }) }) }));
|
|
9
|
+
}, children: (!backgroundImage || logo) && _jsx(SSILogo, { logo: logo, color: logoColor, size: logo?.style?.height }) }) }));
|
|
10
10
|
};
|
|
11
11
|
export default CredentialMiniCardView;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CSSProperties, FC } from 'react';
|
|
2
|
+
import { CredentialStatus } from '@sphereon/ui-components.core';
|
|
3
|
+
import { CredentialMiniCardViewProps } from '../CredentialMiniCardView';
|
|
4
|
+
type Props = {
|
|
5
|
+
credentialTitle: string;
|
|
6
|
+
credentialStatus: CredentialStatus;
|
|
7
|
+
issuerName: string;
|
|
8
|
+
issueDate: number;
|
|
9
|
+
expirationDate?: number;
|
|
10
|
+
showTime?: boolean;
|
|
11
|
+
showCard?: boolean;
|
|
12
|
+
credentialBranding?: CredentialMiniCardViewProps;
|
|
13
|
+
style?: CSSProperties;
|
|
14
|
+
};
|
|
15
|
+
declare const CredentialViewItem: FC<Props>;
|
|
16
|
+
export default CredentialViewItem;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Localization, toLocalDateString, toLocalDateTimeString } from '@sphereon/ui-components.core';
|
|
3
|
+
import SSIStatusLabel from '../../labels/SSIStatusLabel';
|
|
4
|
+
import CredentialMiniCardView from '../CredentialMiniCardView';
|
|
5
|
+
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';
|
|
6
|
+
const CredentialViewItem = (props) => {
|
|
7
|
+
const { credentialStatus, credentialTitle, issuerName, showTime = false, showCard = true, credentialBranding, style } = props;
|
|
8
|
+
const issueDate = showTime ? toLocalDateTimeString(props.issueDate) : toLocalDateString(props.issueDate);
|
|
9
|
+
const expirationDate = props.expirationDate
|
|
10
|
+
? `${Localization.translate('credentials_view_item_expires_on')} ${showTime
|
|
11
|
+
? toLocalDateTimeString(props.expirationDate)
|
|
12
|
+
: toLocalDateString(props.expirationDate)}`
|
|
13
|
+
: Localization.translate('credential_status_never_expires_date_label');
|
|
14
|
+
return (_jsxs(Container, { style: { ...style }, children: [showCard &&
|
|
15
|
+
_jsx(CredentialMiniCardView, { ...credentialBranding }), _jsxs(DetailsContainer, { children: [_jsxs(ContentRowContainer, { children: [_jsxs("div", { children: [_jsx(TitleCaption, { children: credentialTitle }), _jsx(IssuerCaption, { children: issuerName })] }), _jsx(StatusContainer, { children: _jsx(SSIStatusLabel, { status: credentialStatus }) })] }), _jsxs(ContentRowContainer, { children: [_jsx(IssueDateCaption, { children: issueDate }), _jsx(ExpirationDateCaption, { children: expirationDate })] })] })] }));
|
|
16
|
+
};
|
|
17
|
+
export default CredentialViewItem;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
import { JSONTree } from 'react-json-tree';
|
|
4
|
+
import { backgroundColors, calculateAspectRatio, fontColors, isBase64ImageUri, isBoolean, Localization, parseToBoolean } from '@sphereon/ui-components.core';
|
|
5
|
+
import SSICheckmarkBadge from '../../assets/badges/SSICheckmarkBadge';
|
|
6
|
+
import SSIExclamationMarkBadge from '../../assets/badges/SSIExclamationMarkBadge';
|
|
7
|
+
import { getImageSize } from '../../../utils';
|
|
8
|
+
import { JSONDataViewContainerStyled as Container, JSONDataViewHeaderContainerStyled as HeaderContainer, JSONDataViewColumnHeaderCaptionStyled as ColumnHeaderCaption, JSONDataViewDataContainerCaptionStyled as ContainerCaption, JSONDataViewDataImageValueStyled as ImageValue, JSONDataViewDataTextValueStyled as TextValue, JSONDataViewDataLabelStyled as Label } from '../../../styles';
|
|
9
|
+
const JSONDataView = (props) => {
|
|
10
|
+
const { showHeader = true, shouldExpandNodeInitially = () => false } = props;
|
|
11
|
+
const expandNodeInitially = typeof shouldExpandNodeInitially === 'function' ? shouldExpandNodeInitially : () => shouldExpandNodeInitially;
|
|
12
|
+
const [focused, setFocused] = React.useState(false);
|
|
13
|
+
const [data, setData] = React.useState();
|
|
14
|
+
const preprocessData = async (data) => {
|
|
15
|
+
if (typeof data !== 'object' || data === null) {
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
const processedData = {};
|
|
19
|
+
await Promise.all(Object.entries(data).map(async ([key, value]) => {
|
|
20
|
+
if (typeof value === 'object' && value !== null) {
|
|
21
|
+
processedData[key] = await preprocessData(value);
|
|
22
|
+
}
|
|
23
|
+
else if (typeof value === 'string' && isBase64ImageUri(value)) {
|
|
24
|
+
const base64Uri = value;
|
|
25
|
+
const dimensions = await getImageSize(base64Uri);
|
|
26
|
+
processedData[key] = {
|
|
27
|
+
uri: base64Uri,
|
|
28
|
+
dimensions: {
|
|
29
|
+
height: dimensions.height,
|
|
30
|
+
width: dimensions.width,
|
|
31
|
+
aspectRatio: calculateAspectRatio(dimensions.width, dimensions.height)
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
processedData[key] = value;
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
|
+
return processedData;
|
|
40
|
+
};
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
preprocessData(props.data).then((data) => setData(data));
|
|
43
|
+
}, [props.data]);
|
|
44
|
+
const getItemString = () => {
|
|
45
|
+
return null;
|
|
46
|
+
};
|
|
47
|
+
const valueRenderer = (valueAsString, value) => {
|
|
48
|
+
if (isBoolean(value)) {
|
|
49
|
+
return parseToBoolean(value) ? _jsx(SSICheckmarkBadge, {}) : _jsx(SSIExclamationMarkBadge, {});
|
|
50
|
+
}
|
|
51
|
+
if (typeof value === 'object'
|
|
52
|
+
&& value !== null
|
|
53
|
+
&& 'uri' in value) {
|
|
54
|
+
const imageData = value;
|
|
55
|
+
return _jsx(ImageValue, { style: {
|
|
56
|
+
aspectRatio: imageData.dimensions?.aspectRatio,
|
|
57
|
+
backgroundImage: `url(${imageData.uri})`,
|
|
58
|
+
} });
|
|
59
|
+
}
|
|
60
|
+
return _jsx(TextValue, { children: value?.toString() });
|
|
61
|
+
};
|
|
62
|
+
const labelRenderer = ([key]) => {
|
|
63
|
+
return _jsx(Label, { children: key });
|
|
64
|
+
};
|
|
65
|
+
const isCustomNode = (value) => {
|
|
66
|
+
return typeof value === 'object' && value !== null && 'uri' in value && 'dimensions' in value;
|
|
67
|
+
};
|
|
68
|
+
return (_jsxs(Container, { children: [showHeader &&
|
|
69
|
+
_jsxs(HeaderContainer, { children: [_jsx(ColumnHeaderCaption, { children: Localization.translate('json_data_view_attribute_column_label') }), _jsx(ColumnHeaderCaption, { children: Localization.translate('json_data_view_value_column_label') })] }), _jsx(ContainerCaption, { onMouseEnter: () => setFocused(true), onMouseLeave: () => setFocused(false), children: data &&
|
|
70
|
+
_jsx(JSONTree, { theme: {
|
|
71
|
+
base0D: fontColors.dark,
|
|
72
|
+
tree: {
|
|
73
|
+
margin: 0,
|
|
74
|
+
backgroundColor: backgroundColors.primaryLight,
|
|
75
|
+
},
|
|
76
|
+
arrowContainer: {
|
|
77
|
+
paddingRight: 6,
|
|
78
|
+
},
|
|
79
|
+
arrow: {
|
|
80
|
+
fontSize: 10,
|
|
81
|
+
...(!focused && { display: 'none' }),
|
|
82
|
+
},
|
|
83
|
+
}, hideRoot: true, shouldExpandNodeInitially: expandNodeInitially, getItemString: getItemString, labelRenderer: labelRenderer, valueRenderer: valueRenderer, isCustomNode: isCustomNode, data: data }) })] }));
|
|
84
|
+
};
|
|
85
|
+
export default JSONDataView;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { SSITabViewHeaderContainerStyled as Container, SSITabViewHeaderTitleContainerStyled as TitleContainer,
|
|
2
|
+
import { SSITabViewHeaderContainerStyled as Container, SSITabViewHeaderTitleContainerStyled as TitleContainer, SSITabViewHeaderTitleCaptionStyled as TitleCaption, } from '../../../../styles';
|
|
3
3
|
const SSITabViewHeader = (props) => {
|
|
4
4
|
const { navigationState, onIndexChange } = props;
|
|
5
5
|
return (_jsx(Container, { children: navigationState.routes.map((value, index) => {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CSSProperties, FC } from 'react';
|
|
2
|
+
import { PaginationProps } from '@mui/material';
|
|
3
|
+
export type PaginationControlsProps = PaginationProps & {
|
|
4
|
+
goToInputId?: string;
|
|
5
|
+
containerStyle?: CSSProperties;
|
|
6
|
+
};
|
|
7
|
+
declare const PaginationControls: FC<PaginationControlsProps>;
|
|
8
|
+
export default PaginationControls;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Stack } from '@mui/material';
|
|
3
|
+
import { GoToInputContainer, GoToInputStyled, PaginationContainerStyled, PaginationStyled } from '../../../../styles';
|
|
4
|
+
import { Localization } from '@sphereon/ui-components.core';
|
|
5
|
+
const PaginationControls = (props) => {
|
|
6
|
+
const { onKeyDown, containerStyle, goToInputId = 'goTo' } = props;
|
|
7
|
+
return (_jsxs(PaginationContainerStyled, { style: containerStyle, children: [_jsx(Stack, { children: _jsx(PaginationStyled, { ...props }) }), _jsxs(GoToInputContainer, { children: [Localization.translate('table_pagination_input_caption_go_to'), _jsx(GoToInputStyled, { id: goToInputId, onKeyDown: onKeyDown }), Localization.translate('table_pagination_input_caption_page')] })] }));
|
|
8
|
+
};
|
|
9
|
+
export default PaginationControls;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ButtonIcon, Localization } from '@sphereon/ui-components.core';
|
|
2
|
+
import { ButtonIcon, Localization, statusColors } from '@sphereon/ui-components.core';
|
|
3
3
|
import SSIIconButton from '../../../buttons/SSIIconButton';
|
|
4
|
-
import SSIDropDownList from '../../../lists/SSIDropDownList';
|
|
5
4
|
import SSIPrimaryButton from '../../../buttons/SSIPrimaryButton';
|
|
6
|
-
import { SSITableViewHeaderActionsContainerStyled as ActionsContainer, SSITableViewHeaderContainerStyled as Container, SSITableViewHeaderContentContainerStyled as ContentContainer, SSITextH3Styled as FilterCaption, SSITableViewHeaderFilterContainerStyled as FilterContainer,
|
|
5
|
+
import { SSITableViewHeaderActionsContainerStyled as ActionsContainer, SSITableViewHeaderContainerStyled as Container, SSITableViewHeaderContentContainerStyled as ContentContainer, SSITextH3Styled as FilterCaption, SSITableViewHeaderFilterContainerStyled as FilterContainer, TableViewHeaderStaticActionsContainerStyled as StaticActionsContainer, } from '../../../../styles';
|
|
7
6
|
const SSITableViewHeader = (props) => {
|
|
8
|
-
const { enableFiltering = false, enableMostRecent = false, actions = [] } = props;
|
|
9
|
-
|
|
7
|
+
const { enableFiltering = false, enableMostRecent = false, actions = [], onDelete } = props;
|
|
8
|
+
const onDeleteClick = async () => {
|
|
9
|
+
await onDelete?.();
|
|
10
|
+
};
|
|
11
|
+
return (_jsxs(Container, { children: [_jsx(StaticActionsContainer, { children: onDelete && (_jsx(SSIIconButton, { caption: Localization.translate('action_delete_label'), icon: ButtonIcon.DELETE, iconColor: statusColors.error, onClick: onDeleteClick })) }), _jsx(ContentContainer, { style: { width: 'fit-content' }, children: _jsxs(ActionsContainer, { children: [enableFiltering && (_jsxs(FilterContainer, { children: [_jsx(SSIIconButton, { icon: ButtonIcon.FILTER, onClick: async () => console.log('add filter clicked') }), _jsx(FilterCaption, { children: Localization.translate('action_filter_caption') })] })), actions.map((action, index) => (_jsx(SSIPrimaryButton, { caption: action.caption, onClick: action.onClick, icon: action.icon }, index)))] }) })] }));
|
|
10
12
|
};
|
|
11
13
|
export default SSITableViewHeader;
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
import { ColumnResizeMode, Row } from '@tanstack/react-table';
|
|
3
|
-
import {
|
|
3
|
+
import { Button, ColumnHeader } from '../../../types';
|
|
4
|
+
import { PaginationControlsProps } from './PaginationControls';
|
|
4
5
|
type Props<T> = {
|
|
5
6
|
data: Array<T>;
|
|
6
7
|
columns: Array<ColumnHeader<T>>;
|
|
7
8
|
onRowClick?: (data: Row<T>) => Promise<void>;
|
|
9
|
+
onDelete?: (rows: Array<T>) => Promise<void>;
|
|
8
10
|
enableRowSelection?: boolean;
|
|
11
|
+
enableRowHover?: boolean;
|
|
9
12
|
enableFiltering?: boolean;
|
|
10
13
|
enableMostRecent?: boolean;
|
|
11
14
|
enableResultCount?: boolean;
|
|
12
15
|
columnResizeMode?: ColumnResizeMode;
|
|
13
16
|
actions?: Array<Button>;
|
|
14
|
-
|
|
17
|
+
pagination?: PaginationControlsProps;
|
|
15
18
|
};
|
|
16
19
|
declare const SSITableView: <T extends {}>(props: Props<T>) => ReactElement;
|
|
17
20
|
export default SSITableView;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { createColumnHelper, flexRender, getCoreRowModel, useReactTable, } from '@tanstack/react-table';
|
|
4
|
-
import { ButtonIcon, Localization } from '@sphereon/ui-components.core';
|
|
4
|
+
import { ButtonIcon, Localization, selectionElementColors } from '@sphereon/ui-components.core';
|
|
5
5
|
import SSITableViewHeader from './SSITableViewHeader';
|
|
6
6
|
import SSITypeLabel from '../../labels/SSITypeLabel';
|
|
7
7
|
import SSIHoverText from '../../fields/SSIHoverText';
|
|
8
|
-
import
|
|
8
|
+
import SSIStatusLabel from '../../labels/SSIStatusLabel';
|
|
9
|
+
import CredentialMiniCardView from '../CredentialMiniCardView';
|
|
10
|
+
import DropDownList from '../../lists/DropDownList';
|
|
11
|
+
import { SSITableViewCellContainerStyled as CellContainer, SSITableViewContainerStyled as Container, SSITableViewHeaderCellContainerStyled as HeaderCellContainer, SSITableViewLabelCellStyled as LabelCell, SSITableViewResultCountCaptionStyled as ResultCountCaption, SSITableViewHeaderRowContainerStyled as HeaderRowContainer, SSITableViewRowContainerStyled as RowContainer, SSITableViewTableContainerStyled as TableContainer, TableViewRowSelectionCheckboxContainerStyled as RowSelectionCheckboxContainer, } from '../../../styles';
|
|
9
12
|
import { TableCellType } from '../../../types';
|
|
10
|
-
import
|
|
11
|
-
import
|
|
13
|
+
import PaginationControls from './PaginationControls';
|
|
14
|
+
import ComboBox from "../../fields/ComboBox";
|
|
15
|
+
import CredentialDetailsView from "../CredentialViewItem";
|
|
12
16
|
function IndeterminateCheckbox({ indeterminate, className = '', ...rest }) {
|
|
13
17
|
const ref = React.useRef(null);
|
|
14
18
|
React.useEffect(() => {
|
|
@@ -18,10 +22,10 @@ function IndeterminateCheckbox({ indeterminate, className = '', ...rest }) {
|
|
|
18
22
|
}, [ref, indeterminate]);
|
|
19
23
|
return _jsx("input", { type: "checkbox", ref: ref, className: className + ' cursor-pointer', ...rest });
|
|
20
24
|
}
|
|
21
|
-
const getCellFormatting = (type, value,
|
|
25
|
+
const getCellFormatting = (type, value, row, options) => {
|
|
22
26
|
switch (type) {
|
|
23
27
|
case TableCellType.TEXT:
|
|
24
|
-
const { truncationLength, enableHover = false } =
|
|
28
|
+
const { truncationLength, enableHover = false } = options ?? {};
|
|
25
29
|
return _jsx(SSIHoverText, { text: value, truncationLength: truncationLength, enableHover: enableHover });
|
|
26
30
|
case TableCellType.LABEL: {
|
|
27
31
|
const labels = Array.isArray(value) ? value.map((label) => _jsx(SSITypeLabel, { type: label })) : _jsx(SSITypeLabel, { type: value });
|
|
@@ -33,21 +37,44 @@ const getCellFormatting = (type, value, opts) => {
|
|
|
33
37
|
case TableCellType.CREDENTIAL_CARD: {
|
|
34
38
|
return _jsx(CredentialMiniCardView, { ...value });
|
|
35
39
|
}
|
|
40
|
+
case TableCellType.CREDENTIAL_DETAILS: {
|
|
41
|
+
return _jsx(CredentialDetailsView, { ...value, style: { maxWidth: 261 } });
|
|
42
|
+
}
|
|
43
|
+
case TableCellType.ACTIONS: {
|
|
44
|
+
const { actions = [] } = options ?? {};
|
|
45
|
+
const buttons = actions.map((action) => ({
|
|
46
|
+
...action,
|
|
47
|
+
onClick: () => action.onClick(row),
|
|
48
|
+
}));
|
|
49
|
+
return _jsx(DropDownList, { icon: ButtonIcon.MEATBALLS, buttons: buttons, showBorder: true });
|
|
50
|
+
}
|
|
51
|
+
case TableCellType.COMBOBOX: {
|
|
52
|
+
const { defaultValue, onChange, selectOptions = [] } = options ?? {};
|
|
53
|
+
return _jsx(ComboBox, { defaultValue: defaultValue, value: value, onChange: onChange, options: selectOptions });
|
|
54
|
+
}
|
|
36
55
|
default:
|
|
37
56
|
return _jsx("div", {});
|
|
38
57
|
}
|
|
39
58
|
};
|
|
59
|
+
const toRowSelectionObject = (rows) => {
|
|
60
|
+
const rowSelectionObject = {};
|
|
61
|
+
rows.forEach((row) => {
|
|
62
|
+
rowSelectionObject[row.rowId] = true;
|
|
63
|
+
});
|
|
64
|
+
return rowSelectionObject;
|
|
65
|
+
};
|
|
40
66
|
const SSITableView = (props) => {
|
|
41
|
-
const { columns, data, enableRowSelection = false, enableFiltering = false, enableMostRecent = false, enableResultCount = false, columnResizeMode = 'onChange', actions = [],
|
|
42
|
-
const [rowSelection, setRowSelection] = React.useState(
|
|
67
|
+
const { columns, data, enableRowSelection = false, enableRowHover = true, enableFiltering = false, enableMostRecent = false, enableResultCount = false, columnResizeMode = 'onChange', actions = [], onRowClick, onDelete, pagination, } = props;
|
|
68
|
+
const [rowSelection, setRowSelection] = React.useState([]);
|
|
69
|
+
const [focusedRowId, setFocusedRowId] = React.useState();
|
|
43
70
|
const columnHelper = createColumnHelper();
|
|
44
71
|
let availableColumns = columns.map((header) => columnHelper.accessor(header.accessor, {
|
|
45
72
|
id: header.accessor,
|
|
46
73
|
header: header.label,
|
|
47
|
-
cell: (info) => getCellFormatting(header.type, info.getValue(), header.
|
|
48
|
-
minSize: header.
|
|
49
|
-
maxSize: header.
|
|
50
|
-
size: header.
|
|
74
|
+
cell: (info) => getCellFormatting(header.type, info.getValue(), info.row, header.columnOptions?.cellOptions),
|
|
75
|
+
minSize: header.columnOptions?.columnMinWidth,
|
|
76
|
+
maxSize: header.columnOptions?.columnMaxWidth,
|
|
77
|
+
size: header.columnOptions?.columnWidth,
|
|
51
78
|
}));
|
|
52
79
|
if (enableRowSelection) {
|
|
53
80
|
availableColumns = [
|
|
@@ -58,60 +85,64 @@ const SSITableView = (props) => {
|
|
|
58
85
|
indeterminate: table.getIsSomeRowsSelected(),
|
|
59
86
|
onChange: table.getToggleAllRowsSelectedHandler(),
|
|
60
87
|
} })),
|
|
61
|
-
cell: ({ row }) => (_jsx(
|
|
88
|
+
cell: ({ row }) => (_jsx(RowSelectionCheckboxContainer, { children: (row.id === focusedRowId || rowSelection.length > 0) && (_jsx(IndeterminateCheckbox, { ...{
|
|
62
89
|
checked: row.getIsSelected(),
|
|
63
90
|
disabled: !row.getCanSelect(),
|
|
64
91
|
indeterminate: row.getIsSomeSelected(),
|
|
65
92
|
onChange: row.getToggleSelectedHandler(),
|
|
66
|
-
} }) })),
|
|
93
|
+
} })) })),
|
|
67
94
|
},
|
|
68
95
|
...availableColumns,
|
|
69
96
|
];
|
|
70
97
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
98
|
+
const onFocusRow = (rowId) => {
|
|
99
|
+
setFocusedRowId(rowId);
|
|
100
|
+
};
|
|
101
|
+
const onRowSelectionChange = (updatedRowSelection) => {
|
|
102
|
+
const currentRowSelection = updatedRowSelection(toRowSelectionObject(rowSelection));
|
|
103
|
+
const selection = Object.keys(currentRowSelection).map((key) => {
|
|
104
|
+
return {
|
|
105
|
+
rowId: key,
|
|
106
|
+
rowData: data[Number(key)],
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
setRowSelection(selection);
|
|
110
|
+
};
|
|
81
111
|
const table = useReactTable({
|
|
82
112
|
defaultColumn: {
|
|
83
113
|
size: 0,
|
|
84
114
|
},
|
|
85
115
|
state: {
|
|
86
|
-
rowSelection,
|
|
116
|
+
rowSelection: toRowSelectionObject(rowSelection),
|
|
87
117
|
},
|
|
88
118
|
enableRowSelection,
|
|
89
|
-
onRowSelectionChange:
|
|
119
|
+
onRowSelectionChange: onRowSelectionChange,
|
|
90
120
|
data,
|
|
91
121
|
columns: availableColumns,
|
|
92
122
|
columnResizeMode,
|
|
93
123
|
getCoreRowModel: getCoreRowModel(),
|
|
94
124
|
});
|
|
95
125
|
const onRowClicked = async (row) => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
126
|
+
await onRowClick?.(row);
|
|
127
|
+
};
|
|
128
|
+
const onDeleteClicked = async () => {
|
|
129
|
+
await onDelete?.(rowSelection.map((row) => row.rowData));
|
|
99
130
|
};
|
|
100
|
-
return (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
131
|
+
return (_jsxs(Container, { children: [_jsxs("div", { className: "overflow-x-auto", children: [enableResultCount && (_jsx(ResultCountCaption, { children: Localization.translate('result_count_label', {
|
|
132
|
+
count: data.length,
|
|
133
|
+
maxCount: data.length,
|
|
134
|
+
}) })), (enableFiltering || enableMostRecent || actions.length > 0) && (_jsx(SSITableViewHeader, { actions: actions, enableFiltering: enableFiltering, enableMostRecent: enableMostRecent, ...(onDelete && { onDelete: onDeleteClicked }) })), _jsxs(TableContainer, { children: [_jsx("thead", { children: table.getHeaderGroups().map((headerGroup) => (_jsx(HeaderRowContainer, { children: headerGroup.headers.map((header) => (_jsxs(HeaderCellContainer, { colSpan: header.colSpan, style: {
|
|
135
|
+
...(header.column.columnDef.minSize && { minWidth: header.column.columnDef.minSize }),
|
|
136
|
+
...(header.column.columnDef.maxSize && { maxWidth: header.column.columnDef.maxSize }),
|
|
137
|
+
...(header.column.columnDef.size !== 0 && { width: header.column.columnDef.size }),
|
|
138
|
+
}, children: [header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()), _jsx("div", { className: `resizer ${header.column.getIsResizing() ? 'isResizing' : ''}`, onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), style: {
|
|
139
|
+
transform: columnResizeMode === 'onEnd' && header.column.getIsResizing()
|
|
140
|
+
? `translateX(${table.getState().columnSizingInfo.deltaOffset}px)`
|
|
141
|
+
: '',
|
|
142
|
+
} })] }, header.id))) }, headerGroup.id))) }), _jsx("tbody", { children: table.getRowModel().rows.map((row) => (_jsx(RowContainer, { enableHover: enableRowHover, onClick: () => onRowClicked(row), onMouseEnter: () => onFocusRow(row.id), onMouseLeave: () => onFocusRow(), style: { ...(row.getIsSelected() && { backgroundColor: selectionElementColors.selectedRow }) }, children: row.getVisibleCells().map((cell) => (_jsx(CellContainer, { style: {
|
|
143
|
+
...(cell.column.columnDef.minSize && { minWidth: cell.column.columnDef.minSize }),
|
|
144
|
+
...(cell.column.columnDef.maxSize && { maxWidth: cell.column.columnDef.maxSize }),
|
|
145
|
+
...(cell.column.columnDef.size !== 0 && { width: cell.column.columnDef.size }),
|
|
146
|
+
}, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id))) })] })] }), pagination && _jsx(PaginationControls, { ...pagination })] }));
|
|
116
147
|
};
|
|
117
148
|
export default SSITableView;
|