@rovula/ui 0.1.16 → 0.1.20

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.
@@ -4,6 +4,7 @@ export type ConfirmDialogProps = {
4
4
  onOpenChange?: (open: boolean) => void;
5
5
  title: string;
6
6
  description?: string;
7
+ children?: React.ReactNode;
7
8
  confirmLabel?: string;
8
9
  cancelLabel?: string;
9
10
  onConfirm?: () => void;
@@ -21,5 +22,7 @@ export type ConfirmDialogProps = {
21
22
  */
22
23
  hideCancelButton?: boolean;
23
24
  testId?: string;
25
+ cancelClassName?: string;
26
+ confirmClassName?: string;
24
27
  };
25
28
  export declare const ConfirmDialog: React.FC<ConfirmDialogProps>;
@@ -13,6 +13,7 @@ declare const meta: {
13
13
  onOpenChange?: ((open: boolean) => void) | undefined;
14
14
  title: string;
15
15
  description?: string | undefined;
16
+ children?: React.ReactNode;
16
17
  confirmLabel?: string | undefined;
17
18
  cancelLabel?: string | undefined;
18
19
  onConfirm?: (() => void) | undefined;
@@ -22,6 +23,8 @@ declare const meta: {
22
23
  typeToConfirm?: string | undefined;
23
24
  hideCancelButton?: boolean | undefined;
24
25
  testId?: string | undefined;
26
+ cancelClassName?: string | undefined;
27
+ confirmClassName?: string | undefined;
25
28
  }>) => import("react/jsx-runtime").JSX.Element)[];
26
29
  argTypes: {
27
30
  open: {
@@ -8,6 +8,7 @@ export type FormDialogAction = {
8
8
  disabled?: boolean;
9
9
  isLoading?: boolean;
10
10
  type?: "button" | "submit" | "reset";
11
+ className?: string;
11
12
  };
12
13
  export type FormDialogProps = {
13
14
  open?: boolean;
package/dist/index.d.ts CHANGED
@@ -1287,6 +1287,7 @@ type ConfirmDialogProps = {
1287
1287
  onOpenChange?: (open: boolean) => void;
1288
1288
  title: string;
1289
1289
  description?: string;
1290
+ children?: React.ReactNode;
1290
1291
  confirmLabel?: string;
1291
1292
  cancelLabel?: string;
1292
1293
  onConfirm?: () => void;
@@ -1304,6 +1305,8 @@ type ConfirmDialogProps = {
1304
1305
  */
1305
1306
  hideCancelButton?: boolean;
1306
1307
  testId?: string;
1308
+ cancelClassName?: string;
1309
+ confirmClassName?: string;
1307
1310
  };
1308
1311
  declare const ConfirmDialog: React.FC<ConfirmDialogProps>;
1309
1312
 
@@ -1315,6 +1318,7 @@ type FormDialogAction = {
1315
1318
  disabled?: boolean;
1316
1319
  isLoading?: boolean;
1317
1320
  type?: "button" | "submit" | "reset";
1321
+ className?: string;
1318
1322
  };
1319
1323
  type FormDialogProps = {
1320
1324
  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, children, 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({
@@ -33,13 +33,13 @@ export const ConfirmDialog = ({ open, onOpenChange, title, description, confirmL
33
33
  onCancel === null || onCancel === void 0 ? void 0 : onCancel();
34
34
  onClose === null || onClose === void 0 ? void 0 : onClose();
35
35
  };
36
- 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 }))] }), requiresInput && (_jsxs(FormRoot, { id: formId, className: "flex flex-col gap-4 w-full", onSubmit: () => onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(), children: [_jsxs("p", { className: "typography-small1 text-text-contrast-max", children: ["Type \u201C", typeToConfirm, "\u201D to proceed."] }), _jsx(Field, { name: "confirmInput", component: TextInput, componentProps: {
36
+ 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, { id: formId, className: "flex flex-col gap-4 w-full", onSubmit: () => onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(), children: [_jsxs("p", { className: "typography-small1 text-text-contrast-max", children: ["Type \u201C", typeToConfirm, "\u201D to proceed."] }), _jsx(Field, { name: "confirmInput", component: TextInput, componentProps: {
37
37
  label: "Type to confirm",
38
38
  required: true,
39
39
  hasClearIcon: true,
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: [title && (_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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rovula/ui",
3
- "version": "0.1.16",
3
+ "version": "0.1.20",
4
4
  "main": "dist/cjs/bundle.js",
5
5
  "module": "dist/esm/bundle.js",
6
6
  "types": "dist/index.d.ts",
@@ -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}
@@ -21,6 +21,7 @@ export type ConfirmDialogProps = {
21
21
  onOpenChange?: (open: boolean) => void;
22
22
  title: string;
23
23
  description?: string;
24
+ children?: React.ReactNode;
24
25
  confirmLabel?: string;
25
26
  cancelLabel?: string;
26
27
  onConfirm?: () => void;
@@ -38,6 +39,8 @@ export type ConfirmDialogProps = {
38
39
  */
39
40
  hideCancelButton?: boolean;
40
41
  testId?: string;
42
+ cancelClassName?: string;
43
+ confirmClassName?: string;
41
44
  };
42
45
 
43
46
  type ConfirmFormValues = { confirmInput: string };
@@ -47,6 +50,7 @@ export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
47
50
  onOpenChange,
48
51
  title,
49
52
  description,
53
+ children,
50
54
  confirmLabel = "Confirm",
51
55
  cancelLabel = "Cancel",
52
56
  onConfirm,
@@ -56,6 +60,8 @@ export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
56
60
  typeToConfirm,
57
61
  hideCancelButton = false,
58
62
  testId,
63
+ cancelClassName,
64
+ confirmClassName,
59
65
  }) => {
60
66
  const formId = React.useId();
61
67
  const requiresInput = !!typeToConfirm;
@@ -113,6 +119,8 @@ export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
113
119
  )}
114
120
  </AlertDialogHeader>
115
121
 
122
+ {children}
123
+
116
124
  {requiresInput && (
117
125
  <FormRoot
118
126
  id={formId}
@@ -140,6 +148,7 @@ export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
140
148
  <AlertDialogFooter>
141
149
  {!hideCancelButton && (
142
150
  <AlertDialogCancel
151
+ className={cancelClassName}
143
152
  data-testid={testId && `${testId}-cancel-button`}
144
153
  onClick={handleCancel}
145
154
  >
@@ -151,6 +160,7 @@ export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
151
160
  form={requiresInput ? formId : undefined}
152
161
  disabled={requiresInput && !isFormValid}
153
162
  onClick={requiresInput ? undefined : () => onConfirm?.()}
163
+ className={confirmClassName}
154
164
  data-testid={testId && `${testId}-confirm-button`}
155
165
  >
156
166
  {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 = {
@@ -75,7 +76,11 @@ export const FormDialog: React.FC<FormDialogProps> = ({
75
76
  {trigger && <DialogTrigger asChild>{trigger}</DialogTrigger>}
76
77
  <DialogContent className={className} data-testid={testId}>
77
78
  <DialogHeader>
78
- <DialogTitle data-testid={testId && `${testId}-title`}>{title}</DialogTitle>
79
+ {title && (
80
+ <DialogTitle data-testid={testId && `${testId}-title`}>
81
+ {title}
82
+ </DialogTitle>
83
+ )}
79
84
  {description && (
80
85
  <DialogDescription data-testid={testId && `${testId}-description`}>
81
86
  {description}
@@ -98,6 +103,7 @@ export const FormDialog: React.FC<FormDialogProps> = ({
98
103
  disabled={extraAction.disabled}
99
104
  isLoading={extraAction.isLoading}
100
105
  onClick={extraAction.onClick}
106
+ className={extraAction.className}
101
107
  data-testid={testId && `${testId}-extra-button`}
102
108
  >
103
109
  {extraAction.label}
@@ -113,6 +119,7 @@ export const FormDialog: React.FC<FormDialogProps> = ({
113
119
  disabled={cancelAction.disabled}
114
120
  isLoading={cancelAction.isLoading}
115
121
  onClick={cancelAction.onClick}
122
+ className={cancelAction.className}
116
123
  data-testid={testId && `${testId}-cancel-button`}
117
124
  >
118
125
  {cancelAction.label}
@@ -128,6 +135,7 @@ export const FormDialog: React.FC<FormDialogProps> = ({
128
135
  disabled={confirmAction.disabled}
129
136
  isLoading={confirmAction.isLoading}
130
137
  onClick={confirmAction.onClick}
138
+ className={confirmAction.className}
131
139
  data-testid={testId && `${testId}-confirm-button`}
132
140
  >
133
141
  {confirmAction.label}