@dbcdk/react-components 0.0.205 → 0.0.206
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/README.md +16 -0
- package/dist/client.cjs +9 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +1 -0
- package/dist/index.cjs +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/files/mimeTypes.cjs +92 -0
- package/dist/utils/files/mimeTypes.d.ts +2 -0
- package/dist/utils/files/mimeTypes.js +89 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -233,6 +233,22 @@ Storybook includes the a11y addon to help identify issues during development.
|
|
|
233
233
|
|
|
234
234
|
---
|
|
235
235
|
|
|
236
|
+
## MIME type helpers
|
|
237
|
+
|
|
238
|
+
These helpers work on both the server and client and are exported from the root and `/client` entrypoints:
|
|
239
|
+
|
|
240
|
+
```ts
|
|
241
|
+
import { formatMimeType, getMimeTypeExtension } from '@dbcdk/react-components'
|
|
242
|
+
|
|
243
|
+
formatMimeType('application/pdf') // 'PDF'
|
|
244
|
+
formatMimeType('text/plain; charset=utf-8') // 'Tekst'
|
|
245
|
+
getMimeTypeExtension('image/jpeg') // 'jpg'
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
`formatMimeType` provides Danish labels for common MIME types, preserves unknown values unchanged, and returns `-` for `null` or `undefined`. `getMimeTypeExtension` returns an extension without a dot for common image types and PDF, or `undefined` for unsupported types. Both ignore MIME parameters, casing, and surrounding whitespace when looking up known types.
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
236
252
|
## Contributing
|
|
237
253
|
|
|
238
254
|
See [`CONTRIBUTING.md`](./CONTRIBUTING.md) for detailed guidelines on:
|
package/dist/client.cjs
CHANGED
|
@@ -51,6 +51,7 @@ var MultiSelect = require('./components/forms/multi-select/MultiSelect');
|
|
|
51
51
|
var useViewportFill = require('./hooks/useViewportFill');
|
|
52
52
|
var useStickyLayout = require('./hooks/useStickyLayout');
|
|
53
53
|
var formatDate = require('./utils/date/formatDate');
|
|
54
|
+
var mimeTypes = require('./utils/files/mimeTypes');
|
|
54
55
|
var FilterField = require('./components/filter-field/FilterField');
|
|
55
56
|
var Select = require('./components/forms/select/Select');
|
|
56
57
|
var SplitButton = require('./components/split-button/SplitButton');
|
|
@@ -335,6 +336,14 @@ Object.defineProperty(exports, "formatDate", {
|
|
|
335
336
|
enumerable: true,
|
|
336
337
|
get: function () { return formatDate.formatDate; }
|
|
337
338
|
});
|
|
339
|
+
Object.defineProperty(exports, "formatMimeType", {
|
|
340
|
+
enumerable: true,
|
|
341
|
+
get: function () { return mimeTypes.formatMimeType; }
|
|
342
|
+
});
|
|
343
|
+
Object.defineProperty(exports, "getMimeTypeExtension", {
|
|
344
|
+
enumerable: true,
|
|
345
|
+
get: function () { return mimeTypes.getMimeTypeExtension; }
|
|
346
|
+
});
|
|
338
347
|
Object.defineProperty(exports, "FilterField", {
|
|
339
348
|
enumerable: true,
|
|
340
349
|
get: function () { return FilterField.FilterField; }
|
package/dist/client.d.ts
CHANGED
|
@@ -83,6 +83,7 @@ export type { MultiselectOption } from './components/forms/multi-select/MultiSel
|
|
|
83
83
|
export { useViewportFill } from './hooks/useViewportFill';
|
|
84
84
|
export { useStickyLayout } from './hooks/useStickyLayout';
|
|
85
85
|
export { formatDate } from './utils/date/formatDate';
|
|
86
|
+
export { formatMimeType, getMimeTypeExtension } from './utils/files/mimeTypes';
|
|
86
87
|
export type { FormatDateOptions } from './utils/date/formatDate';
|
|
87
88
|
export { FilterField, NUMBER_OPERATORS } from './components/filter-field/FilterField';
|
|
88
89
|
export type { Operator, FilterEvent, FilterFieldProps } from './components/filter-field/FilterField';
|
package/dist/client.js
CHANGED
|
@@ -49,6 +49,7 @@ export { MultiSelect } from './components/forms/multi-select/MultiSelect';
|
|
|
49
49
|
export { useViewportFill } from './hooks/useViewportFill';
|
|
50
50
|
export { useStickyLayout } from './hooks/useStickyLayout';
|
|
51
51
|
export { formatDate } from './utils/date/formatDate';
|
|
52
|
+
export { formatMimeType, getMimeTypeExtension } from './utils/files/mimeTypes';
|
|
52
53
|
export { FilterField, NUMBER_OPERATORS } from './components/filter-field/FilterField';
|
|
53
54
|
export { Select } from './components/forms/select/Select';
|
|
54
55
|
export { SplitButton } from './components/split-button/SplitButton';
|
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ var severity_types = require('./constants/severity.types');
|
|
|
26
26
|
var AppHeader = require('./components/app-header/AppHeader');
|
|
27
27
|
var nestedFiltering = require('./utils/arrays/nested-filtering');
|
|
28
28
|
var formatDate = require('./utils/date/formatDate');
|
|
29
|
+
var mimeTypes = require('./utils/files/mimeTypes');
|
|
29
30
|
var clipboard_utils = require('./utils/clipboard.utils');
|
|
30
31
|
var AttributeChip = require('./components/attribute-chip/AttributeChip');
|
|
31
32
|
var MetaBar = require('./components/meta-bar/MetaBar');
|
|
@@ -210,6 +211,12 @@ Object.keys(formatDate).forEach(function (k) {
|
|
|
210
211
|
get: function () { return formatDate[k]; }
|
|
211
212
|
});
|
|
212
213
|
});
|
|
214
|
+
Object.keys(mimeTypes).forEach(function (k) {
|
|
215
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
216
|
+
enumerable: true,
|
|
217
|
+
get: function () { return mimeTypes[k]; }
|
|
218
|
+
});
|
|
219
|
+
});
|
|
213
220
|
Object.keys(clipboard_utils).forEach(function (k) {
|
|
214
221
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
215
222
|
enumerable: true,
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export * from './constants/severity.types';
|
|
|
24
24
|
export * from './components/app-header/AppHeader';
|
|
25
25
|
export * from './utils/arrays/nested-filtering';
|
|
26
26
|
export * from './utils/date/formatDate';
|
|
27
|
+
export * from './utils/files/mimeTypes';
|
|
27
28
|
export * from './utils/clipboard.utils';
|
|
28
29
|
export * from './components/attribute-chip/AttributeChip';
|
|
29
30
|
export * from './components/meta-bar/MetaBar';
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ export * from './constants/severity.types';
|
|
|
24
24
|
export * from './components/app-header/AppHeader';
|
|
25
25
|
export * from './utils/arrays/nested-filtering';
|
|
26
26
|
export * from './utils/date/formatDate';
|
|
27
|
+
export * from './utils/files/mimeTypes';
|
|
27
28
|
export * from './utils/clipboard.utils';
|
|
28
29
|
export * from './components/attribute-chip/AttributeChip';
|
|
29
30
|
export * from './components/meta-bar/MetaBar';
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const MIME_TYPE_LABELS = /* @__PURE__ */ new Map([
|
|
4
|
+
["application/pdf", "PDF"],
|
|
5
|
+
["application/epub+zip", "EPUB"],
|
|
6
|
+
["application/vnd.amazon.ebook", "Kindle"],
|
|
7
|
+
["application/msword", "Word (DOC)"],
|
|
8
|
+
["application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Word (DOCX)"],
|
|
9
|
+
["application/vnd.ms-excel", "Excel (XLS)"],
|
|
10
|
+
["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Excel (XLSX)"],
|
|
11
|
+
["application/vnd.ms-powerpoint", "PowerPoint (PPT)"],
|
|
12
|
+
[
|
|
13
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
14
|
+
"PowerPoint (PPTX)"
|
|
15
|
+
],
|
|
16
|
+
["application/vnd.oasis.opendocument.text", "OpenDocument-tekst (ODT)"],
|
|
17
|
+
["application/vnd.oasis.opendocument.spreadsheet", "OpenDocument-regneark (ODS)"],
|
|
18
|
+
["application/vnd.oasis.opendocument.presentation", "OpenDocument-pr\xE6sentation (ODP)"],
|
|
19
|
+
["application/rtf", "RTF"],
|
|
20
|
+
["text/rtf", "RTF"],
|
|
21
|
+
["text/plain", "Tekst"],
|
|
22
|
+
["text/html", "HTML"],
|
|
23
|
+
["application/xhtml+xml", "XHTML"],
|
|
24
|
+
["text/csv", "CSV"],
|
|
25
|
+
["text/tab-separated-values", "TSV"],
|
|
26
|
+
["text/markdown", "Markdown"],
|
|
27
|
+
["text/calendar", "Kalender (ICS)"],
|
|
28
|
+
["application/xml", "XML"],
|
|
29
|
+
["text/xml", "XML"],
|
|
30
|
+
["application/json", "JSON"],
|
|
31
|
+
["application/ld+json", "JSON-LD"],
|
|
32
|
+
["image/jpeg", "JPEG"],
|
|
33
|
+
["image/png", "PNG"],
|
|
34
|
+
["image/apng", "APNG"],
|
|
35
|
+
["image/gif", "GIF"],
|
|
36
|
+
["image/webp", "WebP"],
|
|
37
|
+
["image/avif", "AVIF"],
|
|
38
|
+
["image/tiff", "TIFF"],
|
|
39
|
+
["image/bmp", "BMP"],
|
|
40
|
+
["image/svg+xml", "SVG"],
|
|
41
|
+
["image/vnd.microsoft.icon", "ICO"],
|
|
42
|
+
["audio/mpeg", "MP3"],
|
|
43
|
+
["audio/mp4", "MP4-lyd"],
|
|
44
|
+
["audio/aac", "AAC"],
|
|
45
|
+
["audio/ogg", "Ogg-lyd"],
|
|
46
|
+
["audio/wav", "WAV"],
|
|
47
|
+
["audio/webm", "WebM-lyd"],
|
|
48
|
+
["audio/midi", "MIDI"],
|
|
49
|
+
["audio/x-midi", "MIDI"],
|
|
50
|
+
["video/mp4", "MP4-video"],
|
|
51
|
+
["video/mpeg", "MPEG-video"],
|
|
52
|
+
["video/ogg", "Ogg-video"],
|
|
53
|
+
["video/webm", "WebM-video"],
|
|
54
|
+
["video/quicktime", "QuickTime (MOV)"],
|
|
55
|
+
["video/x-msvideo", "AVI"],
|
|
56
|
+
["application/zip", "ZIP"],
|
|
57
|
+
["application/x-zip-compressed", "ZIP"],
|
|
58
|
+
["application/gzip", "GZIP"],
|
|
59
|
+
["application/x-gzip", "GZIP"],
|
|
60
|
+
["application/x-tar", "TAR"],
|
|
61
|
+
["application/vnd.rar", "RAR"],
|
|
62
|
+
["application/x-rar-compressed", "RAR"],
|
|
63
|
+
["application/x-7z-compressed", "7-Zip"],
|
|
64
|
+
["application/x-bzip", "BZIP"],
|
|
65
|
+
["application/x-bzip2", "BZIP2"],
|
|
66
|
+
["application/octet-stream", "Bin\xE6r fil"]
|
|
67
|
+
]);
|
|
68
|
+
const MIME_TYPE_EXTENSIONS = /* @__PURE__ */ new Map([
|
|
69
|
+
["application/pdf", "pdf"],
|
|
70
|
+
["image/jpeg", "jpg"],
|
|
71
|
+
["image/png", "png"],
|
|
72
|
+
["image/apng", "apng"],
|
|
73
|
+
["image/gif", "gif"],
|
|
74
|
+
["image/webp", "webp"],
|
|
75
|
+
["image/avif", "avif"],
|
|
76
|
+
["image/tiff", "tiff"],
|
|
77
|
+
["image/bmp", "bmp"],
|
|
78
|
+
["image/svg+xml", "svg"],
|
|
79
|
+
["image/vnd.microsoft.icon", "ico"]
|
|
80
|
+
]);
|
|
81
|
+
function getMimeTypeExtension(mimeType) {
|
|
82
|
+
return MIME_TYPE_EXTENSIONS.get(mimeType.split(";", 1)[0].trim().toLowerCase());
|
|
83
|
+
}
|
|
84
|
+
function formatMimeType(mimeType) {
|
|
85
|
+
var _a;
|
|
86
|
+
if (mimeType === void 0 || mimeType === null) return "-";
|
|
87
|
+
const type = mimeType.split(";", 1)[0].trim().toLowerCase();
|
|
88
|
+
return (_a = MIME_TYPE_LABELS.get(type)) != null ? _a : mimeType;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
exports.formatMimeType = formatMimeType;
|
|
92
|
+
exports.getMimeTypeExtension = getMimeTypeExtension;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const MIME_TYPE_LABELS = /* @__PURE__ */ new Map([
|
|
2
|
+
["application/pdf", "PDF"],
|
|
3
|
+
["application/epub+zip", "EPUB"],
|
|
4
|
+
["application/vnd.amazon.ebook", "Kindle"],
|
|
5
|
+
["application/msword", "Word (DOC)"],
|
|
6
|
+
["application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Word (DOCX)"],
|
|
7
|
+
["application/vnd.ms-excel", "Excel (XLS)"],
|
|
8
|
+
["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Excel (XLSX)"],
|
|
9
|
+
["application/vnd.ms-powerpoint", "PowerPoint (PPT)"],
|
|
10
|
+
[
|
|
11
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
12
|
+
"PowerPoint (PPTX)"
|
|
13
|
+
],
|
|
14
|
+
["application/vnd.oasis.opendocument.text", "OpenDocument-tekst (ODT)"],
|
|
15
|
+
["application/vnd.oasis.opendocument.spreadsheet", "OpenDocument-regneark (ODS)"],
|
|
16
|
+
["application/vnd.oasis.opendocument.presentation", "OpenDocument-pr\xE6sentation (ODP)"],
|
|
17
|
+
["application/rtf", "RTF"],
|
|
18
|
+
["text/rtf", "RTF"],
|
|
19
|
+
["text/plain", "Tekst"],
|
|
20
|
+
["text/html", "HTML"],
|
|
21
|
+
["application/xhtml+xml", "XHTML"],
|
|
22
|
+
["text/csv", "CSV"],
|
|
23
|
+
["text/tab-separated-values", "TSV"],
|
|
24
|
+
["text/markdown", "Markdown"],
|
|
25
|
+
["text/calendar", "Kalender (ICS)"],
|
|
26
|
+
["application/xml", "XML"],
|
|
27
|
+
["text/xml", "XML"],
|
|
28
|
+
["application/json", "JSON"],
|
|
29
|
+
["application/ld+json", "JSON-LD"],
|
|
30
|
+
["image/jpeg", "JPEG"],
|
|
31
|
+
["image/png", "PNG"],
|
|
32
|
+
["image/apng", "APNG"],
|
|
33
|
+
["image/gif", "GIF"],
|
|
34
|
+
["image/webp", "WebP"],
|
|
35
|
+
["image/avif", "AVIF"],
|
|
36
|
+
["image/tiff", "TIFF"],
|
|
37
|
+
["image/bmp", "BMP"],
|
|
38
|
+
["image/svg+xml", "SVG"],
|
|
39
|
+
["image/vnd.microsoft.icon", "ICO"],
|
|
40
|
+
["audio/mpeg", "MP3"],
|
|
41
|
+
["audio/mp4", "MP4-lyd"],
|
|
42
|
+
["audio/aac", "AAC"],
|
|
43
|
+
["audio/ogg", "Ogg-lyd"],
|
|
44
|
+
["audio/wav", "WAV"],
|
|
45
|
+
["audio/webm", "WebM-lyd"],
|
|
46
|
+
["audio/midi", "MIDI"],
|
|
47
|
+
["audio/x-midi", "MIDI"],
|
|
48
|
+
["video/mp4", "MP4-video"],
|
|
49
|
+
["video/mpeg", "MPEG-video"],
|
|
50
|
+
["video/ogg", "Ogg-video"],
|
|
51
|
+
["video/webm", "WebM-video"],
|
|
52
|
+
["video/quicktime", "QuickTime (MOV)"],
|
|
53
|
+
["video/x-msvideo", "AVI"],
|
|
54
|
+
["application/zip", "ZIP"],
|
|
55
|
+
["application/x-zip-compressed", "ZIP"],
|
|
56
|
+
["application/gzip", "GZIP"],
|
|
57
|
+
["application/x-gzip", "GZIP"],
|
|
58
|
+
["application/x-tar", "TAR"],
|
|
59
|
+
["application/vnd.rar", "RAR"],
|
|
60
|
+
["application/x-rar-compressed", "RAR"],
|
|
61
|
+
["application/x-7z-compressed", "7-Zip"],
|
|
62
|
+
["application/x-bzip", "BZIP"],
|
|
63
|
+
["application/x-bzip2", "BZIP2"],
|
|
64
|
+
["application/octet-stream", "Bin\xE6r fil"]
|
|
65
|
+
]);
|
|
66
|
+
const MIME_TYPE_EXTENSIONS = /* @__PURE__ */ new Map([
|
|
67
|
+
["application/pdf", "pdf"],
|
|
68
|
+
["image/jpeg", "jpg"],
|
|
69
|
+
["image/png", "png"],
|
|
70
|
+
["image/apng", "apng"],
|
|
71
|
+
["image/gif", "gif"],
|
|
72
|
+
["image/webp", "webp"],
|
|
73
|
+
["image/avif", "avif"],
|
|
74
|
+
["image/tiff", "tiff"],
|
|
75
|
+
["image/bmp", "bmp"],
|
|
76
|
+
["image/svg+xml", "svg"],
|
|
77
|
+
["image/vnd.microsoft.icon", "ico"]
|
|
78
|
+
]);
|
|
79
|
+
function getMimeTypeExtension(mimeType) {
|
|
80
|
+
return MIME_TYPE_EXTENSIONS.get(mimeType.split(";", 1)[0].trim().toLowerCase());
|
|
81
|
+
}
|
|
82
|
+
function formatMimeType(mimeType) {
|
|
83
|
+
var _a;
|
|
84
|
+
if (mimeType === void 0 || mimeType === null) return "-";
|
|
85
|
+
const type = mimeType.split(";", 1)[0].trim().toLowerCase();
|
|
86
|
+
return (_a = MIME_TYPE_LABELS.get(type)) != null ? _a : mimeType;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { formatMimeType, getMimeTypeExtension };
|