Skip to content

Commit

Permalink
* picker: support for getting picker instance from picker menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Aug 23, 2024
1 parent 4869b8a commit 7eca974
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/picker/src/component/picker-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export class PickerMenu extends PickPop<PickerState, PickerMenuProps> {
return this._menu.current;
}

get picker() {
return this.props.picker;
}

componentDidMount(): void {
super.componentDidMount();
if (this._firstSelected === undefined) {
Expand Down
1 change: 1 addition & 0 deletions lib/picker/src/component/picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ export class Picker<S extends PickerState = PickerState, O extends PickerOptions
protected _getPopProps(props: RenderableProps<O>, state: Readonly<S>): PickerMenuProps<S> {
return {
...super._getPopProps(props, state),
picker: this as unknown as Picker,
menu: props.menu,
tree: props.tree,
checkbox: props.checkbox,
Expand Down
2 changes: 2 additions & 0 deletions lib/picker/src/types/picker-menu-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {TreeOptions} from '@zui/tree';
import type {PickPopProps} from '@zui/pick';
import type {CustomContentType} from '@zui/core';
import type {PickerState} from './picker-state';
import type {Picker} from '../component/picker';

export interface PickerMenuProps<S extends PickerState = PickerState> extends PickPopProps<S> {
multiple?: boolean | number;
Expand All @@ -15,6 +16,7 @@ export interface PickerMenuProps<S extends PickerState = PickerState> extends Pi
footer?: CustomContentType;
noMatchHint?: string;
maxItemsCount?: number;
picker?: Picker;

onSelect: (values: string | string[]) => void;
onDeselect: (values: string | string[]) => void;
Expand Down

0 comments on commit 7eca974

Please sign in to comment.