@fibery/ui-kit 1.17.1 → 1.19.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/index.ts +1 -1
- package/package.json +29 -23
- package/src/antd/styles.ts +1 -1
- package/src/back-button.tsx +3 -0
- package/src/{Button → button}/actions-button.tsx +2 -2
- package/src/{Button → button}/button-base.tsx +2 -2
- package/src/{Button → button}/button-group.tsx +1 -1
- package/src/{Button → button}/button.tsx +3 -3
- package/src/{Button → button}/icon-button.tsx +1 -0
- package/src/button.tsx +3 -0
- package/src/create-inline-theme.ts +2 -0
- package/src/design-system.ts +1009 -0
- package/src/emoji-picker/app-icon-picker.tsx +2 -2
- package/src/emoji-picker/emoji-picker-content-with-color.tsx +7 -7
- package/src/emoji-picker/emoji-picker.tsx +11 -5
- package/src/emoji-picker/icon-emoji-picker.tsx +2 -2
- package/src/emoji-picker/primitives/category.tsx +2 -2
- package/src/emoji-picker/primitives/content.tsx +3 -2
- package/src/emoji-picker/primitives/emoji.tsx +1 -1
- package/src/emoji-picker/primitives/footer.tsx +1 -1
- package/src/emoji-picker/primitives/header.tsx +1 -1
- package/src/emoji-picker/primitives/layout.ts +1 -1
- package/src/emoji-picker/primitives/search.tsx +2 -2
- package/src/emoji-picker/primitives/skin-tone.tsx +2 -2
- package/src/emoji-picker/stores/lazy-emoji-data-store.tsx +3 -3
- package/src/emoji-picker/stores/lazy-icon-data-store.tsx +1 -1
- package/src/error-alert.tsx +3 -3
- package/src/form-field-loader.tsx +1 -1
- package/src/icons/Icon.tsx +5 -5
- package/src/icons/ast/Activity.ts +1 -1
- package/src/icons/ast/BellFilled.ts +8 -0
- package/src/icons/ast/BellOff.ts +8 -0
- package/src/icons/ast/BellRinging.ts +8 -0
- package/src/icons/ast/Clock.ts +8 -0
- package/src/icons/ast/ClockAlarm.ts +8 -0
- package/src/icons/ast/Copy.ts +1 -1
- package/src/icons/ast/Export.ts +8 -0
- package/src/icons/ast/ExtensionComments.ts +1 -1
- package/src/icons/ast/Favorites.ts +1 -1
- package/src/icons/ast/FavoritesChecked.ts +1 -1
- package/src/icons/ast/FavoritesOff.ts +8 -0
- package/src/icons/ast/GlobeSimple.ts +8 -0
- package/src/icons/ast/Import.ts +8 -0
- package/src/icons/ast/Lab.ts +8 -0
- package/src/icons/ast/Link.ts +8 -0
- package/src/icons/ast/Monitor.ts +8 -0
- package/src/icons/ast/Network.ts +8 -0
- package/src/icons/ast/Pencil.ts +8 -0
- package/src/icons/ast/People.ts +8 -0
- package/src/icons/ast/RicheditorCommentCreate.ts +1 -1
- package/src/icons/ast/RicheditorLinkCreate.ts +1 -1
- package/src/icons/ast/RicheditorOpenLink.ts +1 -1
- package/src/icons/ast/RicheditorUnlink.ts +1 -1
- package/src/icons/ast/ShieldKeyhole.ts +8 -0
- package/src/icons/ast/Success.ts +8 -0
- package/src/icons/ast/Terminal.ts +8 -0
- package/src/icons/ast/TypeUrl.ts +1 -1
- package/src/icons/ast/WarningTriangle.ts +8 -0
- package/src/icons/ast/index.tsx +19 -4
- package/src/icons/{getIconContainerStyle.tsx → get-icon-container-style.tsx} +1 -1
- package/src/icons/react/BellFilled.tsx +12 -0
- package/src/icons/react/BellOff.tsx +12 -0
- package/src/icons/react/BellRinging.tsx +12 -0
- package/src/icons/react/Clock.tsx +12 -0
- package/src/icons/react/ClockAlarm.tsx +12 -0
- package/src/icons/react/Export.tsx +12 -0
- package/src/icons/react/FavoritesOff.tsx +12 -0
- package/src/icons/react/GlobeSimple.tsx +12 -0
- package/src/icons/react/Import.tsx +12 -0
- package/src/icons/react/Lab.tsx +12 -0
- package/src/icons/react/Link.tsx +12 -0
- package/src/icons/react/Monitor.tsx +12 -0
- package/src/icons/react/Network.tsx +12 -0
- package/src/icons/react/Pencil.tsx +12 -0
- package/src/icons/react/People.tsx +12 -0
- package/src/icons/react/ShieldKeyhole.tsx +12 -0
- package/src/icons/react/Success.tsx +12 -0
- package/src/icons/react/Terminal.tsx +12 -0
- package/src/icons/react/WarningTriangle.tsx +12 -0
- package/src/icons/react/index.tsx +19 -4
- package/src/{Item.tsx → item.tsx} +1 -1
- package/src/loaders.tsx +19 -6
- package/src/loading-sausage.tsx +3 -1
- package/src/select/custom-select-partials/clear-indicator.tsx +22 -0
- package/src/select/custom-select-partials/drop-down-indicator.tsx +26 -0
- package/src/select/custom-select-partials/group-heading.tsx +54 -0
- package/src/select/custom-select-partials/menu.tsx +25 -0
- package/src/select/custom-select-partials/no-option-message.tsx +10 -0
- package/src/select/custom-select-partials/option.tsx +65 -0
- package/src/{Select → select}/index.tsx +54 -48
- package/src/{Select → select}/select-in-popover.tsx +5 -5
- package/src/{Select → select}/styles.ts +9 -53
- package/src/{ThemeProvider.tsx → theme-provider.tsx} +11 -1
- package/src/theme-styles.ts +2 -5
- package/src/toast/primitives.tsx +145 -0
- package/src/toast/toast-action.tsx +20 -0
- package/src/toast/toast-queue.tsx +121 -0
- package/src/toast/toast.tsx +114 -0
- package/src/toast/toaster.tsx +72 -0
- package/src/tooltip.tsx +3 -3
- package/src/BackButton.tsx +0 -3
- package/src/Button.tsx +0 -3
- package/src/Select/components.tsx +0 -90
- package/src/designSystem.ts +0 -951
- package/src/icons/ast/AppTemplatesOneColor.ts +0 -8
- package/src/icons/ast/CopyUrl.ts +0 -8
- package/src/icons/ast/FavoritesMenu.ts +0 -8
- package/src/icons/ast/Markdown.ts +0 -8
- package/src/icons/react/AppTemplatesOneColor.tsx +0 -12
- package/src/icons/react/CopyUrl.tsx +0 -12
- package/src/icons/react/FavoritesMenu.tsx +0 -12
- package/src/icons/react/Markdown.tsx +0 -12
- /package/src/{Button → button}/actions-button-compact.tsx +0 -0
- /package/src/{Button/AddButton.tsx → button/add-button.tsx} +0 -0
- /package/src/{Button/BackButton.tsx → button/back-button.tsx} +0 -0
- /package/src/icons/{generateIconFromAst.ts → generate-icon-from-ast.ts} +0 -0
- /package/src/icons/{IconAsPaths.ts → get-paths.ts} +0 -0
- /package/src/icons/{getShiftStyle.ts → get-shift-style.ts} +0 -0
- /package/src/{Pallete.ts → pallete.ts} +0 -0
- /package/src/{Select → select}/select-control-settings-context.tsx +0 -0
- /package/src/{Select → select}/select-loader.tsx +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import RemoveIcon from "../../icons/react/Remove";
|
|
3
|
+
import {ClearIndicatorProps, GroupBase, MultiValueRemoveProps} from "react-select";
|
|
4
|
+
import {Button} from "../../button/button";
|
|
5
|
+
|
|
6
|
+
export function ClearIndicator<
|
|
7
|
+
TOption,
|
|
8
|
+
IsMulti extends boolean = boolean,
|
|
9
|
+
Group extends GroupBase<TOption> = GroupBase<TOption>
|
|
10
|
+
>({
|
|
11
|
+
innerProps,
|
|
12
|
+
selectProps,
|
|
13
|
+
}: ClearIndicatorProps<TOption, IsMulti, Group> | MultiValueRemoveProps<TOption, IsMulti, Group>) {
|
|
14
|
+
if (selectProps.isDisabled) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return (
|
|
18
|
+
<div {...innerProps}>
|
|
19
|
+
<Button borderless Icon={RemoveIcon} disabled={selectProps.isDisabled} size={":button-size/super-small"} />
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import cn from "classnames";
|
|
2
|
+
import {DropdownIndicatorProps} from "react-select";
|
|
3
|
+
import {expanderExpandedStyle} from "../styles";
|
|
4
|
+
import ArrowCollapseVertical from "../../icons/react/ArrowCollapseVertical";
|
|
5
|
+
import {themeVars, transition} from "../../design-system";
|
|
6
|
+
import React from "react";
|
|
7
|
+
import {css} from "@linaria/core";
|
|
8
|
+
import {GroupBase} from "../index";
|
|
9
|
+
|
|
10
|
+
const expanderStyle = css`
|
|
11
|
+
transition: transform ${transition};
|
|
12
|
+
`;
|
|
13
|
+
export function DropdownIndicator<
|
|
14
|
+
TOption,
|
|
15
|
+
IsMulti extends boolean = boolean,
|
|
16
|
+
Group extends GroupBase<TOption> = GroupBase<TOption>
|
|
17
|
+
>(props: DropdownIndicatorProps<TOption, IsMulti, Group>) {
|
|
18
|
+
if (props.selectProps.isDisabled) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return (
|
|
22
|
+
<div className={cn(expanderStyle, props.selectProps.menuIsOpen && expanderExpandedStyle)}>
|
|
23
|
+
<ArrowCollapseVertical color={themeVars.disabledTextColor} />
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {GroupBase} from "../index";
|
|
2
|
+
import {components} from "react-windowed-select";
|
|
3
|
+
import {GroupHeadingProps} from "react-select";
|
|
4
|
+
import {css} from "@linaria/core";
|
|
5
|
+
import {layout, space, textStyles, themeVars} from "../../design-system";
|
|
6
|
+
import React from "react";
|
|
7
|
+
export const groupHeadingNulledStyles = {
|
|
8
|
+
paddingLeft: "",
|
|
9
|
+
paddingRight: "",
|
|
10
|
+
paddingTop: "",
|
|
11
|
+
margin: "",
|
|
12
|
+
...textStyles.small,
|
|
13
|
+
color: "",
|
|
14
|
+
height: layout.menuItemHeight,
|
|
15
|
+
};
|
|
16
|
+
const groupHeadingClass = css`
|
|
17
|
+
white-space: nowrap;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
text-overflow: ellipsis;
|
|
20
|
+
padding: ${space.m + space.xs}px ${space.m}px ${space.l}px ${space.m}px;
|
|
21
|
+
color: ${themeVars.disabledTextColor};
|
|
22
|
+
`;
|
|
23
|
+
const groupDividerContainerStyle = css`
|
|
24
|
+
padding: ${space.l}px 0;
|
|
25
|
+
box-sizing: content-box;
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
const groupDividerStyle = css`
|
|
29
|
+
width: 100%;
|
|
30
|
+
border-top: 1px solid #eeeff1;
|
|
31
|
+
`;
|
|
32
|
+
const GroupDivider = () => (
|
|
33
|
+
<div className={groupDividerContainerStyle}>
|
|
34
|
+
<div className={groupDividerStyle}></div>
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
export function GroupHeading<
|
|
38
|
+
Option,
|
|
39
|
+
IsMulti extends boolean = false,
|
|
40
|
+
Group extends GroupBase<Option> = GroupBase<Option>
|
|
41
|
+
>({children, ...props}: GroupHeadingProps<Option, IsMulti, Group>) {
|
|
42
|
+
if (props.data.separator) {
|
|
43
|
+
return <GroupDivider />;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!children) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return (
|
|
50
|
+
<components.GroupHeading {...props} className={groupHeadingClass}>
|
|
51
|
+
{children}
|
|
52
|
+
</components.GroupHeading>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {GroupBase} from "../index";
|
|
2
|
+
import {CSSObjectWithLabel, MenuProps} from "react-select";
|
|
3
|
+
import cn from "classnames";
|
|
4
|
+
import {components} from "react-windowed-select";
|
|
5
|
+
import {css} from "@linaria/core";
|
|
6
|
+
import {border, themeVars} from "../../design-system";
|
|
7
|
+
|
|
8
|
+
export const MenuNulledStyles: CSSObjectWithLabel = {
|
|
9
|
+
backgroundColor: "",
|
|
10
|
+
borderRadius: "",
|
|
11
|
+
boxShadow: "",
|
|
12
|
+
};
|
|
13
|
+
const MenuRootClass = css`
|
|
14
|
+
color: ${themeVars.disabledTextColor};
|
|
15
|
+
z-index: 1050;
|
|
16
|
+
background-color: ${themeVars.colorBgSelectMenu};
|
|
17
|
+
box-shadow: ${themeVars.shadowSelectMenu};
|
|
18
|
+
border-radius: ${border.radius6}px;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
`;
|
|
21
|
+
export function Menu<Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(
|
|
22
|
+
props: MenuProps<Option, IsMulti, Group>
|
|
23
|
+
) {
|
|
24
|
+
return <components.Menu {...props} className={cn(props.className, MenuRootClass, "react-select-menu")} />;
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, {ReactNode} from "react";
|
|
2
|
+
import {css} from "@linaria/core";
|
|
3
|
+
import {space} from "../../design-system";
|
|
4
|
+
|
|
5
|
+
const NopOptionMessageClass = css`
|
|
6
|
+
padding: ${space.l + 2}px ${space.m}px;
|
|
7
|
+
`;
|
|
8
|
+
export const NoOptionsMessage = ({children}: {children: ReactNode}) => {
|
|
9
|
+
return <div className={NopOptionMessageClass}>{children}</div>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {OptionProps} from "react-select";
|
|
2
|
+
import {components} from "react-windowed-select";
|
|
3
|
+
import {GroupBase} from "../index";
|
|
4
|
+
import {css} from "@linaria/core";
|
|
5
|
+
import {layout, space} from "../../design-system";
|
|
6
|
+
import {ListItemGeneral} from "../../lists/list-item-general";
|
|
7
|
+
import cn from "classnames";
|
|
8
|
+
|
|
9
|
+
export const OptionNulledVitualizedStyles = {
|
|
10
|
+
height: layout.newMenuItemHeight,
|
|
11
|
+
};
|
|
12
|
+
export const OptionNulledStyles = {
|
|
13
|
+
minHeight: layout.newMenuItemHeight,
|
|
14
|
+
paddingLeft: "",
|
|
15
|
+
paddingRight: "",
|
|
16
|
+
paddingTop: "",
|
|
17
|
+
opacity: "",
|
|
18
|
+
fontFamily: "",
|
|
19
|
+
fontSize: "",
|
|
20
|
+
lineHeight: "",
|
|
21
|
+
color: "",
|
|
22
|
+
};
|
|
23
|
+
const OptionRootClass = css`
|
|
24
|
+
padding: 0 ${space.s}px;
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: stretch;
|
|
27
|
+
justify-content: stretch;
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Attention! Do not use this option for potentially long lists inside React Select
|
|
33
|
+
* Why is this option slow? Read here https://the.fibery.io/SoftDev/bug/Select-option-behaviour-is-incorrect-9413
|
|
34
|
+
* */
|
|
35
|
+
export function OptionSlow<
|
|
36
|
+
Option,
|
|
37
|
+
IsMulti extends boolean = false,
|
|
38
|
+
Group extends GroupBase<Option> = GroupBase<Option>
|
|
39
|
+
>({children, ...rest}: OptionProps<Option, IsMulti, Group>) {
|
|
40
|
+
const {isDisabled, isSelected, isFocused} = rest;
|
|
41
|
+
return (
|
|
42
|
+
<components.Option {...rest} className={cn(rest.className, OptionRootClass)}>
|
|
43
|
+
<ListItemGeneral focused={isFocused} selected={isSelected} hovered={false} done={isDisabled}>
|
|
44
|
+
{children}
|
|
45
|
+
</ListItemGeneral>
|
|
46
|
+
</components.Option>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* This option is fast when there is 100+ items but breaks natural focus on hover React Select behaviour. Do not use it for short lists
|
|
52
|
+
* The issue is here https://the.fibery.io/SoftDev/bug/Select-option-behaviour-is-incorrect-9413
|
|
53
|
+
*/
|
|
54
|
+
export function Option<Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>({
|
|
55
|
+
children,
|
|
56
|
+
...rest
|
|
57
|
+
}: OptionProps<Option, IsMulti, Group>) {
|
|
58
|
+
/**
|
|
59
|
+
* This makes this option component fast
|
|
60
|
+
*/
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
62
|
+
const {onMouseOver, onMouseMove, ...truncatedInnerProps} = rest.innerProps;
|
|
63
|
+
const props = Object.assign(rest, {innerProps: truncatedInnerProps});
|
|
64
|
+
return <OptionSlow {...props}>{children}</OptionSlow>;
|
|
65
|
+
}
|
|
@@ -1,39 +1,34 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
import cn from "classnames";
|
|
3
1
|
import {forwardRef, useCallback, useMemo, useState} from "react";
|
|
4
2
|
import BaseSelect, {
|
|
3
|
+
ActionMeta,
|
|
4
|
+
components as reactSelectComponents,
|
|
5
5
|
createFilter,
|
|
6
6
|
GroupBase as ReactSelectGroupBase,
|
|
7
|
-
GroupHeadingProps,
|
|
8
7
|
MenuListProps,
|
|
9
8
|
MenuProps,
|
|
10
9
|
mergeStyles,
|
|
11
10
|
MultiValue,
|
|
12
11
|
MultiValueProps,
|
|
12
|
+
OnChangeValue,
|
|
13
13
|
OptionProps,
|
|
14
14
|
OptionsOrGroups,
|
|
15
15
|
Props as BaseSelectProps,
|
|
16
|
+
PropsValue,
|
|
16
17
|
SingleValue,
|
|
17
18
|
SingleValueProps,
|
|
18
19
|
StylesConfig,
|
|
19
|
-
ActionMeta,
|
|
20
|
-
OnChangeValue,
|
|
21
|
-
PropsValue,
|
|
22
|
-
components as reactSelectComponents,
|
|
23
20
|
} from "react-select";
|
|
24
21
|
import BaseCreatableSelect, {CreatableProps} from "react-select/creatable";
|
|
25
22
|
import WindowedSelect, {components, WindowedMenuList} from "react-windowed-select";
|
|
26
|
-
import {createInlineTheme} from "../designSystem";
|
|
27
|
-
import {useTheme} from "../ThemeProvider";
|
|
28
|
-
import {
|
|
29
|
-
ClearIndicator,
|
|
30
|
-
DropdownIndicator,
|
|
31
|
-
GroupDivider,
|
|
32
|
-
NoOptionsMessage,
|
|
33
|
-
Option as OptionComponent,
|
|
34
|
-
} from "./components";
|
|
35
23
|
import {componentsStyles, singleLineComponentsStyle, virtualizedStyles, zIndexStyles} from "./styles";
|
|
36
24
|
import {useSelectControlSettings} from "./select-control-settings-context";
|
|
25
|
+
import {Option, OptionSlow} from "./custom-select-partials/option";
|
|
26
|
+
import {Menu} from "./custom-select-partials/menu";
|
|
27
|
+
import {GroupHeading} from "./custom-select-partials/group-heading";
|
|
28
|
+
import {DropdownIndicator} from "./custom-select-partials/drop-down-indicator";
|
|
29
|
+
import {NoOptionsMessage} from "./custom-select-partials/no-option-message";
|
|
30
|
+
import {ClearIndicator} from "./custom-select-partials/clear-indicator";
|
|
31
|
+
import {isObject} from "lodash";
|
|
37
32
|
|
|
38
33
|
type GroupBase<T> = ReactSelectGroupBase<T> & {separator?: boolean};
|
|
39
34
|
|
|
@@ -52,32 +47,6 @@ export type {
|
|
|
52
47
|
OnChangeValue,
|
|
53
48
|
PropsValue,
|
|
54
49
|
};
|
|
55
|
-
|
|
56
|
-
function GroupHeading<
|
|
57
|
-
Option = unknown,
|
|
58
|
-
IsMulti extends boolean = boolean,
|
|
59
|
-
Group extends GroupBase<Option> = GroupBase<Option>
|
|
60
|
-
>({children, ...props}: GroupHeadingProps<Option, IsMulti, Group>) {
|
|
61
|
-
if (props.data.separator) {
|
|
62
|
-
return <GroupDivider />;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (!children) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return <components.GroupHeading {...props}>{children}</components.GroupHeading>;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function Menu<Option = unknown, IsMulti extends boolean = boolean, Group extends GroupBase<Option> = GroupBase<Option>>(
|
|
73
|
-
props: MenuProps<Option, IsMulti, Group>
|
|
74
|
-
) {
|
|
75
|
-
const theme = useTheme();
|
|
76
|
-
const {innerProps, className} = props;
|
|
77
|
-
const overridedInnerProps = {...innerProps, style: {...innerProps.style, ...createInlineTheme(theme)}};
|
|
78
|
-
return <components.Menu {...props} innerProps={overridedInnerProps} className={cn(className, "react-select-menu")} />;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
50
|
export {WindowedMenuList};
|
|
82
51
|
|
|
83
52
|
export {components};
|
|
@@ -101,7 +70,6 @@ export type SelectProps<
|
|
|
101
70
|
isCollectionMode?: IsMulti;
|
|
102
71
|
disabled?: boolean;
|
|
103
72
|
};
|
|
104
|
-
|
|
105
73
|
export function SingleRowSelect<
|
|
106
74
|
Option = unknown,
|
|
107
75
|
IsMulti extends boolean = boolean,
|
|
@@ -118,6 +86,23 @@ export function SingleRowSelect<
|
|
|
118
86
|
);
|
|
119
87
|
}
|
|
120
88
|
|
|
89
|
+
const FAST_OPTION_USAGE_THRESHOLD = 200;
|
|
90
|
+
function isGroup<Option, Group extends GroupBase<Option>>(optionOrGroup: Option | Group): optionOrGroup is Group {
|
|
91
|
+
return isObject(optionOrGroup) && "options" in optionOrGroup;
|
|
92
|
+
}
|
|
93
|
+
function countOptions<Option, Group extends GroupBase<Option>>(categorizedOptions?: OptionsOrGroups<Option, Group>) {
|
|
94
|
+
if (!categorizedOptions) {
|
|
95
|
+
return 0;
|
|
96
|
+
}
|
|
97
|
+
return categorizedOptions.reduce<number>((optionsAccumulator, categorizedOption) => {
|
|
98
|
+
if (isGroup<Option, Group>(categorizedOption)) {
|
|
99
|
+
return optionsAccumulator + categorizedOption.options.length;
|
|
100
|
+
} else {
|
|
101
|
+
return optionsAccumulator + 1;
|
|
102
|
+
}
|
|
103
|
+
}, 0);
|
|
104
|
+
}
|
|
105
|
+
|
|
121
106
|
export const Select = forwardRef(function Select<
|
|
122
107
|
Option = unknown,
|
|
123
108
|
IsMulti extends boolean = boolean,
|
|
@@ -140,6 +125,9 @@ export const Select = forwardRef(function Select<
|
|
|
140
125
|
) {
|
|
141
126
|
const {getPopupContainerElement, zIndex} = useSelectControlSettings();
|
|
142
127
|
const [menuOpenState, setMenuOpenState] = useState(rest.defaultMenuIsOpen);
|
|
128
|
+
const optionsCount = useMemo(() => {
|
|
129
|
+
return countOptions<Option, Group>(rest.options);
|
|
130
|
+
}, [rest.options]);
|
|
143
131
|
const onMenuOpenWrapped = useCallback(() => {
|
|
144
132
|
setMenuOpenState(true);
|
|
145
133
|
onMenuOpen && onMenuOpen();
|
|
@@ -191,7 +179,7 @@ export const Select = forwardRef(function Select<
|
|
|
191
179
|
zIndex ? zIndexStyles(zIndex) : {},
|
|
192
180
|
styles,
|
|
193
181
|
] as StylesConfig<Option, IsMulti, Group>[]);
|
|
194
|
-
}, [styles, virtualized]);
|
|
182
|
+
}, [styles, virtualized, zIndex]);
|
|
195
183
|
|
|
196
184
|
return (
|
|
197
185
|
<SelectComponent
|
|
@@ -205,10 +193,16 @@ export const Select = forwardRef(function Select<
|
|
|
205
193
|
backspaceRemovesValue={isCollectionMode}
|
|
206
194
|
tabSelectsValue={false}
|
|
207
195
|
components={{
|
|
208
|
-
Menu,
|
|
196
|
+
Menu: Menu,
|
|
209
197
|
DropdownIndicator,
|
|
210
198
|
ClearIndicator,
|
|
211
|
-
|
|
199
|
+
/*
|
|
200
|
+
Fast Options break option focus on hover behaviour but help with slow React Select performance with large options list.
|
|
201
|
+
This isolates bug for big lists only
|
|
202
|
+
Read Option definition for more info
|
|
203
|
+
bug here: https://the.fibery.io/SoftDev/bug/Select-option-behaviour-is-incorrect-9413
|
|
204
|
+
*/
|
|
205
|
+
Option: optionsCount > FAST_OPTION_USAGE_THRESHOLD ? Option : OptionSlow,
|
|
212
206
|
MultiValueRemove: ClearIndicator,
|
|
213
207
|
NoOptionsMessage,
|
|
214
208
|
GroupHeading,
|
|
@@ -231,8 +225,10 @@ export const Select = forwardRef(function Select<
|
|
|
231
225
|
export const CreatableSelect = forwardRef(CreatableSelectInner) as <
|
|
232
226
|
Option = unknown,
|
|
233
227
|
IsMulti extends boolean = boolean,
|
|
228
|
+
// eslint-disable-next-line no-use-before-define
|
|
234
229
|
Group extends GroupBase<Option> = GroupBase<Option>
|
|
235
230
|
>(
|
|
231
|
+
// eslint-disable-next-line no-use-before-define
|
|
236
232
|
props: CreatableProps<Option, IsMulti, Group> & SelectProps<Option, IsMulti, Group>
|
|
237
233
|
) => ReturnType<typeof CreatableSelectInner>;
|
|
238
234
|
|
|
@@ -249,8 +245,12 @@ export function CreatableSelectInner<
|
|
|
249
245
|
virtualized = true,
|
|
250
246
|
...rest
|
|
251
247
|
}: CreatableProps<Option, IsMulti, Group> & SelectProps<Option, IsMulti, Group>,
|
|
248
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
252
249
|
ref: any
|
|
253
250
|
) {
|
|
251
|
+
const optionsCount = useMemo(() => {
|
|
252
|
+
return countOptions<Option, Group>(rest.options);
|
|
253
|
+
}, [rest.options]);
|
|
254
254
|
return (
|
|
255
255
|
<BaseCreatableSelect
|
|
256
256
|
ref={ref}
|
|
@@ -264,11 +264,17 @@ export function CreatableSelectInner<
|
|
|
264
264
|
backspaceRemovesValue={isCollectionMode}
|
|
265
265
|
tabSelectsValue={false}
|
|
266
266
|
components={{
|
|
267
|
-
Menu,
|
|
267
|
+
Menu: Menu,
|
|
268
268
|
MenuList: virtualized ? WindowedMenuList : reactSelectComponents.MenuList,
|
|
269
269
|
DropdownIndicator,
|
|
270
270
|
ClearIndicator,
|
|
271
|
-
|
|
271
|
+
/*
|
|
272
|
+
Fast Options break option focus on hover behaviour but help with slow React Select performance with large options list.
|
|
273
|
+
This isolates bug for big lists only
|
|
274
|
+
Read Option definition for more info
|
|
275
|
+
bug here: https://the.fibery.io/SoftDev/bug/Select-option-behaviour-is-incorrect-9413
|
|
276
|
+
*/
|
|
277
|
+
Option: optionsCount > FAST_OPTION_USAGE_THRESHOLD ? Option : OptionSlow,
|
|
272
278
|
MultiValueRemove: ClearIndicator,
|
|
273
279
|
NoOptionsMessage,
|
|
274
280
|
GroupHeading,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {css, cx} from "@linaria/core";
|
|
2
|
-
import {border,
|
|
2
|
+
import {border, space, textStyles} from "../design-system";
|
|
3
3
|
import {inputOverrides} from "../antd/styles";
|
|
4
4
|
import React, {
|
|
5
5
|
ComponentType,
|
|
@@ -12,7 +12,7 @@ import React, {
|
|
|
12
12
|
useRef,
|
|
13
13
|
useState,
|
|
14
14
|
} from "react";
|
|
15
|
-
import {Popup} from "../
|
|
15
|
+
import {Popup} from "../popup";
|
|
16
16
|
import {$TSFixMe} from "../tsfixme";
|
|
17
17
|
import {
|
|
18
18
|
combineStyles,
|
|
@@ -38,7 +38,7 @@ const popupClassName = css`
|
|
|
38
38
|
`;
|
|
39
39
|
|
|
40
40
|
const valueClassName = css`
|
|
41
|
-
border-radius: ${
|
|
41
|
+
border-radius: ${border.radius4}px;
|
|
42
42
|
|
|
43
43
|
&:focus {
|
|
44
44
|
outline: none;
|
|
@@ -72,7 +72,7 @@ export const selectInPopupStyles = {
|
|
|
72
72
|
}),
|
|
73
73
|
option: (props: $TSFixMe) => ({
|
|
74
74
|
...props,
|
|
75
|
-
borderRadius: border.
|
|
75
|
+
borderRadius: border.radius4,
|
|
76
76
|
}),
|
|
77
77
|
menu: (props: $TSFixMe) => ({
|
|
78
78
|
...props,
|
|
@@ -81,7 +81,7 @@ export const selectInPopupStyles = {
|
|
|
81
81
|
marginTop: space.s,
|
|
82
82
|
marginBottom: 0,
|
|
83
83
|
boxShadow: "none",
|
|
84
|
-
borderRadius:
|
|
84
|
+
borderRadius: border.radius4,
|
|
85
85
|
}),
|
|
86
86
|
};
|
|
87
87
|
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import {css} from "@linaria/core";
|
|
2
|
-
import {
|
|
3
|
-
import type {StylesConfig, CSSObjectWithLabel, ControlProps} from "react-select";
|
|
2
|
+
import type {ControlProps, CSSObjectWithLabel, StylesConfig} from "react-select";
|
|
4
3
|
import {inputOverrides} from "../antd/styles";
|
|
5
|
-
import {
|
|
4
|
+
import {layout, space, themeVars} from "../design-system";
|
|
5
|
+
import {OptionNulledStyles, OptionNulledVitualizedStyles} from "./custom-select-partials/option";
|
|
6
|
+
import {MenuNulledStyles} from "./custom-select-partials/menu";
|
|
7
|
+
import {groupHeadingNulledStyles} from "./custom-select-partials/group-heading";
|
|
6
8
|
|
|
7
|
-
export const expanderStyle = css`
|
|
8
|
-
${{
|
|
9
|
-
transition: `transform ${transition}`,
|
|
10
|
-
}}
|
|
11
|
-
`;
|
|
12
9
|
export const expanderExpandedStyle = css`
|
|
13
10
|
transform: rotate(180deg);
|
|
14
11
|
`;
|
|
@@ -45,10 +42,7 @@ function createControlStyle({
|
|
|
45
42
|
}
|
|
46
43
|
|
|
47
44
|
export const virtualizedStyles: StylesConfig = {
|
|
48
|
-
option: (
|
|
49
|
-
...provided,
|
|
50
|
-
height: layout.menuItemHeight,
|
|
51
|
-
}),
|
|
45
|
+
option: () => ({...OptionNulledVitualizedStyles, ...OptionNulledStyles}),
|
|
52
46
|
groupHeading: (provided) => ({
|
|
53
47
|
...provided,
|
|
54
48
|
height: layout.menuItemHeight,
|
|
@@ -70,36 +64,7 @@ export const zIndexStyles = (zIndex: number): StylesConfig => ({
|
|
|
70
64
|
});
|
|
71
65
|
|
|
72
66
|
export const componentsStyles: StylesConfig = {
|
|
73
|
-
option: (
|
|
74
|
-
const disabledStyles = {
|
|
75
|
-
cursor: "not-allowed",
|
|
76
|
-
color: themeVars.disabledTextColor,
|
|
77
|
-
};
|
|
78
|
-
const enabledStyles = {
|
|
79
|
-
":hover": {
|
|
80
|
-
backgroundColor: state.isFocused ? themeVars.actionMenuInnerHover : themeVars.actionMenuInnerHover,
|
|
81
|
-
},
|
|
82
|
-
":active": {
|
|
83
|
-
backgroundColor: themeVars.actionMenuInnerHover,
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
return {
|
|
87
|
-
...provided,
|
|
88
|
-
...textStyles.regular,
|
|
89
|
-
minHeight: layout.menuItemHeight,
|
|
90
|
-
paddingLeft: space.l,
|
|
91
|
-
paddingRight: space.l,
|
|
92
|
-
paddingTop: 0,
|
|
93
|
-
paddingBottom: 0,
|
|
94
|
-
margin: 0,
|
|
95
|
-
backgroundColor: state.isFocused ? themeVars.actionMenuInnerHover : themeVars.actionMenuInnerBg,
|
|
96
|
-
cursor: "pointer",
|
|
97
|
-
display: "flex",
|
|
98
|
-
alignItems: "center",
|
|
99
|
-
justifyContent: "stretch",
|
|
100
|
-
...(state.isDisabled ? disabledStyles : enabledStyles),
|
|
101
|
-
};
|
|
102
|
-
},
|
|
67
|
+
option: () => OptionNulledStyles,
|
|
103
68
|
placeholder: (provided) => ({
|
|
104
69
|
...provided,
|
|
105
70
|
color: themeVars.disabledTextColor,
|
|
@@ -140,12 +105,7 @@ export const componentsStyles: StylesConfig = {
|
|
|
140
105
|
multiValueLabel: () => ({}),
|
|
141
106
|
groupHeading: (provided) => ({
|
|
142
107
|
...provided,
|
|
143
|
-
|
|
144
|
-
paddingRight: space.m,
|
|
145
|
-
paddingTop: space.m + space.xs,
|
|
146
|
-
margin: 0,
|
|
147
|
-
...textStyles.small,
|
|
148
|
-
color: themeVars.disabledTextColor,
|
|
108
|
+
...groupHeadingNulledStyles,
|
|
149
109
|
}),
|
|
150
110
|
menuPortal: (provided) => ({
|
|
151
111
|
...provided,
|
|
@@ -153,11 +113,7 @@ export const componentsStyles: StylesConfig = {
|
|
|
153
113
|
}),
|
|
154
114
|
menu: (provided) => ({
|
|
155
115
|
...provided,
|
|
156
|
-
|
|
157
|
-
zIndex: 1050,
|
|
158
|
-
backgroundColor: themeVars.actionMenuInnerBg,
|
|
159
|
-
boxShadow: themeVars.actionMenuShadow as unknown as Property.BoxShadow,
|
|
160
|
-
borderRadius: border.radius6,
|
|
116
|
+
...MenuNulledStyles,
|
|
161
117
|
}),
|
|
162
118
|
container: (provided, state) => ({
|
|
163
119
|
...provided,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import invariant from "invariant";
|
|
2
2
|
import {themeStyles} from "./theme-styles";
|
|
3
3
|
import {createContext, ReactNode, useContext, useEffect, useState} from "react";
|
|
4
|
-
import {colors, getThemeColors, ThemeColors} from "./
|
|
4
|
+
import {colors, getThemeColors, ThemeColors} from "./design-system";
|
|
5
5
|
import {
|
|
6
6
|
subscribeOnThemeMenuPreferenceChange,
|
|
7
7
|
subscribeOnThemeModeChange,
|
|
@@ -51,6 +51,16 @@ export function useThemeMenuPreference(): ThemeMenuPreference {
|
|
|
51
51
|
return themeMenuPreference;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
export function useMenuTheme() {
|
|
55
|
+
const themeMode = useThemeMode();
|
|
56
|
+
return getThemeColors(colors.brandColors.blue, themeMode === "light" ? "light" : "dark");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function MenuThemeProvider({children}: {children: ReactNode}) {
|
|
60
|
+
const theme = useMenuTheme();
|
|
61
|
+
return <ThemeProvider theme={theme}>{children}</ThemeProvider>;
|
|
62
|
+
}
|
|
63
|
+
|
|
54
64
|
export function RootThemeProvider({
|
|
55
65
|
initialThemeMode,
|
|
56
66
|
initialPreference,
|
package/src/theme-styles.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {css} from "@linaria/core";
|
|
2
|
-
import {createInlineTheme, getThemeColors, colors} from "./
|
|
2
|
+
import {createInlineTheme, getThemeColors, colors} from "./design-system";
|
|
3
3
|
const lightTheme = getThemeColors(colors.brandColors.blue, "light");
|
|
4
4
|
const darkTheme = getThemeColors(colors.brandColors.blue, "dark");
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
export const themeStyles = css`
|
|
7
7
|
:global(html) {
|
|
8
8
|
&:root {
|
|
@@ -11,8 +11,5 @@ export const themeStyles = css`
|
|
|
11
11
|
&.dark-theme:root {
|
|
12
12
|
${createInlineTheme(darkTheme, [])}
|
|
13
13
|
}
|
|
14
|
-
&.light-theme-and-dark-menu:root {
|
|
15
|
-
${createInlineTheme(light2Theme, [])}
|
|
16
|
-
}
|
|
17
14
|
}
|
|
18
15
|
`;
|