@sentry/scraps 0.3.0 → 0.4.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/dist/layout/styles.d.ts +1 -1
- 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 +159 -0
- package/dist/menu/menu.js +464 -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/overlayTrigger.d.ts +22 -0
- package/dist/overlayTrigger.js +30 -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 +36 -0
- package/dist/splitPanel/splitPanel.js +144 -0
- 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/useDimensions.d.ts +12 -0
- package/dist/useDimensions.js +31 -0
- package/dist/useResizableDrawer.d.ts +72 -0
- package/dist/useResizableDrawer.js +136 -0
- package/package.json +34 -1
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useEffect, useId, useRef } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import is_prop_valid from "@emotion/is-prop-valid";
|
|
5
|
+
import { css, useTheme } from "@emotion/react";
|
|
6
|
+
import styled from "@emotion/styled";
|
|
7
|
+
import { autoUpdate, hide, offset, useFloating } from "@floating-ui/react-dom";
|
|
8
|
+
import { mergeRefs } from "@react-aria/utils";
|
|
9
|
+
import { IconSearch } from "@sentry/icons/search";
|
|
10
|
+
import { Button } from "../button/index.js";
|
|
11
|
+
import { InputGroup } from "../input/index.js";
|
|
12
|
+
import interactionStateLayer from "../interactionStateLayer/index.js";
|
|
13
|
+
import { Container, Flex, Stack } from "../layout/index.js";
|
|
14
|
+
import { Overlay, PositionWrapper } from "../overlay.js";
|
|
15
|
+
import { flipOverlay, shiftOverlay } from "../overlayPositioning.js";
|
|
16
|
+
import { Separator } from "../separator/index.js";
|
|
17
|
+
import { Text } from "../text/index.js";
|
|
18
|
+
import { Tooltip } from "../tooltip/index.js";
|
|
19
|
+
function calculateMenuMinHeight(first, second) {
|
|
20
|
+
if (void 0 === first) return 'number' == typeof second ? `${second}px` : second;
|
|
21
|
+
if (void 0 === second) return 'number' == typeof first ? `${first}px` : first;
|
|
22
|
+
const firstHeight = 'number' == typeof first ? `${first}px` : first;
|
|
23
|
+
const secondHeight = 'number' == typeof second ? `${second}px` : second;
|
|
24
|
+
return `min(${firstHeight}, ${secondHeight})`;
|
|
25
|
+
}
|
|
26
|
+
function MenuHeaderLayout(props) {
|
|
27
|
+
return /*#__PURE__*/ jsx(Stack, {
|
|
28
|
+
borderBottom: "muted",
|
|
29
|
+
gap: "0",
|
|
30
|
+
...props
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function MenuHeading({ children, padding }) {
|
|
34
|
+
const heading = /*#__PURE__*/ jsx(Text, {
|
|
35
|
+
size: "sm",
|
|
36
|
+
density: "fixed",
|
|
37
|
+
bold: true,
|
|
38
|
+
tabular: true,
|
|
39
|
+
children: children
|
|
40
|
+
});
|
|
41
|
+
return padding ? /*#__PURE__*/ jsx(Container, {
|
|
42
|
+
padding: padding,
|
|
43
|
+
children: heading
|
|
44
|
+
}) : heading;
|
|
45
|
+
}
|
|
46
|
+
function MenuSectionLabel({ children, padding, ...props }) {
|
|
47
|
+
return /*#__PURE__*/ jsx(Container, {
|
|
48
|
+
padding: padding,
|
|
49
|
+
children: /*#__PURE__*/ jsx(Text, {
|
|
50
|
+
as: "span",
|
|
51
|
+
size: "sm",
|
|
52
|
+
density: "fixed",
|
|
53
|
+
bold: true,
|
|
54
|
+
tabular: true,
|
|
55
|
+
...props,
|
|
56
|
+
children: children
|
|
57
|
+
})
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function MenuSectionHeader({ children, trailingAction, ...props }) {
|
|
61
|
+
return /*#__PURE__*/ jsxs(Flex, {
|
|
62
|
+
"data-section-header": true,
|
|
63
|
+
justify: "between",
|
|
64
|
+
align: "center",
|
|
65
|
+
minHeight: "1.5em",
|
|
66
|
+
padding: "2xs lg",
|
|
67
|
+
...props,
|
|
68
|
+
children: [
|
|
69
|
+
children,
|
|
70
|
+
trailingAction
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function MenuSectionSeparator() {
|
|
75
|
+
return /*#__PURE__*/ jsx(Separator, {
|
|
76
|
+
orientation: "horizontal",
|
|
77
|
+
border: "muted"
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function MenuSectionGroup(props) {
|
|
81
|
+
return /*#__PURE__*/ jsx(Container, {
|
|
82
|
+
as: "li",
|
|
83
|
+
display: "block",
|
|
84
|
+
...props
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function MenuSectionList(props) {
|
|
88
|
+
return /*#__PURE__*/ jsx(Container, {
|
|
89
|
+
as: "ul",
|
|
90
|
+
role: "presentation",
|
|
91
|
+
margin: "0",
|
|
92
|
+
padding: "0",
|
|
93
|
+
...props
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function MenuFooterLayout(props) {
|
|
97
|
+
return /*#__PURE__*/ jsx(Flex, {
|
|
98
|
+
borderTop: "muted",
|
|
99
|
+
align: "center",
|
|
100
|
+
padding: "md lg",
|
|
101
|
+
...props
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function SearchInput({ padding = 'xs', ...props }) {
|
|
105
|
+
return /*#__PURE__*/ jsx(Container, {
|
|
106
|
+
padding: padding,
|
|
107
|
+
children: /*#__PURE__*/ jsxs(InputGroup, {
|
|
108
|
+
children: [
|
|
109
|
+
/*#__PURE__*/ jsx(InputGroup.LeadingItems, {
|
|
110
|
+
disablePointerEvents: true,
|
|
111
|
+
children: /*#__PURE__*/ jsx(Flex, {
|
|
112
|
+
paddingLeft: "2xs",
|
|
113
|
+
align: "center",
|
|
114
|
+
justify: "center",
|
|
115
|
+
children: /*#__PURE__*/ jsx(IconSearch, {
|
|
116
|
+
size: "xs",
|
|
117
|
+
variant: "muted"
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
}),
|
|
121
|
+
/*#__PURE__*/ jsx(InputGroup.Input, {
|
|
122
|
+
size: "xs",
|
|
123
|
+
...props
|
|
124
|
+
})
|
|
125
|
+
]
|
|
126
|
+
})
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
const ReserveLeadingSlotContext = /*#__PURE__*/ createContext(false);
|
|
130
|
+
function ReserveLeadingSlot({ reserve, children }) {
|
|
131
|
+
return /*#__PURE__*/ jsx(ReserveLeadingSlotContext, {
|
|
132
|
+
value: reserve,
|
|
133
|
+
children: children
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function useReserveLeadingSlot() {
|
|
137
|
+
return useContext(ReserveLeadingSlotContext);
|
|
138
|
+
}
|
|
139
|
+
const TRAILING_ACTION_INSET = 'lg';
|
|
140
|
+
const TRAILING_ACTION_SPACE = '3xl';
|
|
141
|
+
const ITEM_PADDING_BY_SIZE = {
|
|
142
|
+
xs: 'xs md xs lg',
|
|
143
|
+
sm: 'sm md sm lg',
|
|
144
|
+
md: 'xs sm xs md'
|
|
145
|
+
};
|
|
146
|
+
const LABEL_TEXT_SIZE_BY_SIZE = {
|
|
147
|
+
xs: 'sm',
|
|
148
|
+
sm: 'md',
|
|
149
|
+
md: 'md'
|
|
150
|
+
};
|
|
151
|
+
function getTextColor({ theme, priority, disabled }) {
|
|
152
|
+
if (disabled) return theme.tokens.content.secondary;
|
|
153
|
+
switch(priority){
|
|
154
|
+
case 'primary':
|
|
155
|
+
return theme.tokens.content.accent;
|
|
156
|
+
case 'danger':
|
|
157
|
+
return theme.tokens.content.danger;
|
|
158
|
+
case 'default':
|
|
159
|
+
default:
|
|
160
|
+
return theme.tokens.content.primary;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const StyledInnerWrap = styled(Flex, {
|
|
164
|
+
shouldForwardProp: (prop)=>'string' == typeof prop && (is_prop_valid(prop) || [
|
|
165
|
+
'padding',
|
|
166
|
+
'paddingLeft',
|
|
167
|
+
'paddingRight',
|
|
168
|
+
'align',
|
|
169
|
+
'alignSelf'
|
|
170
|
+
].includes(prop)) && ![
|
|
171
|
+
'disabled',
|
|
172
|
+
'isFocused',
|
|
173
|
+
'hasTrailingAction',
|
|
174
|
+
'priority'
|
|
175
|
+
].includes(prop)
|
|
176
|
+
})`
|
|
177
|
+
gap: ${(p)=>p.theme.space.xs};
|
|
178
|
+
position: relative;
|
|
179
|
+
border-radius: ${(p)=>p.theme.radius.md};
|
|
180
|
+
box-sizing: border-box;
|
|
181
|
+
|
|
182
|
+
font-size: ${(p)=>p.theme.form[p.size ?? 'md'].fontSize};
|
|
183
|
+
|
|
184
|
+
&,
|
|
185
|
+
&:hover,
|
|
186
|
+
&:focus,
|
|
187
|
+
&:focus-visible {
|
|
188
|
+
color: ${getTextColor};
|
|
189
|
+
box-shadow: none;
|
|
190
|
+
outline: none;
|
|
191
|
+
}
|
|
192
|
+
${(p)=>p.disabled && 'cursor: default;'}
|
|
193
|
+
|
|
194
|
+
&::before {
|
|
195
|
+
content: '';
|
|
196
|
+
position: absolute;
|
|
197
|
+
top: 0;
|
|
198
|
+
left: 0;
|
|
199
|
+
width: 100%;
|
|
200
|
+
height: 100%;
|
|
201
|
+
z-index: -1;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
${(p)=>p.isFocused && css`
|
|
205
|
+
${!p.hasTrailingAction && 'z-index: 1;'}
|
|
206
|
+
/* Background to hide the previous item's divider */
|
|
207
|
+
::before {
|
|
208
|
+
background: ${p.theme.tokens.background.overlay};
|
|
209
|
+
}
|
|
210
|
+
`}
|
|
211
|
+
`;
|
|
212
|
+
const StyledContentWrap = styled('div')`
|
|
213
|
+
position: relative;
|
|
214
|
+
width: 100%;
|
|
215
|
+
min-width: 0;
|
|
216
|
+
display: flex;
|
|
217
|
+
gap: ${(p)=>p.theme.space.md};
|
|
218
|
+
justify-content: space-between;
|
|
219
|
+
align-items: center;
|
|
220
|
+
padding: 0;
|
|
221
|
+
`;
|
|
222
|
+
const StyledLeadingItems = styled('div')`
|
|
223
|
+
display: flex;
|
|
224
|
+
gap: ${(p)=>p.theme.space.md};
|
|
225
|
+
min-width: ${(p)=>p.theme.space['2xl']};
|
|
226
|
+
justify-content: center;
|
|
227
|
+
flex-shrink: 0;
|
|
228
|
+
/* Match the label's first line when details appear below it. */
|
|
229
|
+
min-height: ${(p)=>p.hasDetails ? p.theme.font.lineHeight.fixed : '24px'};
|
|
230
|
+
align-self: ${(p)=>p.hasDetails ? 'flex-start' : 'center'};
|
|
231
|
+
align-items: center;
|
|
232
|
+
margin-top: ${(p)=>p.hasDetails ? p.theme.space.xs : '0'};
|
|
233
|
+
|
|
234
|
+
${(p)=>p.disabled && 'opacity: 0.5;'}
|
|
235
|
+
`;
|
|
236
|
+
const StyledDetails = styled('div')`
|
|
237
|
+
font-size: ${(p)=>p.theme.font.size.sm};
|
|
238
|
+
color: ${(p)=>p.theme.tokens.content.secondary};
|
|
239
|
+
line-height: 1.4;
|
|
240
|
+
margin-bottom: 0;
|
|
241
|
+
|
|
242
|
+
${(p)=>'default' !== p.priority && css`
|
|
243
|
+
color: ${getTextColor(p)};
|
|
244
|
+
`}
|
|
245
|
+
`;
|
|
246
|
+
function MenuListItem({ label, details, as, priority = 'default', size, disabled = false, leadingItems = false, trailingItems = false, trailingAction, isFocused = false, isSelected = false, isPressed, innerWrapProps = {}, labelProps = {}, detailsProps = {}, showDetailsInOverlay = false, tooltip, tooltipOptions, ref, trailingActionRef, trailingActionWrapperProps, ...props }) {
|
|
247
|
+
const itemRef = useRef(null);
|
|
248
|
+
const theme = useTheme();
|
|
249
|
+
const labelId = useId();
|
|
250
|
+
const detailId = useId();
|
|
251
|
+
const hasInlineDetails = Boolean(details && !showDetailsInOverlay);
|
|
252
|
+
const reserveLeadingSlot = useReserveLeadingSlot();
|
|
253
|
+
const hasLeadingSlot = Boolean(leadingItems) || reserveLeadingSlot;
|
|
254
|
+
return /*#__PURE__*/ jsxs(MenuItemWrap, {
|
|
255
|
+
hasTrailingAction: Boolean(trailingAction),
|
|
256
|
+
isFocused: isFocused,
|
|
257
|
+
"aria-disabled": disabled,
|
|
258
|
+
"aria-labelledby": labelId,
|
|
259
|
+
"aria-describedby": detailId,
|
|
260
|
+
as: as ?? 'li',
|
|
261
|
+
ref: mergeRefs(ref, itemRef),
|
|
262
|
+
...props,
|
|
263
|
+
children: [
|
|
264
|
+
/*#__PURE__*/ jsx(Tooltip, {
|
|
265
|
+
skipWrapper: true,
|
|
266
|
+
title: 'function' == typeof tooltip ? tooltip({
|
|
267
|
+
disabled,
|
|
268
|
+
isFocused,
|
|
269
|
+
isSelected
|
|
270
|
+
}) : tooltip,
|
|
271
|
+
delay: 500,
|
|
272
|
+
...tooltipOptions,
|
|
273
|
+
children: /*#__PURE__*/ jsxs(StyledInnerWrap, {
|
|
274
|
+
"data-menu-item-content": true,
|
|
275
|
+
padding: ITEM_PADDING_BY_SIZE[size ?? 'md'],
|
|
276
|
+
paddingLeft: hasLeadingSlot ? 'md' : void 0,
|
|
277
|
+
paddingRight: trailingAction ? TRAILING_ACTION_SPACE : void 0,
|
|
278
|
+
isFocused: isFocused,
|
|
279
|
+
hasTrailingAction: Boolean(trailingAction),
|
|
280
|
+
disabled: disabled,
|
|
281
|
+
priority: priority,
|
|
282
|
+
size: size,
|
|
283
|
+
...innerWrapProps,
|
|
284
|
+
children: [
|
|
285
|
+
/*#__PURE__*/ jsx(StyledInteractionStateLayer, {
|
|
286
|
+
isHovered: isFocused,
|
|
287
|
+
isPressed: isPressed,
|
|
288
|
+
higherOpacity: 'default' !== priority
|
|
289
|
+
}),
|
|
290
|
+
hasLeadingSlot && /*#__PURE__*/ jsx(StyledLeadingItems, {
|
|
291
|
+
disabled: disabled,
|
|
292
|
+
hasDetails: hasInlineDetails,
|
|
293
|
+
size: size,
|
|
294
|
+
children: 'function' == typeof leadingItems ? leadingItems({
|
|
295
|
+
disabled,
|
|
296
|
+
isFocused,
|
|
297
|
+
isSelected
|
|
298
|
+
}) : leadingItems
|
|
299
|
+
}),
|
|
300
|
+
/*#__PURE__*/ jsxs(StyledContentWrap, {
|
|
301
|
+
isFocused: isFocused,
|
|
302
|
+
size: size,
|
|
303
|
+
children: [
|
|
304
|
+
/*#__PURE__*/ jsxs(Stack, {
|
|
305
|
+
padding: hasInlineDetails ? 'xs 0' : void 0,
|
|
306
|
+
minHeight: hasInlineDetails ? void 0 : '24px',
|
|
307
|
+
justify: "center",
|
|
308
|
+
align: "start",
|
|
309
|
+
gap: "2xs",
|
|
310
|
+
flex: "1 0 0",
|
|
311
|
+
minWidth: "0",
|
|
312
|
+
children: [
|
|
313
|
+
/*#__PURE__*/ jsx(Text, {
|
|
314
|
+
as: "div",
|
|
315
|
+
size: LABEL_TEXT_SIZE_BY_SIZE[size ?? 'md'],
|
|
316
|
+
density: "fixed",
|
|
317
|
+
variant: disabled ? 'muted' : 'default' === priority ? void 0 : priority,
|
|
318
|
+
bold: false,
|
|
319
|
+
tabular: true,
|
|
320
|
+
ellipsis: true,
|
|
321
|
+
trim: 'string' == typeof label || 'number' == typeof label,
|
|
322
|
+
id: labelId,
|
|
323
|
+
"data-test-id": "menu-list-item-label",
|
|
324
|
+
...labelProps,
|
|
325
|
+
children: label
|
|
326
|
+
}),
|
|
327
|
+
!showDetailsInOverlay && details && /*#__PURE__*/ jsx(StyledDetails, {
|
|
328
|
+
id: detailId,
|
|
329
|
+
disabled: disabled,
|
|
330
|
+
priority: priority,
|
|
331
|
+
...detailsProps,
|
|
332
|
+
children: 'function' == typeof details ? details({
|
|
333
|
+
disabled,
|
|
334
|
+
isFocused,
|
|
335
|
+
isSelected
|
|
336
|
+
}) : details
|
|
337
|
+
})
|
|
338
|
+
]
|
|
339
|
+
}),
|
|
340
|
+
trailingItems && /*#__PURE__*/ jsx(TrailingItems, {
|
|
341
|
+
disabled: disabled,
|
|
342
|
+
children: 'function' == typeof trailingItems ? trailingItems({
|
|
343
|
+
disabled,
|
|
344
|
+
isFocused,
|
|
345
|
+
isSelected
|
|
346
|
+
}) : trailingItems
|
|
347
|
+
})
|
|
348
|
+
]
|
|
349
|
+
})
|
|
350
|
+
]
|
|
351
|
+
})
|
|
352
|
+
}),
|
|
353
|
+
trailingAction && /*#__PURE__*/ jsx(Flex, {
|
|
354
|
+
position: "absolute",
|
|
355
|
+
right: theme.space[TRAILING_ACTION_INSET],
|
|
356
|
+
top: "0",
|
|
357
|
+
height: "100%",
|
|
358
|
+
align: "center",
|
|
359
|
+
...trailingActionWrapperProps,
|
|
360
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
361
|
+
ref: trailingActionRef,
|
|
362
|
+
size: "zero",
|
|
363
|
+
variant: "transparent",
|
|
364
|
+
icon: trailingAction.icon,
|
|
365
|
+
"aria-label": trailingAction.label,
|
|
366
|
+
tooltipProps: {
|
|
367
|
+
title: trailingAction.label
|
|
368
|
+
},
|
|
369
|
+
onClick: trailingAction.onAction
|
|
370
|
+
})
|
|
371
|
+
}),
|
|
372
|
+
showDetailsInOverlay && details && isFocused && /*#__PURE__*/ jsx(DetailsOverlay, {
|
|
373
|
+
size: size,
|
|
374
|
+
id: detailId,
|
|
375
|
+
itemRef: itemRef,
|
|
376
|
+
children: 'function' == typeof details ? details({
|
|
377
|
+
disabled,
|
|
378
|
+
isFocused,
|
|
379
|
+
isSelected
|
|
380
|
+
}) : details
|
|
381
|
+
})
|
|
382
|
+
]
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
const DETAILS_MIDDLEWARE = [
|
|
386
|
+
offset({
|
|
387
|
+
crossAxis: -4,
|
|
388
|
+
mainAxis: 8
|
|
389
|
+
}),
|
|
390
|
+
flipOverlay(),
|
|
391
|
+
shiftOverlay(),
|
|
392
|
+
hide()
|
|
393
|
+
];
|
|
394
|
+
function DetailsOverlay({ children, size, id, itemRef }) {
|
|
395
|
+
const theme = useTheme();
|
|
396
|
+
const { refs: { setReference, setFloating }, floatingStyles, middlewareData } = useFloating({
|
|
397
|
+
placement: 'right-start',
|
|
398
|
+
strategy: 'fixed',
|
|
399
|
+
middleware: DETAILS_MIDDLEWARE,
|
|
400
|
+
whileElementsMounted: autoUpdate
|
|
401
|
+
});
|
|
402
|
+
useEffect(()=>{
|
|
403
|
+
setReference(itemRef.current);
|
|
404
|
+
}, [
|
|
405
|
+
itemRef,
|
|
406
|
+
setReference
|
|
407
|
+
]);
|
|
408
|
+
return /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx(StyledPositionWrapper, {
|
|
409
|
+
"data-reference-hidden": middlewareData.hide?.referenceHidden,
|
|
410
|
+
ref: setFloating,
|
|
411
|
+
zIndex: theme.zIndex.tooltip,
|
|
412
|
+
style: floatingStyles,
|
|
413
|
+
children: /*#__PURE__*/ jsx(StyledOverlay, {
|
|
414
|
+
id: id,
|
|
415
|
+
role: "tooltip",
|
|
416
|
+
placement: "right-start",
|
|
417
|
+
size: size,
|
|
418
|
+
children: children
|
|
419
|
+
})
|
|
420
|
+
}), document.body);
|
|
421
|
+
}
|
|
422
|
+
const StyledPositionWrapper = styled(PositionWrapper)`
|
|
423
|
+
&[data-reference-hidden='true'] {
|
|
424
|
+
opacity: 0;
|
|
425
|
+
pointer-events: none;
|
|
426
|
+
}
|
|
427
|
+
`;
|
|
428
|
+
const StyledOverlay = styled(Overlay)`
|
|
429
|
+
padding: 4px;
|
|
430
|
+
font-size: ${(p)=>p.theme.form[p.size ?? 'md'].fontSize};
|
|
431
|
+
cursor: auto;
|
|
432
|
+
user-select: contain;
|
|
433
|
+
max-height: 80vh;
|
|
434
|
+
overflow: auto;
|
|
435
|
+
`;
|
|
436
|
+
const MenuItemWrap = styled('li')`
|
|
437
|
+
position: ${(p)=>p.hasTrailingAction ? 'relative' : 'static'};
|
|
438
|
+
${(p)=>p.hasTrailingAction && p.isFocused && 'z-index: 1;'}
|
|
439
|
+
list-style-type: none;
|
|
440
|
+
margin: 0;
|
|
441
|
+
padding: 0 ${(p)=>p.theme.space.xs};
|
|
442
|
+
cursor: pointer;
|
|
443
|
+
scroll-margin: ${(p)=>p.theme.space.xs} 0;
|
|
444
|
+
|
|
445
|
+
&:focus {
|
|
446
|
+
outline: none;
|
|
447
|
+
}
|
|
448
|
+
&:focus-visible {
|
|
449
|
+
outline: none;
|
|
450
|
+
}
|
|
451
|
+
`;
|
|
452
|
+
const StyledInteractionStateLayer = styled(interactionStateLayer)`
|
|
453
|
+
z-index: -1;
|
|
454
|
+
`;
|
|
455
|
+
const TrailingItems = styled('div')`
|
|
456
|
+
display: flex;
|
|
457
|
+
align-items: center;
|
|
458
|
+
height: 24px;
|
|
459
|
+
gap: ${(p)=>p.theme.space.md};
|
|
460
|
+
margin-right: ${(p)=>p.theme.space.xs};
|
|
461
|
+
|
|
462
|
+
${(p)=>p.disabled && 'opacity: 0.5;'}
|
|
463
|
+
`;
|
|
464
|
+
export { MenuFooterLayout, MenuHeaderLayout, MenuHeading, MenuListItem, MenuSectionGroup, MenuSectionHeader, MenuSectionLabel, MenuSectionList, MenuSectionSeparator, ReserveLeadingSlot, SearchInput, calculateMenuMinHeight, useReserveLeadingSlot };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { SelectValue } from './selectValue.js';
|
|
3
|
+
export type ListItemBase = object & {
|
|
4
|
+
showToggleAllButton?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type SelectKey = string | number;
|
|
7
|
+
export interface SelectOption<Value extends SelectKey> extends SelectValue<Value> {
|
|
8
|
+
/**
|
|
9
|
+
* Whether to hide the checkbox/checkmark. Available for backward compatibility only.
|
|
10
|
+
* If true, an alternative selection state indicator must be present.
|
|
11
|
+
*
|
|
12
|
+
* @deprecated
|
|
13
|
+
*/
|
|
14
|
+
hideCheck?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface SelectSection<Value extends SelectKey> {
|
|
17
|
+
options: Array<SelectOption<Value>>;
|
|
18
|
+
/**
|
|
19
|
+
* When true, all options inside this section will be disabled.
|
|
20
|
+
*/
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Optional key to identify this section. If not specified, the section's index will
|
|
24
|
+
* be used.
|
|
25
|
+
*/
|
|
26
|
+
key?: SelectKey;
|
|
27
|
+
/**
|
|
28
|
+
* Title to display in the section header.
|
|
29
|
+
*/
|
|
30
|
+
label?: React.ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* Whether to show a "Select All"/"Unselect All" button in the section header (only
|
|
33
|
+
* applicable in multiple-selection mode).
|
|
34
|
+
*/
|
|
35
|
+
showToggleAllButton?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export type SelectOptionOrSection<Value extends SelectKey> = SelectOption<Value> | SelectSection<Value>;
|
|
38
|
+
/**
|
|
39
|
+
* The result of a custom `searchMatcher` function. Returning this (instead of a plain
|
|
40
|
+
* boolean) allows callers to influence how matching options are sorted: options with a
|
|
41
|
+
* higher `score` are shown first. To hide an option, return `{score: 0}.
|
|
42
|
+
*/
|
|
43
|
+
export interface SearchMatchResult {
|
|
44
|
+
/**
|
|
45
|
+
* Match quality score. Higher values cause the option to appear earlier in the list.
|
|
46
|
+
* Options that match but return no score maintain their original order relative to
|
|
47
|
+
* each other.
|
|
48
|
+
*/
|
|
49
|
+
score: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Configuration for CompactSelect's search/filter behavior. Providing this prop
|
|
53
|
+
* implicitly enables the search input.
|
|
54
|
+
*/
|
|
55
|
+
export interface SearchConfig<Value extends SelectKey> {
|
|
56
|
+
/**
|
|
57
|
+
* Controls client-side option filtering:
|
|
58
|
+
* - Omitted: default fuzzy (fzf) filter, results sorted by match score
|
|
59
|
+
* - Function: custom matcher (receives option + search string, returns SearchMatchResult)
|
|
60
|
+
* - `false`: disables client-side filtering entirely (use with `onChange` for server-side search)
|
|
61
|
+
*/
|
|
62
|
+
filter?: ((option: SelectOptionWithKey<Value>, search: string) => SearchMatchResult) | false;
|
|
63
|
+
/**
|
|
64
|
+
* When true, the matched contiguous substring of each option's (string) label will be
|
|
65
|
+
* visually highlighted as the user types. Paired best with a substring-based `filter` function.
|
|
66
|
+
*/
|
|
67
|
+
highlight?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Called when the search input value changes.
|
|
70
|
+
*/
|
|
71
|
+
onChange?: (value: string) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Placeholder text for the search input. Defaults to 'Search…'.
|
|
74
|
+
*/
|
|
75
|
+
placeholder?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface SelectOptionWithKey<Value extends SelectKey> extends SelectOption<Value> {
|
|
78
|
+
/**
|
|
79
|
+
* Key to identify this section. If not specified, the section's index will
|
|
80
|
+
* be used.
|
|
81
|
+
*/
|
|
82
|
+
key: SelectKey;
|
|
83
|
+
}
|
|
84
|
+
export interface SelectSectionWithKey<Value extends SelectKey> extends SelectSection<Value> {
|
|
85
|
+
/**
|
|
86
|
+
* Key to identify this section. If not specified, the section's index will
|
|
87
|
+
* be used.
|
|
88
|
+
*/
|
|
89
|
+
key: SelectKey;
|
|
90
|
+
options: Array<SelectOptionWithKey<Value>>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Select option/section type used for internal selection manager. DO NOT import in
|
|
94
|
+
* other components. Import `SelectOptionOrSection` instead.
|
|
95
|
+
*/
|
|
96
|
+
export type SelectOptionOrSectionWithKey<Value extends SelectKey> = SelectOptionWithKey<Value> | SelectSectionWithKey<Value>;
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ListItemProps } from './menu.js';
|
|
2
|
+
/**
|
|
3
|
+
* The option format used by react-select based components
|
|
4
|
+
*/
|
|
5
|
+
export interface SelectValue<T> extends ListItemProps {
|
|
6
|
+
value: T;
|
|
7
|
+
/**
|
|
8
|
+
* In scenarios where you're using a react element as the label react-select
|
|
9
|
+
* will be unable to filter to that label. Use this to specify the plain text of
|
|
10
|
+
* the label.
|
|
11
|
+
*/
|
|
12
|
+
textValue?: string;
|
|
13
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { DistributedOmit, SetRequired } from 'type-fest';
|
|
3
|
+
import { type DropdownButtonProps } from './menu/dropdownButton.js';
|
|
4
|
+
type TriggerEl = HTMLButtonElement | (Omit<HTMLButtonElement, 'ELEMENT_NODE'> & {
|
|
5
|
+
ELEMENT_NODE: 'only use `OverlayTrigger.Button` or `OverlayTrigger.IconButton` for the trigger prop!';
|
|
6
|
+
});
|
|
7
|
+
export type TriggerProps = Omit<React.HTMLAttributes<TriggerEl>, 'children'> & {
|
|
8
|
+
children: NonNullable<React.ReactNode>;
|
|
9
|
+
ref?: React.Ref<TriggerEl>;
|
|
10
|
+
};
|
|
11
|
+
export type OverlayTriggerButtonProps = DistributedOmit<DropdownButtonProps, 'ref' | 'children' | 'onClick'> & {
|
|
12
|
+
children: NonNullable<React.ReactNode>;
|
|
13
|
+
ref?: React.Ref<TriggerEl> | React.Ref<HTMLButtonElement>;
|
|
14
|
+
};
|
|
15
|
+
export type OverlayTriggerIconButtonProps = SetRequired<DistributedOmit<DropdownButtonProps, 'ref' | 'showChevron' | 'onClick'>, 'aria-label' | 'icon'> & {
|
|
16
|
+
ref?: React.Ref<TriggerEl> | React.Ref<HTMLButtonElement>;
|
|
17
|
+
};
|
|
18
|
+
export declare const OverlayTrigger: {
|
|
19
|
+
Button({ ref, ...props }: OverlayTriggerButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
20
|
+
IconButton({ ref, children: _, ...props }: OverlayTriggerIconButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { ControlContext } from "./menu/controlContext.js";
|
|
3
|
+
import { DropdownButton } from "./menu/dropdownButton.js";
|
|
4
|
+
import * as __rspack_external_react from "react";
|
|
5
|
+
const useContextProps = ()=>{
|
|
6
|
+
const selectContext = __rspack_external_react.useContext(ControlContext);
|
|
7
|
+
return {
|
|
8
|
+
size: selectContext.size,
|
|
9
|
+
isOpen: selectContext.overlayIsOpen,
|
|
10
|
+
disabled: selectContext.disabled
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const OverlayTrigger = {
|
|
14
|
+
Button ({ ref, ...props }) {
|
|
15
|
+
return /*#__PURE__*/ jsx(DropdownButton, {
|
|
16
|
+
...useContextProps(),
|
|
17
|
+
...props,
|
|
18
|
+
ref: ref
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
IconButton ({ ref, children: _, ...props }) {
|
|
22
|
+
return /*#__PURE__*/ jsx(DropdownButton, {
|
|
23
|
+
...useContextProps(),
|
|
24
|
+
...props,
|
|
25
|
+
showChevron: false,
|
|
26
|
+
ref: ref
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export { OverlayTrigger };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const KNOWN_BRIDGED_CONTEXTS: readonly [import("react").Context<("xs" | "sm" | "md") | undefined>, import("react").Context<"
|
|
1
|
+
export declare const KNOWN_BRIDGED_CONTEXTS: readonly [import("react").Context<("xs" | "sm" | "md") | undefined>, import("react").Context<"2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "zero" | "3xs" | "5xl" | null>];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Spinner, type SpinnerProps } from './spinner.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Spinner } from "./spinner.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
export interface SpinnerProps {
|
|
3
|
+
children?: NonNullable<React.ReactNode>;
|
|
4
|
+
className?: string;
|
|
5
|
+
['data-test-id']?: string;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use `size` instead.
|
|
8
|
+
*/
|
|
9
|
+
mini?: boolean;
|
|
10
|
+
relative?: boolean;
|
|
11
|
+
size?: number;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
}
|
|
14
|
+
export declare function Spinner(props: SpinnerProps): import("@emotion/react/jsx-runtime").JSX.Element;
|