Skip to content

Commit

Permalink
refactor(core): ♻️ correct 'OnChange' to 'onChange' props
Browse files Browse the repository at this point in the history
correct 'OnChange' to 'onChange' props

ref: #183
  • Loading branch information
irkfaisal committed Apr 5, 2024
1 parent 7107046 commit 69ead92
Show file tree
Hide file tree
Showing 18 changed files with 52 additions and 48 deletions.
2 changes: 1 addition & 1 deletion package/components/dataDisplay/CoreEmailOrPhoneLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function CoreEmailOrPhoneLink(props) {
{!props.verified && (
<CoreTextButton
label="Verify"
OnClick={() => HandleModalOpen(props)}
onClick={() => HandleModalOpen(props)}
/>
)}
</CoreTypographyBody1>
Expand Down
2 changes: 1 addition & 1 deletion package/components/dataDisplay/CoreTimer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function CoreTimer({ seconds, action, actionLabel, timerLabel })
timer === 0 ?
<CoreBox
styleClasses={[CoreClasses.TEXT.TEXT_CENTER, CoreClasses.MARGIN.MT1]}>
<CoreTextButton OnClick={action} label={actionLabel} />
<CoreTextButton onClick={action} label={actionLabel} />
</CoreBox>
:
<CoreTypographyBody2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export default function CoreDataTableRow(props) {
label={
createEntityButtonText || `Add ${getLabel(tableUUID || "")}`
}
OnClick={() => {
onClick={() => {
setDetailedRowId(null);
setDetailedRowData(null);
set_showDetailsPane(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export default function CoreDataTableToolbar(props) {
label={`${createEntityButtonText || getLabel(tableUUID)}`}
variant="outlined"
startIcon={<CoreIcon>add</CoreIcon>}
OnClick={() => {
onClick={() => {
if (navigationOnCreateUrl) {
navigate(navigationOnCreateUrl);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function CoreTableAction(props) {
label={action?.label}
icon={action?.icon}
disabled={action.disabled}
OnClick={() => {
onClick={() => {
if (action.clearRowData) {
set_showDetailsPane(true);
setDetailedRowId(null);
Expand Down
2 changes: 1 addition & 1 deletion package/components/dataDisplay/dataTable/FilterData.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default function FilterData(props) {
<CoreIcon>add</CoreIcon>&nbsp;Add Filter
</>
}
OnClick={() => {
onClick={() => {
set_filterDatas([..._filterDatas, _filterOB]);
}}
/>
Expand Down
2 changes: 1 addition & 1 deletion package/components/inputs/CoreButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CoreButton.validProps = [
types: [{ type: "string" }]
},
{
name : "OnClick",
name : "onClick",
types: [{ type: "function" }],
},
{
Expand Down
4 changes: 2 additions & 2 deletions package/components/inputs/CoreIconButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export default function CoreIconButton(props) {
CoreIconButton.validProps = [
...CoreButton.validProps,
{
name : "OnClick", /// temporary adding 'OnClick' it should come default from CoreButton which is 'onClick'. OnClick should changed to onClick
name : "onClick", /// temporary adding 'onClick' it should come default from CoreButton which is 'onClick'. onClick should changed to onClick
types: [{ type: "function" }]
},
{
name : "onClick", /// we have already a OnClick props available in CoreButton but it's starting with Capital 'O' that's need to be changed to present 'onClicl' props.
name : "onClick", /// we have already a onClick props available in CoreButton but it's starting with Capital 'O' that's need to be changed to present 'onClicl' props.
types: [{ type: "function" }],
},
{
Expand Down
2 changes: 1 addition & 1 deletion package/components/inputs/CoreResponsiveButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function CoreResponsiveButton(props) {
<CoreIconButton
styleClasses={[CoreClasses.DISPLAY.BLOCK, CoreClasses.DISPLAY.SM.NONE]}
title={props?.label || props?.title}
onClick={props?.OnClick || props?.onClick}
onClick={props?.onClick || props?.onClick}
>
<CoreIcon
options={
Expand Down
2 changes: 1 addition & 1 deletion package/components/inputs/forms/CoreFieldButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function CoreFieldButton(props) {
onClick={
element.actionType === "submit"
? formikprops?.handleSubmit
: buttonProps?.OnClick
: buttonProps?.onClick
}
>
<CoreIcon fontSize="small">
Expand Down
54 changes: 27 additions & 27 deletions package/components/inputs/forms/CoreForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -831,9 +831,9 @@ class CoreForm extends Component {
? allowAdd !== false
? [
{
OnClick: this.OnAdd,
disable: preview,
icon : "add",
onClick: this.OnAdd,
title : "add",
},
]
Expand All @@ -842,42 +842,42 @@ class CoreForm extends Component {
? allowDelete !== false
? [
{
OnClick: this.OnEditClick,
disable: preview,
icon : "edit_note",
onClick: this.OnEditClick,
title : "edit",
},
{
OnClick: this.OnDeleteClick,

// -- OnClick: () => {
// -- onClick: () => {
// // alert("Single component delete tobe done");
// },
disable: preview,

icon : "delete_outline",
onClick: this.OnDeleteClick,
title : "delete",
},
]
: [
{
OnClick: this.OnEditClick,
disable: preview,
icon : "edit_note",
onClick: this.OnEditClick,
title : "edit",
},
]
: allowDelete !== false
? [
{
OnClick: this.OnDeleteClick,

disable: preview,

icon : "delete_outline",
// -- OnClick: () => {
icon: "delete_outline",

onClick: this.OnDeleteClick,
// -- onClick: () => {
// alert("Single component delete tobe done");
// },
title: "delete",
title : "delete",
},
]
: []
Expand Down Expand Up @@ -971,7 +971,9 @@ class CoreForm extends Component {
? allowDelete !== false
? [
{
OnClick:
disable: preview,
icon : "edit_note",
onClick:
processedForms[formId] &&
processedForms[formId]
.arrayDataNotEditable
Expand All @@ -988,12 +990,12 @@ class CoreForm extends Component {
// );
}
: this.OnEditClick,
disable: preview,
icon : "edit_note",
title : "edit",
title: "edit",
},
{
OnClick:
disable: preview,
icon : "delete_outline",
onClick:
processedForms[formId] &&
processedForms[formId]
.arrayDataNotDeletable
Expand All @@ -1010,14 +1012,14 @@ class CoreForm extends Component {
// );
}
: this.OnDeleteClick,
disable: preview,
icon : "delete_outline",
title : "delete",
title: "delete",
},
]
: [
mode === FORM_EDIT_MODE && {
OnClick:
disable: preview,
icon : "edit_note",
onClick:
processedForms[formId] &&
processedForms[formId]
.arrayDataNotEditable
Expand All @@ -1033,15 +1035,15 @@ class CoreForm extends Component {
// );
}
: this.OnEditClick,
disable: preview,
icon : "edit_note",
title : "edit",
title: "edit",
},
]
: allowDelete !== false
? [
{
OnClick:
disable: preview,
icon : "delete_outline",
onClick:
processedForms[formId] &&
processedForms[formId]
.arrayDataNotDeletable
Expand All @@ -1057,9 +1059,7 @@ class CoreForm extends Component {
// );
}
: this.OnDeleteClick,
disable: preview,
icon : "delete_outline",
title : "delete",
title: "delete",
},
]
: []
Expand Down
4 changes: 2 additions & 2 deletions package/components/inputs/forms/CoreFormHeaderActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function CoreFormHeaderActions(props) {
title={action.title}
disabled={action.disable}
onClick={() => {
action.OnClick(props.id);
action.onClick(props.id);
}}>
<CoreIcon>{action.icon}</CoreIcon>
</CoreIconButton>
Expand All @@ -40,7 +40,7 @@ export default function CoreFormHeaderActions(props) {
<CoreIconButton
disabled={props.action.disable}
title={props.action.title}
onClick={props.action.OnClick}>
onClick={props.action.onClick}>
<CoreIcon>{props.action.icon}</CoreIcon>
</CoreIconButton>
)
Expand Down
4 changes: 2 additions & 2 deletions package/components/inputs/forms/CoreFormInputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export default function CoreFormInputs(props) {
: "Cancel"
}
disabled={submitLoading || preview}
OnClick={OnCancelClick}
onClick={OnCancelClick}
/>
)}

Expand All @@ -204,7 +204,7 @@ export default function CoreFormInputs(props) {
}
disabled={submitLoading || preview}
type="submit"
OnClick={formikprops.handleSubmit}
onClick={formikprops.handleSubmit}
/>
)}
</CoreBox>
Expand Down
2 changes: 1 addition & 1 deletion package/components/surfaces/CoreCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CoreCard.validProps = [
types : [{ default: false, type: "boolean", validValues: [true, false] }],
},
{
name : "onClick", /// we have already a OnClick props available in CoreButton but it's starting with Capital 'O' that's need to be changed to present 'onClicl' props.
name : "onClick", /// we have already a onClick props available in CoreButton but it's starting with Capital 'O' that's need to be changed to present 'onClicl' props.
types: [{ type: "function" }],
},
];
Expand Down
4 changes: 4 additions & 0 deletions package/components/surfaces/CoreDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export default function CoreDrawer(props) {
}

CoreDrawer.validProps = [
{
name : "toggleDrawer",
types: [{ type: "function" }],
},
{
description: "Side from which the drawer will appear.",
name : "anchor",
Expand Down
2 changes: 1 addition & 1 deletion package/components/utils/CoreProfilePopOver.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default function CoreProfilePopOver(props) {
label="Logout"
variant="contained"
fullWidth={true}
OnClick={() => {
onClick={() => {
/**
* @todo have to make a route for logout
*/
Expand Down
2 changes: 1 addition & 1 deletion package/theme/ThemeSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function ThemeSelector() {
Current Theme: {themes[userThemeID || config?.defaultTheme]?.name || "Unknown"}
</CoreTypographyCaption>

<CoreTextButton OnClick={() => {
<CoreTextButton onClick={() => {
setThemeChangeFormEnable(true);
}}>Change</CoreTextButton>
</>
Expand Down
6 changes: 3 additions & 3 deletions package/utils/formUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,9 @@ export function createFormActionProps(element) {

export function createFormButtonProps(element, formikprops, handleButtonCLick) {
return {
OnClick: element.onClick
alignment: element.actionContainerStyle ? null : "end",
label : element.label,
onClick : element.onClick
? typeof element.onClick === "object"
? () => {
handleButtonCLick(element.onClick, formikprops?.values);
Expand All @@ -480,8 +482,6 @@ export function createFormButtonProps(element, formikprops, handleButtonCLick) {
: () => {
alert("error in button action");
},
alignment : element.actionContainerStyle ? null : "end",
label : element.label,
styleClasses: element.styleClasses || [],
type : element.actionType === "submit" ? "submit" : "button",
};
Expand Down

0 comments on commit 69ead92

Please sign in to comment.