@kystverket/styrbord 2.12.0 → 2.13.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/src/components/kystverket/FileUploader/FileUploader.d.ts +12 -2
- package/dist/src/components/kystverket/FileUploader/FileUploader.stories.d.ts +3 -0
- package/dist/src/components/kystverket/FileUploader/FileUploader.types.d.ts +12 -0
- package/dist/src/components/kystverket/FileUploader/fileUploadActions/FileUploadActions.d.ts +2 -2
- package/dist/src/components/kystverket/FileUploader/item/FileUploaderItem.d.ts +3 -2
- package/dist/style.js +1249 -1217
- package/dist/style.umd.cjs +9 -9
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { Exif, FileInfo } from './FileUploader.types';
|
|
2
|
+
import { Exif, FileInfo, FileUploaderAction, FileUploaderFileAction } from './FileUploader.types';
|
|
3
3
|
export interface FileAndExif {
|
|
4
4
|
file: File;
|
|
5
5
|
exif?: Exif;
|
|
@@ -38,5 +38,15 @@ export interface FileUploaderProps {
|
|
|
38
38
|
* When enabled, a preview button appears on each uploaded file that can be previewed.
|
|
39
39
|
*/
|
|
40
40
|
allowFilePreview?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Extra buttons in the button row, after "Upload" / "Choose existing".
|
|
43
|
+
* Hidden together with the built-in buttons when the field is full or a file is uploading.
|
|
44
|
+
*/
|
|
45
|
+
uploadActions?: FileUploaderAction[];
|
|
46
|
+
/**
|
|
47
|
+
* Extra icon buttons per file, before preview and delete.
|
|
48
|
+
* Only shown when the file's status is 'uploaded'.
|
|
49
|
+
*/
|
|
50
|
+
fileActions?: (file: FileInfo) => FileUploaderFileAction[];
|
|
41
51
|
}
|
|
42
|
-
export declare const FileUploader: ({ label, maxSizeInBytes, required, optional, description, error, multiple, files, maxFiles, onChange, allowedFileTypes, withCaptureButton, existingFilesProvider, variant, allowFilePreview, }: FileUploaderProps) => React.JSX.Element;
|
|
52
|
+
export declare const FileUploader: ({ label, maxSizeInBytes, required, optional, description, error, multiple, files, maxFiles, onChange, allowedFileTypes, withCaptureButton, existingFilesProvider, variant, allowFilePreview, uploadActions, fileActions, }: FileUploaderProps) => React.JSX.Element;
|
|
@@ -20,6 +20,8 @@ declare const meta: {
|
|
|
20
20
|
existingFilesProvider?: (() => Promise<ExistingFilesProviderItem[]>) | undefined;
|
|
21
21
|
variant?: "dropzone" | "buttons" | "capture" | undefined;
|
|
22
22
|
allowFilePreview?: boolean | undefined;
|
|
23
|
+
uploadActions?: import("./FileUploader.types").FileUploaderAction[] | undefined;
|
|
24
|
+
fileActions?: ((file: FileInfo) => import("./FileUploader.types").FileUploaderFileAction[]) | undefined;
|
|
23
25
|
}>) => React.JSX.Element))[];
|
|
24
26
|
tags: string[];
|
|
25
27
|
argTypes: {};
|
|
@@ -37,6 +39,7 @@ export declare const WithError: Story;
|
|
|
37
39
|
export declare const WithCaptureButton: Story;
|
|
38
40
|
export declare const CaptureOnly: Story;
|
|
39
41
|
export declare const WithExistingFiles: Story;
|
|
42
|
+
export declare const WithCustomActions: Story;
|
|
40
43
|
export declare const withFileSizeLimit: Story;
|
|
41
44
|
export declare const withPreviews: Story;
|
|
42
45
|
export declare const withAllowedFileTypes: Story;
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
+
import { MaterialIconProps } from '~/components/kystverket/Icon/icon';
|
|
1
2
|
export type FileStatus = 'uploading' | 'uploaded' | 'error';
|
|
3
|
+
/** An extra button in the FileUploader's button row, after the built-in upload buttons. */
|
|
4
|
+
export type FileUploaderAction = {
|
|
5
|
+
icon: MaterialIconProps['material'];
|
|
6
|
+
label: string;
|
|
7
|
+
onClick: () => void;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/** An extra icon button on a single file in the FileUploader's file list. `label` is used as aria-label. */
|
|
11
|
+
export type FileUploaderFileAction = Omit<FileUploaderAction, 'onClick'> & {
|
|
12
|
+
onClick: (file: FileInfo) => void;
|
|
13
|
+
};
|
|
2
14
|
export type FileInfo = {
|
|
3
15
|
contextId: string;
|
|
4
16
|
fileName: string;
|
package/dist/src/components/kystverket/FileUploader/fileUploadActions/FileUploadActions.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ type FileUploadActionsProps = {
|
|
|
7
7
|
t: (key: string) => string;
|
|
8
8
|
onUploadFile: (uploadedFiles: File[]) => void;
|
|
9
9
|
allowedFileTypes: string[];
|
|
10
|
-
} & Pick<FileUploaderProps, 'variant' | 'existingFilesProvider' | 'withCaptureButton' | 'multiple'>;
|
|
11
|
-
export declare function FileUploadActions({ variant, fileInputRef, onUploadFile, existingFilesProvider, fileCameraInputRef, dialogRef, allowedFileTypes, withCaptureButton, multiple, t, }: FileUploadActionsProps): React.JSX.Element;
|
|
10
|
+
} & Pick<FileUploaderProps, 'variant' | 'existingFilesProvider' | 'withCaptureButton' | 'multiple' | 'uploadActions'>;
|
|
11
|
+
export declare function FileUploadActions({ variant, fileInputRef, onUploadFile, existingFilesProvider, fileCameraInputRef, dialogRef, allowedFileTypes, withCaptureButton, multiple, uploadActions, t, }: FileUploadActionsProps): React.JSX.Element;
|
|
12
12
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExtraFileInfo, FileInfo } from '../FileUploader.types';
|
|
1
|
+
import { ExtraFileInfo, FileInfo, FileUploaderFileAction } from '../FileUploader.types';
|
|
2
2
|
import { MaterialIconProps } from '~/components/kystverket/Icon/icon';
|
|
3
3
|
type FileUploaderItemProps = {
|
|
4
4
|
file: FileInfo;
|
|
@@ -6,7 +6,8 @@ type FileUploaderItemProps = {
|
|
|
6
6
|
t: (key: string) => string;
|
|
7
7
|
onDeleteFile: (file: FileInfo) => void;
|
|
8
8
|
onPreviewFile?: () => void;
|
|
9
|
+
actions?: FileUploaderFileAction[];
|
|
9
10
|
};
|
|
10
11
|
export declare const getPrefixIcon: (contentType: FileInfo["contentType"]) => MaterialIconProps["material"];
|
|
11
|
-
export declare function FileUploaderItem({ file, extraInfo, t, onDeleteFile, onPreviewFile }: FileUploaderItemProps): React.JSX.Element;
|
|
12
|
+
export declare function FileUploaderItem({ file, extraInfo, t, onDeleteFile, onPreviewFile, actions }: FileUploaderItemProps): React.JSX.Element;
|
|
12
13
|
export {};
|