@sustaina/shared-ui 1.10.0 → 1.11.0
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.d.mts +49 -2
- package/dist/index.d.ts +49 -2
- package/dist/index.js +171 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +172 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -20,6 +20,7 @@ import * as SelectPrimitive from '@radix-ui/react-select';
|
|
|
20
20
|
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
21
21
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
22
22
|
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
23
|
+
import { Area, CropperProps } from 'react-easy-crop';
|
|
23
24
|
import { ClassValue } from 'clsx';
|
|
24
25
|
|
|
25
26
|
declare function Accordion({ ...props }: React$1.ComponentProps<typeof AccordionPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
@@ -854,6 +855,7 @@ declare const index_CollapsibleContent: typeof CollapsibleContent;
|
|
|
854
855
|
declare const index_CollapsibleTrigger: typeof CollapsibleTrigger;
|
|
855
856
|
declare const index_Dialog: typeof Dialog;
|
|
856
857
|
declare const index_DialogContent: typeof DialogContent;
|
|
858
|
+
type index_DialogContentProps = DialogContentProps;
|
|
857
859
|
declare const index_DialogDescription: typeof DialogDescription;
|
|
858
860
|
declare const index_DialogFooter: typeof DialogFooter;
|
|
859
861
|
declare const index_DialogTitle: typeof DialogTitle;
|
|
@@ -939,7 +941,7 @@ declare const index_spinnerVariants: typeof spinnerVariants;
|
|
|
939
941
|
declare const index_useFormField: typeof useFormField;
|
|
940
942
|
declare const index_useSidebar: typeof useSidebar;
|
|
941
943
|
declare namespace index {
|
|
942
|
-
export { index_Accordion as Accordion, index_AccordionContent as AccordionContent, index_AccordionItem as AccordionItem, index_AccordionTrigger as AccordionTrigger, index_Button as Button, index_Checkbox as Checkbox, index_ClearButton as ClearButton, index_Collapsible as Collapsible, index_CollapsibleContent as CollapsibleContent, index_CollapsibleTrigger as CollapsibleTrigger, DatePicker$1 as DatePicker, index_Dialog as Dialog, index_DialogContent as DialogContent, index_DialogDescription as DialogDescription, index_DialogFooter as DialogFooter, index_DialogTitle as DialogTitle, index_DialogTrigger as DialogTrigger, index_Form as Form, index_FormControl as FormControl, index_FormDescription as FormDescription, index_FormField as FormField, index_FormItem as FormItem, index_FormLabel as FormLabel, index_FormMessage as FormMessage, index_InputPrimitive as InputPrimitive, type index_InputPrimitiveProps as InputPrimitiveProps, index_Label as Label, MonthPicker$1 as MonthPicker, type MonthPickerProps$1 as MonthPickerProps, index_Popover as Popover, index_PopoverAnchor as PopoverAnchor, index_PopoverArrow as PopoverArrow, index_PopoverContent as PopoverContent, index_PopoverTrigger as PopoverTrigger, index_RadioGroupItem as RadioGroupItem, index_RadioGroupRoot as RadioGroupRoot, index_RadioLabel as RadioLabel, index_RichText as RichText, index_Select as Select, index_SelectContent as SelectContent, index_SelectGroup as SelectGroup, index_SelectItem as SelectItem, index_SelectLabel as SelectLabel, index_SelectScrollDownButton as SelectScrollDownButton, index_SelectScrollUpButton as SelectScrollUpButton, index_SelectSeparator as SelectSeparator, index_SelectTrigger as SelectTrigger, index_SelectValue as SelectValue, index_Separator as Separator, index_Sheet as Sheet, index_SheetClose as SheetClose, index_SheetContent as SheetContent, index_SheetDescription as SheetDescription, index_SheetFooter as SheetFooter, index_SheetHeader as SheetHeader, index_SheetTitle as SheetTitle, index_SheetTrigger as SheetTrigger, index_Sidebar as Sidebar, index_SidebarContent as SidebarContent, index_SidebarFooter as SidebarFooter, index_SidebarGroup as SidebarGroup, index_SidebarGroupAction as SidebarGroupAction, index_SidebarGroupContent as SidebarGroupContent, index_SidebarGroupLabel as SidebarGroupLabel, index_SidebarHeader as SidebarHeader, index_SidebarInput as SidebarInput, index_SidebarInset as SidebarInset, index_SidebarLayout as SidebarLayout, index_SidebarMenu as SidebarMenu, index_SidebarMenuAction as SidebarMenuAction, index_SidebarMenuBadge as SidebarMenuBadge, index_SidebarMenuButton as SidebarMenuButton, index_SidebarMenuItem as SidebarMenuItem, index_SidebarMenuSkeleton as SidebarMenuSkeleton, index_SidebarMenuSub as SidebarMenuSub, index_SidebarMenuSubButton as SidebarMenuSubButton, index_SidebarMenuSubItem as SidebarMenuSubItem, index_SidebarProvider as SidebarProvider, index_SidebarRail as SidebarRail, index_SidebarSeparator as SidebarSeparator, index_SidebarTrigger as SidebarTrigger, index_Skeleton as Skeleton, index_Spinner as Spinner, type index_SpinnerProps as SpinnerProps, index_Switch as Switch, index_Table as Table, index_TableBody as TableBody, index_TableCaption as TableCaption, index_TableCell as TableCell, index_TableContainer as TableContainer, index_TableFooter as TableFooter, index_TableHead as TableHead, index_TableHeader as TableHeader, index_TableRow as TableRow, index_Textarea as Textarea, Tooltip$1 as Tooltip, TooltipContent$1 as TooltipContent, TooltipProvider$1 as TooltipProvider, TooltipTrigger$1 as TooltipTrigger, index_buttonVariants as buttonVariants, index_spinnerVariants as spinnerVariants, index_useFormField as useFormField, index_useSidebar as useSidebar };
|
|
944
|
+
export { index_Accordion as Accordion, index_AccordionContent as AccordionContent, index_AccordionItem as AccordionItem, index_AccordionTrigger as AccordionTrigger, index_Button as Button, index_Checkbox as Checkbox, index_ClearButton as ClearButton, index_Collapsible as Collapsible, index_CollapsibleContent as CollapsibleContent, index_CollapsibleTrigger as CollapsibleTrigger, DatePicker$1 as DatePicker, index_Dialog as Dialog, index_DialogContent as DialogContent, type index_DialogContentProps as DialogContentProps, index_DialogDescription as DialogDescription, index_DialogFooter as DialogFooter, index_DialogTitle as DialogTitle, index_DialogTrigger as DialogTrigger, index_Form as Form, index_FormControl as FormControl, index_FormDescription as FormDescription, index_FormField as FormField, index_FormItem as FormItem, index_FormLabel as FormLabel, index_FormMessage as FormMessage, index_InputPrimitive as InputPrimitive, type index_InputPrimitiveProps as InputPrimitiveProps, index_Label as Label, MonthPicker$1 as MonthPicker, type MonthPickerProps$1 as MonthPickerProps, index_Popover as Popover, index_PopoverAnchor as PopoverAnchor, index_PopoverArrow as PopoverArrow, index_PopoverContent as PopoverContent, index_PopoverTrigger as PopoverTrigger, index_RadioGroupItem as RadioGroupItem, index_RadioGroupRoot as RadioGroupRoot, index_RadioLabel as RadioLabel, index_RichText as RichText, index_Select as Select, index_SelectContent as SelectContent, index_SelectGroup as SelectGroup, index_SelectItem as SelectItem, index_SelectLabel as SelectLabel, index_SelectScrollDownButton as SelectScrollDownButton, index_SelectScrollUpButton as SelectScrollUpButton, index_SelectSeparator as SelectSeparator, index_SelectTrigger as SelectTrigger, index_SelectValue as SelectValue, index_Separator as Separator, index_Sheet as Sheet, index_SheetClose as SheetClose, index_SheetContent as SheetContent, index_SheetDescription as SheetDescription, index_SheetFooter as SheetFooter, index_SheetHeader as SheetHeader, index_SheetTitle as SheetTitle, index_SheetTrigger as SheetTrigger, index_Sidebar as Sidebar, index_SidebarContent as SidebarContent, index_SidebarFooter as SidebarFooter, index_SidebarGroup as SidebarGroup, index_SidebarGroupAction as SidebarGroupAction, index_SidebarGroupContent as SidebarGroupContent, index_SidebarGroupLabel as SidebarGroupLabel, index_SidebarHeader as SidebarHeader, index_SidebarInput as SidebarInput, index_SidebarInset as SidebarInset, index_SidebarLayout as SidebarLayout, index_SidebarMenu as SidebarMenu, index_SidebarMenuAction as SidebarMenuAction, index_SidebarMenuBadge as SidebarMenuBadge, index_SidebarMenuButton as SidebarMenuButton, index_SidebarMenuItem as SidebarMenuItem, index_SidebarMenuSkeleton as SidebarMenuSkeleton, index_SidebarMenuSub as SidebarMenuSub, index_SidebarMenuSubButton as SidebarMenuSubButton, index_SidebarMenuSubItem as SidebarMenuSubItem, index_SidebarProvider as SidebarProvider, index_SidebarRail as SidebarRail, index_SidebarSeparator as SidebarSeparator, index_SidebarTrigger as SidebarTrigger, index_Skeleton as Skeleton, index_Spinner as Spinner, type index_SpinnerProps as SpinnerProps, index_Switch as Switch, index_Table as Table, index_TableBody as TableBody, index_TableCaption as TableCaption, index_TableCell as TableCell, index_TableContainer as TableContainer, index_TableFooter as TableFooter, index_TableHead as TableHead, index_TableHeader as TableHeader, index_TableRow as TableRow, index_Textarea as Textarea, Tooltip$1 as Tooltip, TooltipContent$1 as TooltipContent, TooltipProvider$1 as TooltipProvider, TooltipTrigger$1 as TooltipTrigger, index_buttonVariants as buttonVariants, index_spinnerVariants as spinnerVariants, index_useFormField as useFormField, index_useSidebar as useSidebar };
|
|
943
945
|
}
|
|
944
946
|
|
|
945
947
|
type SidebarContextProps = {
|
|
@@ -1019,6 +1021,51 @@ declare function TooltipTrigger({ ...props }: React$1.ComponentProps<typeof Tool
|
|
|
1019
1021
|
declare function TooltipArrow(props: React$1.ComponentProps<typeof TooltipPrimitive.Arrow>): react_jsx_runtime.JSX.Element;
|
|
1020
1022
|
declare function TooltipContent({ className, sideOffset, children, ...props }: React$1.ComponentProps<typeof TooltipPrimitive.Content>): react_jsx_runtime.JSX.Element;
|
|
1021
1023
|
|
|
1024
|
+
interface CroppedImagePayload {
|
|
1025
|
+
crop: {
|
|
1026
|
+
x: number;
|
|
1027
|
+
y: number;
|
|
1028
|
+
};
|
|
1029
|
+
croppedAreaPixels: Area | null;
|
|
1030
|
+
}
|
|
1031
|
+
interface CroppedImagePayloadWithBlobUrl extends CroppedImagePayload {
|
|
1032
|
+
croppedImageBlobUrl: string;
|
|
1033
|
+
}
|
|
1034
|
+
interface CropperModalBaseProps {
|
|
1035
|
+
open?: boolean;
|
|
1036
|
+
onOpenChange: (open: boolean) => void;
|
|
1037
|
+
onCancel?: () => void;
|
|
1038
|
+
onError?: (e: unknown) => void;
|
|
1039
|
+
imageSrc?: string | null;
|
|
1040
|
+
cropSize?: {
|
|
1041
|
+
width: number;
|
|
1042
|
+
height: number;
|
|
1043
|
+
};
|
|
1044
|
+
/**
|
|
1045
|
+
* @property {boolean} outputExactCropSize - Determine whether to ouput image with the exact size given in cropSize attribute
|
|
1046
|
+
* @description an original image dimension is 1000x1000px, if cropSize is 500x500px, the output image will be exactly 500x500px
|
|
1047
|
+
*/
|
|
1048
|
+
outputExactCropSize?: boolean;
|
|
1049
|
+
title?: string;
|
|
1050
|
+
props?: {
|
|
1051
|
+
dialogTitleContainer?: React.ComponentProps<"div">;
|
|
1052
|
+
dialogTitle?: React.ComponentProps<typeof SheetPrimitive.Title>;
|
|
1053
|
+
dialogContent?: DialogContentProps;
|
|
1054
|
+
cropper?: CropperProps;
|
|
1055
|
+
cropperContainer?: React.ComponentProps<"div">;
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
interface CropperModalWithBlobUrlOutputProps extends CropperModalBaseProps {
|
|
1059
|
+
onConfirm?: (payload: CroppedImagePayloadWithBlobUrl) => void;
|
|
1060
|
+
generateBlobUrlOutput: true;
|
|
1061
|
+
}
|
|
1062
|
+
interface CropperModalNormalProps extends CropperModalBaseProps {
|
|
1063
|
+
onConfirm?: (payload: CroppedImagePayload) => void;
|
|
1064
|
+
generateBlobUrlOutput: undefined | false;
|
|
1065
|
+
}
|
|
1066
|
+
type CropperModalProps = CropperModalWithBlobUrlOutputProps | CropperModalNormalProps;
|
|
1067
|
+
declare const CropperModal: ({ open, onOpenChange, imageSrc, onConfirm, onCancel, onError, cropSize, outputExactCropSize, generateBlobUrlOutput, title, props }: CropperModalProps) => react_jsx_runtime.JSX.Element;
|
|
1068
|
+
|
|
1022
1069
|
declare function isDefined(value: any): boolean;
|
|
1023
1070
|
declare function isEmptyObject(value: any): boolean;
|
|
1024
1071
|
type DebounceOptions = {
|
|
@@ -1116,4 +1163,4 @@ type UseTruncatedOptions<T> = {
|
|
|
1116
1163
|
type UseTruncatedResult = boolean;
|
|
1117
1164
|
declare const useTruncated: <T extends HTMLElement = any>({ elementRef, onChange, resizeDetectDelay }: UseTruncatedOptions<T>) => UseTruncatedResult;
|
|
1118
1165
|
|
|
1119
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AdvanceSearch, ArrowIcon, type Breakpoints, Button, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, type Column, DataTable, type DataTableChildrenKeyHandler, type DataTableColumnFilter, type DataTableColumnFilterProps, type DataTableColumnGrouping, type DataTableColumnOrdering, type DataTableColumnPinning, type DataTableColumnSeparatorProps, type DataTableColumnSorting, type DataTableColumnVisibility, type DataTableComponentProps, type DataTableFilterConfig, type DataTableFilters, type DataTableGlobalFilter, type DataTableHeaderCell, type DataTableProps, type DataTableRenderHeaderHandler, type DataTableRenderHeaderProps, type DataTableRenderRowHandler, type DataTableRenderRowProps, type DataTableRowCell, type DataTableRowClickHandler, type DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, DatePicker, type DatePickerProps, type DebounceOptions, type DebouncedFunction, Dialog, DialogAlert, type DialogAlertProps, DialogContent, DialogDescription, DialogFooter, DialogTitle, DialogTrigger, type DialogVariant, type FieldSchema, type FieldType, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, type GridPayload, GridSettingsModal, type GridSettingsModalProps, HeaderCell, type HeaderCellProps, Input, type InputProps, Label, List, ListContainer, type ListContainerProps, ListHeader, type ListHeaderProps, type ListProps, ListTable, type ListTableProps, LookupSelect, type LookupSelectOption, type LookupSelectProps, MonthPicker, type MonthPickerProps, _default as Navbar, type NavbarProps, NotFoundIcon, type Params, Popover, PopoverAnchor, PopoverArrow, PopoverContent, PopoverTrigger, PreventPageLeave, RadioGroupItem, RadioGroupRoot, RadioLabel, RichText, type RowClickType, type RowState, type ScrollInfo, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarLayout, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, type SorterProps, type StatusContentKey, SuiCalendarIcon, SuiCheckIcon, SuiDotsVerticalIcon, SuiEmptyDataIcon, SuiExpandIcon, SuiFilterIcon, SuiSettingIcon, SuiTriangleDownIcon, SuiWarningIcon, Switch, Textarea, Tooltip, TooltipArrow, TooltipContent, TooltipProvider, TooltipTrigger, index as UI, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UsePreventPageLeaveOptions, type UseScreenSizeResult, type UseTruncatedOptions, type UseTruncatedResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, debounce, inputVariants, isDefined, isEmptyObject, selectValueToBoolean, stripNullishObject, throttle, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize, useSidebar, useTruncated };
|
|
1166
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AdvanceSearch, ArrowIcon, type Breakpoints, Button, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, type Column, type CroppedImagePayload, type CroppedImagePayloadWithBlobUrl, CropperModal, type CropperModalProps, DataTable, type DataTableChildrenKeyHandler, type DataTableColumnFilter, type DataTableColumnFilterProps, type DataTableColumnGrouping, type DataTableColumnOrdering, type DataTableColumnPinning, type DataTableColumnSeparatorProps, type DataTableColumnSorting, type DataTableColumnVisibility, type DataTableComponentProps, type DataTableFilterConfig, type DataTableFilters, type DataTableGlobalFilter, type DataTableHeaderCell, type DataTableProps, type DataTableRenderHeaderHandler, type DataTableRenderHeaderProps, type DataTableRenderRowHandler, type DataTableRenderRowProps, type DataTableRowCell, type DataTableRowClickHandler, type DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, DatePicker, type DatePickerProps, type DebounceOptions, type DebouncedFunction, Dialog, DialogAlert, type DialogAlertProps, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, DialogTitle, DialogTrigger, type DialogVariant, type FieldSchema, type FieldType, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, type GridPayload, GridSettingsModal, type GridSettingsModalProps, HeaderCell, type HeaderCellProps, Input, type InputProps, Label, List, ListContainer, type ListContainerProps, ListHeader, type ListHeaderProps, type ListProps, ListTable, type ListTableProps, LookupSelect, type LookupSelectOption, type LookupSelectProps, MonthPicker, type MonthPickerProps, _default as Navbar, type NavbarProps, NotFoundIcon, type Params, Popover, PopoverAnchor, PopoverArrow, PopoverContent, PopoverTrigger, PreventPageLeave, RadioGroupItem, RadioGroupRoot, RadioLabel, RichText, type RowClickType, type RowState, type ScrollInfo, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarLayout, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, type SorterProps, type StatusContentKey, SuiCalendarIcon, SuiCheckIcon, SuiDotsVerticalIcon, SuiEmptyDataIcon, SuiExpandIcon, SuiFilterIcon, SuiSettingIcon, SuiTriangleDownIcon, SuiWarningIcon, Switch, Textarea, Tooltip, TooltipArrow, TooltipContent, TooltipProvider, TooltipTrigger, index as UI, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UsePreventPageLeaveOptions, type UseScreenSizeResult, type UseTruncatedOptions, type UseTruncatedResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, debounce, inputVariants, isDefined, isEmptyObject, selectValueToBoolean, stripNullishObject, throttle, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize, useSidebar, useTruncated };
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ import * as SelectPrimitive from '@radix-ui/react-select';
|
|
|
20
20
|
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
21
21
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
22
22
|
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
23
|
+
import { Area, CropperProps } from 'react-easy-crop';
|
|
23
24
|
import { ClassValue } from 'clsx';
|
|
24
25
|
|
|
25
26
|
declare function Accordion({ ...props }: React$1.ComponentProps<typeof AccordionPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
@@ -854,6 +855,7 @@ declare const index_CollapsibleContent: typeof CollapsibleContent;
|
|
|
854
855
|
declare const index_CollapsibleTrigger: typeof CollapsibleTrigger;
|
|
855
856
|
declare const index_Dialog: typeof Dialog;
|
|
856
857
|
declare const index_DialogContent: typeof DialogContent;
|
|
858
|
+
type index_DialogContentProps = DialogContentProps;
|
|
857
859
|
declare const index_DialogDescription: typeof DialogDescription;
|
|
858
860
|
declare const index_DialogFooter: typeof DialogFooter;
|
|
859
861
|
declare const index_DialogTitle: typeof DialogTitle;
|
|
@@ -939,7 +941,7 @@ declare const index_spinnerVariants: typeof spinnerVariants;
|
|
|
939
941
|
declare const index_useFormField: typeof useFormField;
|
|
940
942
|
declare const index_useSidebar: typeof useSidebar;
|
|
941
943
|
declare namespace index {
|
|
942
|
-
export { index_Accordion as Accordion, index_AccordionContent as AccordionContent, index_AccordionItem as AccordionItem, index_AccordionTrigger as AccordionTrigger, index_Button as Button, index_Checkbox as Checkbox, index_ClearButton as ClearButton, index_Collapsible as Collapsible, index_CollapsibleContent as CollapsibleContent, index_CollapsibleTrigger as CollapsibleTrigger, DatePicker$1 as DatePicker, index_Dialog as Dialog, index_DialogContent as DialogContent, index_DialogDescription as DialogDescription, index_DialogFooter as DialogFooter, index_DialogTitle as DialogTitle, index_DialogTrigger as DialogTrigger, index_Form as Form, index_FormControl as FormControl, index_FormDescription as FormDescription, index_FormField as FormField, index_FormItem as FormItem, index_FormLabel as FormLabel, index_FormMessage as FormMessage, index_InputPrimitive as InputPrimitive, type index_InputPrimitiveProps as InputPrimitiveProps, index_Label as Label, MonthPicker$1 as MonthPicker, type MonthPickerProps$1 as MonthPickerProps, index_Popover as Popover, index_PopoverAnchor as PopoverAnchor, index_PopoverArrow as PopoverArrow, index_PopoverContent as PopoverContent, index_PopoverTrigger as PopoverTrigger, index_RadioGroupItem as RadioGroupItem, index_RadioGroupRoot as RadioGroupRoot, index_RadioLabel as RadioLabel, index_RichText as RichText, index_Select as Select, index_SelectContent as SelectContent, index_SelectGroup as SelectGroup, index_SelectItem as SelectItem, index_SelectLabel as SelectLabel, index_SelectScrollDownButton as SelectScrollDownButton, index_SelectScrollUpButton as SelectScrollUpButton, index_SelectSeparator as SelectSeparator, index_SelectTrigger as SelectTrigger, index_SelectValue as SelectValue, index_Separator as Separator, index_Sheet as Sheet, index_SheetClose as SheetClose, index_SheetContent as SheetContent, index_SheetDescription as SheetDescription, index_SheetFooter as SheetFooter, index_SheetHeader as SheetHeader, index_SheetTitle as SheetTitle, index_SheetTrigger as SheetTrigger, index_Sidebar as Sidebar, index_SidebarContent as SidebarContent, index_SidebarFooter as SidebarFooter, index_SidebarGroup as SidebarGroup, index_SidebarGroupAction as SidebarGroupAction, index_SidebarGroupContent as SidebarGroupContent, index_SidebarGroupLabel as SidebarGroupLabel, index_SidebarHeader as SidebarHeader, index_SidebarInput as SidebarInput, index_SidebarInset as SidebarInset, index_SidebarLayout as SidebarLayout, index_SidebarMenu as SidebarMenu, index_SidebarMenuAction as SidebarMenuAction, index_SidebarMenuBadge as SidebarMenuBadge, index_SidebarMenuButton as SidebarMenuButton, index_SidebarMenuItem as SidebarMenuItem, index_SidebarMenuSkeleton as SidebarMenuSkeleton, index_SidebarMenuSub as SidebarMenuSub, index_SidebarMenuSubButton as SidebarMenuSubButton, index_SidebarMenuSubItem as SidebarMenuSubItem, index_SidebarProvider as SidebarProvider, index_SidebarRail as SidebarRail, index_SidebarSeparator as SidebarSeparator, index_SidebarTrigger as SidebarTrigger, index_Skeleton as Skeleton, index_Spinner as Spinner, type index_SpinnerProps as SpinnerProps, index_Switch as Switch, index_Table as Table, index_TableBody as TableBody, index_TableCaption as TableCaption, index_TableCell as TableCell, index_TableContainer as TableContainer, index_TableFooter as TableFooter, index_TableHead as TableHead, index_TableHeader as TableHeader, index_TableRow as TableRow, index_Textarea as Textarea, Tooltip$1 as Tooltip, TooltipContent$1 as TooltipContent, TooltipProvider$1 as TooltipProvider, TooltipTrigger$1 as TooltipTrigger, index_buttonVariants as buttonVariants, index_spinnerVariants as spinnerVariants, index_useFormField as useFormField, index_useSidebar as useSidebar };
|
|
944
|
+
export { index_Accordion as Accordion, index_AccordionContent as AccordionContent, index_AccordionItem as AccordionItem, index_AccordionTrigger as AccordionTrigger, index_Button as Button, index_Checkbox as Checkbox, index_ClearButton as ClearButton, index_Collapsible as Collapsible, index_CollapsibleContent as CollapsibleContent, index_CollapsibleTrigger as CollapsibleTrigger, DatePicker$1 as DatePicker, index_Dialog as Dialog, index_DialogContent as DialogContent, type index_DialogContentProps as DialogContentProps, index_DialogDescription as DialogDescription, index_DialogFooter as DialogFooter, index_DialogTitle as DialogTitle, index_DialogTrigger as DialogTrigger, index_Form as Form, index_FormControl as FormControl, index_FormDescription as FormDescription, index_FormField as FormField, index_FormItem as FormItem, index_FormLabel as FormLabel, index_FormMessage as FormMessage, index_InputPrimitive as InputPrimitive, type index_InputPrimitiveProps as InputPrimitiveProps, index_Label as Label, MonthPicker$1 as MonthPicker, type MonthPickerProps$1 as MonthPickerProps, index_Popover as Popover, index_PopoverAnchor as PopoverAnchor, index_PopoverArrow as PopoverArrow, index_PopoverContent as PopoverContent, index_PopoverTrigger as PopoverTrigger, index_RadioGroupItem as RadioGroupItem, index_RadioGroupRoot as RadioGroupRoot, index_RadioLabel as RadioLabel, index_RichText as RichText, index_Select as Select, index_SelectContent as SelectContent, index_SelectGroup as SelectGroup, index_SelectItem as SelectItem, index_SelectLabel as SelectLabel, index_SelectScrollDownButton as SelectScrollDownButton, index_SelectScrollUpButton as SelectScrollUpButton, index_SelectSeparator as SelectSeparator, index_SelectTrigger as SelectTrigger, index_SelectValue as SelectValue, index_Separator as Separator, index_Sheet as Sheet, index_SheetClose as SheetClose, index_SheetContent as SheetContent, index_SheetDescription as SheetDescription, index_SheetFooter as SheetFooter, index_SheetHeader as SheetHeader, index_SheetTitle as SheetTitle, index_SheetTrigger as SheetTrigger, index_Sidebar as Sidebar, index_SidebarContent as SidebarContent, index_SidebarFooter as SidebarFooter, index_SidebarGroup as SidebarGroup, index_SidebarGroupAction as SidebarGroupAction, index_SidebarGroupContent as SidebarGroupContent, index_SidebarGroupLabel as SidebarGroupLabel, index_SidebarHeader as SidebarHeader, index_SidebarInput as SidebarInput, index_SidebarInset as SidebarInset, index_SidebarLayout as SidebarLayout, index_SidebarMenu as SidebarMenu, index_SidebarMenuAction as SidebarMenuAction, index_SidebarMenuBadge as SidebarMenuBadge, index_SidebarMenuButton as SidebarMenuButton, index_SidebarMenuItem as SidebarMenuItem, index_SidebarMenuSkeleton as SidebarMenuSkeleton, index_SidebarMenuSub as SidebarMenuSub, index_SidebarMenuSubButton as SidebarMenuSubButton, index_SidebarMenuSubItem as SidebarMenuSubItem, index_SidebarProvider as SidebarProvider, index_SidebarRail as SidebarRail, index_SidebarSeparator as SidebarSeparator, index_SidebarTrigger as SidebarTrigger, index_Skeleton as Skeleton, index_Spinner as Spinner, type index_SpinnerProps as SpinnerProps, index_Switch as Switch, index_Table as Table, index_TableBody as TableBody, index_TableCaption as TableCaption, index_TableCell as TableCell, index_TableContainer as TableContainer, index_TableFooter as TableFooter, index_TableHead as TableHead, index_TableHeader as TableHeader, index_TableRow as TableRow, index_Textarea as Textarea, Tooltip$1 as Tooltip, TooltipContent$1 as TooltipContent, TooltipProvider$1 as TooltipProvider, TooltipTrigger$1 as TooltipTrigger, index_buttonVariants as buttonVariants, index_spinnerVariants as spinnerVariants, index_useFormField as useFormField, index_useSidebar as useSidebar };
|
|
943
945
|
}
|
|
944
946
|
|
|
945
947
|
type SidebarContextProps = {
|
|
@@ -1019,6 +1021,51 @@ declare function TooltipTrigger({ ...props }: React$1.ComponentProps<typeof Tool
|
|
|
1019
1021
|
declare function TooltipArrow(props: React$1.ComponentProps<typeof TooltipPrimitive.Arrow>): react_jsx_runtime.JSX.Element;
|
|
1020
1022
|
declare function TooltipContent({ className, sideOffset, children, ...props }: React$1.ComponentProps<typeof TooltipPrimitive.Content>): react_jsx_runtime.JSX.Element;
|
|
1021
1023
|
|
|
1024
|
+
interface CroppedImagePayload {
|
|
1025
|
+
crop: {
|
|
1026
|
+
x: number;
|
|
1027
|
+
y: number;
|
|
1028
|
+
};
|
|
1029
|
+
croppedAreaPixels: Area | null;
|
|
1030
|
+
}
|
|
1031
|
+
interface CroppedImagePayloadWithBlobUrl extends CroppedImagePayload {
|
|
1032
|
+
croppedImageBlobUrl: string;
|
|
1033
|
+
}
|
|
1034
|
+
interface CropperModalBaseProps {
|
|
1035
|
+
open?: boolean;
|
|
1036
|
+
onOpenChange: (open: boolean) => void;
|
|
1037
|
+
onCancel?: () => void;
|
|
1038
|
+
onError?: (e: unknown) => void;
|
|
1039
|
+
imageSrc?: string | null;
|
|
1040
|
+
cropSize?: {
|
|
1041
|
+
width: number;
|
|
1042
|
+
height: number;
|
|
1043
|
+
};
|
|
1044
|
+
/**
|
|
1045
|
+
* @property {boolean} outputExactCropSize - Determine whether to ouput image with the exact size given in cropSize attribute
|
|
1046
|
+
* @description an original image dimension is 1000x1000px, if cropSize is 500x500px, the output image will be exactly 500x500px
|
|
1047
|
+
*/
|
|
1048
|
+
outputExactCropSize?: boolean;
|
|
1049
|
+
title?: string;
|
|
1050
|
+
props?: {
|
|
1051
|
+
dialogTitleContainer?: React.ComponentProps<"div">;
|
|
1052
|
+
dialogTitle?: React.ComponentProps<typeof SheetPrimitive.Title>;
|
|
1053
|
+
dialogContent?: DialogContentProps;
|
|
1054
|
+
cropper?: CropperProps;
|
|
1055
|
+
cropperContainer?: React.ComponentProps<"div">;
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
interface CropperModalWithBlobUrlOutputProps extends CropperModalBaseProps {
|
|
1059
|
+
onConfirm?: (payload: CroppedImagePayloadWithBlobUrl) => void;
|
|
1060
|
+
generateBlobUrlOutput: true;
|
|
1061
|
+
}
|
|
1062
|
+
interface CropperModalNormalProps extends CropperModalBaseProps {
|
|
1063
|
+
onConfirm?: (payload: CroppedImagePayload) => void;
|
|
1064
|
+
generateBlobUrlOutput: undefined | false;
|
|
1065
|
+
}
|
|
1066
|
+
type CropperModalProps = CropperModalWithBlobUrlOutputProps | CropperModalNormalProps;
|
|
1067
|
+
declare const CropperModal: ({ open, onOpenChange, imageSrc, onConfirm, onCancel, onError, cropSize, outputExactCropSize, generateBlobUrlOutput, title, props }: CropperModalProps) => react_jsx_runtime.JSX.Element;
|
|
1068
|
+
|
|
1022
1069
|
declare function isDefined(value: any): boolean;
|
|
1023
1070
|
declare function isEmptyObject(value: any): boolean;
|
|
1024
1071
|
type DebounceOptions = {
|
|
@@ -1116,4 +1163,4 @@ type UseTruncatedOptions<T> = {
|
|
|
1116
1163
|
type UseTruncatedResult = boolean;
|
|
1117
1164
|
declare const useTruncated: <T extends HTMLElement = any>({ elementRef, onChange, resizeDetectDelay }: UseTruncatedOptions<T>) => UseTruncatedResult;
|
|
1118
1165
|
|
|
1119
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AdvanceSearch, ArrowIcon, type Breakpoints, Button, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, type Column, DataTable, type DataTableChildrenKeyHandler, type DataTableColumnFilter, type DataTableColumnFilterProps, type DataTableColumnGrouping, type DataTableColumnOrdering, type DataTableColumnPinning, type DataTableColumnSeparatorProps, type DataTableColumnSorting, type DataTableColumnVisibility, type DataTableComponentProps, type DataTableFilterConfig, type DataTableFilters, type DataTableGlobalFilter, type DataTableHeaderCell, type DataTableProps, type DataTableRenderHeaderHandler, type DataTableRenderHeaderProps, type DataTableRenderRowHandler, type DataTableRenderRowProps, type DataTableRowCell, type DataTableRowClickHandler, type DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, DatePicker, type DatePickerProps, type DebounceOptions, type DebouncedFunction, Dialog, DialogAlert, type DialogAlertProps, DialogContent, DialogDescription, DialogFooter, DialogTitle, DialogTrigger, type DialogVariant, type FieldSchema, type FieldType, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, type GridPayload, GridSettingsModal, type GridSettingsModalProps, HeaderCell, type HeaderCellProps, Input, type InputProps, Label, List, ListContainer, type ListContainerProps, ListHeader, type ListHeaderProps, type ListProps, ListTable, type ListTableProps, LookupSelect, type LookupSelectOption, type LookupSelectProps, MonthPicker, type MonthPickerProps, _default as Navbar, type NavbarProps, NotFoundIcon, type Params, Popover, PopoverAnchor, PopoverArrow, PopoverContent, PopoverTrigger, PreventPageLeave, RadioGroupItem, RadioGroupRoot, RadioLabel, RichText, type RowClickType, type RowState, type ScrollInfo, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarLayout, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, type SorterProps, type StatusContentKey, SuiCalendarIcon, SuiCheckIcon, SuiDotsVerticalIcon, SuiEmptyDataIcon, SuiExpandIcon, SuiFilterIcon, SuiSettingIcon, SuiTriangleDownIcon, SuiWarningIcon, Switch, Textarea, Tooltip, TooltipArrow, TooltipContent, TooltipProvider, TooltipTrigger, index as UI, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UsePreventPageLeaveOptions, type UseScreenSizeResult, type UseTruncatedOptions, type UseTruncatedResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, debounce, inputVariants, isDefined, isEmptyObject, selectValueToBoolean, stripNullishObject, throttle, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize, useSidebar, useTruncated };
|
|
1166
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AdvanceSearch, ArrowIcon, type Breakpoints, Button, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, type Column, type CroppedImagePayload, type CroppedImagePayloadWithBlobUrl, CropperModal, type CropperModalProps, DataTable, type DataTableChildrenKeyHandler, type DataTableColumnFilter, type DataTableColumnFilterProps, type DataTableColumnGrouping, type DataTableColumnOrdering, type DataTableColumnPinning, type DataTableColumnSeparatorProps, type DataTableColumnSorting, type DataTableColumnVisibility, type DataTableComponentProps, type DataTableFilterConfig, type DataTableFilters, type DataTableGlobalFilter, type DataTableHeaderCell, type DataTableProps, type DataTableRenderHeaderHandler, type DataTableRenderHeaderProps, type DataTableRenderRowHandler, type DataTableRenderRowProps, type DataTableRowCell, type DataTableRowClickHandler, type DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, DatePicker, type DatePickerProps, type DebounceOptions, type DebouncedFunction, Dialog, DialogAlert, type DialogAlertProps, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, DialogTitle, DialogTrigger, type DialogVariant, type FieldSchema, type FieldType, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, type GridPayload, GridSettingsModal, type GridSettingsModalProps, HeaderCell, type HeaderCellProps, Input, type InputProps, Label, List, ListContainer, type ListContainerProps, ListHeader, type ListHeaderProps, type ListProps, ListTable, type ListTableProps, LookupSelect, type LookupSelectOption, type LookupSelectProps, MonthPicker, type MonthPickerProps, _default as Navbar, type NavbarProps, NotFoundIcon, type Params, Popover, PopoverAnchor, PopoverArrow, PopoverContent, PopoverTrigger, PreventPageLeave, RadioGroupItem, RadioGroupRoot, RadioLabel, RichText, type RowClickType, type RowState, type ScrollInfo, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarLayout, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, type SorterProps, type StatusContentKey, SuiCalendarIcon, SuiCheckIcon, SuiDotsVerticalIcon, SuiEmptyDataIcon, SuiExpandIcon, SuiFilterIcon, SuiSettingIcon, SuiTriangleDownIcon, SuiWarningIcon, Switch, Textarea, Tooltip, TooltipArrow, TooltipContent, TooltipProvider, TooltipTrigger, index as UI, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UsePreventPageLeaveOptions, type UseScreenSizeResult, type UseTruncatedOptions, type UseTruncatedResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, debounce, inputVariants, isDefined, isEmptyObject, selectValueToBoolean, stripNullishObject, throttle, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize, useSidebar, useTruncated };
|
package/dist/index.js
CHANGED
|
@@ -49,6 +49,7 @@ var utils = require('@lexical/utils');
|
|
|
49
49
|
var selection = require('@lexical/selection');
|
|
50
50
|
var SeparatorPrimitive = require('@radix-ui/react-separator');
|
|
51
51
|
var SwitchPrimitive = require('@radix-ui/react-switch');
|
|
52
|
+
var Cropper = require('react-easy-crop');
|
|
52
53
|
|
|
53
54
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
54
55
|
|
|
@@ -83,6 +84,7 @@ var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitiv
|
|
|
83
84
|
var RadioGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(RadioGroupPrimitive);
|
|
84
85
|
var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespace(SeparatorPrimitive);
|
|
85
86
|
var SwitchPrimitive__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitive);
|
|
87
|
+
var Cropper__default = /*#__PURE__*/_interopDefault(Cropper);
|
|
86
88
|
|
|
87
89
|
var __defProp = Object.defineProperty;
|
|
88
90
|
var __export = (target, all) => {
|
|
@@ -5062,7 +5064,7 @@ var GridSettingsModal = ({
|
|
|
5062
5064
|
move(oldIndex, newIndex);
|
|
5063
5065
|
}
|
|
5064
5066
|
}
|
|
5065
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsxRuntime.jsx(DialogContent, { className: "sm:max-w-xl border-0 p-0 rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col min-h-[
|
|
5067
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsxRuntime.jsx(DialogContent, { className: "sm:max-w-xl border-0 p-0 rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col min-h-[550px] rounded-lg overflow-hidden", children: [
|
|
5066
5068
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-shrink-0", children: [
|
|
5067
5069
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5068
5070
|
"div",
|
|
@@ -7677,6 +7679,173 @@ function SidebarLayout({
|
|
|
7677
7679
|
] }) });
|
|
7678
7680
|
}
|
|
7679
7681
|
|
|
7682
|
+
// src/components/cropperModal/helper.ts
|
|
7683
|
+
var createImage = (url) => new Promise((resolve, reject) => {
|
|
7684
|
+
const image = new Image();
|
|
7685
|
+
image.addEventListener("load", () => resolve(image));
|
|
7686
|
+
image.addEventListener("error", (error) => reject(error));
|
|
7687
|
+
image.setAttribute("crossOrigin", "anonymous");
|
|
7688
|
+
image.src = url;
|
|
7689
|
+
});
|
|
7690
|
+
async function getCroppedImg(imageSrc, pixelCrop, desiredDimension) {
|
|
7691
|
+
const image = await createImage(imageSrc);
|
|
7692
|
+
const canvas = document.createElement("canvas");
|
|
7693
|
+
const ctx = canvas.getContext("2d");
|
|
7694
|
+
if (!ctx) {
|
|
7695
|
+
throw new Error("can not create canvas");
|
|
7696
|
+
}
|
|
7697
|
+
canvas.width = image.width;
|
|
7698
|
+
canvas.height = image.height;
|
|
7699
|
+
ctx.drawImage(image, 0, 0);
|
|
7700
|
+
const croppedCanvas = document.createElement("canvas");
|
|
7701
|
+
const croppedCtx = croppedCanvas.getContext("2d");
|
|
7702
|
+
if (!croppedCtx) {
|
|
7703
|
+
throw new Error("can not create canvas");
|
|
7704
|
+
}
|
|
7705
|
+
croppedCanvas.width = desiredDimension?.width ?? pixelCrop.width;
|
|
7706
|
+
croppedCanvas.height = desiredDimension?.height ?? pixelCrop.height;
|
|
7707
|
+
croppedCtx.drawImage(
|
|
7708
|
+
canvas,
|
|
7709
|
+
pixelCrop.x,
|
|
7710
|
+
pixelCrop.y,
|
|
7711
|
+
pixelCrop.width,
|
|
7712
|
+
pixelCrop.height,
|
|
7713
|
+
0,
|
|
7714
|
+
0,
|
|
7715
|
+
desiredDimension?.width ?? pixelCrop.width,
|
|
7716
|
+
desiredDimension?.height ?? pixelCrop.height
|
|
7717
|
+
);
|
|
7718
|
+
return new Promise((resolve, reject) => {
|
|
7719
|
+
croppedCanvas.toBlob((file) => {
|
|
7720
|
+
if (file) {
|
|
7721
|
+
resolve(URL.createObjectURL(file));
|
|
7722
|
+
} else {
|
|
7723
|
+
reject("croppedCanvas gave null object");
|
|
7724
|
+
}
|
|
7725
|
+
}, "image/png");
|
|
7726
|
+
});
|
|
7727
|
+
}
|
|
7728
|
+
var CropperModal = ({
|
|
7729
|
+
open,
|
|
7730
|
+
onOpenChange,
|
|
7731
|
+
imageSrc,
|
|
7732
|
+
onConfirm,
|
|
7733
|
+
onCancel,
|
|
7734
|
+
onError,
|
|
7735
|
+
cropSize,
|
|
7736
|
+
outputExactCropSize,
|
|
7737
|
+
generateBlobUrlOutput,
|
|
7738
|
+
title,
|
|
7739
|
+
props
|
|
7740
|
+
}) => {
|
|
7741
|
+
const [isLoading, setIsLoading] = React5.useState(false);
|
|
7742
|
+
const [crop, setCrop] = React5.useState({ x: 0, y: 0 });
|
|
7743
|
+
const [zoom, setZoom] = React5.useState();
|
|
7744
|
+
const [croppedAreaPixels, setCroppedAreaPixels] = React5.useState(null);
|
|
7745
|
+
const handleClose = React5.useCallback(() => {
|
|
7746
|
+
onOpenChange(false);
|
|
7747
|
+
}, [onOpenChange]);
|
|
7748
|
+
const handleCancel = React5.useCallback(() => {
|
|
7749
|
+
if (onCancel) {
|
|
7750
|
+
onCancel();
|
|
7751
|
+
}
|
|
7752
|
+
handleClose();
|
|
7753
|
+
}, [handleClose, onCancel]);
|
|
7754
|
+
const handleCropComplete = React5.useCallback((_, croppedAreaPixels2) => {
|
|
7755
|
+
setCroppedAreaPixels(croppedAreaPixels2);
|
|
7756
|
+
}, []);
|
|
7757
|
+
const handleConfirm = async () => {
|
|
7758
|
+
if (!imageSrc || !onConfirm) {
|
|
7759
|
+
handleClose();
|
|
7760
|
+
return;
|
|
7761
|
+
}
|
|
7762
|
+
if (!generateBlobUrlOutput) {
|
|
7763
|
+
onConfirm({ crop, croppedAreaPixels });
|
|
7764
|
+
return;
|
|
7765
|
+
}
|
|
7766
|
+
if (!croppedAreaPixels) {
|
|
7767
|
+
onConfirm({ crop, croppedAreaPixels, croppedImageBlobUrl: imageSrc });
|
|
7768
|
+
return;
|
|
7769
|
+
}
|
|
7770
|
+
setIsLoading(true);
|
|
7771
|
+
try {
|
|
7772
|
+
const desiredDimension = outputExactCropSize ? cropSize : void 0;
|
|
7773
|
+
const croppedImage = await getCroppedImg(imageSrc, croppedAreaPixels, desiredDimension);
|
|
7774
|
+
onConfirm({ crop, croppedAreaPixels, croppedImageBlobUrl: croppedImage });
|
|
7775
|
+
} catch (e) {
|
|
7776
|
+
if (onError) {
|
|
7777
|
+
onError(e);
|
|
7778
|
+
}
|
|
7779
|
+
} finally {
|
|
7780
|
+
setIsLoading(false);
|
|
7781
|
+
handleClose();
|
|
7782
|
+
}
|
|
7783
|
+
};
|
|
7784
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7785
|
+
Dialog,
|
|
7786
|
+
{
|
|
7787
|
+
open,
|
|
7788
|
+
onOpenChange: (nextOpen) => {
|
|
7789
|
+
if (!nextOpen) {
|
|
7790
|
+
handleClose();
|
|
7791
|
+
} else {
|
|
7792
|
+
onOpenChange(true);
|
|
7793
|
+
}
|
|
7794
|
+
},
|
|
7795
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
7796
|
+
DialogContent,
|
|
7797
|
+
{
|
|
7798
|
+
className: "flex flex-col w-fit !max-w-6xl p-0 overflow-clip gap-0 border-0",
|
|
7799
|
+
...props?.dialogContent,
|
|
7800
|
+
children: [
|
|
7801
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
7802
|
+
"div",
|
|
7803
|
+
{
|
|
7804
|
+
className: "flex w-full bg-[#82B495] text-white justify-between items-center p-4",
|
|
7805
|
+
...props?.dialogTitleContainer,
|
|
7806
|
+
children: [
|
|
7807
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { className: "text-2xl font-semibold", ...props?.dialogTitle, children: title ?? "Crop Image" }),
|
|
7808
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7809
|
+
"button",
|
|
7810
|
+
{
|
|
7811
|
+
type: "button",
|
|
7812
|
+
className: "text-white hover:text-gray-100 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",
|
|
7813
|
+
onClick: handleCancel,
|
|
7814
|
+
disabled: isLoading,
|
|
7815
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, { className: "w-4 h-4" })
|
|
7816
|
+
}
|
|
7817
|
+
)
|
|
7818
|
+
]
|
|
7819
|
+
}
|
|
7820
|
+
),
|
|
7821
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-120 md:w-[50vw] h-[70vh] mx-auto", ...props?.cropperContainer, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
7822
|
+
Cropper__default.default,
|
|
7823
|
+
{
|
|
7824
|
+
image: imageSrc ?? void 0,
|
|
7825
|
+
crop,
|
|
7826
|
+
onCropChange: setCrop,
|
|
7827
|
+
zoom,
|
|
7828
|
+
onZoomChange: setZoom,
|
|
7829
|
+
style: { containerStyle: { position: "relative", width: "100%", height: "100%" } },
|
|
7830
|
+
onCropComplete: handleCropComplete,
|
|
7831
|
+
aspect: cropSize ? cropSize.width / cropSize.height : void 0,
|
|
7832
|
+
zoomWithScroll: true,
|
|
7833
|
+
showGrid: true,
|
|
7834
|
+
restrictPosition: true,
|
|
7835
|
+
...props?.cropper
|
|
7836
|
+
}
|
|
7837
|
+
) }),
|
|
7838
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full py-4 px-8", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full justify-between", children: [
|
|
7839
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", variant: "cancel", onClick: handleCancel, disabled: isLoading, children: "Cancel" }),
|
|
7840
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto flex gap-x-2", children: /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", variant: "default", onClick: handleConfirm, disabled: isLoading, children: "Confirm" }) })
|
|
7841
|
+
] }) })
|
|
7842
|
+
]
|
|
7843
|
+
}
|
|
7844
|
+
)
|
|
7845
|
+
}
|
|
7846
|
+
);
|
|
7847
|
+
};
|
|
7848
|
+
|
|
7680
7849
|
exports.Accordion = Accordion;
|
|
7681
7850
|
exports.AccordionContent = AccordionContent;
|
|
7682
7851
|
exports.AccordionItem = AccordionItem;
|
|
@@ -7688,6 +7857,7 @@ exports.Checkbox = Checkbox;
|
|
|
7688
7857
|
exports.Collapsible = Collapsible;
|
|
7689
7858
|
exports.CollapsibleContent = CollapsibleContent2;
|
|
7690
7859
|
exports.CollapsibleTrigger = CollapsibleTrigger2;
|
|
7860
|
+
exports.CropperModal = CropperModal;
|
|
7691
7861
|
exports.DataTable = DataTable_default;
|
|
7692
7862
|
exports.DatePicker = DatePicker2;
|
|
7693
7863
|
exports.Dialog = Dialog;
|