@fibery/ui-kit 3.0.0 → 4.1.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 +18 -0
- package/esfint.config.mjs +0 -17
- package/package.json +18 -13
- package/scripts/generate-icons.mjs +45 -44
- package/src/actions-menu/actions-menu-item.tsx +2 -1
- package/src/actions-menu/actions-menu.tsx +1 -3
- package/src/actions-menu/context-actions-menu.tsx +1 -1
- package/src/animated-height-container.tsx +1 -1
- package/src/antd/ant-modal.tsx +158 -9
- package/src/antd/ant-upload.tsx +285 -27
- package/src/antd/auto-complete.tsx +145 -0
- package/src/antd/auto-width-transparent-textarea.tsx +9 -2
- package/src/antd/global-overrides.ts +352 -0
- package/src/antd/index.tsx +3 -2
- package/src/antd/input-number.tsx +97 -11
- package/src/antd/input.tsx +127 -8
- package/src/antd/styles.ts +92 -32
- package/src/antd/tabs.tsx +139 -27
- package/src/app-icon-with-fallback.tsx +3 -7
- package/src/app-icon-wrapper.tsx +1 -13
- package/src/avatar.tsx +2 -56
- package/src/breadcrumb.tsx +5 -1
- package/src/color-adjuster.ts +24 -1
- package/src/color-utils.test.ts +2 -2
- package/src/color-utils.ts +2 -2
- package/src/copy-to-clipboard.ts +14 -3
- package/src/count-badge.tsx +10 -1
- package/src/date-picker/contexts.ts +6 -3
- package/src/date-picker/date-range-picker.tsx +7 -8
- package/src/date-picker/single-date-picker.tsx +3 -5
- package/src/date-picker/types.ts +1 -1
- package/src/date-picker/with-popup-control.tsx +3 -9
- package/src/day-select/iso-week-day-select.tsx +2 -2
- package/src/design-system/colors-callout.warm-dark.test.ts +22 -22
- package/src/design-system/colors-callout.warm-light.test.ts +19 -19
- package/src/design-system/colors-css.ts +1 -1
- package/src/design-system/colors-enum.dark.warm.test.ts +63 -63
- package/src/design-system/colors-enum.light.warm.test.ts +54 -54
- package/src/design-system/colors-highlight.warm-dark.test.ts +21 -21
- package/src/design-system/colors-highlight.warm-light.test.ts +21 -21
- package/src/design-system/colors.ts +4 -4
- package/src/design-system/fns.badge.dark.warm.test.ts +34 -34
- package/src/design-system/fns.badge.light.warm.test.ts +31 -31
- package/src/design-system/fns.deneutralize.test.ts +44 -0
- package/src/design-system/fns.icon.dark.warm.test.ts +21 -21
- package/src/design-system/fns.icon.light.warm.test.ts +17 -17
- package/src/design-system/fns.icon.ts +21 -13
- package/src/design-system/fns.ts +27 -3
- package/src/design-system/typography.ts +1 -1
- package/src/design-system.ts +1 -1
- package/src/emoji-picker/icon-emoji-picker.tsx +3 -3
- package/src/fibermoji-placeholder.tsx +2 -3
- package/src/icons/ast/index.tsx +446 -446
- package/src/icons/icon.tsx +23 -1
- package/src/icons/icons-integrity.test.ts +145 -0
- package/src/icons/react/index.tsx +446 -446
- package/src/icons/types.ts +1 -1
- package/src/images-gallery/images-gallery.tsx +2 -2
- package/src/images-gallery/slide-buttons.tsx +2 -4
- package/src/layout-styles.ts +5 -1
- package/src/link-input/components/ant-text-area-with-custom-read-state.tsx +2 -1
- package/src/lists/actions-menu-row-surface.tsx +1 -1
- package/src/media-query-utils.ts +5 -14
- package/src/mobile-keyboard-aware-popup.tsx +1 -1
- package/src/number-input/decimal.ts +6 -9
- package/src/number-input/number-input-inline-with-autosize.tsx +1 -1
- package/src/online-users.tsx +4 -5
- package/src/palettes/inspect.defs.colors.neutral-arch.test.ts +4 -4
- package/src/palettes/inspect.defs.colors.neutral-user.test.ts +4 -4
- package/src/palettes/inspect.defs.colors.warm-arch.test.ts +141 -141
- package/src/palettes/inspect.defs.colors.warm-user.test.ts +141 -141
- package/src/palettes/warm.ts +2 -0
- package/src/popover/index.tsx +4 -4
- package/src/popover/mobile-popover-context.tsx +1 -1
- package/src/popover/modifiers.tsx +1 -1
- package/src/rich-input-loader.tsx +1 -1
- package/src/root-theme-provider.test.tsx +1 -1
- package/src/select/components/menu-list-virtua.tsx +15 -16
- package/src/select/components/menu-list-virtualized.tsx +26 -29
- package/src/select/components/menu.tsx +3 -3
- package/src/select/index.tsx +4 -4
- package/src/select/reflection.ts +4 -5
- package/src/select/select-in-popover.tsx +34 -51
- package/src/select/select.tsx +5 -5
- package/src/select/styles.ts +1 -7
- package/src/select/util.ts +2 -2
- package/src/theme-provider.test.tsx +1 -1
- package/src/theme-provider.tsx +3 -9
- package/src/theme-snapshots.test.ts +9 -13
- package/src/{theming/build.ts → theming.build.ts} +6 -9
- package/src/{theming/theming-fibery.snapshot.css → theming.generated.css} +60 -60
- package/src/{theming/theming-fibery.snapshot.ts → theming.generated.ts} +60 -60
- package/src/type-badge.tsx +1 -2
- package/src/{themed-ink.tsx → type-label.tsx} +2 -5
- package/src/use-on-screen-keyboard-data.tsx +1 -1
- package/src/with-data.tsx +1 -1
- package/src/antd/auto-complete.d.ts +0 -2
- package/src/antd/auto-complete.ts +0 -37
- package/src/antd/tabs.d.ts +0 -5
- package/src/theming/index.ts +0 -20
- package/src/theming/theming-vzdbery.snapshot.css +0 -2001
- package/src/theming/theming-vzdbery.snapshot.ts +0 -2519
package/src/antd/ant-upload.tsx
CHANGED
|
@@ -1,21 +1,56 @@
|
|
|
1
1
|
import {css, cx} from "@linaria/core";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import type {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
import RcUpload from "rc-upload";
|
|
3
|
+
import type {RcFile, UploadProps as RcUploadProps, UploadRequestOption} from "rc-upload/lib/interface";
|
|
4
|
+
import type {ComponentPropsWithoutRef} from "react";
|
|
5
|
+
import {forwardRef, useCallback, useRef, useState} from "react";
|
|
6
|
+
|
|
7
|
+
import {border, space, textStyles, themeVars, transitions} from "../design-system";
|
|
8
|
+
|
|
9
|
+
export type UploadFileStatus = "error" | "success" | "done" | "uploading" | "removed";
|
|
10
|
+
|
|
11
|
+
export interface UploadFile<T = unknown> {
|
|
12
|
+
uid: string;
|
|
13
|
+
size?: number;
|
|
14
|
+
name: string;
|
|
15
|
+
lastModified?: number;
|
|
16
|
+
lastModifiedDate?: Date;
|
|
17
|
+
url?: string;
|
|
18
|
+
status?: UploadFileStatus;
|
|
19
|
+
percent?: number;
|
|
20
|
+
thumbUrl?: string;
|
|
21
|
+
originFileObj?: RcFile;
|
|
22
|
+
response?: T;
|
|
23
|
+
error?: unknown;
|
|
24
|
+
type?: string;
|
|
25
|
+
xhr?: T;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface UploadChangeParam<T = UploadFile> {
|
|
29
|
+
file: T;
|
|
30
|
+
fileList: T[];
|
|
31
|
+
event?: {percent: number};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function file2Obj(file: RcFile): UploadFile {
|
|
35
|
+
return {
|
|
36
|
+
uid: file.uid,
|
|
37
|
+
name: file.name,
|
|
38
|
+
size: file.size,
|
|
39
|
+
type: file.type,
|
|
40
|
+
lastModified: file.lastModified,
|
|
41
|
+
percent: 0,
|
|
42
|
+
originFileObj: file,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function upsertFile(file: UploadFile, list: UploadFile[]): UploadFile[] {
|
|
47
|
+
const index = list.findIndex((f) => f.uid === file.uid);
|
|
48
|
+
if (index === -1) {
|
|
49
|
+
return [...list, file];
|
|
50
|
+
}
|
|
51
|
+
const next = list.slice();
|
|
52
|
+
next[index] = file;
|
|
53
|
+
return next;
|
|
19
54
|
}
|
|
20
55
|
|
|
21
56
|
export const antUploadStyle = css`
|
|
@@ -29,12 +64,50 @@ export const antUploadStyle = css`
|
|
|
29
64
|
alignItems: "stretch",
|
|
30
65
|
alignContent: "stretch",
|
|
31
66
|
},
|
|
32
|
-
"& .ant-upload
|
|
67
|
+
"& .ant-upload": {
|
|
68
|
+
boxSizing: "border-box",
|
|
69
|
+
margin: 0,
|
|
70
|
+
padding: 0,
|
|
71
|
+
...textStyles.regular,
|
|
72
|
+
color: themeVars.textColor,
|
|
73
|
+
listStyle: "none",
|
|
74
|
+
outline: "none",
|
|
75
|
+
},
|
|
76
|
+
"& .ant-upload p": {
|
|
77
|
+
margin: 0,
|
|
78
|
+
},
|
|
79
|
+
"& .ant-upload-btn": {
|
|
80
|
+
display: "block",
|
|
81
|
+
width: "100%",
|
|
82
|
+
outline: "none",
|
|
83
|
+
},
|
|
84
|
+
"& .ant-upload input[type='file']": {
|
|
85
|
+
cursor: "pointer",
|
|
86
|
+
},
|
|
87
|
+
"& .ant-upload.ant-upload-disabled": {
|
|
88
|
+
color: themeVars.disabledTextColor,
|
|
89
|
+
cursor: "not-allowed",
|
|
90
|
+
},
|
|
91
|
+
"& .ant-upload.ant-upload-disabled input[type='file']": {
|
|
92
|
+
cursor: "not-allowed",
|
|
93
|
+
},
|
|
94
|
+
"& .ant-upload-select": {
|
|
95
|
+
display: "inline-flex",
|
|
96
|
+
alignItems: "stretch",
|
|
97
|
+
maxWidth: "100%",
|
|
98
|
+
},
|
|
99
|
+
"& .ant-upload-select > .ant-upload": {
|
|
100
|
+
display: "inline-flex",
|
|
101
|
+
alignItems: "center",
|
|
102
|
+
outline: "none",
|
|
103
|
+
},
|
|
104
|
+
"& .ant-upload:where(.ant-upload-drag), & .ant-upload:where(.ant-upload-select-picture-card)": {
|
|
33
105
|
border: `1px dashed ${themeVars.colorAccentBgStrong}`,
|
|
34
106
|
position: "relative",
|
|
35
107
|
backgroundColor: themeVars.transparent,
|
|
36
108
|
borderRadius: border.radius6,
|
|
37
|
-
transition: `border-color ${
|
|
109
|
+
transition: `border-color ${transitions.faster}`,
|
|
110
|
+
cursor: "pointer",
|
|
38
111
|
margin: 0,
|
|
39
112
|
flex: 1,
|
|
40
113
|
alignSelf: "stretch",
|
|
@@ -57,19 +130,204 @@ export const antUploadStyle = css`
|
|
|
57
130
|
alignContent: "stretch",
|
|
58
131
|
padding: space.s8,
|
|
59
132
|
},
|
|
60
|
-
"&.ant-upload-drag-hover": {
|
|
61
|
-
border: `1px dashed ${themeVars.
|
|
133
|
+
"&.ant-upload-drag-hover:not(.ant-upload-disabled)": {
|
|
134
|
+
border: `1px dashed ${themeVars.colorAccentStrokeFocus}`,
|
|
62
135
|
transition: "none",
|
|
63
136
|
},
|
|
64
|
-
"&:hover": {
|
|
65
|
-
border: `1px dashed ${themeVars.
|
|
137
|
+
"&:not(.ant-upload-disabled):hover": {
|
|
138
|
+
border: `1px dashed ${themeVars.colorAccentStrokeHover}`,
|
|
66
139
|
transition: "none",
|
|
67
140
|
},
|
|
68
141
|
},
|
|
142
|
+
"& .ant-upload.ant-upload-drag .ant-upload-btn": {
|
|
143
|
+
display: "table",
|
|
144
|
+
height: "100%",
|
|
145
|
+
},
|
|
146
|
+
"& .ant-upload.ant-upload-drag .ant-upload-drag-container": {
|
|
147
|
+
display: "table-cell",
|
|
148
|
+
verticalAlign: "middle",
|
|
149
|
+
},
|
|
150
|
+
"& .ant-upload-picture-card-wrapper": {
|
|
151
|
+
display: "inline-block",
|
|
152
|
+
width: "100%",
|
|
153
|
+
},
|
|
154
|
+
"& .ant-upload-picture-card-wrapper::before": {
|
|
155
|
+
display: "table",
|
|
156
|
+
content: "''",
|
|
157
|
+
},
|
|
158
|
+
"& .ant-upload-picture-card-wrapper::after": {
|
|
159
|
+
display: "table",
|
|
160
|
+
clear: "both",
|
|
161
|
+
content: "''",
|
|
162
|
+
},
|
|
69
163
|
}}
|
|
70
164
|
`;
|
|
71
165
|
|
|
72
|
-
export
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
166
|
+
export type AntUploadProps = Omit<
|
|
167
|
+
RcUploadProps,
|
|
168
|
+
"prefixCls" | "onStart" | "onSuccess" | "onError" | "onProgress" | "type" | "onChange" | "children"
|
|
169
|
+
> & {
|
|
170
|
+
type?: "select" | "drag";
|
|
171
|
+
listType?: "text" | "picture" | "picture-card";
|
|
172
|
+
disabled?: boolean;
|
|
173
|
+
className?: string;
|
|
174
|
+
wrapClassName?: string;
|
|
175
|
+
children?: React.ReactNode;
|
|
176
|
+
onChange?: (info: UploadChangeParam) => void;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
function Wrapper({className, ...props}: ComponentPropsWithoutRef<"div">) {
|
|
180
|
+
return <div className={cx(className, antUploadStyle)} {...props} />;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export const AntUpload = forwardRef<HTMLSpanElement, AntUploadProps>(function AntUpload(
|
|
184
|
+
{type = "select", listType = "text", disabled, className, wrapClassName, children, onChange, ...rcProps},
|
|
185
|
+
ref
|
|
186
|
+
) {
|
|
187
|
+
const [fileList, setFileList] = useState<UploadFile[]>([]);
|
|
188
|
+
const fileListRef = useRef(fileList);
|
|
189
|
+
fileListRef.current = fileList;
|
|
190
|
+
const [dragState, setDragState] = useState<"drop" | "dragover" | "dragleave">("drop");
|
|
191
|
+
|
|
192
|
+
const emit = useCallback(
|
|
193
|
+
(file: UploadFile, nextList: UploadFile[], event?: {percent: number}) => {
|
|
194
|
+
fileListRef.current = nextList;
|
|
195
|
+
setFileList(nextList);
|
|
196
|
+
onChange?.({file, fileList: nextList, event});
|
|
197
|
+
},
|
|
198
|
+
[onChange]
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
const handleStart = useCallback(
|
|
202
|
+
(file: RcFile) => {
|
|
203
|
+
const obj = file2Obj(file);
|
|
204
|
+
obj.status = "uploading";
|
|
205
|
+
emit(obj, upsertFile(obj, fileListRef.current));
|
|
206
|
+
},
|
|
207
|
+
[emit]
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
const handleProgress = useCallback(
|
|
211
|
+
(event: {percent?: number}, file: RcFile) => {
|
|
212
|
+
const current = fileListRef.current.find((f) => f.uid === file.uid);
|
|
213
|
+
if (!current) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const next = {...current, status: "uploading" as UploadFileStatus, percent: event.percent};
|
|
217
|
+
emit(next, upsertFile(next, fileListRef.current), {percent: event.percent ?? 0});
|
|
218
|
+
},
|
|
219
|
+
[emit]
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
const handleSuccess = useCallback(
|
|
223
|
+
(response: unknown, file: RcFile, xhr?: XMLHttpRequest) => {
|
|
224
|
+
const current = fileListRef.current.find((f) => f.uid === file.uid);
|
|
225
|
+
if (!current) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
let parsed = response;
|
|
229
|
+
if (typeof response === "string") {
|
|
230
|
+
try {
|
|
231
|
+
parsed = JSON.parse(response);
|
|
232
|
+
} catch {
|
|
233
|
+
/* ignore */
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const next: UploadFile = {
|
|
237
|
+
...current,
|
|
238
|
+
status: "done",
|
|
239
|
+
percent: 100,
|
|
240
|
+
response: parsed,
|
|
241
|
+
xhr,
|
|
242
|
+
};
|
|
243
|
+
emit(next, upsertFile(next, fileListRef.current));
|
|
244
|
+
},
|
|
245
|
+
[emit]
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
const handleError = useCallback(
|
|
249
|
+
(error: Error, response: unknown, file: RcFile) => {
|
|
250
|
+
const current = fileListRef.current.find((f) => f.uid === file.uid);
|
|
251
|
+
if (!current) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const next: UploadFile = {
|
|
255
|
+
...current,
|
|
256
|
+
status: "error",
|
|
257
|
+
error,
|
|
258
|
+
response,
|
|
259
|
+
};
|
|
260
|
+
emit(next, upsertFile(next, fileListRef.current));
|
|
261
|
+
},
|
|
262
|
+
[emit]
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
const onFileDrop = useCallback((e: React.DragEvent<HTMLDivElement>) => {
|
|
266
|
+
setDragState(e.type as typeof dragState);
|
|
267
|
+
}, []);
|
|
268
|
+
|
|
269
|
+
const rcUploadProps: RcUploadProps = {
|
|
270
|
+
...rcProps,
|
|
271
|
+
prefixCls: "ant-upload",
|
|
272
|
+
disabled,
|
|
273
|
+
onStart: handleStart,
|
|
274
|
+
onProgress: handleProgress,
|
|
275
|
+
onSuccess: handleSuccess,
|
|
276
|
+
onError: handleError,
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
if (type === "drag") {
|
|
280
|
+
const hasUploading = fileList.some((f) => f.status === "uploading");
|
|
281
|
+
const dragCls = cx(
|
|
282
|
+
"ant-upload",
|
|
283
|
+
"ant-upload-drag",
|
|
284
|
+
hasUploading && "ant-upload-drag-uploading",
|
|
285
|
+
dragState === "dragover" && "ant-upload-drag-hover",
|
|
286
|
+
disabled && "ant-upload-disabled",
|
|
287
|
+
className
|
|
288
|
+
);
|
|
289
|
+
return (
|
|
290
|
+
<Wrapper className={wrapClassName}>
|
|
291
|
+
<span ref={ref}>
|
|
292
|
+
<div className={dragCls} onDrop={onFileDrop} onDragOver={onFileDrop} onDragLeave={onFileDrop}>
|
|
293
|
+
<RcUpload {...rcUploadProps} className="ant-upload-btn">
|
|
294
|
+
<div className="ant-upload-drag-container">{children}</div>
|
|
295
|
+
</RcUpload>
|
|
296
|
+
</div>
|
|
297
|
+
</span>
|
|
298
|
+
</Wrapper>
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const buttonCls = cx(
|
|
303
|
+
"ant-upload",
|
|
304
|
+
"ant-upload-select",
|
|
305
|
+
`ant-upload-select-${listType}`,
|
|
306
|
+
disabled && "ant-upload-disabled"
|
|
307
|
+
);
|
|
308
|
+
const button = (
|
|
309
|
+
<div className={buttonCls}>
|
|
310
|
+
<RcUpload {...rcUploadProps}>{children}</RcUpload>
|
|
311
|
+
</div>
|
|
312
|
+
);
|
|
313
|
+
|
|
314
|
+
if (listType === "picture-card") {
|
|
315
|
+
return (
|
|
316
|
+
<Wrapper className={wrapClassName}>
|
|
317
|
+
<span ref={ref} className={cx("ant-upload-picture-card-wrapper", className)}>
|
|
318
|
+
{button}
|
|
319
|
+
</span>
|
|
320
|
+
</Wrapper>
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return (
|
|
325
|
+
<Wrapper className={wrapClassName}>
|
|
326
|
+
<span ref={ref} className={className}>
|
|
327
|
+
{button}
|
|
328
|
+
</span>
|
|
329
|
+
</Wrapper>
|
|
330
|
+
);
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
export type {UploadRequestOption};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import {css, cx} from "@linaria/core";
|
|
2
|
+
import Select from "rc-select";
|
|
3
|
+
import type {BaseSelectRef, SelectProps} from "rc-select";
|
|
4
|
+
import type {DefaultOptionType} from "rc-select/lib/Select";
|
|
5
|
+
import type {ReactElement} from "react";
|
|
6
|
+
import {forwardRef, useCallback} from "react";
|
|
7
|
+
|
|
8
|
+
import {border, layout, space, textStyles, themeVars, transitions} from "../design-system";
|
|
9
|
+
import {ThemeProvider} from "../theme-provider";
|
|
10
|
+
import {getWrapper} from "./get-wrapper";
|
|
11
|
+
import {wrapWithPopupContainer} from "./utils";
|
|
12
|
+
|
|
13
|
+
const autoCompleteStyles = css`
|
|
14
|
+
${{
|
|
15
|
+
position: "relative",
|
|
16
|
+
"& .ant-select": {
|
|
17
|
+
...textStyles.regular,
|
|
18
|
+
boxSizing: "border-box",
|
|
19
|
+
display: "inline-block",
|
|
20
|
+
width: "100%",
|
|
21
|
+
cursor: "text",
|
|
22
|
+
},
|
|
23
|
+
"& .ant-select-selector": {
|
|
24
|
+
boxSizing: "border-box",
|
|
25
|
+
display: "flex",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
width: "100%",
|
|
28
|
+
minHeight: layout.inputHeight,
|
|
29
|
+
position: "relative",
|
|
30
|
+
backgroundColor: themeVars.transparent,
|
|
31
|
+
},
|
|
32
|
+
"& .ant-select-selection-search": {
|
|
33
|
+
flex: 1,
|
|
34
|
+
minWidth: 0,
|
|
35
|
+
},
|
|
36
|
+
"& .ant-select-selection-search-input, & .ant-select-selection-search .ant-input": {
|
|
37
|
+
width: "100%",
|
|
38
|
+
margin: 0,
|
|
39
|
+
// horizontal padding to match other Fibery inputs (was 0 → text sat flush against selector edge,
|
|
40
|
+
// a regression vs master where antd input CSS gave it 4px 11px)
|
|
41
|
+
padding: `0 ${space.s12}px`,
|
|
42
|
+
border: "none",
|
|
43
|
+
outline: "none",
|
|
44
|
+
backgroundColor: themeVars.transparent,
|
|
45
|
+
appearance: "none",
|
|
46
|
+
...textStyles.regular,
|
|
47
|
+
},
|
|
48
|
+
"& .ant-select-dropdown": {
|
|
49
|
+
boxSizing: "border-box",
|
|
50
|
+
position: "absolute",
|
|
51
|
+
zIndex: 1050,
|
|
52
|
+
backgroundColor: themeVars.colorBgPopup,
|
|
53
|
+
boxShadow: themeVars.shadowSelectMenu,
|
|
54
|
+
borderRadius: border.radius6,
|
|
55
|
+
paddingTop: space.s8,
|
|
56
|
+
paddingBottom: space.s8,
|
|
57
|
+
},
|
|
58
|
+
"& .ant-select-dropdown-hidden": {
|
|
59
|
+
display: "none",
|
|
60
|
+
},
|
|
61
|
+
"& .ant-select-item-empty": {
|
|
62
|
+
minHeight: 32,
|
|
63
|
+
padding: "5px 12px",
|
|
64
|
+
lineHeight: "22px",
|
|
65
|
+
color: themeVars.colorTextListItemGeneralDisabled,
|
|
66
|
+
},
|
|
67
|
+
"& .ant-select-item": {
|
|
68
|
+
...textStyles.regular,
|
|
69
|
+
color: themeVars.textColor,
|
|
70
|
+
minHeight: 32,
|
|
71
|
+
padding: "5px 12px",
|
|
72
|
+
lineHeight: "22px",
|
|
73
|
+
backgroundColor: themeVars.colorBgListItemGeneral,
|
|
74
|
+
borderRadius: border.radius6,
|
|
75
|
+
cursor: "pointer",
|
|
76
|
+
transition: `background-color ${transitions.slow}`,
|
|
77
|
+
},
|
|
78
|
+
"& .ant-select-item-option-content": {
|
|
79
|
+
flex: 1,
|
|
80
|
+
overflow: "hidden",
|
|
81
|
+
textOverflow: "ellipsis",
|
|
82
|
+
whiteSpace: "nowrap",
|
|
83
|
+
},
|
|
84
|
+
"& .ant-select-item-option-state": {
|
|
85
|
+
display: "none",
|
|
86
|
+
},
|
|
87
|
+
"& .ant-select-item-option": {
|
|
88
|
+
display: "flex",
|
|
89
|
+
alignItems: "center",
|
|
90
|
+
"&:hover": {
|
|
91
|
+
backgroundColor: themeVars.colorBgListItemGeneralHover,
|
|
92
|
+
},
|
|
93
|
+
"&.ant-select-item-option-active:not(.ant-select-item-option-disabled)": {
|
|
94
|
+
backgroundColor: themeVars.colorBgListItemGeneralFocus,
|
|
95
|
+
},
|
|
96
|
+
"&.ant-select-item-option-selected:not(.ant-select-item-option-disabled)": {
|
|
97
|
+
fontWeight: "normal",
|
|
98
|
+
backgroundColor: themeVars.colorBgListItemGeneralSelected,
|
|
99
|
+
"&:hover": {
|
|
100
|
+
backgroundColor: themeVars.colorBgListItemGeneralSelectedHover,
|
|
101
|
+
},
|
|
102
|
+
"&.ant-select-item-option-active": {
|
|
103
|
+
backgroundColor: themeVars.colorBgListItemGeneralSelectedFocus,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
"&.ant-select-item-option-disabled": {
|
|
107
|
+
color: themeVars.colorTextListItemGeneralDisabled,
|
|
108
|
+
backgroundColor: themeVars.colorBgListItemGeneralDisabled,
|
|
109
|
+
cursor: "not-allowed",
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
}}
|
|
113
|
+
`;
|
|
114
|
+
|
|
115
|
+
type AutoCompleteProps<ValueType = string, OptionType extends DefaultOptionType = DefaultOptionType> = Omit<
|
|
116
|
+
SelectProps<ValueType, OptionType>,
|
|
117
|
+
"mode" | "prefixCls" | "getInputElement" | "children"
|
|
118
|
+
> & {
|
|
119
|
+
children?: ReactElement;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const AutoComplete = forwardRef<BaseSelectRef, AutoCompleteProps>(function AutoComplete(
|
|
123
|
+
{children, className, dropdownRender, ...props},
|
|
124
|
+
ref
|
|
125
|
+
) {
|
|
126
|
+
const getInputElement = children ? () => children : undefined;
|
|
127
|
+
const themedDropdownRender = useCallback(
|
|
128
|
+
(menu: ReactElement) => <ThemeProvider portal>{dropdownRender ? dropdownRender(menu) : menu}</ThemeProvider>,
|
|
129
|
+
[dropdownRender]
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<Select<string>
|
|
134
|
+
ref={ref}
|
|
135
|
+
prefixCls="ant-select"
|
|
136
|
+
className={cx("ant-select-auto-complete", className)}
|
|
137
|
+
mode="combobox"
|
|
138
|
+
getInputElement={getInputElement}
|
|
139
|
+
dropdownRender={themedDropdownRender}
|
|
140
|
+
{...props}
|
|
141
|
+
/>
|
|
142
|
+
);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
export const AntAutoComplete = wrapWithPopupContainer(getWrapper(autoCompleteStyles), AutoComplete);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {useComposedRefs} from "@fibery/react/src/use-composed-refs";
|
|
2
2
|
import {css, cx} from "@linaria/core";
|
|
3
|
-
import TextArea from "
|
|
3
|
+
import TextArea from "rc-textarea";
|
|
4
4
|
import {forwardRef, useRef} from "react";
|
|
5
5
|
|
|
6
6
|
import {TransparentInputWrapper} from "./input";
|
|
@@ -50,7 +50,14 @@ export const AutoWidthTransparentTextArea = forwardRef<HTMLDivElement, AutoWidth
|
|
|
50
50
|
data-value={props.value || props.placeholder}
|
|
51
51
|
ref={composedRef}
|
|
52
52
|
>
|
|
53
|
-
<TextArea
|
|
53
|
+
<TextArea
|
|
54
|
+
prefixCls="ant-input"
|
|
55
|
+
className={cx("ant-input", textArea, className)}
|
|
56
|
+
style={style}
|
|
57
|
+
onChange={handleChange}
|
|
58
|
+
cols={1}
|
|
59
|
+
{...props}
|
|
60
|
+
/>
|
|
54
61
|
</TransparentInputWrapper>
|
|
55
62
|
);
|
|
56
63
|
}
|