Skip to content

Commit

Permalink
Update types
Browse files Browse the repository at this point in the history
  • Loading branch information
brookewp committed Nov 7, 2023
1 parent 7476022 commit 72c6e34
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/components/src/custom-select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import * as Ariakit from '@ariakit/react';
// import { type CustomSelectProps } from './types';
import { CustomSelectButton, CustomSelectPopover } from './styles';
import CustomSelectItem from './custom-select-item';
import type { CustomSelectProps } from './types';

function CustomSelect( props: any ) {
const { children, defaultValue, label, onChange, value } = props;
function CustomSelect( props: CustomSelectProps ) {
const { children, defaultValue, label, onChange } = props;

const store = Ariakit.useSelectStore( {
setValue: ( nextValue ) => onChange?.( nextValue ),
value,
defaultValue,
} );

Expand Down
23 changes: 22 additions & 1 deletion packages/components/src/custom-select/types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
// TO DO
export type CustomSelectProps = {
/**
* The children elements. This should be composed
* of CustomSelect.Item components.
*/
children: React.ReactNode;
/**
* An optional default value for the control.
* If left undefined, the first non-disabled
* item will be used
*/
defaultValue?: any;
/**
* Label for the control.
*/
label?: string;
/**
* A function that receives the new value of the input.
*/
onChange?: Function;
value?: string;
};

export type CustomSelectItemProps = {
/**
* The children elements to be displayed for the select options.
*/
children: React.ReactNode;
/**
* The current value of the select. Can be used in lieu of
* children if only a string is needed.
*/
value?: any;
};

0 comments on commit 72c6e34

Please sign in to comment.