@dbcdk/react-components 0.0.204 → 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 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');
@@ -98,6 +99,7 @@ var CopyButton = require('./components/copy-button/CopyButton');
98
99
  var Divider = require('./components/divider/Divider');
99
100
  var Grid = require('./components/grid/Grid');
100
101
  var Alert = require('./components/alert/Alert');
102
+ var Callout = require('./components/callout/Callout');
101
103
  var InlineStatus = require('./components/inline-status/InlineStatus');
102
104
  var MediaCard = require('./components/media-card/MediaCard');
103
105
  var Lightbox = require('./components/lightbox/Lightbox');
@@ -334,6 +336,14 @@ Object.defineProperty(exports, "formatDate", {
334
336
  enumerable: true,
335
337
  get: function () { return formatDate.formatDate; }
336
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
+ });
337
347
  Object.defineProperty(exports, "FilterField", {
338
348
  enumerable: true,
339
349
  get: function () { return FilterField.FilterField; }
@@ -570,6 +580,10 @@ Object.defineProperty(exports, "Alert", {
570
580
  enumerable: true,
571
581
  get: function () { return Alert.Alert; }
572
582
  });
583
+ Object.defineProperty(exports, "Callout", {
584
+ enumerable: true,
585
+ get: function () { return Callout.Callout; }
586
+ });
573
587
  Object.defineProperty(exports, "InlineStatus", {
574
588
  enumerable: true,
575
589
  get: function () { return InlineStatus.InlineStatus; }
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';
@@ -164,6 +165,8 @@ export { Grid, GridItem } from './components/grid/Grid';
164
165
  export type { GridGap, GridMaxWidth, GridProps, GridItemProps } from './components/grid/Grid';
165
166
  export { Alert } from './components/alert/Alert';
166
167
  export type { AlertProps } from './components/alert/Alert';
168
+ export { Callout } from './components/callout/Callout';
169
+ export type { CalloutProps } from './components/callout/Callout';
167
170
  export { InlineStatus } from './components/inline-status/InlineStatus';
168
171
  export type { InlineStatusProps } from './components/inline-status/InlineStatus';
169
172
  export { MediaCard } from './components/media-card/MediaCard';
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';
@@ -96,6 +97,7 @@ export { CopyButton } from './components/copy-button/CopyButton';
96
97
  export { Divider } from './components/divider/Divider';
97
98
  export { Grid, GridItem } from './components/grid/Grid';
98
99
  export { Alert } from './components/alert/Alert';
100
+ export { Callout } from './components/callout/Callout';
99
101
  export { InlineStatus } from './components/inline-status/InlineStatus';
100
102
  export { MediaCard } from './components/media-card/MediaCard';
101
103
  export { Lightbox } from './components/lightbox/Lightbox';
@@ -1,18 +1,16 @@
1
1
  .container {
2
- --alert-bg: var(--color-bg-toolbar);
3
- --alert-fg: var(--color-fg-default);
4
-
5
2
  display: flex;
6
3
  align-items: flex-start;
7
4
  gap: var(--spacing-sm);
8
5
  inline-size: min(100%, var(--alert-max-width, 72ch));
9
6
  max-inline-size: 100%;
10
7
  padding: var(--spacing-sm) var(--spacing-md);
8
+ border: var(--border-width-thin) solid var(--color-border-default);
9
+ /* Severity accent on the left edge, as on toasts. */
10
+ border-inline-start: var(--border-width-thick) solid var(--alert-accent);
11
11
  border-radius: var(--border-radius-default);
12
- background: var(--alert-bg);
13
- color: var(--alert-fg);
14
- /* Severity stripe on the left edge. An inset shadow keeps size and padding unchanged. */
15
- box-shadow: inset var(--border-width-thick) 0 0 var(--alert-accent, transparent);
12
+ background: color-mix(in srgb, var(--alert-accent) 4%, var(--color-bg-surface));
13
+ color: var(--color-fg-default);
16
14
  box-sizing: border-box;
17
15
  }
18
16
 
@@ -66,53 +64,35 @@
66
64
  }
67
65
 
68
66
  .neutral {
69
- --alert-bg: var(--color-bg-toolbar);
70
- --alert-fg: var(--color-fg-default);
67
+ --alert-accent: var(--color-border-default);
68
+ background: var(--color-bg-surface-subtle);
71
69
  }
72
70
 
73
71
  .success {
74
- --alert-bg: var(--color-status-success-bg);
75
- --alert-fg: var(--color-status-success-fg);
76
72
  --alert-accent: var(--color-status-success);
77
73
  }
78
74
 
79
75
  .warning {
80
- --alert-bg: var(--color-status-warning-bg);
81
- --alert-fg: var(--color-status-warning-fg);
82
76
  --alert-accent: var(--color-status-warning);
83
77
  }
84
78
 
85
79
  .error {
86
- --alert-bg: var(--color-status-error-bg);
87
- --alert-fg: var(--color-status-error-fg);
88
80
  --alert-accent: var(--color-status-error);
89
81
  }
90
82
 
91
83
  .info {
92
- --alert-bg: var(--color-status-info-bg);
93
- --alert-fg: var(--color-status-info-fg);
94
84
  --alert-accent: var(--color-status-info);
95
85
  }
96
86
 
97
87
  .brand {
98
- --alert-bg: color-mix(in srgb, var(--color-brand) 10%, var(--color-bg-surface));
99
- --alert-fg: var(--color-brand);
100
88
  --alert-accent: var(--color-brand);
101
89
  }
102
90
 
103
91
  .accent {
104
- --alert-bg: var(--color-accent-bg);
105
- --alert-fg: var(--color-accent-fg);
106
92
  --alert-accent: var(--color-accent);
107
93
  }
108
94
 
109
- /* Square corners on the striped edge, so the stripe stays straight. */
110
- .success,
111
- .warning,
112
- .error,
113
- .info,
114
- .brand,
115
- .accent {
116
- border-top-left-radius: 0;
117
- border-bottom-left-radius: 0;
95
+ /* The brand icon is light (made for brand backgrounds), so use the brand colour here. */
96
+ .brand .leading svg {
97
+ color: var(--color-brand);
118
98
  }
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var styles = require('./Callout.module.css');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var styles__default = /*#__PURE__*/_interopDefault(styles);
9
+
10
+ function Callout({ children, severity = "neutral" }) {
11
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${styles__default.default.callout} ${styles__default.default[severity]}`, children });
12
+ }
13
+
14
+ exports.Callout = Callout;
@@ -0,0 +1,15 @@
1
+ import type { JSX, ReactNode } from 'react';
2
+ import type { Severity } from '../../constants/severity.types';
3
+ export interface CalloutProps {
4
+ children: ReactNode;
5
+ /** Colour of the bar on the left edge. */
6
+ severity?: Severity;
7
+ }
8
+ /**
9
+ * A quiet box for extra content that belongs to what is right above it, e.g.
10
+ * help or examples under a form field. A light background and a bar on the
11
+ * left, without an outer border, so it doesn't look like an input or a card.
12
+ *
13
+ * Unlike Alert it has no icon, title or role: it isn't a message.
14
+ */
15
+ export declare function Callout({ children, severity }: CalloutProps): JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import styles from './Callout.module.css';
3
+
4
+ function Callout({ children, severity = "neutral" }) {
5
+ return /* @__PURE__ */ jsx("div", { className: `${styles.callout} ${styles[severity]}`, children });
6
+ }
7
+
8
+ export { Callout };
@@ -0,0 +1,44 @@
1
+ .callout {
2
+ padding: var(--spacing-xs) var(--spacing-sm);
3
+ border-inline-start: var(--border-width-thick) solid var(--callout-accent);
4
+ border-radius: var(--border-radius-default);
5
+ background: var(--callout-bg);
6
+ color: var(--color-fg-default);
7
+ font-size: var(--font-size-sm);
8
+ overflow-wrap: anywhere;
9
+ }
10
+
11
+ .neutral {
12
+ --callout-accent: var(--color-border-strong);
13
+ --callout-bg: var(--color-bg-surface-subtle);
14
+ }
15
+
16
+ .success {
17
+ --callout-accent: var(--color-status-success);
18
+ --callout-bg: color-mix(in srgb, var(--color-status-success) 8%, var(--color-bg-surface));
19
+ }
20
+
21
+ .warning {
22
+ --callout-accent: var(--color-status-warning);
23
+ --callout-bg: color-mix(in srgb, var(--color-status-warning) 8%, var(--color-bg-surface));
24
+ }
25
+
26
+ .error {
27
+ --callout-accent: var(--color-status-error);
28
+ --callout-bg: color-mix(in srgb, var(--color-status-error) 8%, var(--color-bg-surface));
29
+ }
30
+
31
+ .info {
32
+ --callout-accent: var(--color-status-info);
33
+ --callout-bg: color-mix(in srgb, var(--color-status-info) 8%, var(--color-bg-surface));
34
+ }
35
+
36
+ .brand {
37
+ --callout-accent: var(--color-brand);
38
+ --callout-bg: color-mix(in srgb, var(--color-brand) 8%, var(--color-bg-surface));
39
+ }
40
+
41
+ .accent {
42
+ --callout-accent: var(--color-accent);
43
+ --callout-bg: color-mix(in srgb, var(--color-accent) 8%, var(--color-bg-surface));
44
+ }
@@ -473,7 +473,7 @@
473
473
  pointer-events: auto;
474
474
  }
475
475
 
476
- /* Error: wins over variant and modified styles */
476
+ /* Error: wins over the variant's own border, hover and focus colours */
477
477
  .field.invalid,
478
478
  .field.invalid:hover:not([aria-disabled='true']) {
479
479
  border-color: var(--color-status-error);
@@ -7,7 +7,7 @@
7
7
  background-color: var(--color-bg-toolbar-hover);
8
8
  }
9
9
 
10
- /* Error: wins over modified styles (attribute bumps specificity over Button's own styles) */
10
+ /* Error (the attribute raises specificity above Button's own border styles) */
11
11
  .triggerInvalid[data-forminput],
12
12
  .triggerInvalid[data-forminput]:hover:not([disabled]) {
13
13
  border-color: var(--color-status-error);
@@ -38,7 +38,7 @@
38
38
  box-shadow: inset 0 0 0 1px var(--color-field-focus);
39
39
  }
40
40
 
41
- /* Error: wins over modified styles */
41
+ /* Error */
42
42
  .container.invalid textarea,
43
43
  .container.invalid textarea:hover {
44
44
  border-color: var(--color-status-error);
@@ -1,18 +1,15 @@
1
1
  .container {
2
- --inline-status-bg: var(--color-bg-toolbar);
3
- --inline-status-fg: var(--color-fg-default);
4
- --inline-status-border: var(--color-border-subtle);
5
-
6
2
  display: inline-flex;
7
3
  align-items: flex-start;
8
4
  gap: var(--spacing-xs);
9
5
  max-inline-size: 100%;
10
6
 
11
7
  padding: var(--spacing-2xs) var(--spacing-sm);
12
- border: 1px solid var(--inline-status-border);
8
+ border: var(--border-width-thin) solid
9
+ color-mix(in srgb, var(--inline-status-accent) 25%, var(--color-border-default));
13
10
  border-radius: var(--border-radius-default);
14
- background: var(--inline-status-bg);
15
- color: var(--inline-status-fg);
11
+ background: color-mix(in srgb, var(--inline-status-accent) 4%, var(--color-bg-surface));
12
+ color: var(--color-fg-default);
16
13
 
17
14
  font-family: var(--font-family);
18
15
  font-size: var(--font-size-sm);
@@ -56,43 +53,35 @@
56
53
  }
57
54
 
58
55
  .neutral {
59
- --inline-status-bg: var(--color-bg-toolbar);
60
- --inline-status-fg: var(--color-fg-default);
61
- --inline-status-border: transparent;
56
+ --inline-status-accent: var(--color-border-default);
57
+ background: var(--color-bg-surface-subtle);
62
58
  }
63
59
 
64
60
  .success {
65
- --inline-status-bg: var(--color-status-success-bg);
66
- --inline-status-fg: var(--color-status-success-fg);
67
- --inline-status-border: var(--color-status-success-border);
61
+ --inline-status-accent: var(--color-status-success);
68
62
  }
69
63
 
70
64
  .warning {
71
- --inline-status-bg: var(--color-status-warning-bg);
72
- --inline-status-fg: var(--color-status-warning-fg);
73
- --inline-status-border: var(--color-status-warning-border);
65
+ --inline-status-accent: var(--color-status-warning);
74
66
  }
75
67
 
76
68
  .error {
77
- --inline-status-bg: var(--color-status-error-bg);
78
- --inline-status-fg: var(--color-status-error-fg);
79
- --inline-status-border: var(--color-status-error-border);
69
+ --inline-status-accent: var(--color-status-error);
80
70
  }
81
71
 
82
72
  .info {
83
- --inline-status-bg: var(--color-status-info-bg);
84
- --inline-status-fg: var(--color-status-info-fg);
85
- --inline-status-border: var(--color-status-info-border);
73
+ --inline-status-accent: var(--color-status-info);
86
74
  }
87
75
 
88
76
  .brand {
89
- --inline-status-bg: color-mix(in srgb, var(--color-brand) 10%, var(--color-bg-surface));
90
- --inline-status-fg: var(--color-brand);
91
- --inline-status-border: color-mix(in srgb, var(--color-brand) 35%, transparent);
77
+ --inline-status-accent: var(--color-brand);
92
78
  }
93
79
 
94
80
  .accent {
95
- --inline-status-bg: var(--color-accent-bg);
96
- --inline-status-fg: var(--color-accent-fg);
97
- --inline-status-border: var(--color-accent-border);
81
+ --inline-status-accent: var(--color-accent);
82
+ }
83
+
84
+ /* The shared brand icon uses an on-brand colour; keep it visible on the faint tint. */
85
+ .brand .leading svg {
86
+ color: var(--color-brand);
98
87
  }
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');
@@ -41,6 +42,7 @@ var Toast = require('./components/toast/Toast');
41
42
  var Hyperlink = require('./components/hyperlink/Hyperlink');
42
43
  var StatePage = require('./components/state-page/StatePage');
43
44
  var Alert = require('./components/alert/Alert');
45
+ var Callout = require('./components/callout/Callout');
44
46
  var InlineStatus = require('./components/inline-status/InlineStatus');
45
47
  var MediaCard = require('./components/media-card/MediaCard');
46
48
  var HighlightedText = require('./components/highlighted-text/HighlightedText');
@@ -209,6 +211,12 @@ Object.keys(formatDate).forEach(function (k) {
209
211
  get: function () { return formatDate[k]; }
210
212
  });
211
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
+ });
212
220
  Object.keys(clipboard_utils).forEach(function (k) {
213
221
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
214
222
  enumerable: true,
@@ -299,6 +307,12 @@ Object.keys(Alert).forEach(function (k) {
299
307
  get: function () { return Alert[k]; }
300
308
  });
301
309
  });
310
+ Object.keys(Callout).forEach(function (k) {
311
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
312
+ enumerable: true,
313
+ get: function () { return Callout[k]; }
314
+ });
315
+ });
302
316
  Object.keys(InlineStatus).forEach(function (k) {
303
317
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
304
318
  enumerable: true,
package/dist/index.css CHANGED
@@ -10,6 +10,7 @@
10
10
  @import './components/breadcrumbs/Breadcrumbs.module.css';
11
11
  @import './components/button-select/ButtonSelect.module.css';
12
12
  @import './components/button/Button.module.css';
13
+ @import './components/callout/Callout.module.css';
13
14
  @import './components/card-container/CardContainer.module.css';
14
15
  @import './components/card/Card.module.css';
15
16
  @import './components/card/components/CardMeta.module.css';
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';
@@ -40,6 +41,7 @@ export * from './components/toast/Toast';
40
41
  export * from './components/hyperlink/Hyperlink';
41
42
  export * from './components/state-page/StatePage';
42
43
  export * from './components/alert/Alert';
44
+ export * from './components/callout/Callout';
43
45
  export * from './components/inline-status/InlineStatus';
44
46
  export * from './components/media-card/MediaCard';
45
47
  export * from './components/highlighted-text/HighlightedText';
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';
@@ -39,6 +40,7 @@ export * from './components/toast/Toast';
39
40
  export * from './components/hyperlink/Hyperlink';
40
41
  export * from './components/state-page/StatePage';
41
42
  export * from './components/alert/Alert';
43
+ export * from './components/callout/Callout';
42
44
  export * from './components/inline-status/InlineStatus';
43
45
  export * from './components/media-card/MediaCard';
44
46
  export * from './components/highlighted-text/HighlightedText';
@@ -251,10 +251,18 @@ tr.dbc-table--hover:hover td:last-child {
251
251
  color: var(--color-fg-subtle);
252
252
  }
253
253
 
254
+ .dbc-default-text {
255
+ color: var(--color-fg-default);
256
+ }
257
+
254
258
  .dbc-tabular-nums {
255
259
  font-variant-numeric: tabular-nums;
256
260
  }
257
261
 
262
+ .dbc-xs-text {
263
+ font-size: var(--font-size-xs);
264
+ }
265
+
258
266
  .dbc-sm-text {
259
267
  font-size: var(--font-size-sm);
260
268
  }
@@ -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,2 @@
1
+ export declare function getMimeTypeExtension(mimeType: string): string | undefined;
2
+ export declare function formatMimeType(mimeType: string | undefined | null): string;
@@ -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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbcdk/react-components",
3
- "version": "0.0.204",
3
+ "version": "0.0.206",
4
4
  "description": "Reusable React components for DBC projects",
5
5
  "license": "ISC",
6
6
  "author": "",