@rovula/ui 0.1.37 → 0.1.39

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.
@@ -24,6 +24,11 @@ export type ConfirmDialogProps = {
24
24
  /** When true, shows a loading spinner on the confirm button and disables all interactive controls. */
25
25
  isLoading?: boolean;
26
26
  testId?: string;
27
+ contentClassName?: string;
28
+ headerClassName?: string;
29
+ titleClassName?: string;
30
+ descriptionClassName?: string;
31
+ footerClassName?: string;
27
32
  cancelClassName?: string;
28
33
  confirmClassName?: string;
29
34
  };
@@ -24,6 +24,11 @@ declare const meta: {
24
24
  hideCancelButton?: boolean | undefined;
25
25
  isLoading?: boolean | undefined;
26
26
  testId?: string | undefined;
27
+ contentClassName?: string | undefined;
28
+ headerClassName?: string | undefined;
29
+ titleClassName?: string | undefined;
30
+ descriptionClassName?: string | undefined;
31
+ footerClassName?: string | undefined;
27
32
  cancelClassName?: string | undefined;
28
33
  confirmClassName?: string | undefined;
29
34
  }>) => import("react/jsx-runtime").JSX.Element)[];
package/dist/index.d.ts CHANGED
@@ -1699,6 +1699,11 @@ type ConfirmDialogProps = {
1699
1699
  /** When true, shows a loading spinner on the confirm button and disables all interactive controls. */
1700
1700
  isLoading?: boolean;
1701
1701
  testId?: string;
1702
+ contentClassName?: string;
1703
+ headerClassName?: string;
1704
+ titleClassName?: string;
1705
+ descriptionClassName?: string;
1706
+ footerClassName?: string;
1702
1707
  cancelClassName?: string;
1703
1708
  confirmClassName?: string;
1704
1709
  };
@@ -6,7 +6,7 @@ import { AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, A
6
6
  import { useControlledForm, Field } from "@/components/Form";
7
7
  import { TextInput } from "@/components/TextInput/TextInput";
8
8
  import Loading from "@/components/Loading/Loading";
9
- export const ConfirmDialog = ({ open, onOpenChange, title, description, children, confirmLabel = "Confirm", cancelLabel = "Cancel", onConfirm, onCancel, onClose, trigger, typeToConfirm, hideCancelButton = false, isLoading = false, testId, cancelClassName, confirmClassName, }) => {
9
+ export const ConfirmDialog = ({ open, onOpenChange, title, description, children, confirmLabel = "Confirm", cancelLabel = "Cancel", onConfirm, onCancel, onClose, trigger, typeToConfirm, hideCancelButton = false, isLoading = false, testId, contentClassName, headerClassName, titleClassName, descriptionClassName, footerClassName, cancelClassName, confirmClassName, }) => {
10
10
  const requiresInput = !!typeToConfirm;
11
11
  const validationSchema = React.useMemo(() => yup.object({
12
12
  confirmInput: yup
@@ -41,14 +41,17 @@ export const ConfirmDialog = ({ open, onOpenChange, title, description, children
41
41
  const handleSubmit = () => {
42
42
  onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm();
43
43
  };
44
- return (_jsxs(AlertDialog, { open: open, onOpenChange: handleOpenChange, children: [trigger && _jsx(AlertDialogTrigger, { asChild: true, children: trigger }), _jsxs(AlertDialogContent, { "data-testid": testId, children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { "data-testid": testId && `${testId}-title`, children: title }), description && (_jsx(AlertDialogDescription, { "data-testid": testId && `${testId}-description`, children: description }))] }), children, requiresInput && (_jsxs(FormRoot, { className: "flex flex-col gap-4 w-full", onSubmit: handleSubmit, children: [_jsxs("p", { className: "typography-small1 text-text-contrast-max", children: ["Type \u201C", typeToConfirm, "\u201D to proceed."] }), _jsx(Field, { name: "confirmInput", component: TextInput, componentProps: {
44
+ return (_jsxs(AlertDialog, { open: open, onOpenChange: handleOpenChange, children: [trigger && _jsx(AlertDialogTrigger, { asChild: true, children: trigger }), _jsxs(AlertDialogContent, { className: contentClassName, "data-testid": testId, onCloseAutoFocus: (event) => {
45
+ event.preventDefault();
46
+ document.body.style.pointerEvents = "auto";
47
+ }, children: [_jsxs(AlertDialogHeader, { className: headerClassName, children: [_jsx(AlertDialogTitle, { className: titleClassName, "data-testid": testId && `${testId}-title`, children: title }), description && (_jsx(AlertDialogDescription, { className: descriptionClassName, "data-testid": testId && `${testId}-description`, children: description }))] }), children, requiresInput && (_jsxs(FormRoot, { className: "flex flex-col gap-4 w-full", onSubmit: handleSubmit, children: [_jsxs("p", { className: "typography-small1 text-text-contrast-max", children: ["Type \u201C", typeToConfirm, "\u201D to proceed."] }), _jsx(Field, { name: "confirmInput", component: TextInput, componentProps: {
45
48
  label: "Type to confirm",
46
49
  required: true,
47
50
  hasClearIcon: true,
48
51
  keepFooterSpace: true,
49
52
  fullwidth: true,
50
53
  testId: testId && `${testId}-type-to-confirm-input`,
51
- }, disabled: isLoading })] })), _jsxs(AlertDialogFooter, { children: [!hideCancelButton && (_jsx(AlertDialogCancel, { className: cancelClassName, "data-testid": testId && `${testId}-cancel-button`, onClick: handleCancel, disabled: isLoading, children: cancelLabel })), _jsxs(AlertDialogAction, { type: "button", disabled: isLoading || (requiresInput && !isFormValid), onClick: (e) => {
54
+ }, disabled: isLoading })] })), _jsxs(AlertDialogFooter, { className: footerClassName, children: [!hideCancelButton && (_jsx(AlertDialogCancel, { className: cancelClassName, "data-testid": testId && `${testId}-cancel-button`, onClick: handleCancel, disabled: isLoading, children: cancelLabel })), _jsxs(AlertDialogAction, { type: "button", disabled: isLoading || (requiresInput && !isFormValid), onClick: (e) => {
52
55
  e.preventDefault();
53
56
  if (requiresInput) {
54
57
  methods.handleSubmit(handleSubmit)();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rovula/ui",
3
- "version": "0.1.37",
3
+ "version": "0.1.39",
4
4
  "main": "dist/cjs/bundle.js",
5
5
  "module": "dist/esm/bundle.js",
6
6
  "types": "dist/index.d.ts",
@@ -42,6 +42,11 @@ export type ConfirmDialogProps = {
42
42
  /** When true, shows a loading spinner on the confirm button and disables all interactive controls. */
43
43
  isLoading?: boolean;
44
44
  testId?: string;
45
+ contentClassName?: string;
46
+ headerClassName?: string;
47
+ titleClassName?: string;
48
+ descriptionClassName?: string;
49
+ footerClassName?: string;
45
50
  cancelClassName?: string;
46
51
  confirmClassName?: string;
47
52
  };
@@ -64,6 +69,11 @@ export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
64
69
  hideCancelButton = false,
65
70
  isLoading = false,
66
71
  testId,
72
+ contentClassName,
73
+ headerClassName,
74
+ titleClassName,
75
+ descriptionClassName,
76
+ footerClassName,
67
77
  cancelClassName,
68
78
  confirmClassName,
69
79
  }) => {
@@ -119,13 +129,24 @@ export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
119
129
  return (
120
130
  <AlertDialog open={open} onOpenChange={handleOpenChange}>
121
131
  {trigger && <AlertDialogTrigger asChild>{trigger}</AlertDialogTrigger>}
122
- <AlertDialogContent data-testid={testId}>
123
- <AlertDialogHeader>
124
- <AlertDialogTitle data-testid={testId && `${testId}-title`}>
132
+ <AlertDialogContent
133
+ className={contentClassName}
134
+ data-testid={testId}
135
+ onCloseAutoFocus={(event) => {
136
+ event.preventDefault();
137
+ document.body.style.pointerEvents = "auto";
138
+ }}
139
+ >
140
+ <AlertDialogHeader className={headerClassName}>
141
+ <AlertDialogTitle
142
+ className={titleClassName}
143
+ data-testid={testId && `${testId}-title`}
144
+ >
125
145
  {title}
126
146
  </AlertDialogTitle>
127
147
  {description && (
128
148
  <AlertDialogDescription
149
+ className={descriptionClassName}
129
150
  data-testid={testId && `${testId}-description`}
130
151
  >
131
152
  {description}
@@ -159,7 +180,7 @@ export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
159
180
  </FormRoot>
160
181
  )}
161
182
 
162
- <AlertDialogFooter>
183
+ <AlertDialogFooter className={footerClassName}>
163
184
  {!hideCancelButton && (
164
185
  <AlertDialogCancel
165
186
  className={cancelClassName}