@sentry/scraps 0.6.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 +27 -0
- package/dist/alert/alert.js +10 -7
- package/dist/compactSelect/compactSelect.d.ts +2 -2
- package/dist/compactSelect/compactSelect.js +37 -23
- package/dist/compactSelect/control.js +12 -9
- 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/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 +10 -0
- package/dist/dropdownMenu/context.js +2 -1
- package/dist/dropdownMenu/item.d.ts +2 -7
- package/dist/dropdownMenu/item.js +13 -7
- package/dist/dropdownMenu/list.js +25 -23
- package/dist/dropdownMenu/useDropdownMenuRowLayout.js +6 -14
- 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/layout/container.d.ts +18 -7
- package/dist/layout/container.js +8 -11
- 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 -8
- package/dist/layout/styles.js +67 -13
- package/dist/layout/surface.d.ts +2 -2
- package/dist/layout/surface.js +6 -3
- package/dist/menu/menu.js +4 -4
- package/dist/menu/selectValue.d.ts +2 -6
- package/dist/modal/components.js +2 -2
- package/dist/overlayArrow.js +2 -2
- 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/tab.js +3 -1
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/index.js +2 -0
- package/dist/theme/types.d.ts +1 -0
- 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/useVirtualCollection.d.ts +14 -1
- package/dist/useVirtualCollection.js +59 -3
- package/package.json +12 -6
- package/dist/compactSelect/useVirtualizedItems.d.ts +0 -52
- package/dist/compactSelect/useVirtualizedItems.js +0 -74
- 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
|
@@ -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 {};
|
|
@@ -1,56 +1,37 @@
|
|
|
1
1
|
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { Fragment, useMemo } from "react";
|
|
3
2
|
import { useListBoxSection } from "@react-aria/listbox";
|
|
4
|
-
import { useSeparator } from "@react-aria/separator";
|
|
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 ListBoxSection({ item, listState, size, hiddenOptions, showSectionHeaders, showDetails = true, ref, 'data-index': dataIndex }) {
|
|
6
|
+
function ListBoxSection({ children, item, listState, showSectionHeaders, showSeparator, rowProps }) {
|
|
10
7
|
const { itemProps, headingProps, groupProps } = useListBoxSection({
|
|
11
8
|
heading: item.rendered,
|
|
12
9
|
'aria-label': item['aria-label']
|
|
13
10
|
});
|
|
14
|
-
const { separatorProps } = useSeparator({
|
|
15
|
-
elementType: 'li'
|
|
16
|
-
});
|
|
17
11
|
const showToggleAllButton = 'multiple' === listState.selectionManager.selectionMode && item.value?.showToggleAllButton;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
].filter((child)=>!hiddenOptions.has(child.key)), [
|
|
21
|
-
item.childNodes,
|
|
22
|
-
hiddenOptions
|
|
23
|
-
]);
|
|
24
|
-
return /*#__PURE__*/ jsxs(Fragment, {
|
|
12
|
+
return /*#__PURE__*/ jsxs(SectionGroup, {
|
|
13
|
+
...itemProps,
|
|
25
14
|
children: [
|
|
26
|
-
|
|
27
|
-
...
|
|
28
|
-
}),
|
|
29
|
-
/*#__PURE__*/ jsxs(SectionGroup, {
|
|
30
|
-
...itemProps,
|
|
31
|
-
"data-index": dataIndex,
|
|
32
|
-
ref: ref,
|
|
15
|
+
/*#__PURE__*/ jsxs("div", {
|
|
16
|
+
...rowProps,
|
|
33
17
|
children: [
|
|
18
|
+
showSectionHeaders && showSeparator && /*#__PURE__*/ jsx(SectionSeparator, {}),
|
|
34
19
|
(item.rendered || showToggleAllButton) && showSectionHeaders && /*#__PURE__*/ jsx(SectionHeader, {
|
|
35
20
|
trailingAction: showToggleAllButton ? /*#__PURE__*/ jsx(SectionToggle, {
|
|
36
21
|
item: item,
|
|
37
22
|
listState: listState
|
|
38
23
|
}) : null,
|
|
39
24
|
children: item.rendered && /*#__PURE__*/ jsx(SectionLabel, {
|
|
25
|
+
size: "md",
|
|
40
26
|
...headingProps,
|
|
41
27
|
children: item.rendered
|
|
42
28
|
})
|
|
43
|
-
}),
|
|
44
|
-
/*#__PURE__*/ jsx(SectionList, {
|
|
45
|
-
...groupProps,
|
|
46
|
-
children: childItems.map((child)=>/*#__PURE__*/ jsx(ListBoxOption, {
|
|
47
|
-
item: child,
|
|
48
|
-
listState: listState,
|
|
49
|
-
size: size,
|
|
50
|
-
showDetails: showDetails
|
|
51
|
-
}, child.key))
|
|
52
29
|
})
|
|
53
30
|
]
|
|
31
|
+
}),
|
|
32
|
+
/*#__PURE__*/ jsx(SectionList, {
|
|
33
|
+
...groupProps,
|
|
34
|
+
children: children
|
|
54
35
|
})
|
|
55
36
|
]
|
|
56
37
|
});
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import type * as React from 'react';
|
|
2
1
|
import { type FlexProps } from '../layout/index.js';
|
|
3
2
|
export declare const ListWrap: import("@emotion/styled").StyledComponent<{
|
|
4
3
|
theme?: import("@emotion/react").Theme;
|
|
5
4
|
as?: React.ElementType;
|
|
6
|
-
},
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, {}>;
|
|
7
6
|
export declare const ListLabel: import("@emotion/styled").StyledComponent<{
|
|
8
7
|
theme?: import("@emotion/react").Theme;
|
|
9
8
|
as?: React.ElementType;
|
|
10
|
-
},
|
|
9
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
11
10
|
export declare const ListSeparator: import("@emotion/styled").StyledComponent<{
|
|
12
11
|
theme?: import("@emotion/react").Theme;
|
|
13
12
|
as?: React.ElementType;
|
|
14
|
-
},
|
|
13
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
15
14
|
export declare const SectionToggleButton: import("@emotion/styled").StyledComponent<(import("../button/index.js").ButtonProps & {
|
|
16
15
|
theme?: import("@emotion/react").Theme;
|
|
17
16
|
}) & {
|
|
18
17
|
visible: boolean;
|
|
19
18
|
}, {}, {}>;
|
|
20
|
-
export declare function SectionSeparator(
|
|
19
|
+
export declare function SectionSeparator(): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
21
20
|
/**
|
|
22
21
|
* Left inset for CompactSelect options. CompactSelect puts its check column 4px
|
|
23
22
|
* closer to the menu edge than dropdown menus, in line with the title. The shared
|
|
@@ -32,8 +31,8 @@ export declare function LeadWrap(props: FlexProps): import("@emotion/react/jsx-r
|
|
|
32
31
|
export declare const EmptyMessage: import("@emotion/styled").StyledComponent<{
|
|
33
32
|
theme?: import("@emotion/react").Theme;
|
|
34
33
|
as?: React.ElementType;
|
|
35
|
-
},
|
|
34
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, {}>;
|
|
36
35
|
export declare const SizeLimitMessage: import("@emotion/styled").StyledComponent<{
|
|
37
36
|
theme?: import("@emotion/react").Theme;
|
|
38
37
|
as?: React.ElementType;
|
|
39
|
-
},
|
|
38
|
+
}, import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, {}>;
|
|
@@ -8,10 +8,6 @@ const ListWrap = styled('ul')`
|
|
|
8
8
|
margin: 0;
|
|
9
9
|
padding: ${(p)=>p.theme.space.xs} 0;
|
|
10
10
|
|
|
11
|
-
> [data-section-separator]:first-of-type {
|
|
12
|
-
display: none;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
11
|
/* Add 1px to top padding if preceded by menu header, to account for the header's
|
|
16
12
|
shadow border */
|
|
17
13
|
[data-menu-has-header='true'] > div > &:first-of-type {
|
|
@@ -24,13 +20,6 @@ const ListWrap = styled('ul')`
|
|
|
24
20
|
padding-bottom: calc(${(p)=>p.theme.space.xs} + 1px);
|
|
25
21
|
}
|
|
26
22
|
|
|
27
|
-
/* Remove top padding if preceded by search input, since search input already has
|
|
28
|
-
vertical padding. Account for InputGroup wrapper div. */
|
|
29
|
-
div:has(input) ~ &&:first-of-type,
|
|
30
|
-
div:has(input) ~ div > &&:first-of-type {
|
|
31
|
-
padding-top: 0;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
23
|
&:empty {
|
|
35
24
|
padding: 0;
|
|
36
25
|
}
|
|
@@ -44,14 +33,6 @@ const ListWrap = styled('ul')`
|
|
|
44
33
|
:focus-visible {
|
|
45
34
|
outline: none;
|
|
46
35
|
}
|
|
47
|
-
|
|
48
|
-
/* The first section follows a hidden separator in a headerless menu. */
|
|
49
|
-
[data-menu-has-header='false']
|
|
50
|
-
&:first-of-type
|
|
51
|
-
li[role='presentation']:nth-of-type(2)
|
|
52
|
-
> [data-section-header] {
|
|
53
|
-
padding-top: 0;
|
|
54
|
-
}
|
|
55
36
|
`;
|
|
56
37
|
const ListLabel = styled('span')`
|
|
57
38
|
display: inline-block;
|
|
@@ -102,14 +83,11 @@ const SectionToggleButton = styled(Button)`
|
|
|
102
83
|
pointer-events: all;
|
|
103
84
|
}
|
|
104
85
|
`;
|
|
105
|
-
function styles_SectionSeparator(
|
|
86
|
+
function styles_SectionSeparator() {
|
|
106
87
|
return /*#__PURE__*/ jsx(Stack, {
|
|
107
|
-
as: "li",
|
|
108
|
-
"data-section-separator": true,
|
|
109
88
|
justify: "center",
|
|
110
89
|
height: "8px",
|
|
111
90
|
padding: "0 lg 0 xl",
|
|
112
|
-
...props,
|
|
113
91
|
role: "presentation",
|
|
114
92
|
children: /*#__PURE__*/ jsx(SectionSeparator, {})
|
|
115
93
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface Diagnostics {
|
|
2
|
+
captureException: (error: Error, context?: {
|
|
3
|
+
fingerprint?: string[];
|
|
4
|
+
level?: 'fatal' | 'error' | 'warning' | 'log' | 'info' | 'debug';
|
|
5
|
+
tags?: Record<string, string>;
|
|
6
|
+
}) => void;
|
|
7
|
+
logger: {
|
|
8
|
+
error: (message: string, attributes?: Record<string, boolean | number | string>) => void;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare const DiagnosticsContextProvider: import("react").Provider<Diagnostics>;
|
|
12
|
+
export declare const useDiagnostics: () => Diagnostics;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
const defaultDiagnostics = {
|
|
3
|
+
captureException: ()=>{},
|
|
4
|
+
logger: {
|
|
5
|
+
error: ()=>{}
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
const DiagnosticsContext = createContext(defaultDiagnostics);
|
|
9
|
+
const DiagnosticsContextProvider = DiagnosticsContext.Provider;
|
|
10
|
+
const useDiagnostics = ()=>useContext(DiagnosticsContext);
|
|
11
|
+
export { DiagnosticsContextProvider, useDiagnostics };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DiagnosticsContextProvider } from "./context.js";
|
|
@@ -128,7 +128,7 @@ function Content({ children, ...props }) {
|
|
|
128
128
|
if ('outline' === context.variant) return /*#__PURE__*/ jsx(Container, {
|
|
129
129
|
ref: panelRef,
|
|
130
130
|
...panelProps,
|
|
131
|
-
|
|
131
|
+
borderColor: "primary",
|
|
132
132
|
radius: OUTLINE_RADIUS[context.size],
|
|
133
133
|
padding: OUTLINE_PADDING[context.size],
|
|
134
134
|
width: "100%",
|
|
@@ -39,13 +39,11 @@ const DragHandleLine = styled('div')`
|
|
|
39
39
|
touch-action: none;
|
|
40
40
|
pointer-events: none;
|
|
41
41
|
|
|
42
|
-
/*
|
|
43
|
-
One below the drawer z-index: above pane content, but below global drawers, which render
|
|
44
|
-
before the app in the DOM and so lose a z-index tie. */
|
|
42
|
+
/* Keep the hit area and highlight above pane content and below dropdowns and drawers. */
|
|
45
43
|
&::before {
|
|
46
44
|
content: '';
|
|
47
45
|
position: absolute;
|
|
48
|
-
z-index: ${(p)=>p.theme.zIndex.
|
|
46
|
+
z-index: ${(p)=>p.theme.zIndex.dropdown - 1};
|
|
49
47
|
pointer-events: auto;
|
|
50
48
|
cursor: ${(p)=>p.$cursor};
|
|
51
49
|
}
|
|
@@ -54,7 +52,7 @@ const DragHandleLine = styled('div')`
|
|
|
54
52
|
&::after {
|
|
55
53
|
content: '';
|
|
56
54
|
position: absolute;
|
|
57
|
-
z-index: ${(p)=>p.theme.zIndex.
|
|
55
|
+
z-index: ${(p)=>p.theme.zIndex.dropdown - 1};
|
|
58
56
|
opacity: 0.8;
|
|
59
57
|
background: transparent;
|
|
60
58
|
transition: background ${(p)=>p.theme.motion.smooth.slow};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type * as React from 'react';
|
|
2
2
|
import type { RootMenuTriggerState } from '@react-stately/menu';
|
|
3
|
+
import type { TreeState } from '@react-stately/tree';
|
|
4
|
+
import type { MenuItemProps } from './item.js';
|
|
3
5
|
interface DropdownMenuContextValue {
|
|
4
6
|
/**
|
|
5
7
|
* `isDismissable` of the root menu. Dismissing a submenu closes the root menu,
|
|
@@ -36,4 +38,12 @@ interface DropdownMenuContextValue {
|
|
|
36
38
|
virtualizeThreshold?: number;
|
|
37
39
|
}
|
|
38
40
|
export declare const DropdownMenuContext: React.Context<DropdownMenuContextValue>;
|
|
41
|
+
/**
|
|
42
|
+
* Tree state of the menu that renders the current items. Items read it from
|
|
43
|
+
* context rather than props: React Aria returns a new state on every render,
|
|
44
|
+
* and as a prop it would re-render every component between the list and its
|
|
45
|
+
* items, including a submenu trigger's open submenu. Through context, only the
|
|
46
|
+
* items that read it re-render.
|
|
47
|
+
*/
|
|
48
|
+
export declare const DropdownMenuTreeStateContext: React.Context<TreeState<MenuItemProps>>;
|
|
39
49
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { createContext } from "react";
|
|
2
2
|
const DropdownMenuContext = /*#__PURE__*/ createContext({});
|
|
3
|
-
|
|
3
|
+
const DropdownMenuTreeStateContext = /*#__PURE__*/ createContext(null);
|
|
4
|
+
export { DropdownMenuContext, DropdownMenuTreeStateContext };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type * as React from 'react';
|
|
2
2
|
import type { SubmenuTriggerAria } from '@react-aria/menu';
|
|
3
|
-
import type { TreeState } from '@react-stately/tree';
|
|
4
3
|
import type { Node } from '@react-types/shared';
|
|
5
|
-
import {
|
|
4
|
+
import type { LinkProps } from '../link/index.js';
|
|
6
5
|
import { type ListItemProps, type MenuItemTrailingAction } from '../menu/index.js';
|
|
7
6
|
import type { UseOverlayProps } from '../useOverlay.js';
|
|
8
7
|
import { type VirtualRowProps } from '../useVirtualCollection.js';
|
|
@@ -96,10 +95,6 @@ interface DropdownMenuItemProps<T extends React.ElementType = 'li'> {
|
|
|
96
95
|
* Node representation (from @react-aria) of the item
|
|
97
96
|
*/
|
|
98
97
|
node: Node<MenuItemProps>;
|
|
99
|
-
/**
|
|
100
|
-
* Tree state (from @react-stately) inherited from parent menu
|
|
101
|
-
*/
|
|
102
|
-
state: TreeState<MenuItemProps>;
|
|
103
98
|
id?: string;
|
|
104
99
|
/**
|
|
105
100
|
* Whether the item is in a virtualized menu. React Aria then sets
|
|
@@ -136,5 +131,5 @@ interface DropdownMenuItemProps<T extends React.ElementType = 'li'> {
|
|
|
136
131
|
* Can also be used as a trigger button for a submenu. See:
|
|
137
132
|
* https://react-spectrum.adobe.com/react-aria/useMenu.html
|
|
138
133
|
*/
|
|
139
|
-
export declare function DropdownMenuItem<T extends React.ElementType = 'li'>({ node,
|
|
134
|
+
export declare function DropdownMenuItem<T extends React.ElementType = 'li'>({ node, closeOnSelect, onClose, renderAs, ref, menuItemRef, submenuTriggerProps, isVirtualized, rowProps, ...props }: DropdownMenuItemProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
140
135
|
export {};
|
|
@@ -5,10 +5,10 @@ import { useMenuItem } from "@react-aria/menu";
|
|
|
5
5
|
import { mergeProps, mergeRefs } from "@react-aria/utils";
|
|
6
6
|
import { IconCheckmark } from "@sentry/icons/checkmark";
|
|
7
7
|
import { IconChevron } from "@sentry/icons/chevron";
|
|
8
|
-
import {
|
|
8
|
+
import { useLinkBehavior } from "../link/linkBehaviorContext.js";
|
|
9
9
|
import { ListItem } from "../menu/index.js";
|
|
10
10
|
import { isAfterFirstInSection } from "../useVirtualCollection.js";
|
|
11
|
-
import { DropdownMenuContext } from "./context.js";
|
|
11
|
+
import { DropdownMenuContext, DropdownMenuTreeStateContext } from "./context.js";
|
|
12
12
|
function getSectionItemAttributes(node, state) {
|
|
13
13
|
const section = null === node.parentKey || void 0 === node.parentKey ? null : state.collection.getItem(node.parentKey);
|
|
14
14
|
if (section?.type !== 'section') return {};
|
|
@@ -17,9 +17,10 @@ function getSectionItemAttributes(node, state) {
|
|
|
17
17
|
'data-first-in-section': isAfterFirstInSection(node, section) ? void 0 : true
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
function DropdownMenuItem({ node,
|
|
20
|
+
function DropdownMenuItem({ node, closeOnSelect, onClose, renderAs, ref, menuItemRef, submenuTriggerProps, isVirtualized, rowProps, ...props }) {
|
|
21
21
|
const innerWrapRef = useRef(null);
|
|
22
22
|
const trailingActionRef = useRef(null);
|
|
23
|
+
const state = useContext(DropdownMenuTreeStateContext);
|
|
23
24
|
const isDisabled = state.disabledKeys.has(node.key);
|
|
24
25
|
const isFocused = state.selectionManager.focusedKey === node.key;
|
|
25
26
|
const { key, onAction, to, label, isSelected, leadingItems, submenu, trailingItems, trailingAction, externalHref, closeOnSelect: itemCloseOnSelect, ref: itemRef, ...itemProps } = node.value ?? {};
|
|
@@ -27,6 +28,9 @@ function DropdownMenuItem({ node, state, closeOnSelect, onClose, renderAs, ref,
|
|
|
27
28
|
const { size } = node.props;
|
|
28
29
|
const { rootMenuState } = useContext(DropdownMenuContext);
|
|
29
30
|
const isLink = to || externalHref;
|
|
31
|
+
const { Component: RouterLink, behavior: linkBehavior } = useLinkBehavior({
|
|
32
|
+
to: to ?? ''
|
|
33
|
+
});
|
|
30
34
|
const resolvedCloseOnSelect = itemCloseOnSelect ?? closeOnSelect;
|
|
31
35
|
const actionHandler = ()=>{
|
|
32
36
|
if (isLink) {
|
|
@@ -60,12 +64,14 @@ function DropdownMenuItem({ node, state, closeOnSelect, onClose, renderAs, ref,
|
|
|
60
64
|
}, state, innerWrapRef);
|
|
61
65
|
const makeInnerWrapProps = ()=>{
|
|
62
66
|
if (to) return {
|
|
63
|
-
as:
|
|
64
|
-
|
|
67
|
+
as: RouterLink,
|
|
68
|
+
...linkBehavior()
|
|
65
69
|
};
|
|
66
70
|
if (externalHref) return {
|
|
67
|
-
as:
|
|
68
|
-
href: externalHref
|
|
71
|
+
as: 'a',
|
|
72
|
+
href: externalHref,
|
|
73
|
+
target: '_blank',
|
|
74
|
+
rel: 'noreferrer noopener'
|
|
69
75
|
};
|
|
70
76
|
return {
|
|
71
77
|
as: 'div',
|
|
@@ -15,8 +15,8 @@ import { Overlay, PositionWrapper } from "../overlay.js";
|
|
|
15
15
|
import { Text } from "../text/index.js";
|
|
16
16
|
import { useTranslation } from "../translation/useTranslation.js";
|
|
17
17
|
import { useOverlay } from "../useOverlay.js";
|
|
18
|
-
import { DEFAULT_VIRTUALIZE_THRESHOLD, VirtualRows, flattenSections } from "../useVirtualCollection.js";
|
|
19
|
-
import { DropdownMenuContext } from "./context.js";
|
|
18
|
+
import { DEFAULT_VIRTUALIZE_THRESHOLD, VirtualRows, flattenSections, getWidestMenuItemKey } from "../useVirtualCollection.js";
|
|
19
|
+
import { DropdownMenuContext, DropdownMenuTreeStateContext } from "./context.js";
|
|
20
20
|
import { DropdownMenuItem } from "./item.js";
|
|
21
21
|
import { DropdownMenuSearch } from "./search.js";
|
|
22
22
|
import { DropdownMenuSection } from "./section.js";
|
|
@@ -25,7 +25,7 @@ import { useDropdownMenuKeyboard } from "./useDropdownMenuKeyboard.js";
|
|
|
25
25
|
import { useDropdownMenuRowLayout } from "./useDropdownMenuRowLayout.js";
|
|
26
26
|
import { useDropdownSubmenuState } from "./useDropdownSubmenuState.js";
|
|
27
27
|
import { countMenuItems, filterMenuItems, getDisabledKeys, isMenuSection, removeHiddenItemsAndSetHref } from "./utils.js";
|
|
28
|
-
const list_DropdownMenuCollectionItem = /*#__PURE__*/ memo(function({ node, isVirtualized, rowIndex, rowRef, closeOnSelect, disableTextSelection, onClose, size
|
|
28
|
+
const list_DropdownMenuCollectionItem = /*#__PURE__*/ memo(function({ node, isDisabled, isVirtualized, rowIndex, rowRef, closeOnSelect, disableTextSelection, onClose, size }) {
|
|
29
29
|
const rowProps = void 0 === rowIndex || void 0 === rowRef ? void 0 : {
|
|
30
30
|
'data-index': rowIndex,
|
|
31
31
|
ref: rowRef
|
|
@@ -35,9 +35,9 @@ const list_DropdownMenuCollectionItem = /*#__PURE__*/ memo(function({ node, isVi
|
|
|
35
35
|
return /*#__PURE__*/ jsx(DropdownSubmenu, {
|
|
36
36
|
items: node.value.children,
|
|
37
37
|
node: node,
|
|
38
|
+
isDisabled: isDisabled,
|
|
38
39
|
isVirtualized: isVirtualized,
|
|
39
40
|
rowProps: rowProps,
|
|
40
|
-
state: state,
|
|
41
41
|
onClose: onClose,
|
|
42
42
|
closeOnSelect: closeOnSelect,
|
|
43
43
|
disableTextSelection: disableTextSelection,
|
|
@@ -48,15 +48,15 @@ const list_DropdownMenuCollectionItem = /*#__PURE__*/ memo(function({ node, isVi
|
|
|
48
48
|
node: node,
|
|
49
49
|
isVirtualized: isVirtualized,
|
|
50
50
|
rowProps: rowProps,
|
|
51
|
-
state: state,
|
|
52
51
|
onClose: onClose,
|
|
53
52
|
closeOnSelect: closeOnSelect
|
|
54
53
|
});
|
|
55
54
|
});
|
|
56
55
|
function DropdownMenuRows({ collection, separatorProps, isWidthLocked, menuRef, onLockWidth, virtualized, widestKey, ...itemProps }) {
|
|
56
|
+
const state = useContext(DropdownMenuTreeStateContext);
|
|
57
57
|
const { itemsAfterSections, virtual } = useDropdownMenuRowLayout({
|
|
58
58
|
collection,
|
|
59
|
-
focusedKey:
|
|
59
|
+
focusedKey: state.selectionManager.focusedKey,
|
|
60
60
|
isWidthLocked,
|
|
61
61
|
menuRef,
|
|
62
62
|
onLockWidth,
|
|
@@ -76,6 +76,7 @@ function DropdownMenuRows({ collection, separatorProps, isWidthLocked, menuRef,
|
|
|
76
76
|
/*#__PURE__*/ jsx(SectionList, {
|
|
77
77
|
children: /*#__PURE__*/ jsx(list_DropdownMenuCollectionItem, {
|
|
78
78
|
node: node,
|
|
79
|
+
isDisabled: state.disabledKeys.has(node.key),
|
|
79
80
|
isVirtualized: virtualized,
|
|
80
81
|
...itemProps
|
|
81
82
|
})
|
|
@@ -83,6 +84,7 @@ function DropdownMenuRows({ collection, separatorProps, isWidthLocked, menuRef,
|
|
|
83
84
|
]
|
|
84
85
|
}) : /*#__PURE__*/ jsx(list_DropdownMenuCollectionItem, {
|
|
85
86
|
node: node,
|
|
87
|
+
isDisabled: state.disabledKeys.has(node.key),
|
|
86
88
|
isVirtualized: virtualized,
|
|
87
89
|
rowIndex: props?.['data-index'],
|
|
88
90
|
rowRef: props?.ref,
|
|
@@ -136,7 +138,7 @@ function DropdownMenuList({ closeOnSelect = true, onClose, size, menuTitle, empt
|
|
|
136
138
|
const { separatorProps } = useSeparator({
|
|
137
139
|
elementType: 'li'
|
|
138
140
|
});
|
|
139
|
-
const widestKey = useMemo(()=>virtualized ? items
|
|
141
|
+
const widestKey = useMemo(()=>virtualized ? getWidestMenuItemKey(items) : void 0, [
|
|
140
142
|
items,
|
|
141
143
|
virtualized
|
|
142
144
|
]);
|
|
@@ -233,19 +235,21 @@ function DropdownMenuList({ closeOnSelect = true, onClose, size, menuTitle, empt
|
|
|
233
235
|
children: [
|
|
234
236
|
/*#__PURE__*/ jsx(ReserveLeadingSlot, {
|
|
235
237
|
reserve: hasLeadingItems,
|
|
236
|
-
children: /*#__PURE__*/ jsx(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
238
|
+
children: /*#__PURE__*/ jsx(DropdownMenuTreeStateContext, {
|
|
239
|
+
value: state,
|
|
240
|
+
children: /*#__PURE__*/ jsx(DropdownMenuRows, {
|
|
241
|
+
collection: stateCollection,
|
|
242
|
+
isWidthLocked: void 0 !== lockedWidth,
|
|
243
|
+
menuRef: menuRef,
|
|
244
|
+
onLockWidth: setLockedWidth,
|
|
245
|
+
virtualized: virtualized,
|
|
246
|
+
widestKey: widestKey,
|
|
247
|
+
closeOnSelect: closeOnSelect,
|
|
248
|
+
disableTextSelection: disableTextSelection,
|
|
249
|
+
onClose: onClose,
|
|
250
|
+
separatorProps: separatorProps,
|
|
251
|
+
size: size
|
|
252
|
+
})
|
|
249
253
|
})
|
|
250
254
|
}),
|
|
251
255
|
showEmptyMessage && /*#__PURE__*/ jsx(Stack, {
|
|
@@ -331,12 +335,11 @@ function DropdownMenuContent({ items, disabledKeys, size, search, isDismissable,
|
|
|
331
335
|
}
|
|
332
336
|
});
|
|
333
337
|
}
|
|
334
|
-
function DropdownSubmenu({ items, node, isVirtualized, rowProps,
|
|
338
|
+
function DropdownSubmenu({ isDisabled, items, node, isVirtualized, rowProps, closeOnSelect, disableTextSelection, onClose, size }) {
|
|
335
339
|
const { rootMenuState, parentMenuRef, portalContainer, submenuLevel, isDismissable } = useContext(DropdownMenuContext);
|
|
336
340
|
if (!rootMenuState || !parentMenuRef || void 0 === submenuLevel) throw new Error('DropdownSubmenu must be rendered inside a DropdownMenu');
|
|
337
341
|
const submenu = node.value?.submenu;
|
|
338
342
|
const options = 'object' == typeof submenu ? submenu : {};
|
|
339
|
-
const isDisabled = state.disabledKeys.has(node.key);
|
|
340
343
|
const submenuState = useDropdownSubmenuState({
|
|
341
344
|
level: submenuLevel,
|
|
342
345
|
rootMenuState,
|
|
@@ -376,7 +379,6 @@ function DropdownSubmenu({ items, node, isVirtualized, rowProps, state, closeOnS
|
|
|
376
379
|
node: node,
|
|
377
380
|
isVirtualized: isVirtualized,
|
|
378
381
|
rowProps: rowProps,
|
|
379
|
-
state: state,
|
|
380
382
|
closeOnSelect: false
|
|
381
383
|
}),
|
|
382
384
|
isOpen && portalContainer && /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx(DropdownMenuContent, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useCallback,
|
|
1
|
+
import { useCallback, useMemo } from "react";
|
|
2
2
|
import { useTheme } from "@emotion/react";
|
|
3
3
|
import { SECTION_ITEM_SPACE } from "../menu/index.js";
|
|
4
|
-
import { estimateRowHeight, useVirtualCollection } from "../useVirtualCollection.js";
|
|
4
|
+
import { estimateRowHeight, useVirtualCollection, useVirtualMenuWidth } from "../useVirtualCollection.js";
|
|
5
5
|
import { SEPARATOR_HEIGHT } from "./separator.js";
|
|
6
6
|
function useDropdownMenuRowLayout({ collection, focusedKey, isWidthLocked, menuRef, onLockWidth, size, virtualized, widestKey }) {
|
|
7
7
|
const theme = useTheme();
|
|
@@ -41,21 +41,13 @@ function useDropdownMenuRowLayout({ collection, focusedKey, isWidthLocked, menuR
|
|
|
41
41
|
size,
|
|
42
42
|
widestKey
|
|
43
43
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (!virtualized || !isWidestRowMounted || isWidthLocked || !menu) return;
|
|
48
|
-
const { width } = menu.style;
|
|
49
|
-
menu.style.width = 'max-content';
|
|
50
|
-
onLockWidth(Math.ceil(menu.getBoundingClientRect().width));
|
|
51
|
-
menu.style.width = width;
|
|
52
|
-
}, [
|
|
53
|
-
virtualized,
|
|
54
|
-
isWidestRowMounted,
|
|
44
|
+
useVirtualMenuWidth({
|
|
45
|
+
enabled: virtualized,
|
|
46
|
+
isWidthCandidateMounted: virtual.rows.some((row)=>row.node.key === widestKey),
|
|
55
47
|
isWidthLocked,
|
|
56
48
|
menuRef,
|
|
57
49
|
onLockWidth
|
|
58
|
-
|
|
50
|
+
});
|
|
59
51
|
return {
|
|
60
52
|
itemsAfterSections,
|
|
61
53
|
virtual
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type * as React from 'react';
|
|
2
|
+
import { type ToggleCardProps } from '../../toggleCard/index.js';
|
|
2
3
|
export interface RadioGroupProps<T extends string> {
|
|
3
4
|
children: (components: {
|
|
5
|
+
Card: (props: RadioCardProps<NoInfer<T>>) => React.JSX.Element;
|
|
4
6
|
Item: (props: RadioItemProps<NoInfer<T>>) => React.JSX.Element;
|
|
5
7
|
}) => React.ReactNode;
|
|
6
8
|
onChange: (value: NoInfer<T>) => void;
|
|
@@ -12,5 +14,10 @@ interface RadioItemProps<T extends string> {
|
|
|
12
14
|
value: T;
|
|
13
15
|
description?: React.ReactNode;
|
|
14
16
|
}
|
|
17
|
+
interface RadioCardProps<T extends string> {
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
value: T;
|
|
20
|
+
padding?: ToggleCardProps['padding'];
|
|
21
|
+
}
|
|
15
22
|
export declare const RadioGroupField: <T extends string>(props: RadioGroupProps<T>) => React.JSX.Element;
|
|
16
23
|
export {};
|
|
@@ -8,6 +8,7 @@ import { useFieldContext } from "../formContext.js";
|
|
|
8
8
|
import { Flex, Stack } from "../../layout/index.js";
|
|
9
9
|
import { Radio } from "../../radio/index.js";
|
|
10
10
|
import { Text } from "../../text/index.js";
|
|
11
|
+
import { ToggleCard } from "../../toggleCard/index.js";
|
|
11
12
|
import { useAutoSaveIndicator } from "./baseField.js";
|
|
12
13
|
function RadioGroup({ children, value, onChange, disabled }) {
|
|
13
14
|
const field = useFieldContext();
|
|
@@ -85,7 +86,20 @@ function RadioItem({ children, value, description }) {
|
|
|
85
86
|
]
|
|
86
87
|
});
|
|
87
88
|
}
|
|
89
|
+
function RadioCard({ children, value, padding }) {
|
|
90
|
+
const { checked, onChange, ...fieldProps } = useGroupItemContext(value);
|
|
91
|
+
return /*#__PURE__*/ jsx(ToggleCard, {
|
|
92
|
+
...fieldProps,
|
|
93
|
+
variant: "radio",
|
|
94
|
+
padding: padding,
|
|
95
|
+
value: value,
|
|
96
|
+
checked: checked,
|
|
97
|
+
onChange: ()=>onChange(value, true),
|
|
98
|
+
children: children
|
|
99
|
+
});
|
|
100
|
+
}
|
|
88
101
|
const radioGroupComponents = {
|
|
102
|
+
Card: RadioCard,
|
|
89
103
|
Item: RadioItem
|
|
90
104
|
};
|
|
91
105
|
const RadioGroupField = RadioGroup;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { BaseSelectProps,
|
|
1
|
+
import type { BaseSelectProps, SelectSelectionProps, SelectValue } from '../../select/index.js';
|
|
2
2
|
import { type BaseFieldProps } from './baseField.js';
|
|
3
|
-
type BaseSelectFieldProps<TValue, TOption extends SelectValue<TValue>> = Omit<BaseSelectProps<TValue, TOption
|
|
3
|
+
type BaseSelectFieldProps<TValue, TOption extends SelectValue<TValue>> = Omit<BaseSelectProps<TValue, TOption, SelectValue<TValue | string>>, 'onBlur' | 'disabled' | 'ref' | 'inputRef' | 'id' | 'options'> & BaseFieldProps<HTMLInputElement> & {
|
|
4
4
|
options: ReadonlyArray<TOption & SelectValue<TValue>>;
|
|
5
|
-
components?: Omit<SelectComponents<TOption>, 'Indicators'>;
|
|
6
5
|
};
|
|
7
6
|
export type SelectFieldProps<TValue, TOption extends SelectValue<TValue> = SelectValue<TValue>> = BaseSelectFieldProps<TValue, TOption> & SelectSelectionProps<TValue>;
|
|
8
|
-
export declare function SelectField<TValue, TOption extends SelectValue<TValue> = SelectValue<TValue>>({ onChange, disabled, multiple, clearable, value, ref, ...props }: SelectFieldProps<TValue, TOption>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function SelectField<TValue, TOption extends SelectValue<TValue> = SelectValue<TValue>>({ onChange, disabled, multiple, clearable, trailingItems, value, ref, ...props }: SelectFieldProps<TValue, TOption>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
9
8
|
export {};
|