@fibery/ui-kit 1.42.0 → 2.0.1
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/.oxlintrc.json +24 -0
- package/CHANGELOG.md +20 -0
- package/eslint.config.mjs +1 -1
- package/jest.config.cjs +36 -0
- package/package.json +12 -52
- package/src/@types/css.d.ts +1 -0
- package/src/actions-menu/actions-menu-checkbox-item.tsx +74 -0
- package/src/actions-menu/contexts/actions-menu-context.tsx +1 -0
- package/src/actions-menu/index.tsx +1 -0
- package/src/animated-number.tsx +2 -2
- package/src/antd/AutoComplete.d.ts +1 -0
- package/src/app-icon-with-fallback.tsx +4 -4
- package/src/app-icon.tsx +4 -4
- package/src/appIcons.json +1227 -1227
- package/src/avatar.tsx +44 -5
- package/src/box.tsx +10 -17
- package/src/button/make-button-colors.ts +13 -13
- package/src/checkbox.tsx +3 -3
- package/src/collapsible-section.tsx +1 -1
- package/src/context-menu/index.tsx +4 -0
- package/src/date-picker/date-range-picker.tsx +1 -1
- package/src/date-picker/relative-date-picker.tsx +3 -0
- package/src/date-picker/single-date-picker.tsx +10 -9
- package/src/design-system/alpha.ts +9 -0
- package/src/design-system/colors-css.test.ts +1 -9
- package/src/design-system/colors-css.ts +1 -1
- package/src/design-system/colors.ts +351 -313
- package/src/design-system/layout.ts +1 -1
- package/src/design-system/theme.ts +4 -1
- package/src/design-system/vars.test.ts +4 -0
- package/src/design-system.test.ts +1 -0
- package/src/design-system.ts +1 -1
- package/src/dropdown-menu/index.tsx +4 -0
- package/src/emoji-picker/primitives/emoji.tsx +12 -0
- package/src/emoji-picker/primitives/grid.tsx +100 -104
- package/src/emoji.tsx +1 -0
- package/src/file-item.tsx +308 -265
- package/src/icons/ast/AddDatabase.ts +1 -1
- package/src/icons/ast/AddIntegration.ts +1 -1
- package/src/icons/ast/ArrowsRightLeft.ts +1 -1
- package/src/icons/ast/ChatBubble.ts +1 -1
- package/src/icons/ast/ChatFloat.ts +1 -1
- package/src/icons/ast/ChatSidebar.ts +1 -1
- package/src/icons/ast/Clean.ts +1 -1
- package/src/icons/ast/Create.ts +1 -1
- package/src/icons/ast/ItemsTimeline.ts +1 -1
- package/src/icons/ast/Key.ts +1 -1
- package/src/icons/ast/NetworkAdd.ts +1 -1
- package/src/icons/ast/Print.ts +1 -1
- package/src/icons/ast/Success.ts +1 -1
- package/src/icons/ast/SuggestIntegration.ts +1 -1
- package/src/icons/ast/WarningTriangle.ts +1 -1
- package/src/icons/ast/Windows.ts +1 -1
- package/src/icons/svg/add-database.svg +1 -1
- package/src/icons/svg/add-integration.svg +1 -1
- package/src/icons/svg/arrows-right-left.svg +1 -1
- package/src/icons/svg/chat-bubble.svg +1 -1
- package/src/icons/svg/chat-float.svg +1 -1
- package/src/icons/svg/chat-sidebar.svg +3 -3
- package/src/icons/svg/clean.svg +1 -1
- package/src/icons/svg/create.svg +1 -1
- package/src/icons/svg/items-timeline.svg +1 -1
- package/src/icons/svg/key.svg +1 -1
- package/src/icons/svg/network-add.svg +1 -1
- package/src/icons/svg/print.svg +1 -1
- package/src/icons/svg/success.svg +1 -1
- package/src/icons/svg/suggest-integration.svg +1 -1
- package/src/icons/svg/warning-triangle.svg +1 -1
- package/src/icons/svg/windows.svg +1 -1
- package/src/images-gallery/images-gallery.tsx +24 -0
- package/src/lists/actions-menu-row-surface.tsx +2 -1
- package/src/logo.tsx +14 -13
- package/src/modal-menu/index.tsx +1 -0
- package/src/modal-menu/modal-menu-checkbox-item.tsx +50 -0
- package/src/online-users.tsx +45 -46
- package/src/palettes/slate-arch.colors-snapshot.test.ts +7 -7
- package/src/palettes/slate-user.colors-snapshot.test.ts +11 -11
- package/src/palettes/warm-arch.colors-snapshot.test.ts +7 -7
- package/src/palettes/warm-user.colors-snapshot.test.ts +7 -7
- package/src/popover/index.tsx +91 -203
- package/src/popover/popover-old.tsx +113 -0
- package/src/popover/popup-modifiers-context.ts +1 -1
- package/src/scale-generator.ts +2 -2
- package/src/select/components/clear-indicator.tsx +1 -1
- package/src/select/components/drop-down-indicator.tsx +2 -2
- package/src/select/components/group-heading.tsx +2 -2
- package/src/select/components/menu-list-virtualized.tsx +1 -1
- package/src/select/components/option.tsx +1 -1
- package/src/select/index.tsx +34 -37
- package/src/select/select-in-popover.tsx +34 -202
- package/src/select/select.tsx +5 -4
- package/src/select/styles.ts +3 -0
- package/src/thematic-state.ts +1 -1
- package/src/theme-provider.tsx +14 -2
- package/src/theme-styles.ts +14 -7
- package/src/toggle-button/toggle-button.tsx +48 -35
- package/src/tree-utils.test.ts +166 -0
- package/src/tree-utils.ts +107 -0
- package/src/file-item/use-register-in-image-gallery.tsx +0 -70
- package/src/file-item-2.tsx +0 -357
package/src/select/index.tsx
CHANGED
|
@@ -38,7 +38,7 @@ const emptyComponents = {
|
|
|
38
38
|
export const Select = forwardRef(function SelectInner<
|
|
39
39
|
T = unknown,
|
|
40
40
|
U extends boolean = boolean,
|
|
41
|
-
V extends GroupBase<T> = GroupBase<T
|
|
41
|
+
V extends GroupBase<T> = GroupBase<T>,
|
|
42
42
|
>(
|
|
43
43
|
{
|
|
44
44
|
maxMenuHeight,
|
|
@@ -51,6 +51,7 @@ export const Select = forwardRef(function SelectInner<
|
|
|
51
51
|
title,
|
|
52
52
|
isSearchable,
|
|
53
53
|
inline,
|
|
54
|
+
menuPortalTarget,
|
|
54
55
|
...restProps
|
|
55
56
|
}: SelectProps<T, U, V>,
|
|
56
57
|
forwardedRef: ForwardedRef<SelectInstance<T, U, V>>
|
|
@@ -59,53 +60,48 @@ export const Select = forwardRef(function SelectInner<
|
|
|
59
60
|
if (isPhone && !inline) {
|
|
60
61
|
return (
|
|
61
62
|
<SelectInPopover
|
|
62
|
-
{...
|
|
63
|
+
{...restProps}
|
|
63
64
|
options={options}
|
|
64
65
|
isSearchable={isSearchable}
|
|
65
66
|
title={title || typeof placeholder === "string" ? placeholder : ""}
|
|
66
67
|
isClearable={typeof isClearable === "undefined" ? false : isClearable}
|
|
67
|
-
formatOptionLabel={
|
|
68
|
-
formatOptionLabel as ((option: T, {context}: {context: "menu" | "value"}) => React.ReactNode) | undefined
|
|
69
|
-
}
|
|
68
|
+
formatOptionLabel={formatOptionLabel}
|
|
70
69
|
isOptionDisabled={isOptionDisabled as ((option: T) => boolean) | undefined}
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
trigger={
|
|
71
|
+
<div
|
|
72
|
+
className={css`
|
|
73
|
+
display: block;
|
|
74
|
+
position: relative;
|
|
75
|
+
`}
|
|
76
|
+
>
|
|
73
77
|
<div
|
|
74
78
|
className={css`
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
position: absolute;
|
|
80
|
+
inset: 0;
|
|
81
|
+
z-index: 1;
|
|
82
|
+
`}
|
|
83
|
+
/>
|
|
84
|
+
<div
|
|
85
|
+
className={css`
|
|
86
|
+
pointer-events: none;
|
|
77
87
|
`}
|
|
78
88
|
>
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
<SelectComponent
|
|
90
|
+
{...restProps}
|
|
91
|
+
isSearchable={false}
|
|
92
|
+
components={emptyComponents}
|
|
93
|
+
placeholder={placeholder}
|
|
94
|
+
maxMenuHeight={maxMenuHeight}
|
|
95
|
+
options={options}
|
|
96
|
+
styles={styles}
|
|
97
|
+
formatOptionLabel={formatOptionLabel}
|
|
98
|
+
isOptionDisabled={isOptionDisabled}
|
|
99
|
+
isClearable={isClearable}
|
|
100
|
+
menuIsOpen={false}
|
|
85
101
|
/>
|
|
86
|
-
<div
|
|
87
|
-
className={css`
|
|
88
|
-
pointer-events: none;
|
|
89
|
-
`}
|
|
90
|
-
>
|
|
91
|
-
<SelectComponent
|
|
92
|
-
{...restProps}
|
|
93
|
-
isSearchable={false}
|
|
94
|
-
components={emptyComponents}
|
|
95
|
-
placeholder={placeholder}
|
|
96
|
-
maxMenuHeight={maxMenuHeight}
|
|
97
|
-
options={options}
|
|
98
|
-
styles={styles}
|
|
99
|
-
formatOptionLabel={formatOptionLabel}
|
|
100
|
-
isOptionDisabled={isOptionDisabled}
|
|
101
|
-
isClearable={isClearable}
|
|
102
|
-
menuIsOpen={false}
|
|
103
|
-
/>
|
|
104
|
-
</div>
|
|
105
102
|
</div>
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
inline={inline}
|
|
103
|
+
</div>
|
|
104
|
+
}
|
|
109
105
|
/>
|
|
110
106
|
);
|
|
111
107
|
}
|
|
@@ -120,6 +116,7 @@ export const Select = forwardRef(function SelectInner<
|
|
|
120
116
|
isClearable={isClearable}
|
|
121
117
|
styles={styles}
|
|
122
118
|
inline={inline}
|
|
119
|
+
menuPortalTarget={menuPortalTarget}
|
|
123
120
|
{...restProps}
|
|
124
121
|
/>
|
|
125
122
|
);
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import {useControllableState} from "@fibery/react/src/use-controllable-state";
|
|
2
2
|
import {css, cx} from "@linaria/core";
|
|
3
3
|
import React, {
|
|
4
|
-
ComponentType,
|
|
5
4
|
ForwardedRef,
|
|
6
5
|
forwardRef,
|
|
7
6
|
ReactNode,
|
|
8
7
|
RefObject,
|
|
9
8
|
useCallback,
|
|
10
|
-
useEffect,
|
|
11
9
|
useImperativeHandle,
|
|
12
10
|
useMemo,
|
|
13
11
|
useRef,
|
|
14
12
|
useState,
|
|
15
13
|
} from "react";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {Popover, Placement} from "../popover";
|
|
14
|
+
import {space, textStyles} from "../design-system";
|
|
15
|
+
import {Placement, Popover} from "../popover";
|
|
19
16
|
import {useIsPhone} from "../use-is-phone";
|
|
20
17
|
import {MenuTransparent} from "./components/menu";
|
|
21
18
|
import {
|
|
@@ -30,7 +27,6 @@ import {
|
|
|
30
27
|
StylesConfig,
|
|
31
28
|
} from "./select";
|
|
32
29
|
import {SelectControlSettingsProvider} from "./select-control-settings-context";
|
|
33
|
-
import {ButtonColor, ButtonVariant} from "../button/base-button";
|
|
34
30
|
import {makeSelectInPopoverStyles} from "./styles";
|
|
35
31
|
import {SelectInstance} from "react-select";
|
|
36
32
|
import {SELECT_IN_POPOVER_VALUE_MAX_HEIGHT} from "./constants";
|
|
@@ -67,63 +63,12 @@ const mobileClassName = css`
|
|
|
67
63
|
padding-right: ${space.s12}px;
|
|
68
64
|
`;
|
|
69
65
|
|
|
70
|
-
const triggerCss = css`
|
|
71
|
-
min-width: 0;
|
|
72
|
-
border-radius: ${border.radius6}px;
|
|
73
|
-
|
|
74
|
-
&:focus {
|
|
75
|
-
outline: none;
|
|
76
|
-
${inputOverrides.focus}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
&:focus:not(:focus-visible) {
|
|
80
|
-
outline: none;
|
|
81
|
-
box-shadow: none !important;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
&:focus-visible {
|
|
85
|
-
outline: none;
|
|
86
|
-
${inputOverrides.focus}
|
|
87
|
-
}
|
|
88
|
-
`;
|
|
89
|
-
|
|
90
66
|
const titleClassName = css`
|
|
91
67
|
${textStyles.heading6}
|
|
92
68
|
padding-top: ${space.s12}px;
|
|
93
69
|
padding-inline: ${space.s12}px;
|
|
94
70
|
`;
|
|
95
71
|
|
|
96
|
-
export type TriggerProps = {
|
|
97
|
-
innerRef: React.Ref<HTMLDivElement>;
|
|
98
|
-
children: ReactNode;
|
|
99
|
-
onClick?: React.MouseEventHandler;
|
|
100
|
-
iconStart?: ReactNode;
|
|
101
|
-
pending?: boolean;
|
|
102
|
-
pressed?: boolean;
|
|
103
|
-
menuOpened?: boolean;
|
|
104
|
-
onKeyDown?: React.KeyboardEventHandler;
|
|
105
|
-
disabled?: boolean;
|
|
106
|
-
size?: "small" | "medium" | "large";
|
|
107
|
-
fullWidth?: boolean;
|
|
108
|
-
style?: React.CSSProperties;
|
|
109
|
-
className?: string;
|
|
110
|
-
variant?: ButtonVariant;
|
|
111
|
-
color?: ButtonColor;
|
|
112
|
-
valueSelected: boolean;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const TriggerDefault = ({innerRef, children, onClick, onKeyDown}: TriggerProps) => {
|
|
116
|
-
return (
|
|
117
|
-
<div ref={innerRef} onClick={onClick} onKeyDown={onKeyDown} tabIndex={0} className={triggerCss}>
|
|
118
|
-
{children}
|
|
119
|
-
</div>
|
|
120
|
-
);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export type SelectComponents<T, U extends boolean, V extends GroupBase<T>> = SelectProps<T, U, V>["components"] & {
|
|
124
|
-
Trigger?: ComponentType<TriggerProps>;
|
|
125
|
-
};
|
|
126
|
-
|
|
127
72
|
export type SelectInPopoverRef<T, U extends boolean, V extends GroupBase<T>> = {
|
|
128
73
|
valueRef: HTMLDivElement | null;
|
|
129
74
|
selectRef: RefObject<SelectInstance<T, U, V>>;
|
|
@@ -133,40 +78,41 @@ type Props<T, U extends boolean, V extends GroupBase<T>> = {
|
|
|
133
78
|
value?: PropsValue<T>;
|
|
134
79
|
isSearchable?: boolean;
|
|
135
80
|
menuIsOpen?: boolean;
|
|
136
|
-
autoFocus?: boolean;
|
|
137
|
-
virtualized?: boolean;
|
|
138
|
-
defaultMenuIsOpen?: boolean;
|
|
139
|
-
placeholder?: string;
|
|
140
|
-
noOptionsMessage?: () => string | JSX.Element | null;
|
|
141
81
|
options: OptionsOrGroups<T, V>;
|
|
142
|
-
filterOption?: SelectProps<T, U, V>["filterOption"];
|
|
143
|
-
menuPortalTarget?: SelectProps<T, U, V>["menuPortalTarget"];
|
|
144
|
-
inputValue?: string;
|
|
145
82
|
disabled?: boolean;
|
|
146
83
|
isCollectionMode?: U;
|
|
147
84
|
isClearable?: boolean;
|
|
148
|
-
|
|
85
|
+
trigger?: ReactNode;
|
|
149
86
|
title?: string;
|
|
150
87
|
maxMenuHeight?: number;
|
|
151
88
|
hideOnChange?: boolean | ((newValue: OnChangeValue<T, U>, actionMeta: ActionMeta<T>) => boolean);
|
|
152
89
|
renderInPortal?: boolean;
|
|
153
90
|
popupStyles?: string;
|
|
154
91
|
selectStyles?: StylesConfig<T, U, V>;
|
|
155
|
-
formatGroupLabel?: (group: V) => ReactNode;
|
|
156
|
-
formatOptionLabel?: (option: T, {context}: {context: "menu" | "value"}) => ReactNode;
|
|
157
|
-
components?: SelectComponents<T, U, V>;
|
|
158
|
-
onInputChange?: (s: string, actionType: {action: string}) => void;
|
|
159
|
-
onFocus?: () => void;
|
|
160
|
-
onChange: (newValue: OnChangeValue<T, U>, actionMeta: ActionMeta<T>) => void;
|
|
161
92
|
onMenuOpen?: () => void;
|
|
162
93
|
onMenuClose?: () => void | boolean;
|
|
163
94
|
getPopupContainer?: () => HTMLElement;
|
|
164
95
|
onSelectKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
|
|
165
|
-
forbidValuesClearInCollnMode?: boolean;
|
|
166
96
|
otherSelectProps?: Record<string, unknown>;
|
|
167
|
-
isOptionDisabled?: (option: T) => boolean;
|
|
168
97
|
popoverPlacement?: Placement;
|
|
169
|
-
}
|
|
98
|
+
} & Pick<
|
|
99
|
+
SelectProps<T, U, V>,
|
|
100
|
+
| "placeholder"
|
|
101
|
+
| "autoFocus"
|
|
102
|
+
| "inputValue"
|
|
103
|
+
| "formatGroupLabel"
|
|
104
|
+
| "defaultMenuIsOpen"
|
|
105
|
+
| "virtualized"
|
|
106
|
+
| "formatOptionLabel"
|
|
107
|
+
| "isOptionDisabled"
|
|
108
|
+
| "noOptionsMessage"
|
|
109
|
+
| "forbidValuesClearInCollnMode"
|
|
110
|
+
| "filterOption"
|
|
111
|
+
| "onInputChange"
|
|
112
|
+
| "onChange"
|
|
113
|
+
| "onFocus"
|
|
114
|
+
| "components"
|
|
115
|
+
>;
|
|
170
116
|
|
|
171
117
|
function SelectInPopoverInner<T, U extends boolean, V extends GroupBase<T>>(
|
|
172
118
|
props: Omit<Props<T, U, V>, "maxMenuHeight">,
|
|
@@ -174,40 +120,25 @@ function SelectInPopoverInner<T, U extends boolean, V extends GroupBase<T>>(
|
|
|
174
120
|
) {
|
|
175
121
|
const {
|
|
176
122
|
value,
|
|
177
|
-
virtualized,
|
|
178
123
|
menuIsOpen,
|
|
179
|
-
autoFocus,
|
|
180
|
-
defaultMenuIsOpen,
|
|
181
|
-
placeholder,
|
|
182
|
-
noOptionsMessage,
|
|
183
124
|
options,
|
|
184
|
-
filterOption,
|
|
185
|
-
inputValue,
|
|
186
125
|
disabled,
|
|
187
126
|
isCollectionMode,
|
|
188
127
|
isClearable = true,
|
|
189
|
-
|
|
128
|
+
trigger,
|
|
190
129
|
title,
|
|
191
130
|
hideOnChange = true,
|
|
192
131
|
renderInPortal = true,
|
|
193
132
|
popupStyles,
|
|
194
133
|
selectStyles = {},
|
|
195
|
-
formatGroupLabel,
|
|
196
|
-
formatOptionLabel,
|
|
197
134
|
components = {},
|
|
198
|
-
onInputChange,
|
|
199
|
-
onFocus,
|
|
200
135
|
onChange,
|
|
201
136
|
onMenuOpen,
|
|
202
137
|
onMenuClose,
|
|
203
138
|
getPopupContainer,
|
|
204
139
|
onSelectKeyDown,
|
|
205
140
|
otherSelectProps,
|
|
206
|
-
forbidValuesClearInCollnMode,
|
|
207
|
-
isOptionDisabled,
|
|
208
141
|
isSearchable = true,
|
|
209
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
210
|
-
menuPortalTarget,
|
|
211
142
|
popoverPlacement = "bottom-start",
|
|
212
143
|
...rest
|
|
213
144
|
} = props;
|
|
@@ -219,7 +150,6 @@ function SelectInPopoverInner<T, U extends boolean, V extends GroupBase<T>>(
|
|
|
219
150
|
},
|
|
220
151
|
});
|
|
221
152
|
const isPhone = useIsPhone();
|
|
222
|
-
const blurTimeoutRef = useRef<ReturnType<typeof setTimeout>>();
|
|
223
153
|
const selectRef = useRef<SelectInstance<T, U, V>>(null);
|
|
224
154
|
const [triggerElement, setTriggerElement] = useState<HTMLDivElement | null>(null);
|
|
225
155
|
|
|
@@ -228,50 +158,19 @@ function SelectInPopoverInner<T, U extends boolean, V extends GroupBase<T>>(
|
|
|
228
158
|
selectRef,
|
|
229
159
|
}));
|
|
230
160
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
161
|
+
const onHide = useCallback(() => {
|
|
162
|
+
const wasClosed = onMenuClose?.();
|
|
163
|
+
if (wasClosed === false) {
|
|
164
|
+
return;
|
|
234
165
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
const onHide = useCallback(
|
|
238
|
-
(restoreFocus = true) => {
|
|
239
|
-
const wasClosed = onMenuClose && onMenuClose();
|
|
240
|
-
if (wasClosed === false) {
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
setVisible(false);
|
|
244
|
-
|
|
245
|
-
if (restoreFocus) {
|
|
246
|
-
triggerElement?.focus();
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
[onMenuClose, setVisible, triggerElement]
|
|
250
|
-
);
|
|
251
|
-
|
|
252
|
-
useEffect(() => {
|
|
253
|
-
const onVisibleChange = function () {
|
|
254
|
-
if (document.visibilityState === "visible" && blurTimeoutRef.current && visible) {
|
|
255
|
-
clearTimeout(blurTimeoutRef.current);
|
|
256
|
-
selectRef.current?.focus();
|
|
257
|
-
} else if (document.visibilityState === "hidden" && blurTimeoutRef.current) {
|
|
258
|
-
clearTimeout(blurTimeoutRef.current);
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
document.addEventListener("visibilitychange", onVisibleChange);
|
|
262
|
-
return () => {
|
|
263
|
-
document.removeEventListener("visibilitychange", onVisibleChange);
|
|
264
|
-
};
|
|
265
|
-
}, [visible]);
|
|
166
|
+
setVisible(false);
|
|
167
|
+
}, [onMenuClose, setVisible]);
|
|
266
168
|
|
|
267
169
|
const onShow = useCallback(() => {
|
|
268
170
|
if (disabled) {
|
|
269
171
|
return;
|
|
270
172
|
}
|
|
271
173
|
|
|
272
|
-
if (blurTimeoutRef.current) {
|
|
273
|
-
clearTimeout(blurTimeoutRef.current);
|
|
274
|
-
}
|
|
275
174
|
setVisible(true);
|
|
276
175
|
if (onMenuOpen) {
|
|
277
176
|
onMenuOpen();
|
|
@@ -282,50 +181,6 @@ function SelectInPopoverInner<T, U extends boolean, V extends GroupBase<T>>(
|
|
|
282
181
|
return combineStyles<T, U, V>([makeSelectInPopoverStyles(isPhone), selectStyles]);
|
|
283
182
|
}, [selectStyles, isPhone]);
|
|
284
183
|
|
|
285
|
-
const onTriggerClick: React.MouseEventHandler = useCallback(
|
|
286
|
-
(event) => {
|
|
287
|
-
if (visible) {
|
|
288
|
-
onHide();
|
|
289
|
-
} else {
|
|
290
|
-
onShow();
|
|
291
|
-
}
|
|
292
|
-
event.stopPropagation();
|
|
293
|
-
},
|
|
294
|
-
[onHide, onShow, visible]
|
|
295
|
-
);
|
|
296
|
-
|
|
297
|
-
const onTriggerKeyDown: React.KeyboardEventHandler = useCallback(
|
|
298
|
-
(event) => {
|
|
299
|
-
const cmdKeyPressed = event.metaKey || event.ctrlKey;
|
|
300
|
-
if (((event.key === "Enter" && !cmdKeyPressed) || event.key === " ") && !visible) {
|
|
301
|
-
event.preventDefault();
|
|
302
|
-
onShow();
|
|
303
|
-
}
|
|
304
|
-
},
|
|
305
|
-
[onShow, visible]
|
|
306
|
-
);
|
|
307
|
-
|
|
308
|
-
const onKeyDown: React.KeyboardEventHandler<HTMLDivElement> = useCallback(
|
|
309
|
-
(event) => {
|
|
310
|
-
if ((event.key === "Escape" || event.key === "Tab") && visible) {
|
|
311
|
-
onHide();
|
|
312
|
-
event.preventDefault();
|
|
313
|
-
event.stopPropagation();
|
|
314
|
-
}
|
|
315
|
-
onSelectKeyDown?.(event);
|
|
316
|
-
},
|
|
317
|
-
[onHide, onSelectKeyDown, visible]
|
|
318
|
-
);
|
|
319
|
-
|
|
320
|
-
const onBlur: React.FocusEventHandler<HTMLDivElement> = useCallback(() => {
|
|
321
|
-
if (isPhone) {
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
blurTimeoutRef.current = setTimeout(() => {
|
|
325
|
-
onHide(false);
|
|
326
|
-
}, 250);
|
|
327
|
-
}, [isPhone, onHide]);
|
|
328
|
-
|
|
329
184
|
const handleChange = useCallback(
|
|
330
185
|
(newValue: OnChangeValue<T, U>, actionMeta: ActionMeta<T>) => {
|
|
331
186
|
if (typeof hideOnChange === "function") {
|
|
@@ -335,7 +190,7 @@ function SelectInPopoverInner<T, U extends boolean, V extends GroupBase<T>>(
|
|
|
335
190
|
} else if (hideOnChange) {
|
|
336
191
|
onHide();
|
|
337
192
|
}
|
|
338
|
-
onChange(newValue, actionMeta);
|
|
193
|
+
onChange?.(newValue, actionMeta);
|
|
339
194
|
},
|
|
340
195
|
[hideOnChange, onChange, onHide]
|
|
341
196
|
);
|
|
@@ -350,7 +205,6 @@ function SelectInPopoverInner<T, U extends boolean, V extends GroupBase<T>>(
|
|
|
350
205
|
paddingPopup -
|
|
351
206
|
paddingMenu;
|
|
352
207
|
|
|
353
|
-
const Trigger = components.Trigger || TriggerDefault;
|
|
354
208
|
const selectComponents = {
|
|
355
209
|
Menu: MenuTransparent,
|
|
356
210
|
DropdownIndicator: null,
|
|
@@ -360,17 +214,9 @@ function SelectInPopoverInner<T, U extends boolean, V extends GroupBase<T>>(
|
|
|
360
214
|
|
|
361
215
|
return (
|
|
362
216
|
<Popover.Root open={visible} onOpen={() => onShow()} onClose={() => onHide()}>
|
|
363
|
-
<Trigger
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
disabled={disabled}
|
|
367
|
-
valueSelected={Boolean(value)}
|
|
368
|
-
onClick={onTriggerClick}
|
|
369
|
-
onKeyDown={onTriggerKeyDown}
|
|
370
|
-
>
|
|
371
|
-
{renderValue ? renderValue() : null}
|
|
372
|
-
</Trigger>
|
|
373
|
-
<Popover.Trigger reference={triggerElement} />
|
|
217
|
+
<Popover.Trigger ref={setTriggerElement} asChild triggerEvent="click">
|
|
218
|
+
{trigger}
|
|
219
|
+
</Popover.Trigger>
|
|
374
220
|
<Wrap with={Popover.Portal} if={renderInPortal} getPopupContainer={getPopupContainer}>
|
|
375
221
|
<Popover.Content
|
|
376
222
|
supportMobile
|
|
@@ -391,35 +237,22 @@ function SelectInPopoverInner<T, U extends boolean, V extends GroupBase<T>>(
|
|
|
391
237
|
ref={selectRef}
|
|
392
238
|
styles={styles}
|
|
393
239
|
isSearchable={isSearchable}
|
|
394
|
-
onKeyDown={
|
|
395
|
-
autoFocus={autoFocus}
|
|
396
|
-
onBlur={onBlur}
|
|
240
|
+
onKeyDown={onSelectKeyDown}
|
|
397
241
|
value={value}
|
|
398
|
-
defaultMenuIsOpen={defaultMenuIsOpen}
|
|
399
242
|
controlShouldRenderValue
|
|
400
243
|
closeMenuOnScroll={false}
|
|
401
244
|
closeMenuOnSelect={false}
|
|
402
245
|
onChange={handleChange}
|
|
403
|
-
placeholder={placeholder}
|
|
404
|
-
onInputChange={onInputChange}
|
|
405
|
-
noOptionsMessage={noOptionsMessage}
|
|
406
246
|
options={options || []}
|
|
407
|
-
filterOption={filterOption}
|
|
408
|
-
inputValue={inputValue}
|
|
409
247
|
menuIsOpen
|
|
410
|
-
virtualized={virtualized}
|
|
411
248
|
maxMenuHeight={maxMenuHeight}
|
|
412
249
|
disabled={disabled}
|
|
413
|
-
onFocus={onFocus}
|
|
414
250
|
isCollectionMode={isCollectionMode}
|
|
415
251
|
isClearable={!isCollectionMode && isClearable}
|
|
416
|
-
formatGroupLabel={formatGroupLabel}
|
|
417
|
-
formatOptionLabel={formatOptionLabel}
|
|
418
252
|
menuShouldBlockScroll={false}
|
|
419
253
|
{...otherSelectProps}
|
|
420
254
|
components={selectComponents}
|
|
421
|
-
|
|
422
|
-
isOptionDisabled={isOptionDisabled}
|
|
255
|
+
inline
|
|
423
256
|
/>
|
|
424
257
|
</SelectControlSettingsProvider>
|
|
425
258
|
</Popover.Content>
|
|
@@ -432,5 +265,4 @@ type SelectInPopoverType = <T, U extends boolean, V extends GroupBase<T>>(
|
|
|
432
265
|
props: Omit<Props<T, U, V>, "maxMenuHeight"> & {ref?: ForwardedRef<SelectInPopoverRef<T, U, V>>}
|
|
433
266
|
) => ReturnType<typeof SelectInPopoverInner>;
|
|
434
267
|
|
|
435
|
-
// Explicit type assertion to specify that component accepts generic props because forwardRef breaks it
|
|
436
268
|
export const SelectInPopover = forwardRef(SelectInPopoverInner) as SelectInPopoverType;
|
package/src/select/select.tsx
CHANGED
|
@@ -73,6 +73,7 @@ export type SelectProps<T = unknown, U extends boolean = boolean, V extends Grou
|
|
|
73
73
|
disabled?: boolean;
|
|
74
74
|
forbidValuesClearInCollnMode?: boolean;
|
|
75
75
|
inline?: boolean;
|
|
76
|
+
placeholder?: string;
|
|
76
77
|
};
|
|
77
78
|
|
|
78
79
|
const FAST_OPTION_USAGE_THRESHOLD = 200;
|
|
@@ -107,8 +108,8 @@ function useSelectComponents<T, U extends boolean, V extends GroupBase<T>>({
|
|
|
107
108
|
MenuList: virtualized
|
|
108
109
|
? MenuListVirtualized
|
|
109
110
|
: components?.MenuList
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
? components.MenuList
|
|
112
|
+
: reactSelectComponents.MenuList,
|
|
112
113
|
};
|
|
113
114
|
}
|
|
114
115
|
|
|
@@ -136,7 +137,7 @@ function useSelectStyles<T, U extends boolean, V extends GroupBase<T>>({
|
|
|
136
137
|
export const SelectComponent = forwardRef(function Select<
|
|
137
138
|
T = unknown,
|
|
138
139
|
U extends boolean = boolean,
|
|
139
|
-
V extends GroupBase<T> = GroupBase<T
|
|
140
|
+
V extends GroupBase<T> = GroupBase<T>,
|
|
140
141
|
>(
|
|
141
142
|
{
|
|
142
143
|
components,
|
|
@@ -281,7 +282,7 @@ function CreatableSelectInner<T = unknown, U extends boolean = boolean, V extend
|
|
|
281
282
|
export const CreatableSelect = forwardRef(CreatableSelectInner) as <
|
|
282
283
|
T = unknown,
|
|
283
284
|
U extends boolean = boolean,
|
|
284
|
-
V extends GroupBase<T> = GroupBase<T
|
|
285
|
+
V extends GroupBase<T> = GroupBase<T>,
|
|
285
286
|
>(
|
|
286
287
|
props: CreatableProps<T, U, V> & SelectProps<T, U, V>
|
|
287
288
|
) => ReturnType<typeof CreatableSelectInner>;
|
package/src/select/styles.ts
CHANGED
|
@@ -114,6 +114,9 @@ export const makeComponentsStyles = <T, U extends boolean, V extends GroupBase<T
|
|
|
114
114
|
alignItems: "center",
|
|
115
115
|
height: layout.inputHeight - 2,
|
|
116
116
|
}),
|
|
117
|
+
multiValueRemove: (base) => {
|
|
118
|
+
return {};
|
|
119
|
+
},
|
|
117
120
|
control: makeControlStyle<T, U, V>({isSingleLine: false}).control,
|
|
118
121
|
group: (provided) => ({
|
|
119
122
|
...provided,
|
package/src/thematic-state.ts
CHANGED
package/src/theme-provider.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
defaultLightTheme,
|
|
5
5
|
defaultLightThemeStyles,
|
|
6
6
|
defaultPalette,
|
|
7
|
-
|
|
7
|
+
selectGlobalThemePair,
|
|
8
8
|
} from "./theme-styles";
|
|
9
9
|
import {layoutStyles} from "./layout-styles";
|
|
10
10
|
import {
|
|
@@ -156,6 +156,15 @@ export function MenuThemeProvider({children}: {children: ReactNode}) {
|
|
|
156
156
|
return <ThemeProvider mode={mode}>{children}</ThemeProvider>;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
function useUpdateBrowserThemeColor(light: ThemeColors, dark: ThemeColors) {
|
|
160
|
+
useEffect(() => {
|
|
161
|
+
const lightEl = document.querySelector('meta[name="theme-color"][media*="light"]');
|
|
162
|
+
const darkEl = document.querySelector('meta[name="theme-color"][media*="dark"]');
|
|
163
|
+
lightEl?.setAttribute("content", light.mainBg);
|
|
164
|
+
darkEl?.setAttribute("content", dark.mainBg);
|
|
165
|
+
}, [light.mainBg, dark.mainBg]);
|
|
166
|
+
}
|
|
167
|
+
|
|
159
168
|
export function RootThemeProvider({
|
|
160
169
|
initialThemeMode,
|
|
161
170
|
initialPreference,
|
|
@@ -184,10 +193,13 @@ export function RootThemeProvider({
|
|
|
184
193
|
let res = <ThemeProvider theme={getThemeColors(null, themeMode, palette)}>{children}</ThemeProvider>;
|
|
185
194
|
|
|
186
195
|
// Set base context to what global CSS has, so ThemeProvider diffs against it
|
|
187
|
-
const [
|
|
196
|
+
const [[lightThemeColors, lightThemeStyles], [darkThemeColors, darkThemeStyles]] = selectGlobalThemePair(warm);
|
|
197
|
+
const [cssThemeColors, cssThemeStyles] =
|
|
198
|
+
themeMode === "dark" ? [darkThemeColors, darkThemeStyles] : [lightThemeColors, lightThemeStyles];
|
|
188
199
|
res = <ThemeStylesContext.Provider value={cssThemeStyles}>{res}</ThemeStylesContext.Provider>;
|
|
189
200
|
res = <RootThemeStylesContext.Provider value={cssThemeStyles}>{res}</RootThemeStylesContext.Provider>;
|
|
190
201
|
res = <ThemeColorsContext.Provider value={cssThemeColors}>{res}</ThemeColorsContext.Provider>;
|
|
202
|
+
useUpdateBrowserThemeColor(lightThemeColors, darkThemeColors);
|
|
191
203
|
|
|
192
204
|
res = <ThemePaletteContext.Provider value={palette}>{res}</ThemePaletteContext.Provider>;
|
|
193
205
|
|
package/src/theme-styles.ts
CHANGED
|
@@ -18,23 +18,30 @@ export const defaultDarkThemeStyles = createInlineStyles(defaultDarkTheme);
|
|
|
18
18
|
const warmLightThemeStyles = createInlineStyles(warmLightTheme);
|
|
19
19
|
const warmDarkThemeStyles = createInlineStyles(warmDarkTheme);
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
type GlobalTheme = [colors: ThemeColors, styles: ThemeStyles];
|
|
22
|
+
|
|
23
|
+
export function selectGlobalThemePair(warm: boolean): [light: GlobalTheme, dark: GlobalTheme] {
|
|
24
|
+
return warm
|
|
25
|
+
? [
|
|
26
|
+
[warmLightTheme, warmLightThemeStyles],
|
|
27
|
+
[warmDarkTheme, warmDarkThemeStyles],
|
|
28
|
+
]
|
|
29
|
+
: [
|
|
30
|
+
[defaultLightTheme, defaultLightThemeStyles],
|
|
31
|
+
[defaultDarkTheme, defaultDarkThemeStyles],
|
|
32
|
+
];
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
const darkClassName = "dark-theme";
|
|
30
36
|
const light2ClassName = "light-theme-and-dark-menu";
|
|
31
37
|
const warmClassName = "warm-palette";
|
|
38
|
+
const warmStickyClassName = "warm-palette-sticky";
|
|
32
39
|
|
|
33
40
|
export function chooseGlobalStyles(themeMode: ThemeMode, warm: boolean) {
|
|
34
41
|
const htmlElement = document.documentElement;
|
|
35
42
|
htmlElement.classList.toggle(darkClassName, themeMode === "dark");
|
|
36
43
|
htmlElement.classList.toggle(light2ClassName, themeMode === "light2");
|
|
37
|
-
htmlElement.classList.toggle(warmClassName, warm);
|
|
44
|
+
htmlElement.classList.toggle(warmClassName, warm || htmlElement.classList.contains(warmStickyClassName));
|
|
38
45
|
|
|
39
46
|
const colorScheme = themeMode === "dark" ? "dark" : "light";
|
|
40
47
|
htmlElement.style.colorScheme = colorScheme;
|