Skip to content

Commit bb4130e

Browse files
4manasamanasa
andauthored
fixed the styling issues identified in selectable card (#477)
Co-authored-by: manasa <[email protected]>
1 parent ef35796 commit bb4130e

File tree

5 files changed

+62
-48
lines changed

5 files changed

+62
-48
lines changed

packages/react-sdk-components/src/components/field/Checkbox/Checkbox.tsx

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ const useStyles = makeStyles(() => ({
3535
checkbox: {
3636
display: 'flex',
3737
flexDirection: 'column'
38+
},
39+
selectableCard: {
40+
display: 'grid',
41+
gridTemplateColumns: 'repeat(auto-fit, minmax(min(100%, 40ch), 1fr))',
42+
gridAutoRows: '1fr',
43+
gap: '0.5rem'
3844
}
3945
}));
4046

@@ -75,6 +81,8 @@ export default function CheckboxComponent(props: CheckboxProps) {
7581
renderMode,
7682
image
7783
} = props;
84+
const readOnlyMode = renderMode === 'ReadOnly' || displayMode === 'DISPLAY_ONLY' || readOnly;
85+
7886
// eslint-disable-next-line @typescript-eslint/no-unused-vars
7987
const [theSelectedButton, setSelectedButton] = useState(value);
8088
const classes = useStyles();
@@ -90,7 +98,7 @@ export default function CheckboxComponent(props: CheckboxProps) {
9098
}, [value]);
9199

92100
useEffect(() => {
93-
if (referenceList?.length > 0) {
101+
if (referenceList?.length > 0 && !readOnlyMode) {
94102
thePConn.setReferenceList(selectionList);
95103
updateNewInstuctions(thePConn, selectionList);
96104
}
@@ -140,39 +148,41 @@ export default function CheckboxComponent(props: CheckboxProps) {
140148
return (
141149
<div>
142150
<h4 style={{ marginTop: 0, marginBottom: 0 }}>{label}</h4>
143-
<SelectableCard
144-
{...commonProps}
145-
testId={testId}
146-
displayMode={displayMode}
147-
dataSource={datasource}
148-
getPConnect={getPConnect}
149-
readOnly={renderMode === 'ReadOnly' || displayMode === 'DISPLAY_ONLY' || readOnly}
150-
onChange={e => {
151-
e.stopPropagation();
152-
const recordKey = selectionKey?.split('.').pop();
153-
const selectedItem = datasource?.source?.find(item => item[recordKey as any] === e.target.id) ?? {};
154-
handleCheckboxChange(e, {
155-
id: selectedItem[recordKey as any],
156-
primary: selectedItem[recordKey as any]
157-
});
158-
}}
159-
onBlur={() => {
160-
thePConn.getValidationApi().validate(selectedvalues, selectionList);
161-
}}
162-
hideFieldLabels={hideFieldLabels}
163-
recordKey={selectionKey?.split('.').pop()}
164-
cardLabel={primaryField.split('.').pop()}
165-
image={{
166-
imagePosition,
167-
imageSize,
168-
showImageDescription,
169-
imageField: image?.split('.').pop(),
170-
imageDescription: (thePConn?.getRawMetadata()?.config as any).imageDescription?.split('.').pop()
171-
}}
172-
readOnlyList={selectedvalues}
173-
type='checkbox'
174-
showNoValue={(renderMode === 'ReadOnly' || readOnly || displayMode === 'DISPLAY_ONLY') && selectedvalues.length === 0}
175-
/>
151+
<div className={classes.selectableCard}>
152+
<SelectableCard
153+
{...commonProps}
154+
testId={testId}
155+
displayMode={displayMode}
156+
dataSource={datasource}
157+
getPConnect={getPConnect}
158+
readOnly={renderMode === 'ReadOnly' || displayMode === 'DISPLAY_ONLY' || readOnly}
159+
onChange={e => {
160+
e.stopPropagation();
161+
const recordKey = selectionKey?.split('.').pop();
162+
const selectedItem = datasource?.source?.find(item => item[recordKey as any] === e.target.id) ?? {};
163+
handleCheckboxChange(e, {
164+
id: selectedItem[recordKey as any],
165+
primary: selectedItem[recordKey as any]
166+
});
167+
}}
168+
onBlur={() => {
169+
thePConn.getValidationApi().validate(selectedvalues, selectionList);
170+
}}
171+
hideFieldLabels={hideFieldLabels}
172+
recordKey={selectionKey?.split('.').pop()}
173+
cardLabel={primaryField.split('.').pop()}
174+
image={{
175+
imagePosition,
176+
imageSize,
177+
showImageDescription,
178+
imageField: image?.split('.').pop(),
179+
imageDescription: (thePConn?.getRawMetadata()?.config as any).imageDescription?.split('.').pop()
180+
}}
181+
readOnlyList={selectedvalues}
182+
type='checkbox'
183+
showNoValue={(renderMode === 'ReadOnly' || readOnly || displayMode === 'DISPLAY_ONLY') && selectedvalues.length === 0}
184+
/>
185+
</div>
176186
</div>
177187
);
178188
}

packages/react-sdk-components/src/components/field/SelectableCard/SelectableCard.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,18 @@ export default function SelectableCard(props) {
7676

7777
const component = (
7878
<div style={{ paddingTop: '15px' }}>
79-
<Card className={className} style={{ display: 'flex', height: '500px' }} data-testid={testId}>
79+
<Card className={className} style={{ display: 'flex', flexDirection: 'column', height: '100%' }} data-testid={testId}>
8080
<CardContent
8181
style={{
82-
...(imagePosition === 'inline-start' && { display: 'flex' })
82+
...((imagePosition === 'inline-start' || imagePosition === 'inline-end') && { display: 'flex', height: '100%' }),
83+
...(imagePosition === 'inline-end' && { flexDirection: 'row-reverse' })
8384
}}
8485
>
85-
<div>
86+
<div
87+
style={{
88+
...((imagePosition === 'inline-start' || imagePosition === 'inline-end') && { width: '40%' })
89+
}}
90+
>
8691
{image && (
8792
<img
8893
src={image.src}
@@ -99,7 +104,11 @@ export default function SelectableCard(props) {
99104
/>
100105
)}
101106
</div>
102-
<div>
107+
<div
108+
style={{
109+
...((imagePosition === 'inline-start' || imagePosition === 'inline-end') && { width: '60%' })
110+
}}
111+
>
103112
{type === 'radio' ? (
104113
<FormControlLabel
105114
control={

packages/react-sdk-components/src/components/template/DataReference/SearchForm.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useState } from 'react';
2-
import { Tab, Tabs, Typography, RadioGroup, FormControlLabel, Radio, Select, MenuItem, Grid, Box } from '@mui/material';
2+
import { Tab, Tabs, Typography, RadioGroup, FormControlLabel, Radio, MenuItem, Box, TextField } from '@mui/material';
3+
import Grid from '@mui/material/Grid2';
34
import { TabContext, TabPanel } from '@mui/lab';
45
import { Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';
56

@@ -92,13 +93,13 @@ const SearchForm = props => {
9293
if (tabItems.length > 3) {
9394
searchCategoriesComp = (
9495
<Grid container spacing={2}>
95-
<Select value={currentTabId} onChange={handleTabClick} fullWidth>
96+
<TextField value={currentTabId} select onChange={handleTabClick} fullWidth>
9697
{tabItems.map(tab => (
9798
<MenuItem key={tab.id} value={tab.id}>
9899
{tab.name}
99100
</MenuItem>
100101
))}
101-
</Select>
102+
</TextField>
102103
</Grid>
103104
);
104105
} else if (tabItems.length > 1) {

packages/react-sdk-components/src/components/template/ListView/ListView.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,13 @@ export default function ListView(props: ListViewProps) {
102102
// List component context
103103
const [listContext, setListContext] = useState<any>({});
104104
const { meta } = listContext;
105-
const xRayApis = PCore.getDebugger().getXRayRuntime();
106-
const xRayUid = xRayApis.startXRay();
107105
const { current: uniqueId } = useRef(crypto.randomUUID());
108106

109107
useInit({
110108
...props,
111109
setListContext,
112110
ref,
113111
showDynamicFields,
114-
xRayUid,
115112
cosmosTableRef
116113
});
117114

packages/react-sdk-components/src/components/template/ListView/hooks.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export default function useInit(props) {
1414
ref,
1515
showDynamicFields,
1616
isDataObject,
17-
xRayUid,
1817
cosmosTableRef
1918
} = props;
2019
let { editing, selectionMode } = props;
@@ -73,8 +72,7 @@ export default function useInit(props) {
7372
getPConnect,
7473
compositeKeys,
7574
isSearchable,
76-
isCacheable: true,
77-
xRayUid
75+
isCacheable: true
7876
}).then(async context => {
7977
if (isCompStillMounted) {
8078
return readContextResponse(context, {
@@ -83,7 +81,6 @@ export default function useInit(props) {
8381
selectionCountThreshold,
8482
ref,
8583
selectionMode,
86-
xRayUid,
8784
cosmosTableRef
8885
});
8986
}

0 commit comments

Comments
 (0)