@norges-domstoler/dds-components 9.0.1 → 9.1.1
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/assets/fonts/IBMPlexMono-Light.woff +0 -0
- package/dist/assets/fonts/IBMPlexMono-Light.woff2 +0 -0
- package/dist/assets/fonts/IBMPlexMono-Regular.woff +0 -0
- package/dist/assets/fonts/IBMPlexMono-Regular.woff2 +0 -0
- package/dist/assets/fonts/IBMPlexMono-SemiBold.woff +0 -0
- package/dist/assets/fonts/IBMPlexMono-SemiBold.woff2 +0 -0
- package/dist/bundle.css +30 -0
- package/dist/cjs/bundle.css +30 -0
- package/dist/cjs/components/FileUploader/ErrorList.d.ts +9 -0
- package/dist/cjs/components/FileUploader/File.d.ts +10 -0
- package/dist/cjs/components/FileUploader/FileUploader.d.ts +19 -0
- package/dist/cjs/components/FileUploader/FileUploader.stories.d.ts +25 -0
- package/dist/cjs/components/FileUploader/FileUploader.tokens.d.ts +25 -0
- package/dist/cjs/components/FileUploader/fileUploaderReducer.d.ts +35 -0
- package/dist/cjs/components/FileUploader/index.d.ts +1 -0
- package/dist/cjs/components/FileUploader/types.d.ts +10 -0
- package/dist/cjs/components/FileUploader/useFileUploader.d.ts +27 -0
- package/dist/cjs/components/FileUploader/utils.d.ts +6 -0
- package/dist/cjs/index.js +0 -1
- package/dist/components/FileUploader/ErrorList.d.ts +9 -0
- package/dist/components/FileUploader/File.d.ts +10 -0
- package/dist/components/FileUploader/FileUploader.d.ts +19 -0
- package/dist/components/FileUploader/FileUploader.stories.d.ts +25 -0
- package/dist/components/FileUploader/FileUploader.tokens.d.ts +25 -0
- package/dist/components/FileUploader/fileUploaderReducer.d.ts +35 -0
- package/dist/components/FileUploader/index.d.ts +1 -0
- package/dist/components/FileUploader/types.d.ts +10 -0
- package/dist/components/FileUploader/useFileUploader.d.ts +27 -0
- package/dist/components/FileUploader/utils.d.ts +6 -0
- package/dist/components/Select/Select.js +0 -1
- package/dist/styles/fontStyles.css +30 -0
- package/package.json +3 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/bundle.css
CHANGED
|
@@ -59,6 +59,36 @@
|
|
|
59
59
|
url('../assets/fonts/IBMPlexSans-SemiBoldItalic.woff') format('woff');
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
@font-face {
|
|
63
|
+
font-family: IBM Plex Mono;
|
|
64
|
+
font-style: normal;
|
|
65
|
+
font-weight: 400;
|
|
66
|
+
font-display: swap;
|
|
67
|
+
src: local('IBM Plex Mono'), local('IBMPlexMono'),
|
|
68
|
+
url('../assets/fonts/IBMPlexMono-Regular.woff2') format('woff2'),
|
|
69
|
+
url('../assets/fonts/IBMPlexMono-Regular.woff') format('woff');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@font-face {
|
|
73
|
+
font-family: IBM Plex Mono;
|
|
74
|
+
font-style: normal;
|
|
75
|
+
font-weight: 300;
|
|
76
|
+
font-display: swap;
|
|
77
|
+
src: local('IBM Plex Mono Light'), local('IBMPlexMono-Light'),
|
|
78
|
+
url('../assets/fonts/IBMPlexMono-Light.woff2') format('woff2'),
|
|
79
|
+
url('../assets/fonts/IBMPlexMono-Light.woff') format('woff');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@font-face {
|
|
83
|
+
font-family: IBM Plex Mono;
|
|
84
|
+
font-style: normal;
|
|
85
|
+
font-weight: 600;
|
|
86
|
+
font-display: swap;
|
|
87
|
+
src: local('IBM Plex Mono SemiBold'), local('IBMPlexMono-SemiBold'),
|
|
88
|
+
url('../assets/fonts/IBMPlexMono-SemiBold.woff2') format('woff2'),
|
|
89
|
+
url('../assets/fonts/IBMPlexMono-SemiBold.woff') format('woff');
|
|
90
|
+
}
|
|
91
|
+
|
|
62
92
|
@import '~@norges-domstoler/dds-design-tokens/dist/css/colors.css';
|
|
63
93
|
|
|
64
94
|
*::selection {
|
package/dist/cjs/bundle.css
CHANGED
|
@@ -59,6 +59,36 @@
|
|
|
59
59
|
url('../assets/fonts/IBMPlexSans-SemiBoldItalic.woff') format('woff');
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
@font-face {
|
|
63
|
+
font-family: IBM Plex Mono;
|
|
64
|
+
font-style: normal;
|
|
65
|
+
font-weight: 400;
|
|
66
|
+
font-display: swap;
|
|
67
|
+
src: local('IBM Plex Mono'), local('IBMPlexMono'),
|
|
68
|
+
url('../assets/fonts/IBMPlexMono-Regular.woff2') format('woff2'),
|
|
69
|
+
url('../assets/fonts/IBMPlexMono-Regular.woff') format('woff');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@font-face {
|
|
73
|
+
font-family: IBM Plex Mono;
|
|
74
|
+
font-style: normal;
|
|
75
|
+
font-weight: 300;
|
|
76
|
+
font-display: swap;
|
|
77
|
+
src: local('IBM Plex Mono Light'), local('IBMPlexMono-Light'),
|
|
78
|
+
url('../assets/fonts/IBMPlexMono-Light.woff2') format('woff2'),
|
|
79
|
+
url('../assets/fonts/IBMPlexMono-Light.woff') format('woff');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@font-face {
|
|
83
|
+
font-family: IBM Plex Mono;
|
|
84
|
+
font-style: normal;
|
|
85
|
+
font-weight: 600;
|
|
86
|
+
font-display: swap;
|
|
87
|
+
src: local('IBM Plex Mono SemiBold'), local('IBMPlexMono-SemiBold'),
|
|
88
|
+
url('../assets/fonts/IBMPlexMono-SemiBold.woff2') format('woff2'),
|
|
89
|
+
url('../assets/fonts/IBMPlexMono-SemiBold.woff') format('woff');
|
|
90
|
+
}
|
|
91
|
+
|
|
62
92
|
@import '~@norges-domstoler/dds-design-tokens/dist/css/colors.css';
|
|
63
93
|
|
|
64
94
|
*::selection {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare type ErrorListProps = {
|
|
2
|
+
errors: {
|
|
3
|
+
id: string | undefined;
|
|
4
|
+
message: string;
|
|
5
|
+
}[];
|
|
6
|
+
};
|
|
7
|
+
export declare const MessageContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
|
+
export declare const ErrorList: (props: ErrorListProps) => JSX.Element | null;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FileUploaderFile } from './fileUploaderReducer';
|
|
2
|
+
declare type FileProps = {
|
|
3
|
+
parentId: string;
|
|
4
|
+
index: number;
|
|
5
|
+
isValid: boolean;
|
|
6
|
+
file: FileUploaderFile;
|
|
7
|
+
removeFile: () => void;
|
|
8
|
+
};
|
|
9
|
+
export declare const File: (props: FileProps) => JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FileList } from './types';
|
|
2
|
+
import { FileUploaderHookProps } from './useFileUploader';
|
|
3
|
+
import { Property } from 'csstype';
|
|
4
|
+
declare type FileUploaderProps = {
|
|
5
|
+
/**Id til filopplasteren. */
|
|
6
|
+
id?: string;
|
|
7
|
+
/**Ledetekst for filopplaster. */
|
|
8
|
+
label?: string;
|
|
9
|
+
/**Hjelpetekst. */
|
|
10
|
+
tip?: string;
|
|
11
|
+
/**Om det er påkrevd med minst en fil. */
|
|
12
|
+
required?: boolean;
|
|
13
|
+
/**Callback for når fil-listen endres. */
|
|
14
|
+
onChange: (newFiles: FileList) => void;
|
|
15
|
+
/**Bredde for filopplasteren. */
|
|
16
|
+
width?: Property.Width<string>;
|
|
17
|
+
} & Pick<FileUploaderHookProps, 'initialFiles' | 'accept' | 'maxFiles' | 'disabled'>;
|
|
18
|
+
export declare const FileUploader: (props: FileUploaderProps) => JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
title: string;
|
|
3
|
+
component: (props: {
|
|
4
|
+
id?: string | undefined;
|
|
5
|
+
label?: string | undefined;
|
|
6
|
+
tip?: string | undefined;
|
|
7
|
+
required?: boolean | undefined;
|
|
8
|
+
onChange: (newFiles: import("./types").FileList) => void;
|
|
9
|
+
width?: import("csstype").Property.Width<string> | undefined;
|
|
10
|
+
} & Pick<import("./useFileUploader").FileUploaderHookProps, "disabled" | "accept" | "initialFiles" | "maxFiles">) => JSX.Element;
|
|
11
|
+
argTypes: {
|
|
12
|
+
color: {
|
|
13
|
+
control: {
|
|
14
|
+
type: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
size: {
|
|
18
|
+
control: {
|
|
19
|
+
type: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|
|
25
|
+
export declare const Overview: () => JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const rootTokens: {
|
|
2
|
+
borderColor: string;
|
|
3
|
+
borderColorError: string;
|
|
4
|
+
paddingLeftRightTop: string;
|
|
5
|
+
paddingBottom: string;
|
|
6
|
+
gap: string;
|
|
7
|
+
backgroundColor: string;
|
|
8
|
+
dragActive: {
|
|
9
|
+
borderColor: string;
|
|
10
|
+
backgroundColor: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare const fileTokens: {
|
|
14
|
+
marginTop: string;
|
|
15
|
+
paddingLeftRight: string;
|
|
16
|
+
paddingTopBottom: string;
|
|
17
|
+
backgroundColor: string;
|
|
18
|
+
textToIconsGap: string;
|
|
19
|
+
invalid: {
|
|
20
|
+
borderColor: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare const errorsTokens: {
|
|
24
|
+
gap: string;
|
|
25
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FileWithPath } from 'file-selector';
|
|
2
|
+
import { Reducer } from 'react';
|
|
3
|
+
export declare type FileUploaderFile = {
|
|
4
|
+
file: FileWithPath;
|
|
5
|
+
errors: string[];
|
|
6
|
+
};
|
|
7
|
+
declare type FileChangePayload = {
|
|
8
|
+
rootErrors: RootErrorList;
|
|
9
|
+
files: FileUploaderFile[];
|
|
10
|
+
};
|
|
11
|
+
export declare type RootErrorList = string[];
|
|
12
|
+
export declare type FileUploaderAction = {
|
|
13
|
+
type: 'focus';
|
|
14
|
+
} | {
|
|
15
|
+
type: 'blur';
|
|
16
|
+
} | {
|
|
17
|
+
type: 'dragEnter';
|
|
18
|
+
} | {
|
|
19
|
+
type: 'dragLeave';
|
|
20
|
+
} | {
|
|
21
|
+
type: 'onSetFiles';
|
|
22
|
+
payload: FileChangePayload;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'onRemoveFile';
|
|
25
|
+
payload: FileChangePayload;
|
|
26
|
+
};
|
|
27
|
+
export declare type FileUploaderState = {
|
|
28
|
+
files: FileUploaderFile[];
|
|
29
|
+
isFocused: boolean;
|
|
30
|
+
isFileDialogActive: boolean;
|
|
31
|
+
isDragActive: boolean;
|
|
32
|
+
rootErrors: string[];
|
|
33
|
+
};
|
|
34
|
+
export declare const fileUploaderReducer: Reducer<FileUploaderState, FileUploaderAction>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FileUploader';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare type FileExtensionAccept = `.${string}`;
|
|
2
|
+
declare type AnyMimeType = '*';
|
|
3
|
+
declare type ImageMimeType = 'png' | 'jpeg' | 'bmp' | 'gif' | 'svg+xml' | 'tiff' | 'webp';
|
|
4
|
+
declare type VideoMimeType = 'x-msvideo' | 'mp4' | 'mpeg' | 'ogg' | 'mp2t' | 'webm' | '3gpp' | '3gpp2';
|
|
5
|
+
declare type AudioMimeType = 'aac' | 'midi' | 'x-midi' | 'mpeg' | 'ogg' | 'opus' | 'wav' | 'webm' | '3gpp' | '3gpp2';
|
|
6
|
+
declare type ApplicationMimeType = 'octet-stream' | 'msword' | 'vnd.openxmlformats-officedocument.wordprocessingml.document' | 'epub+zip' | 'gzip' | 'java-archive' | 'json' | 'vnd.oasis.opendocument.presentation' | 'vnd.oasis.opendocument.spreadsheet' | 'vnd.oasis.opendocument.text' | 'pdf' | 'vnd.ms-powerpoint' | 'vnd.openxmlformats-officedocument.presentationml.presentation' | 'rtf' | 'x-sh' | 'x-tar' | 'vnd.visio' | 'xhtml+xml' | 'vnd.ms-excel' | 'vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'xml' | 'vnd.mozilla.xul+xml' | 'zip';
|
|
7
|
+
declare type MimeType = `image/${ImageMimeType | AnyMimeType}` | `video/${VideoMimeType | AnyMimeType}` | `audio/${AudioMimeType | AnyMimeType}` | `application/${ApplicationMimeType}`;
|
|
8
|
+
export declare type Accept = MimeType | FileExtensionAccept;
|
|
9
|
+
export declare type FileList = File[];
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { ButtonHTMLAttributes, HTMLAttributes, InputHTMLAttributes, Ref } from 'react';
|
|
2
|
+
import { FileUploaderFile } from './fileUploaderReducer';
|
|
3
|
+
import { Accept, FileList } from './types';
|
|
4
|
+
export declare type FileUploaderHookProps = {
|
|
5
|
+
id?: string;
|
|
6
|
+
/**Dersom komponenten styres utenfra. En liste over filer som skal være med ved første render. */
|
|
7
|
+
initialFiles?: FileList;
|
|
8
|
+
/**Hvilke filendelser eller mime-typer som filopplasteren skal akseptere. */
|
|
9
|
+
accept?: Accept[];
|
|
10
|
+
/**Om filopplasteren er avslått eller ikke */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/**Maks antall filer som tillates. */
|
|
13
|
+
maxFiles?: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const useFileUploader: <TRootElement extends HTMLElement>(props: FileUploaderHookProps) => {
|
|
16
|
+
state: import("./fileUploaderReducer").FileUploaderState;
|
|
17
|
+
getRootProps: () => React.HTMLAttributes<TRootElement> & {
|
|
18
|
+
ref: React.Ref<TRootElement>;
|
|
19
|
+
};
|
|
20
|
+
getInputProps: () => InputHTMLAttributes<HTMLInputElement> & {
|
|
21
|
+
ref: Ref<HTMLInputElement>;
|
|
22
|
+
};
|
|
23
|
+
getButtonProps: () => ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
24
|
+
ref: Ref<HTMLButtonElement>;
|
|
25
|
+
};
|
|
26
|
+
removeFile: (file: FileUploaderFile) => void;
|
|
27
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const preventDefaults: (event: React.BaseSyntheticEvent) => void;
|
|
2
|
+
export declare const isDragEvent: (event: unknown) => event is import("react").DragEvent<unknown>;
|
|
3
|
+
export declare const isEventWithFiles: (event: React.DragEvent<unknown> | React.ChangeEvent<HTMLInputElement>) => boolean;
|
|
4
|
+
export declare const isFileAccepted: (file: File, accept: string[] | undefined) => boolean;
|
|
5
|
+
export declare const getTooManyFilesErrorMessage: (maxFiles: number) => string;
|
|
6
|
+
export declare const getInvalidFileTypeErrorMessage: () => string;
|
package/dist/cjs/index.js
CHANGED
|
@@ -6199,7 +6199,6 @@ var SelectInner = function SelectInner(props, ref) {
|
|
|
6199
6199
|
NoOptionsMessage: DDSNoOptionsMessage,
|
|
6200
6200
|
Input: function Input(props) {
|
|
6201
6201
|
return DDSInput(Object.assign(Object.assign({}, props), {
|
|
6202
|
-
required: required,
|
|
6203
6202
|
'aria-required': ariaRequired
|
|
6204
6203
|
}), hasErrorMessage, spaceSeparatedIdListGenerator([singleValueId, tip ? tipId : undefined, errorMessage ? errorMessageId : undefined]));
|
|
6205
6204
|
},
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare type ErrorListProps = {
|
|
2
|
+
errors: {
|
|
3
|
+
id: string | undefined;
|
|
4
|
+
message: string;
|
|
5
|
+
}[];
|
|
6
|
+
};
|
|
7
|
+
export declare const MessageContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
|
+
export declare const ErrorList: (props: ErrorListProps) => JSX.Element | null;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FileUploaderFile } from './fileUploaderReducer';
|
|
2
|
+
declare type FileProps = {
|
|
3
|
+
parentId: string;
|
|
4
|
+
index: number;
|
|
5
|
+
isValid: boolean;
|
|
6
|
+
file: FileUploaderFile;
|
|
7
|
+
removeFile: () => void;
|
|
8
|
+
};
|
|
9
|
+
export declare const File: (props: FileProps) => JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FileList } from './types';
|
|
2
|
+
import { FileUploaderHookProps } from './useFileUploader';
|
|
3
|
+
import { Property } from 'csstype';
|
|
4
|
+
declare type FileUploaderProps = {
|
|
5
|
+
/**Id til filopplasteren. */
|
|
6
|
+
id?: string;
|
|
7
|
+
/**Ledetekst for filopplaster. */
|
|
8
|
+
label?: string;
|
|
9
|
+
/**Hjelpetekst. */
|
|
10
|
+
tip?: string;
|
|
11
|
+
/**Om det er påkrevd med minst en fil. */
|
|
12
|
+
required?: boolean;
|
|
13
|
+
/**Callback for når fil-listen endres. */
|
|
14
|
+
onChange: (newFiles: FileList) => void;
|
|
15
|
+
/**Bredde for filopplasteren. */
|
|
16
|
+
width?: Property.Width<string>;
|
|
17
|
+
} & Pick<FileUploaderHookProps, 'initialFiles' | 'accept' | 'maxFiles' | 'disabled'>;
|
|
18
|
+
export declare const FileUploader: (props: FileUploaderProps) => JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
title: string;
|
|
3
|
+
component: (props: {
|
|
4
|
+
id?: string | undefined;
|
|
5
|
+
label?: string | undefined;
|
|
6
|
+
tip?: string | undefined;
|
|
7
|
+
required?: boolean | undefined;
|
|
8
|
+
onChange: (newFiles: import("./types").FileList) => void;
|
|
9
|
+
width?: import("csstype").Property.Width<string> | undefined;
|
|
10
|
+
} & Pick<import("./useFileUploader").FileUploaderHookProps, "disabled" | "accept" | "initialFiles" | "maxFiles">) => JSX.Element;
|
|
11
|
+
argTypes: {
|
|
12
|
+
color: {
|
|
13
|
+
control: {
|
|
14
|
+
type: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
size: {
|
|
18
|
+
control: {
|
|
19
|
+
type: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|
|
25
|
+
export declare const Overview: () => JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const rootTokens: {
|
|
2
|
+
borderColor: string;
|
|
3
|
+
borderColorError: string;
|
|
4
|
+
paddingLeftRightTop: string;
|
|
5
|
+
paddingBottom: string;
|
|
6
|
+
gap: string;
|
|
7
|
+
backgroundColor: string;
|
|
8
|
+
dragActive: {
|
|
9
|
+
borderColor: string;
|
|
10
|
+
backgroundColor: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare const fileTokens: {
|
|
14
|
+
marginTop: string;
|
|
15
|
+
paddingLeftRight: string;
|
|
16
|
+
paddingTopBottom: string;
|
|
17
|
+
backgroundColor: string;
|
|
18
|
+
textToIconsGap: string;
|
|
19
|
+
invalid: {
|
|
20
|
+
borderColor: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare const errorsTokens: {
|
|
24
|
+
gap: string;
|
|
25
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FileWithPath } from 'file-selector';
|
|
2
|
+
import { Reducer } from 'react';
|
|
3
|
+
export declare type FileUploaderFile = {
|
|
4
|
+
file: FileWithPath;
|
|
5
|
+
errors: string[];
|
|
6
|
+
};
|
|
7
|
+
declare type FileChangePayload = {
|
|
8
|
+
rootErrors: RootErrorList;
|
|
9
|
+
files: FileUploaderFile[];
|
|
10
|
+
};
|
|
11
|
+
export declare type RootErrorList = string[];
|
|
12
|
+
export declare type FileUploaderAction = {
|
|
13
|
+
type: 'focus';
|
|
14
|
+
} | {
|
|
15
|
+
type: 'blur';
|
|
16
|
+
} | {
|
|
17
|
+
type: 'dragEnter';
|
|
18
|
+
} | {
|
|
19
|
+
type: 'dragLeave';
|
|
20
|
+
} | {
|
|
21
|
+
type: 'onSetFiles';
|
|
22
|
+
payload: FileChangePayload;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'onRemoveFile';
|
|
25
|
+
payload: FileChangePayload;
|
|
26
|
+
};
|
|
27
|
+
export declare type FileUploaderState = {
|
|
28
|
+
files: FileUploaderFile[];
|
|
29
|
+
isFocused: boolean;
|
|
30
|
+
isFileDialogActive: boolean;
|
|
31
|
+
isDragActive: boolean;
|
|
32
|
+
rootErrors: string[];
|
|
33
|
+
};
|
|
34
|
+
export declare const fileUploaderReducer: Reducer<FileUploaderState, FileUploaderAction>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FileUploader';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare type FileExtensionAccept = `.${string}`;
|
|
2
|
+
declare type AnyMimeType = '*';
|
|
3
|
+
declare type ImageMimeType = 'png' | 'jpeg' | 'bmp' | 'gif' | 'svg+xml' | 'tiff' | 'webp';
|
|
4
|
+
declare type VideoMimeType = 'x-msvideo' | 'mp4' | 'mpeg' | 'ogg' | 'mp2t' | 'webm' | '3gpp' | '3gpp2';
|
|
5
|
+
declare type AudioMimeType = 'aac' | 'midi' | 'x-midi' | 'mpeg' | 'ogg' | 'opus' | 'wav' | 'webm' | '3gpp' | '3gpp2';
|
|
6
|
+
declare type ApplicationMimeType = 'octet-stream' | 'msword' | 'vnd.openxmlformats-officedocument.wordprocessingml.document' | 'epub+zip' | 'gzip' | 'java-archive' | 'json' | 'vnd.oasis.opendocument.presentation' | 'vnd.oasis.opendocument.spreadsheet' | 'vnd.oasis.opendocument.text' | 'pdf' | 'vnd.ms-powerpoint' | 'vnd.openxmlformats-officedocument.presentationml.presentation' | 'rtf' | 'x-sh' | 'x-tar' | 'vnd.visio' | 'xhtml+xml' | 'vnd.ms-excel' | 'vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'xml' | 'vnd.mozilla.xul+xml' | 'zip';
|
|
7
|
+
declare type MimeType = `image/${ImageMimeType | AnyMimeType}` | `video/${VideoMimeType | AnyMimeType}` | `audio/${AudioMimeType | AnyMimeType}` | `application/${ApplicationMimeType}`;
|
|
8
|
+
export declare type Accept = MimeType | FileExtensionAccept;
|
|
9
|
+
export declare type FileList = File[];
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { ButtonHTMLAttributes, HTMLAttributes, InputHTMLAttributes, Ref } from 'react';
|
|
2
|
+
import { FileUploaderFile } from './fileUploaderReducer';
|
|
3
|
+
import { Accept, FileList } from './types';
|
|
4
|
+
export declare type FileUploaderHookProps = {
|
|
5
|
+
id?: string;
|
|
6
|
+
/**Dersom komponenten styres utenfra. En liste over filer som skal være med ved første render. */
|
|
7
|
+
initialFiles?: FileList;
|
|
8
|
+
/**Hvilke filendelser eller mime-typer som filopplasteren skal akseptere. */
|
|
9
|
+
accept?: Accept[];
|
|
10
|
+
/**Om filopplasteren er avslått eller ikke */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/**Maks antall filer som tillates. */
|
|
13
|
+
maxFiles?: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const useFileUploader: <TRootElement extends HTMLElement>(props: FileUploaderHookProps) => {
|
|
16
|
+
state: import("./fileUploaderReducer").FileUploaderState;
|
|
17
|
+
getRootProps: () => React.HTMLAttributes<TRootElement> & {
|
|
18
|
+
ref: React.Ref<TRootElement>;
|
|
19
|
+
};
|
|
20
|
+
getInputProps: () => InputHTMLAttributes<HTMLInputElement> & {
|
|
21
|
+
ref: Ref<HTMLInputElement>;
|
|
22
|
+
};
|
|
23
|
+
getButtonProps: () => ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
24
|
+
ref: Ref<HTMLButtonElement>;
|
|
25
|
+
};
|
|
26
|
+
removeFile: (file: FileUploaderFile) => void;
|
|
27
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const preventDefaults: (event: React.BaseSyntheticEvent) => void;
|
|
2
|
+
export declare const isDragEvent: (event: unknown) => event is import("react").DragEvent<unknown>;
|
|
3
|
+
export declare const isEventWithFiles: (event: React.DragEvent<unknown> | React.ChangeEvent<HTMLInputElement>) => boolean;
|
|
4
|
+
export declare const isFileAccepted: (file: File, accept: string[] | undefined) => boolean;
|
|
5
|
+
export declare const getTooManyFilesErrorMessage: (maxFiles: number) => string;
|
|
6
|
+
export declare const getInvalidFileTypeErrorMessage: () => string;
|
|
@@ -195,7 +195,6 @@ var SelectInner = function SelectInner(props, ref) {
|
|
|
195
195
|
NoOptionsMessage: DDSNoOptionsMessage,
|
|
196
196
|
Input: function Input(props) {
|
|
197
197
|
return DDSInput(Object.assign(Object.assign({}, props), {
|
|
198
|
-
required: required,
|
|
199
198
|
'aria-required': ariaRequired
|
|
200
199
|
}), hasErrorMessage, spaceSeparatedIdListGenerator([singleValueId, tip ? tipId : undefined, errorMessage ? errorMessageId : undefined]));
|
|
201
200
|
},
|
|
@@ -58,3 +58,33 @@
|
|
|
58
58
|
url('../assets/fonts/IBMPlexSans-SemiBoldItalic.woff2') format('woff2'),
|
|
59
59
|
url('../assets/fonts/IBMPlexSans-SemiBoldItalic.woff') format('woff');
|
|
60
60
|
}
|
|
61
|
+
|
|
62
|
+
@font-face {
|
|
63
|
+
font-family: IBM Plex Mono;
|
|
64
|
+
font-style: normal;
|
|
65
|
+
font-weight: 400;
|
|
66
|
+
font-display: swap;
|
|
67
|
+
src: local('IBM Plex Mono'), local('IBMPlexMono'),
|
|
68
|
+
url('../assets/fonts/IBMPlexMono-Regular.woff2') format('woff2'),
|
|
69
|
+
url('../assets/fonts/IBMPlexMono-Regular.woff') format('woff');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@font-face {
|
|
73
|
+
font-family: IBM Plex Mono;
|
|
74
|
+
font-style: normal;
|
|
75
|
+
font-weight: 300;
|
|
76
|
+
font-display: swap;
|
|
77
|
+
src: local('IBM Plex Mono Light'), local('IBMPlexMono-Light'),
|
|
78
|
+
url('../assets/fonts/IBMPlexMono-Light.woff2') format('woff2'),
|
|
79
|
+
url('../assets/fonts/IBMPlexMono-Light.woff') format('woff');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@font-face {
|
|
83
|
+
font-family: IBM Plex Mono;
|
|
84
|
+
font-style: normal;
|
|
85
|
+
font-weight: 600;
|
|
86
|
+
font-display: swap;
|
|
87
|
+
src: local('IBM Plex Mono SemiBold'), local('IBMPlexMono-SemiBold'),
|
|
88
|
+
url('../assets/fonts/IBMPlexMono-SemiBold.woff2') format('woff2'),
|
|
89
|
+
url('../assets/fonts/IBMPlexMono-SemiBold.woff') format('woff');
|
|
90
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@norges-domstoler/dds-components",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.1.1",
|
|
4
4
|
"description": "React components used in Elsa - domstolenes designsystem",
|
|
5
5
|
"author": "Elsa team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -116,6 +116,8 @@
|
|
|
116
116
|
},
|
|
117
117
|
"dependencies": {
|
|
118
118
|
"@floating-ui/react-dom": "^1.0.0",
|
|
119
|
+
"attr-accept": "^2.2.2",
|
|
120
|
+
"file-selector": "^0.6.0",
|
|
119
121
|
"focus-visible": "^5.2.0",
|
|
120
122
|
"react-select": "^5.4.0",
|
|
121
123
|
"tslib": "^2.4.0"
|