Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
2d61d98
chore: init
zombieJ Oct 9, 2025
597ecab
of it
zombieJ Oct 9, 2025
f1e9ff9
chore: of it
zombieJ Oct 10, 2025
4a6925f
chore: fill content
zombieJ Oct 10, 2025
2477daf
chore: style
zombieJ Oct 10, 2025
1c2573d
chore: style
zombieJ Oct 10, 2025
e1c5e34
chore: basic content
zombieJ Oct 10, 2025
d954431
chore: blur clear
zombieJ Oct 10, 2025
b14de98
chore: clear logic
zombieJ Oct 11, 2025
992b22d
chore: fit logic
zombieJ Oct 11, 2025
012e64f
chore: connect logic
zombieJ Oct 11, 2025
d78b95f
chore: fix logic
zombieJ Oct 11, 2025
70fa69f
chore: fix logic
zombieJ Oct 11, 2025
9e32905
chore: adjust omit position
zombieJ Oct 11, 2025
9e78943
chore: adjust omit position
zombieJ Oct 11, 2025
fe07192
chore: adjust omit position
zombieJ Oct 11, 2025
85b64f7
test: more test
zombieJ Oct 11, 2025
7f38025
chore: test config
zombieJ Oct 11, 2025
3ca6f16
chore: test config
zombieJ Oct 11, 2025
f9e8a2c
chore: adjust logic
zombieJ Oct 11, 2025
9a4d6d3
chore: backfill
zombieJ Oct 11, 2025
8101a4c
chore: lots of logic
zombieJ Oct 11, 2025
fcc578d
chore: lots of logic
zombieJ Oct 11, 2025
d04df92
chore: connect combobox
zombieJ Oct 11, 2025
341a834
test: fix test
zombieJ Oct 11, 2025
3f538ab
chore: add polit
zombieJ Oct 11, 2025
484c523
chore: mv code
zombieJ Oct 11, 2025
0a18a4f
chore: multiple
zombieJ Oct 11, 2025
1faca1f
chore: multiple of it
zombieJ Oct 11, 2025
211f982
chore: clean up
zombieJ Oct 13, 2025
5e712d1
chore: fix logic
zombieJ Oct 13, 2025
db75428
chore: fix logic
zombieJ Oct 13, 2025
c03a03e
test: batch update
zombieJ Oct 13, 2025
ef34813
test: batch update
zombieJ Oct 13, 2025
f71f4c5
fix: display logic
zombieJ Oct 13, 2025
afdf9c5
fix: display logic
zombieJ Oct 13, 2025
cf95331
test: update snapshot
zombieJ Oct 13, 2025
0ed8ae6
chore: more logic
zombieJ Oct 13, 2025
83cd06f
chore: more
zombieJ Oct 13, 2025
2b14e52
chore: more and more
zombieJ Oct 13, 2025
c91c43b
test: update snapshot
zombieJ Oct 13, 2025
8b2da80
test: update snapshot
zombieJ Oct 13, 2025
27e7b2c
test: base test
zombieJ Oct 13, 2025
04db275
chore: update
zombieJ Oct 13, 2025
de31413
chore: update
zombieJ Oct 13, 2025
648f73d
test: fix test
zombieJ Oct 13, 2025
3f98735
chore: adjust cls
zombieJ Oct 13, 2025
30bdebe
chore: multiple default search
zombieJ Oct 13, 2025
97bce99
chore: of it
zombieJ Oct 14, 2025
b606279
chore: of it
zombieJ Oct 14, 2025
4649241
test: all of multiple
zombieJ Oct 14, 2025
36220d3
chore: clean up
zombieJ Oct 14, 2025
e81f2f5
chore: adjust logic
zombieJ Oct 14, 2025
de3f3a6
chore: replace components
zombieJ Oct 14, 2025
a8ca6ec
chore: support components
zombieJ Oct 14, 2025
0ca69af
chore: of it
zombieJ Oct 14, 2025
370a165
chore: new logic of passing
zombieJ Oct 14, 2025
8234174
chore: fix input logic
zombieJ Oct 14, 2025
2cb9ad2
test: fix test
zombieJ Oct 14, 2025
97ee306
test: fix test
zombieJ Oct 14, 2025
7e86869
chore: fix combobox logic
zombieJ Oct 15, 2025
ff55f9a
chore: fix ref
zombieJ Oct 15, 2025
250d0c8
chore: all test
zombieJ Oct 15, 2025
a8d598c
chore: clean up
zombieJ Oct 15, 2025
7e2ffc6
chore: clean up
zombieJ Oct 15, 2025
d5f7692
chore: clean up
zombieJ Oct 15, 2025
2facc4e
chore: adjust import
zombieJ Oct 16, 2025
1428565
chore: rm useless file
zombieJ Oct 16, 2025
41ccbca
chore: clean up
zombieJ Oct 16, 2025
fd508bd
chore: clean up
zombieJ Oct 16, 2025
be51de6
test: coverage
zombieJ Oct 16, 2025
ff308c8
test: coverage
zombieJ Oct 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: adjust omit position
  • Loading branch information
zombieJ committed Oct 11, 2025
commit 9e7894393dae71227e4e5cf5b2b28c52534f1220
15 changes: 12 additions & 3 deletions src/SelectInput/Content/MultipleContent.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import * as React from 'react';
import Input from '../Input';
import { useSelectInputContext } from '../context';
import type { SharedContentProps } from '.';

// This is just a placeholder, do not code any logic here

export default React.forwardRef<HTMLInputElement>(function MultipleContent(_, ref) {
const { prefixCls, displayValues: value, maxLength } = useSelectInputContext();
export default React.forwardRef<HTMLInputElement, SharedContentProps>(function MultipleContent(
{ inputProps },
ref,
) {
const { prefixCls, displayValues: value, maxLength, mode } = useSelectInputContext();

// For multiple mode, we show all values as a comma-separated string
const displayValue = value
Expand All @@ -14,7 +18,12 @@ export default React.forwardRef<HTMLInputElement>(function MultipleContent(_, re

return (
<div className={`${prefixCls}-content`}>
<Input ref={ref} value={displayValue} maxLength={maxLength} />
<Input
ref={ref}
{...inputProps}
value={displayValue}
maxLength={mode === 'combobox' ? maxLength : undefined}
/>
</div>
);
});
15 changes: 12 additions & 3 deletions src/SelectInput/Content/SingleContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import * as React from 'react';
import Input from '../Input';
import { useSelectInputContext } from '../context';
import Placeholder from './Placeholder';
import type { SharedContentProps } from '.';

export default React.forwardRef<HTMLInputElement>(function SingleContent(_, ref) {
const { prefixCls, searchValue, displayValues, maxLength } = useSelectInputContext();
export default React.forwardRef<HTMLInputElement, SharedContentProps>(function SingleContent(
{ inputProps },
ref,
) {
const { prefixCls, searchValue, displayValues, maxLength, mode } = useSelectInputContext();

const displayValue = displayValues[0];

Expand All @@ -22,7 +26,12 @@ export default React.forwardRef<HTMLInputElement>(function SingleContent(_, ref)
) : (
<Placeholder />
)}
<Input ref={ref} value={searchValue} maxLength={maxLength} />
<Input
ref={ref}
{...inputProps}
value={searchValue}
maxLength={mode === 'combobox' ? maxLength : undefined}
/>
</div>
);
});
14 changes: 11 additions & 3 deletions src/SelectInput/Content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ import SingleContent from './SingleContent';
import MultipleContent from './MultipleContent';
import { useSelectInputContext } from '../context';

export interface SharedContentProps {
inputProps: React.HTMLAttributes<HTMLInputElement>;
}

const SelectContent = React.forwardRef<HTMLInputElement>(function SelectContent(_, ref) {
const { multiple } = useSelectInputContext();
const { multiple, onInputKeyDown } = useSelectInputContext();

const sharedInputProps: SharedContentProps['inputProps'] = {
onKeyDown: onInputKeyDown,
};

if (multiple) {
return <MultipleContent ref={ref} />;
return <MultipleContent ref={ref} inputProps={sharedInputProps} />;
}

return <SingleContent ref={ref} />;
return <SingleContent ref={ref} inputProps={sharedInputProps} />;
});

export default SelectContent;
1 change: 0 additions & 1 deletion src/SelectInput/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>((props, ref) => {
ref={ref}
autoFocus={autoFocus}
className={inputCls}
maxLength={mode === 'combobox' ? maxLength : undefined}
onChange={handleChange}
onKeyDown={handleKeyDown}
onBlur={handleBlur}
Expand Down
16 changes: 2 additions & 14 deletions src/SelectInput/context.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
import type { DisplayValueType, Mode } from '../interface';
import * as React from 'react';
import type { SelectInputProps } from '.';

export interface ContentContextProps {
prefixCls: string;
multiple: boolean;
displayValues: DisplayValueType[];
placeholder: React.ReactNode;
searchValue: string;
maxLength?: number;
autoFocus?: boolean;
mode: Mode;
onSearch: (searchText: string, fromTyping: boolean, isCompositing: boolean) => void;
onSearchSubmit: (searchText: string) => void;
onInputBlur: () => void;
}
export type ContentContextProps = SelectInputProps;

const SelectInputContext = React.createContext<ContentContextProps>(null!);

Expand Down
67 changes: 20 additions & 47 deletions src/SelectInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,6 @@ import Affix from './Affix';
import SelectContent from './Content';
import SelectInputContext, { type ContentContextProps } from './context';
import type { DisplayValueType, Mode } from '../interface';
import useBaseProps from '../hooks/useBaseProps';
import { omit, useEvent } from '@rc-component/util';

const DEFAULT_OMIT_PROPS = [
'value',
'onChange',
'removeIcon',
'placeholder',
'maxTagCount',
'maxTagTextLength',
'maxTagPlaceholder',
'choiceTransitionName',
'onInputKeyDown',
'onPopupScroll',
'tabIndex',
] as const;

export interface SelectInputRef {
focus: (options?: FocusOptions) => void;
Expand All @@ -41,12 +25,30 @@ export interface SelectInputProps extends Omit<React.HTMLAttributes<HTMLDivEleme
onSearchSubmit?: (searchText: string) => void;
onInputBlur?: () => void;
onClearMouseDown?: React.MouseEventHandler<HTMLElement>;
onInputKeyDown?: React.KeyboardEventHandler<HTMLInputElement | HTMLTextAreaElement>;
maxLength?: number;
autoFocus?: boolean;
// Add other props that need to be passed through
className?: string;
style?: React.CSSProperties;
[key: string]: any;
}
import useBaseProps from '../hooks/useBaseProps';
import { omit, useEvent } from '@rc-component/util';

const DEFAULT_OMIT_PROPS = [
'value',
'onChange',
'removeIcon',
'placeholder',
'maxTagCount',
'maxTagTextLength',
'maxTagPlaceholder',
'choiceTransitionName',
'onInputKeyDown',
'onPopupScroll',
'tabIndex',
] as const;

export default React.forwardRef<SelectInputRef, SelectInputProps>(function SelectInput(
props: SelectInputProps,
Expand Down Expand Up @@ -83,6 +85,7 @@ export default React.forwardRef<SelectInputRef, SelectInputProps>(function Selec
onMouseDown,
onBlur,
onClearMouseDown,
onInputKeyDown,

...restProps
} = props;
Expand Down Expand Up @@ -128,41 +131,11 @@ export default React.forwardRef<SelectInputRef, SelectInputProps>(function Selec
onBlur?.(event);
};

// ==================== Context =====================
const cachedContext = React.useMemo<ContentContextProps>(
() => ({
prefixCls,
multiple: !!multiple,
displayValues,
placeholder,
searchValue,
mode,
onSearch,
onSearchSubmit,
onInputBlur,
maxLength,
autoFocus,
}),
[
prefixCls,
multiple,
displayValues,
placeholder,
searchValue,
mode,
onSearch,
onSearchSubmit,
onInputBlur,
maxLength,
autoFocus,
],
);

// ===================== Render =====================
const domProps = omit(restProps, DEFAULT_OMIT_PROPS);

return (
<SelectInputContext.Provider value={cachedContext}>
<SelectInputContext.Provider value={props}>
<div
{...domProps}
// Style
Expand Down