Skip to content

Commit 8392956

Browse files
committed
Optional chaining fixed
1 parent b5f163d commit 8392956

15 files changed

Lines changed: 68 additions & 81 deletions

File tree

packages/lib/src/accordion/Accordion.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const DxcAccordion = ({
3030
};
3131

3232
return (
33-
<ThemeProvider theme={colorsTheme?.accordion}>
33+
<ThemeProvider theme={colorsTheme.accordion}>
3434
<AccordionContainer isExpanded={isExpanded ?? innerIsExpanded} margin={margin}>
3535
<AccordionHeader>
3636
<AccordionTrigger

packages/lib/src/bulleted-list/BulletedList.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ const DxcBulletedList = ({ children, type = "disc", icon = "" }: BulletedListPro
1212
const colorsTheme = useTheme();
1313

1414
return (
15-
<ThemeProvider theme={colorsTheme?.bulletedList}>
15+
<ThemeProvider theme={colorsTheme.bulletedList}>
1616
<ListContainer>
1717
<DxcFlex direction="column" as={type === "number" ? "ol" : "ul"} gap="0.125rem">
1818
{Children.map(children, (child, index) => (
1919
<ListItem>
2020
<GeneralContent>
2121
{type === "number" ? (
2222
<Number>
23-
<DxcTypography color={colorsTheme?.bulletedList?.fontColor}>{index + 1}.</DxcTypography>
23+
<DxcTypography color={colorsTheme.bulletedList.fontColor}>{index + 1}.</DxcTypography>
2424
</Number>
2525
) : type === "square" ? (
2626
<Bullet>
@@ -39,7 +39,7 @@ const DxcBulletedList = ({ children, type = "disc", icon = "" }: BulletedListPro
3939
<Disc />
4040
</Bullet>
4141
)}
42-
<DxcTypography color={colorsTheme?.bulletedList?.fontColor}>{child}</DxcTypography>
42+
<DxcTypography color={colorsTheme.bulletedList.fontColor}>{child}</DxcTypography>
4343
</GeneralContent>
4444
</ListItem>
4545
))}

packages/lib/src/checkbox/Checkbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const DxcCheckbox = forwardRef<RefType, CheckboxPropsType>(
6262
};
6363

6464
return (
65-
<ThemeProvider theme={colorsTheme?.checkbox}>
65+
<ThemeProvider theme={colorsTheme.checkbox}>
6666
<MainContainer
6767
disabled={disabled}
6868
readOnly={readOnly}
@@ -75,7 +75,7 @@ const DxcCheckbox = forwardRef<RefType, CheckboxPropsType>(
7575
{label && (
7676
<LabelContainer id={labelId} disabled={disabled} labelPosition={labelPosition} aria-label={label}>
7777
{label}
78-
{optional && ` ${translatedLabels?.formFields?.optionalLabel}`}
78+
{optional && ` ${translatedLabels.formFields.optionalLabel}`}
7979
</LabelContainer>
8080
)}
8181
<ValueInput

packages/lib/src/data-grid/DataGrid.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const DxcDataGrid = ({
6666
setSortColumns(newSortColumns);
6767
};
6868

69-
// Proccess columns prop into usable columns based on other props
69+
// Process columns prop into usable columns based on other props
7070
const columnsToRender = useMemo(() => {
7171
let expectedColumns = columns.map((column) => convertToRDGColumns(column, summaryRow));
7272
if (expandable) {
@@ -250,20 +250,15 @@ const DxcDataGrid = ({
250250
sortColumns={sortColumns}
251251
onSortColumnsChange={handleSortChange}
252252
rowKeyGetter={(row) => (uniqueRowId ? rowKeyGetter(row, uniqueRowId) : "")}
253-
rowHeight={(row) => {
254-
if (
255-
row.isExpandedChildContent &&
256-
typeof row.expandedContentHeight === "number" &&
257-
row.expandedContentHeight > 0
258-
) {
259-
return row.expandedContentHeight;
260-
}
261-
return colorsTheme?.dataGrid?.dataRowHeight ?? 0;
262-
}}
253+
rowHeight={(row) =>
254+
row.isExpandedChildContent && typeof row.expandedContentHeight === "number" && row.expandedContentHeight > 0
255+
? row.expandedContentHeight
256+
: (colorsTheme.dataGrid?.dataRowHeight ?? 0)
257+
}
263258
selectedRows={selectedRows}
264259
bottomSummaryRows={summaryRow ? [summaryRow] : undefined}
265-
headerRowHeight={colorsTheme?.dataGrid?.headerRowHeight}
266-
summaryRowHeight={colorsTheme?.dataGrid?.summaryRowHeight}
260+
headerRowHeight={colorsTheme.dataGrid.headerRowHeight}
261+
summaryRowHeight={colorsTheme.dataGrid.summaryRowHeight}
267262
className="fill-grid"
268263
/>
269264
{showPaginator && (

packages/lib/src/date-input/Calendar.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,11 @@ const Calendar = ({
5858
onDaySelect,
5959
today,
6060
}: CalendarPropsType): JSX.Element => {
61-
const id = useId();
6261
const [dateToFocus, setDateToFocus] = useState(getDateToFocus(selectedDate, innerDate, today));
6362
const [isFocusable, setIsFocusable] = useState(false);
64-
const dayCells = useMemo(() => getDays(innerDate), [innerDate]);
63+
const id = useId();
6564
const translatedLabels = useTranslatedLabels();
66-
const weekDays = translatedLabels?.calendar?.daysShort ?? [];
65+
const dayCells = useMemo(() => getDays(innerDate), [innerDate]);
6766

6867
const onDateClickHandler = (date: DateType) => {
6968
const newDate = innerDate.set("month", date.month).set("date", date.day);
@@ -170,14 +169,14 @@ const Calendar = ({
170169
return (
171170
<CalendarContainer role="grid">
172171
<CalendarHeaderRow role="row">
173-
{weekDays.map((weekDay) => (
172+
{translatedLabels.calendar.daysShort.map((weekDay) => (
174173
<WeekHeaderCell key={weekDay} role="columnheader">
175174
{weekDay}
176175
</WeekHeaderCell>
177176
))}
178177
</CalendarHeaderRow>
179178
<MonthContainer onBlur={handleOnBlur} role="rowgroup">
180-
{divideDaysIntoWeeks(dayCells, weekDays.length).map((week, rowIndex) => (
179+
{divideDaysIntoWeeks(dayCells, translatedLabels.calendar.daysShort.length).map((week, rowIndex) => (
181180
<WeekContainer key={`${id}_week_${rowIndex}`} role="row">
182181
{week.map((date) => (
183182
<DayCellButton

packages/lib/src/date-input/DateInput.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ const DxcDateInput = forwardRef<RefType, DateInputPropsType>(
118118
}
119119
const newDate = getDate(newValue, format, lastValidYear, setLastValidYear);
120120
const invalidDateMessage =
121-
newValue !== "" && !newDate.isValid() && translatedLabels?.dateInput?.invalidDateErrorMessage;
121+
newValue !== "" && !newDate.isValid() && translatedLabels.dateInput.invalidDateErrorMessage;
122122
const callbackParams = {
123123
value: newValue,
124124
error: inputError || invalidDateMessage || undefined,
@@ -138,7 +138,7 @@ const DxcDateInput = forwardRef<RefType, DateInputPropsType>(
138138
const handleOnBlur = ({ value: blurValue, error: inputError }: { value: string; error?: string }) => {
139139
const date = getDate(blurValue, format, lastValidYear, setLastValidYear);
140140
const invalidDateMessage =
141-
blurValue !== "" && !date.isValid() && translatedLabels?.dateInput?.invalidDateErrorMessage;
141+
blurValue !== "" && !date.isValid() && translatedLabels.dateInput.invalidDateErrorMessage;
142142
const callbackParams = {
143143
value: blurValue,
144144
error: inputError || invalidDateMessage || undefined,
@@ -233,7 +233,7 @@ const DxcDateInput = forwardRef<RefType, DateInputPropsType>(
233233
disabled={disabled}
234234
hasHelperText={!!helperText}
235235
>
236-
{label} {optional && <OptionalLabel>{translatedLabels?.formFields?.optionalLabel}</OptionalLabel>}
236+
{label} {optional && <OptionalLabel>{translatedLabels.formFields.optionalLabel}</OptionalLabel>}
237237
</Label>
238238
)}
239239
{helperText && <HelperText disabled={disabled}>{helperText}</HelperText>}

packages/lib/src/date-input/DatePicker.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Calendar from "./Calendar";
66
import YearPicker from "./YearPicker";
77
import useTranslatedLabels from "../utils/useTranslatedLabels";
88
import DxcIcon from "../icon/Icon";
9-
import {Tooltip} from "../tooltip/Tooltip";
9+
import { Tooltip } from "../tooltip/Tooltip";
1010

1111
const today = dayjs();
1212

@@ -33,9 +33,9 @@ const DatePicker = ({ date, onDateSelect, id }: DatePickerPropsType): JSX.Elemen
3333
return (
3434
<DatePickerContainer id={id}>
3535
<PickerHeader>
36-
<Tooltip label={translatedLabels?.calendar?.previousMonthTitle}>
36+
<Tooltip label={translatedLabels.calendar.previousMonthTitle}>
3737
<HeaderButton
38-
aria-label={translatedLabels?.calendar?.previousMonthTitle}
38+
aria-label={translatedLabels.calendar.previousMonthTitle}
3939
onClick={() => handleMonthChange(innerDate.set("month", innerDate.get("month") - 1))}
4040
>
4141
<DxcIcon icon="keyboard_arrow_left" />
@@ -46,13 +46,13 @@ const DatePicker = ({ date, onDateSelect, id }: DatePickerPropsType): JSX.Elemen
4646
onClick={() => setContent((currentContent) => (currentContent === "yearPicker" ? "calendar" : "yearPicker"))}
4747
>
4848
<HeaderYearTriggerLabel>
49-
{translatedLabels?.calendar?.months?.[innerDate.get("month")]} {innerDate.format("YYYY")}
49+
{translatedLabels.calendar.months[innerDate.get("month")]} {innerDate.format("YYYY")}
5050
</HeaderYearTriggerLabel>
5151
<DxcIcon icon={content === "yearPicker" ? "arrow_drop_up" : "arrow_drop_down"} />
5252
</HeaderYearTrigger>
53-
<Tooltip label={translatedLabels?.calendar?.nextMonthTitle}>
53+
<Tooltip label={translatedLabels.calendar.nextMonthTitle}>
5454
<HeaderButton
55-
aria-label={translatedLabels?.calendar?.nextMonthTitle}
55+
aria-label={translatedLabels.calendar.nextMonthTitle}
5656
onClick={() => handleMonthChange(innerDate.set("month", innerDate.get("month") + 1))}
5757
>
5858
<DxcIcon icon="keyboard_arrow_right" />

packages/lib/src/dialog/Dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const DxcDialog = ({
127127
onClick={() => {
128128
onCloseClick?.();
129129
}}
130-
aria-label={translatedLabels?.dialog?.closeIconAriaLabel}
130+
aria-label={translatedLabels.dialog.closeIconAriaLabel}
131131
tabIndex={tabIndex}
132132
>
133133
<DxcIcon icon="close" />

packages/lib/src/dropdown/Dropdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ const DxcDropdown = ({
151151
}, [visualFocusIndex]);
152152

153153
return (
154-
<ThemeProvider theme={colorsTheme?.dropdown}>
154+
<ThemeProvider theme={colorsTheme.dropdown}>
155155
<DropdownContainer
156156
onMouseEnter={!disabled && expandOnHover ? handleOnOpenMenu : undefined}
157157
onMouseLeave={!disabled && expandOnHover ? handleOnCloseMenu : undefined}

packages/lib/src/file-input/FileInput.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ const DxcFileInput = forwardRef<RefType, FileInputPropsType>(
6161
const translatedLabels = useTranslatedLabels();
6262

6363
const checkFileSize = (file: File) => {
64-
if (minSize && file.size < minSize) return translatedLabels?.fileInput?.fileSizeGreaterThanErrorMessage;
65-
else if (maxSize && file.size > maxSize) return translatedLabels?.fileInput?.fileSizeLessThanErrorMessage;
64+
if (minSize && file.size < minSize) return translatedLabels.fileInput.fileSizeGreaterThanErrorMessage;
65+
else if (maxSize && file.size > maxSize) return translatedLabels.fileInput.fileSizeLessThanErrorMessage;
6666
};
6767

6868
const getFilesToAdd = async (selectedFiles: File[]) => {
@@ -123,7 +123,7 @@ const DxcFileInput = forwardRef<RefType, FileInputPropsType>(
123123
}
124124
};
125125
const handleDragOut = (e: DragEvent<HTMLDivElement>) => {
126-
// only if dragged items leave container (outside, not to childs)
126+
// only if dragged items leave container (outside, not to children)
127127
if (!e.currentTarget?.contains(e.relatedTarget as HTMLDivElement)) {
128128
setIsDragging(false);
129129
}
@@ -158,7 +158,7 @@ const DxcFileInput = forwardRef<RefType, FileInputPropsType>(
158158
}, [value]);
159159

160160
return (
161-
<ThemeProvider theme={colorsTheme?.fileInput}>
161+
<ThemeProvider theme={colorsTheme.fileInput}>
162162
<FileInputContainer margin={margin} ref={ref}>
163163
<Label htmlFor={fileInputId} disabled={disabled}>
164164
{label}
@@ -180,8 +180,8 @@ const DxcFileInput = forwardRef<RefType, FileInputPropsType>(
180180
label={
181181
buttonLabel ??
182182
(multiple
183-
? translatedLabels?.fileInput?.multipleButtonLabelDefault
184-
: translatedLabels?.fileInput?.singleButtonLabelDefault)
183+
? translatedLabels.fileInput.multipleButtonLabelDefault
184+
: translatedLabels.fileInput.singleButtonLabelDefault)
185185
}
186186
onClick={handleClick}
187187
disabled={disabled}
@@ -228,7 +228,7 @@ const DxcFileInput = forwardRef<RefType, FileInputPropsType>(
228228
>
229229
<DxcButton
230230
mode="secondary"
231-
label={buttonLabel ?? translatedLabels?.fileInput?.dropAreaButtonLabelDefault}
231+
label={buttonLabel ?? translatedLabels.fileInput.dropAreaButtonLabelDefault}
232232
onClick={handleClick}
233233
disabled={disabled}
234234
size={{ width: "fitContent" }}
@@ -237,15 +237,15 @@ const DxcFileInput = forwardRef<RefType, FileInputPropsType>(
237237
<DropzoneLabel disabled={disabled}>
238238
{dropAreaLabel ??
239239
(multiple
240-
? translatedLabels?.fileInput?.multipleDropAreaLabelDefault
241-
: translatedLabels?.fileInput?.singleDropAreaLabelDefault)}
240+
? translatedLabels.fileInput.multipleDropAreaLabelDefault
241+
: translatedLabels.fileInput.singleDropAreaLabelDefault)}
242242
</DropzoneLabel>
243243
) : (
244244
<FiledropLabel disabled={disabled}>
245245
{dropAreaLabel ??
246246
(multiple
247-
? translatedLabels?.fileInput?.multipleDropAreaLabelDefault
248-
: translatedLabels?.fileInput?.singleDropAreaLabelDefault)}
247+
? translatedLabels.fileInput.multipleDropAreaLabelDefault
248+
: translatedLabels.fileInput.singleDropAreaLabelDefault)}
249249
</FiledropLabel>
250250
)}
251251
</DragDropArea>

0 commit comments

Comments
 (0)