gantri-components 2.127.0-beta.2 → 2.127.0-beta.20

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.
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ /// <reference types="react" />
2
3
  import { CSSProperties } from 'styled-components';
3
4
  import { ColorPickerVariant } from '../../color-picker.types';
4
5
  import { ProductColorCode } from '../../../../styles/theme';
@@ -1,6 +1,7 @@
1
1
  export declare const defaultImageExtensions: readonly ["gif", "jpeg", "jpg", "png", "webp"];
2
2
  export declare const fileUploaderVariants: {
3
3
  readonly button: "button";
4
+ readonly custom: "custom";
4
5
  readonly link: "link";
5
6
  readonly plain: "plain";
6
7
  readonly thumbnail: "thumbnail";
@@ -3,7 +3,6 @@ import { ButtonProps } from '../button/button.types';
3
3
  import { BoxProps } from '../box/box.types';
4
4
  import { fileUploaderVariants } from './file-uploader.constants';
5
5
  export type FileUploaderProps = {
6
- CustomContent?: FileUploaderCustomContent;
7
6
  /** Any children passed will appear just within the uploader above everything else. Use this for notifications like download toasts. */
8
7
  children?: ReactNode;
9
8
  className?: string;
@@ -13,6 +12,8 @@ export type FileUploaderProps = {
13
12
  fileUrl: string;
14
13
  /** This function should delete the record from the database, ***then*** delete the file. */
15
14
  handleDeleteFile: HandleDeleteFile;
15
+ /** Provide this if supporting multiple uploads to prevent multiple calls to update the database. */
16
+ handleUploadsComplete: HandleUploadsComplete;
16
17
  inputName?: string;
17
18
  isActive?: boolean;
18
19
  isDisabled?: boolean;
@@ -30,9 +31,9 @@ export type FileUploaderProps = {
30
31
  /** If invalid, return the error message to display. */
31
32
  validateFile?: ValidateFile;
32
33
  /** The 'link' and 'plain' variants will show the 'button' variant if nothing has been uploaded yet. */
33
- variant: UploaderVariant;
34
- } & Partial<FileUploaderDefaultProps> & (WithDraggableProps | WithoutDraggableProps) & (WithReplaceableProps | WithoutReplaceableProps) & (ImmediatelyUploadProps | DelayUploadProps);
35
- export type UploaderVariant = (typeof fileUploaderVariants)[keyof typeof fileUploaderVariants];
34
+ variant: FileUploaderVariant;
35
+ } & Partial<FileUploaderDefaultProps> & (WithDraggableProps | WithoutDraggableProps) & (WithReplaceableProps | WithoutReplaceableProps) & (ImmediatelyUploadProps | DelayUploadProps) & (WithCustomContent | WithoutCustomContent);
36
+ export type FileUploaderVariant = (typeof fileUploaderVariants)[keyof typeof fileUploaderVariants];
36
37
  export type HandleDeleteFile = (props: HandleFileDeleteArgs) => Promise<void>;
37
38
  export type HandleFileDeleteArgs = {
38
39
  fileName: string;
@@ -43,11 +44,12 @@ export type HandleFileDeleteArgs = {
43
44
  export type DeleteFile = (options?: {
44
45
  isReplacing?: boolean;
45
46
  }) => Promise<void>;
46
- export type HandleUploadFile = (props: SelectedFileDetails) => Promise<{
47
- [key: string]: any;
47
+ export type HandleUploadFile = (props: SelectedFileDetails) => Promise<UploadedFileDetails>;
48
+ export type HandleUploadsComplete<Data = Record<string, any>> = (uploadedFiles: UploadedFileDetails<Data>[]) => Promise<void>;
49
+ export type UploadedFileDetails<Data = Record<string, any>> = Data & {
48
50
  fileName: string;
49
51
  fileUrl: string;
50
- }>;
52
+ };
51
53
  /** Applicable to Firebase uploads. */
52
54
  export interface FileMetaData {
53
55
  contentType: string;
@@ -70,6 +72,7 @@ export type FileUploaderCustomContent = (props: {
70
72
  UploaderActionIcons: () => JSX.Element;
71
73
  fileName: string;
72
74
  fileUrl: string;
75
+ handleOpenFileSelect: () => void;
73
76
  isDraggingOver: boolean;
74
77
  processing: boolean;
75
78
  }) => JSX.Element;
@@ -104,6 +107,14 @@ type WithoutReplaceableProps = {
104
107
  isReplaceable?: never;
105
108
  onReplace?: never;
106
109
  };
110
+ type WithCustomContent = {
111
+ CustomContent: FileUploaderCustomContent;
112
+ variant: 'custom';
113
+ };
114
+ type WithoutCustomContent = {
115
+ CustomContent?: never | undefined;
116
+ variant: FileUploaderVariant;
117
+ };
107
118
  export type FileUploaderDefaultProps = {
108
119
  buttonProps?: Partial<ButtonProps>;
109
120
  /** Set to `null` or `[]` to allow all file types. */
@@ -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' | 'isUploaderOnly' | 'maxUploadsAllowed' | 'onError' | 'transformFileName' | 'validateFile' | 'maxFileSizeMB' | 'minImageHeight' | 'minImageWidth'>>> & {
4
+ export type UseHandleSelectedFilesProps = OptionalValues<Required<Pick<FileUploaderProps, 'expectedExtensions' | 'fileUrl' | 'handleFileSelected' | 'handleUploadsComplete' | 'isUploaderOnly' | 'maxFileSizeMB' | 'maxUploadsAllowed' | 'minImageHeight' | 'minImageWidth' | 'onError' | 'transformFileName' | 'validateFile'>>> & {
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' | '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' | 'purifyFileName' | 'transformFileName' | 'validateFile'>>> & Partial<Pick<FileUploaderProps, 'maxFileSizeMB' | 'minImageHeight' | 'minImageWidth'>> & {
4
4
  purgeInput: () => void;
5
5
  };
@@ -1,2 +1,4 @@
1
1
  export * from './file-uploader';
2
+ export * from './file-uploader.constants';
2
3
  export * from './file-uploader.types';
4
+ export * from './helpers';