@rovula/ui 0.1.16 → 0.1.18
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.
- package/dist/cjs/bundle.css +6 -0
- package/dist/cjs/bundle.js +1 -1
- package/dist/cjs/bundle.js.map +1 -1
- package/dist/cjs/types/patterns/confirm-dialog/ConfirmDialog.d.ts +2 -0
- package/dist/cjs/types/patterns/confirm-dialog/ConfirmDialog.stories.d.ts +2 -0
- package/dist/cjs/types/patterns/form-dialog/FormDialog.d.ts +1 -0
- package/dist/components/AlertDialog/AlertDialog.js +2 -2
- package/dist/esm/bundle.css +6 -0
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/types/patterns/confirm-dialog/ConfirmDialog.d.ts +2 -0
- package/dist/esm/types/patterns/confirm-dialog/ConfirmDialog.stories.d.ts +2 -0
- package/dist/esm/types/patterns/form-dialog/FormDialog.d.ts +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/patterns/confirm-dialog/ConfirmDialog.js +2 -2
- package/dist/patterns/form-dialog/FormDialog.js +1 -1
- package/dist/src/theme/global.css +8 -0
- package/package.json +1 -1
- package/src/components/AlertDialog/AlertDialog.tsx +2 -2
- package/src/patterns/confirm-dialog/ConfirmDialog.tsx +6 -0
- package/src/patterns/form-dialog/FormDialog.tsx +4 -0
|
@@ -22,6 +22,8 @@ declare const meta: {
|
|
|
22
22
|
typeToConfirm?: string | undefined;
|
|
23
23
|
hideCancelButton?: boolean | undefined;
|
|
24
24
|
testId?: string | undefined;
|
|
25
|
+
cancelClassName?: string | undefined;
|
|
26
|
+
confirmClassName?: string | undefined;
|
|
25
27
|
}>) => import("react/jsx-runtime").JSX.Element)[];
|
|
26
28
|
argTypes: {
|
|
27
29
|
open: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1304,6 +1304,8 @@ type ConfirmDialogProps = {
|
|
|
1304
1304
|
*/
|
|
1305
1305
|
hideCancelButton?: boolean;
|
|
1306
1306
|
testId?: string;
|
|
1307
|
+
cancelClassName?: string;
|
|
1308
|
+
confirmClassName?: string;
|
|
1307
1309
|
};
|
|
1308
1310
|
declare const ConfirmDialog: React.FC<ConfirmDialogProps>;
|
|
1309
1311
|
|
|
@@ -1315,6 +1317,7 @@ type FormDialogAction = {
|
|
|
1315
1317
|
disabled?: boolean;
|
|
1316
1318
|
isLoading?: boolean;
|
|
1317
1319
|
type?: "button" | "submit" | "reset";
|
|
1320
|
+
className?: string;
|
|
1318
1321
|
};
|
|
1319
1322
|
type FormDialogProps = {
|
|
1320
1323
|
open?: boolean;
|
|
@@ -5,7 +5,7 @@ import * as yup from "yup";
|
|
|
5
5
|
import { AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogAction, AlertDialogCancel, AlertDialogTrigger, } from "@/components/AlertDialog/AlertDialog";
|
|
6
6
|
import { useControlledForm, Field } from "@/components/Form";
|
|
7
7
|
import { TextInput } from "@/components/TextInput/TextInput";
|
|
8
|
-
export const ConfirmDialog = ({ open, onOpenChange, title, description, confirmLabel = "Confirm", cancelLabel = "Cancel", onConfirm, onCancel, onClose, trigger, typeToConfirm, hideCancelButton = false, testId, }) => {
|
|
8
|
+
export const ConfirmDialog = ({ open, onOpenChange, title, description, confirmLabel = "Confirm", cancelLabel = "Cancel", onConfirm, onCancel, onClose, trigger, typeToConfirm, hideCancelButton = false, testId, cancelClassName, confirmClassName, }) => {
|
|
9
9
|
const formId = React.useId();
|
|
10
10
|
const requiresInput = !!typeToConfirm;
|
|
11
11
|
const validationSchema = React.useMemo(() => yup.object({
|
|
@@ -40,6 +40,6 @@ export const ConfirmDialog = ({ open, onOpenChange, title, description, confirmL
|
|
|
40
40
|
keepFooterSpace: true,
|
|
41
41
|
fullwidth: true,
|
|
42
42
|
testId: testId && `${testId}-type-to-confirm-input`,
|
|
43
|
-
} })] })), _jsxs(AlertDialogFooter, { children: [!hideCancelButton && (_jsx(AlertDialogCancel, { "data-testid": testId && `${testId}-cancel-button`, onClick: handleCancel, children: cancelLabel })), _jsx(AlertDialogAction, { type: "submit", form: requiresInput ? formId : undefined, disabled: requiresInput && !isFormValid, onClick: requiresInput ? undefined : () => onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(), "data-testid": testId && `${testId}-confirm-button`, children: confirmLabel })] })] })] }));
|
|
43
|
+
} })] })), _jsxs(AlertDialogFooter, { children: [!hideCancelButton && (_jsx(AlertDialogCancel, { className: cancelClassName, "data-testid": testId && `${testId}-cancel-button`, onClick: handleCancel, children: cancelLabel })), _jsx(AlertDialogAction, { type: "submit", form: requiresInput ? formId : undefined, disabled: requiresInput && !isFormValid, onClick: requiresInput ? undefined : () => onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(), className: confirmClassName, "data-testid": testId && `${testId}-confirm-button`, children: confirmLabel })] })] })] }));
|
|
44
44
|
};
|
|
45
45
|
ConfirmDialog.displayName = "ConfirmDialog";
|
|
@@ -5,6 +5,6 @@ import Button from "@/components/Button/Button";
|
|
|
5
5
|
export const FormDialog = ({ open, onOpenChange, title, description, children, trigger, confirmAction, cancelAction, extraAction, scrollable = false, className, formId, testId, }) => {
|
|
6
6
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
7
7
|
const hasFooter = confirmAction || cancelAction || extraAction;
|
|
8
|
-
return (_jsxs(Dialog, { open: open, onOpenChange: onOpenChange, children: [trigger && _jsx(DialogTrigger, { asChild: true, children: trigger }), _jsxs(DialogContent, { className: className, "data-testid": testId, children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { "data-testid": testId && `${testId}-title`, children: title }), description && (_jsx(DialogDescription, { "data-testid": testId && `${testId}-description`, children: description }))] }), children && (_jsx(DialogBody, { scrollable: scrollable, children: children })), hasFooter && (_jsxs(DialogFooter, { className: extraAction ? "justify-between" : undefined, children: [extraAction && (_jsx(Button, { type: (_a = extraAction.type) !== null && _a !== void 0 ? _a : "button", variant: (_b = extraAction.variant) !== null && _b !== void 0 ? _b : "outline", color: (_c = extraAction.color) !== null && _c !== void 0 ? _c : "secondary", fullwidth: false, disabled: extraAction.disabled, isLoading: extraAction.isLoading, onClick: extraAction.onClick, "data-testid": testId && `${testId}-extra-button`, children: extraAction.label })), _jsxs("div", { className: "flex items-center gap-4", children: [cancelAction && (_jsx(Button, { type: (_d = cancelAction.type) !== null && _d !== void 0 ? _d : "button", variant: (_e = cancelAction.variant) !== null && _e !== void 0 ? _e : "outline", color: (_f = cancelAction.color) !== null && _f !== void 0 ? _f : "primary", fullwidth: false, disabled: cancelAction.disabled, isLoading: cancelAction.isLoading, onClick: cancelAction.onClick, "data-testid": testId && `${testId}-cancel-button`, children: cancelAction.label })), confirmAction && (_jsx(Button, { type: formId ? "submit" : (_g = confirmAction.type) !== null && _g !== void 0 ? _g : "button", form: formId, variant: (_h = confirmAction.variant) !== null && _h !== void 0 ? _h : "solid", color: (_j = confirmAction.color) !== null && _j !== void 0 ? _j : "primary", fullwidth: false, disabled: confirmAction.disabled, isLoading: confirmAction.isLoading, onClick: confirmAction.onClick, "data-testid": testId && `${testId}-confirm-button`, children: confirmAction.label }))] })] }))] })] }));
|
|
8
|
+
return (_jsxs(Dialog, { open: open, onOpenChange: onOpenChange, children: [trigger && _jsx(DialogTrigger, { asChild: true, children: trigger }), _jsxs(DialogContent, { className: className, "data-testid": testId, children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { "data-testid": testId && `${testId}-title`, children: title }), description && (_jsx(DialogDescription, { "data-testid": testId && `${testId}-description`, children: description }))] }), children && (_jsx(DialogBody, { scrollable: scrollable, children: children })), hasFooter && (_jsxs(DialogFooter, { className: extraAction ? "justify-between" : undefined, children: [extraAction && (_jsx(Button, { type: (_a = extraAction.type) !== null && _a !== void 0 ? _a : "button", variant: (_b = extraAction.variant) !== null && _b !== void 0 ? _b : "outline", color: (_c = extraAction.color) !== null && _c !== void 0 ? _c : "secondary", fullwidth: false, disabled: extraAction.disabled, isLoading: extraAction.isLoading, onClick: extraAction.onClick, className: extraAction.className, "data-testid": testId && `${testId}-extra-button`, children: extraAction.label })), _jsxs("div", { className: "flex items-center gap-4", children: [cancelAction && (_jsx(Button, { type: (_d = cancelAction.type) !== null && _d !== void 0 ? _d : "button", variant: (_e = cancelAction.variant) !== null && _e !== void 0 ? _e : "outline", color: (_f = cancelAction.color) !== null && _f !== void 0 ? _f : "primary", fullwidth: false, disabled: cancelAction.disabled, isLoading: cancelAction.isLoading, onClick: cancelAction.onClick, className: cancelAction.className, "data-testid": testId && `${testId}-cancel-button`, children: cancelAction.label })), confirmAction && (_jsx(Button, { type: formId ? "submit" : (_g = confirmAction.type) !== null && _g !== void 0 ? _g : "button", form: formId, variant: (_h = confirmAction.variant) !== null && _h !== void 0 ? _h : "solid", color: (_j = confirmAction.color) !== null && _j !== void 0 ? _j : "primary", fullwidth: false, disabled: confirmAction.disabled, isLoading: confirmAction.isLoading, onClick: confirmAction.onClick, className: confirmAction.className, "data-testid": testId && `${testId}-confirm-button`, children: confirmAction.label }))] })] }))] })] }));
|
|
9
9
|
};
|
|
10
10
|
FormDialog.displayName = "FormDialog";
|
|
@@ -4259,6 +4259,10 @@ input[type=number] {
|
|
|
4259
4259
|
min-width: 18rem;
|
|
4260
4260
|
}
|
|
4261
4261
|
|
|
4262
|
+
.min-w-\[100px\] {
|
|
4263
|
+
min-width: 100px;
|
|
4264
|
+
}
|
|
4265
|
+
|
|
4262
4266
|
.min-w-\[154px\] {
|
|
4263
4267
|
min-width: 154px;
|
|
4264
4268
|
}
|
|
@@ -4641,6 +4645,10 @@ input[type=number] {
|
|
|
4641
4645
|
white-space: nowrap;
|
|
4642
4646
|
}
|
|
4643
4647
|
|
|
4648
|
+
.whitespace-pre-line {
|
|
4649
|
+
white-space: pre-line;
|
|
4650
|
+
}
|
|
4651
|
+
|
|
4644
4652
|
.break-all {
|
|
4645
4653
|
word-break: break-all;
|
|
4646
4654
|
}
|
package/package.json
CHANGED
|
@@ -101,7 +101,7 @@ const AlertDialogAction = React.forwardRef<
|
|
|
101
101
|
ref={ref}
|
|
102
102
|
className={cn(
|
|
103
103
|
buttonVariants({ fullwidth: false }),
|
|
104
|
-
"w-[100px] justify-center",
|
|
104
|
+
"min-w-[100px] justify-center",
|
|
105
105
|
className,
|
|
106
106
|
)}
|
|
107
107
|
{...props}
|
|
@@ -117,7 +117,7 @@ const AlertDialogCancel = React.forwardRef<
|
|
|
117
117
|
ref={ref}
|
|
118
118
|
className={cn(
|
|
119
119
|
buttonVariants({ fullwidth: false, variant: "outline" }),
|
|
120
|
-
"w-[100px] justify-center",
|
|
120
|
+
"min-w-[100px] justify-center whitespace-pre-line",
|
|
121
121
|
className,
|
|
122
122
|
)}
|
|
123
123
|
{...props}
|
|
@@ -38,6 +38,8 @@ export type ConfirmDialogProps = {
|
|
|
38
38
|
*/
|
|
39
39
|
hideCancelButton?: boolean;
|
|
40
40
|
testId?: string;
|
|
41
|
+
cancelClassName?: string;
|
|
42
|
+
confirmClassName?: string;
|
|
41
43
|
};
|
|
42
44
|
|
|
43
45
|
type ConfirmFormValues = { confirmInput: string };
|
|
@@ -56,6 +58,8 @@ export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
|
|
|
56
58
|
typeToConfirm,
|
|
57
59
|
hideCancelButton = false,
|
|
58
60
|
testId,
|
|
61
|
+
cancelClassName,
|
|
62
|
+
confirmClassName,
|
|
59
63
|
}) => {
|
|
60
64
|
const formId = React.useId();
|
|
61
65
|
const requiresInput = !!typeToConfirm;
|
|
@@ -140,6 +144,7 @@ export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
|
|
|
140
144
|
<AlertDialogFooter>
|
|
141
145
|
{!hideCancelButton && (
|
|
142
146
|
<AlertDialogCancel
|
|
147
|
+
className={cancelClassName}
|
|
143
148
|
data-testid={testId && `${testId}-cancel-button`}
|
|
144
149
|
onClick={handleCancel}
|
|
145
150
|
>
|
|
@@ -151,6 +156,7 @@ export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
|
|
|
151
156
|
form={requiresInput ? formId : undefined}
|
|
152
157
|
disabled={requiresInput && !isFormValid}
|
|
153
158
|
onClick={requiresInput ? undefined : () => onConfirm?.()}
|
|
159
|
+
className={confirmClassName}
|
|
154
160
|
data-testid={testId && `${testId}-confirm-button`}
|
|
155
161
|
>
|
|
156
162
|
{confirmLabel}
|
|
@@ -22,6 +22,7 @@ export type FormDialogAction = {
|
|
|
22
22
|
disabled?: boolean;
|
|
23
23
|
isLoading?: boolean;
|
|
24
24
|
type?: "button" | "submit" | "reset";
|
|
25
|
+
className?: string;
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
export type FormDialogProps = {
|
|
@@ -98,6 +99,7 @@ export const FormDialog: React.FC<FormDialogProps> = ({
|
|
|
98
99
|
disabled={extraAction.disabled}
|
|
99
100
|
isLoading={extraAction.isLoading}
|
|
100
101
|
onClick={extraAction.onClick}
|
|
102
|
+
className={extraAction.className}
|
|
101
103
|
data-testid={testId && `${testId}-extra-button`}
|
|
102
104
|
>
|
|
103
105
|
{extraAction.label}
|
|
@@ -113,6 +115,7 @@ export const FormDialog: React.FC<FormDialogProps> = ({
|
|
|
113
115
|
disabled={cancelAction.disabled}
|
|
114
116
|
isLoading={cancelAction.isLoading}
|
|
115
117
|
onClick={cancelAction.onClick}
|
|
118
|
+
className={cancelAction.className}
|
|
116
119
|
data-testid={testId && `${testId}-cancel-button`}
|
|
117
120
|
>
|
|
118
121
|
{cancelAction.label}
|
|
@@ -128,6 +131,7 @@ export const FormDialog: React.FC<FormDialogProps> = ({
|
|
|
128
131
|
disabled={confirmAction.disabled}
|
|
129
132
|
isLoading={confirmAction.isLoading}
|
|
130
133
|
onClick={confirmAction.onClick}
|
|
134
|
+
className={confirmAction.className}
|
|
131
135
|
data-testid={testId && `${testId}-confirm-button`}
|
|
132
136
|
>
|
|
133
137
|
{confirmAction.label}
|