@dbcdk/react-components 0.0.96 → 0.0.97
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/table/Table.d.ts +1 -1
- package/dist/components/table/Table.types.d.ts +3 -0
- package/dist/components/table/components/TableHeader.d.ts +2 -1
- package/dist/index.cjs +12750 -0
- package/dist/index.css +7149 -0
- package/dist/index.js +12641 -79
- package/dist/tanstack.cjs +2674 -0
- package/dist/tanstack.css +1267 -0
- package/dist/tanstack.js +2650 -3
- package/dist/themes/dbc.css +3 -0
- package/dist/themes/forfatterweb.css +2 -0
- package/package.json +11 -10
- package/dist/assets/logo.js +0 -2
- package/dist/components/__stories__/_data/table.d.ts +0 -15
- package/dist/components/__stories__/_data/table.js +0 -55
- package/dist/components/__stories__/_data/tabs.d.ts +0 -9
- package/dist/components/__stories__/_data/tabs.js +0 -31
- package/dist/components/__stories__/story-components/Colors.d.ts +0 -11
- package/dist/components/__stories__/story-components/Colors.js +0 -96
- package/dist/components/__stories__/story-components/Colors.module.css +0 -27
- package/dist/components/__stories__/story-components/ComponentSizes.d.ts +0 -2
- package/dist/components/__stories__/story-components/ComponentSizes.js +0 -26
- package/dist/components/__stories__/story-components/Elevation.d.ts +0 -2
- package/dist/components/__stories__/story-components/Elevation.js +0 -49
- package/dist/components/__stories__/story-components/Flex.d.ts +0 -2
- package/dist/components/__stories__/story-components/Flex.js +0 -177
- package/dist/components/__stories__/story-components/Flex.module.css +0 -317
- package/dist/components/__stories__/story-components/Spacing.d.ts +0 -6
- package/dist/components/__stories__/story-components/Spacing.js +0 -76
- package/dist/components/__stories__/story-components/Spacing.module.css +0 -154
- package/dist/components/accordion/Accordion.js +0 -70
- package/dist/components/accordion/Accordion.module.css +0 -28
- package/dist/components/accordion/components/AccordionRow.js +0 -53
- package/dist/components/accordion/components/AccordionRow.module.css +0 -90
- package/dist/components/alert/Alert.js +0 -17
- package/dist/components/alert/Alert.module.css +0 -98
- package/dist/components/app-header/AppHeader.js +0 -5
- package/dist/components/app-header/AppHeader.module.css +0 -74
- package/dist/components/attribute-chip/AttributeChip.js +0 -5
- package/dist/components/attribute-chip/AttributeChip.module.css +0 -65
- package/dist/components/avatar/Avatar.js +0 -48
- package/dist/components/avatar/Avatar.module.css +0 -91
- package/dist/components/breadcrumbs/Breadcrumbs.js +0 -6
- package/dist/components/breadcrumbs/Breadcrumbs.module.css +0 -80
- package/dist/components/button/Button.js +0 -81
- package/dist/components/button/Button.module.css +0 -249
- package/dist/components/button-select/ButtonSelect.js +0 -7
- package/dist/components/button-select/ButtonSelect.module.css +0 -40
- package/dist/components/card/Card.js +0 -71
- package/dist/components/card/Card.module.css +0 -160
- package/dist/components/card/components/CardMeta.js +0 -26
- package/dist/components/card/components/CardMeta.module.css +0 -55
- package/dist/components/card-container/CardContainer.js +0 -6
- package/dist/components/card-container/CardContainer.module.css +0 -61
- package/dist/components/chip/Chip.js +0 -31
- package/dist/components/chip/Chip.module.css +0 -236
- package/dist/components/circle/Circle.js +0 -5
- package/dist/components/circle/Circle.module.css +0 -128
- package/dist/components/clear-button/ClearButton.js +0 -13
- package/dist/components/clear-button/ClearButton.module.css +0 -26
- package/dist/components/code-block/CodeBlock.js +0 -58
- package/dist/components/code-block/CodeBlock.module.css +0 -124
- package/dist/components/copy-button/CopyButton.js +0 -78
- package/dist/components/copy-button/CopyButton.module.css +0 -22
- package/dist/components/datetime-picker/DateTimePicker.js +0 -403
- package/dist/components/datetime-picker/DateTimePicker.module.css +0 -155
- package/dist/components/datetime-picker/dateTimeHelpers.js +0 -248
- package/dist/components/divider/Divider.js +0 -12
- package/dist/components/filter-field/FilterField.js +0 -191
- package/dist/components/filter-field/FilterField.module.css +0 -379
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.js +0 -52
- package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.module.css +0 -59
- package/dist/components/forms/checkbox/Checkbox.js +0 -28
- package/dist/components/forms/checkbox/Checkbox.module.css +0 -103
- package/dist/components/forms/checkbox-group/CheckboxGroup.js +0 -75
- package/dist/components/forms/checkbox-group/CheckboxGroup.module.css +0 -115
- package/dist/components/forms/form-select/FormSelect.js +0 -86
- package/dist/components/forms/form-select/FormSelect.module.css +0 -236
- package/dist/components/forms/input/Input.js +0 -77
- package/dist/components/forms/input/Input.module.css +0 -468
- package/dist/components/forms/input-container/InputContainer.js +0 -15
- package/dist/components/forms/input-container/InputContainer.module.css +0 -60
- package/dist/components/forms/multi-select/MultiSelect.js +0 -122
- package/dist/components/forms/radio-buttons/RadioButton.js +0 -26
- package/dist/components/forms/radio-buttons/RadioButtonGroup.js +0 -19
- package/dist/components/forms/radio-buttons/RadioButtons.module.css +0 -118
- package/dist/components/forms/select/Select.js +0 -185
- package/dist/components/forms/select/Select.module.css +0 -32
- package/dist/components/forms/text-area/Textarea.js +0 -47
- package/dist/components/forms/text-area/Textarea.module.css +0 -70
- package/dist/components/forms/typeahead/Typeahead.js +0 -668
- package/dist/components/forms/typeahead/Typeahead.module.css +0 -38
- package/dist/components/grid/Grid.js +0 -23
- package/dist/components/grid/Grid.module.css +0 -35
- package/dist/components/headline/CollapsibleHeadline.js +0 -29
- package/dist/components/headline/Headline.js +0 -26
- package/dist/components/headline/Headline.module.css +0 -185
- package/dist/components/hyperlink/Hyperlink.js +0 -40
- package/dist/components/hyperlink/Hyperlink.module.css +0 -107
- package/dist/components/icon/Icon.js +0 -14
- package/dist/components/icon/Icon.module.css +0 -36
- package/dist/components/interval-select/IntervalSelect.js +0 -99
- package/dist/components/json-viewer/HighlightedText.js +0 -6
- package/dist/components/json-viewer/JsonNode.js +0 -30
- package/dist/components/json-viewer/JsonViewer.js +0 -68
- package/dist/components/json-viewer/JsonViewer.module.css +0 -346
- package/dist/components/json-viewer/types.js +0 -1
- package/dist/components/json-viewer/useClipboardStatus.js +0 -11
- package/dist/components/json-viewer/utils.js +0 -125
- package/dist/components/menu/Menu.js +0 -165
- package/dist/components/menu/Menu.module.css +0 -220
- package/dist/components/meta-bar/MetaBar.js +0 -9
- package/dist/components/meta-bar/MetaBar.module.css +0 -27
- package/dist/components/nav-bar/NavBar.js +0 -29
- package/dist/components/nav-bar/NavBar.module.css +0 -221
- package/dist/components/overlay/fade-overlay/FadeOverlay.js +0 -8
- package/dist/components/overlay/fade-overlay/FadeOverlay.module.css +0 -54
- package/dist/components/overlay/modal/Modal.js +0 -115
- package/dist/components/overlay/modal/Modal.module.css +0 -109
- package/dist/components/overlay/modal/provider/ModalProvider.js +0 -73
- package/dist/components/overlay/side-panel/SidePanel.js +0 -83
- package/dist/components/overlay/side-panel/SidePanel.module.css +0 -177
- package/dist/components/overlay/side-panel/useSidePanel.js +0 -11
- package/dist/components/overlay/tooltip/Tooltip.js +0 -17
- package/dist/components/overlay/tooltip/Tooltip.module.css +0 -104
- package/dist/components/overlay/tooltip/TooltipProvider.js +0 -255
- package/dist/components/overlay/tooltip/useTooltipTrigger.js +0 -118
- package/dist/components/page/Page.js +0 -11
- package/dist/components/page/Page.module.css +0 -89
- package/dist/components/page-layout/PageLayout.js +0 -76
- package/dist/components/page-layout/PageLayout.module.css +0 -236
- package/dist/components/page-layout/components/layout-footer/LayoutFooter.js +0 -27
- package/dist/components/page-layout/components/layout-footer/LayoutFooter.module.css +0 -89
- package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.js +0 -14
- package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.module.css +0 -84
- package/dist/components/pagination/Pagination.js +0 -56
- package/dist/components/pagination/Pagination.module.css +0 -25
- package/dist/components/panel/Panel.js +0 -7
- package/dist/components/panel/Panel.module.css +0 -29
- package/dist/components/popover/Popover.js +0 -257
- package/dist/components/popover/Popover.module.css +0 -54
- package/dist/components/search-box/SearchBox.js +0 -170
- package/dist/components/search-box/SearchBox.module.css +0 -21
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.js +0 -48
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.module.css +0 -167
- package/dist/components/sidebar/Sidebar.js +0 -6
- package/dist/components/sidebar/components/SidebarItem.js +0 -8
- package/dist/components/sidebar/components/SidebarItem.module.css +0 -0
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.js +0 -63
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.module.css +0 -29
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.js +0 -153
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.module.css +0 -260
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.js +0 -18
- package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.module.css +0 -106
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.js +0 -26
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.module.css +0 -20
- package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.js +0 -30
- package/dist/components/sidebar/providers/SidebarProvider.js +0 -229
- package/dist/components/skeleton-loader/SkeletonLoader.js +0 -73
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.js +0 -13
- package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.module.css +0 -51
- package/dist/components/split-button/SplitButton.js +0 -10
- package/dist/components/split-button/SplitButton.module.css +0 -32
- package/dist/components/split-pane/SplitPane.js +0 -107
- package/dist/components/split-pane/SplitPane.module.css +0 -111
- package/dist/components/split-pane/provider/SplitPaneContext.js +0 -124
- package/dist/components/stack/Stack.js +0 -33
- package/dist/components/stack/Stack.module.css +0 -61
- package/dist/components/state-page/StatePage.js +0 -20
- package/dist/components/state-page/StatePage.module.css +0 -9
- package/dist/components/state-page/empty.js +0 -2
- package/dist/components/state-page/error.js +0 -2
- package/dist/components/state-page/notFound.js +0 -2
- package/dist/components/sticky-footer-layout/StickyFooterLayout.js +0 -64
- package/dist/components/table/Table.js +0 -50
- package/dist/components/table/Table.module.css +0 -536
- package/dist/components/table/Table.types.js +0 -1
- package/dist/components/table/TanstackTable.js +0 -111
- package/dist/components/table/components/TableBody.js +0 -10
- package/dist/components/table/components/TableHeader.js +0 -7
- package/dist/components/table/components/TableHeaderCell.js +0 -24
- package/dist/components/table/components/TableLoadingBody.js +0 -26
- package/dist/components/table/components/TablePagination.js +0 -1
- package/dist/components/table/components/TableRow.js +0 -54
- package/dist/components/table/components/TableSelectionCell.js +0 -16
- package/dist/components/table/components/column-resizer/ColumnResizer.js +0 -5
- package/dist/components/table/components/column-resizer/ColumnResizer.module.css +0 -22
- package/dist/components/table/components/empty-state/EmptyState.js +0 -23
- package/dist/components/table/components/empty-state/EmptyState.module.css +0 -4
- package/dist/components/table/components/table-settings/TableSettings.js +0 -63
- package/dist/components/table/hooks/useTableRowInteractions.js +0 -30
- package/dist/components/table/table.classes.js +0 -23
- package/dist/components/table/table.utils.js +0 -47
- package/dist/components/table/tanstackTable.utils.js +0 -175
- package/dist/components/tabs/Tabs.js +0 -125
- package/dist/components/tabs/Tabs.module.css +0 -233
- package/dist/components/theme-button/ThemeButton.js +0 -23
- package/dist/components/toast/Toast.js +0 -20
- package/dist/components/toast/Toast.module.css +0 -161
- package/dist/components/toast/provider/ToastProvider.js +0 -70
- package/dist/components/user-display/UserDisplay.js +0 -6
- package/dist/components/user-display/UserDisplay.module.css +0 -25
- package/dist/constants/severity.js +0 -24
- package/dist/constants/severity.types.js +0 -1
- package/dist/constants/sizes.js +0 -7
- package/dist/hooks/useDeviceSize.js +0 -32
- package/dist/hooks/useListNavigation.js +0 -234
- package/dist/hooks/usePagination.js +0 -140
- package/dist/hooks/useSorting.js +0 -118
- package/dist/hooks/useTableData.js +0 -45
- package/dist/hooks/useTableSelection.js +0 -164
- package/dist/hooks/useTableSettings.js +0 -71
- package/dist/hooks/useTheme.js +0 -66
- package/dist/hooks/useTimeDuration.js +0 -68
- package/dist/hooks/useViewportFill.js +0 -77
- package/dist/styles/animation.js +0 -5
- package/dist/styles/themes/types.js +0 -1
- package/dist/types/a11y-props.types.js +0 -1
- package/dist/types/sizes.types.js +0 -1
- package/dist/utils/arrays/nested-filtering.js +0 -48
- package/dist/utils/date/formatDate.js +0 -51
- package/dist/utils/localStorage.utils.js +0 -78
- package/dist/utils/text/get-highlighted-segments.js +0 -46
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Search, X } from 'lucide-react';
|
|
4
|
-
import { useEffect, useId, useMemo, useState } from 'react';
|
|
5
|
-
import { JsonNode } from './JsonNode';
|
|
6
|
-
import styles from './JsonViewer.module.css';
|
|
7
|
-
import { useClipboardStatus } from './useClipboardStatus';
|
|
8
|
-
import { collectExpandableNodeIds, collectInitiallyExpandedNodeIds, collectSearchMatches, isJsonValue, normalizeSearch, } from './utils';
|
|
9
|
-
export function JsonViewer({ value, defaultExpandedDepth = 2, expandAll = false, searchDebounceMs = 800, helperText, searchPlaceholder = 'Søg i nøgler, stier og værdier', emptySearchText = 'Ingen matchende noder fundet.', className, maxHeight, }) {
|
|
10
|
-
const [queryInput, setQueryInput] = useState('');
|
|
11
|
-
const [query, setQuery] = useState('');
|
|
12
|
-
const normalizedQuery = normalizeSearch(query);
|
|
13
|
-
const inputId = useId();
|
|
14
|
-
const { copiedId, setCopiedId } = useClipboardStatus();
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
const timeoutId = window.setTimeout(() => {
|
|
17
|
-
setQuery(queryInput);
|
|
18
|
-
}, searchDebounceMs);
|
|
19
|
-
return () => window.clearTimeout(timeoutId);
|
|
20
|
-
}, [queryInput, searchDebounceMs]);
|
|
21
|
-
const safeValue = useMemo(() => {
|
|
22
|
-
if (isJsonValue(value))
|
|
23
|
-
return value;
|
|
24
|
-
return {
|
|
25
|
-
unsupported: {
|
|
26
|
-
besked: 'Den angivne værdi kan ikke vises som JSON',
|
|
27
|
-
modtagetType: typeof value,
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
}, [value]);
|
|
31
|
-
const matches = useMemo(() => (normalizedQuery ? collectSearchMatches(safeValue, normalizedQuery) : new Map()), [normalizedQuery, safeValue]);
|
|
32
|
-
const allExpandableNodeIds = useMemo(() => collectExpandableNodeIds(safeValue), [safeValue]);
|
|
33
|
-
const [expandedNodeIds, setExpandedNodeIds] = useState(() => new Set(collectInitiallyExpandedNodeIds(safeValue, defaultExpandedDepth, expandAll)));
|
|
34
|
-
const hasResults = normalizedQuery ? matches.size > 0 : true;
|
|
35
|
-
const handleCopy = async (nodeId, rawValue) => {
|
|
36
|
-
try {
|
|
37
|
-
await navigator.clipboard.writeText(rawValue);
|
|
38
|
-
setCopiedId(nodeId);
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
setCopiedId(null);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const handleExpandAll = () => {
|
|
45
|
-
setExpandedNodeIds(new Set(allExpandableNodeIds));
|
|
46
|
-
};
|
|
47
|
-
const handleCollapseAll = () => {
|
|
48
|
-
setExpandedNodeIds(new Set());
|
|
49
|
-
};
|
|
50
|
-
const handleToggleNode = (nodeId) => {
|
|
51
|
-
setExpandedNodeIds(current => {
|
|
52
|
-
const next = new Set(current);
|
|
53
|
-
if (next.has(nodeId))
|
|
54
|
-
next.delete(nodeId);
|
|
55
|
-
else
|
|
56
|
-
next.add(nodeId);
|
|
57
|
-
return next;
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
return (_jsxs("section", { className: [styles.viewer, className].filter(Boolean).join(' '), children: [_jsxs("div", { className: styles.toolbar, children: [_jsxs("div", { className: styles.toolbarTop, children: [_jsxs("label", { htmlFor: inputId, className: styles.searchField, children: [_jsx(Search, { className: styles.searchIcon, "aria-hidden": "true" }), _jsx("input", { id: inputId, type: "search", value: queryInput, onChange: event => setQueryInput(event.target.value), placeholder: searchPlaceholder, className: styles.searchInput }), queryInput ? (_jsx("button", { type: "button", className: styles.clearButton, "aria-label": "Ryd s\u00F8gning", onClick: () => {
|
|
61
|
-
setQueryInput('');
|
|
62
|
-
setQuery('');
|
|
63
|
-
}, children: _jsx(X, { "aria-hidden": "true" }) })) : null] }), _jsxs("div", { className: styles.actions, children: [_jsx("button", { type: "button", className: styles.toolbarButton, onClick: handleExpandAll, disabled: Boolean(normalizedQuery), children: "Fold alle ud" }), _jsx("button", { type: "button", className: styles.toolbarButton, onClick: handleCollapseAll, disabled: Boolean(normalizedQuery), children: "Fold alle sammen" })] })] }), _jsxs("div", { className: styles.metaRow, children: [helperText ? _jsx("span", { className: styles.helperText, children: helperText }) : _jsx("span", {}), _jsx("span", { className: styles.statusText, children: normalizedQuery
|
|
64
|
-
? `${matches.size} matchende node${matches.size === 1 ? '' : 'r'}`
|
|
65
|
-
: '' })] })] }), _jsx("div", { className: styles.treePane, role: "tree", "aria-label": "JSON-visning", style: maxHeight !== undefined
|
|
66
|
-
? { maxHeight: typeof maxHeight === 'number' ? `${maxHeight}px` : maxHeight }
|
|
67
|
-
: undefined, children: hasResults ? (_jsx(JsonNode, { keyName: undefined, path: [], value: safeValue, depth: 0, defaultExpandedDepth: defaultExpandedDepth, query: normalizedQuery, matches: matches, expandedNodeIds: expandedNodeIds, onToggleNode: handleToggleNode, copiedId: copiedId, onCopy: handleCopy })) : (_jsx("div", { className: styles.emptyState, children: emptySearchText })) })] }));
|
|
68
|
-
}
|
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
.viewer {
|
|
2
|
-
--json-pane-bg: var(--color-bg-inverse);
|
|
3
|
-
--json-pane-border: color-mix(in oklab, var(--color-fg-inverse) 12%, transparent);
|
|
4
|
-
--json-pane-border-strong: color-mix(in oklab, var(--color-fg-inverse) 18%, transparent);
|
|
5
|
-
--json-pane-text: var(--color-fg-inverse);
|
|
6
|
-
--json-pane-muted: color-mix(in oklab, var(--color-fg-inverse) 64%, transparent);
|
|
7
|
-
--json-pane-subtle: color-mix(in oklab, var(--color-fg-inverse) 44%, transparent);
|
|
8
|
-
--json-pane-hover: color-mix(in oklab, var(--color-fg-inverse) 8%, transparent);
|
|
9
|
-
--json-pane-selected: color-mix(in oklab, var(--color-brand) 24%, transparent);
|
|
10
|
-
--json-pane-highlight: color-mix(
|
|
11
|
-
in oklab,
|
|
12
|
-
var(--color-brand) 68%,
|
|
13
|
-
var(--color-syntax-accent) 32%
|
|
14
|
-
);
|
|
15
|
-
--color-highlight-bg: color-mix(in oklab, var(--json-pane-highlight) 58%, transparent);
|
|
16
|
-
--color-highlight-fg: var(--color-fg-inverse);
|
|
17
|
-
--json-pane-key: color-mix(in oklab, var(--color-fg-inverse) 88%, var(--color-syntax-accent) 12%);
|
|
18
|
-
--json-pane-string: color-mix(in oklab, var(--color-syntax-string) 78%, white 22%);
|
|
19
|
-
--json-pane-number: color-mix(in oklab, var(--color-syntax-number) 76%, white 24%);
|
|
20
|
-
--json-pane-boolean: color-mix(in oklab, var(--color-syntax-boolean) 74%, white 26%);
|
|
21
|
-
--json-pane-null: color-mix(in oklab, var(--color-fg-inverse) 54%, transparent);
|
|
22
|
-
|
|
23
|
-
display: flex;
|
|
24
|
-
flex-direction: column;
|
|
25
|
-
gap: var(--spacing-sm);
|
|
26
|
-
background: var(--json-pane-bg);
|
|
27
|
-
color: var(--json-pane-text);
|
|
28
|
-
border: var(--border-width-thin) solid var(--json-pane-border);
|
|
29
|
-
border-radius: var(--border-radius-xl);
|
|
30
|
-
box-shadow: var(--shadow-md);
|
|
31
|
-
padding: var(--spacing-sm);
|
|
32
|
-
font-family: var(--font-family-mono);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.toolbar {
|
|
36
|
-
display: grid;
|
|
37
|
-
gap: var(--spacing-xs);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.toolbarTop {
|
|
41
|
-
display: grid;
|
|
42
|
-
grid-template-columns: minmax(0, 1fr) auto;
|
|
43
|
-
gap: var(--spacing-sm);
|
|
44
|
-
align-items: center;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.searchField {
|
|
48
|
-
display: grid;
|
|
49
|
-
grid-template-columns: auto minmax(0, 1fr) auto;
|
|
50
|
-
align-items: center;
|
|
51
|
-
gap: var(--spacing-xs);
|
|
52
|
-
min-height: var(--component-size-md);
|
|
53
|
-
padding-inline: var(--spacing-sm);
|
|
54
|
-
border: var(--border-width-thin) solid var(--json-pane-border);
|
|
55
|
-
border-radius: var(--border-radius-lg);
|
|
56
|
-
background: transparent;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.searchField:focus-within {
|
|
60
|
-
border-color: var(--json-pane-border-strong);
|
|
61
|
-
box-shadow: var(--focus-ring);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.searchIcon,
|
|
65
|
-
.clearButton svg {
|
|
66
|
-
inline-size: var(--icon-size-sm);
|
|
67
|
-
block-size: var(--icon-size-sm);
|
|
68
|
-
color: var(--json-pane-subtle);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.searchInput {
|
|
72
|
-
inline-size: 100%;
|
|
73
|
-
min-inline-size: 0;
|
|
74
|
-
min-block-size: var(--component-size-md);
|
|
75
|
-
background: transparent;
|
|
76
|
-
border: 0;
|
|
77
|
-
color: var(--json-pane-text);
|
|
78
|
-
font: inherit;
|
|
79
|
-
outline: none;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.searchInput::placeholder {
|
|
83
|
-
color: var(--json-pane-subtle);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.clearButton {
|
|
87
|
-
display: inline-flex;
|
|
88
|
-
align-items: center;
|
|
89
|
-
justify-content: center;
|
|
90
|
-
inline-size: var(--component-size-xs);
|
|
91
|
-
block-size: var(--component-size-xs);
|
|
92
|
-
border: 0;
|
|
93
|
-
border-radius: var(--border-radius-round);
|
|
94
|
-
background: transparent;
|
|
95
|
-
cursor: pointer;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.clearButton:hover {
|
|
99
|
-
background: var(--json-pane-hover);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.metaRow {
|
|
103
|
-
display: flex;
|
|
104
|
-
align-items: center;
|
|
105
|
-
justify-content: space-between;
|
|
106
|
-
gap: var(--spacing-md);
|
|
107
|
-
font-size: var(--font-size-xs);
|
|
108
|
-
color: var(--json-pane-muted);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.actions {
|
|
112
|
-
display: inline-flex;
|
|
113
|
-
align-items: center;
|
|
114
|
-
gap: var(--spacing-xs);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.toolbarButton {
|
|
118
|
-
min-block-size: var(--component-size-sm);
|
|
119
|
-
padding-inline: var(--spacing-sm);
|
|
120
|
-
border: var(--border-width-thin) solid var(--json-pane-border);
|
|
121
|
-
border-radius: var(--border-radius-md);
|
|
122
|
-
background: transparent;
|
|
123
|
-
color: var(--json-pane-text);
|
|
124
|
-
font: inherit;
|
|
125
|
-
cursor: pointer;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.toolbarButton:hover:not(:disabled) {
|
|
129
|
-
background: var(--json-pane-hover);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.toolbarButton:focus-visible {
|
|
133
|
-
outline: none;
|
|
134
|
-
box-shadow: var(--focus-ring);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
.toolbarButton:disabled {
|
|
138
|
-
opacity: 0.45;
|
|
139
|
-
cursor: default;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.helperText,
|
|
143
|
-
.statusText {
|
|
144
|
-
min-inline-size: 0;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.treePane {
|
|
148
|
-
display: flex;
|
|
149
|
-
flex-direction: column;
|
|
150
|
-
gap: var(--spacing-2xs);
|
|
151
|
-
background: transparent;
|
|
152
|
-
padding: 0;
|
|
153
|
-
overflow: auto;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
.node {
|
|
157
|
-
display: flex;
|
|
158
|
-
flex-direction: column;
|
|
159
|
-
gap: 1px;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
.row,
|
|
163
|
-
.pathHint {
|
|
164
|
-
padding-left: calc(var(--json-indent) * var(--spacing-md));
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.row {
|
|
168
|
-
display: flex;
|
|
169
|
-
align-items: flex-start;
|
|
170
|
-
min-inline-size: 0;
|
|
171
|
-
border-radius: var(--border-radius-md);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
.row[data-match='true'] {
|
|
175
|
-
background: var(--json-pane-selected);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
.toggle,
|
|
179
|
-
.valueButton {
|
|
180
|
-
display: inline-flex;
|
|
181
|
-
align-items: center;
|
|
182
|
-
gap: var(--spacing-xs);
|
|
183
|
-
min-inline-size: 0;
|
|
184
|
-
inline-size: 100%;
|
|
185
|
-
padding-block: 6px;
|
|
186
|
-
padding-inline: var(--spacing-xs);
|
|
187
|
-
background: transparent;
|
|
188
|
-
border: 0;
|
|
189
|
-
border-radius: var(--border-radius-md);
|
|
190
|
-
color: inherit;
|
|
191
|
-
text-align: left;
|
|
192
|
-
cursor: pointer;
|
|
193
|
-
font: inherit;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
.toggle {
|
|
197
|
-
justify-content: flex-start;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
.valueButton {
|
|
201
|
-
justify-content: flex-start;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
.toggle:hover,
|
|
205
|
-
.valueButton:hover {
|
|
206
|
-
background: var(--json-pane-hover);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
.toggle:focus-visible,
|
|
210
|
-
.valueButton:focus-visible,
|
|
211
|
-
.clearButton:focus-visible {
|
|
212
|
-
outline: none;
|
|
213
|
-
box-shadow: var(--focus-ring);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
.toggle svg,
|
|
217
|
-
.copyState svg {
|
|
218
|
-
inline-size: var(--icon-size-sm);
|
|
219
|
-
block-size: var(--icon-size-sm);
|
|
220
|
-
flex: 0 0 auto;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
.rowLabel {
|
|
224
|
-
display: inline-flex;
|
|
225
|
-
align-items: baseline;
|
|
226
|
-
flex-wrap: nowrap;
|
|
227
|
-
gap: 6px;
|
|
228
|
-
min-inline-size: 0;
|
|
229
|
-
flex: 1 1 auto;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
.keyChunk {
|
|
233
|
-
display: inline-flex;
|
|
234
|
-
align-items: baseline;
|
|
235
|
-
gap: 4px;
|
|
236
|
-
flex: 0 0 auto;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
.rootLabel,
|
|
240
|
-
.key {
|
|
241
|
-
color: var(--json-pane-key);
|
|
242
|
-
font-weight: var(--font-weight-medium);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
.punctuation,
|
|
246
|
-
.bracket {
|
|
247
|
-
color: var(--json-pane-subtle);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
.summary,
|
|
251
|
-
.pathHint {
|
|
252
|
-
color: var(--json-pane-muted);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
.children {
|
|
256
|
-
display: flex;
|
|
257
|
-
flex-direction: column;
|
|
258
|
-
gap: 1px;
|
|
259
|
-
position: relative;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
.children::before {
|
|
263
|
-
content: '';
|
|
264
|
-
position: absolute;
|
|
265
|
-
left: calc(var(--spacing-md) - 2px);
|
|
266
|
-
top: 0;
|
|
267
|
-
bottom: 0;
|
|
268
|
-
width: 1px;
|
|
269
|
-
background: color-mix(in oklab, var(--color-fg-inverse) 8%, transparent);
|
|
270
|
-
pointer-events: none;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
.value {
|
|
274
|
-
min-inline-size: 0;
|
|
275
|
-
flex: 0 1 auto;
|
|
276
|
-
word-break: break-word;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
.valueString {
|
|
280
|
-
color: var(--json-pane-string);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
.valueNumber {
|
|
284
|
-
color: var(--json-pane-number);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
.valueBoolean {
|
|
288
|
-
color: var(--json-pane-boolean);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
.valueNull {
|
|
292
|
-
color: var(--json-pane-null);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
.copyState {
|
|
296
|
-
display: inline-flex;
|
|
297
|
-
align-items: center;
|
|
298
|
-
gap: var(--spacing-xxs);
|
|
299
|
-
margin-left: auto;
|
|
300
|
-
color: var(--json-pane-subtle);
|
|
301
|
-
font-size: var(--font-size-xs);
|
|
302
|
-
white-space: nowrap;
|
|
303
|
-
opacity: 0;
|
|
304
|
-
transform: translateX(4px);
|
|
305
|
-
transition:
|
|
306
|
-
opacity var(--transition-fast) var(--ease-standard),
|
|
307
|
-
transform var(--transition-fast) var(--ease-standard);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
.valueButton:hover .copyState,
|
|
311
|
-
.valueButton:focus-visible .copyState,
|
|
312
|
-
.valueButton:focus-within .copyState {
|
|
313
|
-
opacity: 1;
|
|
314
|
-
transform: translateX(0);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
.valueButton[title='Kopieret'] .copyState {
|
|
318
|
-
opacity: 1;
|
|
319
|
-
transform: translateX(0);
|
|
320
|
-
color: color-mix(in oklab, var(--color-syntax-string) 78%, white 22%);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
.emptyState {
|
|
324
|
-
padding: var(--spacing-md);
|
|
325
|
-
color: var(--json-pane-muted);
|
|
326
|
-
text-align: center;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
@media (max-width: 640px) {
|
|
330
|
-
.toolbarTop {
|
|
331
|
-
grid-template-columns: 1fr;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
.actions {
|
|
335
|
-
flex-wrap: wrap;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
.metaRow {
|
|
339
|
-
flex-direction: column;
|
|
340
|
-
align-items: flex-start;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
.copyState span {
|
|
344
|
-
display: none;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
export function useClipboardStatus() {
|
|
3
|
-
const [copiedId, setCopiedId] = useState(null);
|
|
4
|
-
useEffect(() => {
|
|
5
|
-
if (!copiedId)
|
|
6
|
-
return;
|
|
7
|
-
const timer = window.setTimeout(() => setCopiedId(null), 1400);
|
|
8
|
-
return () => window.clearTimeout(timer);
|
|
9
|
-
}, [copiedId]);
|
|
10
|
-
return { copiedId, setCopiedId };
|
|
11
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
export function isJsonArray(value) {
|
|
2
|
-
return Array.isArray(value);
|
|
3
|
-
}
|
|
4
|
-
export function isJsonObject(value) {
|
|
5
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
6
|
-
}
|
|
7
|
-
export function isJsonValue(value) {
|
|
8
|
-
if (value === null)
|
|
9
|
-
return true;
|
|
10
|
-
if (Array.isArray(value))
|
|
11
|
-
return value.every(isJsonValue);
|
|
12
|
-
if (typeof value === 'object') {
|
|
13
|
-
return Object.values(value).every(isJsonValue);
|
|
14
|
-
}
|
|
15
|
-
return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
|
|
16
|
-
}
|
|
17
|
-
export function getValueType(value) {
|
|
18
|
-
if (value === null)
|
|
19
|
-
return 'null';
|
|
20
|
-
if (Array.isArray(value))
|
|
21
|
-
return 'array';
|
|
22
|
-
if (typeof value === 'object')
|
|
23
|
-
return 'object';
|
|
24
|
-
if (typeof value === 'string')
|
|
25
|
-
return 'string';
|
|
26
|
-
if (typeof value === 'number')
|
|
27
|
-
return 'number';
|
|
28
|
-
if (typeof value === 'boolean')
|
|
29
|
-
return 'boolean';
|
|
30
|
-
return 'string';
|
|
31
|
-
}
|
|
32
|
-
export function formatPrimitive(value) {
|
|
33
|
-
if (value === null)
|
|
34
|
-
return 'null';
|
|
35
|
-
if (typeof value === 'string')
|
|
36
|
-
return JSON.stringify(value);
|
|
37
|
-
return String(value);
|
|
38
|
-
}
|
|
39
|
-
export function getPrimitiveRawValue(value) {
|
|
40
|
-
if (value === null)
|
|
41
|
-
return 'null';
|
|
42
|
-
return String(value);
|
|
43
|
-
}
|
|
44
|
-
export function getSummary(value) {
|
|
45
|
-
if (isJsonArray(value)) {
|
|
46
|
-
return `${value.length} element${value.length === 1 ? '' : 'er'}`;
|
|
47
|
-
}
|
|
48
|
-
if (!isJsonObject(value))
|
|
49
|
-
return '0 felter';
|
|
50
|
-
const count = Object.keys(value).length;
|
|
51
|
-
return `${count} felt${count === 1 ? '' : 'er'}`;
|
|
52
|
-
}
|
|
53
|
-
export function getNodeId(path) {
|
|
54
|
-
return path.length === 0 ? '$' : `$.${path.join('.')}`;
|
|
55
|
-
}
|
|
56
|
-
export function getPathLabel(path) {
|
|
57
|
-
return getNodeId(path);
|
|
58
|
-
}
|
|
59
|
-
export function normalizeSearch(value) {
|
|
60
|
-
return value.trim().toLowerCase();
|
|
61
|
-
}
|
|
62
|
-
export function capitalize(value) {
|
|
63
|
-
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
64
|
-
}
|
|
65
|
-
function valueToSearchString(value) {
|
|
66
|
-
return value === null ? 'null' : String(value).toLowerCase();
|
|
67
|
-
}
|
|
68
|
-
export function collectSearchMatches(value, query, path = [], key) {
|
|
69
|
-
const matches = new Map();
|
|
70
|
-
const visit = (current, currentPath, currentKey) => {
|
|
71
|
-
const nodeId = getNodeId(currentPath);
|
|
72
|
-
const pathLabel = getPathLabel(currentPath).toLowerCase();
|
|
73
|
-
const keyLabel = (currentKey !== null && currentKey !== void 0 ? currentKey : '').toLowerCase();
|
|
74
|
-
let self = keyLabel.includes(query) || pathLabel.includes(query);
|
|
75
|
-
let descendant = false;
|
|
76
|
-
if (isJsonArray(current)) {
|
|
77
|
-
current.forEach((item, index) => {
|
|
78
|
-
const childMatches = visit(item, [...currentPath, String(index)], String(index));
|
|
79
|
-
descendant = descendant || childMatches;
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
else if (isJsonObject(current)) {
|
|
83
|
-
Object.entries(current).forEach(([childKey, childValue]) => {
|
|
84
|
-
const childMatches = visit(childValue, [...currentPath, childKey], childKey);
|
|
85
|
-
descendant = descendant || childMatches;
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
self = self || valueToSearchString(current).includes(query);
|
|
90
|
-
}
|
|
91
|
-
const any = self || descendant;
|
|
92
|
-
if (any) {
|
|
93
|
-
matches.set(nodeId, { self, descendant });
|
|
94
|
-
}
|
|
95
|
-
return any;
|
|
96
|
-
};
|
|
97
|
-
visit(value, path, key);
|
|
98
|
-
return matches;
|
|
99
|
-
}
|
|
100
|
-
export function collectExpandableNodeIds(value, path = []) {
|
|
101
|
-
if (!isJsonArray(value) && !isJsonObject(value))
|
|
102
|
-
return [];
|
|
103
|
-
const nodeId = getNodeId(path);
|
|
104
|
-
const childEntries = isJsonArray(value)
|
|
105
|
-
? value.map((item, index) => [String(index), item])
|
|
106
|
-
: Object.entries(value);
|
|
107
|
-
return [
|
|
108
|
-
nodeId,
|
|
109
|
-
...childEntries.flatMap(([childKey, childValue]) => collectExpandableNodeIds(childValue, [...path, childKey])),
|
|
110
|
-
];
|
|
111
|
-
}
|
|
112
|
-
export function collectInitiallyExpandedNodeIds(value, defaultExpandedDepth, expandAll, depth = 0, path = []) {
|
|
113
|
-
if (!isJsonArray(value) && !isJsonObject(value))
|
|
114
|
-
return [];
|
|
115
|
-
const nodeId = getNodeId(path);
|
|
116
|
-
const childEntries = isJsonArray(value)
|
|
117
|
-
? value.map((item, index) => [String(index), item])
|
|
118
|
-
: Object.entries(value);
|
|
119
|
-
const includeNode = expandAll || depth < defaultExpandedDepth;
|
|
120
|
-
const nested = childEntries.flatMap(([childKey, childValue]) => collectInitiallyExpandedNodeIds(childValue, defaultExpandedDepth, expandAll, depth + 1, [
|
|
121
|
-
...path,
|
|
122
|
-
childKey,
|
|
123
|
-
]));
|
|
124
|
-
return includeNode ? [nodeId, ...nested] : nested;
|
|
125
|
-
}
|