@fibery/ui-kit 1.17.0 → 1.18.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 +26 -21
- package/src/Button/actions-button.tsx +2 -2
- package/src/Button/button-base.tsx +2 -2
- package/src/Button/button-group.tsx +1 -1
- package/src/Button/button.tsx +3 -3
- package/src/Button/icon-button.tsx +1 -0
- 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 +92 -0
- package/src/Select/index.tsx +18 -47
- package/src/Select/select-in-popover.tsx +2 -2
- package/src/Select/styles.ts +11 -53
- package/src/antd/styles.ts +1 -1
- package/src/back-button.tsx +3 -0
- package/src/create-inline-theme.ts +2 -0
- package/src/design-system.ts +961 -0
- package/src/emoji-picker/app-icon-picker.tsx +2 -2
- package/src/emoji-picker/emoji-picker-content-with-color.tsx +4 -4
- 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 +6 -3
- 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 +1 -1
- package/src/emoji-picker/primitives/skin-tone.tsx +1 -1
- 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 +2 -2
- package/src/form-field-loader.tsx +1 -1
- package/src/icons/Icon.tsx +4 -4
- 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/Export.ts +8 -0
- 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/Network.ts +8 -0
- package/src/icons/ast/Pencil.ts +8 -0
- package/src/icons/ast/People.ts +8 -0
- 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/Terminal.ts +8 -0
- package/src/icons/ast/TypeUrl.ts +1 -1
- package/src/icons/ast/index.tsx +14 -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/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/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/Terminal.tsx +12 -0
- package/src/icons/react/index.tsx +14 -4
- package/src/{Item.tsx → item.tsx} +1 -1
- package/src/loaders.tsx +19 -6
- package/src/loading-sausage.tsx +3 -1
- package/src/{ThemeProvider.tsx → theme-provider.tsx} +11 -1
- package/src/theme-styles.ts +2 -5
- package/src/toast/index.tsx +47 -0
- package/src/toast/primitives.tsx +140 -0
- package/src/tooltip.tsx +3 -3
- package/src/BackButton.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/{AddButton.tsx → add-button.tsx} +0 -0
- /package/src/Button/{BackButton.tsx → back-button.tsx} +0 -0
- /package/src/{Button.tsx → 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/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./src/
|
|
1
|
+
export * from "./src/design-system";
|
package/package.json
CHANGED
|
@@ -1,40 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/ui-kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"main": "index.ts",
|
|
5
5
|
"private": false,
|
|
6
6
|
"files": [
|
|
7
7
|
"src/antd/styles.ts",
|
|
8
|
-
"src/
|
|
9
|
-
"src/
|
|
8
|
+
"src/button.tsx",
|
|
9
|
+
"src/design-system.ts",
|
|
10
10
|
"src/theme-styles.ts",
|
|
11
11
|
"src/theme-settings.ts",
|
|
12
12
|
"src/media-query-utils.ts",
|
|
13
13
|
"src/create-inline-theme.ts",
|
|
14
14
|
"src/form-field-loader.tsx",
|
|
15
|
-
"src/
|
|
16
|
-
"src/
|
|
15
|
+
"src/theme-provider.tsx",
|
|
16
|
+
"src/item.tsx",
|
|
17
17
|
"src/loaders.tsx",
|
|
18
18
|
"src/loading-sausage.tsx",
|
|
19
19
|
"src/icons/**/*.ts*",
|
|
20
20
|
"src/Select",
|
|
21
21
|
"src/error-alert.tsx",
|
|
22
|
-
"src/
|
|
22
|
+
"src/pallete.ts",
|
|
23
23
|
"src/tooltip.tsx",
|
|
24
|
-
"src/
|
|
24
|
+
"src/back-button.tsx",
|
|
25
25
|
"src/Button",
|
|
26
26
|
"src/emoji-picker/**/*.ts*",
|
|
27
|
+
"src/toast/**/*.ts*",
|
|
27
28
|
"src/a11y-color.ts"
|
|
28
29
|
],
|
|
29
30
|
"license": "UNLICENSED",
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@linaria/core": "
|
|
32
|
-
"@linaria/react": "
|
|
32
|
+
"@linaria/core": "5.0.1",
|
|
33
|
+
"@linaria/react": "5.0.1",
|
|
33
34
|
"@popperjs/core": "2.11.6",
|
|
34
|
-
"@radix-ui/react-collapsible": "1.0.
|
|
35
|
-
"@radix-ui/react-context-menu": "2.1.
|
|
36
|
-
"@radix-ui/react-dropdown-menu": "2.0.
|
|
37
|
-
"@radix-ui/react-
|
|
35
|
+
"@radix-ui/react-collapsible": "1.0.3",
|
|
36
|
+
"@radix-ui/react-context-menu": "2.1.5",
|
|
37
|
+
"@radix-ui/react-dropdown-menu": "2.0.6",
|
|
38
|
+
"@radix-ui/react-toast": "1.1.5",
|
|
39
|
+
"@radix-ui/react-tooltip": "1.0.7",
|
|
40
|
+
"@types/d3-shape": "^3.1.3",
|
|
41
|
+
"@types/react-select-country-list": "^2.2.1",
|
|
42
|
+
"@types/setimmediate": "^1.0.2",
|
|
38
43
|
"@types/ua-parser-js": "0.7.36",
|
|
39
44
|
"antd": "4.24.7",
|
|
40
45
|
"chroma-js": "2.1.2",
|
|
@@ -61,9 +66,9 @@
|
|
|
61
66
|
"react-windowed-select": "5.0.0",
|
|
62
67
|
"screenfull": "6.0.1",
|
|
63
68
|
"ua-parser-js": "0.7.24",
|
|
64
|
-
"@fibery/
|
|
65
|
-
"@fibery/
|
|
66
|
-
"@fibery/react": "1.0
|
|
69
|
+
"@fibery/helpers": "1.2.0",
|
|
70
|
+
"@fibery/emoji-data": "2.2.0",
|
|
71
|
+
"@fibery/react": "1.1.0"
|
|
67
72
|
},
|
|
68
73
|
"peerDependencies": {
|
|
69
74
|
"react": "^18.2.0",
|
|
@@ -72,7 +77,7 @@
|
|
|
72
77
|
"devDependencies": {
|
|
73
78
|
"@babel/core": "7.20.5",
|
|
74
79
|
"@babel/runtime": "7.20.6",
|
|
75
|
-
"@linaria/babel-preset": "
|
|
80
|
+
"@linaria/babel-preset": "5.0.3",
|
|
76
81
|
"@testing-library/dom": "8.19.1",
|
|
77
82
|
"@testing-library/jest-dom": "5.16.5",
|
|
78
83
|
"@testing-library/react": "13.4.0",
|
|
@@ -95,8 +100,8 @@
|
|
|
95
100
|
"svgo": "2.8.0",
|
|
96
101
|
"typescript": "5.1.6",
|
|
97
102
|
"unist-util-reduce": "0.2.2",
|
|
98
|
-
"@fibery/babel-preset": "7.
|
|
99
|
-
"@fibery/eslint-config": "8.
|
|
103
|
+
"@fibery/babel-preset": "7.3.0",
|
|
104
|
+
"@fibery/eslint-config": "8.4.0"
|
|
100
105
|
},
|
|
101
106
|
"jest": {
|
|
102
107
|
"testEnvironment": "jsdom",
|
|
@@ -124,8 +129,8 @@
|
|
|
124
129
|
},
|
|
125
130
|
"scripts": {
|
|
126
131
|
"test": "TZ=Europe/Minsk jest",
|
|
127
|
-
"test:ci": "
|
|
128
|
-
"test:coverage": "
|
|
132
|
+
"test:ci": "pnpm run test --reporters=default --reporters=jest-junit",
|
|
133
|
+
"test:coverage": "pnpm run test --coverage --coverageDirectory=${JEST_COVERAGE_RESULT_DIR:-$(pwd)}/coverage/ui-kit --reporters=default --reporters=jest-junit",
|
|
129
134
|
"lint": "eslint .",
|
|
130
135
|
"generate-icons": "node scripts/generate-icons.mjs"
|
|
131
136
|
}
|
|
@@ -2,7 +2,7 @@ import {IconButton, IconButtonProps} from "./icon-button";
|
|
|
2
2
|
import MoreCompact from "../icons/react/MoreCompact";
|
|
3
3
|
import {forwardRef} from "react";
|
|
4
4
|
import {css} from "@linaria/core";
|
|
5
|
-
import {border, themeVars} from "../
|
|
5
|
+
import {border, themeVars} from "../design-system";
|
|
6
6
|
|
|
7
7
|
export const ActionsButton = forwardRef<HTMLButtonElement, IconButtonProps>(function ActionsButtonComponent(
|
|
8
8
|
{...rest},
|
|
@@ -19,7 +19,7 @@ export const ActionsButton = forwardRef<HTMLButtonElement, IconButtonProps>(func
|
|
|
19
19
|
export const actionButtonInlineStyle = css`
|
|
20
20
|
background-color: ${themeVars.actionMenuButtonColor};
|
|
21
21
|
box-shadow: ${themeVars.entityCardShadow};
|
|
22
|
-
border-radius: ${border.radius6};
|
|
22
|
+
border-radius: ${border.radius6}px;
|
|
23
23
|
|
|
24
24
|
.Button:hover {
|
|
25
25
|
background-color: ${themeVars.actionMenuButtonHoverColor} !important;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {styled} from "@linaria/react";
|
|
2
2
|
import {ComponentPropsWithoutRef, forwardRef} from "react";
|
|
3
|
-
import {border, colors, fontWeight, getDarkenColor, getOpacities, opacity, ThemeColors} from "../
|
|
4
|
-
import {useTheme} from "../
|
|
3
|
+
import {border, colors, fontWeight, getDarkenColor, getOpacities, opacity, ThemeColors} from "../design-system";
|
|
4
|
+
import {useTheme} from "../theme-provider";
|
|
5
5
|
|
|
6
6
|
export const getMainColor = ({color, dangerous, theme}: {color?: string; dangerous?: boolean; theme: ThemeColors}) => {
|
|
7
7
|
if (color) {
|
package/src/Button/button.tsx
CHANGED
|
@@ -4,9 +4,9 @@ import {styled} from "@linaria/react";
|
|
|
4
4
|
import cx from "classnames";
|
|
5
5
|
import _ from "lodash";
|
|
6
6
|
import React, {forwardRef} from "react";
|
|
7
|
-
import {Item} from "../
|
|
8
|
-
import {useTheme} from "../
|
|
9
|
-
import {border, colors, getOpacities, opacity, space, textStyles} from "../
|
|
7
|
+
import {Item} from "../item";
|
|
8
|
+
import {useTheme} from "../theme-provider";
|
|
9
|
+
import {border, colors, getOpacities, opacity, space, textStyles} from "../design-system";
|
|
10
10
|
import {IconBaseProps} from "../icons/types";
|
|
11
11
|
import {Spinner} from "../loaders";
|
|
12
12
|
import {ButtonBase, ButtonBaseProps, buttonBorderWidth, getMainColor, getTextColor} from "./button-base";
|
|
@@ -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,92 @@
|
|
|
1
|
+
import {OptionProps} from "react-select";
|
|
2
|
+
import {components} from "react-windowed-select";
|
|
3
|
+
import {GroupBase} from "../index";
|
|
4
|
+
import {css, cx} from "@linaria/core";
|
|
5
|
+
import {border, layout, space, textStyles, themeVars, transition} from "../../design-system";
|
|
6
|
+
import {useMemo} from "react";
|
|
7
|
+
|
|
8
|
+
export const OptionNulledStyles = {
|
|
9
|
+
height: layout.menuItemHeight,
|
|
10
|
+
};
|
|
11
|
+
const OptionWrapperClass = css`
|
|
12
|
+
max-width: 100%;
|
|
13
|
+
flex-basis: 100%;
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
align-content: center;
|
|
17
|
+
${{...textStyles.regular}};
|
|
18
|
+
color: ${themeVars.textColor};
|
|
19
|
+
background: ${themeVars.colorBgSelectOptionDefault};
|
|
20
|
+
border-radius: ${border.radius6}px;
|
|
21
|
+
padding: 0 ${space.s}px;
|
|
22
|
+
column-gap: ${space.xs}px;
|
|
23
|
+
transition: background-color ${transition}, color ${transition};
|
|
24
|
+
`;
|
|
25
|
+
const OptionRootClass = css`
|
|
26
|
+
padding: 0 ${space.s}px ${space.xxs}px;
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: stretch;
|
|
29
|
+
justify-content: stretch;
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
&:hover {
|
|
32
|
+
.${OptionWrapperClass} {
|
|
33
|
+
background: ${themeVars.colorBgSelectOptionDefaultHover};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
const DisabledOptionClass = css`
|
|
39
|
+
cursor: not-allowed;
|
|
40
|
+
.${OptionWrapperClass} {
|
|
41
|
+
> * {
|
|
42
|
+
opacity: ${themeVars.opacitySelectOptionDisabled};
|
|
43
|
+
}
|
|
44
|
+
background: ${themeVars.colorBgSelectOptionDisabled};
|
|
45
|
+
}
|
|
46
|
+
&:hover {
|
|
47
|
+
.${OptionWrapperClass} {
|
|
48
|
+
background: ${themeVars.colorBgSelectOptionDisabled};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
const SelectedOptionClass = css`
|
|
53
|
+
cursor: default;
|
|
54
|
+
.${OptionWrapperClass} {
|
|
55
|
+
background: ${themeVars.colorBgSelectOptionSelected};
|
|
56
|
+
}
|
|
57
|
+
&:hover {
|
|
58
|
+
.${OptionWrapperClass} {
|
|
59
|
+
background: ${themeVars.colorBgSelectOptionSelectedHover};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
&.${DisabledOptionClass} {
|
|
63
|
+
background: ${themeVars.colorBgSelectOptionSelectedDisabled};
|
|
64
|
+
&:hover {
|
|
65
|
+
background: ${themeVars.colorBgSelectOptionSelectedDisabled};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
`;
|
|
69
|
+
export function Option<Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(
|
|
70
|
+
props: OptionProps<Option, IsMulti, Group>
|
|
71
|
+
) {
|
|
72
|
+
const {children, ...rest} = props;
|
|
73
|
+
const {isDisabled, isFocused} = rest;
|
|
74
|
+
const className = useMemo(
|
|
75
|
+
() =>
|
|
76
|
+
cx(
|
|
77
|
+
rest.innerProps.className,
|
|
78
|
+
OptionRootClass,
|
|
79
|
+
isFocused && SelectedOptionClass, //do not use isSelected as flag to determine if item is selected. It is not always true, bug
|
|
80
|
+
isDisabled && DisabledOptionClass
|
|
81
|
+
),
|
|
82
|
+
[rest.innerProps.className, isDisabled, isFocused]
|
|
83
|
+
);
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
85
|
+
const {onMouseMove, onMouseOver, ...truncatedProps} = rest.innerProps;
|
|
86
|
+
const newProps = Object.assign(rest, {innerProps: truncatedProps});
|
|
87
|
+
return (
|
|
88
|
+
<components.Option {...newProps} className={className}>
|
|
89
|
+
<div className={OptionWrapperClass}>{children}</div>
|
|
90
|
+
</components.Option>
|
|
91
|
+
);
|
|
92
|
+
}
|
package/src/Select/index.tsx
CHANGED
|
@@ -1,39 +1,33 @@
|
|
|
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} 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";
|
|
37
31
|
|
|
38
32
|
type GroupBase<T> = ReactSelectGroupBase<T> & {separator?: boolean};
|
|
39
33
|
|
|
@@ -52,32 +46,6 @@ export type {
|
|
|
52
46
|
OnChangeValue,
|
|
53
47
|
PropsValue,
|
|
54
48
|
};
|
|
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
49
|
export {WindowedMenuList};
|
|
82
50
|
|
|
83
51
|
export {components};
|
|
@@ -191,7 +159,7 @@ export const Select = forwardRef(function Select<
|
|
|
191
159
|
zIndex ? zIndexStyles(zIndex) : {},
|
|
192
160
|
styles,
|
|
193
161
|
] as StylesConfig<Option, IsMulti, Group>[]);
|
|
194
|
-
}, [styles, virtualized]);
|
|
162
|
+
}, [styles, virtualized, zIndex]);
|
|
195
163
|
|
|
196
164
|
return (
|
|
197
165
|
<SelectComponent
|
|
@@ -205,10 +173,10 @@ export const Select = forwardRef(function Select<
|
|
|
205
173
|
backspaceRemovesValue={isCollectionMode}
|
|
206
174
|
tabSelectsValue={false}
|
|
207
175
|
components={{
|
|
208
|
-
Menu,
|
|
176
|
+
Menu: Menu,
|
|
209
177
|
DropdownIndicator,
|
|
210
178
|
ClearIndicator,
|
|
211
|
-
Option
|
|
179
|
+
Option,
|
|
212
180
|
MultiValueRemove: ClearIndicator,
|
|
213
181
|
NoOptionsMessage,
|
|
214
182
|
GroupHeading,
|
|
@@ -231,8 +199,10 @@ export const Select = forwardRef(function Select<
|
|
|
231
199
|
export const CreatableSelect = forwardRef(CreatableSelectInner) as <
|
|
232
200
|
Option = unknown,
|
|
233
201
|
IsMulti extends boolean = boolean,
|
|
202
|
+
// eslint-disable-next-line no-use-before-define
|
|
234
203
|
Group extends GroupBase<Option> = GroupBase<Option>
|
|
235
204
|
>(
|
|
205
|
+
// eslint-disable-next-line no-use-before-define
|
|
236
206
|
props: CreatableProps<Option, IsMulti, Group> & SelectProps<Option, IsMulti, Group>
|
|
237
207
|
) => ReturnType<typeof CreatableSelectInner>;
|
|
238
208
|
|
|
@@ -249,6 +219,7 @@ export function CreatableSelectInner<
|
|
|
249
219
|
virtualized = true,
|
|
250
220
|
...rest
|
|
251
221
|
}: CreatableProps<Option, IsMulti, Group> & SelectProps<Option, IsMulti, Group>,
|
|
222
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
252
223
|
ref: any
|
|
253
224
|
) {
|
|
254
225
|
return (
|
|
@@ -264,11 +235,11 @@ export function CreatableSelectInner<
|
|
|
264
235
|
backspaceRemovesValue={isCollectionMode}
|
|
265
236
|
tabSelectsValue={false}
|
|
266
237
|
components={{
|
|
267
|
-
Menu,
|
|
238
|
+
Menu: Menu,
|
|
268
239
|
MenuList: virtualized ? WindowedMenuList : reactSelectComponents.MenuList,
|
|
269
240
|
DropdownIndicator,
|
|
270
241
|
ClearIndicator,
|
|
271
|
-
Option
|
|
242
|
+
Option,
|
|
272
243
|
MultiValueRemove: ClearIndicator,
|
|
273
244
|
NoOptionsMessage,
|
|
274
245
|
GroupHeading,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {css, cx} from "@linaria/core";
|
|
2
|
-
import {border, radius, space, textStyles} from "../
|
|
2
|
+
import {border, radius, space, textStyles} from "../design-system";
|
|
3
3
|
import {inputOverrides} from "../antd/styles";
|
|
4
4
|
import React, {
|
|
5
5
|
ComponentType,
|
|
@@ -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,
|
package/src/Select/styles.ts
CHANGED
|
@@ -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} 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: () => OptionNulledStyles,
|
|
52
46
|
groupHeading: (provided) => ({
|
|
53
47
|
...provided,
|
|
54
48
|
height: layout.menuItemHeight,
|
|
@@ -70,36 +64,9 @@ export const zIndexStyles = (zIndex: number): StylesConfig => ({
|
|
|
70
64
|
});
|
|
71
65
|
|
|
72
66
|
export const componentsStyles: StylesConfig = {
|
|
73
|
-
option: (
|
|
74
|
-
|
|
75
|
-
|
|
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: () => ({
|
|
68
|
+
minHeight: layout.menuItemHeight,
|
|
69
|
+
}),
|
|
103
70
|
placeholder: (provided) => ({
|
|
104
71
|
...provided,
|
|
105
72
|
color: themeVars.disabledTextColor,
|
|
@@ -140,12 +107,7 @@ export const componentsStyles: StylesConfig = {
|
|
|
140
107
|
multiValueLabel: () => ({}),
|
|
141
108
|
groupHeading: (provided) => ({
|
|
142
109
|
...provided,
|
|
143
|
-
|
|
144
|
-
paddingRight: space.m,
|
|
145
|
-
paddingTop: space.m + space.xs,
|
|
146
|
-
margin: 0,
|
|
147
|
-
...textStyles.small,
|
|
148
|
-
color: themeVars.disabledTextColor,
|
|
110
|
+
...groupHeadingNulledStyles,
|
|
149
111
|
}),
|
|
150
112
|
menuPortal: (provided) => ({
|
|
151
113
|
...provided,
|
|
@@ -153,11 +115,7 @@ export const componentsStyles: StylesConfig = {
|
|
|
153
115
|
}),
|
|
154
116
|
menu: (provided) => ({
|
|
155
117
|
...provided,
|
|
156
|
-
|
|
157
|
-
zIndex: 1050,
|
|
158
|
-
backgroundColor: themeVars.actionMenuInnerBg,
|
|
159
|
-
boxShadow: themeVars.actionMenuShadow as unknown as Property.BoxShadow,
|
|
160
|
-
borderRadius: border.radius6,
|
|
118
|
+
...MenuNulledStyles,
|
|
161
119
|
}),
|
|
162
120
|
container: (provided, state) => ({
|
|
163
121
|
...provided,
|
package/src/antd/styles.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {css} from "@linaria/core";
|
|
2
|
-
import {colors, layout, border, shadows, space, textStyles, themeVars, transition} from "../
|
|
2
|
+
import {colors, layout, border, shadows, space, textStyles, themeVars, transition} from "../design-system";
|
|
3
3
|
|
|
4
4
|
const inputVariables = {
|
|
5
5
|
default: {
|