-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(queryBuilder): add query-builder component (#3318)
* feat(queryBuilder): add query-builder component * fix: style order * style: add cx, change paddings * chore: remove unused style * fix: fix style order, add more typechecks
- Loading branch information
Showing
46 changed files
with
4,088 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
packages/core/src/components/QueryBuilder/ConfirmationDialog/ConfirmationDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { | ||
HvButton, | ||
HvDialog, | ||
HvDialogActions, | ||
HvDialogContent, | ||
HvDialogTitle, | ||
} from "@core/components"; | ||
import { ClassNames } from "@emotion/react"; | ||
|
||
export interface ConfirmationDialogProps { | ||
title?: string; | ||
message?: string; | ||
isOpen?: boolean; | ||
onConfirm?: (event: React.MouseEvent<HTMLButtonElement> | Event) => void; | ||
onCancel?: () => void; | ||
confirmButtonLabel?: string; | ||
cancelButtonLabel?: string; | ||
closeButtonTooltip?: string; | ||
} | ||
|
||
export const ConfirmationDialog = ({ | ||
title, | ||
message, | ||
isOpen, | ||
onConfirm, | ||
onCancel, | ||
confirmButtonLabel, | ||
cancelButtonLabel, | ||
closeButtonTooltip, | ||
}: ConfirmationDialogProps) => { | ||
const handleClose = (event, reason) => { | ||
if (reason !== "backdropClick") { | ||
onCancel?.(); | ||
} | ||
}; | ||
|
||
return ( | ||
<ClassNames> | ||
{({ css }) => ( | ||
<HvDialog | ||
classes={{ paper: css({ width: 500 }) }} | ||
open={isOpen} | ||
onClose={handleClose} | ||
firstFocusable="confirmation-dialog-cancel" | ||
buttonTitle={closeButtonTooltip} | ||
> | ||
<HvDialogTitle variant="warning">{title}</HvDialogTitle> | ||
<HvDialogContent indentContent>{message}</HvDialogContent> | ||
<HvDialogActions> | ||
<HvButton variant="primaryGhost" onClick={onConfirm}> | ||
{confirmButtonLabel} | ||
</HvButton> | ||
<HvButton | ||
id="confirmation-dialog-cancel" | ||
variant="primaryGhost" | ||
onClick={() => onCancel?.()} | ||
> | ||
{cancelButtonLabel} | ||
</HvButton> | ||
</HvDialogActions> | ||
</HvDialog> | ||
)} | ||
</ClassNames> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/core/src/components/QueryBuilder/ConfirmationDialog/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./ConfirmationDialog"; |
Oops, something went wrong.