@dbcdk/react-components 0.0.96 → 0.0.98
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/page/Page.d.ts +2 -1
- package/dist/components/page-layout/PageLayout.d.ts +0 -2
- package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.d.ts +1 -12
- package/dist/components/skeleton-loader/SkeletonLoader.d.ts +1 -1
- 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/components/tabs/Tabs.d.ts +2 -1
- package/dist/constants/chart-colors.d.ts +2 -0
- package/dist/constants/chart-colors.types.d.ts +3 -0
- package/dist/index.cjs +12830 -0
- package/dist/index.css +7084 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +12720 -79
- package/dist/styles/styles.css +6 -1
- package/dist/styles/themes/dbc/colors.css +14 -6
- package/dist/styles/themes/forfatterweb/light.css +17 -0
- package/dist/styles.css +6 -1
- package/dist/tanstack.cjs +2660 -0
- package/dist/tanstack.css +1267 -0
- package/dist/tanstack.js +2636 -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,104 +0,0 @@
|
|
|
1
|
-
/* Layout neutral wrapper */
|
|
2
|
-
.container {
|
|
3
|
-
display: contents;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
/* Measurable trigger box without forcing full width */
|
|
7
|
-
.trigger {
|
|
8
|
-
display: inline-flex;
|
|
9
|
-
align-items: center;
|
|
10
|
-
max-width: 100%;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.trigger:focus-visible {
|
|
14
|
-
outline: none;
|
|
15
|
-
box-shadow: var(--focus-ring);
|
|
16
|
-
border-radius: var(--border-radius-default);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/* Bubble */
|
|
20
|
-
.bubble {
|
|
21
|
-
position: fixed;
|
|
22
|
-
z-index: var(--z-tooltip);
|
|
23
|
-
pointer-events: none;
|
|
24
|
-
background: var(--color-fg-default);
|
|
25
|
-
color: var(--color-fg-on-strong);
|
|
26
|
-
font-size: var(--font-size-xs);
|
|
27
|
-
line-height: var(--line-height-tight);
|
|
28
|
-
padding: var(--spacing-xxs) var(--spacing-sm);
|
|
29
|
-
border-radius: var(--border-radius-default);
|
|
30
|
-
|
|
31
|
-
/*
|
|
32
|
-
- Don't let it run wild horizontally
|
|
33
|
-
- But don't clip: allow wrap
|
|
34
|
-
- Keep some relation to viewport
|
|
35
|
-
*/
|
|
36
|
-
max-width: min(360px, calc(100vw - 16px));
|
|
37
|
-
white-space: normal;
|
|
38
|
-
overflow-wrap: break-word; /* wrap long words nicely */
|
|
39
|
-
word-break: normal;
|
|
40
|
-
|
|
41
|
-
/*
|
|
42
|
-
If your tooltips often include URLs/IDs, consider 'anywhere' instead:
|
|
43
|
-
overflow-wrap: anywhere;
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
/* Optional: nicer shadow than box-shadow for rounded bubble */
|
|
47
|
-
filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.22));
|
|
48
|
-
|
|
49
|
-
/* Hidden by default */
|
|
50
|
-
opacity: 0;
|
|
51
|
-
visibility: hidden;
|
|
52
|
-
|
|
53
|
-
/* Base transform gets overridden by placement rules below */
|
|
54
|
-
transform: translate3d(0, 0, 0);
|
|
55
|
-
|
|
56
|
-
transition:
|
|
57
|
-
opacity var(--transition-fast),
|
|
58
|
-
transform var(--transition-fast),
|
|
59
|
-
visibility 0s linear var(--transition-fast);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.bubble[data-open='true'] {
|
|
63
|
-
opacity: 1;
|
|
64
|
-
visibility: visible;
|
|
65
|
-
transition:
|
|
66
|
-
opacity var(--transition-fast),
|
|
67
|
-
transform var(--transition-fast),
|
|
68
|
-
visibility 0s;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/* Placement-based motion (so it “comes from” the trigger) */
|
|
72
|
-
.bubble[data-placement='top'] {
|
|
73
|
-
transform: translate3d(0, -6px, 0);
|
|
74
|
-
}
|
|
75
|
-
.bubble[data-placement='bottom'] {
|
|
76
|
-
transform: translate3d(0, 6px, 0);
|
|
77
|
-
}
|
|
78
|
-
.bubble[data-placement='left'] {
|
|
79
|
-
transform: translate3d(-6px, 0, 0);
|
|
80
|
-
}
|
|
81
|
-
.bubble[data-placement='right'] {
|
|
82
|
-
transform: translate3d(6px, 0, 0);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/* Open state resets transform to 0 for all placements */
|
|
86
|
-
.bubble[data-open='true'][data-placement='top'],
|
|
87
|
-
.bubble[data-open='true'][data-placement='bottom'],
|
|
88
|
-
.bubble[data-open='true'][data-placement='left'],
|
|
89
|
-
.bubble[data-open='true'][data-placement='right'] {
|
|
90
|
-
transform: translate3d(0, 0, 0);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.bubble svg {
|
|
94
|
-
height: 20px;
|
|
95
|
-
width: 20px;
|
|
96
|
-
flex: 0 0 auto;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
@media (prefers-reduced-motion: reduce) {
|
|
100
|
-
.bubble {
|
|
101
|
-
transition: none;
|
|
102
|
-
transform: none;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, } from 'react';
|
|
4
|
-
import { createPortal } from 'react-dom';
|
|
5
|
-
import styles from './Tooltip.module.css';
|
|
6
|
-
export const TooltipContext = createContext(null);
|
|
7
|
-
const VIEWPORT_PADDING = 8;
|
|
8
|
-
const SHOW_DELAY_MS = 500;
|
|
9
|
-
function clamp(n, min, max) {
|
|
10
|
-
return Math.max(min, Math.min(n, max));
|
|
11
|
-
}
|
|
12
|
-
function flippedPlacement(p) {
|
|
13
|
-
if (p === 'top')
|
|
14
|
-
return 'bottom';
|
|
15
|
-
if (p === 'bottom')
|
|
16
|
-
return 'top';
|
|
17
|
-
if (p === 'left')
|
|
18
|
-
return 'right';
|
|
19
|
-
return 'left';
|
|
20
|
-
}
|
|
21
|
-
function computePosition(args) {
|
|
22
|
-
const { triggerRect, bubbleRect, placement, offset } = args;
|
|
23
|
-
switch (placement) {
|
|
24
|
-
case 'top':
|
|
25
|
-
return {
|
|
26
|
-
left: triggerRect.left + triggerRect.width / 2 - bubbleRect.width / 2,
|
|
27
|
-
top: triggerRect.top - bubbleRect.height - offset,
|
|
28
|
-
};
|
|
29
|
-
case 'bottom':
|
|
30
|
-
return {
|
|
31
|
-
left: triggerRect.left + triggerRect.width / 2 - bubbleRect.width / 2,
|
|
32
|
-
top: triggerRect.bottom + offset,
|
|
33
|
-
};
|
|
34
|
-
case 'left':
|
|
35
|
-
return {
|
|
36
|
-
left: triggerRect.left - bubbleRect.width - offset,
|
|
37
|
-
top: triggerRect.top + triggerRect.height / 2 - bubbleRect.height / 2,
|
|
38
|
-
};
|
|
39
|
-
case 'right':
|
|
40
|
-
return {
|
|
41
|
-
left: triggerRect.right + offset,
|
|
42
|
-
top: triggerRect.top + triggerRect.height / 2 - bubbleRect.height / 2,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function fitsViewport(pos, bubbleRect) {
|
|
47
|
-
const vw = window.innerWidth;
|
|
48
|
-
const vh = window.innerHeight;
|
|
49
|
-
const leftOk = pos.left >= VIEWPORT_PADDING;
|
|
50
|
-
const rightOk = pos.left + bubbleRect.width <= vw - VIEWPORT_PADDING;
|
|
51
|
-
const topOk = pos.top >= VIEWPORT_PADDING;
|
|
52
|
-
const bottomOk = pos.top + bubbleRect.height <= vh - VIEWPORT_PADDING;
|
|
53
|
-
return leftOk && rightOk && topOk && bottomOk;
|
|
54
|
-
}
|
|
55
|
-
function shallowEqualActive(a, b) {
|
|
56
|
-
if (a === b)
|
|
57
|
-
return true;
|
|
58
|
-
if (!a || !b)
|
|
59
|
-
return false;
|
|
60
|
-
return (a.id === b.id &&
|
|
61
|
-
a.open === b.open &&
|
|
62
|
-
a.content === b.content &&
|
|
63
|
-
a.placement === b.placement &&
|
|
64
|
-
a.offset === b.offset &&
|
|
65
|
-
a.triggerEl === b.triggerEl);
|
|
66
|
-
}
|
|
67
|
-
export function TooltipProvider({ children }) {
|
|
68
|
-
const [active, setActive] = useState(null);
|
|
69
|
-
const showTimerRef = useRef(null);
|
|
70
|
-
const show = useCallback((next) => {
|
|
71
|
-
if (showTimerRef.current)
|
|
72
|
-
clearTimeout(showTimerRef.current);
|
|
73
|
-
showTimerRef.current = setTimeout(() => {
|
|
74
|
-
showTimerRef.current = null;
|
|
75
|
-
setActive(curr => {
|
|
76
|
-
const proposed = { ...next, open: true };
|
|
77
|
-
return shallowEqualActive(curr, proposed) ? curr : proposed;
|
|
78
|
-
});
|
|
79
|
-
}, SHOW_DELAY_MS);
|
|
80
|
-
}, []);
|
|
81
|
-
const hide = useCallback((id) => {
|
|
82
|
-
if (showTimerRef.current) {
|
|
83
|
-
clearTimeout(showTimerRef.current);
|
|
84
|
-
showTimerRef.current = null;
|
|
85
|
-
}
|
|
86
|
-
setActive(curr => {
|
|
87
|
-
if (!curr || curr.id !== id)
|
|
88
|
-
return curr;
|
|
89
|
-
return null;
|
|
90
|
-
});
|
|
91
|
-
}, []);
|
|
92
|
-
const update = useCallback((id, patch) => {
|
|
93
|
-
setActive(curr => {
|
|
94
|
-
if (!curr || curr.id !== id)
|
|
95
|
-
return curr;
|
|
96
|
-
const proposed = { ...curr, ...patch };
|
|
97
|
-
return shallowEqualActive(curr, proposed) ? curr : proposed;
|
|
98
|
-
});
|
|
99
|
-
}, []);
|
|
100
|
-
const value = useMemo(() => ({ show, hide, update, active }), [show, hide, update, active]);
|
|
101
|
-
return (_jsxs(TooltipContext.Provider, { value: value, children: [children, _jsx(TooltipLayer, {})] }));
|
|
102
|
-
}
|
|
103
|
-
function TooltipLayer() {
|
|
104
|
-
const ctx = useContext(TooltipContext);
|
|
105
|
-
const active = ctx === null || ctx === void 0 ? void 0 : ctx.active;
|
|
106
|
-
const bubbleRef = useRef(null);
|
|
107
|
-
const [mounted, setMounted] = useState(false);
|
|
108
|
-
// "open" follows provider state; "visible" only becomes true after a successful measure+position.
|
|
109
|
-
const [open, setOpen] = useState(false);
|
|
110
|
-
const [visible, setVisible] = useState(false);
|
|
111
|
-
const [placement, setPlacement] = useState('top');
|
|
112
|
-
const [pos, setPos] = useState({ top: 0, left: 0 });
|
|
113
|
-
// Prevent unnecessary state churn
|
|
114
|
-
const lastPlacementRef = useRef('top');
|
|
115
|
-
const lastPosRef = useRef({ top: 0, left: 0 });
|
|
116
|
-
// Robust switching between triggers (prevents showing new tooltip at old coords)
|
|
117
|
-
const lastActiveIdRef = useRef(null);
|
|
118
|
-
// Track and cancel scheduled recomputes
|
|
119
|
-
const rafRef = useRef(null);
|
|
120
|
-
useEffect(() => setMounted(true), []);
|
|
121
|
-
const recompute = useCallback(() => {
|
|
122
|
-
if (!(active === null || active === void 0 ? void 0 : active.open))
|
|
123
|
-
return;
|
|
124
|
-
const trigger = active.triggerEl;
|
|
125
|
-
const bubble = bubbleRef.current;
|
|
126
|
-
if (!trigger || !bubble)
|
|
127
|
-
return;
|
|
128
|
-
const triggerRect = trigger.getBoundingClientRect();
|
|
129
|
-
const bubbleRect = bubble.getBoundingClientRect();
|
|
130
|
-
// Keep hidden until bubble has real dimensions
|
|
131
|
-
if (bubbleRect.width === 0 || bubbleRect.height === 0) {
|
|
132
|
-
if (visible)
|
|
133
|
-
setVisible(false);
|
|
134
|
-
if (rafRef.current)
|
|
135
|
-
cancelAnimationFrame(rafRef.current);
|
|
136
|
-
rafRef.current = requestAnimationFrame(recompute);
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
const candidates = [active.placement, flippedPlacement(active.placement)];
|
|
140
|
-
let chosen = candidates[0];
|
|
141
|
-
let nextPos = computePosition({
|
|
142
|
-
triggerRect,
|
|
143
|
-
bubbleRect,
|
|
144
|
-
placement: chosen,
|
|
145
|
-
offset: active.offset,
|
|
146
|
-
});
|
|
147
|
-
if (!fitsViewport(nextPos, bubbleRect)) {
|
|
148
|
-
const alt = candidates[1];
|
|
149
|
-
const altPos = computePosition({
|
|
150
|
-
triggerRect,
|
|
151
|
-
bubbleRect,
|
|
152
|
-
placement: alt,
|
|
153
|
-
offset: active.offset,
|
|
154
|
-
});
|
|
155
|
-
if (fitsViewport(altPos, bubbleRect)) {
|
|
156
|
-
chosen = alt;
|
|
157
|
-
nextPos = altPos;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
const vw = window.innerWidth;
|
|
161
|
-
const vh = window.innerHeight;
|
|
162
|
-
const left = clamp(nextPos.left, VIEWPORT_PADDING, vw - bubbleRect.width - VIEWPORT_PADDING);
|
|
163
|
-
const top = clamp(nextPos.top, VIEWPORT_PADDING, vh - bubbleRect.height - VIEWPORT_PADDING);
|
|
164
|
-
// Only update state if changed
|
|
165
|
-
const prevPos = lastPosRef.current;
|
|
166
|
-
if (prevPos.left !== left || prevPos.top !== top) {
|
|
167
|
-
lastPosRef.current = { left, top };
|
|
168
|
-
setPos({ left, top });
|
|
169
|
-
}
|
|
170
|
-
if (lastPlacementRef.current !== chosen) {
|
|
171
|
-
lastPlacementRef.current = chosen;
|
|
172
|
-
setPlacement(chosen);
|
|
173
|
-
}
|
|
174
|
-
if (!visible)
|
|
175
|
-
setVisible(true);
|
|
176
|
-
}, [active === null || active === void 0 ? void 0 : active.open, active === null || active === void 0 ? void 0 : active.triggerEl, active === null || active === void 0 ? void 0 : active.placement, active === null || active === void 0 ? void 0 : active.offset, visible]);
|
|
177
|
-
// Drive open/close local state, reset visibility on open.
|
|
178
|
-
useEffect(() => {
|
|
179
|
-
const nextOpen = !!(active === null || active === void 0 ? void 0 : active.open);
|
|
180
|
-
setOpen(prev => (prev === nextOpen ? prev : nextOpen));
|
|
181
|
-
if (nextOpen)
|
|
182
|
-
setVisible(false);
|
|
183
|
-
if (!nextOpen)
|
|
184
|
-
lastActiveIdRef.current = null;
|
|
185
|
-
}, [active === null || active === void 0 ? void 0 : active.open]);
|
|
186
|
-
// Handle switching from one trigger to another (hide before paint + recompute)
|
|
187
|
-
useLayoutEffect(() => {
|
|
188
|
-
var _a;
|
|
189
|
-
const id = (_a = active === null || active === void 0 ? void 0 : active.id) !== null && _a !== void 0 ? _a : null;
|
|
190
|
-
if (!id)
|
|
191
|
-
return;
|
|
192
|
-
if (lastActiveIdRef.current && lastActiveIdRef.current !== id) {
|
|
193
|
-
// Switching tooltips: hide immediately to avoid flash at previous position
|
|
194
|
-
setVisible(false);
|
|
195
|
-
}
|
|
196
|
-
lastActiveIdRef.current = id;
|
|
197
|
-
// Schedule a recompute after DOM updates
|
|
198
|
-
if (rafRef.current)
|
|
199
|
-
cancelAnimationFrame(rafRef.current);
|
|
200
|
-
rafRef.current = requestAnimationFrame(recompute);
|
|
201
|
-
return () => {
|
|
202
|
-
if (rafRef.current) {
|
|
203
|
-
cancelAnimationFrame(rafRef.current);
|
|
204
|
-
rafRef.current = null;
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
}, [active === null || active === void 0 ? void 0 : active.id, recompute]);
|
|
208
|
-
// Auto-update while open (resize/scroll/resize-observer)
|
|
209
|
-
useLayoutEffect(() => {
|
|
210
|
-
if (!open)
|
|
211
|
-
return;
|
|
212
|
-
if (rafRef.current)
|
|
213
|
-
cancelAnimationFrame(rafRef.current);
|
|
214
|
-
rafRef.current = requestAnimationFrame(recompute);
|
|
215
|
-
const onResize = () => recompute();
|
|
216
|
-
const onScroll = () => recompute();
|
|
217
|
-
window.addEventListener('resize', onResize);
|
|
218
|
-
window.addEventListener('scroll', onScroll, true);
|
|
219
|
-
const ro = new ResizeObserver(() => recompute());
|
|
220
|
-
if (active === null || active === void 0 ? void 0 : active.triggerEl)
|
|
221
|
-
ro.observe(active.triggerEl);
|
|
222
|
-
if (bubbleRef.current)
|
|
223
|
-
ro.observe(bubbleRef.current);
|
|
224
|
-
return () => {
|
|
225
|
-
if (rafRef.current) {
|
|
226
|
-
cancelAnimationFrame(rafRef.current);
|
|
227
|
-
rafRef.current = null;
|
|
228
|
-
}
|
|
229
|
-
window.removeEventListener('resize', onResize);
|
|
230
|
-
window.removeEventListener('scroll', onScroll, true);
|
|
231
|
-
ro.disconnect();
|
|
232
|
-
};
|
|
233
|
-
}, [open, recompute, active === null || active === void 0 ? void 0 : active.triggerEl]);
|
|
234
|
-
// Escape closes
|
|
235
|
-
useEffect(() => {
|
|
236
|
-
if (!open || !active)
|
|
237
|
-
return;
|
|
238
|
-
const onKeyDown = (e) => {
|
|
239
|
-
if (e.key === 'Escape')
|
|
240
|
-
ctx.hide(active.id);
|
|
241
|
-
};
|
|
242
|
-
window.addEventListener('keydown', onKeyDown);
|
|
243
|
-
return () => window.removeEventListener('keydown', onKeyDown);
|
|
244
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
245
|
-
}, [open, active === null || active === void 0 ? void 0 : active.id]);
|
|
246
|
-
if (!ctx)
|
|
247
|
-
return null;
|
|
248
|
-
if (!mounted || !active)
|
|
249
|
-
return null;
|
|
250
|
-
// While not yet visible, keep it offscreen so it can be measured but never flashes at stale coords.
|
|
251
|
-
const bubbleStyle = visible
|
|
252
|
-
? { top: pos.top, left: pos.left }
|
|
253
|
-
: { top: -9999, left: -9999 };
|
|
254
|
-
return createPortal(_jsx("div", { ref: bubbleRef, id: active.id, role: "tooltip", className: styles.bubble, "data-open": visible ? 'true' : 'false', "data-placement": placement, style: bubbleStyle, "aria-hidden": !visible, children: active.content }), document.body);
|
|
255
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { useCallback, useContext, useEffect, useId, useRef, useState } from 'react';
|
|
2
|
-
import { TooltipContext } from './TooltipProvider';
|
|
3
|
-
export function useTooltipTrigger(options) {
|
|
4
|
-
const ctx = useContext(TooltipContext);
|
|
5
|
-
if (!ctx)
|
|
6
|
-
throw new Error('useTooltipTrigger must be used within <TooltipProvider>.');
|
|
7
|
-
const { content, placement = 'top', offset = 8, open, defaultOpen = false, delayOpenMs = 150, delayCloseMs = 50, focusOpenMode = 'focus-visible', closeOnPointerDown = true, } = options;
|
|
8
|
-
const id = useId();
|
|
9
|
-
const triggerElRef = useRef(null);
|
|
10
|
-
const isControlled = open !== undefined;
|
|
11
|
-
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
12
|
-
const isOpen = isControlled ? !!open : uncontrolledOpen;
|
|
13
|
-
const openTimer = useRef(null);
|
|
14
|
-
const closeTimer = useRef(null);
|
|
15
|
-
const clearTimers = () => {
|
|
16
|
-
if (openTimer.current)
|
|
17
|
-
window.clearTimeout(openTimer.current);
|
|
18
|
-
if (closeTimer.current)
|
|
19
|
-
window.clearTimeout(closeTimer.current);
|
|
20
|
-
openTimer.current = null;
|
|
21
|
-
closeTimer.current = null;
|
|
22
|
-
};
|
|
23
|
-
// Track last values so we only call update when something actually changes
|
|
24
|
-
const lastSentRef = useRef(null);
|
|
25
|
-
const show = useCallback(() => {
|
|
26
|
-
if (!content)
|
|
27
|
-
return;
|
|
28
|
-
ctx.show({
|
|
29
|
-
id,
|
|
30
|
-
content,
|
|
31
|
-
placement,
|
|
32
|
-
offset,
|
|
33
|
-
triggerEl: triggerElRef.current,
|
|
34
|
-
});
|
|
35
|
-
lastSentRef.current = { content, placement, offset };
|
|
36
|
-
}, [ctx, id, content, placement, offset]);
|
|
37
|
-
const hide = useCallback(() => {
|
|
38
|
-
ctx.hide(id);
|
|
39
|
-
}, [ctx, id]);
|
|
40
|
-
// Drive global tooltip open/close from local state
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (!isOpen) {
|
|
43
|
-
hide();
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
show();
|
|
47
|
-
}, [isOpen, show, hide]);
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
var _a;
|
|
50
|
-
if (!isOpen)
|
|
51
|
-
return;
|
|
52
|
-
if (((_a = ctx.active) === null || _a === void 0 ? void 0 : _a.id) !== id)
|
|
53
|
-
return;
|
|
54
|
-
const last = lastSentRef.current;
|
|
55
|
-
const changed = !last || last.content !== content || last.placement !== placement || last.offset !== offset;
|
|
56
|
-
if (!changed)
|
|
57
|
-
return;
|
|
58
|
-
ctx.update(id, {
|
|
59
|
-
content,
|
|
60
|
-
placement,
|
|
61
|
-
offset,
|
|
62
|
-
triggerEl: triggerElRef.current,
|
|
63
|
-
});
|
|
64
|
-
lastSentRef.current = { content, placement, offset };
|
|
65
|
-
}, [ctx, id, isOpen, content, placement, offset]);
|
|
66
|
-
const setOpen = (next) => {
|
|
67
|
-
if (isControlled)
|
|
68
|
-
return;
|
|
69
|
-
setUncontrolledOpen(next);
|
|
70
|
-
};
|
|
71
|
-
const onPointerEnter = () => {
|
|
72
|
-
clearTimers();
|
|
73
|
-
if (isControlled)
|
|
74
|
-
return;
|
|
75
|
-
openTimer.current = window.setTimeout(() => setOpen(true), delayOpenMs);
|
|
76
|
-
};
|
|
77
|
-
const onPointerLeave = () => {
|
|
78
|
-
clearTimers();
|
|
79
|
-
if (isControlled)
|
|
80
|
-
return;
|
|
81
|
-
closeTimer.current = window.setTimeout(() => setOpen(false), delayCloseMs);
|
|
82
|
-
};
|
|
83
|
-
const onPointerDown = () => {
|
|
84
|
-
clearTimers();
|
|
85
|
-
if (!isControlled && closeOnPointerDown)
|
|
86
|
-
setOpen(false);
|
|
87
|
-
};
|
|
88
|
-
const onFocus = (e) => {
|
|
89
|
-
clearTimers();
|
|
90
|
-
if (focusOpenMode === 'off')
|
|
91
|
-
return;
|
|
92
|
-
const shouldOpen = focusOpenMode === 'any' || e.currentTarget.matches(':focus-visible');
|
|
93
|
-
// By default we only show for keyboard focus. Callers can opt into opening on any focus.
|
|
94
|
-
if (!isControlled && shouldOpen) {
|
|
95
|
-
openTimer.current = window.setTimeout(() => setOpen(true), delayOpenMs);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
const onBlur = () => {
|
|
99
|
-
clearTimers();
|
|
100
|
-
if (!isControlled)
|
|
101
|
-
setOpen(false);
|
|
102
|
-
};
|
|
103
|
-
return {
|
|
104
|
-
id,
|
|
105
|
-
isOpen,
|
|
106
|
-
triggerProps: {
|
|
107
|
-
ref: (node) => {
|
|
108
|
-
triggerElRef.current = node;
|
|
109
|
-
},
|
|
110
|
-
onPointerEnter,
|
|
111
|
-
onPointerLeave,
|
|
112
|
-
onPointerDown,
|
|
113
|
-
onFocus,
|
|
114
|
-
onBlur,
|
|
115
|
-
'aria-describedby': content ? id : undefined,
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import styles from './Page.module.css';
|
|
3
|
-
import { Breadcrumbs } from '../breadcrumbs/Breadcrumbs';
|
|
4
|
-
import { Headline } from '../headline/Headline';
|
|
5
|
-
export function Page({ header, subheader, severity, headerIcon, headerAddition, breadcrumbs, disableContentBox, disableTopPadding = true, maxWidth, containScrolling = false, children, }) {
|
|
6
|
-
const maxWidthClass = maxWidth
|
|
7
|
-
? styles[`maxWidth${maxWidth.charAt(0).toUpperCase()}${maxWidth.slice(1)}`]
|
|
8
|
-
: '';
|
|
9
|
-
const hasHeadline = Boolean(header || subheader || headerAddition);
|
|
10
|
-
return (_jsxs("div", { className: `${styles.container} ${containScrolling ? styles.containScrolling : styles.documentScrolling} ${disableTopPadding ? styles.disableTopPadding : ''} ${maxWidthClass}`, children: [_jsx("div", { className: styles.headerContainer, children: _jsxs("div", { className: styles.headerMain, children: [breadcrumbs ? _jsx(Breadcrumbs, { items: breadcrumbs }) : null, hasHeadline ? (_jsx(Headline, { disableMargin: true, size: 2, severity: severity, icon: headerIcon, subheader: subheader, addition: headerAddition, children: header })) : null] }) }), _jsx("div", { className: `${styles.content} ${disableContentBox ? styles.disableContentBox : ''}`, children: children })] }));
|
|
11
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
.container {
|
|
2
|
-
box-sizing: border-box;
|
|
3
|
-
display: flex;
|
|
4
|
-
flex-direction: column;
|
|
5
|
-
min-width: 0;
|
|
6
|
-
min-height: 0;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.maxWidthSm,
|
|
10
|
-
.maxWidthMd,
|
|
11
|
-
.maxWidthLg {
|
|
12
|
-
margin-inline: auto;
|
|
13
|
-
width: 100%;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.maxWidthSm {
|
|
17
|
-
max-width: 560px;
|
|
18
|
-
}
|
|
19
|
-
.maxWidthMd {
|
|
20
|
-
max-width: 768px;
|
|
21
|
-
}
|
|
22
|
-
.maxWidthLg {
|
|
23
|
-
max-width: 1024px;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.containScrolling {
|
|
27
|
-
height: 100%;
|
|
28
|
-
overflow: hidden;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.documentScrolling {
|
|
32
|
-
height: auto;
|
|
33
|
-
overflow: visible;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.headerContainer {
|
|
37
|
-
display: flex;
|
|
38
|
-
align-items: flex-start;
|
|
39
|
-
padding: var(--spacing-lg) 0;
|
|
40
|
-
gap: var(--spacing-md);
|
|
41
|
-
min-width: 0;
|
|
42
|
-
flex: 0 0 auto;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.disableTopPadding {
|
|
46
|
-
padding-block-start: 0;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.disableTopPadding .headerContainer {
|
|
50
|
-
padding-block-start: 0;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.headerMain {
|
|
54
|
-
display: flex;
|
|
55
|
-
flex-direction: column;
|
|
56
|
-
gap: var(--spacing-md);
|
|
57
|
-
flex: 1 1 auto;
|
|
58
|
-
min-width: 0;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.content {
|
|
62
|
-
flex: 1 1 auto;
|
|
63
|
-
min-height: 0;
|
|
64
|
-
min-width: 0;
|
|
65
|
-
overflow: auto;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.documentScrolling .content {
|
|
69
|
-
overflow: visible;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.content:not(.disableContentBox) {
|
|
73
|
-
padding: var(--spacing-lg);
|
|
74
|
-
border: 1px solid var(--color-border-default);
|
|
75
|
-
border-radius: var(--border-radius-default);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
@media (max-width: 767px) {
|
|
79
|
-
.headerContainer {
|
|
80
|
-
padding-block: var(--spacing-md);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.content:not(.disableContentBox) {
|
|
84
|
-
padding-block: var(--spacing-md);
|
|
85
|
-
padding-inline: 0;
|
|
86
|
-
border: 0;
|
|
87
|
-
border-radius: 0;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Children, isValidElement } from 'react';
|
|
3
|
-
import { PageLayoutHero, } from './components/page-layout-hero/PageLayoutHero';
|
|
4
|
-
import styles from './PageLayout.module.css';
|
|
5
|
-
function getMaxWidthClass(value, styles) {
|
|
6
|
-
if (!value)
|
|
7
|
-
return '';
|
|
8
|
-
if (value === 'sm')
|
|
9
|
-
return styles.maxWidthSm;
|
|
10
|
-
return styles.maxWidthMd;
|
|
11
|
-
}
|
|
12
|
-
function getSlotName(el) {
|
|
13
|
-
var _a;
|
|
14
|
-
const t = el.type;
|
|
15
|
-
return (_a = t === null || t === void 0 ? void 0 : t.__PAGE_LAYOUT_SLOT__) !== null && _a !== void 0 ? _a : null;
|
|
16
|
-
}
|
|
17
|
-
function splitSlots(children) {
|
|
18
|
-
const slots = {};
|
|
19
|
-
const rest = [];
|
|
20
|
-
Children.forEach(children, child => {
|
|
21
|
-
if (!isValidElement(child)) {
|
|
22
|
-
if (child != null)
|
|
23
|
-
rest.push(child);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const slot = getSlotName(child);
|
|
27
|
-
if (!slot) {
|
|
28
|
-
rest.push(child);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
// If multiple of same slot are provided, last wins (simple + predictable).
|
|
32
|
-
slots[slot] = child;
|
|
33
|
-
});
|
|
34
|
-
return { slots, rest };
|
|
35
|
-
}
|
|
36
|
-
/** Slot components */
|
|
37
|
-
const PageLayoutSidebar = ({ children, }) => {
|
|
38
|
-
// This returns children; layout wrapper decides how to render.
|
|
39
|
-
// We keep this as a slot marker component.
|
|
40
|
-
return _jsx(_Fragment, { children: children });
|
|
41
|
-
};
|
|
42
|
-
PageLayoutSidebar.__PAGE_LAYOUT_SLOT__ = 'Sidebar';
|
|
43
|
-
const PageLayoutHeader = ({ maxWidth = false, children, }) => {
|
|
44
|
-
return (_jsx("div", { className: styles.headerContainer, children: _jsx("div", { className: `${styles.headerContent} ${getMaxWidthClass(maxWidth, styles)}`, children: children }) }));
|
|
45
|
-
};
|
|
46
|
-
PageLayoutHeader.__PAGE_LAYOUT_SLOT__ = 'Header';
|
|
47
|
-
const PageLayoutContent = ({ maxWidth = false, children, }) => {
|
|
48
|
-
return (_jsx("div", { className: `${styles.contentInner} ${getMaxWidthClass(maxWidth, styles)}`, children: children }));
|
|
49
|
-
};
|
|
50
|
-
PageLayoutContent.__PAGE_LAYOUT_SLOT__ = 'Content';
|
|
51
|
-
const PageLayoutFooter = ({ maxWidth = false, children, }) => {
|
|
52
|
-
return (_jsx("div", { className: `${styles.footerContent} ${getMaxWidthClass(maxWidth, styles)}`, children: children }));
|
|
53
|
-
};
|
|
54
|
-
PageLayoutFooter.__PAGE_LAYOUT_SLOT__ = 'Footer';
|
|
55
|
-
PageLayoutHero.__PAGE_LAYOUT_SLOT__ = 'Hero';
|
|
56
|
-
const PageLayoutBase = ({ children, containScrolling = false, orientation = 'vertical', }) => {
|
|
57
|
-
var _a, _b;
|
|
58
|
-
const { slots, rest } = splitSlots(children);
|
|
59
|
-
// If no explicit <PageLayout.Content>, we’ll treat remaining children as content.
|
|
60
|
-
const content = (_a = slots.Content) !== null && _a !== void 0 ? _a : (rest.length ? _jsx(PageLayoutContent, { maxWidth: "md", children: rest }) : undefined);
|
|
61
|
-
const rootClass = [
|
|
62
|
-
styles.root,
|
|
63
|
-
orientation === 'vertical' ? styles.vertical : styles.horizontal,
|
|
64
|
-
containScrolling ? styles.containScrolling : styles.documentScrolling,
|
|
65
|
-
]
|
|
66
|
-
.filter(Boolean)
|
|
67
|
-
.join(' ');
|
|
68
|
-
return (_jsxs("div", { className: rootClass, children: [slots.Sidebar ? (_jsx("aside", { className: styles.sidebar, "aria-label": (_b = slots.Sidebar.props) === null || _b === void 0 ? void 0 : _b.ariaLabel, children: slots.Sidebar })) : null, _jsxs("div", { className: styles.mainColumn, children: [slots.Header ? _jsx("header", { className: styles.header, children: slots.Header }) : null, slots.Hero ? _jsx("div", { className: styles.hero, children: slots.Hero }) : null, content || slots.Footer ? (_jsxs("div", { className: styles.mainScroll, children: [content ? _jsx("main", { className: styles.content, children: content }) : null, slots.Footer ? _jsx("footer", { className: styles.footer, children: slots.Footer }) : null] })) : null] })] }));
|
|
69
|
-
};
|
|
70
|
-
export const PageLayout = Object.assign(PageLayoutBase, {
|
|
71
|
-
Sidebar: PageLayoutSidebar,
|
|
72
|
-
Header: PageLayoutHeader,
|
|
73
|
-
Hero: PageLayoutHero,
|
|
74
|
-
Content: PageLayoutContent,
|
|
75
|
-
Footer: PageLayoutFooter,
|
|
76
|
-
});
|