@sentry/scraps 0.3.0 → 0.5.0
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 +6 -5
- package/dist/alert/alert.js +0 -3
- package/dist/badge/badge.js +1 -2
- package/dist/badge/tag.js +0 -2
- package/dist/button/index.d.ts +0 -1
- package/dist/button/index.js +0 -1
- package/dist/clipboard/copyToClipboardButton.d.ts +15 -0
- package/dist/clipboard/copyToClipboardButton.js +32 -0
- package/dist/clipboard/index.d.ts +1 -0
- package/dist/clipboard/index.js +1 -0
- package/dist/code/index.d.ts +1 -0
- package/dist/code/index.js +1 -0
- package/dist/codeBlock/codeBlock.d.ts +68 -0
- package/dist/codeBlock/codeBlock.js +242 -0
- package/dist/codeBlock/index.d.ts +2 -0
- package/dist/codeBlock/index.js +2 -0
- package/dist/codeBlock/prism.d.ts +11 -0
- package/dist/codeBlock/prism.js +101 -0
- package/dist/codeBlock/styles.d.ts +2 -0
- package/dist/codeBlock/styles.js +133 -0
- package/dist/compactSelect/compactSelect.d.ts +21 -0
- package/dist/compactSelect/compactSelect.js +150 -0
- package/dist/compactSelect/composite.d.ts +54 -0
- package/dist/compactSelect/composite.js +101 -0
- package/dist/compactSelect/control.d.ts +112 -0
- package/dist/compactSelect/control.js +354 -0
- package/dist/compactSelect/fzf.d.ts +8 -0
- package/dist/compactSelect/fzf.js +151 -0
- package/dist/compactSelect/gridList/index.d.ts +46 -0
- package/dist/compactSelect/gridList/index.js +102 -0
- package/dist/compactSelect/gridList/option.d.ts +15 -0
- package/dist/compactSelect/gridList/option.js +111 -0
- package/dist/compactSelect/gridList/section.d.ts +15 -0
- package/dist/compactSelect/gridList/section.js +58 -0
- package/dist/compactSelect/highlightText.d.ts +6 -0
- package/dist/compactSelect/highlightText.js +33 -0
- package/dist/compactSelect/index.d.ts +9 -0
- package/dist/compactSelect/index.js +8 -0
- package/dist/compactSelect/list.d.ts +94 -0
- package/dist/compactSelect/list.js +167 -0
- package/dist/compactSelect/listBox/index.d.ts +84 -0
- package/dist/compactSelect/listBox/index.js +175 -0
- package/dist/compactSelect/listBox/option.d.ts +19 -0
- package/dist/compactSelect/listBox/option.js +101 -0
- package/dist/compactSelect/listBox/section.d.ts +21 -0
- package/dist/compactSelect/listBox/section.js +58 -0
- package/dist/compactSelect/menuComponents.d.ts +89 -0
- package/dist/compactSelect/menuComponents.js +117 -0
- package/dist/compactSelect/selectFilterContext.d.ts +2 -0
- package/dist/compactSelect/selectFilterContext.js +3 -0
- package/dist/compactSelect/styles.d.ts +39 -0
- package/dist/compactSelect/styles.js +155 -0
- package/dist/compactSelect/types.d.ts +1 -0
- package/dist/compactSelect/types.js +0 -0
- package/dist/compactSelect/useVirtualizedItems.d.ts +52 -0
- package/dist/compactSelect/useVirtualizedItems.js +74 -0
- package/dist/compactSelect/utils.d.ts +80 -0
- package/dist/compactSelect/utils.js +268 -0
- package/dist/confirm/index.d.ts +153 -0
- package/dist/confirm/index.js +132 -0
- package/dist/descriptionList/descriptionList.js +4 -3
- package/dist/disclosure/disclosure.js +2 -2
- package/dist/dragHandle/dragHandle.d.ts +3 -1
- package/dist/dragHandle/dragHandle.js +8 -5
- package/dist/drawer/components.d.ts +46 -0
- package/dist/drawer/components.js +265 -0
- package/dist/drawer/globalDrawer.d.ts +106 -0
- package/dist/drawer/globalDrawer.js +173 -0
- package/dist/drawer/index.d.ts +3 -0
- package/dist/drawer/index.js +2 -0
- package/dist/drawer/useDrawerResizing.d.ts +19 -0
- package/dist/drawer/useDrawerResizing.js +111 -0
- package/dist/drawer/useDrawerWidth.d.ts +1 -0
- package/dist/drawer/useDrawerWidth.js +42 -0
- package/dist/dropdownMenu/content.d.ts +1 -0
- package/dist/dropdownMenu/content.js +1 -0
- package/dist/dropdownMenu/context.d.ts +24 -0
- package/dist/dropdownMenu/context.js +3 -0
- package/dist/dropdownMenu/dropdownMenu.d.ts +70 -0
- package/dist/dropdownMenu/dropdownMenu.js +103 -0
- package/dist/dropdownMenu/index.d.ts +2 -0
- package/dist/dropdownMenu/index.js +1 -0
- package/dist/dropdownMenu/item.d.ts +136 -0
- package/dist/dropdownMenu/item.js +182 -0
- package/dist/dropdownMenu/list.d.ts +59 -0
- package/dist/dropdownMenu/list.js +410 -0
- package/dist/dropdownMenu/search.d.ts +16 -0
- package/dist/dropdownMenu/search.js +16 -0
- package/dist/dropdownMenu/section.d.ts +21 -0
- package/dist/dropdownMenu/section.js +40 -0
- package/dist/dropdownMenu/separator.d.ts +7 -0
- package/dist/dropdownMenu/separator.js +15 -0
- package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +260 -0
- package/dist/dropdownMenu/useDropdownMenuKeyboard.js +55 -0
- package/dist/dropdownMenu/useDropdownMenuRowLayout.d.ts +29 -0
- package/dist/dropdownMenu/useDropdownMenuRowLayout.js +64 -0
- package/dist/dropdownMenu/useSafetyTriangle.d.ts +12 -0
- package/dist/dropdownMenu/useSafetyTriangle.js +119 -0
- package/dist/dropdownMenu/utils.d.ts +21 -0
- package/dist/dropdownMenu/utils.js +57 -0
- package/dist/form/FormSearch.d.ts +19 -0
- package/dist/form/FormSearch.js +4 -0
- package/dist/form/autoSaveForm.d.ts +110 -0
- package/dist/form/autoSaveForm.js +100 -0
- package/dist/{formPresentation → form}/displayField.js +2 -2
- package/dist/form/field/baseField.d.ts +23 -0
- package/dist/form/field/baseField.js +116 -0
- package/dist/form/field/checkboxField.d.ts +11 -0
- package/dist/form/field/checkboxField.js +42 -0
- package/dist/form/field/checkboxGroupField.d.ts +16 -0
- package/dist/form/field/checkboxGroupField.js +80 -0
- package/dist/form/field/compactSelectField.d.ts +19 -0
- package/dist/form/field/compactSelectField.js +77 -0
- package/dist/{formPresentation → form/field}/fieldIds.js +1 -1
- package/dist/form/field/inputField.d.ts +19 -0
- package/dist/form/field/inputField.js +31 -0
- package/dist/{formPresentation → form/field}/meta.js +6 -6
- package/dist/form/field/numberField.d.ts +5 -0
- package/dist/form/field/numberField.js +11 -0
- package/dist/form/field/passwordField.d.ts +3 -0
- package/dist/form/field/passwordField.js +27 -0
- package/dist/form/field/radioGroupField.d.ts +16 -0
- package/dist/form/field/radioGroupField.js +92 -0
- package/dist/form/field/rangeField.d.ts +8 -0
- package/dist/form/field/rangeField.js +34 -0
- package/dist/form/field/selectAsyncField.d.ts +31 -0
- package/dist/form/field/selectAsyncField.js +22 -0
- package/dist/form/field/selectField.d.ts +9 -0
- package/dist/form/field/selectField.js +72 -0
- package/dist/form/field/switchField.d.ts +7 -0
- package/dist/form/field/switchField.js +37 -0
- package/dist/form/field/textAreaField.d.ts +7 -0
- package/dist/form/field/textAreaField.js +25 -0
- package/dist/{formPresentation → form}/formContext.js +1 -1
- package/dist/form/formErrorContext/index.d.ts +9 -0
- package/dist/form/formErrorContext/index.js +7 -0
- package/dist/form/index.d.ts +9 -0
- package/dist/form/index.js +8 -0
- package/dist/{formPresentation → form/layout}/base.d.ts +1 -1
- package/dist/{formPresentation → form/layout}/base.js +1 -1
- package/dist/form/layout/fieldGroup.d.ts +6 -0
- package/dist/form/layout/fieldGroup.js +60 -0
- package/dist/{formPresentation/fieldLayout.d.ts → form/layout/index.d.ts} +1 -1
- package/dist/{formPresentation/fieldLayout.js → form/layout/index.js} +3 -3
- package/dist/{formPresentation → form/layout}/useStackedLayout.js +1 -1
- package/dist/form/scrapsForm.d.ts +220 -0
- package/dist/form/scrapsForm.js +126 -0
- package/dist/hotkey/hotkey.d.ts +9 -8
- package/dist/hotkey/hotkey.js +13 -6
- package/dist/hotkey/index.d.ts +2 -1
- package/dist/hotkey/index.js +2 -1
- package/dist/hotkey/keyMappings.d.ts +1 -15
- package/dist/hotkey/keyMappings.js +29 -174
- package/dist/hotkey/useHotkeys.d.ts +3 -47
- package/dist/hotkey/useHotkeys.js +8 -42
- package/dist/image/image.js +2 -1
- package/dist/info/infoTip.d.ts +1 -1
- package/dist/info/infoTip.js +4 -3
- package/dist/input/index.d.ts +0 -3
- package/dist/input/index.js +0 -2
- package/dist/input/input.d.ts +2 -0
- package/dist/input/input.js +2 -0
- package/dist/input/passwordManagerIgnoreProps.d.ts +11 -0
- package/dist/input/passwordManagerIgnoreProps.js +8 -0
- package/dist/layout/index.d.ts +2 -2
- package/dist/layout/index.js +1 -1
- package/dist/layout/styles.d.ts +1 -1
- package/dist/link/link.js +4 -3
- package/dist/link/linkBehaviorContext.d.ts +2 -0
- package/dist/link/linkBehaviorContext.js +17 -10
- package/dist/menu/controlContext.d.ts +32 -0
- package/dist/menu/controlContext.js +7 -0
- package/dist/menu/dropdownButton.d.ts +18 -0
- package/dist/menu/dropdownButton.js +66 -0
- package/dist/menu/index.d.ts +7 -0
- package/dist/menu/index.js +3 -0
- package/dist/menu/menu.d.ts +167 -0
- package/dist/menu/menu.js +568 -0
- package/dist/menu/selectTypes.d.ts +96 -0
- package/dist/menu/selectTypes.js +0 -0
- package/dist/menu/selectValue.d.ts +13 -0
- package/dist/menu/selectValue.js +0 -0
- package/dist/modal/components.d.ts +19 -0
- package/dist/modal/components.js +99 -0
- package/dist/modal/errorBoundary.d.ts +2 -0
- package/dist/modal/errorBoundary.js +35 -0
- package/dist/modal/index.d.ts +33 -0
- package/dist/modal/index.js +260 -0
- package/dist/modal/portal.d.ts +1 -0
- package/dist/modal/portal.js +10 -0
- package/dist/modal/state.d.ts +17 -0
- package/dist/modal/state.js +41 -0
- package/dist/modal/types.d.ts +75 -0
- package/dist/modal/types.js +0 -0
- package/dist/numberInput/index.d.ts +3 -0
- package/dist/numberInput/index.js +2 -0
- package/dist/{input → numberInput}/numberDragInput.d.ts +1 -1
- package/dist/{input → numberInput}/numberDragInput.js +1 -1
- package/dist/{input → numberInput}/numberInput.d.ts +1 -1
- package/dist/{input → numberInput}/numberInput.js +1 -1
- package/dist/overlayContext.d.ts +29 -0
- package/dist/overlayContext.js +7 -0
- package/dist/overlayTrigger.d.ts +22 -0
- package/dist/overlayTrigger.js +30 -0
- package/dist/pagination/index.d.ts +1 -0
- package/dist/pagination/index.js +1 -0
- package/dist/pagination/pagination.d.ts +24 -0
- package/dist/pagination/pagination.js +63 -0
- package/dist/pictureInPicture/index.d.ts +2 -0
- package/dist/pictureInPicture/index.js +2 -0
- package/dist/pictureInPicture/pictureInPicture.d.ts +47 -0
- package/dist/pictureInPicture/pictureInPicture.js +100 -0
- package/dist/pictureInPicture/pictureInPicturePortal.d.ts +16 -0
- package/dist/pictureInPicture/pictureInPicturePortal.js +46 -0
- package/dist/pictureInPicture/portalContext.d.ts +2 -0
- package/dist/pictureInPicture/portalContext.js +3 -0
- package/dist/revealOnHover/revealOnHover.js +1 -1
- package/dist/segmentedControl/segmentedControl.js +1 -1
- package/dist/select/filter.d.ts +4 -0
- package/dist/select/filter.js +12 -0
- package/dist/select/index.d.ts +3 -0
- package/dist/select/index.js +2 -0
- package/dist/select/option.d.ts +16 -0
- package/dist/select/option.js +81 -0
- package/dist/select/reactSelectWrapper.d.ts +8 -0
- package/dist/select/reactSelectWrapper.js +25 -0
- package/dist/select/select.d.ts +79 -0
- package/dist/select/select.js +454 -0
- package/dist/select/styles.d.ts +9 -0
- package/dist/select/styles.js +27 -0
- package/dist/select/types.d.ts +60 -0
- package/dist/select/types.js +0 -0
- package/dist/select/virtualizedMenuList.d.ts +24 -0
- package/dist/select/virtualizedMenuList.js +123 -0
- package/dist/slideOverPanel.d.ts +20 -0
- package/dist/slideOverPanel.js +141 -0
- package/dist/slot/knownContexts.d.ts +1 -1
- package/dist/spinner/index.d.ts +1 -0
- package/dist/spinner/index.js +1 -0
- package/dist/spinner/spinner.d.ts +14 -0
- package/dist/spinner/spinner.js +126 -0
- package/dist/splitPanel/index.d.ts +1 -0
- package/dist/splitPanel/index.js +1 -0
- package/dist/splitPanel/splitPanel.d.ts +38 -0
- package/dist/splitPanel/splitPanel.js +145 -0
- package/dist/table/table.d.ts +1 -1
- package/dist/table/table.js +39 -20
- package/dist/table/useColumnResize.d.ts +6 -5
- package/dist/table/useColumnResize.js +5 -4
- package/dist/tabs/index.d.ts +4 -0
- package/dist/tabs/index.js +3 -0
- package/dist/tabs/item.d.ts +13 -0
- package/dist/tabs/item.js +4 -0
- package/dist/tabs/tab.d.ts +22 -0
- package/dist/tabs/tab.js +205 -0
- package/dist/tabs/tabList.d.ts +18 -0
- package/dist/tabs/tabList.js +256 -0
- package/dist/tabs/tabPanels.d.ts +14 -0
- package/dist/tabs/tabPanels.js +62 -0
- package/dist/tabs/tabs.d.ts +38 -0
- package/dist/tabs/tabs.js +56 -0
- package/dist/tabs/utils.d.ts +3 -0
- package/dist/tabs/utils.js +6 -0
- package/dist/text/heading.d.ts +1 -1
- package/dist/text/heading.js +1 -1
- package/dist/text/styles.js +1 -1
- package/dist/text/text.d.ts +1 -1
- package/dist/text/text.js +1 -1
- package/dist/theme/dark.js +9 -9
- package/dist/theme/light.js +9 -9
- package/dist/toast/index.d.ts +5 -0
- package/dist/toast/index.js +4 -0
- package/dist/toast/toast.d.ts +10 -0
- package/dist/toast/toast.js +182 -0
- package/dist/toast/toastApi.d.ts +10 -0
- package/dist/toast/toastApi.js +53 -0
- package/dist/toast/toaster.d.ts +4 -0
- package/dist/toast/toaster.js +42 -0
- package/dist/toast/types.d.ts +17 -0
- package/dist/toast/types.js +2 -0
- package/dist/toggleCard/index.d.ts +1 -0
- package/dist/toggleCard/index.js +1 -0
- package/dist/toggleCard/toggleCard.d.ts +32 -0
- package/dist/toggleCard/toggleCard.js +301 -0
- package/dist/tooltip/tooltip.js +2 -5
- package/dist/useDimensions.d.ts +12 -0
- package/dist/useDimensions.js +31 -0
- package/dist/useMedia.d.ts +15 -0
- package/dist/useMedia.js +24 -0
- package/dist/useOnClickOutside.d.ts +2 -0
- package/dist/useOnClickOutside.js +22 -0
- package/dist/useOverlay.d.ts +1 -0
- package/dist/useOverlay.js +1 -0
- package/dist/useResizableDrawer.d.ts +72 -0
- package/dist/useResizableDrawer.js +136 -0
- package/dist/useVirtualCollection.d.ts +154 -0
- package/dist/useVirtualCollection.js +143 -0
- package/dist/useVirtualRows.d.ts +26 -0
- package/dist/useVirtualRows.js +26 -0
- package/dist/virtualCollectionLayout.d.ts +51 -0
- package/dist/virtualCollectionLayout.js +49 -0
- package/package.json +148 -16
- package/dist/formPresentation/index.d.ts +0 -8
- package/dist/formPresentation/index.js +0 -8
- package/dist/interactionStateLayer/index.d.ts +0 -1
- package/dist/interactionStateLayer/index.js +0 -1
- package/dist/interactionStateLayer/interactionStateLayer.d.ts +0 -23
- package/dist/interactionStateLayer/interactionStateLayer.js +0 -67
- package/dist/unreachable.d.ts +0 -1
- package/dist/unreachable.js +0 -4
- /package/dist/{formPresentation → form}/autoSaveContext.d.ts +0 -0
- /package/dist/{formPresentation → form}/autoSaveContext.js +0 -0
- /package/dist/{formPresentation → form}/displayField.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/fieldIds.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/groupContext.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/groupContext.js +0 -0
- /package/dist/{formPresentation → form/field}/meta.d.ts +0 -0
- /package/dist/{formPresentation → form}/formContext.d.ts +0 -0
- /package/dist/{formPresentation → form}/icons.d.ts +0 -0
- /package/dist/{formPresentation → form}/icons.js +0 -0
- /package/dist/{formPresentation → form/layout}/useStackedLayout.d.ts +0 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Children, isValidElement, useEffect, useRef } from "react";
|
|
3
|
+
import { useTheme } from "@emotion/react";
|
|
4
|
+
import { getInteractionModality } from "@react-aria/interactions";
|
|
5
|
+
import { mergeRefs } from "@react-aria/utils";
|
|
6
|
+
import { useVirtualRows } from "../useVirtualRows.js";
|
|
7
|
+
const OPTION_HEIGHT = 36;
|
|
8
|
+
const GROUP_HEADING_HEIGHT = 24;
|
|
9
|
+
const MAX_MENU_HEIGHT = 300;
|
|
10
|
+
const MENU_PADDING = 4;
|
|
11
|
+
function toOptionRow(node, fallbackKey) {
|
|
12
|
+
const element = /*#__PURE__*/ isValidElement(node) ? node : null;
|
|
13
|
+
return {
|
|
14
|
+
isHeading: false,
|
|
15
|
+
key: element?.key ?? fallbackKey,
|
|
16
|
+
node,
|
|
17
|
+
data: element?.props.data
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function flattenMenuRows(children) {
|
|
21
|
+
const rows = [];
|
|
22
|
+
for (const child of children){
|
|
23
|
+
if (!/*#__PURE__*/ isValidElement(child) || !child.props.Heading) {
|
|
24
|
+
rows.push(toOptionRow(child, rows.length));
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const { Heading, headingProps, label, selectProps, theme, getStyles, cx } = child.props;
|
|
28
|
+
rows.push({
|
|
29
|
+
isHeading: true,
|
|
30
|
+
key: child.key ?? rows.length,
|
|
31
|
+
node: /*#__PURE__*/ jsx(Heading, {
|
|
32
|
+
...headingProps,
|
|
33
|
+
selectProps: selectProps,
|
|
34
|
+
theme: theme,
|
|
35
|
+
getStyles: getStyles,
|
|
36
|
+
cx: cx,
|
|
37
|
+
children: label
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
const groupOptions = Children.toArray(child.props.children);
|
|
41
|
+
for (const option of groupOptions)rows.push(toOptionRow(option, rows.length));
|
|
42
|
+
}
|
|
43
|
+
return rows;
|
|
44
|
+
}
|
|
45
|
+
function VirtualizedMenuList({ children, focusedOption, maxHeight = MAX_MENU_HEIGHT, innerRef, innerProps }) {
|
|
46
|
+
const theme = useTheme();
|
|
47
|
+
const rows = Array.isArray(children) ? flattenMenuRows(Children.toArray(children)) : [];
|
|
48
|
+
const scrollRef = useRef(null);
|
|
49
|
+
const combinedRef = mergeRefs(scrollRef, innerRef ?? null);
|
|
50
|
+
const visibleOptionCount = Math.max(1, Math.floor((maxHeight - 2 * MENU_PADDING) / OPTION_HEIGHT));
|
|
51
|
+
const alignedMaxHeight = visibleOptionCount * OPTION_HEIGHT + 2 * MENU_PADDING;
|
|
52
|
+
const { totalSize, virtualItems, virtualizer } = useVirtualRows({
|
|
53
|
+
count: rows.length,
|
|
54
|
+
getScrollElement: ()=>scrollRef.current,
|
|
55
|
+
estimateSize: (index)=>rows[index]?.isHeading ? GROUP_HEADING_HEIGHT : OPTION_HEIGHT,
|
|
56
|
+
getItemKey: (index)=>rows[index]?.key ?? index,
|
|
57
|
+
paddingStart: MENU_PADDING,
|
|
58
|
+
paddingEnd: MENU_PADDING,
|
|
59
|
+
scrollPaddingStart: MENU_PADDING,
|
|
60
|
+
scrollPaddingEnd: MENU_PADDING
|
|
61
|
+
});
|
|
62
|
+
const focusedIndex = rows.findIndex((row)=>!row.isHeading && row.data === focusedOption);
|
|
63
|
+
useEffect(()=>{
|
|
64
|
+
if (-1 !== focusedIndex && 'pointer' !== getInteractionModality()) virtualizer.scrollToIndex(focusedIndex, {
|
|
65
|
+
align: 'auto'
|
|
66
|
+
});
|
|
67
|
+
}, [
|
|
68
|
+
focusedIndex,
|
|
69
|
+
virtualizer
|
|
70
|
+
]);
|
|
71
|
+
if (!Array.isArray(children)) return /*#__PURE__*/ jsx("div", {
|
|
72
|
+
ref: innerRef,
|
|
73
|
+
...innerProps,
|
|
74
|
+
style: {
|
|
75
|
+
maxHeight,
|
|
76
|
+
overflowY: 'auto'
|
|
77
|
+
},
|
|
78
|
+
children: children
|
|
79
|
+
});
|
|
80
|
+
return /*#__PURE__*/ jsx("div", {
|
|
81
|
+
ref: combinedRef,
|
|
82
|
+
...innerProps,
|
|
83
|
+
style: {
|
|
84
|
+
maxHeight: alignedMaxHeight,
|
|
85
|
+
overflowY: 'auto'
|
|
86
|
+
},
|
|
87
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
88
|
+
style: {
|
|
89
|
+
height: totalSize,
|
|
90
|
+
position: 'relative'
|
|
91
|
+
},
|
|
92
|
+
children: virtualItems.map((virtualRow)=>{
|
|
93
|
+
const row = rows[virtualRow.index];
|
|
94
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
95
|
+
ref: virtualizer.measureElement,
|
|
96
|
+
"data-index": virtualRow.index,
|
|
97
|
+
style: {
|
|
98
|
+
position: 'absolute',
|
|
99
|
+
top: 0,
|
|
100
|
+
left: 0,
|
|
101
|
+
width: '100%',
|
|
102
|
+
transform: `translateY(${virtualRow.start}px)`
|
|
103
|
+
},
|
|
104
|
+
children: [
|
|
105
|
+
row?.isHeading && virtualRow.index > 0 && /*#__PURE__*/ jsx("div", {
|
|
106
|
+
"data-test-id": "menu-group-divider",
|
|
107
|
+
style: {
|
|
108
|
+
padding: `${theme.space.md} ${theme.space.lg}`
|
|
109
|
+
},
|
|
110
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
111
|
+
style: {
|
|
112
|
+
borderTop: `1px solid ${theme.tokens.border.secondary}`
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
}),
|
|
116
|
+
row?.node
|
|
117
|
+
]
|
|
118
|
+
}, virtualRow.key);
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
export { VirtualizedMenuList };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
interface ChildRenderProps {
|
|
3
|
+
isOpening: boolean;
|
|
4
|
+
}
|
|
5
|
+
type ChildRenderFunction = (renderPropProps: ChildRenderProps) => React.ReactNode;
|
|
6
|
+
export type SlideOverPanelProps = {
|
|
7
|
+
children: React.ReactNode | ChildRenderFunction;
|
|
8
|
+
ariaLabel?: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
'data-test-id'?: string;
|
|
11
|
+
height?: string;
|
|
12
|
+
mode?: 'blocking' | 'passive';
|
|
13
|
+
panelWidth?: string;
|
|
14
|
+
position?: 'right' | 'bottom' | 'left';
|
|
15
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
16
|
+
/** Override placement to clear banners above the panel. */
|
|
17
|
+
topOffset?: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function SlideOverPanel({ 'data-test-id': testId, mode, ariaLabel, children, className, height, position, panelWidth, ref, topOffset, }: SlideOverPanelProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useEffect, useId, useState, useTransition } from "react";
|
|
3
|
+
import is_prop_valid from "@emotion/is-prop-valid";
|
|
4
|
+
import { css, useTheme } from "@emotion/react";
|
|
5
|
+
import styled from "@emotion/styled";
|
|
6
|
+
import { motion } from "framer-motion";
|
|
7
|
+
import { BoundaryContextProvider } from "./boundaryContext.js";
|
|
8
|
+
import { useOverlayContext } from "./overlayContext.js";
|
|
9
|
+
const RIGHT_SIDE_PANEL_WIDTH = '50vw';
|
|
10
|
+
const LEFT_SIDE_PANEL_WIDTH = '40vw';
|
|
11
|
+
const PANEL_HEIGHT = '50vh';
|
|
12
|
+
const OPEN_STYLES = {
|
|
13
|
+
bottom: {
|
|
14
|
+
transform: 'translateX(0) translateY(0)',
|
|
15
|
+
opacity: 1
|
|
16
|
+
},
|
|
17
|
+
right: {
|
|
18
|
+
transform: 'translateX(0) translateY(0)',
|
|
19
|
+
opacity: 1
|
|
20
|
+
},
|
|
21
|
+
left: {
|
|
22
|
+
transform: 'translateX(0) translateY(0)',
|
|
23
|
+
opacity: 1
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const COLLAPSED_STYLES = {
|
|
27
|
+
bottom: {
|
|
28
|
+
transform: `translateX(0) translateY(${PANEL_HEIGHT})`,
|
|
29
|
+
opacity: 0
|
|
30
|
+
},
|
|
31
|
+
right: {
|
|
32
|
+
transform: 'translateX(100%) translateY(0)',
|
|
33
|
+
opacity: 0
|
|
34
|
+
},
|
|
35
|
+
left: {
|
|
36
|
+
transform: 'translateX(-100%) translateY(0)',
|
|
37
|
+
opacity: 0
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
function SlideOverPanel({ 'data-test-id': testId, mode = 'blocking', ariaLabel, children, className, height, position, panelWidth, ref, topOffset }) {
|
|
41
|
+
const theme = useTheme();
|
|
42
|
+
const { contentTop = '0px' } = useOverlayContext();
|
|
43
|
+
const [isTransitioning, startTransition] = useTransition();
|
|
44
|
+
const [isContentVisible, setIsContentVisible] = useState(false);
|
|
45
|
+
useEffect(()=>{
|
|
46
|
+
startTransition(()=>{
|
|
47
|
+
setIsContentVisible(true);
|
|
48
|
+
});
|
|
49
|
+
}, []);
|
|
50
|
+
const id = useId();
|
|
51
|
+
const renderFunctionProps = {
|
|
52
|
+
isOpening: isTransitioning || !isContentVisible
|
|
53
|
+
};
|
|
54
|
+
const openStyle = position ? OPEN_STYLES[position] : OPEN_STYLES.right;
|
|
55
|
+
const collapsedStyle = position ? COLLAPSED_STYLES[position] : COLLAPSED_STYLES.right;
|
|
56
|
+
return /*#__PURE__*/ jsx(BoundaryContextProvider, {
|
|
57
|
+
value: id,
|
|
58
|
+
children: /*#__PURE__*/ jsx(_SlideOverPanel, {
|
|
59
|
+
ref: ref,
|
|
60
|
+
id: id,
|
|
61
|
+
mode: mode,
|
|
62
|
+
top: contentTop,
|
|
63
|
+
topOffset: topOffset,
|
|
64
|
+
height: height,
|
|
65
|
+
initial: collapsedStyle,
|
|
66
|
+
animate: openStyle,
|
|
67
|
+
exit: collapsedStyle,
|
|
68
|
+
position: position,
|
|
69
|
+
transition: theme.motion.framer.spring.moderate,
|
|
70
|
+
role: "complementary",
|
|
71
|
+
"aria-hidden": false,
|
|
72
|
+
"aria-label": ariaLabel ?? 'slide out drawer',
|
|
73
|
+
className: className,
|
|
74
|
+
"data-test-id": testId,
|
|
75
|
+
panelWidth: panelWidth,
|
|
76
|
+
children: 'function' == typeof children ? children(renderFunctionProps) : renderFunctionProps.isOpening ? null : children
|
|
77
|
+
})
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const _SlideOverPanel = styled(motion.div, {
|
|
81
|
+
shouldForwardProp: (prop)=>[
|
|
82
|
+
'initial',
|
|
83
|
+
'animate',
|
|
84
|
+
'exit',
|
|
85
|
+
'transition'
|
|
86
|
+
].includes(prop) || 'height' !== prop && is_prop_valid(prop)
|
|
87
|
+
})`
|
|
88
|
+
position: fixed;
|
|
89
|
+
|
|
90
|
+
top: ${(p)=>p.topOffset ?? ('left' === p.position || 'passive' === p.mode ? p.top : p.theme.space.xl)};
|
|
91
|
+
height: ${(p)=>p.height ?? 'auto'};
|
|
92
|
+
right: ${(p)=>'left' === p.position ? p.theme.space.xl : 0};
|
|
93
|
+
bottom: ${(p)=>p.theme.space.xl};
|
|
94
|
+
left: ${(p)=>'left' === p.position ? 0 : p.theme.space.xl};
|
|
95
|
+
|
|
96
|
+
overflow: auto;
|
|
97
|
+
pointer-events: auto;
|
|
98
|
+
overscroll-behavior: contain;
|
|
99
|
+
|
|
100
|
+
z-index: ${(p)=>p.theme.zIndex.modal - 1};
|
|
101
|
+
background: ${(p)=>p.theme.tokens.background.overlay};
|
|
102
|
+
box-shadow: ${(p)=>p.theme.shadow.high};
|
|
103
|
+
color: ${(p)=>p.theme.tokens.content.primary};
|
|
104
|
+
|
|
105
|
+
text-align: left;
|
|
106
|
+
|
|
107
|
+
@media (min-width: ${(p)=>p.theme.breakpoints.sm}) {
|
|
108
|
+
${(p)=>'bottom' === p.position ? css`
|
|
109
|
+
position: sticky;
|
|
110
|
+
|
|
111
|
+
width: 100%;
|
|
112
|
+
height: ${p.height ?? PANEL_HEIGHT};
|
|
113
|
+
|
|
114
|
+
right: 0;
|
|
115
|
+
bottom: 0;
|
|
116
|
+
left: 0;
|
|
117
|
+
` : 'right' === p.position ? css`
|
|
118
|
+
position: fixed;
|
|
119
|
+
|
|
120
|
+
width: ${p.panelWidth ?? RIGHT_SIDE_PANEL_WIDTH};
|
|
121
|
+
height: ${p.height ?? ('passive' === p.mode ? `calc(100% - ${p.top})` : '100%')};
|
|
122
|
+
|
|
123
|
+
top: ${p.topOffset ?? ('passive' === p.mode ? p.top : 0)};
|
|
124
|
+
right: 0;
|
|
125
|
+
bottom: 0;
|
|
126
|
+
left: auto;
|
|
127
|
+
` : css`
|
|
128
|
+
position: relative;
|
|
129
|
+
|
|
130
|
+
width: ${p.panelWidth ?? LEFT_SIDE_PANEL_WIDTH};
|
|
131
|
+
min-width: 450px;
|
|
132
|
+
height: ${p.height ?? ('passive' === p.mode ? `calc(100% - ${p.top})` : '100%')};
|
|
133
|
+
|
|
134
|
+
top: ${p.topOffset ?? ('passive' === p.mode ? p.top : 0)};
|
|
135
|
+
right: auto;
|
|
136
|
+
bottom: 0;
|
|
137
|
+
left: auto;
|
|
138
|
+
`}
|
|
139
|
+
}
|
|
140
|
+
`;
|
|
141
|
+
export { SlideOverPanel };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const KNOWN_BRIDGED_CONTEXTS: readonly [import("react").Context<("xs" | "sm" | "md") | undefined>, import("react").Context<"
|
|
1
|
+
export declare const KNOWN_BRIDGED_CONTEXTS: readonly [import("react").Context<("xs" | "sm" | "md") | undefined>, import("react").Context<"2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "zero" | "3xs" | "5xl" | null>];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Spinner, type SpinnerProps } from './spinner.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Spinner } from "./spinner.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
export interface SpinnerProps {
|
|
3
|
+
children?: NonNullable<React.ReactNode>;
|
|
4
|
+
className?: string;
|
|
5
|
+
['data-test-id']?: string;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use `size` instead.
|
|
8
|
+
*/
|
|
9
|
+
mini?: boolean;
|
|
10
|
+
relative?: boolean;
|
|
11
|
+
size?: number;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
}
|
|
14
|
+
export declare function Spinner(props: SpinnerProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { keyframes } from "@emotion/react";
|
|
3
|
+
import styled from "@emotion/styled";
|
|
4
|
+
import classnames from "classnames";
|
|
5
|
+
function Spinner(props) {
|
|
6
|
+
return /*#__PURE__*/ jsxs(Container, {
|
|
7
|
+
className: classnames('scraps-spinner', props.className, {
|
|
8
|
+
'scraps-spinner-mini': props.mini
|
|
9
|
+
}),
|
|
10
|
+
style: props.style,
|
|
11
|
+
"data-test-id": props['data-test-id'] ?? 'loading-indicator',
|
|
12
|
+
children: [
|
|
13
|
+
/*#__PURE__*/ jsx("div", {
|
|
14
|
+
className: classnames('scraps-spinner-container', {
|
|
15
|
+
'scraps-spinner-relative': props.relative
|
|
16
|
+
}),
|
|
17
|
+
style: {
|
|
18
|
+
width: props.size,
|
|
19
|
+
height: props.size
|
|
20
|
+
},
|
|
21
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
22
|
+
className: "scraps-spinner-ring",
|
|
23
|
+
style: props.size ? {
|
|
24
|
+
width: props.size - 1,
|
|
25
|
+
height: props.size - 1,
|
|
26
|
+
borderWidth: getSpinnerBorderWidth(props.size)
|
|
27
|
+
} : void 0
|
|
28
|
+
})
|
|
29
|
+
}),
|
|
30
|
+
props.children && /*#__PURE__*/ jsx("div", {
|
|
31
|
+
className: "scraps-spinner-message",
|
|
32
|
+
children: props.children
|
|
33
|
+
})
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function getSpinnerBorderWidth(size) {
|
|
38
|
+
if (!size) return;
|
|
39
|
+
if (size > 64) return 6;
|
|
40
|
+
return 2 + (size - 24) / 40 * 4;
|
|
41
|
+
}
|
|
42
|
+
const loading = keyframes`
|
|
43
|
+
from { transform: rotate(0deg); }
|
|
44
|
+
to { transform: rotate(360deg); }
|
|
45
|
+
`;
|
|
46
|
+
const Container = styled('div')`
|
|
47
|
+
margin: 6em auto;
|
|
48
|
+
position: relative;
|
|
49
|
+
|
|
50
|
+
.scraps-spinner-container {
|
|
51
|
+
box-sizing: border-box;
|
|
52
|
+
position: relative;
|
|
53
|
+
width: fit-content;
|
|
54
|
+
margin: 0 auto;
|
|
55
|
+
padding: 0.5px;
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.scraps-spinner-ring {
|
|
60
|
+
box-sizing: border-box;
|
|
61
|
+
position: relative;
|
|
62
|
+
background: transparent;
|
|
63
|
+
/* oxlint-disable-next-line @sentry/scraps/use-semantic-token -- Preserve the existing light-theme loader colors. */
|
|
64
|
+
border: 6px solid
|
|
65
|
+
${(p)=>'dark' === p.theme.type ? p.theme.tokens.border.transparent.neutral.muted : '#e6e9ec'};
|
|
66
|
+
/* oxlint-disable-next-line @sentry/scraps/use-semantic-token -- Preserve the existing light-theme loader colors. */
|
|
67
|
+
border-left-color: ${(p)=>'dark' === p.theme.type ? p.theme.tokens.border.accent.vibrant : '#6c5fc7'};
|
|
68
|
+
animation: ${loading} 0.55s infinite linear;
|
|
69
|
+
margin: 0 auto;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.scraps-spinner-ring,
|
|
73
|
+
.scraps-spinner-ring::after {
|
|
74
|
+
border-radius: 50%;
|
|
75
|
+
width: 63px;
|
|
76
|
+
height: 63px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.scraps-spinner-message {
|
|
80
|
+
margin-top: 20px;
|
|
81
|
+
text-align: center;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&.scraps-spinner-mini {
|
|
85
|
+
margin: 4px 0;
|
|
86
|
+
font-size: 13px;
|
|
87
|
+
height: 24px;
|
|
88
|
+
width: 24px;
|
|
89
|
+
|
|
90
|
+
.scraps-spinner-container {
|
|
91
|
+
position: absolute;
|
|
92
|
+
left: 0;
|
|
93
|
+
top: 0;
|
|
94
|
+
width: 24px;
|
|
95
|
+
height: 24px;
|
|
96
|
+
|
|
97
|
+
&.scraps-spinner-relative {
|
|
98
|
+
position: relative;
|
|
99
|
+
left: auto;
|
|
100
|
+
top: auto;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.scraps-spinner-ring {
|
|
105
|
+
margin: 0;
|
|
106
|
+
width: 23px;
|
|
107
|
+
height: 23px;
|
|
108
|
+
border-width: 2px;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.scraps-spinner-message {
|
|
112
|
+
padding-left: 30px;
|
|
113
|
+
margin-top: 1px;
|
|
114
|
+
display: inline-block;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@media (prefers-reduced-motion) {
|
|
119
|
+
.scraps-spinner-ring {
|
|
120
|
+
animation-delay: -1ms !important;
|
|
121
|
+
animation-duration: 0ms !important;
|
|
122
|
+
animation-iteration-count: 1 !important;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
`;
|
|
126
|
+
export { Spinner };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SplitPanel, type SplitPanelHandle } from './splitPanel.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SplitPanel } from "./splitPanel.js";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { type Responsive } from '../layout/index.js';
|
|
3
|
+
export interface SplitPanelHandle {
|
|
4
|
+
/**
|
|
5
|
+
* Imperatively set the `sized` pane's size (px). Useful to seed the size from
|
|
6
|
+
* a measurement the parent takes after mount, without remounting (and thus
|
|
7
|
+
* without the parent gating the whole panel on its own measurement).
|
|
8
|
+
*/
|
|
9
|
+
setSize: (size: number, userEvent?: boolean) => void;
|
|
10
|
+
}
|
|
11
|
+
interface SplitPanelProps {
|
|
12
|
+
/** Initial size of the `sized` pane in pixels; restored on double-click. */
|
|
13
|
+
defaultSize: number;
|
|
14
|
+
/** The pane with a draggable size. */
|
|
15
|
+
sized: React.ReactNode;
|
|
16
|
+
/** The pane that fills the remaining space. Omit to render a single pane. */
|
|
17
|
+
fill?: React.ReactNode;
|
|
18
|
+
/** Minimum size of the `fill` pane in pixels. */
|
|
19
|
+
fillMinSize?: number;
|
|
20
|
+
/** Starting size, e.g. restored from persistence. Defaults to `defaultSize`. */
|
|
21
|
+
initialSize?: number;
|
|
22
|
+
maxSize?: number;
|
|
23
|
+
minSize?: number;
|
|
24
|
+
/** Fires once when a drag ends. */
|
|
25
|
+
onResizeEnd?: (payload: {
|
|
26
|
+
direction: 'increase' | 'decrease';
|
|
27
|
+
endSize: number;
|
|
28
|
+
startSize: number;
|
|
29
|
+
}) => void;
|
|
30
|
+
/** Layout direction. Accepts a responsive value. */
|
|
31
|
+
orientation?: Responsive<'horizontal' | 'vertical'>;
|
|
32
|
+
/** Imperative handle exposing `setSize`. */
|
|
33
|
+
ref?: React.Ref<SplitPanelHandle>;
|
|
34
|
+
/** Set to false to keep the divider in place but stop it from resizing. */
|
|
35
|
+
resizable?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare function SplitPanel({ sized, fill, ref, orientation: orientationProp, defaultSize, initialSize, minSize, maxSize, fillMinSize, onResizeEnd, resizable, }: SplitPanelProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useCallback, useImperativeHandle, useRef, useState } from "react";
|
|
3
|
+
import styled from "@emotion/styled";
|
|
4
|
+
import { DRAG_HANDLE_SIZE, DragHandle } from "../dragHandle/index.js";
|
|
5
|
+
import { Flex, Stack } from "../layout/index.js";
|
|
6
|
+
import { useResponsivePropValue } from "../layout/styles.js";
|
|
7
|
+
import { useTranslation } from "../translation/useTranslation.js";
|
|
8
|
+
import { useDimensions } from "../useDimensions.js";
|
|
9
|
+
import { useResizableDrawer } from "../useResizableDrawer.js";
|
|
10
|
+
function Pane({ size, children }) {
|
|
11
|
+
const isFilling = null === size;
|
|
12
|
+
return /*#__PURE__*/ jsx(Stack, {
|
|
13
|
+
minHeight: "0",
|
|
14
|
+
minWidth: "0",
|
|
15
|
+
flexGrow: isFilling ? 1 : 0,
|
|
16
|
+
flexShrink: isFilling ? 1 : 0,
|
|
17
|
+
flexBasis: isFilling ? 0 : `${size}px`,
|
|
18
|
+
children: children
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function SplitPanel({ sized, fill, ref, orientation: orientationProp = 'horizontal', defaultSize, initialSize = defaultSize, minSize = 0, maxSize, fillMinSize = 0, onResizeEnd, resizable = true }) {
|
|
22
|
+
const { t } = useTranslation();
|
|
23
|
+
const orientation = 'vertical' === useResponsivePropValue(orientationProp) ? 'vertical' : 'horizontal';
|
|
24
|
+
const hasFill = null != fill;
|
|
25
|
+
const containerRef = useRef(null);
|
|
26
|
+
const dims = useDimensions({
|
|
27
|
+
elementRef: containerRef
|
|
28
|
+
});
|
|
29
|
+
const availableSize = 'horizontal' === orientation ? dims.width : dims.height;
|
|
30
|
+
const min = minSize;
|
|
31
|
+
const explicitMax = maxSize ?? 1 / 0;
|
|
32
|
+
const max = availableSize > 0 ? Math.max(min, Math.min(explicitMax, availableSize - fillMinSize - DRAG_HANDLE_SIZE)) : explicitMax;
|
|
33
|
+
const handleResizeEnd = useCallback((startSize, endSize)=>{
|
|
34
|
+
if (startSize === endSize) return;
|
|
35
|
+
onResizeEnd?.({
|
|
36
|
+
startSize,
|
|
37
|
+
endSize,
|
|
38
|
+
direction: endSize > startSize ? 'increase' : 'decrease'
|
|
39
|
+
});
|
|
40
|
+
}, [
|
|
41
|
+
onResizeEnd
|
|
42
|
+
]);
|
|
43
|
+
const [isHeld, setIsHeld] = useState(false);
|
|
44
|
+
const dragStateRef = useRef(null);
|
|
45
|
+
const { setSize, size: containerSize } = useResizableDrawer({
|
|
46
|
+
direction: 'horizontal' === orientation ? 'left' : 'down',
|
|
47
|
+
initialSize,
|
|
48
|
+
min,
|
|
49
|
+
max
|
|
50
|
+
});
|
|
51
|
+
useImperativeHandle(ref, ()=>({
|
|
52
|
+
setSize
|
|
53
|
+
}), [
|
|
54
|
+
setSize
|
|
55
|
+
]);
|
|
56
|
+
const visibleSize = Math.max(min, Math.min(containerSize, max));
|
|
57
|
+
const handleDoubleClick = ()=>{
|
|
58
|
+
const target = Math.max(min, Math.min(defaultSize, max));
|
|
59
|
+
setSize(target, true);
|
|
60
|
+
handleResizeEnd(visibleSize, target);
|
|
61
|
+
};
|
|
62
|
+
const handleMoveStart = ()=>{
|
|
63
|
+
dragStateRef.current = {
|
|
64
|
+
size: visibleSize,
|
|
65
|
+
startSize: visibleSize
|
|
66
|
+
};
|
|
67
|
+
setIsHeld(true);
|
|
68
|
+
};
|
|
69
|
+
const handleMove = (delta)=>{
|
|
70
|
+
const state = dragStateRef.current;
|
|
71
|
+
if (!state) return;
|
|
72
|
+
state.size = Math.max(min, Math.min(max, state.size + delta));
|
|
73
|
+
setSize(Math.round(state.size), true);
|
|
74
|
+
};
|
|
75
|
+
const handleMoveEnd = ()=>{
|
|
76
|
+
const state = dragStateRef.current;
|
|
77
|
+
dragStateRef.current = null;
|
|
78
|
+
setIsHeld(false);
|
|
79
|
+
if (state) handleResizeEnd(state.startSize, Math.round(state.size));
|
|
80
|
+
};
|
|
81
|
+
const handleKeyDown = (event)=>{
|
|
82
|
+
let newSize = null;
|
|
83
|
+
if ('Home' === event.key) newSize = min;
|
|
84
|
+
else if ('End' === event.key) newSize = max;
|
|
85
|
+
if (null !== newSize && Number.isFinite(newSize)) {
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
setSize(newSize, true);
|
|
88
|
+
handleResizeEnd(visibleSize, newSize);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const panes = [
|
|
92
|
+
/*#__PURE__*/ jsx(Pane, {
|
|
93
|
+
size: hasFill ? visibleSize : null,
|
|
94
|
+
children: sized
|
|
95
|
+
}, "sized")
|
|
96
|
+
];
|
|
97
|
+
if (hasFill) panes.push(/*#__PURE__*/ jsx(DragHandle, {
|
|
98
|
+
"aria-label": t('Resize panels'),
|
|
99
|
+
disabled: !resizable,
|
|
100
|
+
isSizedFirst: true,
|
|
101
|
+
max: max,
|
|
102
|
+
min: min,
|
|
103
|
+
orientation: orientation,
|
|
104
|
+
value: visibleSize,
|
|
105
|
+
onDoubleClick: handleDoubleClick,
|
|
106
|
+
onKeyDown: handleKeyDown,
|
|
107
|
+
onMove: handleMove,
|
|
108
|
+
onMoveEnd: handleMoveEnd,
|
|
109
|
+
onMoveStart: handleMoveStart
|
|
110
|
+
}, "divider"), /*#__PURE__*/ jsx(Pane, {
|
|
111
|
+
size: null,
|
|
112
|
+
children: fill
|
|
113
|
+
}, "fill"));
|
|
114
|
+
return /*#__PURE__*/ jsx(Flex, {
|
|
115
|
+
direction: 'horizontal' === orientation ? 'row' : 'column',
|
|
116
|
+
position: "relative",
|
|
117
|
+
width: "100%",
|
|
118
|
+
height: "100%",
|
|
119
|
+
minHeight: "0",
|
|
120
|
+
minWidth: "0",
|
|
121
|
+
flex: "1",
|
|
122
|
+
children: (props)=>/*#__PURE__*/ jsx(RootElement, {
|
|
123
|
+
...props,
|
|
124
|
+
ref: containerRef,
|
|
125
|
+
"data-is-held": isHeld,
|
|
126
|
+
style: hasFill && 0 === availableSize ? {
|
|
127
|
+
visibility: 'hidden'
|
|
128
|
+
} : void 0,
|
|
129
|
+
children: panes
|
|
130
|
+
})
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const RootElement = styled('div')`
|
|
134
|
+
/*
|
|
135
|
+
* Disable iframe pointer events while dragging so the divider doesn't lose the
|
|
136
|
+
* cursor when crossing an embedded iframe (e.g. the Replay player). The
|
|
137
|
+
* triple-& raises specificity so this beats the player's own
|
|
138
|
+
* [data-inspectable] .replayer-wrapper > iframe !important rule, which would
|
|
139
|
+
* otherwise tie and make the drag intermittently stick over the video.
|
|
140
|
+
*/
|
|
141
|
+
&&&[data-is-held='true'] iframe {
|
|
142
|
+
pointer-events: none !important;
|
|
143
|
+
}
|
|
144
|
+
`;
|
|
145
|
+
export { SplitPanel };
|
package/dist/table/table.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as React from 'react';
|
|
2
2
|
import type { ComponentProps, HTMLAttributes, ReactNode, Ref, RefObject, TdHTMLAttributes, ThHTMLAttributes } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import type { Responsive } from '../layout/index.js';
|
|
4
4
|
import type { LinkProps } from '../link/index.js';
|
|
5
5
|
import { type ColumnAlign, type SortDirection } from './sortableHeaderCell.js';
|
|
6
6
|
import { TableBody, TableCell, TableHead, TableRow } from './styles.js';
|