@dbcdk/react-components 0.0.205 → 0.0.207
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 +2 -0
- package/dist/client.js +1 -0
- package/dist/components/lightbox/Lightbox.cjs +2 -22
- package/dist/components/lightbox/Lightbox.d.ts +2 -8
- package/dist/components/lightbox/Lightbox.js +2 -22
- package/dist/components/menu/Menu.cjs +1 -1
- package/dist/components/menu/Menu.js +1 -1
- package/dist/components/menu/Menu.types.cjs +2 -0
- package/dist/components/menu/Menu.types.d.ts +19 -0
- package/dist/components/menu/Menu.types.js +1 -0
- package/dist/components/menu/MenuAction.cjs +61 -0
- package/dist/components/menu/MenuAction.d.ts +7 -0
- package/dist/components/menu/MenuAction.js +59 -0
- package/dist/components/table/Table.types.d.ts +6 -9
- package/dist/components/table/components/TableRow.cjs +5 -26
- package/dist/components/table/components/TableRow.js +5 -26
- package/dist/index.cjs +7 -0
- package/dist/index.d.ts +2 -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';
|
|
@@ -176,3 +177,4 @@ export { FileUpload } from './components/forms/file-upload/FileUpload';
|
|
|
176
177
|
export type { FileUploadProps, FileUploadHandle } from './components/forms/file-upload/FileUpload';
|
|
177
178
|
export { HighlightedText } from './components/highlighted-text/HighlightedText';
|
|
178
179
|
export type { HighlightedTextProps } from './components/highlighted-text/HighlightedText';
|
|
180
|
+
export type { MenuActionItem, MenuButtonItem, MenuLinkItem } from './components/menu/Menu.types';
|
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';
|
|
@@ -9,6 +9,7 @@ var Popover = require('../../components/popover/Popover');
|
|
|
9
9
|
var styles = require('./Lightbox.module.css');
|
|
10
10
|
var Button = require('../button/Button');
|
|
11
11
|
var Menu = require('../menu/Menu');
|
|
12
|
+
var MenuAction = require('../menu/MenuAction');
|
|
12
13
|
|
|
13
14
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
15
|
|
|
@@ -262,28 +263,7 @@ function ThumbnailContextMenu({
|
|
|
262
263
|
}
|
|
263
264
|
);
|
|
264
265
|
},
|
|
265
|
-
children: (close) => /* @__PURE__ */ jsxRuntime.jsx(Menu.Menu, { children: menuItems.map((menuItem, menuItemIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
266
|
-
Menu.Menu.Item,
|
|
267
|
-
{
|
|
268
|
-
active: menuItem.active,
|
|
269
|
-
selected: menuItem.selected,
|
|
270
|
-
disabled: menuItem.disabled,
|
|
271
|
-
variant: menuItem.variant,
|
|
272
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
273
|
-
"button",
|
|
274
|
-
{
|
|
275
|
-
type: "button",
|
|
276
|
-
onClick: (e) => {
|
|
277
|
-
e.stopPropagation();
|
|
278
|
-
menuItem.onClick();
|
|
279
|
-
close();
|
|
280
|
-
},
|
|
281
|
-
children: menuItem.label
|
|
282
|
-
}
|
|
283
|
-
)
|
|
284
|
-
},
|
|
285
|
-
menuItemIndex
|
|
286
|
-
)) })
|
|
266
|
+
children: (close) => /* @__PURE__ */ jsxRuntime.jsx(Menu.Menu, { children: menuItems.map((menuItem, menuItemIndex) => /* @__PURE__ */ jsxRuntime.jsx(MenuAction.MenuAction, { item: menuItem, onActivate: close }, menuItemIndex)) })
|
|
287
267
|
}
|
|
288
268
|
);
|
|
289
269
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactElement, ReactNode } from 'react';
|
|
2
2
|
import { type MetaItem } from '../../components/meta-bar/MetaBar';
|
|
3
|
+
import type { MenuActionItem } from '../menu/Menu.types';
|
|
3
4
|
export type LightboxItem = {
|
|
4
5
|
thumbnail: ReactNode;
|
|
5
6
|
preview?: ReactNode;
|
|
@@ -10,14 +11,7 @@ export type LightboxItem = {
|
|
|
10
11
|
height?: number;
|
|
11
12
|
metaAddition?: MetaItem[];
|
|
12
13
|
};
|
|
13
|
-
export type LightboxContextMenuItem =
|
|
14
|
-
label: ReactNode;
|
|
15
|
-
onClick: () => void;
|
|
16
|
-
active?: boolean;
|
|
17
|
-
selected?: boolean;
|
|
18
|
-
disabled?: boolean;
|
|
19
|
-
variant?: 'default' | 'danger';
|
|
20
|
-
};
|
|
14
|
+
export type LightboxContextMenuItem = MenuActionItem;
|
|
21
15
|
export interface LightboxProps {
|
|
22
16
|
items: LightboxItem[];
|
|
23
17
|
title?: string;
|
|
@@ -7,6 +7,7 @@ import { Popover } from '../../components/popover/Popover';
|
|
|
7
7
|
import styles from './Lightbox.module.css';
|
|
8
8
|
import { Button } from '../button/Button';
|
|
9
9
|
import { Menu } from '../menu/Menu';
|
|
10
|
+
import { MenuAction } from '../menu/MenuAction';
|
|
10
11
|
|
|
11
12
|
function extFromMime(mime) {
|
|
12
13
|
var _a;
|
|
@@ -256,28 +257,7 @@ function ThumbnailContextMenu({
|
|
|
256
257
|
}
|
|
257
258
|
);
|
|
258
259
|
},
|
|
259
|
-
children: (close) => /* @__PURE__ */ jsx(Menu, { children: menuItems.map((menuItem, menuItemIndex) => /* @__PURE__ */ jsx(
|
|
260
|
-
Menu.Item,
|
|
261
|
-
{
|
|
262
|
-
active: menuItem.active,
|
|
263
|
-
selected: menuItem.selected,
|
|
264
|
-
disabled: menuItem.disabled,
|
|
265
|
-
variant: menuItem.variant,
|
|
266
|
-
children: /* @__PURE__ */ jsx(
|
|
267
|
-
"button",
|
|
268
|
-
{
|
|
269
|
-
type: "button",
|
|
270
|
-
onClick: (e) => {
|
|
271
|
-
e.stopPropagation();
|
|
272
|
-
menuItem.onClick();
|
|
273
|
-
close();
|
|
274
|
-
},
|
|
275
|
-
children: menuItem.label
|
|
276
|
-
}
|
|
277
|
-
)
|
|
278
|
-
},
|
|
279
|
-
menuItemIndex
|
|
280
|
-
)) })
|
|
260
|
+
children: (close) => /* @__PURE__ */ jsx(Menu, { children: menuItems.map((menuItem, menuItemIndex) => /* @__PURE__ */ jsx(MenuAction, { item: menuItem, onActivate: close }, menuItemIndex)) })
|
|
281
261
|
}
|
|
282
262
|
);
|
|
283
263
|
}
|
|
@@ -31,7 +31,7 @@ function _interopNamespace(e) {
|
|
|
31
31
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
32
32
|
var styles__default = /*#__PURE__*/_interopDefault(styles);
|
|
33
33
|
|
|
34
|
-
const INTERACTIVE_SELECTOR = 'a:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"]):not([aria-disabled="true"]), [role="menuitem"]:not([aria-disabled="true"]), [role="menuitemradio"]:not([aria-disabled="true"]), [role="menuitemcheckbox"]:not([aria-disabled="true"]), [role="option"]:not([aria-disabled="true"])';
|
|
34
|
+
const INTERACTIVE_SELECTOR = 'a[href]:not([aria-disabled="true"]), button:not([disabled]), [tabindex]:not([tabindex="-1"]):not([aria-disabled="true"]), [role="menuitem"]:not([aria-disabled="true"]), [role="menuitemradio"]:not([aria-disabled="true"]), [role="menuitemcheckbox"]:not([aria-disabled="true"]), [role="option"]:not([aria-disabled="true"])';
|
|
35
35
|
function getMenuItems(el) {
|
|
36
36
|
return Array.from(el.querySelectorAll(INTERACTIVE_SELECTOR));
|
|
37
37
|
}
|
|
@@ -6,7 +6,7 @@ import { Checkbox } from '../forms/checkbox/Checkbox';
|
|
|
6
6
|
import { RadioButton } from '../forms/radio-buttons/RadioButton';
|
|
7
7
|
import { Switch } from '../forms/switch/Switch';
|
|
8
8
|
|
|
9
|
-
const INTERACTIVE_SELECTOR = 'a:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"]):not([aria-disabled="true"]), [role="menuitem"]:not([aria-disabled="true"]), [role="menuitemradio"]:not([aria-disabled="true"]), [role="menuitemcheckbox"]:not([aria-disabled="true"]), [role="option"]:not([aria-disabled="true"])';
|
|
9
|
+
const INTERACTIVE_SELECTOR = 'a[href]:not([aria-disabled="true"]), button:not([disabled]), [tabindex]:not([tabindex="-1"]):not([aria-disabled="true"]), [role="menuitem"]:not([aria-disabled="true"]), [role="menuitemradio"]:not([aria-disabled="true"]), [role="menuitemcheckbox"]:not([aria-disabled="true"]), [role="option"]:not([aria-disabled="true"])';
|
|
10
10
|
function getMenuItems(el) {
|
|
11
11
|
return Array.from(el.querySelectorAll(INTERACTIVE_SELECTOR));
|
|
12
12
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AnchorHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
type MenuItemBase = {
|
|
3
|
+
label: ReactNode;
|
|
4
|
+
icon?: ReactNode;
|
|
5
|
+
active?: boolean;
|
|
6
|
+
selected?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
variant?: 'default' | 'danger';
|
|
9
|
+
};
|
|
10
|
+
export type MenuButtonItem = MenuItemBase & {
|
|
11
|
+
href?: undefined;
|
|
12
|
+
onClick: () => void;
|
|
13
|
+
};
|
|
14
|
+
export type MenuLinkItem = MenuItemBase & Pick<AnchorHTMLAttributes<HTMLAnchorElement>, 'download' | 'target' | 'rel'> & {
|
|
15
|
+
href: string;
|
|
16
|
+
onClick?: () => void;
|
|
17
|
+
};
|
|
18
|
+
export type MenuActionItem = MenuButtonItem | MenuLinkItem;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var Menu = require('./Menu');
|
|
6
|
+
|
|
7
|
+
function MenuAction({
|
|
8
|
+
item,
|
|
9
|
+
onActivate,
|
|
10
|
+
children
|
|
11
|
+
}) {
|
|
12
|
+
var _a;
|
|
13
|
+
function handleClick(event) {
|
|
14
|
+
var _a2;
|
|
15
|
+
event.stopPropagation();
|
|
16
|
+
if (item.disabled) {
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
(_a2 = item.onClick) == null ? void 0 : _a2.call(item);
|
|
21
|
+
onActivate();
|
|
22
|
+
}
|
|
23
|
+
function handleKeyDown(event) {
|
|
24
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
25
|
+
event.stopPropagation();
|
|
26
|
+
if (item.href !== void 0) {
|
|
27
|
+
if (event.key === "Enter" && (event.ctrlKey || event.metaKey || event.shiftKey || event.altKey))
|
|
28
|
+
return;
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
if (!item.disabled && !event.repeat) event.currentTarget.click();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const content = children != null ? children : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
34
|
+
item.icon,
|
|
35
|
+
item.label
|
|
36
|
+
] });
|
|
37
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
38
|
+
Menu.Menu.Item,
|
|
39
|
+
{
|
|
40
|
+
active: item.active,
|
|
41
|
+
selected: item.selected,
|
|
42
|
+
disabled: item.disabled,
|
|
43
|
+
variant: item.variant,
|
|
44
|
+
children: item.href !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
45
|
+
"a",
|
|
46
|
+
{
|
|
47
|
+
href: item.disabled ? void 0 : item.href,
|
|
48
|
+
download: item.download,
|
|
49
|
+
target: item.target,
|
|
50
|
+
rel: (_a = item.rel) != null ? _a : item.target === "_blank" ? "noopener noreferrer" : void 0,
|
|
51
|
+
tabIndex: item.disabled ? -1 : 0,
|
|
52
|
+
onClick: handleClick,
|
|
53
|
+
onKeyDown: handleKeyDown,
|
|
54
|
+
children: content
|
|
55
|
+
}
|
|
56
|
+
) : /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: handleClick, onKeyDown: handleKeyDown, children: content })
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
exports.MenuAction = MenuAction;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import type { MenuActionItem } from './Menu.types';
|
|
3
|
+
export declare function MenuAction({ item, onActivate, children, }: {
|
|
4
|
+
item: MenuActionItem;
|
|
5
|
+
onActivate: () => void;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
}): ReactElement;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Menu } from './Menu';
|
|
4
|
+
|
|
5
|
+
function MenuAction({
|
|
6
|
+
item,
|
|
7
|
+
onActivate,
|
|
8
|
+
children
|
|
9
|
+
}) {
|
|
10
|
+
var _a;
|
|
11
|
+
function handleClick(event) {
|
|
12
|
+
var _a2;
|
|
13
|
+
event.stopPropagation();
|
|
14
|
+
if (item.disabled) {
|
|
15
|
+
event.preventDefault();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
(_a2 = item.onClick) == null ? void 0 : _a2.call(item);
|
|
19
|
+
onActivate();
|
|
20
|
+
}
|
|
21
|
+
function handleKeyDown(event) {
|
|
22
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
23
|
+
event.stopPropagation();
|
|
24
|
+
if (item.href !== void 0) {
|
|
25
|
+
if (event.key === "Enter" && (event.ctrlKey || event.metaKey || event.shiftKey || event.altKey))
|
|
26
|
+
return;
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
if (!item.disabled && !event.repeat) event.currentTarget.click();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const content = children != null ? children : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
32
|
+
item.icon,
|
|
33
|
+
item.label
|
|
34
|
+
] });
|
|
35
|
+
return /* @__PURE__ */ jsx(
|
|
36
|
+
Menu.Item,
|
|
37
|
+
{
|
|
38
|
+
active: item.active,
|
|
39
|
+
selected: item.selected,
|
|
40
|
+
disabled: item.disabled,
|
|
41
|
+
variant: item.variant,
|
|
42
|
+
children: item.href !== void 0 ? /* @__PURE__ */ jsx(
|
|
43
|
+
"a",
|
|
44
|
+
{
|
|
45
|
+
href: item.disabled ? void 0 : item.href,
|
|
46
|
+
download: item.download,
|
|
47
|
+
target: item.target,
|
|
48
|
+
rel: (_a = item.rel) != null ? _a : item.target === "_blank" ? "noopener noreferrer" : void 0,
|
|
49
|
+
tabIndex: item.disabled ? -1 : 0,
|
|
50
|
+
onClick: handleClick,
|
|
51
|
+
onKeyDown: handleKeyDown,
|
|
52
|
+
children: content
|
|
53
|
+
}
|
|
54
|
+
) : /* @__PURE__ */ jsx("button", { type: "button", onClick: handleClick, onKeyDown: handleKeyDown, children: content })
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { MenuAction };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
|
+
import type { MenuButtonItem, MenuLinkItem } from '../../components/menu/Menu.types';
|
|
2
3
|
import type { PageChangeEvent } from '../../components/pagination/Pagination';
|
|
3
4
|
import type { Severity } from '../../constants/severity.types';
|
|
4
5
|
export type ViewMode = 'compact' | 'wrapped';
|
|
@@ -69,21 +70,17 @@ export type HeaderExtrasArgs<T> = {
|
|
|
69
70
|
column: ColumnItem<T>;
|
|
70
71
|
index: number;
|
|
71
72
|
};
|
|
72
|
-
export type TableContextMenuActionItem = {
|
|
73
|
+
export type TableContextMenuActionItem = MenuButtonItem & {
|
|
74
|
+
type?: 'item';
|
|
75
|
+
};
|
|
76
|
+
export type TableContextMenuLinkItem = MenuLinkItem & {
|
|
73
77
|
type?: 'item';
|
|
74
|
-
label: ReactNode;
|
|
75
|
-
icon?: ReactNode;
|
|
76
|
-
onClick: () => void;
|
|
77
|
-
active?: boolean;
|
|
78
|
-
selected?: boolean;
|
|
79
|
-
disabled?: boolean;
|
|
80
|
-
variant?: 'default' | 'danger';
|
|
81
78
|
};
|
|
82
79
|
export type TableContextMenuHeaderItem = {
|
|
83
80
|
type: 'header';
|
|
84
81
|
label: ReactNode;
|
|
85
82
|
};
|
|
86
|
-
export type TableContextMenuItem = TableContextMenuActionItem | TableContextMenuHeaderItem;
|
|
83
|
+
export type TableContextMenuItem = TableContextMenuActionItem | TableContextMenuLinkItem | TableContextMenuHeaderItem;
|
|
87
84
|
export type StickyHeader = false | 'app-header' | number;
|
|
88
85
|
export type TableVariant = 'primary' | 'embedded';
|
|
89
86
|
export type SortDirection = 'asc' | 'desc' | null;
|
|
@@ -9,6 +9,7 @@ var Popover = require('../../../components/popover/Popover');
|
|
|
9
9
|
var severity = require('../../../constants/severity');
|
|
10
10
|
var Button = require('../../button/Button');
|
|
11
11
|
var Menu = require('../../menu/Menu');
|
|
12
|
+
var MenuAction = require('../../menu/MenuAction');
|
|
12
13
|
var useTableRowInteractions = require('../hooks/useTableRowInteractions');
|
|
13
14
|
var table_classes = require('../table.classes');
|
|
14
15
|
var styles = require('../Table.module.css');
|
|
@@ -252,32 +253,10 @@ function RowActions({
|
|
|
252
253
|
);
|
|
253
254
|
},
|
|
254
255
|
children: (close) => /* @__PURE__ */ jsxRuntime.jsx(Menu.Menu, { children: menuItems.map(
|
|
255
|
-
(item, index) => item.type === "header" ? /* @__PURE__ */ jsxRuntime.jsx(Menu.Menu.Header, { children: item.label }, index) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
256
|
-
|
|
257
|
-
{
|
|
258
|
-
|
|
259
|
-
selected: item.selected,
|
|
260
|
-
disabled: item.disabled,
|
|
261
|
-
variant: item.variant,
|
|
262
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
263
|
-
"button",
|
|
264
|
-
{
|
|
265
|
-
type: "button",
|
|
266
|
-
"data-row-context-menu": "true",
|
|
267
|
-
onClick: (e) => {
|
|
268
|
-
e.stopPropagation();
|
|
269
|
-
item.onClick();
|
|
270
|
-
close();
|
|
271
|
-
},
|
|
272
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: styles__default.default.contextMenuItemLabel, children: [
|
|
273
|
-
item.icon,
|
|
274
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.contextMenuItemText, children: item.label })
|
|
275
|
-
] })
|
|
276
|
-
}
|
|
277
|
-
)
|
|
278
|
-
},
|
|
279
|
-
index
|
|
280
|
-
)
|
|
256
|
+
(item, index) => item.type === "header" ? /* @__PURE__ */ jsxRuntime.jsx(Menu.Menu.Header, { children: item.label }, index) : /* @__PURE__ */ jsxRuntime.jsx(MenuAction.MenuAction, { item, onActivate: close, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: styles__default.default.contextMenuItemLabel, children: [
|
|
257
|
+
item.icon,
|
|
258
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.contextMenuItemText, children: item.label })
|
|
259
|
+
] }) }, index)
|
|
281
260
|
) })
|
|
282
261
|
}
|
|
283
262
|
) : null
|
|
@@ -7,6 +7,7 @@ import { Popover } from '../../../components/popover/Popover';
|
|
|
7
7
|
import { SeverityBgColor } from '../../../constants/severity';
|
|
8
8
|
import { Button } from '../../button/Button';
|
|
9
9
|
import { Menu } from '../../menu/Menu';
|
|
10
|
+
import { MenuAction } from '../../menu/MenuAction';
|
|
10
11
|
import { useTableRowInteractions } from '../hooks/useTableRowInteractions';
|
|
11
12
|
import { cx } from '../table.classes';
|
|
12
13
|
import styles from '../Table.module.css';
|
|
@@ -246,32 +247,10 @@ function RowActions({
|
|
|
246
247
|
);
|
|
247
248
|
},
|
|
248
249
|
children: (close) => /* @__PURE__ */ jsx(Menu, { children: menuItems.map(
|
|
249
|
-
(item, index) => item.type === "header" ? /* @__PURE__ */ jsx(Menu.Header, { children: item.label }, index) : /* @__PURE__ */ jsx(
|
|
250
|
-
|
|
251
|
-
{
|
|
252
|
-
|
|
253
|
-
selected: item.selected,
|
|
254
|
-
disabled: item.disabled,
|
|
255
|
-
variant: item.variant,
|
|
256
|
-
children: /* @__PURE__ */ jsx(
|
|
257
|
-
"button",
|
|
258
|
-
{
|
|
259
|
-
type: "button",
|
|
260
|
-
"data-row-context-menu": "true",
|
|
261
|
-
onClick: (e) => {
|
|
262
|
-
e.stopPropagation();
|
|
263
|
-
item.onClick();
|
|
264
|
-
close();
|
|
265
|
-
},
|
|
266
|
-
children: /* @__PURE__ */ jsxs("span", { className: styles.contextMenuItemLabel, children: [
|
|
267
|
-
item.icon,
|
|
268
|
-
/* @__PURE__ */ jsx("span", { className: styles.contextMenuItemText, children: item.label })
|
|
269
|
-
] })
|
|
270
|
-
}
|
|
271
|
-
)
|
|
272
|
-
},
|
|
273
|
-
index
|
|
274
|
-
)
|
|
250
|
+
(item, index) => item.type === "header" ? /* @__PURE__ */ jsx(Menu.Header, { children: item.label }, index) : /* @__PURE__ */ jsx(MenuAction, { item, onActivate: close, children: /* @__PURE__ */ jsxs("span", { className: styles.contextMenuItemLabel, children: [
|
|
251
|
+
item.icon,
|
|
252
|
+
/* @__PURE__ */ jsx("span", { className: styles.contextMenuItemText, children: item.label })
|
|
253
|
+
] }) }, index)
|
|
275
254
|
) })
|
|
276
255
|
}
|
|
277
256
|
) : null
|
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';
|
|
@@ -50,3 +51,4 @@ export * from './components/tree-view/TreeView';
|
|
|
50
51
|
export * from './components/split-button/SplitButton';
|
|
51
52
|
export * from './components/filtering/chip-multi-toggle/ChipMultiToggle';
|
|
52
53
|
export * from './components/forms/checkbox-group/CheckboxGroup';
|
|
54
|
+
export type { MenuActionItem, MenuButtonItem, MenuLinkItem } from './components/menu/Menu.types';
|
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 };
|