@ctlyst.id/internal-ui 3.5.4 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.mts CHANGED
@@ -874,11 +874,6 @@ declare const Uploader: React__default.FC<UploaderProps>;
874
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;
882
877
 
883
878
  declare enum ErrorCode {
884
879
  FileInvalidType = "file-invalid-type",
@@ -921,4 +916,4 @@ declare const ProviderContext: React__default.Context<ProviderContextObject>;
921
916
  declare const useInternalUI: () => ProviderContextObject;
922
917
  declare const Provider: FC<ProviderProps>;
923
918
 
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 };
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 };
package/dist/index.d.ts CHANGED
@@ -874,11 +874,6 @@ declare const Uploader: React__default.FC<UploaderProps>;
874
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;
882
877
 
883
878
  declare enum ErrorCode {
884
879
  FileInvalidType = "file-invalid-type",
@@ -921,4 +916,4 @@ declare const ProviderContext: React__default.Context<ProviderContextObject>;
921
916
  declare const useInternalUI: () => ProviderContextObject;
922
917
  declare const Provider: FC<ProviderProps>;
923
918
 
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 };
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 };
package/dist/index.js CHANGED
@@ -340,7 +340,6 @@ __export(src_exports, {
340
340
  defaultOnHandleRejections: () => defaultOnHandleRejections,
341
341
  dimensionValidator: () => dimensionValidator,
342
342
  extendTheme: () => import_react104.extendTheme,
343
- extensionValidator: () => extensionValidator,
344
343
  forwardRef: () => import_react104.forwardRef,
345
344
  getSelectAllCheckboxState: () => getSelectAllCheckboxState,
346
345
  getTheme: () => getTheme,
@@ -3120,7 +3119,7 @@ var Datepicker = ({
3120
3119
  isError,
3121
3120
  addOnRight: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_react20.InputRightElement, { alignSelf: "center", bottom: 0, flexDir: "row-reverse", width: "auto", mr: 2, gap: 2, children: [
3122
3121
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_internal_icon6.Calendar, { size: 4, color: "neutral.400" }),
3123
- value && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3122
+ value && !props.disabled && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3124
3123
  import_react33.IconButton,
3125
3124
  {
3126
3125
  "data-test-id": "H0rseVCzGIaqoLho-EPbu",
@@ -5843,47 +5842,6 @@ var defaultOnHandleRejections = (fileRejection, config2, handleRejection) => {
5843
5842
  }
5844
5843
  };
5845
5844
 
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 : formatValidationMessage(extensions)
5881
- };
5882
- }
5883
- return null;
5884
- };
5885
- };
5886
-
5887
5845
  // src/components/uploader/components/uploader.tsx
5888
5846
  var import_jsx_runtime66 = require("react/jsx-runtime");
5889
5847
  var Uploader = ({
@@ -5958,12 +5916,6 @@ var Uploader = ({
5958
5916
  const validator = (0, import_react90.useCallback)(
5959
5917
  (file) => {
5960
5918
  const result = [];
5961
- if (acceptFormat.validate) {
5962
- const error = extensionValidator(acceptFormat.validate, acceptFormat.message)(file);
5963
- if (error) {
5964
- result.push(error);
5965
- }
5966
- }
5967
5919
  if (validatorExt) {
5968
5920
  validatorExt.forEach((validatorFn) => {
5969
5921
  const error = validatorFn(file);
@@ -5977,12 +5929,11 @@ var Uploader = ({
5977
5929
  },
5978
5930
  [validatorExt]
5979
5931
  );
5932
+ const acceptFile = acceptFormat.validate.map((type) => [`image/${type}`, []]);
5980
5933
  const { getRootProps, getInputProps, isDragActive, acceptedFiles, open } = (0, import_react_dropzone.useDropzone)({
5981
5934
  onDropAccepted,
5982
5935
  onDropRejected,
5983
- accept: {
5984
- "image/*": [...acceptFormat.validate]
5985
- },
5936
+ accept: Object.fromEntries(acceptFile),
5986
5937
  maxFiles: 1,
5987
5938
  maxSize: maxFileSize == null ? void 0 : maxFileSize.validate,
5988
5939
  noClick: isDisabled,
@@ -6132,6 +6083,35 @@ var Uploader = ({
6132
6083
  };
6133
6084
  var uploader_default = Uploader;
6134
6085
 
6086
+ // src/components/uploader/utils/is-ratio-equal.ts
6087
+ var isRatioEqual = (base, img) => {
6088
+ const baseRatio = (base.width / base.height).toFixed(2);
6089
+ const imgRatio = (img.width / img.height).toFixed(2);
6090
+ return baseRatio === imgRatio;
6091
+ };
6092
+
6093
+ // src/components/uploader/components/validator.ts
6094
+ var dimensionValidator = (dimension, message) => {
6095
+ return (file) => {
6096
+ const imageUrl = URL.createObjectURL(file);
6097
+ const img = new Image();
6098
+ img.src = imageUrl;
6099
+ img.onload = () => {
6100
+ };
6101
+ const isRatioValid = isRatioEqual(
6102
+ { width: dimension[0], height: dimension[1] },
6103
+ { width: img.width, height: img.height }
6104
+ );
6105
+ if (isRatioValid) {
6106
+ return null;
6107
+ }
6108
+ return {
6109
+ code: error_code_default.FileInvalidDimension,
6110
+ message: message != null ? message : "File has invalid dimension"
6111
+ };
6112
+ };
6113
+ };
6114
+
6135
6115
  // src/components/index.ts
6136
6116
  var import_react91 = require("@chakra-ui/react");
6137
6117
 
@@ -8148,7 +8128,6 @@ var import_react104 = require("@chakra-ui/react");
8148
8128
  defaultOnHandleRejections,
8149
8129
  dimensionValidator,
8150
8130
  extendTheme,
8151
- extensionValidator,
8152
8131
  forwardRef,
8153
8132
  getSelectAllCheckboxState,
8154
8133
  getTheme,