@fibery/ui-kit 1.36.2 → 1.37.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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/action-badge.tsx +5 -4
- package/src/actions-menu/actions-menu-confirmation.tsx +1 -12
- package/src/actions-menu/actions-menu-item.tsx +1 -1
- package/src/antd/ant-modal.tsx +17 -2
- package/src/antd/input.tsx +4 -3
- package/src/app-icon-with-fallback.tsx +5 -8
- package/src/app-icon-wrapper.tsx +4 -4
- package/src/appIcons.json +20 -0
- package/src/badge.tsx +14 -7
- package/src/beta-badge.tsx +12 -8
- package/src/button/actions-button-compact.tsx +1 -1
- package/src/button/base-button.tsx +2 -1
- package/src/button/button.tsx +89 -2
- package/src/button/icon-button.tsx +4 -2
- package/src/button/select-button.tsx +23 -8
- package/src/card-container.tsx +29 -65
- package/src/card-hidden-link.tsx +52 -0
- package/src/collapsible-section.tsx +13 -3
- package/src/color-picker/index.js +65 -60
- package/src/color-picker/swatch.tsx +28 -14
- package/src/command-menu/index.tsx +2 -2
- package/src/count-badge.tsx +57 -0
- package/src/date-picker/date-range-input.tsx +1 -1
- package/src/date-picker/fake-date-input.tsx +1 -1
- package/src/date-picker/relative-date-picker.tsx +1 -1
- package/src/date-picker/single-date-input.tsx +1 -1
- package/src/date-picker/utils.ts +9 -2
- package/src/design-system.ts +72 -41
- package/src/emoji-picker/emoji-picker-content-with-color.tsx +3 -9
- package/src/emoji-picker/icon-emoji-picker.tsx +75 -69
- package/src/emoji-picker/primitives/header.tsx +1 -0
- package/src/emoji-picker/primitives/search.tsx +12 -13
- package/src/error-alert/error-alert.tsx +19 -7
- package/src/field-app-icon.tsx +29 -0
- package/src/field-container.tsx +4 -2
- package/src/field-icon.tsx +26 -0
- package/src/field-type-icon.tsx +82 -0
- package/src/guide-link.tsx +4 -3
- package/src/hint.tsx +10 -1
- package/src/html-styles.ts +15 -13
- package/src/icons/ast/AiFiberyBuild.ts +8 -0
- package/src/icons/ast/Anthropic.ts +1 -1
- package/src/icons/ast/Apple.ts +8 -0
- package/src/icons/ast/ArrowBottom.ts +1 -1
- package/src/icons/ast/ArrowForward.ts +1 -1
- package/src/icons/ast/ArrowLeft.ts +1 -1
- package/src/icons/ast/ArrowRight.ts +1 -1
- package/src/icons/ast/ArrowTop.ts +1 -1
- package/src/icons/ast/Crosshair.ts +8 -0
- package/src/icons/ast/Document.ts +8 -0
- package/src/icons/ast/EntityCreate.ts +8 -0
- package/src/icons/ast/ExpandAll.ts +8 -0
- package/src/icons/ast/FiberyDesktopApp.ts +8 -0
- package/src/icons/ast/FileDownload.ts +8 -0
- package/src/icons/ast/GraduationCapFilled.ts +8 -0
- package/src/icons/ast/Home.ts +1 -1
- package/src/icons/ast/ImportFilled.ts +8 -0
- package/src/icons/ast/IntegrationsFilled.ts +8 -0
- package/src/icons/ast/LocationEdit.ts +8 -0
- package/src/icons/ast/MessagePlus.ts +8 -0
- package/src/icons/ast/OpenAi.ts +1 -1
- package/src/icons/ast/RicheditorMarkHighlight.ts +8 -0
- package/src/icons/ast/RicheditorMarkStrike.ts +1 -1
- package/src/icons/ast/RicheditorMarkUnderline.ts +1 -1
- package/src/icons/ast/SpaceApp.ts +8 -0
- package/src/icons/ast/SpaceGenerate.ts +8 -0
- package/src/icons/ast/SpaceScratch.ts +8 -0
- package/src/icons/ast/SpaceTemplate.ts +8 -0
- package/src/icons/ast/TableLayout.ts +8 -0
- package/src/icons/ast/TemplatesFilled.ts +8 -0
- package/src/icons/ast/ThumbsDown.ts +8 -0
- package/src/icons/ast/ThumbsUp.ts +8 -0
- package/src/icons/ast/ViewDashboard.ts +8 -0
- package/src/icons/ast/WarningTriangleFilled.ts +8 -0
- package/src/icons/ast/Windows.ts +8 -0
- package/src/icons/ast/index.tsx +25 -0
- package/src/icons/react/AiFiberyBuild.tsx +13 -0
- package/src/icons/react/Apple.tsx +13 -0
- package/src/icons/react/Crosshair.tsx +13 -0
- package/src/icons/react/Document.tsx +13 -0
- package/src/icons/react/EntityCreate.tsx +13 -0
- package/src/icons/react/ExpandAll.tsx +13 -0
- package/src/icons/react/FiberyDesktopApp.tsx +13 -0
- package/src/icons/react/FileDownload.tsx +13 -0
- package/src/icons/react/GraduationCapFilled.tsx +13 -0
- package/src/icons/react/ImportFilled.tsx +13 -0
- package/src/icons/react/IntegrationsFilled.tsx +13 -0
- package/src/icons/react/LocationEdit.tsx +13 -0
- package/src/icons/react/MessagePlus.tsx +13 -0
- package/src/icons/react/RicheditorMarkHighlight.tsx +13 -0
- package/src/icons/react/SpaceApp.tsx +13 -0
- package/src/icons/react/SpaceGenerate.tsx +13 -0
- package/src/icons/react/SpaceScratch.tsx +13 -0
- package/src/icons/react/SpaceTemplate.tsx +13 -0
- package/src/icons/react/TableLayout.tsx +13 -0
- package/src/icons/react/TemplatesFilled.tsx +13 -0
- package/src/icons/react/ThumbsDown.tsx +13 -0
- package/src/icons/react/ThumbsUp.tsx +13 -0
- package/src/icons/react/ViewDashboard.tsx +13 -0
- package/src/icons/react/WarningTriangleFilled.tsx +13 -0
- package/src/icons/react/Windows.tsx +13 -0
- package/src/icons/react/index.tsx +25 -0
- package/src/icons/svg/ai-fibery-build.svg +24 -0
- package/src/icons/svg/anthropic.svg +2 -14
- package/src/icons/svg/apple.svg +4 -0
- package/src/icons/svg/arrow-bottom.svg +1 -1
- package/src/icons/svg/arrow-forward.svg +1 -1
- package/src/icons/svg/arrow-left.svg +1 -1
- package/src/icons/svg/arrow-right.svg +1 -1
- package/src/icons/svg/arrow-top.svg +1 -1
- package/src/icons/svg/crosshair.svg +4 -0
- package/src/icons/svg/document.svg +4 -0
- package/src/icons/svg/entity-create.svg +3 -0
- package/src/icons/svg/expand-all.svg +3 -0
- package/src/icons/svg/fibery-desktop-app.svg +101 -0
- package/src/icons/svg/file-download.svg +4 -0
- package/src/icons/svg/go-to.svg +1 -3
- package/src/icons/svg/graduation-cap-filled.svg +4 -0
- package/src/icons/svg/home.svg +4 -2
- package/src/icons/svg/import-filled.svg +4 -0
- package/src/icons/svg/integrations-filled.svg +4 -0
- package/src/icons/svg/location-edit.svg +13 -0
- package/src/icons/svg/message-plus.svg +4 -0
- package/src/icons/svg/open-ai.svg +2 -7
- package/src/icons/svg/open-as-page.svg +2 -3
- package/src/icons/svg/richeditor/mark/code.svg +4 -5
- package/src/icons/svg/richeditor/mark/em.svg +3 -2
- package/src/icons/svg/richeditor/mark/highlight.svg +3 -0
- package/src/icons/svg/richeditor/mark/strike.svg +3 -2
- package/src/icons/svg/richeditor/mark/strong.svg +3 -2
- package/src/icons/svg/richeditor/mark/underline.svg +4 -2
- package/src/icons/svg/space-app.svg +3 -0
- package/src/icons/svg/space-generate.svg +3 -0
- package/src/icons/svg/space-scratch.svg +3 -0
- package/src/icons/svg/space-template.svg +3 -0
- package/src/icons/svg/table-layout.svg +3 -0
- package/src/icons/svg/templates-filled.svg +6 -0
- package/src/icons/svg/thumbs-down.svg +3 -0
- package/src/icons/svg/thumbs-up.svg +3 -0
- package/src/icons/svg/view-dashboard.svg +5 -0
- package/src/icons/svg/warning-triangle-filled.svg +3 -0
- package/src/icons/svg/windows.svg +15 -0
- package/src/integration-compact-info-button.tsx +3 -1
- package/src/layout-styles.ts +23 -0
- package/src/lists/list-row-surface.tsx +2 -1
- package/src/loaders.tsx +6 -6
- package/src/logo.tsx +16 -9
- package/src/mobile-styles.ts +2 -0
- package/src/new-badge.tsx +4 -7
- package/src/number-input/text-area-auto-sized.tsx +47 -0
- package/src/number-input/text-input-auto-sized.tsx +49 -0
- package/src/palette.ts +50 -50
- package/src/popup/index.tsx +1 -0
- package/src/rich-text-embed-error.tsx +2 -2
- package/src/select/{custom-select-partials → components}/menu.tsx +13 -7
- package/src/select/{custom-select-partials → components}/no-option-message.tsx +0 -1
- package/src/select/constants.ts +1 -0
- package/src/select/index.tsx +136 -145
- package/src/select/select-in-popover.tsx +101 -108
- package/src/select/styles.ts +60 -24
- package/src/shortcut-badge.tsx +1 -0
- package/src/tab-nav/tab-nav.tsx +12 -19
- package/src/theme-provider.tsx +9 -1
- package/src/tooltip-if-overflown.tsx +9 -3
- package/src/unit/index.tsx +9 -1
- package/src/unit/loading-unit-value.tsx +1 -0
- package/src/unit/maybe-unit-value.tsx +3 -3
- package/src/unit/primitive.tsx +58 -42
- package/src/unit/styles.ts +8 -12
- package/src/unit/types.ts +4 -2
- package/src/unit/unit-button-group.tsx +6 -11
- package/src/unit/unit-content.tsx +13 -5
- package/src/unit/unit-with-title.tsx +6 -1
- package/src/unit/unit-with-tooltip.tsx +24 -9
- package/src/use-is-phone.tsx +12 -0
- package/src/workflow-progress-icon.tsx +1 -1
- package/src/number-input/text-area-with-autosize.tsx +0 -91
- package/src/number-input/text-inline-input-with-autosize.tsx +0 -60
- package/src/use-is-phone.ts +0 -5
- /package/src/select/{custom-select-partials → components}/clear-indicator.tsx +0 -0
- /package/src/select/{custom-select-partials → components}/drop-down-indicator.tsx +0 -0
- /package/src/select/{custom-select-partials → components}/group-heading.tsx +0 -0
- /package/src/select/{custom-select-partials → components}/menu-list-virtualized.tsx +0 -0
- /package/src/select/{custom-select-partials → components}/option.tsx +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {css} from "@linaria/core";
|
|
2
|
-
import cn from "classnames";
|
|
1
|
+
import {css, cx} from "@linaria/core";
|
|
3
2
|
import {CSSObjectWithLabel, MenuProps, components} from "react-select";
|
|
4
3
|
import {border, themeVars} from "../../design-system";
|
|
5
4
|
import {GroupBase} from "../index";
|
|
@@ -15,7 +14,8 @@ export const MenuNulledStyles: CSSObjectWithLabel = {
|
|
|
15
14
|
paddingTop: "",
|
|
16
15
|
paddingBottom: "",
|
|
17
16
|
};
|
|
18
|
-
|
|
17
|
+
|
|
18
|
+
const menuCss = css`
|
|
19
19
|
color: ${themeVars.disabledTextColor};
|
|
20
20
|
z-index: 1050;
|
|
21
21
|
background-color: ${themeVars.colorBgSelectMenu};
|
|
@@ -24,8 +24,14 @@ const MenuRootClass = css`
|
|
|
24
24
|
overflow: hidden;
|
|
25
25
|
`;
|
|
26
26
|
|
|
27
|
-
export function Menu<
|
|
28
|
-
props
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
export function Menu<T, U extends boolean, V extends GroupBase<T>>(props: MenuProps<T, U, V>) {
|
|
28
|
+
return <components.Menu {...props} className={cx(menuCss, "react-select-menu", props.className)} />;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const menuTransparentCss = css`
|
|
32
|
+
background-color: ${themeVars.transparent};
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
export function MenuTransparent<T, U extends boolean, V extends GroupBase<T>>(props: MenuProps<T, U, V>) {
|
|
36
|
+
return <components.Menu {...props} className={cx(menuTransparentCss, "react-select-menu", props.className)} />;
|
|
31
37
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const SELECT_IN_POPOVER_VALUE_MAX_HEIGHT = 116;
|
package/src/select/index.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
/* eslint-disable no-use-before-define */
|
|
1
2
|
import {useComposedRefs} from "@fibery/react/src/use-composed-refs";
|
|
2
|
-
import {forwardRef, RefObject, useCallback, useMemo, useRef, useState} from "react";
|
|
3
|
+
import {ForwardedRef, forwardRef, RefObject, useCallback, useMemo, useRef, useState} from "react";
|
|
3
4
|
import BaseSelect, {
|
|
4
5
|
ActionMeta,
|
|
5
|
-
|
|
6
|
+
components as reactSelectComponents,
|
|
6
7
|
createFilter,
|
|
7
8
|
MenuListProps,
|
|
8
9
|
MenuProps,
|
|
@@ -12,32 +13,32 @@ import BaseSelect, {
|
|
|
12
13
|
OnChangeValue,
|
|
13
14
|
OptionProps,
|
|
14
15
|
OptionsOrGroups,
|
|
16
|
+
Props as BaseSelectProps,
|
|
15
17
|
PropsValue,
|
|
16
|
-
components as reactSelectComponents,
|
|
17
18
|
SelectInstance,
|
|
18
19
|
SingleValue,
|
|
19
20
|
SingleValueProps,
|
|
20
21
|
StylesConfig,
|
|
21
22
|
} from "react-select";
|
|
22
23
|
import BaseCreatableSelect, {CreatableProps} from "react-select/creatable";
|
|
23
|
-
import {ClearIndicator, NoClearIndicator} from "./
|
|
24
|
-
import {DropdownIndicator} from "./
|
|
25
|
-
import {GroupHeading} from "./
|
|
26
|
-
import {Menu} from "./
|
|
27
|
-
import {MenuListVirtualized} from "./
|
|
28
|
-
import {NoOptionsMessage} from "./
|
|
29
|
-
import {Option, OptionSlow} from "./
|
|
24
|
+
import {ClearIndicator, NoClearIndicator} from "./components/clear-indicator";
|
|
25
|
+
import {DropdownIndicator} from "./components/drop-down-indicator";
|
|
26
|
+
import {GroupHeading} from "./components/group-heading";
|
|
27
|
+
import {Menu} from "./components/menu";
|
|
28
|
+
import {MenuListVirtualized} from "./components/menu-list-virtualized";
|
|
29
|
+
import {NoOptionsMessage} from "./components/no-option-message";
|
|
30
|
+
import {Option, OptionSlow} from "./components/option";
|
|
30
31
|
import {useSelectControlSettings} from "./select-control-settings-context";
|
|
31
32
|
import {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
makeComponentsStyles,
|
|
34
|
+
makeNonVirtualizedStyles,
|
|
35
|
+
makeSingleLineStyles,
|
|
36
|
+
makeVirtualizedStyles,
|
|
37
|
+
makeZIndexStyles,
|
|
37
38
|
} from "./styles";
|
|
38
39
|
import {countOptions, GroupBase, ReactSelectRefContext} from "./util";
|
|
40
|
+
import _ from "lodash";
|
|
39
41
|
|
|
40
|
-
export {reactSelectComponents as components, MenuListVirtualized};
|
|
41
42
|
export type {
|
|
42
43
|
ActionMeta,
|
|
43
44
|
GroupBase,
|
|
@@ -54,87 +55,124 @@ export type {
|
|
|
54
55
|
StylesConfig,
|
|
55
56
|
};
|
|
56
57
|
|
|
57
|
-
|
|
58
|
+
export {reactSelectComponents as components, MenuListVirtualized, createFilter};
|
|
59
|
+
|
|
58
60
|
function GroupVirtualized() {
|
|
59
61
|
return null;
|
|
60
62
|
}
|
|
61
|
-
export function combineStyles<
|
|
62
|
-
Option,
|
|
63
|
-
IsMulti extends boolean = boolean,
|
|
64
|
-
Group extends GroupBase<Option> = GroupBase<Option>
|
|
65
|
-
>(stylesConfigs: StylesConfig<Option, IsMulti, Group>[]) {
|
|
66
|
-
return stylesConfigs.reduce(mergeStyles, {});
|
|
67
|
-
}
|
|
68
63
|
|
|
69
|
-
export {
|
|
64
|
+
export function combineStyles<T, U extends boolean, V extends GroupBase<T>>(styles: StylesConfig<T, U, V>[]) {
|
|
65
|
+
return styles.reduce(mergeStyles, {});
|
|
66
|
+
}
|
|
70
67
|
|
|
71
|
-
export type SelectProps<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
> = Omit<Omit<Omit<BaseSelectProps<Option, IsMulti, Group>, "isMulti">, "backspaceRemovesValue">, "isDisabled"> & {
|
|
68
|
+
export type SelectProps<T = unknown, U extends boolean = boolean, V extends GroupBase<T> = GroupBase<T>> = Omit<
|
|
69
|
+
Omit<Omit<BaseSelectProps<T, U, V>, "isMulti">, "backspaceRemovesValue">,
|
|
70
|
+
"isDisabled"
|
|
71
|
+
> & {
|
|
76
72
|
virtualized?: boolean;
|
|
77
|
-
isCollectionMode?:
|
|
73
|
+
isCollectionMode?: U;
|
|
78
74
|
disabled?: boolean;
|
|
79
75
|
forbidValuesClearInCollnMode?: boolean;
|
|
80
76
|
};
|
|
81
77
|
|
|
82
|
-
export function SingleRowSelect<
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<Select<Option, IsMulti, Group>
|
|
89
|
-
{...rest}
|
|
90
|
-
styles={combineStyles<Option, IsMulti, Group>([
|
|
91
|
-
singleLineComponentsStyle as unknown as StylesConfig<Option, IsMulti, Group>,
|
|
92
|
-
styles,
|
|
93
|
-
])}
|
|
94
|
-
/>
|
|
95
|
-
);
|
|
78
|
+
export function SingleRowSelect<T = unknown, U extends boolean = boolean, V extends GroupBase<T> = GroupBase<T>>({
|
|
79
|
+
styles = {},
|
|
80
|
+
...rest
|
|
81
|
+
}: SelectProps<T, U, V>) {
|
|
82
|
+
return <Select<T, U, V> {...rest} styles={combineStyles([makeSingleLineStyles(), styles])} />;
|
|
96
83
|
}
|
|
97
84
|
|
|
98
85
|
const FAST_OPTION_USAGE_THRESHOLD = 200;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
86
|
+
|
|
87
|
+
function useSelectComponents<T, U extends boolean, V extends GroupBase<T>>({
|
|
88
|
+
components,
|
|
89
|
+
optionsCount,
|
|
90
|
+
virtualized,
|
|
91
|
+
isCollectionMode,
|
|
92
|
+
forbidValuesClearInCollnMode,
|
|
93
|
+
}: {
|
|
94
|
+
components: SelectProps<T, U, V>["components"];
|
|
95
|
+
optionsCount: number;
|
|
96
|
+
virtualized: boolean;
|
|
97
|
+
isCollectionMode?: U;
|
|
98
|
+
forbidValuesClearInCollnMode?: boolean;
|
|
99
|
+
}) {
|
|
100
|
+
const shouldUseFastOption = optionsCount > FAST_OPTION_USAGE_THRESHOLD;
|
|
101
|
+
const shouldHideMultiValueRemove = isCollectionMode && forbidValuesClearInCollnMode;
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
Menu,
|
|
105
|
+
DropdownIndicator,
|
|
106
|
+
ClearIndicator,
|
|
107
|
+
MultiValueRemove: shouldHideMultiValueRemove ? NoClearIndicator : ClearIndicator,
|
|
108
|
+
NoOptionsMessage,
|
|
109
|
+
GroupHeading,
|
|
110
|
+
Option: shouldUseFastOption ? Option : OptionSlow,
|
|
111
|
+
...components,
|
|
112
|
+
Group: virtualized ? GroupVirtualized : components?.Group ? components.Group : reactSelectComponents.Group,
|
|
113
|
+
MenuList: virtualized
|
|
114
|
+
? MenuListVirtualized
|
|
115
|
+
: components?.MenuList
|
|
116
|
+
? components.MenuList
|
|
117
|
+
: reactSelectComponents.MenuList,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function useSelectStyles<T, U extends boolean, V extends GroupBase<T>>({
|
|
122
|
+
virtualized,
|
|
123
|
+
zIndex,
|
|
124
|
+
styles,
|
|
125
|
+
}: {
|
|
126
|
+
virtualized: boolean;
|
|
127
|
+
zIndex?: number;
|
|
128
|
+
styles?: SelectProps<T, U, V>["styles"];
|
|
129
|
+
}) {
|
|
130
|
+
return useMemo(() => {
|
|
131
|
+
return combineStyles<T, U, V>(
|
|
132
|
+
_.compact([
|
|
133
|
+
makeComponentsStyles<T, U, V>(),
|
|
134
|
+
virtualized ? makeVirtualizedStyles<T, U, V>() : makeNonVirtualizedStyles<T, U, V>(),
|
|
135
|
+
zIndex ? makeZIndexStyles<T, U, V>(zIndex) : null,
|
|
136
|
+
styles,
|
|
137
|
+
])
|
|
138
|
+
);
|
|
139
|
+
}, [styles, virtualized, zIndex]);
|
|
140
|
+
}
|
|
141
|
+
|
|
104
142
|
export const Select = forwardRef(function Select<
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
143
|
+
T = unknown,
|
|
144
|
+
U extends boolean = boolean,
|
|
145
|
+
V extends GroupBase<T> = GroupBase<T>
|
|
108
146
|
>(
|
|
109
147
|
{
|
|
110
148
|
components,
|
|
111
149
|
isCollectionMode,
|
|
112
150
|
menuPortalTarget,
|
|
113
151
|
onKeyDown,
|
|
114
|
-
styles
|
|
152
|
+
styles,
|
|
115
153
|
virtualized = true,
|
|
116
154
|
onMenuOpen,
|
|
117
155
|
onMenuClose,
|
|
118
156
|
onChange,
|
|
119
157
|
forbidValuesClearInCollnMode,
|
|
120
158
|
...rest
|
|
121
|
-
}: SelectProps<
|
|
122
|
-
|
|
123
|
-
forwardedRef: any
|
|
159
|
+
}: SelectProps<T, U, V>,
|
|
160
|
+
forwardedRef: ForwardedRef<SelectInstance<T, U, V>>
|
|
124
161
|
) {
|
|
125
162
|
const {getPopupContainerElement, zIndex} = useSelectControlSettings();
|
|
126
163
|
const [menuOpenState, setMenuOpenState] = useState(rest.defaultMenuIsOpen);
|
|
127
|
-
const optionsCount = useMemo(() =>
|
|
128
|
-
|
|
129
|
-
}, [rest.options]);
|
|
164
|
+
const optionsCount = useMemo(() => countOptions(rest.options), [rest.options]);
|
|
165
|
+
|
|
130
166
|
const onMenuOpenWrapped = useCallback(() => {
|
|
131
167
|
setMenuOpenState(true);
|
|
132
168
|
onMenuOpen && onMenuOpen();
|
|
133
169
|
}, [onMenuOpen]);
|
|
170
|
+
|
|
134
171
|
const onMenuCloseWrapped = useCallback(() => {
|
|
135
172
|
setMenuOpenState(false);
|
|
136
173
|
onMenuClose && onMenuClose();
|
|
137
174
|
}, [onMenuClose]);
|
|
175
|
+
|
|
138
176
|
const handleKeyDown: React.KeyboardEventHandler<HTMLInputElement> = useCallback(
|
|
139
177
|
(e) => {
|
|
140
178
|
switch (e.key) {
|
|
@@ -168,20 +206,23 @@ export const Select = forwardRef(function Select<
|
|
|
168
206
|
},
|
|
169
207
|
[onKeyDown, menuOpenState]
|
|
170
208
|
);
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
componentsStyles,
|
|
174
|
-
virtualized ? virtualizedStyles : nonVirtualizedStyles,
|
|
175
|
-
zIndex ? zIndexStyles(zIndex) : {},
|
|
176
|
-
styles,
|
|
177
|
-
] as StylesConfig<Option, IsMulti, Group>[]);
|
|
178
|
-
}, [styles, virtualized, zIndex]);
|
|
179
|
-
const contextRef = useRef<SelectInstance<Option, IsMulti, Group> | null>(null);
|
|
209
|
+
|
|
210
|
+
const contextRef = useRef<SelectInstance<T, U, V> | null>(null);
|
|
180
211
|
const combined = useComposedRefs(forwardedRef, contextRef);
|
|
181
212
|
|
|
213
|
+
const selectComponents = useSelectComponents({
|
|
214
|
+
components,
|
|
215
|
+
optionsCount,
|
|
216
|
+
virtualized,
|
|
217
|
+
isCollectionMode,
|
|
218
|
+
forbidValuesClearInCollnMode,
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
const combinedStyles = useSelectStyles({virtualized, zIndex, styles});
|
|
222
|
+
|
|
182
223
|
return (
|
|
183
224
|
<ReactSelectRefContext.Provider value={contextRef as RefObject<SelectInstance>}>
|
|
184
|
-
<BaseSelect<
|
|
225
|
+
<BaseSelect<T, U, V>
|
|
185
226
|
ref={combined}
|
|
186
227
|
// There are places, where it is useful to override menuPortalTarget globally for all selects.
|
|
187
228
|
// When you are already in some popup. e.g. user input in buttons, relation filter popover.
|
|
@@ -191,29 +232,7 @@ export const Select = forwardRef(function Select<
|
|
|
191
232
|
isMulti={isCollectionMode}
|
|
192
233
|
backspaceRemovesValue={isCollectionMode && !forbidValuesClearInCollnMode}
|
|
193
234
|
tabSelectsValue={false}
|
|
194
|
-
components={
|
|
195
|
-
Menu: Menu,
|
|
196
|
-
DropdownIndicator,
|
|
197
|
-
ClearIndicator,
|
|
198
|
-
/*
|
|
199
|
-
Fast Options break option focus on hover behaviour but help with slow React Select performance with large options list.
|
|
200
|
-
This isolates bug for big lists only
|
|
201
|
-
Read Option definition for more info
|
|
202
|
-
bug here: https://the.fibery.io/SoftDev/bug/Select-option-behaviour-is-incorrect-9413
|
|
203
|
-
*/
|
|
204
|
-
MultiValueRemove: isCollectionMode && forbidValuesClearInCollnMode ? NoClearIndicator : ClearIndicator,
|
|
205
|
-
NoOptionsMessage,
|
|
206
|
-
GroupHeading,
|
|
207
|
-
Option: optionsCount > FAST_OPTION_USAGE_THRESHOLD ? Option : OptionSlow,
|
|
208
|
-
...components,
|
|
209
|
-
//Using dummy for virtualized lists. Virtualized lists render Groups differently (look MenuListVirtualized).
|
|
210
|
-
Group: virtualized ? GroupVirtualized : components?.Group ? components.Group : reactSelectComponents.Group,
|
|
211
|
-
MenuList: virtualized
|
|
212
|
-
? MenuListVirtualized
|
|
213
|
-
: components?.MenuList
|
|
214
|
-
? components.MenuList
|
|
215
|
-
: reactSelectComponents.MenuList,
|
|
216
|
-
}}
|
|
235
|
+
components={selectComponents}
|
|
217
236
|
{...rest}
|
|
218
237
|
onKeyDown={handleKeyDown}
|
|
219
238
|
onMenuOpen={onMenuOpenWrapped}
|
|
@@ -223,49 +242,34 @@ export const Select = forwardRef(function Select<
|
|
|
223
242
|
/>
|
|
224
243
|
</ReactSelectRefContext.Provider>
|
|
225
244
|
);
|
|
226
|
-
// eslint-disable-next-line no-use-before-define
|
|
227
245
|
}) as <Option = unknown, IsMulti extends boolean = boolean, Group extends GroupBase<Option> = GroupBase<Option>>(
|
|
228
|
-
// eslint-disable-next-line
|
|
246
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
229
247
|
props: SelectProps<Option, IsMulti, Group> & {ref?: any}
|
|
230
248
|
) => JSX.Element;
|
|
231
249
|
|
|
232
|
-
|
|
233
|
-
Option = unknown,
|
|
234
|
-
IsMulti extends boolean = boolean,
|
|
235
|
-
// eslint-disable-next-line no-use-before-define
|
|
236
|
-
Group extends GroupBase<Option> = GroupBase<Option>
|
|
237
|
-
>(
|
|
238
|
-
// eslint-disable-next-line no-use-before-define
|
|
239
|
-
props: CreatableProps<Option, IsMulti, Group> & SelectProps<Option, IsMulti, Group>
|
|
240
|
-
) => ReturnType<typeof CreatableSelectInner>;
|
|
241
|
-
|
|
242
|
-
export function CreatableSelectInner<
|
|
243
|
-
Option = unknown,
|
|
244
|
-
IsMulti extends boolean = boolean,
|
|
245
|
-
Group extends GroupBase<Option> = GroupBase<Option>
|
|
246
|
-
>(
|
|
250
|
+
function CreatableSelectInner<T = unknown, U extends boolean = boolean, V extends GroupBase<T> = GroupBase<T>>(
|
|
247
251
|
{
|
|
248
252
|
components,
|
|
249
253
|
isCollectionMode,
|
|
250
254
|
menuPortalTarget,
|
|
251
255
|
styles = {},
|
|
252
256
|
virtualized = true,
|
|
257
|
+
forbidValuesClearInCollnMode,
|
|
253
258
|
...rest
|
|
254
|
-
}: CreatableProps<
|
|
255
|
-
|
|
256
|
-
ref: any
|
|
259
|
+
}: CreatableProps<T, U, V> & SelectProps<T, U, V>,
|
|
260
|
+
ref: ForwardedRef<SelectInstance<T, U, V>>
|
|
257
261
|
) {
|
|
258
|
-
const optionsCount = useMemo(() =>
|
|
259
|
-
|
|
260
|
-
|
|
262
|
+
const optionsCount = useMemo(() => countOptions(rest.options), [rest.options]);
|
|
263
|
+
|
|
264
|
+
const selectComponents = useSelectComponents({
|
|
265
|
+
components,
|
|
266
|
+
optionsCount,
|
|
267
|
+
virtualized,
|
|
268
|
+
isCollectionMode,
|
|
269
|
+
forbidValuesClearInCollnMode,
|
|
270
|
+
});
|
|
261
271
|
|
|
262
|
-
const combinedStyles =
|
|
263
|
-
return combineStyles<Option, IsMulti, Group>([
|
|
264
|
-
componentsStyles,
|
|
265
|
-
virtualized ? virtualizedStyles : nonVirtualizedStyles,
|
|
266
|
-
styles,
|
|
267
|
-
] as StylesConfig<Option, IsMulti, Group>[]);
|
|
268
|
-
}, [styles, virtualized]);
|
|
272
|
+
const combinedStyles = useSelectStyles({virtualized, styles});
|
|
269
273
|
|
|
270
274
|
return (
|
|
271
275
|
<BaseCreatableSelect
|
|
@@ -276,30 +280,17 @@ export function CreatableSelectInner<
|
|
|
276
280
|
isMulti={isCollectionMode}
|
|
277
281
|
backspaceRemovesValue={isCollectionMode}
|
|
278
282
|
tabSelectsValue={false}
|
|
279
|
-
components={
|
|
280
|
-
Menu: Menu,
|
|
281
|
-
DropdownIndicator,
|
|
282
|
-
ClearIndicator,
|
|
283
|
-
/*
|
|
284
|
-
Fast Options break option focus on hover behaviour but help with slow React Select performance with large options list.
|
|
285
|
-
This isolates bug for big lists only
|
|
286
|
-
Read Option definition for more info
|
|
287
|
-
bug here: https://the.fibery.io/SoftDev/bug/Select-option-behaviour-is-incorrect-9413
|
|
288
|
-
*/
|
|
289
|
-
MultiValueRemove: ClearIndicator,
|
|
290
|
-
NoOptionsMessage,
|
|
291
|
-
GroupHeading,
|
|
292
|
-
Option: optionsCount > FAST_OPTION_USAGE_THRESHOLD ? Option : OptionSlow,
|
|
293
|
-
...components,
|
|
294
|
-
Group: virtualized ? GroupVirtualized : components?.Group ? components.Group : reactSelectComponents.Group,
|
|
295
|
-
MenuList: virtualized
|
|
296
|
-
? MenuListVirtualized
|
|
297
|
-
: components?.MenuList
|
|
298
|
-
? components.MenuList
|
|
299
|
-
: reactSelectComponents.MenuList,
|
|
300
|
-
}}
|
|
283
|
+
components={selectComponents}
|
|
301
284
|
{...rest}
|
|
302
285
|
isDisabled={rest.disabled}
|
|
303
286
|
/>
|
|
304
287
|
);
|
|
305
288
|
}
|
|
289
|
+
|
|
290
|
+
export const CreatableSelect = forwardRef(CreatableSelectInner) as <
|
|
291
|
+
T = unknown,
|
|
292
|
+
U extends boolean = boolean,
|
|
293
|
+
V extends GroupBase<T> = GroupBase<T>
|
|
294
|
+
>(
|
|
295
|
+
props: CreatableProps<T, U, V> & SelectProps<T, U, V>
|
|
296
|
+
) => ReturnType<typeof CreatableSelectInner>;
|