@dbcdk/react-components 0.0.195 → 0.0.196
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 +78 -10
- package/dist/client.cjs +486 -614
- package/dist/client.d.ts +176 -102
- package/dist/client.js +102 -102
- package/dist/components/color-scheme-button/ColorSchemeButton.cjs +7 -4
- package/dist/components/color-scheme-button/ColorSchemeButton.d.ts +7 -3
- package/dist/components/color-scheme-button/ColorSchemeButton.js +7 -4
- package/dist/components/forms/text-area/Textarea.cjs +2 -1
- package/dist/components/forms/text-area/Textarea.d.ts +1 -0
- package/dist/components/forms/text-area/Textarea.js +2 -1
- package/dist/components/highlighted-text/HighlightedText.cjs +6 -3
- package/dist/components/highlighted-text/HighlightedText.js +7 -4
- package/dist/components/json-viewer/JsonNode.cjs +27 -67
- package/dist/components/json-viewer/JsonNode.d.ts +10 -0
- package/dist/components/json-viewer/JsonNode.js +28 -68
- package/dist/components/json-viewer/JsonRow.cjs +85 -0
- package/dist/components/json-viewer/JsonRow.d.ts +5 -0
- package/dist/components/json-viewer/JsonRow.js +79 -0
- package/dist/components/json-viewer/JsonViewer.cjs +36 -253
- package/dist/components/json-viewer/JsonViewer.js +37 -250
- package/dist/components/json-viewer/JsonViewerShell.cjs +208 -0
- package/dist/components/json-viewer/JsonViewerShell.d.ts +25 -0
- package/dist/components/json-viewer/JsonViewerShell.js +202 -0
- package/dist/components/json-viewer/TanstackJsonViewer.cjs +127 -0
- package/dist/components/json-viewer/TanstackJsonViewer.d.ts +17 -0
- package/dist/components/json-viewer/TanstackJsonViewer.js +121 -0
- package/dist/components/json-viewer/types.d.ts +27 -0
- package/dist/components/json-viewer/useJsonViewerState.cjs +111 -0
- package/dist/components/json-viewer/useJsonViewerState.d.ts +42 -0
- package/dist/components/json-viewer/useJsonViewerState.js +108 -0
- package/dist/components/json-viewer/utils.cjs +36 -0
- package/dist/components/json-viewer/utils.d.ts +21 -1
- package/dist/components/json-viewer/utils.js +35 -1
- package/dist/components/lightbox/Lightbox.cjs +2 -2
- package/dist/components/lightbox/Lightbox.d.ts +1 -1
- package/dist/components/lightbox/Lightbox.js +1 -1
- package/dist/components/menu/Menu.cjs +3 -23
- package/dist/components/menu/Menu.js +3 -23
- package/dist/components/menu/Menu.module.css +4 -3
- package/dist/components/metric-tile/MetricTile.cjs +3 -2
- package/dist/components/metric-tile/MetricTile.js +2 -1
- package/dist/components/overlay/tooltip/Tooltip.cjs +7 -2
- package/dist/components/overlay/tooltip/Tooltip.d.ts +7 -1
- package/dist/components/overlay/tooltip/Tooltip.js +7 -2
- package/dist/components/overlay/tooltip/useTooltipTrigger.cjs +7 -1
- package/dist/components/overlay/tooltip/useTooltipTrigger.js +7 -1
- package/dist/components/page-layout/PageLayout.module.css +1 -1
- package/dist/components/table/Table.cjs +45 -16
- package/dist/components/table/Table.d.ts +1 -1
- package/dist/components/table/Table.js +47 -18
- package/dist/components/table/Table.module.css +135 -7
- package/dist/components/table/Table.types.d.ts +47 -1
- package/dist/components/table/TanstackTable.cjs +30 -2
- package/dist/components/table/TanstackTable.js +31 -3
- package/dist/components/table/components/TableBody.d.ts +1 -2
- package/dist/components/table/components/TableHeader.cjs +6 -4
- package/dist/components/table/components/TableHeader.d.ts +2 -1
- package/dist/components/table/components/TableHeader.js +6 -4
- package/dist/components/table/components/TableHeaderCell.cjs +5 -4
- package/dist/components/table/components/TableHeaderCell.d.ts +3 -1
- package/dist/components/table/components/TableHeaderCell.js +5 -4
- package/dist/components/table/components/TableRow.cjs +1 -1
- package/dist/components/table/components/TableRow.d.ts +1 -2
- package/dist/components/table/components/TableRow.js +1 -1
- package/dist/components/table/components/TableSkeletonBody.cjs +30 -0
- package/dist/components/table/components/TableSkeletonBody.d.ts +13 -0
- package/dist/components/table/components/TableSkeletonBody.js +24 -0
- package/dist/components/table/components/table-settings/TableHeaderSettings.cjs +28 -0
- package/dist/components/table/components/table-settings/TableHeaderSettings.d.ts +11 -0
- package/dist/components/table/components/table-settings/TableHeaderSettings.js +26 -0
- package/dist/components/table/components/table-settings/TableSettings.cjs +82 -32
- package/dist/components/table/components/table-settings/TableSettings.d.ts +14 -6
- package/dist/components/table/components/table-settings/TableSettings.js +84 -34
- package/dist/components/table/table.utils.cjs +2 -0
- package/dist/components/table/table.utils.d.ts +6 -0
- package/dist/components/table/table.utils.js +2 -1
- package/dist/components/table/tableSettings.utils.cjs +29 -0
- package/dist/components/table/tableSettings.utils.d.ts +9 -0
- package/dist/components/table/tableSettings.utils.js +24 -0
- package/dist/components/table/tanstackTable.utils.cjs +18 -0
- package/dist/components/table/tanstackTable.utils.js +19 -1
- package/dist/components/theme-button/ThemeButton.cjs +9 -4
- package/dist/components/theme-button/ThemeButton.d.ts +4 -2
- package/dist/components/theme-button/ThemeButton.js +9 -4
- package/dist/components/theme-script/ThemeScript.cjs +10 -4
- package/dist/components/theme-script/ThemeScript.d.ts +9 -1
- package/dist/components/theme-script/ThemeScript.js +10 -4
- package/dist/hooks/useColorScheme.cjs +18 -14
- package/dist/hooks/useColorScheme.d.ts +11 -1
- package/dist/hooks/useColorScheme.js +19 -15
- package/dist/hooks/useGetActiveTheme.cjs +4 -3
- package/dist/hooks/useGetActiveTheme.d.ts +7 -1
- package/dist/hooks/useGetActiveTheme.js +4 -3
- package/dist/hooks/useTableData.cjs +11 -7
- package/dist/hooks/useTableData.d.ts +8 -2
- package/dist/hooks/useTableData.js +11 -7
- package/dist/hooks/useTableSettings.cjs +25 -9
- package/dist/hooks/useTableSettings.d.ts +9 -6
- package/dist/hooks/useTableSettings.js +25 -9
- package/dist/hooks/useTheme.d.ts +6 -0
- package/dist/styles/styles.css +7 -3
- package/dist/styles/themes/dbc/colors.css +1 -1
- package/dist/styles.css +1 -476
- package/dist/tanstack-virtual.cjs +12 -0
- package/dist/tanstack-virtual.d.ts +1 -0
- package/dist/tanstack-virtual.js +1 -0
- package/package.json +13 -1
|
@@ -167,13 +167,7 @@ const MenuCheckItem = React.forwardRef(
|
|
|
167
167
|
className,
|
|
168
168
|
...liProps
|
|
169
169
|
}, ref) => {
|
|
170
|
-
const
|
|
171
|
-
const interactiveClass = [
|
|
172
|
-
styles.interactiveChild,
|
|
173
|
-
styles.item,
|
|
174
|
-
active ? styles.active : "",
|
|
175
|
-
isSelected ? styles.selected : ""
|
|
176
|
-
].filter(Boolean).join(" ");
|
|
170
|
+
const interactiveClass = [styles.interactiveChild, styles.item, active ? styles.active : ""].filter(Boolean).join(" ");
|
|
177
171
|
return /* @__PURE__ */ jsx(
|
|
178
172
|
"li",
|
|
179
173
|
{
|
|
@@ -187,7 +181,6 @@ const MenuCheckItem = React.forwardRef(
|
|
|
187
181
|
ref: interactiveRef,
|
|
188
182
|
role: interactiveProps == null ? void 0 : interactiveProps.role,
|
|
189
183
|
tabIndex: -1,
|
|
190
|
-
"aria-selected": isSelected || void 0,
|
|
191
184
|
"aria-disabled": disabled || void 0,
|
|
192
185
|
className: interactiveClass,
|
|
193
186
|
...interactiveProps,
|
|
@@ -240,12 +233,7 @@ const MenuRadioItem = React.forwardRef(
|
|
|
240
233
|
...liProps
|
|
241
234
|
}, ref) => {
|
|
242
235
|
var _a, _b;
|
|
243
|
-
const interactiveClass = [
|
|
244
|
-
styles.interactiveChild,
|
|
245
|
-
styles.item,
|
|
246
|
-
active ? styles.active : "",
|
|
247
|
-
checked ? styles.selected : ""
|
|
248
|
-
].filter(Boolean).join(" ");
|
|
236
|
+
const interactiveClass = [styles.interactiveChild, styles.item, active ? styles.active : ""].filter(Boolean).join(" ");
|
|
249
237
|
return /* @__PURE__ */ jsx(
|
|
250
238
|
"li",
|
|
251
239
|
{
|
|
@@ -260,7 +248,6 @@ const MenuRadioItem = React.forwardRef(
|
|
|
260
248
|
role: (_a = interactiveProps == null ? void 0 : interactiveProps.role) != null ? _a : "menuitemradio",
|
|
261
249
|
tabIndex: (_b = interactiveProps == null ? void 0 : interactiveProps.tabIndex) != null ? _b : 0,
|
|
262
250
|
"aria-checked": checked || void 0,
|
|
263
|
-
"aria-selected": checked || void 0,
|
|
264
251
|
"aria-disabled": disabled || void 0,
|
|
265
252
|
className: interactiveClass,
|
|
266
253
|
...interactiveProps,
|
|
@@ -318,13 +305,7 @@ const MenuSwitchItem = React.forwardRef(
|
|
|
318
305
|
className,
|
|
319
306
|
...liProps
|
|
320
307
|
}, ref) => {
|
|
321
|
-
const
|
|
322
|
-
const interactiveClass = [
|
|
323
|
-
styles.interactiveChild,
|
|
324
|
-
styles.item,
|
|
325
|
-
active ? styles.active : "",
|
|
326
|
-
isSelected ? styles.selected : ""
|
|
327
|
-
].filter(Boolean).join(" ");
|
|
308
|
+
const interactiveClass = [styles.interactiveChild, styles.item, active ? styles.active : ""].filter(Boolean).join(" ");
|
|
328
309
|
return /* @__PURE__ */ jsx(
|
|
329
310
|
"li",
|
|
330
311
|
{
|
|
@@ -338,7 +319,6 @@ const MenuSwitchItem = React.forwardRef(
|
|
|
338
319
|
ref: interactiveRef,
|
|
339
320
|
role: interactiveProps == null ? void 0 : interactiveProps.role,
|
|
340
321
|
tabIndex: -1,
|
|
341
|
-
"aria-selected": isSelected || void 0,
|
|
342
322
|
"aria-disabled": disabled || void 0,
|
|
343
323
|
className: interactiveClass,
|
|
344
324
|
...interactiveProps,
|
|
@@ -184,9 +184,10 @@
|
|
|
184
184
|
background-color: var(--color-bg-selected-hover);
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
/* Checked (legacy support; kept in case any interactive element still uses aria-checked)
|
|
188
|
-
.
|
|
189
|
-
|
|
187
|
+
/* Checked (legacy support; kept in case any interactive element still uses aria-checked).
|
|
188
|
+
Menu.CheckItem/RadioItem/SwitchItem wrappers (.interactiveChild) are excluded on purpose:
|
|
189
|
+
their control already shows the checked state. */
|
|
190
|
+
.interactive[aria-checked='true'] {
|
|
190
191
|
background-color: var(--color-bg-selected);
|
|
191
192
|
color: var(--color-fg-default);
|
|
192
193
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
'use strict';
|
|
2
3
|
|
|
3
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
5
|
var react = require('react');
|
|
5
|
-
var
|
|
6
|
+
var Tooltip = require('../../components/overlay/tooltip/Tooltip');
|
|
6
7
|
var styles = require('./MetricTile.module.css');
|
|
7
8
|
|
|
8
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -88,7 +89,7 @@ const MetricTileBase = ({
|
|
|
88
89
|
onClick == null ? void 0 : onClick();
|
|
89
90
|
}
|
|
90
91
|
};
|
|
91
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
92
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Tooltip.Tooltip, { content: tooltip, placement: "bottom", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
92
93
|
"span",
|
|
93
94
|
{
|
|
94
95
|
className: styles__default.default.tile,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
3
|
import { Children, isValidElement } from 'react';
|
|
3
|
-
import { Tooltip } from '../../
|
|
4
|
+
import { Tooltip } from '../../components/overlay/tooltip/Tooltip';
|
|
4
5
|
import styles from './MetricTile.module.css';
|
|
5
6
|
|
|
6
7
|
function toSize(v) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
'use strict';
|
|
2
3
|
|
|
3
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -26,7 +27,9 @@ function Tooltip({
|
|
|
26
27
|
open,
|
|
27
28
|
offset = 8,
|
|
28
29
|
delayOpenMs,
|
|
29
|
-
delayCloseMs
|
|
30
|
+
delayCloseMs,
|
|
31
|
+
focusOpenMode,
|
|
32
|
+
closeOnPointerDown
|
|
30
33
|
}) {
|
|
31
34
|
var _a;
|
|
32
35
|
const { triggerProps } = useTooltipTrigger.useTooltipTrigger({
|
|
@@ -35,7 +38,9 @@ function Tooltip({
|
|
|
35
38
|
offset,
|
|
36
39
|
open,
|
|
37
40
|
delayOpenMs,
|
|
38
|
-
delayCloseMs
|
|
41
|
+
delayCloseMs,
|
|
42
|
+
focusOpenMode,
|
|
43
|
+
closeOnPointerDown
|
|
39
44
|
});
|
|
40
45
|
if (!content) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
41
46
|
const child = children;
|
|
@@ -8,5 +8,11 @@ export interface TooltipProps {
|
|
|
8
8
|
offset?: number;
|
|
9
9
|
delayOpenMs?: number;
|
|
10
10
|
delayCloseMs?: number;
|
|
11
|
+
/**
|
|
12
|
+
* When the tooltip should open on focus: only for keyboard focus (default),
|
|
13
|
+
* for any focus (e.g. clicking into an input), or never.
|
|
14
|
+
*/
|
|
15
|
+
focusOpenMode?: 'focus-visible' | 'any' | 'off';
|
|
16
|
+
closeOnPointerDown?: boolean;
|
|
11
17
|
}
|
|
12
|
-
export declare function Tooltip({ children, content, placement, open, offset, delayOpenMs, delayCloseMs, }: TooltipProps): ReactElement;
|
|
18
|
+
export declare function Tooltip({ children, content, placement, open, offset, delayOpenMs, delayCloseMs, focusOpenMode, closeOnPointerDown, }: TooltipProps): ReactElement;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
3
|
import { cloneElement } from 'react';
|
|
3
4
|
import { useTooltipTrigger } from './useTooltipTrigger';
|
|
@@ -24,7 +25,9 @@ function Tooltip({
|
|
|
24
25
|
open,
|
|
25
26
|
offset = 8,
|
|
26
27
|
delayOpenMs,
|
|
27
|
-
delayCloseMs
|
|
28
|
+
delayCloseMs,
|
|
29
|
+
focusOpenMode,
|
|
30
|
+
closeOnPointerDown
|
|
28
31
|
}) {
|
|
29
32
|
var _a;
|
|
30
33
|
const { triggerProps } = useTooltipTrigger({
|
|
@@ -33,7 +36,9 @@ function Tooltip({
|
|
|
33
36
|
offset,
|
|
34
37
|
open,
|
|
35
38
|
delayOpenMs,
|
|
36
|
-
delayCloseMs
|
|
39
|
+
delayCloseMs,
|
|
40
|
+
focusOpenMode,
|
|
41
|
+
closeOnPointerDown
|
|
37
42
|
});
|
|
38
43
|
if (!content) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
39
44
|
const child = children;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
'use strict';
|
|
2
3
|
|
|
3
4
|
var react = require('react');
|
|
@@ -24,6 +25,7 @@ function useTooltipTrigger(options) {
|
|
|
24
25
|
const isOpen = isControlled ? !!open : uncontrolledOpen;
|
|
25
26
|
const openTimer = react.useRef(null);
|
|
26
27
|
const closeTimer = react.useRef(null);
|
|
28
|
+
const openedByFocusRef = react.useRef(false);
|
|
27
29
|
const clearTimers = () => {
|
|
28
30
|
if (openTimer.current) window.clearTimeout(openTimer.current);
|
|
29
31
|
if (closeTimer.current) window.clearTimeout(closeTimer.current);
|
|
@@ -79,6 +81,7 @@ function useTooltipTrigger(options) {
|
|
|
79
81
|
const onPointerLeave = () => {
|
|
80
82
|
clearTimers();
|
|
81
83
|
if (isControlled) return;
|
|
84
|
+
if (openedByFocusRef.current) return;
|
|
82
85
|
closeTimer.current = window.setTimeout(() => setOpen(false), delayCloseMs);
|
|
83
86
|
};
|
|
84
87
|
const onPointerDown = () => {
|
|
@@ -89,12 +92,15 @@ function useTooltipTrigger(options) {
|
|
|
89
92
|
clearTimers();
|
|
90
93
|
if (focusOpenMode === "off") return;
|
|
91
94
|
const shouldOpen = focusOpenMode === "any" || e.currentTarget.matches(":focus-visible");
|
|
92
|
-
if (!
|
|
95
|
+
if (!shouldOpen) return;
|
|
96
|
+
openedByFocusRef.current = true;
|
|
97
|
+
if (!isControlled) {
|
|
93
98
|
openTimer.current = window.setTimeout(() => setOpen(true), delayOpenMs);
|
|
94
99
|
}
|
|
95
100
|
};
|
|
96
101
|
const onBlur = () => {
|
|
97
102
|
clearTimers();
|
|
103
|
+
openedByFocusRef.current = false;
|
|
98
104
|
if (!isControlled) setOpen(false);
|
|
99
105
|
};
|
|
100
106
|
return {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { useContext, useId, useRef, useState, useCallback, useEffect } from 'react';
|
|
2
3
|
import { TooltipContext } from './TooltipProvider';
|
|
3
4
|
|
|
@@ -22,6 +23,7 @@ function useTooltipTrigger(options) {
|
|
|
22
23
|
const isOpen = isControlled ? !!open : uncontrolledOpen;
|
|
23
24
|
const openTimer = useRef(null);
|
|
24
25
|
const closeTimer = useRef(null);
|
|
26
|
+
const openedByFocusRef = useRef(false);
|
|
25
27
|
const clearTimers = () => {
|
|
26
28
|
if (openTimer.current) window.clearTimeout(openTimer.current);
|
|
27
29
|
if (closeTimer.current) window.clearTimeout(closeTimer.current);
|
|
@@ -77,6 +79,7 @@ function useTooltipTrigger(options) {
|
|
|
77
79
|
const onPointerLeave = () => {
|
|
78
80
|
clearTimers();
|
|
79
81
|
if (isControlled) return;
|
|
82
|
+
if (openedByFocusRef.current) return;
|
|
80
83
|
closeTimer.current = window.setTimeout(() => setOpen(false), delayCloseMs);
|
|
81
84
|
};
|
|
82
85
|
const onPointerDown = () => {
|
|
@@ -87,12 +90,15 @@ function useTooltipTrigger(options) {
|
|
|
87
90
|
clearTimers();
|
|
88
91
|
if (focusOpenMode === "off") return;
|
|
89
92
|
const shouldOpen = focusOpenMode === "any" || e.currentTarget.matches(":focus-visible");
|
|
90
|
-
if (!
|
|
93
|
+
if (!shouldOpen) return;
|
|
94
|
+
openedByFocusRef.current = true;
|
|
95
|
+
if (!isControlled) {
|
|
91
96
|
openTimer.current = window.setTimeout(() => setOpen(true), delayOpenMs);
|
|
92
97
|
}
|
|
93
98
|
};
|
|
94
99
|
const onBlur = () => {
|
|
95
100
|
clearTimers();
|
|
101
|
+
openedByFocusRef.current = false;
|
|
96
102
|
if (!isControlled) setOpen(false);
|
|
97
103
|
};
|
|
98
104
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* When PageLayout owns scrolling, the body shouldn't reserve scrollbar gutter space.
|
|
2
2
|
This prevents the right-side gap that body { overflow-y: scroll } would otherwise create. */
|
|
3
|
-
:global(body):has([data-contain-scrolling]) {
|
|
3
|
+
:global(body):has(.root[data-contain-scrolling]) {
|
|
4
4
|
overflow: hidden;
|
|
5
5
|
}
|
|
6
6
|
|
|
@@ -4,19 +4,23 @@
|
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var Pagination = require('../../components/pagination/Pagination');
|
|
7
|
-
var SkeletonLoader = require('../../components/skeleton-loader/SkeletonLoader');
|
|
8
7
|
var useViewportFill = require('../../hooks/useViewportFill');
|
|
9
8
|
var EmptyState = require('./components/empty-state/EmptyState');
|
|
9
|
+
var TableHeaderSettings = require('./components/table-settings/TableHeaderSettings');
|
|
10
10
|
var TableBody = require('./components/TableBody');
|
|
11
11
|
var TableHeader = require('./components/TableHeader');
|
|
12
|
+
var TableSkeletonBody = require('./components/TableSkeletonBody');
|
|
12
13
|
var table_classes = require('./table.classes');
|
|
13
14
|
var styles = require('./Table.module.css');
|
|
14
15
|
var table_utils = require('./table.utils');
|
|
16
|
+
var tableSettings_utils = require('./tableSettings.utils');
|
|
15
17
|
|
|
16
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
19
|
|
|
18
20
|
var styles__default = /*#__PURE__*/_interopDefault(styles);
|
|
19
21
|
|
|
22
|
+
const DEFAULT_SKELETON_ROWS = 10;
|
|
23
|
+
const MAX_SKELETON_ROWS = 20;
|
|
20
24
|
function Table({
|
|
21
25
|
data,
|
|
22
26
|
dataKey,
|
|
@@ -30,7 +34,8 @@ function Table({
|
|
|
30
34
|
emptyConfig,
|
|
31
35
|
variant = "primary",
|
|
32
36
|
size = "md",
|
|
33
|
-
viewMode,
|
|
37
|
+
viewMode: viewModeProp,
|
|
38
|
+
striped: stripedProp,
|
|
34
39
|
fillViewport = false,
|
|
35
40
|
fillViewportBottomOffset = 0,
|
|
36
41
|
containScrolling = true,
|
|
@@ -40,6 +45,9 @@ function Table({
|
|
|
40
45
|
measuringLayout = false,
|
|
41
46
|
toolbar,
|
|
42
47
|
headerExtras,
|
|
48
|
+
headerActions: headerActionsProp,
|
|
49
|
+
settings,
|
|
50
|
+
settingsOptions,
|
|
43
51
|
take,
|
|
44
52
|
skip,
|
|
45
53
|
totalItemsCount,
|
|
@@ -61,7 +69,22 @@ function Table({
|
|
|
61
69
|
onPageChange,
|
|
62
70
|
...rest
|
|
63
71
|
}) {
|
|
64
|
-
|
|
72
|
+
var _a;
|
|
73
|
+
const viewMode = viewModeProp != null ? viewModeProp : settings == null ? void 0 : settings.viewMode;
|
|
74
|
+
const striped = (_a = stripedProp != null ? stripedProp : settings == null ? void 0 : settings.striped) != null ? _a : false;
|
|
75
|
+
const settingsVisibleIds = settings == null ? void 0 : settings.visibleColumnIds;
|
|
76
|
+
const visibleColumns = react.useMemo(
|
|
77
|
+
() => (settingsVisibleIds == null ? void 0 : settingsVisibleIds.length) ? tableSettings_utils.filterColumnsBySettings(columns, settingsVisibleIds) : table_utils.getVisibleColumns(columns),
|
|
78
|
+
[columns, settingsVisibleIds]
|
|
79
|
+
);
|
|
80
|
+
const headerActions = headerActionsProp != null || settings ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles__default.default.headerActions, children: [
|
|
81
|
+
headerActionsProp,
|
|
82
|
+
settings ? /* @__PURE__ */ jsxRuntime.jsx(TableHeaderSettings.TableHeaderSettings, { settings, options: settingsOptions, columns }) : null
|
|
83
|
+
] }) : null;
|
|
84
|
+
const toolbarContent = !showHeader && headerActions ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles__default.default.toolbarWithHeaderActions, children: [
|
|
85
|
+
toolbar,
|
|
86
|
+
headerActions
|
|
87
|
+
] }) : toolbar;
|
|
65
88
|
const selectionInputName = react.useId();
|
|
66
89
|
const internalTableRootRef = react.useRef(null);
|
|
67
90
|
const tableRootRefWrapper = react.useRef(tableRootRef);
|
|
@@ -69,17 +92,14 @@ function Table({
|
|
|
69
92
|
const hasPagination = Boolean(onPageChange && (loading || data.length > 0));
|
|
70
93
|
const paginationRef = react.useRef(null);
|
|
71
94
|
const [paginationHeight, setPaginationHeight] = react.useState(0);
|
|
72
|
-
react.
|
|
95
|
+
react.useLayoutEffect(() => {
|
|
73
96
|
const element = paginationRef.current;
|
|
74
97
|
if (!element) return;
|
|
75
98
|
const measure = () => setPaginationHeight(element.getBoundingClientRect().height);
|
|
76
|
-
|
|
99
|
+
measure();
|
|
77
100
|
const observer = typeof ResizeObserver !== "undefined" ? new ResizeObserver(measure) : null;
|
|
78
101
|
observer == null ? void 0 : observer.observe(element);
|
|
79
|
-
return () =>
|
|
80
|
-
cancelAnimationFrame(frame);
|
|
81
|
-
observer == null ? void 0 : observer.disconnect();
|
|
82
|
-
};
|
|
102
|
+
return () => observer == null ? void 0 : observer.disconnect();
|
|
83
103
|
}, [hasPagination]);
|
|
84
104
|
const [expandedRows, setExpandedRows] = react.useState(() => /* @__PURE__ */ new Set());
|
|
85
105
|
const handleToggleRowExpand = react.useCallback((rowId) => {
|
|
@@ -99,7 +119,7 @@ function Table({
|
|
|
99
119
|
min: 0
|
|
100
120
|
});
|
|
101
121
|
const fillViewportActive = fillViewport && containScrolling;
|
|
102
|
-
const stickyTop = stickyHeader === "app-header" ? "var(--app-header-height, 60px)" : typeof stickyHeader === "number" ? `${stickyHeader}px` : void 0;
|
|
122
|
+
const stickyTop = stickyHeader === "app-header" ? "var(--app-header-height, 60px)" : typeof stickyHeader === "number" ? `${stickyHeader}px` : stickyHeader === void 0 && containScrolling ? "0px" : void 0;
|
|
103
123
|
const setTableRootRef = react.useCallback((node) => {
|
|
104
124
|
internalTableRootRef.current = node;
|
|
105
125
|
if (typeof tableRootRefWrapper.current === "function") {
|
|
@@ -167,16 +187,17 @@ function Table({
|
|
|
167
187
|
measuringLayout && styles__default.default.measuringLayout,
|
|
168
188
|
getRowSeverity && styles__default.default.severityTable
|
|
169
189
|
);
|
|
190
|
+
const tableElementClassName = table_classes.cx(styles__default.default.tableElement, striped && "dbc-table--striped");
|
|
170
191
|
const tableShell = /* @__PURE__ */ jsxRuntime.jsx("div", { ...rest, className: tableClassName, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
171
192
|
"div",
|
|
172
193
|
{
|
|
173
194
|
ref: setTableRootRef,
|
|
174
195
|
className: styles__default.default.tableScroll,
|
|
175
196
|
style: fillViewportActive ? viewportFillStyle : !containScrolling ? { overflow: "visible" } : void 0,
|
|
176
|
-
children: loading && !data.length ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles__default.default.emptyStateSlot, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
197
|
+
children: !loading && !data.length ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles__default.default.emptyStateSlot, children: /* @__PURE__ */ jsxRuntime.jsx(EmptyState.TableEmptyState, { config: emptyConfig }) }) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
177
198
|
"table",
|
|
178
199
|
{
|
|
179
|
-
className:
|
|
200
|
+
className: tableElementClassName,
|
|
180
201
|
"aria-rowcount": data.length,
|
|
181
202
|
"data-show-header": showHeader,
|
|
182
203
|
style: tableWidth != null ? { width: tableWidth } : void 0,
|
|
@@ -197,17 +218,25 @@ function Table({
|
|
|
197
218
|
columns: visibleColumns,
|
|
198
219
|
hasSelection,
|
|
199
220
|
selectionMode,
|
|
200
|
-
hasRowContextMenu: Boolean(getContextMenuItems),
|
|
221
|
+
hasRowContextMenu: Boolean(getContextMenuItems) || expandableRows,
|
|
201
222
|
allRowsSelected,
|
|
202
223
|
onSelectAllRows,
|
|
203
224
|
sortById,
|
|
204
225
|
sortDirection,
|
|
205
226
|
onSortChange,
|
|
206
227
|
headerExtras,
|
|
228
|
+
headerActions,
|
|
207
229
|
stickyTop
|
|
208
230
|
}
|
|
209
231
|
),
|
|
210
|
-
|
|
232
|
+
loading && !data.length ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
233
|
+
TableSkeletonBody.TableSkeletonBody,
|
|
234
|
+
{
|
|
235
|
+
columns: visibleColumns,
|
|
236
|
+
rows: Math.min(take != null ? take : DEFAULT_SKELETON_ROWS, MAX_SKELETON_ROWS),
|
|
237
|
+
hasSelection
|
|
238
|
+
}
|
|
239
|
+
) : bodyContent
|
|
211
240
|
]
|
|
212
241
|
}
|
|
213
242
|
)
|
|
@@ -223,7 +252,7 @@ function Table({
|
|
|
223
252
|
...!fillViewportActive && { blockSize: "auto", overflow: "visible" }
|
|
224
253
|
},
|
|
225
254
|
children: [
|
|
226
|
-
|
|
255
|
+
toolbarContent ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles__default.default.toolbarSlot, children: toolbarContent }) : null,
|
|
227
256
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
228
257
|
"div",
|
|
229
258
|
{
|
|
@@ -246,7 +275,7 @@ function Table({
|
|
|
246
275
|
position: "relative"
|
|
247
276
|
},
|
|
248
277
|
children: [
|
|
249
|
-
|
|
278
|
+
toolbarContent ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles__default.default.toolbarSlot, children: toolbarContent }) : null,
|
|
250
279
|
tableShell,
|
|
251
280
|
paginationEl
|
|
252
281
|
]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { JSX } from 'react';
|
|
2
2
|
import type { TableProps } from './Table.types';
|
|
3
|
-
export declare function Table<T extends Record<string, any>>({ data, dataKey, columns, selectedRows, selectionMode, allRowsSelected, sortById, sortDirection, loading, emptyConfig, variant, size, viewMode, fillViewport, fillViewportBottomOffset, containScrolling, stickyHeader, tableWidth, tableRootRef, measuringLayout, toolbar, headerExtras, take, skip, totalItemsCount, paginationPlacement, showFirstLast, showGoToPage, showPageSize, pageSizeOptions, showHeader, getRowSeverity, getContextMenuItems, showContextMenuOnHover, expandableRows, onRowClick, onRowMouseEnter, onRowSelect, onSelectAllRows, onSortChange, onPageChange, ...rest }: TableProps<T>): JSX.Element;
|
|
3
|
+
export declare function Table<T extends Record<string, any>>({ data, dataKey, columns, selectedRows, selectionMode, allRowsSelected, sortById, sortDirection, loading, emptyConfig, variant, size, viewMode: viewModeProp, striped: stripedProp, fillViewport, fillViewportBottomOffset, containScrolling, stickyHeader, tableWidth, tableRootRef, measuringLayout, toolbar, headerExtras, headerActions: headerActionsProp, settings, settingsOptions, take, skip, totalItemsCount, paginationPlacement, showFirstLast, showGoToPage, showPageSize, pageSizeOptions, showHeader, getRowSeverity, getContextMenuItems, showContextMenuOnHover, expandableRows, onRowClick, onRowMouseEnter, onRowSelect, onSelectAllRows, onSortChange, onPageChange, ...rest }: TableProps<T>): JSX.Element;
|
|
4
4
|
export type { ColumnItem } from './Table.types';
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import { useMemo, useId, useRef, useState,
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useMemo, useId, useRef, useState, useLayoutEffect, useCallback } from 'react';
|
|
4
4
|
import { Pagination } from '../../components/pagination/Pagination';
|
|
5
|
-
import { SkeletonLoader } from '../../components/skeleton-loader/SkeletonLoader';
|
|
6
5
|
import { useViewportFill } from '../../hooks/useViewportFill';
|
|
7
6
|
import { TableEmptyState } from './components/empty-state/EmptyState';
|
|
7
|
+
import { TableHeaderSettings } from './components/table-settings/TableHeaderSettings';
|
|
8
8
|
import { TableBody } from './components/TableBody';
|
|
9
9
|
import { TableHeader } from './components/TableHeader';
|
|
10
|
+
import { TableSkeletonBody } from './components/TableSkeletonBody';
|
|
10
11
|
import { cx } from './table.classes';
|
|
11
12
|
import styles from './Table.module.css';
|
|
12
13
|
import { getVisibleColumns, SELECTION_COLUMN_PX } from './table.utils';
|
|
14
|
+
import { filterColumnsBySettings } from './tableSettings.utils';
|
|
13
15
|
|
|
16
|
+
const DEFAULT_SKELETON_ROWS = 10;
|
|
17
|
+
const MAX_SKELETON_ROWS = 20;
|
|
14
18
|
function Table({
|
|
15
19
|
data,
|
|
16
20
|
dataKey,
|
|
@@ -24,7 +28,8 @@ function Table({
|
|
|
24
28
|
emptyConfig,
|
|
25
29
|
variant = "primary",
|
|
26
30
|
size = "md",
|
|
27
|
-
viewMode,
|
|
31
|
+
viewMode: viewModeProp,
|
|
32
|
+
striped: stripedProp,
|
|
28
33
|
fillViewport = false,
|
|
29
34
|
fillViewportBottomOffset = 0,
|
|
30
35
|
containScrolling = true,
|
|
@@ -34,6 +39,9 @@ function Table({
|
|
|
34
39
|
measuringLayout = false,
|
|
35
40
|
toolbar,
|
|
36
41
|
headerExtras,
|
|
42
|
+
headerActions: headerActionsProp,
|
|
43
|
+
settings,
|
|
44
|
+
settingsOptions,
|
|
37
45
|
take,
|
|
38
46
|
skip,
|
|
39
47
|
totalItemsCount,
|
|
@@ -55,7 +63,22 @@ function Table({
|
|
|
55
63
|
onPageChange,
|
|
56
64
|
...rest
|
|
57
65
|
}) {
|
|
58
|
-
|
|
66
|
+
var _a;
|
|
67
|
+
const viewMode = viewModeProp != null ? viewModeProp : settings == null ? void 0 : settings.viewMode;
|
|
68
|
+
const striped = (_a = stripedProp != null ? stripedProp : settings == null ? void 0 : settings.striped) != null ? _a : false;
|
|
69
|
+
const settingsVisibleIds = settings == null ? void 0 : settings.visibleColumnIds;
|
|
70
|
+
const visibleColumns = useMemo(
|
|
71
|
+
() => (settingsVisibleIds == null ? void 0 : settingsVisibleIds.length) ? filterColumnsBySettings(columns, settingsVisibleIds) : getVisibleColumns(columns),
|
|
72
|
+
[columns, settingsVisibleIds]
|
|
73
|
+
);
|
|
74
|
+
const headerActions = headerActionsProp != null || settings ? /* @__PURE__ */ jsxs("div", { className: styles.headerActions, children: [
|
|
75
|
+
headerActionsProp,
|
|
76
|
+
settings ? /* @__PURE__ */ jsx(TableHeaderSettings, { settings, options: settingsOptions, columns }) : null
|
|
77
|
+
] }) : null;
|
|
78
|
+
const toolbarContent = !showHeader && headerActions ? /* @__PURE__ */ jsxs("div", { className: styles.toolbarWithHeaderActions, children: [
|
|
79
|
+
toolbar,
|
|
80
|
+
headerActions
|
|
81
|
+
] }) : toolbar;
|
|
59
82
|
const selectionInputName = useId();
|
|
60
83
|
const internalTableRootRef = useRef(null);
|
|
61
84
|
const tableRootRefWrapper = useRef(tableRootRef);
|
|
@@ -63,17 +86,14 @@ function Table({
|
|
|
63
86
|
const hasPagination = Boolean(onPageChange && (loading || data.length > 0));
|
|
64
87
|
const paginationRef = useRef(null);
|
|
65
88
|
const [paginationHeight, setPaginationHeight] = useState(0);
|
|
66
|
-
|
|
89
|
+
useLayoutEffect(() => {
|
|
67
90
|
const element = paginationRef.current;
|
|
68
91
|
if (!element) return;
|
|
69
92
|
const measure = () => setPaginationHeight(element.getBoundingClientRect().height);
|
|
70
|
-
|
|
93
|
+
measure();
|
|
71
94
|
const observer = typeof ResizeObserver !== "undefined" ? new ResizeObserver(measure) : null;
|
|
72
95
|
observer == null ? void 0 : observer.observe(element);
|
|
73
|
-
return () =>
|
|
74
|
-
cancelAnimationFrame(frame);
|
|
75
|
-
observer == null ? void 0 : observer.disconnect();
|
|
76
|
-
};
|
|
96
|
+
return () => observer == null ? void 0 : observer.disconnect();
|
|
77
97
|
}, [hasPagination]);
|
|
78
98
|
const [expandedRows, setExpandedRows] = useState(() => /* @__PURE__ */ new Set());
|
|
79
99
|
const handleToggleRowExpand = useCallback((rowId) => {
|
|
@@ -93,7 +113,7 @@ function Table({
|
|
|
93
113
|
min: 0
|
|
94
114
|
});
|
|
95
115
|
const fillViewportActive = fillViewport && containScrolling;
|
|
96
|
-
const stickyTop = stickyHeader === "app-header" ? "var(--app-header-height, 60px)" : typeof stickyHeader === "number" ? `${stickyHeader}px` : void 0;
|
|
116
|
+
const stickyTop = stickyHeader === "app-header" ? "var(--app-header-height, 60px)" : typeof stickyHeader === "number" ? `${stickyHeader}px` : stickyHeader === void 0 && containScrolling ? "0px" : void 0;
|
|
97
117
|
const setTableRootRef = useCallback((node) => {
|
|
98
118
|
internalTableRootRef.current = node;
|
|
99
119
|
if (typeof tableRootRefWrapper.current === "function") {
|
|
@@ -161,16 +181,17 @@ function Table({
|
|
|
161
181
|
measuringLayout && styles.measuringLayout,
|
|
162
182
|
getRowSeverity && styles.severityTable
|
|
163
183
|
);
|
|
184
|
+
const tableElementClassName = cx(styles.tableElement, striped && "dbc-table--striped");
|
|
164
185
|
const tableShell = /* @__PURE__ */ jsx("div", { ...rest, className: tableClassName, children: /* @__PURE__ */ jsx(
|
|
165
186
|
"div",
|
|
166
187
|
{
|
|
167
188
|
ref: setTableRootRef,
|
|
168
189
|
className: styles.tableScroll,
|
|
169
190
|
style: fillViewportActive ? viewportFillStyle : !containScrolling ? { overflow: "visible" } : void 0,
|
|
170
|
-
children: loading && !data.length ? /* @__PURE__ */ jsx("div", { className: styles.emptyStateSlot, children: /* @__PURE__ */ jsx(
|
|
191
|
+
children: !loading && !data.length ? /* @__PURE__ */ jsx("div", { className: styles.emptyStateSlot, children: /* @__PURE__ */ jsx(TableEmptyState, { config: emptyConfig }) }) : /* @__PURE__ */ jsxs(
|
|
171
192
|
"table",
|
|
172
193
|
{
|
|
173
|
-
className:
|
|
194
|
+
className: tableElementClassName,
|
|
174
195
|
"aria-rowcount": data.length,
|
|
175
196
|
"data-show-header": showHeader,
|
|
176
197
|
style: tableWidth != null ? { width: tableWidth } : void 0,
|
|
@@ -191,17 +212,25 @@ function Table({
|
|
|
191
212
|
columns: visibleColumns,
|
|
192
213
|
hasSelection,
|
|
193
214
|
selectionMode,
|
|
194
|
-
hasRowContextMenu: Boolean(getContextMenuItems),
|
|
215
|
+
hasRowContextMenu: Boolean(getContextMenuItems) || expandableRows,
|
|
195
216
|
allRowsSelected,
|
|
196
217
|
onSelectAllRows,
|
|
197
218
|
sortById,
|
|
198
219
|
sortDirection,
|
|
199
220
|
onSortChange,
|
|
200
221
|
headerExtras,
|
|
222
|
+
headerActions,
|
|
201
223
|
stickyTop
|
|
202
224
|
}
|
|
203
225
|
),
|
|
204
|
-
|
|
226
|
+
loading && !data.length ? /* @__PURE__ */ jsx(
|
|
227
|
+
TableSkeletonBody,
|
|
228
|
+
{
|
|
229
|
+
columns: visibleColumns,
|
|
230
|
+
rows: Math.min(take != null ? take : DEFAULT_SKELETON_ROWS, MAX_SKELETON_ROWS),
|
|
231
|
+
hasSelection
|
|
232
|
+
}
|
|
233
|
+
) : bodyContent
|
|
205
234
|
]
|
|
206
235
|
}
|
|
207
236
|
)
|
|
@@ -217,7 +246,7 @@ function Table({
|
|
|
217
246
|
...!fillViewportActive && { blockSize: "auto", overflow: "visible" }
|
|
218
247
|
},
|
|
219
248
|
children: [
|
|
220
|
-
|
|
249
|
+
toolbarContent ? /* @__PURE__ */ jsx("div", { className: styles.toolbarSlot, children: toolbarContent }) : null,
|
|
221
250
|
/* @__PURE__ */ jsx(
|
|
222
251
|
"div",
|
|
223
252
|
{
|
|
@@ -240,7 +269,7 @@ function Table({
|
|
|
240
269
|
position: "relative"
|
|
241
270
|
},
|
|
242
271
|
children: [
|
|
243
|
-
|
|
272
|
+
toolbarContent ? /* @__PURE__ */ jsx("div", { className: styles.toolbarSlot, children: toolbarContent }) : null,
|
|
244
273
|
tableShell,
|
|
245
274
|
paginationEl
|
|
246
275
|
]
|