gantri-components 2.133.0-beta.1 → 2.133.0-beta.10

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.
Files changed (21) hide show
  1. package/dist/components/file-uploader/file-uploader.styles.d.ts +2 -2
  2. package/dist/components/file-uploader/file-uploader.types.d.ts +12 -3
  3. package/dist/components/file-uploader/helpers/get-valid-files/get-valid-files.types.d.ts +1 -1
  4. package/dist/components/file-uploader/helpers/index.d.ts +1 -0
  5. package/dist/components/file-uploader/helpers/validate-file-extension/index.d.ts +1 -0
  6. package/dist/components/file-uploader/helpers/validate-file-extension/validate-file-extension.d.ts +3 -0
  7. package/dist/components/file-uploader/helpers/validate-file-extension/validate-file-extension.types.d.ts +4 -0
  8. package/dist/components/file-uploader/helpers/validate-image-dimensions/validate-image-dimensions.d.ts +3 -3
  9. package/dist/components/file-uploader/helpers/validate-image-dimensions/validate-image-dimensions.types.d.ts +8 -1
  10. package/dist/components/file-uploader/hooks/use-drag-and-drop-files/use-drag-and-drop-files.d.ts +6 -1
  11. package/dist/components/file-uploader/hooks/use-drag-and-drop-files/use-drag-and-drop-files.types.d.ts +3 -3
  12. package/dist/components/file-uploader/hooks/use-uploader-actions/hooks/use-handle-selected-files/use-handle-selected-files.types.d.ts +1 -1
  13. package/dist/components/file-uploader/hooks/use-uploader-actions/use-uploader-actions.types.d.ts +1 -1
  14. package/dist/helpers/generate-skus-functions/helpers/generate-skus-from-options/generate-skus-from-options.types.d.ts +0 -1
  15. package/dist/index.cjs.js +1 -1
  16. package/dist/index.cjs.js.map +1 -1
  17. package/dist/index.esm.js +1 -1
  18. package/dist/index.esm.js.map +1 -1
  19. package/dist/index.umd.js +1 -1
  20. package/dist/index.umd.js.map +1 -1
  21. package/package.json +1 -1
@@ -2,6 +2,6 @@
2
2
  import { OptionalValues } from '../../types/common';
3
3
  export declare const StyledFileInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, OptionalValues<{
4
4
  $fileUrl: string;
5
- $isDisabled: boolean;
6
- $isThumbnail: boolean;
5
+ $isDropZone: boolean;
6
+ disabled: boolean;
7
7
  }, undefined>>> & string;
@@ -12,16 +12,19 @@ export type FileUploaderProps = {
12
12
  fileUrl: string;
13
13
  /** This function should delete the record from the database, ***then*** delete the file. */
14
14
  handleDeleteFile: HandleDeleteFile;
15
- /** Provide this if supporting multiple uploads to prevent multiple calls to update the database. */
16
- handleUploadsComplete: HandleUploadsComplete;
17
15
  inputName?: string;
18
16
  isActive?: boolean;
19
17
  isDisabled?: boolean;
18
+ /** Updates the input to be used as a file drop zone. */
19
+ isDropZone?: boolean;
20
20
  /** Use with variant `'thumbnail'` to always show the uploader view. */
21
21
  isUploaderOnly?: boolean;
22
22
  onBlur?: FocusEventHandler<HTMLInputElement>;
23
23
  onClick?: BoxProps['onClick'];
24
24
  onError: OnFileUploaderError;
25
+ onValidationCompleted?: () => void;
26
+ onValidationStarted?: () => void;
27
+ onlyUseCustomValidationFn?: boolean;
25
28
  /** Used to show loading indicator for `'thumbnail'` variant. For the `'button'` variant, it can be passed here or as part of `buttonProps`. */
26
29
  processing: boolean;
27
30
  purifyFileName?: boolean;
@@ -30,6 +33,7 @@ export type FileUploaderProps = {
30
33
  transformThumbnailSrc?: TransformThumbnailSrc;
31
34
  /** If invalid, return the error message to display. */
32
35
  validateFile?: ValidateFile;
36
+ validateSequentially?: boolean;
33
37
  /** The 'link' and 'plain' variants will show the 'button' variant if nothing has been uploaded yet. */
34
38
  variant: FileUploaderVariant;
35
39
  } & Partial<FileUploaderDefaultProps> & (WithDraggableProps | WithoutDraggableProps) & (WithReplaceableProps | WithoutReplaceableProps) & (ImmediatelyUploadProps | DelayUploadProps) & (WithCustomContent | WithoutCustomContent);
@@ -57,12 +61,13 @@ export interface FileMetaData {
57
61
  }
58
62
  export interface SelectedFileDetails {
59
63
  fileBlob: Blob;
64
+ fileExtension: string;
60
65
  fileName: string;
61
66
  fileSize: number;
62
67
  metadata: FileMetaData;
63
68
  }
64
69
  /** If invalid, return the error message to display. */
65
- export type ValidateFile = (file: SelectedFileDetails) => string | undefined | void;
70
+ export type ValidateFile = (file: SelectedFileDetails) => Promise<string | undefined | void> | string | undefined | void;
66
71
  export type HandleFileSelected = (props: SelectedFileDetails) => Promise<any>;
67
72
  export type FileUploaderCustomContent = (props: {
68
73
  IconCopyUrl: () => JSX.Element;
@@ -88,10 +93,14 @@ export type TransformThumbnailSrc = (props: {
88
93
  type ImmediatelyUploadProps = {
89
94
  handleFileSelected?: never;
90
95
  handleUploadFile: HandleUploadFile;
96
+ /** Use this if supporting multiple uploads to prevent multiple calls to update the database. */
97
+ handleUploadsComplete: HandleUploadsComplete;
91
98
  };
92
99
  type DelayUploadProps = {
93
100
  handleFileSelected: HandleFileSelected;
94
101
  handleUploadFile?: never;
102
+ /** Use this if supporting multiple uploads to prevent multiple calls to update the database. */
103
+ handleUploadsComplete?: never;
95
104
  };
96
105
  type WithDraggableProps = {
97
106
  SortableDragHandleWrapper: (props: PropsWithChildren<HTMLAttributes<HTMLElement>>) => JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { FileUploaderProps } from '../../file-uploader.types';
2
2
  import { OptionalValues } from '../../../../types/common';
3
- export type GetValidFilesProps = OptionalValues<Pick<FileUploaderProps, 'expectedExtensions' | 'maxFileSizeMB' | 'maxUploadsAllowed' | 'minImageHeight' | 'minImageWidth' | 'onError' | 'transformFileName' | 'validateFile'>> & {
3
+ export type GetValidFilesProps = OptionalValues<Required<Pick<FileUploaderProps, 'expectedExtensions' | 'maxFileSizeMB' | 'maxUploadsAllowed' | 'minImageHeight' | 'minImageWidth' | 'onError' | 'onlyUseCustomValidationFn' | 'transformFileName' | 'validateFile' | 'validateSequentially'>>> & {
4
4
  files: File[];
5
5
  };
@@ -2,5 +2,6 @@ export * from './get-base-64-from-blob';
2
2
  export * from './get-purified-file-name';
3
3
  export * from './get-valid-files';
4
4
  export * from './transform-file-name';
5
+ export * from './validate-file-extension';
5
6
  export * from './validate-file-size';
6
7
  export * from './validate-image-dimensions';
@@ -0,0 +1 @@
1
+ export * from './validate-file-extension';
@@ -0,0 +1,3 @@
1
+ import { ValidateExtensionsProps } from './validate-file-extension.types';
2
+ /** Validates when files are added via drag and drop. */
3
+ export declare const validateExtensions: (props: ValidateExtensionsProps) => string | undefined;
@@ -0,0 +1,4 @@
1
+ export interface ValidateExtensionsProps {
2
+ expectedExtensions: string[];
3
+ fileExtension: string;
4
+ }
@@ -1,3 +1,3 @@
1
- import { ValidateImageScale } from './validate-image-dimensions.types';
2
- /** Returns an error message if invalid. */
3
- export declare const validateImageDimensions: (props: ValidateImageScale) => string | undefined;
1
+ import { ValidateImageDimensionsProps } from './validate-image-dimensions.types';
2
+ /** Returns error message if invalid. */
3
+ export declare const validateImageDimensions: (props: ValidateImageDimensionsProps) => Promise<string | undefined>;
@@ -1,6 +1,13 @@
1
- export type ValidateImageScale = {
1
+ export type ValidateDimensionsProps = {
2
2
  fileName: string;
3
3
  img: HTMLImageElement;
4
4
  minHeight: number;
5
5
  minWidth: number;
6
6
  };
7
+ export interface ValidateImageDimensionsProps {
8
+ fileName: string;
9
+ minHeight: number;
10
+ minWidth: number;
11
+ /** If file is a `Blob`, convert to base64 `src` using `getBase64FromBlob`. */
12
+ src: string;
13
+ }
@@ -1,8 +1,13 @@
1
1
  import { DragEvent } from 'react';
2
2
  import { UseDragAndDropFilesProps } from './use-drag-and-drop-files.types';
3
3
  export declare const useDragAndDropFiles: (props: UseDragAndDropFilesProps) => {
4
- isDraggingOver: boolean;
5
4
  onDragEnter: (event: DragEvent<HTMLInputElement>) => void;
6
5
  onDragLeave: (event: DragEvent<HTMLInputElement>) => void;
7
6
  onDrop: (event: DragEvent<HTMLInputElement>) => Promise<void>;
7
+ isDraggingOver: boolean;
8
+ } | {
9
+ onDragEnter?: undefined;
10
+ onDragLeave?: undefined;
11
+ onDrop?: undefined;
12
+ isDraggingOver: boolean;
8
13
  };
@@ -1,4 +1,4 @@
1
- import { FileUploaderProps } from '../../file-uploader.types';
2
- export type UseDragAndDropFilesProps = Pick<FileUploaderProps, 'variant' | 'fileUrl'> & {
1
+ export interface UseDragAndDropFilesProps {
2
+ enable: boolean;
3
3
  handleSelectedFiles: (files: File[]) => Promise<void>;
4
- };
4
+ }
@@ -1,7 +1,7 @@
1
1
  import { Dispatch, SetStateAction } from 'react';
2
2
  import { SelectedFileDetails, FileUploaderProps } from '../../../../file-uploader.types';
3
3
  import { OptionalValues } from '../../../../../../types/common';
4
- export type UseHandleSelectedFilesProps = OptionalValues<Required<Pick<FileUploaderProps, 'expectedExtensions' | 'fileUrl' | 'handleFileSelected' | 'handleUploadsComplete' | 'isUploaderOnly' | 'maxFileSizeMB' | 'maxUploadsAllowed' | 'minImageHeight' | 'minImageWidth' | 'onError' | 'transformFileName' | 'validateFile'>>> & {
4
+ export type UseHandleSelectedFilesProps = OptionalValues<Required<Pick<FileUploaderProps, 'expectedExtensions' | 'fileUrl' | 'handleFileSelected' | 'handleUploadsComplete' | 'isUploaderOnly' | 'maxFileSizeMB' | 'maxUploadsAllowed' | 'minImageHeight' | 'minImageWidth' | 'onError' | 'onValidationCompleted' | 'onValidationStarted' | 'onlyUseCustomValidationFn' | 'transformFileName' | 'validateFile' | 'validateSequentially'>>> & {
5
5
  purgeInput: () => void;
6
6
  setFileName: Dispatch<SetStateAction<string>>;
7
7
  setFileUrl: Dispatch<SetStateAction<string>>;
@@ -1,5 +1,5 @@
1
1
  import { FileUploaderProps } from '../../file-uploader.types';
2
2
  import { OptionalValues } from '../../../../types/common';
3
- export type UseUploadActionsProps = OptionalValues<Required<Pick<FileUploaderProps, 'expectedExtensions' | 'fileName' | 'fileUrl' | 'handleDeleteFile' | 'handleFileSelected' | 'handleUploadsComplete' | 'handleUploadFile' | 'isUploaderOnly' | 'maxUploadsAllowed' | 'onError' | 'purifyFileName' | 'transformFileName' | 'validateFile'>>> & Partial<Pick<FileUploaderProps, 'maxFileSizeMB' | 'minImageHeight' | 'minImageWidth'>> & {
3
+ export type UseUploadActionsProps = OptionalValues<Required<Pick<FileUploaderProps, 'expectedExtensions' | 'fileName' | 'fileUrl' | 'handleDeleteFile' | 'handleFileSelected' | 'handleUploadsComplete' | 'handleUploadFile' | 'isUploaderOnly' | 'maxUploadsAllowed' | 'onError' | 'onValidationCompleted' | 'onValidationStarted' | 'onlyUseCustomValidationFn' | 'purifyFileName' | 'transformFileName' | 'validateFile' | 'validateSequentially'>>> & Partial<Pick<FileUploaderProps, 'maxFileSizeMB' | 'minImageHeight' | 'minImageWidth'>> & {
4
4
  purgeInput: () => void;
5
5
  };
@@ -1,5 +1,4 @@
1
1
  export interface GenerateSkusFromOptionsProps {
2
- loopNum?: number;
3
2
  options: string[][];
4
3
  partialSkus: string[];
5
4
  }