@sentry/scraps 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/alert/alert.js +0 -3
- package/dist/badge/badge.js +1 -2
- package/dist/badge/tag.js +0 -2
- package/dist/button/index.d.ts +0 -1
- package/dist/button/index.js +0 -1
- package/dist/clipboard/copyToClipboardButton.d.ts +15 -0
- package/dist/clipboard/copyToClipboardButton.js +32 -0
- package/dist/clipboard/index.d.ts +1 -0
- package/dist/clipboard/index.js +1 -0
- package/dist/code/index.d.ts +1 -0
- package/dist/code/index.js +1 -0
- package/dist/codeBlock/codeBlock.d.ts +68 -0
- package/dist/codeBlock/codeBlock.js +242 -0
- package/dist/codeBlock/index.d.ts +2 -0
- package/dist/codeBlock/index.js +2 -0
- package/dist/codeBlock/prism.d.ts +11 -0
- package/dist/codeBlock/prism.js +101 -0
- package/dist/codeBlock/styles.d.ts +2 -0
- package/dist/codeBlock/styles.js +133 -0
- package/dist/compactSelect/compactSelect.d.ts +21 -0
- package/dist/compactSelect/compactSelect.js +150 -0
- package/dist/compactSelect/composite.d.ts +54 -0
- package/dist/compactSelect/composite.js +101 -0
- package/dist/compactSelect/control.d.ts +112 -0
- package/dist/compactSelect/control.js +354 -0
- package/dist/compactSelect/fzf.d.ts +8 -0
- package/dist/compactSelect/fzf.js +151 -0
- package/dist/compactSelect/gridList/index.d.ts +46 -0
- package/dist/compactSelect/gridList/index.js +102 -0
- package/dist/compactSelect/gridList/option.d.ts +15 -0
- package/dist/compactSelect/gridList/option.js +111 -0
- package/dist/compactSelect/gridList/section.d.ts +15 -0
- package/dist/compactSelect/gridList/section.js +58 -0
- package/dist/compactSelect/highlightText.d.ts +6 -0
- package/dist/compactSelect/highlightText.js +33 -0
- package/dist/compactSelect/index.d.ts +9 -0
- package/dist/compactSelect/index.js +8 -0
- package/dist/compactSelect/list.d.ts +94 -0
- package/dist/compactSelect/list.js +167 -0
- package/dist/compactSelect/listBox/index.d.ts +84 -0
- package/dist/compactSelect/listBox/index.js +175 -0
- package/dist/compactSelect/listBox/option.d.ts +19 -0
- package/dist/compactSelect/listBox/option.js +101 -0
- package/dist/compactSelect/listBox/section.d.ts +21 -0
- package/dist/compactSelect/listBox/section.js +58 -0
- package/dist/compactSelect/menuComponents.d.ts +89 -0
- package/dist/compactSelect/menuComponents.js +117 -0
- package/dist/compactSelect/selectFilterContext.d.ts +2 -0
- package/dist/compactSelect/selectFilterContext.js +3 -0
- package/dist/compactSelect/styles.d.ts +39 -0
- package/dist/compactSelect/styles.js +155 -0
- package/dist/compactSelect/types.d.ts +1 -0
- package/dist/compactSelect/types.js +0 -0
- package/dist/compactSelect/useVirtualizedItems.d.ts +52 -0
- package/dist/compactSelect/useVirtualizedItems.js +74 -0
- package/dist/compactSelect/utils.d.ts +80 -0
- package/dist/compactSelect/utils.js +268 -0
- package/dist/confirm/index.d.ts +153 -0
- package/dist/confirm/index.js +132 -0
- package/dist/descriptionList/descriptionList.js +4 -3
- package/dist/disclosure/disclosure.js +2 -2
- package/dist/dragHandle/dragHandle.d.ts +3 -1
- package/dist/dragHandle/dragHandle.js +8 -5
- package/dist/drawer/components.d.ts +46 -0
- package/dist/drawer/components.js +265 -0
- package/dist/drawer/globalDrawer.d.ts +106 -0
- package/dist/drawer/globalDrawer.js +173 -0
- package/dist/drawer/index.d.ts +3 -0
- package/dist/drawer/index.js +2 -0
- package/dist/drawer/useDrawerResizing.d.ts +19 -0
- package/dist/drawer/useDrawerResizing.js +111 -0
- package/dist/drawer/useDrawerWidth.d.ts +1 -0
- package/dist/drawer/useDrawerWidth.js +42 -0
- package/dist/dropdownMenu/content.d.ts +1 -0
- package/dist/dropdownMenu/content.js +1 -0
- package/dist/dropdownMenu/context.d.ts +24 -0
- package/dist/dropdownMenu/context.js +3 -0
- package/dist/dropdownMenu/dropdownMenu.d.ts +70 -0
- package/dist/dropdownMenu/dropdownMenu.js +103 -0
- package/dist/dropdownMenu/index.d.ts +2 -0
- package/dist/dropdownMenu/index.js +1 -0
- package/dist/dropdownMenu/item.d.ts +136 -0
- package/dist/dropdownMenu/item.js +182 -0
- package/dist/dropdownMenu/list.d.ts +59 -0
- package/dist/dropdownMenu/list.js +410 -0
- package/dist/dropdownMenu/search.d.ts +16 -0
- package/dist/dropdownMenu/search.js +16 -0
- package/dist/dropdownMenu/section.d.ts +21 -0
- package/dist/dropdownMenu/section.js +40 -0
- package/dist/dropdownMenu/separator.d.ts +7 -0
- package/dist/dropdownMenu/separator.js +15 -0
- package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +260 -0
- package/dist/dropdownMenu/useDropdownMenuKeyboard.js +55 -0
- package/dist/dropdownMenu/useDropdownMenuRowLayout.d.ts +29 -0
- package/dist/dropdownMenu/useDropdownMenuRowLayout.js +64 -0
- package/dist/dropdownMenu/useSafetyTriangle.d.ts +12 -0
- package/dist/dropdownMenu/useSafetyTriangle.js +119 -0
- package/dist/dropdownMenu/utils.d.ts +21 -0
- package/dist/dropdownMenu/utils.js +57 -0
- package/dist/form/FormSearch.d.ts +19 -0
- package/dist/form/FormSearch.js +4 -0
- package/dist/form/autoSaveForm.d.ts +110 -0
- package/dist/form/autoSaveForm.js +100 -0
- package/dist/{formPresentation → form}/displayField.js +2 -2
- package/dist/form/field/baseField.d.ts +23 -0
- package/dist/form/field/baseField.js +116 -0
- package/dist/form/field/checkboxField.d.ts +11 -0
- package/dist/form/field/checkboxField.js +42 -0
- package/dist/form/field/checkboxGroupField.d.ts +16 -0
- package/dist/form/field/checkboxGroupField.js +80 -0
- package/dist/form/field/compactSelectField.d.ts +19 -0
- package/dist/form/field/compactSelectField.js +77 -0
- package/dist/{formPresentation → form/field}/fieldIds.js +1 -1
- package/dist/form/field/inputField.d.ts +19 -0
- package/dist/form/field/inputField.js +31 -0
- package/dist/{formPresentation → form/field}/meta.js +6 -6
- package/dist/form/field/numberField.d.ts +5 -0
- package/dist/form/field/numberField.js +11 -0
- package/dist/form/field/passwordField.d.ts +3 -0
- package/dist/form/field/passwordField.js +27 -0
- package/dist/form/field/radioGroupField.d.ts +16 -0
- package/dist/form/field/radioGroupField.js +92 -0
- package/dist/form/field/rangeField.d.ts +8 -0
- package/dist/form/field/rangeField.js +34 -0
- package/dist/form/field/selectAsyncField.d.ts +31 -0
- package/dist/form/field/selectAsyncField.js +22 -0
- package/dist/form/field/selectField.d.ts +9 -0
- package/dist/form/field/selectField.js +72 -0
- package/dist/form/field/switchField.d.ts +7 -0
- package/dist/form/field/switchField.js +37 -0
- package/dist/form/field/textAreaField.d.ts +7 -0
- package/dist/form/field/textAreaField.js +25 -0
- package/dist/{formPresentation → form}/formContext.js +1 -1
- package/dist/form/formErrorContext/index.d.ts +9 -0
- package/dist/form/formErrorContext/index.js +7 -0
- package/dist/form/index.d.ts +9 -0
- package/dist/form/index.js +8 -0
- package/dist/{formPresentation → form/layout}/base.d.ts +1 -1
- package/dist/{formPresentation → form/layout}/base.js +1 -1
- package/dist/form/layout/fieldGroup.d.ts +6 -0
- package/dist/form/layout/fieldGroup.js +60 -0
- package/dist/{formPresentation/fieldLayout.d.ts → form/layout/index.d.ts} +1 -1
- package/dist/{formPresentation/fieldLayout.js → form/layout/index.js} +3 -3
- package/dist/{formPresentation → form/layout}/useStackedLayout.js +1 -1
- package/dist/form/scrapsForm.d.ts +220 -0
- package/dist/form/scrapsForm.js +126 -0
- package/dist/hotkey/hotkey.d.ts +9 -8
- package/dist/hotkey/hotkey.js +13 -6
- package/dist/hotkey/index.d.ts +2 -1
- package/dist/hotkey/index.js +2 -1
- package/dist/hotkey/keyMappings.d.ts +1 -15
- package/dist/hotkey/keyMappings.js +29 -174
- package/dist/hotkey/useHotkeys.d.ts +3 -47
- package/dist/hotkey/useHotkeys.js +8 -42
- package/dist/image/image.js +2 -1
- package/dist/info/infoTip.d.ts +1 -1
- package/dist/info/infoTip.js +4 -3
- package/dist/input/index.d.ts +0 -3
- package/dist/input/index.js +0 -2
- package/dist/input/input.d.ts +2 -0
- package/dist/input/input.js +2 -0
- package/dist/input/passwordManagerIgnoreProps.d.ts +11 -0
- package/dist/input/passwordManagerIgnoreProps.js +8 -0
- package/dist/layout/index.d.ts +2 -2
- package/dist/layout/index.js +1 -1
- package/dist/layout/styles.d.ts +1 -1
- package/dist/link/link.js +4 -3
- package/dist/link/linkBehaviorContext.d.ts +2 -0
- package/dist/link/linkBehaviorContext.js +17 -10
- package/dist/menu/controlContext.d.ts +32 -0
- package/dist/menu/controlContext.js +7 -0
- package/dist/menu/dropdownButton.d.ts +18 -0
- package/dist/menu/dropdownButton.js +66 -0
- package/dist/menu/index.d.ts +7 -0
- package/dist/menu/index.js +3 -0
- package/dist/menu/menu.d.ts +167 -0
- package/dist/menu/menu.js +568 -0
- package/dist/menu/selectTypes.d.ts +96 -0
- package/dist/menu/selectTypes.js +0 -0
- package/dist/menu/selectValue.d.ts +13 -0
- package/dist/menu/selectValue.js +0 -0
- package/dist/modal/components.d.ts +19 -0
- package/dist/modal/components.js +99 -0
- package/dist/modal/errorBoundary.d.ts +2 -0
- package/dist/modal/errorBoundary.js +35 -0
- package/dist/modal/index.d.ts +33 -0
- package/dist/modal/index.js +260 -0
- package/dist/modal/portal.d.ts +1 -0
- package/dist/modal/portal.js +10 -0
- package/dist/modal/state.d.ts +17 -0
- package/dist/modal/state.js +41 -0
- package/dist/modal/types.d.ts +75 -0
- package/dist/modal/types.js +0 -0
- package/dist/numberInput/index.d.ts +3 -0
- package/dist/numberInput/index.js +2 -0
- package/dist/{input → numberInput}/numberDragInput.d.ts +1 -1
- package/dist/{input → numberInput}/numberDragInput.js +1 -1
- package/dist/{input → numberInput}/numberInput.d.ts +1 -1
- package/dist/{input → numberInput}/numberInput.js +1 -1
- package/dist/overlayContext.d.ts +29 -0
- package/dist/overlayContext.js +7 -0
- package/dist/overlayTrigger.d.ts +22 -0
- package/dist/overlayTrigger.js +30 -0
- package/dist/pagination/index.d.ts +1 -0
- package/dist/pagination/index.js +1 -0
- package/dist/pagination/pagination.d.ts +24 -0
- package/dist/pagination/pagination.js +63 -0
- package/dist/pictureInPicture/index.d.ts +2 -0
- package/dist/pictureInPicture/index.js +2 -0
- package/dist/pictureInPicture/pictureInPicture.d.ts +47 -0
- package/dist/pictureInPicture/pictureInPicture.js +100 -0
- package/dist/pictureInPicture/pictureInPicturePortal.d.ts +16 -0
- package/dist/pictureInPicture/pictureInPicturePortal.js +46 -0
- package/dist/pictureInPicture/portalContext.d.ts +2 -0
- package/dist/pictureInPicture/portalContext.js +3 -0
- package/dist/revealOnHover/revealOnHover.js +1 -1
- package/dist/segmentedControl/segmentedControl.js +1 -1
- package/dist/select/filter.d.ts +4 -0
- package/dist/select/filter.js +12 -0
- package/dist/select/index.d.ts +3 -0
- package/dist/select/index.js +2 -0
- package/dist/select/option.d.ts +16 -0
- package/dist/select/option.js +81 -0
- package/dist/select/reactSelectWrapper.d.ts +8 -0
- package/dist/select/reactSelectWrapper.js +25 -0
- package/dist/select/select.d.ts +79 -0
- package/dist/select/select.js +454 -0
- package/dist/select/styles.d.ts +9 -0
- package/dist/select/styles.js +27 -0
- package/dist/select/types.d.ts +60 -0
- package/dist/select/types.js +0 -0
- package/dist/select/virtualizedMenuList.d.ts +24 -0
- package/dist/select/virtualizedMenuList.js +123 -0
- package/dist/slideOverPanel.d.ts +20 -0
- package/dist/slideOverPanel.js +141 -0
- package/dist/slot/knownContexts.d.ts +1 -1
- package/dist/spinner/index.d.ts +1 -0
- package/dist/spinner/index.js +1 -0
- package/dist/spinner/spinner.d.ts +14 -0
- package/dist/spinner/spinner.js +126 -0
- package/dist/splitPanel/index.d.ts +1 -0
- package/dist/splitPanel/index.js +1 -0
- package/dist/splitPanel/splitPanel.d.ts +38 -0
- package/dist/splitPanel/splitPanel.js +145 -0
- package/dist/table/table.d.ts +1 -1
- package/dist/table/table.js +39 -20
- package/dist/table/useColumnResize.d.ts +6 -5
- package/dist/table/useColumnResize.js +5 -4
- package/dist/tabs/index.d.ts +4 -0
- package/dist/tabs/index.js +3 -0
- package/dist/tabs/item.d.ts +13 -0
- package/dist/tabs/item.js +4 -0
- package/dist/tabs/tab.d.ts +22 -0
- package/dist/tabs/tab.js +205 -0
- package/dist/tabs/tabList.d.ts +18 -0
- package/dist/tabs/tabList.js +256 -0
- package/dist/tabs/tabPanels.d.ts +14 -0
- package/dist/tabs/tabPanels.js +62 -0
- package/dist/tabs/tabs.d.ts +38 -0
- package/dist/tabs/tabs.js +56 -0
- package/dist/tabs/utils.d.ts +3 -0
- package/dist/tabs/utils.js +6 -0
- package/dist/text/heading.d.ts +1 -1
- package/dist/text/heading.js +1 -1
- package/dist/text/styles.js +1 -1
- package/dist/text/text.d.ts +1 -1
- package/dist/text/text.js +1 -1
- package/dist/theme/dark.js +9 -9
- package/dist/theme/light.js +9 -9
- package/dist/toast/index.d.ts +5 -0
- package/dist/toast/index.js +4 -0
- package/dist/toast/toast.d.ts +10 -0
- package/dist/toast/toast.js +182 -0
- package/dist/toast/toastApi.d.ts +10 -0
- package/dist/toast/toastApi.js +53 -0
- package/dist/toast/toaster.d.ts +4 -0
- package/dist/toast/toaster.js +42 -0
- package/dist/toast/types.d.ts +17 -0
- package/dist/toast/types.js +2 -0
- package/dist/toggleCard/index.d.ts +1 -0
- package/dist/toggleCard/index.js +1 -0
- package/dist/toggleCard/toggleCard.d.ts +32 -0
- package/dist/toggleCard/toggleCard.js +301 -0
- package/dist/tooltip/tooltip.js +2 -5
- package/dist/useDimensions.d.ts +12 -0
- package/dist/useDimensions.js +31 -0
- package/dist/useMedia.d.ts +15 -0
- package/dist/useMedia.js +24 -0
- package/dist/useOnClickOutside.d.ts +2 -0
- package/dist/useOnClickOutside.js +22 -0
- package/dist/useOverlay.d.ts +1 -0
- package/dist/useOverlay.js +1 -0
- package/dist/useResizableDrawer.d.ts +72 -0
- package/dist/useResizableDrawer.js +136 -0
- package/dist/useVirtualCollection.d.ts +154 -0
- package/dist/useVirtualCollection.js +143 -0
- package/dist/useVirtualRows.d.ts +26 -0
- package/dist/useVirtualRows.js +26 -0
- package/dist/virtualCollectionLayout.d.ts +51 -0
- package/dist/virtualCollectionLayout.js +49 -0
- package/package.json +148 -16
- package/dist/formPresentation/index.d.ts +0 -8
- package/dist/formPresentation/index.js +0 -8
- package/dist/interactionStateLayer/index.d.ts +0 -1
- package/dist/interactionStateLayer/index.js +0 -1
- package/dist/interactionStateLayer/interactionStateLayer.d.ts +0 -23
- package/dist/interactionStateLayer/interactionStateLayer.js +0 -67
- package/dist/unreachable.d.ts +0 -1
- package/dist/unreachable.js +0 -4
- /package/dist/{formPresentation → form}/autoSaveContext.d.ts +0 -0
- /package/dist/{formPresentation → form}/autoSaveContext.js +0 -0
- /package/dist/{formPresentation → form}/displayField.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/fieldIds.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/groupContext.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/groupContext.js +0 -0
- /package/dist/{formPresentation → form/field}/meta.d.ts +0 -0
- /package/dist/{formPresentation → form}/formContext.d.ts +0 -0
- /package/dist/{formPresentation → form}/icons.d.ts +0 -0
- /package/dist/{formPresentation → form}/icons.js +0 -0
- /package/dist/{formPresentation → form/layout}/useStackedLayout.d.ts +0 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { FormSize } from '../theme/index.js';
|
|
3
|
+
import type { SelectComponents, SelectHandle, SelectSelectionProps, SelectValue, StylesConfig } from './types.js';
|
|
4
|
+
/** Props shared by form fields and standalone selects. Implementation components stay private. */
|
|
5
|
+
export interface BaseSelectProps<TValue, TOption extends SelectValue<TValue> = SelectValue<TValue>> {
|
|
6
|
+
options: ReadonlyArray<(TOption & SelectValue<TValue>) | {
|
|
7
|
+
options: ReadonlyArray<TOption & SelectValue<TValue>>;
|
|
8
|
+
label?: React.ReactNode;
|
|
9
|
+
}>;
|
|
10
|
+
'aria-describedby'?: string;
|
|
11
|
+
'aria-invalid'?: boolean;
|
|
12
|
+
'aria-label'?: string;
|
|
13
|
+
'aria-labelledby'?: string;
|
|
14
|
+
autoFocus?: boolean;
|
|
15
|
+
/** Blur after selection. Defaults to true for single selects, false for multiple. */
|
|
16
|
+
blurInputOnSelect?: boolean;
|
|
17
|
+
className?: string;
|
|
18
|
+
/** Customize content while Select retains input, option, and chip behavior. */
|
|
19
|
+
components?: SelectComponents<TOption>;
|
|
20
|
+
/** Content inside the control, before the selected value and input. */
|
|
21
|
+
controlLeadingItems?: React.ReactNode;
|
|
22
|
+
/** Allow values that are not in `options`. */
|
|
23
|
+
creatable?: boolean;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
/** Set to null to hide the dropdown indicator. */
|
|
26
|
+
dropdownIndicator?: React.ReactNode;
|
|
27
|
+
filterOption?: ((option: TOption, input: string) => boolean) | null;
|
|
28
|
+
formatCreateLabel?: (input: string) => React.ReactNode;
|
|
29
|
+
/** ID of the native input, for association with a label. */
|
|
30
|
+
id?: string;
|
|
31
|
+
/** Ref to the native search input. */
|
|
32
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
33
|
+
inputValue?: string;
|
|
34
|
+
isInsideModal?: boolean;
|
|
35
|
+
isLoading?: boolean;
|
|
36
|
+
/** Controlled menu state. */
|
|
37
|
+
isOpen?: boolean;
|
|
38
|
+
/** Compare object values. Values are compared with === by default. */
|
|
39
|
+
isValueEqual?: (a: TValue, b: TValue) => boolean;
|
|
40
|
+
loadingMessage?: () => React.ReactNode;
|
|
41
|
+
maxMenuHeight?: number;
|
|
42
|
+
maxMenuWidth?: number | string;
|
|
43
|
+
/** Content after the options, outside the scroll container. */
|
|
44
|
+
menuFooter?: React.ReactNode;
|
|
45
|
+
menuPortalTarget?: HTMLElement | null;
|
|
46
|
+
minMenuHeight?: number;
|
|
47
|
+
name?: string;
|
|
48
|
+
noOptionsMessage?: (state: {
|
|
49
|
+
inputValue: string;
|
|
50
|
+
}) => React.ReactNode;
|
|
51
|
+
onBlur?: React.FocusEventHandler<HTMLInputElement>;
|
|
52
|
+
onCreateOption?: (input: string) => void;
|
|
53
|
+
onFocus?: React.FocusEventHandler<HTMLInputElement>;
|
|
54
|
+
/** Search text changes, including resets after selection, blur, or menu close. */
|
|
55
|
+
onInputChange?: (input: string, reason: 'input' | 'reset') => void;
|
|
56
|
+
onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
|
|
57
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
58
|
+
openMenuOnClick?: boolean;
|
|
59
|
+
openMenuOnFocus?: boolean;
|
|
60
|
+
placeholder?: React.ReactNode;
|
|
61
|
+
ref?: React.Ref<SelectHandle>;
|
|
62
|
+
searchable?: boolean;
|
|
63
|
+
showCreateOptionIcon?: boolean;
|
|
64
|
+
showDividers?: boolean;
|
|
65
|
+
size?: FormSize;
|
|
66
|
+
styles?: StylesConfig<NoInfer<TValue>, NoInfer<TOption>>;
|
|
67
|
+
tabIndex?: number;
|
|
68
|
+
/** Virtualize large lists, including lists with sections. */
|
|
69
|
+
virtualized?: boolean;
|
|
70
|
+
}
|
|
71
|
+
type DisabledSelectionProps<Props extends {
|
|
72
|
+
onChange: unknown;
|
|
73
|
+
}> = Props extends unknown ? Omit<Props, 'onChange'> & {
|
|
74
|
+
disabled: true;
|
|
75
|
+
onChange?: Props['onChange'];
|
|
76
|
+
} : never;
|
|
77
|
+
export type ControlProps<TValue, TOption extends SelectValue<TValue> = SelectValue<TValue>> = (SelectSelectionProps<TValue, TOption> | DisabledSelectionProps<SelectSelectionProps<TValue, TOption>>) & BaseSelectProps<TValue, TOption>;
|
|
78
|
+
export declare function Select<TValue, TOption extends SelectValue<TValue> = SelectValue<TValue>>(props: ControlProps<TValue, TOption>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useCallback, useImperativeHandle, useMemo, useRef } from "react";
|
|
3
|
+
import { useTheme } from "@emotion/react";
|
|
4
|
+
import styled from "@emotion/styled";
|
|
5
|
+
import { useObjectRef } from "@react-aria/utils";
|
|
6
|
+
import { IconChevron } from "@sentry/icons/chevron";
|
|
7
|
+
import { IconClose } from "@sentry/icons/close";
|
|
8
|
+
import { Button } from "../button/index.js";
|
|
9
|
+
import { PanelProvider } from "../panelProvider.js";
|
|
10
|
+
import { Spinner } from "../spinner/index.js";
|
|
11
|
+
import { useTranslation } from "../translation/index.js";
|
|
12
|
+
import { createFilter } from "./filter.js";
|
|
13
|
+
import { SelectOption } from "./option.js";
|
|
14
|
+
import { Creatable, ReactSelect, components as external_reactSelectWrapper_js_components, mergeStyles } from "./reactSelectWrapper.js";
|
|
15
|
+
import { VirtualizedMenuList } from "./virtualizedMenuList.js";
|
|
16
|
+
const selectSpacing = {
|
|
17
|
+
md: '8px',
|
|
18
|
+
sm: '6px',
|
|
19
|
+
xs: '4px'
|
|
20
|
+
};
|
|
21
|
+
const multiValueSizeMapping = {
|
|
22
|
+
md: {
|
|
23
|
+
height: '20px',
|
|
24
|
+
spacing: '4px'
|
|
25
|
+
},
|
|
26
|
+
sm: {
|
|
27
|
+
height: '18px',
|
|
28
|
+
spacing: '2px'
|
|
29
|
+
},
|
|
30
|
+
xs: {
|
|
31
|
+
height: '16px',
|
|
32
|
+
spacing: '2px'
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const getStylesConfig = ({ theme, size = 'md', maxMenuWidth, isInsideModal, isSearchable, isDisabled })=>{
|
|
36
|
+
const indicatorStyles = (provided, state)=>({
|
|
37
|
+
...provided,
|
|
38
|
+
padding: '0 4px 0 4px',
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
cursor: state.isDisabled ? 'not-allowed' : 'pointer',
|
|
41
|
+
color: state.isDisabled ? theme.tokens.content.disabled : theme.tokens.content.primary,
|
|
42
|
+
':hover': {
|
|
43
|
+
color: 'currentcolor'
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const boxShadow = `0px 1px 0px 0px ${theme.tokens.interactive.chonky.debossed.neutral.chonk} inset`;
|
|
47
|
+
return {
|
|
48
|
+
control: (_, state)=>({
|
|
49
|
+
display: 'flex',
|
|
50
|
+
color: state.isDisabled ? theme.tokens.content.disabled : theme.tokens.content.primary,
|
|
51
|
+
backgroundColor: theme.tokens.interactive.chonky.debossed.neutral.background,
|
|
52
|
+
border: `1px solid ${theme.tokens.border.primary}`,
|
|
53
|
+
boxShadow,
|
|
54
|
+
borderRadius: theme.form[size].borderRadius,
|
|
55
|
+
transition: `border ${theme.motion.smooth.fast}, box-shadow ${theme.motion.smooth.fast}`,
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
...state.isFocused && theme.focusRing(boxShadow),
|
|
58
|
+
...state.isDisabled && {
|
|
59
|
+
background: theme.tokens.background.primary,
|
|
60
|
+
color: theme.tokens.content.disabled,
|
|
61
|
+
cursor: 'not-allowed',
|
|
62
|
+
opacity: '60%'
|
|
63
|
+
},
|
|
64
|
+
minHeight: theme.form[size].minHeight,
|
|
65
|
+
fontSize: theme.form[size].fontSize,
|
|
66
|
+
lineHeight: theme.form[size].lineHeight,
|
|
67
|
+
...state.isMulti && {
|
|
68
|
+
maxHeight: '12em',
|
|
69
|
+
overflow: 'hidden'
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
menu: (provided)=>({
|
|
73
|
+
...provided,
|
|
74
|
+
zIndex: theme.zIndex.dropdown,
|
|
75
|
+
background: theme.tokens.background.primary,
|
|
76
|
+
borderRadius: theme.radius.md,
|
|
77
|
+
border: `1px solid ${theme.tokens.border.primary}`,
|
|
78
|
+
boxShadow: 'none',
|
|
79
|
+
width: 'auto',
|
|
80
|
+
minWidth: '100%',
|
|
81
|
+
maxWidth: maxMenuWidth ?? 'auto'
|
|
82
|
+
}),
|
|
83
|
+
noOptionsMessage: (provided)=>({
|
|
84
|
+
...provided,
|
|
85
|
+
color: theme.tokens.content.disabled
|
|
86
|
+
}),
|
|
87
|
+
menuPortal: (provided)=>({
|
|
88
|
+
...provided,
|
|
89
|
+
maxWidth: maxMenuWidth ?? '24rem',
|
|
90
|
+
zIndex: isInsideModal ? theme.zIndex.modal + 1 : theme.zIndex.dropdown
|
|
91
|
+
}),
|
|
92
|
+
option: (provided)=>({
|
|
93
|
+
...provided,
|
|
94
|
+
color: theme.tokens.content.primary,
|
|
95
|
+
background: 'transparent',
|
|
96
|
+
padding: 0,
|
|
97
|
+
':active': {
|
|
98
|
+
background: 'transparent'
|
|
99
|
+
}
|
|
100
|
+
}),
|
|
101
|
+
container: (provided, state)=>({
|
|
102
|
+
...provided,
|
|
103
|
+
...state.isDisabled && {
|
|
104
|
+
pointerEvents: 'unset'
|
|
105
|
+
}
|
|
106
|
+
}),
|
|
107
|
+
valueContainer: (provided, state)=>({
|
|
108
|
+
...provided,
|
|
109
|
+
cursor: isDisabled ? 'not-allowed' : isSearchable ? 'default' : 'pointer',
|
|
110
|
+
alignItems: 'center',
|
|
111
|
+
paddingTop: 0,
|
|
112
|
+
paddingBottom: 0,
|
|
113
|
+
paddingLeft: theme.form[size].paddingLeft,
|
|
114
|
+
paddingRight: selectSpacing[size],
|
|
115
|
+
...state.isMulti && {
|
|
116
|
+
maxHeight: 'inherit',
|
|
117
|
+
overflowY: 'auto',
|
|
118
|
+
scrollbarColor: `${theme.tokens.graphics.accent.moderate} ${theme.tokens.background.primary}`
|
|
119
|
+
}
|
|
120
|
+
}),
|
|
121
|
+
input: (provided)=>({
|
|
122
|
+
...provided,
|
|
123
|
+
color: theme.tokens.content.primary,
|
|
124
|
+
margin: 0
|
|
125
|
+
}),
|
|
126
|
+
singleValue: (provided, state)=>({
|
|
127
|
+
...provided,
|
|
128
|
+
color: state.isDisabled ? theme.tokens.content.disabled : theme.tokens.content.primary,
|
|
129
|
+
display: 'flex',
|
|
130
|
+
alignItems: 'center',
|
|
131
|
+
marginLeft: 0,
|
|
132
|
+
marginRight: 0,
|
|
133
|
+
width: `calc(100% - ${theme.form[size].paddingLeft}px - ${theme.space.xs})`
|
|
134
|
+
}),
|
|
135
|
+
placeholder: (provided, state)=>({
|
|
136
|
+
...provided,
|
|
137
|
+
color: state.isDisabled ? theme.tokens.content.disabled : theme.tokens.content.secondary
|
|
138
|
+
}),
|
|
139
|
+
multiValue: (provided)=>({
|
|
140
|
+
...provided,
|
|
141
|
+
backgroundColor: theme.tokens.background.primary,
|
|
142
|
+
color: isDisabled ? theme.tokens.content.disabled : theme.tokens.content.primary,
|
|
143
|
+
borderRadius: '4px',
|
|
144
|
+
border: `1px solid ${theme.tokens.border.primary}`,
|
|
145
|
+
boxShadow: `0px 1px 0px 0px ${theme.tokens.border.primary}`,
|
|
146
|
+
display: 'flex',
|
|
147
|
+
margin: 0,
|
|
148
|
+
marginTop: multiValueSizeMapping[size].spacing,
|
|
149
|
+
marginBottom: multiValueSizeMapping[size].spacing,
|
|
150
|
+
marginRight: multiValueSizeMapping[size].spacing
|
|
151
|
+
}),
|
|
152
|
+
multiValueLabel: (provided)=>({
|
|
153
|
+
...provided,
|
|
154
|
+
color: isDisabled ? theme.tokens.content.disabled : theme.tokens.content.primary,
|
|
155
|
+
padding: multiValueSizeMapping[size].spacing,
|
|
156
|
+
paddingLeft: multiValueSizeMapping[size].spacing,
|
|
157
|
+
height: multiValueSizeMapping[size].height,
|
|
158
|
+
display: 'flex',
|
|
159
|
+
alignItems: 'center'
|
|
160
|
+
}),
|
|
161
|
+
multiValueRemove: ()=>({
|
|
162
|
+
alignItems: 'center',
|
|
163
|
+
display: 'flex',
|
|
164
|
+
margin: '4px 4px',
|
|
165
|
+
...isDisabled ? {
|
|
166
|
+
pointerEvents: 'none'
|
|
167
|
+
} : {
|
|
168
|
+
'&:hover': {
|
|
169
|
+
cursor: 'pointer',
|
|
170
|
+
background: theme.tokens.interactive.transparent.neutral.background.hover
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}),
|
|
174
|
+
indicatorsContainer: ()=>({
|
|
175
|
+
display: 'grid',
|
|
176
|
+
gridAutoFlow: 'column',
|
|
177
|
+
marginRight: selectSpacing[size]
|
|
178
|
+
}),
|
|
179
|
+
clearIndicator: indicatorStyles,
|
|
180
|
+
dropdownIndicator: indicatorStyles,
|
|
181
|
+
loadingIndicator: indicatorStyles,
|
|
182
|
+
groupHeading: (provided)=>({
|
|
183
|
+
...provided,
|
|
184
|
+
lineHeight: '1.5',
|
|
185
|
+
fontWeight: 600,
|
|
186
|
+
color: theme.tokens.content.secondary,
|
|
187
|
+
marginBottom: 0,
|
|
188
|
+
padding: `${theme.space.xs} ${theme.space.lg}`,
|
|
189
|
+
':empty': {
|
|
190
|
+
display: 'none'
|
|
191
|
+
}
|
|
192
|
+
}),
|
|
193
|
+
group: (provided)=>({
|
|
194
|
+
...provided,
|
|
195
|
+
paddingTop: 0,
|
|
196
|
+
':last-of-type': {
|
|
197
|
+
paddingBottom: 0
|
|
198
|
+
},
|
|
199
|
+
':not(:last-of-type)': {
|
|
200
|
+
position: 'relative',
|
|
201
|
+
marginBottom: theme.space.md
|
|
202
|
+
},
|
|
203
|
+
':not(:last-of-type)::after': {
|
|
204
|
+
content: '""',
|
|
205
|
+
position: 'absolute',
|
|
206
|
+
left: theme.space.lg,
|
|
207
|
+
right: theme.space.lg,
|
|
208
|
+
bottom: 0,
|
|
209
|
+
borderBottom: `solid 1px ${theme.tokens.border.secondary}`
|
|
210
|
+
}
|
|
211
|
+
})
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
function SelectInput({ selectProps, ...props }) {
|
|
215
|
+
const { inputRef } = selectProps;
|
|
216
|
+
const nativeInputRef = useObjectRef(inputRef);
|
|
217
|
+
const ref = useCallback((instance)=>{
|
|
218
|
+
nativeInputRef.current = instance?.input ?? null;
|
|
219
|
+
}, [
|
|
220
|
+
nativeInputRef
|
|
221
|
+
]);
|
|
222
|
+
return /*#__PURE__*/ jsx(external_reactSelectWrapper_js_components.Input, {
|
|
223
|
+
...props,
|
|
224
|
+
ref,
|
|
225
|
+
"aria-invalid": selectProps['aria-invalid'],
|
|
226
|
+
"aria-describedby": selectProps['aria-describedby']
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
function SelectControl({ children, ...props }) {
|
|
230
|
+
return /*#__PURE__*/ jsxs(external_reactSelectWrapper_js_components.Control, {
|
|
231
|
+
...props,
|
|
232
|
+
children: [
|
|
233
|
+
props.selectProps.controlLeadingItems,
|
|
234
|
+
children
|
|
235
|
+
]
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function IndicatorsContainer({ children, ...props }) {
|
|
239
|
+
const Indicators = props.selectProps.contentComponents?.Indicators;
|
|
240
|
+
if (null === Indicators) return null;
|
|
241
|
+
return Indicators ? /*#__PURE__*/ jsx(Indicators, {
|
|
242
|
+
children: children
|
|
243
|
+
}) : /*#__PURE__*/ jsx(external_reactSelectWrapper_js_components.IndicatorsContainer, {
|
|
244
|
+
...props,
|
|
245
|
+
children: children
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
function MultiValueLabel({ children, ...props }) {
|
|
249
|
+
const Label = props.selectProps.contentComponents?.MultiValueLabel;
|
|
250
|
+
return /*#__PURE__*/ jsx(external_reactSelectWrapper_js_components.MultiValueLabel, {
|
|
251
|
+
...props,
|
|
252
|
+
children: Label ? /*#__PURE__*/ jsx(Label, {
|
|
253
|
+
option: props.data,
|
|
254
|
+
children: children
|
|
255
|
+
}) : children
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
function ClearIndicator(props) {
|
|
259
|
+
const { t } = useTranslation();
|
|
260
|
+
return /*#__PURE__*/ jsx(external_reactSelectWrapper_js_components.ClearIndicator, {
|
|
261
|
+
...props,
|
|
262
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
263
|
+
variant: "transparent",
|
|
264
|
+
icon: /*#__PURE__*/ jsx(IconClose, {
|
|
265
|
+
legacySize: "10px"
|
|
266
|
+
}),
|
|
267
|
+
size: "zero",
|
|
268
|
+
"aria-label": t('Clear choices'),
|
|
269
|
+
onClick: props.clearValue
|
|
270
|
+
})
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
function DropdownIndicator(props) {
|
|
274
|
+
return /*#__PURE__*/ jsx(external_reactSelectWrapper_js_components.DropdownIndicator, {
|
|
275
|
+
...props,
|
|
276
|
+
children: props.selectProps.dropdownIndicator ?? /*#__PURE__*/ jsx(IconChevron, {
|
|
277
|
+
direction: "down",
|
|
278
|
+
size: "xs"
|
|
279
|
+
})
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
function MultiValueRemove(props) {
|
|
283
|
+
const { t } = useTranslation();
|
|
284
|
+
return /*#__PURE__*/ jsx(external_reactSelectWrapper_js_components.MultiValueRemove, {
|
|
285
|
+
...props,
|
|
286
|
+
children: /*#__PURE__*/ jsx(IconClose, {
|
|
287
|
+
"aria-label": t('Remove item'),
|
|
288
|
+
legacySize: "8px"
|
|
289
|
+
})
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
function SelectSpinner() {
|
|
293
|
+
return /*#__PURE__*/ jsx(Spinner, {
|
|
294
|
+
mini: true,
|
|
295
|
+
size: 14,
|
|
296
|
+
style: {
|
|
297
|
+
height: 14,
|
|
298
|
+
width: 14
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
function SingleValue(props) {
|
|
303
|
+
const { leadingItems, label } = props.data;
|
|
304
|
+
const ValueComponent = props.selectProps.contentComponents?.Value;
|
|
305
|
+
const renderedLeadingItems = 'function' == typeof leadingItems ? leadingItems({
|
|
306
|
+
disabled: props.isDisabled,
|
|
307
|
+
isFocused: false,
|
|
308
|
+
isSelected: true
|
|
309
|
+
}) : leadingItems;
|
|
310
|
+
return /*#__PURE__*/ jsx(external_reactSelectWrapper_js_components.SingleValue, {
|
|
311
|
+
...props,
|
|
312
|
+
children: ValueComponent ? /*#__PURE__*/ jsx(ValueComponent, {
|
|
313
|
+
option: props.data
|
|
314
|
+
}) : /*#__PURE__*/ jsxs(SingleValueWrap, {
|
|
315
|
+
children: [
|
|
316
|
+
renderedLeadingItems,
|
|
317
|
+
/*#__PURE__*/ jsx(SingleValueLabel, {
|
|
318
|
+
children: label
|
|
319
|
+
})
|
|
320
|
+
]
|
|
321
|
+
})
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
const SingleValueWrap = styled('div')`
|
|
325
|
+
display: grid;
|
|
326
|
+
grid-auto-flow: column;
|
|
327
|
+
gap: ${(p)=>p.theme.space.md};
|
|
328
|
+
align-items: center;
|
|
329
|
+
`;
|
|
330
|
+
const SingleValueLabel = styled('div')`
|
|
331
|
+
display: block;
|
|
332
|
+
width: 100%;
|
|
333
|
+
white-space: nowrap;
|
|
334
|
+
overflow: hidden;
|
|
335
|
+
text-overflow: ellipsis;
|
|
336
|
+
`;
|
|
337
|
+
function Menu(props) {
|
|
338
|
+
const { children, ...otherProps } = props;
|
|
339
|
+
return /*#__PURE__*/ jsx(external_reactSelectWrapper_js_components.Menu, {
|
|
340
|
+
...otherProps,
|
|
341
|
+
children: /*#__PURE__*/ jsxs(PanelProvider, {
|
|
342
|
+
children: [
|
|
343
|
+
children,
|
|
344
|
+
props.selectProps.menuFooter
|
|
345
|
+
]
|
|
346
|
+
})
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
function Select(props) {
|
|
350
|
+
const theme = useTheme();
|
|
351
|
+
const { size, maxMenuWidth, isInsideModal } = props;
|
|
352
|
+
const isSearchable = props.searchable;
|
|
353
|
+
const isDisabled = props.disabled;
|
|
354
|
+
const defaultStyles = useMemo(()=>getStylesConfig({
|
|
355
|
+
theme,
|
|
356
|
+
size,
|
|
357
|
+
maxMenuWidth,
|
|
358
|
+
isInsideModal,
|
|
359
|
+
isSearchable,
|
|
360
|
+
isDisabled
|
|
361
|
+
}), [
|
|
362
|
+
theme,
|
|
363
|
+
size,
|
|
364
|
+
maxMenuWidth,
|
|
365
|
+
isInsideModal,
|
|
366
|
+
isSearchable,
|
|
367
|
+
isDisabled
|
|
368
|
+
]);
|
|
369
|
+
const { creatable, options, clearable, styles, onInputChange, filterOption, ref, inputRef, id, isOpen, onOpenChange, components, controlLeadingItems, dropdownIndicator, menuFooter, loadingMessage, virtualized, ...rest } = props;
|
|
370
|
+
const flatOptions = options.flatMap((option)=>'options' in option ? option.options : [
|
|
371
|
+
option
|
|
372
|
+
]);
|
|
373
|
+
const compare = (a, b)=>{
|
|
374
|
+
if (props.isValueEqual && null != a && null != b) return props.isValueEqual(a, b);
|
|
375
|
+
return a === b;
|
|
376
|
+
};
|
|
377
|
+
const toOption = (val)=>flatOptions.find((option)=>compare(option.value, val)) ?? (creatable && null != val ? {
|
|
378
|
+
value: val,
|
|
379
|
+
label: String(val)
|
|
380
|
+
} : void 0);
|
|
381
|
+
const mappedValue = props.multiple ? props.value.map(toOption).filter((option)=>null != option) : toOption(props.value) ?? null;
|
|
382
|
+
const mappedStyles = styles ? mergeStyles(defaultStyles, styles) : defaultStyles;
|
|
383
|
+
const selectRef = useRef(null);
|
|
384
|
+
useImperativeHandle(ref, ()=>({
|
|
385
|
+
focus: ()=>selectRef.current?.focus(),
|
|
386
|
+
blur: ()=>selectRef.current?.blur()
|
|
387
|
+
}), []);
|
|
388
|
+
const replacedComponents = {
|
|
389
|
+
SingleValue: SingleValue,
|
|
390
|
+
ClearIndicator,
|
|
391
|
+
DropdownIndicator,
|
|
392
|
+
MultiValueRemove,
|
|
393
|
+
LoadingIndicator: SelectSpinner,
|
|
394
|
+
IndicatorSeparator: null,
|
|
395
|
+
Menu,
|
|
396
|
+
Input: SelectInput,
|
|
397
|
+
Control: SelectControl,
|
|
398
|
+
IndicatorsContainer: IndicatorsContainer,
|
|
399
|
+
MultiValueLabel: MultiValueLabel,
|
|
400
|
+
Option: SelectOption,
|
|
401
|
+
...null === dropdownIndicator && {
|
|
402
|
+
DropdownIndicator: null
|
|
403
|
+
},
|
|
404
|
+
...virtualized && {
|
|
405
|
+
MenuList: VirtualizedMenuList
|
|
406
|
+
},
|
|
407
|
+
...loadingMessage && {
|
|
408
|
+
LoadingMessage: ()=>loadingMessage()
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
const filterOptions = createFilter();
|
|
412
|
+
return /*#__PURE__*/ jsx(SelectPicker, {
|
|
413
|
+
filterOption: null === filterOption ? null : (candidate, input)=>(filterOption ?? filterOptions)(candidate.data, input),
|
|
414
|
+
styles: mappedStyles,
|
|
415
|
+
components: replacedComponents,
|
|
416
|
+
creatable: creatable,
|
|
417
|
+
isClearable: clearable,
|
|
418
|
+
backspaceRemovesValue: clearable,
|
|
419
|
+
isMulti: props.multiple,
|
|
420
|
+
isDisabled: isDisabled,
|
|
421
|
+
isSearchable: isSearchable ?? true,
|
|
422
|
+
isOptionDisabled: (option)=>!!option.disabled,
|
|
423
|
+
showDividers: props.showDividers,
|
|
424
|
+
options: options,
|
|
425
|
+
blurInputOnSelect: !props.multiple,
|
|
426
|
+
closeMenuOnSelect: !props.multiple,
|
|
427
|
+
hideSelectedOptions: false,
|
|
428
|
+
tabSelectsValue: false,
|
|
429
|
+
...rest,
|
|
430
|
+
value: mappedValue,
|
|
431
|
+
ref: selectRef,
|
|
432
|
+
inputRef: inputRef,
|
|
433
|
+
inputId: id,
|
|
434
|
+
onInputChange: (input, { action })=>{
|
|
435
|
+
onInputChange?.(input, 'input-change' === action ? 'input' : 'reset');
|
|
436
|
+
},
|
|
437
|
+
menuIsOpen: isOpen,
|
|
438
|
+
onMenuOpen: ()=>onOpenChange?.(true),
|
|
439
|
+
onMenuClose: ()=>onOpenChange?.(false),
|
|
440
|
+
contentComponents: components,
|
|
441
|
+
controlLeadingItems: controlLeadingItems,
|
|
442
|
+
dropdownIndicator: dropdownIndicator,
|
|
443
|
+
menuFooter: menuFooter
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
function SelectPicker({ creatable, ref, ...props }) {
|
|
447
|
+
const Component = creatable ? Creatable : ReactSelect;
|
|
448
|
+
return /*#__PURE__*/ jsx(Component, {
|
|
449
|
+
ref: ref,
|
|
450
|
+
...props,
|
|
451
|
+
menuPlacement: "auto"
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
export { Select };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FormSize } from '../theme/index.js';
|
|
2
|
+
export declare const CheckWrap: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme;
|
|
4
|
+
as?: React.ElementType;
|
|
5
|
+
} & {
|
|
6
|
+
isMultiple: boolean;
|
|
7
|
+
isSelected: boolean;
|
|
8
|
+
size: FormSize;
|
|
9
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { css } from "@emotion/react";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
const CheckWrap = styled('div')`
|
|
4
|
+
display: flex;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
align-items: center;
|
|
7
|
+
width: 1em;
|
|
8
|
+
height: 1.4em;
|
|
9
|
+
|
|
10
|
+
${(p)=>p.isMultiple ? css`
|
|
11
|
+
padding: 1px;
|
|
12
|
+
border: solid 1px ${p.theme.tokens.border.primary};
|
|
13
|
+
background: ${p.theme.tokens.background.primary};
|
|
14
|
+
border-radius: 2px;
|
|
15
|
+
height: 1em;
|
|
16
|
+
margin-top: 2px;
|
|
17
|
+
${p.isSelected && css`
|
|
18
|
+
background: ${p.theme.tokens.background.accent.vibrant};
|
|
19
|
+
border-color: ${p.theme.tokens.border.accent};
|
|
20
|
+
`}
|
|
21
|
+
` : css`
|
|
22
|
+
${p.isSelected && css`
|
|
23
|
+
color: ${p.theme.tokens.content.accent};
|
|
24
|
+
`}
|
|
25
|
+
`}
|
|
26
|
+
`;
|
|
27
|
+
export { CheckWrap };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { CSSObject } from '@emotion/react';
|
|
3
|
+
import type { SelectValue } from '../menu/index.js';
|
|
4
|
+
export type { SelectValue } from '../menu/index.js';
|
|
5
|
+
/** Content components receive public option data, without implementation props. */
|
|
6
|
+
export interface SelectComponents<Option extends SelectValue<any> = SelectValue<any>> {
|
|
7
|
+
Indicators?: React.ComponentType<{
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}> | null;
|
|
10
|
+
MultiValueLabel?: React.ComponentType<{
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
option: Option;
|
|
13
|
+
}>;
|
|
14
|
+
OptionLabel?: React.ComponentType<{
|
|
15
|
+
option: Option;
|
|
16
|
+
}>;
|
|
17
|
+
Value?: React.ComponentType<{
|
|
18
|
+
option: Option;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
type NonArray<T> = T extends readonly unknown[] ? never : T;
|
|
22
|
+
interface SingleUnclearableSelectProps<TValue, TSelection> {
|
|
23
|
+
onChange: (value: NonArray<TSelection>) => void;
|
|
24
|
+
value: NonArray<TValue> | null;
|
|
25
|
+
clearable?: false;
|
|
26
|
+
multiple?: false;
|
|
27
|
+
}
|
|
28
|
+
interface SingleClearableSelectProps<TValue, TSelection> {
|
|
29
|
+
clearable: true;
|
|
30
|
+
onChange: (value: NonArray<TSelection> | null) => void;
|
|
31
|
+
value: NonArray<TValue> | null;
|
|
32
|
+
multiple?: false;
|
|
33
|
+
}
|
|
34
|
+
interface MultipleSelectProps<TValue, TSelection> {
|
|
35
|
+
multiple: true;
|
|
36
|
+
onChange: (value: TSelection[]) => void;
|
|
37
|
+
value: TValue[];
|
|
38
|
+
clearable?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Shared selection rules for selects and form fields. Core Select returns option
|
|
42
|
+
* objects; form fields return raw values, so the callback payload is configurable.
|
|
43
|
+
*/
|
|
44
|
+
export type SelectSelectionProps<TValue, TSelection = TValue> = SingleUnclearableSelectProps<TValue, TSelection> | SingleClearableSelectProps<TValue, TSelection> | MultipleSelectProps<TValue, TSelection>;
|
|
45
|
+
/** The supported imperative operations on a select. */
|
|
46
|
+
export interface SelectHandle {
|
|
47
|
+
blur: () => void;
|
|
48
|
+
focus: () => void;
|
|
49
|
+
}
|
|
50
|
+
interface SelectStyleState {
|
|
51
|
+
isDisabled?: boolean;
|
|
52
|
+
isSelected?: boolean;
|
|
53
|
+
}
|
|
54
|
+
type SelectStyleSlot = 'container' | 'control' | 'groupHeading' | 'input' | 'menu' | 'menuList' | 'menuPortal' | 'multiValue' | 'multiValueLabel' | 'multiValueRemove' | 'option' | 'placeholder' | 'singleValue';
|
|
55
|
+
/** Style overrides receive CSS and selection state, without implementation components. */
|
|
56
|
+
export type StylesConfig<TValue = unknown, TOption extends SelectValue<TValue> = SelectValue<TValue>> = {
|
|
57
|
+
[Slot in SelectStyleSlot]?: (base: CSSObject, state: Slot extends 'option' | 'singleValue' | 'multiValue' | 'multiValueLabel' | 'multiValueRemove' ? SelectStyleState & {
|
|
58
|
+
data: TOption;
|
|
59
|
+
} : Slot extends 'control' | 'container' ? Pick<SelectStyleState, 'isDisabled'> : unknown) => CSSObject;
|
|
60
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Virtualized MenuList for the Select (react-select) component.
|
|
4
|
+
* react-select re-renders every Option on hover/focus changes, which
|
|
5
|
+
* causes ~1s lag with 130+ platform options containing PlatformIcon SVGs.
|
|
6
|
+
* Virtualizing limits mounted components to the visible set.
|
|
7
|
+
*
|
|
8
|
+
* Supports grouped options: react-select renders each group as a single
|
|
9
|
+
* <Group> element wrapping its Option children, which would virtualize as one
|
|
10
|
+
* giant row. Groups are flattened here into heading + option rows instead,
|
|
11
|
+
* with per-row measurement since headings and options differ in height.
|
|
12
|
+
*
|
|
13
|
+
* Implementation detail of the shared Select virtualized prop.
|
|
14
|
+
*/
|
|
15
|
+
import { type Ref } from 'react';
|
|
16
|
+
interface VirtualizedMenuListProps {
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
focusedOption?: unknown;
|
|
19
|
+
innerProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
20
|
+
innerRef?: Ref<HTMLDivElement>;
|
|
21
|
+
maxHeight?: number;
|
|
22
|
+
}
|
|
23
|
+
export declare function VirtualizedMenuList({ children, focusedOption, maxHeight, innerRef, innerProps, }: VirtualizedMenuListProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
24
|
+
export {};
|