@dbcdk/react-components 0.0.197 → 0.0.198
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/components/json-viewer/JsonViewer.module.css +52 -0
- package/dist/components/json-viewer/JsonViewerShell.cjs +147 -143
- package/dist/components/json-viewer/JsonViewerShell.js +149 -145
- package/dist/components/line-viewer/LineViewer.cjs +15 -10
- package/dist/components/line-viewer/LineViewer.d.ts +1 -1
- package/dist/components/line-viewer/LineViewer.js +15 -10
- package/dist/components/line-viewer/LineViewer.module.css +58 -3
- package/dist/components/page-layout/PageLayout.module.css +1 -1
- package/dist/components/scroll-fade/ScrollFade.cjs +42 -0
- package/dist/components/scroll-fade/ScrollFade.d.ts +18 -0
- package/dist/components/scroll-fade/ScrollFade.js +36 -0
- package/dist/components/scroll-fade/ScrollFade.module.css +71 -0
- package/dist/components/search-box/SearchBox.cjs +39 -35
- package/dist/components/search-box/SearchBox.d.ts +2 -0
- package/dist/components/search-box/SearchBox.js +39 -35
- package/dist/components/table/Table.cjs +52 -23
- package/dist/components/table/Table.d.ts +1 -1
- package/dist/components/table/Table.js +53 -24
- package/dist/components/table/Table.module.css +4 -0
- package/dist/components/table/Table.types.d.ts +27 -0
- package/dist/components/table/TanstackTable.cjs +64 -64
- package/dist/components/table/TanstackTable.js +67 -67
- package/dist/components/table/columnLayout.utils.cjs +146 -0
- package/dist/components/table/columnLayout.utils.d.ts +44 -0
- package/dist/components/table/columnLayout.utils.js +141 -0
- package/dist/components/table/components/TableHeader.cjs +3 -1
- package/dist/components/table/components/TableHeader.d.ts +2 -1
- package/dist/components/table/components/TableHeader.js +3 -1
- package/dist/components/table/components/TableHeaderCell.cjs +29 -19
- package/dist/components/table/components/TableHeaderCell.d.ts +2 -1
- package/dist/components/table/components/TableHeaderCell.js +29 -19
- package/dist/components/table/hooks/useElementWidth.cjs +40 -0
- package/dist/components/table/hooks/useElementWidth.d.ts +7 -0
- package/dist/components/table/hooks/useElementWidth.js +38 -0
- package/dist/components/table/table.utils.cjs +24 -2
- package/dist/components/table/table.utils.d.ts +40 -2
- package/dist/components/table/table.utils.js +20 -2
- package/dist/components/table/tanstackTable.utils.cjs +33 -97
- package/dist/components/table/tanstackTable.utils.d.ts +24 -8
- package/dist/components/table/tanstackTable.utils.js +34 -99
- package/dist/components/xml-viewer/XmlViewer.cjs +15 -10
- package/dist/components/xml-viewer/XmlViewer.d.ts +1 -1
- package/dist/components/xml-viewer/XmlViewer.js +15 -10
- package/dist/components/xml-viewer/XmlViewer.module.css +58 -3
- package/dist/hooks/useScrollOverflow.cjs +71 -0
- package/dist/hooks/useScrollOverflow.d.ts +23 -0
- package/dist/hooks/useScrollOverflow.js +69 -0
- package/dist/hooks/useTableSettings.cjs +2 -1
- package/dist/hooks/useTableSettings.d.ts +1 -0
- package/dist/hooks/useTableSettings.js +2 -1
- package/dist/index.css +1 -0
- package/dist/utils/refs.utils.cjs +13 -0
- package/dist/utils/refs.utils.d.ts +7 -0
- package/dist/utils/refs.utils.js +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Which edges of a scroll container have more content beyond them. */
|
|
2
|
+
export type ScrollOverflow = {
|
|
3
|
+
top: boolean;
|
|
4
|
+
bottom: boolean;
|
|
5
|
+
left: boolean;
|
|
6
|
+
right: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Space taken by classic (non-overlay) scrollbars, in pixels: the vertical
|
|
9
|
+
* scrollbar's width and the horizontal one's height. Lets edge hints stay
|
|
10
|
+
* clear of the scrollbars. 0 for overlay scrollbars.
|
|
11
|
+
*/
|
|
12
|
+
scrollbarWidth: number;
|
|
13
|
+
scrollbarHeight: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Tracks which edges of the scroll container `el` hide more content, so the
|
|
17
|
+
* caller can hint at it (e.g. with edge fades) without restyling the native
|
|
18
|
+
* scrollbars. Updates on scroll, on resize and when the content changes.
|
|
19
|
+
* Takes the element rather than a ref so it follows the element when it's
|
|
20
|
+
* replaced; keep it in state via a callback ref. All edges are `false` on the
|
|
21
|
+
* server and until the first client measurement.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useScrollOverflow(el: HTMLElement | null): ScrollOverflow;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useState, useLayoutEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
const NONE = {
|
|
5
|
+
top: false,
|
|
6
|
+
bottom: false,
|
|
7
|
+
left: false,
|
|
8
|
+
right: false,
|
|
9
|
+
scrollbarWidth: 0,
|
|
10
|
+
scrollbarHeight: 0
|
|
11
|
+
};
|
|
12
|
+
const THRESHOLD_PX = 1;
|
|
13
|
+
function measureScrollbars(el) {
|
|
14
|
+
const style = getComputedStyle(el);
|
|
15
|
+
const borderX = parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth) || 0;
|
|
16
|
+
const borderY = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth) || 0;
|
|
17
|
+
return {
|
|
18
|
+
scrollbarWidth: Math.max(0, el.offsetWidth - el.clientWidth - borderX),
|
|
19
|
+
scrollbarHeight: Math.max(0, el.offsetHeight - el.clientHeight - borderY)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function measure(el, scrollbars) {
|
|
23
|
+
const { scrollTop, scrollLeft, scrollHeight, scrollWidth, clientHeight, clientWidth } = el;
|
|
24
|
+
return {
|
|
25
|
+
top: scrollTop > THRESHOLD_PX,
|
|
26
|
+
bottom: scrollHeight - clientHeight - scrollTop > THRESHOLD_PX,
|
|
27
|
+
left: scrollLeft > THRESHOLD_PX,
|
|
28
|
+
right: scrollWidth - clientWidth - scrollLeft > THRESHOLD_PX,
|
|
29
|
+
...scrollbars
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function sameOverflow(a, b) {
|
|
33
|
+
return Object.keys(a).every((key) => a[key] === b[key]);
|
|
34
|
+
}
|
|
35
|
+
function useScrollOverflow(el) {
|
|
36
|
+
const [overflow, setOverflow] = useState(NONE);
|
|
37
|
+
useLayoutEffect(() => {
|
|
38
|
+
if (!el) return;
|
|
39
|
+
let scrollbars = measureScrollbars(el);
|
|
40
|
+
const update = () => {
|
|
41
|
+
const next = measure(el, scrollbars);
|
|
42
|
+
setOverflow((prev) => sameOverflow(prev, next) ? prev : next);
|
|
43
|
+
};
|
|
44
|
+
const updateLayout = () => {
|
|
45
|
+
scrollbars = measureScrollbars(el);
|
|
46
|
+
update();
|
|
47
|
+
};
|
|
48
|
+
update();
|
|
49
|
+
el.addEventListener("scroll", update, { passive: true });
|
|
50
|
+
const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(updateLayout) : null;
|
|
51
|
+
resizeObserver == null ? void 0 : resizeObserver.observe(el);
|
|
52
|
+
const mutationObserver = typeof MutationObserver !== "undefined" ? new MutationObserver(updateLayout) : null;
|
|
53
|
+
mutationObserver == null ? void 0 : mutationObserver.observe(el, {
|
|
54
|
+
subtree: true,
|
|
55
|
+
childList: true,
|
|
56
|
+
characterData: true,
|
|
57
|
+
attributes: true,
|
|
58
|
+
attributeFilter: ["class", "style"]
|
|
59
|
+
});
|
|
60
|
+
return () => {
|
|
61
|
+
el.removeEventListener("scroll", update);
|
|
62
|
+
resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
63
|
+
mutationObserver == null ? void 0 : mutationObserver.disconnect();
|
|
64
|
+
};
|
|
65
|
+
}, [el]);
|
|
66
|
+
return el ? overflow : NONE;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { useScrollOverflow };
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var react = require('react');
|
|
5
|
+
var table_utils = require('../components/table/table.utils');
|
|
5
6
|
var tableSettings_utils = require('../components/table/tableSettings.utils');
|
|
6
7
|
var localStorage_utils = require('../utils/localStorage.utils');
|
|
7
8
|
|
|
@@ -27,7 +28,7 @@ const localStorageTableSettingsStorage = {
|
|
|
27
28
|
function useTableSettings({
|
|
28
29
|
storageKey,
|
|
29
30
|
tableColumns,
|
|
30
|
-
defaultViewMode =
|
|
31
|
+
defaultViewMode = table_utils.DEFAULT_VIEW_MODE,
|
|
31
32
|
defaultVisibleColumnIds,
|
|
32
33
|
defaultStriped = false,
|
|
33
34
|
storage = localStorageTableSettingsStorage
|
|
@@ -13,6 +13,7 @@ export declare const localStorageTableSettingsStorage: TableSettingsStorage;
|
|
|
13
13
|
export interface UseTableSettingsOptions<T = unknown> {
|
|
14
14
|
storageKey: string;
|
|
15
15
|
tableColumns?: ReadonlyArray<ColumnItem<T> | TableSettingsColumn>;
|
|
16
|
+
/** View mode until the user picks one. Defaults to `'wrapped'`; pass `'compact'` for even row heights. */
|
|
16
17
|
defaultViewMode?: ViewMode;
|
|
17
18
|
defaultVisibleColumnIds?: string[];
|
|
18
19
|
defaultStriped?: boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useMemo, useState, useEffect, useCallback } from 'react';
|
|
3
|
+
import { DEFAULT_VIEW_MODE } from '../components/table/table.utils';
|
|
3
4
|
import { isSettingsColumnHidden, getSettingsColumnId } from '../components/table/tableSettings.utils';
|
|
4
5
|
import { writeLocalStorage, readLocalStorage } from '../utils/localStorage.utils';
|
|
5
6
|
|
|
@@ -25,7 +26,7 @@ const localStorageTableSettingsStorage = {
|
|
|
25
26
|
function useTableSettings({
|
|
26
27
|
storageKey,
|
|
27
28
|
tableColumns,
|
|
28
|
-
defaultViewMode =
|
|
29
|
+
defaultViewMode = DEFAULT_VIEW_MODE,
|
|
29
30
|
defaultVisibleColumnIds,
|
|
30
31
|
defaultStriped = false,
|
|
31
32
|
storage = localStorageTableSettingsStorage
|
package/dist/index.css
CHANGED
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
@import './components/pagination/Pagination.module.css';
|
|
57
57
|
@import './components/panel/Panel.module.css';
|
|
58
58
|
@import './components/popover/Popover.module.css';
|
|
59
|
+
@import './components/scroll-fade/ScrollFade.module.css';
|
|
59
60
|
@import './components/search-box/SearchBox.module.css';
|
|
60
61
|
@import './components/section-label/SectionLabel.module.css';
|
|
61
62
|
@import './components/segmented-progress-bar/SegmentedProgressBar.module.css';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Ref } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Combines refs into one callback ref. Returns a new function on every call,
|
|
4
|
+
* so memoize it (e.g. with `useMemo`) when a stable ref matters, such as when
|
|
5
|
+
* one of the refs sets state.
|
|
6
|
+
*/
|
|
7
|
+
export declare function mergeRefs<T>(...refs: Array<Ref<T> | undefined>): (node: T | null) => void;
|