@@ -23,7 +23,11 @@ export default function Playground() {
23
23
const [ containerClassName , setContainerClassName ] = useState ( "" ) ;
24
24
const [ displayFormat , setDisplayFormat ] = useState ( "YYYY-MM-DD" ) ;
25
25
const [ readOnly , setReadOnly ] = useState ( false ) ;
26
- const [ startFrom , setStartFrom ] = useState ( "2023-03-01" ) ;
26
+ const [ startFrom , setStartFrom ] = useState ( "2023-01-02" ) ;
27
+ const [ minDate , setMinDate ] = useState ( "" ) ;
28
+ const [ maxDate , setMaxDate ] = useState ( "" ) ;
29
+ const [ disabledDates , setDisabledDates ] = useState ( [ ] ) ;
30
+ const [ newDisabledDates , setNewDisabledDates ] = useState ( { startDate : "" , endDate : "" } ) ;
27
31
28
32
return (
29
33
< div className = "px-4 py-8" >
@@ -58,6 +62,9 @@ export default function Playground() {
58
62
containerClassName = { containerClassName }
59
63
displayFormat = { displayFormat }
60
64
readOnly = { readOnly }
65
+ minDate = { minDate }
66
+ maxDate = { maxDate }
67
+ disabledDates = { disabledDates }
61
68
/>
62
69
</ div >
63
70
@@ -207,6 +214,19 @@ export default function Playground() {
207
214
} }
208
215
/>
209
216
</ div >
217
+ < div className = "mb-2" >
218
+ < label className = "block" htmlFor = "minDate" >
219
+ Minimum Date
220
+ </ label >
221
+ < input
222
+ className = "rounded border px-4 py-2 w-full border-gray-200"
223
+ id = "minDate"
224
+ value = { minDate }
225
+ onChange = { e => {
226
+ setMinDate ( e . target . value ) ;
227
+ } }
228
+ />
229
+ </ div >
210
230
</ div >
211
231
< div className = "w-full sm:w-1/3 pr-2 flex flex-col" >
212
232
< div className = "mb-2" >
@@ -261,6 +281,97 @@ export default function Playground() {
261
281
} }
262
282
/>
263
283
</ div >
284
+ < div className = "mb-2" >
285
+ < label className = "block" htmlFor = "maxDate" >
286
+ Maximum Date
287
+ </ label >
288
+ < input
289
+ className = "rounded border px-4 py-2 w-full border-gray-200"
290
+ id = "maxDate"
291
+ value = { maxDate }
292
+ onChange = { e => {
293
+ setMaxDate ( e . target . value ) ;
294
+ } }
295
+ />
296
+ </ div >
297
+ </ div >
298
+ < div className = "w-full grid sm:grid-cols-3" >
299
+ < div className = "sm:col-start-2 sm:col-span-2 p-2 border-t grid grid-cols-2" >
300
+ < h1 className = "mb-2 text-lg font-semibold text-center col-span-3" >
301
+ Disable Dates
302
+ </ h1 >
303
+ < div className = "mb-2 sm:col-span-2 mr-2" >
304
+ < label className = "block" htmlFor = "startDate" >
305
+ Start Date
306
+ </ label >
307
+ < input
308
+ className = "rounded border px-4 py-2 border-gray-200 sm:w-full w-3/4"
309
+ id = "startDate"
310
+ value = { newDisabledDates . startDate }
311
+ onChange = { e => {
312
+ setNewDisabledDates ( prev => {
313
+ return {
314
+ ...prev ,
315
+ startDate : e . target . value
316
+ } ;
317
+ } ) ;
318
+ } }
319
+ />
320
+ </ div >
321
+ < div className = "mb-2" >
322
+ < label className = "block" htmlFor = "endDate" >
323
+ End Date
324
+ </ label >
325
+ < input
326
+ className = "rounded border px-4 py-2 border-gray-200 sm:w-full w-3/4"
327
+ id = "endDate"
328
+ value = { newDisabledDates . endDate }
329
+ onChange = { e => {
330
+ setNewDisabledDates ( prev => {
331
+ return {
332
+ ...prev ,
333
+ endDate : e . target . value
334
+ } ;
335
+ } ) ;
336
+ } }
337
+ />
338
+ </ div >
339
+ < div className = "mb-2 col-span-3" >
340
+ < button
341
+ onClick = { ( ) => {
342
+ if (
343
+ newDisabledDates . startDate !== "" &&
344
+ newDisabledDates . endDate !== ""
345
+ ) {
346
+ setDisabledDates ( prev => [ ...prev , newDisabledDates ] ) ;
347
+ setNewDisabledDates ( { startDate : "" , endDate : "" } ) ;
348
+ }
349
+ } }
350
+ className = "w-full bg-black text-white text-lg text-center p-2 rounded-lg"
351
+ >
352
+ Add
353
+ </ button >
354
+ </ div >
355
+ < div className = "mb-2 grid col-span-3 grid-col-2" >
356
+ { disabledDates . map ( ( range , index ) => (
357
+ < div className = "mb-2 p-2" key = { index } >
358
+ < button
359
+ className = "bg-red-500 text-white text-center rounded-xl p-2"
360
+ onClick = { ( ) => {
361
+ setDisabledDates (
362
+ disabledDates . filter ( r => r !== range )
363
+ ) ;
364
+ } }
365
+ >
366
+ Delete
367
+ </ button >
368
+ < span className = "pl-2" >
369
+ { range . startDate } - { range . endDate }
370
+ </ span >
371
+ </ div >
372
+ ) ) }
373
+ </ div >
374
+ </ div >
264
375
</ div >
265
376
</ div >
266
377
< div className = "flex flex-row flex-wrap items-center justify-center w-full" >
0 commit comments