File tree Expand file tree Collapse file tree
apps/storybook/src/stories/molecules
packages/react/src/molecules/pickers/select Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import React from 'react' ;
2- import { ComponentStory , ComponentMeta } from '@storybook/react' ;
31import { PickerSelectSimple } from '@reusejs/react' ;
4- // import { CheckIcon, XIcon } from '@heroicons /react/solid ';
5- // import { TextInputBase } from '@reusejs/ react';
2+ import { ComponentMeta , ComponentStory } from '@storybook /react' ;
3+ import React from 'react' ;
64
75const fetchContinents = ( q = '' ) => {
8- let continents = [
6+ const continents = [
97 'Africa' ,
108 'Antarctica' ,
119 'Asia' ,
Original file line number Diff line number Diff line change 1+ import { LabelBase , PickerSelectSimple } from '@reusejs/react' ;
2+ import { ComponentMeta , ComponentStory } from '@storybook/react' ;
13import React , { useState } from 'react' ;
2- import { ComponentStory , ComponentMeta } from '@storybook/react' ;
3- import { PickerSelectSimple , LabelBase } from '@reusejs/react' ;
4- // import { CheckIcon, XIcon } from '@heroicons/react/solid';
5- // import { TextInputBase } from '@reusejs/react';
64
75const fetchContinents = ( q = '' ) => {
8- let continents = [
6+ const continents = [
97 'Africa' ,
108 'Antarctica' ,
119 'Asia' ,
@@ -127,6 +125,23 @@ DisableSearch.args = {
127125 } ,
128126} ;
129127
128+ export const ToggledDisableSearch = Template . bind ( { } ) ;
129+ ToggledDisableSearch . args = {
130+ labelBaseProps : {
131+ label : 'Country' ,
132+ labelBaseClasses : {
133+ color : 'text-yellow-800 dark:text-yellow-100' ,
134+ } ,
135+ } ,
136+ valueKey : 'value' ,
137+ multiple : false ,
138+ enableSearch : false ,
139+ dataSource : ( q : any ) => {
140+ return fetchContinents ( q ) ;
141+ } ,
142+ enableToggle : true ,
143+ } ;
144+
130145export const Selected = Template . bind ( { } ) ;
131146Selected . args = {
132147 labelBaseProps : {
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ export interface PickerSelectBaseProps {
4949 clearComponent ?: any ;
5050 noDataComponent ?: any ;
5151 customRightComponent ?: React . FC ;
52+ enableToggle ?: boolean ;
5253}
5354
5455const PickerSelectBase = React . forwardRef (
@@ -153,7 +154,13 @@ const PickerSelectBase = React.forwardRef(
153154 ) }
154155
155156 { open === true && (
156- < div className = "relative" ref = { visRef } >
157+ < div
158+ className = "relative"
159+ ref = { visRef }
160+ onClick = { ( ) => {
161+ props . enableToggle && setOpen ( false ) ;
162+ } }
163+ >
157164 { props . searchRenderer && (
158165 < props . searchRenderer
159166 variant = { props . variant }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export interface PickerSelectSimpleProps extends PickerSelectBaseProps {
1010 enableClear : boolean ;
1111 enableClose : boolean ;
1212 enableSearch : boolean ;
13+ enableToggle ?: boolean ;
1314}
1415
1516const PickerSelectSimple = ( props : PickerSelectSimpleProps ) => {
@@ -47,6 +48,7 @@ const PickerSelectSimple = (props: PickerSelectSimpleProps) => {
4748 refresh = { props . refresh }
4849 error = { props . error }
4950 customRightComponent = { props . customRightComponent }
51+ enableToggle = { props . enableToggle }
5052 />
5153 ) ;
5254} ;
@@ -319,4 +321,8 @@ const OptionsRenderer = ({
319321 ) ;
320322} ;
321323
324+ PickerSelectSimple . defaultProps = {
325+ enableToggle : false ,
326+ } ;
327+
322328export default PickerSelectSimple ;
You can’t perform that action at this time.
0 commit comments