@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
package/dist/table/table.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { Fragment, createContext, useCallback, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
3
3
|
import { DragHandle } from "../dragHandle/index.js";
|
|
4
|
-
import { useResponsivePropResolver } from "../layout/
|
|
4
|
+
import { useResponsivePropResolver } from "../layout/styles.js";
|
|
5
5
|
import { useStableMergeRef } from "../useStableMergeRef.js";
|
|
6
6
|
import { COLUMN_ALIGN_JUSTIFY, SortableHeaderCell, getAriaSort } from "./sortableHeaderCell.js";
|
|
7
7
|
import { TableBody, TableCell, TableGrid, TableHead, TableHeadCell, TableResizer, TableRow, TableStatusCell } from "./styles.js";
|
|
@@ -22,6 +22,10 @@ function getDefaultColumnTrack(width, { flexible, minimumColumnWidth }) {
|
|
|
22
22
|
if (width > minimumColumnWidth) return flexible ? `minmax(${width}px, auto)` : `${width}px`;
|
|
23
23
|
return flexible ? `minmax(${minimumColumnWidth}px, auto)` : `${minimumColumnWidth}px`;
|
|
24
24
|
}
|
|
25
|
+
function isFlexibleWidth(width) {
|
|
26
|
+
if ('string' == typeof width) return /\bauto\b|fr\b/.test(width) && !width.includes('content');
|
|
27
|
+
return void 0 === width || width === COL_WIDTH_UNDEFINED;
|
|
28
|
+
}
|
|
25
29
|
const TableContext = /*#__PURE__*/ createContext(null);
|
|
26
30
|
function useTableContext() {
|
|
27
31
|
return useContext(TableContext);
|
|
@@ -40,23 +44,16 @@ function Table({ children, columns = EMPTY_COLUMNS, flexibleLastColumn = true, m
|
|
|
40
44
|
const isControlled = !!onColumnResize;
|
|
41
45
|
const resolveResponsiveProp = useResponsivePropResolver();
|
|
42
46
|
const resolvedColumns = [];
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
width: resolveResponsiveProp(width)
|
|
49
|
-
};
|
|
50
|
-
resolvedColumns.push(resolved);
|
|
51
|
-
if (!resolved.hidden) visibleColumns.push(resolved);
|
|
52
|
-
}
|
|
47
|
+
for (const { visible, width, ...column } of columns)resolvedColumns.push({
|
|
48
|
+
...column,
|
|
49
|
+
hidden: !resolveResponsiveProp(withHiddenBase(visible)),
|
|
50
|
+
width: resolveResponsiveProp(width)
|
|
51
|
+
});
|
|
53
52
|
const lastVisibleIndex = resolvedColumns.findLastIndex((column)=>!column.hidden);
|
|
54
|
-
const trackIndexes = resolvedColumns.map((_, index)=>resolvedColumns.slice(0, index).filter((column)=>!column.hidden).length);
|
|
55
53
|
const resolveWidth = (column)=>isControlled ? column.width : internalWidths[column.key] ?? column.width;
|
|
56
|
-
const buildTemplate = (
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
flexible: flexibleLastColumn && index === visibleColumns.length - 1,
|
|
54
|
+
const buildTemplate = (overrides)=>{
|
|
55
|
+
const tracks = resolvedColumns.flatMap((column, index)=>column.hidden ? [] : getDefaultColumnTrack(overrides?.get(index) ?? resolveWidth(column), {
|
|
56
|
+
flexible: flexibleLastColumn && index === lastVisibleIndex,
|
|
60
57
|
minimumColumnWidth
|
|
61
58
|
}));
|
|
62
59
|
if (!tracks.length) return '';
|
|
@@ -73,10 +70,27 @@ function Table({ children, columns = EMPTY_COLUMNS, flexibleLastColumn = true, m
|
|
|
73
70
|
[key]: width
|
|
74
71
|
}));
|
|
75
72
|
};
|
|
73
|
+
const measurePinnedWidths = (draggedIndex)=>{
|
|
74
|
+
const pinned = new Map();
|
|
75
|
+
const grid = gridRef.current;
|
|
76
|
+
if (!grid || !flexibleLastColumn) return pinned;
|
|
77
|
+
const tracks = getComputedStyle(grid).gridTemplateColumns.split(' ');
|
|
78
|
+
if (!tracks.every((track)=>track.endsWith('px'))) return pinned;
|
|
79
|
+
const columnTracks = tracks.slice(prependColumnWidths?.length ?? 0).values();
|
|
80
|
+
for (const [index, column] of resolvedColumns.slice(0, draggedIndex).entries()){
|
|
81
|
+
if (column.hidden) continue;
|
|
82
|
+
const trackWidth = Math.round(parseFloat(columnTracks.next().value ?? ''));
|
|
83
|
+
if (false !== column.resizable && isFlexibleWidth(resolveWidth(column)) && trackWidth >= minimumColumnWidth) pinned.set(index, trackWidth);
|
|
84
|
+
}
|
|
85
|
+
return pinned;
|
|
86
|
+
};
|
|
87
|
+
const withResizedWidth = (pinnedWidths, index, width)=>new Map(pinnedWidths).set(index, Math.max(width, minimumColumnWidth));
|
|
76
88
|
const { applyTemplate, onResizeEnd, onResizeMove, onResizeStart } = useColumnResize({
|
|
77
89
|
gridRef,
|
|
78
|
-
getResizeTemplate: (index, newWidth)=>buildTemplate(index,
|
|
79
|
-
onColumnResizeEnd: (index, newWidth
|
|
90
|
+
getResizeTemplate: (index, newWidth, pinnedWidths)=>buildTemplate(withResizedWidth(pinnedWidths, index, newWidth)),
|
|
91
|
+
onColumnResizeEnd: (index, newWidth, pinnedWidths)=>{
|
|
92
|
+
for (const [columnIndex, width] of withResizedWidth(pinnedWidths, index, newWidth))commitWidth(columnIndex, width);
|
|
93
|
+
}
|
|
80
94
|
});
|
|
81
95
|
const template = buildTemplate();
|
|
82
96
|
const redraw = useCallback(()=>{
|
|
@@ -101,12 +115,17 @@ function Table({ children, columns = EMPTY_COLUMNS, flexibleLastColumn = true, m
|
|
|
101
115
|
minimumColumnWidth,
|
|
102
116
|
onResetColumnSize: (event, index)=>{
|
|
103
117
|
event.stopPropagation();
|
|
104
|
-
applyTemplate(buildTemplate(
|
|
118
|
+
applyTemplate(buildTemplate(new Map([
|
|
119
|
+
[
|
|
120
|
+
index,
|
|
121
|
+
COL_WIDTH_UNDEFINED
|
|
122
|
+
]
|
|
123
|
+
])));
|
|
105
124
|
commitWidth(index, COL_WIDTH_UNDEFINED);
|
|
106
125
|
},
|
|
107
126
|
onResizeEnd,
|
|
108
127
|
onResizeMove,
|
|
109
|
-
onResizeStart,
|
|
128
|
+
onResizeStart: (index, cell)=>onResizeStart(index, cell, measurePinnedWidths(index)),
|
|
110
129
|
resizableByIndex: resolvedColumns.map((column)=>!column.hidden && false !== column.resizable),
|
|
111
130
|
tableRef: gridRef
|
|
112
131
|
};
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type * as React from 'react';
|
|
2
2
|
interface UseColumnResizeOptions<T extends HTMLElement> {
|
|
3
3
|
/**
|
|
4
|
-
* Build the `gridTemplateColumns` string while `columnIndex` is being resized to `newWidth
|
|
4
|
+
* Build the `gridTemplateColumns` string while `columnIndex` is being resized to `newWidth`,
|
|
5
|
+
* holding the columns in `pinnedWidths` (passed to `onResizeStart`) at those widths.
|
|
5
6
|
*/
|
|
6
|
-
getResizeTemplate: (columnIndex: number, newWidth: number) => string;
|
|
7
|
+
getResizeTemplate: (columnIndex: number, newWidth: number, pinnedWidths: ReadonlyMap<number, number>) => string;
|
|
7
8
|
/**
|
|
8
9
|
* The grid element whose `gridTemplateColumns` is mutated during a resize.
|
|
9
10
|
*/
|
|
10
11
|
gridRef: React.RefObject<T | null>;
|
|
11
12
|
/**
|
|
12
|
-
* Persist the finalized width once the resize ends.
|
|
13
|
+
* Persist the finalized width, and any `pinnedWidths`, once the resize ends.
|
|
13
14
|
*/
|
|
14
|
-
onColumnResizeEnd?: (columnIndex: number, newWidth: number) => void;
|
|
15
|
+
onColumnResizeEnd?: (columnIndex: number, newWidth: number, pinnedWidths: ReadonlyMap<number, number>) => void;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* Shared column-resize mechanic for the sanctioned table shells. Owns the width
|
|
@@ -22,6 +23,6 @@ export declare function useColumnResize<T extends HTMLElement>({ gridRef, getRes
|
|
|
22
23
|
applyTemplate: (template: string) => void;
|
|
23
24
|
onResizeEnd: () => void;
|
|
24
25
|
onResizeMove: (delta: number) => void;
|
|
25
|
-
onResizeStart: (columnIndex: number, cell: HTMLElement | null) => void;
|
|
26
|
+
onResizeStart: (columnIndex: number, cell: HTMLElement | null, pinnedWidths?: ReadonlyMap<number, number>) => void;
|
|
26
27
|
};
|
|
27
28
|
export {};
|
|
@@ -15,10 +15,11 @@ function useColumnResize({ gridRef, getResizeTemplate, onColumnResizeEnd }) {
|
|
|
15
15
|
}, [
|
|
16
16
|
gridRef
|
|
17
17
|
]);
|
|
18
|
-
const onResizeStart = useCallback((columnIndex, cell)=>{
|
|
18
|
+
const onResizeStart = useCallback((columnIndex, cell, pinnedWidths = new Map())=>{
|
|
19
19
|
resizeStateRef.current = {
|
|
20
20
|
columnIndex,
|
|
21
21
|
moved: false,
|
|
22
|
+
pinnedWidths,
|
|
22
23
|
width: cell?.offsetWidth ?? 0
|
|
23
24
|
};
|
|
24
25
|
}, []);
|
|
@@ -30,7 +31,7 @@ function useColumnResize({ gridRef, getResizeTemplate, onColumnResizeEnd }) {
|
|
|
30
31
|
cancelPendingFrame();
|
|
31
32
|
frameRef.current = window.requestAnimationFrame(()=>{
|
|
32
33
|
frameRef.current = null;
|
|
33
|
-
applyTemplate(getResizeTemplate(state.columnIndex, Math.round(state.width)));
|
|
34
|
+
applyTemplate(getResizeTemplate(state.columnIndex, Math.round(state.width), state.pinnedWidths));
|
|
34
35
|
});
|
|
35
36
|
}, [
|
|
36
37
|
applyTemplate,
|
|
@@ -44,8 +45,8 @@ function useColumnResize({ gridRef, getResizeTemplate, onColumnResizeEnd }) {
|
|
|
44
45
|
resizeStateRef.current = null;
|
|
45
46
|
if (!state.moved) return;
|
|
46
47
|
const width = Math.round(state.width);
|
|
47
|
-
applyTemplate(getResizeTemplate(state.columnIndex, width));
|
|
48
|
-
onColumnResizeEnd?.(state.columnIndex, width);
|
|
48
|
+
applyTemplate(getResizeTemplate(state.columnIndex, width, state.pinnedWidths));
|
|
49
|
+
onColumnResizeEnd?.(state.columnIndex, width, state.pinnedWidths);
|
|
49
50
|
}, [
|
|
50
51
|
applyTemplate,
|
|
51
52
|
cancelPendingFrame,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import type { ItemProps } from '@react-types/shared';
|
|
3
|
+
import type { LinkProps } from '../link/index.js';
|
|
4
|
+
import type { TooltipProps } from '../tooltip/index.js';
|
|
5
|
+
export interface TabListItemProps extends ItemProps<any> {
|
|
6
|
+
key: string | number;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
hidden?: boolean;
|
|
9
|
+
to?: LinkProps['to'];
|
|
10
|
+
tooltip?: TooltipProps;
|
|
11
|
+
}
|
|
12
|
+
export declare const TabListItem: (props: TabListItemProps) => JSX.Element;
|
|
13
|
+
export declare const TabPanelItem: (props: ItemProps<any>) => JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ElementType, Ref } from 'react';
|
|
2
|
+
import type { AriaTabProps } from '@react-aria/tabs';
|
|
3
|
+
import type { TabListState } from '@react-stately/tabs';
|
|
4
|
+
import type { Node, Orientation } from '@react-types/shared';
|
|
5
|
+
import { type TooltipProps } from '../tooltip/index.js';
|
|
6
|
+
export interface TabProps extends AriaTabProps {
|
|
7
|
+
item: Node<any>;
|
|
8
|
+
orientation: Orientation;
|
|
9
|
+
/**
|
|
10
|
+
* Whether this tab is overflowing the TabList container. If so, the tab
|
|
11
|
+
* needs to be visually hidden. Users can instead select it via an overflow
|
|
12
|
+
* menu.
|
|
13
|
+
*/
|
|
14
|
+
overflowing: boolean;
|
|
15
|
+
size: 'md' | 'sm' | 'xs';
|
|
16
|
+
state: TabListState<any>;
|
|
17
|
+
as?: ElementType;
|
|
18
|
+
ref?: Ref<HTMLLIElement>;
|
|
19
|
+
tooltipProps?: TooltipProps;
|
|
20
|
+
variant?: 'flat' | 'floating';
|
|
21
|
+
}
|
|
22
|
+
export declare function Tab({ ref, item, state, orientation, overflowing, variant, size, as, tooltipProps, }: TabProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
package/dist/tabs/tab.js
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Fragment, useRef } from "react";
|
|
3
|
+
import { css } from "@emotion/react";
|
|
4
|
+
import styled from "@emotion/styled";
|
|
5
|
+
import { useTab } from "@react-aria/tabs";
|
|
6
|
+
import { useObjectRef } from "@react-aria/utils";
|
|
7
|
+
import { Link } from "../link/index.js";
|
|
8
|
+
import { Tooltip } from "../tooltip/index.js";
|
|
9
|
+
import { isModifiedClick, tabsShouldForwardProp } from "./utils.js";
|
|
10
|
+
const StyledTabWrap = styled('li', {
|
|
11
|
+
shouldForwardProp: tabsShouldForwardProp
|
|
12
|
+
})`
|
|
13
|
+
color: ${(p)=>p.selected ? p.theme.tokens.interactive.link.accent.rest : p.theme.tokens.interactive.link.neutral.rest};
|
|
14
|
+
white-space: nowrap;
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
|
|
17
|
+
&:focus-visible {
|
|
18
|
+
outline: none;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&[aria-disabled] {
|
|
22
|
+
opacity: 0.6;
|
|
23
|
+
cursor: default;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
${(p)=>p.overflowing && css`
|
|
27
|
+
display: none;
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
`}
|
|
30
|
+
`;
|
|
31
|
+
const paddingPerSize = (theme, orientation)=>({
|
|
32
|
+
md: 'horizontal' === orientation ? `10px ${theme.space.xl}` : `10px ${theme.space.md}`,
|
|
33
|
+
sm: 'horizontal' === orientation ? `${theme.space.md} ${theme.space.lg}` : `${theme.space.md} ${theme.space.sm}`,
|
|
34
|
+
xs: 'horizontal' === orientation ? `${theme.space.sm} ${theme.space.md}` : `${theme.space.sm} ${theme.space.xs}`
|
|
35
|
+
});
|
|
36
|
+
const selectionIndicatorSize = '2px';
|
|
37
|
+
const innerWrapStyles = ({ theme, orientation, variant, size, selected })=>css`
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
position: relative;
|
|
41
|
+
height: ${theme.form[size].height};
|
|
42
|
+
min-height: ${theme.form[size].minHeight};
|
|
43
|
+
font-size: ${theme.form[size].fontSize};
|
|
44
|
+
line-height: ${theme.form[size].lineHeight};
|
|
45
|
+
padding: ${paddingPerSize(theme, orientation)[size]};
|
|
46
|
+
border-radius: ${theme.radius.md};
|
|
47
|
+
transform: translateY(1px);
|
|
48
|
+
margin-bottom: ${'horizontal' === orientation && 'flat' === variant ? theme.space.xs : 0};
|
|
49
|
+
|
|
50
|
+
${'horizontal' === orientation ? css`
|
|
51
|
+
gap: ${theme.space.md};
|
|
52
|
+
` : css`
|
|
53
|
+
gap: ${theme.space.sm};
|
|
54
|
+
/**
|
|
55
|
+
* To align the SelectionIndicator (2px width, 4px spacing)
|
|
56
|
+
*/
|
|
57
|
+
margin-left: ${'flat' === variant ? `calc(${theme.space.xs} + ${selectionIndicatorSize})` : 0};
|
|
58
|
+
/* static padding towards SelectionIndicator */
|
|
59
|
+
padding-left: ${theme.space.md};
|
|
60
|
+
`}
|
|
61
|
+
|
|
62
|
+
li[aria-disabled]:hover & {
|
|
63
|
+
background-color: transparent;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&:focus-visible,
|
|
67
|
+
li:focus-visible & {
|
|
68
|
+
outline: none;
|
|
69
|
+
box-shadow: inset 0 0 0 2px ${theme.tokens.focus.default};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
li:not([aria-disabled]):hover & {
|
|
73
|
+
background-color: ${selected ? 'floating' === variant ? theme.tokens.interactive.transparent.accent.selected.background.hover : theme.tokens.interactive.transparent.accent.selected.background.rest : theme.tokens.interactive.transparent.neutral.background.hover};
|
|
74
|
+
color: ${selected ? theme.tokens.interactive.link.accent.hover : theme.tokens.interactive.link.neutral.hover};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
li:not([aria-disabled]):active & {
|
|
78
|
+
background-color: ${selected ? 'floating' === variant ? theme.tokens.interactive.transparent.accent.selected.background.active : theme.tokens.interactive.transparent.accent.selected.background.hover : theme.tokens.interactive.transparent.neutral.background.active};
|
|
79
|
+
color: ${selected ? theme.tokens.interactive.link.accent.active : theme.tokens.interactive.link.neutral.active};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
${'floating' === variant && selected && css`
|
|
83
|
+
background-color: ${theme.tokens.interactive.transparent.accent.selected.background.rest};
|
|
84
|
+
`}
|
|
85
|
+
`;
|
|
86
|
+
const StyledTabSelectionIndicator = styled('div')`
|
|
87
|
+
position: absolute;
|
|
88
|
+
border-radius: 1px;
|
|
89
|
+
pointer-events: none;
|
|
90
|
+
background: ${(p)=>p.selected ? p.theme.tokens.graphics.accent.vibrant : 'transparent'};
|
|
91
|
+
|
|
92
|
+
li[aria-disabled] & {
|
|
93
|
+
opacity: 0.6;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
${(p)=>'horizontal' === p.orientation ? css`
|
|
97
|
+
width: 100%;
|
|
98
|
+
height: ${selectionIndicatorSize};
|
|
99
|
+
|
|
100
|
+
bottom: 0;
|
|
101
|
+
left: 50%;
|
|
102
|
+
transform: translate(-50%, ${p.theme.space.xs});
|
|
103
|
+
` : css`
|
|
104
|
+
width: ${selectionIndicatorSize};
|
|
105
|
+
height: 50%;
|
|
106
|
+
|
|
107
|
+
left: -6px;
|
|
108
|
+
top: 50%;
|
|
109
|
+
transform: translateY(-50%);
|
|
110
|
+
`}
|
|
111
|
+
`;
|
|
112
|
+
function Tab({ ref, item, state, orientation, overflowing, variant = 'flat', size, as = 'li', tooltipProps }) {
|
|
113
|
+
const wrapperRef = useObjectRef(ref);
|
|
114
|
+
const controlRef = useRef(null);
|
|
115
|
+
const { key, rendered, props: { to, hidden } } = item;
|
|
116
|
+
const { tabProps, isSelected, isDisabled } = useTab({
|
|
117
|
+
key,
|
|
118
|
+
isDisabled: hidden,
|
|
119
|
+
shouldSelectOnPressUp: !!to
|
|
120
|
+
}, state, controlRef);
|
|
121
|
+
const isLink = !!to && !isDisabled;
|
|
122
|
+
const styleProps = {
|
|
123
|
+
orientation,
|
|
124
|
+
variant,
|
|
125
|
+
selected: isSelected,
|
|
126
|
+
size
|
|
127
|
+
};
|
|
128
|
+
const content = /*#__PURE__*/ jsxs(Fragment, {
|
|
129
|
+
children: [
|
|
130
|
+
rendered,
|
|
131
|
+
'flat' === variant && /*#__PURE__*/ jsx(StyledTabSelectionIndicator, {
|
|
132
|
+
orientation: orientation,
|
|
133
|
+
selected: isSelected
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
});
|
|
137
|
+
const tab = /*#__PURE__*/ jsx(TabWrap, {
|
|
138
|
+
...isLink ? {
|
|
139
|
+
role: 'presentation'
|
|
140
|
+
} : tabProps,
|
|
141
|
+
hidden: hidden,
|
|
142
|
+
"aria-disabled": isDisabled || void 0,
|
|
143
|
+
selected: isSelected,
|
|
144
|
+
overflowing: overflowing,
|
|
145
|
+
ref: (element)=>{
|
|
146
|
+
wrapperRef.current = element;
|
|
147
|
+
if (!isLink) controlRef.current = element;
|
|
148
|
+
},
|
|
149
|
+
as: as,
|
|
150
|
+
children: isLink ? /*#__PURE__*/ jsx(TabLink, {
|
|
151
|
+
...tabProps,
|
|
152
|
+
...styleProps,
|
|
153
|
+
to: to,
|
|
154
|
+
ref: (element)=>{
|
|
155
|
+
controlRef.current = element;
|
|
156
|
+
},
|
|
157
|
+
onMouseDown: (event)=>{
|
|
158
|
+
if (!isModifiedClick(event)) tabProps.onMouseDown?.(event);
|
|
159
|
+
},
|
|
160
|
+
onPointerDown: (event)=>{
|
|
161
|
+
if (!isModifiedClick(event)) tabProps.onPointerDown?.(event);
|
|
162
|
+
},
|
|
163
|
+
onClick: (event)=>{
|
|
164
|
+
if (!isModifiedClick(event)) tabProps.onClick?.(event);
|
|
165
|
+
},
|
|
166
|
+
onKeyDown: (event)=>{
|
|
167
|
+
if (' ' === event.key) event.preventDefault();
|
|
168
|
+
tabProps.onKeyDown?.(event);
|
|
169
|
+
},
|
|
170
|
+
children: content
|
|
171
|
+
}) : /*#__PURE__*/ jsx(TabInnerWrap, {
|
|
172
|
+
...styleProps,
|
|
173
|
+
children: content
|
|
174
|
+
})
|
|
175
|
+
});
|
|
176
|
+
return tooltipProps ? /*#__PURE__*/ jsx(Tooltip, {
|
|
177
|
+
...tooltipProps,
|
|
178
|
+
children: tab
|
|
179
|
+
}) : tab;
|
|
180
|
+
}
|
|
181
|
+
const TabWrap = StyledTabWrap;
|
|
182
|
+
const TabLink = styled(Link)`
|
|
183
|
+
${(p)=>innerWrapStyles({
|
|
184
|
+
variant: p.variant,
|
|
185
|
+
selected: p.selected,
|
|
186
|
+
orientation: p.orientation,
|
|
187
|
+
theme: p.theme,
|
|
188
|
+
size: p.size
|
|
189
|
+
})}
|
|
190
|
+
|
|
191
|
+
&,
|
|
192
|
+
&:hover {
|
|
193
|
+
color: inherit;
|
|
194
|
+
}
|
|
195
|
+
`;
|
|
196
|
+
const TabInnerWrap = styled('span')`
|
|
197
|
+
${(p)=>innerWrapStyles({
|
|
198
|
+
variant: p.variant,
|
|
199
|
+
selected: p.selected,
|
|
200
|
+
orientation: p.orientation,
|
|
201
|
+
size: p.size,
|
|
202
|
+
theme: p.theme
|
|
203
|
+
})}
|
|
204
|
+
`;
|
|
205
|
+
export { Tab };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { TabListStateOptions } from '@react-stately/tabs';
|
|
3
|
+
import type { TabListItemProps } from './item.js';
|
|
4
|
+
import type { TabProps } from './tab.js';
|
|
5
|
+
interface TabListProps {
|
|
6
|
+
children: TabListStateOptions<TabListItemProps>['children'];
|
|
7
|
+
outerWrapStyles?: CSSProperties;
|
|
8
|
+
variant?: TabProps['variant'];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* To be used as a direct child of the `<Tabs />` component. See example usage
|
|
12
|
+
* in tabs.stories.js
|
|
13
|
+
*/
|
|
14
|
+
export declare function TabList({ variant, ...props }: TabListProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare namespace TabList {
|
|
16
|
+
var Item: (props: TabListItemProps) => import("react").JSX.Element;
|
|
17
|
+
}
|
|
18
|
+
export {};
|