@sentry/scraps 0.5.0 → 0.7.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 +95 -3
- package/dist/alert/alert.js +10 -7
- package/dist/badge/tag.js +4 -2
- package/dist/button/button.js +1 -0
- package/dist/button/linkButton.js +1 -0
- package/dist/button/styles.js +157 -152
- package/dist/codeBlock/codeBlock.js +1 -0
- package/dist/compactSelect/compactSelect.d.ts +2 -2
- package/dist/compactSelect/compactSelect.js +37 -23
- package/dist/compactSelect/control.js +14 -10
- package/dist/compactSelect/gridList/index.js +35 -36
- package/dist/compactSelect/gridList/option.d.ts +4 -1
- package/dist/compactSelect/gridList/option.js +4 -3
- package/dist/compactSelect/gridList/section.d.ts +10 -3
- package/dist/compactSelect/gridList/section.js +16 -33
- package/dist/compactSelect/listBox/index.d.ts +1 -1
- package/dist/compactSelect/listBox/index.js +46 -58
- package/dist/compactSelect/listBox/section.d.ts +10 -8
- package/dist/compactSelect/listBox/section.js +11 -30
- package/dist/compactSelect/styles.d.ts +6 -7
- package/dist/compactSelect/styles.js +1 -23
- package/dist/compactSelect/utils.js +2 -6
- package/dist/dateTime/config.d.ts +23 -0
- package/dist/dateTime/config.js +50 -0
- package/dist/dateTime/context.d.ts +18 -0
- package/dist/dateTime/context.js +46 -0
- package/dist/dateTime/dateTime.d.ts +6 -0
- package/dist/dateTime/dateTime.js +30 -0
- package/dist/dateTime/format.d.ts +24 -0
- package/dist/dateTime/format.js +45 -0
- package/dist/dateTime/index.d.ts +6 -0
- package/dist/dateTime/index.js +6 -0
- package/dist/dateTime/intlFormatter.d.ts +9 -0
- package/dist/dateTime/intlFormatter.js +16 -0
- package/dist/dateTime/parseDate.d.ts +3 -0
- package/dist/dateTime/parseDate.js +12 -0
- package/dist/diagnostics/context.d.ts +12 -0
- package/dist/diagnostics/context.js +11 -0
- package/dist/diagnostics/index.d.ts +2 -0
- package/dist/diagnostics/index.js +1 -0
- package/dist/disclosure/disclosure.js +1 -1
- package/dist/dragHandle/dragHandle.js +3 -5
- package/dist/dropdownMenu/context.d.ts +36 -11
- package/dist/dropdownMenu/context.js +2 -1
- package/dist/dropdownMenu/dropdownMenu.d.ts +2 -2
- package/dist/dropdownMenu/dropdownMenu.js +9 -3
- package/dist/dropdownMenu/item.d.ts +7 -8
- package/dist/dropdownMenu/item.js +43 -77
- package/dist/dropdownMenu/list.d.ts +31 -5
- package/dist/dropdownMenu/list.js +154 -133
- package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +5 -241
- package/dist/dropdownMenu/useDropdownMenuKeyboard.js +5 -29
- package/dist/dropdownMenu/useDropdownMenuRowLayout.js +6 -14
- package/dist/dropdownMenu/useDropdownRootMenuState.d.ts +13 -0
- package/dist/dropdownMenu/useDropdownRootMenuState.js +30 -0
- package/dist/dropdownMenu/useDropdownSubmenuState.d.ts +19 -0
- package/dist/dropdownMenu/useDropdownSubmenuState.js +25 -0
- package/dist/dropdownMenu/utils.js +5 -7
- package/dist/duration/formatElapsedDuration.d.ts +4 -0
- package/dist/duration/formatElapsedDuration.js +10 -0
- package/dist/duration/getDuration.d.ts +68 -0
- package/dist/duration/getDuration.js +80 -0
- package/dist/duration/index.d.ts +2 -0
- package/dist/duration/index.js +2 -0
- package/dist/form/field/radioGroupField.d.ts +7 -0
- package/dist/form/field/radioGroupField.js +14 -0
- package/dist/form/field/selectField.d.ts +3 -4
- package/dist/form/field/selectField.js +16 -24
- package/dist/{compactSelect/fzf.d.ts → fzf.d.ts} +1 -0
- package/dist/{compactSelect/fzf.js → fzf.js} +5 -1
- package/dist/layout/container.d.ts +24 -7
- package/dist/layout/container.js +9 -12
- package/dist/layout/flex.js +1 -1
- package/dist/layout/grid.js +2 -2
- package/dist/layout/index.d.ts +1 -1
- package/dist/layout/index.js +1 -1
- package/dist/layout/stack.js +1 -1
- package/dist/layout/styles.d.ts +28 -7
- package/dist/layout/styles.js +76 -16
- package/dist/layout/surface.d.ts +2 -2
- package/dist/layout/surface.js +6 -3
- package/dist/legacyDatetime.d.ts +21 -0
- package/dist/legacyDatetime.js +13 -0
- package/dist/link/index.d.ts +1 -1
- package/dist/link/index.js +1 -1
- package/dist/link/linkBehaviorContext.d.ts +9 -0
- package/dist/link/linkBehaviorContext.js +37 -7
- package/dist/menu/menu.d.ts +1 -3
- package/dist/menu/menu.js +5 -6
- package/dist/menu/selectValue.d.ts +2 -6
- package/dist/modal/components.js +2 -2
- package/dist/overlayArrow.js +2 -2
- package/dist/relativeTime/getRelativeDate.d.ts +14 -0
- package/dist/relativeTime/getRelativeDate.js +107 -0
- package/dist/relativeTime/index.d.ts +3 -0
- package/dist/relativeTime/index.js +3 -0
- package/dist/relativeTime/relativeTime.d.ts +55 -0
- package/dist/relativeTime/relativeTime.js +102 -0
- package/dist/relativeTime/useRelativeTimeFormatter.d.ts +2 -0
- package/dist/relativeTime/useRelativeTimeFormatter.js +10 -0
- package/dist/select/chips.d.ts +14 -0
- package/dist/select/chips.js +45 -0
- package/dist/select/filter.js +7 -11
- package/dist/select/index.d.ts +1 -1
- package/dist/select/indicators.d.ts +11 -0
- package/dist/select/indicators.js +61 -0
- package/dist/select/menu.d.ts +44 -0
- package/dist/select/menu.js +103 -0
- package/dist/select/option.d.ts +23 -15
- package/dist/select/option.js +66 -58
- package/dist/select/options.d.ts +31 -0
- package/dist/select/options.js +74 -0
- package/dist/select/select.d.ts +24 -11
- package/dist/select/select.js +527 -429
- package/dist/select/styles.d.ts +148 -2
- package/dist/select/styles.js +156 -1
- package/dist/select/types.d.ts +6 -7
- package/dist/select/types.js +4 -0
- package/dist/select/utils.d.ts +2 -0
- package/dist/select/utils.js +4 -0
- package/dist/separator/separator.d.ts +2 -2
- package/dist/separator/separator.js +4 -3
- package/dist/slot/slot.js +16 -12
- package/dist/tabs/context.d.ts +9 -0
- package/dist/tabs/context.js +9 -0
- package/dist/tabs/index.d.ts +2 -4
- package/dist/tabs/index.js +1 -3
- package/dist/tabs/item.d.ts +16 -5
- package/dist/tabs/tab.js +9 -4
- package/dist/tabs/tabList.d.ts +5 -5
- package/dist/tabs/tabList.js +8 -6
- package/dist/tabs/tabPanels.d.ts +2 -3
- package/dist/tabs/tabPanels.js +1 -1
- package/dist/tabs/tabs.d.ts +46 -31
- package/dist/tabs/tabs.js +38 -35
- package/dist/text/prose.d.ts +2 -2
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/index.js +2 -0
- package/dist/theme/theme.d.ts +34 -34
- package/dist/theme/theme.js +9 -0
- package/dist/theme/types.d.ts +21 -2
- package/dist/theme/useResolvedTheme.d.ts +12 -0
- package/dist/theme/useResolvedTheme.js +20 -0
- package/dist/theme/variables.css +1116 -0
- package/dist/theme/variables.d.ts +985 -0
- package/dist/theme/variables.js +455 -0
- package/dist/translation/index.d.ts +1 -0
- package/dist/translation/index.js +1 -0
- package/dist/translation/translate.d.ts +9 -0
- package/dist/translation/translate.js +5 -0
- package/dist/translation/translationContext.d.ts +2 -1
- package/dist/translation/translationContext.js +2 -1
- package/dist/useVirtualCollection.d.ts +14 -1
- package/dist/useVirtualCollection.js +59 -3
- package/fonts/OFL.txt +94 -0
- package/fonts/roboto-mono-variable-cyrillic-ext.woff2 +0 -0
- package/fonts/roboto-mono-variable-cyrillic.woff2 +0 -0
- package/fonts/roboto-mono-variable-greek.woff2 +0 -0
- package/fonts/roboto-mono-variable-latin-ext.woff2 +0 -0
- package/fonts/roboto-mono-variable-vietnamese.woff2 +0 -0
- package/fonts/roboto-mono-variable.woff2 +0 -0
- package/fonts/rubik-variable-cyrillic-ext.woff2 +0 -0
- package/fonts/rubik-variable-cyrillic.woff2 +0 -0
- package/fonts/rubik-variable-latin-ext.woff2 +0 -0
- package/fonts/rubik-variable.woff2 +0 -0
- package/fonts.css +211 -0
- package/package.json +39 -15
- package/dist/compactSelect/useVirtualizedItems.d.ts +0 -52
- package/dist/compactSelect/useVirtualizedItems.js +0 -74
- package/dist/datetime.d.ts +0 -39
- package/dist/datetime.js +0 -20
- package/dist/dropdownMenu/useSafetyTriangle.d.ts +0 -12
- package/dist/dropdownMenu/useSafetyTriangle.js +0 -119
- package/dist/select/reactSelectWrapper.d.ts +0 -8
- package/dist/select/reactSelectWrapper.js +0 -25
- package/dist/select/virtualizedMenuList.d.ts +0 -24
- package/dist/select/virtualizedMenuList.js +0 -123
|
@@ -3,13 +3,15 @@ import { createElement } from "@emotion/react";
|
|
|
3
3
|
import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { Item, Section } from "@react-stately/collections";
|
|
5
5
|
import { useTranslation } from "../translation/index.js";
|
|
6
|
+
import { DEFAULT_VIRTUALIZE_THRESHOLD } from "../useVirtualCollection.js";
|
|
7
|
+
import { useDiagnostics } from "../diagnostics/context.js";
|
|
6
8
|
import { Control } from "./control.js";
|
|
7
9
|
import { List } from "./list.js";
|
|
8
10
|
import { EmptyMessage } from "./styles.js";
|
|
9
11
|
import { getDuplicateOptionKeysInfo, getItemsWithKeys, shouldCloseOnSelect } from "./utils.js";
|
|
10
|
-
import * as __rspack_external__sentry_react_f0cda475 from "@sentry/react";
|
|
11
12
|
function CompactSelect({ options, value, onChange, multiple, clearable, isOptionDisabled, sizeLimit, sizeLimitMessage, virtualizeThreshold, mode, disabled, emptyMessage, size = 'md', closeOnSelect, menuWidth, ...controlProps }) {
|
|
12
13
|
const { t } = useTranslation();
|
|
14
|
+
const diagnostics = useDiagnostics();
|
|
13
15
|
const generatedTriggerId = useId();
|
|
14
16
|
const triggerId = controlProps.triggerId ?? generatedTriggerId;
|
|
15
17
|
const listProps = useMemo(()=>{
|
|
@@ -43,23 +45,7 @@ function CompactSelect({ options, value, onChange, multiple, clearable, isOption
|
|
|
43
45
|
const allItemsWithKey = useMemo(()=>getItemsWithKeys(options), [
|
|
44
46
|
options
|
|
45
47
|
]);
|
|
46
|
-
const longestOptionItemsWithKey = useMemo(()=>
|
|
47
|
-
if (needsMeasuring) {
|
|
48
|
-
let longestOption;
|
|
49
|
-
let longestLength = -1;
|
|
50
|
-
for (const option of options){
|
|
51
|
-
const length = 'options' in option ? 0 : option.textValue ? option.textValue.length : 'string' == typeof option.label ? option.label.length : 0;
|
|
52
|
-
if (length > longestLength) {
|
|
53
|
-
longestOption = option;
|
|
54
|
-
longestLength = length;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return longestOption ? getItemsWithKeys([
|
|
58
|
-
longestOption
|
|
59
|
-
]) : [];
|
|
60
|
-
}
|
|
61
|
-
return [];
|
|
62
|
-
}, [
|
|
48
|
+
const longestOptionItemsWithKey = useMemo(()=>needsMeasuring ? getItemsWithKeys(getLongestOptionItems(options)) : [], [
|
|
63
49
|
needsMeasuring,
|
|
64
50
|
options
|
|
65
51
|
]);
|
|
@@ -77,7 +63,7 @@ function CompactSelect({ options, value, onChange, multiple, clearable, isOption
|
|
|
77
63
|
const duplicateOptionKeySignature = duplicateOptionKeys.join(',');
|
|
78
64
|
if (lastLoggedDuplicateKeySignatureRef.current === duplicateOptionKeySignature) return;
|
|
79
65
|
lastLoggedDuplicateKeySignatureRef.current = duplicateOptionKeySignature;
|
|
80
|
-
|
|
66
|
+
diagnostics.logger.error('CompactSelect has duplicate option keys', {
|
|
81
67
|
component_title: componentTitle,
|
|
82
68
|
duplicate_option_key_count: duplicateOptionKeys.length,
|
|
83
69
|
duplicate_option_key_signature: duplicateOptionKeySignature,
|
|
@@ -88,6 +74,7 @@ function CompactSelect({ options, value, onChange, multiple, clearable, isOption
|
|
|
88
74
|
}, [
|
|
89
75
|
allItemsWithKey,
|
|
90
76
|
componentTitle,
|
|
77
|
+
diagnostics,
|
|
91
78
|
virtualizeThreshold
|
|
92
79
|
]);
|
|
93
80
|
return /*#__PURE__*/ jsxs(Control, {
|
|
@@ -142,9 +129,36 @@ function CompactSelect({ options, value, onChange, multiple, clearable, isOption
|
|
|
142
129
|
]
|
|
143
130
|
});
|
|
144
131
|
}
|
|
145
|
-
function shouldVirtualize(items, virtualizeThreshold =
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
132
|
+
function shouldVirtualize(items, virtualizeThreshold = DEFAULT_VIRTUALIZE_THRESHOLD) {
|
|
133
|
+
const optionCount = items.reduce((count, item)=>count + ('options' in item ? item.options.length : 1), 0);
|
|
134
|
+
return optionCount > virtualizeThreshold;
|
|
135
|
+
}
|
|
136
|
+
function getLabelLength(option) {
|
|
137
|
+
if (option.textValue) return option.textValue.length;
|
|
138
|
+
return 'string' == typeof option.label ? option.label.length : 0;
|
|
139
|
+
}
|
|
140
|
+
function getLongestOptionItems(items) {
|
|
141
|
+
let longest;
|
|
142
|
+
let longestLength = -1;
|
|
143
|
+
for (const item of items){
|
|
144
|
+
const options = 'options' in item ? item.options : [
|
|
145
|
+
item
|
|
146
|
+
];
|
|
147
|
+
for (const option of options){
|
|
148
|
+
const length = getLabelLength(option);
|
|
149
|
+
if (length > longestLength) {
|
|
150
|
+
longestLength = length;
|
|
151
|
+
longest = 'options' in item ? {
|
|
152
|
+
...item,
|
|
153
|
+
options: [
|
|
154
|
+
option
|
|
155
|
+
]
|
|
156
|
+
} : option;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return longest ? [
|
|
161
|
+
longest
|
|
162
|
+
] : [];
|
|
149
163
|
}
|
|
150
164
|
export { CompactSelect };
|
|
@@ -193,6 +193,7 @@ function Control({ autoFocus, trigger, triggerId, isOpen, onClose, isDismissable
|
|
|
193
193
|
return /*#__PURE__*/ jsx(ControlContext, {
|
|
194
194
|
value: contextValue,
|
|
195
195
|
children: /*#__PURE__*/ jsxs(Container, {
|
|
196
|
+
display: "flex",
|
|
196
197
|
width: "max-content",
|
|
197
198
|
position: "relative",
|
|
198
199
|
...wrapperProps,
|
|
@@ -222,13 +223,13 @@ function Control({ autoFocus, trigger, triggerId, isOpen, onClose, isDismissable
|
|
|
222
223
|
contain: true,
|
|
223
224
|
children: [
|
|
224
225
|
hasHeader && /*#__PURE__*/ jsx(Header, {
|
|
225
|
-
|
|
226
|
+
borderBottomColor: searchEnabled ? 'none' : 'secondary',
|
|
227
|
+
padding: searchEnabled ? 'xs lg 0 lg' : 'xs lg',
|
|
226
228
|
children: /*#__PURE__*/ jsxs(Flex, {
|
|
227
229
|
align: "center",
|
|
228
230
|
justify: "between",
|
|
229
231
|
gap: "xl",
|
|
230
232
|
minHeight: "24px",
|
|
231
|
-
padding: searchEnabled ? 'xs lg 0 lg' : 'xs lg',
|
|
232
233
|
children: [
|
|
233
234
|
menuTitle && /*#__PURE__*/ jsx(Title, {
|
|
234
235
|
children: menuTitle
|
|
@@ -259,14 +260,17 @@ function Control({ autoFocus, trigger, triggerId, isOpen, onClose, isDismissable
|
|
|
259
260
|
]
|
|
260
261
|
})
|
|
261
262
|
}),
|
|
262
|
-
searchEnabled && /*#__PURE__*/ jsx(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
263
|
+
searchEnabled && /*#__PURE__*/ jsx(Container, {
|
|
264
|
+
borderBottomColor: "secondary",
|
|
265
|
+
children: /*#__PURE__*/ jsx(Search, {
|
|
266
|
+
ref: searchRef,
|
|
267
|
+
placeholder: normalizedSearch?.placeholder ?? 'Search…',
|
|
268
|
+
value: searchInputValue,
|
|
269
|
+
onFocus: onSearchFocus,
|
|
270
|
+
onBlur: onSearchBlur,
|
|
271
|
+
onChange: (e)=>updateSearch(e.target.value),
|
|
272
|
+
...searchKeyboardProps
|
|
273
|
+
})
|
|
270
274
|
}),
|
|
271
275
|
'function' == typeof menuBody ? menuBody({
|
|
272
276
|
closeOverlay: overlayState.close
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { createElement } from "@emotion/react";
|
|
2
|
+
import { createElement, useTheme } from "@emotion/react";
|
|
3
3
|
import { useContext, useId, useMemo, useRef } from "react";
|
|
4
4
|
import { useGridList } from "@react-aria/gridlist";
|
|
5
5
|
import { mergeProps } from "@react-aria/utils";
|
|
6
6
|
import { SelectFilterContext } from "../selectFilterContext.js";
|
|
7
7
|
import { ListLabel, ListSeparator, ListWrap, SizeLimitMessage } from "../styles.js";
|
|
8
|
-
import { useVirtualizedItems } from "../useVirtualizedItems.js";
|
|
9
8
|
import { hasVisibleLeadingItems } from "../utils.js";
|
|
10
9
|
import { Container } from "../../layout/index.js";
|
|
11
10
|
import { ControlContext, ReserveLeadingSlot } from "../../menu/index.js";
|
|
12
11
|
import { useTranslation } from "../../translation/index.js";
|
|
12
|
+
import { VirtualRows, useVirtualCollection } from "../../useVirtualCollection.js";
|
|
13
13
|
import { GridListOption } from "./option.js";
|
|
14
14
|
import { GridListSection } from "./section.js";
|
|
15
15
|
function GridList({ listState, size = 'md', label, sizeLimitMessage, keyDownHandler, virtualized, ...props }) {
|
|
16
16
|
const { t } = useTranslation();
|
|
17
|
+
const theme = useTheme();
|
|
17
18
|
const ref = useRef(null);
|
|
19
|
+
const scrollElementRef = useRef(null);
|
|
18
20
|
const labelId = useId();
|
|
19
21
|
const { gridProps } = useGridList({
|
|
20
22
|
...props,
|
|
@@ -41,9 +43,13 @@ function GridList({ listState, size = 'md', label, sizeLimitMessage, keyDownHand
|
|
|
41
43
|
listItems,
|
|
42
44
|
hiddenOptions
|
|
43
45
|
]);
|
|
44
|
-
const
|
|
45
|
-
listItems,
|
|
46
|
-
virtualized,
|
|
46
|
+
const virtual = useVirtualCollection({
|
|
47
|
+
collection: listItems,
|
|
48
|
+
enabled: !!virtualized,
|
|
49
|
+
scrollRef: scrollElementRef,
|
|
50
|
+
focusedKey: listState.selectionManager.focusedKey,
|
|
51
|
+
hiddenKeys: hiddenOptions,
|
|
52
|
+
listPadding: parseFloat(theme.space.xs),
|
|
47
53
|
size
|
|
48
54
|
});
|
|
49
55
|
const mergedProps = mergeProps(gridProps, props);
|
|
@@ -58,42 +64,35 @@ function GridList({ listState, size = 'md', label, sizeLimitMessage, keyDownHand
|
|
|
58
64
|
children: label
|
|
59
65
|
}),
|
|
60
66
|
overlayIsOpen && /*#__PURE__*/ jsx(Container, {
|
|
61
|
-
ref:
|
|
67
|
+
ref: scrollElementRef,
|
|
62
68
|
height: "100%",
|
|
63
69
|
overflowY: "auto",
|
|
64
|
-
children: /*#__PURE__*/
|
|
65
|
-
...
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
virtualizer.items.map((row)=>{
|
|
76
|
-
const item = listItems[row.index];
|
|
77
|
-
if (!item) return null;
|
|
78
|
-
if ('section' === item.type) return /*#__PURE__*/ createElement(GridListSection, {
|
|
79
|
-
...virtualizer.itemProps(row.index),
|
|
80
|
-
key: item.key,
|
|
81
|
-
node: item,
|
|
70
|
+
children: /*#__PURE__*/ jsxs(ListWrap, {
|
|
71
|
+
...mergedProps,
|
|
72
|
+
onKeyDown: onKeyDown,
|
|
73
|
+
ref: ref,
|
|
74
|
+
children: [
|
|
75
|
+
/*#__PURE__*/ jsx(VirtualRows, {
|
|
76
|
+
virtual: virtual,
|
|
77
|
+
renderRow: ({ node, props: rowProps })=>/*#__PURE__*/ createElement(GridListOption, {
|
|
78
|
+
...rowProps,
|
|
79
|
+
key: node.key,
|
|
80
|
+
node: node,
|
|
82
81
|
listState: listState,
|
|
83
82
|
size: size
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
node: item,
|
|
83
|
+
}),
|
|
84
|
+
renderSection: (section, rows)=>/*#__PURE__*/ jsx(GridListSection, {
|
|
85
|
+
node: section.node,
|
|
88
86
|
listState: listState,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
87
|
+
rowProps: section.props,
|
|
88
|
+
showSeparator: section.node !== listItems[0],
|
|
89
|
+
children: rows
|
|
90
|
+
})
|
|
91
|
+
}),
|
|
92
|
+
!searchable && hiddenOptions.size > 0 && /*#__PURE__*/ jsx(SizeLimitMessage, {
|
|
93
|
+
children: sizeLimitMessage ?? t('Use search to find more options…')
|
|
94
|
+
})
|
|
95
|
+
]
|
|
97
96
|
})
|
|
98
97
|
})
|
|
99
98
|
]
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
1
2
|
import type { AriaGridListItemOptions } from '@react-aria/gridlist';
|
|
2
3
|
import type { ListState } from '@react-stately/list';
|
|
3
4
|
import type { Node } from '@react-types/shared';
|
|
@@ -7,9 +8,11 @@ export interface GridListOptionProps<T extends ListItemBase> extends AriaGridLis
|
|
|
7
8
|
listState: ListState<T>;
|
|
8
9
|
node: Node<T>;
|
|
9
10
|
size: FormSize;
|
|
11
|
+
'data-index'?: number;
|
|
12
|
+
ref?: React.Ref<HTMLLIElement>;
|
|
10
13
|
}
|
|
11
14
|
/**
|
|
12
15
|
* A <li /> element with accessibile behaviors & attributes.
|
|
13
16
|
* https://react-spectrum.adobe.com/react-aria/useGridList.html
|
|
14
17
|
*/
|
|
15
|
-
export declare function GridListOption<T extends ListItemBase>({ node, listState, size, }: GridListOptionProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare function GridListOption<T extends ListItemBase>({ node, listState, size, ref: refProp, 'data-index': dataIndex, }: GridListOptionProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -2,13 +2,13 @@ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
|
2
2
|
import { Fragment, useContext, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { useGridListItem, useGridListSelectionCheckbox } from "@react-aria/gridlist";
|
|
4
4
|
import { useFocusWithin, useHover } from "@react-aria/interactions";
|
|
5
|
-
import { mergeProps } from "@react-aria/utils";
|
|
5
|
+
import { mergeProps, mergeRefs } from "@react-aria/utils";
|
|
6
6
|
import { IconCheckmark } from "@sentry/icons/checkmark";
|
|
7
7
|
import { Checkbox } from "../../checkbox/index.js";
|
|
8
8
|
import { HighlightText } from "../highlightText.js";
|
|
9
9
|
import { LeadWrap, getOptionPaddingLeft } from "../styles.js";
|
|
10
10
|
import { ControlContext, ListItem, useReserveLeadingSlot } from "../../menu/index.js";
|
|
11
|
-
function GridListOption({ node, listState, size }) {
|
|
11
|
+
function GridListOption({ node, listState, size, ref: refProp, 'data-index': dataIndex }) {
|
|
12
12
|
const ref = useRef(null);
|
|
13
13
|
const { label, details, trailingItems, priority, hideCheck, tooltip, tooltipOptions, selectionMode } = node.props;
|
|
14
14
|
const multiple = selectionMode ? 'multiple' === selectionMode : 'multiple' === listState.selectionManager.selectionMode;
|
|
@@ -84,7 +84,8 @@ function GridListOption({ node, listState, size }) {
|
|
|
84
84
|
]);
|
|
85
85
|
return /*#__PURE__*/ jsx(ListItem, {
|
|
86
86
|
...rowPropsMerged,
|
|
87
|
-
|
|
87
|
+
"data-index": dataIndex,
|
|
88
|
+
ref: mergeRefs(ref, refProp),
|
|
88
89
|
size: size,
|
|
89
90
|
label: renderedLabel,
|
|
90
91
|
details: details,
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
1
2
|
import type { ListState } from '@react-stately/list';
|
|
2
3
|
import type { Node } from '@react-types/shared';
|
|
3
4
|
import type { ListItemBase } from '../types.js';
|
|
4
|
-
import {
|
|
5
|
+
import type { VirtualRowProps } from '../../useVirtualCollection.js';
|
|
5
6
|
interface GridListSectionProps<T extends ListItemBase> {
|
|
7
|
+
children: React.ReactNode;
|
|
6
8
|
listState: ListState<T>;
|
|
7
9
|
node: Node<T>;
|
|
8
|
-
|
|
10
|
+
showSeparator: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Measurement props for the section's own row when the list is virtualized.
|
|
13
|
+
* The row holds the separator and header above the section's options.
|
|
14
|
+
*/
|
|
15
|
+
rowProps?: VirtualRowProps;
|
|
9
16
|
}
|
|
10
17
|
/**
|
|
11
18
|
* A <li /> element that functions as a grid list section (renders a nested <ul />
|
|
12
19
|
* inside). https://react-spectrum.adobe.com/react-aria/useGridList.html
|
|
13
20
|
*/
|
|
14
|
-
export declare function GridListSection<T extends ListItemBase>({ node, listState,
|
|
21
|
+
export declare function GridListSection<T extends ListItemBase>({ children, node, listState, showSeparator, rowProps, }: GridListSectionProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
15
22
|
export {};
|
|
@@ -1,37 +1,23 @@
|
|
|
1
1
|
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { useSeparator } from "@react-aria/separator";
|
|
4
|
-
import { SelectFilterContext } from "../selectFilterContext.js";
|
|
2
|
+
import { useId } from "react";
|
|
5
3
|
import { SectionSeparator } from "../styles.js";
|
|
6
4
|
import { SectionToggle } from "../utils.js";
|
|
7
5
|
import { SectionGroup, SectionHeader, SectionLabel, SectionList } from "../../menu/index.js";
|
|
8
|
-
|
|
9
|
-
function GridListSection({ node, listState, size }) {
|
|
6
|
+
function GridListSection({ children, node, listState, showSeparator, rowProps }) {
|
|
10
7
|
const titleId = useId();
|
|
11
|
-
const { separatorProps } = useSeparator({
|
|
12
|
-
elementType: 'li'
|
|
13
|
-
});
|
|
14
8
|
const showToggleAllButton = 'multiple' === listState.selectionManager.selectionMode && node.value?.showToggleAllButton;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return /*#__PURE__*/ jsxs(Fragment, {
|
|
9
|
+
return /*#__PURE__*/ jsxs(SectionGroup, {
|
|
10
|
+
role: "rowgroup",
|
|
11
|
+
...node['aria-label'] ? {
|
|
12
|
+
'aria-label': node['aria-label']
|
|
13
|
+
} : {
|
|
14
|
+
'aria-labelledby': titleId
|
|
15
|
+
},
|
|
23
16
|
children: [
|
|
24
|
-
/*#__PURE__*/
|
|
25
|
-
...
|
|
26
|
-
}),
|
|
27
|
-
/*#__PURE__*/ jsxs(SectionGroup, {
|
|
28
|
-
role: "rowgroup",
|
|
29
|
-
...node['aria-label'] ? {
|
|
30
|
-
'aria-label': node['aria-label']
|
|
31
|
-
} : {
|
|
32
|
-
'aria-labelledby': titleId
|
|
33
|
-
},
|
|
17
|
+
/*#__PURE__*/ jsxs("div", {
|
|
18
|
+
...rowProps,
|
|
34
19
|
children: [
|
|
20
|
+
showSeparator && /*#__PURE__*/ jsx(SectionSeparator, {}),
|
|
35
21
|
(node.rendered || showToggleAllButton) && /*#__PURE__*/ jsx(SectionHeader, {
|
|
36
22
|
trailingAction: showToggleAllButton ? /*#__PURE__*/ jsx(SectionToggle, {
|
|
37
23
|
item: node,
|
|
@@ -39,18 +25,15 @@ function GridListSection({ node, listState, size }) {
|
|
|
39
25
|
}) : null,
|
|
40
26
|
children: node.rendered && /*#__PURE__*/ jsx(SectionLabel, {
|
|
41
27
|
id: titleId,
|
|
28
|
+
size: "md",
|
|
42
29
|
"aria-hidden": true,
|
|
43
30
|
children: node.rendered
|
|
44
31
|
})
|
|
45
|
-
}),
|
|
46
|
-
/*#__PURE__*/ jsx(SectionList, {
|
|
47
|
-
children: childNodes.map((child)=>/*#__PURE__*/ jsx(GridListOption, {
|
|
48
|
-
node: child,
|
|
49
|
-
listState: listState,
|
|
50
|
-
size: size
|
|
51
|
-
}, child.key))
|
|
52
32
|
})
|
|
53
33
|
]
|
|
34
|
+
}),
|
|
35
|
+
/*#__PURE__*/ jsx(SectionList, {
|
|
36
|
+
children: children
|
|
54
37
|
})
|
|
55
38
|
]
|
|
56
39
|
});
|
|
@@ -66,7 +66,7 @@ interface ListBoxProps<T extends ListItemBase> extends Omit<React.HTMLAttributes
|
|
|
66
66
|
*/
|
|
67
67
|
virtualized?: boolean;
|
|
68
68
|
/**
|
|
69
|
-
* Vertical padding (in px) added to the virtualizer height. Defaults to
|
|
69
|
+
* Vertical padding (in px) added to the virtualizer height. Defaults to ListWrap's padding, theme.space.xs.
|
|
70
70
|
*/
|
|
71
71
|
virtualizedListPadding?: number;
|
|
72
72
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { createElement } from "@emotion/react";
|
|
2
|
+
import { createElement, useTheme } from "@emotion/react";
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
-
import { getInteractionModality } from "@react-aria/interactions";
|
|
5
4
|
import { useListBox } from "@react-aria/listbox";
|
|
6
5
|
import { mergeProps, mergeRefs } from "@react-aria/utils";
|
|
7
6
|
import { ListLabel, ListSeparator, ListWrap, SizeLimitMessage } from "../styles.js";
|
|
8
|
-
import { useVirtualizedItems } from "../useVirtualizedItems.js";
|
|
9
7
|
import { hasVisibleLeadingItems } from "../utils.js";
|
|
10
8
|
import { Container } from "../../layout/index.js";
|
|
11
9
|
import { ReserveLeadingSlot } from "../../menu/index.js";
|
|
12
10
|
import { useTranslation } from "../../translation/index.js";
|
|
11
|
+
import { VirtualRows, useVirtualCollection } from "../../useVirtualCollection.js";
|
|
13
12
|
import { ListBoxDetailsHoverContext, ListBoxOption } from "./option.js";
|
|
14
13
|
import { ListBoxSection } from "./section.js";
|
|
15
14
|
const EMPTY_SET = new Set();
|
|
@@ -17,10 +16,11 @@ const DETAILS_CLOSE_DELAY = 150;
|
|
|
17
16
|
const DEFAULT_KEY_DOWN_HANDLER = ()=>true;
|
|
18
17
|
function ListBox({ ref, listState, autoFocus, size = 'md', shouldFocusWrap = true, shouldFocusOnHover = true, sizeLimitMessage, keyDownHandler = DEFAULT_KEY_DOWN_HANDLER, label, hiddenOptions = EMPTY_SET, hasSearch, searchable, overlayIsOpen, showSectionHeaders = true, showDetails = true, onAction, virtualized, virtualizedListPadding, scrollContainerRef, className, ...props }) {
|
|
19
18
|
const { t } = useTranslation();
|
|
19
|
+
const theme = useTheme();
|
|
20
20
|
const listElementRef = useRef(null);
|
|
21
21
|
const scrollElementRef = useRef(null);
|
|
22
22
|
const [hasEverOverflowed, setHasEverOverflowed] = useState(false);
|
|
23
|
-
const
|
|
23
|
+
const listBoxOptions = {
|
|
24
24
|
...props,
|
|
25
25
|
scrollRef: scrollElementRef,
|
|
26
26
|
autoFocus,
|
|
@@ -29,7 +29,8 @@ function ListBox({ ref, listState, autoFocus, size = 'md', shouldFocusWrap = tru
|
|
|
29
29
|
shouldFocusOnHover,
|
|
30
30
|
shouldSelectOnPressUp: true,
|
|
31
31
|
onAction
|
|
32
|
-
}
|
|
32
|
+
};
|
|
33
|
+
const { listBoxProps, labelProps } = useListBox(listBoxOptions, listState, listElementRef);
|
|
33
34
|
const onKeyDown = (e)=>{
|
|
34
35
|
const continueCallback = keyDownHandler?.(e);
|
|
35
36
|
if (continueCallback && 'Escape' !== e.key) listBoxProps.onKeyDown?.(e);
|
|
@@ -79,31 +80,26 @@ function ListBox({ ref, listState, autoFocus, size = 'md', shouldFocusWrap = tru
|
|
|
79
80
|
mergedProps.onMouseEnter?.(e);
|
|
80
81
|
cancelFocusClear();
|
|
81
82
|
};
|
|
82
|
-
const
|
|
83
|
-
listItems,
|
|
84
|
-
virtualized,
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
const virtual = useVirtualCollection({
|
|
84
|
+
collection: listItems,
|
|
85
|
+
enabled: !!virtualized,
|
|
86
|
+
scrollRef: scrollElementRef,
|
|
87
|
+
focusedKey: listState.selectionManager.focusedKey,
|
|
88
|
+
hiddenKeys: hiddenOptions,
|
|
89
|
+
listPadding: virtualizedListPadding ?? parseFloat(theme.space.xs),
|
|
90
|
+
size
|
|
87
91
|
});
|
|
88
|
-
useEffect(()=>{
|
|
89
|
-
if (!virtualized || null === listState.selectionManager.focusedKey || 'pointer' === getInteractionModality()) return;
|
|
90
|
-
const focusedIndex = listItems.findIndex((item)=>item.key === listState.selectionManager.focusedKey);
|
|
91
|
-
if (-1 !== focusedIndex) virtualizer.scrollToIndex(focusedIndex);
|
|
92
|
-
}, [
|
|
93
|
-
virtualized,
|
|
94
|
-
listItems,
|
|
95
|
-
listState.selectionManager.focusedKey,
|
|
96
|
-
virtualizer
|
|
97
|
-
]);
|
|
98
92
|
const refs = useMemo(()=>{
|
|
99
93
|
const overflowTracker = (scrollContainer)=>{
|
|
100
94
|
if (hasEverOverflowed || 0 === listItems.length || !scrollContainer) return;
|
|
101
|
-
|
|
95
|
+
requestAnimationFrame(()=>{
|
|
96
|
+
const overflowed = scrollContainer.scrollHeight - scrollContainer.clientHeight > 1;
|
|
97
|
+
setHasEverOverflowed((prev)=>prev || overflowed);
|
|
98
|
+
});
|
|
102
99
|
};
|
|
103
|
-
return mergeRefs(scrollElementRef, overflowTracker,
|
|
100
|
+
return mergeRefs(scrollElementRef, overflowTracker, scrollContainerRef);
|
|
104
101
|
}, [
|
|
105
102
|
hasEverOverflowed,
|
|
106
|
-
virtualizer.scrollElementRef,
|
|
107
103
|
listItems,
|
|
108
104
|
scrollContainerRef
|
|
109
105
|
]);
|
|
@@ -121,51 +117,43 @@ function ListBox({ ref, listState, autoFocus, size = 'md', shouldFocusWrap = tru
|
|
|
121
117
|
}),
|
|
122
118
|
/*#__PURE__*/ jsx(Container, {
|
|
123
119
|
ref: refs,
|
|
120
|
+
"data-test-id": "compact-select-scroll-container",
|
|
124
121
|
height: "100%",
|
|
125
122
|
overflowY: "auto",
|
|
126
123
|
className: className,
|
|
127
124
|
style: hasEverOverflowed ? {
|
|
128
125
|
scrollbarGutter: 'stable'
|
|
129
126
|
} : void 0,
|
|
130
|
-
children: /*#__PURE__*/
|
|
131
|
-
...
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
overlayIsOpen && virtualizer.items.map((row)=>{
|
|
144
|
-
const item = listItems[row.index];
|
|
145
|
-
if (!item) return null;
|
|
146
|
-
if ('section' === item.type) return /*#__PURE__*/ createElement(ListBoxSection, {
|
|
147
|
-
...virtualizer.itemProps(row.index),
|
|
148
|
-
key: item.key,
|
|
149
|
-
item: item,
|
|
127
|
+
children: /*#__PURE__*/ jsxs(ListWrap, {
|
|
128
|
+
...mergedProps,
|
|
129
|
+
onKeyDown: onKeyDown,
|
|
130
|
+
onMouseEnter: onMouseEnter,
|
|
131
|
+
onMouseLeave: onMouseLeave,
|
|
132
|
+
ref: mergeRefs(listElementRef, ref),
|
|
133
|
+
children: [
|
|
134
|
+
overlayIsOpen && /*#__PURE__*/ jsx(VirtualRows, {
|
|
135
|
+
virtual: virtual,
|
|
136
|
+
renderRow: ({ node, props: rowProps })=>/*#__PURE__*/ createElement(ListBoxOption, {
|
|
137
|
+
...rowProps,
|
|
138
|
+
key: node.key,
|
|
139
|
+
item: node,
|
|
150
140
|
listState: listState,
|
|
151
|
-
hiddenOptions: hiddenOptions,
|
|
152
141
|
size: size,
|
|
153
|
-
showSectionHeaders: showSectionHeaders,
|
|
154
142
|
showDetails: showDetails
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
item: item,
|
|
143
|
+
}),
|
|
144
|
+
renderSection: (section, rows)=>/*#__PURE__*/ jsx(ListBoxSection, {
|
|
145
|
+
item: section.node,
|
|
159
146
|
listState: listState,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
147
|
+
rowProps: section.props,
|
|
148
|
+
showSectionHeaders: showSectionHeaders,
|
|
149
|
+
showSeparator: section.node !== listItems[0],
|
|
150
|
+
children: rows
|
|
151
|
+
})
|
|
152
|
+
}),
|
|
153
|
+
!searchable && !hasSearch && hiddenOptions.size > 0 && /*#__PURE__*/ jsx(SizeLimitMessage, {
|
|
154
|
+
children: sizeLimitMessage ?? t('Use search to find more options…')
|
|
155
|
+
})
|
|
156
|
+
]
|
|
169
157
|
})
|
|
170
158
|
})
|
|
171
159
|
]
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import type * as React from 'react';
|
|
2
2
|
import type { ListState } from '@react-stately/list';
|
|
3
3
|
import type { Node } from '@react-types/shared';
|
|
4
|
-
import type {
|
|
5
|
-
import {
|
|
4
|
+
import type { ListItemBase } from '../types.js';
|
|
5
|
+
import type { VirtualRowProps } from '../../useVirtualCollection.js';
|
|
6
6
|
interface ListBoxSectionProps<T extends ListItemBase> {
|
|
7
|
-
|
|
7
|
+
children: React.ReactNode;
|
|
8
8
|
item: Node<T>;
|
|
9
9
|
listState: ListState<T>;
|
|
10
10
|
showSectionHeaders: boolean;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
showSeparator: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Measurement props for the section's own row when the list is virtualized.
|
|
14
|
+
* The row holds the separator and header above the section's options.
|
|
15
|
+
*/
|
|
16
|
+
rowProps?: VirtualRowProps;
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* A <li /> element that functions as a list box section (renders a nested <ul />
|
|
18
20
|
* inside). https://react-spectrum.adobe.com/react-aria/useListBox.html
|
|
19
21
|
*/
|
|
20
|
-
export declare function ListBoxSection<T extends ListItemBase>({ item, listState,
|
|
22
|
+
export declare function ListBoxSection<T extends ListItemBase>({ children, item, listState, showSectionHeaders, showSeparator, rowProps, }: ListBoxSectionProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
21
23
|
export {};
|