@ctlyst.id/internal-ui 3.5.1 → 3.5.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.mts CHANGED
@@ -870,10 +870,15 @@ type UploaderProps = FlexProps & {
870
870
  declare const Uploader: React__default.FC<UploaderProps>;
871
871
 
872
872
  /**
873
- * @param file
874
873
  * @param dimension [[width, height]]
874
+ * @param message
875
875
  */
876
876
  declare const dimensionValidator: (dimension: [number, number], message?: string) => (file: File) => FileError | null;
877
+ /**
878
+ * @param extension
879
+ * @param message
880
+ */
881
+ declare const extensionValidator: (extensions: string[], message?: string) => (file: File) => FileError | null;
877
882
 
878
883
  declare enum ErrorCode {
879
884
  FileInvalidType = "file-invalid-type",
@@ -916,4 +921,4 @@ declare const ProviderContext: React__default.Context<ProviderContextObject>;
916
921
  declare const useInternalUI: () => ProviderContextObject;
917
922
  declare const Provider: FC<ProviderProps>;
918
923
 
919
- export { AccordionEye, AccordionIndicator, Alert, AlertAction, type AlertActionProps, AlertClose, type AlertCloseProps, AlertDescription, type AlertDescriptionProps, AlertIcon, type AlertIconProps, type AlertProps, type AlertStatus, AlertTitle, type AlertTitleProps, Anchor, type AnchorProps, Badge, type BadgeProps, BreadCrumb, type BreadCrumbParentProps, type BreadCrumbProps, Button, type ButtonProps, CHECKBOX_STATE, CardCustom as Card, type CardProps, CheckboxComponent as Checkbox, type CheckboxComponentProps, CheckboxGroupComponent as CheckboxGroup, type CheckboxGroupComponentProps, Chips, type ChipsProps, ClearIndicator, Counter, type CustomLoaderProps, _default as DataTable, type DataTableProps, type DataTableRefs, DatePickerMonth, type DatePickerMonthProps, Datepicker, type DatepickerProps, Dialog, type DisabledRowData, DropdownIndicator, EmptyState, type Environment, ErrorCode, Field, type FieldProps, Header, type HeaderDataProps, type HeaderProps, InputAddonLeft, InputAddonRight, InputField, type InputFieldProps, Loader, type LoaderProps, Logo, type LogoProps, Navigation as MainMenu, ModalBackButton, MultiDatePickerMonth, type MultiDatePickerMonthProps, MultiValue, MultiValueRemove, NavItem, type NavItemProps, Navbar, type NavbarProps, NavigationBar, type NavigationBarProps, type NavigationProps, NoOptionsMessage, type OptionGroup, type OptionMultiGroup, type OptionsGroup, Pagination, PaginationDetail, type PaginationDetailProps, PaginationFilter, type PaginationFilterProps, type PaginationProps, Profile, type ProfileProps, type Props, Provider, ProviderContext, Radio, RadioGroup, type RadioGroupComponentProps, type RadioProps, Rating, type RatingProps, Select, SelectAsync, SelectAsyncCreatable, type SelectAsyncCreatableProps, type SelectAsyncProps, SelectCheckbox as SelectCheckBox, SelectCreatable, type SelectCreatableProps, type SelectProps, type SelectWithCheckboxBaseProps, Sidebar, SidebarHeader, type SidebarHeaderProps, SidebarMenu, type SidebarMenuProps, type SidebarProps, Switch, type SwitchProps, Tab, type TableStyleProps, type TextAreaProps, TextareaField, type Theme, Time, TimeInput, type TimeInputProps, type TimeOptions, Tooltip, type TooltipProps, Uploader, type UploaderProps, Version, type VersionProps, VoilaLogo, XMSLogo, createExtendTheme, defaultOnHandleRejections, dimensionValidator, getSelectAllCheckboxState, getTheme, isCellDisabled, isRatioEqual, selectStyles, theme, themeSelect, useAlertStyles, useDataTable, useFetcher, useInternalUI, useToast };
924
+ export { AccordionEye, AccordionIndicator, Alert, AlertAction, type AlertActionProps, AlertClose, type AlertCloseProps, AlertDescription, type AlertDescriptionProps, AlertIcon, type AlertIconProps, type AlertProps, type AlertStatus, AlertTitle, type AlertTitleProps, Anchor, type AnchorProps, Badge, type BadgeProps, BreadCrumb, type BreadCrumbParentProps, type BreadCrumbProps, Button, type ButtonProps, CHECKBOX_STATE, CardCustom as Card, type CardProps, CheckboxComponent as Checkbox, type CheckboxComponentProps, CheckboxGroupComponent as CheckboxGroup, type CheckboxGroupComponentProps, Chips, type ChipsProps, ClearIndicator, Counter, type CustomLoaderProps, _default as DataTable, type DataTableProps, type DataTableRefs, DatePickerMonth, type DatePickerMonthProps, Datepicker, type DatepickerProps, Dialog, type DisabledRowData, DropdownIndicator, EmptyState, type Environment, ErrorCode, Field, type FieldProps, Header, type HeaderDataProps, type HeaderProps, InputAddonLeft, InputAddonRight, InputField, type InputFieldProps, Loader, type LoaderProps, Logo, type LogoProps, Navigation as MainMenu, ModalBackButton, MultiDatePickerMonth, type MultiDatePickerMonthProps, MultiValue, MultiValueRemove, NavItem, type NavItemProps, Navbar, type NavbarProps, NavigationBar, type NavigationBarProps, type NavigationProps, NoOptionsMessage, type OptionGroup, type OptionMultiGroup, type OptionsGroup, Pagination, PaginationDetail, type PaginationDetailProps, PaginationFilter, type PaginationFilterProps, type PaginationProps, Profile, type ProfileProps, type Props, Provider, ProviderContext, Radio, RadioGroup, type RadioGroupComponentProps, type RadioProps, Rating, type RatingProps, Select, SelectAsync, SelectAsyncCreatable, type SelectAsyncCreatableProps, type SelectAsyncProps, SelectCheckbox as SelectCheckBox, SelectCreatable, type SelectCreatableProps, type SelectProps, type SelectWithCheckboxBaseProps, Sidebar, SidebarHeader, type SidebarHeaderProps, SidebarMenu, type SidebarMenuProps, type SidebarProps, Switch, type SwitchProps, Tab, type TableStyleProps, type TextAreaProps, TextareaField, type Theme, Time, TimeInput, type TimeInputProps, type TimeOptions, Tooltip, type TooltipProps, Uploader, type UploaderProps, Version, type VersionProps, VoilaLogo, XMSLogo, createExtendTheme, defaultOnHandleRejections, dimensionValidator, extensionValidator, getSelectAllCheckboxState, getTheme, isCellDisabled, isRatioEqual, selectStyles, theme, themeSelect, useAlertStyles, useDataTable, useFetcher, useInternalUI, useToast };
package/dist/index.d.ts CHANGED
@@ -870,10 +870,15 @@ type UploaderProps = FlexProps & {
870
870
  declare const Uploader: React__default.FC<UploaderProps>;
871
871
 
872
872
  /**
873
- * @param file
874
873
  * @param dimension [[width, height]]
874
+ * @param message
875
875
  */
876
876
  declare const dimensionValidator: (dimension: [number, number], message?: string) => (file: File) => FileError | null;
877
+ /**
878
+ * @param extension
879
+ * @param message
880
+ */
881
+ declare const extensionValidator: (extensions: string[], message?: string) => (file: File) => FileError | null;
877
882
 
878
883
  declare enum ErrorCode {
879
884
  FileInvalidType = "file-invalid-type",
@@ -916,4 +921,4 @@ declare const ProviderContext: React__default.Context<ProviderContextObject>;
916
921
  declare const useInternalUI: () => ProviderContextObject;
917
922
  declare const Provider: FC<ProviderProps>;
918
923
 
919
- export { AccordionEye, AccordionIndicator, Alert, AlertAction, type AlertActionProps, AlertClose, type AlertCloseProps, AlertDescription, type AlertDescriptionProps, AlertIcon, type AlertIconProps, type AlertProps, type AlertStatus, AlertTitle, type AlertTitleProps, Anchor, type AnchorProps, Badge, type BadgeProps, BreadCrumb, type BreadCrumbParentProps, type BreadCrumbProps, Button, type ButtonProps, CHECKBOX_STATE, CardCustom as Card, type CardProps, CheckboxComponent as Checkbox, type CheckboxComponentProps, CheckboxGroupComponent as CheckboxGroup, type CheckboxGroupComponentProps, Chips, type ChipsProps, ClearIndicator, Counter, type CustomLoaderProps, _default as DataTable, type DataTableProps, type DataTableRefs, DatePickerMonth, type DatePickerMonthProps, Datepicker, type DatepickerProps, Dialog, type DisabledRowData, DropdownIndicator, EmptyState, type Environment, ErrorCode, Field, type FieldProps, Header, type HeaderDataProps, type HeaderProps, InputAddonLeft, InputAddonRight, InputField, type InputFieldProps, Loader, type LoaderProps, Logo, type LogoProps, Navigation as MainMenu, ModalBackButton, MultiDatePickerMonth, type MultiDatePickerMonthProps, MultiValue, MultiValueRemove, NavItem, type NavItemProps, Navbar, type NavbarProps, NavigationBar, type NavigationBarProps, type NavigationProps, NoOptionsMessage, type OptionGroup, type OptionMultiGroup, type OptionsGroup, Pagination, PaginationDetail, type PaginationDetailProps, PaginationFilter, type PaginationFilterProps, type PaginationProps, Profile, type ProfileProps, type Props, Provider, ProviderContext, Radio, RadioGroup, type RadioGroupComponentProps, type RadioProps, Rating, type RatingProps, Select, SelectAsync, SelectAsyncCreatable, type SelectAsyncCreatableProps, type SelectAsyncProps, SelectCheckbox as SelectCheckBox, SelectCreatable, type SelectCreatableProps, type SelectProps, type SelectWithCheckboxBaseProps, Sidebar, SidebarHeader, type SidebarHeaderProps, SidebarMenu, type SidebarMenuProps, type SidebarProps, Switch, type SwitchProps, Tab, type TableStyleProps, type TextAreaProps, TextareaField, type Theme, Time, TimeInput, type TimeInputProps, type TimeOptions, Tooltip, type TooltipProps, Uploader, type UploaderProps, Version, type VersionProps, VoilaLogo, XMSLogo, createExtendTheme, defaultOnHandleRejections, dimensionValidator, getSelectAllCheckboxState, getTheme, isCellDisabled, isRatioEqual, selectStyles, theme, themeSelect, useAlertStyles, useDataTable, useFetcher, useInternalUI, useToast };
924
+ export { AccordionEye, AccordionIndicator, Alert, AlertAction, type AlertActionProps, AlertClose, type AlertCloseProps, AlertDescription, type AlertDescriptionProps, AlertIcon, type AlertIconProps, type AlertProps, type AlertStatus, AlertTitle, type AlertTitleProps, Anchor, type AnchorProps, Badge, type BadgeProps, BreadCrumb, type BreadCrumbParentProps, type BreadCrumbProps, Button, type ButtonProps, CHECKBOX_STATE, CardCustom as Card, type CardProps, CheckboxComponent as Checkbox, type CheckboxComponentProps, CheckboxGroupComponent as CheckboxGroup, type CheckboxGroupComponentProps, Chips, type ChipsProps, ClearIndicator, Counter, type CustomLoaderProps, _default as DataTable, type DataTableProps, type DataTableRefs, DatePickerMonth, type DatePickerMonthProps, Datepicker, type DatepickerProps, Dialog, type DisabledRowData, DropdownIndicator, EmptyState, type Environment, ErrorCode, Field, type FieldProps, Header, type HeaderDataProps, type HeaderProps, InputAddonLeft, InputAddonRight, InputField, type InputFieldProps, Loader, type LoaderProps, Logo, type LogoProps, Navigation as MainMenu, ModalBackButton, MultiDatePickerMonth, type MultiDatePickerMonthProps, MultiValue, MultiValueRemove, NavItem, type NavItemProps, Navbar, type NavbarProps, NavigationBar, type NavigationBarProps, type NavigationProps, NoOptionsMessage, type OptionGroup, type OptionMultiGroup, type OptionsGroup, Pagination, PaginationDetail, type PaginationDetailProps, PaginationFilter, type PaginationFilterProps, type PaginationProps, Profile, type ProfileProps, type Props, Provider, ProviderContext, Radio, RadioGroup, type RadioGroupComponentProps, type RadioProps, Rating, type RatingProps, Select, SelectAsync, SelectAsyncCreatable, type SelectAsyncCreatableProps, type SelectAsyncProps, SelectCheckbox as SelectCheckBox, SelectCreatable, type SelectCreatableProps, type SelectProps, type SelectWithCheckboxBaseProps, Sidebar, SidebarHeader, type SidebarHeaderProps, SidebarMenu, type SidebarMenuProps, type SidebarProps, Switch, type SwitchProps, Tab, type TableStyleProps, type TextAreaProps, TextareaField, type Theme, Time, TimeInput, type TimeInputProps, type TimeOptions, Tooltip, type TooltipProps, Uploader, type UploaderProps, Version, type VersionProps, VoilaLogo, XMSLogo, createExtendTheme, defaultOnHandleRejections, dimensionValidator, extensionValidator, getSelectAllCheckboxState, getTheme, isCellDisabled, isRatioEqual, selectStyles, theme, themeSelect, useAlertStyles, useDataTable, useFetcher, useInternalUI, useToast };
package/dist/index.js CHANGED
@@ -340,6 +340,7 @@ __export(src_exports, {
340
340
  defaultOnHandleRejections: () => defaultOnHandleRejections,
341
341
  dimensionValidator: () => dimensionValidator,
342
342
  extendTheme: () => import_react104.extendTheme,
343
+ extensionValidator: () => extensionValidator,
343
344
  forwardRef: () => import_react104.forwardRef,
344
345
  getSelectAllCheckboxState: () => getSelectAllCheckboxState,
345
346
  getTheme: () => getTheme,
@@ -3106,7 +3107,7 @@ var Datepicker = ({
3106
3107
  const { placement, y } = state;
3107
3108
  return {
3108
3109
  ...state,
3109
- y: placement.startsWith("bottom") ? y - 10 : y + 10
3110
+ y: placement.startsWith("bottom") ? y - 10 : y + 14
3110
3111
  // condition for auto placement
3111
3112
  };
3112
3113
  }
@@ -5842,6 +5843,47 @@ var defaultOnHandleRejections = (fileRejection, config2, handleRejection) => {
5842
5843
  }
5843
5844
  };
5844
5845
 
5846
+ // src/components/uploader/utils/is-ratio-equal.ts
5847
+ var isRatioEqual = (base, img) => {
5848
+ const baseRatio = (base.width / base.height).toFixed(2);
5849
+ const imgRatio = (img.width / img.height).toFixed(2);
5850
+ return baseRatio === imgRatio;
5851
+ };
5852
+
5853
+ // src/components/uploader/components/validator.ts
5854
+ var dimensionValidator = (dimension, message) => {
5855
+ return (file) => {
5856
+ const imageUrl = URL.createObjectURL(file);
5857
+ const img = new Image();
5858
+ img.src = imageUrl;
5859
+ img.onload = () => {
5860
+ };
5861
+ const isRatioValid = isRatioEqual(
5862
+ { width: dimension[0], height: dimension[1] },
5863
+ { width: img.width, height: img.height }
5864
+ );
5865
+ if (isRatioValid) {
5866
+ return null;
5867
+ }
5868
+ return {
5869
+ code: error_code_default.FileInvalidDimension,
5870
+ message: message != null ? message : "File has invalid dimension"
5871
+ };
5872
+ };
5873
+ };
5874
+ var extensionValidator = (extensions, message) => {
5875
+ return (file) => {
5876
+ const fileFormat = file.name.split(".").pop();
5877
+ if (!extensions.includes(fileFormat)) {
5878
+ return {
5879
+ code: error_code_default.FileInvalidType,
5880
+ message: message != null ? message : "File has invalid dimension"
5881
+ };
5882
+ }
5883
+ return null;
5884
+ };
5885
+ };
5886
+
5845
5887
  // src/components/uploader/components/uploader.tsx
5846
5888
  var import_jsx_runtime66 = require("react/jsx-runtime");
5847
5889
  var Uploader = ({
@@ -5915,16 +5957,22 @@ var Uploader = ({
5915
5957
  }, []);
5916
5958
  const validator = (0, import_react90.useCallback)(
5917
5959
  (file) => {
5960
+ const result = [];
5961
+ if (acceptFormat.validate) {
5962
+ const error = extensionValidator(acceptFormat.validate, acceptFormat.message)(file);
5963
+ if (error) {
5964
+ result.push(error);
5965
+ }
5966
+ }
5918
5967
  if (validatorExt) {
5919
- const result = [];
5920
5968
  validatorExt.forEach((validatorFn) => {
5921
5969
  const error = validatorFn(file);
5922
5970
  if (Array.isArray(error)) {
5923
5971
  result.push(...error);
5924
5972
  } else if (error) result.push(error);
5925
5973
  });
5926
- return result;
5927
5974
  }
5975
+ if (result.length > 0) return result;
5928
5976
  return null;
5929
5977
  },
5930
5978
  [validatorExt]
@@ -6084,36 +6132,6 @@ var Uploader = ({
6084
6132
  };
6085
6133
  var uploader_default = Uploader;
6086
6134
 
6087
- // src/components/uploader/utils/is-ratio-equal.ts
6088
- var isRatioEqual = (base, img) => {
6089
- const baseRatio = (base.width / base.height).toFixed(2);
6090
- const imgRatio = (img.width / img.height).toFixed(2);
6091
- return baseRatio === imgRatio;
6092
- };
6093
-
6094
- // src/components/uploader/components/validator.ts
6095
- var dimensionValidator = (dimension, message) => {
6096
- return (file) => {
6097
- const imageUrl = URL.createObjectURL(file);
6098
- const img = new Image();
6099
- img.src = imageUrl;
6100
- img.onload = () => {
6101
- };
6102
- const isRatioValid = isRatioEqual(
6103
- { width: dimension[0], height: dimension[1] },
6104
- { width: img.width, height: img.height }
6105
- );
6106
- console.log("log", isRatioValid);
6107
- if (isRatioValid) {
6108
- return null;
6109
- }
6110
- return {
6111
- code: error_code_default.FileInvalidDimension,
6112
- message: message != null ? message : "File has invalid dimension"
6113
- };
6114
- };
6115
- };
6116
-
6117
6135
  // src/components/index.ts
6118
6136
  var import_react91 = require("@chakra-ui/react");
6119
6137
 
@@ -8130,6 +8148,7 @@ var import_react104 = require("@chakra-ui/react");
8130
8148
  defaultOnHandleRejections,
8131
8149
  dimensionValidator,
8132
8150
  extendTheme,
8151
+ extensionValidator,
8133
8152
  forwardRef,
8134
8153
  getSelectAllCheckboxState,
8135
8154
  getTheme,