@sustaina/shared-ui 1.13.2 → 1.14.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 +18 -5
- package/dist/index.d.ts +18 -5
- package/dist/index.js +71 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -8,6 +8,7 @@ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
|
8
8
|
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
9
9
|
import { Header, RowData as RowData$1, Column as Column$1, Table as Table$1, ColumnDef, ColumnFiltersState, OnChangeFn, FilterFnOption, SortingState, ColumnOrderState, VisibilityState, ColumnPinningState, GroupingState, GroupingOptions, ColumnResizeMode, RowSelectionState, Row, ExpandedState, Cell, HeaderGroup, HeaderContext } from '@tanstack/react-table';
|
|
10
10
|
import * as SheetPrimitive from '@radix-ui/react-dialog';
|
|
11
|
+
import { DialogContentProps as DialogContentProps$1 } from '@radix-ui/react-dialog';
|
|
11
12
|
import * as react_hook_form from 'react-hook-form';
|
|
12
13
|
import { FieldValues, FieldPath, ControllerProps } from 'react-hook-form';
|
|
13
14
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
@@ -20,7 +21,7 @@ import * as SelectPrimitive from '@radix-ui/react-select';
|
|
|
20
21
|
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
21
22
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
22
23
|
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
23
|
-
import {
|
|
24
|
+
import { CropperProps, Area } from 'react-easy-crop';
|
|
24
25
|
import { ClassValue } from 'clsx';
|
|
25
26
|
|
|
26
27
|
declare function Accordion({ ...props }: React$1.ComponentProps<typeof AccordionPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
@@ -1108,7 +1109,7 @@ interface CropperModalBaseProps {
|
|
|
1108
1109
|
open?: boolean;
|
|
1109
1110
|
onOpenChange: (open: boolean) => void;
|
|
1110
1111
|
onCancel?: () => void;
|
|
1111
|
-
onError?: (e: unknown) => void;
|
|
1112
|
+
onError?: (e: CropperModalError | unknown) => void;
|
|
1112
1113
|
imageSrc?: string | null;
|
|
1113
1114
|
isSVG?: boolean;
|
|
1114
1115
|
cropSize?: {
|
|
@@ -1120,11 +1121,12 @@ interface CropperModalBaseProps {
|
|
|
1120
1121
|
* @description an original image dimension is 1000x1000px, if cropSize is 500x500px, the output image will be exactly 500x500px
|
|
1121
1122
|
*/
|
|
1122
1123
|
outputExactCropSize?: boolean;
|
|
1124
|
+
targetFileSizeKB?: number;
|
|
1123
1125
|
title?: string;
|
|
1124
1126
|
props?: {
|
|
1125
1127
|
dialogTitleContainer?: React.ComponentProps<"div">;
|
|
1126
1128
|
dialogTitle?: React.ComponentProps<typeof SheetPrimitive.Title>;
|
|
1127
|
-
dialogContent?: DialogContentProps;
|
|
1129
|
+
dialogContent?: DialogContentProps$1;
|
|
1128
1130
|
cropper?: CropperProps;
|
|
1129
1131
|
cropperContainer?: React.ComponentProps<"div">;
|
|
1130
1132
|
};
|
|
@@ -1138,7 +1140,18 @@ interface CropperModalNormalProps extends CropperModalBaseProps {
|
|
|
1138
1140
|
generateBlobUrlOutput: undefined | false;
|
|
1139
1141
|
}
|
|
1140
1142
|
type CropperModalProps = CropperModalWithBlobUrlOutputProps | CropperModalNormalProps;
|
|
1141
|
-
|
|
1143
|
+
type CropperModalErrorType = "ERROR_GENERATE_BLOB" | "ERROR_CREATE_CANVAS" | "ERROR_INVALID_SVG" | "ERROR_COMPRESSION" | "ERROR_SVG_EXCEED_SIZE";
|
|
1144
|
+
declare class CropperModalError extends Error {
|
|
1145
|
+
readonly error: CropperModalErrorType;
|
|
1146
|
+
constructor(errorType: CropperModalErrorType, message: string);
|
|
1147
|
+
}
|
|
1148
|
+
declare const ErrorGeneratingBlob: CropperModalError;
|
|
1149
|
+
declare const ErrorCreateCanvas: CropperModalError;
|
|
1150
|
+
declare const ErrorInvalidSVG: CropperModalError;
|
|
1151
|
+
declare const ErrorCompression: CropperModalError;
|
|
1152
|
+
declare const ErrorSVGExceedSize: CropperModalError;
|
|
1153
|
+
|
|
1154
|
+
declare const CropperModal: ({ open, onOpenChange, imageSrc, isSVG, onConfirm, onCancel, onError, cropSize, outputExactCropSize, targetFileSizeKB, generateBlobUrlOutput, title, props }: CropperModalProps) => react_jsx_runtime.JSX.Element;
|
|
1142
1155
|
|
|
1143
1156
|
declare function isDefined(value: any): boolean;
|
|
1144
1157
|
declare function isEmptyObject(value: any): boolean;
|
|
@@ -1237,4 +1250,4 @@ type UseTruncatedOptions<T> = {
|
|
|
1237
1250
|
type UseTruncatedResult = boolean;
|
|
1238
1251
|
declare const useTruncated: <T extends HTMLElement = any>({ elementRef, onChange, resizeDetectDelay }: UseTruncatedOptions<T>) => UseTruncatedResult;
|
|
1239
1252
|
|
|
1240
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AdvanceSearch, ArrowIcon, type Breakpoints, Button, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, type Column, type CroppedImagePayload, type CroppedImagePayloadWithBlobUrl, CropperModal, type CropperModalProps, DIALOG_ALERT_I18N_NAMESPACE, 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 DialogAlertI18nResource, type DialogAlertProps, DialogAlertProvider, type DialogAlertTemplates, 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, type TemplateKeys, 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, getDialogAlertControls, getDialogTemplates, inputVariants, isDefined, isEmptyObject, selectValueToBoolean, stripNullishObject, throttle, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize, useSidebar, useTruncated };
|
|
1253
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AdvanceSearch, ArrowIcon, type Breakpoints, Button, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, type Column, type CroppedImagePayload, type CroppedImagePayloadWithBlobUrl, CropperModal, CropperModalError, type CropperModalErrorType, type CropperModalProps, DIALOG_ALERT_I18N_NAMESPACE, 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 DialogAlertI18nResource, type DialogAlertProps, DialogAlertProvider, type DialogAlertTemplates, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, DialogTitle, DialogTrigger, type DialogVariant, ErrorCompression, ErrorCreateCanvas, ErrorGeneratingBlob, ErrorInvalidSVG, ErrorSVGExceedSize, 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, Spinner, type SpinnerProps, type StatusContentKey, SuiCalendarIcon, SuiCheckIcon, SuiDotsVerticalIcon, SuiEmptyDataIcon, SuiExpandIcon, SuiFilterIcon, SuiSettingIcon, SuiTriangleDownIcon, SuiWarningIcon, Switch, type TemplateKeys, 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, getDialogAlertControls, getDialogTemplates, inputVariants, isDefined, isEmptyObject, selectValueToBoolean, spinnerVariants, stripNullishObject, throttle, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize, useSidebar, useTruncated };
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
|
8
8
|
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
9
9
|
import { Header, RowData as RowData$1, Column as Column$1, Table as Table$1, ColumnDef, ColumnFiltersState, OnChangeFn, FilterFnOption, SortingState, ColumnOrderState, VisibilityState, ColumnPinningState, GroupingState, GroupingOptions, ColumnResizeMode, RowSelectionState, Row, ExpandedState, Cell, HeaderGroup, HeaderContext } from '@tanstack/react-table';
|
|
10
10
|
import * as SheetPrimitive from '@radix-ui/react-dialog';
|
|
11
|
+
import { DialogContentProps as DialogContentProps$1 } from '@radix-ui/react-dialog';
|
|
11
12
|
import * as react_hook_form from 'react-hook-form';
|
|
12
13
|
import { FieldValues, FieldPath, ControllerProps } from 'react-hook-form';
|
|
13
14
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
@@ -20,7 +21,7 @@ import * as SelectPrimitive from '@radix-ui/react-select';
|
|
|
20
21
|
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
21
22
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
22
23
|
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
23
|
-
import {
|
|
24
|
+
import { CropperProps, Area } from 'react-easy-crop';
|
|
24
25
|
import { ClassValue } from 'clsx';
|
|
25
26
|
|
|
26
27
|
declare function Accordion({ ...props }: React$1.ComponentProps<typeof AccordionPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
@@ -1108,7 +1109,7 @@ interface CropperModalBaseProps {
|
|
|
1108
1109
|
open?: boolean;
|
|
1109
1110
|
onOpenChange: (open: boolean) => void;
|
|
1110
1111
|
onCancel?: () => void;
|
|
1111
|
-
onError?: (e: unknown) => void;
|
|
1112
|
+
onError?: (e: CropperModalError | unknown) => void;
|
|
1112
1113
|
imageSrc?: string | null;
|
|
1113
1114
|
isSVG?: boolean;
|
|
1114
1115
|
cropSize?: {
|
|
@@ -1120,11 +1121,12 @@ interface CropperModalBaseProps {
|
|
|
1120
1121
|
* @description an original image dimension is 1000x1000px, if cropSize is 500x500px, the output image will be exactly 500x500px
|
|
1121
1122
|
*/
|
|
1122
1123
|
outputExactCropSize?: boolean;
|
|
1124
|
+
targetFileSizeKB?: number;
|
|
1123
1125
|
title?: string;
|
|
1124
1126
|
props?: {
|
|
1125
1127
|
dialogTitleContainer?: React.ComponentProps<"div">;
|
|
1126
1128
|
dialogTitle?: React.ComponentProps<typeof SheetPrimitive.Title>;
|
|
1127
|
-
dialogContent?: DialogContentProps;
|
|
1129
|
+
dialogContent?: DialogContentProps$1;
|
|
1128
1130
|
cropper?: CropperProps;
|
|
1129
1131
|
cropperContainer?: React.ComponentProps<"div">;
|
|
1130
1132
|
};
|
|
@@ -1138,7 +1140,18 @@ interface CropperModalNormalProps extends CropperModalBaseProps {
|
|
|
1138
1140
|
generateBlobUrlOutput: undefined | false;
|
|
1139
1141
|
}
|
|
1140
1142
|
type CropperModalProps = CropperModalWithBlobUrlOutputProps | CropperModalNormalProps;
|
|
1141
|
-
|
|
1143
|
+
type CropperModalErrorType = "ERROR_GENERATE_BLOB" | "ERROR_CREATE_CANVAS" | "ERROR_INVALID_SVG" | "ERROR_COMPRESSION" | "ERROR_SVG_EXCEED_SIZE";
|
|
1144
|
+
declare class CropperModalError extends Error {
|
|
1145
|
+
readonly error: CropperModalErrorType;
|
|
1146
|
+
constructor(errorType: CropperModalErrorType, message: string);
|
|
1147
|
+
}
|
|
1148
|
+
declare const ErrorGeneratingBlob: CropperModalError;
|
|
1149
|
+
declare const ErrorCreateCanvas: CropperModalError;
|
|
1150
|
+
declare const ErrorInvalidSVG: CropperModalError;
|
|
1151
|
+
declare const ErrorCompression: CropperModalError;
|
|
1152
|
+
declare const ErrorSVGExceedSize: CropperModalError;
|
|
1153
|
+
|
|
1154
|
+
declare const CropperModal: ({ open, onOpenChange, imageSrc, isSVG, onConfirm, onCancel, onError, cropSize, outputExactCropSize, targetFileSizeKB, generateBlobUrlOutput, title, props }: CropperModalProps) => react_jsx_runtime.JSX.Element;
|
|
1142
1155
|
|
|
1143
1156
|
declare function isDefined(value: any): boolean;
|
|
1144
1157
|
declare function isEmptyObject(value: any): boolean;
|
|
@@ -1237,4 +1250,4 @@ type UseTruncatedOptions<T> = {
|
|
|
1237
1250
|
type UseTruncatedResult = boolean;
|
|
1238
1251
|
declare const useTruncated: <T extends HTMLElement = any>({ elementRef, onChange, resizeDetectDelay }: UseTruncatedOptions<T>) => UseTruncatedResult;
|
|
1239
1252
|
|
|
1240
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AdvanceSearch, ArrowIcon, type Breakpoints, Button, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, type Column, type CroppedImagePayload, type CroppedImagePayloadWithBlobUrl, CropperModal, type CropperModalProps, DIALOG_ALERT_I18N_NAMESPACE, 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 DialogAlertI18nResource, type DialogAlertProps, DialogAlertProvider, type DialogAlertTemplates, 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, type TemplateKeys, 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, getDialogAlertControls, getDialogTemplates, inputVariants, isDefined, isEmptyObject, selectValueToBoolean, stripNullishObject, throttle, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize, useSidebar, useTruncated };
|
|
1253
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AdvanceSearch, ArrowIcon, type Breakpoints, Button, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, type Column, type CroppedImagePayload, type CroppedImagePayloadWithBlobUrl, CropperModal, CropperModalError, type CropperModalErrorType, type CropperModalProps, DIALOG_ALERT_I18N_NAMESPACE, 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 DialogAlertI18nResource, type DialogAlertProps, DialogAlertProvider, type DialogAlertTemplates, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, DialogTitle, DialogTrigger, type DialogVariant, ErrorCompression, ErrorCreateCanvas, ErrorGeneratingBlob, ErrorInvalidSVG, ErrorSVGExceedSize, 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, Spinner, type SpinnerProps, type StatusContentKey, SuiCalendarIcon, SuiCheckIcon, SuiDotsVerticalIcon, SuiEmptyDataIcon, SuiExpandIcon, SuiFilterIcon, SuiSettingIcon, SuiTriangleDownIcon, SuiWarningIcon, Switch, type TemplateKeys, 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, getDialogAlertControls, getDialogTemplates, inputVariants, isDefined, isEmptyObject, selectValueToBoolean, spinnerVariants, stripNullishObject, throttle, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize, useSidebar, useTruncated };
|
package/dist/index.js
CHANGED
|
@@ -8175,6 +8175,31 @@ function SidebarLayout({
|
|
|
8175
8175
|
] }) });
|
|
8176
8176
|
}
|
|
8177
8177
|
|
|
8178
|
+
// src/components/cropperModal/type.ts
|
|
8179
|
+
var CropperModalError = class extends Error {
|
|
8180
|
+
constructor(errorType, message) {
|
|
8181
|
+
super(message);
|
|
8182
|
+
this.error = errorType;
|
|
8183
|
+
}
|
|
8184
|
+
};
|
|
8185
|
+
var ErrorGeneratingBlob = new CropperModalError(
|
|
8186
|
+
"ERROR_GENERATE_BLOB",
|
|
8187
|
+
"failed to generate a valid Blob"
|
|
8188
|
+
);
|
|
8189
|
+
var ErrorCreateCanvas = new CropperModalError("ERROR_CREATE_CANVAS", "Failed to create canvas");
|
|
8190
|
+
var ErrorInvalidSVG = new CropperModalError(
|
|
8191
|
+
"ERROR_INVALID_SVG",
|
|
8192
|
+
"The file is not a valid SVG document root"
|
|
8193
|
+
);
|
|
8194
|
+
var ErrorCompression = new CropperModalError(
|
|
8195
|
+
"ERROR_COMPRESSION",
|
|
8196
|
+
"Compression failed to generate a valid Blob"
|
|
8197
|
+
);
|
|
8198
|
+
var ErrorSVGExceedSize = new CropperModalError(
|
|
8199
|
+
"ERROR_SVG_EXCEED_SIZE",
|
|
8200
|
+
"The SVG file is too large"
|
|
8201
|
+
);
|
|
8202
|
+
|
|
8178
8203
|
// src/components/cropperModal/helper.ts
|
|
8179
8204
|
var createImage = (url) => new Promise((resolve, reject) => {
|
|
8180
8205
|
const image = new Image();
|
|
@@ -8183,12 +8208,38 @@ var createImage = (url) => new Promise((resolve, reject) => {
|
|
|
8183
8208
|
image.setAttribute("crossOrigin", "anonymous");
|
|
8184
8209
|
image.src = url;
|
|
8185
8210
|
});
|
|
8186
|
-
|
|
8211
|
+
function toBlobPromise(canvas, quality) {
|
|
8212
|
+
return new Promise((resolve) => {
|
|
8213
|
+
canvas.toBlob((blob) => resolve(blob), "image/jpeg", quality);
|
|
8214
|
+
});
|
|
8215
|
+
}
|
|
8216
|
+
async function resizeImage(canvas, targetSizeKB) {
|
|
8217
|
+
const targetSizeBytes = targetSizeKB * 1024;
|
|
8218
|
+
let quality = 1;
|
|
8219
|
+
const qualityStep = 0.05;
|
|
8220
|
+
let compressedBlob = null;
|
|
8221
|
+
let currentSize = Infinity;
|
|
8222
|
+
while (currentSize > targetSizeBytes && quality > 0) {
|
|
8223
|
+
compressedBlob = await toBlobPromise(canvas, quality);
|
|
8224
|
+
if (compressedBlob === null) {
|
|
8225
|
+
throw ErrorCompression;
|
|
8226
|
+
}
|
|
8227
|
+
currentSize = compressedBlob.size;
|
|
8228
|
+
if (currentSize > targetSizeBytes) {
|
|
8229
|
+
quality = Math.max(0, quality - qualityStep);
|
|
8230
|
+
}
|
|
8231
|
+
}
|
|
8232
|
+
if (compressedBlob && currentSize <= targetSizeBytes) {
|
|
8233
|
+
return URL.createObjectURL(compressedBlob);
|
|
8234
|
+
}
|
|
8235
|
+
throw ErrorCompression;
|
|
8236
|
+
}
|
|
8237
|
+
async function getCroppedImg(imageSrc, pixelCrop, desiredDimension, targetSizeKB = Infinity) {
|
|
8187
8238
|
const image = await createImage(imageSrc);
|
|
8188
8239
|
const canvas = document.createElement("canvas");
|
|
8189
8240
|
const ctx = canvas.getContext("2d");
|
|
8190
8241
|
if (!ctx) {
|
|
8191
|
-
throw
|
|
8242
|
+
throw ErrorCreateCanvas;
|
|
8192
8243
|
}
|
|
8193
8244
|
canvas.width = image.width;
|
|
8194
8245
|
canvas.height = image.height;
|
|
@@ -8196,7 +8247,7 @@ async function getCroppedImg(imageSrc, pixelCrop, desiredDimension) {
|
|
|
8196
8247
|
const croppedCanvas = document.createElement("canvas");
|
|
8197
8248
|
const croppedCtx = croppedCanvas.getContext("2d");
|
|
8198
8249
|
if (!croppedCtx) {
|
|
8199
|
-
throw
|
|
8250
|
+
throw ErrorCreateCanvas;
|
|
8200
8251
|
}
|
|
8201
8252
|
croppedCanvas.width = desiredDimension?.width ?? pixelCrop.width;
|
|
8202
8253
|
croppedCanvas.height = desiredDimension?.height ?? pixelCrop.height;
|
|
@@ -8211,17 +8262,9 @@ async function getCroppedImg(imageSrc, pixelCrop, desiredDimension) {
|
|
|
8211
8262
|
desiredDimension?.width ?? pixelCrop.width,
|
|
8212
8263
|
desiredDimension?.height ?? pixelCrop.height
|
|
8213
8264
|
);
|
|
8214
|
-
return
|
|
8215
|
-
croppedCanvas.toBlob((file) => {
|
|
8216
|
-
if (file) {
|
|
8217
|
-
resolve(URL.createObjectURL(file));
|
|
8218
|
-
} else {
|
|
8219
|
-
reject("croppedCanvas gave null object");
|
|
8220
|
-
}
|
|
8221
|
-
}, "image/png");
|
|
8222
|
-
});
|
|
8265
|
+
return resizeImage(croppedCanvas, targetSizeKB);
|
|
8223
8266
|
}
|
|
8224
|
-
async function getCroppedSVG(imageSrc, pixelCrop, desiredDimension) {
|
|
8267
|
+
async function getCroppedSVG(imageSrc, pixelCrop, desiredDimension, targetSizeKB = Infinity) {
|
|
8225
8268
|
let svgString;
|
|
8226
8269
|
const parts = imageSrc.split(",");
|
|
8227
8270
|
const meta = parts[0];
|
|
@@ -8235,7 +8278,7 @@ async function getCroppedSVG(imageSrc, pixelCrop, desiredDimension) {
|
|
|
8235
8278
|
const svgDoc = parser.parseFromString(svgString, "image/svg+xml");
|
|
8236
8279
|
const svgElement = svgDoc.documentElement;
|
|
8237
8280
|
if (svgElement.tagName.toLowerCase() !== "svg") {
|
|
8238
|
-
throw
|
|
8281
|
+
throw ErrorInvalidSVG;
|
|
8239
8282
|
}
|
|
8240
8283
|
const newViewBox = `${pixelCrop.x} ${pixelCrop.y} ${pixelCrop.width} ${pixelCrop.height}`;
|
|
8241
8284
|
svgElement.setAttribute("viewBox", newViewBox);
|
|
@@ -8246,6 +8289,10 @@ async function getCroppedSVG(imageSrc, pixelCrop, desiredDimension) {
|
|
|
8246
8289
|
const serializer = new XMLSerializer();
|
|
8247
8290
|
const croppedSvgString = serializer.serializeToString(svgElement);
|
|
8248
8291
|
const blob = new Blob([croppedSvgString], { type: "image/svg+xml" });
|
|
8292
|
+
const targetSizeBytes = targetSizeKB * 1024;
|
|
8293
|
+
if (blob.size > targetSizeBytes) {
|
|
8294
|
+
throw ErrorSVGExceedSize;
|
|
8295
|
+
}
|
|
8249
8296
|
return URL.createObjectURL(blob);
|
|
8250
8297
|
}
|
|
8251
8298
|
var CropperModal = ({
|
|
@@ -8258,6 +8305,7 @@ var CropperModal = ({
|
|
|
8258
8305
|
onError,
|
|
8259
8306
|
cropSize,
|
|
8260
8307
|
outputExactCropSize,
|
|
8308
|
+
targetFileSizeKB,
|
|
8261
8309
|
generateBlobUrlOutput,
|
|
8262
8310
|
title,
|
|
8263
8311
|
props
|
|
@@ -8294,7 +8342,7 @@ var CropperModal = ({
|
|
|
8294
8342
|
setIsLoading(true);
|
|
8295
8343
|
try {
|
|
8296
8344
|
const desiredDimension = outputExactCropSize ? cropSize : void 0;
|
|
8297
|
-
const croppedImage = isSVG ? await getCroppedSVG(imageSrc, croppedAreaPixels, desiredDimension) : await getCroppedImg(imageSrc, croppedAreaPixels, desiredDimension);
|
|
8345
|
+
const croppedImage = isSVG ? await getCroppedSVG(imageSrc, croppedAreaPixels, desiredDimension, targetFileSizeKB) : await getCroppedImg(imageSrc, croppedAreaPixels, desiredDimension, targetFileSizeKB);
|
|
8298
8346
|
onConfirm({ crop, croppedAreaPixels, croppedImageBlobUrl: croppedImage });
|
|
8299
8347
|
} catch (e) {
|
|
8300
8348
|
if (onError) {
|
|
@@ -8382,6 +8430,7 @@ exports.Collapsible = Collapsible;
|
|
|
8382
8430
|
exports.CollapsibleContent = CollapsibleContent2;
|
|
8383
8431
|
exports.CollapsibleTrigger = CollapsibleTrigger2;
|
|
8384
8432
|
exports.CropperModal = CropperModal;
|
|
8433
|
+
exports.CropperModalError = CropperModalError;
|
|
8385
8434
|
exports.DIALOG_ALERT_I18N_NAMESPACE = DIALOG_ALERT_I18N_NAMESPACE;
|
|
8386
8435
|
exports.DataTable = DataTable_default;
|
|
8387
8436
|
exports.DatePicker = DatePicker2;
|
|
@@ -8393,6 +8442,11 @@ exports.DialogDescription = DialogDescription;
|
|
|
8393
8442
|
exports.DialogFooter = DialogFooter;
|
|
8394
8443
|
exports.DialogTitle = DialogTitle;
|
|
8395
8444
|
exports.DialogTrigger = DialogTrigger;
|
|
8445
|
+
exports.ErrorCompression = ErrorCompression;
|
|
8446
|
+
exports.ErrorCreateCanvas = ErrorCreateCanvas;
|
|
8447
|
+
exports.ErrorGeneratingBlob = ErrorGeneratingBlob;
|
|
8448
|
+
exports.ErrorInvalidSVG = ErrorInvalidSVG;
|
|
8449
|
+
exports.ErrorSVGExceedSize = ErrorSVGExceedSize;
|
|
8396
8450
|
exports.Form = Form;
|
|
8397
8451
|
exports.FormControl = FormControl;
|
|
8398
8452
|
exports.FormDescription = FormDescription;
|
|
@@ -8466,6 +8520,7 @@ exports.SidebarRail = SidebarRail;
|
|
|
8466
8520
|
exports.SidebarSeparator = SidebarSeparator;
|
|
8467
8521
|
exports.SidebarTrigger = SidebarTrigger;
|
|
8468
8522
|
exports.Skeleton = Skeleton;
|
|
8523
|
+
exports.Spinner = Spinner;
|
|
8469
8524
|
exports.SuiCalendarIcon = calendar_default;
|
|
8470
8525
|
exports.SuiCheckIcon = check_default;
|
|
8471
8526
|
exports.SuiDotsVerticalIcon = dots_vertical_default;
|
|
@@ -8494,6 +8549,7 @@ exports.inputVariants = inputVariants;
|
|
|
8494
8549
|
exports.isDefined = isDefined;
|
|
8495
8550
|
exports.isEmptyObject = isEmptyObject;
|
|
8496
8551
|
exports.selectValueToBoolean = selectValueToBoolean;
|
|
8552
|
+
exports.spinnerVariants = spinnerVariants;
|
|
8497
8553
|
exports.stripNullishObject = stripNullishObject;
|
|
8498
8554
|
exports.throttle = throttle;
|
|
8499
8555
|
exports.useFormField = useFormField;
|