myoperator-ui 0.0.131 → 0.0.133
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/index.js +155 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3570,6 +3570,161 @@ const ConfirmationModal = React.forwardRef<
|
|
|
3570
3570
|
ConfirmationModal.displayName = "ConfirmationModal";
|
|
3571
3571
|
|
|
3572
3572
|
export { ConfirmationModal };
|
|
3573
|
+
`, prefix)
|
|
3574
|
+
}
|
|
3575
|
+
]
|
|
3576
|
+
},
|
|
3577
|
+
"form-modal": {
|
|
3578
|
+
name: "form-modal",
|
|
3579
|
+
description: "A reusable modal component for forms with consistent layout",
|
|
3580
|
+
dependencies: [
|
|
3581
|
+
"clsx",
|
|
3582
|
+
"tailwind-merge"
|
|
3583
|
+
],
|
|
3584
|
+
internalDependencies: [
|
|
3585
|
+
"dialog",
|
|
3586
|
+
"button"
|
|
3587
|
+
],
|
|
3588
|
+
files: [
|
|
3589
|
+
{
|
|
3590
|
+
name: "form-modal.tsx",
|
|
3591
|
+
content: prefixTailwindClasses(`import * as React from "react";
|
|
3592
|
+
|
|
3593
|
+
import { cn } from "../../lib/utils";
|
|
3594
|
+
import {
|
|
3595
|
+
Dialog,
|
|
3596
|
+
DialogContent,
|
|
3597
|
+
DialogHeader,
|
|
3598
|
+
DialogFooter,
|
|
3599
|
+
DialogTitle,
|
|
3600
|
+
DialogDescription,
|
|
3601
|
+
} from "./dialog";
|
|
3602
|
+
import { Button } from "./button";
|
|
3603
|
+
|
|
3604
|
+
/**
|
|
3605
|
+
* Props for the FormModal component
|
|
3606
|
+
*/
|
|
3607
|
+
export interface FormModalProps {
|
|
3608
|
+
/** Controls modal visibility (controlled mode) */
|
|
3609
|
+
open: boolean;
|
|
3610
|
+
/** Callback when open state changes */
|
|
3611
|
+
onOpenChange: (open: boolean) => void;
|
|
3612
|
+
/** Modal title */
|
|
3613
|
+
title: React.ReactNode;
|
|
3614
|
+
/** Optional modal description */
|
|
3615
|
+
description?: React.ReactNode;
|
|
3616
|
+
/** Form content (inputs, selects, etc.) */
|
|
3617
|
+
children: React.ReactNode;
|
|
3618
|
+
/** Called when user saves/submits the form */
|
|
3619
|
+
onSave?: () => void;
|
|
3620
|
+
/** Called when user cancels */
|
|
3621
|
+
onCancel?: () => void;
|
|
3622
|
+
/** Loading state for save button */
|
|
3623
|
+
loading?: boolean;
|
|
3624
|
+
/** Text for save button (default: "Save") */
|
|
3625
|
+
saveButtonText?: string;
|
|
3626
|
+
/** Text for cancel button (default: "Cancel") */
|
|
3627
|
+
cancelButtonText?: string;
|
|
3628
|
+
/** Disable the save button */
|
|
3629
|
+
disableSave?: boolean;
|
|
3630
|
+
/** Additional className for the dialog content */
|
|
3631
|
+
className?: string;
|
|
3632
|
+
/** Size of the dialog */
|
|
3633
|
+
size?: "sm" | "default" | "lg" | "xl" | "full";
|
|
3634
|
+
}
|
|
3635
|
+
|
|
3636
|
+
/**
|
|
3637
|
+
* A reusable modal component for forms with inputs, selects, and other form controls.
|
|
3638
|
+
* Provides consistent layout and spacing for form-based dialogs.
|
|
3639
|
+
*
|
|
3640
|
+
* @example
|
|
3641
|
+
* Basic usage with form fields
|
|
3642
|
+
*
|
|
3643
|
+
* \`\`\`tsx
|
|
3644
|
+
* const [isOpen, setIsOpen] = useState(false);
|
|
3645
|
+
* const [name, setName] = useState('');
|
|
3646
|
+
*
|
|
3647
|
+
* <FormModal
|
|
3648
|
+
* open={isOpen}
|
|
3649
|
+
* onOpenChange={setIsOpen}
|
|
3650
|
+
* title="Edit Profile"
|
|
3651
|
+
* description="Make changes to your profile here."
|
|
3652
|
+
* onSave={handleSave}
|
|
3653
|
+
* loading={loading}
|
|
3654
|
+
* >
|
|
3655
|
+
* <div className="grid gap-2">
|
|
3656
|
+
* <label htmlFor="name">Name</label>
|
|
3657
|
+
* <Input id="name" value={name} onChange={e => setName(e.target.value)} />
|
|
3658
|
+
* </div>
|
|
3659
|
+
* </FormModal>
|
|
3660
|
+
* \`\`\`
|
|
3661
|
+
*/
|
|
3662
|
+
const FormModal = React.forwardRef<HTMLDivElement, FormModalProps>(
|
|
3663
|
+
(
|
|
3664
|
+
{
|
|
3665
|
+
open,
|
|
3666
|
+
onOpenChange,
|
|
3667
|
+
title,
|
|
3668
|
+
description,
|
|
3669
|
+
children,
|
|
3670
|
+
onSave,
|
|
3671
|
+
onCancel,
|
|
3672
|
+
loading = false,
|
|
3673
|
+
saveButtonText = "Save",
|
|
3674
|
+
cancelButtonText = "Cancel",
|
|
3675
|
+
disableSave = false,
|
|
3676
|
+
className,
|
|
3677
|
+
size = "sm",
|
|
3678
|
+
},
|
|
3679
|
+
ref
|
|
3680
|
+
) => {
|
|
3681
|
+
const handleSave = () => {
|
|
3682
|
+
onSave?.();
|
|
3683
|
+
};
|
|
3684
|
+
|
|
3685
|
+
const handleCancel = () => {
|
|
3686
|
+
onCancel?.();
|
|
3687
|
+
onOpenChange?.(false);
|
|
3688
|
+
};
|
|
3689
|
+
|
|
3690
|
+
return (
|
|
3691
|
+
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
3692
|
+
<DialogContent ref={ref} size={size} className={cn(className)}>
|
|
3693
|
+
<DialogHeader>
|
|
3694
|
+
<DialogTitle>{title}</DialogTitle>
|
|
3695
|
+
{description && (
|
|
3696
|
+
<DialogDescription>{description}</DialogDescription>
|
|
3697
|
+
)}
|
|
3698
|
+
</DialogHeader>
|
|
3699
|
+
|
|
3700
|
+
{/* Form content with consistent spacing */}
|
|
3701
|
+
<div className="grid gap-4 py-4">{children}</div>
|
|
3702
|
+
|
|
3703
|
+
<DialogFooter className="gap-2 sm:gap-0">
|
|
3704
|
+
<Button
|
|
3705
|
+
variant="outline"
|
|
3706
|
+
onClick={handleCancel}
|
|
3707
|
+
disabled={loading}
|
|
3708
|
+
>
|
|
3709
|
+
{cancelButtonText}
|
|
3710
|
+
</Button>
|
|
3711
|
+
<Button
|
|
3712
|
+
variant="default"
|
|
3713
|
+
onClick={handleSave}
|
|
3714
|
+
disabled={loading || disableSave}
|
|
3715
|
+
loading={loading}
|
|
3716
|
+
>
|
|
3717
|
+
{saveButtonText}
|
|
3718
|
+
</Button>
|
|
3719
|
+
</DialogFooter>
|
|
3720
|
+
</DialogContent>
|
|
3721
|
+
</Dialog>
|
|
3722
|
+
);
|
|
3723
|
+
}
|
|
3724
|
+
);
|
|
3725
|
+
FormModal.displayName = "FormModal";
|
|
3726
|
+
|
|
3727
|
+
export { FormModal };
|
|
3573
3728
|
`, prefix)
|
|
3574
3729
|
}
|
|
3575
3730
|
]
|