Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

React Suite V6 #4084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 152 commits into
base: main
Choose a base branch
Loading
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
4b6b61c
build(deps): bump react-window from 1.8.8 to 1.8.11 (#4074)
simonguo Dec 20, 2024
e74920a
refactor: remove propTypes and use fireEvent instead of ReactDOMTestU…
simonguo Dec 20, 2024
4868e0e
refactor: remove special handling code for IE11 support (#4077)
simonguo Dec 23, 2024
a1107ef
refactor: deprecated React 17 (#4078)
simonguo Dec 23, 2024
03d5e4b
Merge branch 'main' into next
simonguo Dec 24, 2024
f3d3bbf
build: bump date-fns@4.1.0 (#4079)
obdulia-losantos Dec 24, 2024
d679636
refactor: remove deprecated Less variables (#4080)
simonguo Dec 24, 2024
44393c8
build(deps): bump lunar-typescript from 1.7.5 to 1.7.6 in docs (#4083)
simonguo Dec 24, 2024
b69b002
ci: add size-limit (#4086)
simonguo Dec 25, 2024
fa8bcdb
refactor(less): remove special handling code for IE11 support (#4087)
simonguo Dec 26, 2024
f263246
chore: run npm audit fix --force to update dependencies (#4089)
simonguo Dec 26, 2024
82e7a79
build(deps): bump stylelint from 14 to 16 (#4090)
simonguo Dec 26, 2024
4c0efdb
build(deps): bump babel 7.26.* (#4091)
simonguo Dec 26, 2024
3449dc3
build(deps): bump eslint from 7.25.0 to 9.17.0 (#4092)
simonguo Dec 27, 2024
fa2a076
ci(mocha): fix test command error when release version (#4093)
simonguo Dec 27, 2024
b88f83e
build(deps): bump less from 3.7.0 to 4.2.1 (#4094)
simonguo Dec 27, 2024
b3199d3
feat(Badge): add support for `compact`, `invisible`, `outline`, `plac…
simonguo Dec 31, 2024
7a190be
Merge branch 'main' into next
simonguo Jan 1, 2025
0a3e0e2
chore: remove deprecated dtslint (#4100)
simonguo Jan 2, 2025
e80e4fb
refactor(toaster): removed support for React 17 (#4102)
simonguo Jan 2, 2025
c419d14
build(deps): bump prettier from 2.8.8 to 3.4.2 (#4101)
simonguo Jan 2, 2025
613d142
feat(Tag): support custom color (#4104)
simonguo Jan 2, 2025
db6e615
test: add tests for Rate
simonguo Jan 2, 2025
10bc4e5
feat(Rate): add custom color support (#4105)
simonguo Jan 3, 2025
cf160fe
feat(Button): add support for toggleable and onToggle (#4095)
simonguo Jan 3, 2025
8635e84
build(deps): bump gulp-sourcemaps from 2.6.4 to 3.0.0 (#4108)
simonguo Jan 3, 2025
c449205
Merge branch 'main' into next
simonguo Jan 7, 2025
5ec1c4f
Merge branch 'main' into next
simonguo Jan 10, 2025
5e2eb4a
feat(Text): support custom color (#4106)
simonguo Jan 10, 2025
fb319f8
fix(Tree): improve duplicate value detection in Tree data structure a…
simonguo Jan 10, 2025
f84d095
feat(Navbar): adopt new design, optimize style and interaction (#4096)
simonguo Jan 10, 2025
31d21e2
refactor: improve the type export of all components (#4117)
simonguo Jan 13, 2025
399a43d
docs: remove deprecated props from v5 (#4115)
simonguo Jan 14, 2025
2406bca
feat(Navbar): add `visible` and `hidden` prop on Navbar.Content to su…
simonguo Jan 20, 2025
21f736b
chore: merge code from main branch
simonguo Jan 21, 2025
6dad326
docs: add Bun installation guide and update related documentation (#4…
simonguo Jan 21, 2025
b1d949d
test(Badge): add style test cases for positioning and independent dis…
simonguo Jan 21, 2025
9dfb1d7
refactor(docs): optimize device simulation and code display (#4122)
simonguo Jan 21, 2025
af6276a
feat(sidenav): implement new design for Sidenav (#4132)
simonguo Jan 24, 2025
99ed6d9
chore: merge main
simonguo Feb 7, 2025
09a5507
chore: merge main
simonguo Feb 7, 2025
60d5c0b
chore: update dependencies (#4143)
simonguo Feb 7, 2025
37cc54c
fix(pickers): improve pickers `renderValue` property type definition …
simonguo Feb 8, 2025
654ba35
feat(ButtonGroup): add disabled prop to ButtonGroup (#4146)
simonguo Feb 8, 2025
53992a9
docs: update theme documentation and related components (#4148)
simonguo Feb 9, 2025
2017b7a
feat(ButtonGroup): add divided property and improve button styles (#4…
simonguo Feb 9, 2025
93f86e8
fix(InputGroup): improve button styles in inside mode (#4149)
simonguo Feb 9, 2025
61796cd
feat(Kbd): add support for Kbd (#4150)
simonguo Feb 10, 2025
2264379
chore: merge main
simonguo Feb 21, 2025
8f9175f
refactor: use `rem` instead of `px` and use CSS variables (#4152)
simonguo Feb 21, 2025
7f55b6b
docs(animation): enhance animation examples (#4157)
simonguo Feb 21, 2025
26bc9f5
docs: update UI suite descriptions and style adjustments
simonguo Feb 21, 2025
35eb5a5
docs(animation): update animation fragments with new styles and descr…
simonguo Feb 21, 2025
dcbe346
docs(animation): adjust collapse animation fragment for consistent st…
simonguo Feb 21, 2025
4882ae8
refactor(styles): replace physical CSS properties with logical proper…
simonguo Feb 24, 2025
c469bed
docs: update component documentation format (#4159)
simonguo Feb 24, 2025
bba8e2f
refactor(Picker)!: rename properties for better consistency (#4160)
simonguo Feb 24, 2025
29f2ae7
feat(Menu): add Menu component (#4161)
simonguo Feb 26, 2025
e2a1eed
refactor(types): improve HTML props type definitions and organization
simonguo Feb 26, 2025
7143753
feat(Divider): enhance Divider component (#4164)
simonguo Mar 2, 2025
44705a5
feat(Navbar): add support for Nav.MegaMenu (#4162)
simonguo Mar 2, 2025
62f6aee
feat(Grid): redesign Row and Col components, optimize responsive layo…
simonguo Mar 5, 2025
a5173ca
fix(FormErrorMessage): use standard radius variable (#4169)
simonguo Mar 6, 2025
2a5ad86
refactor(Stack): update Stack component API and improve styles (#4167)
simonguo Mar 6, 2025
a968f32
refactor(FormErrorMessage): improve styles and placement handling (#4…
simonguo Mar 6, 2025
4df2425
refactor: improve dropdown and sidenav placement handling (#4171)
simonguo Mar 7, 2025
d10f4d3
refactor(overlay): improve overlay component architecture and positio…
simonguo Mar 9, 2025
954f29f
feat(Drawer): enhance responsive behavior and styling (#4176)
simonguo Mar 10, 2025
64da403
Merge branch 'main' into next
simonguo Mar 10, 2025
4d539b2
feat(Modal): add centered property and improve documentation for Moda…
simonguo Mar 12, 2025
8592d52
feat(Breadcrumb): enhance Breadcrumb component with size, icon suppor…
simonguo Mar 12, 2025
a08b986
feat: add Box and Center components (#4182)
simonguo Mar 14, 2025
15392be
fix(Box): improve responsive visibility behavior (#4185)
simonguo Mar 14, 2025
7d0c323
refactor(Uploader): migrate to TypeScript and improve code quality
simonguo Mar 15, 2025
30e9ba1
feat: migrate components to use Box as base component (#4188)
simonguo Mar 19, 2025
a63adda
feat: add named exports for Schema types and improve component styles…
simonguo Mar 19, 2025
5afddde
feat(Form): add FormStack component and update form styles (#4191)
simonguo Mar 20, 2025
e8e10fd
fix(DatePicker): adjust label padding based on size (#4190)
simonguo Mar 20, 2025
d4d6ee5
refactor: update picker styles and tests (#4195)
simonguo Mar 26, 2025
c2e86d8
Merge branch 'main' into next
simonguo Mar 26, 2025
7abfff5
chore: merge main
simonguo Mar 26, 2025
22a99a7
feat: add support for Link component (#4208)
simonguo Mar 27, 2025
d5236df
fix(Slider): fix issue where arrow in Tooltip is not displayed (#4209)
simonguo Mar 27, 2025
ada2c7b
feat(Slider): add size and marks properties to Slider and RangeSlider…
simonguo Mar 29, 2025
4ae63e2
feat(Picker): add responsive control to Picker components (#4211)
simonguo Mar 29, 2025
cfb38b1
docs(picker): improve picker components documentation and mobile adap…
simonguo Apr 2, 2025
aaa5f95
chore: update browserslist
simonguo Apr 2, 2025
2ae1eb6
Merge branch 'main' into next
simonguo Apr 2, 2025
f448d0b
feat(Toggle): add `xl` and `xs` values to `size` prop (#4217)
simonguo Apr 3, 2025
31319cf
Merge branch 'main' into next
simonguo Apr 3, 2025
ceac7e4
feat(Row): `gutter` property supports array to set horizontal and ver…
simonguo Apr 3, 2025
4bf19bc
feat(Toggle): add support for `label` and `labelPlacement` properties…
simonguo Apr 3, 2025
031324a
Merge branch 'main' into next
simonguo Apr 3, 2025
87bdd88
fix(List): fix timeout issues in List component sorting tests
simonguo Apr 3, 2025
e485eb5
chore: update package dependencies including React, TypeScript and St…
simonguo Apr 3, 2025
c2b4402
docs(table): add filterable table component documentation (#4225)
simonguo Apr 9, 2025
e3bbcb4
fix(Image): fix lazy loading not working (#4224)
simonguo Apr 11, 2025
aaf4b05
docs(thumbnails): add component thumbnails for all components (#4227)
simonguo Apr 11, 2025
27d1a8e
feat(rate): add fractional rating support (#4231)
simonguo Apr 14, 2025
e2d982d
refactor(divider): rename labelPosition to labelPlacement for consist…
simonguo Apr 15, 2025
ee166db
docs(form): unify demo layout with Form.Stack (#4236)
simonguo Apr 15, 2025
b92dd2d
Merge branch 'main' into next
simonguo Apr 15, 2025
1e3e8e6
feat(password-input): add PasswordInput and PasswordStrengthMeter com…
simonguo Apr 15, 2025
3d62bb2
feat(Textarea): add Textarea component (#4235)
simonguo Apr 15, 2025
a77dd94
docs: update version badges and component meta for v6.0.0 (#4238)
simonguo Apr 16, 2025
c65cd89
feat(PasswordInput): add startIcon and endIcon props (#4239)
simonguo Apr 17, 2025
acc10a1
feat(PinInput): add support for PinInput component (#4242)
simonguo Apr 17, 2025
28fa8f9
chore: merge updates from main branch
simonguo Apr 18, 2025
7a1848a
refactor(NumberInput): rename InputNumber to NumberInput (#4243)
simonguo Apr 18, 2025
add801a
feat(Navbar.Toggle): add a new Burger component, applied to Navbar.To…
simonguo Apr 18, 2025
8616ac5
fix(vite): resolve circular dependency between chunks (#4249)
simonguo Apr 18, 2025
f4f0492
fix(Slider): fix handle style issue on mobile devices (#4244)
simonguo Apr 18, 2025
ff44b9f
docs: update examples of responsive components (#4251)
simonguo Apr 19, 2025
56a3a59
feat(input,picker): improve focus and hover effects (#4252)
simonguo Apr 24, 2025
85db80a
fix(message): update spacing to use css variables (#4258)
simonguo Apr 24, 2025
db74792
fix(CloseButton): standardize close button styles (#4260)
simonguo Apr 24, 2025
15dcdf3
docs(breadcrumb): add example descriptions and dropdown example (#4261)
simonguo Apr 28, 2025
71a3414
Merge branch 'main' into next
simonguo May 7, 2025
34b9c8d
Merge branch 'main' into next
simonguo May 8, 2025
3a66273
feat(Form): add useFormControl hook (#4268)
simonguo May 9, 2025
2dce8fb
Merge branch 'main' into next
simonguo May 9, 2025
7d4a8ef
feat(Form.Control): add static error placement option (#4269)
simonguo May 9, 2025
961ff5f
feat(Progress): add new properties to Progress and ProgressCircle com…
simonguo May 9, 2025
fecb72d
docs: move version column to the end of the table (#4275)
simonguo May 9, 2025
7945b17
Merge branch 'main' into next
simonguo May 17, 2025
86597bd
chore: migrate test framework from Karma/Mocha to Vitest (#4284)
simonguo May 17, 2025
8387065
docs(PasswordInput): fix incorrect order of examples (#4290)
simonguo May 21, 2025
fe4a27b
chore: replace sinon with vitest's vi (#4289)
simonguo May 23, 2025
d5d9915
chore: merge main
simonguo May 23, 2025
0aded45
docs(Stat): update ring progress documentation and related examples (…
simonguo May 24, 2025
853d81b
fix(useToaster): add warning when used outside of CustomProvider (#4296)
simonguo May 26, 2025
603601f
feat(useDialog): add support for useDialog (#4300)
simonguo May 26, 2025
f8ca46d
docs: add Modal Integrations documentation and update related example…
simonguo May 27, 2025
8227750
chore: update .gitignore file (#4303)
simonguo May 28, 2025
4a36956
docs(overview): add optional chaining to prevent potential runtime er…
simonguo May 29, 2025
767d5e6
refactor: convert less variables to css variables (#4311)
simonguo Jun 6, 2025
da28ae0
chore: merge main
simonguo Jun 19, 2025
d80228f
chore(docs): update rsuite dependency to 6.0.0-canary-20250416
simonguo Jun 19, 2025
d46ecf0
fix(locales): update date-fns imports and add Dialog translations (#4…
simonguo Jun 19, 2025
196f73a
refactor(styles): convert Less to SCSS (#4312)
simonguo Jun 19, 2025
592bd28
refactor: remove unused color palette generation code (#4322)
simonguo Jun 20, 2025
c6972ca
feat(SegmentedControl): add new SegmentedControl component (#4321)
simonguo Jun 20, 2025
fdacb22
docs: update component documentation and examples (#4323)
simonguo Jun 21, 2025
7bd4080
docs: enhance Carbon Ads with loading states and dark mode (#4326)
simonguo Jun 21, 2025
6ef0839
docs: disable auto-focus and autocomplete on email input (#4327)
simonguo Jun 21, 2025
e58b86b
docs(stack): update stack component documentation (#4328)
simonguo Jun 22, 2025
c086f37
refactor(Box,Stack): replace inline styles with CSS-in-JS solution (#…
simonguo Jun 22, 2025
efdc6cb
feat(Box): implement responsive shorthand CSS properties (#4329)
simonguo Jun 26, 2025
9be2637
chore: merge main
simonguo Jun 27, 2025
7c368f5
style: update SCSS files and documentation
simonguo Jun 30, 2025
e96b5fe
docs: update CSS variables documentation (#4331)
simonguo Jun 30, 2025
99c3f46
refactor(IconButton): use data-shape for circle styling instead of cl…
simonguo Jun 30, 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
fix(pickers): improve pickers renderValue property type definition (#…
  • Loading branch information
simonguo authored Feb 8, 2025
commit 37cc54ce6472d76b70f775a2e96baad5cb17aa49
17 changes: 17 additions & 0 deletions 17 src/Cascader/test/Cascader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,20 @@ const stringValuedData = [{ label: 'One', value: 'One' }];
const ref = React.useRef<PickerHandle>(null);
<Cascader data={[]} ref={ref} />;
ref.current?.open?.();
const pickerRef = React.createRef<PickerHandle>();

<Cascader ref={pickerRef} data={[]} />;

interface Item<T> {
label?: React.ReactNode;
value?: T;
}

// Check renderValue
<Cascader
data={[]}
renderValue={(value: string, selectedPaths: Item<string>[]) => {
console.log(value, selectedPaths);
return selectedPaths.map(item => item.label).join(' / ');
}}
/>;
20 changes: 16 additions & 4 deletions 20 src/CheckPicker/CheckPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,25 @@ import {
} from '@/internals/Picker';
import type { PickerLocale } from '../locales';
import type { ItemDataType, FormControlPickerProps } from '@/internals/types';
import type { MultipleSelectProps } from '../SelectPicker';
import type { SelectProps } from '../SelectPicker';

export type ValueType = (number | string)[];
export interface CheckPickerProps<T = any>
extends FormControlPickerProps<T[], PickerLocale, ItemDataType<T>>,
MultipleSelectProps<T>,
Omit<SelectProps<T>, 'renderValue'>,
Pick<PickerToggleProps, 'label' | 'caretAs' | 'loading'> {
/** Top the selected option in the options */
sticky?: boolean;

/** A picker that can be counted */
countable?: boolean;

/** Custom render selected items */
renderValue?: (
value: T[],
item: ItemDataType<T>[],
selectedElement: React.ReactNode
) => React.ReactNode;
}

const emptyArray = [];
Expand Down Expand Up @@ -210,13 +217,18 @@ const CheckPicker = forwardRef<'div', CheckPickerProps>(
});

const handleSelect = useEventCallback(
(nextItemValue: any, item: ItemDataType, event: React.SyntheticEvent) => {
(nextItemValue: any, item: ItemDataType<T>, event: React.SyntheticEvent) => {
onSelect?.(nextItemValue, item, event);
}
);

const handleItemSelect = useEventCallback(
(nextItemValue: any, item: ItemDataType, event: React.SyntheticEvent, checked: boolean) => {
(
nextItemValue: any,
item: ItemDataType<T>,
event: React.SyntheticEvent,
checked: boolean
) => {
const nextValue = clone(value);

if (checked) {
Expand Down
13 changes: 13 additions & 0 deletions 13 src/CheckPicker/test/CheckPicker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ const stringValuedData = [{ label: 'One', value: 'One' }];
const ref = React.useRef<PickerHandle>(null);
<CheckPicker data={[]} ref={ref} />;
ref.current?.open?.();

interface Item<T> {
label?: React.ReactNode;
value?: T;
}
// Check renderValue
<CheckPicker
data={[]}
renderValue={(value: string[], items: Item<string>[]) => {
console.log(value, items);
return value.map(v => items.find(item => item.value === v)?.label).join(', ');
}}
/>;
8 changes: 7 additions & 1 deletion 8 src/InputPicker/InputPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import type { SelectProps } from '../SelectPicker';
export type ValueType = any;
export interface InputPickerProps<V = ValueType>
extends FormControlPickerProps<V, InputPickerLocale, InputItemDataType>,
SelectProps<V>,
Omit<SelectProps<V>, 'renderValue'>,
Pick<PickerToggleProps, 'caretAs' | 'loading'> {
tabIndex?: number;

Expand Down Expand Up @@ -82,6 +82,12 @@ export interface InputPickerProps<V = ValueType>
searchKeyword: string,
filteredData: InputItemDataType<V>[]
) => boolean;

renderValue?: (
value: V,
item: ItemDataType<V>,
selectedElement: React.ReactNode
) => React.ReactNode;
}

/**
Expand Down
13 changes: 13 additions & 0 deletions 13 src/InputPicker/test/InputPicker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,16 @@ import type { PickerHandle } from '@/internals/Picker';
const ref = React.useRef<PickerHandle>(null);
<InputPicker data={[]} ref={ref} />;
ref.current?.open?.();
interface Item<T> {
label?: React.ReactNode;
value?: T;
}

// Check renderValue
<InputPicker
data={[]}
renderValue={(value: string, item: Item<string>) => {
console.log(value, item);
return item.label;
}}
/>;
6 changes: 3 additions & 3 deletions 6 src/MultiCascader/MultiCascader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import type { FormControlPickerProps, ItemDataType, DataItemValue } from '@/inte
import type { PickerLocale } from '../locales';
import type { MultiCascadeTreeProps } from '../MultiCascadeTree';

export interface MultiCascaderProps<T extends DataItemValue = any>
export interface MultiCascaderProps<T = any>
extends FormControlPickerProps<T[], PickerLocale, ItemDataType<T>, T>,
MultiCascadeTreeProps<T, T[], PickerLocale>,
Pick<PickerToggleProps, 'loading'> {
Pick<PickerToggleProps, 'label' | 'caretAs' | 'loading'> {
/**
* A picker that can be counted
*/
Expand Down Expand Up @@ -119,7 +119,7 @@ const emptyArray = [];
* The `MultiCascader` component is used to select multiple values from cascading options.
* @see https://rsuitejs.com/components/multi-cascader/
*/
const MultiCascader = forwardRef<'div', MultiCascaderProps<DataItemValue>>(
const MultiCascader = forwardRef<'div', MultiCascaderProps>(
<T extends DataItemValue>(props: MultiCascaderProps<T>, ref) => {
const { propsWithDefaults, rtl } = useCustom('MultiCascader', props);
const {
Expand Down
14 changes: 14 additions & 0 deletions 14 src/MultiCascader/test/MultiCascader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,17 @@ import type { PickerHandle } from '@/internals/Picker';
const ref = React.useRef<PickerHandle>(null);
<MultiCascader data={[]} ref={ref} />;
ref.current?.open?.();

interface Item<T> {
label?: React.ReactNode;
value?: T;
}

// Check renderValue
<MultiCascader
data={[]}
renderValue={(value: string[], selectedPaths: Item<string>[]) => {
console.log(value, selectedPaths);
return selectedPaths.map(item => item.label).join(' / ');
}}
/>;
17 changes: 4 additions & 13 deletions 17 src/SelectPicker/SelectPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ export interface SelectProps<T> {
/** Custom render selected items */
renderValue?: (
value: T,
item: ItemDataType | ItemDataType[],
item: ItemDataType<T>,
selectedElement: React.ReactNode
) => React.ReactNode;

/** Called when the option is selected */
onSelect?: (value: any, item: ItemDataType, event: React.SyntheticEvent) => void;
onSelect?: (value: any, item: ItemDataType<T>, event: React.SyntheticEvent) => void;

/** Called after clicking the group title */
onGroupTitleClick?: (event: React.SyntheticEvent) => void;
Expand All @@ -83,15 +83,6 @@ export interface SelectProps<T> {
onClean?: (event: React.SyntheticEvent) => void;
}

export interface MultipleSelectProps<T> extends Omit<SelectProps<T>, 'renderValue'> {
/** Custom render selected items */
renderValue?: (
value: T[],
item: ItemDataType<T>[],
selectedElement: React.ReactNode
) => React.ReactNode;
}

export interface SelectPickerProps<T = any>
extends Omit<
FormControlPickerProps<T, PickerLocale, ItemDataType<T>>,
Expand Down Expand Up @@ -207,7 +198,7 @@ const SelectPicker = forwardRef<'div', SelectPickerProps>(
});

const handleSelect = useEventCallback(
(value: any, item: ItemDataType, event: React.SyntheticEvent) => {
(value: any, item: ItemDataType<T>, event: React.SyntheticEvent) => {
onSelect?.(value, item, event);
target.current?.focus();
}
Expand Down Expand Up @@ -296,7 +287,7 @@ const SelectPicker = forwardRef<'div', SelectPickerProps>(
}

if (!isNil(value) && isFunction(renderValue)) {
selectedElement = renderValue(value, activeItem as ItemDataType, selectedElement);
selectedElement = renderValue(value, activeItem as ItemDataType<T>, selectedElement);
// If renderValue returns null or undefined, hasValue is false.
if (isNil(selectedElement)) {
hasValue = false;
Expand Down
2 changes: 1 addition & 1 deletion 2 src/SelectPicker/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SelectPicker from './SelectPicker';

// export types
export type { SelectProps, MultipleSelectProps, SelectPickerProps } from './SelectPicker';
export type { SelectProps, SelectPickerProps } from './SelectPicker';

// export components
export { SelectPicker };
Expand Down
13 changes: 13 additions & 0 deletions 13 src/SelectPicker/test/SelectPicker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,16 @@ type SortDirection = 'asc' | 'desc';
const ref = React.useRef<PickerHandle>(null);
<SelectPicker data={[]} ref={ref} />;
ref.current?.open?.();
interface Item<T> {
label?: React.ReactNode;
value?: T;
}

// Check renderValue
<SelectPicker
data={[]}
renderValue={(value: string, item: Item<string>) => {
console.log(value, item);
return item.label;
}}
/>;
19 changes: 17 additions & 2 deletions 19 src/TagPicker/TagPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@ import InputPicker, { InputPickerProps } from '../InputPicker/InputPicker';
import { TagProvider, TagOnlyProps } from '../InputPicker/InputPickerContext';
import { useCustom } from '../CustomProvider';
import { forwardRef } from '@/internals/utils';
import type { ItemDataType } from '@/internals/types';
import type { CheckboxProps } from '../Checkbox';

export interface TagPickerProps extends InputPickerProps, Partial<TagOnlyProps> {
export interface TagPickerProps<V = any>
extends Omit<InputPickerProps<V>, 'renderValue'>,
Partial<TagOnlyProps> {
/**
* Custom render checkbox on menu item
* @version 5.47.0
**/
renderMenuItemCheckbox?: (checkboxProps: CheckboxProps) => React.ReactNode;

/** Custom render selected items */
renderValue?: (
values: V[],
items: ItemDataType<V>[],
selectedElement: React.ReactNode
) => React.ReactNode;
}

/**
Expand All @@ -25,6 +35,7 @@ const TagPicker = forwardRef<'div', TagPickerProps>((props, ref) => {
trigger = 'Enter',
onTagRemove,
renderMenuItemCheckbox,
renderValue,
...rest
} = propsWithDefaults;

Expand All @@ -41,7 +52,11 @@ const TagPicker = forwardRef<'div', TagPickerProps>((props, ref) => {

return (
<TagProvider value={contextValue}>
<InputPicker {...rest} ref={ref} />
<InputPicker
renderValue={renderValue as InputPickerProps['renderValue']}
{...rest}
ref={ref}
/>
</TagProvider>
);
});
Expand Down
13 changes: 13 additions & 0 deletions 13 src/TagPicker/test/TagPicker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,16 @@ import type { PickerHandle } from '@/internals/Picker';
const ref = React.useRef<PickerHandle>(null);
<TagPicker data={[]} ref={ref} />;
ref.current?.open?.();

interface Item<T> {
label?: React.ReactNode;
value?: T;
}

<TagPicker
data={[]}
renderValue={(value: string[], items: Item<string>[]) => {
console.log(value, items);
return value.map(v => items.find(item => item.value === v)?.label).join(', ');
}}
/>;
Morty Proxy This is a proxified and sanitized view of the page, visit original site.