@dbcdk/react-components 0.0.186 → 0.0.188
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/client.cjs +7 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +1 -0
- package/dist/components/badge/Badge.cjs +28 -0
- package/dist/components/badge/Badge.d.ts +16 -0
- package/dist/components/badge/Badge.js +21 -0
- package/dist/components/badge/Badge.module.css +53 -0
- package/dist/components/button-select/ButtonSelect.cjs +1 -2
- package/dist/components/button-select/ButtonSelect.d.ts +10 -4
- package/dist/components/button-select/ButtonSelect.js +1 -2
- package/dist/components/table/components/table-settings/TableSettings.cjs +74 -67
- package/dist/components/table/components/table-settings/TableSettings.d.ts +13 -4
- package/dist/components/table/components/table-settings/TableSettings.js +75 -69
- package/dist/components/tabs/Tabs.module.css +13 -2
- package/dist/index.cjs +7 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/styles/styles.css +7 -0
- package/dist/styles.css +7 -0
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -34,6 +34,7 @@ var SkeletonLoader = require('./components/skeleton-loader/SkeletonLoader');
|
|
|
34
34
|
var Page = require('./components/page/Page');
|
|
35
35
|
var Breadcrumbs = require('./components/breadcrumbs/Breadcrumbs');
|
|
36
36
|
var Circle = require('./components/circle/Circle');
|
|
37
|
+
var Badge = require('./components/badge/Badge');
|
|
37
38
|
var Checkbox = require('./components/forms/checkbox/Checkbox');
|
|
38
39
|
var Switch = require('./components/forms/switch/Switch');
|
|
39
40
|
var Table = require('./components/table/Table');
|
|
@@ -301,6 +302,12 @@ Object.keys(Circle).forEach(function (k) {
|
|
|
301
302
|
get: function () { return Circle[k]; }
|
|
302
303
|
});
|
|
303
304
|
});
|
|
305
|
+
Object.keys(Badge).forEach(function (k) {
|
|
306
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
307
|
+
enumerable: true,
|
|
308
|
+
get: function () { return Badge[k]; }
|
|
309
|
+
});
|
|
310
|
+
});
|
|
304
311
|
Object.keys(Checkbox).forEach(function (k) {
|
|
305
312
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
306
313
|
enumerable: true,
|
package/dist/client.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export * from './components/skeleton-loader/SkeletonLoader';
|
|
|
31
31
|
export * from './components/page/Page';
|
|
32
32
|
export * from './components/breadcrumbs/Breadcrumbs';
|
|
33
33
|
export * from './components/circle/Circle';
|
|
34
|
+
export * from './components/badge/Badge';
|
|
34
35
|
export * from './components/forms/checkbox/Checkbox';
|
|
35
36
|
export * from './components/forms/switch/Switch';
|
|
36
37
|
export * from './components/table/Table';
|
package/dist/client.js
CHANGED
|
@@ -32,6 +32,7 @@ export * from './components/skeleton-loader/SkeletonLoader';
|
|
|
32
32
|
export * from './components/page/Page';
|
|
33
33
|
export * from './components/breadcrumbs/Breadcrumbs';
|
|
34
34
|
export * from './components/circle/Circle';
|
|
35
|
+
export * from './components/badge/Badge';
|
|
35
36
|
export * from './components/forms/checkbox/Checkbox';
|
|
36
37
|
export * from './components/forms/switch/Switch';
|
|
37
38
|
export * from './components/table/Table';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var styles = require('./Badge.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 formatBadgeCount(count, max) {
|
|
11
|
+
return count > max ? `${max}+` : String(count);
|
|
12
|
+
}
|
|
13
|
+
function Badge({
|
|
14
|
+
children,
|
|
15
|
+
count,
|
|
16
|
+
max = 99,
|
|
17
|
+
severity = "error",
|
|
18
|
+
dot = false
|
|
19
|
+
}) {
|
|
20
|
+
const showBadge = dot || typeof count === "number" && count > 0;
|
|
21
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: styles__default.default.wrapper, children: [
|
|
22
|
+
children,
|
|
23
|
+
showBadge && /* @__PURE__ */ jsxRuntime.jsx("span", { className: `${styles__default.default.badge} ${styles__default.default[severity]}`, "data-dot": dot || void 0, children: !dot && typeof count === "number" ? formatBadgeCount(count, max) : null })
|
|
24
|
+
] });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.Badge = Badge;
|
|
28
|
+
exports.formatBadgeCount = formatBadgeCount;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode, JSX } from 'react';
|
|
2
|
+
import { Severity } from '../../constants/severity.types';
|
|
3
|
+
interface BadgeProps {
|
|
4
|
+
/** The element the badge is overlaid on top of, e.g. an icon. */
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
/** Shown inside the badge, capped at `max`. Omit (with `dot` false) to render nothing. */
|
|
7
|
+
count?: number;
|
|
8
|
+
/** Counts above this render as `${max}+`. */
|
|
9
|
+
max?: number;
|
|
10
|
+
severity?: Severity;
|
|
11
|
+
/** Render a plain dot instead of a count - use when only "something changed" matters, not how much. */
|
|
12
|
+
dot?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function formatBadgeCount(count: number, max: number): string;
|
|
15
|
+
export declare function Badge({ children, count, max, severity, dot, }: BadgeProps): JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import styles from './Badge.module.css';
|
|
3
|
+
|
|
4
|
+
function formatBadgeCount(count, max) {
|
|
5
|
+
return count > max ? `${max}+` : String(count);
|
|
6
|
+
}
|
|
7
|
+
function Badge({
|
|
8
|
+
children,
|
|
9
|
+
count,
|
|
10
|
+
max = 99,
|
|
11
|
+
severity = "error",
|
|
12
|
+
dot = false
|
|
13
|
+
}) {
|
|
14
|
+
const showBadge = dot || typeof count === "number" && count > 0;
|
|
15
|
+
return /* @__PURE__ */ jsxs("span", { className: styles.wrapper, children: [
|
|
16
|
+
children,
|
|
17
|
+
showBadge && /* @__PURE__ */ jsx("span", { className: `${styles.badge} ${styles[severity]}`, "data-dot": dot || void 0, children: !dot && typeof count === "number" ? formatBadgeCount(count, max) : null })
|
|
18
|
+
] });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { Badge, formatBadgeCount };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
.wrapper {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.badge {
|
|
7
|
+
position: absolute;
|
|
8
|
+
top: 0;
|
|
9
|
+
right: 0;
|
|
10
|
+
transform: translate(50%, -50%);
|
|
11
|
+
display: inline-flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
min-inline-size: 16px;
|
|
16
|
+
block-size: 16px;
|
|
17
|
+
padding-inline: var(--spacing-2xs);
|
|
18
|
+
border-radius: var(--border-radius-rounded);
|
|
19
|
+
font-size: var(--font-size-xs);
|
|
20
|
+
line-height: 1;
|
|
21
|
+
color: var(--color-fg-inverse);
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.badge[data-dot='true'] {
|
|
26
|
+
min-inline-size: 8px;
|
|
27
|
+
inline-size: 8px;
|
|
28
|
+
block-size: 8px;
|
|
29
|
+
padding-inline: 0;
|
|
30
|
+
border-radius: var(--border-radius-round);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.neutral {
|
|
34
|
+
background-color: var(--color-neutral);
|
|
35
|
+
}
|
|
36
|
+
.brand {
|
|
37
|
+
background-color: var(--color-brand);
|
|
38
|
+
}
|
|
39
|
+
.accent {
|
|
40
|
+
background-color: var(--color-accent);
|
|
41
|
+
}
|
|
42
|
+
.success {
|
|
43
|
+
background-color: var(--color-status-success);
|
|
44
|
+
}
|
|
45
|
+
.warning {
|
|
46
|
+
background-color: var(--color-status-warning);
|
|
47
|
+
}
|
|
48
|
+
.error {
|
|
49
|
+
background-color: var(--color-status-error);
|
|
50
|
+
}
|
|
51
|
+
.info {
|
|
52
|
+
background-color: var(--color-status-info);
|
|
53
|
+
}
|
|
@@ -14,8 +14,7 @@ function ButtonSelect(props) {
|
|
|
14
14
|
const selectedValues = Array.isArray(props.value) ? props.value : [props.value];
|
|
15
15
|
function handleSelect(optionValue) {
|
|
16
16
|
if (props.multiple) {
|
|
17
|
-
const
|
|
18
|
-
const nextValue = currentValues.includes(optionValue) ? currentValues.filter((current) => current !== optionValue) : [...currentValues, optionValue];
|
|
17
|
+
const nextValue = props.value.includes(optionValue) ? props.value.filter((current) => current !== optionValue) : [...props.value, optionValue];
|
|
19
18
|
props.onChange(nextValue);
|
|
20
19
|
return;
|
|
21
20
|
}
|
|
@@ -11,10 +11,16 @@ interface ButtonSelectBaseProps<T extends string = string> {
|
|
|
11
11
|
size?: ButtonSize;
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
}
|
|
14
|
-
export interface
|
|
15
|
-
value: T
|
|
16
|
-
onChange: (value: T
|
|
17
|
-
multiple?:
|
|
14
|
+
export interface ButtonSelectSingleProps<T extends string = string> extends ButtonSelectBaseProps<T> {
|
|
15
|
+
value: T;
|
|
16
|
+
onChange: (value: T) => void;
|
|
17
|
+
multiple?: false;
|
|
18
|
+
}
|
|
19
|
+
export interface ButtonSelectMultipleProps<T extends string = string> extends ButtonSelectBaseProps<T> {
|
|
20
|
+
value: T[];
|
|
21
|
+
onChange: (value: T[]) => void;
|
|
22
|
+
multiple: true;
|
|
18
23
|
}
|
|
24
|
+
export type ButtonSelectProps<T extends string = string> = ButtonSelectSingleProps<T> | ButtonSelectMultipleProps<T>;
|
|
19
25
|
export declare function ButtonSelect<T extends string>(props: ButtonSelectProps<T>): JSX.Element;
|
|
20
26
|
export {};
|
|
@@ -8,8 +8,7 @@ function ButtonSelect(props) {
|
|
|
8
8
|
const selectedValues = Array.isArray(props.value) ? props.value : [props.value];
|
|
9
9
|
function handleSelect(optionValue) {
|
|
10
10
|
if (props.multiple) {
|
|
11
|
-
const
|
|
12
|
-
const nextValue = currentValues.includes(optionValue) ? currentValues.filter((current) => current !== optionValue) : [...currentValues, optionValue];
|
|
11
|
+
const nextValue = props.value.includes(optionValue) ? props.value.filter((current) => current !== optionValue) : [...props.value, optionValue];
|
|
13
12
|
props.onChange(nextValue);
|
|
14
13
|
return;
|
|
15
14
|
}
|
|
@@ -8,7 +8,7 @@ var Button = require('../../../button/Button');
|
|
|
8
8
|
var Menu = require('../../../menu/Menu');
|
|
9
9
|
var Popover = require('../../../popover/Popover');
|
|
10
10
|
|
|
11
|
-
function
|
|
11
|
+
function TableSettingsMenuSection({
|
|
12
12
|
viewMode,
|
|
13
13
|
handleChangeViewMode,
|
|
14
14
|
columns = [],
|
|
@@ -17,12 +17,12 @@ function TableSettings({
|
|
|
17
17
|
columnsLabel = "Kolonner",
|
|
18
18
|
allPresetLabel = "Alle",
|
|
19
19
|
standardPresetLabel = "Standard",
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
additionalSettings,
|
|
21
|
+
close
|
|
22
22
|
}) {
|
|
23
|
-
const handleViewModeChange = (mode,
|
|
23
|
+
const handleViewModeChange = (mode, close2) => {
|
|
24
24
|
handleChangeViewMode(mode === "wrapped" ? "compact" : "wrapped");
|
|
25
|
-
|
|
25
|
+
close2 == null ? void 0 : close2();
|
|
26
26
|
};
|
|
27
27
|
const hideableColumns = react.useMemo(() => columns.filter((c) => c.enableHiding !== false), [columns]);
|
|
28
28
|
const allPresetIds = react.useMemo(() => hideableColumns.map((c) => c.id), [hideableColumns]);
|
|
@@ -63,6 +63,73 @@ function TableSettings({
|
|
|
63
63
|
return hideableColumns.every((c) => c.id && visibleSet.has(c.id) === std.has(c.id));
|
|
64
64
|
}, [hideableColumns, visibleSet, standardPresetIds]);
|
|
65
65
|
const presetRadioName = "table-columns-preset";
|
|
66
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
67
|
+
additionalSettings == null ? void 0 : additionalSettings(close),
|
|
68
|
+
/* @__PURE__ */ jsxRuntime.jsx(Menu.Menu.Item, { active: viewMode === "wrapped", children: /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", onClick: () => handleViewModeChange(viewMode, close), children: [
|
|
69
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ListChevronsUpDown, {}),
|
|
70
|
+
"Ombryd tekst"
|
|
71
|
+
] }) }),
|
|
72
|
+
hideableColumns.length > 0 && onVisibleColumnIdsChange ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
73
|
+
/* @__PURE__ */ jsxRuntime.jsx(Menu.Menu.Separator, {}),
|
|
74
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "6px 10px", fontSize: 12, opacity: 0.7 }, children: columnsLabel }),
|
|
75
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
76
|
+
Menu.Menu.RadioItem,
|
|
77
|
+
{
|
|
78
|
+
name: presetRadioName,
|
|
79
|
+
value: "all",
|
|
80
|
+
checked: isAllActive,
|
|
81
|
+
label: allPresetLabel,
|
|
82
|
+
onValueChange: () => {
|
|
83
|
+
setVisibleIds(
|
|
84
|
+
allPresetIds.filter((id) => typeof id === "string" && Boolean(id))
|
|
85
|
+
);
|
|
86
|
+
close == null ? void 0 : close();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
91
|
+
Menu.Menu.RadioItem,
|
|
92
|
+
{
|
|
93
|
+
name: presetRadioName,
|
|
94
|
+
value: "standard",
|
|
95
|
+
checked: isStandardActive,
|
|
96
|
+
label: standardPresetLabel,
|
|
97
|
+
onValueChange: () => {
|
|
98
|
+
setVisibleIds(
|
|
99
|
+
standardPresetIds.filter(
|
|
100
|
+
(id) => typeof id === "string" && Boolean(id)
|
|
101
|
+
)
|
|
102
|
+
);
|
|
103
|
+
close == null ? void 0 : close();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
/* @__PURE__ */ jsxRuntime.jsx(Menu.Menu.Separator, {}),
|
|
108
|
+
hideableColumns.map((col) => {
|
|
109
|
+
const isVisible = col.id ? visibleSet.has(col.id) : false;
|
|
110
|
+
const disableUncheckingLast = isVisible && visibleCount <= 1;
|
|
111
|
+
const label = col.header;
|
|
112
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
113
|
+
Menu.Menu.CheckItem,
|
|
114
|
+
{
|
|
115
|
+
checked: isVisible,
|
|
116
|
+
disabled: disableUncheckingLast,
|
|
117
|
+
label,
|
|
118
|
+
onCheckedChange: (nextChecked) => {
|
|
119
|
+
if (disableUncheckingLast) return;
|
|
120
|
+
toggleColumn(col.id, nextChecked);
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
col.id
|
|
124
|
+
);
|
|
125
|
+
})
|
|
126
|
+
] }) : null
|
|
127
|
+
] });
|
|
128
|
+
}
|
|
129
|
+
function TableSettings({
|
|
130
|
+
buttonSize = "sm",
|
|
131
|
+
...sectionProps
|
|
132
|
+
}) {
|
|
66
133
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
67
134
|
Popover.Popover,
|
|
68
135
|
{
|
|
@@ -70,70 +137,10 @@ function TableSettings({
|
|
|
70
137
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, {}),
|
|
71
138
|
icon
|
|
72
139
|
] }),
|
|
73
|
-
children: (close) => /* @__PURE__ */ jsxRuntime.
|
|
74
|
-
additionalSettings == null ? void 0 : additionalSettings(close),
|
|
75
|
-
/* @__PURE__ */ jsxRuntime.jsx(Menu.Menu.Item, { active: viewMode === "wrapped", children: /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", onClick: () => handleViewModeChange(viewMode, close), children: [
|
|
76
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ListChevronsUpDown, {}),
|
|
77
|
-
"Ombryd tekst"
|
|
78
|
-
] }) }),
|
|
79
|
-
hideableColumns.length > 0 && onVisibleColumnIdsChange ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
80
|
-
/* @__PURE__ */ jsxRuntime.jsx(Menu.Menu.Separator, {}),
|
|
81
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "6px 10px", fontSize: 12, opacity: 0.7 }, children: columnsLabel }),
|
|
82
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
83
|
-
Menu.Menu.RadioItem,
|
|
84
|
-
{
|
|
85
|
-
name: presetRadioName,
|
|
86
|
-
value: "all",
|
|
87
|
-
checked: isAllActive,
|
|
88
|
-
label: allPresetLabel,
|
|
89
|
-
onValueChange: () => {
|
|
90
|
-
setVisibleIds(
|
|
91
|
-
allPresetIds.filter((id) => typeof id === "string" && Boolean(id))
|
|
92
|
-
);
|
|
93
|
-
close == null ? void 0 : close();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
),
|
|
97
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
98
|
-
Menu.Menu.RadioItem,
|
|
99
|
-
{
|
|
100
|
-
name: presetRadioName,
|
|
101
|
-
value: "standard",
|
|
102
|
-
checked: isStandardActive,
|
|
103
|
-
label: standardPresetLabel,
|
|
104
|
-
onValueChange: () => {
|
|
105
|
-
setVisibleIds(
|
|
106
|
-
standardPresetIds.filter(
|
|
107
|
-
(id) => typeof id === "string" && Boolean(id)
|
|
108
|
-
)
|
|
109
|
-
);
|
|
110
|
-
close == null ? void 0 : close();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
),
|
|
114
|
-
/* @__PURE__ */ jsxRuntime.jsx(Menu.Menu.Separator, {}),
|
|
115
|
-
hideableColumns.map((col) => {
|
|
116
|
-
const isVisible = col.id ? visibleSet.has(col.id) : false;
|
|
117
|
-
const disableUncheckingLast = isVisible && visibleCount <= 1;
|
|
118
|
-
const label = col.header;
|
|
119
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
120
|
-
Menu.Menu.CheckItem,
|
|
121
|
-
{
|
|
122
|
-
checked: isVisible,
|
|
123
|
-
disabled: disableUncheckingLast,
|
|
124
|
-
label,
|
|
125
|
-
onCheckedChange: (nextChecked) => {
|
|
126
|
-
if (disableUncheckingLast) return;
|
|
127
|
-
toggleColumn(col.id, nextChecked);
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
col.id
|
|
131
|
-
);
|
|
132
|
-
})
|
|
133
|
-
] }) : null
|
|
134
|
-
] })
|
|
140
|
+
children: (close) => /* @__PURE__ */ jsxRuntime.jsx(Menu.Menu, { children: /* @__PURE__ */ jsxRuntime.jsx(TableSettingsMenuSection, { ...sectionProps, close }) })
|
|
135
141
|
}
|
|
136
142
|
);
|
|
137
143
|
}
|
|
138
144
|
|
|
139
145
|
exports.TableSettings = TableSettings;
|
|
146
|
+
exports.TableSettingsMenuSection = TableSettingsMenuSection;
|
|
@@ -2,7 +2,7 @@ import { ColumnDef } from '@tanstack/react-table';
|
|
|
2
2
|
import type { JSX, ReactNode } from 'react';
|
|
3
3
|
import { ViewMode } from '../../../../hooks/useTableSettings';
|
|
4
4
|
import { ButtonSize } from '../../../button/Button';
|
|
5
|
-
interface
|
|
5
|
+
export interface TableSettingsMenuSectionProps<T extends Record<string, any>> {
|
|
6
6
|
handleChangeViewMode: (mode: ViewMode) => void;
|
|
7
7
|
viewMode: ViewMode;
|
|
8
8
|
columns?: ColumnDef<T>[];
|
|
@@ -11,8 +11,17 @@ interface TableSettingsProps<T extends Record<string, any>> {
|
|
|
11
11
|
columnsLabel?: string;
|
|
12
12
|
allPresetLabel?: string;
|
|
13
13
|
standardPresetLabel?: string;
|
|
14
|
-
buttonSize?: ButtonSize;
|
|
15
14
|
additionalSettings?: (close?: () => void) => ReactNode;
|
|
15
|
+
/** Called after an action closes the surrounding menu/popover, if any. */
|
|
16
|
+
close?: () => void;
|
|
17
|
+
}
|
|
18
|
+
export interface TableSettingsProps<T extends Record<string, any>> extends Omit<TableSettingsMenuSectionProps<T>, 'close'> {
|
|
19
|
+
buttonSize?: ButtonSize;
|
|
16
20
|
}
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The table settings menu items (view mode toggle + column visibility), with
|
|
23
|
+
* no `Menu`/`Popover`/trigger wrapper. Use this to fold table settings into
|
|
24
|
+
* another menu; use `TableSettings` for the standalone button + popover.
|
|
25
|
+
*/
|
|
26
|
+
export declare function TableSettingsMenuSection<T extends Record<string, any>>({ viewMode, handleChangeViewMode, columns, visibleColumnIds, onVisibleColumnIdsChange, columnsLabel, allPresetLabel, standardPresetLabel, additionalSettings, close, }: TableSettingsMenuSectionProps<T>): JSX.Element;
|
|
27
|
+
export declare function TableSettings<T extends Record<string, any>>({ buttonSize, ...sectionProps }: TableSettingsProps<T>): JSX.Element;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { ListChevronsUpDown, Settings } from 'lucide-react';
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import { Button } from '../../../button/Button';
|
|
6
6
|
import { Menu } from '../../../menu/Menu';
|
|
7
7
|
import { Popover } from '../../../popover/Popover';
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function TableSettingsMenuSection({
|
|
10
10
|
viewMode,
|
|
11
11
|
handleChangeViewMode,
|
|
12
12
|
columns = [],
|
|
@@ -15,12 +15,12 @@ function TableSettings({
|
|
|
15
15
|
columnsLabel = "Kolonner",
|
|
16
16
|
allPresetLabel = "Alle",
|
|
17
17
|
standardPresetLabel = "Standard",
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
additionalSettings,
|
|
19
|
+
close
|
|
20
20
|
}) {
|
|
21
|
-
const handleViewModeChange = (mode,
|
|
21
|
+
const handleViewModeChange = (mode, close2) => {
|
|
22
22
|
handleChangeViewMode(mode === "wrapped" ? "compact" : "wrapped");
|
|
23
|
-
|
|
23
|
+
close2 == null ? void 0 : close2();
|
|
24
24
|
};
|
|
25
25
|
const hideableColumns = useMemo(() => columns.filter((c) => c.enableHiding !== false), [columns]);
|
|
26
26
|
const allPresetIds = useMemo(() => hideableColumns.map((c) => c.id), [hideableColumns]);
|
|
@@ -61,6 +61,73 @@ function TableSettings({
|
|
|
61
61
|
return hideableColumns.every((c) => c.id && visibleSet.has(c.id) === std.has(c.id));
|
|
62
62
|
}, [hideableColumns, visibleSet, standardPresetIds]);
|
|
63
63
|
const presetRadioName = "table-columns-preset";
|
|
64
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
65
|
+
additionalSettings == null ? void 0 : additionalSettings(close),
|
|
66
|
+
/* @__PURE__ */ jsx(Menu.Item, { active: viewMode === "wrapped", children: /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => handleViewModeChange(viewMode, close), children: [
|
|
67
|
+
/* @__PURE__ */ jsx(ListChevronsUpDown, {}),
|
|
68
|
+
"Ombryd tekst"
|
|
69
|
+
] }) }),
|
|
70
|
+
hideableColumns.length > 0 && onVisibleColumnIdsChange ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
71
|
+
/* @__PURE__ */ jsx(Menu.Separator, {}),
|
|
72
|
+
/* @__PURE__ */ jsx("div", { style: { padding: "6px 10px", fontSize: 12, opacity: 0.7 }, children: columnsLabel }),
|
|
73
|
+
/* @__PURE__ */ jsx(
|
|
74
|
+
Menu.RadioItem,
|
|
75
|
+
{
|
|
76
|
+
name: presetRadioName,
|
|
77
|
+
value: "all",
|
|
78
|
+
checked: isAllActive,
|
|
79
|
+
label: allPresetLabel,
|
|
80
|
+
onValueChange: () => {
|
|
81
|
+
setVisibleIds(
|
|
82
|
+
allPresetIds.filter((id) => typeof id === "string" && Boolean(id))
|
|
83
|
+
);
|
|
84
|
+
close == null ? void 0 : close();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
/* @__PURE__ */ jsx(
|
|
89
|
+
Menu.RadioItem,
|
|
90
|
+
{
|
|
91
|
+
name: presetRadioName,
|
|
92
|
+
value: "standard",
|
|
93
|
+
checked: isStandardActive,
|
|
94
|
+
label: standardPresetLabel,
|
|
95
|
+
onValueChange: () => {
|
|
96
|
+
setVisibleIds(
|
|
97
|
+
standardPresetIds.filter(
|
|
98
|
+
(id) => typeof id === "string" && Boolean(id)
|
|
99
|
+
)
|
|
100
|
+
);
|
|
101
|
+
close == null ? void 0 : close();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
/* @__PURE__ */ jsx(Menu.Separator, {}),
|
|
106
|
+
hideableColumns.map((col) => {
|
|
107
|
+
const isVisible = col.id ? visibleSet.has(col.id) : false;
|
|
108
|
+
const disableUncheckingLast = isVisible && visibleCount <= 1;
|
|
109
|
+
const label = col.header;
|
|
110
|
+
return /* @__PURE__ */ jsx(
|
|
111
|
+
Menu.CheckItem,
|
|
112
|
+
{
|
|
113
|
+
checked: isVisible,
|
|
114
|
+
disabled: disableUncheckingLast,
|
|
115
|
+
label,
|
|
116
|
+
onCheckedChange: (nextChecked) => {
|
|
117
|
+
if (disableUncheckingLast) return;
|
|
118
|
+
toggleColumn(col.id, nextChecked);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
col.id
|
|
122
|
+
);
|
|
123
|
+
})
|
|
124
|
+
] }) : null
|
|
125
|
+
] });
|
|
126
|
+
}
|
|
127
|
+
function TableSettings({
|
|
128
|
+
buttonSize = "sm",
|
|
129
|
+
...sectionProps
|
|
130
|
+
}) {
|
|
64
131
|
return /* @__PURE__ */ jsx(
|
|
65
132
|
Popover,
|
|
66
133
|
{
|
|
@@ -68,70 +135,9 @@ function TableSettings({
|
|
|
68
135
|
/* @__PURE__ */ jsx(Settings, {}),
|
|
69
136
|
icon
|
|
70
137
|
] }),
|
|
71
|
-
children: (close) => /* @__PURE__ */
|
|
72
|
-
additionalSettings == null ? void 0 : additionalSettings(close),
|
|
73
|
-
/* @__PURE__ */ jsx(Menu.Item, { active: viewMode === "wrapped", children: /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => handleViewModeChange(viewMode, close), children: [
|
|
74
|
-
/* @__PURE__ */ jsx(ListChevronsUpDown, {}),
|
|
75
|
-
"Ombryd tekst"
|
|
76
|
-
] }) }),
|
|
77
|
-
hideableColumns.length > 0 && onVisibleColumnIdsChange ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
78
|
-
/* @__PURE__ */ jsx(Menu.Separator, {}),
|
|
79
|
-
/* @__PURE__ */ jsx("div", { style: { padding: "6px 10px", fontSize: 12, opacity: 0.7 }, children: columnsLabel }),
|
|
80
|
-
/* @__PURE__ */ jsx(
|
|
81
|
-
Menu.RadioItem,
|
|
82
|
-
{
|
|
83
|
-
name: presetRadioName,
|
|
84
|
-
value: "all",
|
|
85
|
-
checked: isAllActive,
|
|
86
|
-
label: allPresetLabel,
|
|
87
|
-
onValueChange: () => {
|
|
88
|
-
setVisibleIds(
|
|
89
|
-
allPresetIds.filter((id) => typeof id === "string" && Boolean(id))
|
|
90
|
-
);
|
|
91
|
-
close == null ? void 0 : close();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
),
|
|
95
|
-
/* @__PURE__ */ jsx(
|
|
96
|
-
Menu.RadioItem,
|
|
97
|
-
{
|
|
98
|
-
name: presetRadioName,
|
|
99
|
-
value: "standard",
|
|
100
|
-
checked: isStandardActive,
|
|
101
|
-
label: standardPresetLabel,
|
|
102
|
-
onValueChange: () => {
|
|
103
|
-
setVisibleIds(
|
|
104
|
-
standardPresetIds.filter(
|
|
105
|
-
(id) => typeof id === "string" && Boolean(id)
|
|
106
|
-
)
|
|
107
|
-
);
|
|
108
|
-
close == null ? void 0 : close();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
),
|
|
112
|
-
/* @__PURE__ */ jsx(Menu.Separator, {}),
|
|
113
|
-
hideableColumns.map((col) => {
|
|
114
|
-
const isVisible = col.id ? visibleSet.has(col.id) : false;
|
|
115
|
-
const disableUncheckingLast = isVisible && visibleCount <= 1;
|
|
116
|
-
const label = col.header;
|
|
117
|
-
return /* @__PURE__ */ jsx(
|
|
118
|
-
Menu.CheckItem,
|
|
119
|
-
{
|
|
120
|
-
checked: isVisible,
|
|
121
|
-
disabled: disableUncheckingLast,
|
|
122
|
-
label,
|
|
123
|
-
onCheckedChange: (nextChecked) => {
|
|
124
|
-
if (disableUncheckingLast) return;
|
|
125
|
-
toggleColumn(col.id, nextChecked);
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
col.id
|
|
129
|
-
);
|
|
130
|
-
})
|
|
131
|
-
] }) : null
|
|
132
|
-
] })
|
|
138
|
+
children: (close) => /* @__PURE__ */ jsx(Menu, { children: /* @__PURE__ */ jsx(TableSettingsMenuSection, { ...sectionProps, close }) })
|
|
133
139
|
}
|
|
134
140
|
);
|
|
135
141
|
}
|
|
136
142
|
|
|
137
|
-
export { TableSettings };
|
|
143
|
+
export { TableSettings, TableSettingsMenuSection };
|
|
@@ -32,14 +32,23 @@
|
|
|
32
32
|
|
|
33
33
|
.tabButtons {
|
|
34
34
|
display: flex;
|
|
35
|
-
flex-wrap:
|
|
35
|
+
flex-wrap: nowrap;
|
|
36
|
+
overflow-x: auto;
|
|
37
|
+
/* Explicit, not just tidy: leaving this "visible" would compute to "auto"
|
|
38
|
+
too (overflow-x auto + overflow-y visible isn't a valid combination per
|
|
39
|
+
spec), silently turning on a vertical scrollbar/clip that's never needed
|
|
40
|
+
here. */
|
|
41
|
+
overflow-y: hidden;
|
|
36
42
|
min-width: 0;
|
|
37
43
|
}
|
|
38
44
|
|
|
39
|
-
/* Extra content next to the tab buttons, pushed into the free space on the
|
|
45
|
+
/* Extra content next to the tab buttons, pushed into the free space on the
|
|
46
|
+
right. It takes the space it needs — .tabButtons scrolls instead of
|
|
47
|
+
squeezing it. */
|
|
40
48
|
.tabListAddition {
|
|
41
49
|
display: flex;
|
|
42
50
|
align-items: center;
|
|
51
|
+
flex-shrink: 0;
|
|
43
52
|
gap: var(--spacing-sm);
|
|
44
53
|
margin-inline-start: auto;
|
|
45
54
|
padding-inline-start: var(--spacing-md);
|
|
@@ -49,6 +58,7 @@
|
|
|
49
58
|
.tab {
|
|
50
59
|
display: flex;
|
|
51
60
|
align-items: stretch;
|
|
61
|
+
flex-shrink: 0;
|
|
52
62
|
border-radius: 0;
|
|
53
63
|
border-block-end: 2px solid var(--color-border-default);
|
|
54
64
|
}
|
|
@@ -134,6 +144,7 @@
|
|
|
134
144
|
align-items: center;
|
|
135
145
|
justify-content: center;
|
|
136
146
|
align-self: stretch;
|
|
147
|
+
flex-shrink: 0;
|
|
137
148
|
|
|
138
149
|
color: var(--color-fg-muted);
|
|
139
150
|
background: none;
|
package/dist/index.cjs
CHANGED
|
@@ -18,6 +18,7 @@ var SkeletonLoader = require('./components/skeleton-loader/SkeletonLoader');
|
|
|
18
18
|
var Page = require('./components/page/Page');
|
|
19
19
|
var Breadcrumbs = require('./components/breadcrumbs/Breadcrumbs');
|
|
20
20
|
var Circle = require('./components/circle/Circle');
|
|
21
|
+
var Badge = require('./components/badge/Badge');
|
|
21
22
|
var chartColors = require('./constants/chart-colors');
|
|
22
23
|
var chartColors_types = require('./constants/chart-colors.types');
|
|
23
24
|
var severity_types = require('./constants/severity.types');
|
|
@@ -159,6 +160,12 @@ Object.keys(Circle).forEach(function (k) {
|
|
|
159
160
|
get: function () { return Circle[k]; }
|
|
160
161
|
});
|
|
161
162
|
});
|
|
163
|
+
Object.keys(Badge).forEach(function (k) {
|
|
164
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: function () { return Badge[k]; }
|
|
167
|
+
});
|
|
168
|
+
});
|
|
162
169
|
Object.keys(chartColors).forEach(function (k) {
|
|
163
170
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
164
171
|
enumerable: true,
|
package/dist/index.css
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
@import './components/app-header/AppHeader.module.css';
|
|
7
7
|
@import './components/attribute-chip/AttributeChip.module.css';
|
|
8
8
|
@import './components/avatar/Avatar.module.css';
|
|
9
|
+
@import './components/badge/Badge.module.css';
|
|
9
10
|
@import './components/breadcrumbs/Breadcrumbs.module.css';
|
|
10
11
|
@import './components/button-select/ButtonSelect.module.css';
|
|
11
12
|
@import './components/button/Button.module.css';
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from './components/skeleton-loader/SkeletonLoader';
|
|
|
16
16
|
export * from './components/page/Page';
|
|
17
17
|
export * from './components/breadcrumbs/Breadcrumbs';
|
|
18
18
|
export * from './components/circle/Circle';
|
|
19
|
+
export * from './components/badge/Badge';
|
|
19
20
|
export * from './constants/chart-colors';
|
|
20
21
|
export * from './constants/chart-colors.types';
|
|
21
22
|
export * from './constants/severity.types';
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export * from './components/skeleton-loader/SkeletonLoader';
|
|
|
16
16
|
export * from './components/page/Page';
|
|
17
17
|
export * from './components/breadcrumbs/Breadcrumbs';
|
|
18
18
|
export * from './components/circle/Circle';
|
|
19
|
+
export * from './components/badge/Badge';
|
|
19
20
|
export * from './constants/chart-colors';
|
|
20
21
|
export * from './constants/chart-colors.types';
|
|
21
22
|
export * from './constants/severity.types';
|
package/dist/styles/styles.css
CHANGED
|
@@ -303,8 +303,15 @@ tr.dbc-table--hover:hover td:last-child {
|
|
|
303
303
|
Scrollbars
|
|
304
304
|
========================================================================== */
|
|
305
305
|
|
|
306
|
+
/* Firefox equivalent of the thin, muted webkit scrollbar below. */
|
|
307
|
+
* {
|
|
308
|
+
scrollbar-width: thin;
|
|
309
|
+
scrollbar-color: var(--color-border-strong) transparent;
|
|
310
|
+
}
|
|
311
|
+
|
|
306
312
|
::-webkit-scrollbar {
|
|
307
313
|
width: 10px;
|
|
314
|
+
height: 10px;
|
|
308
315
|
}
|
|
309
316
|
|
|
310
317
|
::-webkit-scrollbar-track {
|
package/dist/styles.css
CHANGED
|
@@ -303,8 +303,15 @@ tr.dbc-table--hover:hover td:last-child {
|
|
|
303
303
|
Scrollbars
|
|
304
304
|
========================================================================== */
|
|
305
305
|
|
|
306
|
+
/* Firefox equivalent of the thin, muted webkit scrollbar below. */
|
|
307
|
+
* {
|
|
308
|
+
scrollbar-width: thin;
|
|
309
|
+
scrollbar-color: var(--color-border-strong) transparent;
|
|
310
|
+
}
|
|
311
|
+
|
|
306
312
|
::-webkit-scrollbar {
|
|
307
313
|
width: 10px;
|
|
314
|
+
height: 10px;
|
|
308
315
|
}
|
|
309
316
|
|
|
310
317
|
::-webkit-scrollbar-track {
|