@@ -3,6 +3,8 @@ import { Select } from '../../src';
33import { optionsBase } from '../../docs/src/options' ;
44
55const options = optionsBase ( 4 ) ;
6+ const largeOptions = optionsBase ( 20000 ) ;
7+
68const baseArgs = {
79 ...Select . defaultProps ,
810 options,
@@ -22,5 +24,231 @@ export default {
2224 }
2325} ;
2426
27+ // Basic single select
2528export const Basic = { args : baseArgs } ;
29+
30+ // Multi select
2631export const Multi = { args : { ...baseArgs , multi : true } } ;
32+
33+ // Form with validation
34+ export const FormValidation = {
35+ args : {
36+ ...baseArgs ,
37+ required : true ,
38+ name : 'select-field' ,
39+ pattern : '.+'
40+ }
41+ } ;
42+
43+ // Windowed (Large Dataset)
44+ export const WindowedLargeDataset = {
45+ args : {
46+ ...baseArgs ,
47+ options : largeOptions ,
48+ dropdownRenderer : ( { props, state, methods } ) => (
49+ < div style = { { maxHeight : '300px' , overflow : 'auto' } } >
50+ { state . searchResults . map ( ( item , index ) => (
51+ < div
52+ key = { index }
53+ onClick = { ( ) => methods . addItem ( item ) }
54+ style = { { padding : '10px' , cursor : 'pointer' } } >
55+ { item . label }
56+ </ div >
57+ ) ) }
58+ </ div >
59+ )
60+ }
61+ } ;
62+
63+ // Select All functionality
64+ export const SelectAllExample = {
65+ args : {
66+ ...baseArgs ,
67+ multi : true ,
68+ selectAll : true ,
69+ selectAllLabel : 'Select all' ,
70+ clearAllLabel : 'Clear all'
71+ }
72+ } ;
73+
74+ // Custom Item Renderer
75+ export const CustomItemRenderer = {
76+ args : {
77+ ...baseArgs ,
78+ itemRenderer : ( { item, itemIndex, props, state, methods } ) => (
79+ < div
80+ key = { itemIndex }
81+ onClick = { ( ) => methods . addItem ( item ) }
82+ style = { {
83+ padding : '10px' ,
84+ cursor : 'pointer' ,
85+ backgroundColor : methods . isSelected ( item ) ? '#f2f2f2' : 'white'
86+ } } >
87+ < div style = { { fontWeight : 'bold' } } > { item . label } </ div >
88+ < div style = { { fontSize : '12px' , color : '#666' } } > { item . value } </ div >
89+ </ div >
90+ )
91+ }
92+ } ;
93+
94+ // Custom Content and Dropdown
95+ export const CustomContentAndDropdown = {
96+ args : {
97+ ...baseArgs ,
98+ contentRenderer : ( { props, state, methods } ) => (
99+ < div style = { { padding : '10px' } } >
100+ { state . values . length ? state . values . map ( ( item ) => item . label ) . join ( ', ' ) : 'Select...' }
101+ </ div >
102+ ) ,
103+ dropdownRenderer : ( { props, state, methods } ) => (
104+ < div style = { { padding : '10px' , border : '1px solid #ccc' } } >
105+ { state . searchResults . map ( ( item , index ) => (
106+ < div
107+ key = { index }
108+ onClick = { ( ) => methods . addItem ( item ) }
109+ style = { { padding : '5px' , cursor : 'pointer' } } >
110+ { item . label }
111+ </ div >
112+ ) ) }
113+ </ div >
114+ )
115+ }
116+ } ;
117+
118+ // Custom Dropdown Handle
119+ export const CustomDropdownHandle = {
120+ args : {
121+ ...baseArgs ,
122+ dropdownHandleRenderer : ( { state } ) => (
123+ < span style = { { padding : '5px' } } > { state . dropdown ? '▲' : '▼' } </ span >
124+ )
125+ }
126+ } ;
127+
128+ // With Animation
129+ export const WithAnimation = {
130+ args : {
131+ ...baseArgs ,
132+ style : {
133+ transition : 'all 0.2s ease'
134+ } ,
135+ contentRenderer : ( { props, state, methods } ) => (
136+ < div
137+ style = { {
138+ transition : 'all 0.2s ease' ,
139+ transform : state . dropdown ? 'scale(1.05)' : 'scale(1)'
140+ } } >
141+ { state . values . length ? state . values . map ( ( item ) => item . label ) . join ( ', ' ) : 'Select...' }
142+ </ div >
143+ )
144+ }
145+ } ;
146+
147+ // Custom Search Function
148+ export const CustomSearch = {
149+ args : {
150+ ...baseArgs ,
151+ searchFn : ( { state, props } ) => {
152+ const regexp = new RegExp ( state . search , 'i' ) ;
153+ return props . options . filter ( ( item ) => regexp . test ( item . label ) || regexp . test ( item . value ) ) ;
154+ }
155+ }
156+ } ;
157+
158+ // No Data Example
159+ export const NoDataExample = {
160+ args : {
161+ ...baseArgs ,
162+ options : [ ] ,
163+ noDataLabel : 'No options available' ,
164+ noDataRenderer : ( { props, state, methods } ) => (
165+ < div style = { { padding : '10px' , color : '#666' } } > { props . noDataLabel } </ div >
166+ )
167+ }
168+ } ;
169+
170+ // Searchable select
171+ export const Searchable = {
172+ args : {
173+ ...baseArgs ,
174+ searchable : true ,
175+ placeholder : 'Search and select...'
176+ }
177+ } ;
178+
179+ // Disabled select
180+ export const Disabled = {
181+ args : {
182+ ...baseArgs ,
183+ disabled : true ,
184+ values : [ options [ 0 ] ]
185+ }
186+ } ;
187+
188+ // Select with custom colors
189+ export const CustomColor = {
190+ args : {
191+ ...baseArgs ,
192+ color : '#ff0000'
193+ }
194+ } ;
195+
196+ // Select with create option
197+ export const CreateOption = {
198+ args : {
199+ ...baseArgs ,
200+ create : true ,
201+ createNewLabel : 'Create: {search}'
202+ }
203+ } ;
204+
205+ // Select with loading state
206+ export const Loading = {
207+ args : {
208+ ...baseArgs ,
209+ loading : true
210+ }
211+ } ;
212+
213+ // Select with clear option
214+ export const Clearable = {
215+ args : {
216+ ...baseArgs ,
217+ clearable : true ,
218+ values : [ options [ 0 ] ]
219+ }
220+ } ;
221+
222+ // Select with custom dropdown position
223+ export const DropdownPosition = {
224+ args : {
225+ ...baseArgs ,
226+ dropdownPosition : 'top'
227+ }
228+ } ;
229+
230+ // Select with RTL support
231+ export const RTLSupport = {
232+ args : {
233+ ...baseArgs ,
234+ direction : 'rtl'
235+ }
236+ } ;
237+
238+ // Select with all features
239+ export const AllFeatures = {
240+ args : {
241+ ...baseArgs ,
242+ multi : true ,
243+ searchable : true ,
244+ clearable : true ,
245+ create : true ,
246+ selectAll : true ,
247+ dropdownHandle : true ,
248+ separator : true ,
249+ keepSelectedInList : true ,
250+ closeOnSelect : false ,
251+ dropdownPosition : 'auto' ,
252+ values : [ options [ 0 ] ]
253+ }
254+ } ;
0 commit comments